drm/amd/pm: enable Wifi RFI mitigation feature support for SMU13.0.0
authorMa Jun <Jun.Ma2@amd.com>
Mon, 11 Dec 2023 10:06:29 +0000 (18:06 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 13 Dec 2023 20:23:50 +0000 (15:23 -0500)
Fulfill the SMU13.0.0 support for Wifi RFI mitigation feature.

--
v10->v11:
 - downgrade the prompt level on message failure(Lijo)
v13:
 - Fix the format issue (IIpo Jarvinen)
 - Move function smu_v13_0_0_set_wbrf_exclusion_ranges to
smu_v13_0.c as a generic code for later use (IIpo Jarvinen)

Co-developed-by: Evan Quan <quanliangl@hotmail.com>
Signed-off-by: Evan Quan <quanliangl@hotmail.com>
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Ma Jun <Jun.Ma2@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h
drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h
drivers/gpu/drm/amd/pm/swsmu/inc/smu_v13_0.h
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c

index f97178a602bc3de4c8c5d30f7176964951c22faf..2aa4fea873147516c23fb2fc568a94d907ee1c8a 100644 (file)
@@ -23,6 +23,7 @@
 #define __AMDGPU_SMU_H__
 
 #include <linux/acpi_amd_wbrf.h>
+#include <linux/units.h>
 
 #include "amdgpu.h"
 #include "kgd_pp_interface.h"
@@ -320,6 +321,7 @@ enum smu_table_id {
        SMU_TABLE_PACE,
        SMU_TABLE_ECCINFO,
        SMU_TABLE_COMBO_PPTABLE,
+       SMU_TABLE_WIFIBAND,
        SMU_TABLE_COUNT,
 };
 
index ea8ea99b74368a6e9b485954b6e9334a9cedc4d6..953a767613b11b1af1b60540b1d1f94e7018f819 100644 (file)
        __SMU_DUMMY_MAP(PowerDownUmsch),        \
        __SMU_DUMMY_MAP(SetSoftMaxVpe), \
        __SMU_DUMMY_MAP(SetSoftMinVpe), \
-       __SMU_DUMMY_MAP(GetMetricsVersion),
+       __SMU_DUMMY_MAP(GetMetricsVersion), \
+       __SMU_DUMMY_MAP(EnableUCLKShadow),
 
 #undef __SMU_DUMMY_MAP
 #define __SMU_DUMMY_MAP(type)  SMU_MSG_##type
index 5e7b8f29fecce9e726f92375959db4984ea578f1..fbd57fa1a004922c49404fee284bb6ccee19f17a 100644 (file)
@@ -294,5 +294,9 @@ int smu_v13_0_update_pcie_parameters(struct smu_context *smu,
 
 int smu_v13_0_disable_pmfw_state(struct smu_context *smu);
 
+int smu_v13_0_enable_uclk_shadow(struct smu_context *smu, bool enable);
+
+int smu_v13_0_set_wbrf_exclusion_ranges(struct smu_context *smu,
+                                                struct freq_band_range *exclusion_ranges);
 #endif
 #endif
index 2877e5da5b5ad202edbcdf18dd3c93163bb76309..771a3d457c335e2cc08582a3e4e3a3ba853d2928 100644 (file)
@@ -2507,3 +2507,51 @@ int smu_v13_0_disable_pmfw_state(struct smu_context *smu)
 
        return ret == 0 ? 0 : -EINVAL;
 }
+
+int smu_v13_0_enable_uclk_shadow(struct smu_context *smu, bool enable)
+{
+       return smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_EnableUCLKShadow, enable, NULL);
+}
+
+int smu_v13_0_set_wbrf_exclusion_ranges(struct smu_context *smu,
+                                                struct freq_band_range *exclusion_ranges)
+{
+       WifiBandEntryTable_t wifi_bands;
+       int valid_entries = 0;
+       int ret, i;
+
+       memset(&wifi_bands, 0, sizeof(wifi_bands));
+       for (i = 0; i < ARRAY_SIZE(wifi_bands.WifiBandEntry); i++) {
+               if (!exclusion_ranges[i].start && !exclusion_ranges[i].end)
+                       break;
+
+               /* PMFW expects the inputs to be in Mhz unit */
+               wifi_bands.WifiBandEntry[valid_entries].LowFreq =
+                       DIV_ROUND_DOWN_ULL(exclusion_ranges[i].start, HZ_PER_MHZ);
+               wifi_bands.WifiBandEntry[valid_entries++].HighFreq =
+                       DIV_ROUND_UP_ULL(exclusion_ranges[i].end, HZ_PER_MHZ);
+       }
+       wifi_bands.WifiBandEntryNum = valid_entries;
+
+       /*
+        * Per confirm with PMFW team, WifiBandEntryNum = 0
+        * is a valid setting.
+        *
+        * Considering the scenarios below:
+        * - At first the wifi device adds an exclusion range e.g. (2400,2500) to
+        *   BIOS and our driver gets notified. We will set WifiBandEntryNum = 1
+        *   and pass the WifiBandEntry (2400, 2500) to PMFW.
+        *
+        * - Later the wifi device removes the wifiband list added above and
+        *   our driver gets notified again. At this time, driver will set
+        *   WifiBandEntryNum = 0 and pass an empty WifiBandEntry list to PMFW.
+        *
+        * - PMFW may still need to do some uclk shadow update(e.g. switching
+        *   from shadow clock back to primary clock) on receiving this.
+        */
+       ret = smu_cmn_update_table(smu, SMU_TABLE_WIFIBAND, 0, &wifi_bands, true);
+       if (ret)
+               dev_warn(smu->adev->dev, "Failed to set wifiband!");
+
+       return ret;
+}
index 2d25a9e47651f750ce99b9228d1f119d05b42ae8..a24aa886c63696ecf85f3c12ed6766058772630a 100644 (file)
@@ -169,6 +169,7 @@ static struct cmn2asic_msg_mapping smu_v13_0_0_message_map[SMU_MSG_MAX_COUNT] =
        MSG_MAP(AllowIHHostInterrupt,           PPSMC_MSG_AllowIHHostInterrupt,       0),
        MSG_MAP(ReenableAcDcInterrupt,          PPSMC_MSG_ReenableAcDcInterrupt,       0),
        MSG_MAP(DALNotPresent,          PPSMC_MSG_DALNotPresent,       0),
