From patchwork Mon Jul 26 18:06:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boqun Feng X-Patchwork-Id: 12400499 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 BFBF2C4338F for ; Mon, 26 Jul 2021 18:10:12 +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 8D50160F90 for ; Mon, 26 Jul 2021 18:10:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 8D50160F90 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=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=iICT58hFj1a/JSEVHqvJ8ZBU6ox64poQqMLQplL7NFs=; b=I0LvwoLPD868JG JjSE4708rkb7aHyMSSupJLEZmIuEPNS+IZfmdKoYQUv+CwNJaMp+GW3caASLKOW34SvhNxYqqf19K s9RR4UP5NpmFKbwCmy1/qLhkSCMaHwIbII+tS43HANANNJcuXfxffGEiMEvzRbYeqVfjBv1J5RDOm g+ARHuqGCQNyVVTzfHOrWptL7RA1VRRCoOBJYY5UQIh7MEJBNj7FgTTp3c6+jINdNBSSTx0TvtzYx hNnC/BAxX/c3cPxvcL/cnmIROOa872XYZ+iv3rOKUaTuiFtIdAT8ozwE7sBGqrF/lFMZsJ4Pvt3Cb RhrSvr/i2P9t62NaPi1w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m851f-00CC47-P9; Mon, 26 Jul 2021 18:08:28 +0000 Received: from mail-io1-xd2b.google.com ([2607:f8b0:4864:20::d2b]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m850i-00CBoz-7G for linux-arm-kernel@lists.infradead.org; Mon, 26 Jul 2021 18:07:30 +0000 Received: by mail-io1-xd2b.google.com with SMTP id r6so13006583ioj.8 for ; Mon, 26 Jul 2021 11:07:27 -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=drzvjYjf9v4fqS1iU+Dz/o3PJvwLUgUtNuIzGT8WydQ=; b=dYH2Rpw/sGNj8TqMiLdymjdVY0FzhPA2uRtfUYyplAfZJUPu2kQNs9ZE5ukJ7zwrqI spKKtLHkqgweKrKQJkL33rVdZmel/h2nL+DpEXiEFU+tQ6VzbXyussz3pEKylFicPeXV 63B2VUJf1ckMqk4adXnYjxg5pWrY8Y2nalAejKBp+M2C1bchiqbIoo3V1NwZWKC23Qa0 K/q+U4zfKlC4q3xXgy4R4SOgZSxlHJLWpmJUkuBWCcYlT3/y0zgYT59W06F4n06bvQQH MDpf1W68m5KMPyJTtCSMU7STejgPaLwpkCl8qbSCQuIYAEw1qdXGLp9BVlmyxW6H5L46 dSvA== 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=drzvjYjf9v4fqS1iU+Dz/o3PJvwLUgUtNuIzGT8WydQ=; b=EX9/QO1UQC/4MNP0VqhDGPBoe4K6ty9tMrIF7MhguTteHaWmvila8K7Md8zLNBtKk7 DjUN96UP+4uxl4Cg0QqEx8Ant/Kh6kxVNlx7xoDLrgvbasmE/0rSCwea7y5NLnBpfA0e MnllZgY1+7hHW3/8Xa9p+k6UdOhJuY8eFVoopKvqa57EXZORi6FfgaPM7Nuylc0x7fvz 3dyEE2xzA8kjLMJ2O3CDiEp2cqEhhA900AK77UPdKfIo70sgbmcwogrQtPEZ8WYAfG+H SD+qUvQzVrVp//dhRMwQiaFOTUHLD7QMIDLLkXbhWOtU7wV7HTWAXkFzc+2wdkDacojO MlVA== X-Gm-Message-State: AOAM531atN8Rx8NMUXdGEmAVYGRHUC014GZ5aP1s9UY/Gxr1n8mFe0a5 73J416nWKxE812E/JHUF5cU= X-Google-Smtp-Source: ABdhPJwYZr8saZ1l0/26xD/I+LMdt9FzRCWubyN+UOi7ghTOrLlNcA6F9VTgZcmh0ysNN5b21EezDQ== X-Received: by 2002:a6b:1685:: with SMTP id 127mr15950564iow.135.1627322847362; Mon, 26 Jul 2021 11:07:27 -0700 (PDT) Received: from auth1-smtp.messagingengine.com (auth1-smtp.messagingengine.com. [66.111.4.227]) by smtp.gmail.com with ESMTPSA id a1sm264889ilp.1.2021.07.26.11.07.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Jul 2021 11:07:26 -0700 (PDT) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailauth.nyi.internal (Postfix) with ESMTP id ED4CE27C0068; Mon, 26 Jul 2021 14:07:25 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Mon, 26 Jul 2021 14:07:25 -0400 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrgeehgdduudejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeeuohhquhhn ucfhvghnghcuoegsohhquhhnrdhfvghnghesghhmrghilhdrtghomheqnecuggftrfgrth htvghrnhephedvveetfefgiedutedtfeevvddvleekjeeuffffleeguefhhfejteekieeu ueelnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepsg hoqhhunhdomhgvshhmthhprghuthhhphgvrhhsohhnrghlihhthidqieelvdeghedtieeg qddujeejkeehheehvddqsghoqhhunhdrfhgvnhhgpeepghhmrghilhdrtghomhesfhhigi hmvgdrnhgrmhgv X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 26 Jul 2021 14:07:25 -0400 (EDT) From: Boqun Feng To: Bjorn Helgaas , Arnd Bergmann , Marc Zyngier , Lorenzo Pieralisi Cc: Catalin Marinas , Will Deacon , "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , Wei Liu , Dexuan Cui , Rob Herring , =?utf-8?q?Krzysztof_Wilczy=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: [PATCH v6 4/8] arm64: PCI: Support root bridge preparation for Hyper-V Date: Tue, 27 Jul 2021 02:06:53 +0800 Message-Id: <20210726180657.142727-5-boqun.feng@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210726180657.142727-1-boqun.feng@gmail.com> References: <20210726180657.142727-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-20210726_110728_335251_1D510971 X-CRM114-Status: GOOD ( 18.73 ) 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: , 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 Acked-by: Catalin Marinas --- 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);