Re: [Linux-fbdev-devel] [PATCH] fb: Remove use of lock_kernel /unlock_kernel in fbmem

From: Andrew Morton
Date: Wed Apr 16 2008 - 01:17:43 EST


On Sun, 13 Apr 2008 11:50:07 -0300 Thiago Galesi <thiagogalesi@xxxxxxxxx> wrote:

> This patch removes lock_kernel(), unlock_kernel() usage in fbmem.c and replaces it with a mutex

It isn't that simple, alas.

vfs_ioctl() runs lock_kernel() prior to calling fb_ioctl(), so the
lock_kernel()s in fb_compat_ioctl() are actually providing exclusion against
fb_ioctl(). Your patch would break that.

A suitable fix might be to do

__fb_ioctl(...)
{
<copy fb_ioctl() into here>
}

fb_ioctl(...)
{
mutex_lock(&info->hwlock);
__fb_ioctl(...);
mutex_unlock(&info->hwlock);
}

and then change fb_compat_ioctl() to call __fb_ioctl(). All the other
callers of fb_ioctl() would need to be reviewed - see if they need to take
the mutex then call __fb_ioctl(), or they might be OK as they are, calling
fb_ioctl().

Then we can switch fb_fops over to

.ioctl = NULL,
.unlocked_ioctl = fb_ioctl,


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/