diff mbox series

wifi: ath12k: indicate scan complete for scan canceled when scan running

Message ID 20230906085746.18968-1-quic_wgong@quicinc.com (mailing list archive)
State Accepted
Commit 870c6a72739c4905e592da9c01731f975e46c30a
Delegated to: Kalle Valo
Headers show
Series wifi: ath12k: indicate scan complete for scan canceled when scan running | expand

Commit Message

Wen Gong Sept. 6, 2023, 8:57 a.m. UTC
ath12k prints "Received scan event for unknown vdev" when doing the
following test:
1. trigger scan
2. wait 0.2 second
3. iw reg set is issued or 11d scan complete event is sent from firmware

Reason is:
When iw reg set is issues or the 11d scan complete event is received, the
new country code will be set to the firmware, and the new regdomain info
indicated to ath12k, then the new channel list will be sent to the firmware.
The firmware will cancel the current scan after receiving WMI_SCAN_CHAN_LIST_CMDID
which is used for the new channel list, and the state of ath12k is
ATH12K_SCAN_RUNNING, then ath12k_get_ar_on_scan_abort() returns NULL and
ath12k_scan_event() returns at this point and does not indicate scan
completion to mac80211.

Indicate scan completion to mac80211 and get rid of the "Received scan
event for unknown vdev" print for the above case.

Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0-03427-QCAHMTSWPL_V1.0_V2.0_SILICONZ-1.15378.4

Signed-off-by: Wen Gong <quic_wgong@quicinc.com>
---
 drivers/net/wireless/ath/ath12k/wmi.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)


base-commit: 3f257461ab0ab19806bae2bfde4c3cd88dbf050e

Comments

Jeff Johnson Sept. 8, 2023, 3:23 p.m. UTC | #1
On 9/6/2023 1:57 AM, Wen Gong wrote:
> ath12k prints "Received scan event for unknown vdev" when doing the
> following test:
> 1. trigger scan
> 2. wait 0.2 second
> 3. iw reg set is issued or 11d scan complete event is sent from firmware
> 
> Reason is:
> When iw reg set is issues or the 11d scan complete event is received, the
> new country code will be set to the firmware, and the new regdomain info
> indicated to ath12k, then the new channel list will be sent to the firmware.
> The firmware will cancel the current scan after receiving WMI_SCAN_CHAN_LIST_CMDID
> which is used for the new channel list, and the state of ath12k is
> ATH12K_SCAN_RUNNING, then ath12k_get_ar_on_scan_abort() returns NULL and
> ath12k_scan_event() returns at this point and does not indicate scan
> completion to mac80211.
> 
> Indicate scan completion to mac80211 and get rid of the "Received scan
> event for unknown vdev" print for the above case.
> 
> Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0-03427-QCAHMTSWPL_V1.0_V2.0_SILICONZ-1.15378.4
> 
> Signed-off-by: Wen Gong <quic_wgong@quicinc.com>

Acked-by: Jeff Johnson <quic_jjohnson@quicinc.com>

