[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>

authored by Salyzyn, Mark and committed by James Bottomley 8e31e607 9927c688

+30 -51
+30 -51
drivers/scsi/aacraid/aachba.c
··· 859 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, 863 - u8 a_sense_code, u8 incorrect_length, 864 - u8 bit_pointer, u16 field_pointer, 865 - u32 residue) 862 + static inline void set_sense(struct sense_data *sense_data, u8 sense_key, 863 + u8 sense_code, u8 a_sense_code, u8 bit_pointer, u16 field_pointer) 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 868 sense_buf[1] = 0; /* Segment number, always zero */ 869 869 870 - if (incorrect_length) { 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 */ 870 + sense_buf[2] = sense_key; /* Sense key */ 883 871 884 872 sense_buf[12] = sense_code; /* Additional sense code */ 885 873 sense_buf[13] = a_sense_code; /* Additional sense code qualifier */ 874 + 886 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) 890 - sense_buf[15] = 0x80;/* Std sense key specific field */ 878 + sense_buf[15] = bit_pointer; 891 879 /* Illegal parameter is in the parameter block */ 892 - 893 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 882 /* Illegal parameter is in the CDB block */ 896 - sense_buf[15] |= bit_pointer; 897 883 sense_buf[16] = field_pointer >> 8; /* MSB */ 898 884 sense_buf[17] = field_pointer; /* LSB */ 899 - } 885 + } else 886 + sense_buf[7] = 6; /* Additional sense length */ 900 887 } 901 888 902 889 static int aac_bounds_32(struct aac_dev * dev, struct scsi_cmnd * cmd, u64 lba) ··· 893 906 dprintk((KERN_DEBUG "aacraid: Illegal lba\n")); 894 907 cmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | 895 908 SAM_STAT_CHECK_CONDITION; 896 - set_sense((u8 *) &dev->fsa_dev[cid].sense_data, 897 - HARDWARE_ERROR, 898 - SENCODE_INTERNAL_TARGET_FAILURE, 899 - ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0, 900 - 0, 0); 909 + set_sense(&dev->fsa_dev[cid].sense_data, 910 + HARDWARE_ERROR, SENCODE_INTERNAL_TARGET_FAILURE, 911 + ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0); 901 912 memcpy(cmd->sense_buffer, &dev->fsa_dev[cid].sense_data, 902 913 min_t(size_t, sizeof(dev->fsa_dev[cid].sense_data), 903 914 SCSI_SENSE_BUFFERSIZE)); ··· 1505 1520 le32_to_cpu(readreply->status)); 1506 1521 #endif 1507 1522 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION; 1508 - set_sense((u8 *) &dev->fsa_dev[cid].sense_data, 1509 - HARDWARE_ERROR, 1510 - SENCODE_INTERNAL_TARGET_FAILURE, 1511 - ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0, 1512 - 0, 0); 1523 + set_sense(&dev->fsa_dev[cid].sense_data, 1524 + HARDWARE_ERROR, SENCODE_INTERNAL_TARGET_FAILURE, 1525 + ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0); 1513 1526 memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data, 1514 1527 min_t(size_t, sizeof(dev->fsa_dev[cid].sense_data), 1515 1528 SCSI_SENSE_BUFFERSIZE)); ··· 1716 1733 le32_to_cpu(synchronizereply->status)); 1717 1734 cmd->result = DID_OK << 16 | 1718 1735 COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION; 1719 - set_sense((u8 *)&dev->fsa_dev[cid].sense_data, 1720 - HARDWARE_ERROR, 1721 - SENCODE_INTERNAL_TARGET_FAILURE, 1722 - ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0, 1723 - 0, 0); 1736 + set_sense(&dev->fsa_dev[cid].sense_data, 1737 + HARDWARE_ERROR, SENCODE_INTERNAL_TARGET_FAILURE, 1738 + ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0); 1724 1739 memcpy(cmd->sense_buffer, &dev->fsa_dev[cid].sense_data, 1725 1740 min_t(size_t, sizeof(dev->fsa_dev[cid].sense_data), 1726 1741 SCSI_SENSE_BUFFERSIZE)); ··· 1926 1945 { 1927 1946 dprintk((KERN_WARNING "Only INQUIRY & TUR command supported for controller, rcvd = 0x%x.\n", scsicmd->cmnd[0])); 1928 1947 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION; 1929 - set_sense((u8 *) &dev->fsa_dev[cid].sense_data, 1930 - ILLEGAL_REQUEST, 1931 - SENCODE_INVALID_COMMAND, 1932 - ASENCODE_INVALID_COMMAND, 0, 0, 0, 0); 1948 + set_sense(&dev->fsa_dev[cid].sense_data, 1949 + ILLEGAL_REQUEST, SENCODE_INVALID_COMMAND, 1950 + ASENCODE_INVALID_COMMAND, 0, 0); 1933 1951 memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data, 1934 1952 min_t(size_t, sizeof(dev->fsa_dev[cid].sense_data), 1935 1953 SCSI_SENSE_BUFFERSIZE)); ··· 1975 1995 scsicmd->result = DID_OK << 16 | 1976 1996 COMMAND_COMPLETE << 8 | 1977 1997 SAM_STAT_CHECK_CONDITION; 1978 - set_sense((u8 *) &dev->fsa_dev[cid].sense_data, 1979 - ILLEGAL_REQUEST, 1980 - SENCODE_INVALID_CDB_FIELD, 1981 - ASENCODE_NO_SENSE, 0, 7, 2, 0); 1998 + set_sense(&dev->fsa_dev[cid].sense_data, 1999 + ILLEGAL_REQUEST, SENCODE_INVALID_CDB_FIELD, 2000 + ASENCODE_NO_SENSE, 7, 2); 1982 2001 memcpy(scsicmd->sense_buffer, 1983 2002 &dev->fsa_dev[cid].sense_data, 1984 2003 min_t(size_t, ··· 2233 2254 */ 2234 2255 dprintk((KERN_WARNING "Unhandled SCSI Command: 0x%x.\n", scsicmd->cmnd[0])); 2235 2256 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION; 2236 - set_sense((u8 *) &dev->fsa_dev[cid].sense_data, 2237 - ILLEGAL_REQUEST, SENCODE_INVALID_COMMAND, 2238 - ASENCODE_INVALID_COMMAND, 0, 0, 0, 0); 2257 + set_sense(&dev->fsa_dev[cid].sense_data, 2258 + ILLEGAL_REQUEST, SENCODE_INVALID_COMMAND, 2259 + ASENCODE_INVALID_COMMAND, 0, 0); 2239 2260 memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data, 2240 2261 min_t(size_t, 2241 2262 sizeof(dev->fsa_dev[cid].sense_data),