Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3412437rwa; Tue, 23 Aug 2022 04:28:39 -0700 (PDT) X-Google-Smtp-Source: AA6agR4WtI21IeX0Whhl1FufTqyzSC9mBuM9xTlaG3FRoDQuRFkAw+8+xF+ExP/8ErpcKoqBIACC X-Received: by 2002:a17:907:d07:b0:72e:ec79:ad0f with SMTP id gn7-20020a1709070d0700b0072eec79ad0fmr16386350ejc.296.1661254119459; Tue, 23 Aug 2022 04:28:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661254119; cv=none; d=google.com; s=arc-20160816; b=ai36azU4AZZb1omjkHDT6Jip5uOr4lC0acEICV8+0oEI0AQIR1YSzK6gB3OMkvPsLB QSqlQ5uhhQKYBDUMN+UjM2auEI7//PJoN88RmjdsHiK7g5w3yYSSvki4bM5sGYt4xjyt ntGs20Eq8MtEBRnrmG9vWBvVNBfQMau8zzMxzsi05SuNmNI+eXAy4G6RReZwfA0Rw/9a ZK9IgTUDto2s5dRyQNVscgQZZQ0jmCFbuYE0CuN/mCY/SlnuMZz6DrDmK0KN3EL5PdiG snOvhpLHWlPI0Al9I/tNx4XSwIpQA2xhXGEoyrph3XIc9e4ZCpbTVcRjecbxMQnvWKGi jBaQ== 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=WsWez/T2GntHYA8H8SFIHbRdCmzAB7HQc0cOdjvjY8g=; b=ddrKtYKiPHQrkPEEBd/OEU44LfLBiE75+qbb4eDOuMZrzIHtOOr+lQcRGhZaseiVYv 7eOj6o3YCV+1Je0zm8eEVkt1F7ErNo75ne3FnscqLxwp8vkuc1576kVOECk0b5Vmqc+v TxmTWbWYSCaezfurypLEsSmUhdXdcKRYo3MH8acda5G51kpA3mei5F8nl5wMfTqwjRks n5wrh9e1YKU2X1zRo8Cw9QL3MYOCizHH8ircmVTMQeYCQXq/56KksuU4dmnp5Hn2LZsf JIaJ3Ru3piKp9zdBzrWiRgNd/yKFKd/2gXp++wlumkav8RiKvRr065Yspm2H81Z6BUoj rXZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="RMqj3/w6"; 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 dd15-20020a1709069b8f00b00734804bb362si331400ejc.568.2022.08.23.04.28.13; Tue, 23 Aug 2022 04:28:39 -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="RMqj3/w6"; 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 S1356968AbiHWKws (ORCPT + 99 others); Tue, 23 Aug 2022 06:52:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355859AbiHWKo7 (ORCPT ); Tue, 23 Aug 2022 06:44:59 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8F5047B81; Tue, 23 Aug 2022 02:10: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 45CF5608D5; Tue, 23 Aug 2022 09:10:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4D9A7C433D6; Tue, 23 Aug 2022 09:10:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661245852; bh=qvYNxEp4BkVpp0o3cY2gldmCMqgQYuRgKAATdhdUjZU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RMqj3/w6douiztT7LCD7bc+yrbQcJ7fXJkMC4uX+1U8evJiSNbHTju0ppgh5QT5hN q0hvGyK8k/7Tlmu3Va7kMOhg/YkxAaryqJOKb+mKxB38svc5C8js7jUg6Kze831fpU aXPfgQ/AphvduuzUPjnew63eVLXMoOgxLkfkT1ts= 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.19 170/287] powerpc/pci: Prefer PCI domain assignment via DT linux,pci-domain and alias Date: Tue, 23 Aug 2022 10:25:39 +0200 Message-Id: <20220823080106.487551248@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080100.268827165@linuxfoundation.org> References: <20220823080100.268827165@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: Pali Rohár [ 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: 63a72284b159 ("powerpc/pci: Assign fixed PHB number based on device-tree properties") Signed-off-by: Pali Rohár Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/20220706102148.5060-2-pali@kernel.org Signed-off-by: Sasha Levin --- arch/powerpc/kernel/pci-common.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c index 74628aca2bf1..b0bd55f2ce3a 100644 --- a/arch/powerpc/kernel/pci-common.c +++ b/arch/powerpc/kernel/pci-common.c @@ -82,16 +82,30 @@ EXPORT_SYMBOL(get_pci_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_property_read_u64(dn, "ibm,opal-phbid", &prop); + 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; } @@ -103,10 +117,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); -- 2.35.1