[PATCH] libata-scsi: be tolerant of 12-byte ATAPI commands in 16-byte CDBs

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Tejun Heo <htejun@...>, IDE/ATA development list <linux-ide@...>, Sebastian Kemper <sebastian_ml@...>
Cc: Jeff Garzik <jgarzik@...>, Alan Cox <alan@...>, Linux Kernel <linux-kernel@...>
Date: Wednesday, November 14, 2007 - 1:44 pm

Sebastian Kemper reported that issuing CD/DVD commands under libata
is not fully compatible with ide-scsi.  In particular, the GPCMD_SET_STREAMING
was being rejected at the host level in some instances.

The reason is that libata-scsi insists upon the cmd_len field exactly matching
the SCSI opcode being issued, whereas ide-scsi tolerates 12-byte commands
contained within a 16-byte (cmd_len) CDB.

There doesn't seem to be a good reason for us to not be compatible there,
so here is a patch to fix libata-scsi to permit SCSI opcodes so long as
they fit within whatever size CDB is provided.

Signed-off-by: Mark Lord <mlord@pobox.com>
---

Patch is against 2.6.24-rc2-git4.
Sebastian, could you please re-test with this patch
and let us know that it works for you (or not).

--- old/drivers/ata/libata-scsi.c	2007-11-13 23:25:15.000000000 -0500
+++ linux/drivers/ata/libata-scsi.c	2007-11-14 12:32:16.000000000 -0500
@@ -2869,7 +2869,8 @@
 		xlat_func = NULL;
 		if (likely((scsi_op != ATA_16) || !atapi_passthru16)) {
 			/* relay SCSI command to ATAPI device */
-			if (unlikely(scmd->cmd_len > dev->cdb_len))
+			int len = COMMAND_SIZE(scsi_op);
+			if (unlikely(len > scmd->cmd_len || len > dev->cdb_len))
 				goto bad_cdb_len;
 
 			xlat_func = atapi_xlat;
-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
libata/PATA: GPCMD_SET_STREAMING via SG_IO does nothing, Sebastian Kemper, (Tue Nov 13, 12:43 pm)
Re: libata/PATA: GPCMD_SET_STREAMING via SG_IO does nothing, Sebastian Kemper, (Tue Nov 13, 7:28 pm)
Re: libata/PATA: GPCMD_SET_STREAMING via SG_IO does nothing, Sebastian Kemper, (Wed Nov 14, 1:16 pm)
Re: libata/PATA: GPCMD_SET_STREAMING via SG_IO does nothing, Sebastian Kemper, (Wed Nov 14, 1:11 pm)
Re: libata/PATA: GPCMD_SET_STREAMING via SG_IO does nothing, Bartlomiej Zolnierkiewicz..., (Thu Nov 15, 4:55 pm)
Re: libata/PATA: GPCMD_SET_STREAMING via SG_IO does nothing, Sebastian Kemper, (Wed Nov 14, 11:38 am)
[PATCH] libata-scsi: be tolerant of 12-byte ATAPI commands ..., Mark Lord, (Wed Nov 14, 1:44 pm)
Re: libata/PATA: GPCMD_SET_STREAMING via SG_IO does nothing, Sebastian Kemper, (Wed Nov 14, 8:11 am)