Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 20 Nov 2014 23:00:17 +0000 (UTC)
From:      Gleb Smirnoff <glebius@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r274765 - in projects/sendfile: sbin/fsck sys/cam/scsi sys/dev/ct sys/dev/ncv sys/dev/nsp sys/dev/stg sys/dev/wl sys/i386/isa
Message-ID:  <201411202300.sAKN0HP3019382@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: glebius
Date: Thu Nov 20 23:00:17 2014
New Revision: 274765
URL: https://svnweb.freebsd.org/changeset/base/274765

Log:
  Merge head  r258543 through r274762.

Modified:
  projects/sendfile/sbin/fsck/fsck.c
  projects/sendfile/sys/cam/scsi/scsi_low.c
  projects/sendfile/sys/cam/scsi/scsi_low.h
  projects/sendfile/sys/cam/scsi/scsi_xpt.c
  projects/sendfile/sys/dev/ct/bshw_machdep.c
  projects/sendfile/sys/dev/ct/ct.c
  projects/sendfile/sys/dev/ct/ct_isa.c
  projects/sendfile/sys/dev/ct/ct_machdep.h
  projects/sendfile/sys/dev/ct/ctvar.h
  projects/sendfile/sys/dev/ncv/ncr53c500.c
  projects/sendfile/sys/dev/ncv/ncr53c500_pccard.c
  projects/sendfile/sys/dev/ncv/ncr53c500var.h
  projects/sendfile/sys/dev/nsp/nsp.c
  projects/sendfile/sys/dev/nsp/nsp_pccard.c
  projects/sendfile/sys/dev/nsp/nspvar.h
  projects/sendfile/sys/dev/stg/tmc18c30.c
  projects/sendfile/sys/dev/stg/tmc18c30_isa.c
  projects/sendfile/sys/dev/stg/tmc18c30_pccard.c
  projects/sendfile/sys/dev/stg/tmc18c30_pci.c
  projects/sendfile/sys/dev/stg/tmc18c30_subr.c
  projects/sendfile/sys/dev/stg/tmc18c30var.h
  projects/sendfile/sys/dev/wl/if_wl.c
  projects/sendfile/sys/dev/wl/if_wl.h
  projects/sendfile/sys/i386/isa/spic.c
Directory Properties:
  projects/sendfile/   (props changed)
  projects/sendfile/sbin/   (props changed)
  projects/sendfile/sys/   (props changed)

Modified: projects/sendfile/sbin/fsck/fsck.c
==============================================================================
--- projects/sendfile/sbin/fsck/fsck.c	Thu Nov 20 22:42:40 2014	(r274764)
+++ projects/sendfile/sbin/fsck/fsck.c	Thu Nov 20 23:00:17 2014	(r274765)
@@ -41,7 +41,8 @@ __FBSDID("$FreeBSD$");
 #include <sys/mount.h>
 #include <sys/queue.h>
 #include <sys/wait.h>
-#include <sys/disk.h>
+#define FSTYPENAMES
+#include <sys/disklabel.h>
 #include <sys/ioctl.h>
 
 #include <ctype.h>
