From patchwork Mon May 3 14:46:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boqun Feng X-Patchwork-Id: 12236077 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=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 37162C43461 for ; Mon, 3 May 2021 14:47:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0160561244 for ; Mon, 3 May 2021 14:47:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229737AbhECOsg (ORCPT ); Mon, 3 May 2021 10:48:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229641AbhECOsg (ORCPT ); Mon, 3 May 2021 10:48:36 -0400 Received: from mail-qk1-x72e.google.com (mail-qk1-x72e.google.com [IPv6:2607:f8b0:4864:20::72e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC09CC06174A; Mon, 3 May 2021 07:47:41 -0700 (PDT) Received: by mail-qk1-x72e.google.com with SMTP id k127so5229838qkc.6; Mon, 03 May 2021 07:47:41 -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=czKGTD0imiEyaPGmDnrF7hiFFmcOi2J8PH/hVL6l76NuONoPIcXKtZMLNE3u+7Mi+X GYceVYltxNMbjL8TU7dr/lTvgZ75UkZTD5Tr/XerC7hBmELslQ0FuHEcNj3te/zuk6QL eog4QoNGwW/tly3OpSyoLg77eIAiA+EW17/hDju6YxPIkZOAx91nKHEGwjjwJJUbE0NH 8Yc0/NxGhiHCVeygU/OwFh2Hx8K02wf1Ua8I6BW7UH+dC55xZlDN4Kdc2QN1N09K2ngO KPIp5We6ZP3kdG6gt38Sei3e18jMl9V7Z4txbVLauuIi5OMVZHHQJiHJtjUwidg6cFMq hopQ== X-Gm-Message-State: AOAM533gw+FsykUpC+HEckSQTmCfPi5zCFwlZA+d02bSEi4tfcAiEnvE irhrrHK2AYqatqHwXdA+8wU= 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 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.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 */ From patchwork Mon May 3 14:46:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boqun Feng X-Patchwork-Id: 12236079 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=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 22A23C43470 for ; Mon, 3 May 2021 14:47:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0C3CE611EE for ; Mon, 3 May 2021 14:47:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229724AbhECOsj (ORCPT ); Mon, 3 May 2021 10:48:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229727AbhECOsg (ORCPT ); Mon, 3 May 2021 10:48:36 -0400 Received: from mail-qk1-x72f.google.com (mail-qk1-x72f.google.com [IPv6:2607:f8b0:4864:20::72f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31EBFC06138B; Mon, 3 May 2021 07:47:43 -0700 (PDT) Received: by mail-qk1-x72f.google.com with SMTP id u20so5232415qku.10; Mon, 03 May 2021 07:47:43 -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=pHMX7e7cca//f8WV13d54/Yw94IX+FFVKn38d4yzFvQ=; b=DXIVVgn/RF6pH7mvY6Z3OTOmlU2LdBLelvX8YbNY7kbgAtVktcAGzGNMzkVfVkZ4SD yRuA+W4bm5yLjpw/kGhARLMGrNqENocXS94O4wxIFVXw4WXoBCaBd29lECEU/8vx1/Zc crMH0ojzcJIzgn5acEbz8ATuh9da596Gf9e0qgeN+Ir7NSIRwN9s3sN6vqCtS7t7luLK 4/E3tcJOeNgLbHkB0SPyLhCSKePOBhpXQ9cnWvXgsYS2G63V3BYZx/t0RUiHYgiexhGp itI/gL9VD23M3kEmsuJeQGeNEzDqfrXKZiDHjIqygiNNmpJxQ0Vx3JbnQe0hUHxVTVwT QSAw== 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=pHMX7e7cca//f8WV13d54/Yw94IX+FFVKn38d4yzFvQ=; b=b1spZNX24b9/GWg473dgvbSCmd3LcXhTmbC7xdjnHpBdkgoghbaLuDpd7qhWQjTaZj J8EkzXJ9RZZXZ+qT6aur2D/MvVczx9PKzZ88WFJjN0+NREqM2qdN2rxUN+l/ZJ3PK910 Clcb0GyzYO3LuiGNyCj1W1lb1UctmFeN+k62/k+HkPAWd5eVetAghqV458iPvgnLbq73 PymHIjlKR8h9u4v+hFCDKhq8ca5ntqQDj6pEgJQ3vD2tewa80R35vyGqSkLu2jVH5950 E41+pZCiLWOPOVBUVzSpomed9D7PNF2tERzqtsmiPYjO4tOaEPB75lnCrJaYY0lOvCxS RERg== X-Gm-Message-State: AOAM5331nxR15b9du0RTQ6eDnD5GfJ2MhMqo084fE5f0isXMS0Ftkiaz DZstUyEDi0UfGc/Q/TzYil0= X-Google-Smtp-Source: ABdhPJyEQrN4krK3JagLFsgtZiFtRmmcwogE+AlaLeRSuxSI0/l3UkXy8YAiBwdd49W8aQxYoGf0Ow== X-Received: by 2002:a37:9c50:: with SMTP id f77mr6786789qke.107.1620053262469; Mon, 03 May 2021 07:47:42 -0700 (PDT) Received: from auth1-smtp.messagingengine.com (auth1-smtp.messagingengine.com. [66.111.4.227]) by smtp.gmail.com with ESMTPSA id a26sm9287261qtg.60.2021.05.03.07.47.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 May 2021 07:47:42 -0700 (PDT) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailauth.nyi.internal (Postfix) with ESMTP id 5AE9527C0054; Mon, 3 May 2021 10:47:41 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Mon, 03 May 2021 10:47:41 -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:40 -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 2/7] PCI: Allow msi domain set-up at host probing time Date: Mon, 3 May 2021 22:46:30 +0800 Message-Id: <20210503144635.2297386-3-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 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org For GENERIC_MSI_IRQ_DOMAIN drivers, we can set up the msi domain via dev_set_msi_domain() at probing time, and drivers can use this more generic way to set up the msi domain for the host bridge. This is the preparation for ARM64 Hyper-V PCI support. Originally-by: Arnd Bergmann Signed-off-by: Boqun Feng --- drivers/pci/probe.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 5e71cc5e1b6c..90afa05ab2f1 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -828,11 +828,14 @@ static struct irq_domain *pci_host_bridge_msi_domain(struct pci_bus *bus) { struct irq_domain *d; + /* Default set by host bridge driver */ + d = dev_get_msi_domain(bus->bridge); /* * Any firmware interface that can resolve the msi_domain * should be called from here. */ - d = pci_host_bridge_of_msi_domain(bus); + if (!d) + d = pci_host_bridge_of_msi_domain(bus); if (!d) d = pci_host_bridge_acpi_msi_domain(bus); From patchwork Mon May 3 14:46:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boqun Feng X-Patchwork-Id: 12236081 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=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 6E80AC43600 for ; Mon, 3 May 2021 14:47:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3E1E9611EE for ; Mon, 3 May 2021 14:47:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229879AbhECOsk (ORCPT ); Mon, 3 May 2021 10:48:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229852AbhECOsj (ORCPT ); Mon, 3 May 2021 10:48:39 -0400 Received: from mail-qv1-xf35.google.com (mail-qv1-xf35.google.com [IPv6:2607:f8b0:4864:20::f35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B632BC06174A; Mon, 3 May 2021 07:47:45 -0700 (PDT) Received: by mail-qv1-xf35.google.com with SMTP id q5so2667403qvv.6; Mon, 03 May 2021 07:47:45 -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=K7WNcv9gpl7Pc9Bs4CClcYzbGI8iLKijx7i4GjrAumE=; b=hDTXkLgdcBg/8iActEuVZQsBNINluBlGBSf7I7odEakWa+wbqfIS8ru5mGYOIN3W9a Z8u+zqGdzHrqgNzvNLnG2YTpfUBkO9Pm69m3IWELrOgpm07CycymYoSV0E7Tlh5a12GP N8CSKMpNXgp2AGXk4Id6oTZoCkc0gd1FWZJyKTEf42SJBXZo7FdHE+6ELCXM9YKMX2ua HLOgS1hcP12qpAIdthqyAUltnITk3NcCCVGNaMnj9wjeIq9+MPZNM9ApVf8SFVAMs/7m 0kdHTcxfFvXHezgVH14WCzSV8H+wu03fGHprIRg5AChgBT9MZqNHQyp+zB9vhKkQtV+X xY0w== 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=K7WNcv9gpl7Pc9Bs4CClcYzbGI8iLKijx7i4GjrAumE=; b=YDjD0rJjrNQ1idBEUDF3w4sl//Ib2cwX/gcYa6YLKsEuTUU86jt3fo7h9WsOwg0ISD 0Q+f+LbNDrVsZogHNhekhS/nCOPqeHcB9ixmk+Y6Yn9N4v8DRT1mjmqEpe7uSpAVErT5 IiplDhw7drOQpHnkOEfcYSbVSNjXNhbdtpq8tV+tt4GHQpDHT3kXsY9L93gho+/vkI7N EZ3r7Z65Lt7xu+VToxZBuSQ3QHRPBv63oqFZlccJ4Di5HB+jngIvNXTc7ZbfkYvHqo5g r/R8gqTTblS5C85zReZIOZ2QOwHiyfJ131uLh/spUDIyj6h6wjmi/tTVnTdAas25KeH7 HBIA== X-Gm-Message-State: AOAM530XM8l9QQsXH8FZkxHHvs05XSRBfvht+FYRv0w/AERh7562oAJJ WhpusL0YDPw5Cn3xQwKGYgk= X-Google-Smtp-Source: ABdhPJwhFORps0pBFTvoj1SZER6t9pF8hcj2oPdiHng2UNuDKEAEABMrq6X2quoa/uEV0cg+fxBuVA== X-Received: by 2002:ad4:4f11:: with SMTP id fb17mr20178028qvb.18.1620053264946; Mon, 03 May 2021 07:47:44 -0700 (PDT) Received: from auth1-smtp.messagingengine.com (auth1-smtp.messagingengine.com. [66.111.4.227]) by smtp.gmail.com with ESMTPSA id n15sm8qti.51.2021.05.03.07.47.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 May 2021 07:47:44 -0700 (PDT) Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailauth.nyi.internal (Postfix) with ESMTP id 8439927C005A; Mon, 3 May 2021 10:47:43 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Mon, 03 May 2021 10:47:43 -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:42 -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 3/7] PCI: hv: Generify PCI probing Date: Mon, 3 May 2021 22:46:31 +0800 Message-Id: <20210503144635.2297386-4-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 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org From: Arnd Bergmann In order to support ARM64 Hyper-V PCI, we need to set up the bridge at probing time because ARM64 is a PCI_DOMAIN_GENERIC arch and we don't have pci_config_window (ARM64 sysdata) for a PCI root bus on Hyper-V, so it's impossible to retrieve the information (e.g. PCI domains, irq domains) from bus sysdata on ARM64 after creation. Originally in create_root_hv_pci_bus(), pci_create_root_bus() is used to create the root bus and the corresponding bridge based on x86 sysdata. Now we create a bridge first and then call pci_scan_root_bus_bridge(), which allows us to do the necessary set-ups for the bridge. Signed-off-by: Arnd Bergmann Signed-off-by: Boqun Feng --- drivers/pci/controller/pci-hyperv.c | 61 +++++++++++++++-------------- 1 file changed, 31 insertions(+), 30 deletions(-) diff --git a/drivers/pci/controller/pci-hyperv.c b/drivers/pci/controller/pci-hyperv.c index 27a17a1e4a7c..27b922b4bb7b 100644 --- a/drivers/pci/controller/pci-hyperv.c +++ b/drivers/pci/controller/pci-hyperv.c @@ -450,6 +450,7 @@ enum hv_pcibus_state { struct hv_pcibus_device { struct pci_sysdata sysdata; + struct pci_host_bridge *bridge; /* Protocol version negotiated with the host */ enum pci_protocol_version_t protocol_version; enum hv_pcibus_state state; @@ -462,13 +463,10 @@ struct hv_pcibus_device { struct resource *high_mmio_res; struct completion *survey_event; struct completion remove_event; - struct pci_bus *pci_bus; spinlock_t config_lock; /* Avoid two threads writing index page */ spinlock_t device_list_lock; /* Protect lists below */ void __iomem *cfg_addr; - struct list_head resources_for_children; - struct list_head children; struct list_head dr_list; @@ -1804,7 +1802,7 @@ static void hv_pci_assign_slots(struct hv_pcibus_device *hbus) slot_nr = PCI_SLOT(wslot_to_devfn(hpdev->desc.win_slot.slot)); snprintf(name, SLOT_NAME_SIZE, "%u", hpdev->desc.ser); - hpdev->pci_slot = pci_create_slot(hbus->pci_bus, slot_nr, + hpdev->pci_slot = pci_create_slot(hbus->bridge->bus, slot_nr, name, NULL); if (IS_ERR(hpdev->pci_slot)) { pr_warn("pci_create slot %s failed\n", name); @@ -1834,7 +1832,7 @@ static void hv_pci_remove_slots(struct hv_pcibus_device *hbus) static void hv_pci_assign_numa_node(struct hv_pcibus_device *hbus) { struct pci_dev *dev; - struct pci_bus *bus = hbus->pci_bus; + struct pci_bus *bus = hbus->bridge->bus; struct hv_pci_dev *hv_dev; list_for_each_entry(dev, &bus->devices, bus_list) { @@ -1857,24 +1855,24 @@ static void hv_pci_assign_numa_node(struct hv_pcibus_device *hbus) */ static int create_root_hv_pci_bus(struct hv_pcibus_device *hbus) { - /* Register the device */ - hbus->pci_bus = pci_create_root_bus(&hbus->hdev->device, - 0, /* bus number is always zero */ - &hv_pcifront_ops, - &hbus->sysdata, - &hbus->resources_for_children); - if (!hbus->pci_bus) - return -ENODEV; + int error; + struct pci_host_bridge *bridge = hbus->bridge; + + bridge->dev.parent = &hbus->hdev->device; + bridge->sysdata = &hbus->sysdata; + bridge->ops = &hv_pcifront_ops; + bridge->msi = &hbus->msi_chip; + bridge->msi->dev = &hbus->hdev->device; - hbus->pci_bus->msi = &hbus->msi_chip; - hbus->pci_bus->msi->dev = &hbus->hdev->device; + error = pci_scan_root_bus_bridge(bridge); + if (error) + return error; pci_lock_rescan_remove(); - pci_scan_child_bus(hbus->pci_bus); hv_pci_assign_numa_node(hbus); - pci_bus_assign_resources(hbus->pci_bus); + pci_bus_assign_resources(bridge->bus); hv_pci_assign_slots(hbus); - pci_bus_add_devices(hbus->pci_bus); + pci_bus_add_devices(bridge->bus); pci_unlock_rescan_remove(); hbus->state = hv_pcibus_installed; return 0; @@ -2139,7 +2137,7 @@ static void pci_devices_present_work(struct work_struct *work) * because there may have been changes. */ pci_lock_rescan_remove(); - pci_scan_child_bus(hbus->pci_bus); + pci_scan_child_bus(hbus->bridge->bus); hv_pci_assign_numa_node(hbus); hv_pci_assign_slots(hbus); pci_unlock_rescan_remove(); @@ -2310,8 +2308,8 @@ static void hv_eject_device_work(struct work_struct *work) /* * Ejection can come before or after the PCI bus has been set up, so * attempt to find it and tear down the bus state, if it exists. This - * must be done without constructs like pci_domain_nr(hbus->pci_bus) - * because hbus->pci_bus may not exist yet. + * must be done without constructs like pci_domain_nr(hbus->bridge->bus) + * because hbus->bridge->bus may not exist yet. */ wslot = wslot_to_devfn(hpdev->desc.win_slot.slot); pdev = pci_get_domain_bus_and_slot(hbus->sysdata.domain, 0, wslot); @@ -2680,8 +2678,7 @@ static int hv_pci_allocate_bridge_windows(struct hv_pcibus_device *hbus) /* Modify this resource to become a bridge window. */ hbus->low_mmio_res->flags |= IORESOURCE_WINDOW; hbus->low_mmio_res->flags &= ~IORESOURCE_BUSY; - pci_add_resource(&hbus->resources_for_children, - hbus->low_mmio_res); + pci_add_resource(&hbus->bridge->windows, hbus->low_mmio_res); } if (hbus->high_mmio_space) { @@ -2700,8 +2697,7 @@ static int hv_pci_allocate_bridge_windows(struct hv_pcibus_device *hbus) /* Modify this resource to become a bridge window. */ hbus->high_mmio_res->flags |= IORESOURCE_WINDOW; hbus->high_mmio_res->flags &= ~IORESOURCE_BUSY; - pci_add_resource(&hbus->resources_for_children, - hbus->high_mmio_res); + pci_add_resource(&hbus->bridge->windows, hbus->high_mmio_res); } return 0; @@ -3031,6 +3027,7 @@ static void hv_put_dom_num(u16 dom) static int hv_pci_probe(struct hv_device *hdev, const struct hv_vmbus_device_id *dev_id) { + struct pci_host_bridge *bridge; struct hv_pcibus_device *hbus; u16 dom_req, dom; char *name; @@ -3043,6 +3040,10 @@ static int hv_pci_probe(struct hv_device *hdev, */ BUILD_BUG_ON(sizeof(*hbus) > HV_HYP_PAGE_SIZE); + bridge = devm_pci_alloc_host_bridge(&hdev->device, 0); + if (!bridge) + return -ENOMEM; + /* * With the recent 59bb47985c1d ("mm, sl[aou]b: guarantee natural * alignment for kmalloc(power-of-two)"), kzalloc() is able to allocate @@ -3064,6 +3065,8 @@ static int hv_pci_probe(struct hv_device *hdev, hbus = kzalloc(HV_HYP_PAGE_SIZE, GFP_KERNEL); if (!hbus) return -ENOMEM; + + hbus->bridge = bridge; hbus->state = hv_pcibus_init; hbus->wslot_res_allocated = -1; @@ -3101,7 +3104,6 @@ static int hv_pci_probe(struct hv_device *hdev, refcount_set(&hbus->remove_lock, 1); INIT_LIST_HEAD(&hbus->children); INIT_LIST_HEAD(&hbus->dr_list); - INIT_LIST_HEAD(&hbus->resources_for_children); spin_lock_init(&hbus->config_lock); spin_lock_init(&hbus->device_list_lock); spin_lock_init(&hbus->retarget_msi_interrupt_lock); @@ -3307,9 +3309,9 @@ static int hv_pci_remove(struct hv_device *hdev) if (hbus->state == hv_pcibus_installed) { /* Remove the bus from PCI's point of view. */ pci_lock_rescan_remove(); - pci_stop_root_bus(hbus->pci_bus); + pci_stop_root_bus(hbus->bridge->bus); hv_pci_remove_slots(hbus); - pci_remove_root_bus(hbus->pci_bus); + pci_remove_root_bus(hbus->bridge->bus); pci_unlock_rescan_remove(); hbus->state = hv_pcibus_removed; } @@ -3320,7 +3322,6 @@ static int hv_pci_remove(struct hv_device *hdev) iounmap(hbus->cfg_addr); hv_free_config_window(hbus); - pci_free_resource_list(&hbus->resources_for_children); hv_pci_free_bridge_windows(hbus); irq_domain_remove(hbus->irq_domain); irq_domain_free_fwnode(hbus->sysdata.fwnode); @@ -3406,7 +3407,7 @@ static int hv_pci_restore_msi_msg(struct pci_dev *pdev, void *arg) */ static void hv_pci_restore_msi_state(struct hv_pcibus_device *hbus) { - pci_walk_bus(hbus->pci_bus, hv_pci_restore_msi_msg, NULL); + pci_walk_bus(hbus->bridge->bus, hv_pci_restore_msi_msg, NULL); } static int hv_pci_resume(struct hv_device *hdev) From patchwork Mon May 3 14:46:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boqun Feng X-Patchwork-Id: 12236083 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=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 1D7A9C43460 for ; Mon, 3 May 2021 14:47:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E2E1D6101E for ; Mon, 3 May 2021 14:47:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229939AbhECOst (ORCPT ); Mon, 3 May 2021 10:48:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229940AbhECOsn (ORCPT ); Mon, 3 May 2021 10:48:43 -0400 Received: from mail-qv1-xf2c.google.com (mail-qv1-xf2c.google.com [IPv6:2607:f8b0:4864:20::f2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B64ADC06138B; Mon, 3 May 2021 07:47:49 -0700 (PDT) Received: by mail-qv1-xf2c.google.com with SMTP id q5so2667504qvv.6; Mon, 03 May 2021 07:47:49 -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=ZaynnOWtz1Te8wfxtYrLIk63miL/F4a1HGn3nv7Urqg=; b=f/kTbAKtjUtsRiWLTilOvljJRnbusQs75pq0RiLwmv7SAWfvilihFauytr+8eYpRCG p6Bw1dlvN0JUvKcbDHNfaePTMO5t9yoSHT5fr1g3FRqFF7a+Nvfy2R4kRxpi4zTCM7Jb 1J4kYadymJVE2oeMq8x52ToZBDd12wtbZ1j7YFETYif+mAjM/hBh9MiK0L96l54wxrb6 +MbWQij5LBdaoflS3wtkvlwgXY812BAd3U+OqfV3Fsgwgk51Ct2OuV3SkOWsW+tbdebt OzzHccXeu5s/Wbd9exI0FgfL04jPmRmoEk6j+d/v/2uxwktFzhj5g7oFhx+wdcG7AcEU /TlQ== 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=ZaynnOWtz1Te8wfxtYrLIk63miL/F4a1HGn3nv7Urqg=; b=qF+UY4GMMTjVnEF2Oe+QHVmjpAu19w/u318vyN0FpvgUAyJlpQnNIwrpuGxPGrkvPy VgHbQbyZUI6BqYKAVFCQO/i+UZeY5wT9FcfftMAYckznyzwFTtvaC/Iz0BQW8At7h9nx SpAV+2XGELkhbkcaFf3bDt9/gguaBn5YJPbDmQx30VlZQnHCvUsyJt0aNEsr+QXwcpRh 6nHdJJ4YZ2CLKXNMdG7ZV94Er9Y7rfjaHgeopMSyHTJiapFIfUKMATe2+1hu+P6etJ4H kLemlBtu0TnTHOFeGiscaC+yeBsy0nWLvTPsFONnu+Me4S5Gl5icxvAC+IXWB1oFeGif WJmg== X-Gm-Message-State: AOAM533N41z5ejZ4J7AaF9Pmb4ha29QzRcuxbI+kP1inUtPyWtX/WFYk 1GWRXlDW/QZWmz4kfYK8gdQ= X-Google-Smtp-Source: ABdhPJzZoxPhUl5k38exLjHPsVAjKcwCE/twF8waDy9XYOrkcwBv7GeAm9ddoUSKZURoSAmsT/SChg== X-Received: by 2002:a05:6214:486:: with SMTP id ay6mr19861358qvb.18.1620053268704; Mon, 03 May 2021 07:47:48 -0700 (PDT) Received: from auth1-smtp.messagingengine.com (auth1-smtp.messagingengine.com. [66.111.4.227]) by smtp.gmail.com with ESMTPSA id r81sm8757152qka.82.2021.05.03.07.47.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 May 2021 07:47:48 -0700 (PDT) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailauth.nyi.internal (Postfix) with ESMTP id 8210527C0054; Mon, 3 May 2021 10:47:47 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Mon, 03 May 2021 10:47:47 -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:44 -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 4/7] PCI: hv: Use pci_host_bridge::domain_nr for PCI domain Date: Mon, 3 May 2021 22:46:32 +0800 Message-Id: <20210503144635.2297386-5-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 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org No functional change, just store and maintain the PCI domain number in the generic pci_host_bridge instead of x86 specific pci_sysdata. Signed-off-by: Boqun Feng --- drivers/pci/controller/pci-hyperv.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/pci/controller/pci-hyperv.c b/drivers/pci/controller/pci-hyperv.c index 27b922b4bb7b..05b73d5dfe9d 100644 --- a/drivers/pci/controller/pci-hyperv.c +++ b/drivers/pci/controller/pci-hyperv.c @@ -2312,7 +2312,7 @@ static void hv_eject_device_work(struct work_struct *work) * because hbus->bridge->bus may not exist yet. */ wslot = wslot_to_devfn(hpdev->desc.win_slot.slot); - pdev = pci_get_domain_bus_and_slot(hbus->sysdata.domain, 0, wslot); + pdev = pci_get_domain_bus_and_slot(hbus->bridge->domain_nr, 0, wslot); if (pdev) { pci_lock_rescan_remove(); pci_stop_and_remove_bus_device(pdev); @@ -3098,6 +3098,7 @@ static int hv_pci_probe(struct hv_device *hdev, "PCI dom# 0x%hx has collision, using 0x%hx", dom_req, dom); + hbus->bridge->domain_nr = dom; hbus->sysdata.domain = dom; hbus->hdev = hdev; @@ -3109,7 +3110,7 @@ static int hv_pci_probe(struct hv_device *hdev, spin_lock_init(&hbus->retarget_msi_interrupt_lock); init_completion(&hbus->remove_event); hbus->wq = alloc_ordered_workqueue("hv_pci_%x", 0, - hbus->sysdata.domain); + hbus->bridge->domain_nr); if (!hbus->wq) { ret = -ENOMEM; goto free_dom; @@ -3236,7 +3237,7 @@ static int hv_pci_probe(struct hv_device *hdev, destroy_wq: destroy_workqueue(hbus->wq); free_dom: - hv_put_dom_num(hbus->sysdata.domain); + hv_put_dom_num(hbus->bridge->domain_nr); free_bus: kfree(hbus); return ret; @@ -3329,7 +3330,7 @@ static int hv_pci_remove(struct hv_device *hdev) wait_for_completion(&hbus->remove_event); destroy_workqueue(hbus->wq); - hv_put_dom_num(hbus->sysdata.domain); + hv_put_dom_num(hbus->bridge->domain_nr); kfree(hbus); return ret; From patchwork Mon May 3 14:46:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boqun Feng X-Patchwork-Id: 12236085 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=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 09F4EC43470 for ; Mon, 3 May 2021 14:47:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C708961208 for ; Mon, 3 May 2021 14:47:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229942AbhECOsu (ORCPT ); Mon, 3 May 2021 10:48:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229947AbhECOso (ORCPT ); Mon, 3 May 2021 10:48:44 -0400 Received: from mail-qv1-xf2a.google.com (mail-qv1-xf2a.google.com [IPv6:2607:f8b0:4864:20::f2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFAF3C061763; Mon, 3 May 2021 07:47:50 -0700 (PDT) Received: by mail-qv1-xf2a.google.com with SMTP id jm10so2669315qvb.5; Mon, 03 May 2021 07:47:50 -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=QWGd3JZfCgq7eTKfJP0e8l8aGD/9nEGlQMt+hKKZY8A=; b=pSkfiyb0wtubGvLMi2eXrfzDkJ5X9eLg/4Me5N9YOiME/jPpHKHSwGwsXH1+X1BcSb HlcPE2vOJFcg7orkh4S9K5GSwhd/ytSDy00syRcCCUuZYivKJFufAE/XWV1FFrf1jpeF mvjia0KQQmZcP/goMIGJknd325xKQCRhCUfJe3RmXEhAwNwRDxTmpJilBF4B3IXCF5+y wsq/KrzAA0bp2cXTqsVihNVSS66srFWnf6k73SF2VwwpNIVQfQVL9ilYFvzz8vWEk5Xg odwKKCYTmR32q4yH9WhxmerI/HiVkYMllNfDrTvVcP2inTA2602GZAfDPkF0xsq3KH5F 4WDg== 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=QWGd3JZfCgq7eTKfJP0e8l8aGD/9nEGlQMt+hKKZY8A=; b=I+e1fm/Lfo3S3ljp5trE6fwo57QgfNS+3tn0cVEpbzydiklcqFfIBWwLB7d+Dh/3x6 kjhTjOIJnlf6/jXn8o18lCAOQyTyl3OnA4CBgdMh6hro+ZjI8PIQbnYeNKbPXzJ353Gi UcqyMWoYumWdDZIM2Tqn2OSZiFzGcZmnIrWS361Jrx0bakGnXmM5t7eVJcYaiUwjRDuC 5HrdwBshyJfXOEhQPitOpM/Ip+oiIKAW6rc9YNNBoT1DhTZvzmvv4phL7l97nVRlkQ6o K+ZA34bWBj8M7kE50PxtPQfj2O8olNHXF1oxjak2FAdrauMZEEdcPftw7YPSX7BngQiX qdMg== X-Gm-Message-State: AOAM531vPl41/watcMS/whLwJhOG6yrMVt+QL3eecWZdqC8HzmAbUa9H 7TuPxR724k66YIrnBNTlzdA= X-Google-Smtp-Source: ABdhPJxGkDhQ4Z7gX1EcIbTfincvhtJ+ymk7z9TCLM44IZ4v0r18q4U9mIVYSELaANxcDuZJOCoJ4g== X-Received: by 2002:a0c:ea86:: with SMTP id d6mr16429735qvp.5.1620053270101; Mon, 03 May 2021 07:47:50 -0700 (PDT) Received: from auth1-smtp.messagingengine.com (auth1-smtp.messagingengine.com. [66.111.4.227]) by smtp.gmail.com with ESMTPSA id o12sm5247623qtq.96.2021.05.03.07.47.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 May 2021 07:47:49 -0700 (PDT) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailauth.nyi.internal (Postfix) with ESMTP id D923D27C0054; Mon, 3 May 2021 10:47:48 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Mon, 03 May 2021 10:47:48 -0400 X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrvdefgedgkedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeeuohhquhhn ucfhvghnghcuoegsohhquhhnrdhfvghnghesghhmrghilhdrtghomheqnecuggftrfgrth htvghrnhephedvveetfefgiedutedtfeevvddvleekjeeuffffleeguefhhfejteekieeu ueelnecukfhppedufedurddutdejrddurddvheegnecuvehluhhsthgvrhfuihiivgepud 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:48 -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 5/7] PCI: hv: Set up msi domain at bridge probing time Date: Mon, 3 May 2021 22:46:33 +0800 Message-Id: <20210503144635.2297386-6-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 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Since PCI_HYPERV depends on PCI_MSI_IRQ_DOMAIN which selects GENERIC_MSI_IRQ_DOMAIN, we can use dev_set_msi_domain() to set up the msi irq domain at probing time, and this works for both x86 and ARM64. Therefore use it as the preparation for ARM64 Hyper-V PCI support. As a result, there is no need to set the pci_sysdata::fwnode which is x86 specific. In addition, make hv_pcibus_device own the fwnode instead of sysdata to make the code generic. Signed-off-by: Boqun Feng --- drivers/pci/controller/pci-hyperv.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/pci/controller/pci-hyperv.c b/drivers/pci/controller/pci-hyperv.c index 05b73d5dfe9d..4ec7839d0adf 100644 --- a/drivers/pci/controller/pci-hyperv.c +++ b/drivers/pci/controller/pci-hyperv.c @@ -451,6 +451,7 @@ enum hv_pcibus_state { struct hv_pcibus_device { struct pci_sysdata sysdata; struct pci_host_bridge *bridge; + struct fwnode_handle *fwnode; /* Protocol version negotiated with the host */ enum pci_protocol_version_t protocol_version; enum hv_pcibus_state state; @@ -1571,7 +1572,7 @@ static int hv_pcie_init_irq_domain(struct hv_pcibus_device *hbus) hbus->msi_info.handler = handle_edge_irq; hbus->msi_info.handler_name = "edge"; hbus->msi_info.data = hbus; - hbus->irq_domain = pci_msi_create_irq_domain(hbus->sysdata.fwnode, + hbus->irq_domain = pci_msi_create_irq_domain(hbus->fwnode, &hbus->msi_info, x86_vector_domain); if (!hbus->irq_domain) { @@ -1580,6 +1581,8 @@ static int hv_pcie_init_irq_domain(struct hv_pcibus_device *hbus) return -ENODEV; } + dev_set_msi_domain(&hbus->bridge->dev, hbus->irq_domain); + return 0; } @@ -3147,9 +3150,9 @@ static int hv_pci_probe(struct hv_device *hdev, goto unmap; } - hbus->sysdata.fwnode = irq_domain_alloc_named_fwnode(name); + hbus->fwnode = irq_domain_alloc_named_fwnode(name); kfree(name); - if (!hbus->sysdata.fwnode) { + if (!hbus->fwnode) { ret = -ENOMEM; goto unmap; } @@ -3227,7 +3230,7 @@ static int hv_pci_probe(struct hv_device *hdev, free_irq_domain: irq_domain_remove(hbus->irq_domain); free_fwnode: - irq_domain_free_fwnode(hbus->sysdata.fwnode); + irq_domain_free_fwnode(hbus->fwnode); unmap: iounmap(hbus->cfg_addr); free_config: @@ -3325,7 +3328,7 @@ static int hv_pci_remove(struct hv_device *hdev) hv_free_config_window(hbus); hv_pci_free_bridge_windows(hbus); irq_domain_remove(hbus->irq_domain); - irq_domain_free_fwnode(hbus->sysdata.fwnode); + irq_domain_free_fwnode(hbus->fwnode); put_hvpcibus(hbus); wait_for_completion(&hbus->remove_event); destroy_workqueue(hbus->wq); From patchwork Mon May 3 14:46:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boqun Feng X-Patchwork-Id: 12236087 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=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 DC245C43611 for ; Mon, 3 May 2021 14:47:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C7993611C2 for ; Mon, 3 May 2021 14:47:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229968AbhECOsu (ORCPT ); Mon, 3 May 2021 10:48:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229852AbhECOsp (ORCPT ); Mon, 3 May 2021 10:48:45 -0400 Received: from mail-qk1-x72d.google.com (mail-qk1-x72d.google.com [IPv6:2607:f8b0:4864:20::72d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2FADCC06174A; Mon, 3 May 2021 07:47:52 -0700 (PDT) Received: by mail-qk1-x72d.google.com with SMTP id 197so4943787qkl.12; Mon, 03 May 2021 07:47:52 -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=09mjDqOchQ3sXLyBszDvLfbZqoTTMTmDKqqwf4ikQZc=; b=pmMsJxnVey9c4E53pvhRKlEYMcqliE6+RrOBshRD/M+ZTyjc9fmHmwm3wnJBOjHAVJ IoxAfwILIF79HKEN8ZOeXsjhpImJXJx9xAvNnbGNIdv5Nq2kN0ADIg4bGzHlh3+gZ+Tx T9CCEtfurLhqW9KOJi1N6hSgscu43eSoJP79Pn2aNmHU9GF18BFDSSPrLPdyt6+ix51l YHpIvMj8z0WuXZ/QS2tn/T3KIqlSySHLDlYmahJHqw8RF9mIpUdNF/sCvCNL6tuHqYCQ n3seNl+bmEIbXff96WBJCTnIYErxDfKUPQUJD3nLd9mp+sDlNzMoguHdj1ZN9v5wmSrL CheA== 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=09mjDqOchQ3sXLyBszDvLfbZqoTTMTmDKqqwf4ikQZc=; b=MSp22esGPYinSuGwYa/scIwbVK43kPGI/ljfrbyP53ivgP6R7Djqs3WzniklLNjJwP O89upGna4XvREb5Q6+oMTzC0XtA0ZzuvbDwEIMOJqdmXekhp1cG2UV1Y35jRX4ZZ2kv8 m74cx6oNJsFNjEzVAK7LNYp27MXUHdM8m0FfnVzHRqFrGQHhs7kAYRJ6pUtYjVUAvdld aL8J+S2KZ5e8v4LIcNtA+pPcYbDalWKAbP2dTiZtYtPcMLRj7ctEaWvWedwNGj9l3pEi f9dQOIr6xKxP6Dmt5w2I9jolzZBaq4u0d4LiumLVY5JPDQ9yOoCdAbCGzrCd/28bl8Go 1idA== X-Gm-Message-State: AOAM530FGbKU/u3h7sF0xL6i9GOpHkXmpPB9Oj1mD77wlFZFA3jiy6ci LufB3t/Ijpawqz5Ogc/cfjM= X-Google-Smtp-Source: ABdhPJwHMaknaOV1erqRimblxefA4bDS+Fyjtw1hIZw24oH0fma3iXqpy4sVMOm+4vJaCAJAJZ0QQw== X-Received: by 2002:a37:8084:: with SMTP id b126mr19407096qkd.175.1620053271518; Mon, 03 May 2021 07:47:51 -0700 (PDT) Received: from auth1-smtp.messagingengine.com (auth1-smtp.messagingengine.com. [66.111.4.227]) by smtp.gmail.com with ESMTPSA id a10sm4472qtm.16.2021.05.03.07.47.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 May 2021 07:47:51 -0700 (PDT) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailauth.nyi.internal (Postfix) with ESMTP id 3989B27C005A; Mon, 3 May 2021 10:47:50 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Mon, 03 May 2021 10:47:50 -0400 X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrvdefgedgkedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeeuohhquhhn ucfhvghnghcuoegsohhquhhnrdhfvghnghesghhmrghilhdrtghomheqnecuggftrfgrth htvghrnhephedvveetfefgiedutedtfeevvddvleekjeeuffffleeguefhhfejteekieeu ueelnecukfhppedufedurddutdejrddurddvheegnecuvehluhhsthgvrhfuihiivgepud 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:49 -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 6/7] PCI: arm64: Allow pci_config_window::parent to be NULL Date: Mon, 3 May 2021 22:46:34 +0800 Message-Id: <20210503144635.2297386-7-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 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org This is purely a hack, for ARM64 Hyper-V guest, there is no corresponding ACPI device for the root bridge, so the best we can provide is an all-zeroed pci_config_window, and in this case make pcibios_root_bridge_prepare() act as the ACPI device is NULL. Signed-off-by: Boqun Feng --- arch/arm64/kernel/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/kernel/pci.c b/arch/arm64/kernel/pci.c index e9a6eeb6a694..f159df903ccb 100644 --- a/arch/arm64/kernel/pci.c +++ b/arch/arm64/kernel/pci.c @@ -83,7 +83,7 @@ int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge) { if (!acpi_disabled) { struct pci_config_window *cfg = bridge->bus->sysdata; - struct acpi_device *adev = to_acpi_device(cfg->parent); + struct acpi_device *adev = cfg->parent ? to_acpi_device(cfg->parent) : NULL; struct device *bus_dev = &bridge->bus->dev; ACPI_COMPANION_SET(&bridge->dev, adev); From patchwork Mon May 3 14:46:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boqun Feng X-Patchwork-Id: 12236089 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=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 E44EBC43462 for ; Mon, 3 May 2021 14:48:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AF06B611C0 for ; Mon, 3 May 2021 14:48:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229951AbhECOsz (ORCPT ); Mon, 3 May 2021 10:48:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229924AbhECOst (ORCPT ); Mon, 3 May 2021 10:48:49 -0400 Received: from mail-qk1-x734.google.com (mail-qk1-x734.google.com [IPv6:2607:f8b0:4864:20::734]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F167C061343; Mon, 3 May 2021 07:47:53 -0700 (PDT) Received: by mail-qk1-x734.google.com with SMTP id 76so3413939qkn.13; Mon, 03 May 2021 07:47:53 -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=WmxD0ZZWyLDmbUI7WJl5Chz/U5d4iCfhGGuYidByI1Y=; b=c/7Dh3OQepXd3Gk7+Ktnjc/Q1371ta4WGDJVxAkXb0L72Joe3A+fNs0b5ySNu/jZoD vinJS+TmbfjEYKiAEX4R9lq6tDPkYOlWnfW54p6wLHRr16yh3U1nPH5k8cw29O2XuN5k vAgrU/G3YbZF6jq8+W/77AmS/QUqQxehMoC6oWYfDJgT9B+ih0/CTwM5oXYYkg9hzn9C 2/zxwc8VAuPm2b+ki/jnLscwtksaMRdc10Lek3dsjl+SYRhwAS6OlUjtFBRxb1pPCRNS ZRvP6/1CemSsV4rUkXoJhE4rNVLeT2q6wdJPPc0vcgkcq3gL/3jdWjNCpoQ0GlrKVTxf FbWw== 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=WmxD0ZZWyLDmbUI7WJl5Chz/U5d4iCfhGGuYidByI1Y=; b=VLVmEFfedjjofQdF4YLfMTC0aQd7GCpH/Y7OQft17FAuJtx/fMiqVtq/xBkM6UVreo sVQXle+cYD4iXvmFt2NEci04fS6e9abXEosaq+0+Dl1TnyDoc+5ifd9pol/zLa0hBy92 IykLge47BB11lWZyWx5uq9D7dR4Cxu9dmqMQYA4HHuS1E8Cpe+lD8A+BQE2Kuav6K7jF pfgXEYxWR+9bsjanB1CxQBC5BkY3CnXxWJuiC20TUkPabycfdjbRKwJ9aZTt2Y/yABNQ +VbTOoojMrwPrK0YSUxkagjUy4MzMPq4lhV2POZ07NRmDLlwqX+Q5oozZIn+BHDlkkmO lKNA== X-Gm-Message-State: AOAM530f7d0lJdmP4Aji7M6sXTCiElZs81iMY4JDikF1LxLyAlwmlOiy RHRWYo9P2N3B4MHIfigM+faPZ2d9u1gd2w== X-Google-Smtp-Source: ABdhPJwJQTQ+i5t7XI+bNqjB0PUR0SiUXldDNi1Jbkj/jxzJyLKY99BDP7WgJCH0Jv+QngE01hMA2g== X-Received: by 2002:a37:7004:: with SMTP id l4mr19996241qkc.476.1620053272797; Mon, 03 May 2021 07:47:52 -0700 (PDT) Received: from auth1-smtp.messagingengine.com (auth1-smtp.messagingengine.com. [66.111.4.227]) by smtp.gmail.com with ESMTPSA id w4sm7801qti.6.2021.05.03.07.47.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 May 2021 07:47:52 -0700 (PDT) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailauth.nyi.internal (Postfix) with ESMTP id 7B8A627C0054; Mon, 3 May 2021 10:47:51 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Mon, 03 May 2021 10:47:51 -0400 X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrvdefgedgkedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeeuohhquhhn ucfhvghnghcuoegsohhquhhnrdhfvghnghesghhmrghilhdrtghomheqnecuggftrfgrth htvghrnhephedvveetfefgiedutedtfeevvddvleekjeeuffffleeguefhhfejteekieeu ueelnecukfhppedufedurddutdejrddurddvheegnecuvehluhhsthgvrhfuihiivgepvd 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:50 -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 7/7] PCI: hv: Turn on the host bridge probing on ARM64 Date: Mon, 3 May 2021 22:46:35 +0800 Message-Id: <20210503144635.2297386-8-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 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Now we have everything we need, just provide a proper sysdata type for the bus to use on ARM64 and everything else works. Signed-off-by: Boqun Feng --- drivers/pci/controller/pci-hyperv.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/pci/controller/pci-hyperv.c b/drivers/pci/controller/pci-hyperv.c index 4ec7839d0adf..75ff47bedf2a 100644 --- a/drivers/pci/controller/pci-hyperv.c +++ b/drivers/pci/controller/pci-hyperv.c @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -449,7 +450,11 @@ enum hv_pcibus_state { }; struct hv_pcibus_device { +#ifdef CONFIG_X86 struct pci_sysdata sysdata; +#elif defined(CONFIG_ARM64) + struct pci_config_window sysdata; +#endif struct pci_host_bridge *bridge; struct fwnode_handle *fwnode; /* Protocol version negotiated with the host */ @@ -3102,7 +3107,9 @@ static int hv_pci_probe(struct hv_device *hdev, dom_req, dom); hbus->bridge->domain_nr = dom; +#ifdef CONFIG_X86 hbus->sysdata.domain = dom; +#endif hbus->hdev = hdev; refcount_set(&hbus->remove_lock, 1);