• Arnd Bergmann's avatar
    ataflop: fix sleep_on races · 7b8a3d22
    Arnd Bergmann authored
    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: default avatarArnd 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: default avatarJens Axboe <axboe@fb.com>
    7b8a3d22
ataflop.c 52 KB