Skip to contentSkip to conversation

qla2xxx: use kthread_ API

PATCH In review Christoph Hellwig 2 participants 2 messages Feb 14, 2006 – Mar 1, 2006

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qla2xxx: use kthread_ API

Use the kthread_ API instead of opencoding lots of hairy code for kernel thread creation and teardown.

Also switch from semaphore-based thread wakeup to wake_up_process.

drivers/scsi/qla2xxx/qla_def.h +1 -5
Index: linux-2.6/drivers/scsi/qla2xxx/qla_def.h
===================================================================
@@ -2390,11 +2390,7 @@
 	struct sns_cmd_pkt	*sns_cmd;
 	dma_addr_t		sns_cmd_dma;
 
-	pid_t			dpc_pid;
-	int			dpc_should_die;
-	struct completion	dpc_inited;
-	struct completion	dpc_exited;
-	struct semaphore	*dpc_wait;
+	struct task_struct	*dpc_thread;
 	uint8_t dpc_active;                  /* DPC routine is active */
 
 	/* Timeout timers. */
drivers/scsi/qla2xxx/qla_gbl.h +2 -0
Index: linux-2.6/drivers/scsi/qla2xxx/qla_gbl.h
===================================================================
@@ -81,6 +81,8 @@
 
 extern struct fw_blob *qla2x00_request_firmware(scsi_qla_host_t *);
 
+extern void qla2xxx_wake_dpc(scsi_qla_host_t *);
+
 /*
  * Global Function Prototypes in qla_iocb.c source file.
  */
drivers/scsi/qla2xxx/qla_isr.c +2 -5
Index: linux-2.6/drivers/scsi/qla2xxx/qla_isr.c
===================================================================
@@ -838,9 +838,7 @@
 		qla_printk(KERN_WARNING, ha, "Status Entry invalid handle.\n");
 
 		set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);
-		if (ha->dpc_wait && !ha->dpc_active)
-			up(ha->dpc_wait);
-
+		qla2xxx_wake_dpc(ha);
 		return;
 	}
 	cp = sp->cmd;
@@ -1271,8 +1269,7 @@
 		    "Error entry - invalid handle\n");
 
 		set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);
-		if (ha->dpc_wait && !ha->dpc_active)
-			up(ha->dpc_wait);
+		qla2xxx_wake_dpc(ha);
 	}
 }
 
drivers/scsi/qla2xxx/qla_mbx.c +1 -3
Index: linux-2.6/drivers/scsi/qla2xxx/qla_mbx.c
===================================================================
@@ -285,9 +285,7 @@
 			    "Mailbox command timeout occured. Scheduling ISP "
 			    "abort.\n");
 			set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);
-			if (ha->dpc_wait && !ha->dpc_active)
-				up(ha->dpc_wait);
-
+			qla2xxx_wake_dpc(ha);
 		} else if (!abort_active) {
 			/* call abort directly since we are in the DPC thread */
 			DEBUG(printk("%s(%ld): timeout calling abort_isp\n",
drivers/scsi/qla2xxx/qla_os.c +30 -59

183 lines not on this page · raw message

#1 lore raw
Quoted 7 lines · Christoph Hellwig

Use the kthread_ API instead of opencoding lots of hairy code for kernel thread creation and teardown.

Also switch from semaphore-based thread wakeup to wake_up_process.

Ack. Thanks for doing this.

I've also rebased it against the lastest linux-2.6.git tree to correct the rejected hunk and additonal DPC ringing done in qla_sup.c.

I've added something similar to qla4xxx (which I hope will be submitted soon... nudge...nudge...).

--
av

---

drivers/scsi/qla2xxx/qla_def.h +1 -5
index b31a03b..2e16f32 100644
@@ -2414,11 +2414,7 @@ typedef struct scsi_qla_host {
 	struct sns_cmd_pkt	*sns_cmd;
 	dma_addr_t		sns_cmd_dma;
 
-	pid_t			dpc_pid;
-	int			dpc_should_die;
-	struct completion	dpc_inited;
-	struct completion	dpc_exited;
-	struct semaphore	*dpc_wait;
+	struct task_struct	*dpc_thread;
 	uint8_t dpc_active;                  /* DPC routine is active */
 
 	/* Timeout timers. */
drivers/scsi/qla2xxx/qla_gbl.h +2 -0
index ffdc268..e897ead 100644
@@ -81,6 +81,8 @@ extern struct fw_blob *qla2x00_request_f
 
 extern int qla2x00_wait_for_hba_online(scsi_qla_host_t *);
 
+extern void qla2xxx_wake_dpc(scsi_qla_host_t *);
+
 /*
  * Global Function Prototypes in qla_iocb.c source file.
  */
drivers/scsi/qla2xxx/qla_isr.c +2 -5
index 42aa7a7..c15458c 100644
@@ -838,9 +838,7 @@ qla2x00_status_entry(scsi_qla_host_t *ha
 		qla_printk(KERN_WARNING, ha, "Status Entry invalid handle.\n");
 
 		set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);
-		if (ha->dpc_wait && !ha->dpc_active)
-			up(ha->dpc_wait);
-
+		qla2xxx_wake_dpc(ha);
 		return;
 	}
 	cp = sp->cmd;
@@ -1271,8 +1269,7 @@ qla2x00_error_entry(scsi_qla_host_t *ha,
 		    "Error entry - invalid handle\n");
 
 		set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);
-		if (ha->dpc_wait && !ha->dpc_active)
-			up(ha->dpc_wait);
+		qla2xxx_wake_dpc(ha);
 	}
 }
 
drivers/scsi/qla2xxx/qla_mbx.c +1 -3
index 363dfdd..584cc2f 100644
@@ -284,9 +284,7 @@ qla2x00_mailbox_command(scsi_qla_host_t 
 			    "Mailbox command timeout occured. Scheduling ISP "
 			    "abort.\n");
 			set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);
-			if (ha->dpc_wait && !ha->dpc_active)
-				up(ha->dpc_wait);
-
+			qla2xxx_wake_dpc(ha);
 		} else if (!abort_active) {
 			/* call abort directly since we are in the DPC thread */
 			DEBUG(printk("%s(%ld): timeout calling abort_isp\n",
drivers/scsi/qla2xxx/qla_os.c +30 -59

183 lines not on this page · raw message

drivers/scsi/qla2xxx/qla_sup.c +2 -2
index 3866a57..8d68c46 100644
@@ -1354,7 +1354,7 @@ qla2x00_resume_hba(struct scsi_qla_host 
 	/* Resume HBA. */
 	clear_bit(MBX_UPDATE_FLASH_ACTIVE, &ha->mbx_cmd_flags);
 	set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);
-	up(ha->dpc_wait);
+	qla2xxx_wake_dpc(ha);
 	qla2x00_wait_for_hba_online(ha);
 	scsi_unblock_requests(ha->host);
 }
@@ -1652,7 +1652,7 @@ qla24xx_write_optrom_data(struct scsi_ql
 	/* Resume HBA -- RISC reset needed. */
 	clear_bit(MBX_UPDATE_FLASH_ACTIVE, &ha->mbx_cmd_flags);
 	set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);
-	up(ha->dpc_wait);
+	qla2xxx_wake_dpc(ha);
 	qla2x00_wait_for_hba_online(ha);
 	scsi_unblock_requests(ha->host);