Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1440943 > unrolled thread

[Patch v2] rpaphp: fix slot registration for multiple slots under a PHB

Started byTyrel Datwyler <tyreld@linux.vnet.ibm.com>
First post2016-07-12 00:20 +0200
Last post2016-07-20 11:20 +0200
Articles 3 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [Patch v2] rpaphp: fix slot registration for multiple slots under a PHB Tyrel Datwyler <tyreld@linux.vnet.ibm.com> - 2016-07-12 00:20 +0200
    Re: [Patch v2] rpaphp: fix slot registration for multiple slots under  a PHB Nathan Fontenot <nfont@linux.vnet.ibm.com> - 2016-07-19 15:50 +0200
    Re: [v2] rpaphp: fix slot registration for multiple slots under a PHB Michael Ellerman <patch-notifications@ellerman.id.au> - 2016-07-20 11:20 +0200

#1440943 — [Patch v2] rpaphp: fix slot registration for multiple slots under a PHB

FromTyrel Datwyler <tyreld@linux.vnet.ibm.com>
Date2016-07-12 00:20 +0200
Subject[Patch v2] rpaphp: fix slot registration for multiple slots under a PHB
Message-ID<rTRIt-4Dg-9@gated-at.bofh.it>
PowerVM seems to only ever provide a single hotplug slot per PHB.
The under lying slot hotplug registration code assumed multiple slots,
but the actual implementation is broken for multiple slots. This went
unnoticed for years due to the nature of PowerVM as mentioned
previously. Under qemu/kvm the hotplug slot model aligns more with
x86 where multiple slots are presented under a single PHB. As seen
in the following each additional slot after the first fails to
register due to each slot always being compared against the first
child node of the PHB in the device tree.

[    6.492291] rpaphp: RPA HOT Plug PCI Controller Driver version: 0.1
[    6.492569] rpaphp: Slot [Slot 0] registered
[    6.492577] rpaphp: pci_hp_register failed with error -16
[    6.493082] rpaphp: pci_hp_register failed with error -16
[    6.493138] rpaphp: pci_hp_register failed with error -16
[    6.493161] rpaphp: pci_hp_register failed with error -16

The registration logic is fixed so that each slot is compared
against the existing child devices of the PHB in the device tree to
determine present slots vs empty slots.

[   38.481750] rpaphp: RPA HOT Plug PCI Controller Driver version: 0.1
[   38.482004] rpaphp: Slot [C0] registered
[   38.482127] rpaphp: Slot [C1] registered
[   38.482241] rpaphp: Slot [C2] registered
[   38.482356] rpaphp: Slot [C3] registered
[   38.482495] rpaphp: Slot [C4] registered

Signed-off-by: Tyrel Datwyler <tyreld@linux.vnet.ibm.com>
---

Changes in v2: corrected ibm,my-drc-index property name

---
 drivers/pci/hotplug/rpaphp_slot.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/drivers/pci/hotplug/rpaphp_slot.c b/drivers/pci/hotplug/rpaphp_slot.c
