All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH kernel] powerpc/pci: Fix broken INTx configuration via OF
@ 2018-02-08  5:33 Alexey Kardashevskiy
  2018-02-08 19:20 ` Bjorn Helgaas
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Alexey Kardashevskiy @ 2018-02-08  5:33 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: Alexey Kardashevskiy, Benjamin Herrenschmidt, Bjorn Helgaas,
	Michael Ellerman, Paul Mackerras, Rob Herring, Alistair Popple

Commit 59f47eff03a0 ("powerpc/pci: Use of_irq_parse_and_map_pci() helper")
correctly states that of_irq_parse_and_map_pci() does the same thing as
of_irq_parse_pci() does as it simply calls
of_irq_parse_pci() and irq_create_of_mapping().

However of_irq_parse_and_map_pci() not only returns 0 for success and
negative value for an error but also a positive virq value from
irq_create_of_mapping() which the mentioned commit ignores and
INTx config fails.

This fixes the of_irq_parse_and_map_pci() return value handling.

Fixes: 59f47eff03a0 "powerpc/pci: Use of_irq_parse_and_map_pci() helper"
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---

Found it on POWER9 + powernv system - almost all devices suddenly lost
INTx support.
---
 arch/powerpc/kernel/pci-common.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index ae2ede4..acbb44f2 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -370,7 +370,8 @@ static int pci_read_irq_line(struct pci_dev *pci_dev)
 	memset(&oirq, 0xff, sizeof(oirq));
 #endif
 	/* Try to get a mapping from the device-tree */
-	if (!of_irq_parse_and_map_pci(pci_dev, 0, 0)) {
+	virq = of_irq_parse_and_map_pci(pci_dev, 0, 0);
+	if (virq <= 0) {
 		u8 line, pin;
 
 		/* If that fails, lets fallback to what is in the config
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH kernel] powerpc/pci: Fix broken INTx configuration via OF
  2018-02-08  5:33 [PATCH kernel] powerpc/pci: Fix broken INTx configuration via OF Alexey Kardashevskiy
@ 2018-02-08 19:20 ` Bjorn Helgaas
  2018-02-08 21:39   ` Bjorn Helgaas
  2018-02-08 19:46 ` Rob Herring
  2018-02-09  4:00 ` [kernel] " Michael Ellerman
  2 siblings, 1 reply; 10+ messages in thread
From: Bjorn Helgaas @ 2018-02-08 19:20 UTC (permalink / raw)
  To: Alexey Kardashevskiy
  Cc: linuxppc-dev, Benjamin Herrenschmidt, Michael Ellerman,
	Paul Mackerras, Rob Herring, Alistair Popple, linux-pci

[+cc linux-pci]

The original commit was merged via PCI, and I think it's a good idea
to merge fixes to it the same way.  I'll try to merge this in time for
v4.16-rc1.

On Wed, Feb 7, 2018 at 11:33 PM, Alexey Kardashevskiy <aik@ozlabs.ru> wrote:
> Commit 59f47eff03a0 ("powerpc/pci: Use of_irq_parse_and_map_pci() helper")
> correctly states that of_irq_parse_and_map_pci() does the same thing as
> of_irq_parse_pci() does as it simply calls
> of_irq_parse_pci() and irq_create_of_mapping().
>
> However of_irq_parse_and_map_pci() not only returns 0 for success and
> negative value for an error but also a positive virq value from
> irq_create_of_mapping() which the mentioned commit ignores and
> INTx config fails.
>
> This fixes the of_irq_parse_and_map_pci() return value handling.
>
> Fixes: 59f47eff03a0 "powerpc/pci: Use of_irq_parse_and_map_pci() helper"
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> ---
>
> Found it on POWER9 + powernv system - almost all devices suddenly lost
> INTx support.
> ---
>  arch/powerpc/kernel/pci-common.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
> index ae2ede4..acbb44f2 100644
> --- a/arch/powerpc/kernel/pci-common.c
> +++ b/arch/powerpc/kernel/pci-common.c
> @@ -370,7 +370,8 @@ static int pci_read_irq_line(struct pci_dev *pci_dev)
>         memset(&oirq, 0xff, sizeof(oirq));
>  #endif
>         /* Try to get a mapping from the device-tree */
> -       if (!of_irq_parse_and_map_pci(pci_dev, 0, 0)) {
> +       virq = of_irq_parse_and_map_pci(pci_dev, 0, 0);
> +       if (virq <= 0) {
>                 u8 line, pin;
>
>                 /* If that fails, lets fallback to what is in the config
> --
> 2.11.0
>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH kernel] powerpc/pci: Fix broken INTx configuration via OF
  2018-02-08  5:33 [PATCH kernel] powerpc/pci: Fix broken INTx configuration via OF Alexey Kardashevskiy
  2018-02-08 19:20 ` Bjorn Helgaas
