Skip to content

Commit 0b05a1f

Browse files
Marcus BarrowJames Bottomley
Marcus Barrow
authored and
James Bottomley
committed
[SCSI] qla2xxx: Use completion routines.
Instead of abusing the semaphore interfaces for mailbox command completions. Additional cleanups and Signed-off-by: Andrew Vasquez <[email protected]> Signed-off-by: James Bottomley <[email protected]>
1 parent a4722cf commit 0b05a1f

File tree

6 files changed

+16
-69
lines changed

6 files changed

+16
-69
lines changed

drivers/scsi/qla2xxx/qla_def.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -2413,9 +2413,9 @@ typedef struct scsi_qla_host {
24132413
#define MBX_INTR_WAIT 2
24142414
#define MBX_UPDATE_FLASH_ACTIVE 3
24152415

2416-
struct semaphore mbx_cmd_sem; /* Serialialize mbx access */
24172416
struct semaphore vport_sem; /* Virtual port synchronization */
2418-
struct semaphore mbx_intr_sem; /* Used for completion notification */
2417+
struct completion mbx_cmd_comp; /* Serialize mbx access */
2418+
struct completion mbx_intr_comp; /* Used for completion notification */
24192419

24202420
uint32_t mbx_flags;
24212421
#define MBX_IN_PROGRESS BIT_0

drivers/scsi/qla2xxx/qla_gbl.h

-2
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,6 @@ extern char *qla2x00_get_fw_version_str(struct scsi_qla_host *, char *);
105105
extern void qla2x00_mark_device_lost(scsi_qla_host_t *, fc_port_t *, int, int);
106106
extern void qla2x00_mark_all_devices_lost(scsi_qla_host_t *, int);
107107

108-
extern int qla2x00_down_timeout(struct semaphore *, unsigned long);
109-
110108
extern struct fw_blob *qla2x00_request_firmware(scsi_qla_host_t *);
111109

112110
extern int qla2x00_wait_for_hba_online(scsi_qla_host_t *);

drivers/scsi/qla2xxx/qla_isr.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ qla2100_intr_handler(int irq, void *dev_id)
104104
if (test_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags) &&
105105
(status & MBX_INTERRUPT) && ha->flags.mbox_int) {
106106
set_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags);
107-
up(&ha->mbx_intr_sem);
107+
complete(&ha->mbx_intr_comp);
108108
}
109109

110110
return (IRQ_HANDLED);
@@ -216,7 +216,7 @@ qla2300_intr_handler(int irq, void *dev_id)
216216
if (test_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags) &&
217217
(status & MBX_INTERRUPT) && ha->flags.mbox_int) {
218218
set_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags);
219-
up(&ha->mbx_intr_sem);
219+
complete(&ha->mbx_intr_comp);
220220
}
221221

222222
return (IRQ_HANDLED);
@@ -1597,7 +1597,7 @@ qla24xx_intr_handler(int irq, void *dev_id)
15971597
if (test_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags) &&
15981598
(status & MBX_INTERRUPT) && ha->flags.mbox_int) {
15991599
set_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags);
1600-
up(&ha->mbx_intr_sem);
1600+
complete(&ha->mbx_intr_comp);
16011601
}
16021602

16031603
return IRQ_HANDLED;
@@ -1734,7 +1734,7 @@ qla24xx_msix_default(int irq, void *dev_id)
17341734
if (test_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags) &&
17351735
(status & MBX_INTERRUPT) && ha->flags.mbox_int) {
17361736
set_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags);
1737-
up(&ha->mbx_intr_sem);
1737+
complete(&ha->mbx_intr_comp);
17381738
}
17391739

17401740
return IRQ_HANDLED;

drivers/scsi/qla2xxx/qla_mbx.c

+4-40
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,6 @@
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, "

drivers/scsi/qla2xxx/qla_mid.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -403,8 +403,9 @@ qla24xx_create_vhost(struct fc_vport *fc_vport)
403403
}
404404
vha->mgmt_svr_loop_id = 10 + vha->vp_idx;
405405

406-
init_MUTEX(&vha->mbx_cmd_sem);
407-
init_MUTEX_LOCKED(&vha->mbx_intr_sem);
406+
init_completion(&vha->mbx_cmd_comp);
407+
complete(&vha->mbx_cmd_comp);
408+
init_completion(&vha->mbx_intr_comp);
408409

409410
INIT_LIST_HEAD(&vha->list);
410411
INIT_LIST_HEAD(&vha->fcports);

drivers/scsi/qla2xxx/qla_os.c

+3-19
Original file line numberDiff line numberDiff line change
@@ -1692,9 +1692,10 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
16921692
/* load the F/W, read paramaters, and init the H/W */
16931693
ha->instance = num_hosts;
16941694

1695-
init_MUTEX(&ha->mbx_cmd_sem);
16961695
init_MUTEX(&ha->vport_sem);
1697-
init_MUTEX_LOCKED(&ha->mbx_intr_sem);
1696+
init_completion(&ha->mbx_cmd_comp);
1697+
complete(&ha->mbx_cmd_comp);
1698+
init_completion(&ha->mbx_intr_comp);
16981699

16991700
INIT_LIST_HEAD(&ha->list);
17001701
INIT_LIST_HEAD(&ha->fcports);
@@ -2739,23 +2740,6 @@ qla2x00_timer(scsi_qla_host_t *ha)
27392740
qla2x00_restart_timer(ha, WATCH_INTERVAL);
27402741
}
27412742

2742-
/* XXX(hch): crude hack to emulate a down_timeout() */
2743-
int
2744-
qla2x00_down_timeout(struct semaphore *sema, unsigned long timeout)
2745-
{
2746-
const unsigned int step = 100; /* msecs */
2747-
unsigned int iterations = jiffies_to_msecs(timeout)/100;
2748-
2749-
do {
2750-
if (!down_trylock(sema))
2751-
return 0;
2752-
if (msleep_interruptible(step))
2753-
break;
2754-
} while (--iterations > 0);
2755-
2756-
return -ETIMEDOUT;
2757-
}
2758-
27592743
/* Firmware interface routines. */
27602744

27612745
#define FW_BLOBS 6

0 commit comments

Comments
 (0)