79c1d735b8255f84521c11cad30590c42d67d5f9
[openwrt/staging/jow.git] / package / kernel / mac80211 / patches / ath11k / 0026-wifi-ath11k-fix-Tx-power-value-during-active-CAC.patch
1 From 77f1ee6fd8b6e470f721d05a2e269039d5cafcb7 Mon Sep 17 00:00:00 2001
2 From: Aditya Kumar Singh <quic_adisi@quicinc.com>
3 Date: Tue, 3 Oct 2023 17:26:54 +0300
4 Subject: [PATCH] wifi: ath11k: fix Tx power value during active CAC
5
6 Tx power is fetched from firmware's pdev stats. However, during active
7 CAC, firmware does not fill the current Tx power and sends the max
8 initialised value filled during firmware init. If host sends this power
9 to user space, this is wrong since in certain situations, the Tx power
10 could be greater than the max allowed by the regulatory. Hence, host
11 should not be fetching the Tx power during an active CAC.
12
13 Fix this issue by returning -EAGAIN error so that user space knows that there's
14 no valid value available.
15
16 Tested-on: QCN9074 hw1.0 PCI WLAN.HK.2.7.0.1-01744-QCAHKSWPL_SILICONZ-1
17
18 Fixes: 9a2aa68afe3d ("wifi: ath11k: add get_txpower mac ops")
19 Signed-off-by: Aditya Kumar Singh <quic_adisi@quicinc.com>
20 Acked-by: Jeff Johnson <quic_jjohnson@quicinc.com>
21 Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
22 Link: https://lore.kernel.org/r/20230912051857.2284-4-quic_adisi@quicinc.com
23 ---
24 drivers/net/wireless/ath/ath11k/mac.c | 8 ++++++++
25 1 file changed, 8 insertions(+)
26
27 --- a/drivers/net/wireless/ath/ath11k/mac.c
28 +++ b/drivers/net/wireless/ath/ath11k/mac.c
29 @@ -9060,6 +9060,14 @@ static int ath11k_mac_op_get_txpower(str
30 if (ar->state != ATH11K_STATE_ON)
31 goto err_fallback;
32
33 + /* Firmware doesn't provide Tx power during CAC hence no need to fetch
34 + * the stats.
35 + */
36 + if (test_bit(ATH11K_CAC_RUNNING, &ar->dev_flags)) {
37 + mutex_unlock(&ar->conf_mutex);
38 + return -EAGAIN;
39 + }
40 +
41 req_param.pdev_id = ar->pdev->pdev_id;
42 req_param.stats_id = WMI_REQUEST_PDEV_STAT;
43