Commit 63a2ea09 authored by Jeff Garzik's avatar Jeff Garzik

[libata] random minor bug fixes

* Only call ata_sg_setup{_one} if ATA_QCFLAG_SG is set.  Preparation
  for future use, as currently ATA_QCFLAG_SG is always set when
  ata_qc_issue is called.

  This change in theory is incorrect for Promise TX/SX4 drivers,
  since those drivers set up the Promise-specific packet in their
  ->fill_sg hook, which is now called conditionally.

  A FIXME that doesn't affect anything, for now.

* ATA_PROT_ATAPI and ATA_PROT_ATAPI_DMA command issue need to be
  differentiated.

* Create and use ata_qc_set_polling() to consistently set/clear the
  flags associated with using polling instead of interrupts.
parent 2e0b0572
...@@ -2396,16 +2396,18 @@ int ata_qc_issue(struct ata_queued_cmd *qc) ...@@ -2396,16 +2396,18 @@ int ata_qc_issue(struct ata_queued_cmd *qc)
struct ata_port *ap = qc->ap; struct ata_port *ap = qc->ap;
struct scsi_cmnd *cmd = qc->scsicmd; struct scsi_cmnd *cmd = qc->scsicmd;
/* set up SG table */ if (qc->flags & ATA_QCFLAG_SG) {
if (cmd->use_sg) { /* set up SG table */
if (ata_sg_setup(qc)) if (cmd->use_sg) {
goto err_out; if (ata_sg_setup(qc))
} else { goto err_out;
if (ata_sg_setup_one(qc)) } else {
goto err_out; if (ata_sg_setup_one(qc))
} goto err_out;
}
ap->ops->fill_sg(qc); ap->ops->fill_sg(qc);
}
qc->ap->active_tag = qc->tag; qc->ap->active_tag = qc->tag;
qc->flags |= ATA_QCFLAG_ACTIVE; qc->flags |= ATA_QCFLAG_ACTIVE;
...@@ -2450,14 +2452,17 @@ static int ata_qc_issue_prot(struct ata_queued_cmd *qc) ...@@ -2450,14 +2452,17 @@ static int ata_qc_issue_prot(struct ata_queued_cmd *qc)
break; break;
case ATA_PROT_PIO: /* load tf registers, initiate polling pio */ case ATA_PROT_PIO: /* load tf registers, initiate polling pio */
qc->flags |= ATA_QCFLAG_POLL; ata_qc_set_polling(qc);
qc->tf.ctl |= ATA_NIEN; /* disable interrupts */
ata_tf_to_host_nolock(ap, &qc->tf); ata_tf_to_host_nolock(ap, &qc->tf);
ap->pio_task_state = PIO_ST; ap->pio_task_state = PIO_ST;
queue_work(ata_wq, &ap->pio_task); queue_work(ata_wq, &ap->pio_task);
break; break;
case ATA_PROT_ATAPI: case ATA_PROT_ATAPI:
ata_tf_to_host_nolock(ap, &qc->tf);
queue_work(ata_wq, &ap->packet_task);
break;
case ATA_PROT_ATAPI_DMA: case ATA_PROT_ATAPI_DMA:
ap->ops->tf_load(ap, &qc->tf); /* load tf registers */ ap->ops->tf_load(ap, &qc->tf); /* load tf registers */
ap->ops->bmdma_setup(qc); /* set up bmdma */ ap->ops->bmdma_setup(qc); /* set up bmdma */
......
...@@ -912,9 +912,8 @@ static unsigned int atapi_xlat(struct ata_queued_cmd *qc, u8 *scsicmd) ...@@ -912,9 +912,8 @@ static unsigned int atapi_xlat(struct ata_queued_cmd *qc, u8 *scsicmd)
if ((cmd->sc_data_direction == SCSI_DATA_NONE) || if ((cmd->sc_data_direction == SCSI_DATA_NONE) ||
((qc->flags & ATA_QCFLAG_DMA) == 0)) { ((qc->flags & ATA_QCFLAG_DMA) == 0)) {
qc->flags |= ATA_QCFLAG_POLL; ata_qc_set_polling(qc);
qc->tf.protocol = ATA_PROT_ATAPI; qc->tf.protocol = ATA_PROT_ATAPI;
qc->tf.ctl |= ATA_NIEN; /* disable interrupts */
qc->tf.lbam = (8 * 1024) & 0xff; qc->tf.lbam = (8 * 1024) & 0xff;
qc->tf.lbah = (8 * 1024) >> 8; qc->tf.lbah = (8 * 1024) >> 8;
} else { } else {
......
...@@ -481,6 +481,13 @@ static inline u8 ata_wait_idle(struct ata_port *ap) ...@@ -481,6 +481,13 @@ static inline u8 ata_wait_idle(struct ata_port *ap)
return status; return status;
} }
static inline void ata_qc_set_polling(struct ata_queued_cmd *qc)
{
qc->flags |= ATA_QCFLAG_POLL;
qc->flags &= ~ATA_QCFLAG_DMA;
qc->tf.ctl |= ATA_NIEN;
}
static inline struct ata_queued_cmd *ata_qc_from_tag (struct ata_port *ap, static inline struct ata_queued_cmd *ata_qc_from_tag (struct ata_port *ap,
unsigned int tag) unsigned int tag)
{ {
......
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