linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mark Lord <liml@rtr.ca>
To: Linux IDE <linux-ide@vger.kernel.org>,
	Tejun Heo <htejun@gmail.com>, Jeff Garzik <jeff@garzik.org>,
	linux-scsi@vger.kernel.org
Subject: [PATCH] SCSI, libata: add support for ATA_16 commands to libata ATAPI devices
Date: Tue, 2 Jan 2007 19:35:07 -0500	[thread overview]
Message-ID: <200701021935.07840.liml@rtr.ca> (raw)

In an ideal world, we would use the existing ATA_12 opcode
to issue 12-byte ATA passthrough commands for libata ATAPI drives
from userspace.

But ATA_12 happens to have the same SCSI opcode value as the older
CD/RW "BLANK" command, widely used by cdrecord and friends.

So, to achieve ATA passthru capability for libata ATAPI,
we have to instead use the ATA_16 opcode: a 16-byte command.

SCSI normally disallows issuing 16-byte commands to 12-byte devices,
so special support has to be added for this.

Introduce an "allow_ata_16" boolean to the scsi_host struct.
This provides a means for libata to signal that 16-byte ATA_16
commands should be permitted even for 12-byte ATAPI devices.

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

--- old/include/scsi/scsi_host.h	2007-01-02 19:06:45.000000000 -0500
+++ new/include/scsi/scsi_host.h	2007-01-02 19:09:06.000000000 -0500
@@ -608,6 +608,13 @@
 	unsigned async_scan:1;
 
 	/*
+	 * True for libata, to allow issuing ATA_16 16-byte CDBs
+	 * to (otherwise) 12-byte ATAPI drives.  ATAPI cannot use
+	 * the ATA_12 opcode, because it means "BLANK" to CDRW drives.
+	 */
+	unsigned allow_ata_16:1;
+
+	/*
 	 * Optional work queue to be utilized by the transport
 	 */
 	char work_q_name[KOBJ_NAME_LEN];
--- old/drivers/scsi/scsi.c	2007-01-02 19:06:45.000000000 -0500
+++ new/drivers/scsi/scsi.c	2007-01-02 19:09:06.000000000 -0500
@@ -567,12 +567,17 @@
 	 * length exceeds what the host adapter can handle.
 	 */
 	if (CDB_SIZE(cmd) > cmd->device->host->max_cmd_len) {
-		SCSI_LOG_MLQUEUE(3,
+		/* permit ATA_16 passthru to 12-byte ATAPI devices */
+		if (cmd->cmnd[0]  != ATA_16
+		 || CDB_SIZE(cmd) != 16
+		 || !cmd->device->host->allow_ata_16) {
+			SCSI_LOG_MLQUEUE(3,
 				printk("queuecommand : command too long.\n"));
-		cmd->result = (DID_ABORT << 16);
+			cmd->result = (DID_ABORT << 16);
 
-		scsi_done(cmd);
-		goto out;
+			scsi_done(cmd);
+			goto out;
+		}
 	}
 
 	spin_lock_irqsave(host->host_lock, flags);
--- old/drivers/ata/libata-core.c	2007-01-02 19:06:44.000000000 -0500
+++ new/drivers/ata/libata-core.c	2007-01-02 19:09:06.000000000 -0500
@@ -5686,6 +5686,7 @@
 	shost->max_lun = 1;
 	shost->max_channel = 1;
 	shost->max_cmd_len = 12;
+	shost->allow_ata_16 = 1;
 }
 
 /**

             reply	other threads:[~2007-01-03  0:35 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-03  0:35 Mark Lord [this message]
2007-01-03  1:40 ` [PATCH] SCSI, libata: add support for ATA_16 commands to libata ATAPI devices James Bottomley
2007-01-03  5:42   ` Mark Lord
2007-01-03 15:31     ` James Bottomley
2007-01-03 15:45       ` Jeff Garzik
2007-01-03 15:57         ` James Bottomley
2007-01-03 17:58           ` Mark Lord
2007-01-03 19:39       ` Douglas Gilbert
2007-01-03 21:41         ` James Bottomley
2007-01-03 23:57           ` Mark Lord
2007-01-04 15:09           ` Jens Axboe
2007-01-04 15:29             ` Mark Lord
2007-01-04 15:51               ` Jens Axboe
2007-01-08  5:00         ` Luben Tuikov
     [not found] ` <200701311346.26644.liml@rtr.ca>
2007-02-01  0:33   ` [PATCH] RESEND: " Tejun Heo
2007-02-01  0:42     ` Mark Lord
2007-02-01  0:48       ` James Bottomley
2007-02-01  0:53         ` Mark Lord
2007-02-01  0:48       ` Tejun Heo
2007-02-01  1:01         ` Mark Lord
2007-02-01  8:30           ` Jeff Garzik
2007-02-01  8:28         ` Jeff Garzik
2007-02-01  8:43           ` Tejun Heo
2007-02-01  9:54             ` Jeff Garzik
2007-02-01 15:09               ` James Bottomley
2007-02-01 15:15                 ` Jeff Garzik
2007-02-01 20:21                 ` Douglas Gilbert
2007-02-01 20:30                   ` Jeff Garzik
2007-02-02  9:11                   ` Christoph Hellwig
2007-02-01  8:26       ` Jeff Garzik
2007-02-01  8:35         ` Tejun Heo
2007-02-01  9:52           ` Jeff Garzik
2007-02-01  0:44     ` James Bottomley

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200701021935.07840.liml@rtr.ca \
    --to=liml@rtr.ca \
    --cc=htejun@gmail.com \
    --cc=jeff@garzik.org \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).