From: Jens Axboe <jens.axboe@oracle.com>
To: linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org
Cc: Eric.Moore@lsi.com, jeff@garzik.org, Jens Axboe <jens.axboe@oracle.com>
Subject: [PATCH 2/3] libata: add support for blk-iopoll
Date: Thu, 6 Aug 2009 21:58:04 +0200 [thread overview]
Message-ID: <1249588685-4662-3-git-send-email-jens.axboe@oracle.com> (raw)
In-Reply-To: <1249588685-4662-1-git-send-email-jens.axboe@oracle.com>
This adds basic support to libata, and specific support for ahci.
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
---
drivers/ata/ahci.c | 53 +++++++++++++++++++++++++++++++++++++++++++++--
include/linux/libata.h | 2 +
2 files changed, 52 insertions(+), 3 deletions(-)
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 958c1fa..9dda8ca 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -45,6 +45,7 @@
#include <scsi/scsi_host.h>
#include <scsi/scsi_cmnd.h>
#include <linux/libata.h>
+#include <linux/blk-iopoll.h>
#define DRV_NAME "ahci"
#define DRV_VERSION "3.0"
@@ -2053,7 +2054,7 @@ static void ahci_error_intr(struct ata_port *ap, u32 irq_stat)
ata_port_abort(ap);
}
-static void ahci_port_intr(struct ata_port *ap)
+static int ahci_port_intr(struct ata_port *ap)
{
void __iomem *port_mmio = ahci_port_base(ap);
struct ata_eh_info *ehi = &ap->link.eh_info;
@@ -2083,7 +2084,7 @@ static void ahci_port_intr(struct ata_port *ap)
if (unlikely(status & PORT_IRQ_ERROR)) {
ahci_error_intr(ap, status);
- return;
+ return 0;
}
if (status & PORT_IRQ_SDB_FIS) {
@@ -2124,7 +2125,43 @@ static void ahci_port_intr(struct ata_port *ap)
ehi->err_mask |= AC_ERR_HSM;
ehi->action |= ATA_EH_RESET;
ata_port_freeze(ap);
+ rc = 0;
}
+
+ return rc;
+}
+
+static void ap_irq_disable(struct ata_port *ap)
+{
+ void __iomem *port_mmio = ahci_port_base(ap);
+
+ writel(0, port_mmio + PORT_IRQ_MASK);
+}
+
+static void ap_irq_enable(struct ata_port *ap)
+{
+ void __iomem *port_mmio = ahci_port_base(ap);
+ struct ahci_port_priv *pp = ap->private_data;
+
+ writel(pp->intr_mask, port_mmio + PORT_IRQ_MASK);
+}
+
+static int ahci_iopoll(struct blk_iopoll *iop, int budget)
+{
+ struct ata_port *ap = container_of(iop, struct ata_port, iopoll);
+ unsigned long flags;
+ int ret;
+
+ spin_lock_irqsave(&ap->host->lock, flags);
+ ret = ahci_port_intr(ap);
+ spin_unlock_irqrestore(&ap->host->lock, flags);
+
+ if (ret < budget) {
+ blk_iopoll_complete(iop);
+ ap_irq_enable(ap);
+ }
+
+ return ret;
}
static irqreturn_t ahci_interrupt(int irq, void *dev_instance)
@@ -2157,7 +2194,12 @@ static irqreturn_t ahci_interrupt(int irq, void *dev_instance)
ap = host->ports[i];
if (ap) {
- ahci_port_intr(ap);
+ if (!blk_iopoll_enabled)
+ ahci_port_intr(ap);
+ else if (blk_iopoll_sched_prep(&ap->iopoll)) {
+ ap_irq_disable(ap);
+ blk_iopoll_sched(&ap->iopoll);
+ }
VPRINTK("port %u\n", i);
} else {
VPRINTK("port %u (no irq)\n", i);
@@ -2299,6 +2341,7 @@ static int ahci_port_resume(struct ata_port *ap)
else
ahci_pmp_detach(ap);
+ blk_iopoll_enable(&ap->iopoll);
return 0;
}
@@ -2421,6 +2464,8 @@ static int ahci_port_start(struct ata_port *ap)
ap->private_data = pp;
+ blk_iopoll_init(&ap->iopoll, 32, ahci_iopoll);
+
/* engage engines, captain */
return ahci_port_resume(ap);
}
@@ -2434,6 +2479,8 @@ static void ahci_port_stop(struct ata_port *ap)
rc = ahci_deinit_port(ap, &emsg);
if (rc)
ata_port_printk(ap, KERN_WARNING, "%s (%d)\n", emsg, rc);
+
+ blk_iopoll_disable(&ap->iopoll);
}
static int ahci_configure_dma_masks(struct pci_dev *pdev, int using_dac)
diff --git a/include/linux/libata.h b/include/linux/libata.h
index 7cfed24..14bba58 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -37,6 +37,7 @@
#include <scsi/scsi_host.h>
#include <linux/acpi.h>
#include <linux/cdrom.h>
+#include <linux/blk-iopoll.h>
/*
* Define if arch has non-standard setup. This is a _PCI_ standard
@@ -761,6 +762,7 @@ struct ata_port {
#endif
/* owned by EH */
u8 sector_buf[ATA_SECT_SIZE] ____cacheline_aligned;
+ struct blk_iopoll iopoll;
};
/* The following initializer overrides a method to NULL whether one of
--
1.6.3.2.306.g4f4fa
next prev parent reply other threads:[~2009-08-06 19:58 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-06 19:58 [PATCH 0/3]: blk-iopoll, a polled completion API for block devices Jens Axboe
2009-08-06 19:58 ` [PATCH 1/3] block: add blk-iopoll, a NAPI like approach " Jens Axboe
2009-08-06 21:32 ` Alan Cox
2009-08-07 6:37 ` Jens Axboe
2009-08-07 8:38 ` Jeff Garzik
2009-08-07 8:50 ` Jens Axboe
2009-08-07 11:05 ` Jens Axboe
2009-08-07 11:31 ` Jens Axboe
2009-08-19 19:08 ` Jens Axboe
2009-08-20 11:30 ` [PATCH 1/3] block: add blk-iopoll, a NAPI like approach forblock devices jack wang
2009-08-20 11:38 ` Jens Axboe
2009-08-06 19:58 ` Jens Axboe [this message]
2009-08-10 17:15 ` [PATCH 2/3] libata: add support for blk-iopoll Jonathan Corbet
2009-08-10 17:22 ` Jens Axboe
2009-08-06 19:58 ` [PATCH 3/3] mptfusion: " Jens Axboe
2009-08-11 10:35 ` [PATCH 0/3]: blk-iopoll, a polled completion API for block devices Bart Van Assche
2009-08-11 14:39 ` Jens Axboe
2009-08-11 14:59 ` Bart Van Assche
2009-08-11 17:14 ` Jens Axboe
2009-08-11 18:37 ` Bart Van Assche
2009-08-11 18:41 ` Jens Axboe
2009-08-11 18:49 ` Bart Van Assche
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=1249588685-4662-3-git-send-email-jens.axboe@oracle.com \
--to=jens.axboe@oracle.com \
--cc=Eric.Moore@lsi.com \
--cc=jeff@garzik.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.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
all inboxes | Powered by JetHome®