Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nrf_wifi: Fix TX de-init crash #1277

Merged
merged 5 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 20 additions & 28 deletions nrf_wifi/bus_if/bus/qspi/src/qspi.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ static int nrf_wifi_bus_qspi_irq_handler(void *data)
static void *nrf_wifi_bus_qspi_dev_add(void *bus_priv,
void *bal_dev_ctx)
{
enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL;
struct nrf_wifi_bus_qspi_priv *qspi_priv = NULL;
struct nrf_wifi_bus_qspi_dev_ctx *qspi_dev_ctx = NULL;
struct nrf_wifi_osal_host_map host_map;
Expand Down Expand Up @@ -76,30 +75,6 @@ static void *nrf_wifi_bus_qspi_dev_add(void *bus_priv,
qspi_dev_ctx->addr_pktram_base = qspi_dev_ctx->host_addr_base +
qspi_priv->cfg_params.addr_pktram_base;

status = nrf_wifi_osal_bus_qspi_dev_intr_reg(qspi_dev_ctx->qspi_priv->opriv,
qspi_dev_ctx->os_qspi_dev_ctx,
qspi_dev_ctx,
&nrf_wifi_bus_qspi_irq_handler);

if (status != NRF_WIFI_STATUS_SUCCESS) {
nrf_wifi_osal_log_err(qspi_dev_ctx->qspi_priv->opriv,
"%s: Unable to register interrupt to the OS",
__func__);

nrf_wifi_osal_bus_qspi_dev_intr_unreg(qspi_dev_ctx->qspi_priv->opriv,
qspi_dev_ctx->os_qspi_dev_ctx);

nrf_wifi_osal_bus_qspi_dev_rem(qspi_dev_ctx->qspi_priv->opriv,
qspi_dev_ctx->os_qspi_dev_ctx);

nrf_wifi_osal_mem_free(qspi_priv->opriv,
qspi_dev_ctx);

qspi_dev_ctx = NULL;

goto out;
}

out:
return qspi_dev_ctx;
}
Expand All @@ -111,9 +86,6 @@ static void nrf_wifi_bus_qspi_dev_rem(void *bus_dev_ctx)

qspi_dev_ctx = bus_dev_ctx;

nrf_wifi_osal_bus_qspi_dev_intr_unreg(qspi_dev_ctx->qspi_priv->opriv,
qspi_dev_ctx->os_qspi_dev_ctx);

nrf_wifi_osal_bus_qspi_dev_rem(qspi_dev_ctx->qspi_priv->opriv,
qspi_dev_ctx->os_qspi_dev_ctx);

Expand All @@ -129,13 +101,30 @@ static enum nrf_wifi_status nrf_wifi_bus_qspi_dev_init(void *bus_dev_ctx)

qspi_dev_ctx = bus_dev_ctx;


status = nrf_wifi_osal_bus_qspi_dev_intr_reg(qspi_dev_ctx->qspi_priv->opriv,
qspi_dev_ctx->os_qspi_dev_ctx,
qspi_dev_ctx,
&nrf_wifi_bus_qspi_irq_handler);

if (status != NRF_WIFI_STATUS_SUCCESS) {
nrf_wifi_osal_log_err(qspi_dev_ctx->qspi_priv->opriv,
"%s: Unable to register interrupt to the OS",
__func__);
qspi_dev_ctx = NULL;

goto out;
}

status = nrf_wifi_osal_bus_qspi_dev_init(qspi_dev_ctx->qspi_priv->opriv,
qspi_dev_ctx->os_qspi_dev_ctx);

if (status != NRF_WIFI_STATUS_SUCCESS) {
nrf_wifi_osal_log_err(qspi_dev_ctx->qspi_priv->opriv,
"%s: nrf_wifi_osal_qspi_dev_init failed", __func__);

nrf_wifi_osal_bus_qspi_dev_intr_unreg(qspi_dev_ctx->qspi_priv->opriv,
qspi_dev_ctx->os_qspi_dev_ctx);
goto out;
}
out:
Expand All @@ -149,6 +138,9 @@ static void nrf_wifi_bus_qspi_dev_deinit(void *bus_dev_ctx)

qspi_dev_ctx = bus_dev_ctx;

nrf_wifi_osal_bus_qspi_dev_intr_unreg(qspi_dev_ctx->qspi_priv->opriv,
qspi_dev_ctx->os_qspi_dev_ctx);

nrf_wifi_osal_bus_qspi_dev_deinit(qspi_dev_ctx->qspi_priv->opriv,
qspi_dev_ctx->os_qspi_dev_ctx);
}
Expand Down
45 changes: 18 additions & 27 deletions nrf_wifi/bus_if/bus/spi/src/spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,30 +76,6 @@ static void *nrf_wifi_bus_spi_dev_add(void *bus_priv,
spi_dev_ctx->addr_pktram_base = spi_dev_ctx->host_addr_base +
spi_priv->cfg_params.addr_pktram_base;

status = nrf_wifi_osal_bus_spi_dev_intr_reg(spi_dev_ctx->spi_priv->opriv,
spi_dev_ctx->os_spi_dev_ctx,
spi_dev_ctx,
&nrf_wifi_bus_spi_irq_handler);

if (status != NRF_WIFI_STATUS_SUCCESS) {
nrf_wifi_osal_log_err(spi_dev_ctx->spi_priv->opriv,
"%s: Unable to register interrupt to the OS",
__func__);

nrf_wifi_osal_bus_spi_dev_intr_unreg(spi_dev_ctx->spi_priv->opriv,
spi_dev_ctx->os_spi_dev_ctx);

nrf_wifi_osal_bus_spi_dev_rem(spi_dev_ctx->spi_priv->opriv,
spi_dev_ctx->os_spi_dev_ctx);

nrf_wifi_osal_mem_free(spi_priv->opriv,
spi_dev_ctx);

spi_dev_ctx = NULL;

goto out;
}

out:
return spi_dev_ctx;
}
Expand All @@ -111,9 +87,6 @@ static void nrf_wifi_bus_spi_dev_rem(void *bus_dev_ctx)

