From patchwork Thu Nov 17 15:08:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 21723 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp453252wrr; Thu, 17 Nov 2022 07:11:43 -0800 (PST) X-Google-Smtp-Source: AA0mqf42W1p86Sd/UfQkGMRM7e0ngFFD/R3yU+sdIOiD6h+DlEXu8xm5ohGMmlxt2g6DlRLGjqQC X-Received: by 2002:a17:906:4c92:b0:78d:ad29:396f with SMTP id q18-20020a1709064c9200b0078dad29396fmr2557479eju.165.1668697903387; Thu, 17 Nov 2022 07:11:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668697903; cv=none; d=google.com; s=arc-20160816; b=B5KKLqRFSIaVV0SkUNeL1h6OYl4e2l87BYNotv0BNhq2P2h1n+ztJwe02Pi6Bk06kS CSucgPgwmvg9y8Y4gXSoORPIM2dA5lvdA5akJh6jApRRUBJclCSkwPU2CJjUFBVQspT8 W60WLGMsztqhn4fag4mo3NYhcflgZanp8kmx9k1D6MJKv+T3tBwbnHVv2c+Qt2LBGVCN KqK5pwVTunSj4HWUkb8rUN7CIEOwT1tjqNjvFPyGWlg2QICWeXuWL36AT38opfrCERfU 4D5MDV8UL+JVZOmL0b9gBx6Kd8AESoWNMR+Hwzlj0F6h8VKAG2PjTuPPOTD5z0h41wr2 HBMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=nRoTJJ8dM3yOguRGoxKI7R7uM7nh9vP2NcFmiPHiqD0=; b=VUsxyCfJgz4FyYtlYcxVsapQISnE34kZyIN/vSFhm4MDqyklQF9GKj6GlxlhXbLOob o0RCCrjqcAZrGIS1ZlOMOozKD1kHH8bY6zpmfmhPztIfpBCyK1xSJDDKwmiQZgvrkMPK ZEPoOvAOytUgcT86rBgTsFmjfB3gJOeU3RSite+bil1CyWY/yuADFC+wbSpUDZu2GU9R 35o0wqy7Tw5SrsxCcaON82V+9xaWh3KKRyPjrn/ALDzmwYP6/madeJ/FUJUcc6bFQjKF NAt2zFw9W0A4jKjCQo37XIXtzh3okbYx647Gth76p1ooBc5s+RmRIqRDOMB+7QX+OHts CiLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="XRl/jWST"; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g20-20020a1709063b1400b0078dce38525asi707498ejf.896.2022.11.17.07.11.13; Thu, 17 Nov 2022 07:11:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="XRl/jWST"; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240530AbiKQPJv (ORCPT + 99 others); Thu, 17 Nov 2022 10:09:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240337AbiKQPI5 (ORCPT ); Thu, 17 Nov 2022 10:08:57 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D63E7818E; Thu, 17 Nov 2022 07:08:12 -0800 (PST) Date: Thu, 17 Nov 2022 15:08:09 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668697691; h=from:from:sender:sender:reply-to: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=nRoTJJ8dM3yOguRGoxKI7R7uM7nh9vP2NcFmiPHiqD0=; b=XRl/jWSTF9Vxg8kc2CfRJnub9A/+zV9ujVUXQAu4DMtMbrp7hZ0jJfUYYVv/yYExxJo5EN 2mLB557WS21lFFrkjGDGsgr+eCZXHml4y/7kVOuA4ixe5NpP71MJoE1wDLKRzW+jycPt6m QCnjvUn7hdThu8W3FNBOkcmFGhjoCZqPWzACXujtX+2QzyFREjeFXzy6Q5OscI2UUP07ha hSR/W1Q02tmgLp/l775FELzfkYc5oOS9pD0z8/tNmgjfTNkE48z9CWmu24uDKUn69Pgg8X BCpT3j2PgPeQ3diQwHsljH+S1KChqUPOPwyx0XRla84lwouhxYrUAcCLqj03Iw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668697691; h=from:from:sender:sender:reply-to: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=nRoTJJ8dM3yOguRGoxKI7R7uM7nh9vP2NcFmiPHiqD0=; b=Zg69COPdqEIRXnVkSNQ0kQ8y1cOZijm5WGP2vcjdyHx2yMd451Rzkt/RCCckNZ/WiKC1Nf m+54xWJwlytPZ4Dw== From: "tip-bot2 for Ahmed S. Darwish" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: irq/core] PCI/MSI: Move pci_alloc_irq_vectors() to api.c Cc: "Ahmed S. Darwish" , Thomas Gleixner , Bjorn Helgaas , x86@kernel.org, linux-kernel@vger.kernel.org, maz@kernel.org In-Reply-To: <20221111122014.870888193@linutronix.de> References: <20221111122014.870888193@linutronix.de> MIME-Version: 1.0 Message-ID: <166869768997.4906.10468352470672453485.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749208352937799779?= X-GMAIL-MSGID: =?utf-8?q?1749756572780141925?= The following commit has been merged into the irq/core branch of tip: Commit-ID: 5c0997dc33ac24b7dc0124c2fc1caa37ae39461a Gitweb: https://git.kernel.org/tip/5c0997dc33ac24b7dc0124c2fc1caa37ae39461a Author: Ahmed S. Darwish AuthorDate: Fri, 11 Nov 2022 14:54:50 +01:00 Committer: Thomas Gleixner CommitterDate: Thu, 17 Nov 2022 15:15:20 +01:00 PCI/MSI: Move pci_alloc_irq_vectors() to api.c To disentangle 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 Link: https://lore.kernel.org/r/20221111122014.870888193@linutronix.de --- drivers/pci/msi/api.c | 33 +++++++++++++++++++++++++++++++++ include/linux/pci.h | 15 +++++++++++---- 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/drivers/pci/msi/api.c b/drivers/pci/msi/api.c index d480505..1714905 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 + * 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 + * 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 2bda4a4..243e48f 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) { @@ -1898,15 +1907,13 @@ pci_alloc_irq_vectors_affinity(struct pci_dev *dev, unsigned int min_vecs, { return -ENOSPC; } -#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); + return -ENOSPC; } +#endif /* CONFIG_PCI */ /* Include architecture-dependent settings and functions */