All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chen-Yu Tsai <wenst@chromium.org>
To: Tony Lindgren <tony@atomide.com>
Cc: "John Ogness" <john.ogness@linutronix.de>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Jiri Slaby" <jirislaby@kernel.org>,
	"Andy Shevchenko" <andriy.shevchenko@intel.com>,
	"Dhruva Gole" <d-gole@ti.com>,
	"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
	"Johan Hovold" <johan@kernel.org>,
	"Sebastian Andrzej Siewior" <bigeasy@linutronix.de>,
	"Vignesh Raghavendra" <vigneshr@ti.com>,
	linux-omap@vger.kernel.org,
	"Andy Shevchenko" <andriy.shevchenko@linux.intel.com>,
	linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org,
	"Nícolas F. R. A. Prado" <nfraprado@collabora.com>,
	"AngeloGioacchino Del Regno"
	<angelogioacchino.delregno@collabora.com>,
	linux-mediatek@lists.infradead.org
Subject: Re: [PATCH v12 1/1] serial: core: Start managing serial controllers to enable runtime PM
Date: Mon, 5 Jun 2023 21:01:29 +0800	[thread overview]
Message-ID: <CAGXv+5HwL+R5QpO3pHGQd9qAxu2pCMDjYvdni1HjiC8eEE38mg@mail.gmail.com> (raw)
In-Reply-To: <20230605122447.GY14287@atomide.com>

