From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 70AC0C43460 for ; Mon, 3 May 2021 14:50:45 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AA7426101E for ; Mon, 3 May 2021 14:50:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AA7426101E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=mG07HsEdkShTps3ToDUajB+VPZxSf629s+lISoN5gMs=; b=mZ+AFmuyf0oNPyF/+7K4No0OZ NhdG47wdhO97Ou8p64H+6zuQPGS9mIzl8c441h7g/LEuC943+HTRKyBbwxOLIRTlxLSurHtMw/F3m 8VS30Ddi0RhqwwdQwN3upQOtjvpA5lJlvwOW+OKbyJuzdgJPB8ESKTPYsfdj13stnCCA+xi8NzbI5 p6hh+S5hRxeo7t53PYK9ZLwoKl1TXajPTkgIJlwAsk18SQklyPEX0RQlmPvwfSuKrL4Bs1YEeGGOs Qgy38kNx5ALFioqoGRbp+UiSnW6Ds5FjBRsXSTgb+JJrrZiHWTX9Hlx0wMsgIOHLxIocPKhvacOIl suZOmGDtg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1ldZrZ-00E6Zh-VK; Mon, 03 May 2021 14:47:58 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1ldZrN-00E6XU-AX for linux-arm-kernel@desiato.infradead.org; Mon, 03 May 2021 14:47:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=1FSEhDRBQeVQjstn1rh+EE8wSzHzDFWAgXa30qx5G9M=; b=Eqf/DIrQbzWjolwZ9SLbdIRChT peDRPMqAi6uBwuRuHDC1caUdT5r7TOJRxIZn+hNOjv0wtn68yc6UZ3cpqLklQExwaqR0VOO3Y2SoM 6UkL/PsukUYXH6iLf4/GdmdXdJlSmuXsJzMxDuEJ9KIMFWq86Cqyx64UjX2cJfQQQhZZ01Qze28NL SAQyDkk9a7x74DYyLStAafcWygevt0Kw4IYCUmV4ifpw9y/OEh9ZZnLAvpS2qYcpbioD4E/48krWf XKKe2EruJDfjSN1ToPEAZnLUqOGtq4/spXkY7A9Gj1YG6v7qA/SQu6IAUMoeXajc8T26gcFZ7Jz51 aZ+At9Fg==; Received: from mail-qk1-x732.google.com ([2607:f8b0:4864:20::732]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1ldZrK-0038bG-9u for linux-arm-kernel@lists.infradead.org; Mon, 03 May 2021 14:47:44 +0000 Received: by mail-qk1-x732.google.com with SMTP id 8so5228548qkv.8 for ; Mon, 03 May 2021 07:47:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1FSEhDRBQeVQjstn1rh+EE8wSzHzDFWAgXa30qx5G9M=; b=fug6smugDkskCRhinWaiLtXji0LdsCSMENxrHWEDPVUB8cETbNLSJt71Mqohm5tm90 d/A8W+KELZX2BTkHtlxh1bSBfAcOKMgS5/eehT3vAW6yms3LoU8SDA3wHoUdEYwOXQ/u hEQgfZZt9c2QKF0CaxHfL5lZFIVU/T0RxMFfMLMXXrfLJwfbbsU8xadgUGPIkSSlU32/ iJFe9qV0Z5t83f185ChRQUD/6ySb0G7Vl8+A2ELP/dYkxRQnQzCARXpJZ8anEyDSAk8h zPeLrwd7U5Exz4nyWEe6NgQMdXqsl6a5g31nOIa59h5XzuHfI2WAEH94SyHQWAWLNy8Z WEHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1FSEhDRBQeVQjstn1rh+EE8wSzHzDFWAgXa30qx5G9M=; b=ory9LTBE9GmhlKeLP9Y1YuQ73ePx+5uuX/7sflVO1i8FFdIHMKixwM0/0lpB2HWcvv qKOlFhYzcOc1otHb5ha6hzkbONyPLxcvzXZZE15sYmFLSLHreZuTde5yQ2Ln93KQhxpv QsXUAncG7CmV/bHvmDsi6kw+njteR0kxtbdGUUzLFIfFCIaDxYPBi0rdaJHAINqYNXPr NOUH82cPl/fMxGHgp8zjBkNo0KJRfrdLg8KueT2iP0dfmhc+QLvo6cQHSQe64jGr9sWj Oa7rzr+q8j7Lm72fYM/6VBu0JK6bHNy6UUoa2izlmMjCa7X/XVcy0GylD+dpI6H7kjc0 cngw== X-Gm-Message-State: AOAM531Yq8yOAZo8E78UbItb2ETdoPY7ri/GUhhArbhdNWpCrzrbUff1 6tq7rn4cE2d8zu4c1Cz7p8E= X-Google-Smtp-Source: ABdhPJx62G3wY4pYdtLDRjmUo8hJHBJuEW481c96AunDZIukoWSkSAUgwuT5KHNy7p8rk2UTj2nZSQ== X-Received: by 2002:ae9:f302:: with SMTP id p2mr18993638qkg.103.1620053261145; Mon, 03 May 2021 07:47:41 -0700 (PDT) Received: from auth1-smtp.messagingengine.com (auth1-smtp.messagingengine.com. [66.111.4.227]) by smtp.gmail.com with ESMTPSA id o189sm8645068qkd.60.2021.05.03.07.47.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 May 2021 07:47:40 -0700 (PDT) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailauth.nyi.internal (Postfix) with ESMTP id 191D727C0054; Mon, 3 May 2021 10:47:40 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Mon, 03 May 2021 10:47:40 -0400 X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrvdefgedgkedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeeuohhquhhn ucfhvghnghcuoegsohhquhhnrdhfvghnghesghhmrghilhdrtghomheqnecuggftrfgrth htvghrnhephedvveetfefgiedutedtfeevvddvleekjeeuffffleeguefhhfejteekieeu ueelnecukfhppedufedurddutdejrddurddvheegnecuvehluhhsthgvrhfuihiivgeptd enucfrrghrrghmpehmrghilhhfrhhomhepsghoqhhunhdomhgvshhmthhprghuthhhphgv rhhsohhnrghlihhthidqieelvdeghedtieegqddujeejkeehheehvddqsghoqhhunhdrfh gvnhhgpeepghhmrghilhdrtghomhesfhhigihmvgdrnhgrmhgv X-ME-Proxy: Received: from localhost (unknown [131.107.1.254]) by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 3 May 2021 10:47:37 -0400 (EDT) From: Boqun Feng To: Bjorn Helgaas , Arnd Bergmann , Marc Zyngier Cc: Russell King , Andrew Lunn , Sebastian Hesselbarth , Gregory Clement , Catalin Marinas , Will Deacon , Thomas Bogendoerfer , Lorenzo Pieralisi , Rob Herring , "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , Wei Liu , Thomas Petazzoni , Boqun Feng , Mike Rapoport , Robin Murphy , Thomas Gleixner , Jon Derrick , Sunil Muthuswamy , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, linux-pci@vger.kernel.org, linux-hyperv@vger.kernel.org Subject: [RFC v2 1/7] PCI: Introduce pci_host_bridge::domain_nr Date: Mon, 3 May 2021 22:46:29 +0800 Message-Id: <20210503144635.2297386-2-boqun.feng@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210503144635.2297386-1-boqun.feng@gmail.com> References: <20210503144635.2297386-1-boqun.feng@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210503_074742_371715_28018540 X-CRM114-Status: GOOD ( 21.72 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Currently we retrieve the PCI domain number of the host bridge from the bus sysdata (or pci_config_window if PCI_DOMAINS_GENERIC=y). Actually we have the information at PCI host bridge probing time, and it makes sense that we store it into pci_host_bridge. One benefit of doing so is the requirement for supporting PCI on Hyper-V for ARM64, because the host bridge of Hyper-V doesnt' have pci_config_window, whereas ARM64 is a PCI_DOMAINS_GENERIC=y arch, so we cannot retrieve the PCI domain number from pci_config_window on ARM64 Hyper-V guest. As the preparation for ARM64 Hyper-V PCI support, we introduce the domain_nr in pci_host_bridge, and set it properly at probing time, then for PCI_DOMAINS_GENERIC=y archs, bus domain numbers are set by the bridge domain_nr. Signed-off-by: Boqun Feng --- arch/arm/kernel/bios32.c | 2 ++ arch/arm/mach-dove/pcie.c | 2 ++ arch/arm/mach-mv78xx0/pcie.c | 2 ++ arch/arm/mach-orion5x/pci.c | 2 ++ arch/arm64/kernel/pci.c | 3 +-- arch/mips/pci/pci-legacy.c | 2 ++ arch/mips/pci/pci-xtalk-bridge.c | 2 ++ drivers/pci/controller/pci-ftpci100.c | 2 ++ drivers/pci/controller/pci-mvebu.c | 2 ++ drivers/pci/pci.c | 4 ++-- drivers/pci/probe.c | 7 ++++++- include/linux/pci.h | 11 ++++++++--- 12 files changed, 33 insertions(+), 8 deletions(-) diff --git a/arch/arm/kernel/bios32.c b/arch/arm/kernel/bios32.c index e7ef2b5bea9c..4942cd681e41 100644 --- a/arch/arm/kernel/bios32.c +++ b/arch/arm/kernel/bios32.c @@ -471,6 +471,8 @@ static void pcibios_init_hw(struct device *parent, struct hw_pci *hw, bridge->sysdata = sys; bridge->busnr = sys->busnr; bridge->ops = hw->ops; + if (IS_ENABLED(CONFIG_PCI_DOMAINS_GENERIC)) + bridge->domain_nr = pci_bus_find_domain_nr(sys, parent); ret = pci_scan_root_bus_bridge(bridge); } diff --git a/arch/arm/mach-dove/pcie.c b/arch/arm/mach-dove/pcie.c index ee91ac6b5ebf..92eb8484b49b 100644 --- a/arch/arm/mach-dove/pcie.c +++ b/arch/arm/mach-dove/pcie.c @@ -167,6 +167,8 @@ dove_pcie_scan_bus(int nr, struct pci_host_bridge *bridge) bridge->sysdata = sys; bridge->busnr = sys->busnr; bridge->ops = &pcie_ops; + if (IS_ENABLED(CONFIG_PCI_DOMAINS_GENERIC)) + bridge->domain_nr = pci_bus_find_domain_nr(sys, NULL); return pci_scan_root_bus_bridge(bridge); } diff --git a/arch/arm/mach-mv78xx0/pcie.c b/arch/arm/mach-mv78xx0/pcie.c index 636d84b40466..6703d394bcde 100644 --- a/arch/arm/mach-mv78xx0/pcie.c +++ b/arch/arm/mach-mv78xx0/pcie.c @@ -208,6 +208,8 @@ static int __init mv78xx0_pcie_scan_bus(int nr, struct pci_host_bridge *bridge) bridge->sysdata = sys; bridge->busnr = sys->busnr; bridge->ops = &pcie_ops; + if (IS_ENABLED(CONFIG_PCI_DOMAINS_GENERIC)) + bridge->domain_nr = pci_bus_find_domain_nr(sys, NULL); return pci_scan_root_bus_bridge(bridge); } diff --git a/arch/arm/mach-orion5x/pci.c b/arch/arm/mach-orion5x/pci.c index 76951bfbacf5..6257fbd4e705 100644 --- a/arch/arm/mach-orion5x/pci.c +++ b/arch/arm/mach-orion5x/pci.c @@ -563,6 +563,8 @@ int __init orion5x_pci_sys_scan_bus(int nr, struct pci_host_bridge *bridge) bridge->dev.parent = NULL; bridge->sysdata = sys; bridge->busnr = sys->busnr; + if (IS_ENABLED(CONFIG_PCI_DOMAINS_GENERIC)) + bridge->domain_nr = pci_bus_find_domain_nr(sys, NULL); if (nr == 0) { bridge->ops = &pcie_ops; diff --git a/arch/arm64/kernel/pci.c b/arch/arm64/kernel/pci.c index 1006ed2d7c60..e9a6eeb6a694 100644 --- a/arch/arm64/kernel/pci.c +++ b/arch/arm64/kernel/pci.c @@ -71,9 +71,8 @@ struct acpi_pci_generic_root_info { struct pci_config_window *cfg; /* config space mapping */ }; -int acpi_pci_bus_find_domain_nr(struct pci_bus *bus) +int acpi_pci_bus_find_domain_nr(struct pci_config_window *cfg) { - struct pci_config_window *cfg = bus->sysdata; struct acpi_device *adev = to_acpi_device(cfg->parent); struct acpi_pci_root *root = acpi_driver_data(adev); diff --git a/arch/mips/pci/pci-legacy.c b/arch/mips/pci/pci-legacy.c index 39052de915f3..84ad482be22d 100644 --- a/arch/mips/pci/pci-legacy.c +++ b/arch/mips/pci/pci-legacy.c @@ -97,6 +97,8 @@ static void pcibios_scanbus(struct pci_controller *hose) bridge->ops = hose->pci_ops; bridge->swizzle_irq = pci_common_swizzle; bridge->map_irq = pcibios_map_irq; + if (IS_ENABLED(CONFIG_PCI_DOMAINS_GENERIC)) + bridge->domain_nr = pci_bus_find_domain_nr(hose, NULL); ret = pci_scan_root_bus_bridge(bridge); if (ret) { pci_free_host_bridge(bridge); diff --git a/arch/mips/pci/pci-xtalk-bridge.c b/arch/mips/pci/pci-xtalk-bridge.c index 50f7d42cca5a..23355ab720be 100644 --- a/arch/mips/pci/pci-xtalk-bridge.c +++ b/arch/mips/pci/pci-xtalk-bridge.c @@ -712,6 +712,8 @@ static int bridge_probe(struct platform_device *pdev) host->ops = &bridge_pci_ops; host->map_irq = bridge_map_irq; host->swizzle_irq = pci_common_swizzle; + if (IS_ENABLED(CONFIG_PCI_DOMAINS_GENERIC)) + host->domain_nr = pci_bus_find_domain_nr(bc, dev); err = pci_scan_root_bus_bridge(host); if (err < 0) diff --git a/drivers/pci/controller/pci-ftpci100.c b/drivers/pci/controller/pci-ftpci100.c index da3cd216da00..cf6eec7f90e1 100644 --- a/drivers/pci/controller/pci-ftpci100.c +++ b/drivers/pci/controller/pci-ftpci100.c @@ -439,6 +439,8 @@ static int faraday_pci_probe(struct platform_device *pdev) host->ops = &faraday_pci_ops; p = pci_host_bridge_priv(host); host->sysdata = p; + if (IS_ENABLED(CONFIG_PCI_DOMAINS_GENERIC)) + host->domain_nr = pci_bus_find_domain_nr(p, dev); p->dev = dev; /* Retrieve and enable optional clocks */ diff --git a/drivers/pci/controller/pci-mvebu.c b/drivers/pci/controller/pci-mvebu.c index ed13e81cd691..b329ed2f0956 100644 --- a/drivers/pci/controller/pci-mvebu.c +++ b/drivers/pci/controller/pci-mvebu.c @@ -1122,6 +1122,8 @@ static int mvebu_pcie_probe(struct platform_device *pdev) bridge->sysdata = pcie; bridge->ops = &mvebu_pcie_ops; bridge->align_resource = mvebu_pcie_align_resource; + if (IS_ENABLED(CONFIG_PCI_DOMAINS_GENERIC)) + bridge->domain_nr = pci_bus_find_domain_nr(pcie, dev); return mvebu_pci_host_probe(bridge); } diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 16a17215f633..a249dbf78c34 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -6505,10 +6505,10 @@ static int of_pci_bus_find_domain_nr(struct device *parent) return domain; } -int pci_bus_find_domain_nr(struct pci_bus *bus, struct device *parent) +int pci_bus_find_domain_nr(void *sysdata, struct device *parent) { return acpi_disabled ? of_pci_bus_find_domain_nr(parent) : - acpi_pci_bus_find_domain_nr(bus); + acpi_pci_bus_find_domain_nr(sysdata); } #endif diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 953f15abc850..5e71cc5e1b6c 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -899,7 +899,7 @@ static int pci_register_host_bridge(struct pci_host_bridge *bridge) bus->ops = bridge->ops; bus->number = bus->busn_res.start = bridge->busnr; #ifdef CONFIG_PCI_DOMAINS_GENERIC - bus->domain_nr = pci_bus_find_domain_nr(bus, parent); + bus->domain_nr = bridge->domain_nr; #endif b = pci_find_bus(pci_domain_nr(bus), bridge->busnr); @@ -2974,6 +2974,8 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus, bridge->sysdata = sysdata; bridge->busnr = bus; bridge->ops = ops; + if (IS_ENABLED(CONFIG_PCI_DOMAINS_GENERIC)) + bridge->domain_nr = pci_bus_find_domain_nr(sysdata, parent); error = pci_register_host_bridge(bridge); if (error < 0) @@ -2992,6 +2994,9 @@ int pci_host_probe(struct pci_host_bridge *bridge) struct pci_bus *bus, *child; int ret; + if (IS_ENABLED(CONFIG_PCI_DOMAINS_GENERIC)) + bridge->domain_nr = pci_bus_find_domain_nr(bridge->sysdata, bridge->dev.parent); + ret = pci_scan_root_bus_bridge(bridge); if (ret < 0) { dev_err(bridge->dev.parent, "Scanning root bridge failed"); diff --git a/include/linux/pci.h b/include/linux/pci.h index 86c799c97b77..5bbd8417d219 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -534,6 +534,7 @@ struct pci_host_bridge { struct pci_ops *child_ops; void *sysdata; int busnr; + int domain_nr; struct list_head windows; /* resource_entry */ struct list_head dma_ranges; /* dma ranges resource list */ u8 (*swizzle_irq)(struct pci_dev *, u8 *); /* Platform IRQ swizzler */ @@ -1637,13 +1638,17 @@ static inline int pci_domain_nr(struct pci_bus *bus) { return bus->domain_nr; } +struct pci_config_window; #ifdef CONFIG_ACPI -int acpi_pci_bus_find_domain_nr(struct pci_bus *bus); +int acpi_pci_bus_find_domain_nr(struct pci_config_window *cfg); #else -static inline int acpi_pci_bus_find_domain_nr(struct pci_bus *bus) +static inline int acpi_pci_bus_find_domain_nr(struct pci_config_window *cfg) { return 0; } #endif -int pci_bus_find_domain_nr(struct pci_bus *bus, struct device *parent); +int pci_bus_find_domain_nr(void *sysdata, struct device *parent); +#else +static inline int pci_bus_find_domain_nr(void *sysdata, struct device *parent) +{ return 0; } #endif /* Some architectures require additional setup to direct VGA traffic */ -- 2.30.2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel