* [PATCH] error path improvement in dlpar add
@ 2026-01-27 2:18 wenxiong
2026-01-27 10:29 ` kernel test robot
2026-01-27 10:53 ` kernel test robot
0 siblings, 2 replies; 3+ messages in thread
From: wenxiong @ 2026-01-27 2:18 UTC (permalink / raw)
To: linuxppc-dev; +Cc: maddy, haren, tyreld, Wen Xiong
From: Wen Xiong <wenxiong@linux.ibm.com>
When doing a dlpar adding a device back, expect not loading device driver
if claiming pci resource failed.
Validating PHB DLPAR capability...yes.
[ 4928.798012] pci_bus 0187:c0: root bus resource [bus c0-ff]
[ 4928.798038] pci 0187:c0:00.0: No hypervisor support for SR-IOV on this device, IOV BARs disabled.
[ 4928.815867] pci 0187:c0:00.0: BAR 0 [mem 0xb0020000-0xb0027fff 64bit]: can't claim; no compatible bridge window
---> Expect to exit if claiming resources fails(BAR0)
[ 4928.815899] pci 0187:c0:00.0: ROM [mem 0xb0000000-0xb001ffff]: can't claim; no compatible bridge window
--->Expect to exit if claiming resources fails(ROM), don't load device
driver anymore, showed "dlpar add failed"
[ 4928.815913] pci 0187:c0:00.0: ROM [mem 0x40000000000-0x4000001ffff]: assigned
[ 4928.815923] pci 0187:c0:00.0: BAR 0 [mem 0x40800000000-0x40800007fff 64bit]: assigned
[ 4928.816220] pci 0187:c0:00.0: BAR 0: error updating (0x00000004 != 0xffffffff)
[ 4928.816364] pci 0187:c0:00.0: BAR 0: error updating (high 0x00060238 != 0xffffffff)
[ 4928.816839] pci 0187:c0:00.0: ibm,query-pe-dma-windows(53) b00000 8000000 20000187 returned -3, lb=0 ps=0 wn=0
[ 4928.816855] pci 0187:c0:00.0: spapr_tce_init_table_group: query_ddw failed
[ 4928.816871] pci 0187:c0:00.0: Adding to iommu group 1
[ 4928.816952] pci 0187:c0:00.0: of_irq_parse_pci: no interrupt-map found, INTx interrupts not available
[ 4928.818135] nvme 0187:c0:00.0: ibm,query-pe-dma-windows(53) b00000 8000000 20000187 returned -3, lb=0 ps=0 wn=0
[ 4928.818284] nvme nvme1: pci function 0187:c0:00.0
[ 4928.819321] rpaphp: Slot [U78DB.ND0.WZS08E2-P1-C7] registered
[ 4928.819338] rpadlpar_io: slot PHB 391 added
With adding error path checking, didn't load the device driver anymore
if claiming resources failed.
Validating PHB DLPAR capability...yes.
[ 260.414453] PCI host bridge /pci@800000020000187 ranges:
[ 260.414473] MEM 0x0000040000000000..0x0000040007ffffff -> 0x00000000b8000000
[ 260.414480] MEM 0x0000040800000000..0x0000040fffffffff -> 0x0006023800000000
[ 260.414915] PCI host bridge to bus 0187:c0
[ 260.414922] pci_bus 0187:c0: root bus resource [mem 0x40000000000-0x40007ffffff] (bus address [0xb8000000-0xbfffffff])
[ 260.414929] pci_bus 0187:c0: root bus resource [mem 0x40800000000-0x40fffffffff 64bit] (bus address [0x6023800000000-0x6023fffffffff])
[ 260.414936] pci_bus 0187:c0: root bus resource [bus c0-ff]
[ 260.414948] pci 0187:c0:00.0: No hypervisor support for SR-IOV on this device, IOV BARs disabled.
[ 260.423439] pci 0187:c0:00.0: BAR 0 [mem 0xb0020000-0xb0027fff 64bit]: can't claim; no compatible bridge window
[ 260.423463] after pci_cliam_Resource=-22 ----> pci_claim_resources fails.
[ 260.423471] rpadlpar_io: slot PHB 391 added failed rc=-5 -----> added failed.
Signed-off-by: Wen Xiong <wenxiong@linux.ibm.com>
Reviewed-by: Haren Myneni <haren@linux.ibm.com>
Reviewed-by: Tyrel Datwyler <tyreld@linux.ibm.com>
---
arch/powerpc/include/asm/pci.h | 4 ++--
arch/powerpc/kernel/pci-common.c | 23 +++++++++++++++++-----
arch/powerpc/kernel/pci-hotplug.c | 5 ++++-
arch/powerpc/platforms/pseries/pci_dlpar.c | 3 ++-
drivers/pci/hotplug/rpadlpar_core.c | 7 ++++++-
5 files changed, 32 insertions(+), 10 deletions(-)
diff --git a/arch/powerpc/include/asm/pci.h b/arch/powerpc/include/asm/pci.h
index 46a9c4491ed0..ebeb912a92bf 100644
--- a/arch/powerpc/include/asm/pci.h
+++ b/arch/powerpc/include/asm/pci.h
@@ -86,9 +86,9 @@ extern void pci_adjust_legacy_attr(struct pci_bus *bus,
enum pci_mmap_state mmap_type);
#define HAVE_PCI_LEGACY 1
-extern void pcibios_claim_one_bus(struct pci_bus *b);
+extern int pcibios_claim_one_bus(struct pci_bus *b);
-extern void pcibios_finish_adding_to_bus(struct pci_bus *bus);
+extern int pcibios_finish_adding_to_bus(struct pci_bus *bus);
extern void pcibios_resource_survey(void);
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index eac84d687b53..b16f43c7f02e 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -1446,10 +1446,11 @@ void __init pcibios_resource_survey(void)
* rest of the code later, for now, keep it as-is as our main
* resource allocation function doesn't deal with sub-trees yet.
*/
-void pcibios_claim_one_bus(struct pci_bus *bus)
+int pcibios_claim_one_bus(struct pci_bus *bus)
{
struct pci_dev *dev;
struct pci_bus *child_bus;
+ int ret = 0;
list_for_each_entry(dev, &bus->devices, bus_list) {
struct resource *r;
@@ -1462,15 +1463,20 @@ void pcibios_claim_one_bus(struct pci_bus *bus)
pr_debug("PCI: Claiming %s: Resource %d: %pR\n",
pci_name(dev), i, r);
- if (pci_claim_resource(dev, i) == 0)
+ ret = pci_claim_resource(dev, i);
+ if (ret == 0)
continue;
+ else
+ return ret;
pci_claim_bridge_resource(dev, i);
}
}
list_for_each_entry(child_bus, &bus->children, node)
- pcibios_claim_one_bus(child_bus);
+ ret = pcibios_claim_one_bus(child_bus);
+
+ return ret;
}
EXPORT_SYMBOL_GPL(pcibios_claim_one_bus);
@@ -1481,14 +1487,19 @@ EXPORT_SYMBOL_GPL(pcibios_claim_one_bus);
* added to a bus, this include calling it for a PHB that is just
* being added
*/
-void pcibios_finish_adding_to_bus(struct pci_bus *bus)
+int pcibios_finish_adding_to_bus(struct pci_bus *bus)
{
+ int ret = 0;
+
pr_debug("PCI: Finishing adding to hotplug bus %04x:%02x\n",
pci_domain_nr(bus), bus->number);
/* Allocate bus and devices resources */
pcibios_allocate_bus_resources(bus);
- pcibios_claim_one_bus(bus);
+ ret = pcibios_claim_one_bus(bus);
+ if (ret)
+ return ret;
+
if (!pci_has_flag(PCI_PROBE_ONLY)) {
if (bus->self)
pci_assign_unassigned_bridge_resources(bus->self);
@@ -1498,6 +1509,8 @@ void pcibios_finish_adding_to_bus(struct pci_bus *bus)
/* Add new devices to global lists. Register in proc, sysfs. */
pci_bus_add_devices(bus);
+
+ return ret;
}
EXPORT_SYMBOL_GPL(pcibios_finish_adding_to_bus);
diff --git a/arch/powerpc/kernel/pci-hotplug.c b/arch/powerpc/kernel/pci-hotplug.c
index 6f444d0822d8..133ce03fdd82 100644
--- a/arch/powerpc/kernel/pci-hotplug.c
+++ b/arch/powerpc/kernel/pci-hotplug.c
@@ -140,6 +140,7 @@ void pci_hp_add_devices(struct pci_bus *bus)
struct pci_dev *dev;
struct pci_controller *phb;
struct device_node *dn = pci_bus_to_OF_node(bus);
+ int ret = 0;
if (!dn)
return;
@@ -176,6 +177,8 @@ void pci_hp_add_devices(struct pci_bus *bus)
for_each_pci_bridge(dev, bus)
max = pci_scan_bridge(bus, dev, max, 1);
}
- pcibios_finish_adding_to_bus(bus);
+ ret = pcibios_finish_adding_to_bus(bus);
+ if (ret)
+ pr_err("%s: unable to add hotplug pci device!\n");
}
EXPORT_SYMBOL_GPL(pci_hp_add_devices);
diff --git a/arch/powerpc/platforms/pseries/pci_dlpar.c b/arch/powerpc/platforms/pseries/pci_dlpar.c
index 8c77ec7980de..2b78faba40f6 100644
--- a/arch/powerpc/platforms/pseries/pci_dlpar.c
+++ b/arch/powerpc/platforms/pseries/pci_dlpar.c
@@ -58,7 +58,8 @@ struct pci_controller *init_phb_dynamic(struct device_node *dn)
pseries_eeh_init_edev_recursive(PCI_DN(dn));
pcibios_scan_phb(phb);
- pcibios_finish_adding_to_bus(phb->bus);
+ if (pcibios_finish_adding_to_bus(phb->bus))
+ return NULL;
return phb;
}
diff --git a/drivers/pci/hotplug/rpadlpar_core.c b/drivers/pci/hotplug/rpadlpar_core.c
index 980bb3afd092..4c507dd04fa1 100644
--- a/drivers/pci/hotplug/rpadlpar_core.c
+++ b/drivers/pci/hotplug/rpadlpar_core.c
@@ -240,8 +240,10 @@ static int dlpar_add_phb(char *drc_name, struct device_node *dn)
}
phb = init_phb_dynamic(dn);
- if (!phb)
+ if (!phb) {
+ pr_err("%s: unable to add hotplug slot %s\n", drc_name);
return -EIO;
+ }
if (rpaphp_add_slot(dn)) {
printk(KERN_ERR "%s: unable to add hotplug slot %s\n",
@@ -311,6 +313,9 @@ int dlpar_add_slot(char *drc_name)
}
of_node_put(dn);
+ if (rc)
+ goto exit;
+
printk(KERN_INFO "%s: slot %s added\n", DLPAR_MODULE_NAME, drc_name);
exit:
mutex_unlock(&rpadlpar_mutex);
--
2.47.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] error path improvement in dlpar add
2026-01-27 2:18 [PATCH] error path improvement in dlpar add wenxiong
@ 2026-01-27 10:29 ` kernel test robot
2026-01-27 10:53 ` kernel test robot
1 sibling, 0 replies; 3+ messages in thread
From: kernel test robot @ 2026-01-27 10:29 UTC (permalink / raw)
To: wenxiong, linuxppc-dev; +Cc: oe-kbuild-all, maddy, haren, tyreld, Wen Xiong
Hi,
kernel test robot noticed the following build warnings:
[auto build test WARNING on powerpc/next]
[also build test WARNING on powerpc/fixes linus/master v6.19-rc7 next-20260126]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/wenxiong-linux-ibm-com/error-path-improvement-in-dlpar-add/20260127-121714
base: https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next
patch link: https://lore.kernel.org/r/20260127021845.2326-1-wenxiong%40linux.ibm.com
patch subject: [PATCH] error path improvement in dlpar add
config: powerpc-allmodconfig (https://download.01.org/0day-ci/archive/20260127/202601271847.dv1oYfPw-lkp@intel.com/config)
compiler: powerpc64-linux-gcc (GCC) 15.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260127/202601271847.dv1oYfPw-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202601271847.dv1oYfPw-lkp@intel.com/
All warnings (new ones prefixed by >>):
In file included from include/asm-generic/bug.h:31,
from arch/powerpc/include/asm/bug.h:116,
from include/linux/bug.h:5,
from include/linux/fortify-string.h:6,
from include/linux/string.h:386,
from include/linux/uuid.h:11,
from include/linux/mod_devicetable.h:14,
from include/linux/pci.h:27,
from arch/powerpc/kernel/pci-hotplug.c:13:
arch/powerpc/kernel/pci-hotplug.c: In function 'pci_hp_add_devices':
>> include/linux/kern_levels.h:5:25: warning: format '%s' expects a matching 'char *' argument [-Wformat=]
5 | #define KERN_SOH "\001" /* ASCII Start Of Header */
| ^~~~~~
include/linux/printk.h:484:25: note: in definition of macro 'printk_index_wrap'
484 | _p_func(_fmt, ##__VA_ARGS__); \
| ^~~~
include/linux/printk.h:555:9: note: in expansion of macro 'printk'
555 | printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
| ^~~~~~
include/linux/kern_levels.h:11:25: note: in expansion of macro 'KERN_SOH'
11 | #define KERN_ERR KERN_SOH "3" /* error conditions */
| ^~~~~~~~
include/linux/printk.h:555:16: note: in expansion of macro 'KERN_ERR'
555 | printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
| ^~~~~~~~
arch/powerpc/kernel/pci-hotplug.c:182:17: note: in expansion of macro 'pr_err'
182 | pr_err("%s: unable to add hotplug pci device!\n");
| ^~~~~~
vim +5 include/linux/kern_levels.h
314ba3520e513a Joe Perches 2012-07-30 4
04d2c8c83d0e3a Joe Perches 2012-07-30 @5 #define KERN_SOH "\001" /* ASCII Start Of Header */
04d2c8c83d0e3a Joe Perches 2012-07-30 6 #define KERN_SOH_ASCII '\001'
04d2c8c83d0e3a Joe Perches 2012-07-30 7
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] error path improvement in dlpar add
2026-01-27 2:18 [PATCH] error path improvement in dlpar add wenxiong
2026-01-27 10:29 ` kernel test robot
@ 2026-01-27 10:53 ` kernel test robot
1 sibling, 0 replies; 3+ messages in thread
From: kernel test robot @ 2026-01-27 10:53 UTC (permalink / raw)
To: wenxiong, linuxppc-dev; +Cc: oe-kbuild-all, maddy, haren, tyreld, Wen Xiong
Hi,
kernel test robot noticed the following build warnings:
[auto build test WARNING on powerpc/next]
[also build test WARNING on powerpc/fixes linus/master v6.19-rc7 next-20260126]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/wenxiong-linux-ibm-com/error-path-improvement-in-dlpar-add/20260127-121714
base: https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next
patch link: https://lore.kernel.org/r/20260127021845.2326-1-wenxiong%40linux.ibm.com
patch subject: [PATCH] error path improvement in dlpar add
config: powerpc-allyesconfig (https://download.01.org/0day-ci/archive/20260127/202601271817.2ldcFxjL-lkp@intel.com/config)
compiler: clang version 22.0.0git (https://github.com/llvm/llvm-project 9b8addffa70cee5b2acc5454712d9cf78ce45710)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260127/202601271817.2ldcFxjL-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202601271817.2ldcFxjL-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> arch/powerpc/kernel/pci-hotplug.c:182:12: warning: more '%' conversions than data arguments [-Wformat-insufficient-args]
182 | pr_err("%s: unable to add hotplug pci device!\n");
| ~^
include/linux/printk.h:555:25: note: expanded from macro 'pr_err'
555 | printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
| ^~~
include/linux/printk.h:402:21: note: expanded from macro 'pr_fmt'
402 | #define pr_fmt(fmt) fmt
| ^~~
include/linux/printk.h:512:53: note: expanded from macro 'printk'
512 | #define printk(fmt, ...) printk_index_wrap(_printk, fmt, ##__VA_ARGS__)
| ^~~
include/linux/printk.h:484:11: note: expanded from macro 'printk_index_wrap'
484 | _p_func(_fmt, ##__VA_ARGS__); \
| ^~~~
1 warning generated.
vim +182 arch/powerpc/kernel/pci-hotplug.c
125
126 /**
127 * pci_hp_add_devices - adds new pci devices to bus
128 * @bus: the indicated PCI bus
129 *
130 * This routine will find and fixup new pci devices under
131 * the indicated bus. This routine presumes that there
132 * might already be some devices under this bridge, so
133 * it carefully tries to add only new devices. (And that
134 * is how this routine differs from other, similar pcibios
135 * routines.)
136 */
137 void pci_hp_add_devices(struct pci_bus *bus)
138 {
139 int mode, max;
140 struct pci_dev *dev;
141 struct pci_controller *phb;
142 struct device_node *dn = pci_bus_to_OF_node(bus);
143 int ret = 0;
144
145 if (!dn)
146 return;
147
148 phb = pci_bus_to_host(bus);
149
150 mode = PCI_PROBE_NORMAL;
151 if (phb->controller_ops.probe_mode)
152 mode = phb->controller_ops.probe_mode(bus);
153
154 if (mode == PCI_PROBE_DEVTREE) {
155 /* use ofdt-based probe */
156 of_rescan_bus(dn, bus);
157 } else if (mode == PCI_PROBE_NORMAL &&
158 dn->child && PCI_DN(dn->child)) {
159 /*
160 * Use legacy probe. In the partial hotplug case, we
161 * probably have grandchildren devices unplugged. So
162 * we don't check the return value from pci_scan_slot() in
163 * order for fully rescan all the way down to pick them up.
164 * They can have been removed during partial hotplug.
165 */
166 traverse_siblings_and_scan_slot(dn, bus);
167 max = bus->busn_res.start;
168 /*
169 * Scan bridges that are already configured. We don't touch
170 * them unless they are misconfigured (which will be done in
171 * the second scan below).
172 */
173 for_each_pci_bridge(dev, bus)
174 max = pci_scan_bridge(bus, dev, max, 0);
175
176 /* Scan bridges that need to be reconfigured */
177 for_each_pci_bridge(dev, bus)
178 max = pci_scan_bridge(bus, dev, max, 1);
179 }
180 ret = pcibios_finish_adding_to_bus(bus);
181 if (ret)
> 182 pr_err("%s: unable to add hotplug pci device!\n");
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-01-27 10:53 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-27 2:18 [PATCH] error path improvement in dlpar add wenxiong
2026-01-27 10:29 ` kernel test robot
2026-01-27 10:53 ` kernel test robot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox