sata_mv.c (00b81235aa0368f84c0e704bec4142cd8c516ad5) sata_mv.c (f48765ccb48a62596b664aa88a2b0f943c12c0e1)
1/*
2 * sata_mv.c - Marvell SATA support
3 *
4 * Copyright 2008: Marvell Corporation, all rights reserved.
5 * Copyright 2005: EMC Corporation, all rights reserved.
6 * Copyright 2005 Red Hat, Inc. All rights reserved.
7 *
8 * Please ALWAYS copy linux-ide@vger.kernel.org on emails.

--- 1551 unchanged lines hidden (view full) ---

1560 * caches of the request producer/consumer indices then enables
1561 * DMA and bumps the request producer index.
1562 *
1563 * LOCKING:
1564 * Inherited from caller.
1565 */
1566static unsigned int mv_qc_issue(struct ata_queued_cmd *qc)
1567{
1/*
2 * sata_mv.c - Marvell SATA support
3 *
4 * Copyright 2008: Marvell Corporation, all rights reserved.
5 * Copyright 2005: EMC Corporation, all rights reserved.
6 * Copyright 2005 Red Hat, Inc. All rights reserved.
7 *
8 * Please ALWAYS copy linux-ide@vger.kernel.org on emails.

--- 1551 unchanged lines hidden (view full) ---

1560 * caches of the request producer/consumer indices then enables
1561 * DMA and bumps the request producer index.
1562 *
1563 * LOCKING:
1564 * Inherited from caller.
1565 */
1566static unsigned int mv_qc_issue(struct ata_queued_cmd *qc)
1567{
1568 static int limit_warnings = 10;
1568 struct ata_port *ap = qc->ap;
1569 void __iomem *port_mmio = mv_ap_base(ap);
1570 struct mv_port_priv *pp = ap->private_data;
1571 u32 in_index;
1569 struct ata_port *ap = qc->ap;
1570 void __iomem *port_mmio = mv_ap_base(ap);
1571 struct mv_port_priv *pp = ap->private_data;
1572 u32 in_index;
1573 unsigned int port_irqs = DONE_IRQ | ERR_IRQ;
1572
1574
1573 if ((qc->tf.protocol != ATA_PROT_DMA) &&
1574 (qc->tf.protocol != ATA_PROT_NCQ)) {
1575 static int limit_warnings = 10;
1575 switch (qc->tf.protocol) {
1576 case ATA_PROT_DMA:
1577 case ATA_PROT_NCQ:
1578 mv_start_edma(ap, port_mmio, pp, qc->tf.protocol);
1579 pp->req_idx = (pp->req_idx + 1) & MV_MAX_Q_DEPTH_MASK;
1580 in_index = pp->req_idx << EDMA_REQ_Q_PTR_SHIFT;
1581
1582 /* Write the request in pointer to kick the EDMA to life */
1583 writelfl((pp->crqb_dma & EDMA_REQ_Q_BASE_LO_MASK) | in_index,
1584 port_mmio + EDMA_REQ_Q_IN_PTR_OFS);
1585 return 0;
1586
1587 case ATA_PROT_PIO:
1576 /*
1577 * Errata SATA#16, SATA#24: warn if multiple DRQs expected.
1578 *
1579 * Someday, we might implement special polling workarounds
1580 * for these, but it all seems rather unnecessary since we
1581 * normally use only DMA for commands which transfer more
1582 * than a single block of data.
1583 *
1584 * Much of the time, this could just work regardless.
1585 * So for now, just log the incident, and allow the attempt.
1586 */
1587 if (limit_warnings > 0 && (qc->nbytes / qc->sect_size) > 1) {
1588 --limit_warnings;
1589 ata_link_printk(qc->dev->link, KERN_WARNING, DRV_NAME
1590 ": attempting PIO w/multiple DRQ: "
1591 "this may fail due to h/w errata\n");
1592 }
1588 /*
1589 * Errata SATA#16, SATA#24: warn if multiple DRQs expected.
1590 *
1591 * Someday, we might implement special polling workarounds
1592 * for these, but it all seems rather unnecessary since we
1593 * normally use only DMA for commands which transfer more
1594 * than a single block of data.
1595 *
1596 * Much of the time, this could just work regardless.
1597 * So for now, just log the incident, and allow the attempt.
1598 */
1599 if (limit_warnings > 0 && (qc->nbytes / qc->sect_size) > 1) {
1600 --limit_warnings;
1601 ata_link_printk(qc->dev->link, KERN_WARNING, DRV_NAME
1602 ": attempting PIO w/multiple DRQ: "
1603 "this may fail due to h/w errata\n");
1604 }
1605 /* drop through */
1606 case ATAPI_PROT_PIO:
1607 port_irqs = ERR_IRQ; /* leave DONE_IRQ masked for PIO */
1608 /* drop through */
1609 default:
1593 /*
1594 * We're about to send a non-EDMA capable command to the
1595 * port. Turn off EDMA so there won't be problems accessing
1596 * shadow block, etc registers.
1597 */
1598 mv_stop_edma(ap);
1610 /*
1611 * We're about to send a non-EDMA capable command to the
1612 * port. Turn off EDMA so there won't be problems accessing
1613 * shadow block, etc registers.
1614 */
1615 mv_stop_edma(ap);
1599 mv_enable_port_irqs(ap, ERR_IRQ);
1616 mv_edma_cfg(ap, 0, 0);
1617 mv_clear_and_enable_port_irqs(ap, mv_ap_base(ap), port_irqs);
1600 mv_pmp_select(ap, qc->dev->link->pmp);
1601 return ata_sff_qc_issue(qc);
1602 }
1618 mv_pmp_select(ap, qc->dev->link->pmp);
1619 return ata_sff_qc_issue(qc);
1620 }
1603
1604 mv_start_edma(ap, port_mmio, pp, qc->tf.protocol);
1605
1606 pp->req_idx = (pp->req_idx + 1) & MV_MAX_Q_DEPTH_MASK;
1607 in_index = pp->req_idx << EDMA_REQ_Q_PTR_SHIFT;
1608
1609 /* and write the request in pointer to kick the EDMA to life */
1610 writelfl((pp->crqb_dma & EDMA_REQ_Q_BASE_LO_MASK) | in_index,
1611 port_mmio + EDMA_REQ_Q_IN_PTR_OFS);
1612
1613 return 0;
1614}
1615
1616static struct ata_queued_cmd *mv_get_active_qc(struct ata_port *ap)
1617{
1618 struct mv_port_priv *pp = ap->private_data;
1619 struct ata_queued_cmd *qc;
1620
1621 if (pp->pp_flags & MV_PP_FLAG_NCQ_EN)

--- 1869 unchanged lines hidden ---
1621}
1622
1623static struct ata_queued_cmd *mv_get_active_qc(struct ata_port *ap)
1624{
1625 struct mv_port_priv *pp = ap->private_data;
1626 struct ata_queued_cmd *qc;
1627
1628 if (pp->pp_flags & MV_PP_FLAG_NCQ_EN)

--- 1869 unchanged lines hidden ---