On 17.07.2024 7:03 PM, Manivannan Sadhasivam via B4 Relay wrote: > From: Manivannan Sadhasivam <manivannan.sadhasivam@xxxxxxxxxx> > > Right now, PCI endpoint subsystem doesn't assign PCI domain number for the > PCI endpoint controllers. But this domain number could be useful to the EPC > drivers to uniquely identify each controller based on the hardware instance > when there are multiple ones present in an SoC (even multiple RC/EP). > > So let's make use of the existing pci_bus_find_domain_nr() API to allocate > domain numbers based on either Devicetree (linux,pci-domain) property or > dynamic domain number allocation scheme. > > It should be noted that the domain number allocated by this API will be > based on both RC and EP controllers in a SoC. If the 'linux,pci-domain' DT > property is present, then the domain number represents the actual hardware > instance of the PCI endpoint controller. If not, then the domain number > will be allocated based on the PCI EP/RC controller probe order. > > If the architecture doesn't support CONFIG_PCI_DOMAINS_GENERIC (rare), then > currently a warning is thrown to indicate that the architecture specific > implementation is needed. > > Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@xxxxxxxxxx> > --- > drivers/pci/endpoint/pci-epc-core.c | 10 ++++++++++ > include/linux/pci-epc.h | 2 ++ > 2 files changed, 12 insertions(+) > > diff --git a/drivers/pci/endpoint/pci-epc-core.c b/drivers/pci/endpoint/pci-epc-core.c > index 84309dfe0c68..7fa81b91e762 100644 > --- a/drivers/pci/endpoint/pci-epc-core.c > +++ b/drivers/pci/endpoint/pci-epc-core.c > @@ -838,6 +838,9 @@ void pci_epc_destroy(struct pci_epc *epc) > { > pci_ep_cfs_remove_epc_group(epc->group); > device_unregister(&epc->dev); > + > + if (IS_ENABLED(CONFIG_PCI_DOMAINS_GENERIC)) > + pci_bus_release_domain_nr(NULL, &epc->dev); Shouldn't this be called before device_unregister? pci/remove.c does that (via pci_remove_bus() in pci_remove_root_bus()) Konrad