* [PATCH v3 1/3] drm/amd/pm: Add missing mutex for pp_get_power_profile_mode
@ 2021-11-01 21:28 Mario Limonciello
2021-11-01 21:28 ` [PATCH v3 2/3] drm/amd/pm: Adjust returns when power_profile_mode is not supported Mario Limonciello
2021-11-01 21:28 ` [PATCH v3 3/3] drm/amdgpu/pm: Don't show pp_power_profile_mode for unsupported devices Mario Limonciello
0 siblings, 2 replies; 4+ messages in thread
From: Mario Limonciello @ 2021-11-01 21:28 UTC (permalink / raw)
To: amd-gfx; +Cc: Mario Limonciello
Prevent possible issues from set and get being called simultaneously.
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
Changes from v2->v3:
* New patch
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c b/drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c
index 321215003643..978007664e71 100644
--- a/drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c
+++ b/drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c
@@ -875,6 +875,7 @@ pp_dpm_get_vce_clock_state(void *handle, unsigned idx)
static int pp_get_power_profile_mode(void *handle, char *buf)
{
struct pp_hwmgr *hwmgr = handle;
+ int ret;
if (!hwmgr || !hwmgr->pm_en || !buf)
return -EINVAL;
@@ -884,7 +885,10 @@ static int pp_get_power_profile_mode(void *handle, char *buf)
return snprintf(buf, PAGE_SIZE, "\n");
}
- return hwmgr->hwmgr_func->get_power_profile_mode(hwmgr, buf);
+ mutex_lock(&hwmgr->smu_lock);
+ ret = hwmgr->hwmgr_func->get_power_profile_mode(hwmgr, buf);
+ mutex_unlock(&hwmgr->smu_lock);
+ return ret;
}
static int pp_set_power_profile_mode(void *handle, long *input, uint32_t size)
--
2.25.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v3 2/3] drm/amd/pm: Adjust returns when power_profile_mode is not supported
2021-11-01 21:28 [PATCH v3 1/3] drm/amd/pm: Add missing mutex for pp_get_power_profile_mode Mario Limonciello
@ 2021-11-01 21:28 ` Mario Limonciello
2021-11-01 21:28 ` [PATCH v3 3/3] drm/amdgpu/pm: Don't show pp_power_profile_mode for unsupported devices Mario Limonciello
1 sibling, 0 replies; 4+ messages in thread
From: Mario Limonciello @ 2021-11-01 21:28 UTC (permalink / raw)
To: amd-gfx; +Cc: Mario Limonciello
This better aligns that the caller can make a mistake with the buffer
and -EINVAL should be returned, but if the hardware doesn't support
the feature it should be -EOPNOTSUPP.
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
Changes from v2->v3:
* New patch
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c b/drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c
index 978007664e71..79e565121206 100644
--- a/drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c
+++ b/drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c
@@ -877,7 +877,9 @@ static int pp_get_power_profile_mode(void *handle, char *buf)
struct pp_hwmgr *hwmgr = handle;
int ret;
- if (!hwmgr || !hwmgr->pm_en || !buf)
+ if (!hwmgr || !hwmgr->pm_en)
+ return -EOPNOTSUPP;
+ if (!buf)
return -EINVAL;
if (hwmgr->hwmgr_func->get_power_profile_mode == NULL) {
@@ -894,7 +896,7 @@ static int pp_get_power_profile_mode(void *handle, char *buf)
static int pp_set_power_profile_mode(void *handle, long *input, uint32_t size)
{
struct pp_hwmgr *hwmgr = handle;
- int ret = -EINVAL;
+ int ret = -EOPNOTSUPP;
if (!hwmgr || !hwmgr->pm_en)
return ret;
@@ -906,7 +908,7 @@ static int pp_set_power_profile_mode(void *handle, long *input, uint32_t size)
if (hwmgr->dpm_level != AMD_DPM_FORCED_LEVEL_MANUAL) {
pr_debug("power profile setting is for manual dpm mode only.\n");
- return ret;
+ return -EINVAL;
}
mutex_lock(&hwmgr->smu_lock);
--
2.25.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v3 3/3] drm/amdgpu/pm: Don't show pp_power_profile_mode for unsupported devices
2021-11-01 21:28 [PATCH v3 1/3] drm/amd/pm: Add missing mutex for pp_get_power_profile_mode Mario Limonciello
2021-11-01 21:28 ` [PATCH v3 2/3] drm/amd/pm: Adjust returns when power_profile_mode is not supported Mario Limonciello
@ 2021-11-01 21:28 ` Mario Limonciello
2021-11-02 8:17 ` Lazar, Lijo
1 sibling, 1 reply; 4+ messages in thread
From: Mario Limonciello @ 2021-11-01 21:28 UTC (permalink / raw)
To: amd-gfx; +Cc: Alex Deucher, Mario Limonciello
This command corresponding to this attribute was deprecated in the PMFW
for YC so don't show a non-functional attribute.
Verify that the function has been implemented by the subsystem.
Suggested-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
Changes from v2->v3:
* Handle powerplay to return this as well
drivers/gpu/drm/amd/pm/amdgpu_pm.c | 4 ++++
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c | 14 ++------------
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 11 +++++++----
3 files changed, 13 insertions(+), 16 deletions(-)
diff --git a/drivers/gpu/drm/amd/pm/amdgpu_pm.c b/drivers/gpu/drm/amd/pm/amdgpu_pm.c
index 49fe4155c374..41472ed99253 100644
--- a/drivers/gpu/drm/amd/pm/amdgpu_pm.c
+++ b/drivers/gpu/drm/amd/pm/amdgpu_pm.c
@@ -2094,6 +2094,10 @@ static int default_attr_update(struct amdgpu_device *adev, struct amdgpu_device_
} else if (DEVICE_ATTR_IS(pp_dpm_dclk)) {
if (!(asic_type == CHIP_VANGOGH || asic_type == CHIP_SIENNA_CICHLID))
*states = ATTR_STATE_UNSUPPORTED;
+ } else if (DEVICE_ATTR_IS(pp_power_profile_mode)) {
+ if (!adev->powerplay.pp_funcs->get_power_profile_mode ||
+ amdgpu_dpm_get_power_profile_mode(adev, NULL) == -EOPNOTSUPP)
+ *states = ATTR_STATE_UNSUPPORTED;
}
switch (asic_type) {
diff --git a/drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c b/drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c
index 79e565121206..8d796ed3b7d1 100644
--- a/drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c
+++ b/drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c
@@ -877,16 +877,11 @@ static int pp_get_power_profile_mode(void *handle, char *buf)
struct pp_hwmgr *hwmgr = handle;
int ret;
- if (!hwmgr || !hwmgr->pm_en)
+ if (!hwmgr || !hwmgr->pm_en || !hwmgr->hwmgr_func->get_power_profile_mode)
return -EOPNOTSUPP;
if (!buf)
return -EINVAL;
- if (hwmgr->hwmgr_func->get_power_profile_mode == NULL) {
- pr_info_ratelimited("%s was not implemented.\n", __func__);
- return snprintf(buf, PAGE_SIZE, "\n");
- }
-
mutex_lock(&hwmgr->smu_lock);
ret = hwmgr->hwmgr_func->get_power_profile_mode(hwmgr, buf);
mutex_unlock(&hwmgr->smu_lock);
@@ -898,13 +893,8 @@ static int pp_set_power_profile_mode(void *handle, long *input, uint32_t size)
struct pp_hwmgr *hwmgr = handle;
int ret = -EOPNOTSUPP;
- if (!hwmgr || !hwmgr->pm_en)
- return ret;
-
- if (hwmgr->hwmgr_func->set_power_profile_mode == NULL) {
- pr_info_ratelimited("%s was not implemented.\n", __func__);
+ if (!hwmgr || !hwmgr->pm_en || !hwmgr->hwmgr_func->set_power_profile_mode)
return ret;
- }
if (hwmgr->dpm_level != AMD_DPM_FORCED_LEVEL_MANUAL) {
pr_debug("power profile setting is for manual dpm mode only.\n");
diff --git a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
index b06c59dcc1b4..821ae6e78703 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
@@ -2534,13 +2534,15 @@ static int smu_get_power_profile_mode(void *handle, char *buf)
struct smu_context *smu = handle;
int ret = 0;
- if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
+ if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled ||
+ !smu->ppt_funcs->get_power_profile_mode)
return -EOPNOTSUPP;
+ if (!buf)
+ return -EINVAL;
mutex_lock(&smu->mutex);
- if (smu->ppt_funcs->get_power_profile_mode)
- ret = smu->ppt_funcs->get_power_profile_mode(smu, buf);
+ ret = smu->ppt_funcs->get_power_profile_mode(smu, buf);
mutex_unlock(&smu->mutex);
@@ -2554,7 +2556,8 @@ static int smu_set_power_profile_mode(void *handle,
struct smu_context *smu = handle;
int ret = 0;
- if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
+ if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled ||
+ !smu->ppt_funcs->set_power_profile_mode)
return -EOPNOTSUPP;
mutex_lock(&smu->mutex);
--
2.25.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v3 3/3] drm/amdgpu/pm: Don't show pp_power_profile_mode for unsupported devices
2021-11-01 21:28 ` [PATCH v3 3/3] drm/amdgpu/pm: Don't show pp_power_profile_mode for unsupported devices Mario Limonciello
@ 2021-11-02 8:17 ` Lazar, Lijo
0 siblings, 0 replies; 4+ messages in thread
From: Lazar, Lijo @ 2021-11-02 8:17 UTC (permalink / raw)
To: Mario Limonciello, amd-gfx; +Cc: Alex Deucher
On 11/2/2021 2:58 AM, Mario Limonciello wrote:
> This command corresponding to this attribute was deprecated in the PMFW
> for YC so don't show a non-functional attribute.
>
Now it's a generic patch, not specific to YC. Maybe a generic one like
"for ASICs not supporting power profile mode, don't show the attribute".
Series is
Reviewed-by: Lijo Lazar <lijo.lazar@amd.com>
Thanks,
Lijo
> Verify that the function has been implemented by the subsystem.
>
> Suggested-by: Alex Deucher <alexander.deucher@amd.com>
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> ---
> Changes from v2->v3:
> * Handle powerplay to return this as well
>
> drivers/gpu/drm/amd/pm/amdgpu_pm.c | 4 ++++
> drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c | 14 ++------------
> drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 11 +++++++----
> 3 files changed, 13 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/pm/amdgpu_pm.c b/drivers/gpu/drm/amd/pm/amdgpu_pm.c
> index 49fe4155c374..41472ed99253 100644
> --- a/drivers/gpu/drm/amd/pm/amdgpu_pm.c
> +++ b/drivers/gpu/drm/amd/pm/amdgpu_pm.c
> @@ -2094,6 +2094,10 @@ static int default_attr_update(struct amdgpu_device *adev, struct amdgpu_device_
> } else if (DEVICE_ATTR_IS(pp_dpm_dclk)) {
> if (!(asic_type == CHIP_VANGOGH || asic_type == CHIP_SIENNA_CICHLID))
> *states = ATTR_STATE_UNSUPPORTED;
> + } else if (DEVICE_ATTR_IS(pp_power_profile_mode)) {
> + if (!adev->powerplay.pp_funcs->get_power_profile_mode ||
> + amdgpu_dpm_get_power_profile_mode(adev, NULL) == -EOPNOTSUPP)
> + *states = ATTR_STATE_UNSUPPORTED;
> }
>
> switch (asic_type) {
> diff --git a/drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c b/drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c
> index 79e565121206..8d796ed3b7d1 100644
> --- a/drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c
> +++ b/drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c
> @@ -877,16 +877,11 @@ static int pp_get_power_profile_mode(void *handle, char *buf)
> struct pp_hwmgr *hwmgr = handle;
> int ret;
>
> - if (!hwmgr || !hwmgr->pm_en)
> + if (!hwmgr || !hwmgr->pm_en || !hwmgr->hwmgr_func->get_power_profile_mode)
> return -EOPNOTSUPP;
> if (!buf)
> return -EINVAL;
>
> - if (hwmgr->hwmgr_func->get_power_profile_mode == NULL) {
> - pr_info_ratelimited("%s was not implemented.\n", __func__);
> - return snprintf(buf, PAGE_SIZE, "\n");
> - }
> -
> mutex_lock(&hwmgr->smu_lock);
> ret = hwmgr->hwmgr_func->get_power_profile_mode(hwmgr, buf);
> mutex_unlock(&hwmgr->smu_lock);
> @@ -898,13 +893,8 @@ static int pp_set_power_profile_mode(void *handle, long *input, uint32_t size)
> struct pp_hwmgr *hwmgr = handle;
> int ret = -EOPNOTSUPP;
>
> - if (!hwmgr || !hwmgr->pm_en)
> - return ret;
> -
> - if (hwmgr->hwmgr_func->set_power_profile_mode == NULL) {
> - pr_info_ratelimited("%s was not implemented.\n", __func__);
> + if (!hwmgr || !hwmgr->pm_en || !hwmgr->hwmgr_func->set_power_profile_mode)
> return ret;
> - }
>
> if (hwmgr->dpm_level != AMD_DPM_FORCED_LEVEL_MANUAL) {
> pr_debug("power profile setting is for manual dpm mode only.\n");
> diff --git a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
> index b06c59dcc1b4..821ae6e78703 100644
> --- a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
> +++ b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
> @@ -2534,13 +2534,15 @@ static int smu_get_power_profile_mode(void *handle, char *buf)
> struct smu_context *smu = handle;
> int ret = 0;
>
> - if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
> + if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled ||
> + !smu->ppt_funcs->get_power_profile_mode)
> return -EOPNOTSUPP;
> + if (!buf)
> + return -EINVAL;
>
> mutex_lock(&smu->mutex);
>
> - if (smu->ppt_funcs->get_power_profile_mode)
> - ret = smu->ppt_funcs->get_power_profile_mode(smu, buf);
> + ret = smu->ppt_funcs->get_power_profile_mode(smu, buf);
>
> mutex_unlock(&smu->mutex);
>
> @@ -2554,7 +2556,8 @@ static int smu_set_power_profile_mode(void *handle,
> struct smu_context *smu = handle;
> int ret = 0;
>
> - if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
> + if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled ||
> + !smu->ppt_funcs->set_power_profile_mode)
> return -EOPNOTSUPP;
>
> mutex_lock(&smu->mutex);
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-11-02 8:17 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-01 21:28 [PATCH v3 1/3] drm/amd/pm: Add missing mutex for pp_get_power_profile_mode Mario Limonciello
2021-11-01 21:28 ` [PATCH v3 2/3] drm/amd/pm: Adjust returns when power_profile_mode is not supported Mario Limonciello
2021-11-01 21:28 ` [PATCH v3 3/3] drm/amdgpu/pm: Don't show pp_power_profile_mode for unsupported devices Mario Limonciello
2021-11-02 8:17 ` Lazar, Lijo
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.