summaryrefslogtreecommitdiffstats
path: root/sys/cam/scsi
diff options
context:
space:
mode:
authormav <mav@FreeBSD.org>2010-01-28 08:41:30 +0000
committermav <mav@FreeBSD.org>2010-01-28 08:41:30 +0000
commit72062fdcece91a123423691068781de9366fbfaa (patch)
treed7388e60da90bf39b478369ea46d12722c323f78 /sys/cam/scsi
parent973b5fa5f2d400701ce9699f4118bd6ccc5a418c (diff)
downloadFreeBSD-src-72062fdcece91a123423691068781de9366fbfaa.zip
FreeBSD-src-72062fdcece91a123423691068781de9366fbfaa.tar.gz
MFp4: Large set of CAM inprovements.
- Unify bus reset/probe sequence. Whenever bus attached at boot or later, CAM will automatically reset and scan it. It allows to remove duplicate code from many drivers. - Any bus, attached before CAM completed it's boot-time initialization, will equally join to the process, delaying boot if needed. - New kern.cam.boot_delay loader tunable should help controllers that are still unable to register their buses in time (such as slow USB/ PCCard/ CardBus devices), by adding one more event to wait on boot. - To allow synchronization between different CAM levels, concept of requests priorities was extended. Priorities now split between several "run levels". Device can be freezed at specified level, allowing higher priority requests to pass. For example, no payload requests allowed, until PMP driver enable port. ATA XPT negotiate transfer parameters, periph driver configure caching and so on. - Frozen requests are no more counted by request allocation scheduler. It fixes deadlocks, when frozen low priority payload requests occupying slots, required by higher levels to manage theit execution. - Two last changes were holding proper ATA reinitialization and error recovery implementation. Now it is done: SATA controllers and Port Multipliers now implement automatic hot-plug and should correctly recover from timeouts and bus resets. - Improve SCSI error recovery for devices on buses without automatic sense reporting, such as ATAPI or USB. For example, it allows CAM to wait, while CD drive loads disk, instead of immediately return error status. - Decapitalize diagnostic messages and make them more readable and sensible. - Teach PMP driver to limit maximum speed on fan-out ports. - Make boot wait for PMP scan completes, and make rescan more reliable. - Fix pass driver, to return CCB to user level in case of error. - Increase number of retries in cd driver, as device may return several UAs.
Diffstat (limited to 'sys/cam/scsi')
-rw-r--r--sys/cam/scsi/scsi_all.c59
-rw-r--r--sys/cam/scsi/scsi_cd.c48
-rw-r--r--sys/cam/scsi/scsi_ch.c2
-rw-r--r--sys/cam/scsi/scsi_da.c2
-rw-r--r--sys/cam/scsi/scsi_low.c36
-rw-r--r--sys/cam/scsi/scsi_pass.c12
-rw-r--r--sys/cam/scsi/scsi_xpt.c65
7 files changed, 116 insertions, 108 deletions
diff --git a/sys/cam/scsi/scsi_all.c b/sys/cam/scsi/scsi_all.c
index e6f3a7c..d40a536 100644
--- a/sys/cam/scsi/scsi_all.c
+++ b/sys/cam/scsi/scsi_all.c
@@ -2880,7 +2880,7 @@ scsi_error_action(struct ccb_scsiio *csio, struct scsi_inquiry_data *inq_data,
}
}
}
-#ifdef KERNEL
+#ifdef _KERNEL
if (bootverbose)
sense_flags |= SF_PRINT_ALWAYS;
#endif
@@ -2995,27 +2995,29 @@ scsi_command_string(struct cam_device *device, struct ccb_scsiio *csio,
struct scsi_inquiry_data *inq_data;
char cdb_str[(SCSI_MAX_CDBLEN * 3) + 1];
#ifdef _KERNEL
- struct ccb_getdev cgd;
+ struct ccb_getdev *cgd;
#endif /* _KERNEL */
#ifdef _KERNEL
+ if ((cgd = (struct ccb_getdev*)xpt_alloc_ccb_nowait()) == NULL)
+ return(-1);
/*
* Get the device information.
*/
- xpt_setup_ccb(&cgd.ccb_h,
+ xpt_setup_ccb(&cgd->ccb_h,
csio->ccb_h.path,
CAM_PRIORITY_NORMAL);
- cgd.ccb_h.func_code = XPT_GDEV_TYPE;
- xpt_action((union ccb *)&cgd);
+ cgd->ccb_h.func_code = XPT_GDEV_TYPE;
+ xpt_action((union ccb *)cgd);
/*
* If the device is unconfigured, just pretend that it is a hard
* drive. scsi_op_desc() needs this.
*/
- if (cgd.ccb_h.status == CAM_DEV_NOT_THERE)
- cgd.inq_data.device = T_DIRECT;
+ if (cgd->ccb_h.status == CAM_DEV_NOT_THERE)
+ cgd->inq_data.device = T_DIRECT;
- inq_data = &cgd.inq_data;
+ inq_data = &cgd->inq_data;
#else /* !_KERNEL */
@@ -3055,7 +3057,7 @@ scsi_sense_sbuf(struct cam_device *device, struct ccb_scsiio *csio,
struct scsi_sense_data *sense;
struct scsi_inquiry_data *inq_data;
#ifdef _KERNEL
- struct ccb_getdev cgd;
+ struct ccb_getdev *cgd;
#endif /* _KERNEL */
u_int32_t info;
int error_code;
@@ -3083,23 +3085,25 @@ scsi_sense_sbuf(struct cam_device *device, struct ccb_scsiio *csio,
#endif /* _KERNEL/!_KERNEL */
#ifdef _KERNEL
+ if ((cgd = (struct ccb_getdev*)xpt_alloc_ccb_nowait()) == NULL)
+ return(-1);
/*
* Get the device information.
*/
- xpt_setup_ccb(&cgd.ccb_h,
+ xpt_setup_ccb(&cgd->ccb_h,
csio->ccb_h.path,
CAM_PRIORITY_NORMAL);
- cgd.ccb_h.func_code = XPT_GDEV_TYPE;
- xpt_action((union ccb *)&cgd);
+ cgd->ccb_h.func_code = XPT_GDEV_TYPE;
+ xpt_action((union ccb *)cgd);
/*
* If the device is unconfigured, just pretend that it is a hard
* drive. scsi_op_desc() needs this.
*/
- if (cgd.ccb_h.status == CAM_DEV_NOT_THERE)
- cgd.inq_data.device = T_DIRECT;
+ if (cgd->ccb_h.status == CAM_DEV_NOT_THERE)
+ cgd->inq_data.device = T_DIRECT;
- inq_data = &cgd.inq_data;
+ inq_data = &cgd->inq_data;
#else /* !_KERNEL */
@@ -3125,9 +3129,12 @@ scsi_sense_sbuf(struct cam_device *device, struct ccb_scsiio *csio,
* If the sense data is a physical pointer, forget it.
*/
if (csio->ccb_h.flags & CAM_SENSE_PTR) {
- if (csio->ccb_h.flags & CAM_SENSE_PHYS)
+ if (csio->ccb_h.flags & CAM_SENSE_PHYS) {
+#ifdef _KERNEL
+ xpt_free_ccb((union ccb*)cgd);
+#endif /* _KERNEL/!_KERNEL */
return(-1);
- else {
+ } else {
/*
* bcopy the pointer to avoid unaligned access
* errors on finicky architectures. We don't
@@ -3145,9 +3152,12 @@ scsi_sense_sbuf(struct cam_device *device, struct ccb_scsiio *csio,
* dumped on one of the bogus pointer deferences above
* already.)
*/
- if (csio->ccb_h.flags & CAM_SENSE_PHYS)
+ if (csio->ccb_h.flags & CAM_SENSE_PHYS) {
+#ifdef _KERNEL
+ xpt_free_ccb((union ccb*)cgd);
+#endif /* _KERNEL/!_KERNEL */
return(-1);
- else
+ } else
sense = &csio->sense_data;
}
@@ -3157,9 +3167,10 @@ scsi_sense_sbuf(struct cam_device *device, struct ccb_scsiio *csio,
error_code = sense->error_code & SSD_ERRCODE;
sense_key = sense->flags & SSD_KEY;
+ sbuf_printf(sb, "SCSI sense: ");
switch (error_code) {
case SSD_DEFERRED_ERROR:
- sbuf_printf(sb, "Deferred Error: ");
+ sbuf_printf(sb, "Deferred error: ");
/* FALLTHROUGH */
case SSD_CURRENT_ERROR:
@@ -3212,8 +3223,7 @@ scsi_sense_sbuf(struct cam_device *device, struct ccb_scsiio *csio,
}
}
- sbuf_printf(sb, " asc:%x,%x\n%s%s", asc, ascq,
- path_str, asc_desc);
+ sbuf_printf(sb, " asc:%x,%x (%s)", asc, ascq, asc_desc);
if (sense->extra_len >= 7 && sense->fru) {
sbuf_printf(sb, " field replaceable unit: %x",
@@ -3265,7 +3275,7 @@ scsi_sense_sbuf(struct cam_device *device, struct ccb_scsiio *csio,
}
default:
- sbuf_printf(sb, "Sense Error Code 0x%x", sense->error_code);
+ sbuf_printf(sb, "Error code 0x%x", sense->error_code);
if (sense->error_code & SSD_ERRCODE_VALID) {
sbuf_printf(sb, " at block no. %d (decimal)",
info = scsi_4btoul(sense->info));
@@ -3274,6 +3284,9 @@ scsi_sense_sbuf(struct cam_device *device, struct ccb_scsiio *csio,
sbuf_printf(sb, "\n");
+#ifdef _KERNEL
+ xpt_free_ccb((union ccb*)cgd);
+#endif /* _KERNEL/!_KERNEL */
return(0);
}
diff --git a/sys/cam/scsi/scsi_cd.c b/sys/cam/scsi/scsi_cd.c
index cf99eea..9d5dcf6 100644
--- a/sys/cam/scsi/scsi_cd.c
+++ b/sys/cam/scsi/scsi_cd.c
@@ -433,7 +433,7 @@ cdcleanup(struct cam_periph *periph)
callout_stop(&softc->changer->short_handle);
softc->changer->flags &= ~CHANGER_SHORT_TMOUT_SCHED;
}
- softc->changer->devq.qfrozen_cnt--;
+ softc->changer->devq.qfrozen_cnt[0]--;
softc->changer->flags |= CHANGER_MANUAL_CALL;
cdrunchangerqueue(softc->changer);
}
@@ -972,9 +972,9 @@ cdregisterexit:
(void)cam_periph_hold(periph, PRIBIO);
if ((softc->flags & CD_FLAG_CHANGER) == 0)
- xpt_schedule(periph, /*priority*/5);
+ xpt_schedule(periph, CAM_PRIORITY_DEV);
else
- cdschedule(periph, /*priority*/ 5);
+ cdschedule(periph, CAM_PRIORITY_DEV);
return(CAM_REQ_CMP);
}
@@ -1167,13 +1167,13 @@ cdrunchangerqueue(void *arg)
* If the changer queue is frozen, that means we have an active
* device.
*/
- if (changer->devq.qfrozen_cnt > 0) {
+ if (changer->devq.qfrozen_cnt[0] > 0) {
/*
* We always need to reset the frozen count and clear the
* active flag.
*/
- changer->devq.qfrozen_cnt--;
+ changer->devq.qfrozen_cnt[0]--;
changer->cur_device->flags &= ~CD_FLAG_ACTIVE;
changer->cur_device->flags &= ~CD_FLAG_SCHED_ON_COMP;
@@ -1208,7 +1208,7 @@ cdrunchangerqueue(void *arg)
changer->cur_device = softc;
- changer->devq.qfrozen_cnt++;
+ changer->devq.qfrozen_cnt[0]++;
softc->flags |= CD_FLAG_ACTIVE;
/* Just in case this device is waiting */
@@ -1465,7 +1465,7 @@ cdstart(struct cam_periph *periph, union ccb *start_ccb)
bioq_remove(&softc->bio_queue, bp);
scsi_read_write(&start_ccb->csio,
- /*retries*/cd_retry_count,
+ /*retries*/ cd_retry_count,
/* cbfcnp */ cddone,
MSG_SIMPLE_Q_TAG,
/* read */bp->bio_cmd == BIO_READ,
@@ -1516,7 +1516,7 @@ cdstart(struct cam_periph *periph, union ccb *start_ccb)
}
csio = &start_ccb->csio;
scsi_read_capacity(csio,
- /*retries*/1,
+ /*retries*/ cd_retry_count,
cddone,
MSG_SIMPLE_Q_TAG,
rcap,
@@ -2733,7 +2733,7 @@ cdprevent(struct cam_periph *periph, int action)
ccb = cdgetccb(periph, CAM_PRIORITY_NORMAL);
scsi_prevent(&ccb->csio,
- /*retries*/ 1,
+ /*retries*/ cd_retry_count,
cddone,
MSG_SIMPLE_Q_TAG,
action,
@@ -2911,7 +2911,7 @@ cdsize(struct cam_periph *periph, u_int32_t *size)
return (ENOMEM);
scsi_read_capacity(&ccb->csio,
- /*retries*/ 1,
+ /*retries*/ cd_retry_count,
cddone,
MSG_SIMPLE_Q_TAG,
rcap_buf,
@@ -3159,7 +3159,7 @@ cdreadtoc(struct cam_periph *periph, u_int32_t mode, u_int32_t start,
csio = &ccb->csio;
cam_fill_csio(csio,
- /* retries */ 1,
+ /* retries */ cd_retry_count,
/* cbfcnp */ cddone,
/* flags */ CAM_DIR_IN,
/* tag_action */ MSG_SIMPLE_Q_TAG,
@@ -3206,7 +3206,7 @@ cdreadsubchannel(struct cam_periph *periph, u_int32_t mode,
csio = &ccb->csio;
cam_fill_csio(csio,
- /* retries */ 1,
+ /* retries */ cd_retry_count,
/* cbfcnp */ cddone,
/* flags */ CAM_DIR_IN,
/* tag_action */ MSG_SIMPLE_Q_TAG,
@@ -3267,7 +3267,7 @@ cdgetmode(struct cam_periph *periph, struct cd_mode_params *data,
param_len = min(param_len, data->alloc_len);
scsi_mode_sense_len(csio,
- /* retries */ 1,
+ /* retries */ cd_retry_count,
/* cbfcnp */ cddone,
/* tag_action */ MSG_SIMPLE_Q_TAG,
/* dbd */ 0,
@@ -3410,7 +3410,7 @@ cdsetmode(struct cam_periph *periph, struct cd_mode_params *data)
param_len = min(param_len, data->alloc_len);
scsi_mode_select_len(csio,
- /* retries */ 1,
+ /* retries */ cd_retry_count,
/* cbfcnp */ cddone,
/* tag_action */ MSG_SIMPLE_Q_TAG,
/* scsi_page_fmt */ 1,
@@ -3472,7 +3472,7 @@ cdplay(struct cam_periph *periph, u_int32_t blk, u_int32_t len)
cdb_len = sizeof(*scsi_cmd);
}
cam_fill_csio(csio,
- /*retries*/2,
+ /*retries*/ cd_retry_count,
cddone,
/*flags*/CAM_DIR_NONE,
MSG_SIMPLE_Q_TAG,
@@ -3506,7 +3506,7 @@ cdplaymsf(struct cam_periph *periph, u_int32_t startm, u_int32_t starts,
csio = &ccb->csio;
cam_fill_csio(csio,
- /* retries */ 1,
+ /* retries */ cd_retry_count,
/* cbfcnp */ cddone,
/* flags */ CAM_DIR_NONE,
/* tag_action */ MSG_SIMPLE_Q_TAG,
@@ -3552,7 +3552,7 @@ cdplaytracks(struct cam_periph *periph, u_int32_t strack, u_int32_t sindex,
csio = &ccb->csio;
cam_fill_csio(csio,
- /* retries */ 1,
+ /* retries */ cd_retry_count,
/* cbfcnp */ cddone,
/* flags */ CAM_DIR_NONE,
/* tag_action */ MSG_SIMPLE_Q_TAG,
@@ -3594,7 +3594,7 @@ cdpause(struct cam_periph *periph, u_int32_t go)
csio = &ccb->csio;
cam_fill_csio(csio,
- /* retries */ 1,
+ /* retries */ cd_retry_count,
/* cbfcnp */ cddone,
/* flags */ CAM_DIR_NONE,
/* tag_action */ MSG_SIMPLE_Q_TAG,
@@ -3629,7 +3629,7 @@ cdstartunit(struct cam_periph *periph, int load)
ccb = cdgetccb(periph, CAM_PRIORITY_NORMAL);
scsi_start_stop(&ccb->csio,
- /* retries */ 1,
+ /* retries */ cd_retry_count,
/* cbfcnp */ cddone,
/* tag_action */ MSG_SIMPLE_Q_TAG,
/* start */ TRUE,
@@ -3657,7 +3657,7 @@ cdstopunit(struct cam_periph *periph, u_int32_t eject)
ccb = cdgetccb(periph, CAM_PRIORITY_NORMAL);
scsi_start_stop(&ccb->csio,
- /* retries */ 1,
+ /* retries */ cd_retry_count,
/* cbfcnp */ cddone,
/* tag_action */ MSG_SIMPLE_Q_TAG,
/* start */ FALSE,
@@ -3693,7 +3693,7 @@ cdsetspeed(struct cam_periph *periph, u_int32_t rdspeed, u_int32_t wrspeed)
wrspeed *= 177;
cam_fill_csio(csio,
- /* retries */ 1,
+ /* retries */ cd_retry_count,
/* cbfcnp */ cddone,
/* flags */ CAM_DIR_NONE,
/* tag_action */ MSG_SIMPLE_Q_TAG,
@@ -3768,7 +3768,7 @@ cdreportkey(struct cam_periph *periph, struct dvd_authinfo *authinfo)
ccb = cdgetccb(periph, CAM_PRIORITY_NORMAL);
scsi_report_key(&ccb->csio,
- /* retries */ 1,
+ /* retries */ cd_retry_count,
/* cbfcnp */ cddone,
/* tag_action */ MSG_SIMPLE_Q_TAG,
/* lba */ lba,
@@ -3946,7 +3946,7 @@ cdsendkey(struct cam_periph *periph, struct dvd_authinfo *authinfo)
ccb = cdgetccb(periph, CAM_PRIORITY_NORMAL);
scsi_send_key(&ccb->csio,
- /* retries */ 1,
+ /* retries */ cd_retry_count,
/* cbfcnp */ cddone,
/* tag_action */ MSG_SIMPLE_Q_TAG,
/* agid */ authinfo->agid,
@@ -4050,7 +4050,7 @@ cdreaddvdstructure(struct cam_periph *periph, struct dvd_struct *dvdstruct)
ccb = cdgetccb(periph, CAM_PRIORITY_NORMAL);
scsi_read_dvd_structure(&ccb->csio,
- /* retries */ 1,
+ /* retries */ cd_retry_count,
/* cbfcnp */ cddone,
/* tag_action */ MSG_SIMPLE_Q_TAG,
/* lba */ address,
diff --git a/sys/cam/scsi/scsi_ch.c b/sys/cam/scsi/scsi_ch.c
index 2829a15..107f22b 100644
--- a/sys/cam/scsi/scsi_ch.c
+++ b/sys/cam/scsi/scsi_ch.c
@@ -376,7 +376,7 @@ chregister(struct cam_periph *periph, void *arg)
* This first call can't block
*/
(void)cam_periph_hold(periph, PRIBIO);
- xpt_schedule(periph, /*priority*/5);
+ xpt_schedule(periph, CAM_PRIORITY_DEV);
return(CAM_REQ_CMP);
}
diff --git a/sys/cam/scsi/scsi_da.c b/sys/cam/scsi/scsi_da.c
index d05376e..77652b2 100644
--- a/sys/cam/scsi/scsi_da.c
+++ b/sys/cam/scsi/scsi_da.c
@@ -1272,7 +1272,7 @@ daregister(struct cam_periph *periph, void *arg)
* the end of probe.
*/
(void)cam_periph_hold(periph, PRIBIO);
- xpt_schedule(periph, /*priority*/5);
+ xpt_schedule(periph, CAM_PRIORITY_DEV);
/*
* Schedule a periodic event to occasionally send an
diff --git a/sys/cam/scsi/scsi_low.c b/sys/cam/scsi/scsi_low.c
index 1cee43d..1b2f4f6 100644
--- a/sys/cam/scsi/scsi_low.c
+++ b/sys/cam/scsi/scsi_low.c
@@ -895,8 +895,6 @@ scsi_low_target_open(link, cf)
#define SCSI_LOW_ALLOC_CCB(flags) scsi_low_get_ccb()
static void scsi_low_poll_cam(struct cam_sim *);
-static void scsi_low_cam_rescan_callback(struct cam_periph *, union ccb *);
-static void scsi_low_rescan_bus_cam(struct scsi_low_softc *);
void scsi_low_scsi_action_cam(struct cam_sim *, union ccb *);
static int scsi_low_attach_cam(struct scsi_low_softc *);
@@ -954,38 +952,6 @@ scsi_low_poll_cam(sim)
}
}
-static void
-scsi_low_cam_rescan_callback(periph, ccb)
- struct cam_periph *periph;
- union ccb *ccb;
-{
-
- xpt_free_path(ccb->ccb_h.path);
- xpt_free_ccb(ccb);
-}
-
-static void
-scsi_low_rescan_bus_cam(slp)
- struct scsi_low_softc *slp;
-{
- struct cam_path *path;
- union ccb *ccb;
- cam_status status;
-
- status = xpt_create_path(&path, xpt_periph,
- cam_sim_path(slp->sl_si.sim), -1, 0);
- if (status != CAM_REQ_CMP)
- return;
-
- ccb = xpt_alloc_ccb();
- bzero(ccb, sizeof(union ccb));
- xpt_setup_ccb(&ccb->ccb_h, path, 5);
- ccb->ccb_h.func_code = XPT_SCAN_BUS;
- ccb->ccb_h.cbfcnp = scsi_low_cam_rescan_callback;
- ccb->crcn.flags = CAM_FLAG_NONE;
- xpt_action(ccb);
-}
-
void
scsi_low_scsi_action_cam(sim, ccb)
struct cam_sim *sim;
@@ -1376,8 +1342,6 @@ scsi_low_world_start_cam(slp)
struct scsi_low_softc *slp;
{
- if (!cold)
- scsi_low_rescan_bus_cam(slp);
return 0;
}
diff --git a/sys/cam/scsi/scsi_pass.c b/sys/cam/scsi/scsi_pass.c
index 7551891..9464ca2 100644
--- a/sys/cam/scsi/scsi_pass.c
+++ b/sys/cam/scsi/scsi_pass.c
@@ -563,12 +563,10 @@ passsendccb(struct cam_periph *periph, union ccb *ccb, union ccb *inccb)
* that request. Otherwise, it's up to the user to perform any
* error recovery.
*/
- error = cam_periph_runccb(ccb,
- (ccb->ccb_h.flags & CAM_PASS_ERR_RECOVER) ?
- passerror : NULL,
- /* cam_flags */ CAM_RETRY_SELTO,
- /* sense_flags */SF_RETRY_UA,
- softc->device_stats);
+ cam_periph_runccb(ccb,
+ (ccb->ccb_h.flags & CAM_PASS_ERR_RECOVER) ? passerror : NULL,
+ /* cam_flags */ CAM_RETRY_SELTO, /* sense_flags */SF_RETRY_UA,
+ softc->device_stats);
if (need_unmap != 0)
cam_periph_unmapmem(ccb, &mapinfo);
@@ -577,7 +575,7 @@ passsendccb(struct cam_periph *periph, union ccb *ccb, union ccb *inccb)
ccb->ccb_h.periph_priv = inccb->ccb_h.periph_priv;
bcopy(ccb, inccb, sizeof(union ccb));
- return(error);
+ return(0);
}
static int
diff --git a/sys/cam/scsi/scsi_xpt.c b/sys/cam/scsi/scsi_xpt.c
index cae7be6..7639377 100644
--- a/sys/cam/scsi/scsi_xpt.c
+++ b/sys/cam/scsi/scsi_xpt.c
@@ -616,6 +616,11 @@ proberegister(struct cam_periph *periph, void *arg)
*/
cam_periph_freeze_after_event(periph, &periph->path->bus->last_reset,
scsi_delay);
+ /*
+ * Ensure nobody slip in until probe finish.
+ */
+ cam_freeze_devq_arg(periph->path,
+ RELSIM_RELEASE_RUNLEVEL, CAM_RL_XPT + 1);
probeschedule(periph);
return(CAM_REQ_CMP);
}
@@ -630,7 +635,7 @@ probeschedule(struct cam_periph *periph)
softc = (probe_softc *)periph->softc;
ccb = (union ccb *)TAILQ_FIRST(&softc->request_ccbs);
- xpt_setup_ccb(&cpi.ccb_h, periph->path, CAM_PRIORITY_NORMAL);
+ xpt_setup_ccb(&cpi.ccb_h, periph->path, CAM_PRIORITY_NONE);
cpi.ccb_h.func_code = XPT_PATH_INQ;
xpt_action((union ccb *)&cpi);
@@ -668,7 +673,7 @@ probeschedule(struct cam_periph *periph)
else
softc->flags &= ~PROBE_NO_ANNOUNCE;
- xpt_schedule(periph, ccb->ccb_h.pinfo.priority);
+ xpt_schedule(periph, CAM_PRIORITY_XPT);
}
static void
@@ -881,7 +886,7 @@ proberequestdefaultnegotiation(struct cam_periph *periph)
{
struct ccb_trans_settings cts;
- xpt_setup_ccb(&cts.ccb_h, periph->path, CAM_PRIORITY_NORMAL);
+ xpt_setup_ccb(&cts.ccb_h, periph->path, CAM_PRIORITY_NONE);
cts.ccb_h.func_code = XPT_GET_TRAN_SETTINGS;
cts.type = CTS_TYPE_USER_SETTINGS;
xpt_action((union ccb *)&cts);
@@ -903,7 +908,7 @@ proberequestbackoff(struct cam_periph *periph, struct cam_ed *device)
struct ccb_trans_settings_spi *spi;
memset(&cts, 0, sizeof (cts));
- xpt_setup_ccb(&cts.ccb_h, periph->path, CAM_PRIORITY_NORMAL);
+ xpt_setup_ccb(&cts.ccb_h, periph->path, CAM_PRIORITY_NONE);
cts.ccb_h.func_code = XPT_GET_TRAN_SETTINGS;
cts.type = CTS_TYPE_CURRENT_SETTINGS;
xpt_action((union ccb *)&cts);
@@ -1420,6 +1425,8 @@ probedone(struct cam_periph *periph, union ccb *done_ccb)
done_ccb->ccb_h.status = CAM_REQ_CMP;
xpt_done(done_ccb);
if (TAILQ_FIRST(&softc->request_ccbs) == NULL) {
+ cam_release_devq(periph->path,
+ RELSIM_RELEASE_RUNLEVEL, 0, CAM_RL_XPT + 1, FALSE);
cam_periph_invalidate(periph);
cam_periph_release_locked(periph);
} else {
@@ -1491,7 +1498,7 @@ scsi_scan_bus(struct cam_periph *periph, union ccb *request_ccb)
case XPT_SCAN_BUS:
{
scsi_scan_bus_info *scan_info;
- union ccb *work_ccb;
+ union ccb *work_ccb, *reset_ccb;
struct cam_path *path;
u_int i;
u_int max_target;
@@ -1526,6 +1533,26 @@ scsi_scan_bus(struct cam_periph *periph, union ccb *request_ccb)
return;
}
+ /* We may need to reset bus first, if we haven't done it yet. */
+ if ((work_ccb->cpi.hba_inquiry &
+ (PI_WIDE_32|PI_WIDE_16|PI_SDTR_ABLE)) &&
+ !(work_ccb->cpi.hba_misc & PIM_NOBUSRESET) &&
+ !timevalisset(&request_ccb->ccb_h.path->bus->last_reset)) {
+ reset_ccb = xpt_alloc_ccb_nowait();
+ xpt_setup_ccb(&reset_ccb->ccb_h, request_ccb->ccb_h.path,
+ CAM_PRIORITY_NONE);
+ reset_ccb->ccb_h.func_code = XPT_RESET_BUS;
+ xpt_action(reset_ccb);
+ if (reset_ccb->ccb_h.status != CAM_REQ_CMP) {
+ request_ccb->ccb_h.status = reset_ccb->ccb_h.status;
+ xpt_free_ccb(reset_ccb);
+ xpt_free_ccb(work_ccb);
+ xpt_done(request_ccb);
+ return;
+ }
+ xpt_free_ccb(reset_ccb);
+ }
+
/* Save some state for use while we probe for devices */
scan_info = (scsi_scan_bus_info *)
malloc(sizeof(scsi_scan_bus_info), M_CAMXPT, M_NOWAIT);
@@ -1756,10 +1783,9 @@ scsi_scan_lun(struct cam_periph *periph, struct cam_path *path,
struct cam_path *new_path;
struct cam_periph *old_periph;
- CAM_DEBUG(request_ccb->ccb_h.path, CAM_DEBUG_TRACE,
- ("scsi_scan_lun\n"));
+ CAM_DEBUG(path, CAM_DEBUG_TRACE, ("scsi_scan_lun\n"));
- xpt_setup_ccb(&cpi.ccb_h, path, CAM_PRIORITY_NORMAL);
+ xpt_setup_ccb(&cpi.ccb_h, path, CAM_PRIORITY_NONE);
cpi.ccb_h.func_code = XPT_PATH_INQ;
xpt_action((union ccb *)&cpi);
@@ -1809,7 +1835,7 @@ scsi_scan_lun(struct cam_periph *periph, struct cam_path *path,
free(new_path, M_CAMXPT);
return;
}
- xpt_setup_ccb(&request_ccb->ccb_h, new_path, CAM_PRIORITY_NORMAL);
+ xpt_setup_ccb(&request_ccb->ccb_h, new_path, CAM_PRIORITY_XPT);
request_ccb->ccb_h.cbfcnp = xptscandone;
request_ccb->ccb_h.func_code = XPT_SCAN_LUN;
request_ccb->crcn.flags = flags;
@@ -1907,7 +1933,7 @@ scsi_devise_transport(struct cam_path *path)
struct scsi_inquiry_data *inq_buf;
/* Get transport information from the SIM */
- xpt_setup_ccb(&cpi.ccb_h, path, CAM_PRIORITY_NORMAL);
+ xpt_setup_ccb(&cpi.ccb_h, path, CAM_PRIORITY_NONE);
cpi.ccb_h.func_code = XPT_PATH_INQ;
xpt_action((union ccb *)&cpi);
@@ -1967,7 +1993,7 @@ scsi_devise_transport(struct cam_path *path)
*/
/* Tell the controller what we think */
- xpt_setup_ccb(&cts.ccb_h, path, CAM_PRIORITY_NORMAL);
+ xpt_setup_ccb(&cts.ccb_h, path, CAM_PRIORITY_NONE);
cts.ccb_h.func_code = XPT_SET_TRAN_SETTINGS;
cts.type = CTS_TYPE_CURRENT_SETTINGS;
cts.transport = path->device->transport;
@@ -2095,7 +2121,7 @@ scsi_set_transfer_settings(struct ccb_trans_settings *cts, struct cam_ed *device
inq_data = &device->inq_data;
scsi = &cts->proto_specific.scsi;
- xpt_setup_ccb(&cpi.ccb_h, cts->ccb_h.path, CAM_PRIORITY_NORMAL);
+ xpt_setup_ccb(&cpi.ccb_h, cts->ccb_h.path, CAM_PRIORITY_NONE);
cpi.ccb_h.func_code = XPT_PATH_INQ;
xpt_action((union ccb *)&cpi);
@@ -2116,7 +2142,7 @@ scsi_set_transfer_settings(struct ccb_trans_settings *cts, struct cam_ed *device
* Perform sanity checking against what the
* controller and device can do.
*/
- xpt_setup_ccb(&cur_cts.ccb_h, cts->ccb_h.path, CAM_PRIORITY_NORMAL);
+ xpt_setup_ccb(&cur_cts.ccb_h, cts->ccb_h.path, CAM_PRIORITY_NONE);
cur_cts.ccb_h.func_code = XPT_GET_TRAN_SETTINGS;
cur_cts.type = cts->type;
xpt_action((union ccb *)&cur_cts);
@@ -2300,7 +2326,7 @@ scsi_toggle_tags(struct cam_path *path)
&& (dev->inq_flags & (SID_Sync|SID_WBus16|SID_WBus32)) != 0)) {
struct ccb_trans_settings cts;
- xpt_setup_ccb(&cts.ccb_h, path, CAM_PRIORITY_NORMAL);
+ xpt_setup_ccb(&cts.ccb_h, path, CAM_PRIORITY_NONE);
cts.protocol = PROTO_SCSI;
cts.protocol_version = PROTO_VERSION_UNSPECIFIED;
cts.transport = XPORT_UNSPECIFIED;
@@ -2350,11 +2376,18 @@ scsi_dev_async(u_int32_t async_code, struct cam_eb *bus, struct cam_et *target,
/*
* Allow transfer negotiation to occur in a
- * tag free environment.
+ * tag free environment and after settle delay.
*/
if (async_code == AC_SENT_BDR
- || async_code == AC_BUS_RESET)
+ || async_code == AC_BUS_RESET) {
+ cam_freeze_devq(&newpath);
+ cam_release_devq(&newpath,
+ RELSIM_RELEASE_AFTER_TIMEOUT,
+ /*reduction*/0,
+ /*timeout*/scsi_delay,
+ /*getcount_only*/0);
scsi_toggle_tags(&newpath);
+ }
if (async_code == AC_INQ_CHANGED) {
/*
OpenPOWER on IntegriCloud