From: Alan Cox <alan@lxorguk.ukuu.org.uk>
To: linux-ide@vger.kernel.org, jeff@garzik.org
Subject: [PATCH] libata: PIO bounce copies to avoid long IRQ off runs
Date: Tue, 29 Apr 2008 14:47:54 +0100 [thread overview]
Message-ID: <20080429144754.7d2952c8@core> (raw)
Right now with PIO transfers we can jam the box up horribly as lock IRQs
off when the transfer is from high memory. We still have other things we
need to fix in this area to really make a difference but this is the
buffering side of the fix (the state machine enable/disable irq stuff is
also needed)
Currently uses kmalloc - which seems to work best, but trivial to
allocate at init time if wanted
Signed-off-by: Alan Cox <alan@redhat.com>
diff -u --new-file --recursive --exclude-from /usr/src/exclude linux.vanilla-2.6.25-mm1/drivers/ata/libata-sff.c linux-2.6.25-mm1/drivers/ata/libata-sff.c
--- linux.vanilla-2.6.25-mm1/drivers/ata/libata-sff.c 2008-04-28 11:36:48.000000000 +0100
+++ linux-2.6.25-mm1/drivers/ata/libata-sff.c 2008-04-28 11:42:05.000000000 +0100
@@ -665,6 +665,62 @@
}
/**
+ * ata_bounce_pio_xfer - Transfer a block by PIO from high
+ * @dev: target device
+ * @page: highmem page
+ * @offset: offset in page
+ * @count: bytes to transfer
+ * @do_write: writing if set, reading if not
+ *
+ * Transfer a page of high memory via PIO. Whenever possible use a bounce
+ * buffer to avoid transfers occuring with local IRQ disable
+ */
+
+static unsigned int ata_bounce_pio_xfer(struct ata_device *dev, struct page *page,
+ unsigned int offset, int count, int rw)
+{
+ struct ata_port *ap = dev->link->ap;
+ unsigned long flags;
+ unsigned char *zebedee;
+ unsigned char *buf;
+ unsigned int consumed;
+
+ BUG_ON(offset + count > PAGE_SIZE);
+
+ zebedee = kmalloc(count, GFP_ATOMIC);
+ if (likely(zebedee)) {
+ if (rw == WRITE) {
+ local_irq_save(flags);
+ buf = kmap_atomic(page, KM_IRQ0);
+ memcpy(zebedee, buf + offset, count);
+ kunmap_atomic(buf, KM_IRQ0);
+ local_irq_restore(flags);
+ }
+ /* do the actual data transfer */
+ consumed = ap->ops->sff_data_xfer(dev, zebedee, count, rw);
+ if (rw == READ) {
+ /* Read so bounce data upwards */
+ local_irq_save(flags);
+ buf = kmap_atomic(page, KM_IRQ0);
+ memcpy(buf + offset, zebedee, count);
+ kunmap_atomic(buf, KM_IRQ0);
+ local_irq_restore(flags);
+ }
+ kfree(zebedee);
+ } else {
+ /* Only used when we are out of buffer memory
+ as a last last resort */
+ local_irq_save(flags);
+ buf = kmap_atomic(page, KM_IRQ0);
+ /* do the actual data transfer */
+ consumed = ap->ops->sff_data_xfer(dev, buf + offset, count, rw);
+ kunmap_atomic(buf, KM_IRQ0);
+ local_irq_restore(flags);
+ }
+ return consumed;
+}
+
+/**
* ata_pio_sector - Transfer a sector of data.
* @qc: Command on going
*
@@ -675,7 +731,7 @@
*/
static void ata_pio_sector(struct ata_queued_cmd *qc)
{
- int do_write = (qc->tf.flags & ATA_TFLAG_WRITE);
+ int do_write = (qc->tf.flags & ATA_TFLAG_WRITE) ? WRITE : READ;
struct ata_port *ap = qc->ap;
struct page *page;
unsigned int offset;
@@ -693,19 +749,9 @@
DPRINTK("data %s\n", qc->tf.flags & ATA_TFLAG_WRITE ? "write" : "read");
- if (PageHighMem(page)) {
- unsigned long flags;
-
- /* FIXME: use a bounce buffer */
- local_irq_save(flags);
- buf = kmap_atomic(page, KM_IRQ0);
-
- /* do the actual data transfer */
- ap->ops->sff_data_xfer(qc->dev, buf + offset, qc->sect_size,
- do_write);
-
- kunmap_atomic(buf, KM_IRQ0);
- local_irq_restore(flags);
+ if (PageHighMem(page) || 1 /* TEST FIXME */) {
+ ata_bounce_pio_xfer(qc->dev, page, offset, qc->sect_size,
+ do_write);
} else {
buf = page_address(page);
ap->ops->sff_data_xfer(qc->dev, buf + offset, qc->sect_size,
@@ -830,19 +876,9 @@
DPRINTK("data %s\n", qc->tf.flags & ATA_TFLAG_WRITE ? "write" : "read");
- if (PageHighMem(page)) {
- unsigned long flags;
-
- /* FIXME: use bounce buffer */
- local_irq_save(flags);
- buf = kmap_atomic(page, KM_IRQ0);
-
- /* do the actual data transfer */
- consumed = ap->ops->sff_data_xfer(dev, buf + offset, count, rw);
-
- kunmap_atomic(buf, KM_IRQ0);
- local_irq_restore(flags);
- } else {
+ if (PageHighMem(page))
+ consumed = ata_bounce_pio_xfer(qc->dev, page, offset, count, rw);
+ else {
buf = page_address(page);
consumed = ap->ops->sff_data_xfer(dev, buf + offset, count, rw);
}
next reply other threads:[~2008-04-29 13:55 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-29 13:47 Alan Cox [this message]
2008-04-29 15:51 ` [PATCH] libata: PIO bounce copies to avoid long IRQ off runs Grant Grundler
2008-04-29 16:21 ` Alan Cox
2008-04-29 22:01 ` [PATCH] " Jeff Garzik
2008-04-29 22:01 ` Alan Cox
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=20080429144754.7d2952c8@core \
--to=alan@lxorguk.ukuu.org.uk \
--cc=jeff@garzik.org \
--cc=linux-ide@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.