drm: convert drm_ioctl to unlocked_ioctl
Subsystems (5)
PATCH 1/1 drm: convert drm_ioctl to unlocked_ioctl
drm_ioctl is called with the Big Kernel Lock held, which shows up very high in statistics on vfs_ioctl.
Moving the lock into the drm_ioctl function itself makes sure we blame the right subsystem and it gets us one step closer to eliminating the locked version of fops->ioctl.
Since drm_ioctl does not require the lock itself, we only need to hold it while calling the specific handler. The 32 bit conversion handlers do not interact with any other code, so they don't need the BKL here either and can just call drm_ioctl.
As a bonus, this cleans up all the other users of drm_ioctl which now no longer have to find the inode or call lock_kernel.
--- drivers/gpu/drm/drm_drv.c | 7 ++- drivers/gpu/drm/drm_ioc32.c | 89 ++++++++++-------------------- drivers/gpu/drm/i810/i810_dma.c | 2 +- drivers/gpu/drm/i810/i810_drv.c | 2 +- drivers/gpu/drm/i830/i830_dma.c | 2 +- drivers/gpu/drm/i830/i830_drv.c | 2 +- drivers/gpu/drm/i915/i915_drv.c | 2 +- drivers/gpu/drm/i915/i915_ioc32.c | 23 ++++----- drivers/gpu/drm/mga/mga_drv.c | 2 +- drivers/gpu/drm/mga/mga_ioc32.c | 13 ++--- drivers/gpu/drm/nouveau/nouveau_drv.c | 2 +- drivers/gpu/drm/nouveau/nouveau_ioc32.c | 4 +- drivers/gpu/drm/r128/r128_drv.c | 2 +- drivers/gpu/drm/r128/r128_ioc32.c | 16 ++---- drivers/gpu/drm/radeon/radeon_drv.c | 4 +- drivers/gpu/drm/radeon/radeon_ioc32.c | 38 ++++--------- drivers/gpu/drm/savage/savage_drv.c | 2 +- drivers/gpu/drm/sis/sis_drv.c | 2 +- drivers/gpu/drm/tdfx/tdfx_drv.c | 2 +- drivers/gpu/drm/via/via_drv.c | 2 +- include/drm/drmP.h | 4 +- 21 files changed, 83 insertions(+), 139 deletions(-)
drivers/gpu/drm/drm_drv.c +5 -2
@@ -434,11 +434,11 @@ static int drm_version(struct drm_device *dev, void *data,* Looks up the ioctl function in the ::ioctls table, checking for root * previleges if so required, and dispatches to the respective function. */ -int drm_ioctl (struct inode *inode,struct file *filp, +long drm_ioctl (struct file *filp,unsigned int cmd,unsigned long arg) {struct drm_file *file_priv = filp->private_data; -struct drm_device *dev = file_priv->minor->dev; +struct drm_device *dev;struct drm_ioctl_desc *ioctl;drm_ioctl_t *func;unsigned int nr =DRM_IOCTL_NR (cmd);
@@ -446,6 +446,7 @@ int drm_ioctl(struct inode *inode, struct file *filp,char stack_kdata[128 ];char *kdata =NULL ; + dev = file_priv->minor->dev;atomic_inc (&dev->ioctl_count);atomic_inc (&dev->counts[_DRM_STAT_IOCTLS]); ++file_priv->ioctl_count;
@@ -501,7 +502,9 @@ int drm_ioctl(struct inode *inode, struct file *filp, goto err_i1; } } +lock_kernel (); retcode =func (dev, kdata, file_priv); +unlock_kernel ();if (cmd &IOC_OUT ) { if (copy_to_user((void __user *)arg, kdata,
drivers/gpu/drm/drm_ioc32.c +30 -59
269 lines not on this page · raw message
drivers/gpu/drm/i810/i810_dma.c +1 -1
@@ -115,7 +115,7 @@ static int i810_mmap_buffers(struct file *filp, struct vm_area_struct *vma)static const struct file_operations i810_buffer_fops = { .open = drm_open, .release = drm_release, - .ioctl = drm_ioctl, + .unlocked_ioctl = drm_ioctl, .mmap = i810_mmap_buffers, .fasync = drm_fasync, };
drivers/gpu/drm/i810/i810_drv.c +1 -1
@@ -59,7 +59,7 @@ static struct drm_driver driver = { .owner = THIS_MODULE, .open = drm_open, .release = drm_release, - .ioctl = drm_ioctl, + .unlocked_ioctl = drm_ioctl, .mmap = drm_mmap, .poll = drm_poll, .fasync = drm_fasync,
drivers/gpu/drm/i830/i830_dma.c +1 -1
@@ -117,7 +117,7 @@ static int i830_mmap_buffers(struct file *filp, struct vm_area_struct *vma)static const struct file_operations i830_buffer_fops = { .open = drm_open, .release = drm_release, - .ioctl = drm_ioctl, + .unlocked_ioctl = drm_ioctl, .mmap = i830_mmap_buffers, .fasync = drm_fasync, };
drivers/gpu/drm/i830/i830_drv.c +1 -1
@@ -70,7 +70,7 @@ static struct drm_driver driver = { .owner = THIS_MODULE, .open = drm_open, .release = drm_release, - .ioctl = drm_ioctl, + .unlocked_ioctl = drm_ioctl, .mmap = drm_mmap, .poll = drm_poll, .fasync = drm_fasync,
drivers/gpu/drm/i915/i915_drv.c +1 -1
@@ -329,7 +329,7 @@ static struct drm_driver driver = { .owner = THIS_MODULE, .open = drm_open, .release = drm_release, - .ioctl = drm_ioctl, + .unlocked_ioctl = drm_ioctl, .mmap = drm_gem_mmap, .poll = drm_poll, .fasync = drm_fasync,
drivers/gpu/drm/i915/i915_ioc32.c +10 -13
@@ -66,8 +66,7 @@ static int compat_i915_batchbuffer(struct file *file, unsigned int cmd, &batchbuffer->cliprects))return -EFAULT ; -return drm_ioctl (file->f_path.dentry->d_inode, file, -DRM_IOCTL_I915_BATCHBUFFER , +return drm_ioctl (file,DRM_IOCTL_I915_BATCHBUFFER , (unsigned long )batchbuffer); }
@@ -102,8 +101,8 @@ static int compat_i915_cmdbuffer(struct file *file, unsigned int cmd, &cmdbuffer->cliprects))return -EFAULT ; -return drm_ioctl (file->f_path.dentry->d_inode, file, -DRM_IOCTL_I915_CMDBUFFER , (unsigned long )cmdbuffer); +return drm_ioctl (file,DRM_IOCTL_I915_CMDBUFFER , + (unsigned long )cmdbuffer); } typedef struct drm_i915_irq_emit32 {
@@ -125,8 +124,8 @@ static int compat_i915_irq_emit(struct file *file, unsigned int cmd, &request->irq_seq))return -EFAULT ; -return drm_ioctl (file->f_path.dentry->d_inode, file, -DRM_IOCTL_I915_IRQ_EMIT , (unsigned long )request); +return drm_ioctl (file,DRM_IOCTL_I915_IRQ_EMIT , + (unsigned long )request); } typedef struct drm_i915_getparam32 { int param;
@@ -149,8 +148,8 @@ static int compat_i915_getparam(struct file *file, unsigned int cmd, &request->value))return -EFAULT ; -return drm_ioctl (file->f_path.dentry->d_inode, file, -DRM_IOCTL_I915_GETPARAM , (unsigned long )request); +return drm_ioctl (file,DRM_IOCTL_I915_GETPARAM , + (unsigned long )request); } typedef struct drm_i915_mem_alloc32 {
@@ -178,8 +177,8 @@ static int compat_i915_alloc(struct file *file, unsigned int cmd, &request->region_offset))return -EFAULT ; -return drm_ioctl (file->f_path.dentry->d_inode, file, -DRM_IOCTL_I915_ALLOC , (unsigned long )request); +return drm_ioctl (file,DRM_IOCTL_I915_ALLOC , + (unsigned long )request); }drm_ioctl_compat_t *i915_compat_ioctls[] = {
@@ -211,12 +210,10 @@ long i915_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)if (nr <DRM_COMMAND_BASE +DRM_ARRAY_SIZE (i915_compat_ioctls)) fn = i915_compat_ioctls[nr -DRM_COMMAND_BASE ]; -lock_kernel ();/* XXX for now */ if (fn !=NULL ) ret = (*fn) (filp, cmd, arg);else - ret =drm_ioctl (filp->f_path.dentry->d_inode, filp, cmd, arg); -unlock_kernel (); + ret =drm_ioctl (filp, cmd, arg);return ret; }
drivers/gpu/drm/mga/mga_drv.c +1 -1
@@ -68,7 +68,7 @@ static struct drm_driver driver = { .owner = THIS_MODULE, .open = drm_open, .release = drm_release, - .ioctl = drm_ioctl, + .unlocked_ioctl = drm_ioctl, .mmap = drm_mmap, .poll = drm_poll, .fasync = drm_fasync,
drivers/gpu/drm/mga/mga_ioc32.c +4 -9
@@ -100,8 +100,7 @@ static int compat_mga_init(struct file *file, unsigned int cmd,if (err)return -EFAULT ; -return drm_ioctl (file->f_path.dentry->d_inode, file, -DRM_IOCTL_MGA_INIT , (unsigned long )init); +return drm_ioctl (file,DRM_IOCTL_MGA_INIT , (unsigned long )init); } typedef struct drm_mga_getparam32 {
@@ -125,8 +124,7 @@ static int compat_mga_getparam(struct file *file, unsigned int cmd, &getparam->value))return -EFAULT ; -return drm_ioctl (file->f_path.dentry->d_inode, file, -DRM_IOCTL_MGA_GETPARAM , (unsigned long )getparam); +return drm_ioctl (file,DRM_IOCTL_MGA_GETPARAM , (unsigned long )getparam); } typedef struct drm_mga_drm_bootstrap32 {
@@ -166,8 +164,7 @@ static int compat_mga_dma_bootstrap(struct file *file, unsigned int cmd, || __put_user(dma_bootstrap32.agp_size, &dma_bootstrap->agp_size))return -EFAULT ; - err =drm_ioctl (file->f_path.dentry->d_inode, file, -DRM_IOCTL_MGA_DMA_BOOTSTRAP , + err =drm_ioctl (file,DRM_IOCTL_MGA_DMA_BOOTSTRAP , (unsigned long )dma_bootstrap);if (err)return err;
@@ -220,12 +217,10 @@ long mga_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)if (nr <DRM_COMMAND_BASE +DRM_ARRAY_SIZE (mga_compat_ioctls)) fn = mga_compat_ioctls[nr -DRM_COMMAND_BASE ]; -lock_kernel ();/* XXX for now */ if (fn !=NULL ) ret = (*fn) (filp, cmd, arg);else - ret =drm_ioctl (filp->f_path.dentry->d_inode, filp, cmd, arg); -unlock_kernel (); + ret =drm_ioctl (filp, cmd, arg);return ret; }
drivers/gpu/drm/nouveau/nouveau_drv.c +1 -1
@@ -341,7 +341,7 @@ static struct drm_driver driver = { .owner = THIS_MODULE, .open = drm_open, .release = drm_release, - .ioctl = drm_ioctl, + .unlocked_ioctl = drm_ioctl, .mmap = nouveau_ttm_mmap, .poll = drm_poll, .fasync = drm_fasync,
drivers/gpu/drm/nouveau/nouveau_ioc32.c +1 -3
@@ -61,12 +61,10 @@ long nouveau_compat_ioctl(struct file *filp, unsigned int cmd,if (nr <DRM_COMMAND_BASE +DRM_ARRAY_SIZE (mga_compat_ioctls)) fn = nouveau_compat_ioctls[nr -DRM_COMMAND_BASE ];#endif -lock_kernel ();/* XXX for now */ if (fn !=NULL ) ret = (*fn)(filp, cmd, arg);else - ret =drm_ioctl (filp->f_dentry->d_inode, filp, cmd, arg); -unlock_kernel (); + ret =drm_ioctl (filp, cmd, arg);return ret; }
drivers/gpu/drm/r128/r128_drv.c +1 -1
@@ -64,7 +64,7 @@ static struct drm_driver driver = { .owner = THIS_MODULE, .open = drm_open, .release = drm_release, - .ioctl = drm_ioctl, + .unlocked_ioctl = drm_ioctl, .mmap = drm_mmap, .poll = drm_poll, .fasync = drm_fasync,
drivers/gpu/drm/r128/r128_ioc32.c +5 -11
@@ -95,8 +95,7 @@ static int compat_r128_init(struct file *file, unsigned int cmd, &init->agp_textures_offset))return -EFAULT ; -return drm_ioctl (file->f_path.dentry->d_inode, file, -DRM_IOCTL_R128_INIT , (unsigned long )init); +return drm_ioctl (file,DRM_IOCTL_R128_INIT , (unsigned long )init); } typedef struct drm_r128_depth32 {
@@ -129,8 +128,7 @@ static int compat_r128_depth(struct file *file, unsigned int cmd, &depth->mask))return -EFAULT ; -return drm_ioctl (file->f_path.dentry->d_inode, file, -DRM_IOCTL_R128_DEPTH , (unsigned long )depth); +return drm_ioctl (file,DRM_IOCTL_R128_DEPTH , (unsigned long )depth); }
@@ -153,8 +151,7 @@ static int compat_r128_stipple(struct file *file, unsigned int cmd, &stipple->mask))return -EFAULT ; -return drm_ioctl (file->f_path.dentry->d_inode, file, -DRM_IOCTL_R128_STIPPLE , (unsigned long )stipple); +return drm_ioctl (file,DRM_IOCTL_R128_STIPPLE , (unsigned long )stipple); } typedef struct drm_r128_getparam32 {
@@ -178,8 +175,7 @@ static int compat_r128_getparam(struct file *file, unsigned int cmd, &getparam->value))return -EFAULT ; -return drm_ioctl (file->f_path.dentry->d_inode, file, -DRM_IOCTL_R128_GETPARAM , (unsigned long )getparam); +return drm_ioctl (file,DRM_IOCTL_R128_GETPARAM , (unsigned long )getparam); }drm_ioctl_compat_t *r128_compat_ioctls[] = {
@@ -210,12 +206,10 @@ long r128_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)if (nr <DRM_COMMAND_BASE +DRM_ARRAY_SIZE (r128_compat_ioctls)) fn = r128_compat_ioctls[nr -DRM_COMMAND_BASE ]; -lock_kernel ();/* XXX for now */ if (fn !=NULL ) ret = (*fn) (filp, cmd, arg);else - ret =drm_ioctl (filp->f_path.dentry->d_inode, filp, cmd, arg); -unlock_kernel (); + ret =drm_ioctl (filp, cmd, arg);return ret; }
drivers/gpu/drm/radeon/radeon_drv.c +2 -2
@@ -192,7 +192,7 @@ static struct drm_driver driver_old = { .owner = THIS_MODULE, .open = drm_open, .release = drm_release, - .ioctl = drm_ioctl, + .unlocked_ioctl = drm_ioctl, .mmap = drm_mmap, .poll = drm_poll, .fasync = drm_fasync,
@@ -280,7 +280,7 @@ static struct drm_driver kms_driver = { .owner = THIS_MODULE, .open = drm_open, .release = drm_release, - .ioctl = drm_ioctl, + .unlocked_ioctl = drm_ioctl, .mmap = radeon_mmap, .poll = drm_poll, .fasync = drm_fasync,
drivers/gpu/drm/radeon/radeon_ioc32.c +12 -26
@@ -92,8 +92,7 @@ static int compat_radeon_cp_init(struct file *file, unsigned int cmd, &init->gart_textures_offset))return -EFAULT ; -return drm_ioctl (file->f_path.dentry->d_inode, file, -DRM_IOCTL_RADEON_CP_INIT , (unsigned long )init); +return drm_ioctl (file,DRM_IOCTL_RADEON_CP_INIT , (unsigned long )init); } typedef struct drm_radeon_clear32 {
@@ -125,8 +124,7 @@ static int compat_radeon_cp_clear(struct file *file, unsigned int cmd, &clr->depth_boxes))return -EFAULT ; -return drm_ioctl (file->f_path.dentry->d_inode, file, -DRM_IOCTL_RADEON_CLEAR , (unsigned long )clr); +return drm_ioctl (file,DRM_IOCTL_RADEON_CLEAR , (unsigned long )clr); } typedef struct drm_radeon_stipple32 {
@@ -149,8 +147,7 @@ static int compat_radeon_cp_stipple(struct file *file, unsigned int cmd, &request->mask))return -EFAULT ; -return drm_ioctl (file->f_path.dentry->d_inode, file, -DRM_IOCTL_RADEON_STIPPLE , (unsigned long )request); +return drm_ioctl (file,DRM_IOCTL_RADEON_STIPPLE , (unsigned long )request); } typedef struct drm_radeon_tex_image32 {
@@ -204,8 +201,7 @@ static int compat_radeon_cp_texture(struct file *file, unsigned int cmd, &image->data))return -EFAULT ; -return drm_ioctl (file->f_path.dentry->d_inode, file, -DRM_IOCTL_RADEON_TEXTURE , (unsigned long )request); +return drm_ioctl (file,DRM_IOCTL_RADEON_TEXTURE , (unsigned long )request); } typedef struct drm_radeon_vertex2_32 {
@@ -238,8 +234,7 @@ static int compat_radeon_cp_vertex2(struct file *file, unsigned int cmd, &request->prim))return -EFAULT ; -return drm_ioctl (file->f_path.dentry->d_inode, file, -DRM_IOCTL_RADEON_VERTEX2 , (unsigned long )request); +return drm_ioctl (file,DRM_IOCTL_RADEON_VERTEX2 , (unsigned long )request); } typedef struct drm_radeon_cmd_buffer32 {
@@ -268,8 +263,7 @@ static int compat_radeon_cp_cmdbuf(struct file *file, unsigned int cmd, &request->boxes))return -EFAULT ; -return drm_ioctl (file->f_path.dentry->d_inode, file, -DRM_IOCTL_RADEON_CMDBUF , (unsigned long )request); +return drm_ioctl (file,DRM_IOCTL_RADEON_CMDBUF , (unsigned long )request); } typedef struct drm_radeon_getparam32 {
@@ -293,8 +287,7 @@ static int compat_radeon_cp_getparam(struct file *file, unsigned int cmd, &request->value))return -EFAULT ; -return drm_ioctl (file->f_path.dentry->d_inode, file, -DRM_IOCTL_RADEON_GETPARAM , (unsigned long )request); +return drm_ioctl (file,DRM_IOCTL_RADEON_GETPARAM , (unsigned long )request); } typedef struct drm_radeon_mem_alloc32 {
@@ -322,8 +315,7 @@ static int compat_radeon_mem_alloc(struct file *file, unsigned int cmd, &request->region_offset))return -EFAULT ; -return drm_ioctl (file->f_path.dentry->d_inode, file, -DRM_IOCTL_RADEON_ALLOC , (unsigned long )request); +return drm_ioctl (file,DRM_IOCTL_RADEON_ALLOC , (unsigned long )request); } typedef struct drm_radeon_irq_emit32 {
@@ -345,8 +337,7 @@ static int compat_radeon_irq_emit(struct file *file, unsigned int cmd, &request->irq_seq))return -EFAULT ; -return drm_ioctl (file->f_path.dentry->d_inode, file, -DRM_IOCTL_RADEON_IRQ_EMIT , (unsigned long )request); +return drm_ioctl (file,DRM_IOCTL_RADEON_IRQ_EMIT , (unsigned long )request); }/* The two 64-bit arches where alignof(u64)==4 in 32-bit code */
@@ -372,8 +363,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd, &request->value))return -EFAULT ; -return drm_ioctl (file->f_dentry->d_inode, file, - DRM_IOCTL_RADEON_SETPARAM, (unsigned long) request); + return drm_ioctl(file, DRM_IOCTL_RADEON_SETPARAM, (unsigned long) request); }#else #define compat_radeon_cp_setparam NULL
@@ -413,12 +403,10 @@ long radeon_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)if (nr <DRM_COMMAND_BASE +DRM_ARRAY_SIZE (radeon_compat_ioctls)) fn = radeon_compat_ioctls[nr -DRM_COMMAND_BASE ]; -lock_kernel ();/* XXX for now */ if (fn !=NULL ) ret = (*fn) (filp, cmd, arg);else - ret =drm_ioctl (filp->f_path.dentry->d_inode, filp, cmd, arg); -unlock_kernel (); + ret =drm_ioctl (filp, cmd, arg);return ret; }
@@ -431,9 +419,7 @@ long radeon_kms_compat_ioctl(struct file *filp, unsigned int cmd, unsigned longif (nr <DRM_COMMAND_BASE )return drm_compat_ioctl (filp, cmd, arg); -lock_kernel ();/* XXX for now */ - ret =drm_ioctl (filp->f_path.dentry->d_inode, filp, cmd, arg); -unlock_kernel (); + ret =drm_ioctl (filp, cmd, arg);return ret; }
drivers/gpu/drm/savage/savage_drv.c +1 -1
@@ -50,7 +50,7 @@ static struct drm_driver driver = { .owner = THIS_MODULE, .open = drm_open, .release = drm_release, - .ioctl = drm_ioctl, + .unlocked_ioctl = drm_ioctl, .mmap = drm_mmap, .poll = drm_poll, .fasync = drm_fasync,
drivers/gpu/drm/sis/sis_drv.c +1 -1
@@ -80,7 +80,7 @@ static struct drm_driver driver = { .owner = THIS_MODULE, .open = drm_open, .release = drm_release, - .ioctl = drm_ioctl, + .unlocked_ioctl = drm_ioctl, .mmap = drm_mmap, .poll = drm_poll, .fasync = drm_fasync,
drivers/gpu/drm/tdfx/tdfx_drv.c +1 -1
@@ -48,7 +48,7 @@ static struct drm_driver driver = { .owner = THIS_MODULE, .open = drm_open, .release = drm_release, - .ioctl = drm_ioctl, + .unlocked_ioctl = drm_ioctl, .mmap = drm_mmap, .poll = drm_poll, .fasync = drm_fasync,
drivers/gpu/drm/via/via_drv.c +1 -1
@@ -58,7 +58,7 @@ static struct drm_driver driver = { .owner = THIS_MODULE, .open = drm_open, .release = drm_release, - .ioctl = drm_ioctl, + .unlocked_ioctl = drm_ioctl, .mmap = drm_mmap, .poll = drm_poll, .fasync = drm_fasync,
include/drm/drmP.h +2 -2
@@ -1128,8 +1128,8 @@ static inline int drm_mtrr_del(int handle, unsigned long offset,/* Driver support (drm_drv.h) */ extern int drm_init (struct drm_driver *driver);extern void drm_exit (struct drm_driver *driver); -extern int drm_ioctl (struct inode *inode,struct file *filp, -unsigned int cmd,unsigned long arg); +extern long drm_ioctl (struct file *filp, +unsigned int cmd,unsigned long arg);extern long drm_compat_ioctl (struct file *filp,unsigned int cmd,unsigned long arg);extern int drm_lastclose (struct drm_device *dev);
RFC 1/1 drm: allow unlocked ioctls in drivers
I just tried to find out what it would take to get the BKL /mostly/ out of drm. The approach I tried was to add another flag to the ioctl list for commands that do not need the big kernel lock.
I blindly applied this flag to all the most commonly used ioctl commands without checking if they actually rely on the lock. This cuts down the overall BKL usage on my system by about 90%.
Based on the previous patch to turn drm_ioctl itself into an unlocked call.
---
The machine still crashes because of another problem I'm trying to nail down (coincidentally in the same driver), so I don't even have a way of testing if this otherwise works, but the crashes did not seem to get more frequent either...
drivers/gpu/drm/drm_drv.c +7 -3
@@ -502,9 +502,13 @@ long drm_ioctl(struct file *filp, goto err_i1; } } -lock_kernel (); - retcode =func (dev, kdata, file_priv); -unlock_kernel (); +if (ioctl->flags &DRM_UNLOCKED ) + retcode =func (dev, kdata, file_priv); +else { +lock_kernel (); + retcode =func (dev, kdata, file_priv); +unlock_kernel (); + }if (cmd &IOC_OUT ) { if (copy_to_user((void __user *)arg, kdata,
drivers/gpu/drm/i915/i915_dma.c +10 -10
@@ -1651,20 +1651,20 @@ struct drm_ioctl_desc i915_ioctls[] = {DRM_IOCTL_DEF (DRM_I915_VBLANK_SWAP , i915_vblank_swap,DRM_AUTH ),DRM_IOCTL_DEF (DRM_I915_HWS_ADDR , i915_set_status_page,DRM_AUTH |DRM_MASTER |DRM_ROOT_ONLY ),DRM_IOCTL_DEF (DRM_I915_GEM_INIT , i915_gem_init_ioctl,DRM_AUTH |DRM_MASTER |DRM_ROOT_ONLY ), -DRM_IOCTL_DEF (DRM_I915_GEM_EXECBUFFER , i915_gem_execbuffer,DRM_AUTH ), +DRM_IOCTL_DEF (DRM_I915_GEM_EXECBUFFER , i915_gem_execbuffer,DRM_AUTH |DRM_UNLOCKED ),DRM_IOCTL_DEF (DRM_I915_GEM_PIN , i915_gem_pin_ioctl,DRM_AUTH |DRM_ROOT_ONLY ),DRM_IOCTL_DEF (DRM_I915_GEM_UNPIN , i915_gem_unpin_ioctl,DRM_AUTH |DRM_ROOT_ONLY ), -DRM_IOCTL_DEF (DRM_I915_GEM_BUSY , i915_gem_busy_ioctl,DRM_AUTH ), -DRM_IOCTL_DEF (DRM_I915_GEM_THROTTLE , i915_gem_throttle_ioctl,DRM_AUTH ), +DRM_IOCTL_DEF (DRM_I915_GEM_BUSY , i915_gem_busy_ioctl,DRM_AUTH |DRM_UNLOCKED ), +DRM_IOCTL_DEF (DRM_I915_GEM_THROTTLE , i915_gem_throttle_ioctl,DRM_AUTH |DRM_UNLOCKED ),DRM_IOCTL_DEF (DRM_I915_GEM_ENTERVT , i915_gem_entervt_ioctl,DRM_AUTH |DRM_MASTER |DRM_ROOT_ONLY ),DRM_IOCTL_DEF (DRM_I915_GEM_LEAVEVT , i915_gem_leavevt_ioctl,DRM_AUTH |DRM_MASTER |DRM_ROOT_ONLY ), -DRM_IOCTL_DEF (DRM_I915_GEM_CREATE , i915_gem_create_ioctl,0 ), -DRM_IOCTL_DEF (DRM_I915_GEM_PREAD , i915_gem_pread_ioctl,0 ), -DRM_IOCTL_DEF (DRM_I915_GEM_PWRITE , i915_gem_pwrite_ioctl,0 ), -DRM_IOCTL_DEF (DRM_I915_GEM_MMAP , i915_gem_mmap_ioctl,0 ), -DRM_IOCTL_DEF (DRM_I915_GEM_MMAP_GTT , i915_gem_mmap_gtt_ioctl,0 ), -DRM_IOCTL_DEF (DRM_I915_GEM_SET_DOMAIN , i915_gem_set_domain_ioctl,0 ), -DRM_IOCTL_DEF (DRM_I915_GEM_SW_FINISH , i915_gem_sw_finish_ioctl,0 ), +DRM_IOCTL_DEF (DRM_I915_GEM_CREATE , i915_gem_create_ioctl,DRM_UNLOCKED ), +DRM_IOCTL_DEF (DRM_I915_GEM_PREAD , i915_gem_pread_ioctl,DRM_UNLOCKED ), +DRM_IOCTL_DEF (DRM_I915_GEM_PWRITE , i915_gem_pwrite_ioctl,DRM_UNLOCKED ), +DRM_IOCTL_DEF (DRM_I915_GEM_MMAP , i915_gem_mmap_ioctl,DRM_UNLOCKED ), +DRM_IOCTL_DEF (DRM_I915_GEM_MMAP_GTT , i915_gem_mmap_gtt_ioctl,DRM_UNLOCKED ), +DRM_IOCTL_DEF (DRM_I915_GEM_SET_DOMAIN , i915_gem_set_domain_ioctl,DRM_UNLOCKED ), +DRM_IOCTL_DEF (DRM_I915_GEM_SW_FINISH , i915_gem_sw_finish_ioctl,DRM_UNLOCKED ),DRM_IOCTL_DEF (DRM_I915_GEM_SET_TILING , i915_gem_set_tiling,0 ),DRM_IOCTL_DEF (DRM_I915_GEM_GET_TILING , i915_gem_get_tiling,0 ), DRM_IOCTL_DEF(DRM_I915_GEM_GET_APERTURE, i915_gem_get_aperture_ioctl, 0),
include/drm/drmP.h +1 -0
@@ -296,6 +296,7 @@ typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,#define DRM_MASTER 0x2#define DRM_ROOT_ONLY 0x4#define DRM_CONTROL_ALLOW 0x8 +#define DRM_UNLOCKED 0x10struct drm_ioctl_desc {unsigned int cmd;
Dave Airlie
maintainerQuoted 14 lines · Arnd Bergmann
drm_ioctlis called with the Big Kernel Lock held, which shows up very high in statistics onvfs_ioctl.Moving the lock into the
drm_ioctlfunction itself makes sure we blame the right subsystem and it gets us one step closer to eliminating the locked version offops->ioctl.Since
drm_ioctldoes not require the lock itself, we only need to hold it while calling the specific handler. The 32 bit conversion handlers do not interact with any other code, so they don't need the BKL here either and can just calldrm_ioctl.
Quoted 4 lines
As a bonus, this cleans up all the other users of
drm_ioctlwhich now no longer have to find the inode or calllock_kernel.
This looks good, I've taken this and I've squashed the generic pieces of your RFC into this (i.e. I haven't modified the drivers, but just added the flag to allow the ioctls to be unlocked if the driver selects them).
Do you think we should try and get this in soon, its seems like it shouldn't have any regressions unless we start switching drivers over.
Dave.
Quoted 9 lines · Dave Airlie
This looks good, I've taken this and I've squashed the generic pieces of your RFC into this (i.e. I haven't modified the drivers, but just added the flag to allow the ioctls to be unlocked if the driver selects them).
Do you think we should try and get this in soon, its seems like it shouldn't have any regressions unless we start switching drivers over.
Well, since the patch should not change the behaviour of the drivers, it probably doesn't matter to users either way. However, it touches a number of places, which can break patches that others are working on, so maybe you should get it upstream at a point that has the least impact to developer (possibly now).
Doing it now at least makes it easier to test moving drivers to unlocked operation.
Arnd
Quoted 20 lines · Arnd Bergmann
Quoted 10 lines · Dave Airlie
This looks good, I've taken this and I've squashed the generic pieces of your RFC into this (i.e. I haven't modified the drivers, but just added the flag to allow the ioctls to be unlocked if the driver selects them).
Do you think we should try and get this in soon, its seems like it shouldn't have any regressions unless we start switching drivers over.
Well, since the patch should not change the behaviour of the drivers, it probably doesn't matter to users either way. However, it touches a number of places, which can break patches that others are working on, so maybe you should get it upstream at a point that has the least impact to developer (possibly now).
Quoted 5 lines
Doing it now at least makes it easier to test
moving drivers to unlocked operation.Arnd
I'm very much for this as well.
Note that the vmwgfx driver has another (workaround-like) approach to achieve unlocked driver ioctls, but it shouldn't be too hard to convert it.
/Thomas
Quoted 12 lines
------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community Take advantage of Verizon's best-in-class app development support A streamlined, 14 day to market process makes app distribution fast and easy Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev
--
_______________________________________________
Dri-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dri-devel