Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3411790rwa; Tue, 23 Aug 2022 04:27:55 -0700 (PDT) X-Google-Smtp-Source: AA6agR49T4hpkpwHetukChlAkMnwy8qNH0IbbGGBAmOGdU4CWCler4CdaeV8LZ+VYCUJHcB3hJ89 X-Received: by 2002:a17:90b:3511:b0:1f4:e0cd:1e04 with SMTP id ls17-20020a17090b351100b001f4e0cd1e04mr2950550pjb.154.1661254075235; Tue, 23 Aug 2022 04:27:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661254075; cv=none; d=google.com; s=arc-20160816; b=lfhAbxpUKIF6Y8amZ8/UA3Cc3eMtg4ghYX8sCkkE/himalrst3XWiNh59tzOTZbPOZ tzXLt4LGvP9LDJ0yAWwaPmFYzRaKIf/IlnnRN817XLFEFlVE67uB3aoKpHCnTgWTkd22 tQ1uRRW/b3Ge8JV9CUnMVF+8ry8jqcdTpLTrRYZSbA0wNMjO1yBI18uNuIhzbGFCi30I 3PY5s6VDUnVZtbVXe5zwyEMDWn0KnZ2Rwq0JqQR9PeFidikCVhhf4FeYEI/gLOJ+kTCY hgvVtdBxTk+GVYu3P4Rd7GQMtijYF7KkIqRUmXwI7hyQ0IwMFLwj+tUEXEbwncDSV05s yAaA== 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=wuLK9soqLliWhrZAcpn5JTFSugh2Qfbhd7/xi1FxPEg=; b=axqKpyFIPv+77i6qRYk64eeBf1hFVDPSpq2sirA4B6f+TItn81hlBorYELAB1A7+bI OgAcRBCIEOnuWby0CiEmYBSGgyHDgN0Hwgny0QhVnu7bzUcWb/rxbYA77Of/ry0efSAu z2Htpj1W+bDXXdVAdILDEvpf59QAhDeEQz30J2fXHrfAGYKzoSYzf/RQ/Ix+fSn23VDn qs2ywVoqhGmtoV6liIzqydd98mVe/kVk8yg1oY1ygaUS4/0Wkz+INIi9D81kwTDee0rL 4aMwCGQg6tN9mEzYdv+DrI/mO1w04NwEp3QI+PVeo7drIRstJ5GQ9yzgmteQEp21cRdG ABTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="CK6tzJF/"; 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 t185-20020a6381c2000000b0042a37db75f6si11141745pgd.535.2022.08.23.04.27.44; Tue, 23 Aug 2022 04:27:55 -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="CK6tzJF/"; 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 S240362AbiHWKAQ (ORCPT + 99 others); Tue, 23 Aug 2022 06:00:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351985AbiHWJ4M (ORCPT ); Tue, 23 Aug 2022 05:56:12 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B723A0304; Tue, 23 Aug 2022 01:47:14 -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 sin.source.kernel.org (Postfix) with ESMTPS id 14C66CE1B51; Tue, 23 Aug 2022 08:47:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 27A0CC43470; Tue, 23 Aug 2022 08:47:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661244430; bh=3B+TuonAqc41dsDgKO24WXZ1YqKkDx1ow3hiarHvoNU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CK6tzJF/e/7qTsU7Ku8k3hTVjd0Ftrqq8jo1LLCeAVKlHn3ZIe/yMSWKlV1BXbrkS ptLQJd61ReIISO+M7Y3KSj2/D39gdEHNSUnQtrxdrw6meM8dJETW6xzLm8aPna+ikq g8+l6kKKslOrdVTvi3ZrAaCDs9bHsF5LBA4NGQe0= 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 136/229] powerpc/pci: Prefer PCI domain assignment via DT linux,pci-domain and alias Date: Tue, 23 Aug 2022 10:24:57 +0200 Message-Id: <20220823080058.547331087@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: 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 02831a396419..2e2cc80bf592 100644 --- a/arch/powerpc/kernel/pci-common.c +++ b/arch/powerpc/kernel/pci-common.c @@ -80,16 +80,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; } @@ -101,10 +115,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