Skip to contentSkip to conversation

target: Handle ATA_PASS_THROUGH_16 passthrough

PATCH In review mengcong 3 participants 7 messages May 16, 2012 – May 17, 2012

Subsystems (2)
lore
Share & tools
lore

mengcong

author
#0 lore raw

PATCH 1/1 target: Handle ATA_PASS_THROUGH_16 passthrough

The cdrecord uses ATA_PASS_THROUGH_16 command while burning CDs with a SATA CD-ROM. This patch adds support to it so that PSCSI CD-ROM passthrough works with the cdrecord.

---
 drivers/target/target_core_transport.c |   30 ++++++++++++++++++++++++++++++
 include/scsi/scsi.h                    |    1 +
 2 files changed, 31 insertions(+), 0 deletions(-)
drivers/target/target_core_transport.c +30 -0
index 2d75c29..41439b3 100644
@@ -2926,6 +2926,36 @@ static int transport_generic_cmd_sequencer(
 		size = (cdb[7] << 8) | cdb[8];
 		cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB;
 		break;
+	case ATA_PASS_THROUGH_16:
+		// T_LENGTH
+		switch (cdb[2] & 0x3) {
+		case 0x0:
+			sectors = 0;
+			break;
+		case 0x1:
+			sectors = (((cdb[1] & 0x1) ? cdb[3] : 0) << 8) | cdb[4];
+			break;
+		case 0x2:
+			sectors = (((cdb[1] & 0x1) ? cdb[5] : 0) << 8) | cdb[6];
+			break;
+		case 0x3:
+			pr_err("T_LENGTH=0x3 not supported\n");
+			goto out_invalid_cdb_field;
+			break;
+		}
+		
+		// BYTE_BLOCK
+		if (cdb[2] & 0x4) {
+			// BLOCK
+			// T_TYPE: 512 or sector
+			size = sectors * ((cdb[2] & 0x10) ? 
+				dev->se_sub_dev->se_dev_attrib.block_size : 512);
+		} else {
+			// BYTE
+			size = sectors;
+		}
+		cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB;
+		break;
 	default:
 		pr_warn("TARGET_CORE[%s]: Unsupported SCSI Opcode"
 			" 0x%02x, sending CHECK_CONDITION.\n",
include/scsi/scsi.h +1 -0
index f34a5a8..f6dcd25 100644
@@ -116,6 +116,7 @@ struct scsi_cmnd;
 #define PERSISTENT_RESERVE_IN 0x5e
 #define PERSISTENT_RESERVE_OUT 0x5f
 #define VARIABLE_LENGTH_CMD   0x7f
+#define ATA_PASS_THROUGH_16   0x85
 #define REPORT_LUNS           0xa0
 #define SECURITY_PROTOCOL_IN  0xa2
 #define MAINTENANCE_IN        0xa3
Signature · 1 line
1.7.7
maintainer
#1 lore raw
Quoted 6 lines · mengcong

The cdrecord uses ATA_PASS_THROUGH_16 command while burning CDs with a SATA CD-ROM. This patch adds support to it so that PSCSI CD-ROM passthrough works with the cdrecord.

---

[...]

include/scsi/scsi.h struct scsi_cmnd; · line 122

Quoted 12 lines
include/scsi/scsi.h +1 -0
index f34a5a8..f6dcd25 100644
@@ -116,6 +116,7 @@ struct scsi_cmnd;
 #define PERSISTENT_RESERVE_IN 0x5e
 #define PERSISTENT_RESERVE_OUT 0x5f
 #define VARIABLE_LENGTH_CMD   0x7f
+#define ATA_PASS_THROUGH_16   0x85
 #define REPORT_LUNS           0xa0
 #define SECURITY_PROTOCOL_IN  0xa2
 #define MAINTENANCE_IN        0xa3

We already have this: they're called ATA_16 (and ATA_12) in this very file.

James

#5 lore raw
In reply to mengcong
Quoted 37 lines · mengcong

The cdrecord uses ATA_PASS_THROUGH_16 command while burning CDs with a SATA CD-ROM. This patch adds support to it so that PSCSI CD-ROM passthrough works with the cdrecord.

---
 drivers/target/target_core_transport.c |   30 ++++++++++++++++++++++++++++++
 include/scsi/scsi.h                    |    1 +
 2 files changed, 31 insertions(+), 0 deletions(-)
drivers/target/target_core_transport.c +19 -0
index 2d75c29..41439b3 100644
@@ -2926,6 +2926,36 @@ static int transport_generic_cmd_sequencer(
 		size = (cdb[7] << 8) | cdb[8];
 		cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB;
 		break;
+	case ATA_PASS_THROUGH_16:
+		// T_LENGTH
+		switch (cdb[2] & 0x3) {
+		case 0x0:
+			sectors = 0;
+			break;
+		case 0x1:
+			sectors = (((cdb[1] & 0x1) ? cdb[3] : 0) << 8) | cdb[4];
+			break;
+		case 0x2:
+			sectors = (((cdb[1] & 0x1) ? cdb[5] : 0) << 8) | cdb[6];
+			break;
+		case 0x3:
+			pr_err("T_LENGTH=0x3 not supported\n");
+			goto out_invalid_cdb_field;
+			break;
+		}
+		
+		// BYTE_BLOCK

drivers/target/target_core_transport.c static int transport_generic_cmd_sequencer( · line 2957

Quoted 10 lines
drivers/target/target_core_transport.c +10 -0
+		if (cdb[2] & 0x4) {
+			// BLOCK
+			// T_TYPE: 512 or sector
+			size = sectors * ((cdb[2] & 0x10) ? 
+				dev->se_sub_dev->se_dev_attrib.block_size : 512);
+		} else {
+			// BYTE
+			size = sectors;
+		}
+		cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB;

Mmmm, I think using SCF_SCSI_CONTROL_SG_IO_CDB here for all ATA passthrough cases should be OK with pSCSI, but you'll want to fail this type of cdb when if (!passthrough) for non pSCSI type devices to be safe with virtual backends..

Also just an FYI, checkpatch.pl will complain here using '//' style comments, so you'll want to always use '/* ... */' style comments when submitting a target patch.

So please go ahead and fix up these two bits + use ATA_16 following jejb's comment, and I'm fine with including your v2 into the for-3.5 target queue..

Thanks!

--nab

author
#2 lore raw

Re: [PATCH] V2: target: Handle ATA_PASS_THROUGH_16 passthrough

In reply to James Bottomley

The cdrecord uses ATA_PASS_THROUGH_16 command while burning CDs with a SATA CD-ROM. This patch adds support to it so that PSCSI CD-ROM passthrough works with the cdrecord.

---
 drivers/target/target_core_transport.c |   30 ++++++++++++++++++++++++++++++
 1 files changed, 30 insertions(+), 0 deletions(-)
drivers/target/target_core_transport.c +30 -0
index 2d75c29..25e0fc0 100644
@@ -2926,6 +2926,36 @@ static int transport_generic_cmd_sequencer(
 		size = (cdb[7] << 8) | cdb[8];
 		cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB;
 		break;
+	case ATA_16:
+		// T_LENGTH
+		switch (cdb[2] & 0x3) {
+		case 0x0:
+			sectors = 0;
+			break;
+		case 0x1:
+			sectors = (((cdb[1] & 0x1) ? cdb[3] : 0) << 8) | cdb[4];
+			break;
+		case 0x2:
+			sectors = (((cdb[1] & 0x1) ? cdb[5] : 0) << 8) | cdb[6];
+			break;
+		case 0x3:
+			pr_err("T_LENGTH=0x3 not supported\n");
+			goto out_invalid_cdb_field;
+			break;
+		}
+		
+		// BYTE_BLOCK
+		if (cdb[2] & 0x4) {
+			// BLOCK
+			// T_TYPE: 512 or sector
+			size = sectors * ((cdb[2] & 0x10) ? 
+				dev->se_sub_dev->se_dev_attrib.block_size : 512);
+		} else {
+			// BYTE
+			size = sectors;
+		}
+		cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB;
+		break;
 	default:
 		pr_warn("TARGET_CORE[%s]: Unsupported SCSI Opcode"
 			" 0x%02x, sending CHECK_CONDITION.\n",
Signature · 1 line
1.7.7
#3 lore raw

Re: [PATCH] V2: target: Handle ATA_PASS_THROUGH_16 passthrough

Quoted 9 lines · mengcong

The cdrecord uses ATA_PASS_THROUGH_16 command while burning CDs with a SATA CD-ROM. This patch adds support to it so that PSCSI CD-ROM passthrough works with the cdrecord.

---
 drivers/target/target_core_transport.c |   30 ++++++++++++++++++++++++++++++
 1 files changed, 30 insertions(+), 0 deletions(-)

Ok, I've added the extra !passthrough check to enforce pSCSI backends only usage + /* ... */ style comments changes mentioned as feedback you missed in the last mail. (That's OK this time, but please don't get into the habit of ignoring patch feedback..)

So committed into lio-core.git, and queuing shortly into target-pending/for-next to be picked up for tomorrow's linux-next build.

Thanks for your patch MC!

--nab

Quoted 41 lines
drivers/target/target_core_transport.c +30 -0
index 2d75c29..25e0fc0 100644
@@ -2926,6 +2926,36 @@ static int transport_generic_cmd_sequencer(
 		size = (cdb[7] << 8) | cdb[8];
 		cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB;
 		break;
+	case ATA_16:
+		// T_LENGTH
+		switch (cdb[2] & 0x3) {
+		case 0x0:
+			sectors = 0;
+			break;
+		case 0x1:
+			sectors = (((cdb[1] & 0x1) ? cdb[3] : 0) << 8) | cdb[4];
+			break;
+		case 0x2:
+			sectors = (((cdb[1] & 0x1) ? cdb[5] : 0) << 8) | cdb[6];
+			break;
+		case 0x3:
+			pr_err("T_LENGTH=0x3 not supported\n");
+			goto out_invalid_cdb_field;
+			break;
+		}
+		
+		// BYTE_BLOCK
+		if (cdb[2] & 0x4) {
+			// BLOCK
+			// T_TYPE: 512 or sector
+			size = sectors * ((cdb[2] & 0x10) ? 
+				dev->se_sub_dev->se_dev_attrib.block_size : 512);
+		} else {
+			// BYTE
+			size = sectors;
+		}
+		cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB;
+		break;
 	default:
 		pr_warn("TARGET_CORE[%s]: Unsupported SCSI Opcode"
 			" 0x%02x, sending CHECK_CONDITION.\n",
author
#6 lore raw
In reply to Nicholas A. Bellinger
Quoted 45 lines · Nicholas A. Bellinger
Quoted 44 lines · mengcong

The cdrecord uses ATA_PASS_THROUGH_16 command while burning CDs with a SATA CD-ROM. This patch adds support to it so that PSCSI CD-ROM passthrough works with the cdrecord.

---
 drivers/target/target_core_transport.c |   30 ++++++++++++++++++++++++++++++
 include/scsi/scsi.h                    |    1 +
 2 files changed, 31 insertions(+), 0 deletions(-)
drivers/target/target_core_transport.c +26 -0
index 2d75c29..41439b3 100644
@@ -2926,6 +2926,36 @@ static int transport_generic_cmd_sequencer(
 		size = (cdb[7] << 8) | cdb[8];
 		cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB;
 		break;
+	case ATA_PASS_THROUGH_16:
+		// T_LENGTH
+		switch (cdb[2] & 0x3) {
+		case 0x0:
+			sectors = 0;
+			break;
+		case 0x1:
+			sectors = (((cdb[1] & 0x1) ? cdb[3] : 0) << 8) | cdb[4];
+			break;
+		case 0x2:
+			sectors = (((cdb[1] & 0x1) ? cdb[5] : 0) << 8) | cdb[6];
+			break;
+		case 0x3:
+			pr_err("T_LENGTH=0x3 not supported\n");
+			goto out_invalid_cdb_field;
+			break;
+		}
+		
+		// BYTE_BLOCK
+		if (cdb[2] & 0x4) {
+			// BLOCK
+			// T_TYPE: 512 or sector
+			size = sectors * ((cdb[2] & 0x10) ? 
+				dev->se_sub_dev->se_dev_attrib.block_size : 512);
+		} else {
+			// BYTE
Quoted 8 lines

drivers/target/target_core_transport.c static int transport_generic_cmd_sequencer( · line 2957

Quoted 3 lines
drivers/target/target_core_transport.c +3 -0
+			size = sectors;
+		}
+		cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB;

Mmmm, I think using SCF_SCSI_CONTROL_SG_IO_CDB here for all ATA passthrough cases should be OK with pSCSI, but you'll want to fail this type of cdb when if (!passthrough) for non pSCSI type devices to be safe with virtual backends..

(passthrough) has made sure the backend is non-virtual already.

As I doesn't set cmd->execute_task and SCF_SCSI_DATA_SG_IO_CDB flag, so the below piece of code should guarantee that my patch only works with pSCSI, at least, currently. Is it right?

---
passthrough =

        (dev->transport->transport_type == TRANSPORT_PLUGIN_PHBA_PDEV);

...

if (!(passthrough || cmd->execute_task ||

     (cmd->se_cmd_flags & SCF_SCSI_DATA_SG_IO_CDB)))
        goto out_unsupported_cdb;                   

---

Quoted 4 lines

Also just an FYI, checkpatch.pl will complain here using '//' style comments, so you'll want to always use '/* ... */' style comments when submitting a target patch.

Sure, I will change it.

Thanks.
mc

Quoted 9 lines

So please go ahead and fix up these two bits + use ATA_16 following jejb's comment, and I'm fine with including your v2 into the for-3.5 target queue..

Thanks!

--nab

author
#4 lore raw

Re: [PATCH] V2: target: Handle ATA_PASS_THROUGH_16 passthrough

In reply to Nicholas A. Bellinger
Quoted 11 lines · Nicholas A. Bellinger
Quoted 9 lines · mengcong

The cdrecord uses ATA_PASS_THROUGH_16 command while burning CDs with a SATA CD-ROM. This patch adds support to it so that PSCSI CD-ROM passthrough works with the cdrecord.

---
 drivers/target/target_core_transport.c |   30 ++++++++++++++++++++++++++++++
 1 files changed, 30 insertions(+), 0 deletions(-)
Quoted 4 lines

Ok, I've added the extra !passthrough check to enforce pSCSI backends only usage + /* ... */ style comments changes mentioned as feedback you missed in the last mail. (That's OK this time, but please don't get into the habit of ignoring patch feedback..)

Sorry to the ignoreance of the feedback. My client gets new mail with problem sometimes.

About the passthrough check, I explains in my last mail.

Thanks.
mc.

Quoted 51 lines

So committed into lio-core.git, and queuing shortly into target-pending/for-next to be picked up for tomorrow's linux-next build.

Thanks for your patch MC!

--nab

Quoted 41 lines
drivers/target/target_core_transport.c +30 -0
index 2d75c29..25e0fc0 100644
@@ -2926,6 +2926,36 @@ static int transport_generic_cmd_sequencer(
 		size = (cdb[7] << 8) | cdb[8];
 		cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB;
 		break;
+	case ATA_16:
+		// T_LENGTH
+		switch (cdb[2] & 0x3) {
+		case 0x0:
+			sectors = 0;
+			break;
+		case 0x1:
+			sectors = (((cdb[1] & 0x1) ? cdb[3] : 0) << 8) | cdb[4];
+			break;
+		case 0x2:
+			sectors = (((cdb[1] & 0x1) ? cdb[5] : 0) << 8) | cdb[6];
+			break;
+		case 0x3:
+			pr_err("T_LENGTH=0x3 not supported\n");
+			goto out_invalid_cdb_field;
+			break;
+		}
+		
+		// BYTE_BLOCK
+		if (cdb[2] & 0x4) {
+			// BLOCK
+			// T_TYPE: 512 or sector
+			size = sectors * ((cdb[2] & 0x10) ? 
+				dev->se_sub_dev->se_dev_attrib.block_size : 512);
+		} else {
+			// BYTE
+			size = sectors;
+		}
+		cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB;
+		break;
 	default:
 		pr_warn("TARGET_CORE[%s]: Unsupported SCSI Opcode"
 			" 0x%02x, sending CHECK_CONDITION.\n",