Message ID | 1409745310-19092-8-git-send-email-tomi.valkeinen@ti.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Wed, Sep 03, 2014 at 02:55:09PM +0300, Tomi Valkeinen wrote: > We already wait for all scheduled work to be done on the driver's unload > function. However, I think we need to wait on preclose() also, so that > when an application closes the drm file descriptor, we are sure that > there's no left around. The justification (likely, didn't check omapdrm code) for this is that we need to clear out all outstanding drm_events. Currently i915 and some other drivers (but not all) have that open-coded. We should probably track drm_events on a per-fd list and move this logic into the core instead of adding more driver-specific hacks. -Daniel > > Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com> > --- > drivers/gpu/drm/omapdrm/omap_drv.c | 13 +++++++++++++ > 1 file changed, 13 insertions(+) > > diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c > index 26fda74c1e48..f59fa6600cf8 100644 > --- a/drivers/gpu/drm/omapdrm/omap_drv.c > +++ b/drivers/gpu/drm/omapdrm/omap_drv.c > @@ -594,7 +594,20 @@ static void dev_lastclose(struct drm_device *dev) > > static void dev_preclose(struct drm_device *dev, struct drm_file *file) > { > + struct omap_drm_private *priv = dev->dev_private; > + int i; > + > DBG("preclose: dev=%p", dev); > + > + /* > + * Flush crtcs to finish any pending work. > + * Note: this may not be correct if there are multiple applications > + * using the drm device, and could possibly result in a timeout from > + * omap_crtc_flush() if an other application is actively queuing new > + * work. > + */ > + for (i = 0; i < priv->num_crtcs; i++) > + omap_crtc_flush(priv->crtcs[i]); > } > > static void dev_postclose(struct drm_device *dev, struct drm_file *file) > -- > 1.9.1 > > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/dri-devel
On 03/09/14 17:32, Daniel Vetter wrote: > On Wed, Sep 03, 2014 at 02:55:09PM +0300, Tomi Valkeinen wrote: >> We already wait for all scheduled work to be done on the driver's unload >> function. However, I think we need to wait on preclose() also, so that >> when an application closes the drm file descriptor, we are sure that >> there's no left around. Hmm, that's supposed to say "there's no work left around". > The justification (likely, didn't check omapdrm code) for this is that we > need to clear out all outstanding drm_events. Currently i915 and some > other drivers (but not all) have that open-coded. We should probably track > drm_events on a per-fd list and move this logic into the core instead of > adding more driver-specific hacks. To be honest, I'm not 100% sure what we need to wait for =). I'm still learning DRM, and omapdrm's work handling is not the easiest one to follow. But yes, at least the page-flip event is one that rings alarm bells in my head, if the fb is allowed to be closed and there's still an event outstanding. With this patch we wait until all work is done in the preclose. The performance is not an issue here, so I went for "better safe than sorry". Tomi
diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c index 26fda74c1e48..f59fa6600cf8 100644 --- a/drivers/gpu/drm/omapdrm/omap_drv.c +++ b/drivers/gpu/drm/omapdrm/omap_drv.c @@ -594,7 +594,20 @@ static void dev_lastclose(struct drm_device *dev) static void dev_preclose(struct drm_device *dev, struct drm_file *file) { + struct omap_drm_private *priv = dev->dev_private; + int i; + DBG("preclose: dev=%p", dev); + + /* + * Flush crtcs to finish any pending work. + * Note: this may not be correct if there are multiple applications + * using the drm device, and could possibly result in a timeout from + * omap_crtc_flush() if an other application is actively queuing new + * work. + */ + for (i = 0; i < priv->num_crtcs; i++) + omap_crtc_flush(priv->crtcs[i]); } static void dev_postclose(struct drm_device *dev, struct drm_file *file)
We already wait for all scheduled work to be done on the driver's unload function. However, I think we need to wait on preclose() also, so that when an application closes the drm file descriptor, we are sure that there's no left around. Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com> --- drivers/gpu/drm/omapdrm/omap_drv.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)