diff mbox

drm: Set the plane's crtc before calling disable_plane.

Message ID 1393882716-20789-1-git-send-email-marcheu@chromium.org (mailing list archive)
State New, archived
Headers show

Commit Message

Stéphane Marchesin March 3, 2014, 9:38 p.m. UTC
Some drivers like exynos need the crtc to be able to disable the plane,
so set it before calling disable_plane.

Signed-off-by: Stéphane Marchesin <marcheu@chromium.org>
---
 drivers/gpu/drm/drm_crtc.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

Comments

Stéphane Marchesin March 3, 2014, 10:51 p.m. UTC | #1
On Mon, Mar 3, 2014 at 2:06 PM, Rob Clark <robdclark@gmail.com> wrote:
> On Mon, Mar 3, 2014 at 4:45 PM, Jesse Barnes <jbarnes@virtuousgeek.org> wrote:
>> On Mon,  3 Mar 2014 13:38:36 -0800
>> Stéphane Marchesin <marcheu@chromium.org> wrote:
>>
>>> Some drivers like exynos need the crtc to be able to disable the plane,
>>> so set it before calling disable_plane.
>>>
>>> Signed-off-by: Stéphane Marchesin <marcheu@chromium.org>
>>> ---
>>>  drivers/gpu/drm/drm_crtc.c | 21 +++++++++++----------
>>>  1 file changed, 11 insertions(+), 10 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
>>> index 3b7d32d..0943316 100644
>>> --- a/drivers/gpu/drm/drm_crtc.c
>>> +++ b/drivers/gpu/drm/drm_crtc.c
>>> @@ -1947,10 +1947,21 @@ int drm_mode_setplane(struct drm_device *dev, void *data,
>>>       }
>>>       plane = obj_to_plane(obj);
>>>
>>> +     obj = drm_mode_object_find(dev, plane_req->crtc_id,
>>> +                                DRM_MODE_OBJECT_CRTC);
>>> +     if (!obj) {
>>> +             DRM_DEBUG_KMS("Unknown crtc ID %d\n",
>>> +                           plane_req->crtc_id);
>>> +             ret = -ENOENT;
>>> +             goto out;
>>> +     }
>>> +     crtc = obj_to_crtc(obj);
>>> +
>>>       /* No fb means shut it down */
>>>       if (!plane_req->fb_id) {
>>>               drm_modeset_lock_all(dev);
>>>               old_fb = plane->fb;
>>> +             plane->crtc = crtc;
>
> just curious, but how is the plane ending up enabled *without* a crtc?
>  That sounds a bit.. odd..

Yup it has a crtc, but the plane->crtc is set to NULL just before we
call disable_plane(), and so disable_plane() can't rely on the crtc...

Stéphane

>
> BR,
> -R
>
>>>               plane->funcs->disable_plane(plane);
>>>               plane->crtc = NULL;
>>>               plane->fb = NULL;
>>> @@ -1958,16 +1969,6 @@ int drm_mode_setplane(struct drm_device *dev, void *data,
>>>               goto out;
>>>       }
>>>
>>> -     obj = drm_mode_object_find(dev, plane_req->crtc_id,
>>> -                                DRM_MODE_OBJECT_CRTC);
>>> -     if (!obj) {
>>> -             DRM_DEBUG_KMS("Unknown crtc ID %d\n",
>>> -                           plane_req->crtc_id);
>>> -             ret = -ENOENT;
>>> -             goto out;
>>> -     }
>>> -     crtc = obj_to_crtc(obj);
>>> -
>>>       fb = drm_framebuffer_lookup(dev, plane_req->fb_id);
>>>       if (!fb) {
>>>               DRM_DEBUG_KMS("Unknown framebuffer ID %d\n",
>>
>> I'm pretty sure this is ok since we don't have much userspace using
>> this that might fail to pass in a crtc when shutting down a plane...
>>
>> Reviewed-by: Jesse Barnes <jbarnes@virtuousgeek.org>
>>
>> --
>> Jesse Barnes, Intel Open Source Technology Center
>> _______________________________________________
>> dri-devel mailing list
>> dri-devel@lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/dri-devel
diff mbox

Patch

diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 3b7d32d..0943316 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -1947,10 +1947,21 @@  int drm_mode_setplane(struct drm_device *dev, void *data,
 	}
 	plane = obj_to_plane(obj);
 
+	obj = drm_mode_object_find(dev, plane_req->crtc_id,
+				   DRM_MODE_OBJECT_CRTC);
+	if (!obj) {
+		DRM_DEBUG_KMS("Unknown crtc ID %d\n",
+			      plane_req->crtc_id);
+		ret = -ENOENT;
+		goto out;
+	}
+	crtc = obj_to_crtc(obj);
+
 	/* No fb means shut it down */
 	if (!plane_req->fb_id) {
 		drm_modeset_lock_all(dev);
 		old_fb = plane->fb;
+		plane->crtc = crtc;
 		plane->funcs->disable_plane(plane);
 		plane->crtc = NULL;
 		plane->fb = NULL;
@@ -1958,16 +1969,6 @@  int drm_mode_setplane(struct drm_device *dev, void *data,
 		goto out;
 	}
 
-	obj = drm_mode_object_find(dev, plane_req->crtc_id,
-				   DRM_MODE_OBJECT_CRTC);
-	if (!obj) {
-		DRM_DEBUG_KMS("Unknown crtc ID %d\n",
-			      plane_req->crtc_id);
-		ret = -ENOENT;
-		goto out;
-	}
-	crtc = obj_to_crtc(obj);
-
 	fb = drm_framebuffer_lookup(dev, plane_req->fb_id);
 	if (!fb) {
 		DRM_DEBUG_KMS("Unknown framebuffer ID %d\n",