+       MSG_MAP(EnableUCLKShadow,               PPSMC_MSG_EnableUCLKShadow,            0),
 };
 
 static struct cmn2asic_mapping smu_v13_0_0_clk_map[SMU_CLK_COUNT] = {
@@ -253,6 +254,7 @@ static struct cmn2asic_mapping smu_v13_0_0_table_map[SMU_TABLE_COUNT] = {
        TAB_MAP(I2C_COMMANDS),
        TAB_MAP(ECCINFO),
        TAB_MAP(OVERDRIVE),
+       TAB_MAP(WIFIBAND),
 };
 
 static struct cmn2asic_mapping smu_v13_0_0_pwr_src_map[SMU_POWER_SOURCE_COUNT] = {
@@ -498,6 +500,9 @@ static int smu_v13_0_0_tables_init(struct smu_context *smu)
                        PAGE_SIZE, AMDGPU_GEM_DOMAIN_VRAM);
        SMU_TABLE_INIT(tables, SMU_TABLE_ECCINFO, sizeof(EccInfoTable_t),
                        PAGE_SIZE, AMDGPU_GEM_DOMAIN_VRAM);
+       SMU_TABLE_INIT(tables, SMU_TABLE_WIFIBAND,
+                      sizeof(WifiBandEntryTable_t), PAGE_SIZE,
+                      AMDGPU_GEM_DOMAIN_VRAM);
 
        smu_table->metrics_table = kzalloc(sizeof(SmuMetricsExternal_t), GFP_KERNEL);
        if (!smu_table->metrics_table)
@@ -2938,6 +2943,20 @@ static ssize_t smu_v13_0_0_get_ecc_info(struct smu_context *smu,
        return ret;
 }
 
+static bool smu_v13_0_0_wbrf_support_check(struct smu_context *smu)
+{
+       struct amdgpu_device *adev = smu->adev;
+
+       switch (adev->ip_versions[MP1_HWIP][0]) {
+       case IP_VERSION(13, 0, 0):
+               return smu->smc_fw_version >= 0x004e6300;
+       case IP_VERSION(13, 0, 10):
+               return smu->smc_fw_version >= 0x00503300;
+       default:
+               return false;
+       }
+}
+
 static const struct pptable_funcs smu_v13_0_0_ppt_funcs = {
        .get_allowed_feature_mask = smu_v13_0_0_get_allowed_feature_mask,
        .set_default_dpm_table = smu_v13_0_0_set_default_dpm_table,
@@ -3016,6 +3035,9 @@ static const struct pptable_funcs smu_v13_0_0_ppt_funcs = {
        .gpo_control = smu_v13_0_gpo_control,
        .get_ecc_info = smu_v13_0_0_get_ecc_info,
        .notify_display_change = smu_v13_0_notify_display_change,
+       .is_asic_wbrf_supported = smu_v13_0_0_wbrf_support_check,
+       .enable_uclk_shadow = smu_v13_0_enable_uclk_shadow,
+       .set_wbrf_exclusion_ranges = smu_v13_0_set_wbrf_exclusion_ranges,
 };
 
 void smu_v13_0_0_set_ppt_funcs(struct smu_context *smu)