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.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 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 29049C433B4 for ; Thu, 6 May 2021 10:56:51 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 6388B610D2 for ; Thu, 6 May 2021 10:56:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6388B610D2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.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=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: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:List-Owner; bh=OrJkE47BLDsvodZot/mNtslDJOCZuWAXi91xl1k05Tg=; b=iLKegqmamv6gHWe7PrCTxieg9 V1H0d7hUFPDuUOL+wZYoagd4m2myx+eNGX6Z/FaqdqAScgO5D/jqhjaN7LvvaSqSC5s5PjdAQfRi8 2xE+n8DjFTt69nz6EqnAYKE+5blW3idMHW8Rj98G2VZkN2velLy22p/ScoFuOITmTICkJYkiwMUOn Jhpau5xI/EWR1FQOrQxqbPxs8XHji5CAOXHTH8GV03QlAOYiFzA/+GUvUDAMi7B5mf9+OR1aXKDNd hKbKOfFxtsXGnGikJnQlN9h/TSkULr19qJFFlteaV0zfF1+pgfH6wVqlsO2rWp0xVdqtvK2/r/GqX TkA1OV2CQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lebda-0042q5-5Y; Thu, 06 May 2021 10:53:46 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lebcp-0042ks-Po for linux-arm-kernel@desiato.infradead.org; Thu, 06 May 2021 10:53:08 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=+jSJzry9icFniLqciTA/7+WFfuW23XjmW8QkJiANcFg=; b=A4fPztV4HEdKKrk2FmMbp4NkFX SXqWy1xW0R0j4bI/NZw1BCx3S4SQcv+owecmVVgSc5E7b3/dSb/bBxsO93e/hWKg6LFEM4xB7FMc3 7hdt36mf/snqEuqhk+lZHhFGPb9Jr/IP4yMkF4OBHHd0NIE8WpYPQ08jpgXVgXyU3xMMYvd/frc+f m27k4F2jphrgBv+l8qr7Y51OeDkJcBtuHnygJpiR29PNyFWG0orMQw4CnC9Q9f4jZtHWZ55ZlBth5 pu6G+dDFYdXp1ODD5ALtF/ryZ57jzNS7paxQM+n9h3KKLL7ZW6uJ1ATzRB6YpAI8XyK9s4eGp4szf g5/iTdkg==; Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lebcn-005xvC-2P for linux-arm-kernel@lists.infradead.org; Thu, 06 May 2021 10:52:58 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 89FF4D6E; Thu, 6 May 2021 03:52:53 -0700 (PDT) Received: from lpieralisi (e121166-lin.cambridge.arm.com [10.1.196.255]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 5BD663F73B; Thu, 6 May 2021 03:52:50 -0700 (PDT) Date: Thu, 6 May 2021 11:52:45 +0100 From: Lorenzo Pieralisi To: Mike Rapoport Cc: Boqun Feng , Bjorn Helgaas , Arnd Bergmann , Marc Zyngier , Russell King , Andrew Lunn , Sebastian Hesselbarth , Gregory Clement , Catalin Marinas , Will Deacon , Thomas Bogendoerfer , Rob Herring , "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , Wei Liu , Thomas Petazzoni , 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: Re: [RFC v2 1/7] PCI: Introduce pci_host_bridge::domain_nr Message-ID: <20210506105245.GA26351@lpieralisi> References: <20210503144635.2297386-1-boqun.feng@gmail.com> <20210503144635.2297386-2-boqun.feng@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210506_035257_228432_5929F808 X-CRM114-Status: GOOD ( 30.21 ) 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 Tue, May 04, 2021 at 08:16:30AM +0300, Mike Rapoport wrote: > On Mon, May 03, 2021 at 10:46:29PM +0800, Boqun Feng wrote: > > 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); > > The check for CONFIG_PCI_DOMAINS_GENERIC is excessive because there is a > stub for pci_bus_find_domain_nr(). > > I'm not an expert in PCI, but maybe the repeated assignment of > bridge->domain_nr can live in the generic code, say, in > pci_scan_root_bus_bridge(). E.g. it will set the domain_nr when it is zero. > > > Yes, this churn should be avoided. We need a sentinel value to detect whether the domain_nr is invalid (0 is a valid domain) so generic code (ie pci_scan_root_bus_bridge() and friends) has to call generic functions to get it (pci_bus_find_domain_nr()). We can implement it as a flag or function pointer in the struct pci_host_bridge, if the flag or function pointer is not set the generic pci_bus_find_domain_nr() should be called. Lorenzo _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel