wifi: ath12k: ACPI support
v8 cover wifi: ath12k: ACPI support
From: Kalle Valo <[email protected]>
Through reading ACPI tables, implement Time-Average-SAR(TAS), BIOS SAR, configuration of CCA threshold and band edge channel power functionalities. This is enabled only on WCN7850.
TODO:
* test with ACPI support in hardware (I don't have such hardware), especially suspend and hibernation
v8:
* rebase to ath-202404181528
* rewrite commit messages
* cleanup and improvements all over to match the ath12k style, including
error handling, naming and so on
* locate new place to call ath12k_acpi_[start|stop]()
* move wmi functions up in wmi.c file
* consolidate WMI functions using WMI_PDEV_SET_BIOS_INTERFACE_CMDID into ath12k_wmi_set_bios_cmd()
* ath12k_acpi_stop(): don't call acpi_remove_notify_handler() if we never installed the handler
v7: https://patchwork.kernel.org/project/linux-wireless/cover/[email protected]/
* adjust the length of line
* add cpu_to_le32()
v6:
* remove code that is not called
v5:
* rebase to the latest tag
v4:
* revise commit log using imperative voice
* delete guid_is_null()
v3:
* remove unnecessary cpu_to_le32()
* adjust the order of the macros
* apply jeff's advice
v2:
* put <linux/acpi.h> in the include guard
Lingbo Kong (4):
wifi: ath12k: ACPI TAS support
wifi: ath12k: ACPI SAR support
wifi: ath12k: ACPI CCA threshold support
wifi: ath12k: ACPI band edge channel power support
drivers/net/wireless/ath/ath12k/Makefile | 1 + drivers/net/wireless/ath/ath12k/acpi.c | 394 +++++++++++++++++++++++ drivers/net/wireless/ath/ath12k/acpi.h | 76 +++++ drivers/net/wireless/ath/ath12k/core.c | 7 + drivers/net/wireless/ath/ath12k/core.h | 18 ++ drivers/net/wireless/ath/ath12k/hw.c | 10 + drivers/net/wireless/ath/ath12k/hw.h | 3 + drivers/net/wireless/ath/ath12k/wmi.c | 143 ++++++++ drivers/net/wireless/ath/ath12k/wmi.h | 41 +++ 9 files changed, 693 insertions(+) create mode 100644 drivers/net/wireless/ath/ath12k/acpi.c create mode 100644 drivers/net/wireless/ath/ath12k/acpi.h
base-commit: c416602943dd36fbd13af7496430723935c867a3
Signature · 1 line
2.39.2
PATCH v8 1/4 wifi: ath12k: ACPI TAS support
From: Lingbo Kong <[email protected]>
Currently, ath12k does not support Time-Average-SAR (TAS). In order to enable TAS read the tables from ACPI and send them to the firmware using WMI_PDEV_SET_BIOS_INTERFACE_CMDID command. Besides, ath12k registers an ACPI event callback so that ACPI can notify ath12k to get the updated SAR power table and sends it to the firmware when the device state is changed.
ACPI is only enabled for WCN7850 using struct ath12k_hw_params::acpi_guid field. Most likely QCN9274 will never support ACPI as the chip is not used in laptops.
Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0-03427-QCAHMTSWPL_V1.0_V2.0_SILICONZ-1.15378.4
--- drivers/net/wireless/ath/ath12k/Makefile | 1 + drivers/net/wireless/ath/ath12k/acpi.c | 216 +++++++++++++++++++++++ drivers/net/wireless/ath/ath12k/acpi.h | 45 +++++ drivers/net/wireless/ath/ath12k/core.c | 7 + drivers/net/wireless/ath/ath12k/core.h | 13 ++ drivers/net/wireless/ath/ath12k/hw.c | 10 ++ drivers/net/wireless/ath/ath12k/hw.h | 3 + drivers/net/wireless/ath/ath12k/wmi.c | 44 +++++ drivers/net/wireless/ath/ath12k/wmi.h | 17 ++ 9 files changed, 356 insertions(+) create mode 100644 drivers/net/wireless/ath/ath12k/acpi.c create mode 100644 drivers/net/wireless/ath/ath12k/acpi.h
drivers/net/wireless/ath/ath12k/Makefile +1 -0
@@ -24,6 +24,7 @@ ath12k-y += core.o \ p2p.o ath12k-$(CONFIG_ATH12K_DEBUGFS) += debugfs.o +ath12k-$(CONFIG_ACPI) += acpi.o ath12k-$(CONFIG_ATH12K_TRACING) += trace.o # for tracing framework to find trace.h
drivers/net/wireless/ath/ath12k/acpi.c new file +216 -0
216 lines not on this page · raw message
drivers/net/wireless/ath/ath12k/acpi.h new file +45 -0
45 lines not on this page · raw message
drivers/net/wireless/ath/ath12k/core.c +7 -0
@@ -543,6 +543,8 @@ static void ath12k_core_stop(struct ath12k_base *ab)if (!test_bit (ATH12K_FLAG_CRASH_FLUSH , &ab->dev_flags))ath12k_qmi_firmware_stop (ab); +ath12k_acpi_stop (ab); +ath12k_hif_stop (ab);ath12k_wmi_detach (ab);ath12k_dp_rx_pdev_reo_cleanup (ab);
@@ -784,6 +786,11 @@ static int ath12k_core_start(struct ath12k_base *ab, goto err_reo_cleanup; } + ret =ath12k_acpi_start (ab); +if (ret) +/* ACPI is optional so continue in case of an error */ +ath12k_dbg (ab,ATH12K_DBG_BOOT ,"acpi failed: %d\n" , ret); +return 0 ; err_reo_cleanup:
drivers/net/wireless/ath/ath12k/core.h +13 -0
@@ -26,6 +26,7 @@#include "reg.h" #include "dbring.h" #include "fw.h" +#include "acpi.h" #define SM (_v, _f) (((_v) << _f##_LSB) & _f##_MASK)
@@ -901,6 +902,18 @@ struct ath12k_base {*/ u8 mlo_capable_flags; +#ifdef CONFIG_ACPI + +struct { +bool started; +u32 func_bit; +bool acpi_tas_enable; +u8 tas_cfg[ATH12K_ACPI_DSM_TAS_CFG_SIZE ]; +u8 tas_sar_power_table[ATH12K_ACPI_DSM_TAS_DATA_SIZE ]; + } acpi; + +#endif /* CONFIG_ACPI */ +/* must be last */ u8 drv_priv[]__aligned(sizeof(void *)) ; };
drivers/net/wireless/ath/ath12k/hw.c +10 -0
@@ -15,6 +15,10 @@#include "mhi.h" #include "dp_rx.h" +static const guid_t wcn7850_uuid =GUID_INIT (0xf634f534 ,0x6147 ,0x11ec , +0x90 ,0xd6 ,0x02 ,0x42 , +0xac ,0x12 ,0x00 ,0x03 ); +static u8 ath12k_hw_qcn9274_mac_from_pdev_id (int pdev_idx) {return pdev_idx;
@@ -920,6 +924,8 @@ static const struct ath12k_hw_params ath12k_hw_params[] = { .otp_board_id_register = QCN9274_QFPROM_RAW_RFA_PDET_ROW13_LSB, .supports_sta_ps = false, + + .acpi_guid = NULL, }, { .name = "wcn7850 hw2.0",
@@ -993,6 +999,8 @@ static const struct ath12k_hw_params ath12k_hw_params[] = { .otp_board_id_register = 0, .supports_sta_ps = true, + + .acpi_guid = &wcn7850_uuid, }, { .name = "qcn9274 hw2.0",
@@ -1061,6 +1069,8 @@ static const struct ath12k_hw_params ath12k_hw_params[] = { .otp_board_id_register = QCN9274_QFPROM_RAW_RFA_PDET_ROW13_LSB, .supports_sta_ps = false, + + .acpi_guid = NULL, }, };
drivers/net/wireless/ath/ath12k/hw.h +3 -0
@@ -8,6 +8,7 @@#define ATH12K_HW_H #include <linux/mhi.h> +#include <linux/uuid.h> #include "wmi.h" #include "hal.h"
@@ -212,6 +213,8 @@ struct ath12k_hw_params {u32 otp_board_id_register;bool supports_sta_ps; + +const guid_t *acpi_guid; };struct ath12k_hw_ops {
drivers/net/wireless/ath/ath12k/wmi.c +44 -0
50 lines not on this page · raw message
drivers/net/wireless/ath/ath12k/wmi.h +17 -0
@@ -353,6 +353,7 @@ enum wmi_tlv_cmd_id {WMI_PDEV_DMA_RING_CFG_REQ_CMDID ,WMI_PDEV_HE_TB_ACTION_FRM_CMDID ,WMI_PDEV_PKTLOG_FILTER_CMDID , +WMI_PDEV_SET_BIOS_INTERFACE_CMDID =0x404A ,WMI_VDEV_CREATE_CMDID =WMI_TLV_CMD (WMI_GRP_VDEV ),WMI_VDEV_DELETE_CMDID , WMI_VDEV_START_REQUEST_CMDID,
@@ -1925,6 +1926,7 @@ enum wmi_tlv_tag {WMI_TAG_REGULATORY_RULE_EXT_STRUCT =0x3A9 ,WMI_TAG_REG_CHAN_LIST_CC_EXT_EVENT ,WMI_TAG_EHT_RATE_SET =0x3C4 , +WMI_TAG_PDEV_SET_BIOS_INTERFACE_CMD =0x3FB , WMI_TAG_MAX };
@@ -4791,6 +4793,19 @@ struct ath12k_wmi_base {struct ath12k_wmi_target_cap_arg *targ_cap; }; +struct wmi_pdev_set_bios_interface_cmd { +__le32 tlv_header; +__le32 pdev_id; +__le32 param_type_id; +__le32 length; +} __packed; + +enum wmi_bios_param_type { +WMI_BIOS_PARAM_TAS_CONFIG_TYPE =1 , +WMI_BIOS_PARAM_TAS_DATA_TYPE =2 , +WMI_BIOS_PARAM_TYPE_MAX , +}; +#define ATH12K_FW_STATS_BUF_SIZE (1024 * 1024)enum wmi_sys_cap_info_flags {
@@ -4949,6 +4964,8 @@ int ath12k_wmi_probe_resp_tmpl(struct ath12k *ar, u32 vdev_id, struct sk_buff *tmpl);int ath12k_wmi_set_hw_mode (struct ath12k_base *ab,enum wmi_host_hw_mode_config_type mode); +int ath12k_wmi_set_bios_cmd (struct ath12k_base *ab,u32 param_id, +const u8 *buf,size_t buf_len);static inline u32 ath12k_wmi_caps_ext_get_pdev_id (const struct ath12k_wmi_caps_ext_params *param)
Signature · 1 line
2.39.2
Re: [PATCH v8 1/4] wifi: ath12k: ACPI TAS support
Quoted 16 lines · Kalle Valo
From: Lingbo Kong <[email protected]>
Currently, ath12k does not support Time-Average-SAR (TAS). In order to enable TAS read the tables from ACPI and send them to the firmware using
WMI_PDEV_SET_BIOS_INTERFACE_CMDIDcommand. Besides, ath12k registers an ACPI event callback so that ACPI can notify ath12k to get the updated SAR power table and sends it to the firmware when the device state is changed.ACPI is only enabled for WCN7850 using struct
ath12k_hw_params::acpi_guidfield. Most likely QCN9274 will never support ACPI as the chip is not used in laptops.Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0-03427-QCAHMTSWPL_V1.0_V2.0_SILICONZ-1.15378.4
Signed-off-by Lingbo Kong <[email protected]>Signed-off-by Kalle Valo <[email protected]>
Quoted 13 lines
--- drivers/net/wireless/ath/ath12k/Makefile | 1 + drivers/net/wireless/ath/ath12k/acpi.c | 216 +++++++++++++++++++++++ drivers/net/wireless/ath/ath12k/acpi.h | 45 +++++ drivers/net/wireless/ath/ath12k/core.c | 7 + drivers/net/wireless/ath/ath12k/core.h | 13 ++ drivers/net/wireless/ath/ath12k/hw.c | 10 ++ drivers/net/wireless/ath/ath12k/hw.h | 3 + drivers/net/wireless/ath/ath12k/wmi.c | 44 +++++ drivers/net/wireless/ath/ath12k/wmi.h | 17 ++ 9 files changed, 356 insertions(+) create mode 100644 drivers/net/wireless/ath/ath12k/acpi.c create mode 100644 drivers/net/wireless/ath/ath12k/acpi.h
Pending update of the copyright on these two new files,
PATCH v8 2/4 wifi: ath12k: ACPI SAR support
In reply to Kalle ValoFrom: Lingbo Kong <[email protected]>
In order to enable ACPI SAR (Specific Absorption Rate), ath12k gets SAR and GEO offset tables from ACPI and sends the data to firmware using WMI_PDEV_SET_BIOS_SAR_TABLE_CMDID and WMI_PDEV_SET_BIOS_GEO_TABLE_CMDID commands.
Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0-03427-QCAHMTSWPL_V1.0_V2.0_SILICONZ-1.15378.4
--- drivers/net/wireless/ath/ath12k/acpi.c | 105 +++++++++++++++++++++++++ drivers/net/wireless/ath/ath12k/acpi.h | 18 +++++ drivers/net/wireless/ath/ath12k/core.h | 3 + drivers/net/wireless/ath/ath12k/wmi.c | 99 +++++++++++++++++++++++ drivers/net/wireless/ath/ath12k/wmi.h | 19 +++++ 5 files changed, 244 insertions(+)
drivers/net/wireless/ath/ath12k/acpi.c +105 -0
@@ -55,6 +55,30 @@ static int ath12k_acpi_dsm_get_data(struct ath12k_base *ab, int func)memcpy (&ab->acpi.tas_sar_power_table, obj->buffer.pointer, obj->buffer.length); +break ; +case ATH12K_ACPI_DSM_FUNC_BIOS_SAR : +if (obj->buffer.length !=ATH12K_ACPI_DSM_BIOS_SAR_DATA_SIZE ) { +ath12k_warn (ab,"invalid ACPI BIOS SAR data size: %d\n" , + obj->buffer.length); + ret = -EINVAL ; + goto out; + } + +memcpy (&ab->acpi.bios_sar_data, obj->buffer.pointer, + obj->buffer.length); + +break ; +case ATH12K_ACPI_DSM_FUNC_GEO_OFFSET : +if (obj->buffer.length !=ATH12K_ACPI_DSM_GEO_OFFSET_DATA_SIZE ) { +ath12k_warn (ab,"invalid ACPI GEO OFFSET data size: %d\n" , + obj->buffer.length); + ret = -EINVAL ; + goto out; + } + +memcpy (&ab->acpi.geo_offset_data, obj->buffer.pointer, + obj->buffer.length); +break ; } }else {
@@ -93,6 +117,25 @@ static int ath12k_acpi_set_power_limit(struct ath12k_base *ab)return ret; } +static int ath12k_acpi_set_bios_sar_power (struct ath12k_base *ab) +{ +int ret; + +if (ab->acpi.bios_sar_data[0 ] !=ATH12K_ACPI_POWER_LIMIT_VERSION || + ab->acpi.bios_sar_data[1 ] !=ATH12K_ACPI_POWER_LIMIT_ENABLE_FLAG ) { +ath12k_warn (ab,"invalid latest ACPI BIOS SAR data\n" ); +return -EINVAL ; + } + + ret =ath12k_wmi_set_bios_sar_cmd (ab, ab->acpi.bios_sar_data); +if (ret) { +ath12k_warn (ab,"failed to set ACPI BIOS SAR table: %d\n" , ret); +return ret; + } + +return 0 ; +} +static void ath12k_acpi_dsm_notify (acpi_handle handle,u32 event,void *data) {int ret;
@@ -119,6 +162,40 @@ static void ath12k_acpi_dsm_notify(acpi_handle handle, u32 event, void *data)ath12k_warn (ab,"failed to set ACPI TAS power limit data: %d" , ret);return ; } + +if (!ab->acpi.acpi_bios_sar_enable) +return ; + + ret =ath12k_acpi_dsm_get_data (ab,ATH12K_ACPI_DSM_FUNC_BIOS_SAR ); +if (ret) { +ath12k_warn (ab,"failed to update BIOS SAR: %d\n" , ret); +return ; + } + + ret =ath12k_acpi_set_bios_sar_power (ab); +if (ret) { +ath12k_warn (ab,"failed to set BIOS SAR power limit: %d\n" , ret); +return ; + } +} + +static int ath12k_acpi_set_bios_sar_params (struct ath12k_base *ab) +{ +int ret; + + ret =ath12k_wmi_set_bios_sar_cmd (ab, ab->acpi.bios_sar_data); +if (ret) { +ath12k_warn (ab,"failed to set ACPI BIOS SAR table: %d\n" , ret); +return ret; + } + + ret =ath12k_wmi_set_bios_geo_cmd (ab, ab->acpi.geo_offset_data); +if (ret) { +ath12k_warn (ab,"failed to set ACPI BIOS GEO table: %d\n" , ret); +return ret; + } + +return 0 ; }static int ath12k_acpi_set_tas_params (struct ath12k_base *ab)
@@ -184,6 +261,28 @@ int ath12k_acpi_start(struct ath12k_base *ab) ab->acpi.acpi_tas_enable = true; } +if (ATH12K_ACPI_FUNC_BIT_VALID (ab->acpi,ATH12K_ACPI_FUNC_BIT_BIOS_SAR )) { + ret =ath12k_acpi_dsm_get_data (ab,ATH12K_ACPI_DSM_FUNC_BIOS_SAR ); +if (ret) { +ath12k_warn (ab,"failed to get ACPI bios sar data: %d\n" , ret); +return ret; + } + } + +if (ATH12K_ACPI_FUNC_BIT_VALID (ab->acpi,ATH12K_ACPI_FUNC_BIT_GEO_OFFSET )) { + ret =ath12k_acpi_dsm_get_data (ab,ATH12K_ACPI_DSM_FUNC_GEO_OFFSET ); +if (ret) { +ath12k_warn (ab,"failed to get ACPI geo offset data: %d\n" , ret); +return ret; + } + +if (ATH12K_ACPI_FUNC_BIT_VALID (ab->acpi,ATH12K_ACPI_FUNC_BIT_BIOS_SAR ) && + ab->acpi.bios_sar_data[0 ] ==ATH12K_ACPI_POWER_LIMIT_VERSION && + ab->acpi.bios_sar_data[1 ] ==ATH12K_ACPI_POWER_LIMIT_ENABLE_FLAG && + !ab->acpi.acpi_tas_enable) + ab->acpi.acpi_bios_sar_enable = true; + } +if (ab->acpi.acpi_tas_enable) { ret =ath12k_acpi_set_tas_params (ab);if (ret) {
@@ -192,6 +291,12 @@ int ath12k_acpi_start(struct ath12k_base *ab) } } +if (ab->acpi.acpi_bios_sar_enable) { + ret =ath12k_acpi_set_bios_sar_params (ab); +if (ret) +return ret; + } + status =acpi_install_notify_handler (ACPI_HANDLE (ab->dev),ACPI_DEVICE_NOTIFY , ath12k_acpi_dsm_notify, ab);
drivers/net/wireless/ath/ath12k/acpi.h +18 -0
@@ -9,9 +9,13 @@#include <linux/acpi.h> #define ATH12K_ACPI_DSM_FUNC_SUPPORT_FUNCS 0 +#define ATH12K_ACPI_DSM_FUNC_BIOS_SAR 4 +#define ATH12K_ACPI_DSM_FUNC_GEO_OFFSET 5#define ATH12K_ACPI_DSM_FUNC_TAS_CFG 8#define ATH12K_ACPI_DSM_FUNC_TAS_DATA 9 +#define ATH12K_ACPI_FUNC_BIT_BIOS_SAR BIT(3) +#define ATH12K_ACPI_FUNC_BIT_GEO_OFFSET BIT(4)#define ATH12K_ACPI_FUNC_BIT_TAS_CFG BIT(7)#define ATH12K_ACPI_FUNC_BIT_TAS_DATA BIT(8)
@@ -20,10 +24,24 @@#define ATH12K_ACPI_TAS_DATA_VERSION 0x1#define ATH12K_ACPI_TAS_DATA_ENABLE 0x1 +#define ATH12K_ACPI_POWER_LIMIT_VERSION 0x1 +#define ATH12K_ACPI_POWER_LIMIT_ENABLE_FLAG 0x1 + +#define ATH12K_ACPI_GEO_OFFSET_DATA_OFFSET 1 +#define ATH12K_ACPI_DBS_BACKOFF_DATA_OFFSET 2 +#define ATH12K_ACPI_BIOS_SAR_DBS_BACKOFF_LEN 10 +#define ATH12K_ACPI_POWER_LIMIT_DATA_OFFSET 12 +#define ATH12K_ACPI_BIOS_SAR_GEO_OFFSET_LEN 18 +#define ATH12K_ACPI_BIOS_SAR_TABLE_LEN 22#define ATH12K_ACPI_DSM_TAS_DATA_SIZE 69#define ATH12K_ACPI_DSM_TAS_CFG_SIZE 108 +#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 + \ + ATH12K_ACPI_BIOS_SAR_TABLE_LEN) +#ifdef CONFIG_ACPI int ath12k_acpi_start (struct ath12k_base *ab);
drivers/net/wireless/ath/ath12k/core.h +3 -0
@@ -908,8 +908,11 @@ struct ath12k_base {bool started;u32 func_bit;bool acpi_tas_enable; +bool acpi_bios_sar_enable;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 ]; + u8 geo_offset_data[ATH12K_ACPI_DSM_GEO_OFFSET_DATA_SIZE]; } acpi;#endif /* CONFIG_ACPI */
drivers/net/wireless/ath/ath12k/wmi.c +99 -0
105 lines not on this page · raw message
drivers/net/wireless/ath/ath12k/wmi.h +19 -0
@@ -353,6 +353,8 @@ enum wmi_tlv_cmd_id {WMI_PDEV_DMA_RING_CFG_REQ_CMDID ,WMI_PDEV_HE_TB_ACTION_FRM_CMDID ,WMI_PDEV_PKTLOG_FILTER_CMDID , +WMI_PDEV_SET_BIOS_SAR_TABLE_CMDID =0x4044 , +WMI_PDEV_SET_BIOS_GEO_TABLE_CMDID =0x4045 ,WMI_PDEV_SET_BIOS_INTERFACE_CMDID =0x404A ,WMI_VDEV_CREATE_CMDID =WMI_TLV_CMD (WMI_GRP_VDEV ), WMI_VDEV_DELETE_CMDID,
@@ -1926,6 +1928,8 @@ enum wmi_tlv_tag {WMI_TAG_REGULATORY_RULE_EXT_STRUCT =0x3A9 ,WMI_TAG_REG_CHAN_LIST_CC_EXT_EVENT ,WMI_TAG_EHT_RATE_SET =0x3C4 , +WMI_TAG_PDEV_SET_BIOS_SAR_TABLE_CMD =0x3D8 , +WMI_TAG_PDEV_SET_BIOS_GEO_TABLE_CMD =0x3D9 ,WMI_TAG_PDEV_SET_BIOS_INTERFACE_CMD =0x3FB , WMI_TAG_MAX };
@@ -4806,6 +4810,19 @@ enum wmi_bios_param_type { WMI_BIOS_PARAM_TYPE_MAX, }; +struct wmi_pdev_set_bios_sar_table_cmd { +__le32 tlv_header; +__le32 pdev_id; +__le32 sar_len; +__le32 dbs_backoff_len; +} __packed; + +struct wmi_pdev_set_bios_geo_table_cmd { +__le32 tlv_header; +__le32 pdev_id; +__le32 geo_len; +} __packed; +#define ATH12K_FW_STATS_BUF_SIZE (1024 * 1024)enum wmi_sys_cap_info_flags {
@@ -4966,6 +4983,8 @@ int ath12k_wmi_set_hw_mode(struct ath12k_base *ab, enum wmi_host_hw_mode_config_type mode);int ath12k_wmi_set_bios_cmd (struct ath12k_base *ab,u32 param_id,const u8 *buf,size_t buf_len); +int ath12k_wmi_set_bios_sar_cmd (struct ath12k_base *ab,const u8 *psar_table); +int ath12k_wmi_set_bios_geo_cmd (struct ath12k_base *ab,const u8 *pgeo_table);static inline u32 ath12k_wmi_caps_ext_get_pdev_id (const struct ath12k_wmi_caps_ext_params *param)
Signature · 1 line
2.39.2
Re: [PATCH v8 2/4] wifi: ath12k: ACPI SAR support
Quoted 11 lines · Kalle Valo
From: Lingbo Kong <[email protected]>
In order to enable ACPI SAR (Specific Absorption Rate), ath12k gets SAR and GEO offset tables from ACPI and sends the data to firmware using
WMI_PDEV_SET_BIOS_SAR_TABLE_CMDIDandWMI_PDEV_SET_BIOS_GEO_TABLE_CMDIDcommands.Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0-03427-QCAHMTSWPL_V1.0_V2.0_SILICONZ-1.15378.4
Signed-off-by Lingbo Kong <[email protected]>Signed-off-by Kalle Valo <[email protected]>
PATCH v8 3/4 wifi: ath12k: ACPI CCA threshold support
In reply to Kalle ValoFrom: Lingbo Kong <[email protected]>
Currently, ath12k does not have the ability to adjust Clear Channel Assessment (CCA) threshold values to meet the regulatory requirements. Get the values from ACPI and send them to the firmware using ath12k_wmi_set_bios_cmd() function.
Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0-03427-QCAHMTSWPL_V1.0_V2.0_SILICONZ-1.15378.4
--- drivers/net/wireless/ath/ath12k/acpi.c | 37 ++++++++++++++++++++++++++ drivers/net/wireless/ath/ath12k/acpi.h | 8 ++++++ drivers/net/wireless/ath/ath12k/core.h | 1 + drivers/net/wireless/ath/ath12k/wmi.h | 1 + 4 files changed, 47 insertions(+)
drivers/net/wireless/ath/ath12k/acpi.c +37 -0
@@ -79,6 +79,18 @@ static int ath12k_acpi_dsm_get_data(struct ath12k_base *ab, int func)memcpy (&ab->acpi.geo_offset_data, obj->buffer.pointer, obj->buffer.length); +break ; +case ATH12K_ACPI_DSM_FUNC_INDEX_CCA : +if (obj->buffer.length !=ATH12K_ACPI_DSM_CCA_DATA_SIZE ) { +ath12k_warn (ab,"invalid ACPI DSM CCA data size: %d\n" , + obj->buffer.length); + ret = -EINVAL ; + goto out; + } + +memcpy (&ab->acpi.cca_data, obj->buffer.pointer, + obj->buffer.length); +break ; } }else {
@@ -226,6 +238,7 @@ static int ath12k_acpi_set_tas_params(struct ath12k_base *ab)int ath12k_acpi_start (struct ath12k_base *ab) {acpi_status status; +u8 *buf;int ret;if (!ab->hw_params->acpi_guid)
@@ -297,6 +310,30 @@ int ath12k_acpi_start(struct ath12k_base *ab)return ret; } +if (ATH12K_ACPI_FUNC_BIT_VALID (ab->acpi,ATH12K_ACPI_FUNC_BIT_CCA )) { + ret =ath12k_acpi_dsm_get_data (ab,ATH12K_ACPI_DSM_FUNC_INDEX_CCA ); +if (ret) { +ath12k_warn (ab,"failed to get ACPI DSM CCA threshold configuration: %d\n" , + ret); +return ret; + } + +if (ab->acpi.cca_data[0 ] ==ATH12K_ACPI_CCA_THR_VERSION && + ab->acpi.cca_data[ATH12K_ACPI_CCA_THR_OFFSET_DATA_OFFSET ] == +ATH12K_ACPI_CCA_THR_ENABLE_FLAG ) { + buf = ab->acpi.cca_data +ATH12K_ACPI_CCA_THR_OFFSET_DATA_OFFSET ; + ret =ath12k_wmi_set_bios_cmd (ab, +WMI_BIOS_PARAM_CCA_THRESHOLD_TYPE , + buf, +ATH12K_ACPI_CCA_THR_OFFSET_LEN ); +if (ret) { +ath12k_warn (ab,"failed to set ACPI DSM CCA threshold: %d\n" , + ret); +return ret; + } + } + } + status =acpi_install_notify_handler (ACPI_HANDLE (ab->dev),ACPI_DEVICE_NOTIFY , ath12k_acpi_dsm_notify, ab);
drivers/net/wireless/ath/ath12k/acpi.h +8 -0
@@ -11,11 +11,13 @@#define ATH12K_ACPI_DSM_FUNC_SUPPORT_FUNCS 0#define ATH12K_ACPI_DSM_FUNC_BIOS_SAR 4#define ATH12K_ACPI_DSM_FUNC_GEO_OFFSET 5 +#define ATH12K_ACPI_DSM_FUNC_INDEX_CCA 6#define ATH12K_ACPI_DSM_FUNC_TAS_CFG 8#define ATH12K_ACPI_DSM_FUNC_TAS_DATA 9#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)#define ATH12K_ACPI_FUNC_BIT_TAS_CFG BIT(7)#define ATH12K_ACPI_FUNC_BIT_TAS_DATA BIT(8)
@@ -26,13 +28,17 @@#define ATH12K_ACPI_TAS_DATA_ENABLE 0x1#define ATH12K_ACPI_POWER_LIMIT_VERSION 0x1#define ATH12K_ACPI_POWER_LIMIT_ENABLE_FLAG 0x1 +#define ATH12K_ACPI_CCA_THR_VERSION 0x1 +#define ATH12K_ACPI_CCA_THR_ENABLE_FLAG 0x1#define ATH12K_ACPI_GEO_OFFSET_DATA_OFFSET 1#define ATH12K_ACPI_DBS_BACKOFF_DATA_OFFSET 2 +#define ATH12K_ACPI_CCA_THR_OFFSET_DATA_OFFSET 5#define ATH12K_ACPI_BIOS_SAR_DBS_BACKOFF_LEN 10#define ATH12K_ACPI_POWER_LIMIT_DATA_OFFSET 12#define ATH12K_ACPI_BIOS_SAR_GEO_OFFSET_LEN 18#define ATH12K_ACPI_BIOS_SAR_TABLE_LEN 22 +#define ATH12K_ACPI_CCA_THR_OFFSET_LEN 36#define ATH12K_ACPI_DSM_TAS_DATA_SIZE 69#define ATH12K_ACPI_DSM_TAS_CFG_SIZE 108
@@ -41,6 +47,8 @@ ATH12K_ACPI_BIOS_SAR_GEO_OFFSET_LEN)#define ATH12K_ACPI_DSM_BIOS_SAR_DATA_SIZE (ATH12K_ACPI_POWER_LIMIT_DATA_OFFSET + \ ATH12K_ACPI_BIOS_SAR_TABLE_LEN) +#define ATH12K_ACPI_DSM_CCA_DATA_SIZE (ATH12K_ACPI_CCA_THR_OFFSET_DATA_OFFSET + \ + ATH12K_ACPI_CCA_THR_OFFSET_LEN)#ifdef CONFIG_ACPI
drivers/net/wireless/ath/ath12k/core.h +1 -0
@@ -913,6 +913,7 @@ struct ath12k_base {u8 tas_sar_power_table[ATH12K_ACPI_DSM_TAS_DATA_SIZE ];u8 bios_sar_data[ATH12K_ACPI_DSM_BIOS_SAR_DATA_SIZE ];u8 geo_offset_data[ATH12K_ACPI_DSM_GEO_OFFSET_DATA_SIZE ]; + u8 cca_data[ATH12K_ACPI_DSM_CCA_DATA_SIZE]; } acpi;#endif /* CONFIG_ACPI */
drivers/net/wireless/ath/ath12k/wmi.h +1 -0
@@ -4805,6 +4805,7 @@ struct wmi_pdev_set_bios_interface_cmd { } __packed;enum wmi_bios_param_type { +WMI_BIOS_PARAM_CCA_THRESHOLD_TYPE =0 ,WMI_BIOS_PARAM_TAS_CONFIG_TYPE =1 ,WMI_BIOS_PARAM_TAS_DATA_TYPE =2 ,WMI_BIOS_PARAM_TYPE_MAX ,
Signature · 1 line
2.39.2
Re: [PATCH v8 3/4] wifi: ath12k: ACPI CCA threshold support
Quoted 10 lines · Kalle Valo
From: Lingbo Kong <[email protected]>
Currently, ath12k does not have the ability to adjust Clear Channel Assessment (CCA) threshold values to meet the regulatory requirements. Get the values from ACPI and send them to the firmware using
ath12k_wmi_set_bios_cmd()function.Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0-03427-QCAHMTSWPL_V1.0_V2.0_SILICONZ-1.15378.4
Signed-off-by Lingbo Kong <[email protected]>Signed-off-by Kalle Valo <[email protected]>
PATCH v8 4/4 wifi: ath12k: ACPI band edge channel power support
In reply to Kalle ValoFrom: Lingbo Kong <[email protected]>
Currently, ath12k does not have the ability to set band edge channel power for WCN7850. In order to support this, ath12k gets band edge channel power table in ath12k_acpi_dsm_get_data() function and sets pdev_id and param_type_id, then finally sends these data and WMI_PDEV_SET_BIOS_INTERFACE_CMDID to firmware to set band edge channel power.
Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0-03427-QCAHMTSWPL_V1.0_V2.0_SILICONZ-1.15378.4
--- drivers/net/wireless/ath/ath12k/acpi.c | 36 ++++++++++++++++++++++++++ drivers/net/wireless/ath/ath12k/acpi.h | 5 ++++ drivers/net/wireless/ath/ath12k/core.h | 1 + drivers/net/wireless/ath/ath12k/wmi.h | 4 +++ 4 files changed, 46 insertions(+)
drivers/net/wireless/ath/ath12k/acpi.c +36 -0
@@ -91,6 +91,18 @@ static int ath12k_acpi_dsm_get_data(struct ath12k_base *ab, int func)memcpy (&ab->acpi.cca_data, obj->buffer.pointer, obj->buffer.length); +break ; +case ATH12K_ACPI_DSM_FUNC_INDEX_BAND_EDGE : +if (obj->buffer.length !=ATH12K_ACPI_DSM_BAND_EDGE_DATA_SIZE ) { +ath12k_warn (ab,"invalid ACPI DSM band edge data size: %d\n" , + obj->buffer.length); + ret = -EINVAL ; + goto out; + } + +memcpy (&ab->acpi.band_edge_power, obj->buffer.pointer, + obj->buffer.length); +break ; } }else {
@@ -334,6 +346,30 @@ int ath12k_acpi_start(struct ath12k_base *ab) } } +if (ATH12K_ACPI_FUNC_BIT_VALID (ab->acpi, +ATH12K_ACPI_FUNC_BIT_BAND_EDGE_CHAN_POWER )) { + ret =ath12k_acpi_dsm_get_data (ab,ATH12K_ACPI_DSM_FUNC_INDEX_BAND_EDGE ); +if (ret) { +ath12k_warn (ab,"failed to get ACPI DSM band edge channel power: %d\n" , + ret); +return ret; + } + +if (ab->acpi.band_edge_power[0 ] ==ATH12K_ACPI_BAND_EDGE_VERSION && + ab->acpi.band_edge_power[1 ] ==ATH12K_ACPI_BAND_EDGE_ENABLE_FLAG ) { + ret =ath12k_wmi_set_bios_cmd (ab, +WMI_BIOS_PARAM_TYPE_BANDEDGE , + ab->acpi.band_edge_power, +sizeof (ab->acpi.band_edge_power)); +if (ret) { +ath12k_warn (ab, +"failed to set ACPI DSM band edge channel power: %d\n" , + ret); +return ret; + } + } + } + status =acpi_install_notify_handler (ACPI_HANDLE (ab->dev),ACPI_DEVICE_NOTIFY , ath12k_acpi_dsm_notify, ab);
drivers/net/wireless/ath/ath12k/acpi.h +5 -0
@@ -14,12 +14,14 @@#define ATH12K_ACPI_DSM_FUNC_INDEX_CCA 6#define ATH12K_ACPI_DSM_FUNC_TAS_CFG 8#define ATH12K_ACPI_DSM_FUNC_TAS_DATA 9 +#define ATH12K_ACPI_DSM_FUNC_INDEX_BAND_EDGE 10#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)#define ATH12K_ACPI_FUNC_BIT_TAS_CFG BIT(7)#define ATH12K_ACPI_FUNC_BIT_TAS_DATA BIT(8) +#define ATH12K_ACPI_FUNC_BIT_BAND_EDGE_CHAN_POWER BIT(9)#define ATH12K_ACPI_NOTIFY_EVENT 0x86#define ATH12K_ACPI_FUNC_BIT_VALID (_acdata, _func) (((_acdata).func_bit) & (_func))
@@ -30,6 +32,8 @@#define ATH12K_ACPI_POWER_LIMIT_ENABLE_FLAG 0x1#define ATH12K_ACPI_CCA_THR_VERSION 0x1#define ATH12K_ACPI_CCA_THR_ENABLE_FLAG 0x1 +#define ATH12K_ACPI_BAND_EDGE_VERSION 0x1 +#define ATH12K_ACPI_BAND_EDGE_ENABLE_FLAG 0x1#define ATH12K_ACPI_GEO_OFFSET_DATA_OFFSET 1#define ATH12K_ACPI_DBS_BACKOFF_DATA_OFFSET 2
@@ -41,6 +45,7 @@#define ATH12K_ACPI_CCA_THR_OFFSET_LEN 36#define ATH12K_ACPI_DSM_TAS_DATA_SIZE 69 +#define ATH12K_ACPI_DSM_BAND_EDGE_DATA_SIZE 100#define ATH12K_ACPI_DSM_TAS_CFG_SIZE 108#define ATH12K_ACPI_DSM_GEO_OFFSET_DATA_SIZE (ATH12K_ACPI_GEO_OFFSET_DATA_OFFSET + \
drivers/net/wireless/ath/ath12k/core.h +1 -0
@@ -914,6 +914,7 @@ struct ath12k_base {u8 bios_sar_data[ATH12K_ACPI_DSM_BIOS_SAR_DATA_SIZE ];u8 geo_offset_data[ATH12K_ACPI_DSM_GEO_OFFSET_DATA_SIZE ];u8 cca_data[ATH12K_ACPI_DSM_CCA_DATA_SIZE ]; + u8 band_edge_power[ATH12K_ACPI_DSM_BAND_EDGE_DATA_SIZE]; } acpi;#endif /* CONFIG_ACPI */
drivers/net/wireless/ath/ath12k/wmi.h +4 -0
@@ -4808,6 +4808,10 @@ enum wmi_bios_param_type {WMI_BIOS_PARAM_CCA_THRESHOLD_TYPE =0 ,WMI_BIOS_PARAM_TAS_CONFIG_TYPE =1 ,WMI_BIOS_PARAM_TAS_DATA_TYPE =2 , + +/* bandedge control power */ +WMI_BIOS_PARAM_TYPE_BANDEDGE =3 , + WMI_BIOS_PARAM_TYPE_MAX, };
Signature · 1 line
2.39.2
Re: [PATCH v8 4/4] wifi: ath12k: ACPI band edge channel power support
Quoted 9 lines · Kalle Valo
From: Lingbo Kong <[email protected]>
Currently, ath12k does not have the ability to set band edge channel power for WCN7850. In order to support this, ath12k gets band edge channel power table in
ath12k_acpi_dsm_get_data()function and setspdev_idandparam_type_id, then finally sends these data andWMI_PDEV_SET_BIOS_INTERFACE_CMDIDto firmware to set band edge channel power.
Quoted 4 lines
Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0-03427-QCAHMTSWPL_V1.0_V2.0_SILICONZ-1.15378.4
Signed-off-by Lingbo Kong <[email protected]>Signed-off-by Kalle Valo <[email protected]>
Quoted 70 lines · Kalle Valo
From: Kalle Valo <[email protected]>
Through reading ACPI tables, implement Time-Average-SAR(TAS), BIOS SAR, configuration of CCA threshold and band edge channel power functionalities. This is enabled only on WCN7850.
TODO:
* test with ACPI support in hardware (I don't have such hardware), especially suspend and hibernation
v8:
* rebase to ath-202404181528
* rewrite commit messages
* cleanup and improvements all over to match the ath12k style, including
error handling, naming and so on
* locate new place to call ath12k_acpi_[start|stop]()
* move wmi functions up inwmi.cfile
* consolidate WMI functions usingWMI_PDEV_SET_BIOS_INTERFACE_CMDIDintoath12k_wmi_set_bios_cmd()
*ath12k_acpi_stop(): don't callacpi_remove_notify_handler()if we never installed the handlerv7: https://patchwork.kernel.org/project/linux-wireless/cover/[email protected]/
* adjust the length of line
* addcpu_to_le32()v6:
* remove code that is not called
v5:
* rebase to the latest tag
v4:
* revise commit log using imperative voice
* deleteguid_is_null()v3:
* remove unnecessary
cpu_to_le32()
* adjust the order of the macros
* apply jeff's advicev2:
* put <
linux/acpi.h> in the include guardLingbo Kong (4):
wifi: ath12k: ACPI TAS support
wifi: ath12k: ACPI SAR support
wifi: ath12k: ACPI CCA threshold support
wifi: ath12k: ACPI band edge channel power supportdrivers/net/wireless/ath/ath12k/Makefile | 1 + drivers/net/wireless/ath/ath12k/acpi.c | 394 +++++++++++++++++++++++ drivers/net/wireless/ath/ath12k/acpi.h | 76 +++++ drivers/net/wireless/ath/ath12k/core.c | 7 + drivers/net/wireless/ath/ath12k/core.h | 18 ++ drivers/net/wireless/ath/ath12k/hw.c | 10 + drivers/net/wireless/ath/ath12k/hw.h | 3 + drivers/net/wireless/ath/ath12k/wmi.c | 143 ++++++++ drivers/net/wireless/ath/ath12k/wmi.h | 41 +++ 9 files changed, 693 insertions(+) create mode 100644 drivers/net/wireless/ath/ath12k/acpi.c create mode 100644 drivers/net/wireless/ath/ath12k/acpi.h
Quoted 1 line
base-commit:
c416602943dd36fbd13af7496430723935c867a3
I can verify this doesn't crash my system, but apparently my ACPI doesn't have the underlying settings, so cannot verify actual functionality
Apr 18 15:13:59 qca-HP-ZBook-14-G2 kernel: ath12k_pci 0000:03:00.0: acpi_evaluate_dsm() failed Apr 18 15:13:59 qca-HP-ZBook-14-G2 kernel: ath12k_pci 0000:03:00.0: failed to get ACPI DSM data: -2 Apr 18 15:13:59 qca-HP-ZBook-14-G2 kernel: ath12k_pci 0000:03:00.0: acpi failed: -2
/jeff
Quoted 12 lines · Jeff Johnson
Quoted 10 lines · Kalle Valo
From: Kalle Valo <[email protected]>
Through reading ACPI tables, implement Time-Average-SAR(TAS), BIOS SAR, configuration of CCA threshold and band edge channel power functionalities. This is enabled only on WCN7850.
TODO:
* test with ACPI support in hardware (I don't have such hardware), especially suspend and hibernation
[...]
Quoted 2 lines
I can verify this doesn't crash my system, but apparently my ACPI doesn't have the underlying settings, so cannot verify actual functionality
Thanks for testing. I hope Lingbo has a device with proper ACPI settings.
Quoted 3 lines
Apr 18 15:13:59 qca-HP-ZBook-14-G2 kernel: ath12k_pci 0000:03:00.0: acpi_evaluate_dsm() failed Apr 18 15:13:59 qca-HP-ZBook-14-G2 kernel: ath12k_pci 0000:03:00.0: failed to get ACPI DSM data: -2 Apr 18 15:13:59 qca-HP-ZBook-14-G2 kernel: ath12k_pci 0000:03:00.0: acpi failed: -2
I just want to verify that these are debug messages, right? Normal users shouldn't see any ACPI errors if there are no ACPI settings in the system.
Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/list/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
Quoted 4 lines · Kalle Valo
Quoted 2 lines · Jeff Johnson
I can verify this doesn't crash my system, but apparently my ACPI doesn't have the underlying settings, so cannot verify actual functionality
Quoted 8 lines
Thanks for testing. I hope Lingbo has a device with proper ACPI settings.
Quoted 3 lines
Apr 18 15:13:59 qca-HP-ZBook-14-G2 kernel: ath12k_pci 0000:03:00.0: acpi_evaluate_dsm() failed Apr 18 15:13:59 qca-HP-ZBook-14-G2 kernel: ath12k_pci 0000:03:00.0: failed to get ACPI DSM data: -2 Apr 18 15:13:59 qca-HP-ZBook-14-G2 kernel: ath12k_pci 0000:03:00.0: acpi failed: -2I just want to verify that these are debug messages, right? Normal users shouldn't see any ACPI errors if there are no ACPI settings in the system.
Yes, those were debug messages (I've added ath12k.debug_mask=0xffffeffa to my boot command)
Also note my Qualcomm Innovation Center copyright checker reports that the two new files are missing 2024 copyright, so please update
/jeff
Quoted 14 lines · Jeff Johnson
Quoted 4 lines · Kalle Valo
Quoted 2 lines · Jeff Johnson
I can verify this doesn't crash my system, but apparently my ACPI doesn't have the underlying settings, so cannot verify actual functionality
Quoted 8 lines
Thanks for testing. I hope Lingbo has a device with proper ACPI settings.
Quoted 3 lines
Apr 18 15:13:59 qca-HP-ZBook-14-G2 kernel: ath12k_pci 0000:03:00.0: acpi_evaluate_dsm() failed Apr 18 15:13:59 qca-HP-ZBook-14-G2 kernel: ath12k_pci 0000:03:00.0: failed to get ACPI DSM data: -2 Apr 18 15:13:59 qca-HP-ZBook-14-G2 kernel: ath12k_pci 0000:03:00.0: acpi failed: -2I just want to verify that these are debug messages, right? Normal users shouldn't see any ACPI errors if there are no ACPI settings in the system.
Quoted 8 lines
Yes, those were debug messages (I've added ath12k.debug_mask=0xffffeffa to my boot command)
Also note my Qualcomm Innovation Center copyright checker reports that the two new files are missing 2024 copyright, so please update
/jeff
thx jeff, i'll update the copyright.
best regards
Lingbo Kong