Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3ec50b8a authored by Pali Rohár's avatar Pali Rohár Committed by Greg Kroah-Hartman
Browse files

powerpc/pci: Prefer PCI domain assignment via DT 'linux,pci-domain' and alias



[ Upstream commit 0fe1e96fef0a5c53b4c0d1500d356f3906000f81 ]

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: 63a72284 ("powerpc/pci: Assign fixed PHB number based on device-tree properties")
Signed-off-by: default avatarPali Rohár <pali@kernel.org>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220706102148.5060-2-pali@kernel.org


Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 44a43b65
Loading
Loading
Loading
Loading
+19 −8
Original line number Diff line number Diff line
@@ -73,16 +73,30 @@ void set_pci_dma_ops(const struct dma_map_ops *dma_ops)
static int get_phb_number(struct device_node *dn)
{
	int ret, phb_id = -1;
	u32 prop_32;
	u64 prop;

	/*
	 * Try fixed PHB numbering first, by checking archs and reading
	 * the respective device-tree properties. Firstly, try powernv by
	 * reading "ibm,opal-phbid", only present in OPAL environment.
	 * the respective device-tree properties. Firstly, try reading
	 * standard "linux,pci-domain", then try reading "ibm,opal-phbid"
	 * (only present in powernv OPAL environment), then try device-tree
	 * alias and as the last try to use lower bits of "reg" property.
	 */
	ret = of_get_pci_domain_nr(dn);
	if (ret >= 0) {
		prop = ret;
		ret = 0;
	}
	if (ret)
		ret = of_property_read_u64(dn, "ibm,opal-phbid", &prop);
	if (ret)
		ret = of_alias_get_id(dn, "pci");
	if (ret >= 0) {
		prop = ret;
		ret = 0;
	}
	if (ret) {
		u32 prop_32;
		ret = of_property_read_u32_index(dn, "reg", 1, &prop_32);
		prop = prop_32;
	}
@@ -94,10 +108,7 @@ static int get_phb_number(struct device_node *dn)
	if ((phb_id >= 0) && !test_and_set_bit(phb_id, phb_bitmap))
		return phb_id;

	/*
	 * If not pseries nor powernv, or if fixed PHB numbering tried to add
	 * the same PHB number twice, then fallback to dynamic PHB numbering.
	 */
	/* If everything fails then fallback to dynamic PHB numbering. */
	phb_id = find_first_zero_bit(phb_bitmap, MAX_PHBS);
	BUG_ON(phb_id >= MAX_PHBS);
	set_bit(phb_id, phb_bitmap);