diff options
author | Daniel Vetter <daniel.vetter@ffwll.ch> | 2018-12-17 14:43:00 -0500 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2019-01-11 16:54:29 -0500 |
commit | c2d88e06bcb98540bb83fac874574eaa4f320363 (patch) | |
tree | 6178dcb03cf21b1bfbc5704244ab4ef5176a737b | |
parent | 324bb707d2a53256f3c04ba2e86048427e2a822c (diff) |
drm: Move the legacy kms disable_all helper to crtc helpers
It's not a core function, and the matching atomic functions are also
not in the core. Plus the suspend/resume helper is also already there.
Needs a tiny bit of open-coding, but less midlayer beats that I think.
v2: Rebase onto ast (which gained a new user).
Cc: Sam Bobroff <sbobroff@linux.ibm.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Sean Paul <sean@poorly.run>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Maxime Ripard <maxime.ripard@bootlin.com>
Cc: Sean Paul <sean@poorly.run>
Cc: David Airlie <airlied@linux.ie>
Cc: Ben Skeggs <bskeggs@redhat.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: "Christian König" <christian.koenig@amd.com>
Cc: "David (ChunMing) Zhou" <David1.Zhou@amd.com>
Cc: Rex Zhu <Rex.Zhu@amd.com>
Cc: Andrey Grodzovsky <andrey.grodzovsky@amd.com>
Cc: Huang Rui <ray.huang@amd.com>
Cc: Shaoyun Liu <Shaoyun.Liu@amd.com>
Cc: Monk Liu <Monk.Liu@amd.com>
Cc: nouveau@lists.freedesktop.org
Cc: amd-gfx@lists.freedesktop.org
Link: https://patchwork.freedesktop.org/patch/msgid/20181217194303.14397-4-daniel.vetter@ffwll.ch
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/ast/ast_fb.c | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/drm_crtc.c | 31 | ||||
-rw-r--r-- | drivers/gpu/drm/drm_crtc_helper.c | 35 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nouveau_display.c | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_display.c | 2 | ||||
-rw-r--r-- | include/drm/drm_crtc.h | 2 | ||||
-rw-r--r-- | include/drm/drm_crtc_helper.h | 1 |
8 files changed, 40 insertions, 37 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index 8a078f4ae73d..28bccceaa363 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | |||
@@ -2708,7 +2708,7 @@ void amdgpu_device_fini(struct amdgpu_device *adev) | |||
2708 | amdgpu_irq_disable_all(adev); | 2708 | amdgpu_irq_disable_all(adev); |
2709 | if (adev->mode_info.mode_config_initialized){ | 2709 | if (adev->mode_info.mode_config_initialized){ |
2710 | if (!amdgpu_device_has_dc_support(adev)) | 2710 | if (!amdgpu_device_has_dc_support(adev)) |
2711 | drm_crtc_force_disable_all(adev->ddev); | 2711 | drm_helper_force_disable_all(adev->ddev); |
2712 | else | 2712 | else |
2713 | drm_atomic_helper_shutdown(adev->ddev); | 2713 | drm_atomic_helper_shutdown(adev->ddev); |
2714 | } | 2714 | } |
diff --git a/drivers/gpu/drm/ast/ast_fb.c b/drivers/gpu/drm/ast/ast_fb.c index c2e41369adcf..75f867d00031 100644 --- a/drivers/gpu/drm/ast/ast_fb.c +++ b/drivers/gpu/drm/ast/ast_fb.c | |||
@@ -261,7 +261,7 @@ static void ast_fbdev_destroy(struct drm_device *dev, | |||
261 | { | 261 | { |
262 | struct ast_framebuffer *afb = &afbdev->afb; | 262 | struct ast_framebuffer *afb = &afbdev->afb; |
263 | 263 | ||
264 | drm_crtc_force_disable_all(dev); | 264 | drm_helper_force_disable_all(dev); |
265 | drm_fb_helper_unregister_fbi(&afbdev->helper); | 265 | drm_fb_helper_unregister_fbi(&afbdev->helper); |
266 | 266 | ||
267 | if (afb->obj) { | 267 | if (afb->obj) { |
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index f660819d406e..7dabbaf033a1 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c | |||
@@ -104,37 +104,6 @@ int drm_crtc_force_disable(struct drm_crtc *crtc) | |||
104 | return drm_mode_set_config_internal(&set); | 104 | return drm_mode_set_config_internal(&set); |
105 | } | 105 | } |
106 | 106 | ||
107 | /** | ||
108 | * drm_crtc_force_disable_all - Forcibly turn off all enabled CRTCs | ||
109 | * @dev: DRM device whose CRTCs to turn off | ||
110 | * | ||
111 | * Drivers may want to call this on unload to ensure that all displays are | ||
112 | * unlit and the GPU is in a consistent, low power state. Takes modeset locks. | ||
113 | * | ||
114 | * Note: This should only be used by non-atomic legacy drivers. For an atomic | ||
115 | * version look at drm_atomic_helper_shutdown(). | ||
116 | * | ||
117 | * Returns: | ||
118 | * Zero on success, error code on failure. | ||
119 | */ | ||
120 | int drm_crtc_force_disable_all(struct drm_device *dev) | ||
121 | { | ||
122 | struct drm_crtc *crtc; | ||
123 | int ret = 0; | ||
124 | |||
125 | drm_modeset_lock_all(dev); | ||
126 | drm_for_each_crtc(crtc, dev) | ||
127 | if (crtc->enabled) { | ||
128 | ret = drm_crtc_force_disable(crtc); | ||
129 | if (ret) | ||
130 | goto out; | ||
131 | } | ||
132 | out: | ||
133 | drm_modeset_unlock_all(dev); | ||
134 | return ret; | ||
135 | } | ||
136 | EXPORT_SYMBOL(drm_crtc_force_disable_all); | ||
137 | |||
138 | static unsigned int drm_num_crtcs(struct drm_device *dev) | 107 | static unsigned int drm_num_crtcs(struct drm_device *dev) |
139 | { | 108 | { |
140 | unsigned int num = 0; | 109 | unsigned int num = 0; |
diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c index 3b5cf93233c1..91dc9b6386e7 100644 --- a/drivers/gpu/drm/drm_crtc_helper.c +++ b/drivers/gpu/drm/drm_crtc_helper.c | |||
@@ -994,3 +994,38 @@ void drm_helper_resume_force_mode(struct drm_device *dev) | |||
994 | drm_modeset_unlock_all(dev); | 994 | drm_modeset_unlock_all(dev); |
995 | } | 995 | } |
996 | EXPORT_SYMBOL(drm_helper_resume_force_mode); | 996 | EXPORT_SYMBOL(drm_helper_resume_force_mode); |
997 | |||
998 | /** | ||
999 | * drm_helper_force_disable_all - Forcibly turn off all enabled CRTCs | ||
1000 | * @dev: DRM device whose CRTCs to turn off | ||
1001 | * | ||
1002 | * Drivers may want to call this on unload to ensure that all displays are | ||
1003 | * unlit and the GPU is in a consistent, low power state. Takes modeset locks. | ||
1004 | * | ||
1005 | * Note: This should only be used by non-atomic legacy drivers. For an atomic | ||
1006 | * version look at drm_atomic_helper_shutdown(). | ||
1007 | * | ||
1008 | * Returns: | ||
1009 | * Zero on success, error code on failure. | ||
1010 | */ | ||
1011 | int drm_helper_force_disable_all(struct drm_device *dev) | ||
1012 | { | ||
1013 | struct drm_crtc *crtc; | ||
1014 | int ret = 0; | ||
1015 | |||
1016 | drm_modeset_lock_all(dev); | ||
1017 | drm_for_each_crtc(crtc, dev) | ||
1018 | if (crtc->enabled) { | ||
1019 | struct drm_mode_set set = { | ||
1020 | .crtc = crtc, | ||
1021 | }; | ||
1022 | |||
1023 | ret = drm_mode_set_config_internal(&set); | ||
1024 | if (ret) | ||
1025 | goto out; | ||
1026 | } | ||
1027 | out: | ||
1028 | drm_modeset_unlock_all(dev); | ||
1029 | return ret; | ||
1030 | } | ||
1031 | EXPORT_SYMBOL(drm_helper_force_disable_all); | ||
diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c b/drivers/gpu/drm/nouveau/nouveau_display.c index f326ffd86766..5d273a655479 100644 --- a/drivers/gpu/drm/nouveau/nouveau_display.c +++ b/drivers/gpu/drm/nouveau/nouveau_display.c | |||
@@ -453,7 +453,7 @@ nouveau_display_fini(struct drm_device *dev, bool suspend, bool runtime) | |||
453 | if (drm_drv_uses_atomic_modeset(dev)) | 453 | if (drm_drv_uses_atomic_modeset(dev)) |
454 | drm_atomic_helper_shutdown(dev); | 454 | drm_atomic_helper_shutdown(dev); |
455 | else | 455 | else |
456 | drm_crtc_force_disable_all(dev); | 456 | drm_helper_force_disable_all(dev); |
457 | } | 457 | } |
458 | 458 | ||
459 | /* disable flip completion events */ | 459 | /* disable flip completion events */ |
diff --git a/drivers/gpu/drm/radeon/radeon_display.c b/drivers/gpu/drm/radeon/radeon_display.c index 9d3ac8b981da..b190478ad087 100644 --- a/drivers/gpu/drm/radeon/radeon_display.c +++ b/drivers/gpu/drm/radeon/radeon_display.c | |||
@@ -1646,7 +1646,7 @@ void radeon_modeset_fini(struct radeon_device *rdev) | |||
1646 | if (rdev->mode_info.mode_config_initialized) { | 1646 | if (rdev->mode_info.mode_config_initialized) { |
1647 | drm_kms_helper_poll_fini(rdev->ddev); | 1647 | drm_kms_helper_poll_fini(rdev->ddev); |
1648 | radeon_hpd_fini(rdev); | 1648 | radeon_hpd_fini(rdev); |
1649 | drm_crtc_force_disable_all(rdev->ddev); | 1649 | drm_helper_force_disable_all(rdev->ddev); |
1650 | radeon_fbdev_fini(rdev); | 1650 | radeon_fbdev_fini(rdev); |
1651 | radeon_afmt_fini(rdev); | 1651 | radeon_afmt_fini(rdev); |
1652 | drm_mode_config_cleanup(rdev->ddev); | 1652 | drm_mode_config_cleanup(rdev->ddev); |
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h index b45bec0b7a9c..85abd3fe9e83 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h | |||
@@ -1149,8 +1149,6 @@ static inline uint32_t drm_crtc_mask(const struct drm_crtc *crtc) | |||
1149 | return 1 << drm_crtc_index(crtc); | 1149 | return 1 << drm_crtc_index(crtc); |
1150 | } | 1150 | } |
1151 | 1151 | ||
1152 | int drm_crtc_force_disable_all(struct drm_device *dev); | ||
1153 | |||
1154 | int drm_mode_set_config_internal(struct drm_mode_set *set); | 1152 | int drm_mode_set_config_internal(struct drm_mode_set *set); |
1155 | struct drm_crtc *drm_crtc_from_index(struct drm_device *dev, int idx); | 1153 | struct drm_crtc *drm_crtc_from_index(struct drm_device *dev, int idx); |
1156 | 1154 | ||
diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h index d65f034843ce..0ee9a96b70da 100644 --- a/include/drm/drm_crtc_helper.h +++ b/include/drm/drm_crtc_helper.h | |||
@@ -56,6 +56,7 @@ bool drm_helper_encoder_in_use(struct drm_encoder *encoder); | |||
56 | int drm_helper_connector_dpms(struct drm_connector *connector, int mode); | 56 | int drm_helper_connector_dpms(struct drm_connector *connector, int mode); |
57 | 57 | ||
58 | void drm_helper_resume_force_mode(struct drm_device *dev); | 58 | void drm_helper_resume_force_mode(struct drm_device *dev); |
59 | int drm_helper_force_disable_all(struct drm_device *dev); | ||
59 | 60 | ||
60 | /* drm_probe_helper.c */ | 61 | /* drm_probe_helper.c */ |
61 | int drm_helper_probe_single_connector_modes(struct drm_connector | 62 | int drm_helper_probe_single_connector_modes(struct drm_connector |