spi_dev_ctx = bus_dev_ctx;

nrf_wifi_osal_bus_spi_dev_intr_unreg(spi_dev_ctx->spi_priv->opriv,
spi_dev_ctx->os_spi_dev_ctx);

nrf_wifi_osal_mem_free(spi_dev_ctx->spi_priv->opriv,
spi_dev_ctx);
}
Expand All @@ -126,13 +99,28 @@ static enum nrf_wifi_status nrf_wifi_bus_spi_dev_init(void *bus_dev_ctx)

spi_dev_ctx = bus_dev_ctx;


status = nrf_wifi_osal_bus_spi_dev_intr_reg(spi_dev_ctx->spi_priv->opriv,
spi_dev_ctx->os_spi_dev_ctx,
spi_dev_ctx,
&nrf_wifi_bus_spi_irq_handler);

if (status != NRF_WIFI_STATUS_SUCCESS) {
nrf_wifi_osal_log_err(spi_dev_ctx->spi_priv->opriv,
"%s: Unable to register interrupt to the OS",
__func__);
goto out;
}

status = nrf_wifi_osal_bus_spi_dev_init(spi_dev_ctx->spi_priv->opriv,
spi_dev_ctx->os_spi_dev_ctx);

if (status != NRF_WIFI_STATUS_SUCCESS) {
nrf_wifi_osal_log_err(spi_dev_ctx->spi_priv->opriv,
"%s: nrf_wifi_osal_spi_dev_init failed", __func__);

nrf_wifi_osal_bus_spi_dev_intr_unreg(spi_dev_ctx->spi_priv->opriv,
spi_dev_ctx->os_spi_dev_ctx);
goto out;
}
out:
Expand All @@ -146,6 +134,9 @@ static void nrf_wifi_bus_spi_dev_deinit(void *bus_dev_ctx)

