* [PATCH 1/2] libata-sff: fix 32-bit PIO ATAPI regression
@ 2009-02-15 19:24 Sergei Shtylyov
2009-02-16 23:56 ` Jeff Garzik
0 siblings, 1 reply; 3+ messages in thread
From: Sergei Shtylyov @ 2009-02-15 19:24 UTC (permalink / raw)
To: jgarzik; +Cc: linux-ide, linux-kernel, alan, rjw, akpm
Commit 871af1210f13966ab911ed2166e4ab2ce775b99d (libata: Add 32bit PIO support)
has caused all kinds of errors on the ATAPI devices, so it has been empirically
proven that one shouldn't try to read/write an extra data word when a device is
not expecting it already. "Don't do it then"; however, still use a chance to do
32-bit read/write one last time when there are exactly 3 trailing bytes.
Oh, and stop pointlessly swapping the bytes to and fro on big-endian machines
by using io*_rep() accessors which shouldn't byte-swap.
This patch should fix the kernel.org bug #12609.
Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
---
Added the comments and signoff.
The patch is against the recent Linus' tree.
It's a hopefully better replacement for Hugh Dickins most recent patch
(http://marc.info/?l=linux-ide&m=123352294619281)...
drivers/ata/libata-sff.c | 28 +++++++++++++++++++++-------
1 files changed, 21 insertions(+), 7 deletions(-)
Index: linux-2.6/drivers/ata/libata-sff.c
===================================================================
--- linux-2.6.orig/drivers/ata/libata-sff.c
+++ linux-2.6/drivers/ata/libata-sff.c
@@ -773,18 +773,32 @@ unsigned int ata_sff_data_xfer32(struct
else
iowrite32_rep(data_addr, buf, words);
+ /* Transfer trailing bytes, if any */
if (unlikely(slop)) {
- __le32 pad;
+ unsigned char pad[4];
+
+ /* Point buf to the tail of buffer */
+ buf += buflen - slop;
+
+ /*
+ * Use io*_rep() accessors here as well to avoid pointlessly
+ * swapping bytes to and fro on the big endian machines...
+ */
if (rw == READ) {
- pad = cpu_to_le32(ioread32(ap->ioaddr.data_addr));
- memcpy(buf + buflen - slop, &pad, slop);
+ if (slop < 3)
+ ioread16_rep(data_addr, pad, 1);
+ else
+ ioread32_rep(data_addr, pad, 1);
+ memcpy(buf, pad, slop);
} else {
- memcpy(&pad, buf + buflen - slop, slop);
- iowrite32(le32_to_cpu(pad), ap->ioaddr.data_addr);
+ memcpy(pad, buf, slop);
+ if (slop < 3)
+ iowrite16_rep(data_addr, pad, 1);
+ else
+ iowrite32_rep(data_addr, pad, 1);
}
- words++;
}
- return words << 2;
+ return (buflen + 1) & ~1;
}
EXPORT_SYMBOL_GPL(ata_sff_data_xfer32);
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/2] libata-sff: fix 32-bit PIO ATAPI regression
2009-02-15 19:24 [PATCH 1/2] libata-sff: fix 32-bit PIO ATAPI regression Sergei Shtylyov
@ 2009-02-16 23:56 ` Jeff Garzik
2009-02-17 0:20 ` Sergei Shtylyov
0 siblings, 1 reply; 3+ messages in thread
From: Jeff Garzik @ 2009-02-16 23:56 UTC (permalink / raw)
To: Sergei Shtylyov; +Cc: linux-ide, linux-kernel, alan, rjw, akpm
Sergei Shtylyov wrote:
> Commit 871af1210f13966ab911ed2166e4ab2ce775b99d (libata: Add 32bit PIO support)
> has caused all kinds of errors on the ATAPI devices, so it has been empirically
> proven that one shouldn't try to read/write an extra data word when a device is
> not expecting it already. "Don't do it then"; however, still use a chance to do
> 32-bit read/write one last time when there are exactly 3 trailing bytes.
>
> Oh, and stop pointlessly swapping the bytes to and fro on big-endian machines
> by using io*_rep() accessors which shouldn't byte-swap.
>
> This patch should fix the kernel.org bug #12609.
>
> Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
>
> ---
> Added the comments and signoff.
> The patch is against the recent Linus' tree.
> It's a hopefully better replacement for Hugh Dickins most recent patch
> (http://marc.info/?l=linux-ide&m=123352294619281)...
applied, much appreciated!
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/2] libata-sff: fix 32-bit PIO ATAPI regression
2009-02-16 23:56 ` Jeff Garzik
@ 2009-02-17 0:20 ` Sergei Shtylyov
0 siblings, 0 replies; 3+ messages in thread
From: Sergei Shtylyov @ 2009-02-17 0:20 UTC (permalink / raw)
To: Jeff Garzik; +Cc: linux-ide, linux-kernel, alan, rjw, akpm
Hello.
Jeff Garzik wrote:
>> Commit 871af1210f13966ab911ed2166e4ab2ce775b99d (libata: Add 32bit
>> PIO support)
>> has caused all kinds of errors on the ATAPI devices, so it has been
>> empirically
It started to look as we still don't really know what caused all these
errors... :-/
MBR, Sergei
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-02-17 0:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-15 19:24 [PATCH 1/2] libata-sff: fix 32-bit PIO ATAPI regression Sergei Shtylyov
2009-02-16 23:56 ` Jeff Garzik
2009-02-17 0:20 ` Sergei Shtylyov
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.