Commit 5017077e authored by Jeff Garzik's avatar Jeff Garzik

[libata] move ATAPI command initiation code from libata-scsi to libata-core

parent d27a0b0f
...@@ -2767,6 +2767,59 @@ static unsigned long ata_thread_iter(struct ata_port *ap) ...@@ -2767,6 +2767,59 @@ static unsigned long ata_thread_iter(struct ata_port *ap)
return timeout; return timeout;
} }
void atapi_start(struct ata_queued_cmd *qc)
{
struct ata_port *ap = qc->ap;
struct ata_device *dev = qc->dev;
struct scsi_cmnd *cmd = qc->scsicmd;
u8 status;
int doing_dma;
doing_dma = (qc->tf.protocol == ATA_PROT_ATAPI_DMA);
if (cmd->sc_data_direction == SCSI_DATA_NONE) {
ap->active_tag = qc->tag;
qc->flags |= ATA_QCFLAG_ACTIVE | ATA_QCFLAG_POLL;
ata_dev_select(ap, dev->devno, 1, 0);
DPRINTK("direction: none\n");
qc->tf.ctl |= ATA_NIEN; /* disable interrupts */
ata_tf_to_host_nolock(ap, &qc->tf);
} else {
qc->flags |= ATA_QCFLAG_SG; /* data is present; dma-map it */
qc->tf.feature = ATAPI_PKT_DMA;
/* select device, send command to hardware */
if (ata_qc_issue(qc))
goto err_out;
}
status = ata_busy_wait(ap, ATA_BUSY, 1000);
if (status & ATA_BUSY) {
queue_work(ata_wq, &ap->packet_task);
return;
}
if ((status & ATA_DRQ) == 0)
goto err_out;
/* FIXME: mmio-ize */
DPRINTK("writing cdb\n");
outsl(ap->ioaddr.data_addr, cmd->cmnd, ap->host->max_cmd_len / 4);
if (!doing_dma)
queue_work(ata_wq, &ap->packet_task);
VPRINTK("EXIT\n");
return;
err_out:
if (!doing_dma)
ata_irq_on(ap); /* re-enable interrupts */
ata_bad_cdb(cmd, qc->scsidone);
DPRINTK("EXIT - badcmd\n");
}
/** /**
* atapi_packet_task - Write CDB bytes to hardware * atapi_packet_task - Write CDB bytes to hardware
* @_data: Port to which ATAPI device is attached. * @_data: Port to which ATAPI device is attached.
......
...@@ -885,8 +885,7 @@ static void atapi_scsi_queuecmd(struct ata_port *ap, struct ata_device *dev, ...@@ -885,8 +885,7 @@ static void atapi_scsi_queuecmd(struct ata_port *ap, struct ata_device *dev,
struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)) struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))
{ {
struct ata_queued_cmd *qc; struct ata_queued_cmd *qc;
u8 *scsicmd = cmd->cmnd, status; u8 *scsicmd = cmd->cmnd;
unsigned int doing_dma = 0;
VPRINTK("ENTER, drv_stat = 0x%x\n", ata_chk_status(ap)); VPRINTK("ENTER, drv_stat = 0x%x\n", ata_chk_status(ap));
...@@ -925,53 +924,12 @@ static void atapi_scsi_queuecmd(struct ata_port *ap, struct ata_device *dev, ...@@ -925,53 +924,12 @@ static void atapi_scsi_queuecmd(struct ata_port *ap, struct ata_device *dev,
} }
qc->tf.command = ATA_CMD_PACKET; qc->tf.command = ATA_CMD_PACKET;
if (cmd->sc_data_direction == SCSI_DATA_NONE)
/* set up SG table */
if (cmd->sc_data_direction == SCSI_DATA_NONE) {
ap->active_tag = qc->tag;
qc->flags |= ATA_QCFLAG_ACTIVE | ATA_QCFLAG_POLL;
qc->tf.protocol = ATA_PROT_ATAPI; qc->tf.protocol = ATA_PROT_ATAPI;
else
ata_dev_select(ap, dev->devno, 1, 0);
DPRINTK("direction: none\n");
qc->tf.ctl |= ATA_NIEN; /* disable interrupts */
ata_tf_to_host_nolock(ap, &qc->tf);
} else {
qc->flags |= ATA_QCFLAG_SG; /* data is present; dma-map it */
qc->tf.feature = ATAPI_PKT_DMA;
qc->tf.protocol = ATA_PROT_ATAPI_DMA; qc->tf.protocol = ATA_PROT_ATAPI_DMA;
doing_dma = 1; atapi_start(qc);
/* select device, send command to hardware */
if (ata_qc_issue(qc))
goto err_out;
}
status = ata_busy_wait(ap, ATA_BUSY, 1000);
if (status & ATA_BUSY) {
queue_work(ata_wq, &ap->packet_task);
return;
}
if ((status & ATA_DRQ) == 0)
goto err_out;
/* FIXME: mmio-ize */
DPRINTK("writing cdb\n");
outsl(ap->ioaddr.data_addr, scsicmd, ap->host->max_cmd_len / 4);
if (!doing_dma)
queue_work(ata_wq, &ap->packet_task);
VPRINTK("EXIT\n");
return;
err_out:
if (!doing_dma)
ata_irq_on(ap); /* re-enable interrupts */
ata_bad_cdb(cmd, done);
DPRINTK("EXIT - badcmd\n");
} }
/** /**
......
...@@ -46,6 +46,7 @@ extern int ata_qc_issue(struct ata_queued_cmd *qc); ...@@ -46,6 +46,7 @@ extern int ata_qc_issue(struct ata_queued_cmd *qc);
extern void ata_dev_select(struct ata_port *ap, unsigned int device, extern void ata_dev_select(struct ata_port *ap, unsigned int device,
unsigned int wait, unsigned int can_sleep); unsigned int wait, unsigned int can_sleep);
extern void ata_tf_to_host_nolock(struct ata_port *ap, struct ata_taskfile *tf); extern void ata_tf_to_host_nolock(struct ata_port *ap, struct ata_taskfile *tf);
extern void atapi_start(struct ata_queued_cmd *qc);
/* libata-scsi.c */ /* libata-scsi.c */
......
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