diff options
author | Tejun Heo <htejun@gmail.com> | 2006-03-05 01:29:09 -0500 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2006-03-11 17:57:20 -0500 |
commit | 8061f5f0a04cfd2bc7aa273596ad3fcd426f8eea (patch) | |
tree | e0d9355eeb2caf99841c7692b8ad2770be0b5ea6 /drivers/scsi/libata-core.c | |
parent | 86e45b6bd6900c4a0b3666fb18b46e215f775c4f (diff) |
[PATCH] libata: convert pio_task and packet_task to port_task
Make pio_task and atapi_packet_task use port_task.
atapi_packet_task() is moved upward such that it's right after
ata_pio_task(). This position is more natural and makes adding
prototype for ata_qc_issue_prot() unnecessary.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/scsi/libata-core.c')
-rw-r--r-- | drivers/scsi/libata-core.c | 154 |
1 files changed, 77 insertions, 77 deletions
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c index d59d462130c1..16a108d2f9a9 100644 --- a/drivers/scsi/libata-core.c +++ b/drivers/scsi/libata-core.c | |||
@@ -3709,12 +3709,84 @@ fsm_start: | |||
3709 | } | 3709 | } |
3710 | 3710 | ||
3711 | if (timeout) | 3711 | if (timeout) |
3712 | ata_queue_delayed_pio_task(ap, timeout); | 3712 | ata_port_queue_task(ap, ata_pio_task, ap, timeout); |
3713 | else if (!qc_completed) | 3713 | else if (!qc_completed) |
3714 | goto fsm_start; | 3714 | goto fsm_start; |
3715 | } | 3715 | } |
3716 | 3716 | ||
3717 | /** | 3717 | /** |
3718 | * atapi_packet_task - Write CDB bytes to hardware | ||
3719 | * @_data: Port to which ATAPI device is attached. | ||
3720 | * | ||
3721 | * When device has indicated its readiness to accept | ||
3722 | * a CDB, this function is called. Send the CDB. | ||
3723 | * If DMA is to be performed, exit immediately. | ||
3724 | * Otherwise, we are in polling mode, so poll | ||
3725 | * status under operation succeeds or fails. | ||
3726 | * | ||
3727 | * LOCKING: | ||
3728 | * Kernel thread context (may sleep) | ||
3729 | */ | ||
3730 | |||
3731 | static void atapi_packet_task(void *_data) | ||
3732 | { | ||
3733 | struct ata_port *ap = _data; | ||
3734 | struct ata_queued_cmd *qc; | ||
3735 | u8 status; | ||
3736 | |||
3737 | qc = ata_qc_from_tag(ap, ap->active_tag); | ||
3738 | WARN_ON(qc == NULL); | ||
3739 | WARN_ON(!(qc->flags & ATA_QCFLAG_ACTIVE)); | ||
3740 | |||
3741 | /* sleep-wait for BSY to clear */ | ||
3742 | DPRINTK("busy wait\n"); | ||
3743 | if (ata_busy_sleep(ap, ATA_TMOUT_CDB_QUICK, ATA_TMOUT_CDB)) { | ||
3744 | qc->err_mask |= AC_ERR_TIMEOUT; | ||
3745 | goto err_out; | ||
3746 | } | ||
3747 | |||
3748 | /* make sure DRQ is set */ | ||
3749 | status = ata_chk_status(ap); | ||
3750 | if ((status & (ATA_BUSY | ATA_DRQ)) != ATA_DRQ) { | ||
3751 | qc->err_mask |= AC_ERR_HSM; | ||
3752 | goto err_out; | ||
3753 | } | ||
3754 | |||
3755 | /* send SCSI cdb */ | ||
3756 | DPRINTK("send cdb\n"); | ||
3757 | WARN_ON(qc->dev->cdb_len < 12); | ||
3758 | |||
3759 | if (qc->tf.protocol == ATA_PROT_ATAPI_DMA || | ||
3760 | qc->tf.protocol == ATA_PROT_ATAPI_NODATA) { | ||
3761 | unsigned long flags; | ||
3762 | |||
3763 | /* Once we're done issuing command and kicking bmdma, | ||
3764 | * irq handler takes over. To not lose irq, we need | ||
3765 | * to clear NOINTR flag before sending cdb, but | ||
3766 | * interrupt handler shouldn't be invoked before we're | ||
3767 | * finished. Hence, the following locking. | ||
3768 | */ | ||
3769 | spin_lock_irqsave(&ap->host_set->lock, flags); | ||
3770 | ap->flags &= ~ATA_FLAG_NOINTR; | ||
3771 | ata_data_xfer(ap, qc->cdb, qc->dev->cdb_len, 1); | ||
3772 | if (qc->tf.protocol == ATA_PROT_ATAPI_DMA) | ||
3773 | ap->ops->bmdma_start(qc); /* initiate bmdma */ | ||
3774 | spin_unlock_irqrestore(&ap->host_set->lock, flags); | ||
3775 | } else { | ||
3776 | ata_data_xfer(ap, qc->cdb, qc->dev->cdb_len, 1); | ||
3777 | |||
3778 | /* PIO commands are handled by polling */ | ||
3779 | ap->hsm_task_state = HSM_ST; | ||
3780 | ata_port_queue_task(ap, ata_pio_task, ap, 0); | ||
3781 | } | ||
3782 | |||
3783 | return; | ||
3784 | |||
3785 | err_out: | ||
3786 | ata_poll_qc_complete(qc); | ||
3787 | } | ||
3788 | |||
3789 | /** | ||
3718 | * ata_qc_timeout - Handle timeout of queued command | 3790 | * ata_qc_timeout - Handle timeout of queued command |
3719 | * @qc: Command that timed out | 3791 | * @qc: Command that timed out |
3720 | * | 3792 | * |
@@ -4013,26 +4085,26 @@ unsigned int ata_qc_issue_prot(struct ata_queued_cmd *qc) | |||
4013 | ata_qc_set_polling(qc); | 4085 | ata_qc_set_polling(qc); |
4014 | ata_tf_to_host(ap, &qc->tf); | 4086 | ata_tf_to_host(ap, &qc->tf); |
4015 | ap->hsm_task_state = HSM_ST; | 4087 | ap->hsm_task_state = HSM_ST; |
4016 | ata_queue_pio_task(ap); | 4088 | ata_port_queue_task(ap, ata_pio_task, ap, 0); |
4017 | break; | 4089 | break; |
4018 | 4090 | ||
4019 | case ATA_PROT_ATAPI: | 4091 | case ATA_PROT_ATAPI: |
4020 | ata_qc_set_polling(qc); | 4092 | ata_qc_set_polling(qc); |
4021 | ata_tf_to_host(ap, &qc->tf); | 4093 | ata_tf_to_host(ap, &qc->tf); |
4022 | ata_queue_packet_task(ap); | 4094 | ata_port_queue_task(ap, atapi_packet_task, ap, 0); |
4023 | break; | 4095 | break; |
4024 | 4096 | ||
4025 | case ATA_PROT_ATAPI_NODATA: | 4097 | case ATA_PROT_ATAPI_NODATA: |
4026 | ap->flags |= ATA_FLAG_NOINTR; | 4098 | ap->flags |= ATA_FLAG_NOINTR; |
4027 | ata_tf_to_host(ap, &qc->tf); | 4099 | ata_tf_to_host(ap, &qc->tf); |
4028 | ata_queue_packet_task(ap); | 4100 | ata_port_queue_task(ap, atapi_packet_task, ap, 0); |
4029 | break; | 4101 | break; |
4030 | 4102 | ||
4031 | case ATA_PROT_ATAPI_DMA: | 4103 | case ATA_PROT_ATAPI_DMA: |
4032 | ap->flags |= ATA_FLAG_NOINTR; | 4104 | ap->flags |= ATA_FLAG_NOINTR; |
4033 | ap->ops->tf_load(ap, &qc->tf); /* load tf registers */ | 4105 | ap->ops->tf_load(ap, &qc->tf); /* load tf registers */ |
4034 | ap->ops->bmdma_setup(qc); /* set up bmdma */ | 4106 | ap->ops->bmdma_setup(qc); /* set up bmdma */ |
4035 | ata_queue_packet_task(ap); | 4107 | ata_port_queue_task(ap, atapi_packet_task, ap, 0); |
4036 | break; | 4108 | break; |
4037 | 4109 | ||
4038 | default: | 4110 | default: |
@@ -4400,78 +4472,6 @@ irqreturn_t ata_interrupt (int irq, void *dev_instance, struct pt_regs *regs) | |||
4400 | return IRQ_RETVAL(handled); | 4472 | return IRQ_RETVAL(handled); |
4401 | } | 4473 | } |
4402 | 4474 | ||
4403 | /** | ||
4404 | * atapi_packet_task - Write CDB bytes to hardware | ||
4405 | * @_data: Port to which ATAPI device is attached. | ||
4406 | * | ||
4407 | * When device has indicated its readiness to accept | ||
4408 | * a CDB, this function is called. Send the CDB. | ||
4409 | * If DMA is to be performed, exit immediately. | ||
4410 | * Otherwise, we are in polling mode, so poll | ||
4411 | * status under operation succeeds or fails. | ||
4412 | * | ||
4413 | * LOCKING: | ||
4414 | * Kernel thread context (may sleep) | ||
4415 | */ | ||
4416 | |||
4417 | static void atapi_packet_task(void *_data) | ||
4418 | { | ||
4419 | struct ata_port *ap = _data; | ||
4420 | struct ata_queued_cmd *qc; | ||
4421 | u8 status; | ||
4422 | |||
4423 | qc = ata_qc_from_tag(ap, ap->active_tag); | ||
4424 | WARN_ON(qc == NULL); | ||
4425 | WARN_ON(!(qc->flags & ATA_QCFLAG_ACTIVE)); | ||
4426 | |||
4427 | /* sleep-wait for BSY to clear */ | ||
4428 | DPRINTK("busy wait\n"); | ||
4429 | if (ata_busy_sleep(ap, ATA_TMOUT_CDB_QUICK, ATA_TMOUT_CDB)) { | ||
4430 | qc->err_mask |= AC_ERR_TIMEOUT; | ||
4431 | goto err_out; | ||
4432 | } | ||
4433 | |||
4434 | /* make sure DRQ is set */ | ||
4435 | status = ata_chk_status(ap); | ||
4436 | if ((status & (ATA_BUSY | ATA_DRQ)) != ATA_DRQ) { | ||
4437 | qc->err_mask |= AC_ERR_HSM; | ||
4438 | goto err_out; | ||
4439 | } | ||
4440 | |||
4441 | /* send SCSI cdb */ | ||
4442 | DPRINTK("send cdb\n"); | ||
4443 | WARN_ON(qc->dev->cdb_len < 12); | ||
4444 | |||
4445 | if (qc->tf.protocol == ATA_PROT_ATAPI_DMA || | ||
4446 | qc->tf.protocol == ATA_PROT_ATAPI_NODATA) { | ||
4447 | unsigned long flags; | ||
4448 | |||
4449 | /* Once we're done issuing command and kicking bmdma, | ||
4450 | * irq handler takes over. To not lose irq, we need | ||
4451 | * to clear NOINTR flag before sending cdb, but | ||
4452 | * interrupt handler shouldn't be invoked before we're | ||
4453 | * finished. Hence, the following locking. | ||
4454 | */ | ||
4455 | spin_lock_irqsave(&ap->host_set->lock, flags); | ||
4456 | ap->flags &= ~ATA_FLAG_NOINTR; | ||
4457 | ata_data_xfer(ap, qc->cdb, qc->dev->cdb_len, 1); | ||
4458 | if (qc->tf.protocol == ATA_PROT_ATAPI_DMA) | ||
4459 | ap->ops->bmdma_start(qc); /* initiate bmdma */ | ||
4460 | spin_unlock_irqrestore(&ap->host_set->lock, flags); | ||
4461 | } else { | ||
4462 | ata_data_xfer(ap, qc->cdb, qc->dev->cdb_len, 1); | ||
4463 | |||
4464 | /* PIO commands are handled by polling */ | ||
4465 | ap->hsm_task_state = HSM_ST; | ||
4466 | ata_queue_pio_task(ap); | ||
4467 | } | ||
4468 | |||
4469 | return; | ||
4470 | |||
4471 | err_out: | ||
4472 | ata_poll_qc_complete(qc); | ||
4473 | } | ||
4474 | |||
4475 | 4475 | ||
4476 | /* | 4476 | /* |
4477 | * Execute a 'simple' command, that only consists of the opcode 'cmd' itself, | 4477 | * Execute a 'simple' command, that only consists of the opcode 'cmd' itself, |