diff options
author | mav <mav@FreeBSD.org> | 2017-04-02 10:54:28 +0000 |
---|---|---|
committer | mav <mav@FreeBSD.org> | 2017-04-02 10:54:28 +0000 |
commit | 4caa52c4d85fc10d2d89c93bc9b3037da536250f (patch) | |
tree | a4495f1f5892b9c09f99284d98e7192986409d6f | |
parent | 10897b07044e744ae7f60614cda791990c97e1ea (diff) | |
download | FreeBSD-src-4caa52c4d85fc10d2d89c93bc9b3037da536250f.zip FreeBSD-src-4caa52c4d85fc10d2d89c93bc9b3037da536250f.tar.gz |
MFC r315677: Clean/unify some macro usage.
-rw-r--r-- | sys/dev/isp/isp_freebsd.c | 37 | ||||
-rw-r--r-- | sys/dev/isp/isp_freebsd.h | 16 | ||||
-rw-r--r-- | sys/dev/isp/isp_pci.c | 37 | ||||
-rw-r--r-- | sys/dev/isp/isp_sbus.c | 23 |
4 files changed, 51 insertions, 62 deletions
diff --git a/sys/dev/isp/isp_freebsd.c b/sys/dev/isp/isp_freebsd.c index b4b32a6..1affa51 100644 --- a/sys/dev/isp/isp_freebsd.c +++ b/sys/dev/isp/isp_freebsd.c @@ -112,14 +112,11 @@ isp_attach_chan(ispsoftc_t *isp, struct cam_devq *devq, int chan) int i; #endif - /* - * Construct our SIM entry. - */ - sim = cam_sim_alloc(isp_action, isp_poll, "isp", isp, device_get_unit(isp->isp_dev), &isp->isp_osinfo.lock, isp->isp_maxcmds, isp->isp_maxcmds, devq); - - if (sim == NULL) { + sim = cam_sim_alloc(isp_action, isp_poll, "isp", isp, + device_get_unit(isp->isp_dev), &isp->isp_lock, + isp->isp_maxcmds, isp->isp_maxcmds, devq); + if (sim == NULL) return (ENOMEM); - } ISP_LOCK(isp); if (xpt_bus_register(sim, isp->isp_dev, chan) != CAM_SUCCESS) { @@ -173,7 +170,7 @@ isp_attach_chan(ispsoftc_t *isp, struct cam_devq *devq, int chan) fc->isp = isp; fc->ready = 1; - callout_init_mtx(&fc->gdt, &isp->isp_osinfo.lock, 0); + callout_init_mtx(&fc->gdt, &isp->isp_lock, 0); TASK_INIT(&fc->gtask, 1, isp_gdt_task, fc); #ifdef ISP_TARGET_MODE TAILQ_INIT(&fc->waitq); @@ -267,7 +264,7 @@ isp_detach_chan(ispsoftc_t *isp, int chan) /* Wait for the channel's spawned threads to exit. */ wakeup(isp->isp_osinfo.pc.ptr); while (*num_threads != 0) - mtx_sleep(isp, &isp->isp_osinfo.lock, PRIBIO, "isp_reap", 100); + mtx_sleep(isp, &isp->isp_lock, PRIBIO, "isp_reap", 100); } int @@ -291,7 +288,7 @@ isp_attach(ispsoftc_t *isp) } } - callout_init_mtx(&isp->isp_osinfo.tmo, &isp->isp_osinfo.lock, 0); + callout_init_mtx(&isp->isp_osinfo.tmo, &isp->isp_lock, 0); isp_timer_count = hz >> 2; callout_reset(&isp->isp_osinfo.tmo, isp_timer_count, isp_timer, isp); @@ -2805,8 +2802,7 @@ isp_kthread(void *arg) int slp = 0, d; int lb, lim; - mtx_lock(&isp->isp_osinfo.lock); - + ISP_LOCK(isp); while (isp->isp_osinfo.is_exiting == 0) { isp_prt(isp, ISP_LOG_SANCFG|ISP_LOGDEBUG0, "Chan %d Checking FC state", chan); @@ -2860,10 +2856,10 @@ isp_kthread(void *arg) isp_prt(isp, ISP_LOG_SANCFG|ISP_LOGDEBUG0, "Chan %d sleep for %d seconds", chan, slp); - msleep(fc, &isp->isp_osinfo.lock, PRIBIO, "ispf", slp * hz); + msleep(fc, &isp->isp_lock, PRIBIO, "ispf", slp * hz); } fc->num_threads -= 1; - mtx_unlock(&isp->isp_osinfo.lock); + ISP_UNLOCK(isp); kthread_exit(); } @@ -2969,13 +2965,13 @@ isp_action(struct cam_sim *sim, union ccb *ccb) CAM_DEBUG(ccb->ccb_h.path, CAM_DEBUG_TRACE, ("isp_action\n")); isp = (ispsoftc_t *)cam_sim_softc(sim); - mtx_assert(&isp->isp_lock, MA_OWNED); + ISP_ASSERT_LOCKED(isp); + bus = cam_sim_bus(sim); isp_prt(isp, ISP_LOGDEBUG2, "isp_action code %x", ccb->ccb_h.func_code); ISP_PCMD(ccb) = NULL; switch (ccb->ccb_h.func_code) { case XPT_SCSI_IO: /* Execute the requested I/O operation */ - bus = XS_CHANNEL(ccb); /* * Do a couple of preliminary checks... */ @@ -3133,7 +3129,6 @@ isp_action(struct cam_sim *sim, union ccb *ccb) break; #endif case XPT_RESET_DEV: /* BDR the specified SCSI device */ - bus = cam_sim_bus(xpt_path_sim(ccb->ccb_h.path)); tgt = ccb->ccb_h.target_id; tgt |= (bus << 16); @@ -3192,7 +3187,6 @@ isp_action(struct cam_sim *sim, union ccb *ccb) break; } tgt = cts->ccb_h.target_id; - bus = cam_sim_bus(xpt_path_sim(cts->ccb_h.path)); if (IS_SCSI(isp)) { struct ccb_trans_settings_scsi *scsi = &cts->proto_specific.scsi; struct ccb_trans_settings_spi *spi = &cts->xport_specific.spi; @@ -3257,7 +3251,6 @@ isp_action(struct cam_sim *sim, union ccb *ccb) case XPT_GET_TRAN_SETTINGS: cts = &ccb->cts; tgt = cts->ccb_h.target_id; - bus = cam_sim_bus(xpt_path_sim(cts->ccb_h.path)); if (IS_FC(isp)) { fcparam *fcp = FCPARAM(isp, bus); struct ccb_trans_settings_scsi *scsi = &cts->proto_specific.scsi; @@ -3346,7 +3339,6 @@ isp_action(struct cam_sim *sim, union ccb *ccb) break; case XPT_RESET_BUS: /* Reset the specified bus */ - bus = cam_sim_bus(sim); error = isp_control(isp, ISPCTL_RESET_BUS, bus); if (error) { ccb->ccb_h.status = CAM_REQ_CMP_ERR; @@ -3381,7 +3373,6 @@ isp_action(struct cam_sim *sim, union ccb *ccb) break; } - bus = cam_sim_bus(xpt_path_sim(kp->ccb_h.path)); fcp = FCPARAM(isp, bus); if (kp->xport_specific.fc.valid & KNOB_VALID_ADDRESS) { @@ -3441,7 +3432,6 @@ isp_action(struct cam_sim *sim, union ccb *ccb) if (IS_FC(isp)) { fcparam *fcp; - bus = cam_sim_bus(xpt_path_sim(kp->ccb_h.path)); fcp = FCPARAM(isp, bus); kp->xport_specific.fc.wwnn = fcp->isp_wwnn; @@ -3489,7 +3479,6 @@ isp_action(struct cam_sim *sim, union ccb *ccb) else cpi->maxio = (ISP_NSEG_MAX - 1) * PAGE_SIZE; - bus = cam_sim_bus(xpt_path_sim(cpi->ccb_h.path)); if (IS_FC(isp)) { fcparam *fcp = FCPARAM(isp, bus); @@ -4059,7 +4048,7 @@ isp_mbox_wait_complete(ispsoftc_t *isp, mbreg_t *mbp) if (isp->isp_osinfo.mbox_sleep_ok) { isp->isp_osinfo.mbox_sleep_ok = 0; isp->isp_osinfo.mbox_sleeping = 1; - msleep_sbt(&isp->isp_osinfo.mboxcmd_done, &isp->isp_osinfo.lock, + msleep_sbt(&isp->isp_osinfo.mboxcmd_done, &isp->isp_lock, PRIBIO, "ispmbx_sleep", to * SBT_1US, 0, 0); isp->isp_osinfo.mbox_sleep_ok = 1; isp->isp_osinfo.mbox_sleeping = 0; diff --git a/sys/dev/isp/isp_freebsd.h b/sys/dev/isp/isp_freebsd.h index 65b18ae..2fb122f 100644 --- a/sys/dev/isp/isp_freebsd.h +++ b/sys/dev/isp/isp_freebsd.h @@ -356,9 +356,9 @@ struct isposinfo { /* * Locking macros... */ -#define ISP_LOCK(isp) mtx_lock(&(isp)->isp_osinfo.lock) -#define ISP_UNLOCK(isp) mtx_unlock(&(isp)->isp_osinfo.lock) -#define ISP_ASSERT_LOCKED(isp) mtx_assert(&(isp)->isp_osinfo.lock, MA_OWNED) +#define ISP_LOCK(isp) mtx_lock(&(isp)->isp_lock) +#define ISP_UNLOCK(isp) mtx_unlock(&(isp)->isp_lock) +#define ISP_ASSERT_LOCKED(isp) mtx_assert(&(isp)->isp_lock, MA_OWNED) /* * Required Macros/Defines @@ -370,7 +370,7 @@ struct isposinfo { #define ISP_SNPRINTF snprintf #define ISP_DELAY(x) DELAY(x) #define ISP_SLEEP(isp, x) msleep_sbt(&(isp)->isp_osinfo.is_exiting, \ - &(isp)->isp_osinfo.lock, 0, "isp_sleep", (x) * SBT_1US, 0, 0) + &(isp)->isp_lock, 0, "isp_sleep", (x) * SBT_1US, 0, 0) #define ISP_MIN imin @@ -722,14 +722,6 @@ int isp_fcp_next_crn(ispsoftc_t *, uint8_t *, XS_T *); /* * Platform Version specific defines */ -#define BUS_DMA_ROOTARG(x) bus_get_dma_tag(x) -#define isp_dma_tag_create(a, b, c, d, e, f, g, h, i, j, k, z) \ - bus_dma_tag_create(a, b, c, d, e, f, g, h, i, j, k, \ - busdma_lock_mutex, &isp->isp_osinfo.lock, z) - -#define isp_sim_alloc(a, b, c, d, e, f, g, h) \ - cam_sim_alloc(a, b, c, d, e, &(d)->isp_osinfo.lock, f, g, h) - #define ISP_PATH_PRT(i, l, p, ...) \ if ((l) == ISP_LOGALL || ((l)& (i)->isp_dblev) != 0) { \ xpt_print(p, __VA_ARGS__); \ diff --git a/sys/dev/isp/isp_pci.c b/sys/dev/isp/isp_pci.c index 6210e6d..a6f10ea 100644 --- a/sys/dev/isp/isp_pci.c +++ b/sys/dev/isp/isp_pci.c @@ -684,7 +684,7 @@ isp_pci_attach(device_t dev) isp->isp_nchan = 1; if (sizeof (bus_addr_t) > 4) isp->isp_osinfo.sixtyfourbit = 1; - mtx_init(&isp->isp_osinfo.lock, "isp", NULL, MTX_DEF); + mtx_init(&isp->isp_lock, "isp", NULL, MTX_DEF); /* * Get Generic Options @@ -981,7 +981,7 @@ bad: free(pcs->pci_isp.isp_osinfo.pc.ptr, M_DEVBUF); pcs->pci_isp.isp_osinfo.pc.ptr = NULL; } - mtx_destroy(&isp->isp_osinfo.lock); + mtx_destroy(&isp->isp_lock); return (ENXIO); } @@ -1019,7 +1019,7 @@ isp_pci_detach(device_t dev) free(pcs->pci_isp.isp_osinfo.pc.ptr, M_DEVBUF); pcs->pci_isp.isp_osinfo.pc.ptr = NULL; } - mtx_destroy(&isp->isp_osinfo.lock); + mtx_destroy(&isp->isp_lock); return (0); } @@ -1532,9 +1532,9 @@ isp_pci_mbxdma(ispsoftc_t *isp) else nsegs = ISP_NSEG_MAX; - if (isp_dma_tag_create(BUS_DMA_ROOTARG(ISP_PCD(isp)), 1, + if (bus_dma_tag_create(bus_get_dma_tag(ISP_PCD(isp)), 1, slim, llim, hlim, NULL, NULL, BUS_SPACE_MAXSIZE, nsegs, slim, 0, - &isp->isp_osinfo.dmat)) { + busdma_lock_mutex, &isp->isp_lock, &isp->isp_osinfo.dmat)) { ISP_LOCK(isp); isp_prt(isp, ISP_LOGERR, "could not create master dma tag"); return (1); @@ -1547,9 +1547,10 @@ isp_pci_mbxdma(ispsoftc_t *isp) len = ISP_QUEUE_SIZE(RQUEST_QUEUE_LEN(isp)); if (isp->isp_type >= ISP_HA_FC_2200) len += (N_XCMDS * XCMD_SIZE); - if (isp_dma_tag_create(isp->isp_osinfo.dmat, QENTRY_LEN, slim, + if (bus_dma_tag_create(isp->isp_osinfo.dmat, QENTRY_LEN, slim, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, - len, 1, len, 0, &isp->isp_osinfo.reqdmat)) { + len, 1, len, 0, busdma_lock_mutex, &isp->isp_lock, + &isp->isp_osinfo.reqdmat)) { isp_prt(isp, ISP_LOGERR, "cannot create request DMA tag"); goto bad; } @@ -1588,9 +1589,10 @@ isp_pci_mbxdma(ispsoftc_t *isp) * Allocate and map the result queue. */ len = ISP_QUEUE_SIZE(RESULT_QUEUE_LEN(isp)); - if (isp_dma_tag_create(isp->isp_osinfo.dmat, QENTRY_LEN, slim, + if (bus_dma_tag_create(isp->isp_osinfo.dmat, QENTRY_LEN, slim, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, - len, 1, len, 0, &isp->isp_osinfo.respdmat)) { + len, 1, len, 0, busdma_lock_mutex, &isp->isp_lock, + &isp->isp_osinfo.respdmat)) { isp_prt(isp, ISP_LOGERR, "cannot create response DMA tag"); goto bad; } @@ -1617,9 +1619,10 @@ isp_pci_mbxdma(ispsoftc_t *isp) */ if (IS_24XX(isp)) { len = ISP_QUEUE_SIZE(RESULT_QUEUE_LEN(isp)); - if (isp_dma_tag_create(isp->isp_osinfo.dmat, QENTRY_LEN, slim, + if (bus_dma_tag_create(isp->isp_osinfo.dmat, QENTRY_LEN, slim, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, - len, 1, len, 0, &isp->isp_osinfo.atiodmat)) { + len, 1, len, 0, busdma_lock_mutex, &isp->isp_lock, + &isp->isp_osinfo.atiodmat)) { isp_prt(isp, ISP_LOGERR, "cannot create ATIO DMA tag"); goto bad; } @@ -1643,9 +1646,10 @@ isp_pci_mbxdma(ispsoftc_t *isp) #endif if (IS_FC(isp)) { - if (isp_dma_tag_create(isp->isp_osinfo.dmat, 64, slim, + if (bus_dma_tag_create(isp->isp_osinfo.dmat, 64, slim, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, NULL, - 2*QENTRY_LEN, 1, 2*QENTRY_LEN, 0, &isp->isp_osinfo.iocbdmat)) { + 2*QENTRY_LEN, 1, 2*QENTRY_LEN, 0, busdma_lock_mutex, + &isp->isp_lock, &isp->isp_osinfo.iocbdmat)) { goto bad; } if (bus_dmamem_alloc(isp->isp_osinfo.iocbdmat, @@ -1658,9 +1662,10 @@ isp_pci_mbxdma(ispsoftc_t *isp) goto bad; isp->isp_iocb_dma = im.maddr; - if (isp_dma_tag_create(isp->isp_osinfo.dmat, 64, slim, + if (bus_dma_tag_create(isp->isp_osinfo.dmat, 64, slim, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, NULL, - ISP_FC_SCRLEN, 1, ISP_FC_SCRLEN, 0, &isp->isp_osinfo.scdmat)) + ISP_FC_SCRLEN, 1, ISP_FC_SCRLEN, 0, busdma_lock_mutex, + &isp->isp_lock, &isp->isp_osinfo.scdmat)) goto bad; for (cmap = 0; cmap < isp->isp_nchan; cmap++) { struct isp_fc *fc = ISP_FC_PC(isp, cmap); @@ -1715,7 +1720,7 @@ gotmaxcmds: } goto bad; } - callout_init_mtx(&pcmd->wdog, &isp->isp_osinfo.lock, 0); + callout_init_mtx(&pcmd->wdog, &isp->isp_lock, 0); if (i == isp->isp_maxcmds-1) pcmd->next = NULL; else diff --git a/sys/dev/isp/isp_sbus.c b/sys/dev/isp/isp_sbus.c index 1a5300f..a5223cc 100644 --- a/sys/dev/isp/isp_sbus.c +++ b/sys/dev/isp/isp_sbus.c @@ -143,7 +143,7 @@ isp_sbus_attach(device_t dev) sbs->sbus_dev = dev; sbs->sbus_mdvec = mdvec; isp->isp_dev = dev; - mtx_init(&isp->isp_osinfo.lock, "isp", NULL, MTX_DEF); + mtx_init(&isp->isp_lock, "isp", NULL, MTX_DEF); role = 0; if (resource_int_value(device_get_name(dev), device_get_unit(dev), @@ -310,7 +310,7 @@ bad: (void) bus_release_resource(dev, SYS_RES_MEMORY, sbs->rgd, sbs->regs); } - mtx_destroy(&isp->isp_osinfo.lock); + mtx_destroy(&isp->isp_lock); return (ENXIO); } @@ -334,7 +334,7 @@ isp_sbus_detach(device_t dev) } (void) bus_release_resource(dev, SYS_RES_MEMORY, sbs->rgd, sbs->regs); isp_sbus_mbxdmafree(isp); - mtx_destroy(&isp->isp_osinfo.lock); + mtx_destroy(&isp->isp_lock); return (0); } @@ -429,10 +429,11 @@ isp_sbus_mbxdma(ispsoftc_t *isp) if (isp->isp_rquest != NULL) goto gotmaxcmds; - if (isp_dma_tag_create(BUS_DMA_ROOTARG(ISP_SBD(isp)), 1, + if (bus_dma_tag_create(bus_get_dma_tag(ISP_SBD(isp)), 1, BUS_SPACE_MAXADDR_24BIT+1, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR_32BIT, NULL, NULL, BUS_SPACE_MAXSIZE_32BIT, - ISP_NSEG_MAX, BUS_SPACE_MAXADDR_24BIT, 0, &isp->isp_osinfo.dmat)) { + ISP_NSEG_MAX, BUS_SPACE_MAXADDR_24BIT, 0, + busdma_lock_mutex, &isp->isp_lock, &isp->isp_osinfo.dmat)) { isp_prt(isp, ISP_LOGERR, "could not create master dma tag"); goto bad; } @@ -441,9 +442,10 @@ isp_sbus_mbxdma(ispsoftc_t *isp) * Allocate and map the request queue. */ len = ISP_QUEUE_SIZE(RQUEST_QUEUE_LEN(isp)); - if (isp_dma_tag_create(isp->isp_osinfo.dmat, QENTRY_LEN, BUS_SPACE_MAXADDR_24BIT+1, + if (bus_dma_tag_create(isp->isp_osinfo.dmat, QENTRY_LEN, BUS_SPACE_MAXADDR_24BIT+1, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, - len, 1, len, 0, &isp->isp_osinfo.reqdmat)) { + len, 1, len, 0, busdma_lock_mutex, &isp->isp_lock, + &isp->isp_osinfo.reqdmat)) { isp_prt(isp, ISP_LOGERR, "cannot create request DMA tag"); goto bad; } @@ -468,9 +470,10 @@ isp_sbus_mbxdma(ispsoftc_t *isp) * Allocate and map the result queue. */ len = ISP_QUEUE_SIZE(RESULT_QUEUE_LEN(isp)); - if (isp_dma_tag_create(isp->isp_osinfo.dmat, QENTRY_LEN, BUS_SPACE_MAXADDR_24BIT+1, + if (bus_dma_tag_create(isp->isp_osinfo.dmat, QENTRY_LEN, BUS_SPACE_MAXADDR_24BIT+1, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, - len, 1, len, 0, &isp->isp_osinfo.respdmat)) { + len, 1, len, 0, busdma_lock_mutex, &isp->isp_lock, + &isp->isp_osinfo.respdmat)) { isp_prt(isp, ISP_LOGERR, "cannot create response DMA tag"); goto bad; } @@ -512,7 +515,7 @@ gotmaxcmds: } goto bad; } - callout_init_mtx(&pcmd->wdog, &isp->isp_osinfo.lock, 0); + callout_init_mtx(&pcmd->wdog, &isp->isp_lock, 0); if (i == isp->isp_maxcmds-1) { pcmd->next = NULL; } else { |