Hi This series fixes unplugging of DRM devices. It introduces four new helpers which replace the old drm_put_dev(), drm_unplug_dev(), drm_fill_in_dev() helpers: - drm_dev_alloc() Allocate a DRM device, initialize all static objects and fill in driver data. The device is not registered nor advertised to user-space. But to free it again, you must call drm_dev_free() instead of kfree(). Once a device is allocated, you need to call drm_dev_register() to put life in it and let user-space make use of it. - drm_dev_free() Free a DRM device. This deallocates any resources that are linked to the object. After that, the "struct drm_device" object is invalid and must no longer be accessed. - drm_dev_register() Register a DRM device on the system. This will link it into sysfs and create the device nodes. Once registered, user-space can call into the file-ops. - drm_dev_unregister() Unregister a DRM device. This will unlink the device from all other objects, remove it from sysfs and prevent any further file-ops from user-space. It also takes care that all pending file-ops are finished before returning. This call is immediate! That is, we can use it instead of drm_put_dev() and the device will get unregistered immediately without breaking anything. We no longer need to use hacks like drm_unplug_dev() which just unregister the chardev-nodes. These four are modeled after device_init(), put_device(), device_add() and device_del() from driver-core and follow the standard object rules. However, I didn't add any reference-counting, but instead track device-lifetime via drm_open() and drm_release() callbacks as we always did. But the ->open_count field is basically a reference-count so maybe I will change this in a next revision to drm_dev_get() and drm_dev_put(). This is slightly based on Maarten Lankhorst's patches from: http://cgit.freedesktop.org/~mlankhorst/linux/commit/?id=295965264c73f610e9538db2365142d6e2414849 I haven't tested this so far and I need to adjust the mmap() fops of all drivers, but I thought I'd just send a first RFC so people can comment on that. Furthermore, the first 6 patches can be applied right away and fix error-paths during allocation and unify all the bus systems to use a single helper for device allocation. Cheers David David Herrmann (9): drm: add drm_dev_alloc() helper drm: merge device setup into drm_dev_register() drm/agp: fix AGP cleanup paths drm: move drm_lastclose() to drm_fops.c drm: introduce drm_dev_free() to fix error paths drm: move device unregistration into drm_dev_unregister() percpu_rw_sempahore: export symbols for modules drm: track pending user-space actions drm: support immediate unplugging Documentation/DocBook/drm.tmpl | 5 + drivers/gpu/drm/Kconfig | 1 + drivers/gpu/drm/drm_agpsupport.c | 51 +++++ drivers/gpu/drm/drm_drv.c | 74 +------ drivers/gpu/drm/drm_fops.c | 165 +++++++++++---- drivers/gpu/drm/drm_pci.c | 65 ++---- drivers/gpu/drm/drm_platform.c | 50 +---- drivers/gpu/drm/drm_stub.c | 439 +++++++++++++++++++++++++++++---------- drivers/gpu/drm/drm_usb.c | 48 +---- include/drm/drmP.h | 30 +-- lib/Makefile | 2 +- lib/percpu-rwsem.c | 7 + 12 files changed, 579 insertions(+), 358 deletions(-) -- 1.8.3.3 _______________________________________________ dri-devel mailing list dri-devel@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/dri-devel