Only in /home/s/reference/FreeBSD/src/sys/dev/twa: CVS
Only in sys/dev/raid/twa: Makefile
diff -uwr /home/s/reference/FreeBSD/src/sys/dev/twa/tw_cl_init.c sys/dev/raid/twa/tw_cl_init.c
--- /home/s/reference/FreeBSD/src/sys/dev/twa/tw_cl_init.c	2010-06-11 10:28:57 +0200
+++ sys/dev/raid/twa/tw_cl_init.c	2010-07-26 04:25:00 +0200
@@ -706,5 +706,3 @@
 		tw_cli_req_q_insert_tail(req, TW_CLI_FREE_Q);
 	return(error);
 }
-
-
diff -uwr /home/s/reference/FreeBSD/src/sys/dev/twa/tw_cl_intr.c sys/dev/raid/twa/tw_cl_intr.c
--- /home/s/reference/FreeBSD/src/sys/dev/twa/tw_cl_intr.c	2010-06-11 10:28:57 +0200
+++ sys/dev/raid/twa/tw_cl_intr.c	2010-07-26 04:25:00 +0200
@@ -750,4 +750,3 @@
 		TWA_CONTROL_DISABLE_INTERRUPTS);
 	ctlr->interrupts_enabled = TW_CL_FALSE;
 }
-
diff -uwr /home/s/reference/FreeBSD/src/sys/dev/twa/tw_cl_io.c sys/dev/raid/twa/tw_cl_io.c
--- /home/s/reference/FreeBSD/src/sys/dev/twa/tw_cl_io.c	2010-06-11 10:28:57 +0200
+++ sys/dev/raid/twa/tw_cl_io.c	2010-07-26 04:25:00 +0200
@@ -49,9 +49,9 @@
 #include "tw_cl_externs.h"
 #include "tw_osl_ioctl.h"
 
-#include <cam/cam.h>
-#include <cam/cam_ccb.h>
-#include <cam/cam_xpt_sim.h>
+#include <bus/cam/cam.h>
+#include <bus/cam/cam_ccb.h>
+#include <bus/cam/cam_xpt_sim.h>
 
 
 
@@ -1428,4 +1428,3 @@
 		}
 	}
 }
-
diff -uwr /home/s/reference/FreeBSD/src/sys/dev/twa/tw_cl_misc.c sys/dev/raid/twa/tw_cl_misc.c
--- /home/s/reference/FreeBSD/src/sys/dev/twa/tw_cl_misc.c	2010-06-18 10:33:55 +0200
+++ sys/dev/raid/twa/tw_cl_misc.c	2010-07-26 04:25:00 +0200
@@ -1036,4 +1036,3 @@
 }
 
 #endif /* TW_OSL_DEBUG */
