From patchwork Fri Nov 11 13:54:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 18766 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp753155wru; Fri, 11 Nov 2022 05:57:46 -0800 (PST) X-Google-Smtp-Source: AA0mqf7z9UlfROQeX39/EqRSuKxes0marSDOSP7HkV/jNFTKvMxyAy8WTaHeGiPVIw5gJ+kvHs28 X-Received: by 2002:a05:6402:1547:b0:461:5e99:a299 with SMTP id p7-20020a056402154700b004615e99a299mr1581846edx.40.1668175066460; Fri, 11 Nov 2022 05:57:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668175066; cv=none; d=google.com; s=arc-20160816; b=rhE3DVjw6ONXOw4ZZE6DpdQRP+zuwE1BYllejz1hMm9gUOUFisRD0sc4fcWNHCd+tO O4B4ri8N6TRRB2pVdTHsdmQ6ve1V219qKIFGSUl7b3axhh0ed/LLk2abXOapca7OTdtn pVcGaW2I4E0qyXpeysnqKwvX92ONdcOOt43Fl6KLM6nZaxSvH8AC+CXlzDOpbvC2EqCY C6rbNWc5LfEp6DELV7WoFk0y/iFeHS2FFJh8kxnB/jn6F1DruezXUw8E7zVtSJJW9Ul8 ixLND+9AvDAIsK7ih8GKm6stnJQw3u7XtQMzPbQwvbBCkHjFTmlIYgNAT/cGvPI6QZ8C Aepg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=wQvlSyzCiWq4qPGjM0h6GVII+05+CelOP+QrbE9YOVQ=; b=AzAjTueItOUOoAyZS+BdDYo7zWZ/MNJGyCN6/o2T/3O+BLNAfpWkzR6cF/Fo3oJGe8 6rS1QmZnahKwVlv3IAPlcesxDK/MwJ3my8MEjGLdZTR9M64SSgZexYSSp9P20zyLG29A DgcD8UvAQbPImUpIgr6Kg94YhrP+zxiWpttOZi1PIUdj6UJKdlIiC2cRZzAa62yZVXn8 mWdhwVV9ThNlkXbEO71y1EqRYRxifoc4RilLOVecjiF91O5gE4tAoeA2L+qX3nBYap04 CH2v/T1U4+t6A393HsW3/X6kKxJ7cfW+ISu1xwNFwdVgB2wzLAKRcyiZtQ+R4CoYPcgJ ll8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=fw5D8vTE; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 s4-20020a17090699c400b0078df1c345dasi2368139ejn.534.2022.11.11.05.57.22; Fri, 11 Nov 2022 05:57:46 -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=fw5D8vTE; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 S233898AbiKKN4f (ORCPT + 99 others); Fri, 11 Nov 2022 08:56:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233896AbiKKNzs (ORCPT ); Fri, 11 Nov 2022 08:55:48 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2EFA79D3A; Fri, 11 Nov 2022 05:54:48 -0800 (PST) Message-ID: <20221111122014.755178149@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668174887; 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: references:references; bh=wQvlSyzCiWq4qPGjM0h6GVII+05+CelOP+QrbE9YOVQ=; b=fw5D8vTEf9OL/Hzxz50Ijd298/wbFchLIr8TMyRCskQnsWvuZwH85WDzYjyxa/PEEcm5S/ jq140H9dPnla1HZ3agqexHNFjhhzevUEVMXErO41h9kt9fao5vPKasGbCjKy9taJBY6hzv yXdu189B1M6hsC3msYMEU/SeaOuNFVdBoPjU9PO6ZGO+f4orB+1BmljW6SgW5O74Z3rM4b QSHAkL0lksdoznJyZ5kTjUKaP+JCdBYlcsUUx2Evza+ALkmP6L3ImXtuKlCJSPLOwLVok0 zz/njXuPPM0/spkdh7Z/3jQC9a2dfjIJeIQNNTOdDc1iR6SkzxFynpI0qJ0vhQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668174887; 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: references:references; bh=wQvlSyzCiWq4qPGjM0h6GVII+05+CelOP+QrbE9YOVQ=; b=ziGlwcK3Nj4s7gB/ueyqfSNSgD74IeHz55tHp/olK9uxKE7YDq5psk3BkZY1xDx4OMxWIZ CVYs5Yt0p+c5FYCw== From: Thomas Gleixner To: LKML Cc: 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: [patch 20/39] PCI/MSI: Move pci_enable_msi() API to api.c References: <20221111120501.026511281@linutronix.de> MIME-Version: 1.0 Date: Fri, 11 Nov 2022 14:54:46 +0100 (CET) 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?1749208338166041756?= X-GMAIL-MSGID: =?utf-8?q?1749208338166041756?= 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. Move pci_enable_msi() and make its kernel-doc comprehensive. Signed-off-by: Ahmed S. Darwish Signed-off-by: Thomas Gleixner Acked-by: Bjorn Helgaas --- drivers/pci/msi/api.c | 23 +++++++++++++++++++++++ drivers/pci/msi/msi.c | 14 ++------------ drivers/pci/msi/msi.h | 1 + 3 files changed, 26 insertions(+), 12 deletions(-) --- diff --git a/drivers/pci/msi/api.c b/drivers/pci/msi/api.c index 7485942cbe5d..63d7f8f6a284 100644 --- a/drivers/pci/msi/api.c +++ b/drivers/pci/msi/api.c @@ -13,6 +13,29 @@ #include "msi.h" /** + * pci_enable_msi() - Enable MSI interrupt mode on device + * @dev: the PCI device to operate on + * + * Legacy device driver API to enable MSI interrupts mode on device and + * allocate a single interrupt vector. On success, the allocated vector + * Linux IRQ will be saved at @dev->irq. The driver must invoke + * pci_disable_msi() on cleanup. + * + * NOTE: The newer pci_alloc_irq_vectors() / pci_free_irq_vectors() API + * pair should, in general, be used instead. + * + * Return: 0 on success, errno otherwise + */ +int pci_enable_msi(struct pci_dev *dev) +{ + int rc = __pci_enable_msi_range(dev, 1, 1, NULL); + if (rc < 0) + return rc; + return 0; +} +EXPORT_SYMBOL(pci_enable_msi); + +/** * pci_disable_msi() - Disable MSI interrupt mode on device * @dev: the PCI device to operate on * diff --git a/drivers/pci/msi/msi.c b/drivers/pci/msi/msi.c index 4a1300b74518..98f07ad9af62 100644 --- a/drivers/pci/msi/msi.c +++ b/drivers/pci/msi/msi.c @@ -790,8 +790,8 @@ void pci_disable_msix(struct pci_dev *dev) } EXPORT_SYMBOL(pci_disable_msix); -static int __pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec, - struct irq_affinity *affd) +int __pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec, + struct irq_affinity *affd) { int nvec; int rc; @@ -844,16 +844,6 @@ static int __pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec, } } -/* deprecated, don't use */ -int pci_enable_msi(struct pci_dev *dev) -{ - int rc = __pci_enable_msi_range(dev, 1, 1, NULL); - if (rc < 0) - return rc; - return 0; -} -EXPORT_SYMBOL(pci_enable_msi); - static int __pci_enable_msix_range(struct pci_dev *dev, struct msix_entry *entries, int minvec, int maxvec, struct irq_affinity *affd, diff --git a/drivers/pci/msi/msi.h b/drivers/pci/msi/msi.h index 634879277349..00bb98d5bb0e 100644 --- a/drivers/pci/msi/msi.h +++ b/drivers/pci/msi/msi.h @@ -87,6 +87,7 @@ static inline __attribute_const__ u32 msi_multi_mask(struct msi_desc *desc) /* MSI internal functions invoked from the public APIs */ void pci_msi_shutdown(struct pci_dev *dev); void pci_free_msi_irqs(struct pci_dev *dev); +int __pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec, struct irq_affinity *affd); /* Legacy (!IRQDOMAIN) fallbacks */ #ifdef CONFIG_PCI_MSI_ARCH_FALLBACKS