Skip to content
Open
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
12 changes: 9 additions & 3 deletions hw_if/hal/src/common/hal_api_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@ enum nrf_wifi_status hal_rpu_ps_wake(struct nrf_wifi_hal_dev_ctx *hal_dev_ctx)
if (!hal_dev_ctx->rpu_fw_booted)
return NRF_WIFI_STATUS_SUCCESS;

/* Cancel any pending sleep timer to prevent it from firing during the wake
* operation or subsequent register/memory access.
*
* Note: Timer scheduling is done by the caller after releasing
* the lock to prevent the timer from firing during subsequent
* operations (register/memory reads/writes).
*/
nrf_wifi_osal_timer_kill(hal_dev_ctx->rpu_ps_timer);

if (hal_dev_ctx->rpu_ps_state == RPU_PS_STATE_AWAKE) {
status = NRF_WIFI_STATUS_SUCCESS;

Expand Down Expand Up @@ -121,9 +130,6 @@ enum nrf_wifi_status hal_rpu_ps_wake(struct nrf_wifi_hal_dev_ctx *hal_dev_ctx)
#endif /* NRF_WIFI_RPU_RECOVERY_PS_STATE_DEBUG */

out:

nrf_wifi_osal_timer_schedule(hal_dev_ctx->rpu_ps_timer,
NRF70_RPU_PS_IDLE_TIMEOUT_MS);
return status;
}

Expand Down
16 changes: 16 additions & 0 deletions hw_if/hal/src/common/hal_mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,14 @@ static enum nrf_wifi_status rpu_mem_read_ram(struct nrf_wifi_hal_dev_ctx *hal_de
out:
nrf_wifi_osal_spinlock_irq_rel(hal_dev_ctx->rpu_ps_lock,
&flags);

/* Schedule sleep timer after releasing the lock to prevent
* it from firing during the critical section.
*/
if (status == NRF_WIFI_STATUS_SUCCESS) {
nrf_wifi_osal_timer_schedule(hal_dev_ctx->rpu_ps_timer,
NRF70_RPU_PS_IDLE_TIMEOUT_MS);
}
#endif /* NRF_WIFI_LOW_POWER */

return status;
Expand Down Expand Up @@ -169,6 +177,14 @@ static enum nrf_wifi_status rpu_mem_write_ram(struct nrf_wifi_hal_dev_ctx *hal_d
out:
nrf_wifi_osal_spinlock_irq_rel(hal_dev_ctx->rpu_ps_lock,
&flags);

/* Schedule sleep timer after releasing the lock to prevent
* it from firing during the critical section.
*/
if (status == NRF_WIFI_STATUS_SUCCESS) {
nrf_wifi_osal_timer_schedule(hal_dev_ctx->rpu_ps_timer,
NRF70_RPU_PS_IDLE_TIMEOUT_MS);
}
#endif /* NRF_WIFI_LOW_POWER */

return status;
Expand Down
16 changes: 16 additions & 0 deletions hw_if/hal/src/common/hal_reg.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,14 @@ enum nrf_wifi_status hal_rpu_reg_read(struct nrf_wifi_hal_dev_ctx *hal_dev_ctx,
#ifdef NRF_WIFI_LOW_POWER
nrf_wifi_osal_spinlock_irq_rel(hal_dev_ctx->rpu_ps_lock,
&flags);

/* Schedule sleep timer after releasing the lock to prevent
* it from firing during the critical section.
*/
if (status == NRF_WIFI_STATUS_SUCCESS) {
nrf_wifi_osal_timer_schedule(hal_dev_ctx->rpu_ps_timer,
NRF70_RPU_PS_IDLE_TIMEOUT_MS);
}
#endif /* NRF_WIFI_LOW_POWER */

return status;
Expand Down Expand Up @@ -151,6 +159,14 @@ enum nrf_wifi_status hal_rpu_reg_write(struct nrf_wifi_hal_dev_ctx *hal_dev_ctx,
out:
nrf_wifi_osal_spinlock_irq_rel(hal_dev_ctx->rpu_ps_lock,
&flags);

/* Schedule sleep timer after releasing the lock to prevent
* it from firing during the critical section.
*/
if (status == NRF_WIFI_STATUS_SUCCESS) {
nrf_wifi_osal_timer_schedule(hal_dev_ctx->rpu_ps_timer,
NRF70_RPU_PS_IDLE_TIMEOUT_MS);
}
#endif /* NRF_WIFI_LOW_POWER */

return status;
Expand Down