public inbox for dri-devel@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Matt Roper <matthew.d.roper@intel.com>
To: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Thierry Reding <treding@nvidia.com>,
	DRI Development <dri-devel@lists.freedesktop.org>
Subject: Re: [PATCH 2/2] drm: Handle ->disable_plane failures correctly
Date: Wed, 23 Apr 2014 07:47:33 -0700	[thread overview]
Message-ID: <20140423144733.GV1063@intel.com> (raw)
In-Reply-To: <1398241805-24564-2-git-send-email-daniel.vetter@ffwll.ch>

On Wed, Apr 23, 2014 at 10:30:05AM +0200, Daniel Vetter wrote:
> The ->disable_plane hook always had a return value, but only since the
> introduction of primary planes was there any implementation that
> actually failed.
> 
> So handle such failures correctly.
> 
> Note that drm_plane_force_disable is special: In the modeset cleanup
> case we first disable all crtc, so primary planes should all be freed
> already. And in the fb helper we only reset non-primary planes. Still
> better be paranoid and add an early return.
> 
> I don't see how this could happen, but it might fix the fb refcount
> underrun Thierry is seeing. Matt Roper spotted this issue.
> 
> Cc: Thierry Reding <treding@nvidia.com>
> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> Cc: Matt Roper <matthew.d.roper@intel.com>
> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>

Reviewed-by: Matt Roper <matthew.d.roper@intel.com>

> ---
>  drivers/gpu/drm/drm_crtc.c | 14 ++++++++++----
>  1 file changed, 10 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
> index f6633cb927bc..461d19bd14ee 100644
> --- a/drivers/gpu/drm/drm_crtc.c
> +++ b/drivers/gpu/drm/drm_crtc.c
> @@ -1152,8 +1152,10 @@ void drm_plane_force_disable(struct drm_plane *plane)
>  		return;
>  
>  	ret = plane->funcs->disable_plane(plane);
> -	if (ret)
> +	if (ret) {
>  		DRM_ERROR("failed to disable plane with busy fb\n");
> +		return;
> +	}
>  	/* disconnect the plane from the fb and crtc: */
>  	__drm_framebuffer_unreference(old_fb);
>  	plane->fb = NULL;
> @@ -2117,9 +2119,13 @@ int drm_mode_setplane(struct drm_device *dev, void *data,
>  	if (!plane_req->fb_id) {
>  		drm_modeset_lock_all(dev);
>  		old_fb = plane->fb;
> -		plane->funcs->disable_plane(plane);
> -		plane->crtc = NULL;
> -		plane->fb = NULL;
> +		ret = plane->funcs->disable_plane(plane);
> +		if (!ret) {
> +			plane->crtc = NULL;
> +			plane->fb = NULL;
> +		} else {
> +			old_fb = NULL;
> +		}
>  		drm_modeset_unlock_all(dev);
>  		goto out;
>  	}
> -- 
> 1.9.2
> 

-- 
Matt Roper
Graphics Software Engineer
IoTG Platform Enabling & Development
Intel Corporation
(916) 356-2795

  reply	other threads:[~2014-04-23 14:44 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-22  9:07 [PATCH] drm: Simplify fb refcounting rules around ->update_plane Daniel Vetter
2014-04-22  9:16 ` Thierry Reding
2014-04-22 10:06 ` Ville Syrjälä
2014-04-22 14:09   ` Daniel Vetter
2014-04-22 14:28     ` Ville Syrjälä
2014-04-22 14:37       ` Daniel Vetter
2014-04-22 14:19   ` Daniel Vetter
2014-04-23  1:08     ` Matt Roper
2014-04-23  6:36       ` Daniel Vetter
2014-04-23  6:41         ` Daniel Vetter
2014-04-23  8:30           ` [PATCH 1/2] " Daniel Vetter
2014-04-23  8:30             ` [PATCH 2/2] drm: Handle ->disable_plane failures correctly Daniel Vetter
2014-04-23 14:47               ` Matt Roper [this message]
2014-04-23 14:45             ` [PATCH 1/2] drm: Simplify fb refcounting rules around ->update_plane Matt Roper
2014-04-23 15:25               ` Daniel Vetter
2014-04-23 15:37                 ` [PATCH] " Daniel Vetter
2014-04-23 15:59                   ` Matt Roper

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140423144733.GV1063@intel.com \
    --to=matthew.d.roper@intel.com \
    --cc=daniel.vetter@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=treding@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox