drm/amd/powerplay: replace smu->table_count with SMU_TABLE_COUNT in smu (v2)
authorKevin Wang <kevin1.wang@amd.com>
Tue, 3 Sep 2019 08:02:33 +0000 (16:02 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 13 Sep 2019 22:48:16 +0000 (17:48 -0500)
fix bellow patch issue:
drm/amd/powerplay: introduce smu table id type to handle the smu table
for each asic
----
"This patch introduces new smu table type, it's to handle the
 different smu table
 defines for each asic with the same smu ip."

before:
use smu->table_count to represent the actual table count in smc firmware
use actual table count to check smu function parameter about smu table
after:
use logic table count "SMU_TABLE_COUNT" to check function parameter
because table id already mapped in smu driver,
and smu function will use logic table id not actual table id to check func parameter.

v2: squash in warning fix

Signed-off-by: Kevin Wang <kevin1.wang@amd.com>
Reviewed-by: Evan Quan <evan.quan@amd.com>
Acked-by: Huang Rui <ray.huang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
drivers/gpu/drm/amd/powerplay/arcturus_ppt.c
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h
drivers/gpu/drm/amd/powerplay/navi10_ppt.c
drivers/gpu/drm/amd/powerplay/renoir_ppt.c
drivers/gpu/drm/amd/powerplay/smu_v11_0.c
drivers/gpu/drm/amd/powerplay/smu_v12_0.c
drivers/gpu/drm/amd/powerplay/vega20_ppt.c

index 82a8298b70407a61a073eb8a233ffc6349974fe9..4681ebefc9c3e194da77b15474ac1e5b2a1dc31d 100644 (file)
@@ -482,7 +482,7 @@ int smu_update_table(struct smu_context *smu, enum smu_table_id table_index, int
        int ret = 0;
        int table_id = smu_table_get_index(smu, table_index);
 
-       if (!table_data || table_id >= smu_table->table_count || table_id < 0)
+       if (!table_data || table_id >= SMU_TABLE_COUNT || table_id < 0)
                return -EINVAL;
 
        table = &smu_table->tables[table_index];
@@ -911,14 +911,10 @@ static int smu_init_fb_allocations(struct smu_context *smu)
        struct amdgpu_device *adev = smu->adev;
        struct smu_table_context *smu_table = &smu->smu_table;
        struct smu_table *tables = smu_table->tables;
-       uint32_t table_count = smu_table->table_count;
        uint32_t i = 0;
        int32_t ret = 0;
 
-       if (table_count <= 0)
-               return -EINVAL;
-
-       for (i = 0 ; i < table_count; i++) {
+       for (i = 0; i < SMU_TABLE_COUNT; i++) {
                if (tables[i].size == 0)
                        continue;
                ret = amdgpu_bo_create_kernel(adev,
@@ -949,13 +945,12 @@ static int smu_fini_fb_allocations(struct smu_context *smu)
 {
        struct smu_table_context *smu_table = &smu->smu_table;
        struct smu_table *tables = smu_table->tables;
-       uint32_t table_count = smu_table->table_count;
        uint32_t i = 0;
 
-       if (table_count == 0 || tables == NULL)
+       if (!tables)
                return 0;
 
-       for (i = 0 ; i < table_count; i++) {
+       for (i = 0; i < SMU_TABLE_COUNT; i++) {
                if (tables[i].size == 0)
                        continue;
                amdgpu_bo_free_kernel(&tables[i].bo,
index f1f072012facb18dd156ef964fbe4455c0176de2..1c6732847185db55e7c19c642e1a3ee456baaedf 100644 (file)
@@ -1931,8 +1931,5 @@ static const struct pptable_funcs arcturus_ppt_funcs = {
 
 void arcturus_set_ppt_funcs(struct smu_context *smu)
 {
-       struct smu_table_context *smu_table = &smu->smu_table;
-
        smu->ppt_funcs = &arcturus_ppt_funcs;
-       smu_table->table_count = TABLE_COUNT;
 }
index 8e4b0ad247128e1cabcf90d21721efa5fedce0f9..e1237ea8844cf94b79d5ee7383f736f7b296e3c8 100644 (file)
@@ -259,7 +259,6 @@ struct smu_table_context
        struct smu_bios_boot_up_values  boot_values;
        void                            *driver_pptable;
        struct smu_table                *tables;
-       uint32_t                        table_count;
        struct smu_table                memory_pool;
        uint8_t                         thermal_controller_type;
        uint16_t                        TDPODLimit;
index 12c0e469bf351e34b4789c59790fa11699bb353f..728e282a10c2d210e64c6c6eb62e15e04a2be375 100644 (file)
@@ -1631,8 +1631,5 @@ static const struct pptable_funcs navi10_ppt_funcs = {
 
 void navi10_set_ppt_funcs(struct smu_context *smu)
 {
-       struct smu_table_context *smu_table = &smu->smu_table;
-
        smu->ppt_funcs = &navi10_ppt_funcs;
-       smu_table->table_count = TABLE_COUNT;
 }
index 2a6da546fb55455a2cdba2502c3b724d53df99f9..70a4dfd424c5f41a97021398cb6c2de2476c9687 100644 (file)
@@ -187,9 +187,6 @@ static const struct pptable_funcs renoir_ppt_funcs = {
 
 void renoir_set_ppt_funcs(struct smu_context *smu)
 {
-       struct smu_table_context *smu_table = &smu->smu_table;
-
        smu->ppt_funcs = &renoir_ppt_funcs;
        smu->smc_if_version = SMU12_DRIVER_IF_VERSION;
-       smu_table->table_count = TABLE_COUNT;
 }
index 68740d4b66a0ee2672c7b7502c8068350d896aa8..d50e0d07e6307ca28d3a7e548e388ab1e8ab21d5 100644 (file)
@@ -439,7 +439,7 @@ static int smu_v11_0_init_smc_tables(struct smu_context *smu)
        struct smu_table *tables = NULL;
        int ret = 0;
 
-       if (smu_table->tables || smu_table->table_count == 0)
+       if (smu_table->tables)
                return -EINVAL;
 
        tables = kcalloc(SMU_TABLE_COUNT, sizeof(struct smu_table),
@@ -465,13 +465,12 @@ static int smu_v11_0_fini_smc_tables(struct smu_context *smu)
        struct smu_table_context *smu_table = &smu->smu_table;
        int ret = 0;
 
-       if (!smu_table->tables || smu_table->table_count == 0)
+       if (!smu_table->tables)
                return -EINVAL;
 
        kfree(smu_table->tables);
        kfree(smu_table->metrics_table);
        smu_table->tables = NULL;
-       smu_table->table_count = 0;
        smu_table->metrics_table = NULL;
        smu_table->metrics_time = 0;
 
index 9d2280ca1f4b8d0ec439ced7ad14857a477d77d5..24274c9bb87da167cc59af2697d7a09adc62566e 100644 (file)
@@ -275,7 +275,7 @@ static int smu_v12_0_init_smc_tables(struct smu_context *smu)
        struct smu_table_context *smu_table = &smu->smu_table;
        struct smu_table *tables = NULL;
 
-       if (smu_table->tables || smu_table->table_count == 0)
+       if (smu_table->tables)
                return -EINVAL;
 
        tables = kcalloc(SMU_TABLE_COUNT, sizeof(struct smu_table),
@@ -292,7 +292,7 @@ static int smu_v12_0_fini_smc_tables(struct smu_context *smu)
 {
        struct smu_table_context *smu_table = &smu->smu_table;
 
-       if (!smu_table->tables || smu_table->table_count == 0)
+       if (!smu_table->tables)
                return -EINVAL;
 
        kfree(smu_table->clocks_table);
index e754e0349df926f8beb6503383e2955599acab57..45a3778afdd3b2d714d72721b5ff676f05f633ca 100644 (file)
@@ -3180,8 +3180,5 @@ static const struct pptable_funcs vega20_ppt_funcs = {
 
 void vega20_set_ppt_funcs(struct smu_context *smu)
 {
-       struct smu_table_context *smu_table = &smu->smu_table;
-
        smu->ppt_funcs = &vega20_ppt_funcs;
-       smu_table->table_count = TABLE_COUNT;
 }