-
diff -uwr /home/s/reference/FreeBSD/src/sys/dev/twa/tw_osl.h sys/dev/raid/twa/tw_osl.h
--- /home/s/reference/FreeBSD/src/sys/dev/twa/tw_osl.h	2010-06-11 10:28:57 +0200
+++ sys/dev/raid/twa/tw_osl.h	2010-07-26 04:37:40 +0200
@@ -95,8 +95,8 @@
 /* Driver's request packet. */
 struct tw_osli_req_context {
 	struct tw_cl_req_handle	req_handle;/* tag to track req b/w OSL & CL */
-	struct mtx		ioctl_wake_timeout_lock_handle;/* non-spin lock used to detect ioctl timeout */
-	struct mtx		*ioctl_wake_timeout_lock;/* ptr to above lock */
+	struct lock		ioctl_wake_timeout_lock_handle;/* non-spin lock used to detect ioctl timeout */
+	struct lock		*ioctl_wake_timeout_lock;/* ptr to above lock */
 	struct twa_softc	*ctlr;	/* ptr to OSL's controller context */
 	TW_VOID			*data;	/* ptr to data being passed to CL */
 	TW_UINT32		length;	/* length of buf being passed to CL */
@@ -144,12 +144,12 @@
 	struct tw_cl_link	req_q_head[TW_OSLI_Q_COUNT];
 
 	struct task		deferred_intr_callback;/* taskqueue function */
-	struct mtx		io_lock_handle;/* general purpose lock */
-	struct mtx		*io_lock;/* ptr to general purpose lock */
-	struct mtx		q_lock_handle;	/* queue manipulation lock */
-	struct mtx		*q_lock;/* ptr to queue manipulation lock */
-	struct mtx		sim_lock_handle;/* sim lock shared with cam */
-	struct mtx		*sim_lock;/* ptr to sim lock */
+	struct spinlock		io_lock_handle;/* general purpose lock */
+	struct spinlock		*io_lock;/* ptr to general purpose lock */
+	struct spinlock		q_lock_handle;	/* queue manipulation lock */
+	struct spinlock		*q_lock;/* ptr to queue manipulation lock */
+	struct lock		sim_lock_handle;/* sim lock shared with cam */
+	struct lock		*sim_lock;/* ptr to sim lock */
 
 #ifdef TW_OSL_DEBUG
 	struct tw_osli_q_stats	q_stats[TW_OSLI_Q_COUNT];/* queue statistics */
@@ -229,10 +229,10 @@
 static __inline	TW_VOID
 tw_osli_req_q_insert_head(struct tw_osli_req_context *req, TW_UINT8 q_type)
 {
-	mtx_lock_spin(req->ctlr->q_lock);
+	spin_lock_wr(req->ctlr->q_lock);
 	TW_CL_Q_INSERT_HEAD(&(req->ctlr->req_q_head[q_type]), &(req->link));
 	TW_OSLI_Q_INSERT(req->ctlr, q_type);
-	mtx_unlock_spin(req->ctlr->q_lock);
+	spin_unlock_wr(req->ctlr->q_lock);
 }
 
 
@@ -241,10 +241,10 @@
 static __inline	TW_VOID
 tw_osli_req_q_insert_tail(struct tw_osli_req_context *req, TW_UINT8 q_type)
 {
-	mtx_lock_spin(req->ctlr->q_lock);
+	spin_lock_wr(req->ctlr->q_lock);
 	TW_CL_Q_INSERT_TAIL(&(req->ctlr->req_q_head[q_type]), &(req->link));
 	TW_OSLI_Q_INSERT(req->ctlr, q_type);
-	mtx_unlock_spin(req->ctlr->q_lock);
+	spin_unlock_wr(req->ctlr->q_lock);
 }
 
 
@@ -256,7 +256,7 @@
 	struct tw_osli_req_context	*req = NULL;
 	struct tw_cl_link		*link;
 
-	mtx_lock_spin(sc->q_lock);
+	spin_lock_wr(sc->q_lock);
 	if ((link = TW_CL_Q_FIRST_ITEM(&(sc->req_q_head[q_type]))) !=
 		TW_CL_NULL) {
 		req = TW_CL_STRUCT_HEAD(link,
@@ -264,7 +264,7 @@
 		TW_CL_Q_REMOVE_ITEM(&(sc->req_q_head[q_type]), &(req->link));
 		TW_OSLI_Q_REMOVE(sc, q_type);
 	}
-	mtx_unlock_spin(sc->q_lock);
+	spin_unlock_wr(sc->q_lock);
 	return(req);
 }
 
@@ -274,10 +274,10 @@
 static __inline TW_VOID
 tw_osli_req_q_remove_item(struct tw_osli_req_context *req, TW_UINT8 q_type)
 {
-	mtx_lock_spin(req->ctlr->q_lock);
+	spin_lock_wr(req->ctlr->q_lock);
 	TW_CL_Q_REMOVE_ITEM(&(req->ctlr->req_q_head[q_type]), &(req->link));
 	TW_OSLI_Q_REMOVE(req->ctlr, q_type);
-	mtx_unlock_spin(req->ctlr->q_lock);
+	spin_unlock_wr(req->ctlr->q_lock);
 }
 
 
@@ -294,7 +294,7 @@
 
 #define tw_osli_dbg_printf(dbg_level, fmt, args...)			\
 	if (dbg_level <= TW_DEBUG_LEVEL_FOR_OSL)			\
-		printf("%s: " fmt "\n",	__func__, ##args)
+		kprintf("%s: " fmt "\n", __func__, ##args)
 
 #else /* TW_OSL_DEBUG */
 
diff -uwr /home/s/reference/FreeBSD/src/sys/dev/twa/tw_osl_cam.c sys/dev/raid/twa/tw_osl_cam.c
--- /home/s/reference/FreeBSD/src/sys/dev/twa/tw_osl_cam.c	2010-06-11 10:28:57 +0200
+++ sys/dev/raid/twa/tw_osl_cam.c	2010-07-26 07:46:21 +0200
@@ -41,21 +41,23 @@
  */
 
 
-#include <dev/twa/tw_osl_includes.h>
+#include <dev/raid/twa/tw_osl_includes.h>
 
-#include <cam/cam.h>
-#include <cam/cam_ccb.h>
-#include <cam/cam_sim.h>
-#include <cam/cam_xpt_sim.h>
-#include <cam/cam_debug.h>
-#include <cam/cam_periph.h>
+#include <bus/cam/cam.h>
+#include <bus/cam/cam_ccb.h>
+#include <bus/cam/cam_sim.h>
+#include <bus/cam/cam_xpt_sim.h>
+#include <bus/cam/cam_debug.h>
+#include <bus/cam/cam_periph.h>
+#include <bus/cam/cam_xpt_periph.h>
 
-#include <cam/scsi/scsi_all.h>
-#include <cam/scsi/scsi_message.h>
+#include <bus/cam/scsi/scsi_all.h>
+#include <bus/cam/scsi/scsi_message.h>
 
 static TW_VOID	twa_action(struct cam_sim *sim, union ccb *ccb);
 static TW_VOID	twa_poll(struct cam_sim *sim);
 static TW_VOID	twa_timeout(TW_VOID *arg);
+static TW_VOID	twa_bus_scan_cb(struct cam_periph *periph, union ccb *ccb);
 
 static TW_INT32	tw_osli_execute_scsi(struct tw_osli_req_context *req,
 	union ccb *ccb);
@@ -102,7 +104,6 @@
 			device_get_unit(sc->bus_dev), sc->sim_lock,
 			TW_OSLI_MAX_NUM_IOS, 1, devq);
 	if (sc->sim == NULL) {
-		cam_simq_free(devq);
 		tw_osli_printf(sc, "error = %d",
 			TW_CL_SEVERITY_ERROR_STRING,
 			TW_CL_MESSAGE_SOURCE_FREEBSD_DRIVER,
@@ -116,9 +117,9 @@
 	 * Register the bus.
 	 */
 	tw_osli_dbg_dprintf(3, sc, "Calling xpt_bus_register");
-	mtx_lock(sc->sim_lock);
-	if (xpt_bus_register(sc->sim, sc->bus_dev, 0) != CAM_SUCCESS) {
-		cam_sim_free(sc->sim, TRUE);
+	lockmgr(sc->sim_lock, LK_EXCLUSIVE);
+	if (xpt_bus_register(sc->sim, 0) != CAM_SUCCESS) {
+		cam_sim_free(sc->sim);
 		sc->sim = NULL; /* so cam_detach will not try to free it */
 		tw_osli_printf(sc, "error = %d",
 			TW_CL_SEVERITY_ERROR_STRING,
@@ -126,7 +127,7 @@
 			0x2102,
 			"Failed to register the bus",
 			ENXIO);
-		mtx_unlock(sc->sim_lock);
+		lockmgr(sc->sim_lock, LK_RELEASE);
 		return(ENXIO);
 	}
 
@@ -137,17 +138,17 @@
 				CAM_LUN_WILDCARD) != CAM_REQ_CMP) {
 		xpt_bus_deregister(cam_sim_path (sc->sim));
 		/* Passing TRUE to cam_sim_free will free the devq as well. */
-		cam_sim_free(sc->sim, TRUE);
+		cam_sim_free(sc->sim);
 		tw_osli_printf(sc, "error = %d",
 			TW_CL_SEVERITY_ERROR_STRING,
 			TW_CL_MESSAGE_SOURCE_FREEBSD_DRIVER,
 			0x2103,
 			"Failed to create path",
 			ENXIO);
-		mtx_unlock(sc->sim_lock);
+		lockmgr(sc->sim_lock, LK_RELEASE);
 		return(ENXIO);
 	}
-	mtx_unlock(sc->sim_lock);
+	lockmgr(sc->sim_lock, LK_RELEASE);
 
 	tw_osli_dbg_dprintf(3, sc, "exiting");
 	return(0);
@@ -168,17 +169,17 @@
 {
 	tw_osli_dbg_dprintf(3, sc, "entered");
 
-	mtx_lock(sc->sim_lock);
+	lockmgr(sc->sim_lock, LK_EXCLUSIVE);
            
 	if (sc->path)
 		xpt_free_path(sc->path);
 	if (sc->sim) {
 		xpt_bus_deregister(cam_sim_path(sc->sim));
 		/* Passing TRUE to cam_sim_free will free the devq as well. */
-		cam_sim_free(sc->sim, TRUE);
+		cam_sim_free(sc->sim);
 	}
 	/* It's ok have 1 hold count while destroying the mutex */
-	mtx_destroy(sc->sim_lock);
+	lockuninit(sc->sim_lock);
 }
 
 
@@ -306,8 +307,8 @@
 		return(1);
 	}
 
-	ccb_h->timeout_ch = timeout(twa_timeout, req,
-		(ccb_h->timeout * hz) / 1000);
+	callout_reset(&ccb->ccb_h.timeout_ch,
+		(ccb_h->timeout * hz) / 1000, twa_timeout, ccb);
 	/*
 	 * twa_map_load_data_callback will fill in the SGL,
 	 * and submit the I/O.
@@ -370,7 +371,7 @@
 			"Received Reset Bus request from CAM",
 			" ");
 
-		mtx_unlock(sc->sim_lock);
+		lockmgr(sc->sim_lock, LK_RELEASE);
 		if (tw_cl_reset_ctlr(&sc->ctlr_handle)) {
 			tw_cl_create_event(&(sc->ctlr_handle), TW_CL_TRUE,
 				TW_CL_MESSAGE_SOURCE_FREEBSD_DRIVER,
@@ -382,7 +383,7 @@
 		else
 			ccb_h->status = CAM_REQ_CMP;
 
-		mtx_lock(sc->sim_lock);
+		lockmgr(sc->sim_lock, LK_EXCLUSIVE);
 		xpt_done(ccb);
 		break;
 
@@ -532,22 +533,53 @@
 		return(ENXIO);
 	if ((ccb = xpt_alloc_ccb()) == NULL)
 		return(ENOMEM);
-	mtx_lock(sc->sim_lock);
+	lockmgr(sc->sim_lock, LK_EXCLUSIVE);
 	if (xpt_create_path(&ccb->ccb_h.path, xpt_periph, cam_sim_path(sc->sim),
 	    CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD) != CAM_REQ_CMP) {
 		xpt_free_ccb(ccb);
-		mtx_unlock(sc->sim_lock);
+		lockmgr(sc->sim_lock, LK_RELEASE);
 		return(EIO);
 	}
 
-	xpt_rescan(ccb);
-	mtx_unlock(sc->sim_lock);
+	xpt_setup_ccb(&ccb->ccb_h, ccb->ccb_h.path, 5/*priority (low)*/);
+	ccb->ccb_h.func_code = XPT_SCAN_BUS;
+	ccb->ccb_h.cbfcnp = twa_bus_scan_cb;
+	ccb->crcn.flags = CAM_FLAG_NONE;
+	xpt_action(ccb);
+
+	lockmgr(sc->sim_lock, LK_RELEASE);
 	return(0);
 }
 
 
 
 /*
+ * Function name:	twa_bus_scan_cb
+ * Description:		Callback from CAM on a bus scan request.
+ *
+ * Input:		periph	-- we don't use this
+ *			ccb	-- bus scan request ccb that we sent to CAM
+ * Output:		None
+ * Return value:	None
+ */
+static TW_VOID
+twa_bus_scan_cb(struct cam_periph *periph, union ccb *ccb)
+{
+	tw_osli_dbg_printf(3, "entering");
+
+	if (ccb->ccb_h.status != CAM_REQ_CMP)
+		kprintf("cam_scan_callback: failure status = %x\n",
+			ccb->ccb_h.status);
+	else
+		tw_osli_dbg_printf(3, "success");
+
+	xpt_free_path(ccb->ccb_h.path);
+	kfree(ccb, M_TEMP);
+}
+
+
+
+/*
  * Function name:	tw_osli_disallow_new_requests
  * Description:		Calls the appropriate CAM function, so as to freeze
  *			the flow of new requests from CAM to this controller.
@@ -655,7 +687,7 @@
 
 	tw_osli_unmap_request(req);
 
-	untimeout(twa_timeout, req, ccb->ccb_h.timeout_ch);
+	callout_stop(&ccb->ccb_h.timeout_ch);
 	if (req->error_code) {
 		/* This request never got submitted to the firmware. */
 		if (req->error_code == EBUSY) {
@@ -700,11 +732,10 @@
 	}
 
 	ccb->ccb_h.status &= ~CAM_SIM_QUEUED;
