[SCSI] mpt fusion: removing references to hd->ioc

Cleaning up code by accesing the ioc pointer directly instead of via hd->ioc.  In the future, most data members of struct MPT_SCSI_HOST will be either deleted or moved to struct MPT_ADAPTER.

Signed-off-by: Eric Moore <Eric.Moore@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
This commit is contained in:
Eric Moore 2007-09-14 18:49:03 -06:00 committed by James Bottomley
parent a69de507aa
commit e80b002bfd
4 changed files with 188 additions and 162 deletions

View file

@ -194,12 +194,14 @@ mptfc_block_error_handler(struct scsi_cmnd *SCpnt,
struct fc_rport *rport = starget_to_rport(scsi_target(sdev)); struct fc_rport *rport = starget_to_rport(scsi_target(sdev));
unsigned long flags; unsigned long flags;
int ready; int ready;
MPT_ADAPTER *ioc;
hd = (MPT_SCSI_HOST *) SCpnt->device->host->hostdata; hd = (MPT_SCSI_HOST *) SCpnt->device->host->hostdata;
ioc = hd->ioc;
spin_lock_irqsave(shost->host_lock, flags); spin_lock_irqsave(shost->host_lock, flags);
while ((ready = fc_remote_port_chkready(rport) >> 16) == DID_IMM_RETRY) { while ((ready = fc_remote_port_chkready(rport) >> 16) == DID_IMM_RETRY) {
spin_unlock_irqrestore(shost->host_lock, flags); spin_unlock_irqrestore(shost->host_lock, flags);
dfcprintk (hd->ioc, printk(MYIOC_s_DEBUG_FMT dfcprintk (ioc, printk(MYIOC_s_DEBUG_FMT
"mptfc_block_error_handler.%d: %d:%d, port status is " "mptfc_block_error_handler.%d: %d:%d, port status is "
"DID_IMM_RETRY, deferring %s recovery.\n", "DID_IMM_RETRY, deferring %s recovery.\n",
((MPT_SCSI_HOST *) shost->hostdata)->ioc->name, ((MPT_SCSI_HOST *) shost->hostdata)->ioc->name,
@ -211,7 +213,7 @@ mptfc_block_error_handler(struct scsi_cmnd *SCpnt,
spin_unlock_irqrestore(shost->host_lock, flags); spin_unlock_irqrestore(shost->host_lock, flags);
if (ready == DID_NO_CONNECT || !SCpnt->device->hostdata) { if (ready == DID_NO_CONNECT || !SCpnt->device->hostdata) {
dfcprintk (hd->ioc, printk(MYIOC_s_DEBUG_FMT dfcprintk (ioc, printk(MYIOC_s_DEBUG_FMT
"%s.%d: %d:%d, failing recovery, " "%s.%d: %d:%d, failing recovery, "
"port state %d, vdevice %p.\n", caller, "port state %d, vdevice %p.\n", caller,
((MPT_SCSI_HOST *) shost->hostdata)->ioc->name, ((MPT_SCSI_HOST *) shost->hostdata)->ioc->name,
@ -220,7 +222,7 @@ mptfc_block_error_handler(struct scsi_cmnd *SCpnt,
SCpnt->device->hostdata)); SCpnt->device->hostdata));
return FAILED; return FAILED;
} }
dfcprintk (hd->ioc, printk(MYIOC_s_DEBUG_FMT dfcprintk (ioc, printk(MYIOC_s_DEBUG_FMT
"%s.%d: %d:%d, executing recovery.\n", caller, "%s.%d: %d:%d, executing recovery.\n", caller,
((MPT_SCSI_HOST *) shost->hostdata)->ioc->name, ((MPT_SCSI_HOST *) shost->hostdata)->ioc->name,
((MPT_SCSI_HOST *) shost->hostdata)->ioc->sh->host_no, ((MPT_SCSI_HOST *) shost->hostdata)->ioc->sh->host_no,
@ -605,7 +607,7 @@ mptfc_slave_alloc(struct scsi_device *sdev)
VirtDevice *vdevice; VirtDevice *vdevice;
struct scsi_target *starget; struct scsi_target *starget;
struct fc_rport *rport; struct fc_rport *rport;
MPT_ADAPTER *ioc;
starget = scsi_target(sdev); starget = scsi_target(sdev);
rport = starget_to_rport(starget); rport = starget_to_rport(starget);
@ -614,11 +616,12 @@ mptfc_slave_alloc(struct scsi_device *sdev)
return -ENXIO; return -ENXIO;
hd = (MPT_SCSI_HOST *)sdev->host->hostdata; hd = (MPT_SCSI_HOST *)sdev->host->hostdata;
ioc = hd->ioc;
vdevice = kzalloc(sizeof(VirtDevice), GFP_KERNEL); vdevice = kzalloc(sizeof(VirtDevice), GFP_KERNEL);
if (!vdevice) { if (!vdevice) {
printk(MYIOC_s_ERR_FMT "slave_alloc kmalloc(%zd) FAILED!\n", printk(MYIOC_s_ERR_FMT "slave_alloc kmalloc(%zd) FAILED!\n",
hd->ioc->name, sizeof(VirtDevice)); ioc->name, sizeof(VirtDevice));
return -ENOMEM; return -ENOMEM;
} }
@ -627,7 +630,7 @@ mptfc_slave_alloc(struct scsi_device *sdev)
vtarget = starget->hostdata; vtarget = starget->hostdata;
if (vtarget->num_luns == 0) { if (vtarget->num_luns == 0) {
vtarget->ioc_id = hd->ioc->id; vtarget->ioc_id = ioc->id;
vtarget->tflags = MPT_TARGET_FLAGS_Q_YES; vtarget->tflags = MPT_TARGET_FLAGS_Q_YES;
} }
@ -637,7 +640,7 @@ mptfc_slave_alloc(struct scsi_device *sdev)
vtarget->num_luns++; vtarget->num_luns++;
mptfc_dump_lun_info(hd->ioc, rport, sdev, vtarget); mptfc_dump_lun_info(ioc, rport, sdev, vtarget);
return 0; return 0;
} }

View file

@ -846,13 +846,14 @@ mptsas_target_alloc(struct scsi_target *starget)
struct sas_rphy *rphy; struct sas_rphy *rphy;
struct mptsas_portinfo *p; struct mptsas_portinfo *p;
int i; int i;
MPT_ADAPTER *ioc = hd->ioc;
vtarget = kzalloc(sizeof(VirtTarget), GFP_KERNEL); vtarget = kzalloc(sizeof(VirtTarget), GFP_KERNEL);
if (!vtarget) if (!vtarget)
return -ENOMEM; return -ENOMEM;
vtarget->starget = starget; vtarget->starget = starget;
vtarget->ioc_id = hd->ioc->id; vtarget->ioc_id = ioc->id;
vtarget->tflags = MPT_TARGET_FLAGS_Q_YES; vtarget->tflags = MPT_TARGET_FLAGS_Q_YES;
id = starget->id; id = starget->id;
channel = 0; channel = 0;
@ -861,15 +862,15 @@ mptsas_target_alloc(struct scsi_target *starget)
* RAID volumes placed beyond the last expected port. * RAID volumes placed beyond the last expected port.
*/ */
if (starget->channel == MPTSAS_RAID_CHANNEL) { if (starget->channel == MPTSAS_RAID_CHANNEL) {
for (i=0; i < hd->ioc->raid_data.pIocPg2->NumActiveVolumes; i++) for (i=0; i < ioc->raid_data.pIocPg2->NumActiveVolumes; i++)
if (id == hd->ioc->raid_data.pIocPg2->RaidVolume[i].VolumeID) if (id == ioc->raid_data.pIocPg2->RaidVolume[i].VolumeID)
channel = hd->ioc->raid_data.pIocPg2->RaidVolume[i].VolumeBus; channel = ioc->raid_data.pIocPg2->RaidVolume[i].VolumeBus;
goto out; goto out;
} }
rphy = dev_to_rphy(starget->dev.parent); rphy = dev_to_rphy(starget->dev.parent);
mutex_lock(&hd->ioc->sas_topology_mutex); mutex_lock(&ioc->sas_topology_mutex);
list_for_each_entry(p, &hd->ioc->sas_topology, list) { list_for_each_entry(p, &ioc->sas_topology, list) {
for (i = 0; i < p->num_phys; i++) { for (i = 0; i < p->num_phys; i++) {
if (p->phy_info[i].attached.sas_address != if (p->phy_info[i].attached.sas_address !=
rphy->identify.sas_address) rphy->identify.sas_address)
@ -881,18 +882,18 @@ mptsas_target_alloc(struct scsi_target *starget)
/* /*
* Exposing hidden raid components * Exposing hidden raid components
*/ */
if (mptscsih_is_phys_disk(hd->ioc, channel, id)) { if (mptscsih_is_phys_disk(ioc, channel, id)) {
id = mptscsih_raid_id_to_num(hd->ioc, id = mptscsih_raid_id_to_num(ioc,
channel, id); channel, id);
vtarget->tflags |= vtarget->tflags |=
MPT_TARGET_FLAGS_RAID_COMPONENT; MPT_TARGET_FLAGS_RAID_COMPONENT;
p->phy_info[i].attached.phys_disk_num = id; p->phy_info[i].attached.phys_disk_num = id;
} }
mutex_unlock(&hd->ioc->sas_topology_mutex); mutex_unlock(&ioc->sas_topology_mutex);
goto out; goto out;
} }
} }
mutex_unlock(&hd->ioc->sas_topology_mutex); mutex_unlock(&ioc->sas_topology_mutex);
kfree(vtarget); kfree(vtarget);
return -ENXIO; return -ENXIO;
@ -912,6 +913,7 @@ mptsas_target_destroy(struct scsi_target *starget)
struct sas_rphy *rphy; struct sas_rphy *rphy;
struct mptsas_portinfo *p; struct mptsas_portinfo *p;
int i; int i;
MPT_ADAPTER *ioc = hd->ioc;
if (!starget->hostdata) if (!starget->hostdata)
return; return;
@ -920,7 +922,7 @@ mptsas_target_destroy(struct scsi_target *starget)
goto out; goto out;
rphy = dev_to_rphy(starget->dev.parent); rphy = dev_to_rphy(starget->dev.parent);
list_for_each_entry(p, &hd->ioc->sas_topology, list) { list_for_each_entry(p, &ioc->sas_topology, list) {
for (i = 0; i < p->num_phys; i++) { for (i = 0; i < p->num_phys; i++) {
if (p->phy_info[i].attached.sas_address != if (p->phy_info[i].attached.sas_address !=
rphy->identify.sas_address) rphy->identify.sas_address)
@ -946,11 +948,12 @@ mptsas_slave_alloc(struct scsi_device *sdev)
VirtDevice *vdevice; VirtDevice *vdevice;
struct scsi_target *starget; struct scsi_target *starget;
int i; int i;
MPT_ADAPTER *ioc = hd->ioc;
vdevice = kzalloc(sizeof(VirtDevice), GFP_KERNEL); vdevice = kzalloc(sizeof(VirtDevice), GFP_KERNEL);
if (!vdevice) { if (!vdevice) {
printk(MYIOC_s_ERR_FMT "slave_alloc kzalloc(%zd) FAILED!\n", printk(MYIOC_s_ERR_FMT "slave_alloc kzalloc(%zd) FAILED!\n",
hd->ioc->name, sizeof(VirtDevice)); ioc->name, sizeof(VirtDevice));
return -ENOMEM; return -ENOMEM;
} }
starget = scsi_target(sdev); starget = scsi_target(sdev);
@ -960,8 +963,8 @@ mptsas_slave_alloc(struct scsi_device *sdev)
goto out; goto out;
rphy = dev_to_rphy(sdev->sdev_target->dev.parent); rphy = dev_to_rphy(sdev->sdev_target->dev.parent);
mutex_lock(&hd->ioc->sas_topology_mutex); mutex_lock(&ioc->sas_topology_mutex);
list_for_each_entry(p, &hd->ioc->sas_topology, list) { list_for_each_entry(p, &ioc->sas_topology, list) {
for (i = 0; i < p->num_phys; i++) { for (i = 0; i < p->num_phys; i++) {
if (p->phy_info[i].attached.sas_address != if (p->phy_info[i].attached.sas_address !=
rphy->identify.sas_address) rphy->identify.sas_address)
@ -970,15 +973,15 @@ mptsas_slave_alloc(struct scsi_device *sdev)
/* /*
* Exposing hidden raid components * Exposing hidden raid components
*/ */
if (mptscsih_is_phys_disk(hd->ioc, if (mptscsih_is_phys_disk(ioc,
p->phy_info[i].attached.channel, p->phy_info[i].attached.channel,
p->phy_info[i].attached.id)) p->phy_info[i].attached.id))
sdev->no_uld_attach = 1; sdev->no_uld_attach = 1;
mutex_unlock(&hd->ioc->sas_topology_mutex); mutex_unlock(&ioc->sas_topology_mutex);
goto out; goto out;
} }
} }
mutex_unlock(&hd->ioc->sas_topology_mutex); mutex_unlock(&ioc->sas_topology_mutex);
kfree(vdevice); kfree(vdevice);
return -ENXIO; return -ENXIO;

View file

@ -1036,14 +1036,15 @@ mptscsih_search_running_cmds(MPT_SCSI_HOST *hd, VirtDevice *vdevice)
int max = hd->ioc->req_depth; int max = hd->ioc->req_depth;
struct scsi_cmnd *sc; struct scsi_cmnd *sc;
struct scsi_lun lun; struct scsi_lun lun;
MPT_ADAPTER *ioc = hd->ioc;
dsprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT ": search_running channel %d id %d lun %d max %d\n", dsprintk(ioc, printk(MYIOC_s_DEBUG_FMT ": search_running channel %d id %d lun %d max %d\n",
hd->ioc->name, vdevice->vtarget->channel, vdevice->vtarget->id, vdevice->lun, max)); ioc->name, vdevice->vtarget->channel, vdevice->vtarget->id, vdevice->lun, max));
for (ii=0; ii < max; ii++) { for (ii=0; ii < max; ii++) {
if ((sc = hd->ScsiLookup[ii]) != NULL) { if ((sc = hd->ScsiLookup[ii]) != NULL) {
mf = (SCSIIORequest_t *)MPT_INDEX_2_MFPTR(hd->ioc, ii); mf = (SCSIIORequest_t *)MPT_INDEX_2_MFPTR(ioc, ii);
if (mf == NULL) if (mf == NULL)
continue; continue;
/* If the device is a hidden raid component, then its /* If the device is a hidden raid component, then its
@ -1063,15 +1064,15 @@ mptscsih_search_running_cmds(MPT_SCSI_HOST *hd, VirtDevice *vdevice)
/* Cleanup /* Cleanup
*/ */
hd->ScsiLookup[ii] = NULL; hd->ScsiLookup[ii] = NULL;
mptscsih_freeChainBuffers(hd->ioc, ii); mptscsih_freeChainBuffers(ioc, ii);
mpt_free_msg_frame(hd->ioc, (MPT_FRAME_HDR *)mf); mpt_free_msg_frame(ioc, (MPT_FRAME_HDR *)mf);
if ((unsigned char *)mf != sc->host_scribble) if ((unsigned char *)mf != sc->host_scribble)
continue; continue;
scsi_dma_unmap(sc); scsi_dma_unmap(sc);
sc->host_scribble = NULL; sc->host_scribble = NULL;
sc->result = DID_NO_CONNECT << 16; sc->result = DID_NO_CONNECT << 16;
sdev_printk(MYIOC_s_INFO_FMT, sc->device, "completing cmds: fw_channel %d," sdev_printk(MYIOC_s_INFO_FMT, sc->device, "completing cmds: fw_channel %d,"
"fw_id %d, sc=%p, mf = %p, idx=%x\n", hd->ioc->name, vdevice->vtarget->channel, "fw_id %d, sc=%p, mf = %p, idx=%x\n", ioc->name, vdevice->vtarget->channel,
vdevice->vtarget->id, sc, mf, ii); vdevice->vtarget->id, sc, mf, ii);
sc->scsi_done(sc); sc->scsi_done(sc);
} }
@ -1098,6 +1099,7 @@ mptscsih_report_queue_full(struct scsi_cmnd *sc, SCSIIOReply_t *pScsiReply, SCSI
{ {
long time = jiffies; long time = jiffies;
MPT_SCSI_HOST *hd; MPT_SCSI_HOST *hd;
MPT_ADAPTER *ioc;
if (sc->device == NULL) if (sc->device == NULL)
return; return;
@ -1105,10 +1107,10 @@ mptscsih_report_queue_full(struct scsi_cmnd *sc, SCSIIOReply_t *pScsiReply, SCSI
return; return;
if ((hd = (MPT_SCSI_HOST *)sc->device->host->hostdata) == NULL) if ((hd = (MPT_SCSI_HOST *)sc->device->host->hostdata) == NULL)
return; return;
ioc = hd->ioc;
if (time - hd->last_queue_full > 10 * HZ) { if (time - hd->last_queue_full > 10 * HZ) {
dprintk(hd->ioc, printk(MYIOC_s_WARN_FMT "Device (%d:%d:%d) reported QUEUE_FULL!\n", dprintk(ioc, printk(MYIOC_s_WARN_FMT "Device (%d:%d:%d) reported QUEUE_FULL!\n",
hd->ioc->name, 0, sc->device->id, sc->device->lun)); ioc->name, 0, sc->device->id, sc->device->lun));
hd->last_queue_full = time; hd->last_queue_full = time;
} }
} }
@ -1143,20 +1145,20 @@ mptscsih_remove(struct pci_dev *pdev)
sz1=0; sz1=0;
if (hd->ScsiLookup != NULL) { if (hd->ScsiLookup != NULL) {
sz1 = hd->ioc->req_depth * sizeof(void *); sz1 = ioc->req_depth * sizeof(void *);
kfree(hd->ScsiLookup); kfree(hd->ScsiLookup);
hd->ScsiLookup = NULL; hd->ScsiLookup = NULL;
} }
dprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT dprintk(ioc, printk(MYIOC_s_DEBUG_FMT
"Free'd ScsiLookup (%d) memory\n", "Free'd ScsiLookup (%d) memory\n",
hd->ioc->name, sz1)); ioc->name, sz1));
kfree(hd->info_kbuf); kfree(hd->info_kbuf);
/* NULL the Scsi_Host pointer /* NULL the Scsi_Host pointer
*/ */
hd->ioc->sh = NULL; ioc->sh = NULL;
scsi_host_put(host); scsi_host_put(host);
@ -1386,7 +1388,7 @@ mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
/* /*
* Put together a MPT SCSI request... * Put together a MPT SCSI request...
*/ */
if ((mf = mpt_get_msg_frame(hd->ioc->DoneCtx, hd->ioc)) == NULL) { if ((mf = mpt_get_msg_frame(ioc->DoneCtx, ioc)) == NULL) {
dprintk(ioc, printk(MYIOC_s_WARN_FMT "QueueCmd, no msg frames!!\n", dprintk(ioc, printk(MYIOC_s_WARN_FMT "QueueCmd, no msg frames!!\n",
ioc->name)); ioc->name));
return SCSI_MLQUEUE_HOST_BUSY; return SCSI_MLQUEUE_HOST_BUSY;
@ -1454,7 +1456,7 @@ mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
pScsiReq->DataLength = cpu_to_le32(datalen); pScsiReq->DataLength = cpu_to_le32(datalen);
/* SenseBuffer low address */ /* SenseBuffer low address */
pScsiReq->SenseBufferLowAddr = cpu_to_le32(hd->ioc->sense_buf_low_dma pScsiReq->SenseBufferLowAddr = cpu_to_le32(ioc->sense_buf_low_dma
+ (my_idx * MPT_SENSE_BUFFER_ALLOC)); + (my_idx * MPT_SENSE_BUFFER_ALLOC));
/* Now add the SG list /* Now add the SG list
@ -1466,14 +1468,14 @@ mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
(dma_addr_t) -1); (dma_addr_t) -1);
} else { } else {
/* Add a 32 or 64 bit SGE */ /* Add a 32 or 64 bit SGE */
if (mptscsih_AddSGE(hd->ioc, SCpnt, pScsiReq, my_idx) != SUCCESS) if (mptscsih_AddSGE(ioc, SCpnt, pScsiReq, my_idx) != SUCCESS)
goto fail; goto fail;
} }
SCpnt->host_scribble = (unsigned char *)mf; SCpnt->host_scribble = (unsigned char *)mf;
hd->ScsiLookup[my_idx] = SCpnt; hd->ScsiLookup[my_idx] = SCpnt;
mpt_put_msg_frame(hd->ioc->DoneCtx, hd->ioc, mf); mpt_put_msg_frame(ioc->DoneCtx, ioc, mf);
dmfprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Issued SCSI cmd (%p) mf=%p idx=%d\n", dmfprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Issued SCSI cmd (%p) mf=%p idx=%d\n",
ioc->name, SCpnt, mf, my_idx)); ioc->name, SCpnt, mf, my_idx));
DBG_DUMP_REQUEST_FRAME(ioc, (u32 *)mf); DBG_DUMP_REQUEST_FRAME(ioc, (u32 *)mf);
@ -1481,8 +1483,8 @@ mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
fail: fail:
hd->ScsiLookup[my_idx] = NULL; hd->ScsiLookup[my_idx] = NULL;
mptscsih_freeChainBuffers(hd->ioc, my_idx); mptscsih_freeChainBuffers(ioc, my_idx);
mpt_free_msg_frame(hd->ioc, mf); mpt_free_msg_frame(ioc, mf);
return SCSI_MLQUEUE_HOST_BUSY; return SCSI_MLQUEUE_HOST_BUSY;
} }
@ -1608,12 +1610,12 @@ mptscsih_TMHandler(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 id, int lun, int c
return FAILED; return FAILED;
} }
} else { } else {
spin_lock_irqsave(&hd->ioc->FreeQlock, flags); spin_lock_irqsave(&ioc->FreeQlock, flags);
hd->tmPending |= (1 << type); hd->tmPending |= (1 << type);
spin_unlock_irqrestore(&hd->ioc->FreeQlock, flags); spin_unlock_irqrestore(&ioc->FreeQlock, flags);
} }
ioc_raw_state = mpt_GetIocState(hd->ioc, 0); ioc_raw_state = mpt_GetIocState(ioc, 0);
if ((ioc_raw_state & MPI_IOC_STATE_MASK) != MPI_IOC_STATE_OPERATIONAL) { if ((ioc_raw_state & MPI_IOC_STATE_MASK) != MPI_IOC_STATE_OPERATIONAL) {
printk(MYIOC_s_WARN_FMT printk(MYIOC_s_WARN_FMT
@ -1681,16 +1683,17 @@ mptscsih_IssueTaskMgmt(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 id, int lun, i
SCSITaskMgmt_t *pScsiTm; SCSITaskMgmt_t *pScsiTm;
int ii; int ii;
int retval; int retval;
MPT_ADAPTER *ioc = hd->ioc;
/* Return Fail to calling function if no message frames available. /* Return Fail to calling function if no message frames available.
*/ */
if ((mf = mpt_get_msg_frame(hd->ioc->TaskCtx, hd->ioc)) == NULL) { if ((mf = mpt_get_msg_frame(ioc->TaskCtx, ioc)) == NULL) {
dfailprintk(hd->ioc, printk(MYIOC_s_ERR_FMT "IssueTaskMgmt, no msg frames!!\n", dfailprintk(ioc, printk(MYIOC_s_ERR_FMT "IssueTaskMgmt, no msg frames!!\n",
hd->ioc->name)); ioc->name));
return FAILED; return FAILED;
} }
dtmprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT "IssueTaskMgmt request @ %p\n", dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "IssueTaskMgmt request @ %p\n",
hd->ioc->name, mf)); ioc->name, mf));
/* Format the Request /* Format the Request
*/ */
@ -1713,34 +1716,34 @@ mptscsih_IssueTaskMgmt(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 id, int lun, i
pScsiTm->TaskMsgContext = ctx2abort; pScsiTm->TaskMsgContext = ctx2abort;
dtmprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT "IssueTaskMgmt: ctx2abort (0x%08x) " dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "IssueTaskMgmt: ctx2abort (0x%08x) "
"type=%d\n", hd->ioc->name, ctx2abort, type)); "type=%d\n", ioc->name, ctx2abort, type));
DBG_DUMP_TM_REQUEST_FRAME(ioc, (u32 *)pScsiTm); DBG_DUMP_TM_REQUEST_FRAME(ioc, (u32 *)pScsiTm);
if ((hd->ioc->facts.IOCCapabilities & MPI_IOCFACTS_CAPABILITY_HIGH_PRI_Q) && if ((ioc->facts.IOCCapabilities & MPI_IOCFACTS_CAPABILITY_HIGH_PRI_Q) &&
(hd->ioc->facts.MsgVersion >= MPI_VERSION_01_05)) (ioc->facts.MsgVersion >= MPI_VERSION_01_05))
mpt_put_msg_frame_hi_pri(hd->ioc->TaskCtx, hd->ioc, mf); mpt_put_msg_frame_hi_pri(ioc->TaskCtx, ioc, mf);
else { else {
retval = mpt_send_handshake_request(hd->ioc->TaskCtx, hd->ioc, retval = mpt_send_handshake_request(ioc->TaskCtx, ioc,
sizeof(SCSITaskMgmt_t), (u32*)pScsiTm, CAN_SLEEP); sizeof(SCSITaskMgmt_t), (u32*)pScsiTm, CAN_SLEEP);
if (retval) { if (retval) {
dfailprintk(hd->ioc, printk(MYIOC_s_ERR_FMT "send_handshake FAILED!" dfailprintk(ioc, printk(MYIOC_s_ERR_FMT "send_handshake FAILED!"
" (hd %p, ioc %p, mf %p, rc=%d) \n", hd->ioc->name, hd, " (hd %p, ioc %p, mf %p, rc=%d) \n", ioc->name, hd,
hd->ioc, mf, retval)); ioc, mf, retval));
goto fail_out; goto fail_out;
} }
} }
if(mptscsih_tm_wait_for_completion(hd, timeout) == FAILED) { if(mptscsih_tm_wait_for_completion(hd, timeout) == FAILED) {
dfailprintk(hd->ioc, printk(MYIOC_s_ERR_FMT "task management request TIMED OUT!" dfailprintk(ioc, printk(MYIOC_s_ERR_FMT "task management request TIMED OUT!"
" (hd %p, ioc %p, mf %p) \n", hd->ioc->name, hd, " (hd %p, ioc %p, mf %p) \n", ioc->name, hd,
hd->ioc, mf)); ioc, mf));
dtmprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT "Calling HardReset! \n", dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Calling HardReset! \n",
hd->ioc->name)); ioc->name));
retval = mpt_HardResetHandler(hd->ioc, CAN_SLEEP); retval = mpt_HardResetHandler(ioc, CAN_SLEEP);
dtmprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT "rc=%d \n", dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rc=%d \n",
hd->ioc->name, retval)); ioc->name, retval));
goto fail_out; goto fail_out;
} }
@ -1761,7 +1764,7 @@ mptscsih_IssueTaskMgmt(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 id, int lun, i
/* /*
* Free task managment mf, and corresponding tm flags * Free task managment mf, and corresponding tm flags
*/ */
mpt_free_msg_frame(hd->ioc, mf); mpt_free_msg_frame(ioc, mf);
hd->tmPending = 0; hd->tmPending = 0;
hd->tmState = TM_STATE_NONE; hd->tmState = TM_STATE_NONE;
return FAILED; return FAILED;
@ -1868,7 +1871,7 @@ mptscsih_abort(struct scsi_cmnd * SCpnt)
* swap it here either. It is an opaque cookie to * swap it here either. It is an opaque cookie to
* the controller, so it does not matter. -DaveM * the controller, so it does not matter. -DaveM
*/ */
mf = MPT_INDEX_2_MFPTR(hd->ioc, scpnt_idx); mf = MPT_INDEX_2_MFPTR(ioc, scpnt_idx);
ctx2abort = mf->u.frame.hwhdr.msgctxu.MsgContext; ctx2abort = mf->u.frame.hwhdr.msgctxu.MsgContext;
hd->abortSCpnt = SCpnt; hd->abortSCpnt = SCpnt;
@ -2030,7 +2033,7 @@ mptscsih_host_reset(struct scsi_cmnd *SCpnt)
/* If our attempts to reset the host failed, then return a failed /* If our attempts to reset the host failed, then return a failed
* status. The host will be taken off line by the SCSI mid-layer. * status. The host will be taken off line by the SCSI mid-layer.
*/ */
if (mpt_HardResetHandler(hd->ioc, CAN_SLEEP) < 0) { if (mpt_HardResetHandler(ioc, CAN_SLEEP) < 0) {
retval = FAILED; retval = FAILED;
} else { } else {
/* Make sure TM pending is cleared and TM state is set to /* Make sure TM pending is cleared and TM state is set to
@ -2060,17 +2063,18 @@ mptscsih_tm_pending_wait(MPT_SCSI_HOST * hd)
unsigned long flags; unsigned long flags;
int loop_count = 4 * 10; /* Wait 10 seconds */ int loop_count = 4 * 10; /* Wait 10 seconds */
int status = FAILED; int status = FAILED;
MPT_ADAPTER *ioc = hd->ioc;
do { do {
spin_lock_irqsave(&hd->ioc->FreeQlock, flags); spin_lock_irqsave(&ioc->FreeQlock, flags);
if (hd->tmState == TM_STATE_NONE) { if (hd->tmState == TM_STATE_NONE) {
hd->tmState = TM_STATE_IN_PROGRESS; hd->tmState = TM_STATE_IN_PROGRESS;
hd->tmPending = 1; hd->tmPending = 1;
spin_unlock_irqrestore(&hd->ioc->FreeQlock, flags); spin_unlock_irqrestore(&ioc->FreeQlock, flags);
status = SUCCESS; status = SUCCESS;
break; break;
} }
spin_unlock_irqrestore(&hd->ioc->FreeQlock, flags); spin_unlock_irqrestore(&ioc->FreeQlock, flags);
msleep(250); msleep(250);
} while (--loop_count); } while (--loop_count);
@ -2091,15 +2095,16 @@ mptscsih_tm_wait_for_completion(MPT_SCSI_HOST * hd, ulong timeout )
unsigned long flags; unsigned long flags;
int loop_count = 4 * timeout; int loop_count = 4 * timeout;
int status = FAILED; int status = FAILED;
MPT_ADAPTER *ioc = hd->ioc;
do { do {
spin_lock_irqsave(&hd->ioc->FreeQlock, flags); spin_lock_irqsave(&ioc->FreeQlock, flags);
if(hd->tmPending == 0) { if(hd->tmPending == 0) {
status = SUCCESS; status = SUCCESS;
spin_unlock_irqrestore(&hd->ioc->FreeQlock, flags); spin_unlock_irqrestore(&ioc->FreeQlock, flags);
break; break;
} }
spin_unlock_irqrestore(&hd->ioc->FreeQlock, flags); spin_unlock_irqrestore(&ioc->FreeQlock, flags);
msleep(250); msleep(250);
} while (--loop_count); } while (--loop_count);
@ -2407,11 +2412,12 @@ mptscsih_change_queue_depth(struct scsi_device *sdev, int qdepth)
struct scsi_target *starget; struct scsi_target *starget;
int max_depth; int max_depth;
int tagged; int tagged;
MPT_ADAPTER *ioc = hd->ioc;
starget = scsi_target(sdev); starget = scsi_target(sdev);
vtarget = starget->hostdata; vtarget = starget->hostdata;
if (hd->ioc->bus_type == SPI) { if (ioc->bus_type == SPI) {
if (!(vtarget->tflags & MPT_TARGET_FLAGS_Q_YES)) if (!(vtarget->tflags & MPT_TARGET_FLAGS_Q_YES))
max_depth = 1; max_depth = 1;
else if (sdev->type == TYPE_DISK && else if (sdev->type == TYPE_DISK &&
@ -2447,18 +2453,19 @@ mptscsih_slave_configure(struct scsi_device *sdev)
VirtDevice *vdevice; VirtDevice *vdevice;
struct scsi_target *starget; struct scsi_target *starget;
MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)sh->hostdata; MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)sh->hostdata;
MPT_ADAPTER *ioc = hd->ioc;
starget = scsi_target(sdev); starget = scsi_target(sdev);
vtarget = starget->hostdata; vtarget = starget->hostdata;
vdevice = sdev->hostdata; vdevice = sdev->hostdata;
dsprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT dsprintk(ioc, printk(MYIOC_s_DEBUG_FMT
"device @ %p, channel=%d, id=%d, lun=%d\n", "device @ %p, channel=%d, id=%d, lun=%d\n",
hd->ioc->name, sdev, sdev->channel, sdev->id, sdev->lun)); ioc->name, sdev, sdev->channel, sdev->id, sdev->lun));
if (hd->ioc->bus_type == SPI) if (ioc->bus_type == SPI)
dsprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT dsprintk(ioc, printk(MYIOC_s_DEBUG_FMT
"sdtr %d wdtr %d ppr %d inq length=%d\n", "sdtr %d wdtr %d ppr %d inq length=%d\n",
hd->ioc->name, sdev->sdtr, sdev->wdtr, ioc->name, sdev->sdtr, sdev->wdtr,
sdev->ppr, sdev->inquiry_len)); sdev->ppr, sdev->inquiry_len));
if (sdev->id > sh->max_id) { if (sdev->id > sh->max_id) {
@ -2470,21 +2477,21 @@ mptscsih_slave_configure(struct scsi_device *sdev)
vdevice->configured_lun = 1; vdevice->configured_lun = 1;
mptscsih_change_queue_depth(sdev, MPT_SCSI_CMD_PER_DEV_HIGH); mptscsih_change_queue_depth(sdev, MPT_SCSI_CMD_PER_DEV_HIGH);
dsprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT dsprintk(ioc, printk(MYIOC_s_DEBUG_FMT
"Queue depth=%d, tflags=%x\n", "Queue depth=%d, tflags=%x\n",
hd->ioc->name, sdev->queue_depth, vtarget->tflags)); ioc->name, sdev->queue_depth, vtarget->tflags));
if (hd->ioc->bus_type == SPI) if (ioc->bus_type == SPI)
dsprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT dsprintk(ioc, printk(MYIOC_s_DEBUG_FMT
"negoFlags=%x, maxOffset=%x, SyncFactor=%x\n", "negoFlags=%x, maxOffset=%x, SyncFactor=%x\n",
hd->ioc->name, vtarget->negoFlags, vtarget->maxOffset, ioc->name, vtarget->negoFlags, vtarget->maxOffset,
vtarget->minSyncFactor)); vtarget->minSyncFactor));
slave_configure_exit: slave_configure_exit:
dsprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT dsprintk(ioc, printk(MYIOC_s_DEBUG_FMT
"tagged %d, simple %d, ordered %d\n", "tagged %d, simple %d, ordered %d\n",
hd->ioc->name,sdev->tagged_supported, sdev->simple_tags, ioc->name,sdev->tagged_supported, sdev->simple_tags,
sdev->ordered_tags)); sdev->ordered_tags));
return 0; return 0;
@ -2506,6 +2513,7 @@ mptscsih_copy_sense_data(struct scsi_cmnd *sc, MPT_SCSI_HOST *hd, MPT_FRAME_HDR
VirtDevice *vdevice; VirtDevice *vdevice;
SCSIIORequest_t *pReq; SCSIIORequest_t *pReq;
u32 sense_count = le32_to_cpu(pScsiReply->SenseCount); u32 sense_count = le32_to_cpu(pScsiReply->SenseCount);
MPT_ADAPTER *ioc = hd->ioc;
/* Get target structure /* Get target structure
*/ */
@ -2518,15 +2526,14 @@ mptscsih_copy_sense_data(struct scsi_cmnd *sc, MPT_SCSI_HOST *hd, MPT_FRAME_HDR
/* Copy the sense received into the scsi command block. */ /* Copy the sense received into the scsi command block. */
req_index = le16_to_cpu(mf->u.frame.hwhdr.msgctxu.fld.req_idx); req_index = le16_to_cpu(mf->u.frame.hwhdr.msgctxu.fld.req_idx);
sense_data = ((u8 *)hd->ioc->sense_buf_pool + (req_index * MPT_SENSE_BUFFER_ALLOC)); sense_data = ((u8 *)ioc->sense_buf_pool + (req_index * MPT_SENSE_BUFFER_ALLOC));
memcpy(sc->sense_buffer, sense_data, SNS_LEN(sc)); memcpy(sc->sense_buffer, sense_data, SNS_LEN(sc));
/* Log SMART data (asc = 0x5D, non-IM case only) if required. /* Log SMART data (asc = 0x5D, non-IM case only) if required.
*/ */
if ((hd->ioc->events) && (hd->ioc->eventTypes & (1 << MPI_EVENT_SCSI_DEVICE_STATUS_CHANGE))) { if ((ioc->events) && (ioc->eventTypes & (1 << MPI_EVENT_SCSI_DEVICE_STATUS_CHANGE))) {
if ((sense_data[12] == 0x5D) && (vdevice->vtarget->raidVolume == 0)) { if ((sense_data[12] == 0x5D) && (vdevice->vtarget->raidVolume == 0)) {
int idx; int idx;
MPT_ADAPTER *ioc = hd->ioc;
idx = ioc->eventContext % MPTCTL_EVENT_LOG_SIZE; idx = ioc->eventContext % MPTCTL_EVENT_LOG_SIZE;
ioc->events[idx].event = MPI_EVENT_SCSI_DEVICE_STATUS_CHANGE; 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
ioc->events[idx].data[1] = (sense_data[13] << 8) | sense_data[12]; ioc->events[idx].data[1] = (sense_data[13] << 8) | sense_data[12];
ioc->eventContext++; ioc->eventContext++;
if (hd->ioc->pcidev->vendor == if (ioc->pcidev->vendor ==
PCI_VENDOR_ID_IBM) { PCI_VENDOR_ID_IBM) {
mptscsih_issue_sep_command(hd->ioc, mptscsih_issue_sep_command(ioc,
vdevice->vtarget, MPI_SEP_REQ_SLOTSTATUS_PREDICTED_FAULT); vdevice->vtarget, MPI_SEP_REQ_SLOTSTATUS_PREDICTED_FAULT);
vdevice->vtarget->tflags |= vdevice->vtarget->tflags |=
MPT_TARGET_FLAGS_LED_ON; MPT_TARGET_FLAGS_LED_ON;
@ -2549,8 +2556,8 @@ mptscsih_copy_sense_data(struct scsi_cmnd *sc, MPT_SCSI_HOST *hd, MPT_FRAME_HDR
} }
} }
} else { } else {
dprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT "Hmmm... SenseData len=0! (?)\n", dprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Hmmm... SenseData len=0! (?)\n",
hd->ioc->name)); ioc->name));
} }
} }
@ -2635,7 +2642,7 @@ mptscsih_ioc_reset(MPT_ADAPTER *ioc, int reset_phase)
/* ScsiLookup initialization /* ScsiLookup initialization
*/ */
for (ii=0; ii < hd->ioc->req_depth; ii++) for (ii=0; ii < ioc->req_depth; ii++)
hd->ScsiLookup[ii] = NULL; hd->ScsiLookup[ii] = NULL;
/* 2. Chain Buffer initialization /* 2. Chain Buffer initialization
@ -2780,12 +2787,12 @@ mptscsih_scandv_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
if (mf != hd->cmdPtr) { if (mf != hd->cmdPtr) {
printk(MYIOC_s_WARN_FMT "ScanDvComplete (mf=%p, cmdPtr=%p, idx=%d)\n", printk(MYIOC_s_WARN_FMT "ScanDvComplete (mf=%p, cmdPtr=%p, idx=%d)\n",
hd->ioc->name, (void *)mf, (void *) hd->cmdPtr, req_idx); ioc->name, (void *)mf, (void *) hd->cmdPtr, req_idx);
} }
hd->cmdPtr = NULL; hd->cmdPtr = NULL;
ddvprintk(ioc, printk(MYIOC_s_DEBUG_FMT "ScanDvComplete (mf=%p,mr=%p,idx=%d)\n", ddvprintk(ioc, printk(MYIOC_s_DEBUG_FMT "ScanDvComplete (mf=%p,mr=%p,idx=%d)\n",
hd->ioc->name, mf, mr, req_idx)); ioc->name, mf, mr, req_idx));
hd->pLocal = &hd->localReply; hd->pLocal = &hd->localReply;
hd->pLocal->scsiStatus = 0; hd->pLocal->scsiStatus = 0;
@ -2849,7 +2856,7 @@ mptscsih_scandv_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
*/ */
completionCode = MPT_SCANDV_SENSE; completionCode = MPT_SCANDV_SENSE;
hd->pLocal->scsiStatus = scsi_status; hd->pLocal->scsiStatus = scsi_status;
sense_data = ((u8 *)hd->ioc->sense_buf_pool + sense_data = ((u8 *)ioc->sense_buf_pool +
(req_idx * MPT_SENSE_BUFFER_ALLOC)); (req_idx * MPT_SENSE_BUFFER_ALLOC));
sz = min_t(int, pReq->SenseBufferLength, sz = min_t(int, pReq->SenseBufferLength,
@ -2916,8 +2923,9 @@ void
mptscsih_timer_expired(unsigned long data) mptscsih_timer_expired(unsigned long data)
{ {
MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *) data; MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *) data;
MPT_ADAPTER *ioc = hd->ioc;
ddvprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT "Timer Expired! Cmd %p\n", hd->ioc->name, hd->cmdPtr)); ddvprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Timer Expired! Cmd %p\n", ioc->name, hd->cmdPtr));
if (hd->cmdPtr) { if (hd->cmdPtr) {
MPIHeader_t *cmd = (MPIHeader_t *)hd->cmdPtr; MPIHeader_t *cmd = (MPIHeader_t *)hd->cmdPtr;
@ -2931,13 +2939,13 @@ mptscsih_timer_expired(unsigned long data)
*/ */
} else { } else {
/* Perform a FW reload */ /* Perform a FW reload */
if (mpt_HardResetHandler(hd->ioc, NO_SLEEP) < 0) { if (mpt_HardResetHandler(ioc, NO_SLEEP) < 0) {
printk(MYIOC_s_WARN_FMT "Firmware Reload FAILED!\n", hd->ioc->name); printk(MYIOC_s_WARN_FMT "Firmware Reload FAILED!\n", ioc->name);
} }
} }
} else { } else {
/* This should NEVER happen */ /* This should NEVER happen */
printk(MYIOC_s_WARN_FMT "Null cmdPtr!!!!\n", hd->ioc->name); printk(MYIOC_s_WARN_FMT "Null cmdPtr!!!!\n", ioc->name);
} }
/* No more processing. /* No more processing.
@ -2945,7 +2953,7 @@ mptscsih_timer_expired(unsigned long data)
* The FW will reply to all outstanding commands, callback will finish cleanup. * The FW will reply to all outstanding commands, callback will finish cleanup.
* Hard reset clean-up will free all resources. * Hard reset clean-up will free all resources.
*/ */
ddvprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT "Timer Expired Complete!\n", hd->ioc->name)); ddvprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Timer Expired Complete!\n", ioc->name));
return; return;
} }
@ -2983,11 +2991,12 @@ mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTERNAL_CMD *io)
char cmdLen; char cmdLen;
char CDB[]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; char CDB[]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
char cmd = io->cmd; char cmd = io->cmd;
MPT_ADAPTER *ioc = hd->ioc;
in_isr = in_interrupt(); in_isr = in_interrupt();
if (in_isr) { if (in_isr) {
dprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT "Internal SCSI IO request not allowed in ISR context!\n", dprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Internal SCSI IO request not allowed in ISR context!\n",
hd->ioc->name)); ioc->name));
return -EPERM; return -EPERM;
} }
@ -3088,9 +3097,9 @@ mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTERNAL_CMD *io)
/* Get and Populate a free Frame /* Get and Populate a free Frame
*/ */
if ((mf = mpt_get_msg_frame(hd->ioc->InternalCtx, hd->ioc)) == NULL) { if ((mf = mpt_get_msg_frame(ioc->InternalCtx, ioc)) == NULL) {
dfailprintk(hd->ioc, printk(MYIOC_s_WARN_FMT "No msg frames!\n", dfailprintk(ioc, printk(MYIOC_s_WARN_FMT "No msg frames!\n",
hd->ioc->name)); ioc->name));
return -EBUSY; return -EBUSY;
} }
@ -3129,19 +3138,19 @@ mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTERNAL_CMD *io)
if (cmd == REQUEST_SENSE) { if (cmd == REQUEST_SENSE) {
pScsiReq->Control = cpu_to_le32(dir | MPI_SCSIIO_CONTROL_UNTAGGED); pScsiReq->Control = cpu_to_le32(dir | MPI_SCSIIO_CONTROL_UNTAGGED);
ddvprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT "Untagged! 0x%2x\n", ddvprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Untagged! 0x%2x\n",
hd->ioc->name, cmd)); ioc->name, cmd));
} }
for (ii=0; ii < 16; ii++) for (ii=0; ii < 16; ii++)
pScsiReq->CDB[ii] = CDB[ii]; pScsiReq->CDB[ii] = CDB[ii];
pScsiReq->DataLength = cpu_to_le32(io->size); pScsiReq->DataLength = cpu_to_le32(io->size);
pScsiReq->SenseBufferLowAddr = cpu_to_le32(hd->ioc->sense_buf_low_dma pScsiReq->SenseBufferLowAddr = cpu_to_le32(ioc->sense_buf_low_dma
+ (my_idx * MPT_SENSE_BUFFER_ALLOC)); + (my_idx * MPT_SENSE_BUFFER_ALLOC));
ddvprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT "Sending Command 0x%x for (%d:%d:%d)\n", ddvprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Sending Command 0x%x for (%d:%d:%d)\n",
hd->ioc->name, cmd, io->channel, io->id, io->lun)); ioc->name, cmd, io->channel, io->id, io->lun));
if (dir == MPI_SCSIIO_CONTROL_READ) { if (dir == MPI_SCSIIO_CONTROL_READ) {
mpt_add_sge((char *) &pScsiReq->SGL, mpt_add_sge((char *) &pScsiReq->SGL,
@ -3176,7 +3185,7 @@ mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTERNAL_CMD *io)
hd->cmdPtr = mf; hd->cmdPtr = mf;
add_timer(&hd->timer); add_timer(&hd->timer);
mpt_put_msg_frame(hd->ioc->InternalCtx, hd->ioc, mf); mpt_put_msg_frame(ioc->InternalCtx, ioc, mf);
wait_event(hd->scandv_waitq, hd->scandv_wait_done); wait_event(hd->scandv_waitq, hd->scandv_wait_done);
if (hd->pLocal) { if (hd->pLocal) {
@ -3192,8 +3201,8 @@ mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTERNAL_CMD *io)
} else { } else {
rc = -EFAULT; rc = -EFAULT;
/* This should never happen. */ /* This should never happen. */
ddvprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT "_do_cmd: Null pLocal!!!\n", ddvprintk(ioc, printk(MYIOC_s_DEBUG_FMT "_do_cmd: Null pLocal!!!\n",
hd->ioc->name)); ioc->name));
} }
return rc; return rc;

View file

@ -107,7 +107,8 @@ static void
mptspi_setTargetNegoParms(MPT_SCSI_HOST *hd, VirtTarget *target, mptspi_setTargetNegoParms(MPT_SCSI_HOST *hd, VirtTarget *target,
struct scsi_device *sdev) struct scsi_device *sdev)
{ {
SpiCfgData *pspi_data = &hd->ioc->spi_data; MPT_ADAPTER *ioc = hd->ioc;
SpiCfgData *pspi_data = &ioc->spi_data;
int id = (int) target->id; int id = (int) target->id;
int nvram; int nvram;
u8 width = MPT_NARROW; u8 width = MPT_NARROW;
@ -138,9 +139,9 @@ mptspi_setTargetNegoParms(MPT_SCSI_HOST *hd, VirtTarget *target,
else { else {
factor = MPT_ULTRA320; factor = MPT_ULTRA320;
if (scsi_device_qas(sdev)) { if (scsi_device_qas(sdev)) {
ddvprintk(hd->ioc, ddvprintk(ioc,
printk(MYIOC_s_DEBUG_FMT "Enabling QAS due to " printk(MYIOC_s_DEBUG_FMT "Enabling QAS due to "
"byte56=%02x on id=%d!\n", hd->ioc->name, "byte56=%02x on id=%d!\n", ioc->name,
scsi_device_qas(sdev), id)); scsi_device_qas(sdev), id));
noQas = 0; noQas = 0;
} }
@ -228,8 +229,8 @@ mptspi_setTargetNegoParms(MPT_SCSI_HOST *hd, VirtTarget *target,
/* Disable QAS in a mixed configuration case /* Disable QAS in a mixed configuration case
*/ */
ddvprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT ddvprintk(ioc, printk(MYIOC_s_DEBUG_FMT
"Disabling QAS due to noQas=%02x on id=%d!\n", hd->ioc->name, noQas, id)); "Disabling QAS due to noQas=%02x on id=%d!\n", ioc->name, noQas, id));
} }
} }
@ -375,14 +376,15 @@ static int
mptspi_is_raid(struct _MPT_SCSI_HOST *hd, u32 id) mptspi_is_raid(struct _MPT_SCSI_HOST *hd, u32 id)
{ {
int i, rc = 0; int i, rc = 0;
MPT_ADAPTER *ioc = hd->ioc;
if (!hd->ioc->raid_data.pIocPg2) if (!ioc->raid_data.pIocPg2)
goto out; goto out;
if (!hd->ioc->raid_data.pIocPg2->NumActiveVolumes) if (!ioc->raid_data.pIocPg2->NumActiveVolumes)
goto out; goto out;
for (i=0; i < hd->ioc->raid_data.pIocPg2->NumActiveVolumes; i++) { for (i=0; i < ioc->raid_data.pIocPg2->NumActiveVolumes; i++) {
if (hd->ioc->raid_data.pIocPg2->RaidVolume[i].VolumeID == id) { if (ioc->raid_data.pIocPg2->RaidVolume[i].VolumeID == id) {
rc = 1; rc = 1;
goto out; goto out;
} }
@ -397,15 +399,17 @@ static int mptspi_target_alloc(struct scsi_target *starget)
struct Scsi_Host *shost = dev_to_shost(&starget->dev); struct Scsi_Host *shost = dev_to_shost(&starget->dev);
struct _MPT_SCSI_HOST *hd = (struct _MPT_SCSI_HOST *)shost->hostdata; struct _MPT_SCSI_HOST *hd = (struct _MPT_SCSI_HOST *)shost->hostdata;
VirtTarget *vtarget; VirtTarget *vtarget;
MPT_ADAPTER *ioc;
if (hd == NULL) if (hd == NULL)
return -ENODEV; return -ENODEV;
ioc = hd->ioc;
vtarget = kzalloc(sizeof(VirtTarget), GFP_KERNEL); vtarget = kzalloc(sizeof(VirtTarget), GFP_KERNEL);
if (!vtarget) if (!vtarget)
return -ENOMEM; return -ENOMEM;
vtarget->ioc_id = hd->ioc->id; vtarget->ioc_id = ioc->id;
vtarget->tflags = MPT_TARGET_FLAGS_Q_YES; vtarget->tflags = MPT_TARGET_FLAGS_Q_YES;
vtarget->id = (u8)starget->id; vtarget->id = (u8)starget->id;
vtarget->channel = (u8)starget->channel; vtarget->channel = (u8)starget->channel;
@ -413,34 +417,34 @@ static int mptspi_target_alloc(struct scsi_target *starget)
starget->hostdata = vtarget; starget->hostdata = vtarget;
if (starget->channel == 1) { if (starget->channel == 1) {
if (mptscsih_is_phys_disk(hd->ioc, 0, starget->id) == 0) if (mptscsih_is_phys_disk(ioc, 0, starget->id) == 0)
return 0; return 0;
vtarget->tflags |= MPT_TARGET_FLAGS_RAID_COMPONENT; vtarget->tflags |= MPT_TARGET_FLAGS_RAID_COMPONENT;
/* The real channel for this device is zero */ /* The real channel for this device is zero */
vtarget->channel = 0; vtarget->channel = 0;
/* The actual physdisknum (for RAID passthrough) */ /* The actual physdisknum (for RAID passthrough) */
vtarget->id = mptscsih_raid_id_to_num(hd->ioc, 0, vtarget->id = mptscsih_raid_id_to_num(ioc, 0,
starget->id); starget->id);
} }
if (starget->channel == 0 && if (starget->channel == 0 &&
mptspi_is_raid(hd, starget->id)) { mptspi_is_raid(hd, starget->id)) {
vtarget->raidVolume = 1; vtarget->raidVolume = 1;
ddvprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT ddvprintk(ioc, printk(MYIOC_s_DEBUG_FMT
"RAID Volume @ channel=%d id=%d\n", hd->ioc->name, starget->channel, "RAID Volume @ channel=%d id=%d\n", ioc->name, starget->channel,
starget->id)); starget->id));
} }
if (hd->ioc->spi_data.nvram && if (ioc->spi_data.nvram &&
hd->ioc->spi_data.nvram[starget->id] != MPT_HOST_NVRAM_INVALID) { ioc->spi_data.nvram[starget->id] != MPT_HOST_NVRAM_INVALID) {
u32 nvram = hd->ioc->spi_data.nvram[starget->id]; u32 nvram = ioc->spi_data.nvram[starget->id];
spi_min_period(starget) = (nvram & MPT_NVRAM_SYNC_MASK) >> MPT_NVRAM_SYNC_SHIFT; spi_min_period(starget) = (nvram & MPT_NVRAM_SYNC_MASK) >> MPT_NVRAM_SYNC_SHIFT;
spi_max_width(starget) = nvram & MPT_NVRAM_WIDE_DISABLE ? 0 : 1; spi_max_width(starget) = nvram & MPT_NVRAM_WIDE_DISABLE ? 0 : 1;
} else { } else {
spi_min_period(starget) = hd->ioc->spi_data.minSyncFactor; spi_min_period(starget) = ioc->spi_data.minSyncFactor;
spi_max_width(starget) = hd->ioc->spi_data.maxBusWidth; spi_max_width(starget) = ioc->spi_data.maxBusWidth;
} }
spi_max_offset(starget) = hd->ioc->spi_data.maxSyncOffset; spi_max_offset(starget) = ioc->spi_data.maxSyncOffset;
spi_offset(starget) = 0; spi_offset(starget) = 0;
mptspi_write_width(starget, 0); mptspi_write_width(starget, 0);
@ -614,12 +618,13 @@ mptscsih_quiesce_raid(MPT_SCSI_HOST *hd, int quiesce, u8 channel, u8 id)
{ {
MpiRaidActionRequest_t *pReq; MpiRaidActionRequest_t *pReq;
MPT_FRAME_HDR *mf; MPT_FRAME_HDR *mf;
MPT_ADAPTER *ioc = hd->ioc;
/* Get and Populate a free Frame /* Get and Populate a free Frame
*/ */
if ((mf = mpt_get_msg_frame(hd->ioc->InternalCtx, hd->ioc)) == NULL) { if ((mf = mpt_get_msg_frame(ioc->InternalCtx, ioc)) == NULL) {
ddvprintk(hd->ioc, printk(MYIOC_s_WARN_FMT "_do_raid: no msg frames!\n", ddvprintk(ioc, printk(MYIOC_s_WARN_FMT "_do_raid: no msg frames!\n",
hd->ioc->name)); ioc->name));
return -EAGAIN; return -EAGAIN;
} }
pReq = (MpiRaidActionRequest_t *)mf; pReq = (MpiRaidActionRequest_t *)mf;
@ -640,8 +645,8 @@ mptscsih_quiesce_raid(MPT_SCSI_HOST *hd, int quiesce, u8 channel, u8 id)
mpt_add_sge((char *)&pReq->ActionDataSGE, mpt_add_sge((char *)&pReq->ActionDataSGE,
MPT_SGE_FLAGS_SSIMPLE_READ | 0, (dma_addr_t) -1); MPT_SGE_FLAGS_SSIMPLE_READ | 0, (dma_addr_t) -1);
ddvprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT "RAID Volume action=%x channel=%d id=%d\n", ddvprintk(ioc, printk(MYIOC_s_DEBUG_FMT "RAID Volume action=%x channel=%d id=%d\n",
hd->ioc->name, pReq->Action, channel, id)); ioc->name, pReq->Action, channel, id));
hd->pLocal = NULL; hd->pLocal = NULL;
hd->timer.expires = jiffies + HZ*10; /* 10 second timeout */ hd->timer.expires = jiffies + HZ*10; /* 10 second timeout */
@ -653,7 +658,7 @@ mptscsih_quiesce_raid(MPT_SCSI_HOST *hd, int quiesce, u8 channel, u8 id)
hd->cmdPtr = mf; hd->cmdPtr = mf;
add_timer(&hd->timer); add_timer(&hd->timer);
mpt_put_msg_frame(hd->ioc->InternalCtx, hd->ioc, mf); mpt_put_msg_frame(ioc->InternalCtx, ioc, mf);
wait_event(hd->scandv_waitq, hd->scandv_wait_done); wait_event(hd->scandv_waitq, hd->scandv_wait_done);
if ((hd->pLocal == NULL) || (hd->pLocal->completion != 0)) if ((hd->pLocal == NULL) || (hd->pLocal->completion != 0))
@ -666,6 +671,7 @@ static void mptspi_dv_device(struct _MPT_SCSI_HOST *hd,
struct scsi_device *sdev) struct scsi_device *sdev)
{ {
VirtTarget *vtarget = scsi_target(sdev)->hostdata; VirtTarget *vtarget = scsi_target(sdev)->hostdata;
MPT_ADAPTER *ioc = hd->ioc;
/* no DV on RAID devices */ /* no DV on RAID devices */
if (sdev->channel == 0 && if (sdev->channel == 0 &&
@ -676,7 +682,7 @@ static void mptspi_dv_device(struct _MPT_SCSI_HOST *hd,
if (sdev->channel == 1 && if (sdev->channel == 1 &&
mptscsih_quiesce_raid(hd, 1, vtarget->channel, vtarget->id) < 0) { mptscsih_quiesce_raid(hd, 1, vtarget->channel, vtarget->id) < 0) {
starget_printk(MYIOC_s_ERR_FMT, scsi_target(sdev), starget_printk(MYIOC_s_ERR_FMT, scsi_target(sdev),
"Integrated RAID quiesce failed\n", hd->ioc->name); "Integrated RAID quiesce failed\n", ioc->name);
return; return;
} }
@ -687,7 +693,7 @@ static void mptspi_dv_device(struct _MPT_SCSI_HOST *hd,
if (sdev->channel == 1 && if (sdev->channel == 1 &&
mptscsih_quiesce_raid(hd, 0, vtarget->channel, vtarget->id) < 0) mptscsih_quiesce_raid(hd, 0, vtarget->channel, vtarget->id) < 0)
starget_printk(MYIOC_s_ERR_FMT, scsi_target(sdev), starget_printk(MYIOC_s_ERR_FMT, scsi_target(sdev),
"Integrated RAID resume failed\n", hd->ioc->name); "Integrated RAID resume failed\n", ioc->name);
mptspi_read_parameters(sdev->sdev_target); mptspi_read_parameters(sdev->sdev_target);
spi_display_xfer_agreement(sdev->sdev_target); spi_display_xfer_agreement(sdev->sdev_target);
@ -700,15 +706,16 @@ static int mptspi_slave_alloc(struct scsi_device *sdev)
VirtTarget *vtarget; VirtTarget *vtarget;
VirtDevice *vdevice; VirtDevice *vdevice;
struct scsi_target *starget; struct scsi_target *starget;
MPT_ADAPTER *ioc = hd->ioc;
if (sdev->channel == 1 && if (sdev->channel == 1 &&
mptscsih_is_phys_disk(hd->ioc, 0, sdev->id) == 0) mptscsih_is_phys_disk(ioc, 0, sdev->id) == 0)
return -ENXIO; return -ENXIO;
vdevice = kzalloc(sizeof(VirtDevice), GFP_KERNEL); vdevice = kzalloc(sizeof(VirtDevice), GFP_KERNEL);
if (!vdevice) { if (!vdevice) {
printk(MYIOC_s_ERR_FMT "slave_alloc kmalloc(%zd) FAILED!\n", printk(MYIOC_s_ERR_FMT "slave_alloc kmalloc(%zd) FAILED!\n",
hd->ioc->name, sizeof(VirtDevice)); ioc->name, sizeof(VirtDevice));
return -ENOMEM; return -ENOMEM;
} }
@ -759,6 +766,7 @@ mptspi_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
{ {
struct _MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *) SCpnt->device->host->hostdata; struct _MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *) SCpnt->device->host->hostdata;
VirtDevice *vdevice = SCpnt->device->hostdata; VirtDevice *vdevice = SCpnt->device->hostdata;
MPT_ADAPTER *ioc = hd->ioc;
if (!vdevice || !vdevice->vtarget) { if (!vdevice || !vdevice->vtarget) {
SCpnt->result = DID_NO_CONNECT << 16; SCpnt->result = DID_NO_CONNECT << 16;
@ -767,14 +775,14 @@ mptspi_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
} }
if (SCpnt->device->channel == 1 && if (SCpnt->device->channel == 1 &&
mptscsih_is_phys_disk(hd->ioc, 0, SCpnt->device->id) == 0) { mptscsih_is_phys_disk(ioc, 0, SCpnt->device->id) == 0) {
SCpnt->result = DID_NO_CONNECT << 16; SCpnt->result = DID_NO_CONNECT << 16;
done(SCpnt); done(SCpnt);
return 0; return 0;
} }
if (spi_dv_pending(scsi_target(SCpnt->device))) if (spi_dv_pending(scsi_target(SCpnt->device)))
ddvprintk(hd->ioc, scsi_print_command(SCpnt)); ddvprintk(ioc, scsi_print_command(SCpnt));
return mptscsih_qcmd(SCpnt,done); return mptscsih_qcmd(SCpnt,done);
} }
@ -1071,15 +1079,16 @@ static void mpt_work_wrapper(struct work_struct *work)
struct work_queue_wrapper *wqw = struct work_queue_wrapper *wqw =
container_of(work, struct work_queue_wrapper, work); container_of(work, struct work_queue_wrapper, work);
struct _MPT_SCSI_HOST *hd = wqw->hd; struct _MPT_SCSI_HOST *hd = wqw->hd;
struct Scsi_Host *shost = hd->ioc->sh; MPT_ADAPTER *ioc = hd->ioc;
struct Scsi_Host *shost = ioc->sh;
struct scsi_device *sdev; struct scsi_device *sdev;
int disk = wqw->disk; int disk = wqw->disk;
struct _CONFIG_PAGE_IOC_3 *pg3; struct _CONFIG_PAGE_IOC_3 *pg3;
kfree(wqw); kfree(wqw);
mpt_findImVolumes(hd->ioc); mpt_findImVolumes(ioc);
pg3 = hd->ioc->raid_data.pIocPg3; pg3 = ioc->raid_data.pIocPg3;
if (!pg3) if (!pg3)
return; return;
@ -1097,23 +1106,24 @@ static void mpt_work_wrapper(struct work_struct *work)
continue; continue;
starget_printk(MYIOC_s_INFO_FMT, vtarget->starget, starget_printk(MYIOC_s_INFO_FMT, vtarget->starget,
"Integrated RAID requests DV of new device\n", hd->ioc->name); "Integrated RAID requests DV of new device\n", ioc->name);
mptspi_dv_device(hd, sdev); mptspi_dv_device(hd, sdev);
} }
shost_printk(MYIOC_s_INFO_FMT, shost, shost_printk(MYIOC_s_INFO_FMT, shost,
"Integrated RAID detects new device %d\n", hd->ioc->name, disk); "Integrated RAID detects new device %d\n", ioc->name, disk);
scsi_scan_target(&hd->ioc->sh->shost_gendev, 1, disk, 0, 1); scsi_scan_target(&ioc->sh->shost_gendev, 1, disk, 0, 1);
} }
static void mpt_dv_raid(struct _MPT_SCSI_HOST *hd, int disk) static void mpt_dv_raid(struct _MPT_SCSI_HOST *hd, int disk)
{ {
struct work_queue_wrapper *wqw = kmalloc(sizeof(*wqw), GFP_ATOMIC); struct work_queue_wrapper *wqw = kmalloc(sizeof(*wqw), GFP_ATOMIC);
MPT_ADAPTER *ioc = hd->ioc;
if (!wqw) { if (!wqw) {
shost_printk(MYIOC_s_ERR_FMT, hd->ioc->sh, shost_printk(MYIOC_s_ERR_FMT, ioc->sh,
"Failed to act on RAID event for physical disk %d\n", "Failed to act on RAID event for physical disk %d\n",
hd->ioc->name, disk); ioc->name, disk);
return; return;
} }
INIT_WORK(&wqw->work, mpt_work_wrapper); INIT_WORK(&wqw->work, mpt_work_wrapper);
@ -1216,11 +1226,12 @@ mptspi_dv_renegotiate_work(struct work_struct *work)
struct scsi_target *starget; struct scsi_target *starget;
struct _CONFIG_PAGE_SCSI_DEVICE_1 pg1; struct _CONFIG_PAGE_SCSI_DEVICE_1 pg1;
u32 nego; u32 nego;
MPT_ADAPTER *ioc = hd->ioc;
kfree(wqw); kfree(wqw);
if (hd->spi_pending) { if (hd->spi_pending) {
shost_for_each_device(sdev, hd->ioc->sh) { shost_for_each_device(sdev, ioc->sh) {
if (hd->spi_pending & (1 << sdev->id)) if (hd->spi_pending & (1 << sdev->id))
continue; continue;
starget = scsi_target(sdev); starget = scsi_target(sdev);
@ -1231,7 +1242,7 @@ mptspi_dv_renegotiate_work(struct work_struct *work)
mptspi_write_spi_device_pg1(starget, &pg1); mptspi_write_spi_device_pg1(starget, &pg1);
} }
} else { } else {
shost_for_each_device(sdev, hd->ioc->sh) shost_for_each_device(sdev, ioc->sh)
mptspi_dv_device(hd, sdev); mptspi_dv_device(hd, sdev);
} }
} }
@ -1483,7 +1494,7 @@ mptspi_probe(struct pci_dev *pdev, const struct pci_device_id *id)
/* Some versions of the firmware don't support page 0; without /* Some versions of the firmware don't support page 0; without
* that we can't get the parameters */ * that we can't get the parameters */
if (hd->ioc->spi_data.sdp0length != 0) if (ioc->spi_data.sdp0length != 0)
sh->transportt = mptspi_transport_template; sh->transportt = mptspi_transport_template;
error = scsi_add_host (sh, &ioc->pcidev->dev); error = scsi_add_host (sh, &ioc->pcidev->dev);