Skip to content

Commit 0c67df4

Browse files
committed
drm/amdgpu/pm: add some checks for PX
I.e., doesn't make sense to change power states or check the temperature when the asic is powered off. Reviewed-by: Christian König <christian.koenig@amd.com> Acked-by: Harry Wentland <harry.wentland@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent 10f950f commit 0c67df4

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ static ssize_t amdgpu_get_dpm_forced_performance_level(struct device *dev,
113113
struct drm_device *ddev = dev_get_drvdata(dev);
114114
struct amdgpu_device *adev = ddev->dev_private;
115115

116+
if ((adev->flags & AMD_IS_PX) &&
117+
(ddev->switch_power_state != DRM_SWITCH_POWER_ON))
118+
return snprintf(buf, PAGE_SIZE, "off\n");
119+
116120
if (adev->pp_enabled) {
117121
enum amd_dpm_forced_level level;
118122

@@ -140,6 +144,11 @@ static ssize_t amdgpu_set_dpm_forced_performance_level(struct device *dev,
140144
enum amdgpu_dpm_forced_level level;
141145
int ret = 0;
142146

147+
/* Can't force performance level when the card is off */
148+
if ((adev->flags & AMD_IS_PX) &&
149+
(ddev->switch_power_state != DRM_SWITCH_POWER_ON))
150+
return -EINVAL;
151+
143152
if (strncmp("low", buf, strlen("low")) == 0) {
144153
level = AMDGPU_DPM_FORCED_LEVEL_LOW;
145154
} else if (strncmp("high", buf, strlen("high")) == 0) {
@@ -181,8 +190,14 @@ static ssize_t amdgpu_hwmon_show_temp(struct device *dev,
181190
char *buf)
182191
{
183192
struct amdgpu_device *adev = dev_get_drvdata(dev);
193+
struct drm_device *ddev = adev->ddev;
184194
int temp;
185195

196+
/* Can't get temperature when the card is off */
197+
if ((adev->flags & AMD_IS_PX) &&
198+
(ddev->switch_power_state != DRM_SWITCH_POWER_ON))
199+
return -EINVAL;
200+
186201
if (!adev->pp_enabled && !adev->pm.funcs->get_temperature)
187202
temp = 0;
188203
else
@@ -846,12 +861,16 @@ static int amdgpu_debugfs_pm_info(struct seq_file *m, void *data)
846861
struct drm_info_node *node = (struct drm_info_node *) m->private;
847862
struct drm_device *dev = node->minor->dev;
848863
struct amdgpu_device *adev = dev->dev_private;
864+
struct drm_device *ddev = adev->ddev;
849865

850866
if (!adev->pm.dpm_enabled) {
851867
seq_printf(m, "dpm not enabled\n");
852868
return 0;
853869
}
854-
if (adev->pp_enabled) {
870+
if ((adev->flags & AMD_IS_PX) &&
871+
(ddev->switch_power_state != DRM_SWITCH_POWER_ON)) {
872+
seq_printf(m, "PX asic powered off\n");
873+
} else if (adev->pp_enabled) {
855874
amdgpu_dpm_debugfs_print_current_performance_level(adev, m);
856875
} else {
857876
mutex_lock(&adev->pm.mutex);

0 commit comments

Comments
 (0)