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=-16.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 80DA7C433E2 for ; Sat, 20 Mar 2021 12:53:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 34A5C61949 for ; Sat, 20 Mar 2021 12:53:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229756AbhCTMwk (ORCPT ); Sat, 20 Mar 2021 08:52:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:39462 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229583AbhCTMw2 (ORCPT ); Sat, 20 Mar 2021 08:52:28 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D5E2361975; Sat, 20 Mar 2021 12:52:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1616244747; bh=FXeHEEFPZu+Z4OujvA8/CNPvD0oljphMbhJMuOs+OXM=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=K1bCLgGHIESUpuy8gK8SpKrBsiI4KgDJFRhoPxjusuXnUlSivdfgWm4zq4Rod8Oo3 7Mrm8Tb9XocWRJ587fu3susWkesvhYU7/0pfNilGD+BCA3Di2bc3LlaVYhCjqSWXuo VKDsgNE5YShjld+XOx+10Wv27MNwq01zur5FVzqZKwZiARO6NILQmdoOshYy8eTqyF aydtyunWmoU/vVTUKfMd57nh/J/0dZbOq4uZ9nYmpb6Z6kyA43uRwZFdR2kl1t4CSu lkx8s8QwVetVwRB/O4fDD5TwfbqsRxwjaE+K/x5UxIPaTenvtQC1eWdLWJ3i/evqe8 P/CqJjQtlrC2A== Received: by mail-ot1-f53.google.com with SMTP id 31-20020a9d00220000b02901b64b9b50b1so11194869ota.9; Sat, 20 Mar 2021 05:52:27 -0700 (PDT) X-Gm-Message-State: AOAM5307L8ewCbJ/UF8yrcHbol0KjUE1DsDCLtSZUUEshbhX+r7SvMfO w5JUMNAT01bvMX3yKWhHEyy1XTlHB9aSgqa5Efc= X-Google-Smtp-Source: ABdhPJytWWTHbNfc/Z6ZiNhGc5dEtnzbBd5XnL42oX7cqny6BlJyDJiN6PM6uRjOYArjqYeBxwpkoKmLUKXyzx1BzqQ= X-Received: by 2002:a05:6830:14c1:: with SMTP id t1mr4831024otq.305.1616244747072; Sat, 20 Mar 2021 05:52:27 -0700 (PDT) MIME-Version: 1.0 References: <20210319161956.2838291-1-boqun.feng@gmail.com> <20210319161956.2838291-2-boqun.feng@gmail.com> In-Reply-To: <20210319161956.2838291-2-boqun.feng@gmail.com> From: Arnd Bergmann Date: Sat, 20 Mar 2021 13:52:10 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC 1/2] arm64: PCI: Allow use arch-specific pci sysdata To: Boqun Feng Cc: Bjorn Helgaas , Linux ARM , Linux Kernel Mailing List , Linux on Hyper-V List , linux-pci , Catalin Marinas , Will Deacon , "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , Wei Liu , Lorenzo Pieralisi , Rob Herring , Clint Sbisa , Ard Biesheuvel , Sunil Muthuswamy Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 19, 2021 at 5:22 PM Boqun Feng wrote: > > Currently, if an architecture selects CONFIG_PCI_DOMAINS_GENERIC, the > ->sysdata in bus and bridge will be treated as struct pci_config_window, > which is created by generic ECAM using the data from acpi. > > However, for a virtualized PCI bus, there might be no enough data in of > or acpi table to create a pci_config_window. This is similar to the case > where CONFIG_PCI_DOMAINS_GENERIC=n, IOW, architectures use their own > structure for sysdata, so no apci table lookup is required. > > In order to enable Hyper-V's virtual PCI (which doesn't have acpi table > entry for PCI) on ARM64 (which selects CONFIG_PCI_DOMAINS_GENERIC), we > introduce arch-specific pci sysdata (similar to the one for x86) for > ARM64, and allow the core PCI code to detect the type of sysdata at the > runtime. The latter is achieved by adding a pci_ops::use_arch_sysdata > field. > > Originally-by: Sunil Muthuswamy > Signed-off-by: Boqun Feng (Microsoft) I think this takes it in the opposite direction of where it should be going. > --- > arch/arm64/include/asm/pci.h | 29 +++++++++++++++++++++++++++++ > arch/arm64/kernel/pci.c | 15 ++++++++++++--- > include/linux/pci.h | 3 +++ > 3 files changed, 44 insertions(+), 3 deletions(-) > > diff --git a/arch/arm64/include/asm/pci.h b/arch/arm64/include/asm/pci.h > index b33ca260e3c9..dade061a0658 100644 > --- a/arch/arm64/include/asm/pci.h > +++ b/arch/arm64/include/asm/pci.h > @@ -22,6 +22,16 @@ > > extern int isa_dma_bridge_buggy; > > +struct pci_sysdata { > + int domain; /* PCI domain */ > + int node; /* NUMA Node */ > +#ifdef CONFIG_ACPI > + struct acpi_device *companion; /* ACPI companion device */ > +#endif > +#ifdef CONFIG_PCI_MSI_IRQ_DOMAIN > + void *fwnode; /* IRQ domain for MSI assignment */ > +#endif > +}; I think none of these members belong into sysdata or architecture specific code. The fact that a pci_host_bridge belongs to a particular NUMA node or i associated with a firmware description is neither specific to a host bridge implementation nor a CPU instruction set! Moreover, you cannot assume that all PCI host bridges on any given architecture can share the pci_sysdata pointer, it is purely specific to the bridge driver. A good start would be to move the members (one at a time) into struct pci_host_bridge and out of the sysdata of individual host bridge drivers. > diff --git a/arch/arm64/kernel/pci.c b/arch/arm64/kernel/pci.c > index 1006ed2d7c60..63d420d57e63 100644 > --- a/arch/arm64/kernel/pci.c > +++ b/arch/arm64/kernel/pci.c > @@ -74,15 +74,24 @@ struct acpi_pci_generic_root_info { > int acpi_pci_bus_find_domain_nr(struct pci_bus *bus) > { > struct pci_config_window *cfg = bus->sysdata; > - struct acpi_device *adev = to_acpi_device(cfg->parent); > - struct acpi_pci_root *root = acpi_driver_data(adev); > + struct pci_sysdata *sd = bus->sysdata; > + struct acpi_device *adev; > + struct acpi_pci_root *root; There should be no reason to add even most code to this file, it should in fact become empty as it gets generalized more. Arnd 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.2 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 687CBC433DB for ; Sat, 20 Mar 2021 12:54:12 +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 EF8F061949 for ; Sat, 20 Mar 2021 12:54:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EF8F061949 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=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Cc:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=RJWtggQH7UP1vcRWPKXBYIaLG4948dsy0z+Cc9MHE1M=; b=ToveldBu7aMbmU29jztahGvv6 /k3t+j/rzEgptUkNRTsVjcxJvZ0w+PjDD++jLlBJbgx+HnPmZdNTbiDFdPyIu1BJCrmy4yI4f/qAE u26nsKv2Ah85fH66ZODvUvAV3gHArX46uZ6HTeG2edKPs8VyScs8C1acD4W4KyypT4AFRxLep7aQL AcoII0JMKWt8MktzjpqeYGYL4FFrwrhOsCqTnVu6/gMdEo8Ifq05YkspBHaiRbCnogb7v/3oxt6Z/ 1cHw/yH0rJWt9odcGUObpA958DTxsHlQv0upJ+rZKgH4k1wC1Ras8rUlTz4fVOSoV1kSQ62dponbU 4pRawZxhA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lNb5p-008ppE-LS; Sat, 20 Mar 2021 12:52:37 +0000 Received: from mail.kernel.org ([198.145.29.99]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lNb5k-008pot-72 for linux-arm-kernel@lists.infradead.org; Sat, 20 Mar 2021 12:52:34 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id BCF3E61949 for ; Sat, 20 Mar 2021 12:52:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1616244747; bh=FXeHEEFPZu+Z4OujvA8/CNPvD0oljphMbhJMuOs+OXM=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=K1bCLgGHIESUpuy8gK8SpKrBsiI4KgDJFRhoPxjusuXnUlSivdfgWm4zq4Rod8Oo3 7Mrm8Tb9XocWRJ587fu3susWkesvhYU7/0pfNilGD+BCA3Di2bc3LlaVYhCjqSWXuo VKDsgNE5YShjld+XOx+10Wv27MNwq01zur5FVzqZKwZiARO6NILQmdoOshYy8eTqyF aydtyunWmoU/vVTUKfMd57nh/J/0dZbOq4uZ9nYmpb6Z6kyA43uRwZFdR2kl1t4CSu lkx8s8QwVetVwRB/O4fDD5TwfbqsRxwjaE+K/x5UxIPaTenvtQC1eWdLWJ3i/evqe8 P/CqJjQtlrC2A== Received: by mail-ot1-f43.google.com with SMTP id m21-20020a9d7ad50000b02901b83efc84a0so11201181otn.10 for ; Sat, 20 Mar 2021 05:52:27 -0700 (PDT) X-Gm-Message-State: AOAM531bJpio7zH08ZK/4D9XghjrW3IZa/MQaC6rFV/VdK6deyFpw8RI vh9UX37PNK06Apj5fbdpnGqxndv/Gv2tfRV2k+k= X-Google-Smtp-Source: ABdhPJytWWTHbNfc/Z6ZiNhGc5dEtnzbBd5XnL42oX7cqny6BlJyDJiN6PM6uRjOYArjqYeBxwpkoKmLUKXyzx1BzqQ= X-Received: by 2002:a05:6830:14c1:: with SMTP id t1mr4831024otq.305.1616244747072; Sat, 20 Mar 2021 05:52:27 -0700 (PDT) MIME-Version: 1.0 References: <20210319161956.2838291-1-boqun.feng@gmail.com> <20210319161956.2838291-2-boqun.feng@gmail.com> In-Reply-To: <20210319161956.2838291-2-boqun.feng@gmail.com> From: Arnd Bergmann Date: Sat, 20 Mar 2021 13:52:10 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC 1/2] arm64: PCI: Allow use arch-specific pci sysdata To: Boqun Feng Cc: Bjorn Helgaas , Linux ARM , Linux Kernel Mailing List , Linux on Hyper-V List , linux-pci , Catalin Marinas , Will Deacon , "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , Wei Liu , Lorenzo Pieralisi , Rob Herring , Clint Sbisa , Ard Biesheuvel , Sunil Muthuswamy X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210320_125233_098467_E4428612 X-CRM114-Status: GOOD ( 27.34 ) 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 Fri, Mar 19, 2021 at 5:22 PM Boqun Feng wrote: > > Currently, if an architecture selects CONFIG_PCI_DOMAINS_GENERIC, the > ->sysdata in bus and bridge will be treated as struct pci_config_window, > which is created by generic ECAM using the data from acpi. > > However, for a virtualized PCI bus, there might be no enough data in of > or acpi table to create a pci_config_window. This is similar to the case > where CONFIG_PCI_DOMAINS_GENERIC=n, IOW, architectures use their own > structure for sysdata, so no apci table lookup is required. > > In order to enable Hyper-V's virtual PCI (which doesn't have acpi table > entry for PCI) on ARM64 (which selects CONFIG_PCI_DOMAINS_GENERIC), we > introduce arch-specific pci sysdata (similar to the one for x86) for > ARM64, and allow the core PCI code to detect the type of sysdata at the > runtime. The latter is achieved by adding a pci_ops::use_arch_sysdata > field. > > Originally-by: Sunil Muthuswamy > Signed-off-by: Boqun Feng (Microsoft) I think this takes it in the opposite direction of where it should be going. > --- > arch/arm64/include/asm/pci.h | 29 +++++++++++++++++++++++++++++ > arch/arm64/kernel/pci.c | 15 ++++++++++++--- > include/linux/pci.h | 3 +++ > 3 files changed, 44 insertions(+), 3 deletions(-) > > diff --git a/arch/arm64/include/asm/pci.h b/arch/arm64/include/asm/pci.h > index b33ca260e3c9..dade061a0658 100644 > --- a/arch/arm64/include/asm/pci.h > +++ b/arch/arm64/include/asm/pci.h > @@ -22,6 +22,16 @@ > > extern int isa_dma_bridge_buggy; > > +struct pci_sysdata { > + int domain; /* PCI domain */ > + int node; /* NUMA Node */ > +#ifdef CONFIG_ACPI > + struct acpi_device *companion; /* ACPI companion device */ > +#endif > +#ifdef CONFIG_PCI_MSI_IRQ_DOMAIN > + void *fwnode; /* IRQ domain for MSI assignment */ > +#endif > +}; I think none of these members belong into sysdata or architecture specific code. The fact that a pci_host_bridge belongs to a particular NUMA node or i associated with a firmware description is neither specific to a host bridge implementation nor a CPU instruction set! Moreover, you cannot assume that all PCI host bridges on any given architecture can share the pci_sysdata pointer, it is purely specific to the bridge driver. A good start would be to move the members (one at a time) into struct pci_host_bridge and out of the sysdata of individual host bridge drivers. > diff --git a/arch/arm64/kernel/pci.c b/arch/arm64/kernel/pci.c > index 1006ed2d7c60..63d420d57e63 100644 > --- a/arch/arm64/kernel/pci.c > +++ b/arch/arm64/kernel/pci.c > @@ -74,15 +74,24 @@ struct acpi_pci_generic_root_info { > int acpi_pci_bus_find_domain_nr(struct pci_bus *bus) > { > struct pci_config_window *cfg = bus->sysdata; > - struct acpi_device *adev = to_acpi_device(cfg->parent); > - struct acpi_pci_root *root = acpi_driver_data(adev); > + struct pci_sysdata *sd = bus->sysdata; > + struct acpi_device *adev; > + struct acpi_pci_root *root; There should be no reason to add even most code to this file, it should in fact become empty as it gets generalized more. Arnd _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel