Thu, May 09, 2024 at 05:35:54PM +0530, Krishna Kumar kirjoitti: > There is an issue with the hotplug operation when it's done on the > bridge/switch slot. The bridge-port and devices behind the bridge, which > become offline by hot-unplug operation, don't get hot-plugged/enabled by > doing hot-plug operation on that slot. Only the first port of the bridge > gets enabled and the remaining port/devices remain unplugged. The hot > plug/unplug operation is done by the hotplug driver > (drivers/pci/hotplug/pnv_php.c). > > Root Cause Analysis: This behavior is due to missing code for the DPC > switch/bridge. The existing driver depends on pci_hp_add_devices() > function for device enablement. This function calls pci_scan_slot() on > only one device-node/port of the bridge, not on all the siblings' > device-node/port. > > The missing code needs to be added which will find all the sibling > device-nodes/bridge-ports and will run explicit pci_scan_slot() on > those. A new function has been added for this purpose which gets > invoked from pci_hp_add_devices(). This new function > pci_traverse_sibling_nodes_and_scan_slot() gets all the sibling > bridge-ports by traversal and explicitly invokes pci_scan_slot on them. > > One blank line is enough here. > Signed-off-by: Krishna Kumar <krishnak@xxxxxxxxxxxxx> ... > +void *pci_traverse_sibling_nodes_and_scan_slot(struct device_node *start, struct pci_bus *bus) > +{ > + struct device_node *dn; > + struct device_node *parent; > + int slotno; > + > + const __be32 *classp1; > + u32 class1 = 0; > + classp1 = of_get_property(start->child, "class-code", NULL); > + if (classp1) > + class1 = of_read_number(classp1, 1); What's wrong with of_property_read_u32()? > + /* Call of pci_scan_slot for non-bridge/EP case */ > + if (!((class1 >> 8) == PCI_CLASS_BRIDGE_PCI)) { > + slotno = PCI_SLOT(PCI_DN(start->child)->devfn); > + pci_scan_slot(bus, PCI_DEVFN(slotno, 0)); > + return NULL; > + } > + > + /* Iterate all siblings */ > + parent = start; > + for_each_child_of_node(parent, dn) { > + const __be32 *classp; > + u32 class = 0; > + > + classp = of_get_property(dn, "class-code", NULL); > + if (classp) > + class = of_read_number(classp, 1); Ditto. > + /* Call of pci_scan_slot on each sibling-nodes/bridge-ports */ > + if ((class >> 8) == PCI_CLASS_BRIDGE_PCI) { > + slotno = PCI_SLOT(PCI_DN(dn)->devfn); > + pci_scan_slot(bus, PCI_DEVFN(slotno, 0)); > + } > + } > + > + return NULL; > +} -- With Best Regards, Andy Shevchenko