aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/bnx2fc
diff options
context:
space:
mode:
authorBhanu Prakash Gollapudi <bprakash@broadcom.com>2012-12-21 22:40:30 -0500
committerJames Bottomley <JBottomley@Parallels.com>2013-01-29 18:48:47 -0500
commit26bf62a3dd0752f29609b2dea85a4f0b806da315 (patch)
tree421059bb6e4fd73472952e96a2374e9b3086c5ea /drivers/scsi/bnx2fc
parent50b7186f64d525c1054d996f83e16c200f0b321c (diff)
[SCSI] bnx2fc: Move offload/upload wait logic into a function
Moved the 'waiting for upload/offload completion' logic to respective functions as it is called in multiple places. Also this is done in preperation for the next patch. Signed-off-by: Bhanu Prakash Gollapudi <bprakash@broadcom.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Diffstat (limited to 'drivers/scsi/bnx2fc')
-rw-r--r--drivers/scsi/bnx2fc/bnx2fc_tgt.c65
1 files changed, 30 insertions, 35 deletions
diff --git a/drivers/scsi/bnx2fc/bnx2fc_tgt.c b/drivers/scsi/bnx2fc/bnx2fc_tgt.c
index eba2328f60e7..236d8894bd82 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_tgt.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_tgt.c
@@ -59,6 +59,20 @@ static void bnx2fc_ofld_timer(unsigned long data)
59 wake_up_interruptible(&tgt->ofld_wait); 59 wake_up_interruptible(&tgt->ofld_wait);
60} 60}
61 61
62static void bnx2fc_ofld_wait(struct bnx2fc_rport *tgt)
63{
64 setup_timer(&tgt->ofld_timer, bnx2fc_ofld_timer, (unsigned long)tgt);
65 mod_timer(&tgt->ofld_timer, jiffies + BNX2FC_FW_TIMEOUT);
66
67 wait_event_interruptible(tgt->ofld_wait,
68 (test_bit(
69 BNX2FC_FLAG_OFLD_REQ_CMPL,
70 &tgt->flags)));
71 if (signal_pending(current))
72 flush_signals(current);
73 del_timer_sync(&tgt->ofld_timer);
74}
75
62static void bnx2fc_offload_session(struct fcoe_port *port, 76static void bnx2fc_offload_session(struct fcoe_port *port,
63 struct bnx2fc_rport *tgt, 77 struct bnx2fc_rport *tgt,
64 struct fc_rport_priv *rdata) 78 struct fc_rport_priv *rdata)
@@ -103,17 +117,7 @@ retry_ofld:
103 * wait for the session is offloaded and enabled. 3 Secs 117 * wait for the session is offloaded and enabled. 3 Secs
104 * should be ample time for this process to complete. 118 * should be ample time for this process to complete.
105 */ 119 */
106 setup_timer(&tgt->ofld_timer, bnx2fc_ofld_timer, (unsigned long)tgt); 120 bnx2fc_ofld_wait(tgt);
107 mod_timer(&tgt->ofld_timer, jiffies + BNX2FC_FW_TIMEOUT);
108
109 wait_event_interruptible(tgt->ofld_wait,
110 (test_bit(
111 BNX2FC_FLAG_OFLD_REQ_CMPL,
112 &tgt->flags)));
113 if (signal_pending(current))
114 flush_signals(current);
115
116 del_timer_sync(&tgt->ofld_timer);
117 121
118 if (!(test_bit(BNX2FC_FLAG_OFFLOADED, &tgt->flags))) { 122 if (!(test_bit(BNX2FC_FLAG_OFFLOADED, &tgt->flags))) {
119 if (test_and_clear_bit(BNX2FC_FLAG_CTX_ALLOC_FAILURE, 123 if (test_and_clear_bit(BNX2FC_FLAG_CTX_ALLOC_FAILURE,
@@ -259,6 +263,19 @@ void bnx2fc_flush_active_ios(struct bnx2fc_rport *tgt)
259 spin_unlock_bh(&tgt->tgt_lock); 263 spin_unlock_bh(&tgt->tgt_lock);
260} 264}
261 265
266static void bnx2fc_upld_wait(struct bnx2fc_rport *tgt)
267{
268 setup_timer(&tgt->upld_timer, bnx2fc_upld_timer, (unsigned long)tgt);
269 mod_timer(&tgt->upld_timer, jiffies + BNX2FC_FW_TIMEOUT);
270 wait_event_interruptible(tgt->upld_wait,
271 (test_bit(
272 BNX2FC_FLAG_UPLD_REQ_COMPL,
273 &tgt->flags)));
274 if (signal_pending(current))
275 flush_signals(current);
276 del_timer_sync(&tgt->upld_timer);
277}
278
262static void bnx2fc_upload_session(struct fcoe_port *port, 279static void bnx2fc_upload_session(struct fcoe_port *port,
263 struct bnx2fc_rport *tgt) 280 struct bnx2fc_rport *tgt)
264{ 281{
@@ -279,19 +296,8 @@ static void bnx2fc_upload_session(struct fcoe_port *port,
279 * wait for upload to complete. 3 Secs 296 * wait for upload to complete. 3 Secs
280 * should be sufficient time for this process to complete. 297 * should be sufficient time for this process to complete.
281 */ 298 */
282 setup_timer(&tgt->upld_timer, bnx2fc_upld_timer, (unsigned long)tgt);
283 mod_timer(&tgt->upld_timer, jiffies + BNX2FC_FW_TIMEOUT);
284
285 BNX2FC_TGT_DBG(tgt, "waiting for disable compl\n"); 299 BNX2FC_TGT_DBG(tgt, "waiting for disable compl\n");
286 wait_event_interruptible(tgt->upld_wait, 300 bnx2fc_upld_wait(tgt);
287 (test_bit(
288 BNX2FC_FLAG_UPLD_REQ_COMPL,
289 &tgt->flags)));
290
291 if (signal_pending(current))
292 flush_signals(current);
293
294 del_timer_sync(&tgt->upld_timer);
295 301
296 /* 302 /*
297 * traverse thru the active_q and tmf_q and cleanup 303 * traverse thru the active_q and tmf_q and cleanup
@@ -308,24 +314,13 @@ static void bnx2fc_upload_session(struct fcoe_port *port,
308 bnx2fc_send_session_destroy_req(hba, tgt); 314 bnx2fc_send_session_destroy_req(hba, tgt);
309 315
310 /* wait for destroy to complete */ 316 /* wait for destroy to complete */
311 setup_timer(&tgt->upld_timer, 317 bnx2fc_upld_wait(tgt);
312 bnx2fc_upld_timer, (unsigned long)tgt);
313 mod_timer(&tgt->upld_timer, jiffies + BNX2FC_FW_TIMEOUT);
314
315 wait_event_interruptible(tgt->upld_wait,
316 (test_bit(
317 BNX2FC_FLAG_UPLD_REQ_COMPL,
318 &tgt->flags)));
319 318
320 if (!(test_bit(BNX2FC_FLAG_DESTROYED, &tgt->flags))) 319 if (!(test_bit(BNX2FC_FLAG_DESTROYED, &tgt->flags)))
321 printk(KERN_ERR PFX "ERROR!! destroy timed out\n"); 320 printk(KERN_ERR PFX "ERROR!! destroy timed out\n");
322 321
323 BNX2FC_TGT_DBG(tgt, "destroy wait complete flags = 0x%lx\n", 322 BNX2FC_TGT_DBG(tgt, "destroy wait complete flags = 0x%lx\n",
324 tgt->flags); 323 tgt->flags);
325 if (signal_pending(current))
326 flush_signals(current);
327
328 del_timer_sync(&tgt->upld_timer);
329 324
330 } else if (test_bit(BNX2FC_FLAG_DISABLE_FAILED, &tgt->flags)) { 325 } else if (test_bit(BNX2FC_FLAG_DISABLE_FAILED, &tgt->flags)) {
331 printk(KERN_ERR PFX "ERROR!! DISABLE req failed, destroy" 326 printk(KERN_ERR PFX "ERROR!! DISABLE req failed, destroy"