spi_dev_ctx = bus_dev_ctx;

nrf_wifi_osal_bus_spi_dev_intr_unreg(spi_dev_ctx->spi_priv->opriv,
spi_dev_ctx->os_spi_dev_ctx);

nrf_wifi_osal_bus_spi_dev_deinit(spi_dev_ctx->spi_priv->opriv,
spi_dev_ctx->os_spi_dev_ctx);
}
Expand Down
7 changes: 5 additions & 2 deletions nrf_wifi/fw_if/umac_if/src/default/fmac_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -433,11 +433,10 @@ enum nrf_wifi_status nrf_wifi_fmac_dev_init(struct nrf_wifi_fmac_dev_ctx *fmac_d

void nrf_wifi_fmac_dev_deinit(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx)
{
nrf_wifi_hal_lock_rx(fmac_dev_ctx->hal_dev_ctx);
nrf_wifi_hal_dev_deinit(fmac_dev_ctx->hal_dev_ctx);
nrf_wifi_fmac_fw_deinit(fmac_dev_ctx);
nrf_wifi_osal_mem_free(fmac_dev_ctx->fpriv->opriv,
fmac_dev_ctx->tx_pwr_ceil_params);
nrf_wifi_hal_unlock_rx(fmac_dev_ctx->hal_dev_ctx);
}

#ifdef CONFIG_NRF_WIFI_RPU_RECOVERY
Expand Down Expand Up @@ -2257,6 +2256,10 @@ enum nrf_wifi_status nrf_wifi_fmac_chg_vif(void *dev_ctx,

def_dev_ctx = wifi_dev_priv(fmac_dev_ctx);

nrf_wifi_fmac_vif_update_if_type(fmac_dev_ctx,
if_idx,
vif_info->iftype);

def_dev_ctx->vif_ctx[if_idx]->if_type = vif_info->iftype;
}

Expand Down
13 changes: 3 additions & 10 deletions nrf_wifi/hw_if/hal/src/hal_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -1060,14 +1060,6 @@ void hal_rpu_eventq_drain(struct nrf_wifi_hal_dev_ctx *hal_dev_ctx)
hal_dev_ctx->lock_rx,
&flags);

if (hal_dev_ctx->hal_status != NRF_WIFI_HAL_STATUS_ENABLED) {
/* Ignore the interrupt if the HAL is not enabled */
nrf_wifi_osal_spinlock_irq_rel(hal_dev_ctx->hpriv->opriv,
hal_dev_ctx->lock_rx,
&flags);
goto out;
}

event = nrf_wifi_utils_q_dequeue(hal_dev_ctx->hpriv->opriv,
hal_dev_ctx->event_q);

Expand Down Expand Up @@ -1305,8 +1297,6 @@ void nrf_wifi_hal_dev_rem(struct nrf_wifi_hal_dev_ctx *hal_dev_ctx)
nrf_wifi_osal_tasklet_kill(hal_dev_ctx->hpriv->opriv,
hal_dev_ctx->event_tasklet);

hal_rpu_eventq_drain(hal_dev_ctx);

nrf_wifi_osal_tasklet_free(hal_dev_ctx->hpriv->opriv,
hal_dev_ctx->event_tasklet);

Expand Down Expand Up @@ -1388,14 +1378,17 @@ enum nrf_wifi_status nrf_wifi_hal_dev_init(struct nrf_wifi_hal_dev_ctx *hal_dev_
}

hal_dev_ctx->rpu_info.tx_cmd_base = RPU_MEM_TX_CMD_BASE;
nrf_wifi_hal_enable(hal_dev_ctx);
out:
return status;
}


void nrf_wifi_hal_dev_deinit(struct nrf_wifi_hal_dev_ctx *hal_dev_ctx)
{
nrf_wifi_hal_disable(hal_dev_ctx);
nrf_wifi_bal_dev_deinit(hal_dev_ctx->bal_dev_ctx);
hal_rpu_eventq_drain(hal_dev_ctx);
}


Expand Down
Loading