mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] serial: 8250: Fix oops for port->pm on uart_change_pm()
@ 2023-08-04 13:15 Tony Lindgren
  2023-08-04 19:44 ` Andy Shevchenko
  2023-08-05  5:04 ` Dhruva Gole
  0 siblings, 2 replies; 3+ messages in thread
From: Tony Lindgren @ 2023-08-04 13:15 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby
  Cc: Andy Shevchenko, Dhruva Gole, Ilpo Järvinen, John Ogness,
	Johan Hovold, Sebastian Andrzej Siewior, Vignesh Raghavendra,
	linux-kernel, linux-serial

Unloading a hardware specific 8250 driver can produce error "Unable to
handle kernel paging request at virtual address" about ten seconds after
unloading the driver. This happens on uart_hangup() calling
uart_change_pm().

Turns out commit 04e82793f068 ("serial: 8250: Reinit port->pm on port
specific driver unbind") was only a partial fix. If the hardware specific
driver has initialized port->pm function, we need to clear port->pm too.
Just reinitializing port->ops does not do this. Otherwise serial8250_pm()
will call port->pm() instead of serial8250_do_pm().

Fixes: 04e82793f068 ("serial: 8250: Reinit port->pm on port specific driver unbind")
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 drivers/tty/serial/8250/8250_port.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
--- a/drivers/tty/serial/8250/8250_port.c
+++ b/drivers/tty/serial/8250/8250_port.c
@@ -3278,6 +3278,7 @@ void serial8250_init_port(struct uart_8250_port *up)
 
 	spin_lock_init(&port->lock);
 	port->ctrl_id = 0;
+	port->pm = NULL;
 	port->ops = &serial8250_pops;
 	port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_8250_CONSOLE);
 
-- 
2.41.0

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] serial: 8250: Fix oops for port->pm on uart_change_pm()
  2023-08-04 13:15 [PATCH] serial: 8250: Fix oops for port->pm on uart_change_pm() Tony Lindgren
@ 2023-08-04 19:44 ` Andy Shevchenko
  2023-08-05  5:04 ` Dhruva Gole
  1 sibling, 0 replies; 3+ messages in thread
From: Andy Shevchenko @ 2023-08-04 19:44 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Greg Kroah-Hartman, Jiri Slaby, Dhruva Gole, Ilpo Järvinen,
	John Ogness, Johan Hovold, Sebastian Andrzej Siewior,
	Vignesh Raghavendra, linux-kernel, linux-serial

On Fri, Aug 04, 2023 at 04:15:51PM +0300, Tony Lindgren wrote:
> Unloading a hardware specific 8250 driver can produce error "Unable to
> handle kernel paging request at virtual address" about ten seconds after
> unloading the driver. This happens on uart_hangup() calling
> uart_change_pm().
> 
> Turns out commit 04e82793f068 ("serial: 8250: Reinit port->pm on port
> specific driver unbind") was only a partial fix. If the hardware specific
> driver has initialized port->pm function, we need to clear port->pm too.
> Just reinitializing port->ops does not do this. Otherwise serial8250_pm()
> will call port->pm() instead of serial8250_do_pm().

Oh, good catch!
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] serial: 8250: Fix oops for port->pm on uart_change_pm()
  2023-08-04 13:15 [PATCH] serial: 8250: Fix oops for port->pm on uart_change_pm() Tony Lindgren
  2023-08-04 19:44 ` Andy Shevchenko
@ 2023-08-05  5:04 ` Dhruva Gole
  1 sibling, 0 replies; 3+ messages in thread
From: Dhruva Gole @ 2023-08-05  5:04 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Greg Kroah-Hartman, Jiri Slaby, Andy Shevchenko,
	Ilpo Järvinen, John Ogness, Johan Hovold,
	Sebastian Andrzej Siewior, Vignesh Raghavendra, linux-kernel,
	linux-serial

On Aug 04, 2023 at 16:15:51 +0300, Tony Lindgren wrote:
> Unloading a hardware specific 8250 driver can produce error "Unable to
> handle kernel paging request at virtual address" about ten seconds after
> unloading the driver. This happens on uart_hangup() calling
> uart_change_pm().
> 
> Turns out commit 04e82793f068 ("serial: 8250: Reinit port->pm on port
> specific driver unbind") was only a partial fix. If the hardware specific
> driver has initialized port->pm function, we need to clear port->pm too.
> Just reinitializing port->ops does not do this. Otherwise serial8250_pm()
> will call port->pm() instead of serial8250_do_pm().

Thanks for catching and fixing this!

> 
> Fixes: 04e82793f068 ("serial: 8250: Reinit port->pm on port specific driver unbind")
> Signed-off-by: Tony Lindgren <tony@atomide.com>
> ---
>  drivers/tty/serial/8250/8250_port.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
> --- a/drivers/tty/serial/8250/8250_port.c
> +++ b/drivers/tty/serial/8250/8250_port.c
> @@ -3278,6 +3278,7 @@ void serial8250_init_port(struct uart_8250_port *up)
>  
>  	spin_lock_init(&port->lock);
>  	port->ctrl_id = 0;
> +	port->pm = NULL;

Reviewed-by: Dhruva Gole <d-gole@ti.com>

>  	port->ops = &serial8250_pops;
>  	port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_8250_CONSOLE);
>  
> -- 
> 2.41.0

-- 
Best regards,
Dhruva Gole <d-gole@ti.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-08-05  5:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-04 13:15 [PATCH] serial: 8250: Fix oops for port->pm on uart_change_pm() Tony Lindgren
2023-08-04 19:44 ` Andy Shevchenko
2023-08-05  5:04 ` Dhruva Gole

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®