diff options
-rw-r--r-- | sys/cam/cam_xpt.c | 39 | ||||
-rw-r--r-- | sys/cam/cam_xpt_periph.h | 4 | ||||
-rw-r--r-- | sys/cam/scsi/scsi_low.c | 2 | ||||
-rw-r--r-- | sys/cam/scsi/scsi_pass.c | 2 | ||||
-rw-r--r-- | sys/cam/scsi/scsi_sg.c | 2 | ||||
-rw-r--r-- | sys/dev/isp/isp_freebsd.c | 2 | ||||
-rw-r--r-- | sys/dev/mpt/mpt_cam.c | 8 |
7 files changed, 35 insertions, 24 deletions
diff --git a/sys/cam/cam_xpt.c b/sys/cam/cam_xpt.c index a34b343..86e5344 100644 --- a/sys/cam/cam_xpt.c +++ b/sys/cam/cam_xpt.c @@ -1072,7 +1072,7 @@ xptioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, struct thread *td case XPT_ENG_INQ: case XPT_SCAN_LUN: - ccb = xpt_alloc_ccb(bus->sim); + ccb = xpt_alloc_ccb(); CAM_SIM_LOCK(bus->sim); @@ -4979,26 +4979,20 @@ xpt_done(union ccb *done_ccb) } union ccb * -xpt_alloc_ccb(struct cam_sim *sim) +xpt_alloc_ccb() { union ccb *new_ccb; new_ccb = malloc(sizeof(*new_ccb), M_CAMXPT, M_WAITOK); - if ((sim != NULL) && ((sim->flags & CAM_SIM_MPSAFE) == 0)) { - callout_handle_init(&new_ccb->ccb_h.timeout_ch); - } return (new_ccb); } union ccb * -xpt_alloc_ccb_nowait(struct cam_sim *sim) +xpt_alloc_ccb_nowait() { union ccb *new_ccb; new_ccb = malloc(sizeof(*new_ccb), M_CAMXPT, M_NOWAIT); - if ((sim != NULL) && ((sim->flags & CAM_SIM_MPSAFE) == 0)) { - callout_handle_init(&new_ccb->ccb_h.timeout_ch); - } return (new_ccb); } @@ -5029,11 +5023,13 @@ xpt_get_ccb(struct cam_ed *device) s = splsoftcam(); sim = device->sim; if ((new_ccb = (union ccb *)SLIST_FIRST(&sim->ccb_freeq)) == NULL) { - new_ccb = xpt_alloc_ccb_nowait(sim); + new_ccb = xpt_alloc_ccb_nowait(); if (new_ccb == NULL) { splx(s); return (NULL); } + if ((sim->flags & CAM_SIM_MPSAFE) == 0) + callout_handle_init(&new_ccb->ccb_h.timeout_ch); SLIST_INSERT_HEAD(&sim->ccb_freeq, &new_ccb->ccb_h, xpt_links.sle); sim->ccb_count++; @@ -5353,7 +5349,12 @@ xpt_scan_bus(struct cam_periph *periph, union ccb *request_ccb) u_int initiator_id; /* Find out the characteristics of the bus */ - work_ccb = xpt_alloc_ccb_nowait(periph->sim); + work_ccb = xpt_alloc_ccb_nowait(); + if (work_ccb == NULL) { + request_ccb->ccb_h.status = CAM_RESRC_UNAVAIL; + xpt_done(request_ccb); + return; + } xpt_setup_ccb(&work_ccb->ccb_h, request_ccb->ccb_h.path, request_ccb->ccb_h.pinfo.priority); work_ccb->ccb_h.func_code = XPT_PATH_INQ; @@ -5418,7 +5419,14 @@ xpt_scan_bus(struct cam_periph *periph, union ccb *request_ccb) xpt_done(request_ccb); break; } - work_ccb = xpt_alloc_ccb_nowait(periph->sim); + work_ccb = xpt_alloc_ccb_nowait(); + if (work_ccb == NULL) { + free(scan_info, M_TEMP); + xpt_free_path(path); + request_ccb->ccb_h.status = CAM_RESRC_UNAVAIL; + xpt_done(request_ccb); + break; + } xpt_setup_ccb(&work_ccb->ccb_h, path, request_ccb->ccb_h.pinfo.priority); work_ccb->ccb_h.func_code = XPT_SCAN_LUN; @@ -6970,7 +6978,12 @@ xptconfigfunc(struct cam_eb *bus, void *arg) cam_status status; int can_negotiate; - work_ccb = xpt_alloc_ccb_nowait(bus->sim); + work_ccb = xpt_alloc_ccb_nowait(); + if (work_ccb == NULL) { + busses_to_config--; + xpt_finishconfig(xpt_periph, NULL); + return(0); + } if ((status = xpt_create_path(&path, xpt_periph, bus->path_id, CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD)) !=CAM_REQ_CMP){ diff --git a/sys/cam/cam_xpt_periph.h b/sys/cam/cam_xpt_periph.h index 9c4a3bb..c6b8cc2 100644 --- a/sys/cam/cam_xpt_periph.h +++ b/sys/cam/cam_xpt_periph.h @@ -38,8 +38,8 @@ /* Functions accessed by the peripheral drivers */ #ifdef _KERNEL void xpt_polled_action(union ccb *ccb); -union ccb *xpt_alloc_ccb(struct cam_sim *sim); -union ccb *xpt_alloc_ccb_nowait(struct cam_sim *sim); +union ccb *xpt_alloc_ccb(void); +union ccb *xpt_alloc_ccb_nowait(void); void xpt_free_ccb(union ccb *free_ccb); void xpt_release_ccb(union ccb *released_ccb); void xpt_schedule(struct cam_periph *perph, u_int32_t new_priority); diff --git a/sys/cam/scsi/scsi_low.c b/sys/cam/scsi/scsi_low.c index 296af9b..695815c 100644 --- a/sys/cam/scsi/scsi_low.c +++ b/sys/cam/scsi/scsi_low.c @@ -966,7 +966,7 @@ scsi_low_rescan_bus_cam(slp) struct scsi_low_softc *slp; { struct cam_path *path; - union ccb *ccb = xpt_alloc_ccb(NULL); + union ccb *ccb = xpt_alloc_ccb(); cam_status status; bzero(ccb, sizeof(union ccb)); diff --git a/sys/cam/scsi/scsi_pass.c b/sys/cam/scsi/scsi_pass.c index 62aaccf..5617ef0 100644 --- a/sys/cam/scsi/scsi_pass.c +++ b/sys/cam/scsi/scsi_pass.c @@ -490,7 +490,7 @@ passioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, struct thread *t inccb->ccb_h.pinfo.priority); ccb_malloced = 0; } else { - ccb = xpt_alloc_ccb_nowait(periph->sim); + ccb = xpt_alloc_ccb_nowait(); if (ccb != NULL) xpt_setup_ccb(&ccb->ccb_h, periph->path, diff --git a/sys/cam/scsi/scsi_sg.c b/sys/cam/scsi/scsi_sg.c index 9084654..402d4b4 100644 --- a/sys/cam/scsi/scsi_sg.c +++ b/sys/cam/scsi/scsi_sg.c @@ -699,7 +699,7 @@ sgwrite(struct cdev *dev, struct uio *uio, int ioflag) if (error) goto out_hdr; - ccb = xpt_alloc_ccb(periph->sim); + ccb = xpt_alloc_ccb(); if (ccb == NULL) { error = ENOMEM; goto out_hdr; diff --git a/sys/dev/isp/isp_freebsd.c b/sys/dev/isp/isp_freebsd.c index 6c4fd06..85b292f 100644 --- a/sys/dev/isp/isp_freebsd.c +++ b/sys/dev/isp/isp_freebsd.c @@ -2148,7 +2148,7 @@ isp_make_here(ispsoftc_t *isp, int tgt) * Allocate a CCB, create a wildcard path for this bus, * and schedule a rescan. */ - ccb = xpt_alloc_ccb_nowait(isp->isp_osinfo.sim); + ccb = xpt_alloc_ccb_nowait(); if (ccb == NULL) { isp_prt(isp, ISP_LOGWARN, "unable to alloc CCB for rescan"); CAMLOCK_2_ISPLOCK(mpt); diff --git a/sys/dev/mpt/mpt_cam.c b/sys/dev/mpt/mpt_cam.c index 5d7c5a5..2276ce2 100644 --- a/sys/dev/mpt/mpt_cam.c +++ b/sys/dev/mpt/mpt_cam.c @@ -2087,7 +2087,6 @@ mpt_cam_event(struct mpt_softc *mpt, request_t *req, { union ccb *ccb; uint32_t pathid; - struct cam_sim *sim; /* * In general this means a device has been added to the loop. */ @@ -2096,17 +2095,16 @@ mpt_cam_event(struct mpt_softc *mpt, request_t *req, break; } if (mpt->phydisk_sim) { - sim = mpt->phydisk_sim; + pathid = cam_sim_path(mpt->phydisk_sim); } else { - sim = mpt->sim; + pathid = cam_sim_path(mpt->sim); } - pathid = cam_sim_path(sim); MPTLOCK_2_CAMLOCK(mpt); /* * Allocate a CCB, create a wildcard path for this bus, * and schedule a rescan. */ - ccb = xpt_alloc_ccb_nowait(sim); + ccb = xpt_alloc_ccb_nowait(); if (ccb == NULL) { mpt_prt(mpt, "unable to alloc CCB for rescan\n"); CAMLOCK_2_MPTLOCK(mpt); |