diff options
author | attilio <attilio@FreeBSD.org> | 2009-08-02 14:28:40 +0000 |
---|---|---|
committer | attilio <attilio@FreeBSD.org> | 2009-08-02 14:28:40 +0000 |
commit | 7f42e47a67ad2835fbc404253f835223020256d4 (patch) | |
tree | c00d808d1df8000c2086c86613be9ec8536a5e28 /sys/dev/drm | |
parent | ea03af42ccd07d2533707afe4d1ba08f34bdb2e9 (diff) | |
download | FreeBSD-src-7f42e47a67ad2835fbc404253f835223020256d4.zip FreeBSD-src-7f42e47a67ad2835fbc404253f835223020256d4.tar.gz |
Make the newbus subsystem Giant free by adding the new newbus sxlock.
The newbus lock is responsible for protecting newbus internIal structures,
device states and devclass flags. It is necessary to hold it when all
such datas are accessed. For the other operations, softc locking should
ensure enough protection to avoid races.
Newbus lock is automatically held when virtual operations on the device
and bus are invoked when loading the driver or when the suspend/resume
take place. For other 'spourious' operations trying to access/modify
the newbus topology, newbus lock needs to be automatically acquired and
dropped.
For the moment Giant is also acquired in some key point (modules subsystem)
in order to avoid problems before the 8.0 release as module handlers could
make assumptions about it. This Giant locking should go just after
the release happens.
Please keep in mind that the public interface can be expanded in order
to provide more support, if there are really necessities at some point
and also some bugs could arise as long as the patch needs a bit of
further testing.
Bump __FreeBSD_version in order to reflect the newbus lock introduction.
Reviewed by: ed, hps, jhb, imp, mav, scottl
No answer by: ariff, thompsa, yongari
Tested by: pho,
G. Trematerra <giovanni dot trematerra at gmail dot com>,
Brandon Gooch <jamesbrandongooch at gmail dot com>
Sponsored by: Yahoo! Incorporated
Approved by: re (ksmith)
Diffstat (limited to 'sys/dev/drm')
-rw-r--r-- | sys/dev/drm/drm_drv.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/sys/dev/drm/drm_drv.c b/sys/dev/drm/drm_drv.c index 561afd5..e12f8cd 100644 --- a/sys/dev/drm/drm_drv.c +++ b/sys/dev/drm/drm_drv.c @@ -614,11 +614,13 @@ int drm_open(struct cdev *kdev, int flags, int fmt, DRM_STRUCTPROC *p) if (!retcode) { atomic_inc(&dev->counts[_DRM_STAT_OPENS]); + newbus_xlock(); DRM_LOCK(); device_busy(dev->device); if (!dev->open_count++) retcode = drm_firstopen(dev); DRM_UNLOCK(); + newbus_xunlock(); } return retcode; @@ -632,6 +634,11 @@ void drm_close(void *data) DRM_DEBUG("open_count = %d\n", dev->open_count); + /* + * We require to lock newbus here for handling device_unbusy() and + * avoid a LOR with DRM_LOCK. + */ + newbus_xlock(); DRM_LOCK(); if (dev->driver->preclose != NULL) @@ -708,6 +715,7 @@ void drm_close(void *data) } DRM_UNLOCK(); + newbus_xunlock(); } /* drm_ioctl is called whenever a process performs an ioctl on /dev/drm. |