Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1124610pxk; Fri, 25 Sep 2020 06:56:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyzqSyBs0z/pxkGN/D/bIZ0PzmsJO/frNIqL/aSLcRGuG+yo0/UCUW2dlSJWxcEOXdUnQY/ X-Received: by 2002:a17:906:2659:: with SMTP id i25mr2778592ejc.16.1601042193358; Fri, 25 Sep 2020 06:56:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601042193; cv=none; d=google.com; s=arc-20160816; b=xFVGuyhAx9RWE/MmCIkZX9Nm/LXY5PCTYHaMWXdCL9mvBmBTZQ6D2GiPWX9tLhXcvt +xnqrQTSQgHOBmvbVKRSFDip3cBqwWbQELl9sjorwlEQBOA4BP5xdvx0Hlf3U7T44e4s zpuDEWvK5Pj0fuUrK7JEnyt0sXBQytDCmbWXauAdykR08HBF0QB2cow/xDfcjCcSQbRN HDbeYSu5iJ/rOv8iu/aXVBg6d8phN+wPUUCpURO/tA7hTCXbbnc7Z3Nj0l0Idi24A00n EG08NirMCWjmZNd+eGIBoaSEcdESIPhxZ3HlPhjr0bIUUV0jA+LA4KgDPBQYbnav0pP6 DR+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id :dkim-signature; bh=6n8qfow2srJZ/wVE5bZaW/DNL/DT/TCXXKIdMa5+xeg=; b=Tmy3Kq/oCoKC6bEgRswYKucE/wwgMXO+gFajBprxdbpMup5EwlHpf4obd6BAY+SoS0 stJ1uWk+wp2zi9jK+zfxEqgL/s2YCLH4JMtpt9eTkZ8yQQbVrYA3USMWOU4vr7hEGZlx SkMHnUIOwGchHVhqnTeppc8vh2ul6RuVyrOBA8bzM+vK5MbrD3+kkMtU+Kbk1S9sWhzw 9pItwczqIINJcSiW7KH90BuFbrWsk9259KXK5fyxC2rM/DL1pv5kKDpOprheJK/2VUAp dAqdAUG4YOVCPD+krVSxrs57CtDro79EjRITT03CS0hEsJo9rPNrALxuX93+T5T5h5Wv eqSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="hi/TfxZ3"; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bs4si1959690edb.261.2020.09.25.06.56.09; Fri, 25 Sep 2020 06:56:33 -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=@redhat.com header.s=mimecast20190719 header.b="hi/TfxZ3"; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728504AbgIYNzM (ORCPT + 99 others); Fri, 25 Sep 2020 09:55:12 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:46951 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728436AbgIYNzL (ORCPT ); Fri, 25 Sep 2020 09:55:11 -0400 Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601042110; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6n8qfow2srJZ/wVE5bZaW/DNL/DT/TCXXKIdMa5+xeg=; b=hi/TfxZ3S1Ze2cYNRtIk0TfDcLokKpGNO6WjK4yuOap0/YpYiDfwA1ItLfDE/i30GkHRFZ So6iVEi5Vk2dCy9mY8foO3RoQSewwKWJ86TM1EX2YwyvTVMyjPKnPHUaF5vDXJgj+8oHUt HkOGkygFjh8bBuN0zp3q3ljZyZ3ncR4= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-439-KKpNboZLOfasdSEOvcuo4g-1; Fri, 25 Sep 2020 09:55:05 -0400 X-MC-Unique: KKpNboZLOfasdSEOvcuo4g-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 525441021202; Fri, 25 Sep 2020 13:55:00 +0000 (UTC) Received: from ovpn-66-87.rdu2.redhat.com (unknown [10.10.67.87]) by smtp.corp.redhat.com (Postfix) with ESMTP id 29E9973662; Fri, 25 Sep 2020 13:54:53 +0000 (UTC) Message-ID: Subject: Re: [patch V2 34/46] PCI/MSI: Make arch_.*_msi_irq[s] fallbacks selectable From: Qian Cai To: Thomas Gleixner , LKML , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , linux-s390@vger.kernel.org, Stephen Rothwell , linux-next@vger.kernel.org Cc: x86@kernel.org, Joerg Roedel , iommu@lists.linux-foundation.org, linux-hyperv@vger.kernel.org, Haiyang Zhang , Jon Derrick , Lu Baolu , Wei Liu , "K. Y. Srinivasan" , Stephen Hemminger , Steve Wahl , Dimitri Sivanich , Russ Anderson , linux-pci@vger.kernel.org, Bjorn Helgaas , Lorenzo Pieralisi , Konrad Rzeszutek Wilk , xen-devel@lists.xenproject.org, Juergen Gross , Boris Ostrovsky , Stefano Stabellini , Marc Zyngier , Greg Kroah-Hartman , "Rafael J. Wysocki" , Megha Dey , Jason Gunthorpe , Dave Jiang , Alex Williamson , Jacob Pan , Baolu Lu , Kevin Tian , Dan Williams Date: Fri, 25 Sep 2020 09:54:52 -0400 In-Reply-To: <20200826112333.992429909@linutronix.de> References: <20200826111628.794979401@linutronix.de> <20200826112333.992429909@linutronix.de> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2020-08-26 at 13:17 +0200, Thomas Gleixner wrote: > From: Thomas Gleixner > > The arch_.*_msi_irq[s] fallbacks are compiled in whether an architecture > requires them or not. Architectures which are fully utilizing hierarchical > irq domains should never call into that code. > > It's not only architectures which depend on that by implementing one or > more of the weak functions, there is also a bunch of drivers which relies > on the weak functions which invoke msi_controller::setup_irq[s] and > msi_controller::teardown_irq. > > Make the architectures and drivers which rely on them select them in Kconfig > and if not selected replace them by stub functions which emit a warning and > fail the PCI/MSI interrupt allocation. > > Signed-off-by: Thomas Gleixner Today's linux-next will have some warnings on s390x: .config: https://gitlab.com/cailca/linux-mm/-/blob/master/s390.config WARNING: unmet direct dependencies detected for PCI_MSI_ARCH_FALLBACKS Depends on [n]: PCI [=n] Selected by [y]: - S390 [=y] WARNING: unmet direct dependencies detected for PCI_MSI_ARCH_FALLBACKS Depends on [n]: PCI [=n] Selected by [y]: - S390 [=y] > --- > V2: Make the architectures (and drivers) which need the fallbacks select them > and not the other way round (Bjorn). > --- > arch/ia64/Kconfig | 1 + > arch/mips/Kconfig | 1 + > arch/powerpc/Kconfig | 1 + > arch/s390/Kconfig | 1 + > arch/sparc/Kconfig | 1 + > arch/x86/Kconfig | 1 + > drivers/pci/Kconfig | 3 +++ > drivers/pci/controller/Kconfig | 3 +++ > drivers/pci/msi.c | 3 ++- > include/linux/msi.h | 31 ++++++++++++++++++++++++++----- > 10 files changed, 40 insertions(+), 6 deletions(-) > > --- a/arch/ia64/Kconfig > +++ b/arch/ia64/Kconfig > @@ -56,6 +56,7 @@ config IA64 > select NEED_DMA_MAP_STATE > select NEED_SG_DMA_LENGTH > select NUMA if !FLATMEM > + select PCI_MSI_ARCH_FALLBACKS > default y > help > The Itanium Processor Family is Intel's 64-bit successor to > --- a/arch/mips/Kconfig > +++ b/arch/mips/Kconfig > @@ -86,6 +86,7 @@ config MIPS > select MODULES_USE_ELF_REL if MODULES > select MODULES_USE_ELF_RELA if MODULES && 64BIT > select PERF_USE_VMALLOC > + select PCI_MSI_ARCH_FALLBACKS > select RTC_LIB > select SYSCTL_EXCEPTION_TRACE > select VIRT_TO_BUS > --- a/arch/powerpc/Kconfig > +++ b/arch/powerpc/Kconfig > @@ -246,6 +246,7 @@ config PPC > select OLD_SIGACTION if PPC32 > select OLD_SIGSUSPEND > select PCI_DOMAINS if PCI > + select PCI_MSI_ARCH_FALLBACKS > select PCI_SYSCALL if PCI > select PPC_DAWR if PPC64 > select RTC_LIB > --- a/arch/s390/Kconfig > +++ b/arch/s390/Kconfig > @@ -185,6 +185,7 @@ config S390 > select OLD_SIGSUSPEND3 > select PCI_DOMAINS if PCI > select PCI_MSI if PCI > + select PCI_MSI_ARCH_FALLBACKS > select SPARSE_IRQ > select SYSCTL_EXCEPTION_TRACE > select THREAD_INFO_IN_TASK > --- a/arch/sparc/Kconfig > +++ b/arch/sparc/Kconfig > @@ -43,6 +43,7 @@ config SPARC > select GENERIC_STRNLEN_USER > select MODULES_USE_ELF_RELA > select PCI_SYSCALL if PCI > + select PCI_MSI_ARCH_FALLBACKS > select ODD_RT_SIGACTION > select OLD_SIGSUSPEND > select CPU_NO_EFFICIENT_FFS > --- a/arch/x86/Kconfig > +++ b/arch/x86/Kconfig > @@ -225,6 +225,7 @@ config X86 > select NEED_SG_DMA_LENGTH > select PCI_DOMAINS if PCI > select PCI_LOCKLESS_CONFIG if PCI > + select PCI_MSI_ARCH_FALLBACKS > select PERF_EVENTS > select RTC_LIB > select RTC_MC146818_LIB > --- a/drivers/pci/Kconfig > +++ b/drivers/pci/Kconfig > @@ -56,6 +56,9 @@ config PCI_MSI_IRQ_DOMAIN > depends on PCI_MSI > select GENERIC_MSI_IRQ_DOMAIN > > +config PCI_MSI_ARCH_FALLBACKS > + bool > + > config PCI_QUIRKS > default y > bool "Enable PCI quirk workarounds" if EXPERT > --- a/drivers/pci/controller/Kconfig > +++ b/drivers/pci/controller/Kconfig > @@ -41,6 +41,7 @@ config PCI_TEGRA > bool "NVIDIA Tegra PCIe controller" > depends on ARCH_TEGRA || COMPILE_TEST > depends on PCI_MSI_IRQ_DOMAIN > + select PCI_MSI_ARCH_FALLBACKS > help > Say Y here if you want support for the PCIe host controller found > on NVIDIA Tegra SoCs. > @@ -67,6 +68,7 @@ config PCIE_RCAR_HOST > bool "Renesas R-Car PCIe host controller" > depends on ARCH_RENESAS || COMPILE_TEST > depends on PCI_MSI_IRQ_DOMAIN > + select PCI_MSI_ARCH_FALLBACKS > help > Say Y here if you want PCIe controller support on R-Car SoCs in host > mode. > @@ -103,6 +105,7 @@ config PCIE_XILINX_CPM > bool "Xilinx Versal CPM host bridge support" > depends on ARCH_ZYNQMP || COMPILE_TEST > select PCI_HOST_COMMON > + select PCI_MSI_ARCH_FALLBACKS > help > Say 'Y' here if you want kernel support for the > Xilinx Versal CPM host bridge. > --- a/drivers/pci/msi.c > +++ b/drivers/pci/msi.c > @@ -58,8 +58,8 @@ static void pci_msi_teardown_msi_irqs(st > #define pci_msi_teardown_msi_irqs arch_teardown_msi_irqs > #endif > > +#ifdef CONFIG_PCI_MSI_ARCH_FALLBACKS > /* Arch hooks */ > - > int __weak arch_setup_msi_irq(struct pci_dev *dev, struct msi_desc *desc) > { > struct msi_controller *chip = dev->bus->msi; > @@ -132,6 +132,7 @@ void __weak arch_teardown_msi_irqs(struc > { > return default_teardown_msi_irqs(dev); > } > +#endif /* CONFIG_PCI_MSI_ARCH_FALLBACKS */ > > static void default_restore_msi_irq(struct pci_dev *dev, int irq) > { > --- a/include/linux/msi.h > +++ b/include/linux/msi.h > @@ -193,17 +193,38 @@ void pci_msi_mask_irq(struct irq_data *d > void pci_msi_unmask_irq(struct irq_data *data); > > /* > - * The arch hooks to setup up msi irqs. Those functions are > - * implemented as weak symbols so that they /can/ be overriden by > - * architecture specific code if needed. > + * The arch hooks to setup up msi irqs. Default functions are implemented > + * as weak symbols so that they /can/ be overriden by architecture specific > + * code if needed. These hooks must be enabled by the architecture or by > + * drivers which depend on them via msi_controller based MSI handling. > + * > + * If CONFIG_PCI_MSI_ARCH_FALLBACKS is not selected they are replaced by > + * stubs with warnings. > */ > +#ifdef CONFIG_PCI_MSI_DISABLE_ARCH_FALLBACKS > int arch_setup_msi_irq(struct pci_dev *dev, struct msi_desc *desc); > void arch_teardown_msi_irq(unsigned int irq); > int arch_setup_msi_irqs(struct pci_dev *dev, int nvec, int type); > void arch_teardown_msi_irqs(struct pci_dev *dev); > -void arch_restore_msi_irqs(struct pci_dev *dev); > - > void default_teardown_msi_irqs(struct pci_dev *dev); > +#else > +static inline int arch_setup_msi_irqs(struct pci_dev *dev, int nvec, int > type) > +{ > + WARN_ON_ONCE(1); > + return -ENODEV; > +} > + > +static inline void arch_teardown_msi_irqs(struct pci_dev *dev) > +{ > + WARN_ON_ONCE(1); > +} > +#endif > + > +/* > + * The restore hooks are still available as they are useful even > + * for fully irq domain based setups. Courtesy to XEN/X86. > + */ > +void arch_restore_msi_irqs(struct pci_dev *dev); > void default_restore_msi_irqs(struct pci_dev *dev); > > struct msi_controller { >