aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
authorDan Williams <dan.j.williams@intel.com>2011-11-17 20:59:49 -0500
committerJames Bottomley <JBottomley@Parallels.com>2012-02-19 14:41:04 -0500
commitb15ebe0b5d0b95aeb1d84cae3649df1e0e065e9b (patch)
treeff93ad5f8be5fe91c7e6cf4963253491ddd058fb /drivers/scsi
parent756f173fb5fa90ec15222e80fb579288be7794fd (diff)
[SCSI] libsas: replace event locks with atomic bitops
The locks only served to make sure the pending event bitmask was updated consistently. Signed-off-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/libsas/sas_discover.c10
-rw-r--r--drivers/scsi/libsas/sas_event.c8
-rw-r--r--drivers/scsi/libsas/sas_init.c3
-rw-r--r--drivers/scsi/libsas/sas_internal.h32
-rw-r--r--drivers/scsi/libsas/sas_phy.c12
-rw-r--r--drivers/scsi/libsas/sas_port.c15
6 files changed, 23 insertions, 57 deletions
diff --git a/drivers/scsi/libsas/sas_discover.c b/drivers/scsi/libsas/sas_discover.c
index dc52b1fa218e..ed041189e764 100644
--- a/drivers/scsi/libsas/sas_discover.c
+++ b/drivers/scsi/libsas/sas_discover.c
@@ -295,8 +295,7 @@ static void sas_discover_domain(struct work_struct *work)
295 container_of(work, struct sas_discovery_event, work); 295 container_of(work, struct sas_discovery_event, work);
296 struct asd_sas_port *port = ev->port; 296 struct asd_sas_port *port = ev->port;
297 297
298 sas_begin_event(DISCE_DISCOVER_DOMAIN, &port->disc.disc_event_lock, 298 clear_bit(DISCE_DISCOVER_DOMAIN, &port->disc.pending);
299 &port->disc.pending);
300 299
301 if (port->port_dev) 300 if (port->port_dev)
302 return; 301 return;
@@ -355,8 +354,7 @@ static void sas_revalidate_domain(struct work_struct *work)
355 container_of(work, struct sas_discovery_event, work); 354 container_of(work, struct sas_discovery_event, work);
356 struct asd_sas_port *port = ev->port; 355 struct asd_sas_port *port = ev->port;
357 356
358 sas_begin_event(DISCE_REVALIDATE_DOMAIN, &port->disc.disc_event_lock, 357 clear_bit(DISCE_REVALIDATE_DOMAIN, &port->disc.pending);
359 &port->disc.pending);
360 358
361 SAS_DPRINTK("REVALIDATING DOMAIN on port %d, pid:%d\n", port->id, 359 SAS_DPRINTK("REVALIDATING DOMAIN on port %d, pid:%d\n", port->id,
362 task_pid_nr(current)); 360 task_pid_nr(current));
@@ -379,8 +377,7 @@ int sas_discover_event(struct asd_sas_port *port, enum discover_event ev)
379 377
380 BUG_ON(ev >= DISC_NUM_EVENTS); 378 BUG_ON(ev >= DISC_NUM_EVENTS);
381 379
382 sas_queue_event(ev, &disc->disc_event_lock, &disc->pending, 380 sas_queue_event(ev, &disc->pending, &disc->disc_work[ev].work, port->ha);
383 &disc->disc_work[ev].work, port->ha);
384 381
385 return 0; 382 return 0;
386} 383}
@@ -400,7 +397,6 @@ void sas_init_disc(struct sas_discovery *disc, struct asd_sas_port *port)
400 [DISCE_REVALIDATE_DOMAIN] = sas_revalidate_domain, 397 [DISCE_REVALIDATE_DOMAIN] = sas_revalidate_domain,
401 }; 398 };
402 399
403 spin_lock_init(&disc->disc_event_lock);
404 disc->pending = 0; 400 disc->pending = 0;
405 for (i = 0; i < DISC_NUM_EVENTS; i++) { 401 for (i = 0; i < DISC_NUM_EVENTS; i++) {
406 INIT_WORK(&disc->disc_work[i].work, sas_event_fns[i]); 402 INIT_WORK(&disc->disc_work[i].work, sas_event_fns[i]);
diff --git a/drivers/scsi/libsas/sas_event.c b/drivers/scsi/libsas/sas_event.c
index 9db30fb5caf2..9c084bc09bbd 100644
--- a/drivers/scsi/libsas/sas_event.c
+++ b/drivers/scsi/libsas/sas_event.c
@@ -30,7 +30,7 @@ static void notify_ha_event(struct sas_ha_struct *sas_ha, enum ha_event event)
30{ 30{
31 BUG_ON(event >= HA_NUM_EVENTS); 31 BUG_ON(event >= HA_NUM_EVENTS);
32 32
33 sas_queue_event(event, &sas_ha->event_lock, &sas_ha->pending, 33 sas_queue_event(event, &sas_ha->pending,
34 &sas_ha->ha_events[event].work, sas_ha); 34 &sas_ha->ha_events[event].work, sas_ha);
35} 35}
36 36
@@ -40,7 +40,7 @@ static void notify_port_event(struct asd_sas_phy *phy, enum port_event event)
40 40
41 BUG_ON(event >= PORT_NUM_EVENTS); 41 BUG_ON(event >= PORT_NUM_EVENTS);
42 42
43 sas_queue_event(event, &ha->event_lock, &phy->port_events_pending, 43 sas_queue_event(event, &phy->port_events_pending,
44 &phy->port_events[event].work, ha); 44 &phy->port_events[event].work, ha);
45} 45}
46 46
@@ -50,7 +50,7 @@ static void notify_phy_event(struct asd_sas_phy *phy, enum phy_event event)
50 50
51 BUG_ON(event >= PHY_NUM_EVENTS); 51 BUG_ON(event >= PHY_NUM_EVENTS);
52 52
53 sas_queue_event(event, &ha->event_lock, &phy->phy_events_pending, 53 sas_queue_event(event, &phy->phy_events_pending,
54 &phy->phy_events[event].work, ha); 54 &phy->phy_events[event].work, ha);
55} 55}
56 56
@@ -62,8 +62,6 @@ int sas_init_events(struct sas_ha_struct *sas_ha)
62 62
63 int i; 63 int i;
64 64
65 spin_lock_init(&sas_ha->event_lock);
66
67 for (i = 0; i < HA_NUM_EVENTS; i++) { 65 for (i = 0; i < HA_NUM_EVENTS; i++) {
68 INIT_WORK(&sas_ha->ha_events[i].work, sas_ha_event_fns[i]); 66 INIT_WORK(&sas_ha->ha_events[i].work, sas_ha_event_fns[i]);
69 sas_ha->ha_events[i].ha = sas_ha; 67 sas_ha->ha_events[i].ha = sas_ha;
diff --git a/drivers/scsi/libsas/sas_init.c b/drivers/scsi/libsas/sas_init.c
index d81c3b1989f7..a435876f1f77 100644
--- a/drivers/scsi/libsas/sas_init.c
+++ b/drivers/scsi/libsas/sas_init.c
@@ -97,8 +97,7 @@ void sas_hae_reset(struct work_struct *work)
97 container_of(work, struct sas_ha_event, work); 97 container_of(work, struct sas_ha_event, work);
98 struct sas_ha_struct *ha = ev->ha; 98 struct sas_ha_struct *ha = ev->ha;
99 99
100 sas_begin_event(HAE_RESET, &ha->event_lock, 100 clear_bit(HAE_RESET, &ha->pending);
101 &ha->pending);
102} 101}
103 102
104int sas_register_ha(struct sas_ha_struct *sas_ha) 103int sas_register_ha(struct sas_ha_struct *sas_ha)
diff --git a/drivers/scsi/libsas/sas_internal.h b/drivers/scsi/libsas/sas_internal.h
index 0d43408196f9..7fe4eded2866 100644
--- a/drivers/scsi/libsas/sas_internal.h
+++ b/drivers/scsi/libsas/sas_internal.h
@@ -92,36 +92,18 @@ static inline int sas_smp_host_handler(struct Scsi_Host *shost,
92} 92}
93#endif 93#endif
94 94
95static inline void sas_queue_event(int event, spinlock_t *lock, 95static inline void sas_queue_event(int event, unsigned long *pending,
96 unsigned long *pending,
97 struct work_struct *work, 96 struct work_struct *work,
98 struct sas_ha_struct *sas_ha) 97 struct sas_ha_struct *sas_ha)
99{ 98{
100 unsigned long flags; 99 if (!test_and_set_bit(event, pending)) {
100 unsigned long flags;
101 101
102 spin_lock_irqsave(lock, flags); 102 spin_lock_irqsave(&sas_ha->state_lock, flags);
103 if (test_bit(event, pending)) { 103 if (sas_ha->state != SAS_HA_UNREGISTERED)
104 spin_unlock_irqrestore(lock, flags); 104 scsi_queue_work(sas_ha->core.shost, work);
105 return; 105 spin_unlock_irqrestore(&sas_ha->state_lock, flags);
106 } 106 }
107 __set_bit(event, pending);
108 spin_unlock_irqrestore(lock, flags);
109
110 spin_lock_irqsave(&sas_ha->state_lock, flags);
111 if (sas_ha->state != SAS_HA_UNREGISTERED) {
112 scsi_queue_work(sas_ha->core.shost, work);
113 }
114 spin_unlock_irqrestore(&sas_ha->state_lock, flags);
115}
116
117static inline void sas_begin_event(int event, spinlock_t *lock,
118 unsigned long *pending)
119{
120 unsigned long flags;
121
122 spin_lock_irqsave(lock, flags);
123 __clear_bit(event, pending);
124 spin_unlock_irqrestore(lock, flags);
125} 107}
126 108
127static inline void sas_fill_in_rphy(struct domain_device *dev, 109static inline void sas_fill_in_rphy(struct domain_device *dev,
diff --git a/drivers/scsi/libsas/sas_phy.c b/drivers/scsi/libsas/sas_phy.c
index e0f5018e9071..dcfd4a9105c5 100644
--- a/drivers/scsi/libsas/sas_phy.c
+++ b/drivers/scsi/libsas/sas_phy.c
@@ -36,8 +36,7 @@ static void sas_phye_loss_of_signal(struct work_struct *work)
36 container_of(work, struct asd_sas_event, work); 36 container_of(work, struct asd_sas_event, work);
37 struct asd_sas_phy *phy = ev->phy; 37 struct asd_sas_phy *phy = ev->phy;
38 38
39 sas_begin_event(PHYE_LOSS_OF_SIGNAL, &phy->ha->event_lock, 39 clear_bit(PHYE_LOSS_OF_SIGNAL, &phy->phy_events_pending);
40 &phy->phy_events_pending);
41 phy->error = 0; 40 phy->error = 0;
42 sas_deform_port(phy, 1); 41 sas_deform_port(phy, 1);
43} 42}
@@ -48,8 +47,7 @@ static void sas_phye_oob_done(struct work_struct *work)
48 container_of(work, struct asd_sas_event, work); 47 container_of(work, struct asd_sas_event, work);
49 struct asd_sas_phy *phy = ev->phy; 48 struct asd_sas_phy *phy = ev->phy;
50 49
51 sas_begin_event(PHYE_OOB_DONE, &phy->ha->event_lock, 50 clear_bit(PHYE_OOB_DONE, &phy->phy_events_pending);
52 &phy->phy_events_pending);
53 phy->error = 0; 51 phy->error = 0;
54} 52}
55 53
@@ -63,8 +61,7 @@ static void sas_phye_oob_error(struct work_struct *work)
63 struct sas_internal *i = 61 struct sas_internal *i =
64 to_sas_internal(sas_ha->core.shost->transportt); 62 to_sas_internal(sas_ha->core.shost->transportt);
65 63
66 sas_begin_event(PHYE_OOB_ERROR, &phy->ha->event_lock, 64 clear_bit(PHYE_OOB_ERROR, &phy->phy_events_pending);
67 &phy->phy_events_pending);
68 65
69 sas_deform_port(phy, 1); 66 sas_deform_port(phy, 1);
70 67
@@ -95,8 +92,7 @@ static void sas_phye_spinup_hold(struct work_struct *work)
95 struct sas_internal *i = 92 struct sas_internal *i =
96 to_sas_internal(sas_ha->core.shost->transportt); 93 to_sas_internal(sas_ha->core.shost->transportt);
97 94
98 sas_begin_event(PHYE_SPINUP_HOLD, &phy->ha->event_lock, 95 clear_bit(PHYE_SPINUP_HOLD, &phy->phy_events_pending);
99 &phy->phy_events_pending);
100 96
101 phy->error = 0; 97 phy->error = 0;
102 i->dft->lldd_control_phy(phy, PHY_FUNC_RELEASE_SPINUP_HOLD, NULL); 98 i->dft->lldd_control_phy(phy, PHY_FUNC_RELEASE_SPINUP_HOLD, NULL);
diff --git a/drivers/scsi/libsas/sas_port.c b/drivers/scsi/libsas/sas_port.c
index 42fd1f25b664..a47c7a75327b 100644
--- a/drivers/scsi/libsas/sas_port.c
+++ b/drivers/scsi/libsas/sas_port.c
@@ -213,8 +213,7 @@ void sas_porte_bytes_dmaed(struct work_struct *work)
213 container_of(work, struct asd_sas_event, work); 213 container_of(work, struct asd_sas_event, work);
214 struct asd_sas_phy *phy = ev->phy; 214 struct asd_sas_phy *phy = ev->phy;
215 215
216 sas_begin_event(PORTE_BYTES_DMAED, &phy->ha->event_lock, 216 clear_bit(PORTE_BYTES_DMAED, &phy->port_events_pending);
217 &phy->port_events_pending);
218 217
219 sas_form_port(phy); 218 sas_form_port(phy);
220} 219}
@@ -227,8 +226,7 @@ void sas_porte_broadcast_rcvd(struct work_struct *work)
227 unsigned long flags; 226 unsigned long flags;
228 u32 prim; 227 u32 prim;
229 228
230 sas_begin_event(PORTE_BROADCAST_RCVD, &phy->ha->event_lock, 229 clear_bit(PORTE_BROADCAST_RCVD, &phy->port_events_pending);
231 &phy->port_events_pending);
232 230
233 spin_lock_irqsave(&phy->sas_prim_lock, flags); 231 spin_lock_irqsave(&phy->sas_prim_lock, flags);
234 prim = phy->sas_prim; 232 prim = phy->sas_prim;
@@ -244,8 +242,7 @@ void sas_porte_link_reset_err(struct work_struct *work)
244 container_of(work, struct asd_sas_event, work); 242 container_of(work, struct asd_sas_event, work);
245 struct asd_sas_phy *phy = ev->phy; 243 struct asd_sas_phy *phy = ev->phy;
246 244
247 sas_begin_event(PORTE_LINK_RESET_ERR, &phy->ha->event_lock, 245 clear_bit(PORTE_LINK_RESET_ERR, &phy->port_events_pending);
248 &phy->port_events_pending);
249 246
250 sas_deform_port(phy, 1); 247 sas_deform_port(phy, 1);
251} 248}
@@ -256,8 +253,7 @@ void sas_porte_timer_event(struct work_struct *work)
256 container_of(work, struct asd_sas_event, work); 253 container_of(work, struct asd_sas_event, work);
257 struct asd_sas_phy *phy = ev->phy; 254 struct asd_sas_phy *phy = ev->phy;
258 255
259 sas_begin_event(PORTE_TIMER_EVENT, &phy->ha->event_lock, 256 clear_bit(PORTE_TIMER_EVENT, &phy->port_events_pending);
260 &phy->port_events_pending);
261 257
262 sas_deform_port(phy, 1); 258 sas_deform_port(phy, 1);
263} 259}
@@ -268,8 +264,7 @@ void sas_porte_hard_reset(struct work_struct *work)
268 container_of(work, struct asd_sas_event, work); 264 container_of(work, struct asd_sas_event, work);
269 struct asd_sas_phy *phy = ev->phy; 265 struct asd_sas_phy *phy = ev->phy;
270 266
271 sas_begin_event(PORTE_HARD_RESET, &phy->ha->event_lock, 267 clear_bit(PORTE_HARD_RESET, &phy->port_events_pending);
272 &phy->port_events_pending);
273 268
274 sas_deform_port(phy, 1); 269 sas_deform_port(phy, 1);
275} 270}