From patchwork Fri Oct 10 15:35:43 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Gordeev X-Patchwork-Id: 5066481 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C78F69F295 for ; Fri, 10 Oct 2014 15:35:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AB60620109 for ; Fri, 10 Oct 2014 15:35:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 75D932020E for ; Fri, 10 Oct 2014 15:35:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752790AbaJJPfx (ORCPT ); Fri, 10 Oct 2014 11:35:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60689 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752225AbaJJPfw (ORCPT ); Fri, 10 Oct 2014 11:35:52 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s9AFZqAc014774 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 10 Oct 2014 11:35:52 -0400 Received: from agbook.brq.redhat.com (dhcp-26-194.brq.redhat.com [10.34.26.194]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s9AFZoXa023585; Fri, 10 Oct 2014 11:35:51 -0400 From: Alexander Gordeev To: linux-kernel@vger.kernel.org Cc: Alexander Gordeev , linux-pci@vger.kernel.org Subject: [PATCH] PCI/MSI: Remove pci_enable_msix() Date: Fri, 10 Oct 2014 17:35:43 +0200 Message-Id: <1412955343-27239-1-git-send-email-agordeev@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP There are no users of pci_enable_msix() function left. Obsolete it in favor of pci_enable_msix_range() and pci_enable_msix_exact() functions. Signed-off-by: Alexander Gordeev Cc: linux-pci@vger.kernel.org --- Documentation/PCI/PCIEBUS-HOWTO.txt | 15 +++--- Documentation/PCI/pci.txt | 14 +++--- drivers/pci/msi.c | 91 +++++++++++++++---------------------- include/linux/pci.h | 4 -- 4 files changed, 51 insertions(+), 73 deletions(-) diff --git a/Documentation/PCI/PCIEBUS-HOWTO.txt b/Documentation/PCI/PCIEBUS-HOWTO.txt index 6bd5f37..873a84a 100644 --- a/Documentation/PCI/PCIEBUS-HOWTO.txt +++ b/Documentation/PCI/PCIEBUS-HOWTO.txt @@ -190,13 +190,14 @@ in the field interrupt_mode of struct pcie_device. 6.2 MSI-X Vector Resources Similar to the MSI a device driver for an MSI-X capable device can -call pci_enable_msix to request MSI-X interrupts. All service drivers -are not permitted to switch interrupt mode on its device. The PCI -Express Port Bus driver is responsible for determining the interrupt -mode and this should be transparent to service drivers. Any attempt -by service driver to call pci_enable_msix/pci_disable_msix may -result unpredictable behavior. Service drivers should use -(struct pcie_device*)dev->irq and call request_irq/free_irq. +call pci_enable_msix_range to request MSI-X interrupts. All service +drivers are not permitted to switch interrupt mode on its device. +The PCI Express Port Bus driver is responsible for determining the +interrupt mode and this should be transparent to service drivers. +Any attempt by service driver to call pci_enable_msix_range or +pci_disable_msix may result unpredictable behavior. Service drivers +should use (struct pcie_device*)dev->irq and call request_irq or +free_irq. 6.3 PCI Memory/IO Mapped Regions diff --git a/Documentation/PCI/pci.txt b/Documentation/PCI/pci.txt index 9518006..eb57f0a 100644 --- a/Documentation/PCI/pci.txt +++ b/Documentation/PCI/pci.txt @@ -383,18 +383,18 @@ The fundamental difference between MSI and MSI-X is how multiple "vectors" get allocated. MSI requires contiguous blocks of vectors while MSI-X can allocate several individual ones. -MSI capability can be enabled by calling pci_enable_msi() or -pci_enable_msix() before calling request_irq(). This causes +MSI capability can be enabled by calling pci_enable_msi_range() or +pci_enable_msix_range() before calling request_irq(). This causes the PCI support to program CPU vector data into the PCI device capability registers. If your PCI device supports both, try to enable MSI-X first. Only one can be enabled at a time. Many architectures, chip-sets, -or BIOSes do NOT support MSI or MSI-X and the call to pci_enable_msi/msix -will fail. This is important to note since many drivers have -two (or more) interrupt handlers: one for MSI/MSI-X and another for IRQs. -They choose which handler to register with request_irq() based on the -return value from pci_enable_msi/msix(). +or BIOSes do NOT support MSI or MSI-X and the call to pci_enable_msi_range() +or pci_enable_msix_range() will fail. This is important to note since many +drivers have two (or more) interrupt handlers: one for MSI/MSI-X and another +for IRQs. They choose which handler to register with request_irq() based on +the return value from pci_enable_msi_range() or pci_enable_msix_range(). There are (at least) two really good reasons for using MSI: 1) MSI is an exclusive interrupt vector by definition. diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c index 2f7c92c..0df0ce1 100644 --- a/drivers/pci/msi.c +++ b/drivers/pci/msi.c @@ -903,58 +903,6 @@ int pci_msix_vec_count(struct pci_dev *dev) } EXPORT_SYMBOL(pci_msix_vec_count); -/** - * pci_enable_msix - configure device's MSI-X capability structure - * @dev: pointer to the pci_dev data structure of MSI-X device function - * @entries: pointer to an array of MSI-X entries - * @nvec: number of MSI-X irqs requested for allocation by device driver - * - * Setup the MSI-X capability structure of device function with the number - * of requested irqs upon its software driver call to request for - * MSI-X mode enabled on its hardware device function. A return of zero - * indicates the successful configuration of MSI-X capability structure - * with new allocated MSI-X irqs. A return of < 0 indicates a failure. - * Or a return of > 0 indicates that driver request is exceeding the number - * of irqs or MSI-X vectors available. Driver should use the returned value to - * re-send its request. - **/ -int pci_enable_msix(struct pci_dev *dev, struct msix_entry *entries, int nvec) -{ - int nr_entries; - int i, j; - - if (!pci_msi_supported(dev, nvec)) - return -EINVAL; - - if (!entries) - return -EINVAL; - - nr_entries = pci_msix_vec_count(dev); - if (nr_entries < 0) - return nr_entries; - if (nvec > nr_entries) - return nr_entries; - - /* Check for any invalid entries */ - for (i = 0; i < nvec; i++) { - if (entries[i].entry >= nr_entries) - return -EINVAL; /* invalid entry */ - for (j = i + 1; j < nvec; j++) { - if (entries[i].entry == entries[j].entry) - return -EINVAL; /* duplicate entry */ - } - } - WARN_ON(!!dev->msix_enabled); - - /* Check whether driver already requested for MSI irq */ - if (dev->msi_enabled) { - dev_info(&dev->dev, "can't enable MSI-X (MSI IRQ already assigned)\n"); - return -EINVAL; - } - return msix_capability_init(dev, entries, nvec); -} -EXPORT_SYMBOL(pci_enable_msix); - void pci_msix_shutdown(struct pci_dev *dev) { struct msi_desc *entry; @@ -1088,16 +1036,49 @@ EXPORT_SYMBOL(pci_enable_msi_range); * with new allocated MSI-X interrupts. **/ int pci_enable_msix_range(struct pci_dev *dev, struct msix_entry *entries, - int minvec, int maxvec) + int minvec, int maxvec) { - int nvec = maxvec; + int i, j; + int nvec; int rc; + if (!pci_msi_supported(dev, minvec)) + return -EINVAL; + + WARN_ON(!!dev->msix_enabled); + + /* Check whether driver already requested MSI irqs */ + if (dev->msi_enabled) { + dev_info(&dev->dev, + "can't enable MSI-X (MSI already enabled)\n"); + return -EINVAL; + } + if (maxvec < minvec) return -ERANGE; + else if (!entries) + return -EINVAL; + + nvec = pci_msix_vec_count(dev); + if (nvec < 0) + return nvec; + else if (nvec < minvec) + return -EINVAL; + else if (nvec > maxvec) + nvec = maxvec; + + /* Check for any invalid entries */ + for (i = 0; i < nvec; i++) { + if (entries[i].entry >= nvec) + return -EINVAL; /* invalid entry */ + for (j = i + 1; j < nvec; j++) { + if (entries[i].entry == entries[j].entry) + return -EINVAL; /* duplicate entry */ + } + } do { - rc = pci_enable_msix(dev, entries, nvec); + rc = msix_capability_init(dev, entries, nvec); if (rc < 0) { return rc; } else if (rc > 0) { diff --git a/include/linux/pci.h b/include/linux/pci.h index 5be8db4..ad9b5d4 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1197,7 +1197,6 @@ int pci_msi_vec_count(struct pci_dev *dev); void pci_msi_shutdown(struct pci_dev *dev); void pci_disable_msi(struct pci_dev *dev); int pci_msix_vec_count(struct pci_dev *dev); -int pci_enable_msix(struct pci_dev *dev, struct msix_entry *entries, int nvec); void pci_msix_shutdown(struct pci_dev *dev); void pci_disable_msix(struct pci_dev *dev); void pci_restore_msi_state(struct pci_dev *dev); @@ -1225,9 +1224,6 @@ static inline int pci_msi_vec_count(struct pci_dev *dev) { return -ENOSYS; } static inline void pci_msi_shutdown(struct pci_dev *dev) { } static inline void pci_disable_msi(struct pci_dev *dev) { } static inline int pci_msix_vec_count(struct pci_dev *dev) { return -ENOSYS; } -static inline int pci_enable_msix(struct pci_dev *dev, - struct msix_entry *entries, int nvec) -{ return -ENOSYS; } static inline void pci_msix_shutdown(struct pci_dev *dev) { } static inline void pci_disable_msix(struct pci_dev *dev) { } static inline void pci_restore_msi_state(struct pci_dev *dev) { }