diff --git a/hal/wifi3.0/hal_api.h b/hal/wifi3.0/hal_api.h index e28afcffa2..f01c8f8343 100644 --- a/hal/wifi3.0/hal_api.h +++ b/hal/wifi3.0/hal_api.h @@ -269,6 +269,12 @@ static inline void hal_write32_mb(struct hal_soc *hal_soc, uint32_t offset, unsigned long flags; qdf_iomem_t new_addr; + if (!TARGET_ACCESS_ALLOWED(HIF_GET_SOFTC( + hal_soc->hif_handle))) { + hal_err_rl("%s: target access is not allowed", __func__); + return; + } + /* Region < BAR + 4K can be directly accessed */ if (offset < MAPPED_REF_OFF) { qdf_iowrite32(hal_soc->dev_base_addr + offset, value); @@ -323,6 +329,12 @@ static inline void hal_write32_mb_confirm(struct hal_soc *hal_soc, unsigned long flags; qdf_iomem_t new_addr; + if (!TARGET_ACCESS_ALLOWED(HIF_GET_SOFTC( + hal_soc->hif_handle))) { + hal_err_rl("%s: target access is not allowed", __func__); + return; + } + /* Region < BAR + 4K can be directly accessed */ if (offset < MAPPED_REF_OFF) { qdf_iowrite32(hal_soc->dev_base_addr + offset, value); @@ -477,6 +489,12 @@ uint32_t hal_read32_mb(struct hal_soc *hal_soc, uint32_t offset) unsigned long flags; qdf_iomem_t new_addr; + if (!TARGET_ACCESS_ALLOWED(HIF_GET_SOFTC( + hal_soc->hif_handle))) { + hal_err_rl("%s: target access is not allowed", __func__); + return 0; + } + /* Region < BAR + 4K can be directly accessed */ if (offset < MAPPED_REF_OFF) return qdf_ioread32(hal_soc->dev_base_addr + offset); diff --git a/hif/inc/hif.h b/hif/inc/hif.h index 9fc57b5587..607f5bba2d 100644 --- a/hif/inc/hif.h +++ b/hif/inc/hif.h @@ -1516,6 +1516,21 @@ void hif_srng_init_phase(struct hif_opaque_softc *hif_ctx, } #endif /* FORCE_WAKE */ +#ifdef HIF_IPCI +/** + * hif_shutdown_notifier_cb - Call back for shutdown notifier + * @ctx: hif handle + * + * Return: None + */ +void hif_shutdown_notifier_cb(void *ctx); +#else +static inline +void hif_shutdown_notifier_cb(void *ctx) +{ +} +#endif /* HIF_IPCI */ + #ifdef HIF_CE_LOG_INFO /** * hif_log_ce_info() - API to log ce info diff --git a/hif/src/hif_io32.h b/hif/src/hif_io32.h index e6c282f588..62460edff9 100644 --- a/hif/src/hif_io32.h +++ b/hif/src/hif_io32.h @@ -98,8 +98,27 @@ uint32_t hif_read32_mb_reg_window(void *sc, #include "hif_io32_ipci.h" #endif -#if defined(HIF_REG_WINDOW_SUPPORT) && (defined(HIF_PCI) || \ - defined(HIF_IPCI)) +#ifdef HIF_IPCI +/** + * hif_target_access_allowed(): Check if target access is allowed + * + * @scn: HIF handler + * + * Return: True if access is allowed else False + */ +static inline +bool hif_target_access_allowed(struct hif_softc *scn) +{ + return !(scn->recovery); +} + +#define TARGET_ACCESS_ALLOWED(scn) \ + hif_target_access_allowed(scn) +#else +#define TARGET_ACCESS_ALLOWED(scn) (1) +#endif + +#if defined(HIF_REG_WINDOW_SUPPORT) && defined(HIF_PCI) #include "qdf_lock.h" #include "qdf_util.h" diff --git a/hif/src/hif_main.c b/hif/src/hif_main.c index 8b494b0836..034e6e485f 100644 --- a/hif/src/hif_main.c +++ b/hif/src/hif_main.c @@ -94,6 +94,15 @@ void hif_srng_init_phase(struct hif_opaque_softc *hif_ctx, } #endif /* FORCE_WAKE */ +#ifdef HIF_IPCI +void hif_shutdown_notifier_cb(void *hif_ctx) +{ + struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); + + scn->recovery = true; +} +#endif + /** * hif_vote_link_down(): unvote for link up *