Skip to content

Commit 0328947

Browse files
Mani-Sadhasivamkwilczynski
authored andcommitted
PCI: endpoint: Assign PCI domain number for endpoint controllers
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. Link: https://lore.kernel.org/linux-pci/[email protected] Signed-off-by: Manivannan Sadhasivam <[email protected]> Signed-off-by: Krzysztof Wilczyński <[email protected]> Reviewed-by: Frank Li <[email protected]>
1 parent ada94d0 commit 0328947

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

drivers/pci/endpoint/pci-epc-core.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -838,6 +838,10 @@ void pci_epc_destroy(struct pci_epc *epc)
838838
{
839839
pci_ep_cfs_remove_epc_group(epc->group);
840840
device_unregister(&epc->dev);
841+
842+
#ifdef CONFIG_PCI_DOMAINS_GENERIC
843+
pci_bus_release_domain_nr(NULL, &epc->dev);
844+
#endif
841845
}
842846
EXPORT_SYMBOL_GPL(pci_epc_destroy);
843847

@@ -900,6 +904,16 @@ __pci_epc_create(struct device *dev, const struct pci_epc_ops *ops,
900904
epc->dev.release = pci_epc_release;
901905
epc->ops = ops;
902906

907+
#ifdef CONFIG_PCI_DOMAINS_GENERIC
908+
epc->domain_nr = pci_bus_find_domain_nr(NULL, dev);
909+
#else
910+
/*
911+
* TODO: If the architecture doesn't support generic PCI
912+
* domains, then a custom implementation has to be used.
913+
*/
914+
WARN_ONCE(1, "This architecture doesn't support generic PCI domains\n");
915+
#endif
916+
903917
ret = dev_set_name(&epc->dev, "%s", dev_name(dev));
904918
if (ret)
905919
goto put_dev;

include/linux/pci-epc.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ struct pci_epc_mem {
128128
* @group: configfs group representing the PCI EPC device
129129
* @lock: mutex to protect pci_epc ops
130130
* @function_num_map: bitmap to manage physical function number
131+
* @domain_nr: PCI domain number of the endpoint controller
131132
* @init_complete: flag to indicate whether the EPC initialization is complete
132133
* or not
133134
*/
@@ -145,6 +146,7 @@ struct pci_epc {
145146
/* mutex to protect against concurrent access of EP controller */
146147
struct mutex lock;
147148
unsigned long function_num_map;
149+
int domain_nr;
148150
bool init_complete;
149151
};
150152

0 commit comments

Comments
 (0)