linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] powerpc/pseries: Fix corrupted pdn list
@ 2015-08-27  4:12 Gavin Shan
  2015-08-27  4:12 ` [PATCH 2/2] powerpc/pseries: Cleanup on pci_dn_reconfig_notifier() Gavin Shan
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Gavin Shan @ 2015-08-27  4:12 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: mpe, Gavin Shan

Commit cca87d30 ("powerpc/pci: Refactor pci_dn") introduced pdn
list for SRIOV VFs. It means the pdn is be put into the child list
of its parent pdn when the pdn is created. When doing PCI hot
unplugging on pSeries, the PCI device node as well as its pdn are
released through procfs entry "powerpc/ofdt". Some one else grabs
the memory chunk of the pdn and update it accordingly. At the same
time, the pdn is still tracked in the child list of parent pdn. It
leads to corrupted child list in the parent pdn.

This fixes above issue by removing the pdn from the child list of
its parent pdn when the device node is detached from the system.
Note the pdn is free'd when the device node is released if the
device node is dynamic one. Otherwise, the device node as well
as the pdn won't be released.

Fixes: cca87d30 ("powerpc/pci: Refactor pci_dn")
Reported-by: Santwana Samantray <santwana.samantray@in.ibm.com>
Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
---
 arch/powerpc/platforms/pseries/setup.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c
index df6a704..e6e8b24 100644
--- a/arch/powerpc/platforms/pseries/setup.c
+++ b/arch/powerpc/platforms/pseries/setup.c
@@ -268,6 +268,11 @@ static int pci_dn_reconfig_notifier(struct notifier_block *nb, unsigned long act
 			eeh_dev_init(PCI_DN(np), pci->phb);
 		}
 		break;
+	case OF_RECONFIG_DETACH_NODE:
+		pci = PCI_DN(np);
+		if (pci)
+			list_del(&pci->list);
+		break;
 	default:
 		err = NOTIFY_DONE;
 		break;
-- 
2.1.0

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

* [PATCH 2/2] powerpc/pseries: Cleanup on pci_dn_reconfig_notifier()
  2015-08-27  4:12 [PATCH 1/2] powerpc/pseries: Fix corrupted pdn list Gavin Shan
@ 2015-08-27  4:12 ` Gavin Shan
  2015-08-30 21:20   ` [2/2] " Michael Ellerman
  2015-08-28  0:55 ` [1/2] powerpc/pseries: Fix corrupted pdn list Michael Ellerman
  2015-08-30 21:20 ` Michael Ellerman
  2 siblings, 1 reply; 8+ messages in thread
From: Gavin Shan @ 2015-08-27  4:12 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: mpe, Gavin Shan

This applies cleanup on pci_dn_reconfig_notifier(), no functional
changes:

   * Rename variable "pci" to "pdn" to indicate its purpose clearly.
   * The parent node can be released at any time. So it should be
     hold with of_get_parent() before accessing it.
   * The device node doesn't have to have parent node in theory.
     More check on this.

Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
---
 arch/powerpc/platforms/pseries/setup.c | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c
index e6e8b24..39a74fa 100644
--- a/arch/powerpc/platforms/pseries/setup.c
+++ b/arch/powerpc/platforms/pseries/setup.c
@@ -254,24 +254,26 @@ static void __init pseries_discover_pic(void)
 static int pci_dn_reconfig_notifier(struct notifier_block *nb, unsigned long action, void *data)
 {
 	struct of_reconfig_data *rd = data;
-	struct device_node *np = rd->dn;
-	struct pci_dn *pci = NULL;
+	struct device_node *parent, *np = rd->dn;
+	struct pci_dn *pdn;
 	int err = NOTIFY_OK;
 
 	switch (action) {
 	case OF_RECONFIG_ATTACH_NODE:
-		pci = np->parent->data;
-		if (pci) {
-			update_dn_pci_info(np, pci->phb);
-
-			/* Create EEH device for the OF node */
-			eeh_dev_init(PCI_DN(np), pci->phb);
+		parent = of_get_parent(np);
+		pdn = parent ? PCI_DN(parent) : NULL;
+		if (pdn) {
+			/* Create pdn and EEH device */
+			update_dn_pci_info(np, pdn->phb);
+			eeh_dev_init(PCI_DN(np), pdn->phb);
 		}
+
+		of_node_put(parent);
 		break;
 	case OF_RECONFIG_DETACH_NODE:
-		pci = PCI_DN(np);
-		if (pci)
-			list_del(&pci->list);
+		pdn = PCI_DN(np);
+		if (pdn)
+			list_del(&pdn->list);
 		break;
 	default:
 		err = NOTIFY_DONE;
-- 
2.1.0

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

* Re: [1/2] powerpc/pseries: Fix corrupted pdn list
  2015-08-27  4:12 [PATCH 1/2] powerpc/pseries: Fix corrupted pdn list Gavin Shan
  2015-08-27  4:12 ` [PATCH 2/2] powerpc/pseries: Cleanup on pci_dn_reconfig_notifier() Gavin Shan
