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 | 86e45b6bd6900c4a0b3666fb18b46e215f775c4f (patch) | |
tree | 5b86ebd0b0b17d05bdfdd07b7683f7348577b52a /drivers/scsi | |
parent | d7fc3ca1cd0ecce82263299c6b1631fc83b0ec79 (diff) |
[PATCH] libata: implement port_task
Implement port_task. LLDD's can schedule a function to be executed
with context after specified delay. libata core takes care of
synchronization against EH. This is generalized form of pio_task and
packet_task which are tied to PIO hsm implementation.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/scsi')
-rw-r--r-- | drivers/scsi/libata-core.c | 77 | ||||
-rw-r--r-- | drivers/scsi/libata-scsi.c | 2 | ||||
-rw-r--r-- | drivers/scsi/libata.h | 1 |
3 files changed, 80 insertions, 0 deletions
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c index 5dbcf0cf4a10..d59d462130c1 100644 --- a/drivers/scsi/libata-core.c +++ b/drivers/scsi/libata-core.c | |||
@@ -721,6 +721,81 @@ static unsigned int ata_pio_modes(const struct ata_device *adev) | |||
721 | timing API will get this right anyway */ | 721 | timing API will get this right anyway */ |
722 | } | 722 | } |
723 | 723 | ||
724 | /** | ||
725 | * ata_port_queue_task - Queue port_task | ||
726 | * @ap: The ata_port to queue port_task for | ||
727 | * | ||
728 | * Schedule @fn(@data) for execution after @delay jiffies using | ||
729 | * port_task. There is one port_task per port and it's the | ||
730 | * user(low level driver)'s responsibility to make sure that only | ||
731 | * one task is active at any given time. | ||
732 | * | ||
733 | * libata core layer takes care of synchronization between | ||
734 | * port_task and EH. ata_port_queue_task() may be ignored for EH | ||
735 | * synchronization. | ||
736 | * | ||
737 | * LOCKING: | ||
738 | * Inherited from caller. | ||
739 | */ | ||
740 | void ata_port_queue_task(struct ata_port *ap, void (*fn)(void *), void *data, | ||
741 | unsigned long delay) | ||
742 | { | ||
743 | int rc; | ||
744 | |||
745 | if (ap->flags & ATA_FLAG_FLUSH_PIO_TASK) | ||
746 | return; | ||
747 | |||
748 | PREPARE_WORK(&ap->port_task, fn, data); | ||
749 | |||
750 | if (!delay) | ||
751 | rc = queue_work(ata_wq, &ap->port_task); | ||
752 | else | ||
753 | rc = queue_delayed_work(ata_wq, &ap->port_task, delay); | ||
754 | |||
755 | /* rc == 0 means that another user is using port task */ | ||
756 | WARN_ON(rc == 0); | ||
757 | } | ||
758 | |||
759 | /** | ||
760 | * ata_port_flush_task - Flush port_task | ||
761 | * @ap: The ata_port to flush port_task for | ||
762 | * | ||
763 | * After this function completes, port_task is guranteed not to | ||
764 | * be running or scheduled. | ||
765 | * | ||
766 | * LOCKING: | ||
767 | * Kernel thread context (may sleep) | ||
768 | */ | ||
769 | void ata_port_flush_task(struct ata_port *ap) | ||
770 | { | ||
771 | unsigned long flags; | ||
772 | |||
773 | DPRINTK("ENTER\n"); | ||
774 | |||
775 | spin_lock_irqsave(&ap->host_set->lock, flags); | ||
776 | ap->flags |= ATA_FLAG_FLUSH_PIO_TASK; | ||
777 | spin_unlock_irqrestore(&ap->host_set->lock, flags); | ||
778 | |||
779 | DPRINTK("flush #1\n"); | ||
780 | flush_workqueue(ata_wq); | ||
781 | |||
782 | /* | ||
783 | * At this point, if a task is running, it's guaranteed to see | ||
784 | * the FLUSH flag; thus, it will never queue pio tasks again. | ||
785 | * Cancel and flush. | ||
786 | */ | ||
787 | if (!cancel_delayed_work(&ap->port_task)) { | ||
788 | DPRINTK("flush #2\n"); | ||
789 | flush_workqueue(ata_wq); | ||
790 | } | ||
791 | |||
792 | spin_lock_irqsave(&ap->host_set->lock, flags); | ||
793 | ap->flags &= ~ATA_FLAG_FLUSH_PIO_TASK; | ||
794 | spin_unlock_irqrestore(&ap->host_set->lock, flags); | ||
795 | |||
796 | DPRINTK("EXIT\n"); | ||
797 | } | ||
798 | |||
724 | static inline void | 799 | static inline void |
725 | ata_queue_packet_task(struct ata_port *ap) | 800 | ata_queue_packet_task(struct ata_port *ap) |
726 | { | 801 | { |
@@ -4617,6 +4692,7 @@ static void ata_host_init(struct ata_port *ap, struct Scsi_Host *host, | |||
4617 | ap->active_tag = ATA_TAG_POISON; | 4692 | ap->active_tag = ATA_TAG_POISON; |
4618 | ap->last_ctl = 0xFF; | 4693 | ap->last_ctl = 0xFF; |
4619 | 4694 | ||
4695 | INIT_WORK(&ap->port_task, NULL, NULL); | ||
4620 | INIT_WORK(&ap->packet_task, atapi_packet_task, ap); | 4696 | INIT_WORK(&ap->packet_task, atapi_packet_task, ap); |
4621 | INIT_WORK(&ap->pio_task, ata_pio_task, ap); | 4697 | INIT_WORK(&ap->pio_task, ata_pio_task, ap); |
4622 | INIT_LIST_HEAD(&ap->eh_done_q); | 4698 | INIT_LIST_HEAD(&ap->eh_done_q); |
@@ -5088,6 +5164,7 @@ EXPORT_SYMBOL_GPL(ata_dev_revalidate); | |||
5088 | EXPORT_SYMBOL_GPL(ata_port_disable); | 5164 | EXPORT_SYMBOL_GPL(ata_port_disable); |
5089 | EXPORT_SYMBOL_GPL(ata_ratelimit); | 5165 | EXPORT_SYMBOL_GPL(ata_ratelimit); |
5090 | EXPORT_SYMBOL_GPL(ata_busy_sleep); | 5166 | EXPORT_SYMBOL_GPL(ata_busy_sleep); |
5167 | EXPORT_SYMBOL_GPL(ata_port_queue_task); | ||
5091 | EXPORT_SYMBOL_GPL(ata_scsi_ioctl); | 5168 | EXPORT_SYMBOL_GPL(ata_scsi_ioctl); |
5092 | EXPORT_SYMBOL_GPL(ata_scsi_queuecmd); | 5169 | EXPORT_SYMBOL_GPL(ata_scsi_queuecmd); |
5093 | EXPORT_SYMBOL_GPL(ata_scsi_timed_out); | 5170 | EXPORT_SYMBOL_GPL(ata_scsi_timed_out); |
diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c index d0bd94abb413..ccedb4536977 100644 --- a/drivers/scsi/libata-scsi.c +++ b/drivers/scsi/libata-scsi.c | |||
@@ -785,6 +785,8 @@ int ata_scsi_error(struct Scsi_Host *host) | |||
785 | WARN_ON(ata_qc_from_tag(ap, ap->active_tag) == NULL); | 785 | WARN_ON(ata_qc_from_tag(ap, ap->active_tag) == NULL); |
786 | spin_unlock_irqrestore(&ap->host_set->lock, flags); | 786 | spin_unlock_irqrestore(&ap->host_set->lock, flags); |
787 | 787 | ||
788 | ata_port_flush_task(ap); | ||
789 | |||
788 | ap->ops->eng_timeout(ap); | 790 | ap->ops->eng_timeout(ap); |
789 | 791 | ||
790 | WARN_ON(host->host_failed || !list_empty(&host->eh_cmd_q)); | 792 | WARN_ON(host->host_failed || !list_empty(&host->eh_cmd_q)); |
diff --git a/drivers/scsi/libata.h b/drivers/scsi/libata.h index d822eba05f3c..f4c48c91b63d 100644 --- a/drivers/scsi/libata.h +++ b/drivers/scsi/libata.h | |||
@@ -45,6 +45,7 @@ extern int libata_fua; | |||
45 | extern struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap, | 45 | extern struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap, |
46 | struct ata_device *dev); | 46 | struct ata_device *dev); |
47 | extern int ata_rwcmd_protocol(struct ata_queued_cmd *qc); | 47 | extern int ata_rwcmd_protocol(struct ata_queued_cmd *qc); |
48 | extern void ata_port_flush_task(struct ata_port *ap); | ||
48 | extern void ata_qc_free(struct ata_queued_cmd *qc); | 49 | extern void ata_qc_free(struct ata_queued_cmd *qc); |
49 | extern unsigned int ata_qc_issue(struct ata_queued_cmd *qc); | 50 | extern unsigned int ata_qc_issue(struct ata_queued_cmd *qc); |
50 | extern int ata_check_atapi_dma(struct ata_queued_cmd *qc); | 51 | extern int ata_check_atapi_dma(struct ata_queued_cmd *qc); |