Re: Worrisome IDE PIO transfers...

From: Jeff Garzik
Date: Sat Feb 28 2004 - 21:43:45 EST


Matt Mackall wrote:
On Sun, Feb 29, 2004 at 01:21:30AM +0100, Bartlomiej Zolnierkiewicz wrote:

I like Alan's idea to use loopback instead of "bswap".


Or, more likely, device mapper.


Somehow I doubt anybody cares enough to write a whole driver just for this unlikely case.

For now let's at least record the knowledge... (patch attached)

Jeff


===== drivers/ide/ide-taskfile.c 1.28 vs edited =====
--- 1.28/drivers/ide/ide-taskfile.c Thu Feb 26 12:11:20 2004
+++ edited/drivers/ide/ide-taskfile.c Sat Feb 28 21:18:27 2004
@@ -29,6 +29,7 @@

#include <linux/config.h>
#include <linux/module.h>
+#include <linux/compiler.h>
#include <linux/types.h>
#include <linux/string.h>
#include <linux/kernel.h>
@@ -81,7 +82,12 @@

void taskfile_output_data (ide_drive_t *drive, void *buffer, u32 wcount)
{
- if (drive->bswap) {
+ if (unlikely(drive->bswap)) {
+ /* FIXME: Besides the inefficiency each sector
+ * twice, this can lead to data corruption on
+ * SMP. Fortunately drives that need this swapping
+ * are quite uncommon.
+ */
ata_bswap_data(buffer, wcount);
HWIF(drive)->ata_output_data(drive, buffer, wcount);
ata_bswap_data(buffer, wcount);