From 37e775a0a9d79a031d28d9e21480f99f448e9215 Mon Sep 17 00:00:00 2001 From: Baochen Qiang Date: Wed, 21 May 2025 22:29:30 +0530 Subject: [PATCH] wifi: ath12k: fix regdomain update failure when adding interface Commit 4c546023d71a ("wifi: ath12k: update regulatory rules when interface added"), introduced a call to ath12k_reg_handle_chan_list() during interface addition to update the regulatory domain based on the interface type. While this works initially, subsequent updates (e.g., after an interface delete/re-add cycle) fail because ah->regd_updated is never reset. To address this, reset ah->regd_updated before calling ath12k_reg_handle_chan_list() to allow the update to proceed. However, this change exposes another issue: a timeout occurs when waiting for the 11D scan to complete, as seen in the log: ath12k_pci 0000:05:00.0: failed to receive 11d scan complete: timed out This happens because during interface down, ar->state_11d is set to ATH12K_11D_PREPARING, and during interface up, the host waits for ar->completed_11d_scan even though the scan hasn't started yet. Fix this by updating the wait condition to check for ATH12K_11D_RUNNING, which is the only state where a scan complete event is expected. Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.4.1-00199-QCAHKSWPL_SILICONZ-1 Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.1.c5-00284-QCAHMTSWPL_V1.0_V2.0_SILICONZ-1 Fixes: 4c546023d71a ("wifi: ath12k: update regulatory rules when interface added") Signed-off-by: Baochen Qiang Signed-off-by: Aditya Kumar Singh Link: https://patch.msgid.link/20250521-ath12k-fix-ah-regd_updated-v1-2-9737de5bf98e@oss.qualcomm.com Signed-off-by: Jeff Johnson --- drivers/net/wireless/ath/ath12k/mac.c | 1 + drivers/net/wireless/ath/ath12k/reg.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c index 81ff32d2ce5a..755546246915 100644 --- a/drivers/net/wireless/ath/ath12k/mac.c +++ b/drivers/net/wireless/ath/ath12k/mac.c @@ -8833,6 +8833,7 @@ static int ath12k_mac_op_add_interface(struct ieee80211_hw *hw, ab = ar->ab; reg_info = ab->reg_info[ar->pdev_idx]; ath12k_dbg(ab, ATH12K_DBG_MAC, "interface added to change reg rules\n"); + ah->regd_updated = false; ath12k_reg_handle_chan_list(ab, reg_info, ahvif->vdev_type, IEEE80211_REG_UNSET_AP); break; diff --git a/drivers/net/wireless/ath/ath12k/reg.c b/drivers/net/wireless/ath/ath12k/reg.c index 2134e72e0812..2598b39d5d7e 100644 --- a/drivers/net/wireless/ath/ath12k/reg.c +++ b/drivers/net/wireless/ath/ath12k/reg.c @@ -139,7 +139,7 @@ int ath12k_reg_update_chan_list(struct ath12k *ar, bool wait) int num_channels = 0; int i, ret, left; - if (wait && ar->state_11d != ATH12K_11D_IDLE) { + if (wait && ar->state_11d == ATH12K_11D_RUNNING) { left = wait_for_completion_timeout(&ar->completed_11d_scan, ATH12K_SCAN_TIMEOUT_HZ); if (!left) { -- 2.50.1