[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cdi-devel] [PATCH] ata: Fix bus master direction flag



! ata: Bit 3 in the Bus Master IDE Command Register is set if the DMA
  transfer is a bus master write, i.e. read from disk and write to
  memory. Current code got that wrong and sets it for writes to the
  disk.

Signed-off-by: Kevin Wolf <kevin@xxxxxxxxxx>
---
 ata/device.h  |    2 +-
 ata/request.c |    7 ++++---
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/ata/device.h b/ata/device.h
index 6c438e0..c939a34 100644
--- a/ata/device.h
+++ b/ata/device.h
@@ -116,7 +116,7 @@
 
 // Bits im Busmaster Command Register
 #define BMR_CMD_START           (1 << 0)
-#define BMR_CMD_WRITE           (1 << 3)
+#define BMR_CMD_READ            (1 << 3)
 
 // Bits im Busmaster Status Register
 #define BMR_STATUS_ERROR        (1 << 1)
diff --git a/ata/request.c b/ata/request.c
index 9d618c7..ff5d479 100644
--- a/ata/request.c
+++ b/ata/request.c
@@ -461,10 +461,11 @@ static int ata_protocol_dma(struct ata_request* request)
     // aus, dass es notwendig ist.
     cdi_inb(ctrl->port_bmr_base + BMR_COMMAND);
     cdi_inb(ctrl->port_bmr_base + BMR_STATUS);
+
     // Busmastering starten
-    if (request->flags.direction != READ) {
-        cdi_outb(ctrl->port_bmr_base + BMR_COMMAND, BMR_CMD_START |
-            BMR_CMD_WRITE);
+    if (request->flags.direction == READ) {
+        cdi_outb(ctrl->port_bmr_base + BMR_COMMAND,
+            BMR_CMD_START | BMR_CMD_READ);
     } else {
         cdi_outb(ctrl->port_bmr_base + BMR_COMMAND, BMR_CMD_START);
     }
-- 
1.6.0.2