@ 2015-08-28  0:55 ` Michael Ellerman
  2015-08-28  1:09   ` Gavin Shan
  2015-08-30 21:20 ` Michael Ellerman
  2 siblings, 1 reply; 8+ messages in thread
From: Michael Ellerman @ 2015-08-28  0:55 UTC (permalink / raw)
  To: Gavin Shan, linuxppc-dev; +Cc: Gavin Shan

On Thu, 2015-27-08 at 04:12:36 UTC, Gavin Shan wrote:
> Commit cca87d30 ("powerpc/pci: Refactor pci_dn") introduced pdn
> list for SRIOV VFs. It means the pdn is be put into the child list
> of its parent pdn when the pdn is created. When doing PCI hot
> unplugging on pSeries, the PCI device node as well as its pdn are
> released through procfs entry "powerpc/ofdt". Some one else grabs
> the memory chunk of the pdn and update it accordingly. At the same
> time, the pdn is still tracked in the child list of parent pdn. It
> leads to corrupted child list in the parent pdn.
> 
> This fixes above issue by removing the pdn from the child list of
> its parent pdn when the device node is detached from the system.
> Note the pdn is free'd when the device node is released if the
> device node is dynamic one. Otherwise, the device node as well
> as the pdn won't be released.
> 
> Fixes: cca87d30 ("powerpc/pci: Refactor pci_dn")

That went into 4.1, so this should presumably go to stable?

cheers

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

* Re: [1/2] powerpc/pseries: Fix corrupted pdn list
  2015-08-28  0:55 ` [1/2] powerpc/pseries: Fix corrupted pdn list Michael Ellerman
@ 2015-08-28  1:09   ` Gavin Shan
  2015-08-28  1:32     ` Michael Ellerman
  0 siblings, 1 reply; 8+ messages in thread
From: Gavin Shan @ 2015-08-28  1:09 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: Gavin Shan, linuxppc-dev

On Fri, Aug 28, 2015 at 10:55:35AM +1000, Michael Ellerman wrote:
>On Thu, 2015-27-08 at 04:12:36 UTC, Gavin Shan wrote:
>> Commit cca87d30 ("powerpc/pci: Refactor pci_dn") introduced pdn
>> list for SRIOV VFs. It means the pdn is be put into the child list
>> of its parent pdn when the pdn is created. When doing PCI hot
>> unplugging on pSeries, the PCI device node as well as its pdn are
>> released through procfs entry "powerpc/ofdt". Some one else grabs
>> the memory chunk of the pdn and update it accordingly. At the same
>> time, the pdn is still tracked in the child list of parent pdn. It
>> leads to corrupted child list in the parent pdn.
>> 
>> This fixes above issue by removing the pdn from the child list of
>> its parent pdn when the device node is detached from the system.
>> Note the pdn is free'd when the device node is released if the
>> device node is dynamic one. Otherwise, the device node as well
>> as the pdn won't be released.
>> 
>> Fixes: cca87d30 ("powerpc/pci: Refactor pci_dn")
>
>That went into 4.1, so this should presumably go to stable?
>

Yeah, This should be put into 4.1 stable.

Thanks,
Gavin

>cheers
>

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

* Re: [1/2] powerpc/pseries: Fix corrupted pdn list
  2015-08-28  1:09   ` Gavin Shan
@ 2015-08-28  1:32     ` Michael Ellerman
  2015-08-28  1:42       ` Gavin Shan
  0 siblings, 1 reply; 8+ messages in thread
From: Michael Ellerman @ 2015-08-28  1:32 UTC (permalink / raw)
  To: Gavin Shan; +Cc: linuxppc-dev

On Fri, 2015-08-28 at 11:09 +1000, Gavin Shan wrote:
> On Fri, Aug 28, 2015 at 10:55:35AM +1000, Michael Ellerman wrote:
> >On Thu, 2015-27-08 at 04:12:36 UTC, Gavin Shan wrote:
> >> Commit cca87d30 ("powerpc/pci: Refactor pci_dn") introduced pdn
> >> list for SRIOV VFs. It means the pdn is be put into the child list
> >> of its parent pdn when the pdn is created. When doing PCI hot
> >> unplugging on pSeries, the PCI device node as well as its pdn are
> >> released through procfs entry "powerpc/ofdt". Some one else grabs
> >> the memory chunk of the pdn and update it accordingly. At the same
> >> time, the pdn is still tracked in the child list of parent pdn. It
> >> leads to corrupted child list in the parent pdn.
> >> 
> >> This fixes above issue by removing the pdn from the child list of
> >> its parent pdn when the device node is detached from the system.
> >> Note the pdn is free'd when the device node is released if the
> >> device node is dynamic one. Otherwise, the device node as well
> >> as the pdn won't be released.
> >> 
> >> Fixes: cca87d30 ("powerpc/pci: Refactor pci_dn")
> >
> >That went into 4.1, so this should presumably go to stable?
> 
> Yeah, This should be put into 4.1 stable.

OK thanks.

I've added:

  Cc: stable@vger.kernel.org # 4.1

cheers

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

* Re: [1/2] powerpc/pseries: Fix corrupted pdn list
  2015-08-28  1:32     ` Michael Ellerman
@ 2015-08-28  1:42       ` Gavin Shan
  0 siblings, 0 replies; 8+ messages in thread
From: Gavin Shan @ 2015-08-28  1:42 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: Gavin Shan, linuxppc-dev

On Fri, Aug 28, 2015 at 11:32:40AM +1000, Michael Ellerman wrote:
>On Fri, 2015-08-28 at 11:09 +1000, Gavin Shan wrote:
>> On Fri, Aug 28, 2015 at 10:55:35AM +1000, Michael Ellerman wrote:
>> >On Thu, 2015-27-08 at 04:12:36 UTC, Gavin Shan wrote:
>> >> Commit cca87d30 ("powerpc/pci: Refactor pci_dn") introduced pdn
>> >> list for SRIOV VFs. It means the pdn is be put into the child list
>> >> of its parent pdn when the pdn is created. When doing PCI hot
>> >> unplugging on pSeries, the PCI device node as well as its pdn are
>> >> released through procfs entry "powerpc/ofdt". Some one else grabs
>> >> the memory chunk of the pdn and update it accordingly. At the same
>> >> time, the pdn is still tracked in the child list of parent pdn. It
>> >> leads to corrupted child list in the parent pdn.
>> >> 
>> >> This fixes above issue by removing the pdn from the child list of
>> >> its parent pdn when the device node is detached from the system.
>> >> Note the pdn is free'd when the device node is released if the
>> >> device node is dynamic one. Otherwise, the device node as well
>> >> as the pdn won't be released.
>> >> 
>> >> Fixes: cca87d30 ("powerpc/pci: Refactor pci_dn")
>> >
>> >That went into 4.1, so this should presumably go to stable?
>> 
>> Yeah, This should be put into 4.1 stable.
>
>OK thanks.
>
>I've added:
>
>  Cc: stable@vger.kernel.org # 4.1
>

Thanks, Michael :-)

>cheers
>
>

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

* Re: [1/2] powerpc/pseries: Fix corrupted pdn list
  2015-08-27  4:12 [PATCH 1/2] powerpc/pseries: Fix corrupted pdn list Gavin Shan
  2015-08-27  4:12 ` [PATCH 2/2] powerpc/pseries: Cleanup on pci_dn_reconfig_notifier() Gavin Shan
  2015-08-28  0:55 ` [1/2] powerpc/pseries: Fix corrupted pdn list Michael Ellerman
@ 2015-08-30 21:20 ` Michael Ellerman
  2 siblings, 0 replies; 8+ messages in thread
From: Michael Ellerman @ 2015-08-30 21:20 UTC (permalink / raw)
  To: Gavin Shan, linuxppc-dev; +Cc: Gavin Shan

On Thu, 2015-27-08 at 04:12:36 UTC, Gavin Shan wrote:
> Commit cca87d30 ("powerpc/pci: Refactor pci_dn") introduced pdn
> list for SRIOV VFs. It means the pdn is be put into the child list
> of its parent pdn when the pdn is created. When doing PCI hot
> unplugging on pSeries, the PCI device node as well as its pdn are
> released through procfs entry "powerpc/ofdt". Some one else grabs
> the memory chunk of the pdn and update it accordingly. At the same
> time, the pdn is still tracked in the child list of parent pdn. It
> leads to corrupted child list in the parent pdn.
> 
> This fixes above issue by removing the pdn from the child list of
> its parent pdn when the device node is detached from the system.
> Note the pdn is free'd when the device node is released if the
> device node is dynamic one. Otherwise, the device node as well
> as the pdn won't be released.
> 
> Fixes: cca87d30 ("powerpc/pci: Refactor pci_dn")
> Reported-by: Santwana Samantray <santwana.samantray@in.ibm.com>
> Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/590c7567a2895f939525ead5

cheers

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

* Re: [2/2] powerpc/pseries: Cleanup on pci_dn_reconfig_notifier()
  2015-08-27  4:12 ` [PATCH 2/2] powerpc/pseries: Cleanup on pci_dn_reconfig_notifier() Gavin Shan
@ 2015-08-30 21:20   ` Michael Ellerman
  0 siblings, 0 replies; 8+ messages in thread
From: Michael Ellerman @ 2015-08-30 21:20 UTC (permalink / raw)
  To: Gavin Shan, linuxppc-dev; +Cc: Gavin Shan

On Thu, 2015-27-08 at 04:12:37 UTC, Gavin Shan wrote:
> This applies cleanup on pci_dn_reconfig_notifier(), no functional
> changes:
> 
>    * Rename variable "pci" to "pdn" to indicate its purpose clearly.
>    * The parent node can be released at any time. So it should be
>      hold with of_get_parent() before accessing it.
>    * The device node doesn't have to have parent node in theory.
>      More check on this.
> 
> Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/ea0f8acf4d44727f7d3a3807

cheers

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

end of thread, other threads:[~2015-08-30 21:20 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-27  4:12 [PATCH 1/2] powerpc/pseries: Fix corrupted pdn list Gavin Shan
2015-08-27  4:12 ` [PATCH 2/2] powerpc/pseries: Cleanup on pci_dn_reconfig_notifier() Gavin Shan
2015-08-30 21:20   ` [2/2] " Michael Ellerman
2015-08-28  0:55 ` [1/2] powerpc/pseries: Fix corrupted pdn list Michael Ellerman
2015-08-28  1:09   ` Gavin Shan
2015-08-28  1:32     ` Michael Ellerman
2015-08-28  1:42       ` Gavin Shan
2015-08-30 21:20 ` Michael Ellerman

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).