aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/message/fusion/mptspi.c
diff options
context:
space:
mode:
authorEric Moore <eric.moore@lsi.com>2007-09-14 20:49:03 -0400
committerJames Bottomley <jejb@mulgrave.localdomain>2007-10-12 14:48:46 -0400
commite80b002bfd38263117da93feb4f67f5cf7d9221b (patch)
tree169d482e07e69dbe0fb6407f342e625099916b5c /drivers/message/fusion/mptspi.c
parenta69de507aae293e32d22e873f34f25f49b2db3b2 (diff)
[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>
Diffstat (limited to 'drivers/message/fusion/mptspi.c')
-rw-r--r--drivers/message/fusion/mptspi.c97
1 files changed, 54 insertions, 43 deletions
diff --git a/drivers/message/fusion/mptspi.c b/drivers/message/fusion/mptspi.c
index 4248bf331e13..02062f198be3 100644
--- a/drivers/message/fusion/mptspi.c
+++ b/drivers/message/fusion/mptspi.c
@@ -107,7 +107,8 @@ static void
107mptspi_setTargetNegoParms(MPT_SCSI_HOST *hd, VirtTarget *target, 107mptspi_setTargetNegoParms(MPT_SCSI_HOST *hd, VirtTarget *target,
108 struct scsi_device *sdev) 108 struct scsi_device *sdev)
109{ 109{
110 SpiCfgData *pspi_data = &hd->ioc->spi_data; 110 MPT_ADAPTER *ioc = hd->ioc;
111 SpiCfgData *pspi_data = &ioc->spi_data;
111 int id = (int) target->id; 112 int id = (int) target->id;
112 int nvram; 113 int nvram;
113 u8 width = MPT_NARROW; 114 u8 width = MPT_NARROW;
@@ -138,9 +139,9 @@ mptspi_setTargetNegoParms(MPT_SCSI_HOST *hd, VirtTarget *target,
138 else { 139 else {
139 factor = MPT_ULTRA320; 140 factor = MPT_ULTRA320;
140 if (scsi_device_qas(sdev)) { 141 if (scsi_device_qas(sdev)) {
141 ddvprintk(hd->ioc, 142 ddvprintk(ioc,
142 printk(MYIOC_s_DEBUG_FMT "Enabling QAS due to " 143 printk(MYIOC_s_DEBUG_FMT "Enabling QAS due to "
143 "byte56=%02x on id=%d!\n", hd->ioc->name, 144 "byte56=%02x on id=%d!\n", ioc->name,
144 scsi_device_qas(sdev), id)); 145 scsi_device_qas(sdev), id));
145 noQas = 0; 146 noQas = 0;
146 } 147 }
@@ -228,8 +229,8 @@ mptspi_setTargetNegoParms(MPT_SCSI_HOST *hd, VirtTarget *target,
228 /* Disable QAS in a mixed configuration case 229 /* Disable QAS in a mixed configuration case
229 */ 230 */
230 231
231 ddvprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT 232 ddvprintk(ioc, printk(MYIOC_s_DEBUG_FMT
232 "Disabling QAS due to noQas=%02x on id=%d!\n", hd->ioc->name, noQas, id)); 233 "Disabling QAS due to noQas=%02x on id=%d!\n", ioc->name, noQas, id));
233 } 234 }
234} 235}
235 236
@@ -375,14 +376,15 @@ static int
375mptspi_is_raid(struct _MPT_SCSI_HOST *hd, u32 id) 376mptspi_is_raid(struct _MPT_SCSI_HOST *hd, u32 id)
376{ 377{
377 int i, rc = 0; 378 int i, rc = 0;
379 MPT_ADAPTER *ioc = hd->ioc;
378 380
379 if (!hd->ioc->raid_data.pIocPg2) 381 if (!ioc->raid_data.pIocPg2)
380 goto out; 382 goto out;
381 383
382 if (!hd->ioc->raid_data.pIocPg2->NumActiveVolumes) 384 if (!ioc->raid_data.pIocPg2->NumActiveVolumes)
383 goto out; 385 goto out;
384 for (i=0; i < hd->ioc->raid_data.pIocPg2->NumActiveVolumes; i++) { 386 for (i=0; i < ioc->raid_data.pIocPg2->NumActiveVolumes; i++) {
385 if (hd->ioc->raid_data.pIocPg2->RaidVolume[i].VolumeID == id) { 387 if (ioc->raid_data.pIocPg2->RaidVolume[i].VolumeID == id) {
386 rc = 1; 388 rc = 1;
387 goto out; 389 goto out;
388 } 390 }
@@ -397,15 +399,17 @@ static int mptspi_target_alloc(struct scsi_target *starget)
397 struct Scsi_Host *shost = dev_to_shost(&starget->dev); 399 struct Scsi_Host *shost = dev_to_shost(&starget->dev);
398 struct _MPT_SCSI_HOST *hd = (struct _MPT_SCSI_HOST *)shost->hostdata; 400 struct _MPT_SCSI_HOST *hd = (struct _MPT_SCSI_HOST *)shost->hostdata;
399 VirtTarget *vtarget; 401 VirtTarget *vtarget;
402 MPT_ADAPTER *ioc;
400 403
401 if (hd == NULL) 404 if (hd == NULL)
402 return -ENODEV; 405 return -ENODEV;
403 406
407 ioc = hd->ioc;
404 vtarget = kzalloc(sizeof(VirtTarget), GFP_KERNEL); 408 vtarget = kzalloc(sizeof(VirtTarget), GFP_KERNEL);
405 if (!vtarget) 409 if (!vtarget)
406 return -ENOMEM; 410 return -ENOMEM;
407 411
408 vtarget->ioc_id = hd->ioc->id; 412 vtarget->ioc_id = ioc->id;
409 vtarget->tflags = MPT_TARGET_FLAGS_Q_YES; 413 vtarget->tflags = MPT_TARGET_FLAGS_Q_YES;
410 vtarget->id = (u8)starget->id; 414 vtarget->id = (u8)starget->id;
411 vtarget->channel = (u8)starget->channel; 415 vtarget->channel = (u8)starget->channel;
@@ -413,34 +417,34 @@ static int mptspi_target_alloc(struct scsi_target *starget)
413 starget->hostdata = vtarget; 417 starget->hostdata = vtarget;
414 418
415 if (starget->channel == 1) { 419 if (starget->channel == 1) {
416 if (mptscsih_is_phys_disk(hd->ioc, 0, starget->id) == 0) 420 if (mptscsih_is_phys_disk(ioc, 0, starget->id) == 0)
417 return 0; 421 return 0;
418 vtarget->tflags |= MPT_TARGET_FLAGS_RAID_COMPONENT; 422 vtarget->tflags |= MPT_TARGET_FLAGS_RAID_COMPONENT;
419 /* The real channel for this device is zero */ 423 /* The real channel for this device is zero */
420 vtarget->channel = 0; 424 vtarget->channel = 0;
421 /* The actual physdisknum (for RAID passthrough) */ 425 /* The actual physdisknum (for RAID passthrough) */
422 vtarget->id = mptscsih_raid_id_to_num(hd->ioc, 0, 426 vtarget->id = mptscsih_raid_id_to_num(ioc, 0,
423 starget->id); 427 starget->id);
424 } 428 }
425 429
426 if (starget->channel == 0 && 430 if (starget->channel == 0 &&
427 mptspi_is_raid(hd, starget->id)) { 431 mptspi_is_raid(hd, starget->id)) {
428 vtarget->raidVolume = 1; 432 vtarget->raidVolume = 1;
429 ddvprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT 433 ddvprintk(ioc, printk(MYIOC_s_DEBUG_FMT
430 "RAID Volume @ channel=%d id=%d\n", hd->ioc->name, starget->channel, 434 "RAID Volume @ channel=%d id=%d\n", ioc->name, starget->channel,
431 starget->id)); 435 starget->id));
432 } 436 }
433 437
434 if (hd->ioc->spi_data.nvram && 438 if (ioc->spi_data.nvram &&
435 hd->ioc->spi_data.nvram[starget->id] != MPT_HOST_NVRAM_INVALID) { 439 ioc->spi_data.nvram[starget->id] != MPT_HOST_NVRAM_INVALID) {
436 u32 nvram = hd->ioc->spi_data.nvram[starget->id]; 440 u32 nvram = ioc->spi_data.nvram[starget->id];
437 spi_min_period(starget) = (nvram & MPT_NVRAM_SYNC_MASK) >> MPT_NVRAM_SYNC_SHIFT; 441 spi_min_period(starget) = (nvram & MPT_NVRAM_SYNC_MASK) >> MPT_NVRAM_SYNC_SHIFT;
438 spi_max_width(starget) = nvram & MPT_NVRAM_WIDE_DISABLE ? 0 : 1; 442 spi_max_width(starget) = nvram & MPT_NVRAM_WIDE_DISABLE ? 0 : 1;
439 } else { 443 } else {
440 spi_min_period(starget) = hd->ioc->spi_data.minSyncFactor; 444 spi_min_period(starget) = ioc->spi_data.minSyncFactor;
441 spi_max_width(starget) = hd->ioc->spi_data.maxBusWidth; 445 spi_max_width(starget) = ioc->spi_data.maxBusWidth;
442 } 446 }
443 spi_max_offset(starget) = hd->ioc->spi_data.maxSyncOffset; 447 spi_max_offset(starget) = ioc->spi_data.maxSyncOffset;
444 448
445 spi_offset(starget) = 0; 449 spi_offset(starget) = 0;
446 mptspi_write_width(starget, 0); 450 mptspi_write_width(starget, 0);
@@ -614,12 +618,13 @@ mptscsih_quiesce_raid(MPT_SCSI_HOST *hd, int quiesce, u8 channel, u8 id)
614{ 618{
615 MpiRaidActionRequest_t *pReq; 619 MpiRaidActionRequest_t *pReq;
616 MPT_FRAME_HDR *mf; 620 MPT_FRAME_HDR *mf;
621 MPT_ADAPTER *ioc = hd->ioc;
617 622
618 /* Get and Populate a free Frame 623 /* Get and Populate a free Frame
619 */ 624 */
620 if ((mf = mpt_get_msg_frame(hd->ioc->InternalCtx, hd->ioc)) == NULL) { 625 if ((mf = mpt_get_msg_frame(ioc->InternalCtx, ioc)) == NULL) {
621 ddvprintk(hd->ioc, printk(MYIOC_s_WARN_FMT "_do_raid: no msg frames!\n", 626 ddvprintk(ioc, printk(MYIOC_s_WARN_FMT "_do_raid: no msg frames!\n",
622 hd->ioc->name)); 627 ioc->name));
623 return -EAGAIN; 628 return -EAGAIN;
624 } 629 }
625 pReq = (MpiRaidActionRequest_t *)mf; 630 pReq = (MpiRaidActionRequest_t *)mf;
@@ -640,8 +645,8 @@ mptscsih_quiesce_raid(MPT_SCSI_HOST *hd, int quiesce, u8 channel, u8 id)
640 mpt_add_sge((char *)&pReq->ActionDataSGE, 645 mpt_add_sge((char *)&pReq->ActionDataSGE,
641 MPT_SGE_FLAGS_SSIMPLE_READ | 0, (dma_addr_t) -1); 646 MPT_SGE_FLAGS_SSIMPLE_READ | 0, (dma_addr_t) -1);
642 647
643 ddvprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT "RAID Volume action=%x channel=%d id=%d\n", 648 ddvprintk(ioc, printk(MYIOC_s_DEBUG_FMT "RAID Volume action=%x channel=%d id=%d\n",
644 hd->ioc->name, pReq->Action, channel, id)); 649 ioc->name, pReq->Action, channel, id));
645 650
646 hd->pLocal = NULL; 651 hd->pLocal = NULL;
647 hd->timer.expires = jiffies + HZ*10; /* 10 second timeout */ 652 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)
653 hd->cmdPtr = mf; 658 hd->cmdPtr = mf;
654 659
655 add_timer(&hd->timer); 660 add_timer(&hd->timer);
656 mpt_put_msg_frame(hd->ioc->InternalCtx, hd->ioc, mf); 661 mpt_put_msg_frame(ioc->InternalCtx, ioc, mf);
657 wait_event(hd->scandv_waitq, hd->scandv_wait_done); 662 wait_event(hd->scandv_waitq, hd->scandv_wait_done);
658 663
659 if ((hd->pLocal == NULL) || (hd->pLocal->completion != 0)) 664 if ((hd->pLocal == NULL) || (hd->pLocal->completion != 0))
@@ -666,6 +671,7 @@ static void mptspi_dv_device(struct _MPT_SCSI_HOST *hd,
666 struct scsi_device *sdev) 671 struct scsi_device *sdev)
667{ 672{
668 VirtTarget *vtarget = scsi_target(sdev)->hostdata; 673 VirtTarget *vtarget = scsi_target(sdev)->hostdata;
674 MPT_ADAPTER *ioc = hd->ioc;
669 675
670 /* no DV on RAID devices */ 676 /* no DV on RAID devices */
671 if (sdev->channel == 0 && 677 if (sdev->channel == 0 &&
@@ -676,7 +682,7 @@ static void mptspi_dv_device(struct _MPT_SCSI_HOST *hd,
676 if (sdev->channel == 1 && 682 if (sdev->channel == 1 &&
677 mptscsih_quiesce_raid(hd, 1, vtarget->channel, vtarget->id) < 0) { 683 mptscsih_quiesce_raid(hd, 1, vtarget->channel, vtarget->id) < 0) {
678 starget_printk(MYIOC_s_ERR_FMT, scsi_target(sdev), 684 starget_printk(MYIOC_s_ERR_FMT, scsi_target(sdev),
679 "Integrated RAID quiesce failed\n", hd->ioc->name); 685 "Integrated RAID quiesce failed\n", ioc->name);
680 return; 686 return;
681 } 687 }
682 688
@@ -687,7 +693,7 @@ static void mptspi_dv_device(struct _MPT_SCSI_HOST *hd,
687 if (sdev->channel == 1 && 693 if (sdev->channel == 1 &&
688 mptscsih_quiesce_raid(hd, 0, vtarget->channel, vtarget->id) < 0) 694 mptscsih_quiesce_raid(hd, 0, vtarget->channel, vtarget->id) < 0)
689 starget_printk(MYIOC_s_ERR_FMT, scsi_target(sdev), 695 starget_printk(MYIOC_s_ERR_FMT, scsi_target(sdev),
690 "Integrated RAID resume failed\n", hd->ioc->name); 696 "Integrated RAID resume failed\n", ioc->name);
691 697
692 mptspi_read_parameters(sdev->sdev_target); 698 mptspi_read_parameters(sdev->sdev_target);
693 spi_display_xfer_agreement(sdev->sdev_target); 699 spi_display_xfer_agreement(sdev->sdev_target);
@@ -700,15 +706,16 @@ static int mptspi_slave_alloc(struct scsi_device *sdev)
700 VirtTarget *vtarget; 706 VirtTarget *vtarget;
701 VirtDevice *vdevice; 707 VirtDevice *vdevice;
702 struct scsi_target *starget; 708 struct scsi_target *starget;
709 MPT_ADAPTER *ioc = hd->ioc;
703 710
704 if (sdev->channel == 1 && 711 if (sdev->channel == 1 &&
705 mptscsih_is_phys_disk(hd->ioc, 0, sdev->id) == 0) 712 mptscsih_is_phys_disk(ioc, 0, sdev->id) == 0)
706 return -ENXIO; 713 return -ENXIO;
707 714
708 vdevice = kzalloc(sizeof(VirtDevice), GFP_KERNEL); 715 vdevice = kzalloc(sizeof(VirtDevice), GFP_KERNEL);
709 if (!vdevice) { 716 if (!vdevice) {
710 printk(MYIOC_s_ERR_FMT "slave_alloc kmalloc(%zd) FAILED!\n", 717 printk(MYIOC_s_ERR_FMT "slave_alloc kmalloc(%zd) FAILED!\n",
711 hd->ioc->name, sizeof(VirtDevice)); 718 ioc->name, sizeof(VirtDevice));
712 return -ENOMEM; 719 return -ENOMEM;
713 } 720 }
714 721
@@ -759,6 +766,7 @@ mptspi_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
759{ 766{
760 struct _MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *) SCpnt->device->host->hostdata; 767 struct _MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *) SCpnt->device->host->hostdata;
761 VirtDevice *vdevice = SCpnt->device->hostdata; 768 VirtDevice *vdevice = SCpnt->device->hostdata;
769 MPT_ADAPTER *ioc = hd->ioc;
762 770
763 if (!vdevice || !vdevice->vtarget) { 771 if (!vdevice || !vdevice->vtarget) {
764 SCpnt->result = DID_NO_CONNECT << 16; 772 SCpnt->result = DID_NO_CONNECT << 16;
@@ -767,14 +775,14 @@ mptspi_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
767 } 775 }
768 776
769 if (SCpnt->device->channel == 1 && 777 if (SCpnt->device->channel == 1 &&
770 mptscsih_is_phys_disk(hd->ioc, 0, SCpnt->device->id) == 0) { 778 mptscsih_is_phys_disk(ioc, 0, SCpnt->device->id) == 0) {
771 SCpnt->result = DID_NO_CONNECT << 16; 779 SCpnt->result = DID_NO_CONNECT << 16;
772 done(SCpnt); 780 done(SCpnt);
773 return 0; 781 return 0;
774 } 782 }
775 783
776 if (spi_dv_pending(scsi_target(SCpnt->device))) 784 if (spi_dv_pending(scsi_target(SCpnt->device)))
777 ddvprintk(hd->ioc, scsi_print_command(SCpnt)); 785 ddvprintk(ioc, scsi_print_command(SCpnt));
778 786
779 return mptscsih_qcmd(SCpnt,done); 787 return mptscsih_qcmd(SCpnt,done);
780} 788}
@@ -1071,15 +1079,16 @@ static void mpt_work_wrapper(struct work_struct *work)
1071 struct work_queue_wrapper *wqw = 1079 struct work_queue_wrapper *wqw =
1072 container_of(work, struct work_queue_wrapper, work); 1080 container_of(work, struct work_queue_wrapper, work);
1073 struct _MPT_SCSI_HOST *hd = wqw->hd; 1081 struct _MPT_SCSI_HOST *hd = wqw->hd;
1074 struct Scsi_Host *shost = hd->ioc->sh; 1082 MPT_ADAPTER *ioc = hd->ioc;
1083 struct Scsi_Host *shost = ioc->sh;
1075 struct scsi_device *sdev; 1084 struct scsi_device *sdev;
1076 int disk = wqw->disk; 1085 int disk = wqw->disk;
1077 struct _CONFIG_PAGE_IOC_3 *pg3; 1086 struct _CONFIG_PAGE_IOC_3 *pg3;
1078 1087
1079 kfree(wqw); 1088 kfree(wqw);
1080 1089
1081 mpt_findImVolumes(hd->ioc); 1090 mpt_findImVolumes(ioc);
1082 pg3 = hd->ioc->raid_data.pIocPg3; 1091 pg3 = ioc->raid_data.pIocPg3;
1083 if (!pg3) 1092 if (!pg3)
1084 return; 1093 return;
1085 1094
@@ -1097,23 +1106,24 @@ static void mpt_work_wrapper(struct work_struct *work)
1097 continue; 1106 continue;
1098 1107
1099 starget_printk(MYIOC_s_INFO_FMT, vtarget->starget, 1108 starget_printk(MYIOC_s_INFO_FMT, vtarget->starget,
1100 "Integrated RAID requests DV of new device\n", hd->ioc->name); 1109 "Integrated RAID requests DV of new device\n", ioc->name);
1101 mptspi_dv_device(hd, sdev); 1110 mptspi_dv_device(hd, sdev);
1102 } 1111 }
1103 shost_printk(MYIOC_s_INFO_FMT, shost, 1112 shost_printk(MYIOC_s_INFO_FMT, shost,
1104 "Integrated RAID detects new device %d\n", hd->ioc->name, disk); 1113 "Integrated RAID detects new device %d\n", ioc->name, disk);
1105 scsi_scan_target(&hd->ioc->sh->shost_gendev, 1, disk, 0, 1); 1114 scsi_scan_target(&ioc->sh->shost_gendev, 1, disk, 0, 1);
1106} 1115}
1107 1116
1108 1117
1109static void mpt_dv_raid(struct _MPT_SCSI_HOST *hd, int disk) 1118static void mpt_dv_raid(struct _MPT_SCSI_HOST *hd, int disk)
1110{ 1119{
1111 struct work_queue_wrapper *wqw = kmalloc(sizeof(*wqw), GFP_ATOMIC); 1120 struct work_queue_wrapper *wqw = kmalloc(sizeof(*wqw), GFP_ATOMIC);
1121 MPT_ADAPTER *ioc = hd->ioc;
1112 1122
1113 if (!wqw) { 1123 if (!wqw) {
1114 shost_printk(MYIOC_s_ERR_FMT, hd->ioc->sh, 1124 shost_printk(MYIOC_s_ERR_FMT, ioc->sh,
1115 "Failed to act on RAID event for physical disk %d\n", 1125 "Failed to act on RAID event for physical disk %d\n",
1116 hd->ioc->name, disk); 1126 ioc->name, disk);
1117 return; 1127 return;
1118 } 1128 }
1119 INIT_WORK(&wqw->work, mpt_work_wrapper); 1129 INIT_WORK(&wqw->work, mpt_work_wrapper);
@@ -1216,11 +1226,12 @@ mptspi_dv_renegotiate_work(struct work_struct *work)
1216 struct scsi_target *starget; 1226 struct scsi_target *starget;
1217 struct _CONFIG_PAGE_SCSI_DEVICE_1 pg1; 1227 struct _CONFIG_PAGE_SCSI_DEVICE_1 pg1;
1218 u32 nego; 1228 u32 nego;
1229 MPT_ADAPTER *ioc = hd->ioc;
1219 1230
1220 kfree(wqw); 1231 kfree(wqw);
1221 1232
1222 if (hd->spi_pending) { 1233 if (hd->spi_pending) {
1223 shost_for_each_device(sdev, hd->ioc->sh) { 1234 shost_for_each_device(sdev, ioc->sh) {
1224 if (hd->spi_pending & (1 << sdev->id)) 1235 if (hd->spi_pending & (1 << sdev->id))
1225 continue; 1236 continue;
1226 starget = scsi_target(sdev); 1237 starget = scsi_target(sdev);
@@ -1231,7 +1242,7 @@ mptspi_dv_renegotiate_work(struct work_struct *work)
1231 mptspi_write_spi_device_pg1(starget, &pg1); 1242 mptspi_write_spi_device_pg1(starget, &pg1);
1232 } 1243 }
1233 } else { 1244 } else {
1234 shost_for_each_device(sdev, hd->ioc->sh) 1245 shost_for_each_device(sdev, ioc->sh)
1235 mptspi_dv_device(hd, sdev); 1246 mptspi_dv_device(hd, sdev);
1236 } 1247 }
1237} 1248}
@@ -1483,7 +1494,7 @@ mptspi_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1483 1494
1484 /* Some versions of the firmware don't support page 0; without 1495 /* Some versions of the firmware don't support page 0; without
1485 * that we can't get the parameters */ 1496 * that we can't get the parameters */
1486 if (hd->ioc->spi_data.sdp0length != 0) 1497 if (ioc->spi_data.sdp0length != 0)
1487 sh->transportt = mptspi_transport_template; 1498 sh->transportt = mptspi_transport_template;
1488 1499
1489 error = scsi_add_host (sh, &ioc->pcidev->dev); 1500 error = scsi_add_host (sh, &ioc->pcidev->dev);