From 882f27f79a21332cfcc6818f6ecf79aa7ba5e24e Mon Sep 17 00:00:00 2001 From: Chaitanya Tata Date: Wed, 16 Oct 2024 02:35:30 +0530 Subject: [PATCH 1/5] drivers: wifi: Add regulatory debug log This log helps in identifing if the event is solicited or not. Signed-off-by: Chaitanya Tata --- drivers/wifi/nrfwifi/src/fmac_main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/wifi/nrfwifi/src/fmac_main.c b/drivers/wifi/nrfwifi/src/fmac_main.c index fce5da677223b..30bd150e81160 100644 --- a/drivers/wifi/nrfwifi/src/fmac_main.c +++ b/drivers/wifi/nrfwifi/src/fmac_main.c @@ -453,6 +453,8 @@ void reg_change_callbk_fn(void *vif_ctx, struct nrf_wifi_ctx_zep *rpu_ctx_zep = NULL; struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx = NULL; + LOG_DBG("%s: Regulatory change event received", __func__); + vif_ctx_zep = vif_ctx; if (!vif_ctx_zep) { From c921624702c10f7e8585b4b93bb48b4d673349b3 Mon Sep 17 00:00:00 2001 From: Chaitanya Tata Date: Wed, 16 Oct 2024 03:09:06 +0530 Subject: [PATCH 2/5] manifest: hal_nordic: Pull the flag to identify unsolicited reg event This flag can be used to drop unsolicited regulatory event as it's not supported. Signed-off-by: Chaitanya Tata --- west.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/west.yml b/west.yml index a20edb3c48779..84e0c6f4d1c16 100644 --- a/west.yml +++ b/west.yml @@ -188,7 +188,7 @@ manifest: groups: - hal - name: hal_nordic - revision: af91488c6edc4cebaf8b072c8bb258122a055cdb + revision: 5f1210074cb8bb7ec66317af294596a97ac48815 path: modules/hal/nordic groups: - hal From c913ec5e6496b5425222ccf131047b12b042dc83 Mon Sep 17 00:00:00 2001 From: Chaitanya Tata Date: Wed, 16 Oct 2024 02:43:28 +0530 Subject: [PATCH 3/5] drivers: wifi: Fix memory leak in regulatory processing During Wi-Fi connection UMAC sends an unsolicited regulatory change event but the driver code always assumes that this event is solicited hence doesn't free the memory for the event. Fix this by dropping the unsolicited event as it's not supported yet. Fixes #79733. Signed-off-by: Chaitanya Tata --- drivers/wifi/nrfwifi/src/fmac_main.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/wifi/nrfwifi/src/fmac_main.c b/drivers/wifi/nrfwifi/src/fmac_main.c index 30bd150e81160..82ea0f99267b6 100644 --- a/drivers/wifi/nrfwifi/src/fmac_main.c +++ b/drivers/wifi/nrfwifi/src/fmac_main.c @@ -474,6 +474,12 @@ void reg_change_callbk_fn(void *vif_ctx, return; } + if (!fmac_dev_ctx->waiting_for_reg_event) { + LOG_DBG("%s: Unsolicited regulatory change event", __func__); + /* TODO: Handle unsolicited regulatory change event */ + return; + } + fmac_dev_ctx->reg_change = k_malloc(sizeof(struct nrf_wifi_event_regulatory_change)); if (!fmac_dev_ctx->reg_change) { LOG_ERR("%s: Failed to allocate memory for reg_change", __func__); From 2e3c48681a7b9d558b562604208f6e4b56c7c8ed Mon Sep 17 00:00:00 2001 From: Chaitanya Tata Date: Wed, 16 Oct 2024 02:49:19 +0530 Subject: [PATCH 4/5] drivers: wifi: Clean up exit path Fix couple of bugs in exit path: - In case of calloc failure, return's without unlocking - memory is freed outside lock, in case of a tiny window of race, this can cause a crash when this function is called from two threads. Signed-off-by: Chaitanya Tata --- drivers/wifi/nrfwifi/src/net_if.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/wifi/nrfwifi/src/net_if.c b/drivers/wifi/nrfwifi/src/net_if.c index 813691865335c..b8ca8915ff4c9 100644 --- a/drivers/wifi/nrfwifi/src/net_if.c +++ b/drivers/wifi/nrfwifi/src/net_if.c @@ -440,7 +440,7 @@ static void ip_maddr_event_handler(struct net_if *iface, ret = k_mutex_lock(&vif_ctx_zep->vif_lock, K_FOREVER); if (ret != 0) { LOG_ERR("%s: Failed to lock vif_lock", __func__); - goto out; + return; } rpu_ctx_zep = vif_ctx_zep->rpu_ctx_zep; @@ -455,7 +455,7 @@ static void ip_maddr_event_handler(struct net_if *iface, if (!mcast_info) { LOG_ERR("%s: Unable to allocate memory of size %d " "for mcast_info", __func__, sizeof(*mcast_info)); - return; + goto unlock; } switch (addr->family) { @@ -492,9 +492,8 @@ static void ip_maddr_event_handler(struct net_if *iface, sizeof(mac_string_buf))); } unlock: - k_mutex_unlock(&vif_ctx_zep->vif_lock); -out: k_free(mcast_info); + k_mutex_unlock(&vif_ctx_zep->vif_lock); } #endif /* CONFIG_NRF70_STA_MODE */ From 09066af5ef5a8ccc55abb5b6734b250344134a33 Mon Sep 17 00:00:00 2001 From: Chaitanya Tata Date: Wed, 16 Oct 2024 20:35:01 +0530 Subject: [PATCH 5/5] drivers: nrfwifi: Remove non-existing member Opriv was removed but the doxygen doc string was left. Signed-off-by: Chaitanya Tata --- drivers/wifi/nrfwifi/src/shim.h | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/wifi/nrfwifi/src/shim.h b/drivers/wifi/nrfwifi/src/shim.h index a4162bf89314a..be26fd6355e62 100644 --- a/drivers/wifi/nrfwifi/src/shim.h +++ b/drivers/wifi/nrfwifi/src/shim.h @@ -19,7 +19,6 @@ /** * struct zep_shim_bus_qspi_priv - Structure to hold context information for the Linux OS * shim. - * @opriv: Pointer to OSAL context. * @pcie_callbk_data: Callback data to be passed to the PCIe callback functions. * @pcie_prb_callbk: The callback function to be called when a PCIe device * has been probed.