drm/amd/powerplay: update cached feature enablement status V2
Subsystems (2)
PATCH 1/1 drm/amd/powerplay: update cached feature enablement status V2
Need to update in cache feature enablement status after pp_feature settings. Another fix for the commit below:
drm/amd/powerplay: implment sysfs feature status function in smu
V2: update smu_feature_update_enable_state() and relates
--- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 104 +++++++++--------- .../gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 1 - 2 files changed, 52 insertions(+), 53 deletions(-)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +52 -52
@@ -94,6 +94,55 @@ size_t smu_sys_get_pp_feature_mask(struct smu_context *smu, char *buf)return size; } +static int smu_feature_update_enable_state (struct smu_context *smu, +uint64_t feature_mask, +bool enabled) +{ +struct smu_feature *feature = &smu->smu_feature; +uint32_t feature_low =0 , feature_high =0 ; +uint64_t feature_id; +int ret =0 ; + +if (!smu->pm_enabled) +return ret; + + feature_low = (feature_mask >>0 ) &0xffffffff ; + feature_high = (feature_mask >>32 ) &0xffffffff ; + +if (enabled) { + ret =smu_send_smc_msg_with_param (smu, SMU_MSG_EnableSmuFeaturesLow, + feature_low); +if (ret) +return ret; + ret =smu_send_smc_msg_with_param (smu, SMU_MSG_EnableSmuFeaturesHigh, + feature_high); +if (ret) +return ret; + }else { + ret =smu_send_smc_msg_with_param (smu, SMU_MSG_DisableSmuFeaturesLow, + feature_low); +if (ret) +return ret; + ret =smu_send_smc_msg_with_param (smu, SMU_MSG_DisableSmuFeaturesHigh, + feature_high); +if (ret) +return ret; + } + +mutex_lock (&feature->mutex); +for (feature_id =0 ; feature_id <64 ; feature_id++) { +if (feature_mask & (1ULL << feature_id)) { +if (enabled) +test_and_set_bit (feature_id, feature->enabled); +else +test_and_clear_bit (feature_id, feature->enabled); + } + } +mutex_unlock (&feature->mutex); + +return ret; +} +int smu_sys_set_pp_feature_mask (struct smu_context *smu,uint64_t new_mask) {int ret =0 ;
@@ -591,41 +640,7 @@ int smu_feature_init_dpm(struct smu_context *smu)return ret; } -int smu_feature_update_enable_state (struct smu_context *smu,uint64_t feature_mask,bool enabled) -{ -uint32_t feature_low =0 , feature_high =0 ; -int ret =0 ; -if (!smu->pm_enabled) -return ret; - - feature_low = (feature_mask >>0 ) &0xffffffff ; - feature_high = (feature_mask >>32 ) &0xffffffff ; - -if (enabled) { - ret =smu_send_smc_msg_with_param (smu, SMU_MSG_EnableSmuFeaturesLow, - feature_low); -if (ret) -return ret; - ret =smu_send_smc_msg_with_param (smu, SMU_MSG_EnableSmuFeaturesHigh, - feature_high); -if (ret) -return ret; - - }else { - ret =smu_send_smc_msg_with_param (smu, SMU_MSG_DisableSmuFeaturesLow, - feature_low); -if (ret) -return ret; - ret =smu_send_smc_msg_with_param (smu, SMU_MSG_DisableSmuFeaturesHigh, - feature_high); -if (ret) -return ret; - - } - -return ret; -}int smu_feature_is_enabled (struct smu_context *smu,enum smu_feature_mask mask) {
@@ -651,8 +666,6 @@ int smu_feature_set_enabled(struct smu_context *smu, enum smu_feature_mask mask, {struct smu_feature *feature = &smu->smu_feature;int feature_id; -uint64_t feature_mask =0 ; -int ret =0 ; feature_id =smu_feature_get_index (smu, mask);if (feature_id <0 )
@@ -660,22 +673,9 @@ int smu_feature_set_enabled(struct smu_context *smu, enum smu_feature_mask mask,WARN_ON (feature_id > feature->feature_num); - feature_mask =1ULL << feature_id; - -mutex_lock (&feature->mutex); - ret =smu_feature_update_enable_state (smu, feature_mask, enable); -if (ret) - goto failed; - -if (enable) -test_and_set_bit (feature_id, feature->enabled); -else -test_and_clear_bit (feature_id, feature->enabled); - -failed: -mutex_unlock (&feature->mutex); - -return ret; +return smu_feature_update_enable_state (smu, +1ULL << feature_id, + enable); }int smu_feature_is_supported (struct smu_context *smu,enum smu_feature_mask mask)
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +0 -1
@@ -807,7 +807,6 @@ enum amd_dpm_forced_level smu_get_performance_level(struct smu_context *smu);int smu_force_performance_level (struct smu_context *smu,enum amd_dpm_forced_level level);int smu_set_display_count (struct smu_context *smu,uint32_t count);bool smu_clk_dpm_is_enabled (struct smu_context *smu,enum smu_clk_type clk_type); -int smu_feature_update_enable_state (struct smu_context *smu,uint64_t feature_mask,bool enabled);const char *smu_get_message_name (struct smu_context *smu,enum smu_message_type type);const char *smu_get_feature_name (struct smu_context *smu,enum smu_feature_mask feature);size_t smu_sys_get_pp_feature_mask (struct smu_context *smu,char *buf);
Signature · 6 lines
2.23.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): [email protected]
comment inline.
________________________________
From: amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> on behalf of Evan Quan <[email protected]>
Sent: Thursday, August 22, 2019 6:18 PM
To: [email protected] <[email protected]>
Cc: Quan, Evan <[email protected]>
Subject: [PATCH] drm/amd/powerplay: update cached feature enablement status V2
Need to update in cache feature enablement status after pp_feature settings. Another fix for the commit below:
drm/amd/powerplay: implment sysfs feature status function in smu
V2: update smu_feature_update_enable_state() and relates
Change-Id: I90e29b0d839df26825d5993212f6097c7ad4bebf
[kevin]: this information is not neccessary for public, please remove it. git config gerrit.createchangeid=false
--- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 104 +++++++++--------- .../gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 1 - 2 files changed, 52 insertions(+), 53 deletions(-)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +44 -0
@@ -94,6 +94,55 @@ size_t smu_sys_get_pp_feature_mask(struct smu_context *smu, char *buf)return size; } +static int smu_feature_update_enable_state (struct smu_context *smu, +uint64_t feature_mask, +bool enabled) +{ +struct smu_feature *feature = &smu->smu_feature; +uint32_t feature_low =0 , feature_high =0 ; +uint64_t feature_id; +int ret =0 ; + +if (!smu->pm_enabled) +return ret; + + feature_low = (feature_mask >>0 ) &0xffffffff ; + feature_high = (feature_mask >>32 ) &0xffffffff ; + +if (enabled) { + ret =smu_send_smc_msg_with_param (smu, SMU_MSG_EnableSmuFeaturesLow, + feature_low); +if (ret) +return ret; + ret =smu_send_smc_msg_with_param (smu, SMU_MSG_EnableSmuFeaturesHigh, + feature_high); +if (ret) +return ret; + }else { + ret =smu_send_smc_msg_with_param (smu, SMU_MSG_DisableSmuFeaturesLow, + feature_low); +if (ret) +return ret; + ret =smu_send_smc_msg_with_param (smu, SMU_MSG_DisableSmuFeaturesHigh, + feature_high); +if (ret) +return ret; + } + +mutex_lock (&feature->mutex); +for (feature_id =0 ; feature_id <64 ; feature_id++) { +if (feature_mask & (1ULL << feature_id)) { +if (enabled) +test_and_set_bit (feature_id, feature->enabled); +else +test_and_clear_bit (feature_id, feature->enabled); + } + }
//[kevin]: the code logic is a little redundant.
could you use bellow macro to replace that?
header : linux/bitmap.h
* bitmap_and(dst, src1, src2, nbits) *dst = *src1 & *src2 * bitmap_or(dst, src1, src2, nbits) *dst = *src1 | *src2 * bitmap_xor(dst, src1, src2, nbits) *dst = *src1 ^ *src2 * bitmap_andnot(dst, src1, src2, nbits) *dst = *src1 & ~(*src2)
+ mutex_unlock(&feature->mutex);
+
+ return ret;
+}
+
int smu_sys_set_pp_feature_mask(struct smu_context *smu, uint64_t new_mask)
{
int ret = 0;@@ -591,41 +640,7 @@ int smu_feature_init_dpm(struct smu_context *smu)
return ret;
}
[kevin]:
in this patch, i know you only want to fix not cached feature cache issue,
but in v2 patch,
the patch adjust the order of code functions, it seems that this is a brand new function,
I don't think it is necessary,
could you just reflect the modified content in the patch, which can facilitate us to trace problems and review. thanks.
-int smu_feature_update_enable_state(struct smu_context *smu, uint64_t feature_mask, bool enabled) -{
- uint32_t feature_low = 0, feature_high = 0;
- int ret = 0;
- if (!smu->pm_enabled)
- return ret;
-
- feature_low = (feature_mask >> 0 ) & 0xffffffff;
- feature_high = (feature_mask >> 32) & 0xffffffff;
-
- if (enabled) {
- ret = smu_send_smc_msg_with_param(smu, SMU_MSG_EnableSmuFeaturesLow,
- feature_low);
- if (ret)
- return ret;
- ret = smu_send_smc_msg_with_param(smu, SMU_MSG_EnableSmuFeaturesHigh,
- feature_high);
- if (ret)
- return ret;
-
- } else {
- ret = smu_send_smc_msg_with_param(smu, SMU_MSG_DisableSmuFeaturesLow,
- feature_low);
- if (ret)
- return ret;
- ret = smu_send_smc_msg_with_param(smu, SMU_MSG_DisableSmuFeaturesHigh,
- feature_high);
- if (ret)
- return ret;
-
- }
-
- return ret;
-}
int smu_feature_is_enabled(struct smu_context *smu, enum smu_feature_mask mask)
{
@@ -651,8 +666,6 @@ int smu_feature_set_enabled(struct smu_context *smu, enum smu_feature_mask mask,
{
struct smu_feature *feature = &smu->smu_feature;
int feature_id;- uint64_t feature_mask = 0;
- int ret = 0;
feature_id = smu_feature_get_index(smu, mask);
if (feature_id < 0)@@ -660,22 +673,9 @@ int smu_feature_set_enabled(struct smu_context *smu, enum smu_feature_mask mask,
WARN_ON(feature_id > feature->feature_num);
- feature_mask = 1ULL << feature_id;
-
- mutex_lock(&feature->mutex); - ret = smu_feature_update_enable_state(smu, feature_mask, enable); - if (ret)
- goto failed;
-
- if (enable)
- test_and_set_bit(feature_id, feature->enabled);
- else
- test_and_clear_bit(feature_id, feature->enabled);
-
-failed:
- mutex_unlock(&feature->mutex);
-
- return ret;
+ return smu_feature_update_enable_state(smu,
+ 1ULL << feature_id,
+ enable);
}
int smu_feature_is_supported(struct smu_context *smu, enum smu_feature_mask mask)
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +0 -1
@@ -807,7 +807,6 @@ enum amd_dpm_forced_level smu_get_performance_level(struct smu_context *smu);int smu_force_performance_level (struct smu_context *smu,enum amd_dpm_forced_level level);int smu_set_display_count (struct smu_context *smu,uint32_t count);bool smu_clk_dpm_is_enabled (struct smu_context *smu,enum smu_clk_type clk_type); -int smu_feature_update_enable_state (struct smu_context *smu,uint64_t feature_mask,bool enabled);const char *smu_get_message_name (struct smu_context *smu,enum smu_message_type type);const char *smu_get_feature_name (struct smu_context *smu,enum smu_feature_mask feature);size_t smu_sys_get_pp_feature_mask (struct smu_context *smu,char *buf);
--
2.23.0
_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): MN2PR12MB32964130A7A33074F69384EEA2A50-rweVpJHSKTqAm9ToKNQgFgdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org
Comment inline
From: Wang, Kevin(Yang) <[email protected]>
Sent: Thursday, August 22, 2019 8:00 PM
To: Quan, Evan <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amd/powerplay: update cached feature enablement status V2
comment inline.
________________________________
From: amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org<mailto:[email protected]>> on behalf of Evan Quan <[email protected]<mailto:[email protected]>>
Sent: Thursday, August 22, 2019 6:18 PM
To: [email protected]<mailto:[email protected]> <[email protected]<mailto:[email protected]>>
Cc: Quan, Evan <[email protected]<mailto:[email protected]>>
Subject: [PATCH] drm/amd/powerplay: update cached feature enablement status V2
Need to update in cache feature enablement status after pp_feature settings. Another fix for the commit below:
drm/amd/powerplay: implment sysfs feature status function in smu
V2: update smu_feature_update_enable_state() and relates
Change-Id: I90e29b0d839df26825d5993212f6097c7ad4bebf
[kevin]: this information is not neccessary for public, please remove it. git config gerrit.createchangeid=false
--- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 104 +++++++++--------- .../gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 1 - 2 files changed, 52 insertions(+), 53 deletions(-)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +44 -0
@@ -94,6 +94,55 @@ size_t smu_sys_get_pp_feature_mask(struct smu_context *smu, char *buf)return size; } +static int smu_feature_update_enable_state (struct smu_context *smu, +uint64_t feature_mask, +bool enabled) +{ +struct smu_feature *feature = &smu->smu_feature; +uint32_t feature_low =0 , feature_high =0 ; +uint64_t feature_id; +int ret =0 ; + +if (!smu->pm_enabled) +return ret; + + feature_low = (feature_mask >>0 ) &0xffffffff ; + feature_high = (feature_mask >>32 ) &0xffffffff ; + +if (enabled) { + ret =smu_send_smc_msg_with_param (smu, SMU_MSG_EnableSmuFeaturesLow, + feature_low); +if (ret) +return ret; + ret =smu_send_smc_msg_with_param (smu, SMU_MSG_EnableSmuFeaturesHigh, + feature_high); +if (ret) +return ret; + }else { + ret =smu_send_smc_msg_with_param (smu, SMU_MSG_DisableSmuFeaturesLow, + feature_low); +if (ret) +return ret; + ret =smu_send_smc_msg_with_param (smu, SMU_MSG_DisableSmuFeaturesHigh, + feature_high); +if (ret) +return ret; + } + +mutex_lock (&feature->mutex); +for (feature_id =0 ; feature_id <64 ; feature_id++) { +if (feature_mask & (1ULL << feature_id)) { +if (enabled) +test_and_set_bit (feature_id, feature->enabled); +else +test_and_clear_bit (feature_id, feature->enabled); + } + }
//[kevin]: the code logic is a little redundant.
could you use bellow macro to replace that?
header : linux/bitmap.h
* bitmap_and(dst, src1, src2, nbits) *dst = *src1 & *src2 * bitmap_or(dst, src1, src2, nbits) *dst = *src1 | *src2 * bitmap_xor(dst, src1, src2, nbits) *dst = *src1 ^ *src2 * bitmap_andnot(dst, src1, src2, nbits) *dst = *src1 & ~(*src2)
+ mutex_unlock(&feature->mutex);
+
+ return ret;
+}
+
[Quan, Evan] updated in v3.
int smu_sys_set_pp_feature_mask(struct smu_context *smu, uint64_t new_mask)
{
int ret = 0;@@ -591,41 +640,7 @@ int smu_feature_init_dpm(struct smu_context *smu)
return ret;
}
[kevin]:
in this patch, i know you only want to fix not cached feature cache issue,
but in v2 patch,
the patch adjust the order of code functions, it seems that this is a brand new function,
I don't think it is necessary,
could you just reflect the modified content in the patch, which can facilitate us to trace problems and review. thanks.
[Quan, Evan] Move the API before the place it's called. No problem here.
-int smu_feature_update_enable_state(struct smu_context *smu, uint64_t feature_mask, bool enabled) -{
- uint32_t feature_low = 0, feature_high = 0;
- int ret = 0;
- if (!smu->pm_enabled)
- return ret;
-
- feature_low = (feature_mask >> 0 ) & 0xffffffff;
- feature_high = (feature_mask >> 32) & 0xffffffff;
-
- if (enabled) {
- ret = smu_send_smc_msg_with_param(smu, SMU_MSG_EnableSmuFeaturesLow,
- feature_low);
- if (ret)
- return ret;
- ret = smu_send_smc_msg_with_param(smu, SMU_MSG_EnableSmuFeaturesHigh,
- feature_high);
- if (ret)
- return ret;
-
- } else {
- ret = smu_send_smc_msg_with_param(smu, SMU_MSG_DisableSmuFeaturesLow,
- feature_low);
- if (ret)
- return ret;
- ret = smu_send_smc_msg_with_param(smu, SMU_MSG_DisableSmuFeaturesHigh,
- feature_high);
- if (ret)
- return ret;
-
- }
-
- return ret;
-}
int smu_feature_is_enabled(struct smu_context *smu, enum smu_feature_mask mask)
{
@@ -651,8 +666,6 @@ int smu_feature_set_enabled(struct smu_context *smu, enum smu_feature_mask mask,
{
struct smu_feature *feature = &smu->smu_feature;
int feature_id;- uint64_t feature_mask = 0;
- int ret = 0;
feature_id = smu_feature_get_index(smu, mask);
if (feature_id < 0)@@ -660,22 +673,9 @@ int smu_feature_set_enabled(struct smu_context *smu, enum smu_feature_mask mask,
WARN_ON(feature_id > feature->feature_num);
- feature_mask = 1ULL << feature_id;
-
- mutex_lock(&feature->mutex); - ret = smu_feature_update_enable_state(smu, feature_mask, enable); - if (ret)
- goto failed;
-
- if (enable)
- test_and_set_bit(feature_id, feature->enabled);
- else
- test_and_clear_bit(feature_id, feature->enabled);
-
-failed:
- mutex_unlock(&feature->mutex);
-
- return ret;
+ return smu_feature_update_enable_state(smu,
+ 1ULL << feature_id,
+ enable);
}
int smu_feature_is_supported(struct smu_context *smu, enum smu_feature_mask mask)
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +0 -1
@@ -807,7 +807,6 @@ enum amd_dpm_forced_level smu_get_performance_level(struct smu_context *smu);int smu_force_performance_level (struct smu_context *smu,enum amd_dpm_forced_level level);int smu_set_display_count (struct smu_context *smu,uint32_t count);bool smu_clk_dpm_is_enabled (struct smu_context *smu,enum smu_clk_type clk_type); -int smu_feature_update_enable_state (struct smu_context *smu,uint64_t feature_mask,bool enabled);const char *smu_get_message_name (struct smu_context *smu,enum smu_message_type type);const char *smu_get_feature_name (struct smu_context *smu,enum smu_feature_mask feature);size_t smu_sys_get_pp_feature_mask (struct smu_context *smu,char *buf);
--
2.23.0
_______________________________________________
amd-gfx mailing list [email protected]<mailto:[email protected]>
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx