From: Matthew Wilcox <matthew@wil.cx>
To: linux-pci@vger.kernel.org
Cc: kaneshige.kenji@jp.fujitsu.com, mingo@elte.hu,
tglx@linutronix.de, davem@davemloft.net,
dan.j.williams@intel.com, Martine.Silbermann@hp.com,
benh@kernel.crashing.org, michael@ellerman.id.au,
linux-kernel@vger.kernel.org, Matthew Wilcox <matthew@wil.cx>,
Matthew Wilcox <willy@linux.intel.com>
Subject: [PATCH 3/4] AHCI: Request multiple MSIs
Date: Sat, 5 Jul 2008 09:34:14 -0400 [thread overview]
Message-ID: <1215264855-4372-3-git-send-email-matthew@wil.cx> (raw)
In-Reply-To: <20080705132728.GO14894@parisc-linux.org>
AHCI controllers can support up to 16 interrupts, one per port. This
saves us a readl() in the interrupt path to determine which port has
generated the interrupt.
Signed-off-by: Matthew Wilcox <willy@linux.intel.com>
---
drivers/ata/ahci.c | 84 ++++++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 79 insertions(+), 5 deletions(-)
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 061817a..4b2f90a 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -102,6 +102,7 @@ enum {
/* HOST_CTL bits */
HOST_RESET = (1 << 0), /* reset controller; self-clear */
HOST_IRQ_EN = (1 << 1), /* global IRQ enable */
+ HOST_MSI_RSM = (1 << 2), /* Revert to Single Message */
HOST_AHCI_EN = (1 << 31), /* AHCI enabled */
/* HOST_CAP bits */
@@ -1771,6 +1772,13 @@ static void ahci_port_intr(struct ata_port *ap)
}
}
+static irqreturn_t ahci_msi_interrupt(int irq, void *dev_instance)
+{
+ struct ata_port *ap = dev_instance;
+ ahci_port_intr(ap);
+ return IRQ_HANDLED;
+}
+
static irqreturn_t ahci_interrupt(int irq, void *dev_instance)
{
struct ata_host *host = dev_instance;
@@ -2210,6 +2218,66 @@ static void ahci_p5wdh_workaround(struct ata_host *host)
}
}
+static int ahci_request_irqs(struct pci_dev *pdev, struct ata_host *host)
+{
+ int i, n_irqs, rc;
+ struct ahci_host_priv *hpriv = host->private_data;
+
+ if (hpriv->flags & AHCI_HFLAG_NO_MSI) {
+ n_irqs = 1;
+ } else {
+ u16 control;
+ int pos = pci_find_capability(pdev, PCI_CAP_ID_MSI);
+ pci_read_config_word(pdev, pos + PCI_MSI_FLAGS, &control);
+ n_irqs = 1 << ((control & PCI_MSI_FLAGS_QMASK) >> 1);
+
+ for (;;) {
+ rc = pci_enable_msi_block(pdev, n_irqs);
+ if (rc == 0) {
+ void __iomem *mmio = host->iomap[AHCI_PCI_BAR];
+ u32 host_ctl = readl(mmio + HOST_CTL);
+ if ((host_ctl & HOST_MSI_RSM) == 0)
+ break;
+ pci_disable_msi(pdev);
+ n_irqs = 1;
+ } else if (rc < 0) {
+ n_irqs = 1;
+ pci_intx(pdev, 1);
+ break;
+ } else {
+ n_irqs = rc;
+ }
+ }
+ }
+
+ /* FIXME: Add support for CCC */
+ if (n_irqs > host->n_ports) {
+ n_irqs = host->n_ports;
+ } else if (n_irqs < host->n_ports) {
+ n_irqs--;
+ rc = devm_request_irq(host->dev, pdev->irq + n_irqs,
+ ahci_interrupt, IRQF_SHARED,
+ dev_driver_string(host->dev), host);
+ if (rc)
+ goto release_block;
+ }
+
+ for (i = 0; i < n_irqs; i++) {
+ rc = devm_request_irq(host->dev, pdev->irq + i,
+ ahci_msi_interrupt, IRQF_SHARED,
+ dev_driver_string(host->dev), host->ports[i]);
+ if (rc)
+ goto release_block;
+ }
+
+ return 0;
+
+ release_block:
+ pci_disable_msi(pdev);
+ pci_intx(pdev, 1);
+ return rc;
+}
+
static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
{
static int printed_version;
@@ -2268,9 +2336,6 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
(pdev->revision == 0xa1 || pdev->revision == 0xa2))
hpriv->flags |= AHCI_HFLAG_NO_MSI;
- if ((hpriv->flags & AHCI_HFLAG_NO_MSI) || pci_enable_msi(pdev))
- pci_intx(pdev, 1);
-
/* save initial config */
ahci_save_initial_config(pdev, hpriv);
@@ -2325,8 +2390,17 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
ahci_print_info(host);
pci_set_master(pdev);
- return ata_host_activate(host, pdev->irq, ahci_interrupt, IRQF_SHARED,
- &ahci_sht);
+
+ rc = ata_host_start(host);
+ if (rc)
+ return rc;
+
+ rc = ahci_request_irqs(pdev, host);
+ if (rc)
+ return rc;
+
+ rc = ata_host_register(host, &ahci_sht);
+ return rc;
}
static int __init ahci_init(void)
--
1.5.5.4
next prev parent reply other threads:[~2008-07-05 21:11 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-03 2:44 Multiple MSI Matthew Wilcox
2008-07-03 3:24 ` Benjamin Herrenschmidt
2008-07-03 3:59 ` Matthew Wilcox
2008-07-03 4:41 ` Benjamin Herrenschmidt
2008-07-03 6:44 ` Michael Ellerman
2008-07-03 9:10 ` Arnd Bergmann
2008-07-03 9:17 ` Benjamin Herrenschmidt
2008-07-03 11:31 ` Matthew Wilcox
2008-07-03 11:41 ` Benjamin Herrenschmidt
2008-07-04 1:52 ` Michael Ellerman
2008-07-04 8:08 ` Alan Cox
2008-07-03 11:34 ` Matthew Wilcox
2008-07-07 16:17 ` Grant Grundler
2008-07-07 16:39 ` Matthew Wilcox
2008-07-07 16:51 ` Grant Grundler
2008-07-07 23:06 ` Benjamin Herrenschmidt
2008-07-10 0:55 ` Michael Ellerman
2008-07-05 13:27 ` Matthew Wilcox
2008-07-05 13:34 ` [PATCH 1/4] PCI MSI: Store the number of messages in the msi_desc Matthew Wilcox
2008-07-07 2:05 ` Michael Ellerman
2008-07-07 2:41 ` Matthew Wilcox
2008-07-07 3:26 ` Benjamin Herrenschmidt
2008-07-07 3:48 ` Michael Ellerman
2008-07-07 12:04 ` Matthew Wilcox
2008-07-07 16:02 ` Grant Grundler
2008-07-07 16:19 ` Matthew Wilcox
2008-07-10 1:32 ` Michael Ellerman
2008-07-10 1:35 ` Matthew Wilcox
2008-07-05 13:34 ` [PATCH 2/4] PCI: Support multiple MSI Matthew Wilcox
2008-07-07 2:05 ` Michael Ellerman
2008-07-07 2:45 ` Matthew Wilcox
2008-07-07 3:56 ` Michael Ellerman
2008-07-07 11:31 ` Matthew Wilcox
2008-07-10 1:32 ` Michael Ellerman
2008-07-10 1:43 ` Matthew Wilcox
2008-07-10 4:00 ` Michael Ellerman
2008-07-05 13:34 ` Matthew Wilcox [this message]
2008-07-07 16:45 ` [PATCH 3/4] AHCI: Request multiple MSIs Grant Grundler
2008-07-07 17:48 ` Matthew Wilcox
2008-07-20 7:49 ` Grant Grundler
2008-07-05 13:34 ` [PATCH 4/4] x86-64: Support for " Matthew Wilcox
2008-07-05 13:43 ` Multiple MSI Matthew Wilcox
2008-07-05 22:38 ` Matthew Wilcox
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=1215264855-4372-3-git-send-email-matthew@wil.cx \
--to=matthew@wil.cx \
--cc=Martine.Silbermann@hp.com \
--cc=benh@kernel.crashing.org \
--cc=dan.j.williams@intel.com \
--cc=davem@davemloft.net \
--cc=kaneshige.kenji@jp.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=michael@ellerman.id.au \
--cc=mingo@elte.hu \
--cc=tglx@linutronix.de \
--cc=willy@linux.intel.com \
/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
all inboxes | Powered by JetHome®