LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Willy Tarreau <w@1wt.eu>
To: jeff@garzik.org
Cc: linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 2/2] libata: implement support for 32-bit PIO transfers
Date: Sun, 17 Feb 2008 22:20:04 +0100 [thread overview]
Message-ID: <20080217212004.GB15327@1wt.eu> (raw)
In-Reply-To: <20080217211810.GA15001@1wt.eu>
>From 4ea313fe6a3c46a90226cf40d0e3ece4b36b48f9 Mon Sep 17 00:00:00 2001
From: Willy Tarreau <w@1wt.eu>
Date: Sun, 17 Feb 2008 21:28:25 +0100
Subject: [PATCH 2/2] libata: implement support for 32-bit PIO transfers
When ATA_DFLAG_32BIT_PIO is set in ata flags, PIO transfers
will be performed in 32-bit, just like with the plain old IDE
drivers.
16-bit transfers in libata are as slow as 16-bit transfers in
plain old IDE drivers, which are about 35% slower than 32-bit
transfers with various CF and DOM. This patch restores the
performance to pre-libata level, which is a nice improvement
for many small systems relying on such hardware.
This patch relies on previous patch which implements the
ATA_DFLAG_32BIT_PIO ioctl.
To enable 32-bit transfers, simply proceed like before with
IDE :
# hdparm -c 1 /dev/sda
Signed-off-by: Willy Tarreau <w@1wt.eu>
---
drivers/ata/libata-core.c | 46 +++++++++++++++++++++++++++++++-------------
1 files changed, 32 insertions(+), 14 deletions(-)
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index beaa3a9..2651130 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -4936,7 +4936,7 @@ void swap_buf_le16(u16 *buf, unsigned int buf_words)
}
/**
- * ata_data_xfer - Transfer data by PIO
+ * ata_data_xfer - Transfer data by PIO (16 or 32-bit)
* @dev: device to target
* @buf: data buffer
* @buflen: buffer length
@@ -4955,30 +4955,48 @@ unsigned int ata_data_xfer(struct ata_device *dev, unsigned char *buf,
{
struct ata_port *ap = dev->link->ap;
void __iomem *data_addr = ap->ioaddr.data_addr;
- unsigned int words = buflen >> 1;
+ unsigned int words;
- /* Transfer multiple of 2 bytes */
- if (rw == READ)
- ioread16_rep(data_addr, buf, words);
- else
- iowrite16_rep(data_addr, buf, words);
+ if (dev->flags & ATA_DFLAG_32BIT_PIO) {
+ /* Transfer in 32-bit words */
+ words = buflen >> 2;
+ if (rw == READ)
+ ioread32_rep(data_addr, buf, words);
+ else
+ iowrite32_rep(data_addr, buf, words);
+ words <<= 2;
+ } else {
+ /* Transfer in 16-bit words */
+ words = buflen >> 1;
+ if (rw == READ)
+ ioread16_rep(data_addr, buf, words);
+ else
+ iowrite16_rep(data_addr, buf, words);
+ words <<= 1;
+ }
- /* Transfer trailing 1 byte, if any. */
- if (unlikely(buflen & 0x01)) {
+ /* Transfer trailing 1, 2 or 3 bytes, if any. We know how many bytes
+ * remain because <words> now contains the number of bytes transferred.
+ */
+ while (buflen > words) {
__le16 align_buf[1] = { 0 };
- unsigned char *trailing_buf = buf + buflen - 1;
+ unsigned char *trailing_buf = buf + words;
+ int len = buflen - words;
+
+ if (len > 2)
+ len = 2;
if (rw == READ) {
align_buf[0] = cpu_to_le16(ioread16(data_addr));
- memcpy(trailing_buf, align_buf, 1);
+ memcpy(trailing_buf, align_buf, len);
} else {
- memcpy(align_buf, trailing_buf, 1);
+ memcpy(align_buf, trailing_buf, len);
iowrite16(le16_to_cpu(align_buf[0]), data_addr);
}
- words++;
+ words += len;
}
- return words << 1;
+ return words;
}
/**
--
1.5.3.8
next prev parent reply other threads:[~2008-02-17 21:20 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-17 21:18 [PATCH 0/2] libata: implement 32-bit transfers for PIO mode Willy Tarreau
2008-02-17 21:19 ` [PATCH 1/2] libata: implement ATA_IOC_GET_IO32/ATA_IOC_SET_IO32 ioctls Willy Tarreau
2008-04-17 19:49 ` Jeff Garzik
2008-04-17 19:46 ` Willy Tarreau
2008-04-17 22:02 ` [PATCH] libata: implement support for 32-bit PIO transfers Willy Tarreau
2008-02-17 21:20 ` Willy Tarreau [this message]
2008-02-17 22:32 ` [PATCH 2/2] " Alan Cox
2008-02-17 22:31 ` [PATCH 0/2] libata: implement 32-bit transfers for PIO mode Alan Cox
2008-02-17 23:08 ` Willy Tarreau
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=20080217212004.GB15327@1wt.eu \
--to=w@1wt.eu \
--cc=jeff@garzik.org \
--cc=linux-ide@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--subject='Re: [PATCH 2/2] libata: implement support for 32-bit PIO transfers' \
/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
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).