Skip to content

Commit 0fe1e96

Browse files
palimpe
authored andcommitted
powerpc/pci: Prefer PCI domain assignment via DT 'linux,pci-domain' and alias
Other Linux architectures use DT property 'linux,pci-domain' for specifying fixed PCI domain of PCI controller specified in Device-Tree. And lot of Freescale powerpc boards have defined numbered pci alias in Device-Tree for every PCIe controller which number specify preferred PCI domain. So prefer usage of DT property 'linux,pci-domain' (via function of_get_pci_domain_nr()) and DT pci alias (via function of_alias_get_id()) on powerpc architecture for assigning PCI domain to PCI controller. Fixes: 63a7228 ("powerpc/pci: Assign fixed PHB number based on device-tree properties") Signed-off-by: Pali Rohár <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent d20c96d commit 0fe1e96

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

arch/powerpc/kernel/pci-common.c

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,30 @@ void __init set_pci_dma_ops(const struct dma_map_ops *dma_ops)
7575
static int get_phb_number(struct device_node *dn)
7676
{
7777
int ret, phb_id = -1;
78-
u32 prop_32;
7978
u64 prop;
8079

8180
/*
8281
* Try fixed PHB numbering first, by checking archs and reading
83-
* the respective device-tree properties. Firstly, try powernv by
84-
* reading "ibm,opal-phbid", only present in OPAL environment.
82+
* the respective device-tree properties. Firstly, try reading
83+
* standard "linux,pci-domain", then try reading "ibm,opal-phbid"
84+
* (only present in powernv OPAL environment), then try device-tree
85+
* alias and as the last try to use lower bits of "reg" property.
8586
*/
86-
ret = of_property_read_u64(dn, "ibm,opal-phbid", &prop);
87+
ret = of_get_pci_domain_nr(dn);
88+
if (ret >= 0) {
89+
prop = ret;
90+
ret = 0;
91+
}
92+
if (ret)
93+
ret = of_property_read_u64(dn, "ibm,opal-phbid", &prop);
94+
if (ret)
95+
ret = of_alias_get_id(dn, "pci");
96+
if (ret >= 0) {
97+
prop = ret;
98+
ret = 0;
99+
}
87100
if (ret) {
101+
u32 prop_32;
88102
ret = of_property_read_u32_index(dn, "reg", 1, &prop_32);
89103
prop = prop_32;
90104
}
@@ -96,10 +110,7 @@ static int get_phb_number(struct device_node *dn)
96110
if ((phb_id >= 0) && !test_and_set_bit(phb_id, phb_bitmap))
97111
return phb_id;
98112

99-
/*
100-
* If not pseries nor powernv, or if fixed PHB numbering tried to add
101-
* the same PHB number twice, then fallback to dynamic PHB numbering.
102-
*/
113+
/* If everything fails then fallback to dynamic PHB numbering. */
103114
phb_id = find_first_zero_bit(phb_bitmap, MAX_PHBS);
104115
BUG_ON(phb_id >= MAX_PHBS);
105116
set_bit(phb_id, phb_bitmap);

0 commit comments

Comments
 (0)