From nobody Fri Oct 24 10:08:18 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3F378C00140 for ; Mon, 15 Aug 2022 23:01:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352978AbiHOXBr (ORCPT ); Mon, 15 Aug 2022 19:01:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352507AbiHOW6f (ORCPT ); Mon, 15 Aug 2022 18:58:35 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C10C2753A7; Mon, 15 Aug 2022 12:56:53 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 60F536068D; Mon, 15 Aug 2022 19:56:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5FC11C433C1; Mon, 15 Aug 2022 19:56:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660593412; bh=KmOHx/U+CI3H4Ml+/HVt3af5XMOhhlGluF+L0ZQQOOs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2pCp8FMGK/MeI4LJ4M1prcGB5FVBs5X2WPwssmxJfV2hhHWtvMgY8ZATvBjjntzLu Rz9o+F6pYqqso+UgOhpTd+wmvugBKyiDOyHW8xcsGOzgj3IR6G7L6rMe9X9hD0rxrD U7+uZ9MD63dEdGLIZY6B6ikc7qCG3OgxcdKMBSgU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Pali=20Roh=C3=A1r?= , Michael Ellerman , Sasha Levin Subject: [PATCH 5.18 0942/1095] powerpc/pci: Fix PHB numbering when using opal-phbid Date: Mon, 15 Aug 2022 20:05:41 +0200 Message-Id: <20220815180508.152502580@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Michael Ellerman [ Upstream commit f4b39e88b42d13366b831270306326b5c20971ca ] 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 =3D=3D 0. But then the if (ret >=3D 0) is true, and the body of that if statement sets prop =3D ret which throws away the value that was just read from "ibm,opal-phbid". Fix the logic by only doing the ret >=3D 0 check in the of_alias_get_id() case. Fixes: 0fe1e96fef0a ("powerpc/pci: Prefer PCI domain assignment via DT 'lin= ux,pci-domain' and alias") Reviewed-by: Pali Roh=C3=A1r Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/20220802105723.1055178-1-mpe@ellerman.id.au Signed-off-by: Sasha Levin --- arch/powerpc/kernel/pci-common.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-com= mon.c index 7daa00f3942e..aa37faeb80ee 100644 --- a/arch/powerpc/kernel/pci-common.c +++ b/arch/powerpc/kernel/pci-common.c @@ -90,11 +90,13 @@ static int get_phb_number(struct device_node *dn) } if (ret) ret =3D of_property_read_u64(dn, "ibm,opal-phbid", &prop); - if (ret) + + if (ret) { ret =3D of_alias_get_id(dn, "pci"); - if (ret >=3D 0) { - prop =3D ret; - ret =3D 0; + if (ret >=3D 0) { + prop =3D ret; + ret =3D 0; + } } if (ret) { u32 prop_32; --=20 2.35.1