rpms/kernel/F-8 linux-2.6-libata-scsi-allow-short-commands.patch, NONE, 1.1 linux-2.6-libata-tape-max-sectors.patch, NONE, 1.1 linux-2.6-libata-use-stuck-err-for-tapes.patch, NONE, 1.1 linux-2.6-libata-work-around-drq-1-err-1-for-tapes.patch, NONE, 1.1 kernel.spec, 1.287, 1.288

Chuck Ebbert (cebbert) fedora-extras-commits at redhat.com
Tue Dec 4 21:37:30 UTC 2007


Author: cebbert

Update of /cvs/pkgs/rpms/kernel/F-8
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv18312

Modified Files:
	kernel.spec 
Added Files:
	linux-2.6-libata-scsi-allow-short-commands.patch 
	linux-2.6-libata-tape-max-sectors.patch 
	linux-2.6-libata-use-stuck-err-for-tapes.patch 
	linux-2.6-libata-work-around-drq-1-err-1-for-tapes.patch 
Log Message:
* Tue Dec 04 2007 Chuck Ebbert <cebbert at redhat.com>
- libata: fix ATAPI tape drives (#394961)
- libata: allow short SCSI commands for ATAPI devices


linux-2.6-libata-scsi-allow-short-commands.patch:

--- NEW FILE linux-2.6-libata-scsi-allow-short-commands.patch ---
Backport of commit 607126c2a21cd6e9bb807fdd415c1a992f7b9009
libata-scsi: be tolerant of 12-byte ATAPI commands in 16-byte CDBs

---
 drivers/ata/libata-scsi.c |   27 +++++++++++++++++++--------
 1 file changed, 19 insertions(+), 8 deletions(-)

--- linux-2.6.23.noarch.orig/drivers/ata/libata-scsi.c
+++ linux-2.6.23.noarch/drivers/ata/libata-scsi.c
@@ -2747,16 +2747,15 @@ static inline int __ata_scsi_queuecmd(st
 				      struct ata_device *dev)
 {
 	int rc = 0;
+	u8 scsi_op = scmd->cmnd[0];
 
-	if (unlikely(!scmd->cmd_len || scmd->cmd_len > dev->cdb_len)) {
-		DPRINTK("bad CDB len=%u, max=%u\n",
-			scmd->cmd_len, dev->cdb_len);
-		scmd->result = DID_ERROR << 16;
-		done(scmd);
-		return 0;
-	}
+	if (unlikely(!scmd->cmd_len))
+		goto bad_cdb_len;
 
 	if (dev->class == ATA_DEV_ATA) {
+		if (unlikely(scmd->cmd_len > dev->cdb_len))
+			goto bad_cdb_len;
+
 		ata_xlat_func_t xlat_func = ata_get_xlat_func(dev,
 							      scmd->cmnd[0]);
 
@@ -2764,10 +2763,22 @@ static inline int __ata_scsi_queuecmd(st
 			rc = ata_scsi_translate(dev, scmd, done, xlat_func);
 		else
 			ata_scsi_simulate(dev, scmd, done);
-	} else
+	} else {
+		int len = COMMAND_SIZE(scsi_op);
+		if (unlikely(len > scmd->cmd_len || len > dev->cdb_len))
+			goto bad_cdb_len;
+
 		rc = ata_scsi_translate(dev, scmd, done, atapi_xlat);
+	}
 
 	return rc;
+
+ bad_cdb_len:
+	DPRINTK("bad CDB len=%u, scsi_op=0x%02x, max=%u\n",
+		scmd->cmd_len, scsi_op, dev->cdb_len);
+	scmd->result = DID_ERROR << 16;
+	done(scmd);
+	return 0;
 }
 
 /**

linux-2.6-libata-tape-max-sectors.patch:

--- NEW FILE linux-2.6-libata-tape-max-sectors.patch ---
From: Tony Battersby <tonyb at cybernetics.com>
Date: Tue, 30 Oct 2007 15:44:35 +0000 (-0400)
Subject: libata: increase 128 KB / cmd limit for ATAPI tape drives
X-Git-Tag: v2.6.24-rc2~48^2~6
X-Git-Url: http://git.kernel.org/?p=linux%2Fkernel%2Fgit%2Ftorvalds%2Flinux-2.6.git;a=commitdiff_plain;h=f8d8e5799b75cf7ad530d2bf2a42229bf7360526

libata: increase 128 KB / cmd limit for ATAPI tape drives

Commands sent to ATAPI tape drives via the SCSI generic (sg) driver are
limited in the amount of data that they can transfer by the max_sectors
value.  The max_sectors value is currently calculated according to the
command set for disk drives, which doesn't apply to tape drives.  The
default max_sectors value of 256 limits ATAPI tape drive commands to
128 KB.  This patch against 2.6.24-rc1 increases the max_sectors value
for tape drives to 65535, which permits tape drive commands to transfer
just under 32 MB.

Tested with a SuperMicro PDSME motherboard, AHCI, and a Sony SDX-570V
SATA tape drive.

Note that some of the chipset drivers also set their own max_sectors
value, which may override the value set in libata-core.  I don't have
any of these chipsets to test, so I didn't go messing with them.  Also,
ATAPI devices other than tape drives may benefit from similar changes,
but I have only tape drives and disk drives to test.

Signed-off-by: Tony Battersby <tonyb at cybernetics.com>
Signed-off-by: Jeff Garzik <jeff at garzik.org>
---

---
 drivers/ata/libata-core.c |    4 ++++
 include/linux/ata.h       |    6 ++++++
 2 files changed, 10 insertions(+)

--- linux-2.6.23.noarch.orig/drivers/ata/libata-core.c
+++ linux-2.6.23.noarch/drivers/ata/libata-core.c
@@ -2019,6 +2019,10 @@ int ata_dev_configure(struct ata_device 
 		dev->max_sectors = ATA_MAX_SECTORS;
 	}
 
+	if ((dev->class == ATA_DEV_ATAPI) &&
+	    (atapi_command_packet_set(id) == TYPE_TAPE))
+		dev->max_sectors = ATA_MAX_SECTORS_TAPE;
+
 	if (dev->horkage & ATA_HORKAGE_MAX_SEC_128)
 		dev->max_sectors = min_t(unsigned int, ATA_MAX_SECTORS_128,
 					 dev->max_sectors);
--- linux-2.6.23.noarch.orig/include/linux/ata.h
+++ linux-2.6.23.noarch/include/linux/ata.h
@@ -43,6 +43,7 @@ enum {
 	ATA_MAX_SECTORS_128	= 128,
 	ATA_MAX_SECTORS		= 256,
 	ATA_MAX_SECTORS_LBA48	= 65535,/* TODO: 65536? */
+	ATA_MAX_SECTORS_TAPE	= 65535,
 
 	ATA_ID_WORDS		= 256,
 	ATA_ID_SERNO		= 10,
@@ -430,6 +431,11 @@ static inline int atapi_cdb_len(const u1
 	}
 }
 
