diff mbox series

[2/3] serial: uart_poll_init() should power on the UART

Message ID 20230307073155.2.I106c39498d8094c6f5e7ada42c7db17aa5c64e48@changeid
State Superseded
Headers show
Series [1/3] tty: serial: qcom-geni-serial: Fix kdb/kgdb after port shutdown (again) | expand

Commit Message

Doug Anderson March 7, 2023, 3:32 p.m. UTC
On Qualcomm devices which use the "geni" serial driver, kdb/kgdb won't
be very happy if you use it but the resources of the port haven't been
powered on. Today kdb/kgdb rely on someone else powering the port
on. This could be the normal kernel console or an agetty running.
Let's fix this to explicitly power things on when setting up a polling
driver.

Signed-off-by: Douglas Anderson <dianders@chromium.org>
---

 drivers/tty/serial/serial_core.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Doug Anderson March 13, 2023, 8:53 p.m. UTC | #1
Hi,

On Tue, Mar 7, 2023 at 7:32 AM Douglas Anderson <dianders@chromium.org> wrote:
>
> On Qualcomm devices which use the "geni" serial driver, kdb/kgdb won't
> be very happy if you use it but the resources of the port haven't been
> powered on. Today kdb/kgdb rely on someone else powering the port
> on. This could be the normal kernel console or an agetty running.
> Let's fix this to explicitly power things on when setting up a polling
> driver.
>
> Signed-off-by: Douglas Anderson <dianders@chromium.org>
> ---
>
>  drivers/tty/serial/serial_core.c | 6 ++++++
>  1 file changed, 6 insertions(+)

Just in case it's not obvious, even though we ended up going with
Johan's series [1] instead of patch #1 of my series, patch #2 and #3
of my series are still relevant. I can repost the series without patch
#1 if it's helpful.

[1] https://lore.kernel.org/r/20230307164405.14218-1-johan+linaro@kernel.org

-Doug
Greg KH March 16, 2023, 11:59 a.m. UTC | #2
On Mon, Mar 13, 2023 at 01:53:02PM -0700, Doug Anderson wrote:
> Hi,
> 
> On Tue, Mar 7, 2023 at 7:32 AM Douglas Anderson <dianders@chromium.org> wrote:
> >
> > On Qualcomm devices which use the "geni" serial driver, kdb/kgdb won't
> > be very happy if you use it but the resources of the port haven't been
> > powered on. Today kdb/kgdb rely on someone else powering the port
> > on. This could be the normal kernel console or an agetty running.
> > Let's fix this to explicitly power things on when setting up a polling
> > driver.
> >
> > Signed-off-by: Douglas Anderson <dianders@chromium.org>
> > ---
> >
> >  drivers/tty/serial/serial_core.c | 6 ++++++
> >  1 file changed, 6 insertions(+)
> 
> Just in case it's not obvious, even though we ended up going with
> Johan's series [1] instead of patch #1 of my series, patch #2 and #3
> of my series are still relevant. I can repost the series without patch
> #1 if it's helpful.
> 
> [1] https://lore.kernel.org/r/20230307164405.14218-1-johan+linaro@kernel.org

Ye,s it's not obvious at all.  Please resubmit.

thanks,

greg k-h
diff mbox series

Patch

diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index 2bd32c8ece39..b14b5ed6fff4 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -2593,6 +2593,7 @@  static int uart_poll_init(struct tty_driver *driver, int line, char *options)
 {
 	struct uart_driver *drv = driver->driver_state;
 	struct uart_state *state = drv->state + line;
+	enum uart_pm_state pm_state;
 	struct tty_port *tport;
 	struct uart_port *port;
 	int baud = 9600;
@@ -2610,6 +2611,9 @@  static int uart_poll_init(struct tty_driver *driver, int line, char *options)
 		goto out;
 	}
 
+	pm_state = state->pm_state;
+	uart_change_pm(state, UART_PM_STATE_ON);
+
 	if (port->ops->poll_init) {
 		/*
 		 * We don't set initialized as we only initialized the hw,
@@ -2626,6 +2630,8 @@  static int uart_poll_init(struct tty_driver *driver, int line, char *options)
 		console_list_unlock();
 	}
 out:
+	if (ret)
+		uart_change_pm(state, pm_state);
 	mutex_unlock(&tport->mutex);
 	return ret;
 }