RFC DRM: Device Handling Cleanup
Get series with b4
b4 am [email protected]Versions newest first
- v1 RFC Latest9 patches 5 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/9 | drm: add drm_dev_alloc() helperdrivers/ drivers/ drivers/ +2 more | +80 | 0 replies | |
| 2/9 | drm: merge device setup into drm_dev_register()drivers/ drivers/ drivers/ +2 more | +86 | 0 replies | |
| 3/9 | drm/agp: fix AGP cleanup pathsdrivers/ drivers/ drivers/ +2 more | +71 | 2 replies | |
| 4/9 | drm: move drm_lastclose() to drm_fops.cdrivers/ drivers/ | +49 | 0 replies | |
| 5/9 | drm: introduce drm_dev_free() to fix error pathsdrivers/ drivers/ drivers/ +2 more | +29 | 0 replies | |
| 6/9 | drm: move device unregistration into drm_dev_unregister()drivers/ include/ | +36 | 0 replies | |
| 7/9 | percpu_rw_sempahore: export symbols for moduleslib/ lib/ | +8 | 0 replies | |
| 8/9 | drm: track pending user-space actionsdrivers/ drivers/ drivers/ +2 more | +96 | 3 replies | |
| 9/9 | drm: support immediate unpluggingDocumentation/ drivers/ drivers/ +1 more | +162 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [RFC 0/9] DRM: Device Handling Cleanup
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(-)
Signature · 1 line
1.8.3.3