Re: [RFC][PATCH 0/6] Use printk_safe context for TTY and UART port locks
From: Sergey Senozhatsky
Date: Tue Jun 19 2018 - 04:59:47 EST
On (06/19/18 10:30), Petr Mladek wrote:
> It is re-entrant via printk(). I mean that any printk() called inside
> the locked sections might cause recursion if the same lock is needed
> also by con->write() callbacks.
Perhaps Alan meant that we cannot return back to tty once we passed
the control from tty to printk -> uart serial console. So tty is
probably (but I didn't check) not re-entrant, but uart definitely is
re-entrant: IRQ -> uart console -> tty -> printk -> uart console.
The patch set attempts to address several issues, and re-entrant uart
is just one of them.
[..]
> This patchset forces safe context around TTY and UART locks.
Right.
> In fact, the deferred context would be enough to prevent
> all the mentioned deadlocks.
Agree.
But we can leave it as a printk_safe implementation detail and
change it later, outside of this patch, to avoid further confusion.
> IMHO, the only question is if people might get familiar with
> yet another spin_lock API.
Right. That's why I thought about renaming uart_port and tty_port
->lock to ->____lock. So the naming will suggest [hopefully] that
those locks are not meant to be used directly [anymore] and instead
people should use uart_port_lock/tty_port_lock API.
-ss