Commit 0d4a7bc12ffecd3ba41dd94179cc5b272b71ce8a

Authored by Jonathan Corbet
1 parent 3fa8749e58

UIO: BKL removal

Fill in needed locking around idr accesses, then remove the big kernel lock
from the UIO driver.  Since there are no in-tree UIO drivers with open()
methods, no further BKL pushdown is required.

Acked-by: Hans J. Koch <hjk@linutronix.de>
Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>

Showing 1 changed file with 8 additions and 6 deletions Side-by-side Diff

... ... @@ -47,6 +47,9 @@
47 47 struct class *class;
48 48 } *uio_class;
49 49  
  50 +/* Protect idr accesses */
  51 +static DEFINE_MUTEX(minor_lock);
  52 +
50 53 /*
51 54 * attributes
52 55 */
... ... @@ -231,7 +234,6 @@
231 234  
232 235 static int uio_get_minor(struct uio_device *idev)
233 236 {
234   - static DEFINE_MUTEX(minor_lock);
235 237 int retval = -ENOMEM;
236 238 int id;
237 239  
238 240  
... ... @@ -253,7 +255,9 @@
253 255  
254 256 static void uio_free_minor(struct uio_device *idev)
255 257 {
  258 + mutex_lock(&minor_lock);
256 259 idr_remove(&uio_idr, idev->minor);
  260 + mutex_unlock(&minor_lock);
257 261 }
258 262  
259 263 /**
260 264  
... ... @@ -297,8 +301,9 @@
297 301 struct uio_listener *listener;
298 302 int ret = 0;
299 303  
300   - lock_kernel();
  304 + mutex_lock(&minor_lock);
301 305 idev = idr_find(&uio_idr, iminor(inode));
  306 + mutex_unlock(&minor_lock);
302 307 if (!idev) {
303 308 ret = -ENODEV;
304 309 goto out;
305 310  
306 311  
307 312  
308 313  
... ... @@ -324,18 +329,15 @@
324 329 if (ret)
325 330 goto err_infoopen;
326 331 }
327   - unlock_kernel();
328 332 return 0;
329 333  
330 334 err_infoopen:
331   -
332 335 kfree(listener);
333   -err_alloc_listener:
334 336  
  337 +err_alloc_listener:
335 338 module_put(idev->owner);
336 339  
337 340 out:
338   - unlock_kernel();
339 341 return ret;
340 342 }
341 343