Commit 532de20c authored by Linus Torvalds's avatar Linus Torvalds

Merge bk://gkernel.bkbits.net/libata-2.6

into ppc970.osdl.org:/home/torvalds/v2.6/linux
parents fcd93c96 a9403f0a
...@@ -2245,6 +2245,7 @@ struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap, ...@@ -2245,6 +2245,7 @@ struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap,
qc->scsicmd = NULL; qc->scsicmd = NULL;
qc->ap = ap; qc->ap = ap;
qc->dev = dev; qc->dev = dev;
qc->cursect = qc->cursg = qc->cursg_ofs = 0;
INIT_LIST_HEAD(&qc->node); INIT_LIST_HEAD(&qc->node);
init_MUTEX_LOCKED(&qc->sem); init_MUTEX_LOCKED(&qc->sem);
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include "libata.h" #include "libata.h"
typedef unsigned int (*ata_xlat_func_t)(struct ata_queued_cmd *qc, u8 *scsicmd);
static void ata_scsi_simulate(struct ata_port *ap, struct ata_device *dev, static void ata_scsi_simulate(struct ata_port *ap, struct ata_device *dev,
struct scsi_cmnd *cmd, struct scsi_cmnd *cmd,
void (*done)(struct scsi_cmnd *)); void (*done)(struct scsi_cmnd *));
...@@ -222,7 +223,6 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, u8 *scsicmd) ...@@ -222,7 +223,6 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, u8 *scsicmd)
struct ata_taskfile *tf = &qc->tf; struct ata_taskfile *tf = &qc->tf;
unsigned int lba48 = tf->flags & ATA_TFLAG_LBA48; unsigned int lba48 = tf->flags & ATA_TFLAG_LBA48;
qc->cursect = qc->cursg = qc->cursg_ofs = 0;
tf->flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; tf->flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE;
tf->hob_nsect = 0; tf->hob_nsect = 0;
tf->hob_lbal = 0; tf->hob_lbal = 0;
...@@ -335,7 +335,8 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, u8 *scsicmd) ...@@ -335,7 +335,8 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, u8 *scsicmd)
static void ata_scsi_translate(struct ata_port *ap, struct ata_device *dev, static void ata_scsi_translate(struct ata_port *ap, struct ata_device *dev,
struct scsi_cmnd *cmd, struct scsi_cmnd *cmd,
void (*done)(struct scsi_cmnd *)) void (*done)(struct scsi_cmnd *),
ata_xlat_func_t xlat_func)
{ {
struct ata_queued_cmd *qc; struct ata_queued_cmd *qc;
u8 *scsicmd = cmd->cmnd; u8 *scsicmd = cmd->cmnd;
...@@ -352,9 +353,11 @@ static void ata_scsi_translate(struct ata_port *ap, struct ata_device *dev, ...@@ -352,9 +353,11 @@ static void ata_scsi_translate(struct ata_port *ap, struct ata_device *dev,
if (!qc) if (!qc)
return; return;
qc->flags |= ATA_QCFLAG_SG; /* data is present; dma-map it */ if (cmd->sc_data_direction == SCSI_DATA_READ ||
cmd->sc_data_direction == SCSI_DATA_WRITE)
qc->flags |= ATA_QCFLAG_SG; /* data is present; dma-map it */
if (ata_scsi_rw_xlat(qc, scsicmd)) if (xlat_func(qc, scsicmd))
goto err_out; goto err_out;
/* select device, send command to hardware */ /* select device, send command to hardware */
...@@ -1014,17 +1017,17 @@ ata_scsi_find_dev(struct ata_port *ap, struct scsi_cmnd *cmd) ...@@ -1014,17 +1017,17 @@ ata_scsi_find_dev(struct ata_port *ap, struct scsi_cmnd *cmd)
} }
/** /**
* ata_scsi_xlat_possible - check if SCSI to ATA translation is possible * ata_get_xlat_func - check if SCSI to ATA translation is possible
* @cmd: SCSI command opcode to consider * @cmd: SCSI command opcode to consider
* *
* Look up the SCSI command given, and determine whether the * Look up the SCSI command given, and determine whether the
* SCSI command is to be translated or simulated. * SCSI command is to be translated or simulated.
* *
* RETURNS: * RETURNS:
* Non-zero if possible, zero if not. * Pointer to translation function if possible, %NULL if not.
*/ */
static inline int ata_scsi_xlat_possible(u8 cmd) static inline ata_xlat_func_t ata_get_xlat_func(u8 cmd)
{ {
switch (cmd) { switch (cmd) {
case READ_6: case READ_6:
...@@ -1034,10 +1037,10 @@ static inline int ata_scsi_xlat_possible(u8 cmd) ...@@ -1034,10 +1037,10 @@ static inline int ata_scsi_xlat_possible(u8 cmd)
case WRITE_6: case WRITE_6:
case WRITE_10: case WRITE_10:
case WRITE_16: case WRITE_16:
return 1; return ata_scsi_rw_xlat;
} }
return 0; return NULL;
} }
/** /**
...@@ -1099,8 +1102,10 @@ int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)) ...@@ -1099,8 +1102,10 @@ int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))
} }
if (dev->class == ATA_DEV_ATA) { if (dev->class == ATA_DEV_ATA) {
if (ata_scsi_xlat_possible(cmd->cmnd[0])) ata_xlat_func_t xlat_func = ata_get_xlat_func(cmd->cmnd[0]);
ata_scsi_translate(ap, dev, cmd, done);
if (xlat_func)
ata_scsi_translate(ap, dev, cmd, done, xlat_func);
else else
ata_scsi_simulate(ap, dev, cmd, done); ata_scsi_simulate(ap, dev, cmd, done);
} else } else
......
...@@ -1180,14 +1180,14 @@ static void pdc_dma_start(struct ata_queued_cmd *qc) ...@@ -1180,14 +1180,14 @@ static void pdc_dma_start(struct ata_queued_cmd *qc)
static void pdc_tf_load_mmio(struct ata_port *ap, struct ata_taskfile *tf) static void pdc_tf_load_mmio(struct ata_port *ap, struct ata_taskfile *tf)
{ {
if (tf->protocol != ATA_PROT_DMA) if (tf->protocol == ATA_PROT_PIO)
ata_tf_load_mmio(ap, tf); ata_tf_load_mmio(ap, tf);
} }
static void pdc_exec_command_mmio(struct ata_port *ap, struct ata_taskfile *tf) static void pdc_exec_command_mmio(struct ata_port *ap, struct ata_taskfile *tf)
{ {
if (tf->protocol != ATA_PROT_DMA) if (tf->protocol == ATA_PROT_PIO)
ata_exec_command_mmio(ap, tf); ata_exec_command_mmio(ap, tf);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment