drm/amdgpu/smu: add metrics table lock
Subsystems (2)
PATCH v2 1/5 drm/amdgpu/smu: add metrics table lock
This table is used for lots of things, add it's own lock.
--- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 1 + drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 1 + 2 files changed, 2 insertions(+)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +1 -0
@@ -872,6 +872,7 @@ static int smu_sw_init(void *handle) smu->smu_baco.platform_support = false;mutex_init (&smu->sensor_lock); +mutex_init (&smu->metrics_lock); smu->watermarks_bitmap =0 ; smu->power_profile_mode =PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT ;
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +1 -0
@@ -350,6 +350,7 @@ struct smu_contextconst struct pptable_funcs *ppt_funcs;struct mutex mutex;struct mutex sensor_lock; +struct mutex metrics_lock;uint64_t pool_size;struct smu_table_context smu_table;
Signature · 6 lines
2.23.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH v2 2/5 drm/amdgpu/smu: add metrics table lock for arcturus (v2)
To protect access to the metrics table.
v2: unlock on error
--- drivers/gpu/drm/amd/powerplay/arcturus_ppt.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/powerplay/arcturus_ppt.c +3 -0
@@ -867,18 +867,21 @@ static int arcturus_get_metrics_table(struct smu_context *smu,struct smu_table_context *smu_table= &smu->smu_table;int ret =0 ; +mutex_lock (&smu->metrics_lock);if (!smu_table->metrics_time ||time_after (jiffies, smu_table->metrics_time +HZ /1000 )) { ret =smu_update_table (smu,SMU_TABLE_SMU_METRICS ,0 , (void *)smu_table->metrics_table, false);if (ret) {pr_info ("Failed to export SMU metrics table!\n" ); +mutex_unlock (&smu->metrics_lock);return ret; } smu_table->metrics_time = jiffies; }memcpy (metrics_table, smu_table->metrics_table,sizeof (SmuMetrics_t)); +mutex_unlock (&smu->metrics_lock);return ret; }
Signature · 6 lines
2.23.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH v2 3/5 drm/amdgpu/smu: add metrics table lock for navi (v2)
In reply to Alex DeucherTo protect access to the metrics table.
v2: unlock on error
--- drivers/gpu/drm/amd/powerplay/navi10_ppt.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/powerplay/navi10_ppt.c +3 -0
@@ -564,17 +564,20 @@ static int navi10_get_metrics_table(struct smu_context *smu,struct smu_table_context *smu_table= &smu->smu_table;int ret =0 ; +mutex_lock (&smu->metrics_lock);if (!smu_table->metrics_time ||time_after (jiffies, smu_table->metrics_time +msecs_to_jiffies (100 ))) { ret =smu_update_table (smu,SMU_TABLE_SMU_METRICS ,0 , (void *)smu_table->metrics_table, false);if (ret) {pr_info ("Failed to export SMU metrics table!\n" ); +mutex_unlock (&smu->metrics_lock);return ret; } smu_table->metrics_time = jiffies; }memcpy (metrics_table, smu_table->metrics_table,sizeof (SmuMetrics_t)); +mutex_unlock (&smu->metrics_lock);return ret; }
Signature · 6 lines
2.23.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH v2 4/5 drm/amdgpu/smu: add metrics table lock for renoir (v2)
In reply to Alex DeucherTo protect access to the metrics table.
v2: unlock on error
--- drivers/gpu/drm/amd/powerplay/renoir_ppt.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/powerplay/renoir_ppt.c +4 -2
@@ -171,17 +171,20 @@ static int renoir_get_metrics_table(struct smu_context *smu,struct smu_table_context *smu_table= &smu->smu_table;int ret =0 ; +mutex_lock (&smu->metrics_lock);if (!smu_table->metrics_time ||time_after (jiffies, smu_table->metrics_time +msecs_to_jiffies (100 ))) { ret =smu_update_table (smu,SMU_TABLE_SMU_METRICS ,0 , (void *)smu_table->metrics_table, false);if (ret) {pr_info ("Failed to export SMU metrics table!\n" ); +mutex_unlock (&smu->metrics_lock);return ret; } smu_table->metrics_time = jiffies; }memcpy (metrics_table, smu_table->metrics_table,sizeof (SmuMetrics_t)); +mutex_unlock (&smu->metrics_lock);return ret; }
@@ -239,8 +242,7 @@ static int renoir_print_clk_levels(struct smu_context *smu,memset (&metrics,0 ,sizeof (metrics)); - ret =smu_update_table (smu,SMU_TABLE_SMU_METRICS ,0 , - (void *)&metrics, false); + ret =renoir_get_metrics_table (smu, &metrics);if (ret)return ret;
Signature · 6 lines
2.23.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH v2 5/5 drm/amdgpu/smu: add metrics table lock for vega20 (v2)
In reply to Alex DeucherTo protect access to the metrics table.
v2: unlock on error
--- drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/powerplay/vega20_ppt.c +3 -0
@@ -1678,17 +1678,20 @@ static int vega20_get_metrics_table(struct smu_context *smu,struct smu_table_context *smu_table= &smu->smu_table;int ret =0 ; +mutex_lock (&smu->metrics_lock);if (!smu_table->metrics_time ||time_after (jiffies, smu_table->metrics_time +HZ /1000 )) { ret =smu_update_table (smu,SMU_TABLE_SMU_METRICS ,0 , (void *)smu_table->metrics_table, false);if (ret) {pr_info ("Failed to export SMU metrics table!\n" ); +mutex_unlock (&smu->metrics_lock);return ret; } smu_table->metrics_time = jiffies; }memcpy (metrics_table, smu_table->metrics_table,sizeof (SmuMetrics_t)); +mutex_unlock (&smu->metrics_lock);return ret; }
Signature · 6 lines
2.23.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
RE: [PATCH v2 5/5] drm/amdgpu/smu: add metrics table lock for vega20 (v2)
It's fine with me to check them in as a temporary workaround. Series is reviewed-by: Evan Quan <[email protected]>
Quoted 56 lines
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Wednesday, December 18, 2019 5:46 AM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: [PATCH v2 5/5] drm/amdgpu/smu: add metrics table lock for vega20 (v2)To protect access to the metrics table.
v2: unlock on error
Bug:
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgitlab.fre
edesktop.org%2Fdrm%2Famd%2Fissues%2F900&data=02%7C01%7Cevan.q uan%40amd.com%7Cefa0dd86e5a74ead810708d7833a823e%7C3dd8961fe488 4e608e11a82d994e183d%7C0%7C0%7C637122159732784832&sdata=X0Z UV1r90Dy3mvlp8zONFcxKQcSaciwkVt7GJabYH0I%3D&reserved=0Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 3 +++ 1 file changed, 3 insertions(+)drivers/gpu/drm/amd/powerplay/vega20_ppt.c +3
-0@@ -1678,17 +1678,20 @@ static int vega20_get_metrics_table(structsmu_context *smu, struct smu_table_context *smu_table= &smu->smu_table;int ret =0 ; +mutex_lock (&smu->metrics_lock);if (!smu_table->metrics_time ||time_after (jiffies, smu_table- >metrics_time + HZ / 1000)) { ret =smu_update_table (smu,SMU_TABLE_SMU_METRICS ,0 , (void *)smu_table->metrics_table, false);if (ret) {pr_info ("Failed to export SMU metrics table!\n" ); +mutex_unlock (&smu->metrics_lock);return ret; } smu_table->metrics_time = jiffies; }memcpy (metrics_table, smu_table->metrics_table,sizeof (SmuMetrics_t)); +mutex_unlock (&smu->metrics_lock);return ret;
}
--
2.23.0
Quoted 9 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.free
desktop.org%2Fmailman%2Flistinfo%2Famd- gfx&data=02%7C01%7Cevan.quan%40amd.com%7Cefa0dd86e5a74ead81 0708d7833a823e%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637 122159732784832&sdata=xFCKqTGqv57k9SucgTc7Ur5AGctpMO%2BbPvw RKz53whI%3D&reserved=0
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
[AMD Official Use Only - Internal Distribution Only]
The series patches are
________________________________
From: amd-gfx <[email protected]> on behalf of Alex Deucher <[email protected]>
Sent: Wednesday, December 18, 2019 5:45 AM
To: [email protected] <[email protected]>
Cc: Deucher, Alexander <[email protected]>
Subject: [PATCH v2 1/5] drm/amdgpu/smu: add metrics table lock
This table is used for lots of things, add it's own lock.
--- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 1 + drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 1 + 2 files changed, 2 insertions(+)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +1 -0
@@ -872,6 +872,7 @@ static int smu_sw_init(void *handle) smu->smu_baco.platform_support = false;mutex_init (&smu->sensor_lock); +mutex_init (&smu->metrics_lock); smu->watermarks_bitmap =0 ; smu->power_profile_mode =PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT ;
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +1 -0
@@ -350,6 +350,7 @@ struct smu_contextconst struct pptable_funcs *ppt_funcs;struct mutex mutex;struct mutex sensor_lock; +struct mutex metrics_lock;uint64_t pool_size;struct smu_table_context smu_table;
--
2.23.0
_______________________________________________
amd-gfx mailing list
[email protected]
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&data=02%7C01%7CKevin1.Wang%40amd.com%7C39da818e513e4cfb04fe08d7833a7fc2%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637122160270078326&sdata=5Z573z93vZHHifVEOQoXgpkcgKoGvlm%2B5hC6oVQdTec%3D&reserved=0
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx