* [PATCH] powerpc/powernv: Detach from PE on releasing PCI device
@ 2016-09-06 6:34 Gavin Shan
2016-09-15 22:07 ` Michael Ellerman
0 siblings, 1 reply; 2+ messages in thread
From: Gavin Shan @ 2016-09-06 6:34 UTC (permalink / raw)
To: linuxppc-dev; +Cc: mpe, Gavin Shan
The PCI hotplug can be part of EEH error recovery. The @pdn and
the device's PE number aren't removed and added afterwords. The
PE number in @pdn should be set to an invalid one. Otherwise, the
PE's device count is decreased on removing devices while failing
to be increased on adding devices. It leads to unbalanced PE's
device count and make normal PCI hotplug path broken.
Fixes: c5f7700bbd2e ("powerpc/powernv: Dynamically release PE")
Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
---
arch/powerpc/platforms/powernv/pci-ioda.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
index c16d790..e98f4a8 100644
--- a/arch/powerpc/platforms/powernv/pci-ioda.c
+++ b/arch/powerpc/platforms/powernv/pci-ioda.c
@@ -3442,7 +3442,16 @@ static void pnv_pci_release_device(struct pci_dev *pdev)
if (!pdn || pdn->pe_number == IODA_INVALID_PE)
return;
+ /* PCI hotplug can happen as part of EEH error recovery. The @pdn
+ * isn't removed and added afterwards in this scenario. We should
+ * set the PE number in @pdn to an invalid one. Otherwise, the PE's
+ * device count is decreased on removing devices while failing to
+ * be increased on adding devices. It leads to unbalanced PE's device
+ * count and eventually make normal PCI hotplug path broken.
+ */
pe = &phb->ioda.pe_array[pdn->pe_number];
+ pdn->pe_number = IODA_INVALID_PE;
+
WARN_ON(--pe->device_count < 0);
if (pe->device_count == 0)
pnv_ioda_release_pe(pe);
--
2.1.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: powerpc/powernv: Detach from PE on releasing PCI device
2016-09-06 6:34 [PATCH] powerpc/powernv: Detach from PE on releasing PCI device Gavin Shan
@ 2016-09-15 22:07 ` Michael Ellerman
0 siblings, 0 replies; 2+ messages in thread
From: Michael Ellerman @ 2016-09-15 22:07 UTC (permalink / raw)
To: Gavin Shan, linuxppc-dev; +Cc: Gavin Shan
On Tue, 2016-06-09 at 06:34:01 UTC, Gavin Shan wrote:
> The PCI hotplug can be part of EEH error recovery. The @pdn and
> the device's PE number aren't removed and added afterwords. The
> PE number in @pdn should be set to an invalid one. Otherwise, the
> PE's device count is decreased on removing devices while failing
> to be increased on adding devices. It leads to unbalanced PE's
> device count and make normal PCI hotplug path broken.
>
> Fixes: c5f7700bbd2e ("powerpc/powernv: Dynamically release PE")
> Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
Applied to powerpc fixes, thanks.
https://git.kernel.org/powerpc/c/29bf282dec94f6015a675c0076
cheers
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-09-15 22:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-06 6:34 [PATCH] powerpc/powernv: Detach from PE on releasing PCI device Gavin Shan
2016-09-15 22:07 ` 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).