From a0e1020523ecaeb6ee5e39d90bf1f6df33e47292 Mon Sep 17 00:00:00 2001 From: Thomas Quinot Date: Wed, 11 Feb 2004 10:14:08 +0000 Subject: [PATCH] (atapi_cb): Reenable automatic retrieve of sense data on error, making it asynchronous to avoid incorrect use of ata_atapicmd within an ATAPI callback. Tested by: harti --- sys/dev/ata/atapi-cam.c | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/sys/dev/ata/atapi-cam.c b/sys/dev/ata/atapi-cam.c index bad223835601..7fb897ed0c12 100644 --- a/sys/dev/ata/atapi-cam.c +++ b/sys/dev/ata/atapi-cam.c @@ -62,7 +62,7 @@ struct atapi_hcb { union ccb *ccb; int flags; #define QUEUED 0x0001 - +#define AUTOSENSE 0x0002 char *dxfer_alloc; TAILQ_ENTRY(atapi_hcb) chain; }; @@ -569,26 +569,33 @@ atapi_cb(struct ata_request *request) } #endif - if (request->result != 0) { + if ((hcb->flags & AUTOSENSE) != 0) { + rc = CAM_SCSI_STATUS_ERROR; + if (request->result == 0) { + csio->ccb_h.status |= CAM_AUTOSNS_VALID; + } + } else if (request->result != 0) { rc = CAM_SCSI_STATUS_ERROR; csio->scsi_status = SCSI_STATUS_CHECK_COND; -#if 0 - /* - * XXX Temporarily disable autosense, as this seems to cause - * a missed ATA interrupt. - */ + if ((csio->ccb_h.flags & CAM_DIS_AUTOSENSE) == 0) { - int8_t ccb[16] = { ATAPI_REQUEST_SENSE, 0, 0, 0, + static const int8_t ccb[16] = { ATAPI_REQUEST_SENSE, 0, 0, 0, sizeof(struct atapi_sense), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - if (ata_atapicmd(request->device, ccb, (caddr_t)&csio->sense_data, - sizeof(struct atapi_sense), ATA_R_READ, 30) == 0) - { - csio->ccb_h.status |= CAM_AUTOSNS_VALID; - } + bcopy (ccb, request->u.atapi.ccb, sizeof ccb); + request->data = (caddr_t)&csio->sense_data; + request->bytecount = sizeof(struct atapi_sense); + request->transfersize = min(request->bytecount, 65534); + request->timeout = csio->ccb_h.timeout; + request->retries = 2; + request->flags = ATA_R_QUIET|ATA_R_ATAPI|ATA_R_IMMEDIATE; + hcb->flags |= AUTOSENSE; + + mtx_unlock (&Giant); + ata_queue_request(request); + return; } -#endif } else { rc = CAM_REQ_CMP; csio->scsi_status = SCSI_STATUS_OK;