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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4A727C4332F for ; Wed, 16 Nov 2022 16:25:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237952AbiKPQZ1 (ORCPT ); Wed, 16 Nov 2022 11:25:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237640AbiKPQWw (ORCPT ); Wed, 16 Nov 2022 11:22:52 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C19C157B62; Wed, 16 Nov 2022 08:22:12 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5F04561EC4; Wed, 16 Nov 2022 16:22:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6CB89C43470; Wed, 16 Nov 2022 16:22:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1668615731; bh=gijm9WgljZaZJl0BwvkKpLhLs5VMOo1VnDWNFADbiCo=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=TZn7pEwkK/vcdohvHlBe7c8EAiUHeoEyrLMFW9hHccGUVfCedOkVWDEycBL3kOBqs HM2kzidM9PHkiRWOfciHwtMi+N4xzYI0ClgZOTF5intqMrh98KK7CuhW/TzisKiKgR KIgGixbytdj4W1ClfrRukH99CmlEOyx6LgthVRIOTBo/802CNUOufEZjVREHBhBmFF wSYxoQdmZl1a+3uR/z+xXgxfOm2bN4Ebq4hk9ThOkgp+MNg57h4qCDJ6Mj4jpq0SBI qcn8sVsqpUQ/mx/hAsezFPyadLUfE4d31JDEzp57iATUi7NhbNI4upKC/M9r4WSRIu AcHEJ99x9lSNg== Date: Wed, 16 Nov 2022 10:22:10 -0600 From: Bjorn Helgaas To: Thomas Gleixner Cc: LKML , x86@kernel.org, Joerg Roedel , Will Deacon , linux-pci@vger.kernel.org, Bjorn Helgaas , Lorenzo Pieralisi , Marc Zyngier , Greg Kroah-Hartman , Jason Gunthorpe , Dave Jiang , Alex Williamson , Kevin Tian , Dan Williams , Logan Gunthorpe , Ashok Raj , Jon Mason , Allen Hubbe , "Ahmed S. Darwish" , Reinette Chatre , Michael Ellerman , Christophe Leroy , linuxppc-dev@lists.ozlabs.org Subject: Re: [patch 22/39] PCI/MSI: Move pci_alloc_irq_vectors() to api.c Message-ID: <20221116162210.GA1115315@bhelgaas> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221111122014.870888193@linutronix.de> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 11, 2022 at 02:54:50PM +0100, Thomas Gleixner wrote: > From: Ahmed S. Darwish > > To distangle the maze in msi.c, all exported device-driver MSI APIs are > now to be grouped in one file, api.c. > > Make pci_alloc_irq_vectors() a real function instead of wrapper and add > proper kernel doc to it. > > Signed-off-by: Ahmed S. Darwish > Signed-off-by: Thomas Gleixner Acked-by: Bjorn Helgaas Two nits below. > --- > drivers/pci/msi/api.c | 33 +++++++++++++++++++++++++++++++++ > include/linux/pci.h | 17 +++++++++-------- > 2 files changed, 42 insertions(+), 8 deletions(-) > --- > diff --git a/drivers/pci/msi/api.c b/drivers/pci/msi/api.c > index d48050555d55..1714905943fb 100644 > --- a/drivers/pci/msi/api.c > +++ b/drivers/pci/msi/api.c > @@ -90,3 +90,36 @@ int pci_enable_msix_range(struct pci_dev *dev, struct msix_entry *entries, > return __pci_enable_msix_range(dev, entries, minvec, maxvec, NULL, 0); > } > EXPORT_SYMBOL(pci_enable_msix_range); > + > +/** > + * pci_alloc_irq_vectors() - Allocate multiple device interrupt vectors > + * @dev: the PCI device to operate on > + * @min_vecs: minimum required number of vectors (must be >= 1) > + * @max_vecs: maximum desired number of vectors > + * @flags: One or more of: > + * %PCI_IRQ_MSIX Allow trying MSI-X vector allocations > + * %PCI_IRQ_MSI Allow trying MSI vector allocations > + * %PCI_IRQ_LEGACY Allow trying legacy INTx interrupts, if > + * and only if @min_vecs == 1 > + * %PCI_IRQ_AFFINITY Auto-manage IRQs affinity by spreading > + * the vectors around available CPUs > + * > + * Allocate up to @max_vecs interrupt vectors on device. MSI-X irq s/irq/IRQ/ > + * vector allocation has a higher precedence over plain MSI, which has a > + * higher precedence over legacy INTx emulation. > + * > + * Upon a successful allocation, the caller should use pci_irq_vector() > + * to get the Linux IRQ number to be passed to request_threaded_irq(). > + * The driver must call pci_free_irq_vectors() on cleanup. > + * > + * Return: number of allocated vectors (which might be smaller than > + * @max_vecs), -ENOSPC if less than @min_vecs interrupt vectors are s/less/fewer/ (also in some previous patches, IIRC) > + * available, other errnos otherwise. > + */ > +int pci_alloc_irq_vectors(struct pci_dev *dev, unsigned int min_vecs, > + unsigned int max_vecs, unsigned int flags) > +{ > + return pci_alloc_irq_vectors_affinity(dev, min_vecs, max_vecs, > + flags, NULL); > +} > +EXPORT_SYMBOL(pci_alloc_irq_vectors); > diff --git a/include/linux/pci.h b/include/linux/pci.h > index 2bda4a4e47e8..6a356a39ba94 100644 > --- a/include/linux/pci.h > +++ b/include/linux/pci.h > @@ -1553,6 +1553,8 @@ static inline int pci_enable_msix_exact(struct pci_dev *dev, > return rc; > return 0; > } > +int pci_alloc_irq_vectors(struct pci_dev *dev, unsigned int min_vecs, > + unsigned int max_vecs, unsigned int flags); > int pci_alloc_irq_vectors_affinity(struct pci_dev *dev, unsigned int min_vecs, > unsigned int max_vecs, unsigned int flags, > struct irq_affinity *affd); > @@ -1586,6 +1588,13 @@ pci_alloc_irq_vectors_affinity(struct pci_dev *dev, unsigned int min_vecs, > return 1; > return -ENOSPC; > } > +static inline int > +pci_alloc_irq_vectors(struct pci_dev *dev, unsigned int min_vecs, > + unsigned int max_vecs, unsigned int flags) > +{ > + return pci_alloc_irq_vectors_affinity(dev, min_vecs, max_vecs, > + flags, NULL); > +} > > static inline void pci_free_irq_vectors(struct pci_dev *dev) > { > @@ -1900,14 +1909,6 @@ pci_alloc_irq_vectors_affinity(struct pci_dev *dev, unsigned int min_vecs, > } > #endif /* CONFIG_PCI */ > > -static inline int > -pci_alloc_irq_vectors(struct pci_dev *dev, unsigned int min_vecs, > - unsigned int max_vecs, unsigned int flags) > -{ > - return pci_alloc_irq_vectors_affinity(dev, min_vecs, max_vecs, flags, > - NULL); > -} > - > /* Include architecture-dependent settings and functions */ > > #include > 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 Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2387AC4332F for ; Wed, 16 Nov 2022 16:24:06 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4NC7fD4ktwz3dvq for ; Thu, 17 Nov 2022 03:24:04 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=TZn7pEwk; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=kernel.org (client-ip=139.178.84.217; helo=dfw.source.kernel.org; envelope-from=helgaas@kernel.org; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=TZn7pEwk; dkim-atps=neutral Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4NC7c653CKz3bYF for ; Thu, 17 Nov 2022 03:22:14 +1100 (AEDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id DD74761EE2; Wed, 16 Nov 2022 16:22:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6CB89C43470; Wed, 16 Nov 2022 16:22:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1668615731; bh=gijm9WgljZaZJl0BwvkKpLhLs5VMOo1VnDWNFADbiCo=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=TZn7pEwkK/vcdohvHlBe7c8EAiUHeoEyrLMFW9hHccGUVfCedOkVWDEycBL3kOBqs HM2kzidM9PHkiRWOfciHwtMi+N4xzYI0ClgZOTF5intqMrh98KK7CuhW/TzisKiKgR KIgGixbytdj4W1ClfrRukH99CmlEOyx6LgthVRIOTBo/802CNUOufEZjVREHBhBmFF wSYxoQdmZl1a+3uR/z+xXgxfOm2bN4Ebq4hk9ThOkgp+MNg57h4qCDJ6Mj4jpq0SBI qcn8sVsqpUQ/mx/hAsezFPyadLUfE4d31JDEzp57iATUi7NhbNI4upKC/M9r4WSRIu AcHEJ99x9lSNg== Date: Wed, 16 Nov 2022 10:22:10 -0600 From: Bjorn Helgaas To: Thomas Gleixner Subject: Re: [patch 22/39] PCI/MSI: Move pci_alloc_irq_vectors() to api.c Message-ID: <20221116162210.GA1115315@bhelgaas> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221111122014.870888193@linutronix.de> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-pci@vger.kernel.org, Will Deacon , Lorenzo Pieralisi , Dave Jiang , Ashok Raj , Joerg Roedel , x86@kernel.org, Jason Gunthorpe , Allen Hubbe , Kevin Tian , "Ahmed S. Darwish" , Jon Mason , linuxppc-dev@lists.ozlabs.org, Alex Williamson , Bjorn Helgaas , Dan Williams , Reinette Chatre , Greg Kroah-Hartman , LKML , Marc Zyngier , Logan Gunthorpe Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Fri, Nov 11, 2022 at 02:54:50PM +0100, Thomas Gleixner wrote: > From: Ahmed S. Darwish > > To distangle the maze in msi.c, all exported device-driver MSI APIs are > now to be grouped in one file, api.c. > > Make pci_alloc_irq_vectors() a real function instead of wrapper and add > proper kernel doc to it. > > Signed-off-by: Ahmed S. Darwish > Signed-off-by: Thomas Gleixner Acked-by: Bjorn Helgaas Two nits below. > --- > drivers/pci/msi/api.c | 33 +++++++++++++++++++++++++++++++++ > include/linux/pci.h | 17 +++++++++-------- > 2 files changed, 42 insertions(+), 8 deletions(-) > --- > diff --git a/drivers/pci/msi/api.c b/drivers/pci/msi/api.c > index d48050555d55..1714905943fb 100644 > --- a/drivers/pci/msi/api.c > +++ b/drivers/pci/msi/api.c > @@ -90,3 +90,36 @@ int pci_enable_msix_range(struct pci_dev *dev, struct msix_entry *entries, > return __pci_enable_msix_range(dev, entries, minvec, maxvec, NULL, 0); > } > EXPORT_SYMBOL(pci_enable_msix_range); > + > +/** > + * pci_alloc_irq_vectors() - Allocate multiple device interrupt vectors > + * @dev: the PCI device to operate on > + * @min_vecs: minimum required number of vectors (must be >= 1) > + * @max_vecs: maximum desired number of vectors > + * @flags: One or more of: > + * %PCI_IRQ_MSIX Allow trying MSI-X vector allocations > + * %PCI_IRQ_MSI Allow trying MSI vector allocations > + * %PCI_IRQ_LEGACY Allow trying legacy INTx interrupts, if > + * and only if @min_vecs == 1 > + * %PCI_IRQ_AFFINITY Auto-manage IRQs affinity by spreading > + * the vectors around available CPUs > + * > + * Allocate up to @max_vecs interrupt vectors on device. MSI-X irq s/irq/IRQ/ > + * vector allocation has a higher precedence over plain MSI, which has a > + * higher precedence over legacy INTx emulation. > + * > + * Upon a successful allocation, the caller should use pci_irq_vector() > + * to get the Linux IRQ number to be passed to request_threaded_irq(). > + * The driver must call pci_free_irq_vectors() on cleanup. > + * > + * Return: number of allocated vectors (which might be smaller than > + * @max_vecs), -ENOSPC if less than @min_vecs interrupt vectors are s/less/fewer/ (also in some previous patches, IIRC) > + * available, other errnos otherwise. > + */ > +int pci_alloc_irq_vectors(struct pci_dev *dev, unsigned int min_vecs, > + unsigned int max_vecs, unsigned int flags) > +{ > + return pci_alloc_irq_vectors_affinity(dev, min_vecs, max_vecs, > + flags, NULL); > +} > +EXPORT_SYMBOL(pci_alloc_irq_vectors); > diff --git a/include/linux/pci.h b/include/linux/pci.h > index 2bda4a4e47e8..6a356a39ba94 100644 > --- a/include/linux/pci.h > +++ b/include/linux/pci.h > @@ -1553,6 +1553,8 @@ static inline int pci_enable_msix_exact(struct pci_dev *dev, > return rc; > return 0; > } > +int pci_alloc_irq_vectors(struct pci_dev *dev, unsigned int min_vecs, > + unsigned int max_vecs, unsigned int flags); > int pci_alloc_irq_vectors_affinity(struct pci_dev *dev, unsigned int min_vecs, > unsigned int max_vecs, unsigned int flags, > struct irq_affinity *affd); > @@ -1586,6 +1588,13 @@ pci_alloc_irq_vectors_affinity(struct pci_dev *dev, unsigned int min_vecs, > return 1; > return -ENOSPC; > } > +static inline int > +pci_alloc_irq_vectors(struct pci_dev *dev, unsigned int min_vecs, > + unsigned int max_vecs, unsigned int flags) > +{ > + return pci_alloc_irq_vectors_affinity(dev, min_vecs, max_vecs, > + flags, NULL); > +} > > static inline void pci_free_irq_vectors(struct pci_dev *dev) > { > @@ -1900,14 +1909,6 @@ pci_alloc_irq_vectors_affinity(struct pci_dev *dev, unsigned int min_vecs, > } > #endif /* CONFIG_PCI */ > > -static inline int > -pci_alloc_irq_vectors(struct pci_dev *dev, unsigned int min_vecs, > - unsigned int max_vecs, unsigned int flags) > -{ > - return pci_alloc_irq_vectors_affinity(dev, min_vecs, max_vecs, flags, > - NULL); > -} > - > /* Include architecture-dependent settings and functions */ > > #include >