diff options
Diffstat (limited to 'meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.19.8/1817-drm-amd-powerplay-support-SMU-metrics-table-on-Vega1.patch')
-rw-r--r-- | meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.19.8/1817-drm-amd-powerplay-support-SMU-metrics-table-on-Vega1.patch | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.19.8/1817-drm-amd-powerplay-support-SMU-metrics-table-on-Vega1.patch b/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.19.8/1817-drm-amd-powerplay-support-SMU-metrics-table-on-Vega1.patch new file mode 100644 index 00000000..5f72b3b4 --- /dev/null +++ b/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.19.8/1817-drm-amd-powerplay-support-SMU-metrics-table-on-Vega1.patch @@ -0,0 +1,107 @@ +From aa8817c86c11391f43b56d521bff39a1833bbf67 Mon Sep 17 00:00:00 2001 +From: Evan Quan <evan.quan@amd.com> +Date: Thu, 18 Apr 2019 13:28:12 +0800 +Subject: [PATCH 1817/2940] drm/amd/powerplay: support SMU metrics table on + Vega12 + +That should provide some necessary sensor information. + +Change-Id: I898371cef06795c5369a14c4dd3fe8717959d81a +Signed-off-by: Evan Quan <evan.quan@amd.com> +Reviewed-by: Alex Deucher <alexander.deucher@amd.com> +--- + .../drm/amd/powerplay/hwmgr/vega12_hwmgr.c | 21 +++++++++++++++++++ + .../drm/amd/powerplay/hwmgr/vega12_hwmgr.h | 3 +++ + .../drm/amd/powerplay/smumgr/vega12_smumgr.c | 21 +++++++++++++++++++ + 3 files changed, 45 insertions(+) + +diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega12_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/vega12_hwmgr.c +index 60c9f9502e65..aeeeaa79056c 100644 +--- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega12_hwmgr.c ++++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega12_hwmgr.c +@@ -1237,6 +1237,27 @@ static uint32_t vega12_dpm_get_mclk(struct pp_hwmgr *hwmgr, bool low) + return (mem_clk * 100); + } + ++static int vega12_get_metrics_table(struct pp_hwmgr *hwmgr, SmuMetrics_t *metrics_table) ++{ ++ struct vega12_hwmgr *data = ++ (struct vega12_hwmgr *)(hwmgr->backend); ++ int ret = 0; ++ ++ if (!data->metrics_time || time_after(jiffies, data->metrics_time + HZ / 2)) { ++ ret = smum_smc_table_manager(hwmgr, (uint8_t *)metrics_table, ++ TABLE_SMU_METRICS, true); ++ if (ret) { ++ pr_info("Failed to export SMU metrics table!\n"); ++ return ret; ++ } ++ memcpy(&data->metrics_table, metrics_table, sizeof(SmuMetrics_t)); ++ data->metrics_time = jiffies; ++ } else ++ memcpy(metrics_table, &data->metrics_table, sizeof(SmuMetrics_t)); ++ ++ return ret; ++} ++ + static int vega12_get_gpu_power(struct pp_hwmgr *hwmgr, uint32_t *query) + { + #if 0 +diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega12_hwmgr.h b/drivers/gpu/drm/amd/powerplay/hwmgr/vega12_hwmgr.h +index b3e424d28994..73875399666a 100644 +--- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega12_hwmgr.h ++++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega12_hwmgr.h +@@ -396,6 +396,9 @@ struct vega12_hwmgr { + + /* ---- Gfxoff ---- */ + bool gfxoff_controlled_by_driver; ++ ++ unsigned long metrics_time; ++ SmuMetrics_t metrics_table; + }; + + #define VEGA12_DPM2_NEAR_TDP_DEC 10 +diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/vega12_smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/vega12_smumgr.c +index ddb801517667..1eaf0fa28ef7 100644 +--- a/drivers/gpu/drm/amd/powerplay/smumgr/vega12_smumgr.c ++++ b/drivers/gpu/drm/amd/powerplay/smumgr/vega12_smumgr.c +@@ -287,8 +287,26 @@ static int vega12_smu_init(struct pp_hwmgr *hwmgr) + priv->smu_tables.entry[TABLE_OVERDRIVE].version = 0x01; + priv->smu_tables.entry[TABLE_OVERDRIVE].size = sizeof(OverDriveTable_t); + ++ /* allocate space for SMU_METRICS table */ ++ ret = amdgpu_bo_create_kernel((struct amdgpu_device *)hwmgr->adev, ++ sizeof(SmuMetrics_t), ++ PAGE_SIZE, ++ AMDGPU_GEM_DOMAIN_VRAM, ++ &priv->smu_tables.entry[TABLE_SMU_METRICS].handle, ++ &priv->smu_tables.entry[TABLE_SMU_METRICS].mc_addr, ++ &priv->smu_tables.entry[TABLE_SMU_METRICS].table); ++ if (ret) ++ goto err4; ++ ++ priv->smu_tables.entry[TABLE_SMU_METRICS].version = 0x01; ++ priv->smu_tables.entry[TABLE_SMU_METRICS].size = sizeof(SmuMetrics_t); ++ + return 0; + ++err4: ++ amdgpu_bo_free_kernel(&priv->smu_tables.entry[TABLE_OVERDRIVE].handle, ++ &priv->smu_tables.entry[TABLE_OVERDRIVE].mc_addr, ++ &priv->smu_tables.entry[TABLE_OVERDRIVE].table); + err3: + amdgpu_bo_free_kernel(&priv->smu_tables.entry[TABLE_AVFS_FUSE_OVERRIDE].handle, + &priv->smu_tables.entry[TABLE_AVFS_FUSE_OVERRIDE].mc_addr, +@@ -334,6 +352,9 @@ static int vega12_smu_fini(struct pp_hwmgr *hwmgr) + amdgpu_bo_free_kernel(&priv->smu_tables.entry[TABLE_OVERDRIVE].handle, + &priv->smu_tables.entry[TABLE_OVERDRIVE].mc_addr, + &priv->smu_tables.entry[TABLE_OVERDRIVE].table); ++ amdgpu_bo_free_kernel(&priv->smu_tables.entry[TABLE_SMU_METRICS].handle, ++ &priv->smu_tables.entry[TABLE_SMU_METRICS].mc_addr, ++ &priv->smu_tables.entry[TABLE_SMU_METRICS].table); + kfree(hwmgr->smu_backend); + hwmgr->smu_backend = NULL; + } +-- +2.17.1 + |