Message ID | 20240809025055.6495-3-quic_lingbok@quicinc.com (mailing list archive) |
---|---|
State | Changes Requested |
Delegated to: | Kalle Valo |
Headers | show |
Series | wifi: ath12k: Add new features to ACPI | expand |
On 8/8/2024 7:50 PM, Lingbo Kong wrote: > Currently, ath12k does not support enable or disable specific features by > ACPI bitflag. > > To address this issue, obtain the ACPI bitflag value and use it to > selectively enable or disable specific features. > > This patch will not affect QCN9274, because only WCN7850 supports ACPI. > > Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3 > > Signed-off-by: Lingbo Kong <quic_lingbok@quicinc.com> > --- > v2: > 1.support functions for cases where CONFIG_ACPI is disabled > > drivers/net/wireless/ath/ath12k/acpi.c | 41 ++++++++++++++++++++++++-- > drivers/net/wireless/ath/ath12k/acpi.h | 18 +++++++++++ > drivers/net/wireless/ath/ath12k/core.c | 3 ++ > drivers/net/wireless/ath/ath12k/core.h | 3 ++ > drivers/net/wireless/ath/ath12k/mac.c | 3 +- > 5 files changed, 64 insertions(+), 4 deletions(-) > > diff --git a/drivers/net/wireless/ath/ath12k/acpi.c b/drivers/net/wireless/ath/ath12k/acpi.c > index d83f7e58fb7a..a3f3d0712722 100644 > --- a/drivers/net/wireless/ath/ath12k/acpi.c > +++ b/drivers/net/wireless/ath/ath12k/acpi.c > @@ -29,7 +29,14 @@ static int ath12k_acpi_dsm_get_data(struct ath12k_base *ab, int func) > } > > if (obj->type == ACPI_TYPE_INTEGER) { > - ab->acpi.func_bit = obj->integer.value; > + switch (func) { > + case ATH12K_ACPI_DSM_FUNC_SUPPORT_FUNCS: > + ab->acpi.func_bit = obj->integer.value; > + break; > + case ATH12K_ACPI_DSM_FUNC_DISABLE_FLAG: > + ab->acpi.bit_flag = obj->integer.value; > + break; > + } > } else if (obj->type == ACPI_TYPE_BUFFER) { > switch (func) { > case ATH12K_ACPI_DSM_FUNC_SUPPORT_FUNCS: > @@ -261,24 +268,52 @@ static int ath12k_acpi_set_tas_params(struct ath12k_base *ab) > return 0; > } > > +bool ath12k_acpi_get_disable_rfkill(struct ath12k_base *ab) > +{ > + return ab->acpi.acpi_disable_rfkill; > +} > + > +bool ath12k_acpi_get_disable_11be(struct ath12k_base *ab) > +{ > + return ab->acpi.acpi_disable_11be; > +} IMO the above functions would be better if you remove "get_" from the names. "get" is an action verb and usually action verbs return error codes. removing "get" makes them predicates which normally return bool. And based upon the usage, IMO they become even better as: ath12k_acpi_rfkill_disabled() ath12k_acpi_11be_disabled() Since then they work very well in 'if' statements > + > int ath12k_acpi_start(struct ath12k_base *ab) > { > acpi_status status; > u8 *buf; > int ret; > > + ab->acpi.acpi_tas_enable = false; > + ab->acpi.acpi_disable_11be = false; > + ab->acpi.acpi_disable_rfkill = false; > + > if (!ab->hw_params->acpi_guid) > /* not supported with this hardware */ > return 0; > > - ab->acpi.acpi_tas_enable = false; > - > ret = ath12k_acpi_dsm_get_data(ab, ATH12K_ACPI_DSM_FUNC_SUPPORT_FUNCS); > if (ret) { > ath12k_dbg(ab, ATH12K_DBG_BOOT, "failed to get ACPI DSM data: %d\n", ret); > return ret; > } > > + if (ATH12K_ACPI_FUNC_BIT_VALID(ab->acpi, ATH12K_ACPI_FUNC_BIT_DISABLE_FLAG)) { > + ret = ath12k_acpi_dsm_get_data(ab, ATH12K_ACPI_DSM_FUNC_DISABLE_FLAG); > + if (ret) { > + ath12k_warn(ab, "failed to get ACPI DISABLE FLAG: %d\n", ret); > + return ret; > + } > + > + if (ATH12K_ACPI_CHEK_BIT_VALID(ab->acpi, > + ATH12K_ACPI_DSM_DISABLE_11BE_BIT)) > + ab->acpi.acpi_disable_11be = true; > + > + if (!ATH12K_ACPI_CHEK_BIT_VALID(ab->acpi, > + ATH12K_ACPI_DSM_DISABLE_RFKILL_BIT)) > + ab->acpi.acpi_disable_rfkill = true; > + } > + > if (ATH12K_ACPI_FUNC_BIT_VALID(ab->acpi, ATH12K_ACPI_FUNC_BIT_TAS_CFG)) { > ret = ath12k_acpi_dsm_get_data(ab, ATH12K_ACPI_DSM_FUNC_TAS_CFG); > if (ret) { > diff --git a/drivers/net/wireless/ath/ath12k/acpi.h b/drivers/net/wireless/ath/ath12k/acpi.h > index 7ec7a2e72e40..4b154cfdbd39 100644 > --- a/drivers/net/wireless/ath/ath12k/acpi.h > +++ b/drivers/net/wireless/ath/ath12k/acpi.h > @@ -9,6 +9,7 @@ > #include <linux/acpi.h> > > #define ATH12K_ACPI_DSM_FUNC_SUPPORT_FUNCS 0 > +#define ATH12K_ACPI_DSM_FUNC_DISABLE_FLAG 2 > #define ATH12K_ACPI_DSM_FUNC_BIOS_SAR 4 > #define ATH12K_ACPI_DSM_FUNC_GEO_OFFSET 5 > #define ATH12K_ACPI_DSM_FUNC_INDEX_CCA 6 > @@ -16,6 +17,7 @@ > #define ATH12K_ACPI_DSM_FUNC_TAS_DATA 9 > #define ATH12K_ACPI_DSM_FUNC_INDEX_BAND_EDGE 10 > > +#define ATH12K_ACPI_FUNC_BIT_DISABLE_FLAG BIT(1) > #define ATH12K_ACPI_FUNC_BIT_BIOS_SAR BIT(3) > #define ATH12K_ACPI_FUNC_BIT_GEO_OFFSET BIT(4) > #define ATH12K_ACPI_FUNC_BIT_CCA BIT(5) > @@ -25,6 +27,7 @@ > > #define ATH12K_ACPI_NOTIFY_EVENT 0x86 > #define ATH12K_ACPI_FUNC_BIT_VALID(_acdata, _func) (((_acdata).func_bit) & (_func)) > +#define ATH12K_ACPI_CHEK_BIT_VALID(_acdata, _func) (((_acdata).bit_flag) & (_func)) > > #define ATH12K_ACPI_TAS_DATA_VERSION 0x1 > #define ATH12K_ACPI_TAS_DATA_ENABLE 0x1 > @@ -51,6 +54,9 @@ > #define ATH12K_ACPI_DSM_FUNC_MIN_BITMAP_SIZE 1 > #define ATH12K_ACPI_DSM_FUNC_MAX_BITMAP_SIZE 4 > > +#define ATH12K_ACPI_DSM_DISABLE_11BE_BIT BIT(0) > +#define ATH12K_ACPI_DSM_DISABLE_RFKILL_BIT BIT(2) > + > #define ATH12K_ACPI_DSM_GEO_OFFSET_DATA_SIZE (ATH12K_ACPI_GEO_OFFSET_DATA_OFFSET + \ > ATH12K_ACPI_BIOS_SAR_GEO_OFFSET_LEN) > #define ATH12K_ACPI_DSM_BIOS_SAR_DATA_SIZE (ATH12K_ACPI_POWER_LIMIT_DATA_OFFSET + \ > @@ -62,6 +68,8 @@ > > int ath12k_acpi_start(struct ath12k_base *ab); > void ath12k_acpi_stop(struct ath12k_base *ab); > +bool ath12k_acpi_get_disable_rfkill(struct ath12k_base *ab); > +bool ath12k_acpi_get_disable_11be(struct ath12k_base *ab); > > #else > > @@ -74,6 +82,16 @@ static inline void ath12k_acpi_stop(struct ath12k_base *ab) > { > } > > +static inline bool ath12k_acpi_get_disable_rfkill(struct ath12k_base *ab) > +{ > + return false; > +} > + > +static inline bool ath12k_acpi_get_disable_11be(struct ath12k_base *ab) > +{ > + return false; > +} > + > #endif /* CONFIG_ACPI */ > > #endif /* ATH12K_ACPI_H */ > diff --git a/drivers/net/wireless/ath/ath12k/core.c b/drivers/net/wireless/ath/ath12k/core.c > index 51252e8bc1ae..bda7d40075c4 100644 > --- a/drivers/net/wireless/ath/ath12k/core.c > +++ b/drivers/net/wireless/ath/ath12k/core.c > @@ -30,6 +30,9 @@ static int ath12k_core_rfkill_config(struct ath12k_base *ab) > if (!(ab->target_caps.sys_cap_info & WMI_SYS_CAP_INFO_RFKILL)) > return 0; > > + if (ath12k_acpi_get_disable_rfkill(ab)) > + return 0; As noted previously IMO this is much better if (ath12k_acpi_rfkill_disabled(ab)) > + > for (i = 0; i < ab->num_radios; i++) { > ar = ab->pdevs[i].ar; > > diff --git a/drivers/net/wireless/ath/ath12k/core.h b/drivers/net/wireless/ath/ath12k/core.h > index cdfd43a7321a..cac6647f2776 100644 > --- a/drivers/net/wireless/ath/ath12k/core.h > +++ b/drivers/net/wireless/ath/ath12k/core.h > @@ -940,6 +940,9 @@ struct ath12k_base { > u32 func_bit; > bool acpi_tas_enable; > bool acpi_bios_sar_enable; > + bool acpi_disable_11be; > + bool acpi_disable_rfkill; > + u32 bit_flag; > u8 tas_cfg[ATH12K_ACPI_DSM_TAS_CFG_SIZE]; > u8 tas_sar_power_table[ATH12K_ACPI_DSM_TAS_DATA_SIZE]; > u8 bios_sar_data[ATH12K_ACPI_DSM_BIOS_SAR_DATA_SIZE]; > diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c > index a3248d977532..4be88834e62b 100644 > --- a/drivers/net/wireless/ath/ath12k/mac.c > +++ b/drivers/net/wireless/ath/ath12k/mac.c > @@ -5483,7 +5483,8 @@ static void ath12k_mac_copy_eht_cap(struct ath12k *ar, > > memset(eht_cap, 0, sizeof(struct ieee80211_sta_eht_cap)); > > - if (!(test_bit(WMI_TLV_SERVICE_11BE, ar->ab->wmi_ab.svc_map))) > + if (!(test_bit(WMI_TLV_SERVICE_11BE, ar->ab->wmi_ab.svc_map)) || > + ath12k_acpi_get_disable_11be(ar->ab)) ath12k_acpi_11be_disabled() > return; > > eht_cap->has_eht = true;
diff --git a/drivers/net/wireless/ath/ath12k/acpi.c b/drivers/net/wireless/ath/ath12k/acpi.c index d83f7e58fb7a..a3f3d0712722 100644 --- a/drivers/net/wireless/ath/ath12k/acpi.c +++ b/drivers/net/wireless/ath/ath12k/acpi.c @@ -29,7 +29,14 @@ static int ath12k_acpi_dsm_get_data(struct ath12k_base *ab, int func) } if (obj->type == ACPI_TYPE_INTEGER) { - ab->acpi.func_bit = obj->integer.value; + switch (func) { + case ATH12K_ACPI_DSM_FUNC_SUPPORT_FUNCS: + ab->acpi.func_bit = obj->integer.value; + break; + case ATH12K_ACPI_DSM_FUNC_DISABLE_FLAG: + ab->acpi.bit_flag = obj->integer.value; + break; + } } else if (obj->type == ACPI_TYPE_BUFFER) { switch (func) { case ATH12K_ACPI_DSM_FUNC_SUPPORT_FUNCS: @@ -261,24 +268,52 @@ static int ath12k_acpi_set_tas_params(struct ath12k_base *ab) return 0; } +bool ath12k_acpi_get_disable_rfkill(struct ath12k_base *ab) +{ + return ab->acpi.acpi_disable_rfkill; +} + +bool ath12k_acpi_get_disable_11be(struct ath12k_base *ab) +{ + return ab->acpi.acpi_disable_11be; +} + int ath12k_acpi_start(struct ath12k_base *ab) { acpi_status status; u8 *buf; int ret; + ab->acpi.acpi_tas_enable = false; + ab->acpi.acpi_disable_11be = false; + ab->acpi.acpi_disable_rfkill = false; + if (!ab->hw_params->acpi_guid) /* not supported with this hardware */ return 0; - ab->acpi.acpi_tas_enable = false; - ret = ath12k_acpi_dsm_get_data(ab, ATH12K_ACPI_DSM_FUNC_SUPPORT_FUNCS); if (ret) { ath12k_dbg(ab, ATH12K_DBG_BOOT, "failed to get ACPI DSM data: %d\n", ret); return ret; } + if (ATH12K_ACPI_FUNC_BIT_VALID(ab->acpi, ATH12K_ACPI_FUNC_BIT_DISABLE_FLAG)) { + ret = ath12k_acpi_dsm_get_data(ab, ATH12K_ACPI_DSM_FUNC_DISABLE_FLAG); + if (ret) { + ath12k_warn(ab, "failed to get ACPI DISABLE FLAG: %d\n", ret); + return ret; + } + + if (ATH12K_ACPI_CHEK_BIT_VALID(ab->acpi, + ATH12K_ACPI_DSM_DISABLE_11BE_BIT)) + ab->acpi.acpi_disable_11be = true; + + if (!ATH12K_ACPI_CHEK_BIT_VALID(ab->acpi, + ATH12K_ACPI_DSM_DISABLE_RFKILL_BIT)) + ab->acpi.acpi_disable_rfkill = true; + } + if (ATH12K_ACPI_FUNC_BIT_VALID(ab->acpi, ATH12K_ACPI_FUNC_BIT_TAS_CFG)) { ret = ath12k_acpi_dsm_get_data(ab, ATH12K_ACPI_DSM_FUNC_TAS_CFG); if (ret) { diff --git a/drivers/net/wireless/ath/ath12k/acpi.h b/drivers/net/wireless/ath/ath12k/acpi.h index 7ec7a2e72e40..4b154cfdbd39 100644 --- a/drivers/net/wireless/ath/ath12k/acpi.h +++ b/drivers/net/wireless/ath/ath12k/acpi.h @@ -9,6 +9,7 @@ #include <linux/acpi.h> #define ATH12K_ACPI_DSM_FUNC_SUPPORT_FUNCS 0 +#define ATH12K_ACPI_DSM_FUNC_DISABLE_FLAG 2 #define ATH12K_ACPI_DSM_FUNC_BIOS_SAR 4 #define ATH12K_ACPI_DSM_FUNC_GEO_OFFSET 5 #define ATH12K_ACPI_DSM_FUNC_INDEX_CCA 6 @@ -16,6 +17,7 @@ #define ATH12K_ACPI_DSM_FUNC_TAS_DATA 9 #define ATH12K_ACPI_DSM_FUNC_INDEX_BAND_EDGE 10 +#define ATH12K_ACPI_FUNC_BIT_DISABLE_FLAG BIT(1) #define ATH12K_ACPI_FUNC_BIT_BIOS_SAR BIT(3) #define ATH12K_ACPI_FUNC_BIT_GEO_OFFSET BIT(4) #define ATH12K_ACPI_FUNC_BIT_CCA BIT(5) @@ -25,6 +27,7 @@ #define ATH12K_ACPI_NOTIFY_EVENT 0x86 #define ATH12K_ACPI_FUNC_BIT_VALID(_acdata, _func) (((_acdata).func_bit) & (_func)) +#define ATH12K_ACPI_CHEK_BIT_VALID(_acdata, _func) (((_acdata).bit_flag) & (_func)) #define ATH12K_ACPI_TAS_DATA_VERSION 0x1 #define ATH12K_ACPI_TAS_DATA_ENABLE 0x1 @@ -51,6 +54,9 @@ #define ATH12K_ACPI_DSM_FUNC_MIN_BITMAP_SIZE 1 #define ATH12K_ACPI_DSM_FUNC_MAX_BITMAP_SIZE 4 +#define ATH12K_ACPI_DSM_DISABLE_11BE_BIT BIT(0) +#define ATH12K_ACPI_DSM_DISABLE_RFKILL_BIT BIT(2) + #define ATH12K_ACPI_DSM_GEO_OFFSET_DATA_SIZE (ATH12K_ACPI_GEO_OFFSET_DATA_OFFSET + \ ATH12K_ACPI_BIOS_SAR_GEO_OFFSET_LEN) #define ATH12K_ACPI_DSM_BIOS_SAR_DATA_SIZE (ATH12K_ACPI_POWER_LIMIT_DATA_OFFSET + \ @@ -62,6 +68,8 @@ int ath12k_acpi_start(struct ath12k_base *ab); void ath12k_acpi_stop(struct ath12k_base *ab); +bool ath12k_acpi_get_disable_rfkill(struct ath12k_base *ab); +bool ath12k_acpi_get_disable_11be(struct ath12k_base *ab); #else @@ -74,6 +82,16 @@ static inline void ath12k_acpi_stop(struct ath12k_base *ab) { } +static inline bool ath12k_acpi_get_disable_rfkill(struct ath12k_base *ab) +{ + return false; +} + +static inline bool ath12k_acpi_get_disable_11be(struct ath12k_base *ab) +{ + return false; +} + #endif /* CONFIG_ACPI */ #endif /* ATH12K_ACPI_H */ diff --git a/drivers/net/wireless/ath/ath12k/core.c b/drivers/net/wireless/ath/ath12k/core.c index 51252e8bc1ae..bda7d40075c4 100644 --- a/drivers/net/wireless/ath/ath12k/core.c +++ b/drivers/net/wireless/ath/ath12k/core.c @@ -30,6 +30,9 @@ static int ath12k_core_rfkill_config(struct ath12k_base *ab) if (!(ab->target_caps.sys_cap_info & WMI_SYS_CAP_INFO_RFKILL)) return 0; + if (ath12k_acpi_get_disable_rfkill(ab)) + return 0; + for (i = 0; i < ab->num_radios; i++) { ar = ab->pdevs[i].ar; diff --git a/drivers/net/wireless/ath/ath12k/core.h b/drivers/net/wireless/ath/ath12k/core.h index cdfd43a7321a..cac6647f2776 100644 --- a/drivers/net/wireless/ath/ath12k/core.h +++ b/drivers/net/wireless/ath/ath12k/core.h @@ -940,6 +940,9 @@ struct ath12k_base { u32 func_bit; bool acpi_tas_enable; bool acpi_bios_sar_enable; + bool acpi_disable_11be; + bool acpi_disable_rfkill; + u32 bit_flag; u8 tas_cfg[ATH12K_ACPI_DSM_TAS_CFG_SIZE]; u8 tas_sar_power_table[ATH12K_ACPI_DSM_TAS_DATA_SIZE]; u8 bios_sar_data[ATH12K_ACPI_DSM_BIOS_SAR_DATA_SIZE]; diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c index a3248d977532..4be88834e62b 100644 --- a/drivers/net/wireless/ath/ath12k/mac.c +++ b/drivers/net/wireless/ath/ath12k/mac.c @@ -5483,7 +5483,8 @@ static void ath12k_mac_copy_eht_cap(struct ath12k *ar, memset(eht_cap, 0, sizeof(struct ieee80211_sta_eht_cap)); - if (!(test_bit(WMI_TLV_SERVICE_11BE, ar->ab->wmi_ab.svc_map))) + if (!(test_bit(WMI_TLV_SERVICE_11BE, ar->ab->wmi_ab.svc_map)) || + ath12k_acpi_get_disable_11be(ar->ab)) return; eht_cap->has_eht = true;
Currently, ath12k does not support enable or disable specific features by ACPI bitflag. To address this issue, obtain the ACPI bitflag value and use it to selectively enable or disable specific features. This patch will not affect QCN9274, because only WCN7850 supports ACPI. Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3 Signed-off-by: Lingbo Kong <quic_lingbok@quicinc.com> --- v2: 1.support functions for cases where CONFIG_ACPI is disabled drivers/net/wireless/ath/ath12k/acpi.c | 41 ++++++++++++++++++++++++-- drivers/net/wireless/ath/ath12k/acpi.h | 18 +++++++++++ drivers/net/wireless/ath/ath12k/core.c | 3 ++ drivers/net/wireless/ath/ath12k/core.h | 3 ++ drivers/net/wireless/ath/ath12k/mac.c | 3 +- 5 files changed, 64 insertions(+), 4 deletions(-)