multi-qc SCSI cmd translation - preview
RFC PATCH 1/1 multi-qc SCSI cmd translation - preview
Hello, Douglas & Jeff.
This is preview implementation of multi-qc SCSI command translation.
New translation type 'sequence' is defined and handled by sat_task running on ata_sat_wq. Rationale...
a. inside qc chaining as in sil m15w workaround is too hacky & fragile.
b. multi qc chaining without task is possible but, with thread...
- translation implementation is easier (simple contexts on stack, easier code flow...)
- we are much less restriced in what we can do (in case full SAT implementation requires something weird).
- this isn't a hot path, simplicity & maintainability weigh more than performance.
Current implementation is broken in that each qc's completion status
cannot be acquired. This can be fixed by adding opaque user data field to ->complete_fn and unifying ->waiting mechanism into ->complete_fn. If this task-based approach is okay with other ATA developers, I'll do that and post splitted patches.
The following is one big patch containing multi-qc sequencing
infrastructure and stupid & broken MODE_SELECT_10 implementation. msel10 implemented here only deals with WCE and DRA of caching mode page. It's stupid but demonstrates enough, hopefully.
Thanks.
drivers/scsi/libata-core.c +8 -0
@@ -3924,6 +3924,7 @@ static void ata_host_init(struct ata_porINIT_WORK (&ap->packet_task, atapi_packet_task, ap);INIT_WORK (&ap->pio_task, ata_pio_task, ap); +INIT_WORK (&ap->sat_task, ata_sat_task, ap);for (i =0 ; i <ATA_MAX_DEVICES ; i++) ap->device[i].devno = i;
@@ -4530,6 +4531,12 @@ static int __init ata_init(void)if (!ata_wq)return -ENOMEM ; + ata_sat_wq =create_workqueue ("sat" ); +if (!ata_sat_wq) { +destroy_workqueue (ata_wq); +return -ENOMEM ; + } +printk (KERN_DEBUG "libata version " DRV_VERSION " loaded.\n" );return 0 ; }
@@ -4537,6 +4544,7 @@ static int __init ata_init(void) static void __exit ata_exit(void) {destroy_workqueue (ata_wq); +destroy_workqueue (ata_sat_wq); }module_init (ata_init);
drivers/scsi/libata-scsi.c +183 -17
265 lines not on this page · raw message
drivers/scsi/libata.h +4 -0
@@ -50,6 +50,10 @@ extern void swap_buf_le16(u16 *buf, unsi/* libata-scsi.c */ +extern struct workqueue_struct *ata_sat_wq; + +extern void ata_sat_task (void *_data); +extern void ata_to_sense_error (struct ata_queued_cmd *qc,u8 drv_stat);extern int ata_scsi_error (struct Scsi_Host *host); extern unsigned int ata_scsiop_inq_std(struct ata_scsi_args *args, u8 *rbuf,
include/linux/libata.h +12 -0
@@ -172,10 +172,16 @@ enum pio_task_states {struct scsi_device ;struct ata_port_operations ;struct ata_port ; +struct ata_device ;struct ata_queued_cmd ;/* typedefs */ typedef int (*ata_qc_cb_t ) (struct ata_queued_cmd *qc,u8 drv_stat); +typedef unsigned int (*ata_sat_xlat_func_t )(struct ata_queued_cmd *qc, +u8 *scsicmd); +typedef void (*ata_sat_seq_func_t )(struct ata_port *ap,struct ata_device *dev, +struct scsi_cmnd *cmd, +void (*done)(struct scsi_cmnd *));struct ata_ioports {unsigned long cmd_addr;
@@ -323,6 +329,12 @@ struct ata_port {unsigned int pio_task_state;unsigned long pio_task_timeout; +struct work_struct sat_task; +struct scsi_cmnd *sat_scsicmd; +struct ata_device *sat_dev; +ata_sat_seq_func_t sat_seq_func; +void (*sat_done)(struct scsi_cmnd *); +void *private_data; };