Skip to contentSkip to conversation

mpx5200_uart: drop port lock across tty_flip_buffer() call

PATCH In review Thomas Gleixner 3 participants 6 messages Jul 25, 2007 – Jul 26, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mpx5200_uart: drop port lock across tty_flip_buffer() call

The port lock needs to be dropped across the tty_flip_buffer call, as it would lead to a deadlock with the spin_lock(&port->lock) in uart_start()

Uncovered by lockdep / preempt-rt

drivers/serial/mpc52xx_uart.c +2 -0
Index: linux-2.6.22/drivers/serial/mpc52xx_uart.c
===================================================================
@@ -501,7 +501,9 @@ mpc52xx_uart_int_rx_chars(struct uart_po
 		}
 	}
 
+	spin_unlock(&port->lock);
 	tty_flip_buffer_push(tty);
+	spin_lock(&port->lock);
 
 	return in_be16(&PSC(port)->mpc52xx_psc_status) & MPC52xx_PSC_SR_RXRDY;
 }
#1 lore raw
Quoted 6 lines · Thomas Gleixner

The port lock needs to be dropped across the tty_flip_buffer call, as it would lead to a deadlock with the spin_lock(&port->lock) in uart_start()

Uncovered by lockdep / preempt-rt

Instead of dropping the lock and reclaiming it, would it be better for me to rework the driver to only grab the lock in the 'meat' of
mpc52xx_uart_int_rx_chars() and mpc52xx_uart_int_tx_chars()? (As
opposed to holding the lock for the entirety of mpc52xx_uart_int()) What convention is used in other drivers?

Cheers,
g.

Quoted 23 lines

Index: linux-2.6.22/drivers/serial/mpc52xx_uart.c
===================================================================

drivers/serial/mpc52xx_uart.c 2007-07-25 21:06:11.000000000 +0200 renamed from drivers/serial/mpc52xx_uart.c 2007-07-09 01:32:17.000000000 +0200 +2 -0
@@ -501,7 +501,9 @@ mpc52xx_uart_int_rx_chars(struct uart_po
                }
        }
 
+       spin_unlock(&port->lock);
        tty_flip_buffer_push(tty);
+       spin_lock(&port->lock);
 
        return in_be16(&PSC(port)->mpc52xx_psc_status) & MPC52xx_PSC_SR_RXRDY;
 }

_______________________________________________
Linuxppc-embedded mailing list
[email protected]
https://ozlabs.org/mailman/listinfo/linuxppc-embedded

Signature · 4 lines
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
[email protected]
(403) 399-0195
#2 lore raw
Quoted 4 lines · Grant Likely
Quoted 3 lines · Thomas Gleixner

The port lock needs to be dropped across the tty_flip_buffer call, as it would lead to a deadlock with the spin_lock(&port->lock) in uart_start()

Quoted 8 lines
Quoted 3 lines

Uncovered by lockdep / preempt-rt

Instead of dropping the lock and reclaiming it, would it be better for me to rework the driver to only grab the lock in the 'meat' of
mpc52xx_uart_int_rx_chars() and mpc52xx_uart_int_tx_chars()? (As
opposed to holding the lock for the entirety of mpc52xx_uart_int())

No, it's not worth the trouble. You need to protect the hardware access.

Quoted 1 line

What convention is used in other drivers?

The same.

tglx

#3 lore raw
Quoted 14 lines · Thomas Gleixner
Quoted 4 lines · Grant Likely
Quoted 3 lines · Thomas Gleixner

The port lock needs to be dropped across the tty_flip_buffer call, as it would lead to a deadlock with the spin_lock(&port->lock) in uart_start()

Quoted 8 lines
Quoted 3 lines

Uncovered by lockdep / preempt-rt

Instead of dropping the lock and reclaiming it, would it be better for me to rework the driver to only grab the lock in the 'meat' of
mpc52xx_uart_int_rx_chars() and mpc52xx_uart_int_tx_chars()? (As
opposed to holding the lock for the entirety of mpc52xx_uart_int())

Quoted 5 lines

No, it's not worth the trouble. You need to protect the hardware access.

Quoted 1 line

What convention is used in other drivers?

The same.

Okay, thanks.

Kumar, this is a bug fix, can you pick it up please?

Signature · 4 lines
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
[email protected]
(403) 399-0195
#4 lore raw
In reply to Thomas Gleixner
Quoted 9 lines · Thomas Gleixner
Quoted 8 lines · Grant Likely
Quoted 7 lines · Thomas Gleixner

The port lock needs to be dropped across the tty_flip_buffer call, as it would lead to a deadlock with the spin_lock(&port->lock) in uart_start()=20
=20
Uncovered by lockdep / preempt-rt
=20

While you are at it 8=B0> ... the mpc5200-fec driver has serious = problems with preempt-rt, similar to what the IBM emac had ....

Best regards,

Daniel Schnell.

#5 lore raw
Quoted 8 lines · Daniel Schnell
Quoted 6 lines · Thomas Gleixner
Quoted 5 lines · Grant Likely
Quoted 4 lines · Thomas Gleixner

The port lock needs to be dropped across the tty_flip_buffer call, as it would lead to a deadlock with the spin_lock(&port->lock) in uart_start()

Quoted 6 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Uncovered by lockdep / preempt-rt

While you are at it 8°> ... the mpc5200-fec driver has serious problems with preempt-rt, similar to what the IBM emac had ....

Care to whip up a patch ?

tglx