* [PATCH] gpio: pl061: Warn when IRQ line has not been configured
@ 2020-03-03 9:28 Alexander A Sverdlin
2020-03-04 14:21 ` Bartosz Golaszewski
0 siblings, 1 reply; 7+ messages in thread
From: Alexander A Sverdlin @ 2020-03-03 9:28 UTC (permalink / raw)
To: linux-gpio; +Cc: Alexander Sverdlin, Linus Walleij, Bartosz Golaszewski
From: Alexander Sverdlin <alexander.sverdlin@nokia.com>
Existing (irq < 0) condition is always false because adev->irq has unsigned
type and contains 0 in case of failed irq_of_parse_and_map(). Up to now all
the mapping errors were silently ignored.
Seems that repairing this check would be backwards-incompatible and might
break the probe() for the implementations without IRQ support. Therefore
warn the user instead.
Signed-off-by: Alexander Sverdlin <alexander.sverdlin@nokia.com>
---
drivers/gpio/gpio-pl061.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/gpio/gpio-pl061.c b/drivers/gpio/gpio-pl061.c
index 5df7782..3439120 100644
--- a/drivers/gpio/gpio-pl061.c
+++ b/drivers/gpio/gpio-pl061.c
@@ -326,10 +326,8 @@ static int pl061_probe(struct amba_device *adev, const struct amba_id *id)
writeb(0, pl061->base + GPIOIE); /* disable irqs */
irq = adev->irq[0];
- if (irq < 0) {
- dev_err(&adev->dev, "invalid IRQ\n");
- return -ENODEV;
- }
+ if (!irq)
+ dev_warn(&adev->dev, "IRQ support disabled\n");
pl061->parent_irq = irq;
girq = &pl061->gc.irq;
--
2.4.6
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] gpio: pl061: Warn when IRQ line has not been configured
2020-03-03 9:28 [PATCH] gpio: pl061: Warn when IRQ line has not been configured Alexander A Sverdlin
@ 2020-03-04 14:21 ` Bartosz Golaszewski
2020-03-04 14:58 ` Alexander Sverdlin
0 siblings, 1 reply; 7+ messages in thread
From: Bartosz Golaszewski @ 2020-03-04 14:21 UTC (permalink / raw)
To: Alexander A Sverdlin; +Cc: linux-gpio, Linus Walleij
wt., 3 mar 2020 o 10:29 Alexander A Sverdlin
<alexander.sverdlin@nokia.com> napisał(a):
>
> From: Alexander Sverdlin <alexander.sverdlin@nokia.com>
>
> Existing (irq < 0) condition is always false because adev->irq has unsigned
> type and contains 0 in case of failed irq_of_parse_and_map(). Up to now all
> the mapping errors were silently ignored.
>
> Seems that repairing this check would be backwards-incompatible and might
> break the probe() for the implementations without IRQ support. Therefore
> warn the user instead.
>
> Signed-off-by: Alexander Sverdlin <alexander.sverdlin@nokia.com>
> ---
> drivers/gpio/gpio-pl061.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpio/gpio-pl061.c b/drivers/gpio/gpio-pl061.c
> index 5df7782..3439120 100644
> --- a/drivers/gpio/gpio-pl061.c
> +++ b/drivers/gpio/gpio-pl061.c
> @@ -326,10 +326,8 @@ static int pl061_probe(struct amba_device *adev, const struct amba_id *id)
>
> writeb(0, pl061->base + GPIOIE); /* disable irqs */
> irq = adev->irq[0];
> - if (irq < 0) {
> - dev_err(&adev->dev, "invalid IRQ\n");
> - return -ENODEV;
> - }
> + if (!irq)
> + dev_warn(&adev->dev, "IRQ support disabled\n");
> pl061->parent_irq = irq;
>
> girq = &pl061->gc.irq;
> --
> 2.4.6
>
What happens later on if irq == 0? Does irq_set_irq_wake() fail?
Bart
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] gpio: pl061: Warn when IRQ line has not been configured
2020-03-04 14:21 ` Bartosz Golaszewski
@ 2020-03-04 14:58 ` Alexander Sverdlin
2020-03-04 16:46 ` Bartosz Golaszewski
0 siblings, 1 reply; 7+ messages in thread
From: Alexander Sverdlin @ 2020-03-04 14:58 UTC (permalink / raw)
To: Bartosz Golaszewski; +Cc: linux-gpio, Linus Walleij
Hi!
On 04/03/2020 15:21, Bartosz Golaszewski wrote:
> wt., 3 mar 2020 o 10:29 Alexander A Sverdlin
> <alexander.sverdlin@nokia.com> napisał(a):
>> From: Alexander Sverdlin <alexander.sverdlin@nokia.com>
>>
>> Existing (irq < 0) condition is always false because adev->irq has unsigned
>> type and contains 0 in case of failed irq_of_parse_and_map(). Up to now all
>> the mapping errors were silently ignored.
>>
>> Seems that repairing this check would be backwards-incompatible and might
>> break the probe() for the implementations without IRQ support. Therefore
>> warn the user instead.
>>
>> Signed-off-by: Alexander Sverdlin <alexander.sverdlin@nokia.com>
>> ---
>> drivers/gpio/gpio-pl061.c | 6 ++----
>> 1 file changed, 2 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/gpio/gpio-pl061.c b/drivers/gpio/gpio-pl061.c
>> index 5df7782..3439120 100644
>> --- a/drivers/gpio/gpio-pl061.c
>> +++ b/drivers/gpio/gpio-pl061.c
>> @@ -326,10 +326,8 @@ static int pl061_probe(struct amba_device *adev, const struct amba_id *id)
>>
>> writeb(0, pl061->base + GPIOIE); /* disable irqs */
>> irq = adev->irq[0];
>> - if (irq < 0) {
>> - dev_err(&adev->dev, "invalid IRQ\n");
>> - return -ENODEV;
>> - }
>> + if (!irq)
>> + dev_warn(&adev->dev, "IRQ support disabled\n");
>> pl061->parent_irq = irq;
>>
>> girq = &pl061->gc.irq;
>> --
>> 2.4.6
>>
> What happens later on if irq == 0? Does irq_set_irq_wake() fail?
Yes, would fail if IRQs would be requested from PL061:
int irq_set_irq_wake(unsigned int irq, unsigned int on)
{
unsigned long flags;
struct irq_desc *desc = irq_get_desc_buslock(irq, &flags, IRQ_GET_DESC_CHECK_GLOBAL);
int ret = 0;
if (!desc)
return -EINVAL;
--
Best regards,
Alexander Sverdlin.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] gpio: pl061: Warn when IRQ line has not been configured
2020-03-04 14:58 ` Alexander Sverdlin
@ 2020-03-04 16:46 ` Bartosz Golaszewski
0 siblings, 0 replies; 7+ messages in thread
From: Bartosz Golaszewski @ 2020-03-04 16:46 UTC (permalink / raw)
To: Alexander Sverdlin; +Cc: linux-gpio, Linus Walleij
śr., 4 mar 2020 o 15:58 Alexander Sverdlin
<alexander.sverdlin@nokia.com> napisał(a):
>
> Hi!
>
> On 04/03/2020 15:21, Bartosz Golaszewski wrote:
> > wt., 3 mar 2020 o 10:29 Alexander A Sverdlin
> > <alexander.sverdlin@nokia.com> napisał(a):
> >> From: Alexander Sverdlin <alexander.sverdlin@nokia.com>
> >>
> >> Existing (irq < 0) condition is always false because adev->irq has unsigned
> >> type and contains 0 in case of failed irq_of_parse_and_map(). Up to now all
> >> the mapping errors were silently ignored.
> >>
> >> Seems that repairing this check would be backwards-incompatible and might
> >> break the probe() for the implementations without IRQ support. Therefore
> >> warn the user instead.
> >>
> >> Signed-off-by: Alexander Sverdlin <alexander.sverdlin@nokia.com>
> >> ---
> >> drivers/gpio/gpio-pl061.c | 6 ++----
> >> 1 file changed, 2 insertions(+), 4 deletions(-)
> >>
> >> diff --git a/drivers/gpio/gpio-pl061.c b/drivers/gpio/gpio-pl061.c
> >> index 5df7782..3439120 100644
> >> --- a/drivers/gpio/gpio-pl061.c
> >> +++ b/drivers/gpio/gpio-pl061.c
> >> @@ -326,10 +326,8 @@ static int pl061_probe(struct amba_device *adev, const struct amba_id *id)
> >>
> >> writeb(0, pl061->base + GPIOIE); /* disable irqs */
> >> irq = adev->irq[0];
> >> - if (irq < 0) {
> >> - dev_err(&adev->dev, "invalid IRQ\n");
> >> - return -ENODEV;
> >> - }
> >> + if (!irq)
> >> + dev_warn(&adev->dev, "IRQ support disabled\n");
> >> pl061->parent_irq = irq;
> >>
> >> girq = &pl061->gc.irq;
> >> --
> >> 2.4.6
> >>
> > What happens later on if irq == 0? Does irq_set_irq_wake() fail?
>
> Yes, would fail if IRQs would be requested from PL061:
>
> int irq_set_irq_wake(unsigned int irq, unsigned int on)
> {
> unsigned long flags;
> struct irq_desc *desc = irq_get_desc_buslock(irq, &flags, IRQ_GET_DESC_CHECK_GLOBAL);
> int ret = 0;
>
> if (!desc)
> return -EINVAL;
>
>
> --
> Best regards,
> Alexander Sverdlin.
Ok, I'll go ahead and queue this then.
Thanks!
Bartosz
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] gpio: pl061: Warn when IRQ line has not been configured
[not found] <20210317155919.41450-1-alexander.sverdlin@nokia.com>
@ 2021-03-17 15:59 ` Alexander A Sverdlin
[not found] ` <CAHp75Vd-iUzEyo5X5LtKJ+66512i5-tKC+kkpPYJwG7L2qrvdw@mail.gmail.com>
0 siblings, 1 reply; 7+ messages in thread
From: Alexander A Sverdlin @ 2021-03-17 15:59 UTC (permalink / raw)
To: linux-gpio; +Cc: Alexander Sverdlin, Linus Walleij, Bartosz Golaszewski
From: Alexander Sverdlin <alexander.sverdlin@nokia.com>
Existing (irq < 0) condition is always false because adev->irq has unsigned
type and contains 0 in case of failed irq_of_parse_and_map(). Up to now all
the mapping errors were silently ignored.
Seems that repairing this check would be backwards-incompatible and might
break the probe() for the implementations without IRQ support. Therefore
warn the user instead.
Signed-off-by: Alexander Sverdlin <alexander.sverdlin@nokia.com>
---
drivers/gpio/gpio-pl061.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/gpio/gpio-pl061.c b/drivers/gpio/gpio-pl061.c
index 5df7782..3439120 100644
--- a/drivers/gpio/gpio-pl061.c
+++ b/drivers/gpio/gpio-pl061.c
@@ -326,10 +326,8 @@ static int pl061_probe(struct amba_device *adev, const struct amba_id *id)
writeb(0, pl061->base + GPIOIE); /* disable irqs */
irq = adev->irq[0];
- if (irq < 0) {
- dev_err(&adev->dev, "invalid IRQ\n");
- return -ENODEV;
- }
+ if (!irq)
+ dev_warn(&adev->dev, "IRQ support disabled\n");
pl061->parent_irq = irq;
girq = &pl061->gc.irq;
--
2.4.6
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] gpio: pl061: Warn when IRQ line has not been configured
[not found] ` <CAHp75Vd-iUzEyo5X5LtKJ+66512i5-tKC+kkpPYJwG7L2qrvdw@mail.gmail.com>
@ 2021-03-18 11:11 ` Alexander Sverdlin
2021-03-18 12:19 ` Andy Shevchenko
0 siblings, 1 reply; 7+ messages in thread
From: Alexander Sverdlin @ 2021-03-18 11:11 UTC (permalink / raw)
To: Andy Shevchenko
Cc: linux-gpio@vger.kernel.org, Linus Walleij, Bartosz Golaszewski
Hello Andy,
On 18/03/2021 11:51, Andy Shevchenko wrote:
>
>
> On Wednesday, March 17, 2021, Alexander A Sverdlin <alexander.sverdlin@nokia.com <mailto:alexander.sverdlin@nokia.com>> wrote:
>
> From: Alexander Sverdlin <alexander.sverdlin@nokia.com <mailto:alexander.sverdlin@nokia.com>>
>
> Existing (irq < 0) condition is always false because adev->irq has unsigned
> type and contains 0 in case of failed irq_of_parse_and_map(). Up to now all
> the mapping errors were silently ignored.
>
> Seems that repairing this check would be backwards-incompatible and might
> break the probe() for the implementations without IRQ support. Therefore
> warn the user instead.
>
> Signed-off-by: Alexander Sverdlin <alexander.sverdlin@nokia.com <mailto:alexander.sverdlin@nokia.com>>
> ---
> drivers/gpio/gpio-pl061.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpio/gpio-pl061.c b/drivers/gpio/gpio-pl061.c
> index 5df7782..3439120 100644
> --- a/drivers/gpio/gpio-pl061.c
> +++ b/drivers/gpio/gpio-pl061.c
> @@ -326,10 +326,8 @@ static int pl061_probe(struct amba_device *adev, const struct amba_id *id)
>
> writeb(0, pl061->base + GPIOIE); /* disable irqs */
> irq = adev->irq[0];
> - if (irq < 0) {
> - dev_err(&adev->dev, "invalid IRQ\n");
> - return -ENODEV;
> - }
> + if (!irq)
> + dev_warn(&adev->dev, "IRQ support disabled\n");
>
>
>
> I guess you need to preserve bailing out. Seems nobody hit this error path.
Do you mean preserve "return -ENODEV;"?
This never ever happened, because the "if" is "always false", irqs coming from irq[] cannot be
negative.
And there is another use-case actually: there are legal PL061 configurations without IRQs at all,
which simply work even trying to instantiate irq chip, but as devm_gpiochip_add_data() doesn't
fail with irq==0, this goes completely unnoticed and such a gpio bank works fine.
The proper way would be not even try to instantiate any irq chip in such case.
Let me know if I shall rework the patch this way.
--
Best regards,
Alexander Sverdlin.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] gpio: pl061: Warn when IRQ line has not been configured
2021-03-18 11:11 ` Alexander Sverdlin
@ 2021-03-18 12:19 ` Andy Shevchenko
0 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2021-03-18 12:19 UTC (permalink / raw)
To: Alexander Sverdlin
Cc: linux-gpio@vger.kernel.org, Linus Walleij, Bartosz Golaszewski
On Thu, Mar 18, 2021 at 1:12 PM Alexander Sverdlin
<alexander.sverdlin@nokia.com> wrote:
> On 18/03/2021 11:51, Andy Shevchenko wrote:
> > On Wednesday, March 17, 2021, Alexander A Sverdlin <alexander.sverdlin@nokia.com <mailto:alexander.sverdlin@nokia.com>> wrote:
...
> > Existing (irq < 0) condition is always false because adev->irq has unsigned
> > type and contains 0 in case of failed irq_of_parse_and_map(). Up to now all
> > the mapping errors were silently ignored.
> >
> > Seems that repairing this check would be backwards-incompatible and might
> > break the probe() for the implementations without IRQ support. Therefore
> > warn the user instead.
...
> > - if (irq < 0) {
> > - dev_err(&adev->dev, "invalid IRQ\n");
> > - return -ENODEV;
> > - }
> > + if (!irq)
> > + dev_warn(&adev->dev, "IRQ support disabled\n");
> >
> >
> >
> > I guess you need to preserve bailing out. Seems nobody hit this error path.
>
> Do you mean preserve "return -ENODEV;"?
> This never ever happened, because the "if" is "always false", irqs coming from irq[] cannot be
> negative.
> And there is another use-case actually: there are legal PL061 configurations without IRQs at all,
> which simply work even trying to instantiate irq chip, but as devm_gpiochip_add_data() doesn't
> fail with irq==0, this goes completely unnoticed and such a gpio bank works fine.
>
> The proper way would be not even try to instantiate any irq chip in such case.
> Let me know if I shall rework the patch this way.
Yes, please, rewrite it like
if (irq > 0) {
... instantiate an IRQ chip ...
} else {
// nothing. No warning is needed (as it wasn't ever before), perhaps
just a debug message
}
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2021-03-18 12:20 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-03-03 9:28 [PATCH] gpio: pl061: Warn when IRQ line has not been configured Alexander A Sverdlin
2020-03-04 14:21 ` Bartosz Golaszewski
2020-03-04 14:58 ` Alexander Sverdlin
2020-03-04 16:46 ` Bartosz Golaszewski
[not found] <20210317155919.41450-1-alexander.sverdlin@nokia.com>
2021-03-17 15:59 ` Alexander A Sverdlin
[not found] ` <CAHp75Vd-iUzEyo5X5LtKJ+66512i5-tKC+kkpPYJwG7L2qrvdw@mail.gmail.com>
2021-03-18 11:11 ` Alexander Sverdlin
2021-03-18 12:19 ` Andy Shevchenko
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).