drm: provide device-refcount
authorDavid Herrmann <dh.herrmann@gmail.com>
Wed, 29 Jan 2014 09:21:36 +0000 (10:21 +0100)
committerSimon Horman <horms+renesas@verge.net.au>
Thu, 11 Dec 2014 01:29:43 +0000 (10:29 +0900)
commit570d34b5f554908e95e74bd6dd6f35a7c6c41c65
treec88758f39c1561393c8c781d80e2ae5a7f8849d9
parentc91118f512e8b6b99fe995d62fa22366e645a63e
drm: provide device-refcount

Lets not trick ourselves into thinking "drm_device" objects are not
ref-counted. That's just utterly stupid. We manage "drm_minor" objects on
each drm-device and each minor can have an unlimited number of open
handles. Each of these handles has the drm_minor (and thus the drm_device)
as private-data in the file-handle. Therefore, we may not destroy
"drm_device" until all these handles are closed.

It is *not* possible to reset all these pointers atomically and restrict
access to them, and this is *not* how this is done! Instead, we use
ref-counts to make sure the object is valid and not freed.

Note that we currently use "dev->open_count" for that, which is *exactly*
the same as a reference-count, just open coded. So this patch doesn't
change any semantics on DRM devices (well, this patch just introduces the
ref-count, anyway. Follow-up patches will replace open_count by it).

Also note that generic VFS revoke support could allow us to drop this
ref-count again. We could then just synchronously disable any fops->xy()
calls. However, this is not the case, yet, and no such patches are
in sight (and I seriously question the idea of dropping the ref-cnt
again).

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
(cherry picked from commit 099d1c290e2ebc3b798961a6c177c3aef5f0b789)
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
drivers/gpu/drm/drm_pci.c
drivers/gpu/drm/drm_platform.c
drivers/gpu/drm/drm_stub.c
drivers/gpu/drm/drm_usb.c
drivers/gpu/drm/tegra/bus.c
include/drm/drmP.h