> ---
>   drivers/net/wireless/ath/ath12k/wmi.c | 18 ++++++++++++------
>   1 file changed, 12 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/net/wireless/ath/ath12k/wmi.c b/drivers/net/wireless/ath/ath12k/wmi.c
> index 9ed33e2d6da0..d30de487f43f 100644
> --- a/drivers/net/wireless/ath/ath12k/wmi.c
> +++ b/drivers/net/wireless/ath/ath12k/wmi.c
> @@ -5862,8 +5862,9 @@ static void ath12k_mgmt_tx_compl_event(struct ath12k_base *ab, struct sk_buff *s
>   	rcu_read_unlock();
>   }
>   
> -static struct ath12k *ath12k_get_ar_on_scan_abort(struct ath12k_base *ab,
> -						  u32 vdev_id)
> +static struct ath12k *ath12k_get_ar_on_scan_state(struct ath12k_base *ab,
> +						  u32 vdev_id,
> +						  enum ath12k_scan_state state)
>   {
>   	int i;
>   	struct ath12k_pdev *pdev;
> @@ -5875,7 +5876,7 @@ static struct ath12k *ath12k_get_ar_on_scan_abort(struct ath12k_base *ab,
>   			ar = pdev->ar;
>   
>   			spin_lock_bh(&ar->data_lock);
> -			if (ar->scan.state == ATH12K_SCAN_ABORTING &&
> +			if (ar->scan.state == state &&
>   			    ar->scan.vdev_id == vdev_id) {
>   				spin_unlock_bh(&ar->data_lock);
>   				return ar;
> @@ -5905,10 +5906,15 @@ static void ath12k_scan_event(struct ath12k_base *ab, struct sk_buff *skb)
>   	 * aborting scan's vdev id matches this event info.
>   	 */
>   	if (le32_to_cpu(scan_ev.event_type) == WMI_SCAN_EVENT_COMPLETED &&
> -	    le32_to_cpu(scan_ev.reason) == WMI_SCAN_REASON_CANCELLED)
> -		ar = ath12k_get_ar_on_scan_abort(ab, le32_to_cpu(scan_ev.vdev_id));
> -	else
> +	    le32_to_cpu(scan_ev.reason) == WMI_SCAN_REASON_CANCELLED) {
> +		ar = ath12k_get_ar_on_scan_state(ab, le32_to_cpu(scan_ev.vdev_id),
> +						 ATH12K_SCAN_ABORTING);
> +		if (!ar)
> +			ar = ath12k_get_ar_on_scan_state(ab, le32_to_cpu(scan_ev.vdev_id),
> +							 ATH12K_SCAN_RUNNING);
> +	} else {
>   		ar = ath12k_mac_get_ar_by_vdev_id(ab, le32_to_cpu(scan_ev.vdev_id));
> +	}
>   
>   	if (!ar) {
>   		ath12k_warn(ab, "Received scan event for unknown vdev");
> 
> base-commit: 3f257461ab0ab19806bae2bfde4c3cd88dbf050e
Kalle Valo Sept. 28, 2023, 3:05 p.m. UTC | #2
Wen Gong <quic_wgong@quicinc.com> wrote:

> ath12k prints "Received scan event for unknown vdev" when doing the
> following test:
> 1. trigger scan
> 2. wait 0.2 second
> 3. iw reg set is issued or 11d scan complete event is sent from firmware
> 
> Reason is:
> When iw reg set is issues or the 11d scan complete event is received, the
> new country code will be set to the firmware, and the new regdomain info
> indicated to ath12k, then the new channel list will be sent to the firmware.
> The firmware will cancel the current scan after receiving WMI_SCAN_CHAN_LIST_CMDID
> which is used for the new channel list, and the state of ath12k is
> ATH12K_SCAN_RUNNING, then ath12k_get_ar_on_scan_abort() returns NULL and
> ath12k_scan_event() returns at this point and does not indicate scan
> completion to mac80211.
> 
> Indicate scan completion to mac80211 and get rid of the "Received scan
> event for unknown vdev" print for the above case.
> 
> Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0-03427-QCAHMTSWPL_V1.0_V2.0_SILICONZ-1.15378.4
> 
> Signed-off-by: Wen Gong <quic_wgong@quicinc.com>
> Acked-by: Jeff Johnson <quic_jjohnson@quicinc.com>
> Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>

Patch applied to ath-next branch of ath.git, thanks.

870c6a72739c wifi: ath12k: indicate scan complete for scan canceled when scan running
diff mbox series

Patch

diff --git a/drivers/net/wireless/ath/ath12k/wmi.c b/drivers/net/wireless/ath/ath12k/wmi.c
index 9ed33e2d6da0..d30de487f43f 100644
--- a/drivers/net/wireless/ath/ath12k/wmi.c
+++ b/drivers/net/wireless/ath/ath12k/wmi.c
@@ -5862,8 +5862,9 @@  static void ath12k_mgmt_tx_compl_event(struct ath12k_base *ab, struct sk_buff *s
 	rcu_read_unlock();
 }
 
-static struct ath12k *ath12k_get_ar_on_scan_abort(struct ath12k_base *ab,
-						  u32 vdev_id)
+static struct ath12k *ath12k_get_ar_on_scan_state(struct ath12k_base *ab,
+						  u32 vdev_id,
+						  enum ath12k_scan_state state)
 {
 	int i;
 	struct ath12k_pdev *pdev;
@@ -5875,7 +5876,7 @@  static struct ath12k *ath12k_get_ar_on_scan_abort(struct ath12k_base *ab,
 			ar = pdev->ar;
 
 			spin_lock_bh(&ar->data_lock);
-			if (ar->scan.state == ATH12K_SCAN_ABORTING &&
+			if (ar->scan.state == state &&
 			    ar->scan.vdev_id == vdev_id) {
 				spin_unlock_bh(&ar->data_lock);
 				return ar;
@@ -5905,10 +5906,15 @@  static void ath12k_scan_event(struct ath12k_base *ab, struct sk_buff *skb)
 	 * aborting scan's vdev id matches this event info.
 	 */
 	if (le32_to_cpu(scan_ev.event_type) == WMI_SCAN_EVENT_COMPLETED &&
-	    le32_to_cpu(scan_ev.reason) == WMI_SCAN_REASON_CANCELLED)
-		ar = ath12k_get_ar_on_scan_abort(ab, le32_to_cpu(scan_ev.vdev_id));
-	else
+	    le32_to_cpu(scan_ev.reason) == WMI_SCAN_REASON_CANCELLED) {
+		ar = ath12k_get_ar_on_scan_state(ab, le32_to_cpu(scan_ev.vdev_id),
+						 ATH12K_SCAN_ABORTING);
+		if (!ar)
+			ar = ath12k_get_ar_on_scan_state(ab, le32_to_cpu(scan_ev.vdev_id),
+							 ATH12K_SCAN_RUNNING);
+	} else {
 		ar = ath12k_mac_get_ar_by_vdev_id(ab, le32_to_cpu(scan_ev.vdev_id));
+	}
 
 	if (!ar) {
 		ath12k_warn(ab, "Received scan event for unknown vdev");