diff options
author | Arnd Bergmann <arnd@arndb.de> | 2010-07-10 17:51:39 -0400 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2010-08-04 21:54:40 -0400 |
commit | 58374713c9dfb4d231f8c56cac089f6fbdedc2ec (patch) | |
tree | 9ba01c3990b5a8625437d13722595f5063f2d915 /drivers/gpu/drm/i810 | |
parent | a1e09b62592eb57e25f8d076ffa5b7bef18be812 (diff) |
drm: kill BKL from common code
This restricts the use of the big kernel lock to the i830 and i810
device drivers. The three remaining users in common code (open, ioctl
and release) get converted to a new mutex, the drm_global_mutex,
making the locking stricter than the big kernel lock.
This may have a performance impact, but only in those cases that
currently don't use DRM_UNLOCKED flag in the ioctl list and would
benefit from that anyway.
The reason why i810 and i830 cannot use drm_global_mutex in their
mmap functions is a lock-order inversion problem between the current
use of the BKL and mmap_sem in these drivers. Since the BKL has
release-on-sleep semantics, it's harmless but it would cause trouble
if we replace the BKL with a mutex.
Instead, these drivers get their own ioctl wrappers that take the
BKL around every ioctl call and then set their own handlers as
DRM_UNLOCKED.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: David Airlie <airlied@linux.ie>
Cc: dri-devel@lists.freedesktop.org
Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/i810')
-rw-r--r-- | drivers/gpu/drm/i810/i810_dma.c | 44 | ||||
-rw-r--r-- | drivers/gpu/drm/i810/i810_drv.c | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/i810/i810_drv.h | 1 |
3 files changed, 31 insertions, 16 deletions
diff --git a/drivers/gpu/drm/i810/i810_dma.c b/drivers/gpu/drm/i810/i810_dma.c index 09c86ed89927..0e6c131313d9 100644 --- a/drivers/gpu/drm/i810/i810_dma.c +++ b/drivers/gpu/drm/i810/i810_dma.c | |||
@@ -37,6 +37,7 @@ | |||
37 | #include <linux/interrupt.h> /* For task queue support */ | 37 | #include <linux/interrupt.h> /* For task queue support */ |
38 | #include <linux/delay.h> | 38 | #include <linux/delay.h> |
39 | #include <linux/slab.h> | 39 | #include <linux/slab.h> |
40 | #include <linux/smp_lock.h> | ||
40 | #include <linux/pagemap.h> | 41 | #include <linux/pagemap.h> |
41 | 42 | ||
42 | #define I810_BUF_FREE 2 | 43 | #define I810_BUF_FREE 2 |
@@ -1240,22 +1241,35 @@ int i810_driver_dma_quiescent(struct drm_device *dev) | |||
1240 | return 0; | 1241 | return 0; |
1241 | } | 1242 | } |
1242 | 1243 | ||
1244 | /* | ||
1245 | * call the drm_ioctl under the big kernel lock because | ||
1246 | * to lock against the i810_mmap_buffers function. | ||
1247 | */ | ||
1248 | long i810_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | ||
1249 | { | ||
1250 | int ret; | ||
1251 | lock_kernel(); | ||
1252 | ret = drm_ioctl(file, cmd, arg); | ||
1253 | unlock_kernel(); | ||
1254 | return ret; | ||
1255 | } | ||
1256 | |||
1243 | struct drm_ioctl_desc i810_ioctls[] = { | 1257 | struct drm_ioctl_desc i810_ioctls[] = { |
1244 | DRM_IOCTL_DEF(DRM_I810_INIT, i810_dma_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), | 1258 | DRM_IOCTL_DEF(DRM_I810_INIT, i810_dma_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY|DRM_UNLOCKED), |
1245 | DRM_IOCTL_DEF(DRM_I810_VERTEX, i810_dma_vertex, DRM_AUTH), | 1259 | DRM_IOCTL_DEF(DRM_I810_VERTEX, i810_dma_vertex, DRM_AUTH|DRM_UNLOCKED), |
1246 | DRM_IOCTL_DEF(DRM_I810_CLEAR, i810_clear_bufs, DRM_AUTH), | 1260 | DRM_IOCTL_DEF(DRM_I810_CLEAR, i810_clear_bufs, DRM_AUTH|DRM_UNLOCKED), |
1247 | DRM_IOCTL_DEF(DRM_I810_FLUSH, i810_flush_ioctl, DRM_AUTH), | 1261 | DRM_IOCTL_DEF(DRM_I810_FLUSH, i810_flush_ioctl, DRM_AUTH|DRM_UNLOCKED), |
1248 | DRM_IOCTL_DEF(DRM_I810_GETAGE, i810_getage, DRM_AUTH), | 1262 | DRM_IOCTL_DEF(DRM_I810_GETAGE, i810_getage, DRM_AUTH|DRM_UNLOCKED), |
1249 | DRM_IOCTL_DEF(DRM_I810_GETBUF, i810_getbuf, DRM_AUTH), | 1263 | DRM_IOCTL_DEF(DRM_I810_GETBUF, i810_getbuf, DRM_AUTH|DRM_UNLOCKED), |
1250 | DRM_IOCTL_DEF(DRM_I810_SWAP, i810_swap_bufs, DRM_AUTH), | 1264 | DRM_IOCTL_DEF(DRM_I810_SWAP, i810_swap_bufs, DRM_AUTH|DRM_UNLOCKED), |
1251 | DRM_IOCTL_DEF(DRM_I810_COPY, i810_copybuf, DRM_AUTH), | 1265 | DRM_IOCTL_DEF(DRM_I810_COPY, i810_copybuf, DRM_AUTH|DRM_UNLOCKED), |
1252 | DRM_IOCTL_DEF(DRM_I810_DOCOPY, i810_docopy, DRM_AUTH), | 1266 | DRM_IOCTL_DEF(DRM_I810_DOCOPY, i810_docopy, DRM_AUTH|DRM_UNLOCKED), |
1253 | DRM_IOCTL_DEF(DRM_I810_OV0INFO, i810_ov0_info, DRM_AUTH), | 1267 | DRM_IOCTL_DEF(DRM_I810_OV0INFO, i810_ov0_info, DRM_AUTH|DRM_UNLOCKED), |
1254 | DRM_IOCTL_DEF(DRM_I810_FSTATUS, i810_fstatus, DRM_AUTH), | 1268 | DRM_IOCTL_DEF(DRM_I810_FSTATUS, i810_fstatus, DRM_AUTH|DRM_UNLOCKED), |
1255 | DRM_IOCTL_DEF(DRM_I810_OV0FLIP, i810_ov0_flip, DRM_AUTH), | 1269 | DRM_IOCTL_DEF(DRM_I810_OV0FLIP, i810_ov0_flip, DRM_AUTH|DRM_UNLOCKED), |
1256 | DRM_IOCTL_DEF(DRM_I810_MC, i810_dma_mc, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), | 1270 | DRM_IOCTL_DEF(DRM_I810_MC, i810_dma_mc, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY|DRM_UNLOCKED), |
1257 | DRM_IOCTL_DEF(DRM_I810_RSTATUS, i810_rstatus, DRM_AUTH), | 1271 | DRM_IOCTL_DEF(DRM_I810_RSTATUS, i810_rstatus, DRM_AUTH|DRM_UNLOCKED), |
1258 | DRM_IOCTL_DEF(DRM_I810_FLIP, i810_flip_bufs, DRM_AUTH) | 1272 | DRM_IOCTL_DEF(DRM_I810_FLIP, i810_flip_bufs, DRM_AUTH|DRM_UNLOCKED), |
1259 | }; | 1273 | }; |
1260 | 1274 | ||
1261 | int i810_max_ioctl = DRM_ARRAY_SIZE(i810_ioctls); | 1275 | int i810_max_ioctl = DRM_ARRAY_SIZE(i810_ioctls); |
diff --git a/drivers/gpu/drm/i810/i810_drv.c b/drivers/gpu/drm/i810/i810_drv.c index c1e02752e023..b4250b2cac1f 100644 --- a/drivers/gpu/drm/i810/i810_drv.c +++ b/drivers/gpu/drm/i810/i810_drv.c | |||
@@ -59,7 +59,7 @@ static struct drm_driver driver = { | |||
59 | .owner = THIS_MODULE, | 59 | .owner = THIS_MODULE, |
60 | .open = drm_open, | 60 | .open = drm_open, |
61 | .release = drm_release, | 61 | .release = drm_release, |
62 | .unlocked_ioctl = drm_ioctl, | 62 | .unlocked_ioctl = i810_ioctl, |
63 | .mmap = drm_mmap, | 63 | .mmap = drm_mmap, |
64 | .poll = drm_poll, | 64 | .poll = drm_poll, |
65 | .fasync = drm_fasync, | 65 | .fasync = drm_fasync, |
diff --git a/drivers/gpu/drm/i810/i810_drv.h b/drivers/gpu/drm/i810/i810_drv.h index 0743fe90f1e3..c9339f481795 100644 --- a/drivers/gpu/drm/i810/i810_drv.h +++ b/drivers/gpu/drm/i810/i810_drv.h | |||
@@ -126,6 +126,7 @@ extern void i810_driver_reclaim_buffers_locked(struct drm_device *dev, | |||
126 | struct drm_file *file_priv); | 126 | struct drm_file *file_priv); |
127 | extern int i810_driver_device_is_agp(struct drm_device *dev); | 127 | extern int i810_driver_device_is_agp(struct drm_device *dev); |
128 | 128 | ||
129 | extern long i810_ioctl(struct file *file, unsigned int cmd, unsigned long arg); | ||
129 | extern struct drm_ioctl_desc i810_ioctls[]; | 130 | extern struct drm_ioctl_desc i810_ioctls[]; |
130 | extern int i810_max_ioctl; | 131 | extern int i810_max_ioctl; |
131 | 132 | ||