Received: by 2002:a05:622a:1442:b0:3a5:28ea:c4b9 with SMTP id v2csp753948qtx; Thu, 17 Nov 2022 07:38:42 -0800 (PST) X-Google-Smtp-Source: AA0mqf7dHrmUW1hPiGejYGVzNpWHywc/eMt+et21kIkRRWuwAjLPQdf6na0QKACun/aQd1PF5j9L X-Received: by 2002:a17:906:9493:b0:7ad:83cb:85e6 with SMTP id t19-20020a170906949300b007ad83cb85e6mr2695368ejx.108.1668699521912; Thu, 17 Nov 2022 07:38:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668699521; cv=none; d=google.com; s=arc-20160816; b=Ut/Au6yGppbkBsp0Ymx4O4zpvfzReynTW0PGeb/2BDbxeagx2y9vI75rIJZAnOrNe9 SRNwCDJeh9C3wdYyDuJsHgTT64dkLGdfAyVceK5KE0wO0/B6igjxg1XzqeMk6vCfK35+ 5SXic+V1N2YUn//Q7VmwAiEcc3XCg2jGdgU8DG4EXBEUuxAHHlIRi3fiUprL9nkiekRf xBYIfSQbjuQg0VwzU1uGtxd69jGDvdNOa01/mQV+aJdP4PampU7uxD3ooegh8wxYamwk maQq4xxRCM3wPtTKz5dOe2gfVgxfmp2br8UqoDlD1vqM+2M0yAreHxb4E17kRaU8LF8n kmZw== 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=7wLikxPegdXcM/ihdJAq8N4YWgzWp3+cQYujDgWm1vk=; b=WKzV3hLSZagAH5xUHjS8CQ7TtO+x4HNrY/31OTsy+vB1RvAltbZGuAnYVqw7PbvkFJ yRPpuYM7d5ODxmPtaAAhj2bHYQbojDY7HvJfGQBBfQwv6qw+Bpq75uMlQqiRsfiLa3oV BVBg+dwanKkCGgUF7u6+SfadBJYEvZQljzRt+eoFpNO89qhWhX/6mgWg0onOK5N4m9s0 xEXOXhPRKki641rg7dxvvlwxLacsU1jrgF7arC88n8kxklNTDpYma7Jc6EUcniLMf+Lk jKVaINO4vg3Ikau3h+FnPdDtF44dzfcEdezEeFCO1EKb7Ur9YToem6H3Epx8D8jF81Vo embg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=LQnSdkmW; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t16-20020a056402525000b00461e322ec5dsi1136957edd.294.2022.11.17.07.38.18; Thu, 17 Nov 2022 07:38:41 -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=LQnSdkmW; 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 S240351AbiKQPJr (ORCPT + 92 others); Thu, 17 Nov 2022 10:09:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240329AbiKQPIw (ORCPT ); Thu, 17 Nov 2022 10:08:52 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A32C778180; Thu, 17 Nov 2022 07:08:11 -0800 (PST) Date: Thu, 17 Nov 2022 15:08:08 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668697690; 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=7wLikxPegdXcM/ihdJAq8N4YWgzWp3+cQYujDgWm1vk=; b=LQnSdkmWNjGgtN1YqszBxPtrfUqJEXU/l+WlYxvHBqf8P66KqsoYAsNgXzIQNRpzlSALGh ycyApnsfF6opGuMXL/ZsmewFfVMH8atPhGU3lw24lp7DzFzOd09LhmRQxgR2vOPZWatxCd ZM49hhWYOXHyVLIn/ZGFMMhlW5vYr/wHi2i/RL2zGwEwnQ8NeRoaIroLiVkW1oeEPwrjeS 2FE/WVQy/jRHtl5jmVvnEIrnglFg9P6VYuMKDCEhenXTSm+6H/rIvj6BJAeQuAb2WM8MRO gPe146cWpFxxW4mKSapQqHgSAK4Krw1GCaDhJF+iS8VC0oU6T+2QX4KsQaVxaw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668697690; 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=7wLikxPegdXcM/ihdJAq8N4YWgzWp3+cQYujDgWm1vk=; b=/DFEiTWscUp2hLrydV6DX6OeBj4PQMJHG0LTBGqHi7z3FhsOsYxPylEr7Q50fV1OdAQSCP mfIvDPWBCRZnNRCQ== 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_affinity() 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.927531290@linutronix.de> References: <20221111122014.927531290@linutronix.de> MIME-Version: 1.0 Message-ID: <166869768882.4906.7231729097327796389.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit 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 The following commit has been merged into the irq/core branch of tip: Commit-ID: beddb5efb43ee5b1c048e49225f75b03f8d36aac Gitweb: https://git.kernel.org/tip/beddb5efb43ee5b1c048e49225f75b03f8d36aac Author: Ahmed S. Darwish AuthorDate: Fri, 11 Nov 2022 14:54:51 +01:00 Committer: Thomas Gleixner CommitterDate: Thu, 17 Nov 2022 15:15:20 +01:00 PCI/MSI: Move pci_alloc_irq_vectors_affinity() 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. Move pci_alloc_irq_vectors_affinity() and let its kernel-doc reference pci_alloc_irq_vectors() documentation added in parent commit. Signed-off-by: Ahmed S. Darwish Signed-off-by: Thomas Gleixner Acked-by: Bjorn Helgaas Link: https://lore.kernel.org/r/20221111122014.927531290@linutronix.de --- drivers/pci/msi/api.c | 59 ++++++++++++++++++++++++++++++++++++++- drivers/pci/msi/msi.c | 65 +------------------------------------------ 2 files changed, 59 insertions(+), 65 deletions(-) diff --git a/drivers/pci/msi/api.c b/drivers/pci/msi/api.c index 1714905..8546749 100644 --- a/drivers/pci/msi/api.c +++ b/drivers/pci/msi/api.c @@ -123,3 +123,62 @@ int pci_alloc_irq_vectors(struct pci_dev *dev, unsigned int min_vecs, flags, NULL); } EXPORT_SYMBOL(pci_alloc_irq_vectors); + +/** + * pci_alloc_irq_vectors_affinity() - Allocate multiple device interrupt + * vectors with affinity requirements + * @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: allocation flags, as in pci_alloc_irq_vectors() + * @affd: affinity requirements (can be %NULL). + * + * Same as pci_alloc_irq_vectors(), but with the extra @affd parameter. + * Check that function docs, and &struct irq_affinity, for more details. + */ +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) +{ + struct irq_affinity msi_default_affd = {0}; + int nvecs = -ENOSPC; + + if (flags & PCI_IRQ_AFFINITY) { + if (!affd) + affd = &msi_default_affd; + } else { + if (WARN_ON(affd)) + affd = NULL; + } + + if (flags & PCI_IRQ_MSIX) { + nvecs = __pci_enable_msix_range(dev, NULL, min_vecs, max_vecs, + affd, flags); + if (nvecs > 0) + return nvecs; + } + + if (flags & PCI_IRQ_MSI) { + nvecs = __pci_enable_msi_range(dev, min_vecs, max_vecs, affd); + if (nvecs > 0) + return nvecs; + } + + /* use legacy IRQ if allowed */ + if (flags & PCI_IRQ_LEGACY) { + if (min_vecs == 1 && dev->irq) { + /* + * Invoke the affinity spreading logic to ensure that + * the device driver can adjust queue configuration + * for the single interrupt case. + */ + if (affd) + irq_create_affinity_masks(1, affd); + pci_intx(dev, 1); + return 1; + } + } + + return nvecs; +} +EXPORT_SYMBOL(pci_alloc_irq_vectors_affinity); diff --git a/drivers/pci/msi/msi.c b/drivers/pci/msi/msi.c index 6700ef1..a028774 100644 --- a/drivers/pci/msi/msi.c +++ b/drivers/pci/msi/msi.c @@ -887,71 +887,6 @@ int __pci_enable_msix_range(struct pci_dev *dev, } /** - * pci_alloc_irq_vectors_affinity - allocate multiple IRQs for a device - * @dev: PCI device to operate on - * @min_vecs: minimum number of vectors required (must be >= 1) - * @max_vecs: maximum (desired) number of vectors - * @flags: flags or quirks for the allocation - * @affd: optional description of the affinity requirements - * - * Allocate up to @max_vecs interrupt vectors for @dev, using MSI-X or MSI - * vectors if available, and fall back to a single legacy vector - * if neither is available. Return the number of vectors allocated, - * (which might be smaller than @max_vecs) if successful, or a negative - * error code on error. If less than @min_vecs interrupt vectors are - * available for @dev the function will fail with -ENOSPC. - * - * To get the Linux IRQ number used for a vector that can be passed to - * request_irq() use the pci_irq_vector() helper. - */ -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) -{ - struct irq_affinity msi_default_affd = {0}; - int nvecs = -ENOSPC; - - if (flags & PCI_IRQ_AFFINITY) { - if (!affd) - affd = &msi_default_affd; - } else { - if (WARN_ON(affd)) - affd = NULL; - } - - if (flags & PCI_IRQ_MSIX) { - nvecs = __pci_enable_msix_range(dev, NULL, min_vecs, max_vecs, - affd, flags); - if (nvecs > 0) - return nvecs; - } - - if (flags & PCI_IRQ_MSI) { - nvecs = __pci_enable_msi_range(dev, min_vecs, max_vecs, affd); - if (nvecs > 0) - return nvecs; - } - - /* use legacy IRQ if allowed */ - if (flags & PCI_IRQ_LEGACY) { - if (min_vecs == 1 && dev->irq) { - /* - * Invoke the affinity spreading logic to ensure that - * the device driver can adjust queue configuration - * for the single interrupt case. - */ - if (affd) - irq_create_affinity_masks(1, affd); - pci_intx(dev, 1); - return 1; - } - } - - return nvecs; -} -EXPORT_SYMBOL(pci_alloc_irq_vectors_affinity); - -/** * pci_free_irq_vectors - free previously allocated IRQs for a device * @dev: PCI device to operate on *