* [PATCH 1/1] serial: ns16550: move iomem/ioport init after clock init
@ 2023-02-17 7:31 Maxim Kochetkov
2023-02-17 9:02 ` Ahmad Fatoum
0 siblings, 1 reply; 4+ messages in thread
From: Maxim Kochetkov @ 2023-02-17 7:31 UTC (permalink / raw)
To: barebox; +Cc: pmamonov, a.kuyan, p.mamonov, Maxim Kochetkov, Maxim Kochetkov
While probing ns16550 clock provider may be unavailable and
clk_get() returns -EPROBE_DEFER. Next ns16550_probe() attempts
will be failed too because of dev_request_mem_resource() has already
acquired this resource for the device and returns -EBUSY.
So move resource allocation just after clock init. It will let proper
probe for defered clocks.
Signed-off-by: Maxim Kochetkov <fido_max@inbox.ru>
Signed-off-by: Maxim Kochetkov <m.kochetkov@yadro.com>
---
drivers/serial/serial_ns16550.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/serial/serial_ns16550.c b/drivers/serial/serial_ns16550.c
index 16f3576645..6eeb67ca81 100644
--- a/drivers/serial/serial_ns16550.c
+++ b/drivers/serial/serial_ns16550.c
@@ -479,10 +479,6 @@ static int ns16550_probe(struct device *dev)
priv = xzalloc(sizeof(*priv));
- ret = ns16550_init_iomem(dev, priv);
- if (ret)
- ret = ns16550_init_ioport(dev, priv);
-
if (ret)
return ret;
@@ -511,6 +507,10 @@ static int ns16550_probe(struct device *dev)
goto err;
}
+ ret = ns16550_init_iomem(dev, priv);
+ if (ret)
+ ret = ns16550_init_ioport(dev, priv);
+
cdev = &priv->cdev;
cdev->dev = dev;
cdev->tstc = ns16550_tstc;
--
2.38.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] serial: ns16550: move iomem/ioport init after clock init
2023-02-17 7:31 [PATCH 1/1] serial: ns16550: move iomem/ioport init after clock init Maxim Kochetkov
@ 2023-02-17 9:02 ` Ahmad Fatoum
2023-02-17 14:03 ` Maxim Kochetkov
0 siblings, 1 reply; 4+ messages in thread
From: Ahmad Fatoum @ 2023-02-17 9:02 UTC (permalink / raw)
To: Maxim Kochetkov, barebox; +Cc: pmamonov, a.kuyan, p.mamonov, Maxim Kochetkov
Hello Maxim,
On 17.02.23 08:31, Maxim Kochetkov wrote:
> - ret = ns16550_init_iomem(dev, priv);
> - if (ret)
> - ret = ns16550_init_ioport(dev, priv);
> -
> if (ret)
> return ret;
ret is now uninitialized here.
>
> @@ -511,6 +507,10 @@ static int ns16550_probe(struct device *dev)
> goto err;
> }
>
> + ret = ns16550_init_iomem(dev, priv);
> + if (ret)
> + ret = ns16550_init_ioport(dev, priv);
second ret is never checked.
If you move the second if (ret), patch looks ok to me.
jfyi, If you enable deep probe for your board/platform, clk_get()
would automatically probe the clock driver if unavailable, so you
shouldn't ever see -EPROBE_DEFER.
Cheers,
Ahmad
> +
> cdev = &priv->cdev;
> cdev->dev = dev;
> cdev->tstc = ns16550_tstc;
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] serial: ns16550: move iomem/ioport init after clock init
2023-02-17 9:02 ` Ahmad Fatoum
@ 2023-02-17 14:03 ` Maxim Kochetkov
2023-02-17 14:10 ` Ahmad Fatoum
0 siblings, 1 reply; 4+ messages in thread
From: Maxim Kochetkov @ 2023-02-17 14:03 UTC (permalink / raw)
To: Ahmad Fatoum, barebox; +Cc: pmamonov, a.kuyan, p.mamonov, Maxim Kochetkov
On 17.02.2023 12:02, Ahmad Fatoum wrote:
> Hello Maxim,
>
> On 17.02.23 08:31, Maxim Kochetkov wrote:
>> - ret = ns16550_init_iomem(dev, priv);
>> - if (ret)
>> - ret = ns16550_init_ioport(dev, priv);
>> -
>> if (ret)
>> return ret;
>
> ret is now uninitialized here.
>
>>
>> @@ -511,6 +507,10 @@ static int ns16550_probe(struct device *dev)
>> goto err;
>> }
>>
>> + ret = ns16550_init_iomem(dev, priv);
>> + if (ret)
>> + ret = ns16550_init_ioport(dev, priv);
>
> second ret is never checked.
Sorry about that. I will fix it in v2.
>
> If you move the second if (ret), patch looks ok to me.
> jfyi, If you enable deep probe for your board/platform, clk_get()
> would automatically probe the clock driver if unavailable, so you
> shouldn't ever see -EPROBE_DEFER.
I tried deep probe and it works fine without any -EPROBE_DEFER. Thanks a
lot for the tip!
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] serial: ns16550: move iomem/ioport init after clock init
2023-02-17 14:03 ` Maxim Kochetkov
@ 2023-02-17 14:10 ` Ahmad Fatoum
0 siblings, 0 replies; 4+ messages in thread
From: Ahmad Fatoum @ 2023-02-17 14:10 UTC (permalink / raw)
To: Maxim Kochetkov, barebox; +Cc: pmamonov, a.kuyan, p.mamonov, Maxim Kochetkov
Hello Maxim,
On 17.02.23 15:03, Maxim Kochetkov wrote:
>
>
> On 17.02.2023 12:02, Ahmad Fatoum wrote:
>> Hello Maxim,
>>
>> On 17.02.23 08:31, Maxim Kochetkov wrote:
>>> - ret = ns16550_init_iomem(dev, priv);
>>> - if (ret)
>>> - ret = ns16550_init_ioport(dev, priv);
>>> -
>>> if (ret)
>>> return ret;
>>
>> ret is now uninitialized here.
>>
>>> @@ -511,6 +507,10 @@ static int ns16550_probe(struct device *dev)
>>> goto err;
>>> }
>>> + ret = ns16550_init_iomem(dev, priv);
>>> + if (ret)
>>> + ret = ns16550_init_ioport(dev, priv);
>>
>> second ret is never checked.
>
> Sorry about that. I will fix it in v2.
>>
>> If you move the second if (ret), patch looks ok to me.
>> jfyi, If you enable deep probe for your board/platform, clk_get()
>> would automatically probe the clock driver if unavailable, so you
>> shouldn't ever see -EPROBE_DEFER.
>
> I tried deep probe and it works fine without any -EPROBE_DEFER. Thanks a lot for the tip!
Nice! It's not enabled globally as some existing boards may need rework
(e.g. you need to place of_device_ensure_probed into board code), but new
boards should perferably always use it and just save the time needed to do
EPROBE_DEFER altogether.
Cheers,
Ahmad
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-02-17 14:11 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-17 7:31 [PATCH 1/1] serial: ns16550: move iomem/ioport init after clock init Maxim Kochetkov
2023-02-17 9:02 ` Ahmad Fatoum
2023-02-17 14:03 ` Maxim Kochetkov
2023-02-17 14:10 ` Ahmad Fatoum
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox