aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/message/fusion/mptscsih.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/message/fusion/mptscsih.c')
-rw-r--r--drivers/message/fusion/mptscsih.c199
1 files changed, 104 insertions, 95 deletions
diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
index 02f95900e095..17369f8ba88b 100644
--- a/drivers/message/fusion/mptscsih.c
+++ b/drivers/message/fusion/mptscsih.c
@@ -1036,14 +1036,15 @@ mptscsih_search_running_cmds(MPT_SCSI_HOST *hd, VirtDevice *vdevice)
1036 int max = hd->ioc->req_depth; 1036 int max = hd->ioc->req_depth;
1037 struct scsi_cmnd *sc; 1037 struct scsi_cmnd *sc;
1038 struct scsi_lun lun; 1038 struct scsi_lun lun;
1039 MPT_ADAPTER *ioc = hd->ioc;
1039 1040
1040 dsprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT ": search_running channel %d id %d lun %d max %d\n", 1041 dsprintk(ioc, printk(MYIOC_s_DEBUG_FMT ": search_running channel %d id %d lun %d max %d\n",
1041 hd->ioc->name, vdevice->vtarget->channel, vdevice->vtarget->id, vdevice->lun, max)); 1042 ioc->name, vdevice->vtarget->channel, vdevice->vtarget->id, vdevice->lun, max));
1042 1043
1043 for (ii=0; ii < max; ii++) { 1044 for (ii=0; ii < max; ii++) {
1044 if ((sc = hd->ScsiLookup[ii]) != NULL) { 1045 if ((sc = hd->ScsiLookup[ii]) != NULL) {
1045 1046
1046 mf = (SCSIIORequest_t *)MPT_INDEX_2_MFPTR(hd->ioc, ii); 1047 mf = (SCSIIORequest_t *)MPT_INDEX_2_MFPTR(ioc, ii);
1047 if (mf == NULL) 1048 if (mf == NULL)
1048 continue; 1049 continue;
1049 /* If the device is a hidden raid component, then its 1050 /* If the device is a hidden raid component, then its
@@ -1063,15 +1064,15 @@ mptscsih_search_running_cmds(MPT_SCSI_HOST *hd, VirtDevice *vdevice)
1063 /* Cleanup 1064 /* Cleanup
1064 */ 1065 */
1065 hd->ScsiLookup[ii] = NULL; 1066 hd->ScsiLookup[ii] = NULL;
1066 mptscsih_freeChainBuffers(hd->ioc, ii); 1067 mptscsih_freeChainBuffers(ioc, ii);
1067 mpt_free_msg_frame(hd->ioc, (MPT_FRAME_HDR *)mf); 1068 mpt_free_msg_frame(ioc, (MPT_FRAME_HDR *)mf);
1068 if ((unsigned char *)mf != sc->host_scribble) 1069 if ((unsigned char *)mf != sc->host_scribble)
1069 continue; 1070 continue;
1070 scsi_dma_unmap(sc); 1071 scsi_dma_unmap(sc);
1071 sc->host_scribble = NULL; 1072 sc->host_scribble = NULL;
1072 sc->result = DID_NO_CONNECT << 16; 1073 sc->result = DID_NO_CONNECT << 16;
1073 sdev_printk(MYIOC_s_INFO_FMT, sc->device, "completing cmds: fw_channel %d," 1074 sdev_printk(MYIOC_s_INFO_FMT, sc->device, "completing cmds: fw_channel %d,"
1074 "fw_id %d, sc=%p, mf = %p, idx=%x\n", hd->ioc->name, vdevice->vtarget->channel, 1075 "fw_id %d, sc=%p, mf = %p, idx=%x\n", ioc->name, vdevice->vtarget->channel,
1075 vdevice->vtarget->id, sc, mf, ii); 1076 vdevice->vtarget->id, sc, mf, ii);
1076 sc->scsi_done(sc); 1077 sc->scsi_done(sc);
1077 } 1078 }
@@ -1098,6 +1099,7 @@ mptscsih_report_queue_full(struct scsi_cmnd *sc, SCSIIOReply_t *pScsiReply, SCSI
1098{ 1099{
1099 long time = jiffies; 1100 long time = jiffies;
1100 MPT_SCSI_HOST *hd; 1101 MPT_SCSI_HOST *hd;
1102 MPT_ADAPTER *ioc;
1101 1103
1102 if (sc->device == NULL) 1104 if (sc->device == NULL)
1103 return; 1105 return;
@@ -1105,10 +1107,10 @@ mptscsih_report_queue_full(struct scsi_cmnd *sc, SCSIIOReply_t *pScsiReply, SCSI
1105 return; 1107 return;
1106 if ((hd = (MPT_SCSI_HOST *)sc->device->host->hostdata) == NULL) 1108 if ((hd = (MPT_SCSI_HOST *)sc->device->host->hostdata) == NULL)
1107 return; 1109 return;
1108 1110 ioc = hd->ioc;
1109 if (time - hd->last_queue_full > 10 * HZ) { 1111 if (time - hd->last_queue_full > 10 * HZ) {
1110 dprintk(hd->ioc, printk(MYIOC_s_WARN_FMT "Device (%d:%d:%d) reported QUEUE_FULL!\n", 1112 dprintk(ioc, printk(MYIOC_s_WARN_FMT "Device (%d:%d:%d) reported QUEUE_FULL!\n",
1111 hd->ioc->name, 0, sc->device->id, sc->device->lun)); 1113 ioc->name, 0, sc->device->id, sc->device->lun));
1112 hd->last_queue_full = time; 1114 hd->last_queue_full = time;
1113 } 1115 }
1114} 1116}
@@ -1143,20 +1145,20 @@ mptscsih_remove(struct pci_dev *pdev)
1143 sz1=0; 1145 sz1=0;
1144 1146
1145 if (hd->ScsiLookup != NULL) { 1147 if (hd->ScsiLookup != NULL) {
1146 sz1 = hd->ioc->req_depth * sizeof(void *); 1148 sz1 = ioc->req_depth * sizeof(void *);
1147 kfree(hd->ScsiLookup); 1149 kfree(hd->ScsiLookup);
1148 hd->ScsiLookup = NULL; 1150 hd->ScsiLookup = NULL;
1149 } 1151 }
1150 1152
1151 dprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT 1153 dprintk(ioc, printk(MYIOC_s_DEBUG_FMT
1152 "Free'd ScsiLookup (%d) memory\n", 1154 "Free'd ScsiLookup (%d) memory\n",
1153 hd->ioc->name, sz1)); 1155 ioc->name, sz1));
1154 1156
1155 kfree(hd->info_kbuf); 1157 kfree(hd->info_kbuf);
1156 1158
1157 /* NULL the Scsi_Host pointer 1159 /* NULL the Scsi_Host pointer
1158 */ 1160 */
1159 hd->ioc->sh = NULL; 1161 ioc->sh = NULL;
1160 1162
1161 scsi_host_put(host); 1163 scsi_host_put(host);
1162 1164
@@ -1386,7 +1388,7 @@ mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
1386 /* 1388 /*
1387 * Put together a MPT SCSI request... 1389 * Put together a MPT SCSI request...
1388 */ 1390 */
1389 if ((mf = mpt_get_msg_frame(hd->ioc->DoneCtx, hd->ioc)) == NULL) { 1391 if ((mf = mpt_get_msg_frame(ioc->DoneCtx, ioc)) == NULL) {
1390 dprintk(ioc, printk(MYIOC_s_WARN_FMT "QueueCmd, no msg frames!!\n", 1392 dprintk(ioc, printk(MYIOC_s_WARN_FMT "QueueCmd, no msg frames!!\n",
1391 ioc->name)); 1393 ioc->name));
1392 return SCSI_MLQUEUE_HOST_BUSY; 1394 return SCSI_MLQUEUE_HOST_BUSY;
@@ -1454,7 +1456,7 @@ mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
1454 pScsiReq->DataLength = cpu_to_le32(datalen); 1456 pScsiReq->DataLength = cpu_to_le32(datalen);
1455 1457
1456 /* SenseBuffer low address */ 1458 /* SenseBuffer low address */
1457 pScsiReq->SenseBufferLowAddr = cpu_to_le32(hd->ioc->sense_buf_low_dma 1459 pScsiReq->SenseBufferLowAddr = cpu_to_le32(ioc->sense_buf_low_dma
1458 + (my_idx * MPT_SENSE_BUFFER_ALLOC)); 1460 + (my_idx * MPT_SENSE_BUFFER_ALLOC));
1459 1461
1460 /* Now add the SG list 1462 /* Now add the SG list
@@ -1466,14 +1468,14 @@ mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
1466 (dma_addr_t) -1); 1468 (dma_addr_t) -1);
1467 } else { 1469 } else {
1468 /* Add a 32 or 64 bit SGE */ 1470 /* Add a 32 or 64 bit SGE */
1469 if (mptscsih_AddSGE(hd->ioc, SCpnt, pScsiReq, my_idx) != SUCCESS) 1471 if (mptscsih_AddSGE(ioc, SCpnt, pScsiReq, my_idx) != SUCCESS)
1470 goto fail; 1472 goto fail;
1471 } 1473 }
1472 1474
1473 SCpnt->host_scribble = (unsigned char *)mf; 1475 SCpnt->host_scribble = (unsigned char *)mf;
1474 hd->ScsiLookup[my_idx] = SCpnt; 1476 hd->ScsiLookup[my_idx] = SCpnt;
1475 1477
1476 mpt_put_msg_frame(hd->ioc->DoneCtx, hd->ioc, mf); 1478 mpt_put_msg_frame(ioc->DoneCtx, ioc, mf);
1477 dmfprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Issued SCSI cmd (%p) mf=%p idx=%d\n", 1479 dmfprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Issued SCSI cmd (%p) mf=%p idx=%d\n",
1478 ioc->name, SCpnt, mf, my_idx)); 1480 ioc->name, SCpnt, mf, my_idx));
1479 DBG_DUMP_REQUEST_FRAME(ioc, (u32 *)mf); 1481 DBG_DUMP_REQUEST_FRAME(ioc, (u32 *)mf);
@@ -1481,8 +1483,8 @@ mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
1481 1483
1482 fail: 1484 fail:
1483 hd->ScsiLookup[my_idx] = NULL; 1485 hd->ScsiLookup[my_idx] = NULL;
1484 mptscsih_freeChainBuffers(hd->ioc, my_idx); 1486 mptscsih_freeChainBuffers(ioc, my_idx);
1485 mpt_free_msg_frame(hd->ioc, mf); 1487 mpt_free_msg_frame(ioc, mf);
1486 return SCSI_MLQUEUE_HOST_BUSY; 1488 return SCSI_MLQUEUE_HOST_BUSY;
1487} 1489}
1488 1490
@@ -1608,12 +1610,12 @@ mptscsih_TMHandler(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 id, int lun, int c
1608 return FAILED; 1610 return FAILED;
1609 } 1611 }
1610 } else { 1612 } else {
1611 spin_lock_irqsave(&hd->ioc->FreeQlock, flags); 1613 spin_lock_irqsave(&ioc->FreeQlock, flags);
1612 hd->tmPending |= (1 << type); 1614 hd->tmPending |= (1 << type);
1613 spin_unlock_irqrestore(&hd->ioc->FreeQlock, flags); 1615 spin_unlock_irqrestore(&ioc->FreeQlock, flags);
1614 } 1616 }
1615 1617
1616 ioc_raw_state = mpt_GetIocState(hd->ioc, 0); 1618 ioc_raw_state = mpt_GetIocState(ioc, 0);
1617 1619
1618 if ((ioc_raw_state & MPI_IOC_STATE_MASK) != MPI_IOC_STATE_OPERATIONAL) { 1620 if ((ioc_raw_state & MPI_IOC_STATE_MASK) != MPI_IOC_STATE_OPERATIONAL) {
1619 printk(MYIOC_s_WARN_FMT 1621 printk(MYIOC_s_WARN_FMT
@@ -1681,16 +1683,17 @@ mptscsih_IssueTaskMgmt(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 id, int lun, i
1681 SCSITaskMgmt_t *pScsiTm; 1683 SCSITaskMgmt_t *pScsiTm;
1682 int ii; 1684 int ii;
1683 int retval; 1685 int retval;
1686 MPT_ADAPTER *ioc = hd->ioc;
1684 1687
1685 /* Return Fail to calling function if no message frames available. 1688 /* Return Fail to calling function if no message frames available.
1686 */ 1689 */
1687 if ((mf = mpt_get_msg_frame(hd->ioc->TaskCtx, hd->ioc)) == NULL) { 1690 if ((mf = mpt_get_msg_frame(ioc->TaskCtx, ioc)) == NULL) {
1688 dfailprintk(hd->ioc, printk(MYIOC_s_ERR_FMT "IssueTaskMgmt, no msg frames!!\n", 1691 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT "IssueTaskMgmt, no msg frames!!\n",
1689 hd->ioc->name)); 1692 ioc->name));
1690 return FAILED; 1693 return FAILED;
1691 } 1694 }
1692 dtmprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT "IssueTaskMgmt request @ %p\n", 1695 dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "IssueTaskMgmt request @ %p\n",
1693 hd->ioc->name, mf)); 1696 ioc->name, mf));
1694 1697
1695 /* Format the Request 1698 /* Format the Request
1696 */ 1699 */
@@ -1713,34 +1716,34 @@ mptscsih_IssueTaskMgmt(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 id, int lun, i
1713 1716
1714 pScsiTm->TaskMsgContext = ctx2abort; 1717 pScsiTm->TaskMsgContext = ctx2abort;
1715 1718
1716 dtmprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT "IssueTaskMgmt: ctx2abort (0x%08x) " 1719 dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "IssueTaskMgmt: ctx2abort (0x%08x) "
1717 "type=%d\n", hd->ioc->name, ctx2abort, type)); 1720 "type=%d\n", ioc->name, ctx2abort, type));
1718 1721
1719 DBG_DUMP_TM_REQUEST_FRAME(ioc, (u32 *)pScsiTm); 1722 DBG_DUMP_TM_REQUEST_FRAME(ioc, (u32 *)pScsiTm);
1720 1723
1721 if ((hd->ioc->facts.IOCCapabilities & MPI_IOCFACTS_CAPABILITY_HIGH_PRI_Q) && 1724 if ((ioc->facts.IOCCapabilities & MPI_IOCFACTS_CAPABILITY_HIGH_PRI_Q) &&
1722 (hd->ioc->facts.MsgVersion >= MPI_VERSION_01_05)) 1725 (ioc->facts.MsgVersion >= MPI_VERSION_01_05))
1723 mpt_put_msg_frame_hi_pri(hd->ioc->TaskCtx, hd->ioc, mf); 1726 mpt_put_msg_frame_hi_pri(ioc->TaskCtx, ioc, mf);
1724 else { 1727 else {
1725 retval = mpt_send_handshake_request(hd->ioc->TaskCtx, hd->ioc, 1728 retval = mpt_send_handshake_request(ioc->TaskCtx, ioc,
1726 sizeof(SCSITaskMgmt_t), (u32*)pScsiTm, CAN_SLEEP); 1729 sizeof(SCSITaskMgmt_t), (u32*)pScsiTm, CAN_SLEEP);
1727 if (retval) { 1730 if (retval) {
1728 dfailprintk(hd->ioc, printk(MYIOC_s_ERR_FMT "send_handshake FAILED!" 1731 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT "send_handshake FAILED!"
1729 " (hd %p, ioc %p, mf %p, rc=%d) \n", hd->ioc->name, hd, 1732 " (hd %p, ioc %p, mf %p, rc=%d) \n", ioc->name, hd,
1730 hd->ioc, mf, retval)); 1733 ioc, mf, retval));
1731 goto fail_out; 1734 goto fail_out;
1732 } 1735 }
1733 } 1736 }
1734 1737
1735 if(mptscsih_tm_wait_for_completion(hd, timeout) == FAILED) { 1738 if(mptscsih_tm_wait_for_completion(hd, timeout) == FAILED) {
1736 dfailprintk(hd->ioc, printk(MYIOC_s_ERR_FMT "task management request TIMED OUT!" 1739 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT "task management request TIMED OUT!"
1737 " (hd %p, ioc %p, mf %p) \n", hd->ioc->name, hd, 1740 " (hd %p, ioc %p, mf %p) \n", ioc->name, hd,
1738 hd->ioc, mf)); 1741 ioc, mf));
1739 dtmprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT "Calling HardReset! \n", 1742 dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Calling HardReset! \n",
1740 hd->ioc->name)); 1743 ioc->name));
1741 retval = mpt_HardResetHandler(hd->ioc, CAN_SLEEP); 1744 retval = mpt_HardResetHandler(ioc, CAN_SLEEP);
1742 dtmprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT "rc=%d \n", 1745 dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rc=%d \n",
1743 hd->ioc->name, retval)); 1746 ioc->name, retval));
1744 goto fail_out; 1747 goto fail_out;
1745 } 1748 }
1746 1749
@@ -1761,7 +1764,7 @@ mptscsih_IssueTaskMgmt(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 id, int lun, i
1761 /* 1764 /*
1762 * Free task managment mf, and corresponding tm flags 1765 * Free task managment mf, and corresponding tm flags
1763 */ 1766 */
1764 mpt_free_msg_frame(hd->ioc, mf); 1767 mpt_free_msg_frame(ioc, mf);
1765 hd->tmPending = 0; 1768 hd->tmPending = 0;
1766 hd->tmState = TM_STATE_NONE; 1769 hd->tmState = TM_STATE_NONE;
1767 return FAILED; 1770 return FAILED;
@@ -1868,7 +1871,7 @@ mptscsih_abort(struct scsi_cmnd * SCpnt)
1868 * swap it here either. It is an opaque cookie to 1871 * swap it here either. It is an opaque cookie to
1869 * the controller, so it does not matter. -DaveM 1872 * the controller, so it does not matter. -DaveM
1870 */ 1873 */
1871 mf = MPT_INDEX_2_MFPTR(hd->ioc, scpnt_idx); 1874 mf = MPT_INDEX_2_MFPTR(ioc, scpnt_idx);
1872 ctx2abort = mf->u.frame.hwhdr.msgctxu.MsgContext; 1875 ctx2abort = mf->u.frame.hwhdr.msgctxu.MsgContext;
1873 1876
1874 hd->abortSCpnt = SCpnt; 1877 hd->abortSCpnt = SCpnt;
@@ -2030,7 +2033,7 @@ mptscsih_host_reset(struct scsi_cmnd *SCpnt)
2030 /* If our attempts to reset the host failed, then return a failed 2033 /* If our attempts to reset the host failed, then return a failed
2031 * status. The host will be taken off line by the SCSI mid-layer. 2034 * status. The host will be taken off line by the SCSI mid-layer.
2032 */ 2035 */
2033 if (mpt_HardResetHandler(hd->ioc, CAN_SLEEP) < 0) { 2036 if (mpt_HardResetHandler(ioc, CAN_SLEEP) < 0) {
2034 retval = FAILED; 2037 retval = FAILED;
2035 } else { 2038 } else {
2036 /* Make sure TM pending is cleared and TM state is set to 2039 /* Make sure TM pending is cleared and TM state is set to
@@ -2060,17 +2063,18 @@ mptscsih_tm_pending_wait(MPT_SCSI_HOST * hd)
2060 unsigned long flags; 2063 unsigned long flags;
2061 int loop_count = 4 * 10; /* Wait 10 seconds */ 2064 int loop_count = 4 * 10; /* Wait 10 seconds */
2062 int status = FAILED; 2065 int status = FAILED;
2066 MPT_ADAPTER *ioc = hd->ioc;
2063 2067
2064 do { 2068 do {
2065 spin_lock_irqsave(&hd->ioc->FreeQlock, flags); 2069 spin_lock_irqsave(&ioc->FreeQlock, flags);
2066 if (hd->tmState == TM_STATE_NONE) { 2070 if (hd->tmState == TM_STATE_NONE) {
2067 hd->tmState = TM_STATE_IN_PROGRESS; 2071 hd->tmState = TM_STATE_IN_PROGRESS;
2068 hd->tmPending = 1; 2072 hd->tmPending = 1;
2069 spin_unlock_irqrestore(&hd->ioc->FreeQlock, flags); 2073 spin_unlock_irqrestore(&ioc->FreeQlock, flags);
2070 status = SUCCESS; 2074 status = SUCCESS;
2071 break; 2075 break;
2072 } 2076 }
2073 spin_unlock_irqrestore(&hd->ioc->FreeQlock, flags); 2077 spin_unlock_irqrestore(&ioc->FreeQlock, flags);
2074 msleep(250); 2078 msleep(250);
2075 } while (--loop_count); 2079 } while (--loop_count);
2076 2080
@@ -2091,15 +2095,16 @@ mptscsih_tm_wait_for_completion(MPT_SCSI_HOST * hd, ulong timeout )
2091 unsigned long flags; 2095 unsigned long flags;
2092 int loop_count = 4 * timeout; 2096 int loop_count = 4 * timeout;
2093 int status = FAILED; 2097 int status = FAILED;
2098 MPT_ADAPTER *ioc = hd->ioc;
2094 2099
2095 do { 2100 do {
2096 spin_lock_irqsave(&hd->ioc->FreeQlock, flags); 2101 spin_lock_irqsave(&ioc->FreeQlock, flags);
2097 if(hd->tmPending == 0) { 2102 if(hd->tmPending == 0) {
2098 status = SUCCESS; 2103 status = SUCCESS;
2099 spin_unlock_irqrestore(&hd->ioc->FreeQlock, flags); 2104 spin_unlock_irqrestore(&ioc->FreeQlock, flags);
2100 break; 2105 break;
2101 } 2106 }
2102 spin_unlock_irqrestore(&hd->ioc->FreeQlock, flags); 2107 spin_unlock_irqrestore(&ioc->FreeQlock, flags);
2103 msleep(250); 2108 msleep(250);
2104 } while (--loop_count); 2109 } while (--loop_count);
2105 2110
@@ -2407,11 +2412,12 @@ mptscsih_change_queue_depth(struct scsi_device *sdev, int qdepth)
2407 struct scsi_target *starget; 2412 struct scsi_target *starget;
2408 int max_depth; 2413 int max_depth;
2409 int tagged; 2414 int tagged;
2415 MPT_ADAPTER *ioc = hd->ioc;
2410 2416
2411 starget = scsi_target(sdev); 2417 starget = scsi_target(sdev);
2412 vtarget = starget->hostdata; 2418 vtarget = starget->hostdata;
2413 2419
2414 if (hd->ioc->bus_type == SPI) { 2420 if (ioc->bus_type == SPI) {
2415 if (!(vtarget->tflags & MPT_TARGET_FLAGS_Q_YES)) 2421 if (!(vtarget->tflags & MPT_TARGET_FLAGS_Q_YES))
2416 max_depth = 1; 2422 max_depth = 1;
2417 else if (sdev->type == TYPE_DISK && 2423 else if (sdev->type == TYPE_DISK &&
@@ -2447,18 +2453,19 @@ mptscsih_slave_configure(struct scsi_device *sdev)
2447 VirtDevice *vdevice; 2453 VirtDevice *vdevice;
2448 struct scsi_target *starget; 2454 struct scsi_target *starget;
2449 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)sh->hostdata; 2455 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)sh->hostdata;
2456 MPT_ADAPTER *ioc = hd->ioc;
2450 2457
2451 starget = scsi_target(sdev); 2458 starget = scsi_target(sdev);
2452 vtarget = starget->hostdata; 2459 vtarget = starget->hostdata;
2453 vdevice = sdev->hostdata; 2460 vdevice = sdev->hostdata;
2454 2461
2455 dsprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT 2462 dsprintk(ioc, printk(MYIOC_s_DEBUG_FMT
2456 "device @ %p, channel=%d, id=%d, lun=%d\n", 2463 "device @ %p, channel=%d, id=%d, lun=%d\n",
2457 hd->ioc->name, sdev, sdev->channel, sdev->id, sdev->lun)); 2464 ioc->name, sdev, sdev->channel, sdev->id, sdev->lun));
2458 if (hd->ioc->bus_type == SPI) 2465 if (ioc->bus_type == SPI)
2459 dsprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT 2466 dsprintk(ioc, printk(MYIOC_s_DEBUG_FMT
2460 "sdtr %d wdtr %d ppr %d inq length=%d\n", 2467 "sdtr %d wdtr %d ppr %d inq length=%d\n",
2461 hd->ioc->name, sdev->sdtr, sdev->wdtr, 2468 ioc->name, sdev->sdtr, sdev->wdtr,
2462 sdev->ppr, sdev->inquiry_len)); 2469 sdev->ppr, sdev->inquiry_len));
2463 2470
2464 if (sdev->id > sh->max_id) { 2471 if (sdev->id > sh->max_id) {
@@ -2470,21 +2477,21 @@ mptscsih_slave_configure(struct scsi_device *sdev)
2470 vdevice->configured_lun = 1; 2477 vdevice->configured_lun = 1;
2471 mptscsih_change_queue_depth(sdev, MPT_SCSI_CMD_PER_DEV_HIGH); 2478 mptscsih_change_queue_depth(sdev, MPT_SCSI_CMD_PER_DEV_HIGH);
2472 2479
2473 dsprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT 2480 dsprintk(ioc, printk(MYIOC_s_DEBUG_FMT
2474 "Queue depth=%d, tflags=%x\n", 2481 "Queue depth=%d, tflags=%x\n",
2475 hd->ioc->name, sdev->queue_depth, vtarget->tflags)); 2482 ioc->name, sdev->queue_depth, vtarget->tflags));
2476 2483
2477 if (hd->ioc->bus_type == SPI) 2484 if (ioc->bus_type == SPI)
2478 dsprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT 2485 dsprintk(ioc, printk(MYIOC_s_DEBUG_FMT
2479 "negoFlags=%x, maxOffset=%x, SyncFactor=%x\n", 2486 "negoFlags=%x, maxOffset=%x, SyncFactor=%x\n",
2480 hd->ioc->name, vtarget->negoFlags, vtarget->maxOffset, 2487 ioc->name, vtarget->negoFlags, vtarget->maxOffset,
2481 vtarget->minSyncFactor)); 2488 vtarget->minSyncFactor));
2482 2489
2483slave_configure_exit: 2490slave_configure_exit:
2484 2491
2485 dsprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT 2492 dsprintk(ioc, printk(MYIOC_s_DEBUG_FMT
2486 "tagged %d, simple %d, ordered %d\n", 2493 "tagged %d, simple %d, ordered %d\n",
2487 hd->ioc->name,sdev->tagged_supported, sdev->simple_tags, 2494 ioc->name,sdev->tagged_supported, sdev->simple_tags,
2488 sdev->ordered_tags)); 2495 sdev->ordered_tags));
2489 2496
2490 return 0; 2497 return 0;
@@ -2506,6 +2513,7 @@ mptscsih_copy_sense_data(struct scsi_cmnd *sc, MPT_SCSI_HOST *hd, MPT_FRAME_HDR
2506 VirtDevice *vdevice; 2513 VirtDevice *vdevice;
2507 SCSIIORequest_t *pReq; 2514 SCSIIORequest_t *pReq;
2508 u32 sense_count = le32_to_cpu(pScsiReply->SenseCount); 2515 u32 sense_count = le32_to_cpu(pScsiReply->SenseCount);
2516 MPT_ADAPTER *ioc = hd->ioc;
2509 2517
2510 /* Get target structure 2518 /* Get target structure
2511 */ 2519 */
@@ -2518,15 +2526,14 @@ mptscsih_copy_sense_data(struct scsi_cmnd *sc, MPT_SCSI_HOST *hd, MPT_FRAME_HDR
2518 2526
2519 /* Copy the sense received into the scsi command block. */ 2527 /* Copy the sense received into the scsi command block. */
2520 req_index = le16_to_cpu(mf->u.frame.hwhdr.msgctxu.fld.req_idx); 2528 req_index = le16_to_cpu(mf->u.frame.hwhdr.msgctxu.fld.req_idx);
2521 sense_data = ((u8 *)hd->ioc->sense_buf_pool + (req_index * MPT_SENSE_BUFFER_ALLOC)); 2529 sense_data = ((u8 *)ioc->sense_buf_pool + (req_index * MPT_SENSE_BUFFER_ALLOC));
2522 memcpy(sc->sense_buffer, sense_data, SNS_LEN(sc)); 2530 memcpy(sc->sense_buffer, sense_data, SNS_LEN(sc));
2523 2531
2524 /* Log SMART data (asc = 0x5D, non-IM case only) if required. 2532 /* Log SMART data (asc = 0x5D, non-IM case only) if required.
2525 */ 2533 */
2526 if ((hd->ioc->events) && (hd->ioc->eventTypes & (1 << MPI_EVENT_SCSI_DEVICE_STATUS_CHANGE))) { 2534 if ((ioc->events) && (ioc->eventTypes & (1 << MPI_EVENT_SCSI_DEVICE_STATUS_CHANGE))) {
2527 if ((sense_data[12] == 0x5D) && (vdevice->vtarget->raidVolume == 0)) { 2535 if ((sense_data[12] == 0x5D) && (vdevice->vtarget->raidVolume == 0)) {
2528 int idx; 2536 int idx;
2529 MPT_ADAPTER *ioc = hd->ioc;
2530 2537
2531 idx = ioc->eventContext % MPTCTL_EVENT_LOG_SIZE; 2538 idx = ioc->eventContext % MPTCTL_EVENT_LOG_SIZE;
2532 ioc->events[idx].event = MPI_EVENT_SCSI_DEVICE_STATUS_CHANGE; 2539 ioc->events[idx].event = MPI_EVENT_SCSI_DEVICE_STATUS_CHANGE;
@@ -2539,9 +2546,9 @@ mptscsih_copy_sense_data(struct scsi_cmnd *sc, MPT_SCSI_HOST *hd, MPT_FRAME_HDR
2539 ioc->events[idx].data[1] = (sense_data[13] << 8) | sense_data[12]; 2546 ioc->events[idx].data[1] = (sense_data[13] << 8) | sense_data[12];
2540 2547
2541 ioc->eventContext++; 2548 ioc->eventContext++;
2542 if (hd->ioc->pcidev->vendor == 2549 if (ioc->pcidev->vendor ==
2543 PCI_VENDOR_ID_IBM) { 2550 PCI_VENDOR_ID_IBM) {
2544 mptscsih_issue_sep_command(hd->ioc, 2551 mptscsih_issue_sep_command(ioc,
2545 vdevice->vtarget, MPI_SEP_REQ_SLOTSTATUS_PREDICTED_FAULT); 2552 vdevice->vtarget, MPI_SEP_REQ_SLOTSTATUS_PREDICTED_FAULT);
2546 vdevice->vtarget->tflags |= 2553 vdevice->vtarget->tflags |=
2547 MPT_TARGET_FLAGS_LED_ON; 2554 MPT_TARGET_FLAGS_LED_ON;
@@ -2549,8 +2556,8 @@ mptscsih_copy_sense_data(struct scsi_cmnd *sc, MPT_SCSI_HOST *hd, MPT_FRAME_HDR
2549 } 2556 }
2550 } 2557 }
2551 } else { 2558 } else {
2552 dprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT "Hmmm... SenseData len=0! (?)\n", 2559 dprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Hmmm... SenseData len=0! (?)\n",
2553 hd->ioc->name)); 2560 ioc->name));
2554 } 2561 }
2555} 2562}
2556 2563
@@ -2635,7 +2642,7 @@ mptscsih_ioc_reset(MPT_ADAPTER *ioc, int reset_phase)
2635 2642
2636 /* ScsiLookup initialization 2643 /* ScsiLookup initialization
2637 */ 2644 */
2638 for (ii=0; ii < hd->ioc->req_depth; ii++) 2645 for (ii=0; ii < ioc->req_depth; ii++)
2639 hd->ScsiLookup[ii] = NULL; 2646 hd->ScsiLookup[ii] = NULL;
2640 2647
2641 /* 2. Chain Buffer initialization 2648 /* 2. Chain Buffer initialization
@@ -2780,12 +2787,12 @@ mptscsih_scandv_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
2780 2787
2781 if (mf != hd->cmdPtr) { 2788 if (mf != hd->cmdPtr) {
2782 printk(MYIOC_s_WARN_FMT "ScanDvComplete (mf=%p, cmdPtr=%p, idx=%d)\n", 2789 printk(MYIOC_s_WARN_FMT "ScanDvComplete (mf=%p, cmdPtr=%p, idx=%d)\n",
2783 hd->ioc->name, (void *)mf, (void *) hd->cmdPtr, req_idx); 2790 ioc->name, (void *)mf, (void *) hd->cmdPtr, req_idx);
2784 } 2791 }
2785 hd->cmdPtr = NULL; 2792 hd->cmdPtr = NULL;
2786 2793
2787 ddvprintk(ioc, printk(MYIOC_s_DEBUG_FMT "ScanDvComplete (mf=%p,mr=%p,idx=%d)\n", 2794 ddvprintk(ioc, printk(MYIOC_s_DEBUG_FMT "ScanDvComplete (mf=%p,mr=%p,idx=%d)\n",
2788 hd->ioc->name, mf, mr, req_idx)); 2795 ioc->name, mf, mr, req_idx));
2789 2796
2790 hd->pLocal = &hd->localReply; 2797 hd->pLocal = &hd->localReply;
2791 hd->pLocal->scsiStatus = 0; 2798 hd->pLocal->scsiStatus = 0;
@@ -2849,7 +2856,7 @@ mptscsih_scandv_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
2849 */ 2856 */
2850 completionCode = MPT_SCANDV_SENSE; 2857 completionCode = MPT_SCANDV_SENSE;
2851 hd->pLocal->scsiStatus = scsi_status; 2858 hd->pLocal->scsiStatus = scsi_status;
2852 sense_data = ((u8 *)hd->ioc->sense_buf_pool + 2859 sense_data = ((u8 *)ioc->sense_buf_pool +
2853 (req_idx * MPT_SENSE_BUFFER_ALLOC)); 2860 (req_idx * MPT_SENSE_BUFFER_ALLOC));
2854 2861
2855 sz = min_t(int, pReq->SenseBufferLength, 2862 sz = min_t(int, pReq->SenseBufferLength,
@@ -2916,8 +2923,9 @@ void
2916mptscsih_timer_expired(unsigned long data) 2923mptscsih_timer_expired(unsigned long data)
2917{ 2924{
2918 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *) data; 2925 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *) data;
2926 MPT_ADAPTER *ioc = hd->ioc;
2919 2927
2920 ddvprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT "Timer Expired! Cmd %p\n", hd->ioc->name, hd->cmdPtr)); 2928 ddvprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Timer Expired! Cmd %p\n", ioc->name, hd->cmdPtr));
2921 2929
2922 if (hd->cmdPtr) { 2930 if (hd->cmdPtr) {
2923 MPIHeader_t *cmd = (MPIHeader_t *)hd->cmdPtr; 2931 MPIHeader_t *cmd = (MPIHeader_t *)hd->cmdPtr;
@@ -2931,13 +2939,13 @@ mptscsih_timer_expired(unsigned long data)
2931 */ 2939 */
2932 } else { 2940 } else {
2933 /* Perform a FW reload */ 2941 /* Perform a FW reload */
2934 if (mpt_HardResetHandler(hd->ioc, NO_SLEEP) < 0) { 2942 if (mpt_HardResetHandler(ioc, NO_SLEEP) < 0) {
2935 printk(MYIOC_s_WARN_FMT "Firmware Reload FAILED!\n", hd->ioc->name); 2943 printk(MYIOC_s_WARN_FMT "Firmware Reload FAILED!\n", ioc->name);
2936 } 2944 }
2937 } 2945 }
2938 } else { 2946 } else {
2939 /* This should NEVER happen */ 2947 /* This should NEVER happen */
2940 printk(MYIOC_s_WARN_FMT "Null cmdPtr!!!!\n", hd->ioc->name); 2948 printk(MYIOC_s_WARN_FMT "Null cmdPtr!!!!\n", ioc->name);
2941 } 2949 }
2942 2950
2943 /* No more processing. 2951 /* No more processing.
@@ -2945,7 +2953,7 @@ mptscsih_timer_expired(unsigned long data)
2945 * The FW will reply to all outstanding commands, callback will finish cleanup. 2953 * The FW will reply to all outstanding commands, callback will finish cleanup.
2946 * Hard reset clean-up will free all resources. 2954 * Hard reset clean-up will free all resources.
2947 */ 2955 */
2948 ddvprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT "Timer Expired Complete!\n", hd->ioc->name)); 2956 ddvprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Timer Expired Complete!\n", ioc->name));
2949 2957
2950 return; 2958 return;
2951} 2959}
@@ -2983,11 +2991,12 @@ mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTERNAL_CMD *io)
2983 char cmdLen; 2991 char cmdLen;
2984 char CDB[]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; 2992 char CDB[]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
2985 char cmd = io->cmd; 2993 char cmd = io->cmd;
2994 MPT_ADAPTER *ioc = hd->ioc;
2986 2995
2987 in_isr = in_interrupt(); 2996 in_isr = in_interrupt();
2988 if (in_isr) { 2997 if (in_isr) {
2989 dprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT "Internal SCSI IO request not allowed in ISR context!\n", 2998 dprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Internal SCSI IO request not allowed in ISR context!\n",
2990 hd->ioc->name)); 2999 ioc->name));
2991 return -EPERM; 3000 return -EPERM;
2992 } 3001 }
2993 3002
@@ -3088,9 +3097,9 @@ mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTERNAL_CMD *io)
3088 3097
3089 /* Get and Populate a free Frame 3098 /* Get and Populate a free Frame
3090 */ 3099 */
3091 if ((mf = mpt_get_msg_frame(hd->ioc->InternalCtx, hd->ioc)) == NULL) { 3100 if ((mf = mpt_get_msg_frame(ioc->InternalCtx, ioc)) == NULL) {
3092 dfailprintk(hd->ioc, printk(MYIOC_s_WARN_FMT "No msg frames!\n", 3101 dfailprintk(ioc, printk(MYIOC_s_WARN_FMT "No msg frames!\n",
3093 hd->ioc->name)); 3102 ioc->name));
3094 return -EBUSY; 3103 return -EBUSY;
3095 } 3104 }
3096 3105
@@ -3129,19 +3138,19 @@ mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTERNAL_CMD *io)
3129 3138
3130 if (cmd == REQUEST_SENSE) { 3139 if (cmd == REQUEST_SENSE) {
3131 pScsiReq->Control = cpu_to_le32(dir | MPI_SCSIIO_CONTROL_UNTAGGED); 3140 pScsiReq->Control = cpu_to_le32(dir | MPI_SCSIIO_CONTROL_UNTAGGED);
3132 ddvprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT "Untagged! 0x%2x\n", 3141 ddvprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Untagged! 0x%2x\n",
3133 hd->ioc->name, cmd)); 3142 ioc->name, cmd));
3134 } 3143 }
3135 3144
3136 for (ii=0; ii < 16; ii++) 3145 for (ii=0; ii < 16; ii++)
3137 pScsiReq->CDB[ii] = CDB[ii]; 3146 pScsiReq->CDB[ii] = CDB[ii];
3138 3147
3139 pScsiReq->DataLength = cpu_to_le32(io->size); 3148 pScsiReq->DataLength = cpu_to_le32(io->size);
3140 pScsiReq->SenseBufferLowAddr = cpu_to_le32(hd->ioc->sense_buf_low_dma 3149 pScsiReq->SenseBufferLowAddr = cpu_to_le32(ioc->sense_buf_low_dma
3141 + (my_idx * MPT_SENSE_BUFFER_ALLOC)); 3150 + (my_idx * MPT_SENSE_BUFFER_ALLOC));
3142 3151
3143 ddvprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT "Sending Command 0x%x for (%d:%d:%d)\n", 3152 ddvprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Sending Command 0x%x for (%d:%d:%d)\n",
3144 hd->ioc->name, cmd, io->channel, io->id, io->lun)); 3153 ioc->name, cmd, io->channel, io->id, io->lun));
3145 3154
3146 if (dir == MPI_SCSIIO_CONTROL_READ) { 3155 if (dir == MPI_SCSIIO_CONTROL_READ) {
3147 mpt_add_sge((char *) &pScsiReq->SGL, 3156 mpt_add_sge((char *) &pScsiReq->SGL,
@@ -3176,7 +3185,7 @@ mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTERNAL_CMD *io)
3176 hd->cmdPtr = mf; 3185 hd->cmdPtr = mf;
3177 3186
3178 add_timer(&hd->timer); 3187 add_timer(&hd->timer);
3179 mpt_put_msg_frame(hd->ioc->InternalCtx, hd->ioc, mf); 3188 mpt_put_msg_frame(ioc->InternalCtx, ioc, mf);
3180 wait_event(hd->scandv_waitq, hd->scandv_wait_done); 3189 wait_event(hd->scandv_waitq, hd->scandv_wait_done);
3181 3190
3182 if (hd->pLocal) { 3191 if (hd->pLocal) {
@@ -3192,8 +3201,8 @@ mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTERNAL_CMD *io)
3192 } else { 3201 } else {
3193 rc = -EFAULT; 3202 rc = -EFAULT;
3194 /* This should never happen. */ 3203 /* This should never happen. */
3195 ddvprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT "_do_cmd: Null pLocal!!!\n", 3204 ddvprintk(ioc, printk(MYIOC_s_DEBUG_FMT "_do_cmd: Null pLocal!!!\n",
3196 hd->ioc->name)); 3205 ioc->name));
3197 } 3206 }
3198 3207
3199 return rc; 3208 return rc;