From a82633552c4db42688161135aa0fe4076daaa142 Mon Sep 17 00:00:00 2001
From: chrfranke <chrfranke@4ea69e1a-61f1-4043-bf83-b5c94c648137>
Date: Fri, 4 Dec 2009 17:29:50 +0000
Subject: [PATCH] Linux: Add workaround for Adaptec series 2, 5 and 5Z
 controllers with firmware >= 17380.  Patch was provided by Phil Wilson.

git-svn-id: https://smartmontools.svn.sourceforge.net/svnroot/smartmontools/trunk@2993 4ea69e1a-61f1-4043-bf83-b5c94c648137
---
 smartmontools/CHANGELOG    | 4 ++++
 smartmontools/os_linux.cpp | 6 +++++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/smartmontools/CHANGELOG b/smartmontools/CHANGELOG
index 44c12131f..46c43f5ac 100644
--- a/smartmontools/CHANGELOG
+++ b/smartmontools/CHANGELOG
@@ -43,6 +43,10 @@ NOTES FOR FUTURE RELEASES: see TODO file.
 
 <DEVELOPERS: ADDITIONS TO THE CHANGE LOG GO JUST BELOW HERE, PLEASE>
 
+  [CF] Linux: Add workaround for Adaptec series 2, 5 and 5Z controllers
+       with firmware >= 17380.  Patch was provided by Phil Wilson, see:
+       http://linux.adaptec.com/2009/07/24/using-smartmontools-538-with-series-255z-controllers-with-firmware-17380-onwards
+
   [CF] configure.in: Add '-fno-strict-aliasing' to CXXFLAGS if supported.
        This suppresses gcc 4.4.1 warnings on Linux and avoids possible
        unsafe optimizations (ticket #23).
diff --git a/smartmontools/os_linux.cpp b/smartmontools/os_linux.cpp
index 5993f113d..2ec4b616d 100644
--- a/smartmontools/os_linux.cpp
+++ b/smartmontools/os_linux.cpp
@@ -493,6 +493,7 @@ int linux_ata_device::ata_command_interface(smart_command_set command, int selec
 #define SG_IO_RESP_SENSE_LEN 64 /* large enough see buffer */
 #define LSCSI_DRIVER_MASK  0xf /* mask out "suggestions" */
 #define LSCSI_DRIVER_SENSE  0x8 /* alternate CHECK CONDITION indication */
+#define LSCSI_DID_ERROR 0x7 /* Need to work around aacraid driver quirk */
 #define LSCSI_DRIVER_TIMEOUT  0x6
 #define LSCSI_DID_TIME_OUT  0x3
 #define LSCSI_DID_BUS_BUSY  0x2
@@ -617,7 +618,10 @@ static int sg_io_cmnd_io(int dev_fd, struct scsi_cmnd_io * iop, int report,
                 (LSCSI_DID_TIME_OUT == io_hdr.host_status))
                 return -ETIMEDOUT;
             else
-                return -EIO;    /* catch all */
+               /* Check for DID_ERROR - workaround for aacraid driver quirk */
+               if (LSCSI_DID_ERROR != io_hdr.host_status) {
+                       return -EIO; /* catch all if not DID_ERR */
+               }
         }
         if (0 != masked_driver_status) {
             if (LSCSI_DRIVER_TIMEOUT == masked_driver_status)
-- 
GitLab