88
99#include <linux/delay.h>
1010
11- static void
12- qla2x00_mbx_sem_timeout (unsigned long data )
13- {
14- struct semaphore * sem_ptr = (struct semaphore * )data ;
15-
16- DEBUG11 (printk ("qla2x00_sem_timeout: entered.\n" ));
17-
18- if (sem_ptr != NULL ) {
19- up (sem_ptr );
20- }
21-
22- DEBUG11 (printk ("qla2x00_mbx_sem_timeout: exiting.\n" ));
23- }
2411
2512/*
2613 * qla2x00_mailbox_command
@@ -47,7 +34,6 @@ qla2x00_mailbox_command(scsi_qla_host_t *pvha, mbx_cmd_t *mcp)
4734 int rval ;
4835 unsigned long flags = 0 ;
4936 device_reg_t __iomem * reg ;
50- struct timer_list tmp_intr_timer ;
5137 uint8_t abort_active ;
5238 uint8_t io_lock_on ;
5339 uint16_t command ;
@@ -72,7 +58,8 @@ qla2x00_mailbox_command(scsi_qla_host_t *pvha, mbx_cmd_t *mcp)
7258 * non ISP abort time.
7359 */
7460 if (!abort_active ) {
75- if (qla2x00_down_timeout (& ha -> mbx_cmd_sem , mcp -> tov * HZ )) {
61+ if (!wait_for_completion_timeout (& ha -> mbx_cmd_comp ,
62+ mcp -> tov * HZ )) {
7663 /* Timeout occurred. Return error. */
7764 DEBUG2_3_11 (printk ("%s(%ld): cmd access timeout. "
7865 "Exiting.\n" , __func__ , ha -> host_no ));
@@ -135,22 +122,6 @@ qla2x00_mailbox_command(scsi_qla_host_t *pvha, mbx_cmd_t *mcp)
135122 /* Wait for mbx cmd completion until timeout */
136123
137124 if (!abort_active && io_lock_on ) {
138- /* sleep on completion semaphore */
139- DEBUG11 (printk ("%s(%ld): INTERRUPT MODE. Initializing timer.\n" ,
140- __func__ , ha -> host_no ));
141-
142- init_timer (& tmp_intr_timer );
143- tmp_intr_timer .data = (unsigned long )& ha -> mbx_intr_sem ;
144- tmp_intr_timer .expires = jiffies + mcp -> tov * HZ ;
145- tmp_intr_timer .function =
146- (void (* )(unsigned long ))qla2x00_mbx_sem_timeout ;
147-
148- DEBUG11 (printk ("%s(%ld): Adding timer.\n" , __func__ ,
149- ha -> host_no ));
150- add_timer (& tmp_intr_timer );
151-
152- DEBUG11 (printk ("%s(%ld): going to unlock & sleep. "
153- "time=0x%lx.\n" , __func__ , ha -> host_no , jiffies ));
154125
155126 set_bit (MBX_INTR_WAIT , & ha -> mbx_cmd_flags );
156127
@@ -160,17 +131,10 @@ qla2x00_mailbox_command(scsi_qla_host_t *pvha, mbx_cmd_t *mcp)
160131 WRT_REG_WORD (& reg -> isp .hccr , HCCR_SET_HOST_INT );
161132 spin_unlock_irqrestore (& ha -> hardware_lock , flags );
162133
163- /* Wait for either the timer to expire
164- * or the mbox completion interrupt
165- */
166- down (& ha -> mbx_intr_sem );
134+ wait_for_completion_timeout (& ha -> mbx_intr_comp , mcp -> tov * HZ );
167135
168- DEBUG11 (printk ("%s(%ld): waking up. time=0x%lx\n" , __func__ ,
169- ha -> host_no , jiffies ));
170136 clear_bit (MBX_INTR_WAIT , & ha -> mbx_cmd_flags );
171137
172- /* delete the timer */
173- del_timer (& tmp_intr_timer );
174138 } else {
175139 DEBUG3_11 (printk ("%s(%ld): cmd=%x POLLING MODE.\n" , __func__ ,
176140 ha -> host_no , command ));
@@ -299,7 +263,7 @@ qla2x00_mailbox_command(scsi_qla_host_t *pvha, mbx_cmd_t *mcp)
299263
300264 /* Allow next mbx cmd to come in. */
301265 if (!abort_active )
302- up (& ha -> mbx_cmd_sem );
266+ complete (& ha -> mbx_cmd_comp );
303267
304268 if (rval ) {
305269 DEBUG2_3_11 (printk ("%s(%ld): **** FAILED. mbx0=%x, mbx1=%x, "
0 commit comments