@@ -80,21 +81,10 @@ static void addentry(struct fstypelist *
 static void maketypelist(char *);
 static void catopt(char **, const char *);
 static void mangle(char *, int *, const char ** volatile *, int *);
-static const char *getfstype(const char *);
+static const char *getfslab(const char *);
 static void usage(void) __dead2;
 static int isok(struct fstab *);
 
-static struct {
-	const char *ptype;
-	const char *name;
-} ptype_map[] = {
-	{ "ufs",	"ffs" },
-	{ "ffs",	"ffs" },
-	{ "fat",	"msdosfs" },
-	{ "efi",	"msdosfs" },
-	{ NULL,		NULL },
-};
-
 int
 main(int argc, char *argv[])
 {
@@ -213,7 +203,7 @@ main(int argc, char *argv[])
 		if ((fs = getfsfile(spec)) == NULL &&
 		    (fs = getfsspec(spec)) == NULL) {
 			if (vfstype == NULL)
-				vfstype = getfstype(spec);
+				vfstype = getfslab(spec);
 			if (vfstype == NULL)
 				errx(1, "Could not determine filesystem type");
 			type = vfstype;
@@ -545,27 +535,41 @@ mangle(char *opts, int *argcp, const cha
 	*maxargcp = maxargc;
 }
 
+
 static const char *
-getfstype(const char *str)
+getfslab(const char *str)
 {
-	struct diocgattr_arg attr;
-	int fd, i;
+	struct disklabel dl;
+	int fd;
+	char p;
+	const char *vfstype;
+	u_char t;
 
+	/* deduce the file system type from the disk label */
 	if ((fd = open(str, O_RDONLY)) == -1)
 		err(1, "cannot open `%s'", str);
 
-	strncpy(attr.name, "PART::type", sizeof(attr.name));
-	memset(&attr.value, 0, sizeof(attr.value));
-	attr.len = sizeof(attr.value);
-	if (ioctl(fd, DIOCGATTR, &attr) == -1) {
+	if (ioctl(fd, DIOCGDINFO, &dl) == -1) {
 		(void) close(fd);
 		return(NULL);
 	}
+
 	(void) close(fd);
-	for (i = 0; ptype_map[i].ptype != NULL; i++)
-		if (strstr(attr.value.str, ptype_map[i].ptype) != NULL)
-			return (ptype_map[i].name);
-	return (NULL);
+
+	p = str[strlen(str) - 1];
+
+	if ((p - 'a') >= dl.d_npartitions)
+		errx(1, "partition `%s' is not defined on disk", str);
+
+	if ((t = dl.d_partitions[p - 'a'].p_fstype) >= FSMAXTYPES) 
+		errx(1, "partition `%s' is not of a legal vfstype",
+		    str);
+
+	if ((vfstype = fstypenames[t]) == NULL)
+		errx(1, "vfstype `%s' on partition `%s' is not supported",
+		    fstypenames[t], str);
+
+	return vfstype;
 }
 
 

Modified: projects/sendfile/sys/cam/scsi/scsi_low.c
==============================================================================
--- projects/sendfile/sys/cam/scsi/scsi_low.c	Thu Nov 20 22:42:40 2014	(r274764)
+++ projects/sendfile/sys/cam/scsi/scsi_low.c	Thu Nov 20 23:00:17 2014	(r274765)
@@ -150,6 +150,8 @@ int scsi_low_version_major = 2;
 int scsi_low_version_minor = 17;
 
 static struct scsi_low_softc_tab sl_tab = LIST_HEAD_INITIALIZER(sl_tab);
+static struct mtx sl_tab_lock;
+MTX_SYSINIT(sl_tab_lock, &sl_tab_lock, "scsi low table", MTX_DEF);
 
 /**************************************************************
  * Debug, Run test and Statics
@@ -365,21 +367,10 @@ static void scsi_low_poll_cam(struct cam
 void scsi_low_scsi_action_cam(struct cam_sim *, union ccb *);
 
 static int scsi_low_attach_cam(struct scsi_low_softc *);
-static int scsi_low_world_start_cam(struct scsi_low_softc *);
-static int scsi_low_dettach_cam(struct scsi_low_softc *);
+static int scsi_low_detach_cam(struct scsi_low_softc *);
 static int scsi_low_ccb_setup_cam(struct scsi_low_softc *, struct slccb *);
 static int scsi_low_done_cam(struct scsi_low_softc *, struct slccb *);
-static void scsi_low_timeout_cam(struct scsi_low_softc *, int, int);
 
-struct scsi_low_osdep_funcs scsi_low_osdep_funcs_cam = {
-	scsi_low_attach_cam,
-	scsi_low_world_start_cam,
-	scsi_low_dettach_cam,
-	scsi_low_ccb_setup_cam,
-	scsi_low_done_cam,
-	scsi_low_timeout_cam
-};
-	
 struct scsi_low_error_code scsi_low_error_code_cam[] = {
 	{0,			CAM_REQ_CMP},
 	{SENSEIO, 		CAM_AUTOSNS_VALID | CAM_REQ_CMP_ERR},
@@ -409,12 +400,13 @@ scsi_low_poll_cam(sim)
 {
 	struct scsi_low_softc *slp = SIM2SLP(sim);
 
+	SCSI_LOW_ASSERT_LOCKED(slp);
 	(*slp->sl_funcs->scsi_low_poll) (slp);
 
-	if (slp->sl_si.si_poll_count ++ >= 
+	if (slp->sl_poll_count ++ >= 
 	    SCSI_LOW_CAM_POLL_HZ / SCSI_LOW_TIMEOUT_HZ)
 	{
-		slp->sl_si.si_poll_count = 0;
+		slp->sl_poll_count = 0;
 		scsi_low_timeout_check(slp);
 	}
 }
@@ -429,8 +421,9 @@ scsi_low_scsi_action_cam(sim, ccb)
 	struct lun_info *li;
 	struct slccb *cb;
 	u_int lun, flags, msg, target;
-	int s, rv;
+	int rv;
 
+	SCSI_LOW_ASSERT_LOCKED(slp);
 	target = (u_int) (ccb->ccb_h.target_id);
 	lun = (u_int) ccb->ccb_h.target_lun;
 
@@ -469,7 +462,6 @@ scsi_low_scsi_action_cam(sim, ccb)
 		else
 			flags = CCB_SCSIIO;
 
-		s = splcam();
 		li = scsi_low_alloc_li(ti, lun, 1);
 
 		if (ti->ti_setup_msg != 0)
@@ -485,7 +477,6 @@ scsi_low_scsi_action_cam(sim, ccb)
 			scsi_low_test_abort(slp, ti, li);
 		}
 #endif	/* SCSI_LOW_DEBUG */
-		splx(s);
 		break;
 
 	case XPT_EN_LUN:		/* Enable LUN as a target */
@@ -508,10 +499,8 @@ scsi_low_scsi_action_cam(sim, ccb)
 		}
 #endif	/* SCSI_LOW_DIAGNOSTIC */
 
-		s = splcam();
 		cb = scsi_low_find_ccb(slp, target, lun, ccb->cab.abort_ccb);
 		rv = scsi_low_abort_ccb(slp, cb);
-		splx(s);
 
 		if (rv == 0)
 			ccb->ccb_h.status = CAM_REQ_CMP;
@@ -540,7 +529,6 @@ scsi_low_scsi_action_cam(sim, ccb)
 		if (lun == CAM_LUN_WILDCARD)
 			lun = 0;
 
-		s = splcam();
 		scsi = &cts->proto_specific.scsi;
 		spi = &cts->xport_specific.spi;
 		if ((spi->valid & (CTS_SPI_VALID_BUS_WIDTH |
@@ -587,7 +575,6 @@ scsi_low_scsi_action_cam(sim, ccb)
 			if ((slp->sl_show_result & SHOW_CALCF_RES) != 0)
 				scsi_low_calcf_show(li);
 		}
-		splx(s);
 
 		ccb->ccb_h.status = CAM_REQ_CMP;
 		xpt_done(ccb);
@@ -612,7 +599,6 @@ scsi_low_scsi_action_cam(sim, ccb)
 		if (lun == CAM_LUN_WILDCARD)
 			lun = 0;
 
-		s = splcam();
 		li = scsi_low_alloc_li(ti, lun, 1);
 		if (li != NULL && cts->type == CTS_TYPE_CURRENT_SETTINGS) {
 			struct ccb_trans_settings_scsi *scsi =
@@ -658,7 +644,6 @@ scsi_low_scsi_action_cam(sim, ccb)
 		} else
 			ccb->ccb_h.status = CAM_FUNC_NOTAVAIL;
 settings_out:
-		splx(s);
 		xpt_done(ccb);
 		break;
 	}
@@ -670,9 +655,7 @@ settings_out:
 	}
 
 	case XPT_RESET_BUS:		/* Reset the specified SCSI bus */
-		s = splcam();
 		scsi_low_restart(slp, SCSI_LOW_RESTART_HARD, NULL);
-		splx(s);
 		ccb->ccb_h.status = CAM_REQ_CMP;
 		xpt_done(ccb);
 		break;
@@ -711,10 +694,8 @@ settings_out:
 		else
 			flags = CCB_NORETRY | CCB_URGENT;
 
-		s = splcam();
 		li = scsi_low_alloc_li(ti, lun, 1);
 		scsi_low_enqueue(slp, ti, li, cb, flags, msg);
-		splx(s);
 		break;
 
 	case XPT_PATH_INQ: {		/* Path routing inquiry */
@@ -774,51 +755,47 @@ scsi_low_attach_cam(slp)
 	 * ask the adapter what subunits are present
 	 */
 	tagged_openings = min(slp->sl_openings, SCSI_LOW_MAXNEXUS);
-	slp->sl_si.sim = cam_sim_alloc(scsi_low_scsi_action_cam,
+	slp->sl_sim = cam_sim_alloc(scsi_low_scsi_action_cam,
 				scsi_low_poll_cam,
 				device_get_name(slp->sl_dev), slp,
-				device_get_unit(slp->sl_dev), &Giant,
+				device_get_unit(slp->sl_dev), &slp->sl_lock,
 				slp->sl_openings, tagged_openings, devq);
 
-	if (slp->sl_si.sim == NULL) {
+	if (slp->sl_sim == NULL) {
 		cam_simq_free(devq);
 	 	return ENODEV;
 	}
 
-	if (xpt_bus_register(slp->sl_si.sim, NULL, 0) != CAM_SUCCESS) {
-		free(slp->sl_si.sim, M_SCSILOW);
+	SCSI_LOW_LOCK(slp);
+	if (xpt_bus_register(slp->sl_sim, slp->sl_dev, 0) != CAM_SUCCESS) {
+		cam_sim_free(slp->sl_sim, TRUE);
+		SCSI_LOW_UNLOCK(slp);
 	 	return ENODEV;
 	}
        
-	if (xpt_create_path(&slp->sl_si.path, /*periph*/NULL,
-			cam_sim_path(slp->sl_si.sim), CAM_TARGET_WILDCARD,
+	if (xpt_create_path(&slp->sl_path, /*periph*/NULL,
+			cam_sim_path(slp->sl_sim), CAM_TARGET_WILDCARD,
 			CAM_LUN_WILDCARD) != CAM_REQ_CMP) {
-		xpt_bus_deregister(cam_sim_path(slp->sl_si.sim));
-		cam_sim_free(slp->sl_si.sim, /*free_simq*/TRUE);
+		xpt_bus_deregister(cam_sim_path(slp->sl_sim));
+		cam_sim_free(slp->sl_sim, /*free_simq*/TRUE);
+		SCSI_LOW_UNLOCK(slp);
 		return ENODEV;
 	}
 
 	slp->sl_show_result = SHOW_CALCF_RES;		/* OK ? */
+	SCSI_LOW_UNLOCK(slp);
 	return 0;
 }
 
 static int
-scsi_low_world_start_cam(slp)
-	struct scsi_low_softc *slp;
-{
-
-	return 0;
-}
-
-static int
-scsi_low_dettach_cam(slp)
+scsi_low_detach_cam(slp)
 	struct scsi_low_softc *slp;
 {
 
-	xpt_async(AC_LOST_DEVICE, slp->sl_si.path, NULL);
-	xpt_free_path(slp->sl_si.path);
-	xpt_bus_deregister(cam_sim_path(slp->sl_si.sim));
-	cam_sim_free(slp->sl_si.sim, /* free_devq */ TRUE);
+	xpt_async(AC_LOST_DEVICE, slp->sl_path, NULL);
+	xpt_free_path(slp->sl_path);
+	xpt_bus_deregister(cam_sim_path(slp->sl_sim));
+	cam_sim_free(slp->sl_sim, /* free_devq */ TRUE);
 	return 0;
 }
 
@@ -906,48 +883,6 @@ scsi_low_done_cam(slp, cb)
 	return 0;
 }
 
-static void
-scsi_low_timeout_cam(slp, ch, action)
-	struct scsi_low_softc *slp;
-	int ch;
-	int action;
-{
-
-	switch (ch)
-	{
-	case SCSI_LOW_TIMEOUT_CH_IO:
-		switch (action)
-		{
-		case SCSI_LOW_TIMEOUT_START:
-			slp->sl_si.timeout_ch = timeout(scsi_low_timeout, slp,
-				hz / SCSI_LOW_TIMEOUT_HZ);
-			break;
-		case SCSI_LOW_TIMEOUT_STOP:
-			untimeout(scsi_low_timeout, slp, slp->sl_si.timeout_ch);
-			break;
-		}
-		break;
-
-	case SCSI_LOW_TIMEOUT_CH_ENGAGE:
-		switch (action)
-		{
-		case SCSI_LOW_TIMEOUT_START:
-			slp->sl_si.engage_ch = timeout(scsi_low_engage, slp, 1);
-			break;
-		case SCSI_LOW_TIMEOUT_STOP:
-			untimeout(scsi_low_engage, slp, slp->sl_si.engage_ch);
-			break;
-		}
-		break;
-	case SCSI_LOW_TIMEOUT_CH_RECOVER:
-		break;
-	}
-}
-
-/*=============================================================
- * END OF OS switch  (All OS depend fucntions should be above)
- =============================================================*/
-
 /**************************************************************
  * scsi low deactivate and activate
  **************************************************************/
@@ -965,15 +900,10 @@ int
 scsi_low_deactivate(slp)
 	struct scsi_low_softc *slp;
 {
-	int s;
 
-	s = splcam();
 	slp->sl_flags |= HW_INACTIVE;
-	(*slp->sl_osdep_fp->scsi_low_osdep_timeout)
-		(slp, SCSI_LOW_TIMEOUT_CH_IO, SCSI_LOW_TIMEOUT_STOP);
-	(*slp->sl_osdep_fp->scsi_low_osdep_timeout)
-		(slp, SCSI_LOW_TIMEOUT_CH_ENGAGE, SCSI_LOW_TIMEOUT_STOP);
-	splx(s);
+	callout_stop(&slp->sl_timeout_timer);
+	callout_stop(&slp->sl_engage_timer);
 	return 0;
 }
 
@@ -981,21 +911,18 @@ int
 scsi_low_activate(slp)
 	struct scsi_low_softc *slp;
 {
-	int error, s;
+	int error;
 
-	s = splcam();
 	slp->sl_flags &= ~HW_INACTIVE;
 	if ((error = scsi_low_restart(slp, SCSI_LOW_RESTART_HARD, NULL)) != 0)
 	{
 		slp->sl_flags |= HW_INACTIVE;
-		splx(s);
 		return error;
 	}
 
 	slp->sl_timeout_count = 0;
-	(*slp->sl_osdep_fp->scsi_low_osdep_timeout)
-		(slp, SCSI_LOW_TIMEOUT_CH_IO, SCSI_LOW_TIMEOUT_START);
-	splx(s);
+	callout_reset(&slp->sl_timeout_timer, hz / SCSI_LOW_TIMEOUT_HZ,
+	    scsi_low_timeout, slp);
 	return 0;
 }
 
@@ -1063,15 +990,15 @@ scsi_low_engage(arg)
 	void *arg;
 {
 	struct scsi_low_softc *slp = arg;
-	int s = splcam();
 
+	SCSI_LOW_ASSERT_LOCKED(slp);
 	switch (slp->sl_rstep)
 	{
 	case 0:
 		slp->sl_rstep ++;
 		(*slp->sl_funcs->scsi_low_power) (slp, SCSI_LOW_ENGAGE);
-		(*slp->sl_osdep_fp->scsi_low_osdep_timeout) (slp, 
-			SCSI_LOW_TIMEOUT_CH_ENGAGE, SCSI_LOW_TIMEOUT_START);
+		callout_reset(&slp->sl_engage_timer, hz / 1000,
+		    scsi_low_engage, slp);
 		break;
 
 	case 1:
@@ -1083,7 +1010,6 @@ scsi_low_engage(arg)
 	case 2:
 		break;
 	}
-	splx(s);
 }
 
 static int
@@ -1098,8 +1024,7 @@ scsi_low_init(slp, flags)
 	/* clear power control timeout */
 	if ((slp->sl_flags & HW_POWERCTRL) != 0)
 	{
-		(*slp->sl_osdep_fp->scsi_low_osdep_timeout) (slp, 
-			SCSI_LOW_TIMEOUT_CH_ENGAGE, SCSI_LOW_TIMEOUT_STOP);
+		callout_stop(&slp->sl_engage_timer);
 		slp->sl_flags &= ~(HW_POWDOWN | HW_RESUME);
 		slp->sl_active = 1;
 		slp->sl_powc = SCSI_LOW_POWDOWN_TC;
@@ -1273,13 +1198,10 @@ scsi_low_timeout(arg)
 	void *arg;
 {
 	struct scsi_low_softc *slp = arg;
-	int s;
 
-	s = splcam();
+	SCSI_LOW_ASSERT_LOCKED(slp);
 	(void) scsi_low_timeout_check(slp);
-	(*slp->sl_osdep_fp->scsi_low_osdep_timeout)
-		(slp, SCSI_LOW_TIMEOUT_CH_IO, SCSI_LOW_TIMEOUT_START);
-	splx(s);
+	callout_schedule(&slp->sl_timeout_timer, hz / SCSI_LOW_TIMEOUT_HZ);
 }
 
 static int
@@ -1459,12 +1381,7 @@ scsi_low_attach(slp, openings, ntargs, n
 {
 	struct targ_info *ti;
 	struct lun_info *li;
-	int s, i, nccb, rv;
-
-	slp->sl_osdep_fp = &scsi_low_osdep_funcs_cam;
-
-	if (slp->sl_osdep_fp == NULL)
-		panic("scsi_low: interface not spcified");
+	int i, nccb, rv;
 
 	if (ntargs > SCSI_LOW_NTARGETS)
 	{
@@ -1503,31 +1420,32 @@ scsi_low_attach(slp, openings, ntargs, n
 	TAILQ_INIT(&slp->sl_start);
 
 	/* call os depend attach */
-	s = splcam();
-	rv = (*slp->sl_osdep_fp->scsi_low_osdep_attach) (slp);
+	rv = scsi_low_attach_cam(slp);
 	if (rv != 0)
 	{
-		splx(s);
 		device_printf(slp->sl_dev,
 		    "scsi_low_attach: osdep attach failed\n");
-		return EINVAL;
+		return (rv);
 	}
 
 	/* check hardware */
 	DELAY(1000);	/* wait for 1ms */
+	SCSI_LOW_LOCK(slp);
 	if (scsi_low_init(slp, SCSI_LOW_RESTART_HARD) != 0)
 	{
-		splx(s);
 		device_printf(slp->sl_dev,
 		    "scsi_low_attach: initialization failed\n");
+		SCSI_LOW_UNLOCK(slp);
 		return EINVAL;
 	}
 
 	/* start watch dog */
 	slp->sl_timeout_count = 0;
-	(*slp->sl_osdep_fp->scsi_low_osdep_timeout)
-		 (slp, SCSI_LOW_TIMEOUT_CH_IO, SCSI_LOW_TIMEOUT_START);
+	callout_reset(&slp->sl_timeout_timer, hz / SCSI_LOW_TIMEOUT_HZ,
+	    scsi_low_timeout, slp);
+	mtx_lock(&sl_tab_lock);
 	LIST_INSERT_HEAD(&sl_tab, slp, sl_chain);
+	mtx_unlock(&sl_tab_lock);
 
 	/* fake call */
 	scsi_low_abort_ccb(slp, scsi_low_find_ccb(slp, 0, 0, NULL));
@@ -1536,38 +1454,40 @@ scsi_low_attach(slp, openings, ntargs, n
 	/* probing devices */
 	scsi_low_start_up(slp);
 #endif	/* SCSI_LOW_START_UP_CHECK */
+	SCSI_LOW_UNLOCK(slp);
 
-	/* call os depend attach done*/
-	(*slp->sl_osdep_fp->scsi_low_osdep_world_start) (slp);
-	splx(s);
 	return 0;
 }
 
 int
-scsi_low_dettach(slp)
+scsi_low_detach(slp)
 	struct scsi_low_softc *slp;
 {
-	int s, rv;
+	int rv;
 
-	s = splcam();
+	SCSI_LOW_LOCK(slp);
 	if (scsi_low_is_busy(slp) != 0)
 	{
-		splx(s);
+		SCSI_LOW_UNLOCK(slp);
 		return EBUSY;
 	}
 
 	scsi_low_deactivate(slp);
 
-	rv = (*slp->sl_osdep_fp->scsi_low_osdep_dettach) (slp);
+	rv = scsi_low_detach_cam(slp);
 	if (rv != 0)
 	{
-		splx(s);
+		SCSI_LOW_UNLOCK(slp);
 		return EBUSY;
 	}
 
 	scsi_low_free_ti(slp);
+	SCSI_LOW_UNLOCK(slp);
+	callout_drain(&slp->sl_timeout_timer);
+	callout_drain(&slp->sl_engage_timer);
+	mtx_lock(&sl_tab_lock);
 	LIST_REMOVE(slp, sl_chain);
-	splx(s);
+	mtx_unlock(&sl_tab_lock);
 	return 0;
 }
 
@@ -1753,9 +1673,8 @@ scsi_low_resume(slp)
 		slp->sl_flags |= HW_RESUME;
 		slp->sl_rstep = 0;
 		(*slp->sl_funcs->scsi_low_power) (slp, SCSI_LOW_ENGAGE);
-		(*slp->sl_osdep_fp->scsi_low_osdep_timeout)
-					(slp, SCSI_LOW_TIMEOUT_CH_ENGAGE,
-				         SCSI_LOW_TIMEOUT_START);
+		callout_reset(&slp->sl_engage_timer, hz / 1000,
+		    scsi_low_engage, slp);
 		return EJUSTRETURN;
 	}
 	return 0;
@@ -1839,7 +1758,7 @@ scsi_low_cmd_start:
 	else if (li->li_state >= SCSI_LOW_LUN_OK)
 	{
 		cb->ccb_flags &= ~CCB_INTERNAL;
-		rv = (*slp->sl_osdep_fp->scsi_low_osdep_ccb_setup) (slp, cb);
+		rv = scsi_low_ccb_setup_cam(slp, cb);
 		if (cb->ccb_msgoutflag != 0)
 		{
 			scsi_low_ccb_message_exec(slp, cb);
@@ -2199,7 +2118,7 @@ scsi_low_done(slp, cb)
 	/* call OS depend done */
 	if (cb->osdep != NULL)
 	{
-		rv = (*slp->sl_osdep_fp->scsi_low_osdep_done) (slp, cb);
+		rv = scsi_low_done_cam(slp, cb);
 		if (rv == EJUSTRETURN)
 			goto retry;
 	}
@@ -3140,7 +3059,7 @@ cmd_link_start:
 
 	scsi_low_init_msgsys(slp, ti);
 
-	(*slp->sl_osdep_fp->scsi_low_osdep_ccb_setup) (slp, ncb);
+	scsi_low_ccb_setup_cam(slp, ncb);
 
 	if (ncb->ccb_tcmax < SCSI_LOW_MIN_TOUT)
 		ncb->ccb_tcmax = SCSI_LOW_MIN_TOUT;

Modified: projects/sendfile/sys/cam/scsi/scsi_low.h
==============================================================================
--- projects/sendfile/sys/cam/scsi/scsi_low.h	Thu Nov 20 22:42:40 2014	(r274764)
+++ projects/sendfile/sys/cam/scsi/scsi_low.h	Thu Nov 20 23:00:17 2014	(r274765)
@@ -44,10 +44,6 @@
 #ifndef	_SCSI_LOW_H_
 #define	_SCSI_LOW_H_
 
-/*================================================
- * Scsi low OSDEP 
- * (All os depend structures should be here!)
- ================================================*/
 /******** includes *******************************/
 
 #include <sys/bus.h>
@@ -65,51 +61,8 @@
 
 #undef	MSG_IDENTIFY
 
-/******** os depend interface structures **********/
-typedef	struct scsi_sense_data scsi_low_osdep_sense_data_t;
-
-struct scsi_low_osdep_interface {
-	device_t si_dev;
-
-	struct cam_sim *sim;
-	struct cam_path *path;
-
-	int si_poll_count;
-
-	struct callout_handle engage_ch;
-	struct callout_handle timeout_ch;
-#ifdef	SCSI_LOW_POWFUNC
-	struct callout_handle recover_ch;
-#endif
-};
-
-/******** os depend interface functions *************/
-struct slccb;
-struct scsi_low_softc;
-#define	SCSI_LOW_TIMEOUT_STOP		0
-#define	SCSI_LOW_TIMEOUT_START		1
-#define	SCSI_LOW_TIMEOUT_CH_IO		0
-#define	SCSI_LOW_TIMEOUT_CH_ENGAGE	1
-#define	SCSI_LOW_TIMEOUT_CH_RECOVER	2
-
-struct scsi_low_osdep_funcs {
-	int (*scsi_low_osdep_attach) \
-			(struct scsi_low_softc *);
-	int (*scsi_low_osdep_world_start) \
-			(struct scsi_low_softc *);
-	int (*scsi_low_osdep_dettach) \
-			(struct scsi_low_softc *);
-	int (*scsi_low_osdep_ccb_setup) \
-			(struct scsi_low_softc *, struct slccb *);
-	int (*scsi_low_osdep_done) \
-			(struct scsi_low_softc *, struct slccb *);
-	void (*scsi_low_osdep_timeout) \
-			(struct scsi_low_softc *, int, int);
-};
-
 /*================================================
  * Generic Scsi Low header file 
- * (All os depend structures should be above!)
  ================================================*/
 /*************************************************
  * Scsi low definitions
@@ -229,7 +182,7 @@ struct slccb {
 	 * Sense data buffer
 	 *****************************************/
 	u_int8_t ccb_scsi_cmd[12];
-	scsi_low_osdep_sense_data_t ccb_sense;
+	struct scsi_sense_data ccb_sense;
 };
 
 /*************************************************
@@ -486,10 +439,19 @@ struct scsi_low_funcs {
 };
 
 struct scsi_low_softc {
-	/* os depend structure */
-	struct scsi_low_osdep_interface sl_si;
-#define	sl_dev	sl_si.si_dev
-	struct scsi_low_osdep_funcs *sl_osdep_fp;
+	device_t sl_dev;
+
+	struct cam_sim *sl_sim;
+	struct cam_path *sl_path;
+
+	int sl_poll_count;
+
+	struct mtx sl_lock;
+	struct callout sl_engage_timer;
+	struct callout sl_timeout_timer;
+#ifdef	SCSI_LOW_POWFUNC
+	struct callout sl_recover_timer;
+#endif
 				
 	/* our chain */
 	LIST_ENTRY(scsi_low_softc) sl_chain;
@@ -596,6 +558,10 @@ struct scsi_low_softc {
 	int sl_targsize;
 };
 
+#define	SCSI_LOW_LOCK(sl)		mtx_lock(&(sl)->sl_lock)
+#define	SCSI_LOW_UNLOCK(sl)		mtx_unlock(&(sl)->sl_lock)
+#define	SCSI_LOW_ASSERT_LOCKED(sl)	mtx_assert(&(sl)->sl_lock, MA_OWNED)
+
 /*************************************************
  * SCSI LOW service functions
  *************************************************/
@@ -603,7 +569,7 @@ struct scsi_low_softc {
  * Scsi low attachment function.
  */
 int scsi_low_attach(struct scsi_low_softc *, int, int, int, int, int);
-int scsi_low_dettach(struct scsi_low_softc *);
+int scsi_low_detach(struct scsi_low_softc *);
 
 /* 
  * Scsi low interface activate or deactivate functions

Modified: projects/sendfile/sys/cam/scsi/scsi_xpt.c
==============================================================================
--- projects/sendfile/sys/cam/scsi/scsi_xpt.c	Thu Nov 20 22:42:40 2014	(r274764)
+++ projects/sendfile/sys/cam/scsi/scsi_xpt.c	Thu Nov 20 23:00:17 2014	(r274765)
@@ -2032,23 +2032,7 @@ scsi_scan_bus(struct cam_periph *periph,
 				scan_info->lunindex[target_id]++;
 			} else {
 				mtx_unlock(&target->luns_mtx);
-				/*
-				 * We're done with scanning all luns.
-				 *
-				 * Nuke the bogus device for lun 0 if lun 0
-				 * wasn't on the list.
-				 */
-				if (first != 0) {
-					TAILQ_FOREACH(device,
-					    &target->ed_entries, links) {
-						if (device->lun_id == 0) {
-							break;
-						}
-					}
-					if (device) {
-						xpt_release_device(device);
-					}
-				}
+				/* We're done with scanning all luns. */
 			}
 		} else {
 			mtx_unlock(&target->luns_mtx);

Modified: projects/sendfile/sys/dev/ct/bshw_machdep.c
==============================================================================
--- projects/sendfile/sys/dev/ct/bshw_machdep.c	Thu Nov 20 22:42:40 2014	(r274764)
+++ projects/sendfile/sys/dev/ct/bshw_machdep.c	Thu Nov 20 23:00:17 2014	(r274765)
@@ -46,6 +46,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/queue.h>
 #include <sys/malloc.h>
 #include <sys/errno.h>
+#include <sys/rman.h>
 
 #include <vm/vm.h>
 
@@ -328,7 +329,7 @@ bshw_smit_xfer_start(struct ct_softc *ct
 				break;
 
 			count = (datalen > LC_FSZ ? LC_FSZ : datalen);
-			bus_space_read_region_4(chp->ch_memt, chp->ch_memh,
+			bus_read_region_4(chp->ch_mem,
 				LC_SMIT_OFFSET, (u_int32_t *) data, count >> 2);
 			data += count;
 			datalen -= count;
@@ -354,7 +355,7 @@ bshw_smit_xfer_start(struct ct_softc *ct
 			}
 
 			count = (datalen > LC_SFSZ ? LC_SFSZ : datalen);
-			bus_space_write_region_4(chp->ch_memt, chp->ch_memh,
+			bus_write_region_4(chp->ch_mem,
 				LC_SMIT_OFFSET, (u_int32_t *) data, count >> 2);
 			data += count;
 			datalen -= count;
@@ -363,7 +364,7 @@ bshw_smit_xfer_start(struct ct_softc *ct
 				break;
 
 			count = (datalen > LC_REST ? LC_REST : datalen);
-			bus_space_write_region_4(chp->ch_memt, chp->ch_memh,
+			bus_write_region_4(chp->ch_mem,
 						 LC_SMIT_OFFSET + LC_SFSZ, 
 						 (u_int32_t *) data, count >> 2);
 			data += count;

Modified: projects/sendfile/sys/dev/ct/ct.c
==============================================================================
--- projects/sendfile/sys/dev/ct/ct.c	Thu Nov 20 22:42:40 2014	(r274764)
+++ projects/sendfile/sys/dev/ct/ct.c	Thu Nov 20 23:00:17 2014	(r274765)
@@ -47,6 +47,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/queue.h>
 #include <sys/malloc.h>
 #include <sys/errno.h>
+#include <sys/rman.h>
 
 #include <machine/bus.h>
 
@@ -140,6 +141,7 @@ static int ct_unbusy(struct ct_softc *);
 static void ct_attention(struct ct_softc *);
 static struct ct_synch_data *ct_make_synch_table(struct ct_softc *);
 static int ct_catch_intr(struct ct_softc *);
+static int ct_poll(void *);
 
 struct scsi_low_funcs ct_funcs = {
 	SC_LOW_INIT_T ct_world_start,
@@ -155,7 +157,7 @@ struct scsi_low_funcs ct_funcs = {
 	SC_LOW_MSG_T ct_msg,
 
 	SC_LOW_TIMEOUT_T NULL,
-	SC_LOW_POLL_T ctintr,
+	SC_LOW_POLL_T ct_poll,
 
 	NULL,	/* SC_LOW_POWER_T cthw_power, */
 };
@@ -876,11 +878,22 @@ ct_catch_intr(struct ct_softc *ct)
 	return EJUSTRETURN;
 }
 
-int
+void
 ctintr(void *arg)
 {
 	struct ct_softc *ct = arg;
 	struct scsi_low_softc *slp = &ct->sc_sclow;
+
+	SCSI_LOW_LOCK(slp);
+	ct_poll(ct);
+	SCSI_LOW_UNLOCK(slp);
+}
+
+static int
+ct_poll(void *arg)
+{
+	struct ct_softc *ct = arg;
+	struct scsi_low_softc *slp = &ct->sc_sclow;
 	struct ct_bus_access_handle *chp = &ct->sc_ch;
 	struct targ_info *ti;
 	struct buf *bp;

Modified: projects/sendfile/sys/dev/ct/ct_isa.c
==============================================================================
--- projects/sendfile/sys/dev/ct/ct_isa.c	Thu Nov 20 22:42:40 2014	(r274764)
+++ projects/sendfile/sys/dev/ct/ct_isa.c	Thu Nov 20 23:00:17 2014	(r274765)
@@ -137,8 +137,7 @@ ct_isa_match(device_t dev)
 		return ENXIO;
 
 	bzero(&ch, sizeof(ch));
-	ch.ch_iot = rman_get_bustag(port_res);
-	ch.ch_ioh = rman_get_bushandle(port_res),
+	ch.ch_io = port_res;
 	ch.ch_bus_weight = ct_isa_bus_access_weight;
 
 	rv = ctprobesubr(&ch, 0, BSHW_DEFAULT_HOSTID,
@@ -159,7 +158,7 @@ ct_isa_match(device_t dev)
 		bus_release_resource(dev, SYS_RES_MEMORY, 0, mem_res);
 
 	if (rv != 0)
-		return 0;
+		return (BUS_PROBE_DEFAULT);
 	return ENXIO;
 }
 
@@ -175,7 +174,6 @@ ct_isa_attach(device_t dev)
 	int irq_rid, drq_rid, chiprev;
 	u_int8_t *vaddr;
 	bus_addr_t addr;
-	intrmask_t s;
 
 	hw = ct_find_hw(dev);
 	if (ct_space_map(dev, hw, &ct->port_res, &ct->mem_res) != 0) {
@@ -183,13 +181,8 @@ ct_isa_attach(device_t dev)
 		return ENXIO;
 	}
 
-	bzero(chp, sizeof(*chp));
-	chp->ch_iot = rman_get_bustag(ct->port_res);
-	chp->ch_ioh = rman_get_bushandle(ct->port_res);
-	if (ct->mem_res) {
-		chp->ch_memt = rman_get_bustag(ct->mem_res);
-		chp->ch_memh = rman_get_bushandle(ct->mem_res);
-	}
+	chp->ch_io = ct->port_res;
+	chp->ch_mem = ct->mem_res;
 	chp->ch_bus_weight = ct_isa_bus_access_weight;
 
 	irq_rid = 0;
@@ -254,7 +247,7 @@ ct_isa_attach(device_t dev)
 	ct->ct_synch_setup = bshw_synch_setup;
 
 	ct->sc_xmode = CT_XMODE_DMA;
-	if (chp->ch_memh != NULL)
+	if (chp->ch_mem != NULL)
 		ct->sc_xmode |= CT_XMODE_PIO;
 
 	ct->sc_chiprev = chiprev;
@@ -297,13 +290,12 @@ ct_isa_attach(device_t dev)
 	slp->sl_dev = dev;
 	slp->sl_hostid = bs->sc_hostid;
 	slp->sl_cfgflags = device_get_flags(dev);
+	mtx_init(&slp->sl_lock, "ct", NULL, MTX_DEF);
 
-	s = splcam();
 	ctattachsubr(ct);
-	splx(s);
 
-	if (bus_setup_intr(dev, ct->irq_res, INTR_TYPE_CAM,
-			   NULL, (driver_intr_t *)ctintr, ct, &ct->sc_ih)) {
+	if (bus_setup_intr(dev, ct->irq_res, INTR_TYPE_CAM | INTR_MPSAFE,
+			   NULL, ctintr, ct, &ct->sc_ih)) {
 		ct_space_unmap(dev, ct);
 		return ENXIO;
 	}
@@ -326,7 +318,7 @@ ct_space_map(device_t dev, struct bshw *
 	*memhp = NULL;
 
 	port_rid = 0;
-	*iohp = bus_alloc_resource(dev, SYS_RES_IOPORT, &port_rid, 0, ~0,
+	*iohp = bus_alloc_resource(dev, SYS_RES_IOPORT, &port_rid, 0ul, ~0ul,
 				   BSHW_IOSZ, RF_ACTIVE);
 	if (*iohp == NULL)
 		return ENXIO;
@@ -335,7 +327,7 @@ ct_space_map(device_t dev, struct bshw *
 		return 0;
 
 	mem_rid = 0;
-	*memhp = bus_alloc_resource(dev, SYS_RES_MEMORY, &mem_rid, 0, ~0,
+	*memhp = bus_alloc_resource(dev, SYS_RES_MEMORY, &mem_rid, 0ul, ~0ul,
 				    BSHW_MEMSZ, RF_ACTIVE);
 	if (*memhp == NULL) {
 		bus_release_resource(dev, SYS_RES_IOPORT, port_rid, *iohp);

Modified: projects/sendfile/sys/dev/ct/ct_machdep.h
==============================================================================
--- projects/sendfile/sys/dev/ct/ct_machdep.h	Thu Nov 20 22:42:40 2014	(r274764)
+++ projects/sendfile/sys/dev/ct/ct_machdep.h	Thu Nov 20 23:00:17 2014	(r274765)
@@ -94,7 +94,7 @@ ct_stat_read_1(struct ct_bus_access_hand
 {
 	u_int8_t regv;
 
-	regv = bus_space_read_1(chp->ch_iot, chp->ch_ioh, stat_port);
+	regv = bus_read_1(chp->ch_io, stat_port);
 	CT_BUS_WEIGHT(chp)
 	return regv;
 }
@@ -102,33 +102,29 @@ ct_stat_read_1(struct ct_bus_access_hand
 static __inline void
 cthw_set_count(struct ct_bus_access_handle *chp, u_int count)
 {
-	bus_space_tag_t bst = chp->ch_iot;
-	bus_space_handle_t bsh = chp->ch_ioh;
 
-	bus_space_write_1(bst, bsh, addr_port, wd3s_cnt);
+	bus_write_1(chp->ch_io, addr_port, wd3s_cnt);
 	CT_BUS_WEIGHT(chp)
-	bus_space_write_1(bst, bsh, ctrl_port, count >> 16);
+	bus_write_1(chp->ch_io, ctrl_port, count >> 16);
 	CT_BUS_WEIGHT(chp)
-	bus_space_write_1(bst, bsh, ctrl_port, count >> 8);
+	bus_write_1(chp->ch_io, ctrl_port, count >> 8);
 	CT_BUS_WEIGHT(chp)
-	bus_space_write_1(bst, bsh, ctrl_port, count);
+	bus_write_1(chp->ch_io, ctrl_port, count);
 	CT_BUS_WEIGHT(chp)
 }
 
 static __inline u_int
 cthw_get_count(struct ct_bus_access_handle *chp)
 {
-	bus_space_tag_t bst = chp->ch_iot;
-	bus_space_handle_t bsh = chp->ch_ioh;
 	u_int count;
 
-	bus_space_write_1(bst, bsh, addr_port, wd3s_cnt);
+	bus_write_1(chp->ch_io, addr_port, wd3s_cnt);
 	CT_BUS_WEIGHT(chp)
-	count = (((u_int) bus_space_read_1(bst, bsh, ctrl_port)) << 16);
+	count = (((u_int) bus_read_1(chp->ch_io, ctrl_port)) << 16);
 	CT_BUS_WEIGHT(chp)
-	count += (((u_int) bus_space_read_1(bst, bsh, ctrl_port)) << 8);
+	count += (((u_int) bus_read_1(chp->ch_io, ctrl_port)) << 8);
 	CT_BUS_WEIGHT(chp)
-	count += ((u_int) bus_space_read_1(bst, bsh, ctrl_port));
+	count += ((u_int) bus_read_1(chp->ch_io, ctrl_port));
 	CT_BUS_WEIGHT(chp)
 	return count;
 }
@@ -136,15 +132,13 @@ cthw_get_count(struct ct_bus_access_hand
 static __inline void
 ct_write_cmds(struct ct_bus_access_handle *chp, u_int8_t *cmd, int len)
 {
-	bus_space_tag_t bst = chp->ch_iot;
-	bus_space_handle_t bsh = chp->ch_ioh;
 	int i;
 
-	bus_space_write_1(bst, bsh, addr_port, wd3s_cdb);
+	bus_write_1(chp->ch_io, addr_port, wd3s_cdb);
 	CT_BUS_WEIGHT(chp)
 	for (i = 0; i < len; i ++)
 	{
-		bus_space_write_1(bst, bsh, ctrl_port, cmd[i]);
+		bus_write_1(chp->ch_io, ctrl_port, cmd[i]);
 		CT_BUS_WEIGHT(chp)
 	}
 }	
@@ -152,13 +146,11 @@ ct_write_cmds(struct ct_bus_access_handl
 static __inline u_int8_t
 ct_cr_read_1(struct ct_bus_access_handle *chp, bus_addr_t offs)
 {
-	bus_space_tag_t bst = chp->ch_iot;
-	bus_space_handle_t bsh = chp->ch_ioh;
 	u_int8_t regv;
 
-	bus_space_write_1(bst, bsh, addr_port, offs);
+	bus_write_1(chp->ch_io, addr_port, offs);

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201411202300.sAKN0HP3019382>