Skip to content

Commit 8f6599d

Browse files
David Herrmannairlied
authored andcommitted
drm: delay minor destruction to drm_dev_free()
Instead of freeing minors in drm_dev_unregister(), we only unplug them and delay the free to drm_dev_free(). Note that if drm_dev_register() has never been called, minors are NULL and this has no effect. This change is needed to allow early device unregistration. If we want to call drm_dev_unregister() on live devices, we need to guarantee that minors are still valid (but unplugged). This way, any open file can still access file_priv->minor->dev to get the DRM device. However, the minor is unplugged so no new users can occur. Signed-off-by: David Herrmann <dh.herrmann@gmail.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
1 parent f67e946 commit 8f6599d

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

‎drivers/gpu/drm/drm_stub.c‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,10 @@ EXPORT_SYMBOL(drm_dev_alloc);
487487
*/
488488
void drm_dev_free(struct drm_device *dev)
489489
{
490+
drm_put_minor(dev->control);
491+
drm_put_minor(dev->render);
492+
drm_put_minor(dev->primary);
493+
490494
if (dev->driver->driver_features & DRIVER_GEM)
491495
drm_gem_destroy(dev);
492496

@@ -601,9 +605,9 @@ void drm_dev_unregister(struct drm_device *dev)
601605
list_for_each_entry_safe(r_list, list_temp, &dev->maplist, head)
602606
drm_rmmap(dev, r_list->map);
603607

604-
drm_put_minor(dev->control);
605-
drm_put_minor(dev->render);
606-
drm_put_minor(dev->primary);
608+
drm_unplug_minor(dev->control);
609+
drm_unplug_minor(dev->render);
610+
drm_unplug_minor(dev->primary);
607611

608612
list_del(&dev->driver_item);
609613
}

0 commit comments

Comments
 (0)