aboutsummaryrefslogtreecommitdiffstats
path: root/include/drm
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2012-02-20 09:18:07 -0500
committerDave Airlie <airlied@redhat.com>2012-03-15 09:35:33 -0400
commit2c07a21d6fb0be47fda696a618b726ea258ed1dd (patch)
tree8ab0b7541ee4f9f75397d3da190426041dc08c6e /include/drm
parentcbc7e22151d99ed1dd7649d268ad3d81b9e6255a (diff)
drm: add core support for unplugging a device (v2)
Two parts to this, one is simple unplug from sysfs for the device node. The second adds an unplugged state, if we have device opens, we just set the unplugged state and return, if we have no device opens we drop the drm device. If after a lastclose we discover we are unplugged we then drop the drm device. v2: use an atomic for unplugged and wrap it for users, add checks on open + mmap + ioctl entry points. Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'include/drm')
-rw-r--r--include/drm/drmP.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index cfd921ff0cc4..574bd1c81ebd 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -1170,6 +1170,8 @@ struct drm_device {
1170 struct idr object_name_idr; 1170 struct idr object_name_idr;
1171 /*@} */ 1171 /*@} */
1172 int switch_power_state; 1172 int switch_power_state;
1173
1174 atomic_t unplugged; /* device has been unplugged or gone away */
1173}; 1175};
1174 1176
1175#define DRM_SWITCH_POWER_ON 0 1177#define DRM_SWITCH_POWER_ON 0
@@ -1235,6 +1237,19 @@ static inline int drm_mtrr_del(int handle, unsigned long offset,
1235} 1237}
1236#endif 1238#endif
1237 1239
1240static inline void drm_device_set_unplugged(struct drm_device *dev)
1241{
1242 smp_wmb();
1243 atomic_set(&dev->unplugged, 1);
1244}
1245
1246static inline int drm_device_is_unplugged(struct drm_device *dev)
1247{
1248 int ret = atomic_read(&dev->unplugged);
1249 smp_rmb();
1250 return ret;
1251}
1252
1238/******************************************************************/ 1253/******************************************************************/
1239/** \name Internal function definitions */ 1254/** \name Internal function definitions */
1240/*@{*/ 1255/*@{*/
@@ -1455,6 +1470,7 @@ extern void drm_master_put(struct drm_master **master);
1455 1470
1456extern void drm_put_dev(struct drm_device *dev); 1471extern void drm_put_dev(struct drm_device *dev);
1457extern int drm_put_minor(struct drm_minor **minor); 1472extern int drm_put_minor(struct drm_minor **minor);
1473extern void drm_unplug_dev(struct drm_device *dev);
1458extern unsigned int drm_debug; 1474extern unsigned int drm_debug;
1459 1475
1460extern unsigned int drm_vblank_offdelay; 1476extern unsigned int drm_vblank_offdelay;