From 7a49a0d1fbd9812df28037bb03b5bb8cf2f20c9e Mon Sep 17 00:00:00 2001 From: Matt Jacob Date: Tue, 7 Mar 2006 17:56:40 +0000 Subject: [PATCH] Add a serial number for requests so we don't just depend on a request pointer to try and do forensics on what has occurred. --- sys/dev/mpt/mpt.c | 4 ++++ sys/dev/mpt/mpt.h | 2 ++ sys/dev/mpt/mpt_cam.c | 21 ++++++++++++--------- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/sys/dev/mpt/mpt.c b/sys/dev/mpt/mpt.c index adffd4444a2d..7b3e7377cd9f 100644 --- a/sys/dev/mpt/mpt.c +++ b/sys/dev/mpt/mpt.c @@ -1006,6 +1006,7 @@ mpt_free_request(struct mpt_softc *mpt, request_t *req) req->chain = NULL; mpt_free_request(mpt, nxt); /* NB: recursion */ } + req->serno = 0; req->ccb = NULL; req->state = REQ_STATE_FREE; if (LIST_EMPTY(&mpt->ack_frames)) { @@ -1042,6 +1043,9 @@ mpt_get_request(struct mpt_softc *mpt, int sleep_ok) TAILQ_REMOVE(&mpt->request_free_list, req, links); req->state = REQ_STATE_ALLOCATED; req->chain = NULL; + if ((req->serno = ++(mpt->cmd_serno)) == 0) { + req->serno = ++(mpt->cmd_serno); + } } else if (sleep_ok != 0) { mpt->getreqwaiter = 1; mpt_sleep(mpt, &mpt->request_free_list, PUSER, "mptgreq", 0); diff --git a/sys/dev/mpt/mpt.h b/sys/dev/mpt/mpt.h index 1e3a6a08ca86..b88d94b11729 100644 --- a/sys/dev/mpt/mpt.h +++ b/sys/dev/mpt/mpt.h @@ -280,6 +280,7 @@ struct req_entry { mpt_req_state_t state; /* Request State Information */ uint16_t index; /* Index of this entry */ uint16_t IOCStatus; /* Completion status */ + uint32_t serno; /* serial number */ union ccb *ccb; /* CAM request */ void *req_vbuf; /* Virtual Address of Entry */ void *sense_vbuf; /* Virtual Address of sense data */ @@ -430,6 +431,7 @@ struct mpt_softc { bus : 1; /* FC929/1030 have two busses */ u_int verbose; + uint32_t cmd_serno; /* * IOC Facts diff --git a/sys/dev/mpt/mpt_cam.c b/sys/dev/mpt/mpt_cam.c index c617da7ab782..8cd13b9d0be0 100644 --- a/sys/dev/mpt/mpt_cam.c +++ b/sys/dev/mpt/mpt_cam.c @@ -361,7 +361,7 @@ mpt_timeout(void *arg) MPT_LOCK(mpt); req = ccb->ccb_h.ccb_req_ptr; - mpt_prt(mpt, "Request %p Timed out.\n", req); + mpt_prt(mpt, "Request %p:serno Timed out.\n", req, req->serno); if ((req->state & REQ_STATE_QUEUED) == REQ_STATE_QUEUED) { TAILQ_REMOVE(&mpt->request_pending_list, req, links); TAILQ_INSERT_TAIL(&mpt->request_timeout_list, req, links); @@ -1138,8 +1138,8 @@ mpt_scsi_tmf_reply_handler(struct mpt_softc *mpt, request_t *req, MSG_SCSI_TASK_MGMT_REPLY *tmf_reply; u_int status; - mpt_lprt(mpt, MPT_PRT_DEBUG, "TMF Complete: req %p, reply %p\n", - req, reply_frame); + mpt_lprt(mpt, MPT_PRT_DEBUG, "TMF Complete: req %p:serno, reply %p\n", + req, req->serno, reply_frame); KASSERT(req == mpt->tmf_req, ("TMF Reply not using mpt->tmf_req")); tmf_reply = (MSG_SCSI_TASK_MGMT_REPLY *)reply_frame; @@ -2075,9 +2075,9 @@ mpt_recover_commands(struct mpt_softc *mpt) */ while ((req = TAILQ_FIRST(&mpt->request_timeout_list)) != NULL) { u_int status; + u_int32_t serno = req->serno; - mpt_prt(mpt, "Attempting to Abort Req %p\n", req); - + mpt_prt(mpt, "Attempting to Abort Req %p:%u\n", req, serno); ccb = req->ccb; mpt_set_ccb_status(ccb, CAM_CMD_TIMEOUT); error = mpt_scsi_send_tmf(mpt, @@ -2087,6 +2087,8 @@ mpt_recover_commands(struct mpt_softc *mpt) htole32(req->index | scsi_io_handler_id), /*sleep_ok*/TRUE); if (error != 0) { + mpt_prt(mpt, "Abort Req %p:%u failed to start TMF\n", + req, serno); /* * mpt_scsi_send_tmf hard resets on failure, so no * need to do so here. Our queue should be emptied @@ -2105,8 +2107,8 @@ mpt_recover_commands(struct mpt_softc *mpt) * If we've errored out and the transaction is still * pending, reset the controller. */ - mpt_prt(mpt, "mpt_recover_commands: Abort timed-out. " - "Resetting controller\n"); + mpt_prt(mpt, "Abort Req %p:%d timed-out. " + "Resetting controller\n", req, serno); mpt_reset(mpt, /*reinit*/TRUE); continue; } @@ -2119,8 +2121,9 @@ mpt_recover_commands(struct mpt_softc *mpt) continue; mpt_lprt(mpt, MPT_PRT_DEBUG, - "mpt_recover_commands: Abort Failed " - "with status 0x%x\n. Resetting bus", status); + "Abort Req %p: %u Failed " + "with status 0x%x\n. Resetting bus.", + req, serno, status); /* * If the abort attempt fails for any reason, reset the bus.