Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3409922rwa; Tue, 23 Aug 2022 04:25:47 -0700 (PDT) X-Google-Smtp-Source: AA6agR4yf6rynrjnDlLT/iXrf55IWuplfh12Qvg2AjkYiV023DPrQs9LTGoooc5EYZJY0VDLE/hb X-Received: by 2002:a17:90b:380f:b0:1fb:3286:79b0 with SMTP id mq15-20020a17090b380f00b001fb328679b0mr2881829pjb.170.1661253947523; Tue, 23 Aug 2022 04:25:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661253947; cv=none; d=google.com; s=arc-20160816; b=ZA0VD9bf6qrKO9ewVBuig5chXz3lPnyjKIOdaGPkjnFZXZ66GX8HKeTufLpRci7NLj 7MolJLEpRBduRLXEWMGnUeRI0L9OLr7FNyJDBZ7s75ybV9NDVb3zu+lrHGNdpHV7HvZX 6OWtV22MrwMR1ndWnt7HQnu0iHuA38ftWNnaa5lsNyp+qzZpJZWX7+M0Jsk/AKkaDCG+ ycCtmTZKbhHxOv/7F5lWqgKWpG8Uh8lHncgGxzn3V0kSxBLwTeiqagi6kc7sMhDxZv8G WNFOpanUz5/JhG+ktM2hKHJ3NBv3IIRp6iUTeAHpaQ1sX+bdpnaXvqtBrJDQRi3tRIba 2FVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=MU6qEGYBWzlm/FqCdqfuAxiUkO2boI+WXvNvbA3Os2E=; b=Xu+mC9sjdp/U9Qc/kjoSW30Kz7PXTK7d56zV/enHXh0lIIlBUnas2ilkwUxaTl2iza GPAhAX3NSVyd5thcOH45pSkBxjzqCj52Pfuek6hLK78IjHuVJaXtcH796UIAsdEL4B6Q bIue+JxPfFPzgOVmQhXZ/01bSSdHBpiasjariFnf+OfLEUmFuI15RBl5A2TPmHlxFlFe mkI2wtqyfZucqyZuMlGbFml89Lzq5UoQoq78xdWH6EJh/tL5mMrJG8N7qTaiALpeDsyG lK1XQ/E2wrkxyEBRC7oJU1e9Ww5MRwGMUUrnrj6Cix0lipN2Pft00kX/XYmTtPM79GUg xBaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=OP8SxbLd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cp8-20020a056a00348800b005184183372csi14061629pfb.350.2022.08.23.04.25.36; Tue, 23 Aug 2022 04:25:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=OP8SxbLd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348590AbiHWKDl (ORCPT + 99 others); Tue, 23 Aug 2022 06:03:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243699AbiHWJ56 (ORCPT ); Tue, 23 Aug 2022 05:57:58 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E75CEA1D1E; Tue, 23 Aug 2022 01:47:47 -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 ams.source.kernel.org (Postfix) with ESMTPS id 6191AB81C3B; Tue, 23 Aug 2022 08:47:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A09D7C433D7; Tue, 23 Aug 2022 08:47:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661244466; bh=cGv9YYiCAnF/hXVtpd8NFHpulmJj4WgT2Ko+E71vVug=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OP8SxbLdDrD5qcxJT8qXnaJQyhxyQ/UayEBZi5fMwoGZF+IohwWczYNN7ZWHtmyFq f0aIts7KgSZfesKZFkf9/+eayiGqKCThxL1RbvrxRkxUWqWklskI/Cw2Yc+03/1+TX b5sTZPKfkS12M+30Xmeu2YdpShxlnRbngZHKJIVQ= 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 4.14 141/229] powerpc/pci: Fix PHB numbering when using opal-phbid Date: Tue, 23 Aug 2022 10:25:02 +0200 Message-Id: <20220823080058.719989060@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080053.202747790@linuxfoundation.org> References: <20220823080053.202747790@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 == 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: 0fe1e96fef0a ("powerpc/pci: Prefer PCI domain assignment via DT 'linux,pci-domain' and alias") Reviewed-by: Pali Rohár 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-common.c index 2e2cc80bf592..936f24d7ab4c 100644 --- a/arch/powerpc/kernel/pci-common.c +++ b/arch/powerpc/kernel/pci-common.c @@ -96,11 +96,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; -- 2.35.1