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>
Tue, 12 Feb 2019 18:47:11 +0000 (19:47 +0100)
commitd71126505dba982e4309370efa4bd804f8693f36
tree474ea938e5dbe51ed8e2e715966bfb9c81f7a00d
parent3733632e8bc09971dccf8550e3872fd696d89d92
serial: sh-sci: Fix locking in sci_submit_rx()

[ Upstream commit dd1f2250da95e87cb3e612858f94b14f99445a7c ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/tty/serial/sh-sci.c