* [PATCH v2 1/2] drm/amd/pm: skip to load smu microcode on sriov for aldebaran
@ 2021-08-12 3:36 Kevin Wang
2021-08-12 3:36 ` [PATCH v2 2/2] drm/amd/pm: change return value in aldebaran_get_power_limit() Kevin Wang
2021-08-12 4:01 ` [PATCH v2 1/2] drm/amd/pm: skip to load smu microcode on sriov for aldebaran Wang, Kevin(Yang)
0 siblings, 2 replies; 6+ messages in thread
From: Kevin Wang @ 2021-08-12 3:36 UTC (permalink / raw)
To: amd-gfx; +Cc: lijo.lazar, kenneth.feng, frank.min, hawking.zhang, Kevin Wang
v1:
1. skip to load smu firmware in sriov mode for aldebaran chip
2. using vbios pptable if in sriov mode.
v2:
clean up smu driver code in sriov code path
Signed-off-by: Kevin Wang <kevin1.wang@amd.com>
---
.../gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c | 41 +++++++++++--------
1 file changed, 25 insertions(+), 16 deletions(-)
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 a421ba85bd6d..ebc081dc01cd 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
@@ -85,6 +85,10 @@ int smu_v13_0_init_microcode(struct smu_context *smu)
const struct common_firmware_header *header;
struct amdgpu_firmware_info *ucode = NULL;
+ /* doesn't need to load smu firmware in IOV mode */
+ if (amdgpu_sriov_vf(adev))
+ return 0;
+
switch (adev->asic_type) {
case CHIP_ALDEBARAN:
chip_name = "aldebaran";
@@ -273,34 +277,38 @@ int smu_v13_0_setup_pptable(struct smu_context *smu)
struct amdgpu_device *adev = smu->adev;
const struct smc_firmware_header_v1_0 *hdr;
int ret, index;
- uint32_t size = 0;
+ uint32_t size = 0, pp_table_id;
uint16_t atom_table_size;
uint8_t frev, crev;
void *table;
uint16_t version_major, version_minor;
+ if (!amdgpu_sriov_vf(adev)) {
+ if (amdgpu_smu_pptable_id >= 0) {
+ pp_table_id = amdgpu_smu_pptable_id;
+ dev_info(adev->dev, "override pptable id %d\n", pp_table_id);
+ } else {
+ pp_table_id = smu->smu_table.boot_values.pp_table_id;
+ dev_info(adev->dev, "use driver provided pptable %d\n", pp_table_id);
+ }
- if (amdgpu_smu_pptable_id >= 0) {
- smu->smu_table.boot_values.pp_table_id = amdgpu_smu_pptable_id;
- dev_info(adev->dev, "override pptable id %d\n", amdgpu_smu_pptable_id);
- }
+ hdr = (const struct smc_firmware_header_v1_0 *) adev->pm.fw->data;
+ version_major = le16_to_cpu(hdr->header.header_version_major);
+ version_minor = le16_to_cpu(hdr->header.header_version_minor);
+ if (version_major != 2) {
+ dev_err(adev->dev, "Unsupported smu firwmare version %d.%d\n",
+ version_major, version_minor);
+ return -EINVAL;
+ }
- hdr = (const struct smc_firmware_header_v1_0 *) adev->pm.fw->data;
- version_major = le16_to_cpu(hdr->header.header_version_major);
- version_minor = le16_to_cpu(hdr->header.header_version_minor);
- if (version_major == 2 && smu->smu_table.boot_values.pp_table_id > 0) {
- dev_info(adev->dev, "use driver provided pptable %d\n", smu->smu_table.boot_values.pp_table_id);
switch (version_minor) {
case 1:
- ret = smu_v13_0_set_pptable_v2_1(smu, &table, &size,
- smu->smu_table.boot_values.pp_table_id);
+ ret = smu_v13_0_set_pptable_v2_1(smu, &table, &size, pp_table_id);
break;
default:
ret = -EINVAL;
break;
}
- if (ret)
- return ret;
} else {
dev_info(adev->dev, "use vbios provided pptable\n");
@@ -309,11 +317,12 @@ int smu_v13_0_setup_pptable(struct smu_context *smu)
ret = amdgpu_atombios_get_data_table(adev, index, &atom_table_size, &frev, &crev,
(uint8_t **)&table);
- if (ret)
- return ret;
size = atom_table_size;
}
+ if (ret)
+ return ret;
+
if (!smu->smu_table.power_play_table)
smu->smu_table.power_play_table = table;
if (!smu->smu_table.power_play_table_size)
--
2.25.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v2 2/2] drm/amd/pm: change return value in aldebaran_get_power_limit()
2021-08-12 3:36 [PATCH v2 1/2] drm/amd/pm: skip to load smu microcode on sriov for aldebaran Kevin Wang
@ 2021-08-12 3:36 ` Kevin Wang
2021-08-12 4:01 ` [PATCH v2 1/2] drm/amd/pm: skip to load smu microcode on sriov for aldebaran Wang, Kevin(Yang)
1 sibling, 0 replies; 6+ messages in thread
From: Kevin Wang @ 2021-08-12 3:36 UTC (permalink / raw)
To: amd-gfx; +Cc: lijo.lazar, kenneth.feng, frank.min, hawking.zhang, Kevin Wang
v1:
1. change return value to avoid smu driver probe fails when FEATURE_PPT is
not enabled.
2. if FEATURE_PPT is not enabled, set power limit value to 0.
v2:
instead dev_err with dev_warn
Signed-off-by: Kevin Wang <kevin1.wang@amd.com>
---
.../gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c
index 97cc6fb9b22b..a9f1a2dfbb51 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c
@@ -1194,8 +1194,19 @@ static int aldebaran_get_power_limit(struct smu_context *smu,
uint32_t power_limit = 0;
int ret;
- if (!smu_cmn_feature_is_enabled(smu, SMU_FEATURE_PPT_BIT))
- return -EINVAL;
+ if (!smu_cmn_feature_is_enabled(smu, SMU_FEATURE_PPT_BIT)) {
+ if (current_power_limit)
+ *current_power_limit = 0;
+ if (default_power_limit)
+ *default_power_limit = 0;
+ if (max_power_limit)
+ *max_power_limit = 0;
+
+ dev_warn(smu->adev->dev,
+ "the PPT feature is not enabled, set power limit to 0");
+
+ return 0;
+ }
/* Valid power data is available only from primary die.
* For secondary die show the value as 0.
--
2.25.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2 1/2] drm/amd/pm: skip to load smu microcode on sriov for aldebaran
2021-08-12 3:36 [PATCH v2 1/2] drm/amd/pm: skip to load smu microcode on sriov for aldebaran Kevin Wang
2021-08-12 3:36 ` [PATCH v2 2/2] drm/amd/pm: change return value in aldebaran_get_power_limit() Kevin Wang
@ 2021-08-12 4:01 ` Wang, Kevin(Yang)
1 sibling, 0 replies; 6+ messages in thread
From: Wang, Kevin(Yang) @ 2021-08-12 4:01 UTC (permalink / raw)
To: amd-gfx; +Cc: Lazar, Lijo, Feng, Kenneth, Min, Frank, Zhang, Hawking
[-- Attachment #1: Type: text/plain, Size: 4859 bytes --]
[AMD Official Use Only]
please ignore this patch, there some errors in here.
Best Regards,
Kevin
________________________________
From: Wang, Kevin(Yang) <Kevin1.Wang@amd.com>
Sent: Thursday, August 12, 2021 11:36 AM
To: amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org>
Cc: Lazar, Lijo <Lijo.Lazar@amd.com>; Feng, Kenneth <Kenneth.Feng@amd.com>; Min, Frank <Frank.Min@amd.com>; Zhang, Hawking <Hawking.Zhang@amd.com>; Wang, Kevin(Yang) <Kevin1.Wang@amd.com>
Subject: [PATCH v2 1/2] drm/amd/pm: skip to load smu microcode on sriov for aldebaran
v1:
1. skip to load smu firmware in sriov mode for aldebaran chip
2. using vbios pptable if in sriov mode.
v2:
clean up smu driver code in sriov code path
Signed-off-by: Kevin Wang <kevin1.wang@amd.com>
---
.../gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c | 41 +++++++++++--------
1 file changed, 25 insertions(+), 16 deletions(-)
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 a421ba85bd6d..ebc081dc01cd 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
@@ -85,6 +85,10 @@ int smu_v13_0_init_microcode(struct smu_context *smu)
const struct common_firmware_header *header;
struct amdgpu_firmware_info *ucode = NULL;
+ /* doesn't need to load smu firmware in IOV mode */
+ if (amdgpu_sriov_vf(adev))
+ return 0;
+
switch (adev->asic_type) {
case CHIP_ALDEBARAN:
chip_name = "aldebaran";
@@ -273,34 +277,38 @@ int smu_v13_0_setup_pptable(struct smu_context *smu)
struct amdgpu_device *adev = smu->adev;
const struct smc_firmware_header_v1_0 *hdr;
int ret, index;
- uint32_t size = 0;
+ uint32_t size = 0, pp_table_id;
uint16_t atom_table_size;
uint8_t frev, crev;
void *table;
uint16_t version_major, version_minor;
+ if (!amdgpu_sriov_vf(adev)) {
+ if (amdgpu_smu_pptable_id >= 0) {
+ pp_table_id = amdgpu_smu_pptable_id;
+ dev_info(adev->dev, "override pptable id %d\n", pp_table_id);
+ } else {
+ pp_table_id = smu->smu_table.boot_values.pp_table_id;
+ dev_info(adev->dev, "use driver provided pptable %d\n", pp_table_id);
+ }
- if (amdgpu_smu_pptable_id >= 0) {
- smu->smu_table.boot_values.pp_table_id = amdgpu_smu_pptable_id;
- dev_info(adev->dev, "override pptable id %d\n", amdgpu_smu_pptable_id);
- }
+ hdr = (const struct smc_firmware_header_v1_0 *) adev->pm.fw->data;
+ version_major = le16_to_cpu(hdr->header.header_version_major);
+ version_minor = le16_to_cpu(hdr->header.header_version_minor);
+ if (version_major != 2) {
+ dev_err(adev->dev, "Unsupported smu firwmare version %d.%d\n",
+ version_major, version_minor);
+ return -EINVAL;
+ }
- hdr = (const struct smc_firmware_header_v1_0 *) adev->pm.fw->data;
- version_major = le16_to_cpu(hdr->header.header_version_major);
- version_minor = le16_to_cpu(hdr->header.header_version_minor);
- if (version_major == 2 && smu->smu_table.boot_values.pp_table_id > 0) {
- dev_info(adev->dev, "use driver provided pptable %d\n", smu->smu_table.boot_values.pp_table_id);
switch (version_minor) {
case 1:
- ret = smu_v13_0_set_pptable_v2_1(smu, &table, &size,
- smu->smu_table.boot_values.pp_table_id);
+ ret = smu_v13_0_set_pptable_v2_1(smu, &table, &size, pp_table_id);
break;
default:
ret = -EINVAL;
break;
}
- if (ret)
- return ret;
} else {
dev_info(adev->dev, "use vbios provided pptable\n");
@@ -309,11 +317,12 @@ int smu_v13_0_setup_pptable(struct smu_context *smu)
ret = amdgpu_atombios_get_data_table(adev, index, &atom_table_size, &frev, &crev,
(uint8_t **)&table);
- if (ret)
- return ret;
size = atom_table_size;
}
+ if (ret)
+ return ret;
+
if (!smu->smu_table.power_play_table)
smu->smu_table.power_play_table = table;
if (!smu->smu_table.power_play_table_size)
--
2.25.1
[-- Attachment #2: Type: text/html, Size: 11572 bytes --]
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2 1/2] drm/amd/pm: skip to load smu microcode on sriov for aldebaran
2021-08-12 6:27 ` Lazar, Lijo
@ 2021-08-12 6:28 ` Wang, Kevin(Yang)
0 siblings, 0 replies; 6+ messages in thread
From: Wang, Kevin(Yang) @ 2021-08-12 6:28 UTC (permalink / raw)
To: Lazar, Lijo, amd-gfx; +Cc: Feng, Kenneth, Min, Frank, Zhang, Hawking
[-- Attachment #1: Type: text/plain, Size: 6579 bytes --]
[AMD Official Use Only]
________________________________
From: Lazar, Lijo <Lijo.Lazar@amd.com>
Sent: Thursday, August 12, 2021 2:27 PM
To: Wang, Kevin(Yang) <Kevin1.Wang@amd.com>; amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org>
Cc: Feng, Kenneth <Kenneth.Feng@amd.com>; Min, Frank <Frank.Min@amd.com>; Zhang, Hawking <Hawking.Zhang@amd.com>
Subject: Re: [PATCH v2 1/2] drm/amd/pm: skip to load smu microcode on sriov for aldebaran
On 8/12/2021 11:46 AM, Kevin Wang wrote:
> v1:
> 1. skip to load smu firmware in sriov mode for aldebaran chip
> 2. using vbios pptable if in sriov mode.
>
> v2:
> clean up smu driver code in sriov code path
>
> Signed-off-by: Kevin Wang <kevin1.wang@amd.com>
> ---
> .../gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c | 102 ++++++++++++------
> 1 file changed, 70 insertions(+), 32 deletions(-)
>
> 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 a421ba85bd6d..3765624d8fd6 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
> @@ -85,6 +85,10 @@ int smu_v13_0_init_microcode(struct smu_context *smu)
> const struct common_firmware_header *header;
> struct amdgpu_firmware_info *ucode = NULL;
>
> + /* doesn't need to load smu firmware in IOV mode */
> + if (amdgpu_sriov_vf(adev))
> + return 0;
> +
> switch (adev->asic_type) {
> case CHIP_ALDEBARAN:
> chip_name = "aldebaran";
> @@ -268,52 +272,86 @@ static int smu_v13_0_set_pptable_v2_1(struct smu_context *smu, void **table,
> return 0;
> }
>
> -int smu_v13_0_setup_pptable(struct smu_context *smu)
> +static int smu_v13_0_get_pptable_from_vbios(struct smu_context *smu, void **table, uint32_t *size)
> {
> struct amdgpu_device *adev = smu->adev;
> - const struct smc_firmware_header_v1_0 *hdr;
> - int ret, index;
> - uint32_t size = 0;
> uint16_t atom_table_size;
> uint8_t frev, crev;
> - void *table;
> - uint16_t version_major, version_minor;
> + int ret, index;
>
> + dev_info(adev->dev, "use vbios provided pptable\n");
> + index = get_index_into_master_table(atom_master_list_of_data_tables_v2_1,
> + powerplayinfo);
>
> - if (amdgpu_smu_pptable_id >= 0) {
> - smu->smu_table.boot_values.pp_table_id = amdgpu_smu_pptable_id;
> - dev_info(adev->dev, "override pptable id %d\n", amdgpu_smu_pptable_id);
> - }
> + ret = amdgpu_atombios_get_data_table(adev, index, &atom_table_size, &frev, &crev,
> + (uint8_t **)&table);
> + if (ret)
> + return ret;
> +
> + if (size)
> + *size = atom_table_size;
> +
> + return 0;
> +}
> +
> +static int smu_v13_0_get_pptable_from_firmware(struct smu_context *smu, void **table, uint32_t *size,
> + uint32_t pptable_id)
> +{
> + const struct smc_firmware_header_v1_0 *hdr;
> + struct amdgpu_device *adev = smu->adev;
> + uint16_t version_major, version_minor;
> + int ret;
>
> hdr = (const struct smc_firmware_header_v1_0 *) adev->pm.fw->data;
> + if (!hdr)
> + return -EINVAL;
> +
> + dev_info(adev->dev, "use driver provided pptable %d\n", pptable_id);
> +
> version_major = le16_to_cpu(hdr->header.header_version_major);
> version_minor = le16_to_cpu(hdr->header.header_version_minor);
> - if (version_major == 2 && smu->smu_table.boot_values.pp_table_id > 0) {
> - dev_info(adev->dev, "use driver provided pptable %d\n", smu->smu_table.boot_values.pp_table_id);
> - switch (version_minor) {
> - case 1:
> - ret = smu_v13_0_set_pptable_v2_1(smu, &table, &size,
> - smu->smu_table.boot_values.pp_table_id);
> - break;
> - default:
> - ret = -EINVAL;
> - break;
> - }
> - if (ret)
> - return ret;
> + if (version_major != 2) {
> + dev_err(adev->dev, "Unsupported smu firwmare version %d.%d\n",
> + version_major, version_minor);
> + return -EINVAL;
> + }
>
> - } else {
> - dev_info(adev->dev, "use vbios provided pptable\n");
> - index = get_index_into_master_table(atom_master_list_of_data_tables_v2_1,
> - powerplayinfo);
> + switch (version_minor) {
> + case 1:
> + ret = smu_v13_0_set_pptable_v2_1(smu, table, size, pptable_id);
> + break;
> + default:
> + ret = -EINVAL;
> + break;
> + }
>
> - ret = amdgpu_atombios_get_data_table(adev, index, &atom_table_size, &frev, &crev,
> - (uint8_t **)&table);
> - if (ret)
> - return ret;
> - size = atom_table_size;
> + return 0;
Probably, this should be
return ret;
Fix it before submit. Apart from that series is
Reviewed-by: Lijo Lazar <lijo.lazar@amd.com>
[kevin]:
good catch, thanks lijo.
Best Regards,
Kevin
> +}
> +
> +int smu_v13_0_setup_pptable(struct smu_context *smu)
> +{
> + struct amdgpu_device *adev = smu->adev;
> + uint32_t size = 0, pptable_id = 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;
> }
>
> + /* force using vbios pptable in sriov mode */
> + if (amdgpu_sriov_vf(adev) || !pptable_id)
> + ret = smu_v13_0_get_pptable_from_vbios(smu, &table, &size);
> + else
> + ret = smu_v13_0_get_pptable_from_firmware(smu, &table, &size, pptable_id);
> +
> + if (ret)
> + return ret;
> +
> if (!smu->smu_table.power_play_table)
> smu->smu_table.power_play_table = table;
> if (!smu->smu_table.power_play_table_size)
>
[-- Attachment #2: Type: text/html, Size: 14622 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 1/2] drm/amd/pm: skip to load smu microcode on sriov for aldebaran
2021-08-12 6:16 Kevin Wang
@ 2021-08-12 6:27 ` Lazar, Lijo
2021-08-12 6:28 ` Wang, Kevin(Yang)
0 siblings, 1 reply; 6+ messages in thread
From: Lazar, Lijo @ 2021-08-12 6:27 UTC (permalink / raw)
To: Kevin Wang, amd-gfx; +Cc: kenneth.feng, frank.min, hawking.zhang
On 8/12/2021 11:46 AM, Kevin Wang wrote:
> v1:
> 1. skip to load smu firmware in sriov mode for aldebaran chip
> 2. using vbios pptable if in sriov mode.
>
> v2:
> clean up smu driver code in sriov code path
>
> Signed-off-by: Kevin Wang <kevin1.wang@amd.com>
> ---
> .../gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c | 102 ++++++++++++------
> 1 file changed, 70 insertions(+), 32 deletions(-)
>
> 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 a421ba85bd6d..3765624d8fd6 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
> @@ -85,6 +85,10 @@ int smu_v13_0_init_microcode(struct smu_context *smu)
> const struct common_firmware_header *header;
> struct amdgpu_firmware_info *ucode = NULL;
>
> + /* doesn't need to load smu firmware in IOV mode */
> + if (amdgpu_sriov_vf(adev))
> + return 0;
> +
> switch (adev->asic_type) {
> case CHIP_ALDEBARAN:
> chip_name = "aldebaran";
> @@ -268,52 +272,86 @@ static int smu_v13_0_set_pptable_v2_1(struct smu_context *smu, void **table,
> return 0;
> }
>
> -int smu_v13_0_setup_pptable(struct smu_context *smu)
> +static int smu_v13_0_get_pptable_from_vbios(struct smu_context *smu, void **table, uint32_t *size)
> {
> struct amdgpu_device *adev = smu->adev;
> - const struct smc_firmware_header_v1_0 *hdr;
> - int ret, index;
> - uint32_t size = 0;
> uint16_t atom_table_size;
> uint8_t frev, crev;
> - void *table;
> - uint16_t version_major, version_minor;
> + int ret, index;
>
> + dev_info(adev->dev, "use vbios provided pptable\n");
> + index = get_index_into_master_table(atom_master_list_of_data_tables_v2_1,
> + powerplayinfo);
>
> - if (amdgpu_smu_pptable_id >= 0) {
> - smu->smu_table.boot_values.pp_table_id = amdgpu_smu_pptable_id;
> - dev_info(adev->dev, "override pptable id %d\n", amdgpu_smu_pptable_id);
> - }
> + ret = amdgpu_atombios_get_data_table(adev, index, &atom_table_size, &frev, &crev,
> + (uint8_t **)&table);
> + if (ret)
> + return ret;
> +
> + if (size)
> + *size = atom_table_size;
> +
> + return 0;
> +}
> +
> +static int smu_v13_0_get_pptable_from_firmware(struct smu_context *smu, void **table, uint32_t *size,
> + uint32_t pptable_id)
> +{
> + const struct smc_firmware_header_v1_0 *hdr;
> + struct amdgpu_device *adev = smu->adev;
> + uint16_t version_major, version_minor;
> + int ret;
>
> hdr = (const struct smc_firmware_header_v1_0 *) adev->pm.fw->data;
> + if (!hdr)
> + return -EINVAL;
> +
> + dev_info(adev->dev, "use driver provided pptable %d\n", pptable_id);
> +
> version_major = le16_to_cpu(hdr->header.header_version_major);
> version_minor = le16_to_cpu(hdr->header.header_version_minor);
> - if (version_major == 2 && smu->smu_table.boot_values.pp_table_id > 0) {
> - dev_info(adev->dev, "use driver provided pptable %d\n", smu->smu_table.boot_values.pp_table_id);
> - switch (version_minor) {
> - case 1:
> - ret = smu_v13_0_set_pptable_v2_1(smu, &table, &size,
> - smu->smu_table.boot_values.pp_table_id);
> - break;
> - default:
> - ret = -EINVAL;
> - break;
> - }
> - if (ret)
> - return ret;
> + if (version_major != 2) {
> + dev_err(adev->dev, "Unsupported smu firwmare version %d.%d\n",
> + version_major, version_minor);
> + return -EINVAL;
> + }
>
> - } else {
> - dev_info(adev->dev, "use vbios provided pptable\n");
> - index = get_index_into_master_table(atom_master_list_of_data_tables_v2_1,
> - powerplayinfo);
> + switch (version_minor) {
> + case 1:
> + ret = smu_v13_0_set_pptable_v2_1(smu, table, size, pptable_id);
> + break;
> + default:
> + ret = -EINVAL;
> + break;
> + }
>
> - ret = amdgpu_atombios_get_data_table(adev, index, &atom_table_size, &frev, &crev,
> - (uint8_t **)&table);
> - if (ret)
> - return ret;
> - size = atom_table_size;
> + return 0;
Probably, this should be
return ret;
Fix it before submit. Apart from that series is
Reviewed-by: Lijo Lazar <lijo.lazar@amd.com>
> +}
> +
> +int smu_v13_0_setup_pptable(struct smu_context *smu)
> +{
> + struct amdgpu_device *adev = smu->adev;
> + uint32_t size = 0, pptable_id = 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;
> }
>
> + /* force using vbios pptable in sriov mode */
> + if (amdgpu_sriov_vf(adev) || !pptable_id)
> + ret = smu_v13_0_get_pptable_from_vbios(smu, &table, &size);
> + else
> + ret = smu_v13_0_get_pptable_from_firmware(smu, &table, &size, pptable_id);
> +
> + if (ret)
> + return ret;
> +
> if (!smu->smu_table.power_play_table)
> smu->smu_table.power_play_table = table;
> if (!smu->smu_table.power_play_table_size)
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 1/2] drm/amd/pm: skip to load smu microcode on sriov for aldebaran
@ 2021-08-12 6:16 Kevin Wang
2021-08-12 6:27 ` Lazar, Lijo
0 siblings, 1 reply; 6+ messages in thread
From: Kevin Wang @ 2021-08-12 6:16 UTC (permalink / raw)
To: amd-gfx; +Cc: lijo.lazar, kenneth.feng, frank.min, hawking.zhang, Kevin Wang
v1:
1. skip to load smu firmware in sriov mode for aldebaran chip
2. using vbios pptable if in sriov mode.
v2:
clean up smu driver code in sriov code path
Signed-off-by: Kevin Wang <kevin1.wang@amd.com>
---
.../gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c | 102 ++++++++++++------
1 file changed, 70 insertions(+), 32 deletions(-)
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 a421ba85bd6d..3765624d8fd6 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
@@ -85,6 +85,10 @@ int smu_v13_0_init_microcode(struct smu_context *smu)
const struct common_firmware_header *header;
struct amdgpu_firmware_info *ucode = NULL;
+ /* doesn't need to load smu firmware in IOV mode */
+ if (amdgpu_sriov_vf(adev))
+ return 0;
+
switch (adev->asic_type) {
case CHIP_ALDEBARAN:
chip_name = "aldebaran";
@@ -268,52 +272,86 @@ static int smu_v13_0_set_pptable_v2_1(struct smu_context *smu, void **table,
return 0;
}
-int smu_v13_0_setup_pptable(struct smu_context *smu)
+static int smu_v13_0_get_pptable_from_vbios(struct smu_context *smu, void **table, uint32_t *size)
{
struct amdgpu_device *adev = smu->adev;
- const struct smc_firmware_header_v1_0 *hdr;
- int ret, index;
- uint32_t size = 0;
uint16_t atom_table_size;
uint8_t frev, crev;
- void *table;
- uint16_t version_major, version_minor;
+ int ret, index;
+ dev_info(adev->dev, "use vbios provided pptable\n");
+ index = get_index_into_master_table(atom_master_list_of_data_tables_v2_1,
+ powerplayinfo);
- if (amdgpu_smu_pptable_id >= 0) {
- smu->smu_table.boot_values.pp_table_id = amdgpu_smu_pptable_id;
- dev_info(adev->dev, "override pptable id %d\n", amdgpu_smu_pptable_id);
- }
+ ret = amdgpu_atombios_get_data_table(adev, index, &atom_table_size, &frev, &crev,
+ (uint8_t **)&table);
+ if (ret)
+ return ret;
+
+ if (size)
+ *size = atom_table_size;
+
+ return 0;
+}
+
+static int smu_v13_0_get_pptable_from_firmware(struct smu_context *smu, void **table, uint32_t *size,
+ uint32_t pptable_id)
+{
+ const struct smc_firmware_header_v1_0 *hdr;
+ struct amdgpu_device *adev = smu->adev;
+ uint16_t version_major, version_minor;
+ int ret;
hdr = (const struct smc_firmware_header_v1_0 *) adev->pm.fw->data;
+ if (!hdr)
+ return -EINVAL;
+
+ dev_info(adev->dev, "use driver provided pptable %d\n", pptable_id);
+
version_major = le16_to_cpu(hdr->header.header_version_major);
version_minor = le16_to_cpu(hdr->header.header_version_minor);
- if (version_major == 2 && smu->smu_table.boot_values.pp_table_id > 0) {
- dev_info(adev->dev, "use driver provided pptable %d\n", smu->smu_table.boot_values.pp_table_id);
- switch (version_minor) {
- case 1:
- ret = smu_v13_0_set_pptable_v2_1(smu, &table, &size,
- smu->smu_table.boot_values.pp_table_id);
- break;
- default:
- ret = -EINVAL;
- break;
- }
- if (ret)
- return ret;
+ if (version_major != 2) {
+ dev_err(adev->dev, "Unsupported smu firwmare version %d.%d\n",
+ version_major, version_minor);
+ return -EINVAL;
+ }
- } else {
- dev_info(adev->dev, "use vbios provided pptable\n");
- index = get_index_into_master_table(atom_master_list_of_data_tables_v2_1,
- powerplayinfo);
+ switch (version_minor) {
+ case 1:
+ ret = smu_v13_0_set_pptable_v2_1(smu, table, size, pptable_id);
+ break;
+ default:
+ ret = -EINVAL;
+ break;
+ }
- ret = amdgpu_atombios_get_data_table(adev, index, &atom_table_size, &frev, &crev,
- (uint8_t **)&table);
- if (ret)
- return ret;
- size = atom_table_size;
+ return 0;
+}
+
+int smu_v13_0_setup_pptable(struct smu_context *smu)
+{
+ struct amdgpu_device *adev = smu->adev;
+ uint32_t size = 0, pptable_id = 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;
}
+ /* force using vbios pptable in sriov mode */
+ if (amdgpu_sriov_vf(adev) || !pptable_id)
+ ret = smu_v13_0_get_pptable_from_vbios(smu, &table, &size);
+ else
+ ret = smu_v13_0_get_pptable_from_firmware(smu, &table, &size, pptable_id);
+
+ if (ret)
+ return ret;
+
if (!smu->smu_table.power_play_table)
smu->smu_table.power_play_table = table;
if (!smu->smu_table.power_play_table_size)
--
2.25.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-08-12 6:28 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-12 3:36 [PATCH v2 1/2] drm/amd/pm: skip to load smu microcode on sriov for aldebaran Kevin Wang
2021-08-12 3:36 ` [PATCH v2 2/2] drm/amd/pm: change return value in aldebaran_get_power_limit() Kevin Wang
2021-08-12 4:01 ` [PATCH v2 1/2] drm/amd/pm: skip to load smu microcode on sriov for aldebaran Wang, Kevin(Yang)
2021-08-12 6:16 Kevin Wang
2021-08-12 6:27 ` Lazar, Lijo
2021-08-12 6:28 ` Wang, Kevin(Yang)
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.