aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/libsas/sas_event.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/libsas/sas_event.c')
-rw-r--r--drivers/scsi/libsas/sas_event.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/drivers/scsi/libsas/sas_event.c b/drivers/scsi/libsas/sas_event.c
index 16639bbae629..4e4292d210c1 100644
--- a/drivers/scsi/libsas/sas_event.c
+++ b/drivers/scsi/libsas/sas_event.c
@@ -27,19 +27,21 @@
27#include "sas_internal.h" 27#include "sas_internal.h"
28#include "sas_dump.h" 28#include "sas_dump.h"
29 29
30void sas_queue_work(struct sas_ha_struct *ha, struct work_struct *work) 30void sas_queue_work(struct sas_ha_struct *ha, struct sas_work *sw)
31{ 31{
32 if (!test_bit(SAS_HA_REGISTERED, &ha->state)) 32 if (!test_bit(SAS_HA_REGISTERED, &ha->state))
33 return; 33 return;
34 34
35 if (test_bit(SAS_HA_DRAINING, &ha->state)) 35 if (test_bit(SAS_HA_DRAINING, &ha->state)) {
36 list_add(&work->entry, &ha->defer_q); 36 /* add it to the defer list, if not already pending */
37 else 37 if (list_empty(&sw->drain_node))
38 scsi_queue_work(ha->core.shost, work); 38 list_add(&sw->drain_node, &ha->defer_q);
39 } else
40 scsi_queue_work(ha->core.shost, &sw->work);
39} 41}
40 42
41static void sas_queue_event(int event, unsigned long *pending, 43static void sas_queue_event(int event, unsigned long *pending,
42 struct work_struct *work, 44 struct sas_work *work,
43 struct sas_ha_struct *ha) 45 struct sas_ha_struct *ha)
44{ 46{
45 if (!test_and_set_bit(event, pending)) { 47 if (!test_and_set_bit(event, pending)) {
@@ -55,7 +57,7 @@ static void sas_queue_event(int event, unsigned long *pending,
55void __sas_drain_work(struct sas_ha_struct *ha) 57void __sas_drain_work(struct sas_ha_struct *ha)
56{ 58{
57 struct workqueue_struct *wq = ha->core.shost->work_q; 59 struct workqueue_struct *wq = ha->core.shost->work_q;
58 struct work_struct *w, *_w; 60 struct sas_work *sw, *_sw;
59 61
60 set_bit(SAS_HA_DRAINING, &ha->state); 62 set_bit(SAS_HA_DRAINING, &ha->state);
61 /* flush submitters */ 63 /* flush submitters */
@@ -66,9 +68,9 @@ void __sas_drain_work(struct sas_ha_struct *ha)
66 68
67 spin_lock_irq(&ha->state_lock); 69 spin_lock_irq(&ha->state_lock);
68 clear_bit(SAS_HA_DRAINING, &ha->state); 70 clear_bit(SAS_HA_DRAINING, &ha->state);
69 list_for_each_entry_safe(w, _w, &ha->defer_q, entry) { 71 list_for_each_entry_safe(sw, _sw, &ha->defer_q, drain_node) {
70 list_del_init(&w->entry); 72 list_del_init(&sw->drain_node);
71 sas_queue_work(ha, w); 73 sas_queue_work(ha, sw);
72 } 74 }
73 spin_unlock_irq(&ha->state_lock); 75 spin_unlock_irq(&ha->state_lock);
74} 76}
@@ -151,7 +153,7 @@ int sas_init_events(struct sas_ha_struct *sas_ha)
151 int i; 153 int i;
152 154
153 for (i = 0; i < HA_NUM_EVENTS; i++) { 155 for (i = 0; i < HA_NUM_EVENTS; i++) {
154 INIT_WORK(&sas_ha->ha_events[i].work, sas_ha_event_fns[i]); 156 INIT_SAS_WORK(&sas_ha->ha_events[i].work, sas_ha_event_fns[i]);
155 sas_ha->ha_events[i].ha = sas_ha; 157 sas_ha->ha_events[i].ha = sas_ha;
156 } 158 }
157 159