+static inline int atapi_command_packet_set(const u16 *dev_id)
+{
+	return (dev_id[0] >> 8) & 0x1f;
+}
+
 static inline int is_atapi_taskfile(const struct ata_taskfile *tf)
 {
 	return (tf->protocol == ATA_PROT_ATAPI) ||

linux-2.6-libata-use-stuck-err-for-tapes.patch:

--- NEW FILE linux-2.6-libata-use-stuck-err-for-tapes.patch ---
Gitweb:     http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=f442cd86c1c86c5f44bc2cf23f89536f7e4cfe59
Commit:     f442cd86c1c86c5f44bc2cf23f89536f7e4cfe59
Parent:     2d3b8eea7f2fbafd5d779cc92f7aedbd1ef575e9
Author:     Albert Lee <albertcc at tw.ibm.com>
AuthorDate: Thu Nov 15 10:35:47 2007 +0900
Committer:  Tejun Heo <htejun at gmail.com>
CommitDate: Mon Nov 19 12:28:11 2007 +0900

    libata: use ATA_HORKAGE_STUCK_ERR for ATAPI tape drives
    
    Per Mark's comments, maybe all ATAPI tape drives need ATA_HORKAGE_STUCK_ERR.
    This patch applys ATA_HORKAGE_STUCK_ERR for all ATAPI tape drives.
    
    Signed-off-by: Albert Lee <albertcc at tw.ibm.com>
    Cc: Mark Lord <liml at rtr.ca>
    Signed-off-by: Tejun Heo <htejun at gmail.com>
---
 drivers/ata/libata-core.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

--- linux-2.6.23.noarch.orig/drivers/ata/libata-core.c
+++ linux-2.6.23.noarch/drivers/ata/libata-core.c
@@ -2020,8 +2020,10 @@ int ata_dev_configure(struct ata_device 
 	}
 
 	if ((dev->class == ATA_DEV_ATAPI) &&
-	    (atapi_command_packet_set(id) == TYPE_TAPE))
+	    (atapi_command_packet_set(id) == TYPE_TAPE)) {
 		dev->max_sectors = ATA_MAX_SECTORS_TAPE;
+		dev->horkage |= ATA_HORKAGE_STUCK_ERR;
+	}
 
 	if (dev->horkage & ATA_HORKAGE_MAX_SEC_128)
 		dev->max_sectors = min_t(unsigned int, ATA_MAX_SECTORS_128,

linux-2.6-libata-work-around-drq-1-err-1-for-tapes.patch:

--- NEW FILE linux-2.6-libata-work-around-drq-1-err-1-for-tapes.patch ---
Gitweb:     http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=2d3b8eea7f2fbafd5d779cc92f7aedbd1ef575e9
Commit:     2d3b8eea7f2fbafd5d779cc92f7aedbd1ef575e9
Parent:     21bef6dd2b419f28c8096a8e30ad86dcbff44c02
Author:     Albert Lee <albertcc at tw.ibm.com>
AuthorDate: Thu Nov 15 10:35:46 2007 +0900
Committer:  Tejun Heo <htejun at gmail.com>
CommitDate: Mon Nov 19 12:28:11 2007 +0900

    libata: workaround DRQ=1 ERR=1 for ATAPI tape drives
    
    After an error condition, some ATAPI tape drives set DRQ=1 together
    with ERR=1 when asking the host to transfer the CDB of the next packet
    command (i.e. request sense).  This patch, a revised version of
    Alan/Mark's previous patch, adds ATA_HORKAGE_STUCK_ERR to workaround
    the problem by ignoring the ERR bit and proceed sending the CDB.
    
    Signed-off-by: Albert Lee <albertcc at tw.ibm.com>
    Cc: Alan Cox <alan at lxorguk.ukuu.org.uk>
    Cc: Mark Lord <liml at rtr.ca>
    Signed-off-by: Tejun Heo <htejun at gmail.com>
---
 drivers/ata/libata-core.c |   18 +++++++++++++-----
 include/linux/libata.h    |    1 +
 2 files changed, 14 insertions(+), 5 deletions(-)

--- linux-2.6.23.noarch.orig/drivers/ata/libata-core.c
+++ linux-2.6.23.noarch/drivers/ata/libata-core.c
@@ -4962,11 +4962,19 @@ fsm_start:
 		 * let the EH abort the command or reset the device.
 		 */
 		if (unlikely(status & (ATA_ERR | ATA_DF))) {
-			ata_port_printk(ap, KERN_WARNING, "DRQ=1 with device "
-					"error, dev_stat 0x%X\n", status);
-			qc->err_mask |= AC_ERR_HSM;
-			ap->hsm_task_state = HSM_ST_ERR;
-			goto fsm_start;
+			/* Some ATAPI tape drives forget to clear the ERR bit
+			 * when doing the next command (mostly request sense).
+			 * We ignore ERR here to workaround and proceed sending
+			 * the CDB.
+			 */
+			if (!(qc->dev->horkage & ATA_HORKAGE_STUCK_ERR)) {
+				ata_port_printk(ap, KERN_WARNING,
+						"DRQ=1 with device error, "
+						"dev_stat 0x%X\n", status);
+				qc->err_mask |= AC_ERR_HSM;
+				ap->hsm_task_state = HSM_ST_ERR;
+				goto fsm_start;
+			}
 		}
 
 		/* Send the CDB (atapi) or the first data block (ata pio out).
--- linux-2.6.23.noarch.orig/include/linux/libata.h
+++ linux-2.6.23.noarch/include/linux/libata.h
@@ -306,6 +306,7 @@ enum {
 	ATA_HORKAGE_NONCQ	= (1 << 2),	/* Don't use NCQ */
 	ATA_HORKAGE_MAX_SEC_128	= (1 << 3),	/* Limit max sects to 128 */
 	ATA_HORKAGE_BROKEN_HPA	= (1 << 4),	/* Broken HPA */
+	ATA_HORKAGE_STUCK_ERR	= (1 << 9),	/* stuck ERR on next PACKET */
 
 	 /* DMA mask for user DMA control: User visible values; DO NOT 
 	    renumber */


Index: kernel.spec
===================================================================
RCS file: /cvs/pkgs/rpms/kernel/F-8/kernel.spec,v
retrieving revision 1.287
retrieving revision 1.288
diff -u -r1.287 -r1.288
--- kernel.spec	3 Dec 2007 18:06:50 -0000	1.287
+++ kernel.spec	4 Dec 2007 21:36:51 -0000	1.288
@@ -673,6 +673,11 @@
 Patch666: linux-2.6-libata-pata_serverworks-fix-drive-combinations.patch
 Patch667: linux-2.6-libata-correct-iordy-handling.patch
 Patch670: linux-2.6-ata-quirk.patch
+Patch671: linux-2.6-libata-tape-max-sectors.patch
+Patch672: linux-2.6-libata-work-around-drq-1-err-1-for-tapes.patch
+Patch673: linux-2.6-libata-use-stuck-err-for-tapes.patch
+Patch674: linux-2.6-libata-scsi-allow-short-commands.patch
+
 Patch680: linux-2.6-wireless.patch
 Patch681: linux-2.6-wireless-pending.patch
 Patch690: linux-2.6-at76.patch
@@ -1274,6 +1279,12 @@
 ApplyPatch linux-2.6-libata-pata_serverworks-fix-drive-combinations.patch
 # fix libata IORDY handling
 ApplyPatch linux-2.6-libata-correct-iordy-handling.patch
+# fix ATA tape drives
+ApplyPatch linux-2.6-libata-tape-max-sectors.patch
+ApplyPatch linux-2.6-libata-work-around-drq-1-err-1-for-tapes.patch
+ApplyPatch linux-2.6-libata-use-stuck-err-for-tapes.patch
+# allow 12-byte SCSI commands for ATAPI devices
+ApplyPatch linux-2.6-libata-scsi-allow-short-commands.patch
 
 # wireless patches headed for 2.6.24
 ApplyPatch linux-2.6-wireless.patch
@@ -1989,6 +2000,10 @@
 
 
 %changelog
+* Tue Dec 04 2007 Chuck Ebbert <cebbert at redhat.com>
+- libata: fix ATAPI tape drives (#394961)
+- libata: allow short SCSI commands for ATAPI devices
+
 * Mon Dec 03 2007 Jarod Wilson <jwilson at redhat.com>
 - Fix FireWire OHCI 1.1 regression introduced by 1.0 support
 




More information about the fedora-extras-commits mailing list