diff options
author | Christoph Hellwig <hch@infradead.org> | 2007-04-26 09:38:01 -0400 |
---|---|---|
committer | James Bottomley <jejb@mulgrave.il.steeleye.com> | 2007-05-06 10:33:17 -0400 |
commit | d7a54e30d324b6f3b29a6cf2ff24c95b135013f5 (patch) | |
tree | e009a153ea6cdfc9dfcc14dda0b749a79cc59beb /drivers | |
parent | 4797547778fd51e6ee929c5dd67ab3807898eb82 (diff) |
[SCSI] sas_scsi_host: Convert to use the kthread API
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/scsi/libsas/sas_scsi_host.c | 36 |
1 files changed, 13 insertions, 23 deletions
diff --git a/drivers/scsi/libsas/sas_scsi_host.c b/drivers/scsi/libsas/sas_scsi_host.c index 897a5e2c55e4..b4b52694497c 100644 --- a/drivers/scsi/libsas/sas_scsi_host.c +++ b/drivers/scsi/libsas/sas_scsi_host.c | |||
@@ -23,6 +23,8 @@ | |||
23 | * | 23 | * |
24 | */ | 24 | */ |
25 | 25 | ||
26 | #include <linux/kthread.h> | ||
27 | |||
26 | #include "sas_internal.h" | 28 | #include "sas_internal.h" |
27 | 29 | ||
28 | #include <scsi/scsi_host.h> | 30 | #include <scsi/scsi_host.h> |
@@ -184,7 +186,7 @@ static int sas_queue_up(struct sas_task *task) | |||
184 | list_add_tail(&task->list, &core->task_queue); | 186 | list_add_tail(&task->list, &core->task_queue); |
185 | core->task_queue_size += 1; | 187 | core->task_queue_size += 1; |
186 | spin_unlock_irqrestore(&core->task_queue_lock, flags); | 188 | spin_unlock_irqrestore(&core->task_queue_lock, flags); |
187 | up(&core->queue_thread_sema); | 189 | wake_up_process(core->queue_thread); |
188 | 190 | ||
189 | return 0; | 191 | return 0; |
190 | } | 192 | } |
@@ -819,7 +821,7 @@ static void sas_queue(struct sas_ha_struct *sas_ha) | |||
819 | struct sas_internal *i = to_sas_internal(core->shost->transportt); | 821 | struct sas_internal *i = to_sas_internal(core->shost->transportt); |
820 | 822 | ||
821 | spin_lock_irqsave(&core->task_queue_lock, flags); | 823 | spin_lock_irqsave(&core->task_queue_lock, flags); |
822 | while (!core->queue_thread_kill && | 824 | while (!kthread_should_stop() && |
823 | !list_empty(&core->task_queue)) { | 825 | !list_empty(&core->task_queue)) { |
824 | 826 | ||
825 | can_queue = sas_ha->lldd_queue_size - core->task_queue_size; | 827 | can_queue = sas_ha->lldd_queue_size - core->task_queue_size; |
@@ -858,8 +860,6 @@ static void sas_queue(struct sas_ha_struct *sas_ha) | |||
858 | spin_unlock_irqrestore(&core->task_queue_lock, flags); | 860 | spin_unlock_irqrestore(&core->task_queue_lock, flags); |
859 | } | 861 | } |
860 | 862 | ||
861 | static DECLARE_COMPLETION(queue_th_comp); | ||
862 | |||
863 | /** | 863 | /** |
864 | * sas_queue_thread -- The Task Collector thread | 864 | * sas_queue_thread -- The Task Collector thread |
865 | * @_sas_ha: pointer to struct sas_ha | 865 | * @_sas_ha: pointer to struct sas_ha |
@@ -867,40 +867,33 @@ static DECLARE_COMPLETION(queue_th_comp); | |||
867 | static int sas_queue_thread(void *_sas_ha) | 867 | static int sas_queue_thread(void *_sas_ha) |
868 | { | 868 | { |
869 | struct sas_ha_struct *sas_ha = _sas_ha; | 869 | struct sas_ha_struct *sas_ha = _sas_ha; |
870 | struct scsi_core *core = &sas_ha->core; | ||
871 | 870 | ||
872 | daemonize("sas_queue_%d", core->shost->host_no); | ||
873 | current->flags |= PF_NOFREEZE; | 871 | current->flags |= PF_NOFREEZE; |
874 | 872 | ||
875 | complete(&queue_th_comp); | ||
876 | |||
877 | while (1) { | 873 | while (1) { |
878 | down_interruptible(&core->queue_thread_sema); | 874 | set_current_state(TASK_INTERRUPTIBLE); |
875 | schedule(); | ||
879 | sas_queue(sas_ha); | 876 | sas_queue(sas_ha); |
880 | if (core->queue_thread_kill) | 877 | if (kthread_should_stop()) |
881 | break; | 878 | break; |
882 | } | 879 | } |
883 | 880 | ||
884 | complete(&queue_th_comp); | ||
885 | |||
886 | return 0; | 881 | return 0; |
887 | } | 882 | } |
888 | 883 | ||
889 | int sas_init_queue(struct sas_ha_struct *sas_ha) | 884 | int sas_init_queue(struct sas_ha_struct *sas_ha) |
890 | { | 885 | { |
891 | int res; | ||
892 | struct scsi_core *core = &sas_ha->core; | 886 | struct scsi_core *core = &sas_ha->core; |
893 | 887 | ||
894 | spin_lock_init(&core->task_queue_lock); | 888 | spin_lock_init(&core->task_queue_lock); |
895 | core->task_queue_size = 0; | 889 | core->task_queue_size = 0; |
896 | INIT_LIST_HEAD(&core->task_queue); | 890 | INIT_LIST_HEAD(&core->task_queue); |
897 | init_MUTEX_LOCKED(&core->queue_thread_sema); | ||
898 | 891 | ||
899 | res = kernel_thread(sas_queue_thread, sas_ha, 0); | 892 | core->queue_thread = kthread_run(sas_queue_thread, sas_ha, |
900 | if (res >= 0) | 893 | "sas_queue_%d", core->shost->host_no); |
901 | wait_for_completion(&queue_th_comp); | 894 | if (IS_ERR(core->queue_thread)) |
902 | 895 | return PTR_ERR(core->queue_thread); | |
903 | return res < 0 ? res : 0; | 896 | return 0; |
904 | } | 897 | } |
905 | 898 | ||
906 | void sas_shutdown_queue(struct sas_ha_struct *sas_ha) | 899 | void sas_shutdown_queue(struct sas_ha_struct *sas_ha) |
@@ -909,10 +902,7 @@ void sas_shutdown_queue(struct sas_ha_struct *sas_ha) | |||
909 | struct scsi_core *core = &sas_ha->core; | 902 | struct scsi_core *core = &sas_ha->core; |
910 | struct sas_task *task, *n; | 903 | struct sas_task *task, *n; |
911 | 904 | ||
912 | init_completion(&queue_th_comp); | 905 | kthread_stop(core->queue_thread); |
913 | core->queue_thread_kill = 1; | ||
914 | up(&core->queue_thread_sema); | ||
915 | wait_for_completion(&queue_th_comp); | ||
916 | 906 | ||
917 | if (!list_empty(&core->task_queue)) | 907 | if (!list_empty(&core->task_queue)) |
918 | SAS_DPRINTK("HA: %llx: scsi core task queue is NOT empty!?\n", | 908 | SAS_DPRINTK("HA: %llx: scsi core task queue is NOT empty!?\n", |