public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Chris Wilson <chris@chris-wilson.co.uk>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 2/3] drm/i915/fbdev: Limit the global async-domain synchronization
Date: Tue, 21 Jun 2016 09:35:44 +0200	[thread overview]
Message-ID: <20160621073544.GQ23520@phenom.ffwll.local> (raw)
In-Reply-To: <1466186089-7743-3-git-send-email-chris@chris-wilson.co.uk>

On Fri, Jun 17, 2016 at 06:54:48PM +0100, Chris Wilson wrote:
> During cleanup we have to synchronise with the async task we are using
> to initialise and register our fbdev. Currently, we are using a full
> synchronisation on the global domain, but we can restrict this to just
> synchronising up to our task if we remember our cookie.
> 
> v2: async_synchronize_cookie() takes an exclusive upper bound, to
> synchronize with our task we have to pass in the next cookie.
> v3: Drop premature disregarding of the active cookie (we need to wait
> until the task is complete before continuing in the teardown).
> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Lukas Wunner <lukas@wunner.de>
> ---
>  drivers/gpu/drm/i915/intel_drv.h   |  1 +
>  drivers/gpu/drm/i915/intel_fbdev.c | 29 ++++++++++++++++-------------
>  2 files changed, 17 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
> index 0c1dc9bae170..b657ddd2d078 100644
> --- a/drivers/gpu/drm/i915/intel_drv.h
> +++ b/drivers/gpu/drm/i915/intel_drv.h
> @@ -159,6 +159,7 @@ struct intel_framebuffer {
>  struct intel_fbdev {
>  	struct drm_fb_helper helper;
>  	struct intel_framebuffer *fb;
> +	async_cookie_t cookie;
>  	int preferred_bpp;
>  };
>  
> diff --git a/drivers/gpu/drm/i915/intel_fbdev.c b/drivers/gpu/drm/i915/intel_fbdev.c
> index 4babefc51eb2..638e420a59cb 100644
> --- a/drivers/gpu/drm/i915/intel_fbdev.c
> +++ b/drivers/gpu/drm/i915/intel_fbdev.c
> @@ -538,8 +538,7 @@ static const struct drm_fb_helper_funcs intel_fb_helper_funcs = {
>  	.fb_probe = intelfb_create,
>  };
>  
> -static void intel_fbdev_destroy(struct drm_device *dev,
> -				struct intel_fbdev *ifbdev)
> +static void intel_fbdev_destroy(struct intel_fbdev *ifbdev)
>  {
>  	/* We rely on the object-free to release the VMA pinning for
>  	 * the info->screen_base mmaping. Leaking the VMA is simpler than
> @@ -552,12 +551,14 @@ static void intel_fbdev_destroy(struct drm_device *dev,
>  	drm_fb_helper_fini(&ifbdev->helper);
>  
>  	if (ifbdev->fb) {
> -		mutex_lock(&dev->struct_mutex);
> +		mutex_lock(&ifbdev->helper.dev->struct_mutex);
>  		intel_unpin_fb_obj(&ifbdev->fb->base, BIT(DRM_ROTATE_0));
> -		mutex_unlock(&dev->struct_mutex);
> +		mutex_unlock(&ifbdev->helper.dev->struct_mutex);
>  
>  		drm_framebuffer_remove(&ifbdev->fb->base);
>  	}
> +
> +	kfree(ifbdev);
>  }
>  
>  /*
> @@ -732,32 +733,34 @@ int intel_fbdev_init(struct drm_device *dev)
>  
>  static void intel_fbdev_initial_config(void *data, async_cookie_t cookie)
>  {
> -	struct drm_i915_private *dev_priv = data;
> -	struct intel_fbdev *ifbdev = dev_priv->fbdev;
> +	struct intel_fbdev *ifbdev = data;
>  
>  	/* Due to peculiar init order wrt to hpd handling this is separate. */
>  	if (drm_fb_helper_initial_config(&ifbdev->helper,
>  					 ifbdev->preferred_bpp))
> -		intel_fbdev_fini(dev_priv->dev);
> +		intel_fbdev_fini(ifbdev->helper.dev);
>  }
>  
>  void intel_fbdev_initial_config_async(struct drm_device *dev)
>  {
> -	async_schedule(intel_fbdev_initial_config, to_i915(dev));
> +	struct intel_fbdev *ifbdev = to_i915(dev)->fbdev;
> +
> +	ifbdev->cookie = async_schedule(intel_fbdev_initial_config, ifbdev);
>  }
>  
>  void intel_fbdev_fini(struct drm_device *dev)
>  {
>  	struct drm_i915_private *dev_priv = dev->dev_private;
> -	if (!dev_priv->fbdev)
> +	struct intel_fbdev *ifbdev = dev_priv->fbdev;
> +
> +	if (!ifbdev)
>  		return;
>  
>  	flush_work(&dev_priv->fbdev_suspend_work);
> +	if (ifbdev->cookie && !current_is_async())
> +		async_synchronize_cookie(ifbdev->cookie + 1);

First I went like wtf about the cookie+1, but the main use case for this
function (or intended use-case at least) is to synchronize with everything
before your own async task when you register. To uphold deterministic dev
node ordering ...

Needs a comment in the code imo, this is too suprising:

	/* Only synchronizes with all _preceeding_ async tasks, hence + 1 */

Or whatever you feel like.


>  
> -	if (!current_is_async())
> -		async_synchronize_full();
> -	intel_fbdev_destroy(dev, dev_priv->fbdev);
> -	kfree(dev_priv->fbdev);
> +	intel_fbdev_destroy(ifbdev);

"While at it simplify fbdev functions paramaters." ;-)

With the bikesheds addressed:

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

>  	dev_priv->fbdev = NULL;
>  }
>  
> -- 
> 2.8.1
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2016-06-21  7:35 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-17 17:54 Quick set of async fbdev fixes Chris Wilson
2016-06-17 17:54 ` [PATCH 1/3] drm/i915/fbdev: Perform async fbdev initialisation much later Chris Wilson
2016-06-21  7:27   ` Daniel Vetter
2016-06-17 17:54 ` [PATCH 2/3] drm/i915/fbdev: Limit the global async-domain synchronization Chris Wilson
2016-06-21  7:35   ` Daniel Vetter [this message]
2016-06-21  7:57     ` Chris Wilson
2016-06-17 17:54 ` [PATCH 3/3] drm/i915/fbdev: Flush mode configuration before lastclose Chris Wilson
2016-06-17 18:13   ` Lukas Wunner
2016-06-21  7:37   ` Daniel Vetter
2016-06-18  5:47 ` ✗ Ro.CI.BAT: warning for series starting with [1/3] drm/i915/fbdev: Perform async fbdev initialisation much later Patchwork

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=20160621073544.GQ23520@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --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
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