linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Gordeev <agordeev@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: Alexander Gordeev <agordeev@redhat.com>,
	Bjorn Helgaas <bhelgaas@google.com>,
	Michael Ellerman <michael@ellerman.id.au>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Tejun Heo <tj@kernel.org>,
	Ben Hutchings <bhutchings@solarflare.com>,
	David Laight <David.Laight@ACULAB.COM>,
	Mark Lord <kernel@start.ca>, "H. Peter Anvin" <hpa@zytor.com>,
	linux-pci@vger.kernel.org
Subject: [PATCH RFC v2 10/29] PCI/MSI: Get rid of pci_enable_msi_block_auto() interface
Date: Fri, 18 Oct 2013 19:12:10 +0200	[thread overview]
Message-ID: <246d1586c10fc8c787935e6d14c80f7fc268cd00.1382103786.git.agordeev@redhat.com> (raw)
In-Reply-To: <cover.1382103786.git.agordeev@redhat.com>

As result of introduction of pci_get_msi_cap() interface
pci_enable_msi_block_auto() function became superflous.

To enable maximum possible number of MSIs drivers will
first obtain that number from pci_get_msi_cap() function
and then call pci_enable_msi_block() interface.

Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
---
 Documentation/PCI/MSI-HOWTO.txt |   30 +-------------------
 drivers/ata/ahci.c              |   56 ++++++++++++++++++++++++--------------
 drivers/pci/msi.c               |   22 ---------------
 include/linux/pci.h             |    7 -----
 4 files changed, 37 insertions(+), 78 deletions(-)

diff --git a/Documentation/PCI/MSI-HOWTO.txt b/Documentation/PCI/MSI-HOWTO.txt
index e7e3b20..47118f3 100644
--- a/Documentation/PCI/MSI-HOWTO.txt
+++ b/Documentation/PCI/MSI-HOWTO.txt
@@ -127,33 +127,7 @@ on the number of vectors that can be allocated; pci_enable_msi_block()
 returns as soon as it finds any constraint that doesn't allow the
 call to succeed.
 
-4.2.3 pci_enable_msi_block_auto
-
-int pci_enable_msi_block_auto(struct pci_dev *dev, unsigned int *count)
-
-This variation on pci_enable_msi() call allows a device driver to request
-the maximum possible number of MSIs.  The MSI specification only allows
-interrupts to be allocated in powers of two, up to a maximum of 2^5 (32).
-
-If this function returns a positive number, it indicates that it has
-succeeded and the returned value is the number of allocated interrupts. In
-this case, the function enables MSI on this device and updates dev->irq to
-be the lowest of the new interrupts assigned to it.  The other interrupts
-assigned to the device are in the range dev->irq to dev->irq + returned
-value - 1.
-
-If this function returns a negative number, it indicates an error and
-the driver should not attempt to request any more MSI interrupts for
-this device.
-
-If the device driver needs to know the number of interrupts the device
-supports it can pass the pointer count where that number is stored. The
-device driver must decide what action to take if pci_enable_msi_block_auto()
-succeeds, but returns a value less than the number of interrupts supported.
-If the device driver does not need to know the number of interrupts
-supported, it can set the pointer count to NULL.
-
-4.2.4 pci_disable_msi
+4.2.3 pci_disable_msi
 
 void pci_disable_msi(struct pci_dev *dev)
 
@@ -169,7 +143,7 @@ on any interrupt for which it previously called request_irq().
 Failure to do so results in a BUG_ON(), leaving the device with
 MSI enabled and thus leaking its vector.
 
-4.2.5 pci_get_msi_cap
+4.2.4 pci_get_msi_cap
 
 int pci_get_msi_cap(struct pci_dev *dev)
 
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 9d715ae..f1c8838 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -1091,26 +1091,40 @@ static inline void ahci_gtf_filter_workaround(struct ata_host *host)
 {}
 #endif
 
-int ahci_init_interrupts(struct pci_dev *pdev, struct ahci_host_priv *hpriv)
+int ahci_init_interrupts(struct pci_dev *pdev, unsigned int n_ports,
+			 struct ahci_host_priv *hpriv)
 {
-	int rc;
-	unsigned int maxvec;
+	int rc, nvec;
 
-	if (!(hpriv->flags & AHCI_HFLAG_NO_MSI)) {
-		rc = pci_enable_msi_block_auto(pdev, &maxvec);
-		if (rc > 0) {
-			if ((rc == maxvec) || (rc == 1))
-				return rc;
-			/*
-			 * Assume that advantage of multipe MSIs is negated,
-			 * so fallback to single MSI mode to save resources
-			 */
-			pci_disable_msi(pdev);
-			if (!pci_enable_msi(pdev))
-				return 1;
-		}
-	}
+	if (hpriv->flags & AHCI_HFLAG_NO_MSI)
+		goto intx;
+
+	rc = pci_get_msi_cap(pdev);
+	if (rc < 0)
+		goto intx;
+
+	/*
+	 * If number of MSIs is less than number of ports then Sharing Last
+	 * Message mode could be enforced. In this case assume that advantage
+	 * of multipe MSIs is negated and use single MSI mode instead.
+	 */
+	if (rc < n_ports)
+		goto single_msi;
+
+	nvec = rc;
+	rc = pci_enable_msi_block(pdev, nvec);
+	if (rc)
+		goto intx;
 
+	return nvec;
+
+single_msi:
+	rc = pci_enable_msi(pdev);
+	if (rc)
+		goto intx;
+	return 1;
+
+intx:
 	pci_intx(pdev, 1);
 	return 0;
 }
@@ -1277,10 +1291,6 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 
 	hpriv->mmio = pcim_iomap_table(pdev)[ahci_pci_bar];
 
-	n_msis = ahci_init_interrupts(pdev, hpriv);
-	if (n_msis > 1)
-		hpriv->flags |= AHCI_HFLAG_MULTI_MSI;
-
 	/* save initial config */
 	ahci_pci_save_initial_config(pdev, hpriv);
 
@@ -1335,6 +1345,10 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	 */
 	n_ports = max(ahci_nr_ports(hpriv->cap), fls(hpriv->port_map));
 
+	n_msis = ahci_init_interrupts(pdev, n_ports, hpriv);
+	if (n_msis > 1)
+		hpriv->flags |= AHCI_HFLAG_MULTI_MSI;
+
 	host = ata_host_alloc_pinfo(&pdev->dev, ppi, n_ports);
 	if (!host)
 		return -ENOMEM;
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index 14dc4d1..13bd901 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -851,28 +851,6 @@ int pci_enable_msi_block(struct pci_dev *dev, unsigned int nvec)
 }
 EXPORT_SYMBOL(pci_enable_msi_block);
 
-int pci_enable_msi_block_auto(struct pci_dev *dev, unsigned int *maxvec)
-{
-	int ret, nvec;
-
-	ret = pci_get_msi_cap(dev);
-	if (ret < 0)
-		return ret;
-
-	if (maxvec)
-		*maxvec = ret;
-
-	do {
-		nvec = ret;
-		ret = pci_enable_msi_block(dev, nvec);
-	} while (ret > 0);
-
-	if (ret < 0)
-		return ret;
-	return nvec;
-}
-EXPORT_SYMBOL(pci_enable_msi_block_auto);
-
 void pci_msi_shutdown(struct pci_dev *dev)
 {
 	struct msi_desc *desc;
diff --git a/include/linux/pci.h b/include/linux/pci.h
index df72084..a04f5da 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1156,12 +1156,6 @@ static inline int pci_enable_msi_block(struct pci_dev *dev, unsigned int nvec)
 	return -ENOSYS;
 }
 
-static inline int
-pci_enable_msi_block_auto(struct pci_dev *dev, unsigned int *maxvec)
-{
-	return -ENOSYS;
-}
-
 static inline void pci_msi_shutdown(struct pci_dev *dev)
 { }
 static inline void pci_disable_msi(struct pci_dev *dev)
@@ -1194,7 +1188,6 @@ static inline int pci_msi_enabled(void)
 #else
 int pci_get_msi_cap(struct pci_dev *dev);
 int pci_enable_msi_block(struct pci_dev *dev, unsigned int nvec);
-int pci_enable_msi_block_auto(struct pci_dev *dev, unsigned int *maxvec);
 void pci_msi_shutdown(struct pci_dev *dev);
 void pci_disable_msi(struct pci_dev *dev);
 int pci_msix_table_size(struct pci_dev *dev);
-- 
1.7.7.6


  parent reply	other threads:[~2013-10-19  7:06 UTC|newest]

Thread overview: 64+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-18 17:12 [PATCH RFC v2 00/29] Introduce pcim_enable_msi*() family helpers Alexander Gordeev
2013-10-18 17:12 ` [PATCH RFC v2 01/29] PCI/MSI/s390: Fix single MSI only check Alexander Gordeev
2013-10-18 17:12 ` [PATCH RFC v2 02/29] PCI/MSI/s390: Remove superfluous check of MSI type Alexander Gordeev
2013-10-18 17:12 ` [PATCH RFC v2 03/29] PCI/MSI/pSeries: Fix wrong error code reporting Alexander Gordeev
2013-10-18 17:12 ` [PATCH RFC v2 04/29] PCI/MSI/pSeries: Make quota traversing and requesting race-safe Alexander Gordeev
2013-11-20 15:43   ` Tejun Heo
2013-10-18 17:12 ` [PATCH RFC v2 05/29] PCI/MSI: Fix return value when populate_msi_sysfs() failed Alexander Gordeev
2013-11-20 15:50   ` Tejun Heo
2013-10-18 17:12 ` [PATCH RFC v2 06/29] PCI/MSI: Get rid of useless count of msi_desc leftovers Alexander Gordeev
2013-11-20 16:07   ` Tejun Heo
2013-11-22 18:27     ` Alexander Gordeev
2013-10-18 17:12 ` [PATCH RFC v2 07/29] PCI/MSI: Return -ENOSYS for unimplemented interfaces, not -1 Alexander Gordeev
2013-11-20 16:07   ` Tejun Heo
2013-10-18 17:12 ` [PATCH RFC v2 08/29] PCI/MSI: Make pci_enable_msix() 'nvec' argument unsigned int Alexander Gordeev
2013-11-20 16:14   ` Tejun Heo
2013-11-22 18:34     ` Alexander Gordeev
2013-10-18 17:12 ` [PATCH RFC v2 09/29] PCI/MSI: Factor out pci_get_msi_cap() interface Alexander Gordeev
2013-11-20 16:18   ` Tejun Heo
2013-11-25 13:49     ` Alexander Gordeev
2013-10-18 17:12 ` Alexander Gordeev [this message]
2013-11-20 16:21   ` [PATCH RFC v2 10/29] PCI/MSI: Get rid of pci_enable_msi_block_auto() interface Tejun Heo
2013-10-18 17:12 ` [PATCH RFC v2 11/29] PCI/MSI: Convert pci_msix_table_size() to a public interface Alexander Gordeev
2013-11-20 16:23   ` Tejun Heo
2013-11-22 18:38     ` Alexander Gordeev
2013-10-18 17:12 ` [PATCH RFC v2 12/29] PCI/MSI: Introduce pcim_enable_msi*() family helpers Alexander Gordeev
2013-10-24 10:51   ` Tejun Heo
2013-10-24 10:57     ` David Laight
2013-10-24 11:01       ` Tejun Heo
2013-10-24 11:41       ` Alexander Gordeev
2013-10-25  2:22         ` Mark Lord
2013-10-25  9:10           ` David Laight
2013-10-25 10:01             ` Alexander Gordeev
2013-10-25 14:52               ` intel e1000e pci driver issue on RT Linux kernel Karicheri, Muralidharan
2013-10-25 14:59                 ` Karicheri, Muralidharan
2013-10-27 22:27               ` [PATCH RFC v2 12/29] PCI/MSI: Introduce pcim_enable_msi*() family helpers Michael Ellerman
2013-10-28 16:30               ` Mark Lord
2013-10-24 14:31     ` Alexander Gordeev
2013-10-25  2:23       ` Mark Lord
2013-11-04  8:12     ` Alexander Gordeev
2013-11-20 17:15   ` Tejun Heo
2013-11-22 18:44     ` Alexander Gordeev
2013-11-22 18:44       ` Tejun Heo
2013-11-22 18:54         ` Alexander Gordeev
2013-10-18 17:12 ` [PATCH RFC v2 13/29] ipr: Do not call pci_disable_msi/msix() if pci_enable_msi/msix() failed Alexander Gordeev
2013-10-18 17:12 ` [PATCH RFC v2 14/29] ipr: Make use of pcim_enable_msi/msix() interfaces Alexander Gordeev
2013-10-18 17:12 ` [PATCH RFC v2 15/29] ixgbe: Make use of pcim_enable_msix_range() interface Alexander Gordeev
2013-10-18 17:12 ` [PATCH RFC v2 16/29] ixgbevf: " Alexander Gordeev
2013-10-18 17:12 ` [PATCH RFC v2 17/29] megaraid: Make use of pcim_enable_msix() interface Alexander Gordeev
2013-10-18 17:12 ` [PATCH RFC v2 18/29] ntb: Fix missed call to pci_enable_msix() Alexander Gordeev
2013-10-18 17:12 ` [PATCH RFC v2 19/29] ntb: Make use of pcim_enable_msix/msix_exact() interfaces Alexander Gordeev
2013-10-18 17:12 ` [PATCH RFC v2 20/29] qib: Make use of pcim_enable_msix() and pci_msix_table_size() interfaces Alexander Gordeev
2013-10-18 17:12 ` [PATCH RFC v2 21/29] qla2xxx: Make use of pcim_enable_msix_range() interface Alexander Gordeev
2013-10-18 17:12 ` [PATCH RFC v2 22/29] qlge: Get rid of an redundant assignment Alexander Gordeev
2013-10-18 17:12 ` [PATCH RFC v2 23/29] qlge: Make use of pcim_enable_msix() interface Alexander Gordeev
2013-10-18 17:12 ` [PATCH RFC v2 24/29] tg3: " Alexander Gordeev
2013-10-18 17:12 ` [PATCH RFC v2 25/29] vmxnet3: Return -EINVAL if number of requested MSI-Xs is not enough Alexander Gordeev
2013-10-18 17:12 ` [PATCH RFC v2 26/29] vmxnet3: Fixup a weird loop exit Alexander Gordeev
2013-10-18 17:12 ` [PATCH RFC v2 27/29] vmxnet3: Return -ENOSPC when not enough MSI-X vectors available Alexander Gordeev
2013-10-18 17:12 ` [PATCH RFC v2 28/29] vmxnet3: Limit number of rx queues to 1 if per-queue MSI-Xs failed Alexander Gordeev
2013-10-18 17:12 ` [PATCH RFC v2 29/29] vmxnet3: Make use of pcim_enable_msix_range() interface Alexander Gordeev
2013-10-21  8:51   ` David Laight
2013-10-21 10:19     ` Alexander Gordeev
2013-11-11 19:56 ` [PATCH RFC v2 00/29] Introduce pcim_enable_msi*() family helpers Alexander Gordeev
2013-11-20 17:16 ` Tejun Heo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=246d1586c10fc8c787935e6d14c80f7fc268cd00.1382103786.git.agordeev@redhat.com \
    --to=agordeev@redhat.com \
    --cc=David.Laight@ACULAB.COM \
    --cc=benh@kernel.crashing.org \
    --cc=bhelgaas@google.com \
    --cc=bhutchings@solarflare.com \
    --cc=hpa@zytor.com \
    --cc=kernel@start.ca \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=michael@ellerman.id.au \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).