All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] powerpc/eeh: Fix PE location code
@ 2015-12-02  5:25 Gavin Shan
  2016-01-19 22:41 ` Joel Stanley
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Gavin Shan @ 2015-12-02  5:25 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: mpe, Gavin Shan

In eeh_pe_loc_get(), the PE location code is retrieved from the
"ibm,loc-code" property of the device node for the bridge of the
PE's primary bus. It's not correct because the property indicates
the parent PE's location code.

This reads the correct PE location code from "ibm,io-base-loc-code"
or "ibm,slot-location-code" property of PE parent bus's device node.

Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
---
 arch/powerpc/kernel/eeh_pe.c | 33 +++++++++++++++------------------
 1 file changed, 15 insertions(+), 18 deletions(-)

diff --git a/arch/powerpc/kernel/eeh_pe.c b/arch/powerpc/kernel/eeh_pe.c
index 8654cb1..ca9e537 100644
--- a/arch/powerpc/kernel/eeh_pe.c
+++ b/arch/powerpc/kernel/eeh_pe.c
@@ -883,32 +883,29 @@ void eeh_pe_restore_bars(struct eeh_pe *pe)
 const char *eeh_pe_loc_get(struct eeh_pe *pe)
 {
 	struct pci_bus *bus = eeh_pe_bus_get(pe);
-	struct device_node *dn = pci_bus_to_OF_node(bus);
+	struct device_node *dn;
 	const char *loc = NULL;
 
-	if (!dn)
-		goto out;
+	while (bus) {
+		dn = pci_bus_to_OF_node(bus);
+		if (!dn) {
+			bus = bus->parent;
+			continue;
+		}
 
-	/* PHB PE or root PE ? */
-	if (pci_is_root_bus(bus)) {
-		loc = of_get_property(dn, "ibm,loc-code", NULL);
-		if (!loc)
+		if (pci_is_root_bus(bus))
 			loc = of_get_property(dn, "ibm,io-base-loc-code", NULL);
+		else
+			loc = of_get_property(dn, "ibm,slot-location-code",
+					      NULL);
+
 		if (loc)
-			goto out;
+			return loc;
 
-		/* Check the root port */
-		dn = dn->child;
-		if (!dn)
-			goto out;
+		bus = bus->parent;
 	}
 
-	loc = of_get_property(dn, "ibm,loc-code", NULL);
-	if (!loc)
-		loc = of_get_property(dn, "ibm,slot-location-code", NULL);
-
-out:
-	return loc ? loc : "N/A";
+	return "N/A";
 }
 
 /**
-- 
2.1.0

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

* Re: [PATCH] powerpc/eeh: Fix PE location code
  2015-12-02  5:25 [PATCH] powerpc/eeh: Fix PE location code Gavin Shan
@ 2016-01-19 22:41 ` Joel Stanley
  2016-01-20  3:56 ` Russell Currey
  2016-01-29  1:58 ` Michael Ellerman
  2 siblings, 0 replies; 8+ messages in thread
From: Joel Stanley @ 2016-01-19 22:41 UTC (permalink / raw)
  To: Gavin Shan; +Cc: linuxppc-dev

Hello Gavin,

On Wed, Dec 2, 2015 at 3:55 PM, Gavin Shan <gwshan@linux.vnet.ibm.com> wrote:
> In eeh_pe_loc_get(), the PE location code is retrieved from the
> "ibm,loc-code" property of the device node for the bridge of the
> PE's primary bus. It's not correct because the property indicates
> the parent PE's location code.
>
> This reads the correct PE location code from "ibm,io-base-loc-code"
> or "ibm,slot-location-code" property of PE parent bus's device node.

I think we want this fix included in stable releases. Is that correct?

Cheers,

Joel

> Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
> ---
>  arch/powerpc/kernel/eeh_pe.c | 33 +++++++++++++++------------------
>  1 file changed, 15 insertions(+), 18 deletions(-)
>
> diff --git a/arch/powerpc/kernel/eeh_pe.c b/arch/powerpc/kernel/eeh_pe.c
> index 8654cb1..ca9e537 100644
> --- a/arch/powerpc/kernel/eeh_pe.c
> +++ b/arch/powerpc/kernel/eeh_pe.c
> @@ -883,32 +883,29 @@ void eeh_pe_restore_bars(struct eeh_pe *pe)
>  const char *eeh_pe_loc_get(struct eeh_pe *pe)
>  {
>         struct pci_bus *bus = eeh_pe_bus_get(pe);
> -       struct device_node *dn = pci_bus_to_OF_node(bus);
> +       struct device_node *dn;
>         const char *loc = NULL;
>
> -       if (!dn)
> -               goto out;
> +       while (bus) {
> +               dn = pci_bus_to_OF_node(bus);
> +               if (!dn) {
> +                       bus = bus->parent;
> +                       continue;
> +               }
>
> -       /* PHB PE or root PE ? */
> -       if (pci_is_root_bus(bus)) {
> -               loc = of_get_property(dn, "ibm,loc-code", NULL);
> -               if (!loc)
> +               if (pci_is_root_bus(bus))
>                         loc = of_get_property(dn, "ibm,io-base-loc-code", NULL);
> +               else
> +                       loc = of_get_property(dn, "ibm,slot-location-code",
> +                                             NULL);
> +
>                 if (loc)
> -                       goto out;
> +                       return loc;
>
> -               /* Check the root port */
> -               dn = dn->child;
> -               if (!dn)
> -                       goto out;
> +               bus = bus->parent;
>         }
>
> -       loc = of_get_property(dn, "ibm,loc-code", NULL);
> -       if (!loc)
> -               loc = of_get_property(dn, "ibm,slot-location-code", NULL);
> -
> -out:
> -       return loc ? loc : "N/A";
> +       return "N/A";
>  }
>
>  /**
> --
> 2.1.0
>
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev

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

* Re: [PATCH] powerpc/eeh: Fix PE location code
  2015-12-02  5:25 [PATCH] powerpc/eeh: Fix PE location code Gavin Shan
  2016-01-19 22:41 ` Joel Stanley
@ 2016-01-20  3:56 ` Russell Currey
  2016-01-21  0:08   ` Sam Mendoza-Jonas
  2016-01-29  1:58 ` Michael Ellerman
  2 siblings, 1 reply; 8+ messages in thread
From: Russell Currey @ 2016-01-20  3:56 UTC (permalink / raw)
  To: Gavin Shan, linuxppc-dev

On Wed, 2015-12-02 at 16:25 +1100, Gavin Shan wrote:
> In eeh_pe_loc_get(), the PE location code is retrieved from the
> "ibm,loc-code" property of the device node for the bridge of the
> PE's primary bus. It's not correct because the property indicates
> the parent PE's location code.
> 
> This reads the correct PE location code from "ibm,io-base-loc-code"
> or "ibm,slot-location-code" property of PE parent bus's device node.
> 
> Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
> ---

Tested-by: Russell Currey <ruscur@russell.cc>

>  arch/powerpc/kernel/eeh_pe.c | 33 +++++++++++++++------------------
>  1 file changed, 15 insertions(+), 18 deletions(-)
> 
> diff --git a/arch/powerpc/kernel/eeh_pe.c b/arch/powerpc/kernel/eeh_pe.c
> index 8654cb1..ca9e537 100644
> --- a/arch/powerpc/kernel/eeh_pe.c
> +++ b/arch/powerpc/kernel/eeh_pe.c
> @@ -883,32 +883,29 @@ void eeh_pe_restore_bars(struct eeh_pe *pe)
>  const char *eeh_pe_loc_get(struct eeh_pe *pe)
>  {
>  	struct pci_bus *bus = eeh_pe_bus_get(pe);
> -	struct device_node *dn = pci_bus_to_OF_node(bus);
> +	struct device_node *dn;
>  	const char *loc = NULL;
>  
> -	if (!dn)
> -		goto out;
> +	while (bus) {
> +		dn = pci_bus_to_OF_node(bus);
> +		if (!dn) {
> +			bus = bus->parent;
> +			continue;
> +		}
>  
> -	/* PHB PE or root PE ? */
> -	if (pci_is_root_bus(bus)) {
> -		loc = of_get_property(dn, "ibm,loc-code", NULL);
> -		if (!loc)
> +		if (pci_is_root_bus(bus))
>  			loc = of_get_property(dn, "ibm,io-base-loc-
> code", NULL);
> +		else
> +			loc = of_get_property(dn, "ibm,slot-location-
> code",
> +					      NULL);
> +
>  		if (loc)
> -			goto out;
> +			return loc;
>  
> -		/* Check the root port */
> -		dn = dn->child;
> -		if (!dn)
> -			goto out;
> +		bus = bus->parent;
>  	}
>  
> -	loc = of_get_property(dn, "ibm,loc-code", NULL);
> -	if (!loc)
> -		loc = of_get_property(dn, "ibm,slot-location-code",
> NULL);
> -
> -out:
> -	return loc ? loc : "N/A";
> +	return "N/A";
>  }
>  
>  /**

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

* Re: [PATCH] powerpc/eeh: Fix PE location code
  2016-01-20  3:56 ` Russell Currey
@ 2016-01-21  0:08   ` Sam Mendoza-Jonas
  2016-01-21  5:59     ` Stewart Smith
  0 siblings, 1 reply; 8+ messages in thread
From: Sam Mendoza-Jonas @ 2016-01-21  0:08 UTC (permalink / raw)
  To: Russell Currey; +Cc: Gavin Shan, linuxppc-dev

On Wed, Jan 20, 2016 at 02:56:13PM +1100, Russell Currey wrote:
> On Wed, 2015-12-02 at 16:25 +1100, Gavin Shan wrote:
> > In eeh_pe_loc_get(), the PE location code is retrieved from the
> > "ibm,loc-code" property of the device node for the bridge of the
> > PE's primary bus. It's not correct because the property indicates
> > the parent PE's location code.
> > 
> > This reads the correct PE location code from "ibm,io-base-loc-code"
> > or "ibm,slot-location-code" property of PE parent bus's device node.
> > 
> > Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
> > ---
> 
> Tested-by: Russell Currey <ruscur@russell.cc>

Thanks Russell!

W.R.T including this in stable, I don't believe anything actively breaks
without the patch, but in the event of an EEH freeze the wrong slot for
the device will be identified, making troubleshooting more difficult.
> >  arch/powerpc/kernel/eeh_pe.c | 33 +++++++++++++++------------------
> >  1 file changed, 15 insertions(+), 18 deletions(-)
> > 
> > diff --git a/arch/powerpc/kernel/eeh_pe.c b/arch/powerpc/kernel/eeh_pe.c
> > index 8654cb1..ca9e537 100644
> > --- a/arch/powerpc/kernel/eeh_pe.c
> > +++ b/arch/powerpc/kernel/eeh_pe.c
> > @@ -883,32 +883,29 @@ void eeh_pe_restore_bars(struct eeh_pe *pe)
> >  const char *eeh_pe_loc_get(struct eeh_pe *pe)
> >  {
> >  	struct pci_bus *bus = eeh_pe_bus_get(pe);
> > -	struct device_node *dn = pci_bus_to_OF_node(bus);
> > +	struct device_node *dn;
> >  	const char *loc = NULL;
> >  
> > -	if (!dn)
> > -		goto out;
> > +	while (bus) {
> > +		dn = pci_bus_to_OF_node(bus);
> > +		if (!dn) {
> > +			bus = bus->parent;
> > +			continue;
> > +		}
> >  
> > -	/* PHB PE or root PE ? */
> > -	if (pci_is_root_bus(bus)) {
> > -		loc = of_get_property(dn, "ibm,loc-code", NULL);
> > -		if (!loc)
> > +		if (pci_is_root_bus(bus))
> >  			loc = of_get_property(dn, "ibm,io-base-loc-
> > code", NULL);
> > +		else
> > +			loc = of_get_property(dn, "ibm,slot-location-
> > code",
> > +					      NULL);
> > +
> >  		if (loc)
> > -			goto out;
> > +			return loc;
> >  
> > -		/* Check the root port */
> > -		dn = dn->child;
> > -		if (!dn)
> > -			goto out;
> > +		bus = bus->parent;
> >  	}
> >  
> > -	loc = of_get_property(dn, "ibm,loc-code", NULL);
> > -	if (!loc)
> > -		loc = of_get_property(dn, "ibm,slot-location-code",
> > NULL);
> > -
> > -out:
> > -	return loc ? loc : "N/A";
> > +	return "N/A";
> >  }
> >  
> >  /**
> 
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev

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

* Re: [PATCH] powerpc/eeh: Fix PE location code
  2016-01-21  0:08   ` Sam Mendoza-Jonas
@ 2016-01-21  5:59     ` Stewart Smith
  0 siblings, 0 replies; 8+ messages in thread
From: Stewart Smith @ 2016-01-21  5:59 UTC (permalink / raw)
  To: Sam Mendoza-Jonas, Russell Currey; +Cc: linuxppc-dev, Gavin Shan

Sam Mendoza-Jonas <sam@mendozajonas.com> writes:
> On Wed, Jan 20, 2016 at 02:56:13PM +1100, Russell Currey wrote:
>> On Wed, 2015-12-02 at 16:25 +1100, Gavin Shan wrote:
>> > In eeh_pe_loc_get(), the PE location code is retrieved from the
>> > "ibm,loc-code" property of the device node for the bridge of the
>> > PE's primary bus. It's not correct because the property indicates
>> > the parent PE's location code.
>> > 
>> > This reads the correct PE location code from "ibm,io-base-loc-code"
>> > or "ibm,slot-location-code" property of PE parent bus's device node.
>> > 
>> > Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
>> > ---
>> 
>> Tested-by: Russell Currey <ruscur@russell.cc>
>
> Thanks Russell!
>
> W.R.T including this in stable, I don't believe anything actively breaks
> without the patch, but in the event of an EEH freeze the wrong slot for
> the device will be identified, making troubleshooting more difficult.

As someone who's likely going to have to deal with the bug reports for
such things, I like the idea of this going to stable as *maybe* I'll get
fewer of them that I have to close pointing to this commit...

-- 
Stewart Smith
OPAL Architect, IBM.

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

* Re: powerpc/eeh: Fix PE location code
  2015-12-02  5:25 [PATCH] powerpc/eeh: Fix PE location code Gavin Shan
  2016-01-19 22:41 ` Joel Stanley
  2016-01-20  3:56 ` Russell Currey
@ 2016-01-29  1:58 ` Michael Ellerman
  2 siblings, 0 replies; 8+ messages in thread
From: Michael Ellerman @ 2016-01-29  1:58 UTC (permalink / raw)
  To: Gavin Shan, linuxppc-dev; +Cc: Gavin Shan

On Wed, 2015-02-12 at 05:25:32 UTC, Gavin Shan wrote:
> In eeh_pe_loc_get(), the PE location code is retrieved from the
> "ibm,loc-code" property of the device node for the bridge of the
> PE's primary bus. It's not correct because the property indicates
> the parent PE's location code.
> 
> This reads the correct PE location code from "ibm,io-base-loc-code"
> or "ibm,slot-location-code" property of PE parent bus's device node.
> 
> Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
> Tested-by: Russell Currey <ruscur@russell.cc>

Applied to powerpc fixes, thanks.

https://git.kernel.org/powerpc/c/7e56f627768da4e6480986b514

cheers

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

* Re: [PATCH] powerpc/eeh: Fix PE location code
  2015-12-02  5:17 [PATCH] " Gavin Shan
@ 2015-12-02  5:41 ` Gavin Shan
  0 siblings, 0 replies; 8+ messages in thread
From: Gavin Shan @ 2015-12-02  5:41 UTC (permalink / raw)
  To: Gavin Shan; +Cc: linux-pci, mpe

On Wed, Dec 02, 2015 at 04:17:20PM +1100, Gavin Shan wrote:

Please ignore the noise as it should have been sent to linux-ppc
(not linux-pci) maillist.

Thanks,
Gavin

>In eeh_pe_loc_get(), the PE location code is retrieved from the
>"ibm,loc-code" property of the device node for the bridge of the
>PE's primary bus. It's not correct because the property indicates
>the parent PE's location code.
>
>This reads the correct PE location code from "ibm,io-base-loc-code"
>or "ibm,slot-location-code" property of PE parent bus's device node.
>
>Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
>---
> arch/powerpc/kernel/eeh_pe.c | 33 +++++++++++++++------------------
> 1 file changed, 15 insertions(+), 18 deletions(-)
>
>diff --git a/arch/powerpc/kernel/eeh_pe.c b/arch/powerpc/kernel/eeh_pe.c
>index 8654cb1..ca9e537 100644
>--- a/arch/powerpc/kernel/eeh_pe.c
>+++ b/arch/powerpc/kernel/eeh_pe.c
>@@ -883,32 +883,29 @@ void eeh_pe_restore_bars(struct eeh_pe *pe)
> const char *eeh_pe_loc_get(struct eeh_pe *pe)
> {
> 	struct pci_bus *bus = eeh_pe_bus_get(pe);
>-	struct device_node *dn = pci_bus_to_OF_node(bus);
>+	struct device_node *dn;
> 	const char *loc = NULL;
>
>-	if (!dn)
>-		goto out;
>+	while (bus) {
>+		dn = pci_bus_to_OF_node(bus);
>+		if (!dn) {
>+			bus = bus->parent;
>+			continue;
>+		}
>
>-	/* PHB PE or root PE ? */
>-	if (pci_is_root_bus(bus)) {
>-		loc = of_get_property(dn, "ibm,loc-code", NULL);
>-		if (!loc)
>+		if (pci_is_root_bus(bus))
> 			loc = of_get_property(dn, "ibm,io-base-loc-code", NULL);
>+		else
>+			loc = of_get_property(dn, "ibm,slot-location-code",
>+					      NULL);
>+
> 		if (loc)
>-			goto out;
>+			return loc;
>
>-		/* Check the root port */
>-		dn = dn->child;
>-		if (!dn)
>-			goto out;
>+		bus = bus->parent;
> 	}
>
>-	loc = of_get_property(dn, "ibm,loc-code", NULL);
>-	if (!loc)
>-		loc = of_get_property(dn, "ibm,slot-location-code", NULL);
>-
>-out:
>-	return loc ? loc : "N/A";
>+	return "N/A";
> }
>
> /**
>-- 
>2.1.0
>


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

* [PATCH] powerpc/eeh: Fix PE location code
@ 2015-12-02  5:17 Gavin Shan
  2015-12-02  5:41 ` Gavin Shan
  0 siblings, 1 reply; 8+ messages in thread
From: Gavin Shan @ 2015-12-02  5:17 UTC (permalink / raw)
  To: linux-pci; +Cc: mpe, Gavin Shan

In eeh_pe_loc_get(), the PE location code is retrieved from the
"ibm,loc-code" property of the device node for the bridge of the
PE's primary bus. It's not correct because the property indicates
the parent PE's location code.

This reads the correct PE location code from "ibm,io-base-loc-code"
or "ibm,slot-location-code" property of PE parent bus's device node.

Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
---
 arch/powerpc/kernel/eeh_pe.c | 33 +++++++++++++++------------------
 1 file changed, 15 insertions(+), 18 deletions(-)

diff --git a/arch/powerpc/kernel/eeh_pe.c b/arch/powerpc/kernel/eeh_pe.c
index 8654cb1..ca9e537 100644
--- a/arch/powerpc/kernel/eeh_pe.c
+++ b/arch/powerpc/kernel/eeh_pe.c
@@ -883,32 +883,29 @@ void eeh_pe_restore_bars(struct eeh_pe *pe)
 const char *eeh_pe_loc_get(struct eeh_pe *pe)
 {
 	struct pci_bus *bus = eeh_pe_bus_get(pe);
-	struct device_node *dn = pci_bus_to_OF_node(bus);
+	struct device_node *dn;
 	const char *loc = NULL;
 
-	if (!dn)
-		goto out;
+	while (bus) {
+		dn = pci_bus_to_OF_node(bus);
+		if (!dn) {
+			bus = bus->parent;
+			continue;
+		}
 
-	/* PHB PE or root PE ? */
-	if (pci_is_root_bus(bus)) {
-		loc = of_get_property(dn, "ibm,loc-code", NULL);
-		if (!loc)
+		if (pci_is_root_bus(bus))
 			loc = of_get_property(dn, "ibm,io-base-loc-code", NULL);
+		else
+			loc = of_get_property(dn, "ibm,slot-location-code",
+					      NULL);
+
 		if (loc)
-			goto out;
+			return loc;
 
-		/* Check the root port */
-		dn = dn->child;
-		if (!dn)
-			goto out;
+		bus = bus->parent;
 	}
 
-	loc = of_get_property(dn, "ibm,loc-code", NULL);
-	if (!loc)
-		loc = of_get_property(dn, "ibm,slot-location-code", NULL);
-
-out:
-	return loc ? loc : "N/A";
+	return "N/A";
 }
 
 /**
-- 
2.1.0


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

end of thread, other threads:[~2016-01-29  1:58 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-02  5:25 [PATCH] powerpc/eeh: Fix PE location code Gavin Shan
2016-01-19 22:41 ` Joel Stanley
2016-01-20  3:56 ` Russell Currey
2016-01-21  0:08   ` Sam Mendoza-Jonas
2016-01-21  5:59     ` Stewart Smith
2016-01-29  1:58 ` Michael Ellerman
  -- strict thread matches above, loose matches on Subject: below --
2015-12-02  5:17 [PATCH] " Gavin Shan
2015-12-02  5:41 ` Gavin Shan

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.