1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-29 12:03:03 +00:00

Merge from r225950:

Set the sense residual properly.

Reviewed by:	ken
This commit is contained in:
Marius Strobl 2011-10-13 20:06:19 +00:00
parent f8244106ab
commit 1e5addb750
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=226350
4 changed files with 46 additions and 10 deletions

View File

@ -532,6 +532,7 @@ aac_cam_complete(struct aac_command *cm)
union ccb *ccb;
struct aac_srb_response *srbr;
struct aac_softc *sc;
int sense_returned;
sc = cm->cm_sc;
fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, "");
@ -556,16 +557,17 @@ aac_cam_complete(struct aac_command *cm)
/* Take care of autosense */
if (srbr->sense_len) {
int sense_len, scsi_sense_len;
scsi_sense_len = sizeof(struct scsi_sense_data);
bzero(&ccb->csio.sense_data, scsi_sense_len);
sense_len = (srbr->sense_len >
scsi_sense_len) ? scsi_sense_len :
srbr->sense_len;
sense_returned = srbr->sense_len;
if (sense_returned < ccb->csio.sense_len)
ccb->csio.sense_resid =
ccb->csio.sense_len -
sense_returned;
else
ccb->csio.sense_resid = 0;
bzero(&ccb->csio.sense_data,
sizeof(struct scsi_sense_data));
bcopy(&srbr->sense[0], &ccb->csio.sense_data,
srbr->sense_len);
ccb->csio.sense_len = sense_len;
min(ccb->csio.sense_len, sense_returned));
ccb->ccb_h.status |= CAM_AUTOSNS_VALID;
// scsi_sense_print(&ccb->csio);
}

View File

@ -3071,6 +3071,14 @@ asr_intr(Asr_softc_t *sc)
&& (size > ccb->csio.sense_len)) {
size = ccb->csio.sense_len;
}
if (size < ccb->csio.sense_len) {
ccb->csio.sense_resid =
ccb->csio.sense_len - size;
} else {
ccb->csio.sense_resid = 0;
}
bzero(&(ccb->csio.sense_data),
sizeof(ccb->csio.sense_data));
bcopy(Reply->SenseData,
&(ccb->csio.sense_data), size);
}
@ -3566,6 +3574,12 @@ ASR_queue_i(Asr_softc_t *sc, PI2O_MESSAGE_FRAME Packet)
if (size > sizeof(ccb->csio.sense_data)) {
size = sizeof(ccb->csio.sense_data);
}
if (size < ccb->csio.sense_len) {
ccb->csio.sense_resid = ccb->csio.sense_len - size;
} else {
ccb->csio.sense_resid = 0;
}
bzero(&(ccb->csio.sense_data), sizeof(ccb->csio.sense_data));
bcopy(&(ccb->csio.sense_data), Reply_Ptr->SenseData, size);
I2O_SCSI_ERROR_REPLY_MESSAGE_FRAME_setAutoSenseTransferCount(
Reply_Ptr, size);

View File

@ -424,6 +424,13 @@ static void hptiop_request_callback_itl(struct hpt_iop_hba * hba,
ccb->ccb_h.status = CAM_BUSY;
break;
case IOP_RESULT_CHECK_CONDITION:
memset(&ccb->csio.sense_data, 0,
sizeof(ccb->csio.sense_data));
if (dxfer < ccb->csio.sense_len)
ccb->csio.sense_resid = ccb->csio.sense_len -
dxfer;
else
ccb->csio.sense_resid = 0;
if (srb->srb_flag & HPT_SRB_FLAG_HIGH_MEM_ACESS) {/*iop*/
bus_space_read_region_1(hba->bar0t, hba->bar0h,
index + offsetof(struct hpt_iop_request_scsi_command,
@ -573,6 +580,13 @@ static void hptiop_request_callback_mv(struct hpt_iop_hba * hba,
ccb->ccb_h.status = CAM_BUSY;
break;
case IOP_RESULT_CHECK_CONDITION:
memset(&ccb->csio.sense_data, 0,
sizeof(ccb->csio.sense_data));
if (req->dataxfer_length < ccb->csio.sense_len)
ccb->csio.sense_resid = ccb->csio.sense_len -
req->dataxfer_length;
else
ccb->csio.sense_resid = 0;
memcpy(&ccb->csio.sense_data, &req->sg_list,
MIN(req->dataxfer_length, sizeof(ccb->csio.sense_data)));
ccb->ccb_h.status = CAM_SCSI_STATUS_ERROR;

View File

@ -354,7 +354,13 @@ mfip_done(struct mfi_command *cm)
ccbh->status = CAM_SCSI_STATUS_ERROR | CAM_AUTOSNS_VALID;
csio->scsi_status = pt->header.scsi_status;
sense_len = min(pt->header.sense_len, sizeof(struct scsi_sense_data));
if (pt->header.sense_len < csio->sense_len)
csio->sense_resid = csio->sense_len -
pt->header.sense_len;
else
csio->sense_resid = 0;
sense_len = min(pt->header.sense_len,
sizeof(struct scsi_sense_data));
bzero(&csio->sense_data, sizeof(struct scsi_sense_data));
bcopy(&cm->cm_sense->data[0], &csio->sense_data, sense_len);
break;