Message ID | 20170119114158.17941-2-chris@chris-wilson.co.uk (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On to, 2017-01-19 at 11:41 +0000, Chris Wilson wrote: > Some state is coupled into the device lifetime outside of the > load/unload timeframe and requires teardown during final unreference > from drm_dev_release(). For example, dmabufs hold both a device and > module reference and may live longer than expected (i.e. the current > pattern of the driver tearing down its state and then releasing a > reference to the drm device) and yet touch driver private state when > destroyed. > > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> I'm pretty sure I sent this once already, but here goes; Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> Regards, Joonas
On Wed, Jan 25, 2017 at 01:12:21PM +0200, Joonas Lahtinen wrote: > On to, 2017-01-19 at 11:41 +0000, Chris Wilson wrote: > > Some state is coupled into the device lifetime outside of the > > load/unload timeframe and requires teardown during final unreference > > from drm_dev_release(). For example, dmabufs hold both a device and > > module reference and may live longer than expected (i.e. the current > > pattern of the driver tearing down its state and then releasing a > > reference to the drm device) and yet touch driver private state when > > destroyed. > > > > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> > > I'm pretty sure I sent this once already, but here goes; This is the old one now, as it had to undergo some surgery to make Laurent happy. -Chris
diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c index 1b11ab628da7..a150f0c6a299 100644 --- a/drivers/gpu/drm/drm_drv.c +++ b/drivers/gpu/drm/drm_drv.c @@ -598,6 +598,9 @@ static void drm_dev_release(struct kref *ref) { struct drm_device *dev = container_of(ref, struct drm_device, ref); + if (dev->driver->release) + dev->driver->release(dev); + if (drm_core_check_feature(dev, DRIVER_GEM)) drm_gem_destroy(dev); diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h index 34ece393c639..dfddd8c15b62 100644 --- a/include/drm/drm_drv.h +++ b/include/drm/drm_drv.h @@ -103,6 +103,15 @@ struct drm_driver { * */ void (*unload) (struct drm_device *); + + /** + * @release: + * + * Optional callback for destroying device state after the final + * reference is released, i.e. the device is being destroyed. + */ + void (*release) (struct drm_device *); + int (*dma_ioctl) (struct drm_device *dev, void *data, struct drm_file *file_priv); int (*dma_quiescent) (struct drm_device *); int (*context_dtor) (struct drm_device *dev, int context);
Some state is coupled into the device lifetime outside of the load/unload timeframe and requires teardown during final unreference from drm_dev_release(). For example, dmabufs hold both a device and module reference and may live longer than expected (i.e. the current pattern of the driver tearing down its state and then releasing a reference to the drm device) and yet touch driver private state when destroyed. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> --- drivers/gpu/drm/drm_drv.c | 3 +++ include/drm/drm_drv.h | 9 +++++++++ 2 files changed, 12 insertions(+)