Skip to content

Commit 97f6a21

Browse files
Andrey Grodzovskyalexdeucher
authored andcommitted
drm/amdgpu: Enter low power state if CRTC active.
CRTC in DPMS state off calls for low power state entry. Support both atomic mode setting and pre-atomic mode setting. v2: move comment Acked-by: Feifei Xu <[email protected]> Signed-off-by: Andrey Grodzovsky <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent aec0f26 commit 97f6a21

File tree

1 file changed

+38
-7
lines changed

1 file changed

+38
-7
lines changed

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

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,24 +1299,55 @@ static int amdgpu_pmops_runtime_idle(struct device *dev)
12991299
{
13001300
struct drm_device *drm_dev = dev_get_drvdata(dev);
13011301
struct amdgpu_device *adev = drm_dev->dev_private;
1302-
struct drm_crtc *crtc;
1302+
/* we don't want the main rpm_idle to call suspend - we want to autosuspend */
1303+
int ret = 1;
13031304

13041305
if (!adev->runpm) {
13051306
pm_runtime_forbid(dev);
13061307
return -EBUSY;
13071308
}
13081309

1309-
list_for_each_entry(crtc, &drm_dev->mode_config.crtc_list, head) {
1310-
if (crtc->enabled) {
1311-
DRM_DEBUG_DRIVER("failing to power off - crtc active\n");
1312-
return -EBUSY;
1310+
if (amdgpu_device_has_dc_support(adev)) {
1311+
struct drm_crtc *crtc;
1312+
1313+
drm_modeset_lock_all(drm_dev);
1314+
1315+
drm_for_each_crtc(crtc, drm_dev) {
1316+
if (crtc->state->active) {
1317+
ret = -EBUSY;
1318+
break;
1319+
}
13131320
}
1321+
1322+
drm_modeset_unlock_all(drm_dev);
1323+
1324+
} else {
1325+
struct drm_connector *list_connector;
1326+
struct drm_connector_list_iter iter;
1327+
1328+
mutex_lock(&drm_dev->mode_config.mutex);
1329+
drm_modeset_lock(&drm_dev->mode_config.connection_mutex, NULL);
1330+
1331+
drm_connector_list_iter_begin(drm_dev, &iter);
1332+
drm_for_each_connector_iter(list_connector, &iter) {
1333+
if (list_connector->dpms == DRM_MODE_DPMS_ON) {
1334+
ret = -EBUSY;
1335+
break;
1336+
}
1337+
}
1338+
1339+
drm_connector_list_iter_end(&iter);
1340+
1341+
drm_modeset_unlock(&drm_dev->mode_config.connection_mutex);
1342+
mutex_unlock(&drm_dev->mode_config.mutex);
13141343
}
13151344

1345+
if (ret == -EBUSY)
1346+
DRM_DEBUG_DRIVER("failing to power off - crtc active\n");
1347+
13161348
pm_runtime_mark_last_busy(dev);
13171349
pm_runtime_autosuspend(dev);
1318-
/* we don't want the main rpm_idle to call suspend - we want to autosuspend */
1319-
return 1;
1350+
return ret;
13201351
}
13211352

13221353
long amdgpu_drm_ioctl(struct file *filp,

0 commit comments

Comments
 (0)