serial: sh-sci: Respect deferred probe when getting IRQ
PATCH v2 1/1 serial: sh-sci: Respect deferred probe when getting IRQ
With platform_get_irq() and its optional variant it's possible to get a deferred probe error code. Since the commit ed7027fdf4ec ("driver core:
platform: Make platform_get_irq_optional() optional") the error code can be distinguished from no IRQ case. With this, rewrite IRQ resource handling in sh-sci driver to follow above and allow to respect deferred probe.
---
v2: fixed a typo: i -> 0
drivers/tty/serial/sh-sci.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-)
drivers/tty/serial/sh-sci.c +8 -10
@@ -2899,13 +2899,6 @@ static int sci_init_single(struct platform_device *dev, port->mapbase = res->start; sci_port->reg_size =resource_size (res); -for (i =0 ; i <ARRAY_SIZE (sci_port->irqs); ++i) { -if (i) - sci_port->irqs[i] =platform_get_irq_optional (dev, i); -else - sci_port->irqs[i] =platform_get_irq (dev, i); - } -/* The SCI generates several interrupts. They can be muxed together or * connected to different interrupt lines. In the muxed case only one * interrupt resource is specified as there is only one interrupt ID.
@@ -2913,12 +2906,17 @@ static int sci_init_single(struct platform_device *dev,* from the SCI, however those signals might have their own individual * interrupt ID numbers, or muxed together with another interrupt. */ + sci_port->irqs[0 ] =platform_get_irq (dev,0 );if (sci_port->irqs[0 ] <0 ) -return -ENXIO ; +return sci_port->irqs[0 ]; -if (sci_port->irqs[1 ] <0 ) -for (i =1 ; i <ARRAY_SIZE (sci_port->irqs); i++) +for (i =1 ; i <ARRAY_SIZE (sci_port->irqs); ++i) { + sci_port->irqs[i] =platform_get_irq_optional (dev, i); +if (sci_port->irqs[i] <0 ) +return sci_port->irqs[i]; +if (sci_port->irqs[i] ==0 ) sci_port->irqs[i] = sci_port->irqs[0 ]; + } sci_port->params =sci_probe_regmap (p);if (unlikely (sci_port->params ==NULL ))
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerQuoted 8 lines · Andy Shevchenko
With
platform_get_irq()and its optional variant it's possible to get a deferred probe error code. Since the commited7027fdf4ec("driver core:
platform: Makeplatform_get_irq_optional()optional") the error code can be distinguished from no IRQ case. With this, rewrite IRQ resource handling in sh-sci driver to follow above and allow to respect deferred probe.Fixes ed7027fdf4ec ("driver core: platform: Make platform_get_irq_optional() optional")
I've already reverted this commit, sorry. Please feel free to resend this as a patch series.
thanks,
greg k-h
Quoted 8 lines · Greg Kroah-Hartman
Quoted 7 lines · Andy Shevchenko
With
platform_get_irq()and its optional variant it's possible to get a deferred probe error code. Since the commited7027fdf4ec("driver core:
platform: Makeplatform_get_irq_optional()optional") the error code can be distinguished from no IRQ case. With this, rewrite IRQ resource handling in sh-sci driver to follow above and allow to respect deferred probe.
Quoted 4 lines
Quoted 1 line
Fixes ed7027fdf4ec ("driver core: platform: Make platform_get_irq_optional() optional")I've already reverted this commit, sorry. Please feel free to resend this as a patch series.
Thanks!
I think I will not hurry in this cycle. Perhaps I have to check plenty of places if they could have the same issue before resending. Sorry for the troubles.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 10 lines · Andy Shevchenko
With
platform_get_irq()and its optional variant it's possible to get a deferred probe error code. Since the commited7027fdf4ec("driver core:
platform: Makeplatform_get_irq_optional()optional") the error code can be distinguished from no IRQ case. With this, rewrite IRQ resource handling in sh-sci driver to follow above and allow to respect deferred probe.Fixes ed7027fdf4ec ("driver core: platform: Make platform_get_irq_optional() optional")Reported-by Guenter Roeck <[email protected]>Signed-off-by Andy Shevchenko <[email protected]>
This patch alone causes a hard hang early during boot. It works if applied together with ed7027fdf4ec. Ultimately that means that ed7027fdf4ec introduces a functional change, and will need to be applied very carefully. A cursory glance through callers of platform_get_irq_optional() shows that many do not handle this correctly: various drivers handle a return value of 0 as valid interrupt, and others treat errors other than -ENXIO as fatal.
Also, each patch on its own causes failures on sh, which is problematic when applying them even as series. See below for an idea how to address that.
Quoted 30 lines
---
v2: fixed a typo: i -> 0drivers/tty/serial/sh-sci.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-)drivers/tty/serial/sh-sci.c +1
-8@@ -2899,13 +2899,6 @@ static int sci_init_single(struct platform_device *dev, port->mapbase = res->start; sci_port->reg_size =resource_size (res); -for (i =0 ; i <ARRAY_SIZE (sci_port->irqs); ++i) { -if (i) - sci_port->irqs[i] =platform_get_irq_optional (dev, i); -else - sci_port->irqs[i] =platform_get_irq (dev, i); - } -/* The SCI generates several interrupts. They can be muxed together or * connected to different interrupt lines. In the muxed case only one * interrupt resource is specified as there is only one interrupt ID. @@ -2913,12 +2906,17 @@ static int sci_init_single(struct platform_device *dev,* from the SCI, however those signals might have their own individual * interrupt ID numbers, or muxed together with another interrupt. */ + sci_port->irqs[0 ] =platform_get_irq (dev,0 );if (sci_port->irqs[0 ] <0 ) -return -ENXIO ;
drivers/tty/serial/sh-sci.c static int sci_init_single(struct platform_device *dev, · line 2918
Quoted 10 lines
drivers/tty/serial/sh-sci.c +6
-2+return sci_port->irqs[0 ]; -if (sci_port->irqs[1 ] <0 ) -for (i =1 ; i <ARRAY_SIZE (sci_port->irqs); i++) +for (i =1 ; i <ARRAY_SIZE (sci_port->irqs); ++i) { + sci_port->irqs[i] =platform_get_irq_optional (dev, i); +if (sci_port->irqs[i] <0 ) +return sci_port->irqs[i]; +if (sci_port->irqs[i] ==0 ) sci_port->irqs[i] = sci_port->irqs[0 ];
Since sh never gets -EPROBE_DEFER, the following code can be applied on its own and does not depend on ed7027fdf4ec.
sci_port->irqs[i] = platform_get_irq_optional(dev, i); if (sci_port->irqs[i] <= 0) sci_port->irqs[i] = sci_port->irqs[0];
With this change, sh images boot in qemu both with and without ed7027fdf4ec.
Thanks,
Guenter
Quoted 5 lines
drivers/tty/serial/sh-sci.c +1
-0+ } sci_port->params =sci_probe_regmap (p);if (unlikely (sci_port->params ==NULL ))
Quoted 19 lines · Guenter Roeck
Quoted 10 lines · Andy Shevchenko
With
platform_get_irq()and its optional variant it's possible to get a deferred probe error code. Since the commited7027fdf4ec("driver core:
platform: Makeplatform_get_irq_optional()optional") the error code can be distinguished from no IRQ case. With this, rewrite IRQ resource handling in sh-sci driver to follow above and allow to respect deferred probe.Fixes ed7027fdf4ec ("driver core: platform: Make platform_get_irq_optional() optional")Reported-by Guenter Roeck <[email protected]>Signed-off-by Andy Shevchenko <[email protected]>This patch alone causes a hard hang early during boot. It works if applied together with
ed7027fdf4ec. Ultimately that means thated7027fdf4ecintroduces a functional change, and will need to be applied very carefully. A cursory glance through callers ofplatform_get_irq_optional()shows that many do not handle this correctly: various drivers handle a return value of 0 as valid interrupt, and others treat errors other than-ENXIOas fatal.
Quoted 3 lines
Also, each patch on its own causes failures on sh, which is problematic when applying them even as series. See below for an idea how to address that.
Right, that's why I think I have to slow down with it (as I answered to Greg).
Quoted 8 lines
Since sh never gets -EPROBE_DEFER, the following code can be applied on its own and does not depend on
ed7027fdf4ec.sci_port->irqs[i] = platform_get_irq_optional(dev, i); if (sci_port->irqs[i] <= 0) sci_port->irqs[i] = sci_port->irqs[0];With this change, sh images boot in qemu both with and without
ed7027fdf4ec.
Yeah, thanks! But I think we still can avoid double loops there.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Hi Günter,
Quoted 55 lines · Guenter Roeck
Quoted 10 lines · Andy Shevchenko
With
platform_get_irq()and its optional variant it's possible to get a deferred probe error code. Since the commited7027fdf4ec("driver core:
platform: Makeplatform_get_irq_optional()optional") the error code can be distinguished from no IRQ case. With this, rewrite IRQ resource handling in sh-sci driver to follow above and allow to respect deferred probe.Fixes ed7027fdf4ec ("driver core: platform: Make platform_get_irq_optional() optional")Reported-by Guenter Roeck <[email protected]>Signed-off-by Andy Shevchenko <[email protected]>This patch alone causes a hard hang early during boot. It works if applied together with
ed7027fdf4ec. Ultimately that means thated7027fdf4ecintroduces a functional change, and will need to be applied very carefully. A cursory glance through callers ofplatform_get_irq_optional()shows that many do not handle this correctly: various drivers handle a return value of 0 as valid interrupt, and others treat errors other than-ENXIOas fatal.Also, each patch on its own causes failures on sh, which is problematic when applying them even as series. See below for an idea how to address that.
Quoted 32 lines
---
v2: fixed a typo: i -> 0drivers/tty/serial/sh-sci.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-)drivers/tty/serial/sh-sci.c +2
-8@@ -2899,13 +2899,6 @@ static int sci_init_single(struct platform_device *dev, port->mapbase = res->start; sci_port->reg_size =resource_size (res); -for (i =0 ; i <ARRAY_SIZE (sci_port->irqs); ++i) { -if (i) - sci_port->irqs[i] =platform_get_irq_optional (dev, i); -else - sci_port->irqs[i] =platform_get_irq (dev, i); - } -/* The SCI generates several interrupts. They can be muxed together or * connected to different interrupt lines. In the muxed case only one * interrupt resource is specified as there is only one interrupt ID. @@ -2913,12 +2906,17 @@ static int sci_init_single(struct platform_device *dev,* from the SCI, however those signals might have their own individual * interrupt ID numbers, or muxed together with another interrupt. */ + sci_port->irqs[0 ] =platform_get_irq (dev,0 );if (sci_port->irqs[0 ] <0 ) -return -ENXIO ; +return sci_port->irqs[0 ];
Quoted 11 lines
drivers/tty/serial/sh-sci.c static int sci_init_single(struct platform_device *dev, · line 2918
Quoted 8 lines
drivers/tty/serial/sh-sci.c +5
-2-if (sci_port->irqs[1 ] <0 ) -for (i =1 ; i <ARRAY_SIZE (sci_port->irqs); i++) +for (i =1 ; i <ARRAY_SIZE (sci_port->irqs); ++i) { + sci_port->irqs[i] =platform_get_irq_optional (dev, i); +if (sci_port->irqs[i] <0 ) +return sci_port->irqs[i]; +if (sci_port->irqs[i] ==0 ) sci_port->irqs[i] = sci_port->irqs[0 ];Since sh never gets -EPROBE_DEFER, the following code can be applied on its own and does not depend on
ed7027fdf4ec.
Note that the sh-sci driver is also used on ARM32/64 and H8/300. On ARM, I don't expect GIC interrupts causing -EPROBE_DEFER, though.
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds