From: Tony Battersby <tonyb@cybernetics.com>
Date: Wed, 21 Dec 2005 21:35:44 +0000 (-0500)
Subject: [PATCH] fix libata inquiry VPD for ATAPI devices
X-Git-Tag: firefly_0821_release~39689^2
X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=fd71da468dd8897fe3f565dfd3743a87d8678e3a;p=firefly-linux-kernel-4.4.55.git

[PATCH] fix libata inquiry VPD for ATAPI devices

The following patch prevents libata from incorrectly modifying inquiry
VPD pages and command support data from ATAPI devices.  I have tested
the patch with a SATA ATAPI tape drive on an AHCI controller.

Patch is against kernel 2.4.32 with 2.4.32-libata1.patch applied.

Anthony J. Battersby
Cybernetics

Signed-off-by: Jeff Garzik <jgarzik@pobox.com>
---

diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c
index 72ddba98f8fb..2282c04fee46 100644
--- a/drivers/scsi/libata-scsi.c
+++ b/drivers/scsi/libata-scsi.c
@@ -2044,7 +2044,7 @@ static int atapi_qc_complete(struct ata_queued_cmd *qc, unsigned int err_mask)
 	else {
 		u8 *scsicmd = cmd->cmnd;
 
-		if (scsicmd[0] == INQUIRY) {
+		if ((scsicmd[0] == INQUIRY) && ((scsicmd[1] & 0x03) == 0)) {
 			u8 *buf = NULL;
 			unsigned int buflen;
 
@@ -2057,9 +2057,6 @@ static int atapi_qc_complete(struct ata_queued_cmd *qc, unsigned int err_mask)
 	 * to indicate to the Linux scsi midlayer this is a modern
 	 * device.  2) Ensure response data format / ATAPI information
 	 * are always correct.
-	 */
-	/* FIXME: do we ever override EVPD pages and the like, with
-	 * this code?
 	 */
 			if (buf[2] == 0) {
 				buf[2] = 0x5;