@ 2018-02-08 19:46 ` Rob Herring
  2018-02-09  4:00 ` [kernel] " Michael Ellerman
  2 siblings, 0 replies; 10+ messages in thread
From: Rob Herring @ 2018-02-08 19:46 UTC (permalink / raw)
  To: Alexey Kardashevskiy
  Cc: linuxppc-dev, Benjamin Herrenschmidt, Bjorn Helgaas,
	Michael Ellerman, Paul Mackerras, Alistair Popple

On Wed, Feb 7, 2018 at 11:33 PM, Alexey Kardashevskiy <aik@ozlabs.ru> wrote:
> Commit 59f47eff03a0 ("powerpc/pci: Use of_irq_parse_and_map_pci() helper")
> correctly states that of_irq_parse_and_map_pci() does the same thing as
> of_irq_parse_pci() does as it simply calls
> of_irq_parse_pci() and irq_create_of_mapping().
>
> However of_irq_parse_and_map_pci() not only returns 0 for success and
> negative value for an error but also a positive virq value from
> irq_create_of_mapping() which the mentioned commit ignores and
> INTx config fails.
>
> This fixes the of_irq_parse_and_map_pci() return value handling.
>
> Fixes: 59f47eff03a0 "powerpc/pci: Use of_irq_parse_and_map_pci() helper"
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> ---
>
> Found it on POWER9 + powernv system - almost all devices suddenly lost
> INTx support.
> ---
>  arch/powerpc/kernel/pci-common.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

Thanks.

Acked-by: Rob Herring <robh@kernel.org>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH kernel] powerpc/pci: Fix broken INTx configuration via OF
  2018-02-08 19:20 ` Bjorn Helgaas
@ 2018-02-08 21:39   ` Bjorn Helgaas
  2018-02-08 22:21     ` Benjamin Herrenschmidt
  0 siblings, 1 reply; 10+ messages in thread
From: Bjorn Helgaas @ 2018-02-08 21:39 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Alexey Kardashevskiy, linuxppc-dev, Benjamin Herrenschmidt,
	Michael Ellerman, Paul Mackerras, Rob Herring, Alistair Popple,
	linux-pci

On Thu, Feb 08, 2018 at 01:20:04PM -0600, Bjorn Helgaas wrote:
> [+cc linux-pci]
> 
> The original commit was merged via PCI, and I think it's a good idea
> to merge fixes to it the same way.  I'll try to merge this in time for
> v4.16-rc1.
> 
> On Wed, Feb 7, 2018 at 11:33 PM, Alexey Kardashevskiy <aik@ozlabs.ru> wrote:
> > Commit 59f47eff03a0 ("powerpc/pci: Use of_irq_parse_and_map_pci() helper")
> > correctly states that of_irq_parse_and_map_pci() does the same thing as
> > of_irq_parse_pci() does as it simply calls
> > of_irq_parse_pci() and irq_create_of_mapping().
> >
> > However of_irq_parse_and_map_pci() not only returns 0 for success and
> > negative value for an error but also a positive virq value from
> > irq_create_of_mapping() which the mentioned commit ignores and
> > INTx config fails.
> >
> > This fixes the of_irq_parse_and_map_pci() return value handling.
> >
> > Fixes: 59f47eff03a0 "powerpc/pci: Use of_irq_parse_and_map_pci() helper"
> > Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> > ---
> >
> > Found it on POWER9 + powernv system - almost all devices suddenly lost
> > INTx support.
> > ---
> >  arch/powerpc/kernel/pci-common.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
> > index ae2ede4..acbb44f2 100644
> > --- a/arch/powerpc/kernel/pci-common.c
> > +++ b/arch/powerpc/kernel/pci-common.c
> > @@ -370,7 +370,8 @@ static int pci_read_irq_line(struct pci_dev *pci_dev)
> >         memset(&oirq, 0xff, sizeof(oirq));
> >  #endif
> >         /* Try to get a mapping from the device-tree */
> > -       if (!of_irq_parse_and_map_pci(pci_dev, 0, 0)) {
> > +       virq = of_irq_parse_and_map_pci(pci_dev, 0, 0);
> > +       if (virq <= 0) {

I don't understand how this fix works.  We used to check the result of
of_irq_parse_and_map_pci() and entered the block if it was zero.

Now you enter the block if it is zero or less than zero, but:

  static int pci_read_irq_line(...)
  {
    unsigned int virq = 0;     /* unnecessarily initialized, BTW */

    virq = of_irq_parse_and_map_pci(pci_dev, 0, 0);
    if (virq <= 0) {
      ...

virq is unsigned, so "virq < 0" can never be true.  So how does this
change anything?

Bjorn

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH kernel] powerpc/pci: Fix broken INTx configuration via OF
  2018-02-08 21:39   ` Bjorn Helgaas
