From patchwork Thu Nov 17 15:08:03 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: 21736 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp453852wrr; Thu, 17 Nov 2022 07:12:34 -0800 (PST) X-Google-Smtp-Source: AA0mqf5TPVt8w67q5SQnV22XBAT4BmuP7Rufrjq2TMF6+dyQ0gVu+YQQhl2w4ClhGbuf+eq0OLGb X-Received: by 2002:a17:907:98e3:b0:7af:883:ec72 with SMTP id ke3-20020a17090798e300b007af0883ec72mr2508880ejc.727.1668697954115; Thu, 17 Nov 2022 07:12:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668697954; cv=none; d=google.com; s=arc-20160816; b=XOvJKjISP2IWhh4JNoxdihmT+8srlDL70v2sOcN7DD3mazoFmtkWjuv7L67Vb8j0e1 EYDTwF2wZlHYmxa4hi6qjvD9hpr1sI5TkU4q/JNncETE4HmGiix8BiP1CzzxGUx0RB1A 3Un0xAfMKcq5+vrBX6yxSCNZd/aQc6oSGSEX2pTfRsDO7hQyQ6W82f8Ur1MLuxE3WdBY az+4cu2EVW8bsDar6Irl/omyVwXXan8Ka5jX1ZpJFpPIlhUd/G074F0cd3UjJ0DNSzS/ XfFVtB+CnAjuhFLoy7s9Gy5HyhU9ZqScmpwQFzKRQ/XH3adiGv73Zo2zWLZ9qIlrliXx 1ikw== 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=Hy0E4MZ6jBaGq4Jfstxom6N/KOiljZNorjKOeY3m1Ik=; b=H22Cc0QVmXEazMC/zjPkdDq4aO5fUq89sjbwTDkEVPazh+/xzX/Fr8TgH4e/ZmBG5i DMSqaG1XEInNo5t2L6w5uW2wKNS+UO5+b/pJDTsVo3ZDeVUaDnnKH1snfc68TW3/1r43 4NvQ5iarjRkZH/vfK5ctWnSCoVHRcasI6Rm9mf65GMkIxIl+m7IW3Ow7ys6IGjmxVsIL xS9SBpN6w6kwFngNH+78PtX1QvUwqyCQRSs9zymlXK0m40BKK2t0SyMKtJUlztNSx63P L0pXcAqXO/aagQJ9pREfzzvQGEOuQotEIuuNJ8EG0pgCMjZmNwa5lBxusnIHGJUQ9kUW 2RDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=aT50Ae02; 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 sg34-20020a170907a42200b00791a7e441a3si774339ejc.459.2022.11.17.07.12.09; Thu, 17 Nov 2022 07:12:34 -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=aT50Ae02; 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 S240246AbiKQPJK (ORCPT + 99 others); Thu, 17 Nov 2022 10:09:10 -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 S239716AbiKQPIs (ORCPT ); Thu, 17 Nov 2022 10:08:48 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1287769D6; Thu, 17 Nov 2022 07:08:05 -0800 (PST) Date: Thu, 17 Nov 2022 15:08:03 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668697684; 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=Hy0E4MZ6jBaGq4Jfstxom6N/KOiljZNorjKOeY3m1Ik=; b=aT50Ae02GBSeiKn6JOkOttAO/3VIPe489v1n1CTRIaJ+raPd5kLyRgn+C7c5Pu75YplH5Y qn5Dq76bzvncSDdWE7rcXi2lAniE+BgwcbDwJhqcABplMWaWIk+ml0f0Ovu+zPMl1pHKxh oh+3qVOlXpcHaZ8jXvOZxU4swx5Qf3pQQ5e1esSbRZvH3UkqfknuyWEqMXoCjomK4id6p/ aPqb+vvJwyOkaCx4kOb2dYv3PX5NxFQbp5yj0H/6pvmOCv5IQ3HkCeIHIIqDCGQAXpFtIY q0RPnCwyLcbAThjMqfpxOfTMZVyQxM3NFxADqmI8Fh8fKNg00LkqSqm4Mh0SPw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668697684; 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=Hy0E4MZ6jBaGq4Jfstxom6N/KOiljZNorjKOeY3m1Ik=; b=uyH0ncbzpFLQsgyaMOxwLMjy6r+etP3xJ0qjQwmf9rzVcjdtZSgoz2tD7AY8xxX1MRh4Qa GXjj3PB9cTTRx/CQ== 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_irq_get_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: <20221111122015.214792769@linutronix.de> References: <20221111122015.214792769@linutronix.de> MIME-Version: 1.0 Message-ID: <166869768306.4906.11479048488113384421.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?1749208468148514769?= X-GMAIL-MSGID: =?utf-8?q?1749756625961206030?= The following commit has been merged into the irq/core branch of tip: Commit-ID: be37b8428b7b7740bbbc29c17cfa2ee42b9e2d8b Gitweb: https://git.kernel.org/tip/be37b8428b7b7740bbbc29c17cfa2ee42b9e2d8b Author: Ahmed S. Darwish AuthorDate: Fri, 11 Nov 2022 14:54:59 +01:00 Committer: Thomas Gleixner CommitterDate: Thu, 17 Nov 2022 15:15:21 +01:00 PCI/MSI: Move pci_irq_get_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_irq_get_affinity() and let its kernel-doc match rest of the file. Signed-off-by: Ahmed S. Darwish Signed-off-by: Thomas Gleixner Acked-by: Bjorn Helgaas Link: https://lore.kernel.org/r/20221111122015.214792769@linutronix.de --- drivers/pci/msi/api.c | 43 ++++++++++++++++++++++++++++++++++++++++++- drivers/pci/msi/msi.c | 38 +------------------------------------- 2 files changed, 43 insertions(+), 38 deletions(-) diff --git a/drivers/pci/msi/api.c b/drivers/pci/msi/api.c index 20a580b..93ddc55 100644 --- a/drivers/pci/msi/api.c +++ b/drivers/pci/msi/api.c @@ -9,6 +9,7 @@ */ #include +#include #include "msi.h" @@ -251,6 +252,48 @@ int pci_irq_vector(struct pci_dev *dev, unsigned int nr) EXPORT_SYMBOL(pci_irq_vector); /** + * pci_irq_get_affinity() - Get a device interrupt vector affinity + * @dev: the PCI device to operate on + * @nr: device-relative interrupt vector index (0-based); has different + * meanings, depending on interrupt mode + * MSI-X the index in the MSI-X vector table + * MSI the index of the enabled MSI vectors + * INTx must be 0 + * + * Return: MSI/MSI-X vector affinity, NULL if @nr is out of range or if + * the MSI(-X) vector was allocated without explicit affinity + * requirements (e.g., by pci_enable_msi(), pci_enable_msix_range(), or + * pci_alloc_irq_vectors() without the %PCI_IRQ_AFFINITY flag). Return a + * generic set of CPU IDs representing all possible CPUs available + * during system boot if the device is in legacy INTx mode. + */ +const struct cpumask *pci_irq_get_affinity(struct pci_dev *dev, int nr) +{ + int idx, irq = pci_irq_vector(dev, nr); + struct msi_desc *desc; + + if (WARN_ON_ONCE(irq <= 0)) + return NULL; + + desc = irq_get_msi_desc(irq); + /* Non-MSI does not have the information handy */ + if (!desc) + return cpu_possible_mask; + + /* MSI[X] interrupts can be allocated without affinity descriptor */ + if (!desc->affinity) + return NULL; + + /* + * MSI has a mask array in the descriptor. + * MSI-X has a single mask. + */ + idx = dev->msi_enabled ? nr : 0; + return &desc->affinity[idx].mask; +} +EXPORT_SYMBOL(pci_irq_get_affinity); + +/** * pci_free_irq_vectors() - Free previously allocated IRQs for a device * @dev: the PCI device to operate on * diff --git a/drivers/pci/msi/msi.c b/drivers/pci/msi/msi.c index 6fa90d0..d78646d 100644 --- a/drivers/pci/msi/msi.c +++ b/drivers/pci/msi/msi.c @@ -854,44 +854,6 @@ int __pci_enable_msix_range(struct pci_dev *dev, } } -/** - * pci_irq_get_affinity - return the affinity of a particular MSI vector - * @dev: PCI device to operate on - * @nr: device-relative interrupt vector index (0-based). - * - * @nr has the following meanings depending on the interrupt mode: - * MSI-X: The index in the MSI-X vector table - * MSI: The index of the enabled MSI vectors - * INTx: Must be 0 - * - * Return: A cpumask pointer or NULL if @nr is out of range - */ -const struct cpumask *pci_irq_get_affinity(struct pci_dev *dev, int nr) -{ - int idx, irq = pci_irq_vector(dev, nr); - struct msi_desc *desc; - - if (WARN_ON_ONCE(irq <= 0)) - return NULL; - - desc = irq_get_msi_desc(irq); - /* Non-MSI does not have the information handy */ - if (!desc) - return cpu_possible_mask; - - /* MSI[X] interrupts can be allocated without affinity descriptor */ - if (!desc->affinity) - return NULL; - - /* - * MSI has a mask array in the descriptor. - * MSI-X has a single mask. - */ - idx = dev->msi_enabled ? nr : 0; - return &desc->affinity[idx].mask; -} -EXPORT_SYMBOL(pci_irq_get_affinity); - struct pci_dev *msi_desc_to_pci_dev(struct msi_desc *desc) { return to_pci_dev(desc->dev);