index 6937c72..388c4d8 100644
--- a/drivers/pci/hotplug/rpaphp_slot.c
+++ b/drivers/pci/hotplug/rpaphp_slot.c
@@ -117,8 +117,10 @@ EXPORT_SYMBOL_GPL(rpaphp_deregister_slot);
 int rpaphp_register_slot(struct slot *slot)
 {
 	struct hotplug_slot *php_slot = slot->hotplug_slot;
+	struct device_node *child;
+	u32 my_index;
 	int retval;
-	int slotno;
+	int slotno = -1;
 
 	dbg("%s registering slot:path[%s] index[%x], name[%s] pdomain[%x] type[%d]\n",
 		__func__, slot->dn->full_name, slot->index, slot->name,
@@ -130,10 +132,15 @@ int rpaphp_register_slot(struct slot *slot)
 		return -EAGAIN;
 	}
 
-	if (slot->dn->child)
-		slotno = PCI_SLOT(PCI_DN(slot->dn->child)->devfn);
-	else
-		slotno = -1;
+	for_each_child_of_node(slot->dn, child) {
+		retval = of_property_read_u32(child, "ibm,my-drc-index", &my_index);
+		if (my_index == slot->index) {
+			slotno = PCI_SLOT(PCI_DN(child)->devfn);
+			of_node_put(child);
+			break;
+		}
+	}
+
 	retval = pci_hp_register(php_slot, slot->bus, slotno, slot->name);
 	if (retval) {
 		err("pci_hp_register failed with error %d\n", retval);
-- 
2.7.4

[toc] | [next] | [standalone]


#1446492 — Re: [Patch v2] rpaphp: fix slot registration for multiple slots under a PHB

FromNathan Fontenot <nfont@linux.vnet.ibm.com>
Date2016-07-19 15:50 +0200
SubjectRe: [Patch v2] rpaphp: fix slot registration for multiple slots under a PHB
Message-ID<rWDzl-4Fv-39@gated-at.bofh.it>
In reply to#1440943
On 07/11/2016 05:16 PM, Tyrel Datwyler wrote:
> PowerVM seems to only ever provide a single hotplug slot per PHB.
> The under lying slot hotplug registration code assumed multiple slots,
> but the actual implementation is broken for multiple slots. This went
> unnoticed for years due to the nature of PowerVM as mentioned
> previously. Under qemu/kvm the hotplug slot model aligns more with
> x86 where multiple slots are presented under a single PHB. As seen
> in the following each additional slot after the first fails to
> register due to each slot always being compared against the first
> child node of the PHB in the device tree.
> 
> [    6.492291] rpaphp: RPA HOT Plug PCI Controller Driver version: 0.1
> [    6.492569] rpaphp: Slot [Slot 0] registered
> [    6.492577] rpaphp: pci_hp_register failed with error -16
> [    6.493082] rpaphp: pci_hp_register failed with error -16
> [    6.493138] rpaphp: pci_hp_register failed with error -16
> [    6.493161] rpaphp: pci_hp_register failed with error -16
> 
> The registration logic is fixed so that each slot is compared
> against the existing child devices of the PHB in the device tree to
> determine present slots vs empty slots.
> 
> [   38.481750] rpaphp: RPA HOT Plug PCI Controller Driver version: 0.1
> [   38.482004] rpaphp: Slot [C0] registered
> [   38.482127] rpaphp: Slot [C1] registered
> [   38.482241] rpaphp: Slot [C2] registered
> [   38.482356] rpaphp: Slot [C3] registered
> [   38.482495] rpaphp: Slot [C4] registered
> 
> Signed-off-by: Tyrel Datwyler <tyreld@linux.vnet.ibm.com>

Reviewed-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>

> ---
> 
> Changes in v2: corrected ibm,my-drc-index property name
> 
> ---
>  drivers/pci/hotplug/rpaphp_slot.c | 17 ++++++++++++-----
>  1 file changed, 12 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/pci/hotplug/rpaphp_slot.c b/drivers/pci/hotplug/rpaphp_slot.c
> index 6937c72..388c4d8 100644
> --- a/drivers/pci/hotplug/rpaphp_slot.c
> +++ b/drivers/pci/hotplug/rpaphp_slot.c
> @@ -117,8 +117,10 @@ EXPORT_SYMBOL_GPL(rpaphp_deregister_slot);
>  int rpaphp_register_slot(struct slot *slot)
>  {
>  	struct hotplug_slot *php_slot = slot->hotplug_slot;
> +	struct device_node *child;
> +	u32 my_index;
>  	int retval;
> -	int slotno;
> +	int slotno = -1;
> 
>  	dbg("%s registering slot:path[%s] index[%x], name[%s] pdomain[%x] type[%d]\n",
>  		__func__, slot->dn->full_name, slot->index, slot->name,
> @@ -130,10 +132,15 @@ int rpaphp_register_slot(struct slot *slot)
>  		return -EAGAIN;
>  	}
> 
> -	if (slot->dn->child)
> -		slotno = PCI_SLOT(PCI_DN(slot->dn->child)->devfn);
> -	else
> -		slotno = -1;
> +	for_each_child_of_node(slot->dn, child) {
> +		retval = of_property_read_u32(child, "ibm,my-drc-index", &my_index);
> +		if (my_index == slot->index) {
> +			slotno = PCI_SLOT(PCI_DN(child)->devfn);
> +			of_node_put(child);
> +			break;
> +		}
> +	}
> +
>  	retval = pci_hp_register(php_slot, slot->bus, slotno, slot->name);
>  	if (retval) {
>  		err("pci_hp_register failed with error %d\n", retval);
> 

[toc] | [prev] | [next] | [standalone]


#1447121 — Re: [v2] rpaphp: fix slot registration for multiple slots under a PHB

FromMichael Ellerman <patch-notifications@ellerman.id.au>
Date2016-07-20 11:20 +0200
SubjectRe: [v2] rpaphp: fix slot registration for multiple slots under a PHB
Message-ID<rWVPA-7V0-7@gated-at.bofh.it>
In reply to#1440943
On Mon, 2016-11-07 at 22:16:27 UTC, Tyrel Datwyler wrote:
> PowerVM seems to only ever provide a single hotplug slot per PHB.
> The under lying slot hotplug registration code assumed multiple slots,
> but the actual implementation is broken for multiple slots. This went
> unnoticed for years due to the nature of PowerVM as mentioned
> previously. Under qemu/kvm the hotplug slot model aligns more with
> x86 where multiple slots are presented under a single PHB. As seen
> in the following each additional slot after the first fails to
> register due to each slot always being compared against the first
> child node of the PHB in the device tree.
...
> 
> Signed-off-by: Tyrel Datwyler <tyreld@linux.vnet.ibm.com>

Applied to powerpc next, thanks.

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

cheers

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web