@ 2018-02-08 22:21     ` Benjamin Herrenschmidt
  2018-02-08 22:42       ` Bjorn Helgaas
  0 siblings, 1 reply; 10+ messages in thread
From: Benjamin Herrenschmidt @ 2018-02-08 22:21 UTC (permalink / raw)
  To: Bjorn Helgaas, Bjorn Helgaas
  Cc: Alexey Kardashevskiy, linuxppc-dev, Michael Ellerman,
	Paul Mackerras, Rob Herring, Alistair Popple, linux-pci

On Thu, 2018-02-08 at 15:39 -0600, Bjorn Helgaas wrote:
> I don't understand how this fix works.  We used to check the result of
> of_irq_parse_and_map_pci() and entered the block if it was zero.
> 
> Now you enter the block if it is zero or less than zero, but:
> 
>   static int pci_read_irq_line(...)
>   {
>     unsigned int virq = 0;     /* unnecessarily initialized, BTW */
> 
>     virq = of_irq_parse_and_map_pci(pci_dev, 0, 0);
>     if (virq <= 0) {
>       ...
> 
> virq is unsigned, so "virq < 0" can never be true.  So how does this
> change anything?

Yes it does:

So the unsigned thing is a second bug in the original patch that Alexey
isn't fixing, we need to fix it too.

However, the actual bug Alexey is fixing is that we lost the actual
value of virq. IE, without his fix, we test it for 0 but we don't
actually return it if it's positive.

So he fixes the normal case but there's still a bug in the error case,
we need to make virq signed.

Cheers,
Ben.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH kernel] powerpc/pci: Fix broken INTx configuration via OF
  2018-02-08 22:21     ` Benjamin Herrenschmidt
@ 2018-02-08 22:42       ` Bjorn Helgaas
  2018-02-08 22:50         ` Benjamin Herrenschmidt
  0 siblings, 1 reply; 10+ messages in thread
From: Bjorn Helgaas @ 2018-02-08 22:42 UTC (permalink / raw)
  To: Benjamin Herrenschmidt
  Cc: Bjorn Helgaas, Alexey Kardashevskiy, linuxppc-dev,
	Michael Ellerman, Paul Mackerras, Rob Herring, Alistair Popple,
	linux-pci

On Fri, Feb 09, 2018 at 09:21:43AM +1100, Benjamin Herrenschmidt wrote:
> On Thu, 2018-02-08 at 15:39 -0600, Bjorn Helgaas wrote:
> > I don't understand how this fix works.  We used to check the result of
> > of_irq_parse_and_map_pci() and entered the block if it was zero.
> > 
> > Now you enter the block if it is zero or less than zero, but:
> > 
> >   static int pci_read_irq_line(...)
> >   {
> >     unsigned int virq = 0;     /* unnecessarily initialized, BTW */
> > 
> >     virq = of_irq_parse_and_map_pci(pci_dev, 0, 0);
> >     if (virq <= 0) {
> >       ...
> > 
> > virq is unsigned, so "virq < 0" can never be true.  So how does this
> > change anything?
> 
> Yes it does:
> 
> So the unsigned thing is a second bug in the original patch that Alexey
> isn't fixing, we need to fix it too.
> 
> However, the actual bug Alexey is fixing is that we lost the actual
> value of virq. IE, without his fix, we test it for 0 but we don't
> actually return it if it's positive.

Ah, I see, the bug is that we discarded the non-zero virq value when
we actually need it.  I'm going to wait for a new patch with a
changelog that says that and doesn't test an unsigned value for < 0.

> So he fixes the normal case but there's still a bug in the error case,
> we need to make virq signed.

I looked through the of_irq_parse_and_map_pci() path and I do not see
a case where it can return a negative value.  It either returns zero
or one of these:

  virq = irq_find_mapping(...)
  virq = irq_create_mapping(...)

Both of these functions return unsigned values.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH kernel] powerpc/pci: Fix broken INTx configuration via OF
  2018-02-08 22:42       ` Bjorn Helgaas
@ 2018-02-08 22:50         ` Benjamin Herrenschmidt
  0 siblings, 0 replies; 10+ messages in thread
From: Benjamin Herrenschmidt @ 2018-02-08 22:50 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Bjorn Helgaas, Alexey Kardashevskiy, linuxppc-dev,
	Michael Ellerman, Paul Mackerras, Rob Herring, Alistair Popple,
	linux-pci

On Thu, 2018-02-08 at 16:42 -0600, Bjorn Helgaas wrote:
> On Fri, Feb 09, 2018 at 09:21:43AM +1100, Benjamin Herrenschmidt wrote:
> > On Thu, 2018-02-08 at 15:39 -0600, Bjorn Helgaas wrote:
> > > I don't understand how this fix works.  We used to check the result of
> > > of_irq_parse_and_map_pci() and entered the block if it was zero.
> > > 
> > > Now you enter the block if it is zero or less than zero, but:
> > > 
> > >   static int pci_read_irq_line(...)
> > >   {
> > >     unsigned int virq = 0;     /* unnecessarily initialized, BTW */
> > > 
> > >     virq = of_irq_parse_and_map_pci(pci_dev, 0, 0);
> > >     if (virq <= 0) {
> > >       ...
> > > 
> > > virq is unsigned, so "virq < 0" can never be true.  So how does this
> > > change anything?
> > 
> > Yes it does:
> > 
> > So the unsigned thing is a second bug in the original patch that Alexey
> > isn't fixing, we need to fix it too.
> > 
> > However, the actual bug Alexey is fixing is that we lost the actual
> > value of virq. IE, without his fix, we test it for 0 but we don't
> > actually return it if it's positive.
> 
> Ah, I see, the bug is that we discarded the non-zero virq value when
> we actually need it.  I'm going to wait for a new patch with a
> changelog that says that and doesn't test an unsigned value for < 0.
> 
> > So he fixes the normal case but there's still a bug in the error case,
> > we need to make virq signed.
> 
> I looked through the of_irq_parse_and_map_pci() path and I do not see
> a case where it can return a negative value.  It either returns zero
> or one of these:
> 
>   virq = irq_find_mapping(...)
>   virq = irq_create_mapping(...)
> 
> Both of these functions return unsigned values.

Ok so the test is just wrong then. Aleey, can you respin ?

Cheers,
Ben.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [kernel] powerpc/pci: Fix broken INTx configuration via OF
  2018-02-08  5:33 [PATCH kernel] powerpc/pci: Fix broken INTx configuration via OF Alexey Kardashevskiy
  2018-02-08 19:20 ` Bjorn Helgaas
  2018-02-08 19:46 ` Rob Herring
@ 2018-02-09  4:00 ` Michael Ellerman
  2018-02-09  4:20   ` Alexey Kardashevskiy
  2 siblings, 1 reply; 10+ messages in thread
From: Michael Ellerman @ 2018-02-09  4:00 UTC (permalink / raw)
  To: Alexey Kardashevskiy, linuxppc-dev
  Cc: Rob Herring, Alistair Popple, Alexey Kardashevskiy, Bjorn Helgaas

On Thu, 2018-02-08 at 05:33:54 UTC, Alexey Kardashevskiy wrote:
> Commit 59f47eff03a0 ("powerpc/pci: Use of_irq_parse_and_map_pci() helper")
> correctly states that of_irq_parse_and_map_pci() does the same thing as
> of_irq_parse_pci() does as it simply calls
> of_irq_parse_pci() and irq_create_of_mapping().
> 
> However of_irq_parse_and_map_pci() not only returns 0 for success and
> negative value for an error but also a positive virq value from
> irq_create_of_mapping() which the mentioned commit ignores and
> INTx config fails.
> 
> This fixes the of_irq_parse_and_map_pci() return value handling.
> 
> Fixes: 59f47eff03a0 "powerpc/pci: Use of_irq_parse_and_map_pci() helper"
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>

Applied to powerpc fixes, thanks.

https://git.kernel.org/powerpc/c/560c0f978155282e36f33d21b2aeae

cheers

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [kernel] powerpc/pci: Fix broken INTx configuration via OF
  2018-02-09  4:00 ` [kernel] " Michael Ellerman
@ 2018-02-09  4:20   ` Alexey Kardashevskiy
  2018-02-09  5:34     ` Michael Ellerman
  0 siblings, 1 reply; 10+ messages in thread
From: Alexey Kardashevskiy @ 2018-02-09  4:20 UTC (permalink / raw)
  To: Michael Ellerman, linuxppc-dev
  Cc: Rob Herring, Alistair Popple, Bjorn Helgaas

On 09/02/18 15:00, Michael Ellerman wrote:
> On Thu, 2018-02-08 at 05:33:54 UTC, Alexey Kardashevskiy wrote:
>> Commit 59f47eff03a0 ("powerpc/pci: Use of_irq_parse_and_map_pci() helper")
>> correctly states that of_irq_parse_and_map_pci() does the same thing as
>> of_irq_parse_pci() does as it simply calls
>> of_irq_parse_pci() and irq_create_of_mapping().
>>
>> However of_irq_parse_and_map_pci() not only returns 0 for success and
>> negative value for an error but also a positive virq value from
>> irq_create_of_mapping() which the mentioned commit ignores and
>> INTx config fails.
>>
>> This fixes the of_irq_parse_and_map_pci() return value handling.
>>
>> Fixes: 59f47eff03a0 "powerpc/pci: Use of_irq_parse_and_map_pci() helper"
>> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> 
> Applied to powerpc fixes, thanks.
> 
> https://git.kernel.org/powerpc/c/560c0f978155282e36f33d21b2aeae


there is a v2, this one is not 100% correct


-- 
Alexey

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [kernel] powerpc/pci: Fix broken INTx configuration via OF
  2018-02-09  4:20   ` Alexey Kardashevskiy
@ 2018-02-09  5:34     ` Michael Ellerman
  0 siblings, 0 replies; 10+ messages in thread
From: Michael Ellerman @ 2018-02-09  5:34 UTC (permalink / raw)
  To: Alexey Kardashevskiy, Michael Ellerman, linuxppc-dev
  Cc: Rob Herring, Alistair Popple, Bjorn Helgaas

Alexey Kardashevskiy <aik@ozlabs.ru> writes:

> On 09/02/18 15:00, Michael Ellerman wrote:
>> On Thu, 2018-02-08 at 05:33:54 UTC, Alexey Kardashevskiy wrote:
>>> Commit 59f47eff03a0 ("powerpc/pci: Use of_irq_parse_and_map_pci() helper")
>>> correctly states that of_irq_parse_and_map_pci() does the same thing as
>>> of_irq_parse_pci() does as it simply calls
>>> of_irq_parse_pci() and irq_create_of_mapping().
>>>
>>> However of_irq_parse_and_map_pci() not only returns 0 for success and
>>> negative value for an error but also a positive virq value from
>>> irq_create_of_mapping() which the mentioned commit ignores and
>>> INTx config fails.
>>>
>>> This fixes the of_irq_parse_and_map_pci() return value handling.
>>>
>>> Fixes: 59f47eff03a0 "powerpc/pci: Use of_irq_parse_and_map_pci() helper"
>>> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
>> 
>> Applied to powerpc fixes, thanks.
>> 
>> https://git.kernel.org/powerpc/c/560c0f978155282e36f33d21b2aeae
>
>
> there is a v2, this one is not 100% correct

Yeah I just saw, I'll back this out.

cheers

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2018-02-09  5:34 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-08  5:33 [PATCH kernel] powerpc/pci: Fix broken INTx configuration via OF Alexey Kardashevskiy
2018-02-08 19:20 ` Bjorn Helgaas
2018-02-08 21:39   ` Bjorn Helgaas
2018-02-08 22:21     ` Benjamin Herrenschmidt
2018-02-08 22:42       ` Bjorn Helgaas
2018-02-08 22:50         ` Benjamin Herrenschmidt
2018-02-08 19:46 ` Rob Herring
2018-02-09  4:00 ` [kernel] " Michael Ellerman
2018-02-09  4:20   ` Alexey Kardashevskiy
2018-02-09  5:34     ` Michael Ellerman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.