linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chunyan Zhang <zhang.lyra@gmail.com>
To: wenhua lin <wenhua.lin1994@gmail.com>
Cc: Wenhua Lin <Wenhua.Lin@unisoc.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	 Jiri Slaby <jirislaby@kernel.org>,
	Orson Zhai <orsonzhai@gmail.com>,
	 Baolin Wang <baolin.wang@linux.alibaba.com>,
	Cixi Geng <cixi.geng@linux.dev>,
	 linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org,
	 Xiongpeng Wu <xiongpeng.wu@unisoc.com>,
	Zhaochen Su <Zhaochen.Su@unisoc.com>,
	 Zhirong Qiu <Zhirong.Qiu@unisoc.com>
Subject: Re: [PATCH] serial: sprd: Return -EPROBE_DEFER when uart clock is not ready
Date: Fri, 24 Oct 2025 09:42:20 +0800	[thread overview]
Message-ID: <CAAfSe-sTUC=mW-iO+NK+mq2i8GEv1RaNPvCGgQwb23dOFBigXQ@mail.gmail.com> (raw)
In-Reply-To: <CAB9BWhdKd93kJxPJv10X5uZ00O8d5NugoehX3_QtjmXQOMhDig@mail.gmail.com>

Hi Wenhua,

On Thu, 23 Oct 2025 at 10:10, wenhua lin <wenhua.lin1994@gmail.com> wrote:
>
> On Wed, Oct 22, 2025 at 2:55 PM Chunyan Zhang <zhang.lyra@gmail.com> wrote:
> >
> > On Wed, 22 Oct 2025 at 11:09, Wenhua Lin <Wenhua.Lin@unisoc.com> wrote:
> > >
> > > In sprd_clk_init(), when devm_clk_get() returns -EPROBE_DEFER
> > > for either uart or source clock, we should propagate the
> > > error instead of just warning and continuing with NULL clocks.
> > >
> > > Currently the driver only emits a warning when clock acquisition
> > > fails and proceeds with NULL clock pointers. This can lead to
> > > issues later when the clocks are actually needed. More importantly,
> > > when the clock provider is not ready yet and returns -EPROBE_DEFER,
> > > we should return this error to allow deferred probing.
> > >
> > > This change adds explicit checks for -EPROBE_DEFER after both:
> > > 1. devm_clk_get(uport->dev, uart)
> > > 2. devm_clk_get(uport->dev, source)
> > >
> > > When -EPROBE_DEFER is encountered, the function now returns
> > > -EPROBE_DEFER to let the driver framework retry probing
> > > later when the clock dependencies are resolved.
> > >
> > > Signed-off-by: Wenhua Lin <Wenhua.Lin@unisoc.com>
> > > ---
> > >  drivers/tty/serial/sprd_serial.c | 6 ++++++
> > >  1 file changed, 6 insertions(+)
> > >
> > > diff --git a/drivers/tty/serial/sprd_serial.c b/drivers/tty/serial/sprd_serial.c
> > > index 8c9366321f8e..092755f35683 100644
> > > --- a/drivers/tty/serial/sprd_serial.c
> > > +++ b/drivers/tty/serial/sprd_serial.c
> > > @@ -1133,6 +1133,9 @@ static int sprd_clk_init(struct uart_port *uport)
> > >
> > >         clk_uart = devm_clk_get(uport->dev, "uart");
> > >         if (IS_ERR(clk_uart)) {
> > > +               if (PTR_ERR(clk_uart) == -EPROBE_DEFER)
> > > +                       return -EPROBE_DEFER;
> > > +
> >
> > You are making this clock mandatory, sprd_serial driver could work as
> > serial ports for logs output without this "uart" clock.
>
> Hi chunyan:
>    Thank you very much for your review.
>    This clock is actually mandatory now,some SPRD project use default 26M clock,
>    some new SPRD project use default 24M clock.  If driver can't parse

Oh I see, then you can set a different default clock according to the
compatible string, that's saying make SPRD_DEFAULT_SOURCE_CLK to be an
element of "of_device_id.data".

Thanks,
Chunyan

> this clock correctly,
>    driver will configure wrong baudrate and make the log garbled.
>
> Thanks
>
> >
> > >                 dev_warn(uport->dev, "uart%d can't get uart clock\n",
> > >                          uport->line);
> > >                 clk_uart = NULL;
> > > @@ -1140,6 +1143,9 @@ static int sprd_clk_init(struct uart_port *uport)
> > >
> > >         clk_parent = devm_clk_get(uport->dev, "source");
> > >         if (IS_ERR(clk_parent)) {
> > > +               if (PTR_ERR(clk_parent) == -EPROBE_DEFER)
> > > +                       return -EPROBE_DEFER;
> > > +
> > >                 dev_warn(uport->dev, "uart%d can't get source clock\n",
> > >                          uport->line);
> > >                 clk_parent = NULL;
> > > --
> > > 2.34.1
> > >

  reply	other threads:[~2025-10-24  1:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-22  3:08 [PATCH] serial: sprd: Return -EPROBE_DEFER when uart clock is not ready Wenhua Lin
2025-10-22  6:55 ` Chunyan Zhang
2025-10-23  2:10   ` wenhua lin
2025-10-24  1:42     ` Chunyan Zhang [this message]
2025-11-10  3:05       ` wenhua lin

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='CAAfSe-sTUC=mW-iO+NK+mq2i8GEv1RaNPvCGgQwb23dOFBigXQ@mail.gmail.com' \
    --to=zhang.lyra@gmail.com \
    --cc=Wenhua.Lin@unisoc.com \
    --cc=Zhaochen.Su@unisoc.com \
    --cc=Zhirong.Qiu@unisoc.com \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=cixi.geng@linux.dev \
    --cc=gregkh@linuxfoundation.org \
    --cc=jirislaby@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=orsonzhai@gmail.com \
    --cc=wenhua.lin1994@gmail.com \
    --cc=xiongpeng.wu@unisoc.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).