On Mon, Jun 5, 2023 at 8:24 PM Tony Lindgren <tony@atomide.com> wrote:
>
> * Chen-Yu Tsai <wenst@chromium.org> [230605 11:34]:
> > On Mon, Jun 5, 2023 at 2:15 PM Tony Lindgren <tony@atomide.com> wrote:
> > > diff --git a/drivers/tty/serial/8250/8250_mtk.c b/drivers/tty/serial/8250/8250_mtk.c
> > > --- a/drivers/tty/serial/8250/8250_mtk.c
> > > +++ b/drivers/tty/serial/8250/8250_mtk.c
> > > @@ -425,11 +439,10 @@ mtk8250_set_termios(struct uart_port *port, struct ktermios *termios,
> > >  static int __maybe_unused mtk8250_runtime_suspend(struct device *dev)
> > >  {
> > >         struct mtk8250_data *data = dev_get_drvdata(dev);
> > > -       struct uart_8250_port *up = serial8250_get_port(data->line);
> > >
> > >         /* wait until UART in idle status */
> > >         while
> > > -               (serial_in(up, MTK_UART_DEBUG0));
> > > +               (mtk8250_read(data, MTK_UART_DEBUG0));
> >
> > I believe it still gets stuck here sometimes.
>
> Hmm so maybe you need to mtk8250_write(data, 0, MTK_UART_RATE_FIX) in
> probe before pm_runtime_resume_and_get() that enables the baud clock?
> That's something I changed, so maybe it messes up things.

I think it has something to do with the do_pm() function calling
the callbacks directly, then also calling runtime PM.

> Looking at the 8250_mtk git log, it's runtime PM functions seem to only
> currently manage the baud clock so register access should be doable
> without runtime PM resume?

Actually it only manages the bus clock. The baud clock is simply the system
XTAL which is not gateble.

> > With your earlier patch, it could get through registering the port, and
> > the console would show
> >
> >     11002000.serial: ttyS0 at MMIO 0x11002000 (irq = 240, base_baud =
> > 1625000) is a ST16650V2
> >
> > for the console UART.
>
> OK
>
> > Angelo mentioned that we should be using SLEEP_REQ/SLEEP_ACK registers
> > in the MTK UART hardware.
> >
> > I tried reworking it into your patch here, but it causes issues with the
> > UART-based Bluetooth on one of my devices. After the UART runtime suspends
> > and resumes, something is off and causes the transfers during Bluetooth
> > init to become corrupt.
> >
> > I'll try some more stuff, but the existing code seems timing dependent.
> > If I add too many printk statements to the runtime suspend/resume
> > callbacks, things seem to work. One time I even ended up with broken
> > UARTs but otherwise booted up the system.
>
> Well another thing that now changes is that we now runtime suspend the
> port at the end of the probe. What the 8250_mtk probe was doing earlier
> it was leaving the port baud clock enabled, but runtime PM disabled
> until mtk8250_do_pm() I guess.

I guess that's the biggest difference? Since the *bus* clock gets disabled,
any access will hang. Is it enough to just support runtime PM? Or do I have
to also have UART_CAP_RPM?

ChenYu

  reply	other threads:[~2023-06-05 13:02 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-25 11:30 [PATCH v12 1/1] serial: core: Start managing serial controllers to enable runtime PM Tony Lindgren
2023-05-27  8:25 ` Andy Shevchenko
2023-05-30 14:43 ` Greg Kroah-Hartman
2023-06-01 10:04 ` Steven Price
2023-06-01 10:44   ` Tony Lindgren
2023-06-01 10:53     ` Steven Price
2023-06-01 10:57       ` Tony Lindgren
     [not found] ` <CGME20230601110030eucas1p2eed547c326a51a6110100fb50799d136@eucas1p2.samsung.com>
2023-06-01 11:00   ` Marek Szyprowski
2023-06-01 11:11     ` Tony Lindgren
2023-06-01 13:20       ` Tony Lindgren
2023-06-01 14:16         ` Marek Szyprowski
2023-06-01 14:20           ` Tony Lindgren
2023-06-02  8:33 ` Chen-Yu Tsai
2023-06-02  9:27   ` Tony Lindgren
2023-06-02 10:13   ` John Ogness
2023-06-03  5:41     ` Tony Lindgren
2023-06-03  6:35       ` Tony Lindgren
2023-06-05  6:15         ` Tony Lindgren
2023-06-05 11:28           ` Andy Shevchenko
2023-06-05 12:25             ` Tony Lindgren
2023-06-05 11:34           ` Chen-Yu Tsai
2023-06-05 12:24             ` Tony Lindgren
2023-06-05 13:01               ` Chen-Yu Tsai [this message]
2023-06-05 13:18                 ` Tony Lindgren
2023-06-06  9:16                   ` Chen-Yu Tsai
2023-06-06 12:20                     ` Tony Lindgren
2023-06-07  4:46                       ` Chen-Yu Tsai
2023-06-07  7:17                         ` AngeloGioacchino Del Regno
2023-06-07 20:20                         ` Andy Shevchenko
2023-06-03 21:57       ` Sebastian Reichel
2023-06-04  6:04         ` Tony Lindgren
2023-06-05  3:04     ` Chen-Yu Tsai
2023-10-03 11:57 ` Maximilian Luz
2023-10-03 12:14   ` Tony Lindgren
2023-10-03 12:21     ` Tony Lindgren
2023-10-03 22:09       ` Maximilian Luz
2023-10-04  6:17         ` Tony Lindgren
2023-10-04  7:14           ` Johan Hovold
2023-10-04  9:03             ` Tony Lindgren
2023-10-04  9:14               ` Johan Hovold
2023-10-04 10:01                 ` Tony Lindgren
2023-10-04 18:44                   ` Maximilian Luz
2023-10-04  7:39           ` Maximilian Luz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAGXv+5HwL+R5QpO3pHGQd9qAxu2pCMDjYvdni1HjiC8eEE38mg@mail.gmail.com \
    --to=wenst@chromium.org \
    --cc=andriy.shevchenko@intel.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=bigeasy@linutronix.de \
    --cc=d-gole@ti.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=jirislaby@kernel.org \
    --cc=johan@kernel.org \
    --cc=john.ogness@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=nfraprado@collabora.com \
    --cc=tony@atomide.com \
    --cc=vigneshr@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.