diff options
Diffstat (limited to 'sys/cam/scsi/scsi_all.c')
-rw-r--r-- | sys/cam/scsi/scsi_all.c | 59 |
1 files changed, 36 insertions, 23 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); } |