Thread (4 messages) 4 messages, 3 authors, 2020-08-19

Re: [PATCHv2] serial: 8250: change lock order in serial8250_do_startup()

From: Petr Mladek <pmladek@suse.com>
Date: 2020-08-19 09:21:17
Also in: lkml

On Mon 2020-08-17 11:26:46, Sergey Senozhatsky wrote:
We have a number of "uart.port->desc.lock vs desc.lock->uart.port"
lockdep reports coming from 8250 driver; this causes a bit of trouble
to people, so let's fix it.

The problem is reverse lock order in two different call paths:

chain #1:

 serial8250_do_startup()
  spin_lock_irqsave(&port->lock);
   disable_irq_nosync(port->irq);
    raw_spin_lock_irqsave(&desc->lock)

chain #2:

  __report_bad_irq()
   raw_spin_lock_irqsave(&desc->lock)
    for_each_action_of_desc()
     printk()
      spin_lock_irqsave(&port->lock);

Fix this by changing the order of locks in serial8250_do_startup():
 do disable_irq_nosync() first, which grabs desc->lock, and grab
 uart->port after that, so that chain #1 and chain #2 have same lock
 order.


Signed-off-by: Sergey Senozhatsky <redacted>
The patch is committed in printk/linux.git, branch for-5.10.

Best Regards,
Petr
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help