Re: [Intel-gfx] [PATCH v2] drm/i915/fbdev: Limit the global async-domain synchronization
On Thu, May 19, 2016 at 10:14:35PM +0200, Lukas Wunner wrote: > Hi Chris, > > On Thu, May 19, 2016 at 09:28:10AM +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. > > Oops, good catch, missed that in my own version of this patch: > https://lists.freedesktop.org/archives/intel-gfx/2016-March/091257.html > > > > > Signed-off-by: Chris Wilson> > --- > > drivers/gpu/drm/i915/intel_drv.h | 1 + > > drivers/gpu/drm/i915/intel_fbdev.c | 31 ++- > > 2 files changed, 19 insertions(+), 13 deletions(-) > > > > diff --git a/drivers/gpu/drm/i915/intel_drv.h > > b/drivers/gpu/drm/i915/intel_drv.h > > index 3536292babe0..5bb045ba608e 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 99e27530e264..2e9c3f38c023 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 > > @@ -554,12 +553,14 @@ static void intel_fbdev_destroy(struct drm_device > > *dev, > > if (ifbdev->fb) { > > drm_framebuffer_unregister_private(>fb->base); > > > > - mutex_lock(>struct_mutex); > > + mutex_lock(>helper.dev->struct_mutex); > > intel_unpin_fb_obj(>fb->base, BIT(DRM_ROTATE_0)); > > - mutex_unlock(>struct_mutex); > > + mutex_unlock(>helper.dev->struct_mutex); > > > > drm_framebuffer_remove(>fb->base); > > } > > + > > + kfree(ifbdev); > > } > > > > /* > > @@ -736,32 +737,36 @@ 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; > > + > > + ifbdev->cookie = 0; > > Hm, why are you setting this to 0 here? IIUC the effect is that > async_synchronize_cookie() will wait until intel_fbdev_initial_config() > has been *entered*, but isn't the desired effect that it has *finished*? True, it's also an unserialised write. Premature optimisation to not block the teardown waiting for the out-of-order completion of earlier tasks. -Chris -- Chris Wilson, Intel Open Source Technology Centre ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH v2] drm/i915/fbdev: Limit the global async-domain synchronization
Hi Chris, On Thu, May 19, 2016 at 09:28:10AM +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. Oops, good catch, missed that in my own version of this patch: https://lists.freedesktop.org/archives/intel-gfx/2016-March/091257.html > > Signed-off-by: Chris Wilson> --- > drivers/gpu/drm/i915/intel_drv.h | 1 + > drivers/gpu/drm/i915/intel_fbdev.c | 31 ++- > 2 files changed, 19 insertions(+), 13 deletions(-) > > diff --git a/drivers/gpu/drm/i915/intel_drv.h > b/drivers/gpu/drm/i915/intel_drv.h > index 3536292babe0..5bb045ba608e 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 99e27530e264..2e9c3f38c023 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 > @@ -554,12 +553,14 @@ static void intel_fbdev_destroy(struct drm_device *dev, > if (ifbdev->fb) { > drm_framebuffer_unregister_private(>fb->base); > > - mutex_lock(>struct_mutex); > + mutex_lock(>helper.dev->struct_mutex); > intel_unpin_fb_obj(>fb->base, BIT(DRM_ROTATE_0)); > - mutex_unlock(>struct_mutex); > + mutex_unlock(>helper.dev->struct_mutex); > > drm_framebuffer_remove(>fb->base); > } > + > + kfree(ifbdev); > } > > /* > @@ -736,32 +737,36 @@ 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; > + > + ifbdev->cookie = 0; Hm, why are you setting this to 0 here? IIUC the effect is that async_synchronize_cookie() will wait until intel_fbdev_initial_config() has been *entered*, but isn't the desired effect that it has *finished*? Best regards, Lukas > > /* Due to peculiar init order wrt to hpd handling this is separate. */ > if (drm_fb_helper_initial_config(>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(_priv->fbdev_suspend_work); > + if (ifbdev->cookie && !current_is_async()) > + async_synchronize_cookie(ifbdev->cookie + 1); > > - if (!current_is_async()) > - async_synchronize_full(); > - intel_fbdev_destroy(dev, dev_priv->fbdev); > - kfree(dev_priv->fbdev); > + intel_fbdev_destroy(ifbdev); > dev_priv->fbdev = NULL; > } > > -- > 2.8.1 > > ___ > Intel-gfx mailing list > Intel-gfx@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/intel-gfx ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
[Intel-gfx] [PATCH v2] drm/i915/fbdev: Limit the global async-domain synchronization
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. Signed-off-by: Chris Wilson--- drivers/gpu/drm/i915/intel_drv.h | 1 + drivers/gpu/drm/i915/intel_fbdev.c | 31 ++- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h index 3536292babe0..5bb045ba608e 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 99e27530e264..2e9c3f38c023 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 @@ -554,12 +553,14 @@ static void intel_fbdev_destroy(struct drm_device *dev, if (ifbdev->fb) { drm_framebuffer_unregister_private(>fb->base); - mutex_lock(>struct_mutex); + mutex_lock(>helper.dev->struct_mutex); intel_unpin_fb_obj(>fb->base, BIT(DRM_ROTATE_0)); - mutex_unlock(>struct_mutex); + mutex_unlock(>helper.dev->struct_mutex); drm_framebuffer_remove(>fb->base); } + + kfree(ifbdev); } /* @@ -736,32 +737,36 @@ 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; + + ifbdev->cookie = 0; /* Due to peculiar init order wrt to hpd handling this is separate. */ if (drm_fb_helper_initial_config(>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(_priv->fbdev_suspend_work); + if (ifbdev->cookie && !current_is_async()) + async_synchronize_cookie(ifbdev->cookie + 1); - if (!current_is_async()) - async_synchronize_full(); - intel_fbdev_destroy(dev, dev_priv->fbdev); - kfree(dev_priv->fbdev); + intel_fbdev_destroy(ifbdev); dev_priv->fbdev = NULL; } -- 2.8.1 ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx