]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commit
ataflop: fix sleep_on races
authorArnd Bergmann <arnd@arndb.de>
Wed, 26 Feb 2014 11:01:41 +0000 (12:01 +0100)
committerJens Axboe <axboe@fb.com>
Thu, 13 Mar 2014 20:56:38 +0000 (14:56 -0600)
commit7b8a3d22ba93682a542a445ef43d03f495cdf3d6
treea4eb23f8700166ded319f7e7352ae527fdf234a7
parent9c552e1ddd3658944787d75d90a42e1a2b74b7ea
ataflop: fix sleep_on races

sleep_on() is inherently racy, and has been deprecated for a long time.
This fixes two instances in the atari floppy driver:

* fdc_wait/fdc_busy becomes an open-coded mutex. We cannot use the
  regular mutex since it gets released in interrupt context. The
  open-coded version using wait_event() and cmpxchg() is equivalent
  to the existing code but does the checks atomically, and we can
  now safely check the condition with irqs enabled.

* format_wait becomes a completion, which is the natural structure
  here. The format ioctl waits for the background task to either
  complete or abort.

This does not attempt to fix the preexisting bug of calling schedule
with local interrupts disabled.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Michael Schmitz <schmitz@biophys.uni-duesseldorf.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
drivers/block/ataflop.c