-	mtx_lock(sc->sim_lock);
+	lockmgr(sc->sim_lock, LK_EXCLUSIVE);
 	xpt_done(ccb);
-	mtx_unlock(sc->sim_lock);
+	lockmgr(sc->sim_lock, LK_RELEASE);
 	if (! req->error_code)
 		 /* twa_action will free the request otherwise */
 		tw_osli_req_q_insert_tail(req, TW_OSLI_FREE_Q);
 }
-
diff -uwr /home/s/reference/FreeBSD/src/sys/dev/twa/tw_osl_freebsd.c sys/dev/raid/twa/tw_osl_freebsd.c
--- /home/s/reference/FreeBSD/src/sys/dev/twa/tw_osl_freebsd.c	2010-06-11 10:28:57 +0200
+++ sys/dev/raid/twa/tw_osl_freebsd.c	2010-07-26 06:59:46 +0200
@@ -44,10 +44,10 @@
  */
 
 
-#include <dev/twa/tw_osl_includes.h>
-#include <dev/twa/tw_cl_fwif.h>
-#include <dev/twa/tw_cl_ioctl.h>
-#include <dev/twa/tw_osl_ioctl.h>
+#include <dev/raid/twa/tw_osl_includes.h>
+#include <dev/raid/twa/tw_cl_fwif.h>
+#include <dev/raid/twa/tw_cl_ioctl.h>
+#include <dev/raid/twa/tw_osl_ioctl.h>
 
 #ifdef TW_OSL_DEBUG
 TW_INT32	TW_DEBUG_LEVEL_FOR_OSL = TW_OSL_DEBUG;
