Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp680333pxv; Wed, 14 Jul 2021 12:54:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxDqg87l1D6BaPvQvb4vZnlISaG6YKLXQnZNDp23Zdy2nBCebHoBJzY0hi7V0DopGp2L4vr X-Received: by 2002:aa7:cac8:: with SMTP id l8mr15650893edt.135.1626292497098; Wed, 14 Jul 2021 12:54:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626292497; cv=none; d=google.com; s=arc-20160816; b=uvnGmCFeiKURC8G96Vvv5YrxF5+vNzm+pjliSvUYPqJpeCSzLXmTHD7anNUQ7fhtGi 2ErdGmV3QYg647AUHJIb+XTo4Tdd89mAIKGM3kZ0Bm5vMJ3GSzyB04hg+7BWs+rQvifE L9tXZCnjCpLZaXCpDXg1XzpPQQmQivIVxQ9b3IhINh84DlKhjpRyfov/YEQ5FqdIBt+4 ELASbnaUYajFW8dLDwPj+bu4zzOI6BYpEjDNUrve0oP0PeN3goUKVa9I2bS9YdbsfmuI TPi5dRuRBqzGb6O0q57od6WuyKt1l92ktzf4wObEwqOIUvi2vLAKKv1nGH6f71ewb7iw VXHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :message-id:subject:cc:to:from:date:dkim-signature; bh=sKlKfOo5q16NPg8gOOU1+oPrnhPSMiw74PF0orYj1fE=; b=bzVfUFq+HBWjz/Nhpeob+LykGHZPCP8p5KPpGUs/fq8N7z+pqKPybej8gd2dfPTiKG zJ3t+x/CLCqVgcuHbYJRqjSC9KJ0RmjUDg5JlzNjMfaUQDywcf3YueBBio4XJLqk+BH3 biLdFvZMHDnkxozDYDxdfZ5/qJaFP0mifWRjT64Rq7B4Svq7imHrroaunL3CaY0fVD9A Mfkj8tSwU13IiiBdEJx1Dd6VftRR3ajMT9xZKWoO2JWmSb7r5auT8nTor+SuezIE0V3C ntId5Xs8hH66eCj486kWah8zGFrlyYAc46FQw+KStrGjvHExSlG+NS4TyaTGPt5JdCdf jo9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=uLDQholb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gf2si4261433ejb.500.2021.07.14.12.54.32; Wed, 14 Jul 2021 12:54:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=uLDQholb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233149AbhGNT4M (ORCPT + 99 others); Wed, 14 Jul 2021 15:56:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:47274 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241080AbhGNTuW (ORCPT ); Wed, 14 Jul 2021 15:50:22 -0400 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-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210714102737.198432-4-boqun.feng@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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