lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAB9BWhdHkkm6YYhdZJ2NdaJ6GebZyRi3SN9GLstQv1R7HLe4mQ@mail.gmail.com>
Date: Mon, 10 Nov 2025 11:05:13 +0800
From: wenhua lin <wenhua.lin1994@...il.com>
To: Chunyan Zhang <zhang.lyra@...il.com>
Cc: Wenhua Lin <Wenhua.Lin@...soc.com>, Greg Kroah-Hartman <gregkh@...uxfoundation.org>, 
	Jiri Slaby <jirislaby@...nel.org>, Orson Zhai <orsonzhai@...il.com>, 
	Baolin Wang <baolin.wang@...ux.alibaba.com>, Cixi Geng <cixi.geng@...ux.dev>, 
	linux-kernel@...r.kernel.org, linux-serial@...r.kernel.org, 
	Xiongpeng Wu <xiongpeng.wu@...soc.com>, Zhaochen Su <Zhaochen.Su@...soc.com>, 
	Zhirong Qiu <Zhirong.Qiu@...soc.com>
Subject: Re: [PATCH] serial: sprd: Return -EPROBE_DEFER when uart clock is not ready

On Fri, Oct 24, 2025 at 9:42 AM Chunyan Zhang <zhang.lyra@...il.com> wrote:
>
> Hi Wenhua,
>
> On Thu, 23 Oct 2025 at 10:10, wenhua lin <wenhua.lin1994@...il.com> wrote:
> >
> > On Wed, Oct 22, 2025 at 2:55 PM Chunyan Zhang <zhang.lyra@...il.com> wrote:
> > >
> > > On Wed, 22 Oct 2025 at 11:09, Wenhua Lin <Wenhua.Lin@...soc.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@...soc.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

Hi chunyan:
   This is not the current issue; it will be considered in future modifications.
   The main reason for this change is that the UART driver is
built-in, while the CLK driver is loaded as a module (ko).
   There may be a situation where the UART driver is loaded first.
   If an EPROBE_DEFER error occurs, the driver will return directly
and continue waiting for the CLK driver to complete loading.

Thanks
>
> > 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
> > > >

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