@@ -61,12 +61,11 @@
 static	d_close_t		twa_close;
 static	d_ioctl_t		twa_ioctl;
 
-static struct cdevsw twa_cdevsw = {
-	.d_version =	D_VERSION,
+static struct dev_ops twa_ops = {
+	{ "twa", 0, 0 },
 	.d_open =	twa_open,
 	.d_close =	twa_close,
 	.d_ioctl =	twa_ioctl,
-	.d_name =	"twa",
 };
 
 static devclass_t	twa_devclass;
@@ -86,8 +85,9 @@
  *			non-zero-- failure
  */
 static TW_INT32
-twa_open(struct cdev *dev, TW_INT32 flags, TW_INT32 fmt, struct thread *proc)
+twa_open(struct dev_open_args *ap)
 {
+	cdev_t			dev = ap->a_head.a_dev;
 	struct twa_softc	*sc = (struct twa_softc *)(dev->si_drv1);
 
 	tw_osli_dbg_dprintf(5, sc, "entered");
@@ -111,8 +111,9 @@
  *			non-zero-- failure
  */
 static TW_INT32
-twa_close(struct cdev *dev, TW_INT32 flags, TW_INT32 fmt, struct thread *proc)
+twa_close(struct dev_close_args *ap)
 {
+	cdev_t			dev = ap->a_head.a_dev;
 	struct twa_softc	*sc = (struct twa_softc *)(dev->si_drv1);
 
 	tw_osli_dbg_dprintf(5, sc, "entered");
@@ -140,8 +141,11 @@
  *			non-zero-- failure
  */
 static TW_INT32
-twa_ioctl(struct cdev *dev, u_long cmd, caddr_t buf, TW_INT32 flags, struct thread *proc)
+twa_ioctl(struct dev_ioctl_args *ap)
 {
+	cdev_t			dev = ap->a_head.a_dev;
+	u_long			cmd = ap->a_cmd;
+	caddr_t			buf = ap->a_data;
 	struct twa_softc	*sc = (struct twa_softc *)(dev->si_drv1);
 	TW_INT32		error;
 
@@ -173,7 +177,9 @@
 static TW_INT32	twa_attach(device_t dev);
 static TW_INT32	twa_detach(device_t dev);
 static TW_INT32	twa_shutdown(device_t dev);
+#if 0 /* XXX swildner */
 static TW_VOID	twa_busdma_lock(TW_VOID *lock_arg, bus_dma_lock_op_t op);
+#endif
 static TW_VOID	twa_pci_intr(TW_VOID *arg);
 
 static TW_INT32	tw_osli_alloc_mem(struct twa_softc *sc);
@@ -228,7 +234,7 @@
 		device_set_desc(dev, TW_OSLI_DEVICE_NAME);
 		/* Print the driver version only once. */
 		if (first_ctlr) {
-			printf("3ware device driver for 9000 series storage "
+			kprintf("3ware device driver for 9000 series storage "
 				"controllers, version: %s\n",
 				TW_OSL_DRIVER_VERSION_STRING);
 			first_ctlr = 0;
@@ -272,11 +278,11 @@
 
 	/* Initialize the mutexes right here. */
 	sc->io_lock = &(sc->io_lock_handle);
-	mtx_init(sc->io_lock, "tw_osl_io_lock", NULL, MTX_SPIN);
+	spin_init(sc->io_lock);
 	sc->q_lock = &(sc->q_lock_handle);
-	mtx_init(sc->q_lock, "tw_osl_q_lock", NULL, MTX_SPIN);
+	spin_init(sc->q_lock);
 	sc->sim_lock = &(sc->sim_lock_handle);
-	mtx_init(sc->sim_lock, "tw_osl_sim_lock", NULL, MTX_DEF | MTX_RECURSE);
+	lockinit(sc->sim_lock, "tw_osl_sim_lock", 0, LK_CANRECURSE);
 
 	sysctl_ctx_init(&sc->sysctl_ctxt);
 	sc->sysctl_tree = SYSCTL_ADD_NODE(&sc->sysctl_ctxt,
@@ -355,9 +361,9 @@
 		return(ENXIO);
 	}
 	if ((error = bus_setup_intr(sc->bus_dev, sc->irq_res,
-			INTR_TYPE_CAM | INTR_MPSAFE,
-			NULL, twa_pci_intr,	    
-			sc, &sc->intr_handle))) {
+			0,
+			twa_pci_intr,
+			sc, &sc->intr_handle, NULL))) {
 		tw_osli_printf(sc, "error = %d",
 			TW_CL_SEVERITY_ERROR_STRING,
 			TW_CL_MESSAGE_SOURCE_FREEBSD_DRIVER,
@@ -396,7 +402,7 @@
 	}
 
 	/* Create the control device. */
-	sc->ctrl_dev = make_dev(&twa_cdevsw, device_get_unit(sc->bus_dev),
+	sc->ctrl_dev = make_dev(&twa_ops, device_get_unit(sc->bus_dev),
 			UID_ROOT, GID_OPERATOR, S_IRUSR | S_IWUSR,
 			"twa%d", device_get_unit(sc->bus_dev));
 	sc->ctrl_dev->si_drv1 = sc;
@@ -458,7 +464,7 @@
 		return(error);
 	}
 
-	if ((sc->non_dma_mem = malloc(non_dma_mem_size, TW_OSLI_MALLOC_CLASS,
+	if ((sc->non_dma_mem = kmalloc(non_dma_mem_size, TW_OSLI_MALLOC_CLASS,
 				M_WAITOK)) == NULL) {
 		tw_osli_printf(sc, "error = %d",
 			TW_CL_SEVERITY_ERROR_STRING,
@@ -480,8 +486,6 @@
 				max_sg_elements,	/* nsegments */
 				TW_CL_MAX_IO_SIZE,	/* maxsegsize */
 				0,			/* flags */
-				NULL,			/* lockfunc */
-				NULL,			/* lockfuncarg */
 				&sc->parent_tag		/* tag */)) {
 		tw_osli_printf(sc, "error = %d",
 			TW_CL_SEVERITY_ERROR_STRING,
@@ -503,8 +507,6 @@
 				1,			/* nsegments */
 				BUS_SPACE_MAXSIZE,	/* maxsegsize */
 				0,			/* flags */
-				NULL,			/* lockfunc */
-				NULL,			/* lockfuncarg */
 				&sc->cmd_tag		/* tag */)) {
 		tw_osli_printf(sc, "error = %d",
 			TW_CL_SEVERITY_ERROR_STRING,
@@ -550,8 +552,10 @@
 				max_sg_elements,	/* nsegments */
 				TW_CL_MAX_IO_SIZE,	/* maxsegsize */
 				BUS_DMA_ALLOCNOW,	/* flags */
+#if 0 /* XXX swildner */
 				twa_busdma_lock,	/* lockfunc */
 				sc->io_lock,		/* lockfuncarg */
+#endif
 				&sc->dma_tag		/* tag */)) {
 		tw_osli_printf(sc, "error = %d",
 			TW_CL_SEVERITY_ERROR_STRING,
@@ -576,8 +580,10 @@
 				max_sg_elements,	/* nsegments */
 				TW_CL_MAX_IO_SIZE,	/* maxsegsize */
 				BUS_DMA_ALLOCNOW,	/* flags */
+#if 0 /* XXX swildner */
 				twa_busdma_lock,	/* lockfunc */
 				sc->io_lock,		/* lockfuncarg */
+#endif
 				&sc->ioctl_tag		/* tag */)) {
 		tw_osli_printf(sc, "error = %d",
 			TW_CL_SEVERITY_ERROR_STRING,
@@ -605,7 +611,7 @@
 	tw_osli_req_q_init(sc, TW_OSLI_BUSY_Q);
 
 	if ((sc->req_ctx_buf = (struct tw_osli_req_context *)
-			malloc((sizeof(struct tw_osli_req_context) *
+			kmalloc((sizeof(struct tw_osli_req_context) *
 				TW_OSLI_MAX_NUM_REQUESTS),
 				TW_OSLI_MALLOC_CLASS, M_WAITOK)) == NULL) {
 		tw_osli_printf(sc, "error = %d",
@@ -634,7 +640,7 @@
 
 		/* Initialize the ioctl wakeup/ timeout mutex */
 		req->ioctl_wake_timeout_lock = &(req->ioctl_wake_timeout_lock_handle);
-		mtx_init(req->ioctl_wake_timeout_lock, "tw_ioctl_wake_timeout_lock", NULL, MTX_DEF);
+		lockinit(req->ioctl_wake_timeout_lock, "tw_ioctl_wake_timeout_lock", 0, 0);
 
 		/* Insert request into the free queue. */
 		tw_osli_req_q_insert_tail(req, TW_OSLI_FREE_Q);
@@ -667,7 +673,7 @@
 	if (sc->req_ctx_buf)
 		while ((req = tw_osli_req_q_remove_head(sc, TW_OSLI_FREE_Q)) !=
 			NULL) {
-			mtx_destroy(req->ioctl_wake_timeout_lock);
+			lockuninit(req->ioctl_wake_timeout_lock);
 
 			if ((error = bus_dmamap_destroy(sc->dma_tag,
 					req->dma_map)))
@@ -683,10 +689,10 @@
 
 	/* Free all memory allocated so far. */
 	if (sc->req_ctx_buf)
-		free(sc->req_ctx_buf, TW_OSLI_MALLOC_CLASS);
+		kfree(sc->req_ctx_buf, TW_OSLI_MALLOC_CLASS);
 
 	if (sc->non_dma_mem)
-		free(sc->non_dma_mem, TW_OSLI_MALLOC_CLASS);
+		kfree(sc->non_dma_mem, TW_OSLI_MALLOC_CLASS);
 
 	if (sc->dma_mem) {
 		bus_dmamap_unload(sc->cmd_tag, sc->cmd_map);
@@ -735,6 +741,7 @@
 			tw_osli_dbg_dprintf(1, sc,
 				"release_resource(io) returned %d", error);
 
+	dev_ops_remove_minor(&twa_ops, device_get_unit(sc->bus_dev));
 
 	/* Destroy the control device. */
 	if (sc->ctrl_dev != (struct cdev *)NULL)
@@ -823,6 +830,7 @@
 
 
 
+#if 0 /* XXX swildner */
 /*
  * Function name:	twa_busdma_lock
  * Description:		Function to provide synchronization during busdma_swi.
@@ -835,22 +843,23 @@
 TW_VOID
 twa_busdma_lock(TW_VOID *lock_arg, bus_dma_lock_op_t op)
 {
-	struct mtx	*lock;
+	struct spinlock	*lock;
 
-	lock = (struct mtx *)lock_arg;
+	lock = (struct spinlock *)lock_arg;
 	switch (op) {
 	case BUS_DMA_LOCK:
-		mtx_lock_spin(lock);
+		spin_lock_wr(lock);
 		break;
 
 	case BUS_DMA_UNLOCK:
-		mtx_unlock_spin(lock);
+		spin_unlock_wr(lock);
 		break;
 
 	default:
 		panic("Unknown operation 0x%x for twa_busdma_lock!", op);
 	}
 }
+#endif
 
 
 /*
@@ -918,7 +927,7 @@
 		(user_buf->driver_pkt.buffer_length +
 		(sc->sg_size_factor - 1)) & ~(sc->sg_size_factor - 1);
 	if ((req->length = data_buf_size_adjusted)) {
-		if ((req->data = malloc(data_buf_size_adjusted,
+		if ((req->data = kmalloc(data_buf_size_adjusted,
 			TW_OSLI_MALLOC_CLASS, M_WAITOK)) == NULL) {
 			error = ENOMEM;
 			tw_osli_printf(sc, "error = %d",
@@ -956,12 +965,12 @@
 
 	end_time = tw_osl_get_local_time() + timeout;
 	while (req->state != TW_OSLI_REQ_STATE_COMPLETE) {
-		mtx_lock(req->ioctl_wake_timeout_lock);
+		lockmgr(req->ioctl_wake_timeout_lock, LK_EXCLUSIVE);
 		req->flags |= TW_OSLI_REQ_FLAGS_SLEEPING;
 
-		error = mtx_sleep(req, req->ioctl_wake_timeout_lock, 0,
+		error = lksleep(req, req->ioctl_wake_timeout_lock, 0,
 			    "twa_passthru", timeout*hz);
-		mtx_unlock(req->ioctl_wake_timeout_lock);
+		lockmgr(req->ioctl_wake_timeout_lock, LK_RELEASE);
 
 		if (!(req->flags & TW_OSLI_REQ_FLAGS_SLEEPING))
 			error = 0;
@@ -1054,7 +1063,7 @@
 	user_buf->driver_pkt.os_status = error;
 	/* Free resources. */
 	if (req->data)
-		free(req->data, TW_OSLI_MALLOC_CLASS);
+		kfree(req->data, TW_OSLI_MALLOC_CLASS);
 	tw_osli_req_q_insert_tail(req, TW_OSLI_FREE_Q);
 	return(error);
 }
@@ -1345,7 +1354,7 @@
 			req->length = (req->length +
 				(sc->sg_size_factor - 1)) &
 				~(sc->sg_size_factor - 1);
-			req->data = malloc(req->length, TW_OSLI_MALLOC_CLASS,
+			req->data = kmalloc(req->length, TW_OSLI_MALLOC_CLASS,
 					M_NOWAIT);
 			if (req->data == NULL) {
 				tw_osli_printf(sc, "error = %d",
@@ -1367,12 +1376,12 @@
 		 */
 		if (req->flags & TW_OSLI_REQ_FLAGS_PASSTHRU) {
 			/* Lock against multiple simultaneous ioctl calls. */
-			mtx_lock_spin(sc->io_lock);
+			spin_lock_wr(sc->io_lock);
 			error = bus_dmamap_load(sc->ioctl_tag, sc->ioctl_map,
 				req->data, req->length,
 				twa_map_load_data_callback, req,
 				BUS_DMA_WAITOK);
-			mtx_unlock_spin(sc->io_lock);
+			spin_unlock_wr(sc->io_lock);
 		} else {
 			/*
 			 * There's only one CAM I/O thread running at a time.
@@ -1393,17 +1402,17 @@
 				 * in ...tag_create should protect the access
 				 * of ...FLAGS_MAPPED from the callback.
 				 */
-				mtx_lock_spin(sc->io_lock);
+				spin_lock_wr(sc->io_lock);
 				if (!(req->flags & TW_OSLI_REQ_FLAGS_MAPPED))
 					req->flags |= TW_OSLI_REQ_FLAGS_IN_PROGRESS;
 				tw_osli_disallow_new_requests(sc, &(req->req_handle));
-				mtx_unlock_spin(sc->io_lock);
+				spin_unlock_wr(sc->io_lock);
 				error = 0;
 			} else {
 				/* Free alignment buffer if it was used. */
 				if (req->flags &
 					TW_OSLI_REQ_FLAGS_DATA_COPY_NEEDED) {
-					free(req->data, TW_OSLI_MALLOC_CLASS);
+					kfree(req->data, TW_OSLI_MALLOC_CLASS);
 					/*
 					 * Restore original data pointer
 					 * and length.
@@ -1454,7 +1463,7 @@
 	if (req->data != NULL) {
 		if (req->flags & TW_OSLI_REQ_FLAGS_PASSTHRU) {
 			/* Lock against multiple simultaneous ioctl calls. */
-			mtx_lock_spin(sc->io_lock);
+			spin_lock_wr(sc->io_lock);
 
 			if (req->flags & TW_OSLI_REQ_FLAGS_DATA_IN) {
 				bus_dmamap_sync(sc->ioctl_tag,
@@ -1475,7 +1484,7 @@
 
 			bus_dmamap_unload(sc->ioctl_tag, sc->ioctl_map);
 
-			mtx_unlock_spin(sc->io_lock);
+			spin_unlock_wr(sc->io_lock);
 		} else {
 			if (req->flags & TW_OSLI_REQ_FLAGS_DATA_IN) {
 				bus_dmamap_sync(sc->dma_tag,
@@ -1499,7 +1508,7 @@
 
 	/* Free alignment buffer if it was used. */
 	if (req->flags & TW_OSLI_REQ_FLAGS_DATA_COPY_NEEDED) {
-		free(req->data, TW_OSLI_MALLOC_CLASS);
+		kfree(req->data, TW_OSLI_MALLOC_CLASS);
 		/* Restore original data pointer and length. */
 		req->data = req->real_data;
 		req->length = req->real_length;
diff -uwr /home/s/reference/FreeBSD/src/sys/dev/twa/tw_osl_includes.h sys/dev/raid/twa/tw_osl_includes.h
--- /home/s/reference/FreeBSD/src/sys/dev/twa/tw_osl_includes.h	2009-01-11 04:48:45 +0100
+++ sys/dev/raid/twa/tw_osl_includes.h	2010-07-26 06:30:48 +0200
@@ -50,30 +50,31 @@
 #include <sys/systm.h>
 #include <sys/malloc.h>
 #include <sys/kernel.h>
+#include <sys/device.h>
 #include <sys/module.h>
 #include <sys/sysctl.h>
 #include <sys/bus.h>
 #include <sys/conf.h>
-#include <sys/clock.h>
 #include <sys/disk.h>
+#include <sys/resource.h>
 #include <sys/stat.h>
 #include <sys/devicestat.h>
 #include <sys/taskqueue.h>
+#include <sys/time.h>
 
-#include <machine/bus.h>
-#include <machine/resource.h>
-#include <machine/stdarg.h>
+#include <machine/clock.h>
+#include <stdarg.h>
 
 #include <vm/vm.h>
 
 #include <sys/rman.h>
 
-#include <dev/pci/pcireg.h>
-#include <dev/pci/pcivar.h>
+#include <bus/pci/pcireg.h>
+#include <bus/pci/pcivar.h>
 
-#include <dev/twa/tw_osl_share.h>
-#include <dev/twa/tw_cl_share.h>
-#include <dev/twa/tw_osl_externs.h>
+#include <dev/raid/twa/tw_osl_share.h>
+#include <dev/raid/twa/tw_cl_share.h>
+#include <dev/raid/twa/tw_osl_externs.h>
 
 
 
diff -uwr /home/s/reference/FreeBSD/src/sys/dev/twa/tw_osl_inline.h sys/dev/raid/twa/tw_osl_inline.h
--- /home/s/reference/FreeBSD/src/sys/dev/twa/tw_osl_inline.h	2010-06-11 10:28:57 +0200
+++ sys/dev/raid/twa/tw_osl_inline.h	2010-07-26 05:08:59 +0200
@@ -46,7 +46,7 @@
  */
 
 
-#include <dev/twa/tw_osl.h>
+#include <dev/raid/twa/tw_osl.h>
 
 
 
@@ -60,7 +60,7 @@
  * Return value:	None
  */
 #define tw_osl_init_lock(ctlr_handle, lock_name, lock)	\
-	mtx_init(lock, lock_name, NULL, MTX_SPIN)
+	spin_init(lock)
 
 
 
@@ -75,7 +75,7 @@
  * Return value:	None
  */
 #define tw_osl_destroy_lock(ctlr_handle, lock)	\
-	mtx_destroy(lock)
+	spin_uninit(lock)
 
 
 
@@ -90,7 +90,7 @@
  * Return value:	None
  */
 #define tw_osl_get_lock(ctlr_handle, lock)	\
-	mtx_lock_spin(lock)
+	spin_lock_wr(lock)
 
 
 
@@ -104,7 +104,7 @@
  * Return value:	None
  */
 #define tw_osl_free_lock(ctlr_handle, lock)	\
-	mtx_unlock_spin(lock)
+	spin_unlock_wr(lock)
 
 
 
@@ -262,7 +262,7 @@
  * Return value:	local time
  */
 #define tw_osl_get_local_time()						\
-	(time_second - utc_offset())
+	(time_second - (tz.tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0)))
 
 
 /*
@@ -330,7 +330,7 @@
 
 
 /* Standard sprintf. */
-#define tw_osl_sprintf			sprintf
+#define tw_osl_sprintf			ksprintf
 
 
 /* Copy string 'src' to 'dest'. */
@@ -342,7 +342,7 @@
 
 
 /* Standard vsprintf. */
-#define tw_osl_vsprintf			vsprintf
+#define tw_osl_vsprintf			kvsprintf
 
 
 
diff -uwr /home/s/reference/FreeBSD/src/sys/dev/twa/tw_osl_ioctl.h sys/dev/raid/twa/tw_osl_ioctl.h
--- /home/s/reference/FreeBSD/src/sys/dev/twa/tw_osl_ioctl.h	2009-01-11 04:48:45 +0100
+++ sys/dev/raid/twa/tw_osl_ioctl.h	2010-07-26 04:25:00 +0200
@@ -47,8 +47,8 @@
 
 
 
-#include <dev/twa/tw_cl_fwif.h>
-#include <dev/twa/tw_cl_ioctl.h>
+#include <dev/raid/twa/tw_cl_fwif.h>
+#include <dev/raid/twa/tw_cl_ioctl.h>
 
 
 
diff -uwr /home/s/reference/FreeBSD/src/sys/dev/twa/tw_osl_share.h sys/dev/raid/twa/tw_osl_share.h
--- /home/s/reference/FreeBSD/src/sys/dev/twa/tw_osl_share.h	2010-06-11 10:28:57 +0200
+++ sys/dev/raid/twa/tw_osl_share.h	2010-07-26 05:14:18 +0200
@@ -50,20 +50,21 @@
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/kernel.h>
-#include <sys/clock.h>
 #include <sys/lock.h>
-#include <sys/mutex.h>
+#include <sys/spinlock.h>
+#include <sys/spinlock2.h>
 #include <sys/sysctl.h>
 #include <sys/bus.h>
 #include <sys/taskqueue.h>
+#include <sys/time.h>
 
-#include <machine/bus.h>
+#include <machine/clock.h>
 #include <machine/endian.h>
-#include <machine/stdarg.h>
+#include <stdarg.h>
 
-#include <dev/pci/pcivar.h>
+#include <bus/pci/pcivar.h>
 
-#include <dev/twa/tw_osl_types.h>
+#include <dev/raid/twa/tw_osl_types.h>
 #include "opt_twa.h"
 
 
diff -uwr /home/s/reference/FreeBSD/src/sys/dev/twa/tw_osl_types.h sys/dev/raid/twa/tw_osl_types.h
--- /home/s/reference/FreeBSD/src/sys/dev/twa/tw_osl_types.h	2009-01-11 04:48:45 +0100
+++ sys/dev/raid/twa/tw_osl_types.h	2010-07-26 04:29:02 +0200
@@ -57,7 +57,7 @@
 typedef unsigned long long	TW_UINT64;
 
 typedef time_t			TW_TIME;
-typedef struct mtx		TW_LOCK_HANDLE;
+typedef struct spinlock		TW_LOCK_HANDLE;
 
 
 
