Commit da13ce37 authored by Jeff Garzik's avatar Jeff Garzik

Merge pobox.com:/spare/repo/libata-2.6

into pobox.com:/spare/repo/sata-hacks/qc-xfermode
parents 0c558ca1 fb916546
...@@ -57,6 +57,7 @@ static int fgb(u32 bitmap); ...@@ -57,6 +57,7 @@ static int fgb(u32 bitmap);
static int ata_choose_xfer_mode(struct ata_port *ap, static int ata_choose_xfer_mode(struct ata_port *ap,
u8 *xfer_mode_out, u8 *xfer_mode_out,
unsigned int *xfer_shift_out); unsigned int *xfer_shift_out);
static int ata_qc_complete_noop(struct ata_queued_cmd *qc, u8 drv_stat);
static unsigned int ata_unique_id = 1; static unsigned int ata_unique_id = 1;
static struct workqueue_struct *ata_wq; static struct workqueue_struct *ata_wq;
...@@ -1760,30 +1761,34 @@ static int ata_choose_xfer_mode(struct ata_port *ap, ...@@ -1760,30 +1761,34 @@ static int ata_choose_xfer_mode(struct ata_port *ap,
static void ata_dev_set_xfermode(struct ata_port *ap, struct ata_device *dev) static void ata_dev_set_xfermode(struct ata_port *ap, struct ata_device *dev)
{ {
struct ata_taskfile tf; DECLARE_COMPLETION(wait);
struct ata_queued_cmd *qc;
int rc;
unsigned long flags;
/* set up set-features taskfile */ /* set up set-features taskfile */
DPRINTK("set features - xfer mode\n"); DPRINTK("set features - xfer mode\n");
ata_tf_init(ap, &tf, dev->devno);
tf.ctl |= ATA_NIEN;
tf.command = ATA_CMD_SET_FEATURES;
tf.feature = SETFEATURES_XFER;
tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE;
tf.protocol = ATA_PROT_NODATA;
tf.nsect = dev->xfer_mode;
/* do bus reset */ qc = ata_qc_new_init(ap, dev);
ata_tf_to_host(ap, &tf); BUG_ON(qc == NULL);
/* crazy ATAPI devices... */
if (dev->class == ATA_DEV_ATAPI)
msleep(150);
ata_busy_sleep(ap, ATA_TMOUT_BOOT_QUICK, ATA_TMOUT_BOOT); qc->tf.command = ATA_CMD_SET_FEATURES;
qc->tf.feature = SETFEATURES_XFER;
qc->tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE;
qc->tf.protocol = ATA_PROT_NODATA;
qc->tf.nsect = dev->xfer_mode;
qc->waiting = &wait;
qc->complete_fn = ata_qc_complete_noop;
ata_irq_on(ap); /* re-enable interrupts */ spin_lock_irqsave(&ap->host_set->lock, flags);
rc = ata_qc_issue(qc);
spin_unlock_irqrestore(&ap->host_set->lock, flags);
ata_wait_idle(ap); if (rc)
ata_port_disable(ap);
else
wait_for_completion(&wait);
DPRINTK("EXIT\n"); DPRINTK("EXIT\n");
} }
...@@ -2342,6 +2347,11 @@ struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap, ...@@ -2342,6 +2347,11 @@ struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap,
return qc; return qc;
} }
static int ata_qc_complete_noop(struct ata_queued_cmd *qc, u8 drv_stat)
{
return 0;
}
/** /**
* ata_qc_complete - Complete an active ATA command * ata_qc_complete - Complete an active ATA command
* @qc: Command to complete * @qc: Command to complete
......
...@@ -74,7 +74,6 @@ struct pdc_port_priv { ...@@ -74,7 +74,6 @@ struct pdc_port_priv {
static u32 pdc_sata_scr_read (struct ata_port *ap, unsigned int sc_reg); static u32 pdc_sata_scr_read (struct ata_port *ap, unsigned int sc_reg);
static void pdc_sata_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val); static void pdc_sata_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val);
static int pdc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *ent); static int pdc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *ent);
static void pdc_dma_start(struct ata_queued_cmd *qc);
static irqreturn_t pdc_interrupt (int irq, void *dev_instance, struct pt_regs *regs); static irqreturn_t pdc_interrupt (int irq, void *dev_instance, struct pt_regs *regs);
static void pdc_eng_timeout(struct ata_port *ap); static void pdc_eng_timeout(struct ata_port *ap);
static int pdc_port_start(struct ata_port *ap); static int pdc_port_start(struct ata_port *ap);
...@@ -83,8 +82,6 @@ static void pdc_phy_reset(struct ata_port *ap); ...@@ -83,8 +82,6 @@ static void pdc_phy_reset(struct ata_port *ap);
static void pdc_qc_prep(struct ata_queued_cmd *qc); static void pdc_qc_prep(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);
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);
static inline void pdc_dma_complete (struct ata_port *ap,
struct ata_queued_cmd *qc, int have_err);
static void pdc_irq_clear(struct ata_port *ap); static void pdc_irq_clear(struct ata_port *ap);
static int pdc_qc_issue_prot(struct ata_queued_cmd *qc); static int pdc_qc_issue_prot(struct ata_queued_cmd *qc);
...@@ -271,26 +268,26 @@ static void pdc_qc_prep(struct ata_queued_cmd *qc) ...@@ -271,26 +268,26 @@ static void pdc_qc_prep(struct ata_queued_cmd *qc)
VPRINTK("ENTER\n"); VPRINTK("ENTER\n");
ata_qc_prep(qc); switch (qc->tf.protocol) {
case ATA_PROT_DMA:
i = pdc_pkt_header(&qc->tf, qc->ap->prd_dma, qc->dev->devno, pp->pkt); ata_qc_prep(qc);
/* fall through */
if (qc->tf.flags & ATA_TFLAG_LBA48) case ATA_PROT_NODATA:
i = pdc_prep_lba48(&qc->tf, pp->pkt, i); i = pdc_pkt_header(&qc->tf, qc->ap->prd_dma,
else qc->dev->devno, pp->pkt);
i = pdc_prep_lba28(&qc->tf, pp->pkt, i);
pdc_pkt_footer(&qc->tf, pp->pkt, i); if (qc->tf.flags & ATA_TFLAG_LBA48)
} i = pdc_prep_lba48(&qc->tf, pp->pkt, i);
else
i = pdc_prep_lba28(&qc->tf, pp->pkt, i);
static inline void pdc_dma_complete (struct ata_port *ap, pdc_pkt_footer(&qc->tf, pp->pkt, i);
struct ata_queued_cmd *qc, break;
int have_err)
{
u8 err_bit = have_err ? ATA_ERR : 0;
/* get drive status; clear intr; complete txn */ default:
ata_qc_complete(qc, ata_wait_idle(ap) | err_bit); break;
}
} }
static void pdc_eng_timeout(struct ata_port *ap) static void pdc_eng_timeout(struct ata_port *ap)
...@@ -317,17 +314,9 @@ static void pdc_eng_timeout(struct ata_port *ap) ...@@ -317,17 +314,9 @@ static void pdc_eng_timeout(struct ata_port *ap)
switch (qc->tf.protocol) { switch (qc->tf.protocol) {
case ATA_PROT_DMA: case ATA_PROT_DMA:
printk(KERN_ERR "ata%u: DMA timeout\n", ap->id);
ata_qc_complete(qc, ata_wait_idle(ap) | ATA_ERR);
break;
case ATA_PROT_NODATA: case ATA_PROT_NODATA:
drv_stat = ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 1000); printk(KERN_ERR "ata%u: command timeout\n", ap->id);
ata_qc_complete(qc, ata_wait_idle(ap) | ATA_ERR);
printk(KERN_ERR "ata%u: command 0x%x timeout, stat 0x%x\n",
ap->id, qc->tf.command, drv_stat);
ata_qc_complete(qc, drv_stat);
break; break;
default: default:
...@@ -360,13 +349,8 @@ static inline unsigned int pdc_host_intr( struct ata_port *ap, ...@@ -360,13 +349,8 @@ static inline unsigned int pdc_host_intr( struct ata_port *ap,
switch (qc->tf.protocol) { switch (qc->tf.protocol) {
case ATA_PROT_DMA: case ATA_PROT_DMA:
pdc_dma_complete(ap, qc, have_err); case ATA_PROT_NODATA:
handled = 1; status = ata_wait_idle(ap);
break;
case ATA_PROT_NODATA: /* command completion, but no data xfer */
status = ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 1000);
DPRINTK("BUS_NODATA (drv_stat 0x%X)\n", status);
if (have_err) if (have_err)
status |= ATA_ERR; status |= ATA_ERR;
ata_qc_complete(qc, status); ata_qc_complete(qc, status);
...@@ -442,7 +426,7 @@ static irqreturn_t pdc_interrupt (int irq, void *dev_instance, struct pt_regs *r ...@@ -442,7 +426,7 @@ static irqreturn_t pdc_interrupt (int irq, void *dev_instance, struct pt_regs *r
return IRQ_RETVAL(handled); return IRQ_RETVAL(handled);
} }
static inline void pdc_dma_start(struct ata_queued_cmd *qc) static inline void pdc_packet_start(struct ata_queued_cmd *qc)
{ {
struct ata_port *ap = qc->ap; struct ata_port *ap = qc->ap;
struct pdc_port_priv *pp = ap->private_data; struct pdc_port_priv *pp = ap->private_data;
...@@ -464,7 +448,8 @@ static int pdc_qc_issue_prot(struct ata_queued_cmd *qc) ...@@ -464,7 +448,8 @@ static int pdc_qc_issue_prot(struct ata_queued_cmd *qc)
{ {
switch (qc->tf.protocol) { switch (qc->tf.protocol) {
case ATA_PROT_DMA: case ATA_PROT_DMA:
pdc_dma_start(qc); case ATA_PROT_NODATA:
pdc_packet_start(qc);
return 0; return 0;
case ATA_PROT_ATAPI_DMA: case ATA_PROT_ATAPI_DMA:
...@@ -480,14 +465,16 @@ static int pdc_qc_issue_prot(struct ata_queued_cmd *qc) ...@@ -480,14 +465,16 @@ static int pdc_qc_issue_prot(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)
{ {
WARN_ON (tf->protocol == ATA_PROT_DMA); WARN_ON (tf->protocol == ATA_PROT_DMA ||
tf->protocol == ATA_PROT_NODATA);
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)
{ {
WARN_ON (tf->protocol == ATA_PROT_DMA); WARN_ON (tf->protocol == ATA_PROT_DMA ||
tf->protocol == ATA_PROT_NODATA);
ata_exec_command_mmio(ap, tf); ata_exec_command_mmio(ap, tf);
} }
...@@ -541,8 +528,7 @@ static void pdc_host_init(unsigned int chip_id, struct ata_probe_ent *pe) ...@@ -541,8 +528,7 @@ static void pdc_host_init(unsigned int chip_id, struct ata_probe_ent *pe)
writel(tmp, mmio + PDC_TBG_MODE); writel(tmp, mmio + PDC_TBG_MODE);
readl(mmio + PDC_TBG_MODE); /* flush */ readl(mmio + PDC_TBG_MODE); /* flush */
set_current_state(TASK_UNINTERRUPTIBLE); msleep(10);
schedule_timeout(msecs_to_jiffies(10) + 1);
/* adjust slew rate control register. */ /* adjust slew rate control register. */
tmp = readl(mmio + PDC_SLEW_CTL); tmp = readl(mmio + PDC_SLEW_CTL);
......
...@@ -146,8 +146,6 @@ struct pdc_host_priv { ...@@ -146,8 +146,6 @@ struct pdc_host_priv {
static int pdc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *ent); static int pdc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *ent);
static void pdc20621_dma_setup(struct ata_queued_cmd *qc);
static void pdc20621_dma_start(struct ata_queued_cmd *qc);
static irqreturn_t pdc20621_interrupt (int irq, void *dev_instance, struct pt_regs *regs); static irqreturn_t pdc20621_interrupt (int irq, void *dev_instance, struct pt_regs *regs);
static void pdc_eng_timeout(struct ata_port *ap); static void pdc_eng_timeout(struct ata_port *ap);
static void pdc_20621_phy_reset (struct ata_port *ap); static void pdc_20621_phy_reset (struct ata_port *ap);
...@@ -157,8 +155,6 @@ static void pdc20621_qc_prep(struct ata_queued_cmd *qc); ...@@ -157,8 +155,6 @@ static void pdc20621_qc_prep(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);
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);
static void pdc20621_host_stop(struct ata_host_set *host_set); static void pdc20621_host_stop(struct ata_host_set *host_set);
static inline void pdc_dma_complete (struct ata_port *ap,
struct ata_queued_cmd *qc, int have_err);
static unsigned int pdc20621_dimm_init(struct ata_probe_ent *pe); static unsigned int pdc20621_dimm_init(struct ata_probe_ent *pe);
static int pdc20621_detect_dimm(struct ata_probe_ent *pe); static int pdc20621_detect_dimm(struct ata_probe_ent *pe);
static unsigned int pdc20621_i2c_read(struct ata_probe_ent *pe, static unsigned int pdc20621_i2c_read(struct ata_probe_ent *pe,
...@@ -172,6 +168,7 @@ static void pdc20621_get_from_dimm(struct ata_probe_ent *pe, ...@@ -172,6 +168,7 @@ static void pdc20621_get_from_dimm(struct ata_probe_ent *pe,
static void pdc20621_put_to_dimm(struct ata_probe_ent *pe, static void pdc20621_put_to_dimm(struct ata_probe_ent *pe,
void *psource, u32 offset, u32 size); void *psource, u32 offset, u32 size);
static void pdc20621_irq_clear(struct ata_port *ap); static void pdc20621_irq_clear(struct ata_port *ap);
static int pdc20621_qc_issue_prot(struct ata_queued_cmd *qc);
static Scsi_Host_Template pdc_sata_sht = { static Scsi_Host_Template pdc_sata_sht = {
...@@ -199,10 +196,8 @@ static struct ata_port_operations pdc_20621_ops = { ...@@ -199,10 +196,8 @@ static struct ata_port_operations pdc_20621_ops = {
.check_status = ata_check_status_mmio, .check_status = ata_check_status_mmio,
.exec_command = pdc_exec_command_mmio, .exec_command = pdc_exec_command_mmio,
.phy_reset = pdc_20621_phy_reset, .phy_reset = pdc_20621_phy_reset,
.bmdma_setup = pdc20621_dma_setup,
.bmdma_start = pdc20621_dma_start,
.qc_prep = pdc20621_qc_prep, .qc_prep = pdc20621_qc_prep,
.qc_issue = ata_qc_issue_prot, .qc_issue = pdc20621_qc_issue_prot,
.eng_timeout = pdc_eng_timeout, .eng_timeout = pdc_eng_timeout,
.irq_handler = pdc20621_interrupt, .irq_handler = pdc20621_interrupt,
.irq_clear = pdc20621_irq_clear, .irq_clear = pdc20621_irq_clear,
...@@ -378,7 +373,10 @@ static inline unsigned int pdc20621_ata_pkt(struct ata_taskfile *tf, ...@@ -378,7 +373,10 @@ static inline unsigned int pdc20621_ata_pkt(struct ata_taskfile *tf,
/* dimm dma S/G, and next-pkt */ /* dimm dma S/G, and next-pkt */
dw = i >> 2; dw = i >> 2;
buf32[dw] = cpu_to_le32(dimm_sg); if (tf->protocol == ATA_PROT_NODATA)
buf32[dw] = 0;
else
buf32[dw] = cpu_to_le32(dimm_sg);
buf32[dw + 1] = 0; buf32[dw + 1] = 0;
i += 8; i += 8;
...@@ -438,7 +436,7 @@ static inline void pdc20621_host_pkt(struct ata_taskfile *tf, u8 *buf, ...@@ -438,7 +436,7 @@ static inline void pdc20621_host_pkt(struct ata_taskfile *tf, u8 *buf,
buf32[dw + 3]); buf32[dw + 3]);
} }
static void pdc20621_qc_prep(struct ata_queued_cmd *qc) static void pdc20621_dma_prep(struct ata_queued_cmd *qc)
{ {
struct scatterlist *sg = qc->sg; struct scatterlist *sg = qc->sg;
struct ata_port *ap = qc->ap; struct ata_port *ap = qc->ap;
...@@ -450,8 +448,7 @@ static void pdc20621_qc_prep(struct ata_queued_cmd *qc) ...@@ -450,8 +448,7 @@ static void pdc20621_qc_prep(struct ata_queued_cmd *qc)
unsigned int i, last, idx, total_len = 0, sgt_len; unsigned int i, last, idx, total_len = 0, sgt_len;
u32 *buf = (u32 *) &pp->dimm_buf[PDC_DIMM_HEADER_SZ]; u32 *buf = (u32 *) &pp->dimm_buf[PDC_DIMM_HEADER_SZ];
if (!(qc->flags & ATA_QCFLAG_DMAMAP)) assert(qc->flags & ATA_QCFLAG_DMAMAP);
return;
VPRINTK("ata%u: ENTER\n", ap->id); VPRINTK("ata%u: ENTER\n", ap->id);
...@@ -502,6 +499,56 @@ static void pdc20621_qc_prep(struct ata_queued_cmd *qc) ...@@ -502,6 +499,56 @@ static void pdc20621_qc_prep(struct ata_queued_cmd *qc)
VPRINTK("ata pkt buf ofs %u, prd size %u, mmio copied\n", i, sgt_len); VPRINTK("ata pkt buf ofs %u, prd size %u, mmio copied\n", i, sgt_len);
} }
static void pdc20621_nodata_prep(struct ata_queued_cmd *qc)
{
struct ata_port *ap = qc->ap;
struct pdc_port_priv *pp = ap->private_data;
void *mmio = ap->host_set->mmio_base;
struct pdc_host_priv *hpriv = ap->host_set->private_data;
void *dimm_mmio = hpriv->dimm_mmio;
unsigned int portno = ap->port_no;
unsigned int i;
VPRINTK("ata%u: ENTER\n", ap->id);
/* hard-code chip #0 */
mmio += PDC_CHIP0_OFS;
i = pdc20621_ata_pkt(&qc->tf, qc->dev->devno, &pp->dimm_buf[0], portno);
if (qc->tf.flags & ATA_TFLAG_LBA48)
i = pdc_prep_lba48(&qc->tf, &pp->dimm_buf[0], i);
else
i = pdc_prep_lba28(&qc->tf, &pp->dimm_buf[0], i);
pdc_pkt_footer(&qc->tf, &pp->dimm_buf[0], i);
/* copy three S/G tables and two packets to DIMM MMIO window */
memcpy_toio(dimm_mmio + (portno * PDC_DIMM_WINDOW_STEP),
&pp->dimm_buf, PDC_DIMM_HEADER_SZ);
/* force host FIFO dump */
writel(0x00000001, mmio + PDC_20621_GENERAL_CTL);
readl(dimm_mmio); /* MMIO PCI posting flush */
VPRINTK("ata pkt buf ofs %u, prd size %u, mmio copied\n", i, sgt_len);
}
static void pdc20621_qc_prep(struct ata_queued_cmd *qc)
{
switch (qc->tf.protocol) {
case ATA_PROT_DMA:
pdc20621_dma_prep(qc);
break;
case ATA_PROT_NODATA:
pdc20621_nodata_prep(qc);
break;
default:
break;
}
}
static void __pdc20621_push_hdma(struct ata_queued_cmd *qc, static void __pdc20621_push_hdma(struct ata_queued_cmd *qc,
unsigned int seq, unsigned int seq,
u32 pkt_ofs) u32 pkt_ofs)
...@@ -577,13 +624,7 @@ static void pdc20621_dump_hdma(struct ata_queued_cmd *qc) ...@@ -577,13 +624,7 @@ static void pdc20621_dump_hdma(struct ata_queued_cmd *qc)
static inline void pdc20621_dump_hdma(struct ata_queued_cmd *qc) { } static inline void pdc20621_dump_hdma(struct ata_queued_cmd *qc) { }
#endif /* ATA_VERBOSE_DEBUG */ #endif /* ATA_VERBOSE_DEBUG */
static void pdc20621_dma_setup(struct ata_queued_cmd *qc) static void pdc20621_packet_start(struct ata_queued_cmd *qc)
{
/* nothing for now. later, we will call standard
* code in libata-core for ATAPI here */
}
static void pdc20621_dma_start(struct ata_queued_cmd *qc)
{ {
struct ata_port *ap = qc->ap; struct ata_port *ap = qc->ap;
struct ata_host_set *host_set = ap->host_set; struct ata_host_set *host_set = ap->host_set;
...@@ -591,24 +632,21 @@ static void pdc20621_dma_start(struct ata_queued_cmd *qc) ...@@ -591,24 +632,21 @@ static void pdc20621_dma_start(struct ata_queued_cmd *qc)
void *mmio = host_set->mmio_base; void *mmio = host_set->mmio_base;
unsigned int rw = (qc->tf.flags & ATA_TFLAG_WRITE); unsigned int rw = (qc->tf.flags & ATA_TFLAG_WRITE);
u8 seq = (u8) (port_no + 1); u8 seq = (u8) (port_no + 1);
unsigned int doing_hdma = 0, port_ofs; unsigned int port_ofs;
/* hard-code chip #0 */ /* hard-code chip #0 */
mmio += PDC_CHIP0_OFS; mmio += PDC_CHIP0_OFS;
VPRINTK("ata%u: ENTER\n", ap->id); VPRINTK("ata%u: ENTER\n", ap->id);
wmb(); /* flush PRD, pkt writes */
port_ofs = PDC_20621_DIMM_BASE + (PDC_DIMM_WINDOW_STEP * port_no); port_ofs = PDC_20621_DIMM_BASE + (PDC_DIMM_WINDOW_STEP * port_no);
/* if writing, we (1) DMA to DIMM, then (2) do ATA command */ /* if writing, we (1) DMA to DIMM, then (2) do ATA command */
if (rw) { if (rw && qc->tf.protocol == ATA_PROT_DMA) {
doing_hdma = 1;
seq += 4; seq += 4;
}
wmb(); /* flush PRD, pkt writes */
if (doing_hdma) {
pdc20621_dump_hdma(qc); pdc20621_dump_hdma(qc);
pdc20621_push_hdma(qc, seq, port_ofs + PDC_DIMM_HOST_PKT); pdc20621_push_hdma(qc, seq, port_ofs + PDC_DIMM_HOST_PKT);
VPRINTK("queued ofs 0x%x (%u), seq %u\n", VPRINTK("queued ofs 0x%x (%u), seq %u\n",
...@@ -629,6 +667,25 @@ static void pdc20621_dma_start(struct ata_queued_cmd *qc) ...@@ -629,6 +667,25 @@ static void pdc20621_dma_start(struct ata_queued_cmd *qc)
} }
} }
static int pdc20621_qc_issue_prot(struct ata_queued_cmd *qc)
{
switch (qc->tf.protocol) {
case ATA_PROT_DMA:
case ATA_PROT_NODATA:
pdc20621_packet_start(qc);
return 0;
case ATA_PROT_ATAPI_DMA:
BUG();
break;
default:
break;
}
return ata_qc_issue_prot(qc);
}
static inline unsigned int pdc20621_host_intr( struct ata_port *ap, static inline unsigned int pdc20621_host_intr( struct ata_port *ap,
struct ata_queued_cmd *qc, struct ata_queued_cmd *qc,
unsigned int doing_hdma, unsigned int doing_hdma,
...@@ -649,7 +706,8 @@ static inline unsigned int pdc20621_host_intr( struct ata_port *ap, ...@@ -649,7 +706,8 @@ static inline unsigned int pdc20621_host_intr( struct ata_port *ap,
if (doing_hdma) { if (doing_hdma) {
VPRINTK("ata%u: read hdma, 0x%x 0x%x\n", ap->id, VPRINTK("ata%u: read hdma, 0x%x 0x%x\n", ap->id,
readl(mmio + 0x104), readl(mmio + PDC_HDMA_CTLSTAT)); readl(mmio + 0x104), readl(mmio + PDC_HDMA_CTLSTAT));
pdc_dma_complete(ap, qc, 0); /* get drive status; clear intr; complete txn */
ata_qc_complete(qc, ata_wait_idle(ap));
pdc20621_pop_hdma(qc); pdc20621_pop_hdma(qc);
} }
...@@ -686,7 +744,8 @@ static inline unsigned int pdc20621_host_intr( struct ata_port *ap, ...@@ -686,7 +744,8 @@ static inline unsigned int pdc20621_host_intr( struct ata_port *ap,
else { else {
VPRINTK("ata%u: write ata, 0x%x 0x%x\n", ap->id, VPRINTK("ata%u: write ata, 0x%x 0x%x\n", ap->id,
readl(mmio + 0x104), readl(mmio + PDC_HDMA_CTLSTAT)); readl(mmio + 0x104), readl(mmio + PDC_HDMA_CTLSTAT));
pdc_dma_complete(ap, qc, 0); /* get drive status; clear intr; complete txn */
ata_qc_complete(qc, ata_wait_idle(ap));
pdc20621_pop_hdma(qc); pdc20621_pop_hdma(qc);
} }
handled = 1; handled = 1;
...@@ -780,16 +839,6 @@ static irqreturn_t pdc20621_interrupt (int irq, void *dev_instance, struct pt_re ...@@ -780,16 +839,6 @@ static irqreturn_t pdc20621_interrupt (int irq, void *dev_instance, struct pt_re
return IRQ_RETVAL(handled); return IRQ_RETVAL(handled);
} }
static inline void pdc_dma_complete (struct ata_port *ap,
struct ata_queued_cmd *qc,
int have_err)
{
u8 err_bit = have_err ? ATA_ERR : 0;
/* get drive status; clear intr; complete txn */
ata_qc_complete(qc, ata_wait_idle(ap) | err_bit);
}
static void pdc_eng_timeout(struct ata_port *ap) static void pdc_eng_timeout(struct ata_port *ap)
{ {
u8 drv_stat; u8 drv_stat;
...@@ -814,17 +863,9 @@ static void pdc_eng_timeout(struct ata_port *ap) ...@@ -814,17 +863,9 @@ static void pdc_eng_timeout(struct ata_port *ap)
switch (qc->tf.protocol) { switch (qc->tf.protocol) {
case ATA_PROT_DMA: case ATA_PROT_DMA:
printk(KERN_ERR "ata%u: DMA timeout\n", ap->id);
ata_qc_complete(qc, ata_wait_idle(ap) | ATA_ERR);
break;
case ATA_PROT_NODATA: case ATA_PROT_NODATA:
drv_stat = ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 1000); printk(KERN_ERR "ata%u: command timeout\n", ap->id);
ata_qc_complete(qc, ata_wait_idle(ap) | ATA_ERR);
printk(KERN_ERR "ata%u: command 0x%x timeout, stat 0x%x\n",
ap->id, qc->tf.command, drv_stat);
ata_qc_complete(qc, drv_stat);
break; break;
default: default:
...@@ -843,15 +884,17 @@ static void pdc_eng_timeout(struct ata_port *ap) ...@@ -843,15 +884,17 @@ static void pdc_eng_timeout(struct ata_port *ap)
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) WARN_ON (tf->protocol == ATA_PROT_DMA ||
ata_tf_load_mmio(ap, tf); tf->protocol == ATA_PROT_NODATA);
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) WARN_ON (tf->protocol == ATA_PROT_DMA ||
ata_exec_command_mmio(ap, tf); tf->protocol == ATA_PROT_NODATA);
ata_exec_command_mmio(ap, tf);
} }
...@@ -1396,21 +1439,11 @@ static int pdc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id * ...@@ -1396,21 +1439,11 @@ static int pdc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *
probe_ent->private_data = hpriv; probe_ent->private_data = hpriv;
base += PDC_CHIP0_OFS; base += PDC_CHIP0_OFS;
probe_ent->n_ports = 4;
pdc_sata_setup_port(&probe_ent->port[0], base + 0x200); pdc_sata_setup_port(&probe_ent->port[0], base + 0x200);
pdc_sata_setup_port(&probe_ent->port[1], base + 0x280); pdc_sata_setup_port(&probe_ent->port[1], base + 0x280);
pdc_sata_setup_port(&probe_ent->port[2], base + 0x300);
/* notice 4-port boards */ pdc_sata_setup_port(&probe_ent->port[3], base + 0x380);
switch (board_idx) {
case board_20621:
probe_ent->n_ports = 4;
pdc_sata_setup_port(&probe_ent->port[2], base + 0x300);
pdc_sata_setup_port(&probe_ent->port[3], base + 0x380);
break;
default:
BUG();
break;
}
pci_set_master(pdev); pci_set_master(pdev);
......
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