[PATCH] tty: Remove pointless synchronize_irq() in uart_port_shutdown()

Thomas Pfaff posted 1 patch 3 years, 12 months ago
[PATCH] tty: Remove pointless synchronize_irq() in uart_port_shutdown()
Posted by Thomas Pfaff 3 years, 12 months ago
From: Thomas Pfaff <tpfaff@pcs.com>

Calling synchronize_irq() after free_irq() is pointless, the context to
the irq is already lost.
It was noticed while creating the bugfix "genirq: Synchronize interrupt 
thread startup".

Signed-off-by: Thomas Pfaff <tpfaff@pcs.com>
---
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index 57840cf90388..b76e76e650ba 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -1704,12 +1704,6 @@ static void uart_port_shutdown(struct tty_port *port)
 	 */
 	if (uport)
 		uport->ops->shutdown(uport);
-
-	/*
-	 * Ensure that the IRQ handler isn't running on another CPU.
-	 */
-	if (uport)
-		synchronize_irq(uport->irq);
 }
 
 static int uart_carrier_raised(struct tty_port *port)
Re: [PATCH] tty: Remove pointless synchronize_irq() in uart_port_shutdown()
Posted by Jiri Slaby 3 years, 12 months ago
On 10. 05. 22, 15:54, Thomas Pfaff wrote:
> From: Thomas Pfaff <tpfaff@pcs.com>
> 
> Calling synchronize_irq() after free_irq() is pointless, the context to
> the irq is already lost.
> It was noticed while creating the bugfix "genirq: Synchronize interrupt
> thread startup".

That's correct for most drivers. But some drivers don't call free_irq() 
in ->shutdown(). So you likely have to move the synchronization to them. 
By a quick grep, I found icom, jsm, sccnxp, sifive, sunhv, and sunzilog.

> Signed-off-by: Thomas Pfaff <tpfaff@pcs.com>
> ---
> diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
> index 57840cf90388..b76e76e650ba 100644
> --- a/drivers/tty/serial/serial_core.c
> +++ b/drivers/tty/serial/serial_core.c
> @@ -1704,12 +1704,6 @@ static void uart_port_shutdown(struct tty_port *port)
>   	 */
>   	if (uport)
>   		uport->ops->shutdown(uport);
> -
> -	/*
> -	 * Ensure that the IRQ handler isn't running on another CPU.
> -	 */
> -	if (uport)
> -		synchronize_irq(uport->irq);
>   }
>   
>   static int uart_carrier_raised(struct tty_port *port)
> 
> 


-- 
js
suse labs
Re: [PATCH] tty: Remove pointless synchronize_irq() in uart_port_shutdown()
Posted by Thomas Pfaff 3 years, 12 months ago

On Wed, 11 May 2022, Jiri Slaby wrote:

> On 10. 05. 22, 15:54, Thomas Pfaff wrote:
> > From: Thomas Pfaff <tpfaff@pcs.com>
> > 
> > Calling synchronize_irq() after free_irq() is pointless, the context to
> > the irq is already lost.
> > It was noticed while creating the bugfix "genirq: Synchronize interrupt
> > thread startup".
> 
> That's correct for most drivers. But some drivers don't call free_irq() in
> ->shutdown(). So you likely have to move the synchronization to them. By a
> quick grep, I found icom, jsm, sccnxp, sifive, sunhv, and sunzilog.
> 

Sorry, I did not check all the drivers.
Then I would keep it in serial_core, as it does not hurt anymore.

Thanks,
    Thomas
Re: [PATCH] tty: Remove pointless synchronize_irq() in uart_port_shutdown()
Posted by Thomas Gleixner 3 years, 12 months ago
On Tue, May 10 2022 at 15:54, Thomas Pfaff wrote:
> From: Thomas Pfaff <tpfaff@pcs.com>
>
> Calling synchronize_irq() after free_irq() is pointless, the context to
> the irq is already lost.
> It was noticed while creating the bugfix "genirq: Synchronize interrupt 
> thread startup".
>
> Signed-off-by: Thomas Pfaff <tpfaff@pcs.com>

Reviewed-by: Thomas Gleixner <tglx@linutronix.de>