* [PATCH v2 1/5] PCI: cpqphp: Check pci_hp_add_bridge() return value
2026-09-09 2:22 ` [PATCH v2 0/5] PCI: hotplug: " Fahmy Hassan
@ 2026-09-09 2:22 ` Fahmy Hassan
2026-09-09 2:22 ` [PATCH v2 2/5] PCI: cpcihp: " Fahmy Hassan
` (3 subsequent siblings)
4 siblings, 0 replies; 10+ messages in thread
From: Fahmy Hassan @ 2026-09-09 2:22 UTC (permalink / raw)
To: helgaas, bhelgaas, scott; +Cc: fahmymohammed, kees, linux-kernel, linux-pci
cpqhp_configure_device() calls pci_hp_add_bridge() without checking
its return value. pci_hp_add_bridge() already logs an error for one
failure path (no bus number available for the hot-added bridge), but
returns silently if the bridge's subordinate bus isn't created after
scanning -- that path goes completely unreported, and either way the
caller currently has no way to notice or react to the failure.
Log an error via the driver's existing err() macro when
pci_hp_add_bridge() fails, identifying the device involved, and
remove the now-resolved TODO entry.
Signed-off-by: Fahmy Hassan <fahmymohammed@gmail.com>
---
drivers/pci/hotplug/TODO | 2 --
drivers/pci/hotplug/cpqphp_pci.c | 4 +++-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/pci/hotplug/TODO b/drivers/pci/hotplug/TODO
index 7397374af171..215ab36df11d 100644
--- a/drivers/pci/hotplug/TODO
+++ b/drivers/pci/hotplug/TODO
@@ -14,8 +14,6 @@ cpqphp:
* A large portion of cpqphp_ctrl.c and cpqphp_pci.c concerns resource
management. Doesn't this duplicate functionality in the core?
-* Returned code from pci_hp_add_bridge() is not checked.
-
ibmphp:
* Implementations of hotplug_slot_ops callbacks such as get_adapter_present()
diff --git a/drivers/pci/hotplug/cpqphp_pci.c b/drivers/pci/hotplug/cpqphp_pci.c
index 81c58b1ec200..34803f36ba65 100644
--- a/drivers/pci/hotplug/cpqphp_pci.c
+++ b/drivers/pci/hotplug/cpqphp_pci.c
@@ -100,7 +100,9 @@ int cpqhp_configure_device(struct controller *ctrl, struct pci_func *func)
}
if (func->pci_dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) {
- pci_hp_add_bridge(func->pci_dev);
+ if (pci_hp_add_bridge(func->pci_dev))
+ err("bus/device/function %x/%x/%x: pci_hp_add_bridge() failed\n",
+ func->bus, func->device, func->function);
child = func->pci_dev->subordinate;
if (child)
pci_bus_add_devices(child);
--
2.53.0
^ permalink raw reply [flat|nested] 10+ messages in thread* [PATCH v2 2/5] PCI: cpcihp: Check pci_hp_add_bridge() return value
2026-09-09 2:22 ` [PATCH v2 0/5] PCI: hotplug: " Fahmy Hassan
2026-09-09 2:22 ` [PATCH v2 1/5] PCI: cpqphp: " Fahmy Hassan
@ 2026-09-09 2:22 ` Fahmy Hassan
2026-09-09 2:22 ` [PATCH v2 3/5] PCI: ibmphp: " Fahmy Hassan
` (2 subsequent siblings)
4 siblings, 0 replies; 10+ messages in thread
From: Fahmy Hassan @ 2026-09-09 2:22 UTC (permalink / raw)
To: helgaas, bhelgaas, scott; +Cc: fahmymohammed, kees, linux-kernel, linux-pci
cpci_configure_slot() calls pci_hp_add_bridge() for each bridge on the
newly added slot without checking its return value. pci_hp_add_bridge()
already logs an error for one failure path (no bus number available
for the hot-added bridge), but returns silently if the bridge's
subordinate bus isn't created after scanning -- that path goes
completely unreported, and either way the caller currently has no way
to notice or react to the failure.
Log an error via the driver's existing err() macro when
pci_hp_add_bridge() fails, identifying the device involved, and
remove the now-resolved TODO entry.
Signed-off-by: Fahmy Hassan <fahmymohammed@gmail.com>
---
drivers/pci/hotplug/TODO | 4 ----
drivers/pci/hotplug/cpci_hotplug_pci.c | 5 +++--
2 files changed, 3 insertions(+), 6 deletions(-)
diff --git a/drivers/pci/hotplug/TODO b/drivers/pci/hotplug/TODO
index 215ab36df11d..0a8e23546e5e 100644
--- a/drivers/pci/hotplug/TODO
+++ b/drivers/pci/hotplug/TODO
@@ -1,9 +1,5 @@
Contributions are solicited in particular to remedy the following issues:
-cpcihp:
-
-* Returned code from pci_hp_add_bridge() is not checked.
-
cpqphp:
* The driver spawns a kthread cpqhp_event_thread() which is woken by the
diff --git a/drivers/pci/hotplug/cpci_hotplug_pci.c b/drivers/pci/hotplug/cpci_hotplug_pci.c
index 6c48066acb44..3deeec8dd206 100644
--- a/drivers/pci/hotplug/cpci_hotplug_pci.c
+++ b/drivers/pci/hotplug/cpci_hotplug_pci.c
@@ -269,8 +269,9 @@ int cpci_configure_slot(struct slot *slot)
parent = slot->dev->bus;
for_each_pci_bridge(dev, parent) {
- if (PCI_SLOT(dev->devfn) == PCI_SLOT(slot->devfn))
- pci_hp_add_bridge(dev);
+ if (PCI_SLOT(dev->devfn) == PCI_SLOT(slot->devfn) &&
+ pci_hp_add_bridge(dev))
+ err("pci_hp_add_bridge(%s) failed", pci_name(dev));
}
pci_assign_unassigned_bridge_resources(parent->self);
--
2.53.0
^ permalink raw reply [flat|nested] 10+ messages in thread* [PATCH v2 3/5] PCI: ibmphp: Check pci_hp_add_bridge() return value
2026-09-09 2:22 ` [PATCH v2 0/5] PCI: hotplug: " Fahmy Hassan
2026-09-09 2:22 ` [PATCH v2 1/5] PCI: cpqphp: " Fahmy Hassan
2026-09-09 2:22 ` [PATCH v2 2/5] PCI: cpcihp: " Fahmy Hassan
@ 2026-09-09 2:22 ` Fahmy Hassan
2026-09-09 2:22 ` [PATCH v2 4/5] PCI: pciehp: " Fahmy Hassan
2026-09-09 2:22 ` [PATCH v2 5/5] PCI: shpchp: " Fahmy Hassan
4 siblings, 0 replies; 10+ messages in thread
From: Fahmy Hassan @ 2026-09-09 2:22 UTC (permalink / raw)
To: helgaas, bhelgaas, scott; +Cc: fahmymohammed, kees, linux-kernel, linux-pci
ibm_configure_device() calls pci_hp_add_bridge() without checking its
return value. pci_hp_add_bridge() already logs an error for one
failure path (no bus number available for the hot-added bridge), but
returns silently if the bridge's subordinate bus isn't created after
scanning -- that path goes completely unreported, and either way the
caller currently has no way to notice or react to the failure.
Log an error via the driver's existing err() macro when
pci_hp_add_bridge() fails, identifying the device involved, and
remove the now-resolved TODO entry.
Signed-off-by: Fahmy Hassan <fahmymohammed@gmail.com>
---
drivers/pci/hotplug/TODO | 2 --
drivers/pci/hotplug/ibmphp_core.c | 3 ++-
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/pci/hotplug/TODO b/drivers/pci/hotplug/TODO
index 0a8e23546e5e..2a4f44f9b629 100644
--- a/drivers/pci/hotplug/TODO
+++ b/drivers/pci/hotplug/TODO
@@ -37,8 +37,6 @@ ibmphp:
* A large portion of ibmphp_res.c and ibmphp_pci.c concerns resource
management. Doesn't this duplicate functionality in the core?
-* Returned code from pci_hp_add_bridge() is not checked.
-
shpchp:
* The hardirq handler shpc_isr() queues events on a workqueue. It can be
diff --git a/drivers/pci/hotplug/ibmphp_core.c b/drivers/pci/hotplug/ibmphp_core.c
index aca86c092d4a..b653d3068677 100644
--- a/drivers/pci/hotplug/ibmphp_core.c
+++ b/drivers/pci/hotplug/ibmphp_core.c
@@ -690,7 +690,8 @@ static int ibm_configure_device(struct pci_func *func)
}
}
if (!(flag) && (func->dev->hdr_type == PCI_HEADER_TYPE_BRIDGE)) {
- pci_hp_add_bridge(func->dev);
+ if (pci_hp_add_bridge(func->dev))
+ err("pci_hp_add_bridge(%s) failed\n", pci_name(func->dev));
child = func->dev->subordinate;
if (child)
pci_bus_add_devices(child);
--
2.53.0
^ permalink raw reply [flat|nested] 10+ messages in thread* [PATCH v2 4/5] PCI: pciehp: Check pci_hp_add_bridge() return value
2026-09-09 2:22 ` [PATCH v2 0/5] PCI: hotplug: " Fahmy Hassan
` (2 preceding siblings ...)
2026-09-09 2:22 ` [PATCH v2 3/5] PCI: ibmphp: " Fahmy Hassan
@ 2026-09-09 2:22 ` Fahmy Hassan
2026-09-09 6:42 ` Lukas Wunner
2026-09-09 2:22 ` [PATCH v2 5/5] PCI: shpchp: " Fahmy Hassan
4 siblings, 1 reply; 10+ messages in thread
From: Fahmy Hassan @ 2026-09-09 2:22 UTC (permalink / raw)
To: helgaas, bhelgaas, scott; +Cc: fahmymohammed, kees, linux-kernel, linux-pci
pciehp_configure_device() calls pci_hp_add_bridge() for each bridge on
the newly added slot without checking its return value.
pci_hp_add_bridge() already logs an error for one failure path (no
bus number available for the hot-added bridge), but returns silently
if the bridge's subordinate bus isn't created after scanning -- that
path goes completely unreported, and either way the caller currently
has no way to notice or react to the failure.
Log an error via the driver's existing ctrl_err() macro when
pci_hp_add_bridge() fails, identifying the device involved.
Signed-off-by: Fahmy Hassan <fahmymohammed@gmail.com>
---
drivers/pci/hotplug/pciehp_pci.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/pci/hotplug/pciehp_pci.c b/drivers/pci/hotplug/pciehp_pci.c
index 65e50bee1a8c..cbdfde557f3b 100644
--- a/drivers/pci/hotplug/pciehp_pci.c
+++ b/drivers/pci/hotplug/pciehp_pci.c
@@ -59,7 +59,8 @@ int pciehp_configure_device(struct controller *ctrl)
}
for_each_pci_bridge(dev, parent)
- pci_hp_add_bridge(dev);
+ if (pci_hp_add_bridge(dev))
+ ctrl_err(ctrl, "pci_hp_add_bridge(%s) failed\n", pci_name(dev));
pci_assign_unassigned_bridge_resources(bridge);
pcie_bus_configure_settings(parent);
--
2.53.0
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH v2 4/5] PCI: pciehp: Check pci_hp_add_bridge() return value
2026-09-09 2:22 ` [PATCH v2 4/5] PCI: pciehp: " Fahmy Hassan
@ 2026-09-09 6:42 ` Lukas Wunner
0 siblings, 0 replies; 10+ messages in thread
From: Lukas Wunner @ 2026-09-09 6:42 UTC (permalink / raw)
To: Fahmy Hassan; +Cc: helgaas, bhelgaas, scott, kees, linux-kernel, linux-pci
On Tue, Sep 08, 2026 at 08:22:25PM -0600, Fahmy Hassan wrote:
> pciehp_configure_device() calls pci_hp_add_bridge() for each bridge on
> the newly added slot without checking its return value.
> pci_hp_add_bridge() already logs an error for one failure path (no
> bus number available for the hot-added bridge), but returns silently
> if the bridge's subordinate bus isn't created after scanning -- that
> path goes completely unreported, and either way the caller currently
> has no way to notice or react to the failure.
>
> Log an error via the driver's existing ctrl_err() macro when
> pci_hp_add_bridge() fails, identifying the device involved.
The only change here is to log something on error. That can be done
in pci_hp_add_bridge() itself without having to amend every caller.
However pci_hp_add_bridge() already logs an error for the one failure
case that merits an error message.
The return value is normally evaluated to do something, such as
bailing out or unwinding some earlier actions. But in this case,
I'm not seeing a need to do that.
So I believe this change isn't necessary, at least as far as pciehp
is concerned.
Thanks,
Lukas
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v2 5/5] PCI: shpchp: Check pci_hp_add_bridge() return value
2026-09-09 2:22 ` [PATCH v2 0/5] PCI: hotplug: " Fahmy Hassan
` (3 preceding siblings ...)
2026-09-09 2:22 ` [PATCH v2 4/5] PCI: pciehp: " Fahmy Hassan
@ 2026-09-09 2:22 ` Fahmy Hassan
4 siblings, 0 replies; 10+ messages in thread
From: Fahmy Hassan @ 2026-09-09 2:22 UTC (permalink / raw)
To: helgaas, bhelgaas, scott; +Cc: fahmymohammed, kees, linux-kernel, linux-pci
shpchp_configure_device() calls pci_hp_add_bridge() for each bridge on
the newly added slot without checking its return value.
pci_hp_add_bridge() already logs an error for one failure path (no
bus number available for the hot-added bridge), but returns silently
if the bridge's subordinate bus isn't created after scanning -- that
path goes completely unreported, and either way the caller currently
has no way to notice or react to the failure.
Log an error via the driver's existing ctrl_err() macro when
pci_hp_add_bridge() fails, identifying the device involved.
Signed-off-by: Fahmy Hassan <fahmymohammed@gmail.com>
---
drivers/pci/hotplug/shpchp_pci.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/pci/hotplug/shpchp_pci.c b/drivers/pci/hotplug/shpchp_pci.c
index 36db0c3c4ea6..b9b18879b8ab 100644
--- a/drivers/pci/hotplug/shpchp_pci.c
+++ b/drivers/pci/hotplug/shpchp_pci.c
@@ -48,8 +48,9 @@ int shpchp_configure_device(struct slot *p_slot)
}
for_each_pci_bridge(dev, parent) {
- if (PCI_SLOT(dev->devfn) == p_slot->device)
- pci_hp_add_bridge(dev);
+ if (PCI_SLOT(dev->devfn) == p_slot->device &&
+ pci_hp_add_bridge(dev))
+ ctrl_err(ctrl, "pci_hp_add_bridge(%s) failed\n", pci_name(dev));
}
pci_assign_unassigned_bridge_resources(bridge);
--
2.53.0
^ permalink raw reply [flat|nested] 10+ messages in thread