From 65fdbbce9a41477a87bd5ec4e372ee54e2b62087 Mon Sep 17 00:00:00 2001 From: Jinwei Chen Date: Wed, 13 Sep 2023 04:06:34 -0700 Subject: [PATCH] qcacmn: skip monitor reap timer if irq is enabled For CFR test, monitor reap timer will start, meanwhile irq for monitor status ring is also enabled, these two will conflict and access mon_pdev->rx_status_q in the same time, skb double free issue is reported. If irq for monitor status ring has been enabled, skip to start monitor reap timer which is unnecessary. Change-Id: Ic015d370cb80604d7e4c261054ad529b64edca25 CRs-Fixed: 3614097 --- dp/wifi3.0/monitor/1.0/dp_mon_1.0.c | 24 ++++++++++++++++++++++-- hal/wifi3.0/hal_api.h | 19 +++++++++++++++++++ 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/dp/wifi3.0/monitor/1.0/dp_mon_1.0.c b/dp/wifi3.0/monitor/1.0/dp_mon_1.0.c index 350bade91f..bb15e18d10 100644 --- a/dp/wifi3.0/monitor/1.0/dp_mon_1.0.c +++ b/dp/wifi3.0/monitor/1.0/dp_mon_1.0.c @@ -604,6 +604,25 @@ static void dp_mon_reap_timer_deinit(struct dp_soc *soc) } } +/** + * dp_mon_is_irq_enabled() - check if DP monitor status srng irq enabled + * @soc: point to soc + * + * Return: true if irq enabled, false if not. + */ +static bool +dp_mon_is_irq_enabled(struct dp_soc *soc) +{ + void *mon_status_srng; + + mon_status_srng = soc->rxdma_mon_status_ring[0].hal_srng; + + if (!mon_status_srng) + return false; + + return hal_srng_batch_threshold_irq_enabled(mon_status_srng); +} + /** * dp_mon_reap_timer_start() - start reap timer of monitor status ring * @soc: point to soc @@ -621,7 +640,8 @@ dp_mon_reap_timer_start(struct dp_soc *soc, enum cdp_mon_reap_source source) struct dp_mon_soc *mon_soc = soc->monitor_soc; bool do_start; - if (!mon_soc->reap_timer_init) + /* if monitor status ring irq enabled, no need to start timer */ + if (!mon_soc->reap_timer_init || dp_mon_is_irq_enabled(soc)) return false; qdf_spin_lock_bh(&mon_soc->reap_timer_lock); @@ -656,7 +676,7 @@ dp_mon_reap_timer_stop(struct dp_soc *soc, enum cdp_mon_reap_source source) struct dp_mon_soc *mon_soc = soc->monitor_soc; bool do_stop; - if (!mon_soc->reap_timer_init) + if (!mon_soc->reap_timer_init || dp_mon_is_irq_enabled(soc)) return false; qdf_spin_lock_bh(&mon_soc->reap_timer_lock); diff --git a/hal/wifi3.0/hal_api.h b/hal/wifi3.0/hal_api.h index 33a38444dc..7aa5ce8546 100644 --- a/hal/wifi3.0/hal_api.h +++ b/hal/wifi3.0/hal_api.h @@ -3507,6 +3507,25 @@ uint16_t hal_srng_dst_get_hpidx(hal_ring_handle_t hal_ring_hdl) return hp / srng->entry_size; } +/** + * hal_srng_batch_threshold_irq_enabled() - check if srng batch count + * threshold irq enabled + * @hal_ring_hdl: srng handle + * + * Return: true if enabled, false if not. + */ +static inline +bool hal_srng_batch_threshold_irq_enabled(hal_ring_handle_t hal_ring_hdl) +{ + struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl; + + if (srng->intr_batch_cntr_thres_entries && + srng->flags & HAL_SRNG_MSI_INTR) + return true; + else + return false; +} + #ifdef FEATURE_DIRECT_LINK /** * hal_srng_set_msi_irq_config() - Set the MSI irq configuration for srng