aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata/libata-sff.c
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2010-05-10 15:41:42 -0400
committerJeff Garzik <jgarzik@redhat.com>2010-05-19 13:38:55 -0400
commit360ff7833098e944e5003618b03894251e937802 (patch)
treeaaa8c8f771cf35b2a0dab58ea6bad35d88f4ac8a /drivers/ata/libata-sff.c
parentf60d70113fa04e32aee2dedbf304a48469c9c45c (diff)
libata-sff: separate out BMDMA qc_issue
Separate out ata_bmdma_qc_issue() from ata_sff_qc_issue() such that ata_sff_qc_issue() only deals with non-BMDMA SFF protocols (PIO and nodata) while ata_bmdma_qc_issue() deals with the BMDMA protocols and uses ata_sff_qc_issue() for non-DMA commands. All the users are updated accordingly. Signed-off-by: Tejun Heo <tj@kernel.org> Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers/ata/libata-sff.c')
-rw-r--r--drivers/ata/libata-sff.c112
1 files changed, 67 insertions, 45 deletions
diff --git a/drivers/ata/libata-sff.c b/drivers/ata/libata-sff.c
index 6f52b598b8d2..19ddf924944f 100644
--- a/drivers/ata/libata-sff.c
+++ b/drivers/ata/libata-sff.c
@@ -1379,15 +1379,11 @@ fsm_start:
1379} 1379}
1380 1380
1381/** 1381/**
1382 * ata_sff_qc_issue - issue taskfile to device in proto-dependent manner 1382 * ata_sff_qc_issue - issue taskfile to a SFF controller
1383 * @qc: command to issue to device 1383 * @qc: command to issue to device
1384 * 1384 *
1385 * Using various libata functions and hooks, this function 1385 * This function issues a PIO or NODATA command to a SFF
1386 * starts an ATA command. ATA commands are grouped into 1386 * controller.
1387 * classes called "protocols", and issuing each type of protocol
1388 * is slightly different.
1389 *
1390 * May be used as the qc_issue() entry in ata_port_operations.
1391 * 1387 *
1392 * LOCKING: 1388 * LOCKING:
1393 * spin_lock_irqsave(host lock) 1389 * spin_lock_irqsave(host lock)
@@ -1402,23 +1398,8 @@ unsigned int ata_sff_qc_issue(struct ata_queued_cmd *qc)
1402 /* Use polling pio if the LLD doesn't handle 1398 /* Use polling pio if the LLD doesn't handle
1403 * interrupt driven pio and atapi CDB interrupt. 1399 * interrupt driven pio and atapi CDB interrupt.
1404 */ 1400 */
1405 if (ap->flags & ATA_FLAG_PIO_POLLING) { 1401 if (ap->flags & ATA_FLAG_PIO_POLLING)
1406 switch (qc->tf.protocol) { 1402 qc->tf.flags |= ATA_TFLAG_POLLING;
1407 case ATA_PROT_PIO:
1408 case ATA_PROT_NODATA:
1409 case ATAPI_PROT_PIO:
1410 case ATAPI_PROT_NODATA:
1411 qc->tf.flags |= ATA_TFLAG_POLLING;
1412 break;
1413 case ATAPI_PROT_DMA:
1414 if (qc->dev->flags & ATA_DFLAG_CDB_INTR)
1415 /* see ata_dma_blacklisted() */
1416 BUG();
1417 break;
1418 default:
1419 break;
1420 }
1421 }
1422 1403
1423 /* select the device */ 1404 /* select the device */
1424 ata_dev_select(ap, qc->dev->devno, 1, 0); 1405 ata_dev_select(ap, qc->dev->devno, 1, 0);
@@ -1437,15 +1418,6 @@ unsigned int ata_sff_qc_issue(struct ata_queued_cmd *qc)
1437 1418
1438 break; 1419 break;
1439 1420
1440 case ATA_PROT_DMA:
1441 WARN_ON_ONCE(qc->tf.flags & ATA_TFLAG_POLLING);
1442
1443 ap->ops->sff_tf_load(ap, &qc->tf); /* load tf registers */
1444 ap->ops->bmdma_setup(qc); /* set up bmdma */
1445 ap->ops->bmdma_start(qc); /* initiate bmdma */
1446 ap->hsm_task_state = HSM_ST_LAST;
1447 break;
1448
1449 case ATA_PROT_PIO: 1421 case ATA_PROT_PIO:
1450 if (qc->tf.flags & ATA_TFLAG_POLLING) 1422 if (qc->tf.flags & ATA_TFLAG_POLLING)
1451 ata_qc_set_polling(qc); 1423 ata_qc_set_polling(qc);
@@ -1490,18 +1462,6 @@ unsigned int ata_sff_qc_issue(struct ata_queued_cmd *qc)
1490 ata_sff_queue_pio_task(ap, 0); 1462 ata_sff_queue_pio_task(ap, 0);
1491 break; 1463 break;
1492 1464
1493 case ATAPI_PROT_DMA:
1494 WARN_ON_ONCE(qc->tf.flags & ATA_TFLAG_POLLING);
1495
1496 ap->ops->sff_tf_load(ap, &qc->tf); /* load tf registers */
1497 ap->ops->bmdma_setup(qc); /* set up bmdma */
1498 ap->hsm_task_state = HSM_ST_FIRST;
1499
1500 /* send cdb by polling if no cdb interrupt */
1501 if (!(qc->dev->flags & ATA_DFLAG_CDB_INTR))
1502 ata_sff_queue_pio_task(ap, 0);
1503 break;
1504
1505 default: 1465 default:
1506 WARN_ON_ONCE(1); 1466 WARN_ON_ONCE(1);
1507 return AC_ERR_SYSTEM; 1467 return AC_ERR_SYSTEM;
@@ -2618,6 +2578,7 @@ const struct ata_port_operations ata_bmdma_port_ops = {
2618 .post_internal_cmd = ata_bmdma_post_internal_cmd, 2578 .post_internal_cmd = ata_bmdma_post_internal_cmd,
2619 2579
2620 .qc_prep = ata_bmdma_qc_prep, 2580 .qc_prep = ata_bmdma_qc_prep,
2581 .qc_issue = ata_bmdma_qc_issue,
2621 2582
2622 .bmdma_setup = ata_bmdma_setup, 2583 .bmdma_setup = ata_bmdma_setup,
2623 .bmdma_start = ata_bmdma_start, 2584 .bmdma_start = ata_bmdma_start,
@@ -2782,6 +2743,67 @@ void ata_bmdma_dumb_qc_prep(struct ata_queued_cmd *qc)
2782EXPORT_SYMBOL_GPL(ata_bmdma_dumb_qc_prep); 2743EXPORT_SYMBOL_GPL(ata_bmdma_dumb_qc_prep);
2783 2744
2784/** 2745/**
2746 * ata_bmdma_qc_issue - issue taskfile to a BMDMA controller
2747 * @qc: command to issue to device
2748 *
2749 * This function issues a PIO, NODATA or DMA command to a
2750 * SFF/BMDMA controller. PIO and NODATA are handled by
2751 * ata_sff_qc_issue().
2752 *
2753 * LOCKING:
2754 * spin_lock_irqsave(host lock)
2755 *
2756 * RETURNS:
2757 * Zero on success, AC_ERR_* mask on failure
2758 */
2759unsigned int ata_bmdma_qc_issue(struct ata_queued_cmd *qc)
2760{
2761 struct ata_port *ap = qc->ap;
2762
2763 /* see ata_dma_blacklisted() */
2764 BUG_ON((ap->flags & ATA_FLAG_PIO_POLLING) &&
2765 qc->tf.protocol == ATAPI_PROT_DMA);
2766
2767 /* defer PIO handling to sff_qc_issue */
2768 if (!ata_is_dma(qc->tf.protocol))
2769 return ata_sff_qc_issue(qc);
2770
2771 /* select the device */
2772 ata_dev_select(ap, qc->dev->devno, 1, 0);
2773
2774 /* start the command */
2775 switch (qc->tf.protocol) {
2776 case ATA_PROT_DMA:
2777 WARN_ON_ONCE(qc->tf.flags & ATA_TFLAG_POLLING);
2778
2779 ap->ops->sff_tf_load(ap, &qc->tf); /* load tf registers */
2780 ap->ops->bmdma_setup(qc); /* set up bmdma */
2781 ap->ops->bmdma_start(qc); /* initiate bmdma */
2782 ap->hsm_task_state = HSM_ST_LAST;
2783 break;
2784
2785 case ATAPI_PROT_DMA:
2786 WARN_ON_ONCE(qc->tf.flags & ATA_TFLAG_POLLING);
2787
2788 ap->ops->sff_tf_load(ap, &qc->tf); /* load tf registers */
2789 ap->ops->bmdma_setup(qc); /* set up bmdma */
2790 ap->hsm_task_state = HSM_ST_FIRST;
2791
2792 /* send cdb by polling if no cdb interrupt */
2793 if (!(qc->dev->flags & ATA_DFLAG_CDB_INTR))
2794 ata_sff_queue_pio_task(ap, 0);
2795 break;
2796
2797 default:
2798 WARN_ON(1);
2799 return AC_ERR_SYSTEM;
2800 }
2801
2802 return 0;
2803}
2804EXPORT_SYMBOL_GPL(ata_bmdma_qc_issue);
2805
2806/**
2785 * ata_bmdma_error_handler - Stock error handler for BMDMA controller 2807 * ata_bmdma_error_handler - Stock error handler for BMDMA controller
2786 * @ap: port to handle error for 2808 * @ap: port to handle error for
2787 * 2809 *