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

[cdi-devel] [PATCH 2/2] ata: Retry on error



From: Antoine Kaufmann <toni@xxxxxxxxxx>

! ata: Retrying after read/write errors helps to make the code work a
  bit more reliably on real hardware

Signed-off-by: Antoine Kaufmann <toni@xxxxxxxxxx>
Signed-off-by: Kevin Wolf <kevin@xxxxxxxxxx>
---
 ata/ata.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/ata/ata.c b/ata/ata.c
index a2ab78f..262440a 100644
--- a/ata/ata.c
+++ b/ata/ata.c
@@ -121,6 +121,7 @@ static int ata_drv_rw_sectors(struct ata_device* dev, int direction,
     void* current_buffer = buffer;
     uint64_t lba = start;
     int max_count;
+    int again = 2;
     // Anzahl der Sektoren die noch uebrig sind
     size_t count_left = count;
 
@@ -192,6 +193,10 @@ static int ata_drv_rw_sectors(struct ata_device* dev, int direction,
         
         // Request ausfuehren
         if (!ata_request(&request)) {
+            if (again) {
+                again--;
+                continue;
+            }
             result = 0;
             break;
         }
@@ -200,6 +205,7 @@ static int ata_drv_rw_sectors(struct ata_device* dev, int direction,
         current_buffer += current_count * ATA_SECTOR_SIZE;
         count_left -= current_count;
         lba += current_count;
+        again = 2;
     }
 
     return result;
-- 
1.6.0.2