diff options
author | David Gwynne <dlg@cvs.openbsd.org> | 2007-05-31 18:21:45 +0000 |
---|---|---|
committer | David Gwynne <dlg@cvs.openbsd.org> | 2007-05-31 18:21:45 +0000 |
commit | 7ef27c53aee23663bb2e768d713be7918fdd0c6b (patch) | |
tree | 703d57023af9e86ef95a866512706950acd1e3c8 /sys | |
parent | dde314a98b660e9231a4c64ad9fd05332c111328 (diff) |
remove the scsi task thread, and replace it with the system workq.
"just :wq and do it" tedu@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/ic/mpi.c | 4 | ||||
-rw-r--r-- | sys/scsi/scsi_base.c | 86 | ||||
-rw-r--r-- | sys/scsi/scsiconf.h | 7 |
3 files changed, 9 insertions, 88 deletions
diff --git a/sys/dev/ic/mpi.c b/sys/dev/ic/mpi.c index acb6a24a8ef..930161efd5f 100644 --- a/sys/dev/ic/mpi.c +++ b/sys/dev/ic/mpi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mpi.c,v 1.84 2007/04/03 04:15:50 dlg Exp $ */ +/* $OpenBSD: mpi.c,v 1.85 2007/05/31 18:21:44 dlg Exp $ */ /* * Copyright (c) 2005, 2006 David Gwynne <dlg@openbsd.org> @@ -1907,7 +1907,7 @@ mpi_eventnotify_done(struct mpi_ccb *ccb) if (sc->sc_scsibus == NULL) break; - if (scsi_task(mpi_evt_sas, sc, ccb->ccb_rcb, 1) != 0) { + if (scsi_task(mpi_evt_sas, sc, ccb->ccb_rcb, 0) != 0) { printf("%s: unable to run SAS device status change\n", DEVNAME(sc)); break; diff --git a/sys/scsi/scsi_base.c b/sys/scsi/scsi_base.c index 23080771b65..2fb0a89d5c4 100644 --- a/sys/scsi/scsi_base.c +++ b/sys/scsi/scsi_base.c @@ -1,4 +1,4 @@ -/* $OpenBSD: scsi_base.c,v 1.120 2007/04/10 17:47:56 miod Exp $ */ +/* $OpenBSD: scsi_base.c,v 1.121 2007/05/31 18:21:44 dlg Exp $ */ /* $NetBSD: scsi_base.c,v 1.43 1997/04/02 02:29:36 mycroft Exp $ */ /* @@ -46,25 +46,11 @@ #include <sys/device.h> #include <sys/proc.h> #include <sys/pool.h> -#include <sys/kthread.h> -#include <sys/queue.h> #include <scsi/scsi_all.h> #include <scsi/scsi_disk.h> #include <scsi/scsiconf.h> -struct scsi_task { - void (*func)(void *, void *); - void *sc; - void *arg; - - TAILQ_ENTRY(scsi_task) entry; -}; - -void scsi_create_task_thread(void *); -void scsi_create_task(void *); -void scsi_task_thread(void *); - static __inline struct scsi_xfer *scsi_make_xs(struct scsi_link *, struct scsi_generic *, int cmdlen, u_char *data_addr, int datalen, int retries, int timeout, struct buf *, int flags); @@ -79,10 +65,8 @@ char *scsi_decode_sense(struct scsi_sense_data *, int); #define DECODE_ASC_ASCQ 2 #define DECODE_SKSV 3 +int scsi_running = 0; struct pool scsi_xfer_pool; -struct pool scsi_task_pool; -TAILQ_HEAD(, scsi_task) scsi_task_list; -volatile int scsi_running = 0; /* * Called when a scsibus is attached to initialize global data. @@ -101,14 +85,6 @@ scsi_init() /* Initialize the scsi_xfer pool. */ pool_init(&scsi_xfer_pool, sizeof(struct scsi_xfer), 0, 0, 0, "scxspl", NULL); - - /* Initialize the scsi_task pool. */ - pool_init(&scsi_task_pool, sizeof(struct scsi_task), 0, - 0, 0, "sctkpl", NULL); - - /* Get the creation of the task thread underway. */ - TAILQ_INIT(&scsi_task_list); - kthread_create_deferred(scsi_create_task_thread, NULL); } void @@ -116,64 +92,6 @@ scsi_deinit() { if (--scsi_running) return; - - wakeup(&scsi_task_list); -} - -void -scsi_create_task_thread(void *arg) -{ - if (kthread_create(scsi_task_thread, NULL, NULL, "scsi") != 0) - panic("unable to create scsi task thread"); -} - -void -scsi_task_thread(void *arg) -{ - struct scsi_task *task; - int s; - - s = splbio(); - while (scsi_running) { - while ((task = TAILQ_FIRST(&scsi_task_list)) != NULL) { - TAILQ_REMOVE(&scsi_task_list, task, entry); - splx(s); - - task->func(task->sc, task->arg); - - s = splbio(); - pool_put(&scsi_task_pool, task); - } - tsleep(&scsi_task_list, PWAIT, "slacking", 10 * hz); - } - - if (!TAILQ_EMPTY(&scsi_task_list)) - panic("outstanding scsi tasks"); - splx(s); - - kthread_exit(0); -} - -/* - * Must be called at splbio. - */ -int -scsi_task(void (*func)(void *, void *), void *sc, void *arg, int nosleep) -{ - struct scsi_task *task; - - task = pool_get(&scsi_task_pool, nosleep ? PR_NOWAIT : PR_WAITOK); - if (task == NULL) - return (ENOMEM); - - task->func = func; - task->sc = sc; - task->arg = arg; - - TAILQ_INSERT_TAIL(&scsi_task_list, task, entry); - wakeup(&scsi_task_list); - - return (0); } /* diff --git a/sys/scsi/scsiconf.h b/sys/scsi/scsiconf.h index b0c167a87e7..4823c6b492e 100644 --- a/sys/scsi/scsiconf.h +++ b/sys/scsi/scsiconf.h @@ -1,4 +1,4 @@ -/* $OpenBSD: scsiconf.h,v 1.84 2007/04/10 17:47:56 miod Exp $ */ +/* $OpenBSD: scsiconf.h,v 1.85 2007/05/31 18:21:44 dlg Exp $ */ /* $NetBSD: scsiconf.h,v 1.35 1997/04/02 02:29:38 mycroft Exp $ */ /* @@ -52,6 +52,7 @@ #include <sys/queue.h> #include <sys/timeout.h> +#include <sys/workq.h> #include <machine/cpu.h> #include <scsi/scsi_debug.h> @@ -302,9 +303,11 @@ struct scsi_xfer { const void *scsi_inqmatch(struct scsi_inquiry_data *, const void *, int, int, int *); +#define scsi_task(_f, _a1, _a2, _fl) \ + workq_add_task(NULL, (_f), (_a1), (_a2), (_fl)) + void scsi_init(void); void scsi_deinit(void); -int scsi_task(void (*func)(void *, void *), void *, void *, int); struct scsi_xfer * scsi_get_xs(struct scsi_link *, int); void scsi_free_xs(struct scsi_xfer *, int); |