mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-05 14:40:12 -04:00
wifi: iwlwifi: read WTAS table from UEFI
Try to read the WTAS table from UEFI first, and if the WIFI UEFI tables are unlocked or the table doesn't exist - try to read it from ACPI. Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com> Reviewed-by: Gregory Greenman <gregory.greenman@intel.com> Link: https://msgid.link/20240131091413.45e6ff7b5063.Id3aec70887e14533b10d564f32c0cf5f2a14b792@changeid [move uefi_tables_lock_status outside ifdef to fix build errors] Signed-off-by: Johannes Berg <johannes.berg@intel.com>
This commit is contained in:
committed by
Johannes Berg
parent
3bc67e7c18
commit
084e0452a4
@@ -249,9 +249,8 @@ iwl_acpi_get_wifi_pkg(struct device *dev,
|
||||
tbl_rev);
|
||||
}
|
||||
|
||||
|
||||
int iwl_acpi_get_tas(struct iwl_fw_runtime *fwrt,
|
||||
struct iwl_tas_data *tas_data)
|
||||
int iwl_acpi_get_tas_table(struct iwl_fw_runtime *fwrt,
|
||||
struct iwl_tas_data *tas_data)
|
||||
{
|
||||
union acpi_object *wifi_pkg, *data;
|
||||
int ret, tbl_rev, i, block_list_size, enabled;
|
||||
@@ -326,7 +325,6 @@ int iwl_acpi_get_tas(struct iwl_fw_runtime *fwrt,
|
||||
kfree(data);
|
||||
return ret;
|
||||
}
|
||||
IWL_EXPORT_SYMBOL(iwl_acpi_get_tas);
|
||||
|
||||
int iwl_acpi_get_mcc(struct device *dev, char *mcc)
|
||||
{
|
||||
|
||||
@@ -175,8 +175,8 @@ int iwl_acpi_get_ewrd_table(struct iwl_fw_runtime *fwrt);
|
||||
|
||||
int iwl_acpi_get_wgds_table(struct iwl_fw_runtime *fwrt);
|
||||
|
||||
int iwl_acpi_get_tas(struct iwl_fw_runtime *fwrt,
|
||||
struct iwl_tas_data *data);
|
||||
int iwl_acpi_get_tas_table(struct iwl_fw_runtime *fwrt,
|
||||
struct iwl_tas_data *data);
|
||||
|
||||
__le32 iwl_acpi_get_lari_config_bitmap(struct iwl_fw_runtime *fwrt);
|
||||
|
||||
@@ -237,8 +237,8 @@ static inline int iwl_acpi_get_wgds_table(struct iwl_fw_runtime *fwrt)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static inline int iwl_acpi_get_tas(struct iwl_fw_runtime *fwrt,
|
||||
struct iwl_tas_data *data)
|
||||
static inline int iwl_acpi_get_tas_table(struct iwl_fw_runtime *fwrt,
|
||||
struct iwl_tas_data *data)
|
||||
{
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
@@ -9,22 +9,32 @@
|
||||
#include "fw/runtime.h"
|
||||
#include "fw/uefi.h"
|
||||
|
||||
#define IWL_BIOS_TABLE_LOADER(__name) \
|
||||
int iwl_bios_get_ ## __name ## _table(struct iwl_fw_runtime *fwrt) \
|
||||
{ \
|
||||
#define GET_BIOS_TABLE(__name, ...) \
|
||||
do { \
|
||||
int ret = -ENOENT; \
|
||||
if (fwrt->uefi_tables_lock_status > UEFI_WIFI_GUID_UNLOCKED) \
|
||||
ret = iwl_uefi_get_ ## __name ## _table(fwrt); \
|
||||
ret = iwl_uefi_get_ ## __name(__VA_ARGS__); \
|
||||
if (ret < 0) \
|
||||
ret = iwl_acpi_get_ ## __name ## _table(fwrt); \
|
||||
ret = iwl_acpi_get_ ## __name(__VA_ARGS__); \
|
||||
return ret; \
|
||||
} \
|
||||
IWL_EXPORT_SYMBOL(iwl_bios_get_ ## __name ## _table)
|
||||
} while (0)
|
||||
|
||||
IWL_BIOS_TABLE_LOADER(wrds);
|
||||
IWL_BIOS_TABLE_LOADER(ewrd);
|
||||
IWL_BIOS_TABLE_LOADER(wgds);
|
||||
IWL_BIOS_TABLE_LOADER(ppag);
|
||||
#define IWL_BIOS_TABLE_LOADER(__name) \
|
||||
int iwl_bios_get_ ## __name(struct iwl_fw_runtime *fwrt) \
|
||||
{GET_BIOS_TABLE(__name, fwrt); } \
|
||||
IWL_EXPORT_SYMBOL(iwl_bios_get_ ## __name)
|
||||
|
||||
#define IWL_BIOS_TABLE_LOADER_DATA(__name, data_type) \
|
||||
int iwl_bios_get_ ## __name(struct iwl_fw_runtime *fwrt, \
|
||||
data_type * data) \
|
||||
{GET_BIOS_TABLE(__name, fwrt, data); } \
|
||||
IWL_EXPORT_SYMBOL(iwl_bios_get_ ## __name)
|
||||
|
||||
IWL_BIOS_TABLE_LOADER(wrds_table);
|
||||
IWL_BIOS_TABLE_LOADER(ewrd_table);
|
||||
IWL_BIOS_TABLE_LOADER(wgds_table);
|
||||
IWL_BIOS_TABLE_LOADER(ppag_table);
|
||||
IWL_BIOS_TABLE_LOADER_DATA(tas_table, struct iwl_tas_data);
|
||||
|
||||
static const struct dmi_system_id dmi_ppag_approved_list[] = {
|
||||
{ .ident = "HP",
|
||||
|
||||
@@ -133,4 +133,8 @@ int iwl_bios_get_ewrd_table(struct iwl_fw_runtime *fwrt);
|
||||
int iwl_bios_get_wgds_table(struct iwl_fw_runtime *fwrt);
|
||||
|
||||
int iwl_bios_get_ppag_table(struct iwl_fw_runtime *fwrt);
|
||||
|
||||
int iwl_bios_get_tas_table(struct iwl_fw_runtime *fwrt,
|
||||
struct iwl_tas_data *data);
|
||||
|
||||
#endif /* __fw_regulatory_h__ */
|
||||
|
||||
@@ -179,8 +179,8 @@ struct iwl_fw_runtime {
|
||||
struct iwl_sar_offset_mapping_cmd sgom_table;
|
||||
bool sgom_enabled;
|
||||
struct iwl_uats_table_cmd uats_table;
|
||||
u8 uefi_tables_lock_status;
|
||||
#endif
|
||||
u8 uefi_tables_lock_status;
|
||||
bool uats_enabled;
|
||||
};
|
||||
|
||||
|
||||
@@ -550,3 +550,51 @@ int iwl_uefi_get_ppag_table(struct iwl_fw_runtime *fwrt)
|
||||
kfree(data);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int iwl_uefi_get_tas_table(struct iwl_fw_runtime *fwrt,
|
||||
struct iwl_tas_data *tas_data)
|
||||
{
|
||||
struct uefi_cnv_var_wtas *uefi_tas;
|
||||
int ret = 0, enabled, i;
|
||||
|
||||
uefi_tas = iwl_uefi_get_verified_variable(fwrt->trans, IWL_UEFI_WTAS_NAME,
|
||||
"WTAS", sizeof(*uefi_tas), NULL);
|
||||
if (IS_ERR(uefi_tas))
|
||||
return -EINVAL;
|
||||
|
||||
if (uefi_tas->revision != IWL_UEFI_WTAS_REVISION) {
|
||||
ret = -EINVAL;
|
||||
IWL_DEBUG_RADIO(fwrt, "Unsupported UEFI WTAS revision:%d\n",
|
||||
uefi_tas->revision);
|
||||
goto out;
|
||||
}
|
||||
|
||||
enabled = iwl_parse_tas_selection(fwrt, tas_data,
|
||||
uefi_tas->tas_selection);
|
||||
if (!enabled) {
|
||||
IWL_DEBUG_RADIO(fwrt, "TAS not enabled\n");
|
||||
ret = 0;
|
||||
goto out;
|
||||
}
|
||||
|
||||
IWL_DEBUG_RADIO(fwrt, "Reading TAS table revision %d\n",
|
||||
uefi_tas->revision);
|
||||
if (uefi_tas->black_list_size > IWL_WTAS_BLACK_LIST_MAX) {
|
||||
IWL_DEBUG_RADIO(fwrt, "TAS invalid array size %d\n",
|
||||
uefi_tas->black_list_size);
|
||||
ret = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
tas_data->block_list_size = cpu_to_le32(uefi_tas->black_list_size);
|
||||
IWL_DEBUG_RADIO(fwrt, "TAS array size %u\n", uefi_tas->black_list_size);
|
||||
|
||||
for (i = 0; i < uefi_tas->black_list_size; i++) {
|
||||
tas_data->block_list_array[i] =
|
||||
cpu_to_le32(uefi_tas->black_list[i]);
|
||||
IWL_DEBUG_RADIO(fwrt, "TAS block list country %d\n",
|
||||
uefi_tas->black_list[i]);
|
||||
}
|
||||
out:
|
||||
kfree(uefi_tas);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#define IWL_UEFI_EWRD_NAME L"UefiCnvWlanEWRD"
|
||||
#define IWL_UEFI_WGDS_NAME L"UefiCnvWlanWGDS"
|
||||
#define IWL_UEFI_PPAG_NAME L"UefiCnvWlanPPAG"
|
||||
#define IWL_UEFI_WTAS_NAME L"UefiCnvWlanWTAS"
|
||||
|
||||
#define IWL_SGOM_MAP_SIZE 339
|
||||
#define IWL_UATS_MAP_SIZE 339
|
||||
@@ -25,6 +26,7 @@
|
||||
#define IWL_UEFI_WGDS_REVISION 3
|
||||
#define IWL_UEFI_MIN_PPAG_REV 1
|
||||
#define IWL_UEFI_MAX_PPAG_REV 3
|
||||
#define IWL_UEFI_WTAS_REVISION 1
|
||||
|
||||
struct pnvm_sku_package {
|
||||
u8 rev;
|
||||
@@ -115,6 +117,19 @@ struct uefi_cnv_var_ppag {
|
||||
struct iwl_ppag_chain ppag_chains[IWL_NUM_CHAIN_LIMITS];
|
||||
} __packed;
|
||||
|
||||
/* struct uefi_cnv_var_wtas - WTAS tabled as defined in UEFI
|
||||
* @revision: the revision of the table
|
||||
* @tas_selection: different options of TAS enablement.
|
||||
* @black_list_size: the number of defined entried in the black list
|
||||
* @black_list: a list of countries that are not allowed to use the TAS feature
|
||||
*/
|
||||
struct uefi_cnv_var_wtas {
|
||||
u8 revision;
|
||||
u32 tas_selection;
|
||||
u8 black_list_size;
|
||||
u16 black_list[IWL_WTAS_BLACK_LIST_MAX];
|
||||
} __packed;
|
||||
|
||||
/*
|
||||
* This is known to be broken on v4.19 and to work on v5.4. Until we
|
||||
* figure out why this is the case and how to make it work, simply
|
||||
@@ -133,6 +148,8 @@ int iwl_uefi_get_wrds_table(struct iwl_fw_runtime *fwrt);
|
||||
int iwl_uefi_get_ewrd_table(struct iwl_fw_runtime *fwrt);
|
||||
int iwl_uefi_get_wgds_table(struct iwl_fw_runtime *fwrt);
|
||||
int iwl_uefi_get_ppag_table(struct iwl_fw_runtime *fwrt);
|
||||
int iwl_uefi_get_tas_table(struct iwl_fw_runtime *fwrt,
|
||||
struct iwl_tas_data *data);
|
||||
#else /* CONFIG_EFI */
|
||||
static inline void *iwl_uefi_get_pnvm(struct iwl_trans *trans, size_t *len)
|
||||
{
|
||||
@@ -183,6 +200,12 @@ static inline int iwl_uefi_get_ppag_table(struct iwl_fw_runtime *fwrt)
|
||||
{
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
static inline int iwl_uefi_get_tas_table(struct iwl_fw_runtime *fwrt,
|
||||
struct iwl_tas_data *data)
|
||||
{
|
||||
return -ENOENT;
|
||||
}
|
||||
#endif /* CONFIG_EFI */
|
||||
|
||||
#if defined(CONFIG_EFI) && defined(CONFIG_ACPI)
|
||||
|
||||
@@ -1108,10 +1108,6 @@ static int iwl_mvm_ppag_init(struct iwl_mvm *mvm)
|
||||
return iwl_mvm_ppag_send_cmd(mvm);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_ACPI
|
||||
|
||||
|
||||
|
||||
static bool iwl_mvm_add_to_tas_block_list(__le32 *list, __le32 *le_size, unsigned int mcc)
|
||||
{
|
||||
int i;
|
||||
@@ -1149,7 +1145,7 @@ static void iwl_mvm_tas_init(struct iwl_mvm *mvm)
|
||||
return;
|
||||
}
|
||||
|
||||
ret = iwl_acpi_get_tas(&mvm->fwrt, &data);
|
||||
ret = iwl_bios_get_tas_table(&mvm->fwrt, &data);
|
||||
if (ret < 0) {
|
||||
IWL_DEBUG_RADIO(mvm,
|
||||
"TAS table invalid or unavailable. (%d)\n",
|
||||
@@ -1205,6 +1201,8 @@ static void iwl_mvm_tas_init(struct iwl_mvm *mvm)
|
||||
IWL_DEBUG_RADIO(mvm, "failed to send TAS_CONFIG (%d)\n", ret);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_ACPI
|
||||
|
||||
static u8 iwl_mvm_eval_dsm_rfi(struct iwl_mvm *mvm)
|
||||
{
|
||||
u8 value;
|
||||
@@ -1345,10 +1343,6 @@ static void iwl_mvm_lari_cfg(struct iwl_mvm *mvm)
|
||||
|
||||
#else /* CONFIG_ACPI */
|
||||
|
||||
static void iwl_mvm_tas_init(struct iwl_mvm *mvm)
|
||||
{
|
||||
}
|
||||
|
||||
static void iwl_mvm_lari_cfg(struct iwl_mvm *mvm)
|
||||
{
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user