From owner-svn-src-all@FreeBSD.ORG Thu Nov 20 20:50:08 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 5A67279F; Thu, 20 Nov 2014 20:50:08 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 45D27A5E; Thu, 20 Nov 2014 20:50:08 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id sAKKo8Eq034002; Thu, 20 Nov 2014 20:50:08 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id sAKKo6fv033738; Thu, 20 Nov 2014 20:50:06 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201411202050.sAKKo6fv033738@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Thu, 20 Nov 2014 20:50:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r274760 - in head/sys: cam/scsi dev/ct dev/ncv dev/nsp dev/stg X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 Nov 2014 20:50:08 -0000 Author: jhb Date: Thu Nov 20 20:50:05 2014 New Revision: 274760 URL: https://svnweb.freebsd.org/changeset/base/274760 Log: Lock the scsi_low code and the drivers which use it along with other related cleanups: - Require each driver to initalize a mutex in the scsi_low_softc that is shared with the scsi_low code. This mutex is used for CAM SIMs, timers, and interrupt handlers. - Replace the osdep function switch with direct calls to the relevant CAM functions and direct manipulation of timers via callout(9). - Collapse the CAM-specific scsi_low_osdep_interface substructure directly into scsi_low_softc. - Use bus_*() instead of bus_space_*(). - Return BUS_PROBE_DEFAULT from probe routines instead of 0. - No need to zero softcs. - Pass 0ul and ~0ul instead of 0 and ~0 to bus_alloc_resource(). - Spell "dettach" as "detach". - Remove unused 'dvname' variables. - De-spl(). Tested by: no one Modified: head/sys/cam/scsi/scsi_low.c head/sys/cam/scsi/scsi_low.h head/sys/dev/ct/bshw_machdep.c head/sys/dev/ct/ct.c head/sys/dev/ct/ct_isa.c head/sys/dev/ct/ct_machdep.h head/sys/dev/ct/ctvar.h head/sys/dev/ncv/ncr53c500.c head/sys/dev/ncv/ncr53c500_pccard.c head/sys/dev/ncv/ncr53c500var.h head/sys/dev/nsp/nsp.c head/sys/dev/nsp/nsp_pccard.c head/sys/dev/nsp/nspvar.h head/sys/dev/stg/tmc18c30.c head/sys/dev/stg/tmc18c30_isa.c head/sys/dev/stg/tmc18c30_pccard.c head/sys/dev/stg/tmc18c30_pci.c head/sys/dev/stg/tmc18c30_subr.c head/sys/dev/stg/tmc18c30var.h Modified: head/sys/cam/scsi/scsi_low.c ============================================================================== --- head/sys/cam/scsi/scsi_low.c Thu Nov 20 20:24:30 2014 (r274759) +++ head/sys/cam/scsi/scsi_low.c Thu Nov 20 20:50:05 2014 (r274760) @@ -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: head/sys/cam/scsi/scsi_low.h ============================================================================== --- head/sys/cam/scsi/scsi_low.h Thu Nov 20 20:24:30 2014 (r274759) +++ head/sys/cam/scsi/scsi_low.h Thu Nov 20 20:50:05 2014 (r274760) @@ -44,10 +44,6 @@ #ifndef _SCSI_LOW_H_ #define _SCSI_LOW_H_ -/*================================================ - * Scsi low OSDEP - * (All os depend structures should be here!) - ================================================*/ /******** includes *******************************/ #include @@ -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: head/sys/dev/ct/bshw_machdep.c ============================================================================== --- head/sys/dev/ct/bshw_machdep.c Thu Nov 20 20:24:30 2014 (r274759) +++ head/sys/dev/ct/bshw_machdep.c Thu Nov 20 20:50:05 2014 (r274760) @@ -46,6 +46,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include @@ -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: head/sys/dev/ct/ct.c ============================================================================== --- head/sys/dev/ct/ct.c Thu Nov 20 20:24:30 2014 (r274759) +++ head/sys/dev/ct/ct.c Thu Nov 20 20:50:05 2014 (r274760) @@ -47,6 +47,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include @@ -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: head/sys/dev/ct/ct_isa.c ============================================================================== --- head/sys/dev/ct/ct_isa.c Thu Nov 20 20:24:30 2014 (r274759) +++ head/sys/dev/ct/ct_isa.c Thu Nov 20 20:50:05 2014 (r274760) @@ -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: head/sys/dev/ct/ct_machdep.h ============================================================================== --- head/sys/dev/ct/ct_machdep.h Thu Nov 20 20:24:30 2014 (r274759) +++ head/sys/dev/ct/ct_machdep.h Thu Nov 20 20:50:05 2014 (r274760) @@ -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); CT_BUS_WEIGHT(chp) - regv = bus_space_read_1(bst, bsh, ctrl_port); + regv = bus_read_1(chp->ch_io, ctrl_port); CT_BUS_WEIGHT(chp) return regv; } @@ -166,12 +158,10 @@ ct_cr_read_1(struct ct_bus_access_handle static __inline void ct_cr_write_1(struct ct_bus_access_handle *chp, bus_addr_t offs, u_int8_t val) { - bus_space_tag_t bst = chp->ch_iot; - bus_space_handle_t bsh = chp->ch_ioh; - bus_space_write_1(bst, bsh, addr_port, offs); + bus_write_1(chp->ch_io, addr_port, offs); CT_BUS_WEIGHT(chp) - bus_space_write_1(bst, bsh, ctrl_port, val); + bus_write_1(chp->ch_io, ctrl_port, val); CT_BUS_WEIGHT(chp) } @@ -180,7 +170,7 @@ ct_cmdp_read_1(struct ct_bus_access_hand { u_int8_t regv; - regv = bus_space_read_1(chp->ch_iot, chp->ch_ioh, cmd_port); + regv = bus_read_1(chp->ch_io, cmd_port); CT_BUS_WEIGHT(chp) return regv; } @@ -189,7 +179,7 @@ static __inline void ct_cmdp_write_1(struct ct_bus_access_handle *chp, u_int8_t val) { - bus_space_write_1(chp->ch_iot, chp->ch_ioh, cmd_port, val); + bus_write_1(chp->ch_io, cmd_port, val); CT_BUS_WEIGHT(chp) } Modified: head/sys/dev/ct/ctvar.h ============================================================================== --- head/sys/dev/ct/ctvar.h Thu Nov 20 20:24:30 2014 (r274759) +++ head/sys/dev/ct/ctvar.h Thu Nov 20 20:50:05 2014 (r274760) @@ -44,15 +44,8 @@ * Host adapter structure *****************************************************************/ struct ct_bus_access_handle { - bus_space_tag_t ch_iot; /* core chip ctrl port tag */ - bus_space_tag_t ch_delayt; /* delay port tag */ - bus_space_tag_t ch_datat; /* data port tag (pio) */ - bus_space_tag_t ch_memt; /* data port tag (shm) */ - - bus_space_handle_t ch_ioh; - bus_space_handle_t ch_delaybah; - bus_space_handle_t ch_datah; - bus_space_handle_t ch_memh; + struct resource *ch_io; /* core chip ctrl port */ + struct resource *ch_mem; /* data port (shm) */ void (*ch_bus_weight)(struct ct_bus_access_handle *); @@ -132,5 +125,5 @@ struct ct_targ_info { *****************************************************************/ int ctprobesubr(struct ct_bus_access_handle *, u_int, int, u_int, int *); void ctattachsubr(struct ct_softc *); -int ctintr(void *); +void ctintr(void *); #endif /* !_CTVAR_H_ */ Modified: head/sys/dev/ncv/ncr53c500.c ============================================================================== --- head/sys/dev/ncv/ncr53c500.c Thu Nov 20 20:24:30 2014 (r274759) +++ head/sys/dev/ncv/ncr53c500.c Thu Nov 20 20:50:05 2014 (r274760) @@ -47,6 +47,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -107,18 +108,18 @@ static int ncv_msg(struct ncv_softc *, s static int ncv_reselected(struct ncv_softc *); static int ncv_disconnected(struct ncv_softc *, struct targ_info *); -static __inline void ncvhw_set_count(bus_space_tag_t, bus_space_handle_t, int); -static __inline u_int ncvhw_get_count(bus_space_tag_t, bus_space_handle_t); -static __inline void ncvhw_select_register_0(bus_space_tag_t, bus_space_handle_t, struct ncv_hw *); -static __inline void ncvhw_select_register_1(bus_space_tag_t, bus_space_handle_t, struct ncv_hw *); -static __inline void ncvhw_fpush(bus_space_tag_t, bus_space_handle_t, u_int8_t *, int); +static __inline void ncvhw_set_count(struct resource *, int); +static __inline u_int ncvhw_get_count(struct resource *); +static __inline void ncvhw_select_register_0(struct resource *, struct ncv_hw *); +static __inline void ncvhw_select_register_1(struct resource *, struct ncv_hw *); +static __inline void ncvhw_fpush(struct resource *, u_int8_t *, int); static void ncv_pdma_end(struct ncv_softc *sc, struct targ_info *); static int ncv_world_start(struct ncv_softc *, int); static void ncvhw_bus_reset(struct ncv_softc *); -static void ncvhw_reset(bus_space_tag_t, bus_space_handle_t, struct ncv_hw *); -static int ncvhw_check(bus_space_tag_t, bus_space_handle_t, struct ncv_hw *); -static void ncvhw_init(bus_space_tag_t, bus_space_handle_t, struct ncv_hw *); +static void ncvhw_reset(struct resource *, struct ncv_hw *); +static int ncvhw_check(struct resource *, struct ncv_hw *); +static void ncvhw_init(struct resource *, struct ncv_hw *); static int ncvhw_start_selection(struct ncv_softc *sc, struct slccb *); static void ncvhw_attention(struct ncv_softc *); static int ncv_ccb_nexus_establish(struct ncv_softc *); @@ -154,74 +155,56 @@ struct scsi_low_funcs ncv_funcs = { * hwfuncs **************************************************************/ static __inline void -ncvhw_select_register_0(iot, ioh, hw) - bus_space_tag_t iot; - bus_space_handle_t ioh; - struct ncv_hw *hw; +ncvhw_select_register_0(struct resource *res, struct ncv_hw *hw) { - bus_space_write_1(iot, ioh, cr0_cfg4, hw->hw_cfg4); + bus_write_1(res, cr0_cfg4, hw->hw_cfg4); } static __inline void -ncvhw_select_register_1(iot, ioh, hw) - bus_space_tag_t iot; - bus_space_handle_t ioh; - struct ncv_hw *hw; +ncvhw_select_register_1(struct resource *res, struct ncv_hw *hw) *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***