Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp2286035imw; Wed, 6 Jul 2022 03:23:47 -0700 (PDT) X-Google-Smtp-Source: AGRyM1v3HBItzVy1GlgoFOtWseQ0qxX7ZZxfbZ4hQNpaDVd0Rc9fU6NAc0Pc1ZPqzDk1ji4GGXXf X-Received: by 2002:a17:902:ab12:b0:16b:97b5:bb19 with SMTP id ik18-20020a170902ab1200b0016b97b5bb19mr43834992plb.107.1657103027361; Wed, 06 Jul 2022 03:23:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657103027; cv=none; d=google.com; s=arc-20160816; b=oDgp/kALySwdjeWmUor8uNZ4uivmYlIAGya69j8FU3tGgBwux0VtJNWe1STRqsHZkD goE5sqdIeQoQsfuf91ZNu5oqamf8qNGvcKAFxkBScr+Q5XfUKzI3+BPNgRdiUJ/6ed6R nM2VPZfO5Z6vYQ0iZV5ec7MB+JY+FLWCnWkBDlllPcEwXOW0V2UqouD/5gQsBMiu9IJi jH4awlvlhZmo3zclgO5LmW3Wh5dPfiK9sxlls5uIL9mmvgg21lEolJODy4SgrTm12Q/Q 0jVSIG2Jw3nbNX0jz3HlECn32vP8j2us4fG2trfiHKdfLi3D5IhhE4luffTASaZ4mpkW toOg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=QRGWVJGNUMoScr3dr07i2WQastEZMfos/3/GFc0h7vc=; b=V9cWhpecknDWjUD9GNvyz62O4YZPLbO5wf1IoqiCTmO566aOki0++mfRSy6DivOz+e u6udXLToTwDWslfXAMOtCLujMvlhXGFV8RFOF6wq2e44GktLvN5IrXP7nccwDezAMmwx Kle/YN/WCkFvODccLjicML5FGpIFUT+nAt3mxBH71OqfKclFQb7oSQooffJ+VP1JA4gK sOB2ZY21HoQu9cfmpEvsvWBTeyIa7OZb4luedAzLvpF5mUwBQCjW5vbmRfpva49ZqHP3 gSYxOFwycariUrbtwOABPjC+AsauulULtbnPJextzFxwRHknqYQrcAf7kSit0T1INOIr 4wEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=TIRgolfA; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d131-20020a636889000000b004119e2771eesi29656246pgc.367.2022.07.06.03.23.35; Wed, 06 Jul 2022 03:23: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=@kernel.org header.s=k20201202 header.b=TIRgolfA; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232911AbiGFKWr (ORCPT + 99 others); Wed, 6 Jul 2022 06:22:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233150AbiGFKWW (ORCPT ); Wed, 6 Jul 2022 06:22:22 -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 7732925C70; Wed, 6 Jul 2022 03:22:21 -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 0C07661DFC; Wed, 6 Jul 2022 10:22:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 44B26C341C0; Wed, 6 Jul 2022 10:22:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1657102940; bh=5RJNNFRIVghvmdUSW6GuwgiuwsPcvqMprUl9pG2CXAs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TIRgolfAO2xEEw7akxf7//984YrubOnA0R8bW1OE6XDQJxiyw+77sZBa1fj+WlZv/ d/URcRVv6rQHA/wtyn33AP0T/phtAXwwyN7ngWhcLsFwIEGav9gYP8NfrevZb7BoBL UWgm3BUAAFRH4nTqmYvQN8DuJZiq0Vc+L1t4fgQT/ygCtrvDZT7+zYgocVUtPRcA/v JgDC1x558eTV5Nxj+9PGYjGyAGRiZYI/2K3QP9PJ3g3uDJh7sdJwKatBBqd+tItnaG p0vJmPNOcCj2d0DU2FijgNMNRafXxWCVTQyoNfiP8Kd9+MHrdm8e4zJNXUbY4mG5a8 oxIF+7fqD69zg== Received: by pali.im (Postfix) id C570A7F1; Wed, 6 Jul 2022 12:22:17 +0200 (CEST) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , "Guilherme G. Piccoli" , Bjorn Helgaas , Guowen Shan , Tyrel Datwyler Cc: linuxppc-dev@lists.ozlabs.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/2] powerpc/pci: Prefer PCI domain assignment via DT 'linux,pci-domain' and alias Date: Wed, 6 Jul 2022 12:21:48 +0200 Message-Id: <20220706102148.5060-2-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220706102148.5060-1-pali@kernel.org> References: <20220706102148.5060-1-pali@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.8 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 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 --- Changes in v2: * New patch --- arch/powerpc/kernel/pci-common.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c index 7f959df34833..0715d74855b3 100644 --- a/arch/powerpc/kernel/pci-common.c +++ b/arch/powerpc/kernel/pci-common.c @@ -78,10 +78,25 @@ static int get_phb_number(struct device_node *dn) /* * 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 + * (only if CONFIG_PPC_PCI_DOMAIN_FROM_OF_REG is enabled). */ - 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 && IS_ENABLED(CONFIG_PPC_PCI_DOMAIN_FROM_OF_REG)) { u32 prop_32; ret = of_property_read_u32_index(dn, "reg", 1, &prop_32); @@ -95,10 +110,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.20.1