serial: sh-sci: Fix locking in sci_submit_rx()
authorGeert Uytterhoeven <geert+renesas@glider.be>
Thu, 13 Dec 2018 18:44:41 +0000 (19:44 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 17 Dec 2018 14:04:11 +0000 (15:04 +0100)
commitdd1f2250da95e87cb3e612858f94b14f99445a7c
tree406593c03de741fed6f29c721b69484ebcca2db5
parent9c96f401e91a4358eb4a5e227c1521dea1c20127
serial: sh-sci: Fix locking in sci_submit_rx()

Some callers of sci_submit_rx() hold the port spinlock, others don't.
During fallback to PIO, the driver needs to obtain the port spinlock.
If the lock was already held, spinlock recursion is detected, causing a
deadlock: BUG: spinlock recursion on CPU#0.

Fix this by adding a flag parameter to sci_submit_rx() for the caller to
indicate the port spinlock is already held, so spinlock recursion can be
avoided.

Move the spin_lock_irqsave() up, so all DMA disable steps are protected,
which is safe as the recently introduced dmaengine_terminate_async() can
be called in atomic context.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/sh-sci.c