All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC 0/9] DRM: Device Handling Cleanup
@ 2013-07-24 13:43 David Herrmann
  2013-07-24 13:43 ` [RFC 1/9] drm: add drm_dev_alloc() helper David Herrmann
                   ` (8 more replies)
  0 siblings, 9 replies; 15+ messages in thread
From: David Herrmann @ 2013-07-24 13:43 UTC (permalink / raw)
  To: dri-devel

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

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2013-07-27 12:09 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-24 13:43 [RFC 0/9] DRM: Device Handling Cleanup David Herrmann
2013-07-24 13:43 ` [RFC 1/9] drm: add drm_dev_alloc() helper David Herrmann
2013-07-24 13:43 ` [RFC 2/9] drm: merge device setup into drm_dev_register() David Herrmann
2013-07-24 13:43 ` [RFC 3/9] drm/agp: fix AGP cleanup paths David Herrmann
2013-07-27  6:05   ` Dave Airlie
2013-07-27 12:09     ` David Herrmann
2013-07-24 13:43 ` [RFC 4/9] drm: move drm_lastclose() to drm_fops.c David Herrmann
2013-07-24 13:43 ` [RFC 5/9] drm: introduce drm_dev_free() to fix error paths David Herrmann
2013-07-24 13:43 ` [RFC 6/9] drm: move device unregistration into drm_dev_unregister() David Herrmann
2013-07-24 13:43 ` [RFC 7/9] percpu_rw_sempahore: export symbols for modules David Herrmann
2013-07-24 13:43 ` [RFC 8/9] drm: track pending user-space actions David Herrmann
2013-07-24 14:03   ` Maarten Lankhorst
2013-07-24 14:24     ` David Herrmann
2013-07-24 14:45       ` Maarten Lankhorst
2013-07-24 13:43 ` [RFC 9/9] drm: support immediate unplugging David Herrmann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.