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=-14.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 1246CC12002 for ; Wed, 14 Jul 2021 22:46:50 +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 BF402613C2 for ; Wed, 14 Jul 2021 22:46:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BF402613C2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org 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:In-Reply-To:MIME-Version:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:References: List-Owner; bh=6+cdRocl2PINA/2Fs4Y3Ahe0UpjGXqZ7sIRxFaW9Kzc=; b=ApmaH0XPEfgHJU ybD/qBuSEhRhf6v4fm2A384hZHVpw2AZSR/8j2r8Qq2LK+vtf6dTjRTk5jidtP1UEzZNYUF4GFsuE ZcgAn62fVIZT7KJJPP0g5nbrrOjd2XkhaVsKl1dU5AoG6incEdtNCatXlllp/aVlGbMi33x4SaF12 Eukhu6hIRIvnrQkzrYY2CUnF6eT0gzAhE74E0foY6sNIdRDArbUO5d+Xd6ZUwiVldMTOktL//KIxS zxkmXdkLKV3wPs6Q0LL7Seajp6E73qyBtvSQ/qytHCYKsJ62wYJnAMA/tCvjgQ2NZMbPxERzFVdbV l0GYVZWHUkya0JV1wHRg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m3ncA-00FyTF-2U; Wed, 14 Jul 2021 22:44:26 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m3kqE-00EgO0-Va for linux-arm-kernel@lists.infradead.org; Wed, 14 Jul 2021 19:46:48 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 889A8613CA; Wed, 14 Jul 2021 19:46:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1626292006; bh=8qRBxphBatvbhZhhB7xXPoJR7ipkIeRYImlsAsgH3UE=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=uLDQholbw39gQGez83hc0Sb5Xt6rJzkYrHJwgyEtrRq04FtUGalzuRmdtJ2hVsLl8 ycKT8paFjpnCMquRqRsamNSPeikMuZ9/EZ6ihIWt3GTIvxRczkHlP9IcC/MAiXzhHn x7sHAOUz4Yvvzxgx+Y8cyj5vu4vSq4hL/n79cQHtkSd55iWTwZR2SbX3oeHkCskzob iUMhwYjZwrYoiryYW+4Lwt0JUGwWC+eavGZOTh14XTPYjClNTL6wgO2n/FzXD8etoD f5seRlVErs48dQyXQjgOaBLQuiXr2rH7GGsgQ7LTKJroslTIuxTVy4pi/aK+v5KaJW WIJEuZZF9cCyA== Date: Wed, 14 Jul 2021 14:46:45 -0500 From: Bjorn Helgaas To: Boqun Feng Cc: Bjorn Helgaas , Arnd Bergmann , Marc Zyngier , Catalin Marinas , Will Deacon , "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , Wei Liu , Dexuan Cui , Lorenzo Pieralisi , Rob Herring , Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= , 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: Re: [RFC v4 3/7] arm64: PCI: Support root bridge preparation for Hyper-V PCI Message-ID: <20210714194645.GA1869525@bjorn-Precision-5520> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210714102737.198432-4-boqun.feng@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210714_124647_093497_C14B5C79 X-CRM114-Status: GOOD ( 25.14 ) 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 On Wed, Jul 14, 2021 at 06:27:33PM +0800, Boqun Feng wrote: > 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. It would be nice to have a hint about why we don't actually need the ACPI companion device in this case. > Signed-off-by: Boqun Feng > --- > arch/arm64/kernel/pci.c | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > diff --git a/arch/arm64/kernel/pci.c b/arch/arm64/kernel/pci.c > index 1006ed2d7c60..3b81ac42bc1f 100644 > --- a/arch/arm64/kernel/pci.c > +++ b/arch/arm64/kernel/pci.c > @@ -84,7 +84,13 @@ 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); > + /* > + * On Hyper-V there is no corresponding APCI 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. > + */ > + 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); s/APCI/ACPI/ above. I think this would be more readable like this: struct pci_config_window *cfg = bridge->bus->sysdata; ... if (acpi_disabled) return 0; /* * On Hyper-V there is no corresponding ACPI device for a root * ... */ cfg = bridge->bus->sysdata; if (!cfg->parent) return 0; adev = to_acpi_device(cfg->parent); bus_dev = &bridge->bus->dev; ACPI_COMPANION_SET(&bridge->dev, adev); ... This could be done in two steps: the first to restructure the code without making any functional change, and a second to return when there's no cfg->parent. If you do it in one step, the patch will be much harder to read. Bjorn _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel