dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: David Herrmann <dh.herrmann@gmail.com>
To: dri-devel@lists.freedesktop.org
Subject: [RFC 0/9] DRM: Device Handling Cleanup
Date: Wed, 24 Jul 2013 15:43:49 +0200	[thread overview]
Message-ID: <1374673438-26251-1-git-send-email-dh.herrmann@gmail.com> (raw)

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

             reply	other threads:[~2013-07-24 13:44 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-24 13:43 David Herrmann [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1374673438-26251-1-git-send-email-dh.herrmann@gmail.com \
    --to=dh.herrmann@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox