wifi: iwlwifi: uefi: cache the DSM functions

Just like we did for ACPI, cache the UEFI values to avoid reading the
tables over and over again.

Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://patch.msgid.link/20260111193638.15871db3cfab.Ib39db197646cc303d60bb12448794d20f6ccbd15@changeid
This commit is contained in:
Emmanuel Grumbach 2026-01-11 19:39:21 +02:00 committed by Miri Korenblit
parent af60fe4b12
commit 4172db83b0
2 changed files with 52 additions and 17 deletions

View File

@ -216,7 +216,7 @@ struct iwl_fw_runtime {
u8 uefi_tables_lock_status;
struct iwl_phy_specific_cfg phy_filters;
#ifdef CONFIG_ACPI
#if defined(CONFIG_ACPI) || defined(CONFIG_EFI)
u32 dsm_funcs_valid;
u32 dsm_values[DSM_FUNC_NUM_FUNCS];
#endif

View File

@ -721,17 +721,12 @@ int iwl_uefi_get_wbem(struct iwl_fw_runtime *fwrt, u32 *value)
return ret;
}
int iwl_uefi_get_dsm(struct iwl_fw_runtime *fwrt, enum iwl_dsm_funcs func,
u32 *value)
static int iwl_uefi_load_dsm_values(struct iwl_fw_runtime *fwrt)
{
struct uefi_cnv_var_general_cfg *data;
int ret = -EINVAL;
BUILD_BUG_ON(ARRAY_SIZE(data->functions) < DSM_FUNC_NUM_FUNCS);
/* Not supported function index */
if (func >= DSM_FUNC_NUM_FUNCS || func == 5)
return -EOPNOTSUPP;
BUILD_BUG_ON(ARRAY_SIZE(data->functions) < ARRAY_SIZE(fwrt->dsm_values));
data = iwl_uefi_get_verified_variable(fwrt->trans, IWL_UEFI_DSM_NAME,
"DSM", sizeof(*data), NULL);
@ -744,21 +739,61 @@ int iwl_uefi_get_dsm(struct iwl_fw_runtime *fwrt, enum iwl_dsm_funcs func,
goto out;
}
if (!(data->functions[DSM_FUNC_QUERY] & BIT(func))) {
IWL_DEBUG_RADIO(fwrt, "DSM func %d not in 0x%x\n",
func, data->functions[DSM_FUNC_QUERY]);
goto out;
fwrt->dsm_funcs_valid = data->functions[DSM_FUNC_QUERY];
/*
* Make sure we don't load the DSM values twice. Set this only after we
* validated the DSM table so that if the table in UEFI is not valid,
* we will fallback to ACPI.
*/
fwrt->dsm_funcs_valid |= BIT(DSM_FUNC_QUERY);
for (int func = 1; func < ARRAY_SIZE(fwrt->dsm_values); func++) {
if (!(fwrt->dsm_funcs_valid & BIT(func))) {
IWL_DEBUG_RADIO(fwrt, "DSM func %d not in 0x%x\n",
func, fwrt->dsm_funcs_valid);
continue;
}
fwrt->dsm_values[func] = data->functions[func];
IWL_DEBUG_RADIO(fwrt,
"UEFI: DSM func=%d: value=%d\n", func,
fwrt->dsm_values[func]);
}
ret = 0;
out:
kfree(data);
return ret;
}
int iwl_uefi_get_dsm(struct iwl_fw_runtime *fwrt, enum iwl_dsm_funcs func,
u32 *value)
{
/* Not supported function index */
if (func >= DSM_FUNC_NUM_FUNCS || func == 5)
return -EOPNOTSUPP;
if (!fwrt->dsm_funcs_valid) {
int ret = iwl_uefi_load_dsm_values(fwrt);
if (ret)
return ret;
}
*value = data->functions[func];
if (!(fwrt->dsm_funcs_valid & BIT(func))) {
IWL_DEBUG_RADIO(fwrt, "DSM func %d not in 0x%x\n",
func, fwrt->dsm_funcs_valid);
return -EINVAL;
}
*value = fwrt->dsm_values[func];
IWL_DEBUG_RADIO(fwrt,
"UEFI: DSM func=%d: value=%d\n", func, *value);
ret = 0;
out:
kfree(data);
return ret;
return 0;
}
int iwl_uefi_get_puncturing(struct iwl_fw_runtime *fwrt)