[SCSI] Revert "[SCSI] Retrieve the Caching mode page"
This reverts commit 24d720b726
.
Previously we thought there was little possibility that devices would
crash with this, but some have been found.
Reported-by: Alan Stern <stern@rowland.harvard.edu>
Cc: Luben Tuikov <ltuikov@yahoo.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
This commit is contained in:
parent
fee787129d
commit
3dea642afd
|
@ -2027,14 +2027,10 @@ sd_read_cache_type(struct scsi_disk *sdkp, unsigned char *buffer)
|
||||||
int old_rcd = sdkp->RCD;
|
int old_rcd = sdkp->RCD;
|
||||||
int old_dpofua = sdkp->DPOFUA;
|
int old_dpofua = sdkp->DPOFUA;
|
||||||
|
|
||||||
if (sdp->skip_ms_page_8) {
|
if (sdp->skip_ms_page_8)
|
||||||
if (sdp->type == TYPE_RBC)
|
|
||||||
goto defaults;
|
goto defaults;
|
||||||
else {
|
|
||||||
modepage = 0x3F;
|
if (sdp->type == TYPE_RBC) {
|
||||||
dbd = 0;
|
|
||||||
}
|
|
||||||
} else if (sdp->type == TYPE_RBC) {
|
|
||||||
modepage = 6;
|
modepage = 6;
|
||||||
dbd = 8;
|
dbd = 8;
|
||||||
} else {
|
} else {
|
||||||
|
@ -2062,11 +2058,13 @@ sd_read_cache_type(struct scsi_disk *sdkp, unsigned char *buffer)
|
||||||
*/
|
*/
|
||||||
if (len < 3)
|
if (len < 3)
|
||||||
goto bad_sense;
|
goto bad_sense;
|
||||||
else if (len > SD_BUF_SIZE) {
|
if (len > 20)
|
||||||
sd_printk(KERN_NOTICE, sdkp, "Truncating mode parameter "
|
len = 20;
|
||||||
"data from %d to %d bytes\n", len, SD_BUF_SIZE);
|
|
||||||
len = SD_BUF_SIZE;
|
/* Take headers and block descriptors into account */
|
||||||
}
|
len += data.header_length + data.block_descriptor_length;
|
||||||
|
if (len > SD_BUF_SIZE)
|
||||||
|
goto bad_sense;
|
||||||
|
|
||||||
/* Get the data */
|
/* Get the data */
|
||||||
res = sd_do_mode_sense(sdp, dbd, modepage, buffer, len, &data, &sshdr);
|
res = sd_do_mode_sense(sdp, dbd, modepage, buffer, len, &data, &sshdr);
|
||||||
|
@ -2074,45 +2072,16 @@ sd_read_cache_type(struct scsi_disk *sdkp, unsigned char *buffer)
|
||||||
if (scsi_status_is_good(res)) {
|
if (scsi_status_is_good(res)) {
|
||||||
int offset = data.header_length + data.block_descriptor_length;
|
int offset = data.header_length + data.block_descriptor_length;
|
||||||
|
|
||||||
while (offset < len) {
|
if (offset >= SD_BUF_SIZE - 2) {
|
||||||
u8 page_code = buffer[offset] & 0x3F;
|
sd_printk(KERN_ERR, sdkp, "Malformed MODE SENSE response\n");
|
||||||
u8 spf = buffer[offset] & 0x40;
|
|
||||||
|
|
||||||
if (page_code == 8 || page_code == 6) {
|
|
||||||
/* We're interested only in the first 3 bytes.
|
|
||||||
*/
|
|
||||||
if (len - offset <= 2) {
|
|
||||||
sd_printk(KERN_ERR, sdkp, "Incomplete "
|
|
||||||
"mode parameter data\n");
|
|
||||||
goto defaults;
|
goto defaults;
|
||||||
} else {
|
|
||||||
modepage = page_code;
|
|
||||||
goto Page_found;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
/* Go to the next page */
|
|
||||||
if (spf && len - offset > 3)
|
|
||||||
offset += 4 + (buffer[offset+2] << 8) +
|
|
||||||
buffer[offset+3];
|
|
||||||
else if (!spf && len - offset > 1)
|
|
||||||
offset += 2 + buffer[offset+1];
|
|
||||||
else {
|
|
||||||
sd_printk(KERN_ERR, sdkp, "Incomplete "
|
|
||||||
"mode parameter data\n");
|
|
||||||
goto defaults;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (modepage == 0x3F) {
|
if ((buffer[offset] & 0x3f) != modepage) {
|
||||||
sd_printk(KERN_ERR, sdkp, "No Caching mode page "
|
|
||||||
"present\n");
|
|
||||||
goto defaults;
|
|
||||||
} else if ((buffer[offset] & 0x3f) != modepage) {
|
|
||||||
sd_printk(KERN_ERR, sdkp, "Got wrong page\n");
|
sd_printk(KERN_ERR, sdkp, "Got wrong page\n");
|
||||||
goto defaults;
|
goto defaults;
|
||||||
}
|
}
|
||||||
Page_found:
|
|
||||||
if (modepage == 8) {
|
if (modepage == 8) {
|
||||||
sdkp->WCE = ((buffer[offset + 2] & 0x04) != 0);
|
sdkp->WCE = ((buffer[offset + 2] & 0x04) != 0);
|
||||||
sdkp->RCD = ((buffer[offset + 2] & 0x01) != 0);
|
sdkp->RCD = ((buffer[offset + 2] & 0x01) != 0);
|
||||||
|
|
Loading…
Reference in a new issue