diff options
author | Salyzyn, Mark <Mark_Salyzyn@adaptec.com> | 2008-02-06 16:54:12 -0500 |
---|---|---|
committer | James Bottomley <James.Bottomley@HansenPartnership.com> | 2008-02-07 19:31:51 -0500 |
commit | 8e31e607ea050c0df1483d8b6cdd5b1395c03cbe (patch) | |
tree | 0249b18a545d6f8a5d65ccca70a16a722de372a7 | |
parent | 9927c68864e9c39cc317b4f559309ba29e642168 (diff) |
[SCSI] aacraid: do not set valid bit in sense information
Luben Tuikov [mailto:ltuikov@yahoo.com] sez:
> Just as in your case and Tony's case, which I presume
> uses the same RAID firmware vendor, it would've
> probably been better if the RAID firmware vendor
> fixed the firmware to not set the VALID bit if the
> INFORMATION field is not valid.
Point taken regarding the aacraid driver. Dropped the VALID bit, and
then did some cleanup/simplification of the set_sense procedure and
the associated parameters. Mike did some preliminary tests when the
VALID bit was dropped before the 'Re: [PATCH] [SCSI] sd: make error
handling more robust' patches came on the scene. The change in the
SCSI subsystem does make this enclosed aacraid patch unnecessary, so
this aacraid patch is merely post battle ground cleanup. If the
simplification is an issue, repugnant, too much for a back-port to the
stable trees or clouds the point, this patch could be happily
distilled down to:
diff -ru a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c
--- a/drivers/scsi/aacraid/aachba.c 2008-02-06 16:26:45.834938955 -0500
+++ b/drivers/scsi/aacraid/aachba.c 2008-02-06 16:32:01.109035329 -0500
@@ -865,7 +865,7 @@
u32 residue)
{
- sense_buf[0] = 0xF0; /* Sense data valid, err code 70h (current error) */
+ sense_buf[0] = 0x70; /* Sense data invalid, err code 70h (current error) */
sense_buf[1] = 0; /* Segment number, always zero */
if (incorrect_length) {
Signed-off-by: Mark Salyzyn <aacraid@adaptec.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
-rw-r--r-- | drivers/scsi/aacraid/aachba.c | 81 |
1 files changed, 30 insertions, 51 deletions
diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c index d7235f42cf5f..bfd0e64964ac 100644 --- a/drivers/scsi/aacraid/aachba.c +++ b/drivers/scsi/aacraid/aachba.c | |||
@@ -859,44 +859,31 @@ static int setinqserial(struct aac_dev *dev, void *data, int cid) | |||
859 | le32_to_cpu(dev->adapter_info.serial[0]), cid); | 859 | le32_to_cpu(dev->adapter_info.serial[0]), cid); |
860 | } | 860 | } |
861 | 861 | ||
862 | static void set_sense(u8 *sense_buf, u8 sense_key, u8 sense_code, | 862 | static inline void set_sense(struct sense_data *sense_data, u8 sense_key, |
863 | u8 a_sense_code, u8 incorrect_length, | 863 | u8 sense_code, u8 a_sense_code, u8 bit_pointer, u16 field_pointer) |
864 | u8 bit_pointer, u16 field_pointer, | ||
865 | u32 residue) | ||
866 | { | 864 | { |
867 | sense_buf[0] = 0xF0; /* Sense data valid, err code 70h (current error) */ | 865 | u8 *sense_buf = (u8 *)sense_data; |
866 | /* Sense data valid, err code 70h */ | ||
867 | sense_buf[0] = 0x70; /* No info field */ | ||
868 | sense_buf[1] = 0; /* Segment number, always zero */ | 868 | sense_buf[1] = 0; /* Segment number, always zero */ |
869 | 869 | ||
870 | if (incorrect_length) { | 870 | sense_buf[2] = sense_key; /* Sense key */ |
871 | sense_buf[2] = sense_key | 0x20;/* Set ILI bit | sense key */ | ||
872 | sense_buf[3] = BYTE3(residue); | ||
873 | sense_buf[4] = BYTE2(residue); | ||
874 | sense_buf[5] = BYTE1(residue); | ||
875 | sense_buf[6] = BYTE0(residue); | ||
876 | } else | ||
877 | sense_buf[2] = sense_key; /* Sense key */ | ||
878 | |||
879 | if (sense_key == ILLEGAL_REQUEST) | ||
880 | sense_buf[7] = 10; /* Additional sense length */ | ||
881 | else | ||
882 | sense_buf[7] = 6; /* Additional sense length */ | ||
883 | 871 | ||
884 | sense_buf[12] = sense_code; /* Additional sense code */ | 872 | sense_buf[12] = sense_code; /* Additional sense code */ |
885 | sense_buf[13] = a_sense_code; /* Additional sense code qualifier */ | 873 | sense_buf[13] = a_sense_code; /* Additional sense code qualifier */ |
874 | |||
886 | if (sense_key == ILLEGAL_REQUEST) { | 875 | if (sense_key == ILLEGAL_REQUEST) { |
887 | sense_buf[15] = 0; | 876 | sense_buf[7] = 10; /* Additional sense length */ |
888 | 877 | ||
889 | if (sense_code == SENCODE_INVALID_PARAM_FIELD) | 878 | sense_buf[15] = bit_pointer; |
890 | sense_buf[15] = 0x80;/* Std sense key specific field */ | ||
891 | /* Illegal parameter is in the parameter block */ | 879 | /* Illegal parameter is in the parameter block */ |
892 | |||
893 | if (sense_code == SENCODE_INVALID_CDB_FIELD) | 880 | if (sense_code == SENCODE_INVALID_CDB_FIELD) |
894 | sense_buf[15] = 0xc0;/* Std sense key specific field */ | 881 | sense_buf[15] |= 0xc0;/* Std sense key specific field */ |
895 | /* Illegal parameter is in the CDB block */ | 882 | /* Illegal parameter is in the CDB block */ |
896 | sense_buf[15] |= bit_pointer; | ||
897 | sense_buf[16] = field_pointer >> 8; /* MSB */ | 883 | sense_buf[16] = field_pointer >> 8; /* MSB */ |
898 | sense_buf[17] = field_pointer; /* LSB */ | 884 | sense_buf[17] = field_pointer; /* LSB */ |
899 | } | 885 | } else |
886 | sense_buf[7] = 6; /* Additional sense length */ | ||
900 | } | 887 | } |
901 | 888 | ||
902 | static int aac_bounds_32(struct aac_dev * dev, struct scsi_cmnd * cmd, u64 lba) | 889 | static int aac_bounds_32(struct aac_dev * dev, struct scsi_cmnd * cmd, u64 lba) |
@@ -906,11 +893,9 @@ static int aac_bounds_32(struct aac_dev * dev, struct scsi_cmnd * cmd, u64 lba) | |||
906 | dprintk((KERN_DEBUG "aacraid: Illegal lba\n")); | 893 | dprintk((KERN_DEBUG "aacraid: Illegal lba\n")); |
907 | cmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | | 894 | cmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | |
908 | SAM_STAT_CHECK_CONDITION; | 895 | SAM_STAT_CHECK_CONDITION; |
909 | set_sense((u8 *) &dev->fsa_dev[cid].sense_data, | 896 | set_sense(&dev->fsa_dev[cid].sense_data, |
910 | HARDWARE_ERROR, | 897 | HARDWARE_ERROR, SENCODE_INTERNAL_TARGET_FAILURE, |
911 | SENCODE_INTERNAL_TARGET_FAILURE, | 898 | ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0); |
912 | ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0, | ||
913 | 0, 0); | ||
914 | memcpy(cmd->sense_buffer, &dev->fsa_dev[cid].sense_data, | 899 | memcpy(cmd->sense_buffer, &dev->fsa_dev[cid].sense_data, |
915 | min_t(size_t, sizeof(dev->fsa_dev[cid].sense_data), | 900 | min_t(size_t, sizeof(dev->fsa_dev[cid].sense_data), |
916 | SCSI_SENSE_BUFFERSIZE)); | 901 | SCSI_SENSE_BUFFERSIZE)); |
@@ -1520,11 +1505,9 @@ static void io_callback(void *context, struct fib * fibptr) | |||
1520 | le32_to_cpu(readreply->status)); | 1505 | le32_to_cpu(readreply->status)); |
1521 | #endif | 1506 | #endif |
1522 | scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION; | 1507 | scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION; |
1523 | set_sense((u8 *) &dev->fsa_dev[cid].sense_data, | 1508 | set_sense(&dev->fsa_dev[cid].sense_data, |
1524 | HARDWARE_ERROR, | 1509 | HARDWARE_ERROR, SENCODE_INTERNAL_TARGET_FAILURE, |
1525 | SENCODE_INTERNAL_TARGET_FAILURE, | 1510 | ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0); |
1526 | ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0, | ||
1527 | 0, 0); | ||
1528 | memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data, | 1511 | memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data, |
1529 | min_t(size_t, sizeof(dev->fsa_dev[cid].sense_data), | 1512 | min_t(size_t, sizeof(dev->fsa_dev[cid].sense_data), |
1530 | SCSI_SENSE_BUFFERSIZE)); | 1513 | SCSI_SENSE_BUFFERSIZE)); |
@@ -1733,11 +1716,9 @@ static void synchronize_callback(void *context, struct fib *fibptr) | |||
1733 | le32_to_cpu(synchronizereply->status)); | 1716 | le32_to_cpu(synchronizereply->status)); |
1734 | cmd->result = DID_OK << 16 | | 1717 | cmd->result = DID_OK << 16 | |
1735 | COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION; | 1718 | COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION; |
1736 | set_sense((u8 *)&dev->fsa_dev[cid].sense_data, | 1719 | set_sense(&dev->fsa_dev[cid].sense_data, |
1737 | HARDWARE_ERROR, | 1720 | HARDWARE_ERROR, SENCODE_INTERNAL_TARGET_FAILURE, |
1738 | SENCODE_INTERNAL_TARGET_FAILURE, | 1721 | ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0); |
1739 | ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0, | ||
1740 | 0, 0); | ||
1741 | memcpy(cmd->sense_buffer, &dev->fsa_dev[cid].sense_data, | 1722 | memcpy(cmd->sense_buffer, &dev->fsa_dev[cid].sense_data, |
1742 | min_t(size_t, sizeof(dev->fsa_dev[cid].sense_data), | 1723 | min_t(size_t, sizeof(dev->fsa_dev[cid].sense_data), |
1743 | SCSI_SENSE_BUFFERSIZE)); | 1724 | SCSI_SENSE_BUFFERSIZE)); |
@@ -1945,10 +1926,9 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd) | |||
1945 | { | 1926 | { |
1946 | dprintk((KERN_WARNING "Only INQUIRY & TUR command supported for controller, rcvd = 0x%x.\n", scsicmd->cmnd[0])); | 1927 | dprintk((KERN_WARNING "Only INQUIRY & TUR command supported for controller, rcvd = 0x%x.\n", scsicmd->cmnd[0])); |
1947 | scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION; | 1928 | scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION; |
1948 | set_sense((u8 *) &dev->fsa_dev[cid].sense_data, | 1929 | set_sense(&dev->fsa_dev[cid].sense_data, |
1949 | ILLEGAL_REQUEST, | 1930 | ILLEGAL_REQUEST, SENCODE_INVALID_COMMAND, |
1950 | SENCODE_INVALID_COMMAND, | 1931 | ASENCODE_INVALID_COMMAND, 0, 0); |
1951 | ASENCODE_INVALID_COMMAND, 0, 0, 0, 0); | ||
1952 | memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data, | 1932 | memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data, |
1953 | min_t(size_t, sizeof(dev->fsa_dev[cid].sense_data), | 1933 | min_t(size_t, sizeof(dev->fsa_dev[cid].sense_data), |
1954 | SCSI_SENSE_BUFFERSIZE)); | 1934 | SCSI_SENSE_BUFFERSIZE)); |
@@ -1995,10 +1975,9 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd) | |||
1995 | scsicmd->result = DID_OK << 16 | | 1975 | scsicmd->result = DID_OK << 16 | |
1996 | COMMAND_COMPLETE << 8 | | 1976 | COMMAND_COMPLETE << 8 | |
1997 | SAM_STAT_CHECK_CONDITION; | 1977 | SAM_STAT_CHECK_CONDITION; |
1998 | set_sense((u8 *) &dev->fsa_dev[cid].sense_data, | 1978 | set_sense(&dev->fsa_dev[cid].sense_data, |
1999 | ILLEGAL_REQUEST, | 1979 | ILLEGAL_REQUEST, SENCODE_INVALID_CDB_FIELD, |
2000 | SENCODE_INVALID_CDB_FIELD, | 1980 | ASENCODE_NO_SENSE, 7, 2); |
2001 | ASENCODE_NO_SENSE, 0, 7, 2, 0); | ||
2002 | memcpy(scsicmd->sense_buffer, | 1981 | memcpy(scsicmd->sense_buffer, |
2003 | &dev->fsa_dev[cid].sense_data, | 1982 | &dev->fsa_dev[cid].sense_data, |
2004 | min_t(size_t, | 1983 | min_t(size_t, |
@@ -2254,9 +2233,9 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd) | |||
2254 | */ | 2233 | */ |
2255 | dprintk((KERN_WARNING "Unhandled SCSI Command: 0x%x.\n", scsicmd->cmnd[0])); | 2234 | dprintk((KERN_WARNING "Unhandled SCSI Command: 0x%x.\n", scsicmd->cmnd[0])); |
2256 | scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION; | 2235 | scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION; |
2257 | set_sense((u8 *) &dev->fsa_dev[cid].sense_data, | 2236 | set_sense(&dev->fsa_dev[cid].sense_data, |
2258 | ILLEGAL_REQUEST, SENCODE_INVALID_COMMAND, | 2237 | ILLEGAL_REQUEST, SENCODE_INVALID_COMMAND, |
2259 | ASENCODE_INVALID_COMMAND, 0, 0, 0, 0); | 2238 | ASENCODE_INVALID_COMMAND, 0, 0); |
2260 | memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data, | 2239 | memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data, |
2261 | min_t(size_t, | 2240 | min_t(size_t, |
2262 | sizeof(dev->fsa_dev[cid].sense_data), | 2241 | sizeof(dev->fsa_dev[cid].sense_data), |