]> git.baikalelectronics.ru Git - kernel.git/commitdiff
powerpc/pci: Fix PHB numbering when using opal-phbid
authorMichael Ellerman <mpe@ellerman.id.au>
Tue, 2 Aug 2022 10:38:32 +0000 (20:38 +1000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 17 Aug 2022 12:24:14 +0000 (14:24 +0200)
[ Upstream commit 664ad96097fcc83cc881c712d94210c4a3004e83 ]

The recent change to the PHB numbering logic has a logic error in the
handling of "ibm,opal-phbid".

When an "ibm,opal-phbid" property is present, &prop is written to and
ret is set to zero.

The following call to of_alias_get_id() is skipped because ret == 0.

But then the if (ret >= 0) is true, and the body of that if statement
sets prop = ret which throws away the value that was just read from
"ibm,opal-phbid".

Fix the logic by only doing the ret >= 0 check in the of_alias_get_id()
case.

Fixes: b614cf23313a ("powerpc/pci: Prefer PCI domain assignment via DT 'linux,pci-domain' and alias")
Reviewed-by: Pali Rohár <pali@kernel.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220802105723.1055178-1-mpe@ellerman.id.au
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/powerpc/kernel/pci-common.c

index 08eea633c380745d28c5b031295f8396ac7285f0..fc5187c6559a16655db47a1a2f156f88a516f43f 100644 (file)
@@ -90,11 +90,13 @@ static int get_phb_number(struct device_node *dn)
        }
        if (ret)
                ret = of_property_read_u64(dn, "ibm,opal-phbid", &prop);
-       if (ret)
+
+       if (ret) {
                ret = of_alias_get_id(dn, "pci");
-       if (ret >= 0) {
-               prop = ret;
-               ret = 0;
+               if (ret >= 0) {
+                       prop = ret;
+                       ret = 0;
+               }
        }
        if (ret) {
                u32 prop_32;