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=-15.8 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 2C1E8C636CE for ; Tue, 20 Jul 2021 14:02:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F1FFC6113C for ; Tue, 20 Jul 2021 14:02:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239709AbhGTNU7 (ORCPT ); Tue, 20 Jul 2021 09:20:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239017AbhGTNGf (ORCPT ); Tue, 20 Jul 2021 09:06:35 -0400 Received: from mail-il1-x12d.google.com (mail-il1-x12d.google.com [IPv6:2607:f8b0:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA35AC061768; Tue, 20 Jul 2021 06:46:36 -0700 (PDT) Received: by mail-il1-x12d.google.com with SMTP id o8so19179592ilf.4; Tue, 20 Jul 2021 06:46:36 -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=2l8LjoE1uOwDr72/zLLZTqmL1EazEamG/E8cAH7MR/4=; b=ajtns35Hl78+1NkA8OLkrxH68UpjGJpRlhocpJiDyrPbIuCE+Fk88T15LW08SJbo7f Hs2oZMp/weamcSU/VBHogx3cK5M3ZQHOLJtgVOr4fWy7vEw/MLQbX41/plFyh8Tqpu53 j0mcbP1SeSrw78RVy7QPhbYKf0S9ZPHyUwxKmRS1biWti+jrXEu0y2bTYEhqqJAuYeMK 9/a2enqhvdzo0v8GrQU5si9Ug7A9hYUJK3IT5qfbRIwApA56c379jd/6blSjWAr2hBa4 Y32NwJH+5yPYPr6NDxysobobvJ/Gake7iJjUYzeYjqF/48bBW1r56PMvqaUdOTGFYM09 MVaA== 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=2l8LjoE1uOwDr72/zLLZTqmL1EazEamG/E8cAH7MR/4=; b=kBPjiFPw6HXVLCkvqZYNbCbmEKrHetyvq6u4NuLSwJFwMnL8C8yBRAHd6YLpOt2T3u gPwcSJuHHV0XWHJg3tIH0yhJloJ9FVOn+QyvC0JmwiLvmXQQUgY/bMs0rQdfTalNswbQ 6qmmZt30ayKI+eRAyNZOOGhgL7nItctn9ElBDCHsUR5s1J78CeTofN+pTbEVn0XzCKDx 2i8B5W5DngYZ5JlzDOIXJ4tT26tV3+PTNWu8FayHYJNTBGGHXff/+E6N0vcH+y33soxG 4aOLU6lW4a0GQEzUeQBxct38HASIUclHCXhJvysI3yL+BXx2W6FcRHhiD2+gYON9ZnYc He8g== X-Gm-Message-State: AOAM5335tgi+K0aAFeEp5p2lRcK7PQqTfRs97H02yVvTzEsmJ6uC5TxI dTCDLtYZz6iVJ1SRI49Wwjs= X-Google-Smtp-Source: ABdhPJy5ZlVtS2IpZV+E+tOkjNyl6ikMUUAhFR+jcPbGFJGtQfIDSPtenYJW7ZQP80qXkGRFquPENg== X-Received: by 2002:a92:1906:: with SMTP id 6mr20466375ilz.273.1626788796357; Tue, 20 Jul 2021 06:46:36 -0700 (PDT) Received: from auth2-smtp.messagingengine.com (auth2-smtp.messagingengine.com. [66.111.4.228]) by smtp.gmail.com with ESMTPSA id o13sm11445110ilq.58.2021.07.20.06.46.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jul 2021 06:46:36 -0700 (PDT) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailauth.nyi.internal (Postfix) with ESMTP id 1865E27C0054; Tue, 20 Jul 2021 09:46:35 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Tue, 20 Jul 2021 09:46:35 -0400 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrfedvgdeijecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepuehoqhhunhcu hfgvnhhguceosghoqhhunhdrfhgvnhhgsehgmhgrihhlrdgtohhmqeenucggtffrrghtth gvrhhnpeehvdevteefgfeiudettdefvedvvdelkeejueffffelgeeuhffhjeetkeeiueeu leenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegsoh hquhhnodhmvghsmhhtphgruhhthhhpvghrshhonhgrlhhithihqdeiledvgeehtdeigedq udejjeekheehhedvqdgsohhquhhnrdhfvghngheppehgmhgrihhlrdgtohhmsehfihigmh gvrdhnrghmvg X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 20 Jul 2021 09:46:34 -0400 (EDT) From: Boqun Feng To: Bjorn Helgaas , Arnd Bergmann , Marc Zyngier Cc: Catalin Marinas , Will Deacon , "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , Wei Liu , Dexuan Cui , Lorenzo Pieralisi , Rob Herring , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , Boqun Feng , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-hyperv@vger.kernel.org, linux-pci@vger.kernel.org, Sunil Muthuswamy , Mike Rapoport Subject: [RFC v5 4/8] arm64: PCI: Support root bridge preparation for Hyper-V Date: Tue, 20 Jul 2021 21:44:25 +0800 Message-Id: <20210720134429.511541-5-boqun.feng@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210720134429.511541-1-boqun.feng@gmail.com> References: <20210720134429.511541-1-boqun.feng@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently at root bridge preparation, the corresponding ACPI device will be set as the companion, however for a Hyper-V virtual PCI root bridge, there is no corresponding ACPI device, because a Hyper-V virtual PCI root bridge is discovered via VMBus rather than ACPI table. In order to support this, we need to make pcibios_root_bridge_prepare() work with cfg->parent being NULL. Use a NULL pointer as the ACPI device if there is no corresponding ACPI device, and this is fine because: 1) ACPI_COMPANION_SET() can work with the second parameter being NULL, 2) semantically, if a NULL pointer is set via ACPI_COMPANION_SET(), ACPI_COMPANION() (the read API for this field) will return NULL, and since ACPI_COMPANION() may return NULL, so users must have handled the cases where it returns NULL, and 3) since there is no corresponding ACPI device, it would be wrong to use any other value here. Signed-off-by: Boqun Feng --- arch/arm64/kernel/pci.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kernel/pci.c b/arch/arm64/kernel/pci.c index 5148ae242780..2276689b5411 100644 --- a/arch/arm64/kernel/pci.c +++ b/arch/arm64/kernel/pci.c @@ -90,7 +90,17 @@ int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge) return 0; cfg = bridge->bus->sysdata; - adev = to_acpi_device(cfg->parent); + + /* + * On Hyper-V there is no corresponding ACPI device for a root bridge, + * therefore ->parent is set as NULL by the driver. And set 'adev' as + * NULL in this case because there is no proper ACPI device. + */ + if (!cfg->parent) + adev = NULL; + else + adev = to_acpi_device(cfg->parent); + bus_dev = &bridge->bus->dev; ACPI_COMPANION_SET(&bridge->dev, adev); -- 2.30.2 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=ham 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 CDCE8C07E9B for ; Tue, 20 Jul 2021 13:50:08 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 98E2A61165 for ; Tue, 20 Jul 2021 13:50:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 98E2A61165 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=bombadil.20210309; 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=Xf0c+gRGF6+J25Gc2AfNP+Setvqr7qLzRl6YdxqM8PA=; b=lxYSl1Pxoa36OY nC5n8RZfRrmn4YgWRkxVP/cgJggIH0qcuKzC2DerIKrl5/YU9kbZZGB5/EaVbSjLpwh4dmx0JblC4 obPnvlKRLDq/ONMOXg0C3OW0ArwYMultf16qHC1lhP7E8Uw96m3pu635a1LjjHeJOdvGo5HSbAEaa m033fYsU8U8l2phIN/G2XQL57X2UWGFvjwjmgChx7n3Zw0XQBXeK1av6//oHXQ1Vv27+hYLR6RsVq 0jRhB1Z2G4ZXE0dhS6iuvWIwPhXwcBVrV/jxHLAyLNyNu40YUV8xyGVd714AB2RmQOuuVob0HOg3d oMKdZ9SErW+o8yzwxlwQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m5q5o-00CzWU-Oz; Tue, 20 Jul 2021 13:47:29 +0000 Received: from mail-il1-x12e.google.com ([2607:f8b0:4864:20::12e]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m5q4z-00CzMD-2z for linux-arm-kernel@lists.infradead.org; Tue, 20 Jul 2021 13:46:38 +0000 Received: by mail-il1-x12e.google.com with SMTP id z1so19218897ils.0 for ; Tue, 20 Jul 2021 06:46:36 -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=2l8LjoE1uOwDr72/zLLZTqmL1EazEamG/E8cAH7MR/4=; b=ajtns35Hl78+1NkA8OLkrxH68UpjGJpRlhocpJiDyrPbIuCE+Fk88T15LW08SJbo7f Hs2oZMp/weamcSU/VBHogx3cK5M3ZQHOLJtgVOr4fWy7vEw/MLQbX41/plFyh8Tqpu53 j0mcbP1SeSrw78RVy7QPhbYKf0S9ZPHyUwxKmRS1biWti+jrXEu0y2bTYEhqqJAuYeMK 9/a2enqhvdzo0v8GrQU5si9Ug7A9hYUJK3IT5qfbRIwApA56c379jd/6blSjWAr2hBa4 Y32NwJH+5yPYPr6NDxysobobvJ/Gake7iJjUYzeYjqF/48bBW1r56PMvqaUdOTGFYM09 MVaA== 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=2l8LjoE1uOwDr72/zLLZTqmL1EazEamG/E8cAH7MR/4=; b=P3GHnbA3RSQoMfFDtdRwt9Uz3i8IY0p+HEhtdrJtCgeAZEM7qK/cqahq143bljVHvz Zs01qkgnNytC9u10jh7mj+rYsEbUEdgqZyWoIDUIYnOnABBPIr7myb0iKA+3m6aPLrkJ vkjFxnh/oSqsNoMV2ET5kQLlTnE03uCis2SaOrbCVW1WJfVgSLthO/9vs7rq+H8wS7nd K50HZ3uVlJ81nJht1tYb+56cO1Wznbb+x+EJ1cnAcaKbKNh5W9wDREsDwh7CKoadbkGs 5QjVGOuOLLSbbXxuCWZRbUPrZprOvxBQzX7Awa/E20d+DqpOkSCrevx41jT4ylpExkNW eirg== X-Gm-Message-State: AOAM531WXbH9YTcRI5naWEkIJk/09tHoJAeJCu3MxraYt2eGEEar4CHS NTSfIiUBIuXv1vnRKxs3oKI= X-Google-Smtp-Source: ABdhPJy5ZlVtS2IpZV+E+tOkjNyl6ikMUUAhFR+jcPbGFJGtQfIDSPtenYJW7ZQP80qXkGRFquPENg== X-Received: by 2002:a92:1906:: with SMTP id 6mr20466375ilz.273.1626788796357; Tue, 20 Jul 2021 06:46:36 -0700 (PDT) Received: from auth2-smtp.messagingengine.com (auth2-smtp.messagingengine.com. [66.111.4.228]) by smtp.gmail.com with ESMTPSA id o13sm11445110ilq.58.2021.07.20.06.46.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jul 2021 06:46:36 -0700 (PDT) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailauth.nyi.internal (Postfix) with ESMTP id 1865E27C0054; Tue, 20 Jul 2021 09:46:35 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Tue, 20 Jul 2021 09:46:35 -0400 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrfedvgdeijecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepuehoqhhunhcu hfgvnhhguceosghoqhhunhdrfhgvnhhgsehgmhgrihhlrdgtohhmqeenucggtffrrghtth gvrhhnpeehvdevteefgfeiudettdefvedvvdelkeejueffffelgeeuhffhjeetkeeiueeu leenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegsoh hquhhnodhmvghsmhhtphgruhhthhhpvghrshhonhgrlhhithihqdeiledvgeehtdeigedq udejjeekheehhedvqdgsohhquhhnrdhfvghngheppehgmhgrihhlrdgtohhmsehfihigmh gvrdhnrghmvg X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 20 Jul 2021 09:46:34 -0400 (EDT) From: Boqun Feng To: Bjorn Helgaas , Arnd Bergmann , Marc Zyngier Cc: Catalin Marinas , Will Deacon , "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , Wei Liu , Dexuan Cui , Lorenzo Pieralisi , Rob Herring , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , Boqun Feng , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-hyperv@vger.kernel.org, linux-pci@vger.kernel.org, Sunil Muthuswamy , Mike Rapoport Subject: [RFC v5 4/8] arm64: PCI: Support root bridge preparation for Hyper-V Date: Tue, 20 Jul 2021 21:44:25 +0800 Message-Id: <20210720134429.511541-5-boqun.feng@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210720134429.511541-1-boqun.feng@gmail.com> References: <20210720134429.511541-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-20210720_064637_172735_204311AB X-CRM114-Status: GOOD ( 18.46 ) 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 at root bridge preparation, the corresponding ACPI device will be set as the companion, however for a Hyper-V virtual PCI root bridge, there is no corresponding ACPI device, because a Hyper-V virtual PCI root bridge is discovered via VMBus rather than ACPI table. In order to support this, we need to make pcibios_root_bridge_prepare() work with cfg->parent being NULL. Use a NULL pointer as the ACPI device if there is no corresponding ACPI device, and this is fine because: 1) ACPI_COMPANION_SET() can work with the second parameter being NULL, 2) semantically, if a NULL pointer is set via ACPI_COMPANION_SET(), ACPI_COMPANION() (the read API for this field) will return NULL, and since ACPI_COMPANION() may return NULL, so users must have handled the cases where it returns NULL, and 3) since there is no corresponding ACPI device, it would be wrong to use any other value here. Signed-off-by: Boqun Feng --- arch/arm64/kernel/pci.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kernel/pci.c b/arch/arm64/kernel/pci.c index 5148ae242780..2276689b5411 100644 --- a/arch/arm64/kernel/pci.c +++ b/arch/arm64/kernel/pci.c @@ -90,7 +90,17 @@ int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge) return 0; cfg = bridge->bus->sysdata; - adev = to_acpi_device(cfg->parent); + + /* + * On Hyper-V there is no corresponding ACPI device for a root bridge, + * therefore ->parent is set as NULL by the driver. And set 'adev' as + * NULL in this case because there is no proper ACPI device. + */ + if (!cfg->parent) + adev = NULL; + else + adev = to_acpi_device(cfg->parent); + bus_dev = &bridge->bus->dev; ACPI_COMPANION_SET(&bridge->dev, adev); -- 2.30.2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel