Intel-GFX Archive on lore.kernel.org
 help / color / Atom feed
From: Jesse Barnes <jbarnes@virtuousgeek.org>
To: Chris Wilson <chris@chris-wilson.co.uk>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 02/11] drm/i915: Hold the spinlock whilst resetting unpin_work along error path
Date: Thu, 27 May 2010 09:03:02 -0700
Message-ID: <20100527090302.0e5a878e@virtuousgeek.org> (raw)
In-Reply-To: <1274962702-6530-3-git-send-email-chris@chris-wilson.co.uk>

On Thu, 27 May 2010 13:18:13 +0100
Chris Wilson <chris@chris-wilson.co.uk> wrote:

> Delay taking the mutex until we need to and ensure that we hold the
> spinlock when resetting unpin_work on the error path. Also defer the
> debugging print messages until after we have released the spinlock.
> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Jesse Barnes <jbarnes@virtuousgeek.org>
> Cc: Kristian Høgsberg <krh@bitplanet.net>
> ---
>  drivers/gpu/drm/i915/intel_display.c |   20 ++++++++++++--------
>  1 files changed, 12 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
> index cfac4dd..1845a06 100644
> --- a/drivers/gpu/drm/i915/intel_display.c
> +++ b/drivers/gpu/drm/i915/intel_display.c
> @@ -4667,8 +4667,6 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
>  	if (work == NULL)
>  		return -ENOMEM;
>  
> -	mutex_lock(&dev->struct_mutex);
> -
>  	work->event = event;
>  	work->dev = crtc->dev;
>  	intel_fb = to_intel_framebuffer(crtc->fb);
> @@ -4678,10 +4676,10 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
>  	/* We borrow the event spin lock for protecting unpin_work */
>  	spin_lock_irqsave(&dev->event_lock, flags);
>  	if (intel_crtc->unpin_work) {
> -		DRM_DEBUG_DRIVER("flip queue: crtc already busy\n");
>  		spin_unlock_irqrestore(&dev->event_lock, flags);
>  		kfree(work);
> -		mutex_unlock(&dev->struct_mutex);
> +
> +		DRM_DEBUG_DRIVER("flip queue: crtc already busy\n");
>  		return -EBUSY;
>  	}
>  	intel_crtc->unpin_work = work;
> @@ -4690,13 +4688,19 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
>  	intel_fb = to_intel_framebuffer(fb);
>  	obj = intel_fb->obj;
>  
> +	mutex_lock(&dev->struct_mutex);
>  	ret = intel_pin_and_fence_fb_obj(dev, obj);
>  	if (ret != 0) {
> -		DRM_DEBUG_DRIVER("flip queue: %p pin & fence failed\n",
> -			  to_intel_bo(obj));
> -		kfree(work);
> -		intel_crtc->unpin_work = NULL;
>  		mutex_unlock(&dev->struct_mutex);
> +
> +		spin_lock_irqsave(&dev->event_lock, flags);
> +		intel_crtc->unpin_work = NULL;
> +		spin_unlock_irqrestore(&dev->event_lock, flags);
> +
> +		kfree(work);
> +
> +		DRM_DEBUG_DRIVER("flip queue: %p pin & fence failed\n",
> +				 to_intel_bo(obj));
>  		return ret;
>  	}

The mutex change looks like a good cleanup, and the spin lock addition
is a good fix.  Thanks.

Reviewed-by: Jesse Barnes <jbarnes@virtuousgeek.org>

-- 
Jesse Barnes, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply index

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-27 12:18 A compendium of trivial patches Chris Wilson
2010-05-27 12:18 ` [PATCH 01/11] drm/i915: Only print an message if there was an error Chris Wilson
2010-05-27 12:18 ` [PATCH 02/11] drm/i915: Hold the spinlock whilst resetting unpin_work along error path Chris Wilson
2010-05-27 16:03   ` Jesse Barnes [this message]
2010-05-27 12:18 ` [PATCH 03/11] drm/i915: Avoid nesting of domain changes when setting display plane Chris Wilson
2010-05-27 12:18 ` [PATCH 04/11] drm/i915: Propagate error from unbinding an unfenceable object Chris Wilson
2010-05-27 16:05   ` Jesse Barnes
2010-05-27 16:32     ` Chris Wilson
2010-05-27 12:18 ` [PATCH 05/11] drm/i915: Only print "nothing to do" debug message as required Chris Wilson
2010-05-27 12:18 ` [PATCH 06/11] drm/i915: Include pitch in set_base debug statement Chris Wilson
2010-05-27 12:18 ` [PATCH 07/11] drm/i915: Rebind bo if currently bound with incorrect alignment Chris Wilson
2010-05-27 12:18 ` [PATCH 08/11] drm/i915: Remove spurious warning "Failure to install fence" Chris Wilson
2010-05-27 12:18 ` [PATCH 09/11] drm/i915: Check error code whilst moving buffer to GTT domain Chris Wilson
2010-05-27 12:18 ` [PATCH 10/11] drm/i915: Reject bind_to_gtt() early if object > aperture Chris Wilson
2010-05-27 12:18 ` [PATCH 11/11] drm/i915: Cleanup after failed initialization of ringbuffers Chris Wilson
2010-05-28 18:01   ` Eric Anholt

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=20100527090302.0e5a878e@virtuousgeek.org \
    --to=jbarnes@virtuousgeek.org \
    --cc=chris@chris-wilson.co.uk \
    --cc=intel-gfx@lists.freedesktop.org \
    /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

Intel-GFX Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/intel-gfx/0 intel-gfx/git/0.git
	git clone --mirror https://lore.kernel.org/intel-gfx/1 intel-gfx/git/1.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 intel-gfx intel-gfx/ https://lore.kernel.org/intel-gfx \
		intel-gfx@lists.freedesktop.org
	public-inbox-index intel-gfx

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.freedesktop.lists.intel-gfx


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git