Add a new member to flag where to get the pptable. So that, we can separate those ASIC specific ones from common helpers. Signed-off-by: Evan Quan <evan.quan@xxxxxxx> Change-Id: I814db70b5cedc225578bcb4988663de7dcf535af --- drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 31 ++++++++++++ drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 14 ++++++ .../gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c | 48 ++++++------------- 3 files changed, 60 insertions(+), 33 deletions(-) diff --git a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c index 13c5c7f1ecb9..610f9b68ef73 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +++ b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c @@ -1024,6 +1024,35 @@ static void smu_interrupt_work_fn(struct work_struct *work) smu->ppt_funcs->interrupt_work(smu); } +static void smu_pptable_source_init(struct smu_context *smu) +{ + switch (smu->adev->ip_versions[MP1_HWIP][0]) { + case IP_VERSION(13, 0, 0): + case IP_VERSION(13, 0, 7): + smu->pptable_source = PPTABLE_SOURCE_PMFW; + smu->pptable_id = smu->smu_table.boot_values.pp_table_id; + break; + case IP_VERSION(13, 0, 10): + smu->pptable_source = PPTABLE_SOURCE_INTERNAL_HARDCOPY; + smu->pptable_id = 6666; + break; + default: + smu->pptable_source = PPTABLE_SOURCE_VBIOS; + smu->pptable_id = smu->smu_table.boot_values.pp_table_id; + break; + } + + if (smu->ppt_funcs && smu->ppt_funcs->pptable_source_init) + smu->ppt_funcs->pptable_source_init(smu); + + /* override pptable_id from driver parameter */ + if (amdgpu_smu_pptable_id >= 0) { + dev_info(smu->adev->dev, "override pptable id %d\n", amdgpu_smu_pptable_id); + smu->pptable_id = amdgpu_smu_pptable_id; + smu->pptable_source = PPTABLE_SOURCE_INTERNAL_HARDCOPY; + } +} + static int smu_sw_init(void *handle) { struct amdgpu_device *adev = (struct amdgpu_device *)handle; @@ -1085,6 +1114,8 @@ static int smu_sw_init(void *handle) return ret; } + smu_pptable_source_init(smu); + ret = smu_init_pptable_microcode(smu); if (ret) { dev_err(adev->dev, "Failed to setup pptable firmware!\n"); diff --git a/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h b/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h index e2fa3b066b96..daa6be72bf00 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +++ b/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h @@ -477,6 +477,12 @@ struct stb_context { #define WORKLOAD_POLICY_MAX 7 +enum smu_pptable_source { + PPTABLE_SOURCE_VBIOS, + PPTABLE_SOURCE_PMFW, + PPTABLE_SOURCE_INTERNAL_HARDCOPY, +}; + struct smu_context { struct amdgpu_device *adev; @@ -568,6 +574,9 @@ struct smu_context u32 param_reg; u32 msg_reg; u32 resp_reg; + + enum smu_pptable_source pptable_source; + int pptable_id; }; struct i2c_adapter; @@ -1335,6 +1344,11 @@ struct pptable_funcs { * @init_pptable_microcode: Prepare the pptable microcode to upload via PSP */ int (*init_pptable_microcode)(struct smu_context *smu); + + /** + * @pptable_source_init: Get the smu->pptable_source/pptable_id settings + */ + void (*pptable_source_init)(struct smu_context *smu); }; typedef enum { diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c index 53d26bca524a..e5d742c85416 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c @@ -196,7 +196,7 @@ int smu_v13_0_init_pptable_microcode(struct smu_context *smu) { struct amdgpu_device *adev = smu->adev; struct amdgpu_firmware_info *ucode = NULL; - uint32_t size = 0, pptable_id = 0; + uint32_t size = 0; int ret = 0; void *table; @@ -210,23 +210,10 @@ int smu_v13_0_init_pptable_microcode(struct smu_context *smu) if (!adev->scpm_enabled) return 0; - if ((adev->ip_versions[MP1_HWIP][0] == IP_VERSION(13, 0, 7)) || - (adev->ip_versions[MP1_HWIP][0] == IP_VERSION(13, 0, 0))) + if (smu->pptable_source != PPTABLE_SOURCE_INTERNAL_HARDCOPY) return 0; - /* override pptable_id from driver parameter */ - if (amdgpu_smu_pptable_id >= 0) { - pptable_id = amdgpu_smu_pptable_id; - dev_info(adev->dev, "override pptable id %d\n", pptable_id); - } else { - pptable_id = smu->smu_table.boot_values.pp_table_id; - } - - /* "pptable_id == 0" means vbios carries the pptable. */ - if (!pptable_id) - return 0; - - ret = smu_v13_0_get_pptable_from_firmware(smu, &table, &size, pptable_id); + ret = smu_v13_0_get_pptable_from_firmware(smu, &table, &size, smu->pptable_id); if (ret) return ret; @@ -443,28 +430,23 @@ int smu_v13_0_get_pptable_from_firmware(struct smu_context *smu, int smu_v13_0_setup_pptable(struct smu_context *smu) { - struct amdgpu_device *adev = smu->adev; - uint32_t size = 0, pptable_id = 0; + uint32_t pptable_id = smu->pptable_id; + uint32_t size = 0; void *table; int ret = 0; - /* override pptable_id from driver parameter */ - if (amdgpu_smu_pptable_id >= 0) { - pptable_id = amdgpu_smu_pptable_id; - dev_info(adev->dev, "override pptable id %d\n", pptable_id); - } else { - pptable_id = smu->smu_table.boot_values.pp_table_id; - - if (adev->ip_versions[MP1_HWIP][0] == IP_VERSION(13, 0, 10)) - pptable_id = 6666; - } - - /* force using vbios pptable in sriov mode */ - if ((amdgpu_sriov_vf(adev) || !pptable_id) && (amdgpu_emu_mode != 1)) + switch (smu->pptable_source) { + case PPTABLE_SOURCE_VBIOS: ret = smu_v13_0_get_pptable_from_vbios(smu, &table, &size); - else + break; + case PPTABLE_SOURCE_INTERNAL_HARDCOPY: ret = smu_v13_0_get_pptable_from_firmware(smu, &table, &size, pptable_id); - + break; + case PPTABLE_SOURCE_PMFW: + default: + ret = -EINVAL; + break; + } if (ret) return ret; -- 2.34.1