diff options
Diffstat (limited to 'drivers/message/fusion/mptspi.c')
-rw-r--r-- | drivers/message/fusion/mptspi.c | 211 |
1 files changed, 114 insertions, 97 deletions
diff --git a/drivers/message/fusion/mptspi.c b/drivers/message/fusion/mptspi.c index 8c98420640a5..25bcfcf36f2e 100644 --- a/drivers/message/fusion/mptspi.c +++ b/drivers/message/fusion/mptspi.c | |||
@@ -1,9 +1,9 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/message/fusion/mptspi.c | 2 | * linux/drivers/message/fusion/mptspi.c |
3 | * For use with LSI Logic PCI chip/adapter(s) | 3 | * For use with LSI PCI chip/adapter(s) |
4 | * running LSI Logic Fusion MPT (Message Passing Technology) firmware. | 4 | * running LSI Fusion MPT (Message Passing Technology) firmware. |
5 | * | 5 | * |
6 | * Copyright (c) 1999-2007 LSI Logic Corporation | 6 | * Copyright (c) 1999-2007 LSI Corporation |
7 | * (mailto:DL-MPTFusionLinux@lsi.com) | 7 | * (mailto:DL-MPTFusionLinux@lsi.com) |
8 | * | 8 | * |
9 | */ | 9 | */ |
@@ -90,9 +90,9 @@ static int mptspi_write_spi_device_pg1(struct scsi_target *, | |||
90 | 90 | ||
91 | static struct scsi_transport_template *mptspi_transport_template = NULL; | 91 | static struct scsi_transport_template *mptspi_transport_template = NULL; |
92 | 92 | ||
93 | static int mptspiDoneCtx = -1; | 93 | static u8 mptspiDoneCtx = MPT_MAX_PROTOCOL_DRIVERS; |
94 | static int mptspiTaskCtx = -1; | 94 | static u8 mptspiTaskCtx = MPT_MAX_PROTOCOL_DRIVERS; |
95 | static int mptspiInternalCtx = -1; /* Used only for internal commands */ | 95 | static u8 mptspiInternalCtx = MPT_MAX_PROTOCOL_DRIVERS; /* Used only for internal commands */ |
96 | 96 | ||
97 | /** | 97 | /** |
98 | * mptspi_setTargetNegoParms - Update the target negotiation parameters | 98 | * mptspi_setTargetNegoParms - Update the target negotiation parameters |
@@ -107,7 +107,8 @@ static void | |||
107 | mptspi_setTargetNegoParms(MPT_SCSI_HOST *hd, VirtTarget *target, | 107 | mptspi_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,10 @@ 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(KERN_DEBUG "Enabling QAS due to " | 143 | printk(MYIOC_s_DEBUG_FMT "Enabling QAS due to " |
143 | "byte56=%02x on id=%d!\n", scsi_device_qas(sdev), id)); | 144 | "byte56=%02x on id=%d!\n", ioc->name, |
145 | scsi_device_qas(sdev), id)); | ||
144 | noQas = 0; | 146 | noQas = 0; |
145 | } | 147 | } |
146 | if (sdev->type == TYPE_TAPE && | 148 | if (sdev->type == TYPE_TAPE && |
@@ -227,8 +229,8 @@ mptspi_setTargetNegoParms(MPT_SCSI_HOST *hd, VirtTarget *target, | |||
227 | /* Disable QAS in a mixed configuration case | 229 | /* Disable QAS in a mixed configuration case |
228 | */ | 230 | */ |
229 | 231 | ||
230 | ddvprintk(hd->ioc, printk(KERN_DEBUG | 232 | ddvprintk(ioc, printk(MYIOC_s_DEBUG_FMT |
231 | "Disabling QAS due to noQas=%02x on id=%d!\n", noQas, id)); | 233 | "Disabling QAS due to noQas=%02x on id=%d!\n", ioc->name, noQas, id)); |
232 | } | 234 | } |
233 | } | 235 | } |
234 | 236 | ||
@@ -302,7 +304,7 @@ mptspi_writeIOCPage4(MPT_SCSI_HOST *hd, u8 channel , u8 id) | |||
302 | 304 | ||
303 | ddvprintk(ioc, printk(MYIOC_s_DEBUG_FMT | 305 | ddvprintk(ioc, printk(MYIOC_s_DEBUG_FMT |
304 | "writeIOCPage4: MaxSEP=%d ActiveSEP=%d id=%d bus=%d\n", | 306 | "writeIOCPage4: MaxSEP=%d ActiveSEP=%d id=%d bus=%d\n", |
305 | ioc->name, IOCPage4Ptr->MaxSEP, IOCPage4Ptr->ActiveSEP, id, channel)); | 307 | ioc->name, IOCPage4Ptr->MaxSEP, IOCPage4Ptr->ActiveSEP, id, channel)); |
306 | 308 | ||
307 | mpt_put_msg_frame(ioc->DoneCtx, ioc, mf); | 309 | mpt_put_msg_frame(ioc->DoneCtx, ioc, mf); |
308 | 310 | ||
@@ -374,14 +376,15 @@ static int | |||
374 | mptspi_is_raid(struct _MPT_SCSI_HOST *hd, u32 id) | 376 | mptspi_is_raid(struct _MPT_SCSI_HOST *hd, u32 id) |
375 | { | 377 | { |
376 | int i, rc = 0; | 378 | int i, rc = 0; |
379 | MPT_ADAPTER *ioc = hd->ioc; | ||
377 | 380 | ||
378 | if (!hd->ioc->raid_data.pIocPg2) | 381 | if (!ioc->raid_data.pIocPg2) |
379 | goto out; | 382 | goto out; |
380 | 383 | ||
381 | if (!hd->ioc->raid_data.pIocPg2->NumActiveVolumes) | 384 | if (!ioc->raid_data.pIocPg2->NumActiveVolumes) |
382 | goto out; | 385 | goto out; |
383 | for (i=0; i < hd->ioc->raid_data.pIocPg2->NumActiveVolumes; i++) { | 386 | for (i=0; i < ioc->raid_data.pIocPg2->NumActiveVolumes; i++) { |
384 | if (hd->ioc->raid_data.pIocPg2->RaidVolume[i].VolumeID == id) { | 387 | if (ioc->raid_data.pIocPg2->RaidVolume[i].VolumeID == id) { |
385 | rc = 1; | 388 | rc = 1; |
386 | goto out; | 389 | goto out; |
387 | } | 390 | } |
@@ -394,17 +397,19 @@ mptspi_is_raid(struct _MPT_SCSI_HOST *hd, u32 id) | |||
394 | static int mptspi_target_alloc(struct scsi_target *starget) | 397 | static int mptspi_target_alloc(struct scsi_target *starget) |
395 | { | 398 | { |
396 | struct Scsi_Host *shost = dev_to_shost(&starget->dev); | 399 | struct Scsi_Host *shost = dev_to_shost(&starget->dev); |
397 | struct _MPT_SCSI_HOST *hd = (struct _MPT_SCSI_HOST *)shost->hostdata; | 400 | struct _MPT_SCSI_HOST *hd = shost_priv(shost); |
398 | VirtTarget *vtarget; | 401 | VirtTarget *vtarget; |
402 | MPT_ADAPTER *ioc; | ||
399 | 403 | ||
400 | if (hd == NULL) | 404 | if (hd == NULL) |
401 | return -ENODEV; | 405 | return -ENODEV; |
402 | 406 | ||
407 | ioc = hd->ioc; | ||
403 | vtarget = kzalloc(sizeof(VirtTarget), GFP_KERNEL); | 408 | vtarget = kzalloc(sizeof(VirtTarget), GFP_KERNEL); |
404 | if (!vtarget) | 409 | if (!vtarget) |
405 | return -ENOMEM; | 410 | return -ENOMEM; |
406 | 411 | ||
407 | vtarget->ioc_id = hd->ioc->id; | 412 | vtarget->ioc_id = ioc->id; |
408 | vtarget->tflags = MPT_TARGET_FLAGS_Q_YES; | 413 | vtarget->tflags = MPT_TARGET_FLAGS_Q_YES; |
409 | vtarget->id = (u8)starget->id; | 414 | vtarget->id = (u8)starget->id; |
410 | vtarget->channel = (u8)starget->channel; | 415 | vtarget->channel = (u8)starget->channel; |
@@ -412,34 +417,34 @@ static int mptspi_target_alloc(struct scsi_target *starget) | |||
412 | starget->hostdata = vtarget; | 417 | starget->hostdata = vtarget; |
413 | 418 | ||
414 | if (starget->channel == 1) { | 419 | if (starget->channel == 1) { |
415 | if (mptscsih_is_phys_disk(hd->ioc, 0, starget->id) == 0) | 420 | if (mptscsih_is_phys_disk(ioc, 0, starget->id) == 0) |
416 | return 0; | 421 | return 0; |
417 | vtarget->tflags |= MPT_TARGET_FLAGS_RAID_COMPONENT; | 422 | vtarget->tflags |= MPT_TARGET_FLAGS_RAID_COMPONENT; |
418 | /* The real channel for this device is zero */ | 423 | /* The real channel for this device is zero */ |
419 | vtarget->channel = 0; | 424 | vtarget->channel = 0; |
420 | /* The actual physdisknum (for RAID passthrough) */ | 425 | /* The actual physdisknum (for RAID passthrough) */ |
421 | vtarget->id = mptscsih_raid_id_to_num(hd->ioc, 0, | 426 | vtarget->id = mptscsih_raid_id_to_num(ioc, 0, |
422 | starget->id); | 427 | starget->id); |
423 | } | 428 | } |
424 | 429 | ||
425 | if (starget->channel == 0 && | 430 | if (starget->channel == 0 && |
426 | mptspi_is_raid(hd, starget->id)) { | 431 | mptspi_is_raid(hd, starget->id)) { |
427 | vtarget->raidVolume = 1; | 432 | vtarget->raidVolume = 1; |
428 | ddvprintk(hd->ioc, printk(KERN_DEBUG | 433 | ddvprintk(ioc, printk(MYIOC_s_DEBUG_FMT |
429 | "RAID Volume @ channel=%d id=%d\n", starget->channel, | 434 | "RAID Volume @ channel=%d id=%d\n", ioc->name, starget->channel, |
430 | starget->id)); | 435 | starget->id)); |
431 | } | 436 | } |
432 | 437 | ||
433 | if (hd->ioc->spi_data.nvram && | 438 | if (ioc->spi_data.nvram && |
434 | hd->ioc->spi_data.nvram[starget->id] != MPT_HOST_NVRAM_INVALID) { | 439 | ioc->spi_data.nvram[starget->id] != MPT_HOST_NVRAM_INVALID) { |
435 | u32 nvram = hd->ioc->spi_data.nvram[starget->id]; | 440 | u32 nvram = ioc->spi_data.nvram[starget->id]; |
436 | 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; |
437 | spi_max_width(starget) = nvram & MPT_NVRAM_WIDE_DISABLE ? 0 : 1; | 442 | spi_max_width(starget) = nvram & MPT_NVRAM_WIDE_DISABLE ? 0 : 1; |
438 | } else { | 443 | } else { |
439 | spi_min_period(starget) = hd->ioc->spi_data.minSyncFactor; | 444 | spi_min_period(starget) = ioc->spi_data.minSyncFactor; |
440 | spi_max_width(starget) = hd->ioc->spi_data.maxBusWidth; | 445 | spi_max_width(starget) = ioc->spi_data.maxBusWidth; |
441 | } | 446 | } |
442 | spi_max_offset(starget) = hd->ioc->spi_data.maxSyncOffset; | 447 | spi_max_offset(starget) = ioc->spi_data.maxSyncOffset; |
443 | 448 | ||
444 | spi_offset(starget) = 0; | 449 | spi_offset(starget) = 0; |
445 | mptspi_write_width(starget, 0); | 450 | mptspi_write_width(starget, 0); |
@@ -509,10 +514,10 @@ static int mptspi_read_spi_device_pg0(struct scsi_target *starget, | |||
509 | struct _CONFIG_PAGE_SCSI_DEVICE_0 *pass_pg0) | 514 | struct _CONFIG_PAGE_SCSI_DEVICE_0 *pass_pg0) |
510 | { | 515 | { |
511 | struct Scsi_Host *shost = dev_to_shost(&starget->dev); | 516 | struct Scsi_Host *shost = dev_to_shost(&starget->dev); |
512 | struct _MPT_SCSI_HOST *hd = (struct _MPT_SCSI_HOST *)shost->hostdata; | 517 | struct _MPT_SCSI_HOST *hd = shost_priv(shost); |
513 | struct _MPT_ADAPTER *ioc = hd->ioc; | 518 | struct _MPT_ADAPTER *ioc = hd->ioc; |
514 | struct _CONFIG_PAGE_SCSI_DEVICE_0 *pg0; | 519 | struct _CONFIG_PAGE_SCSI_DEVICE_0 *spi_dev_pg0; |
515 | dma_addr_t pg0_dma; | 520 | dma_addr_t spi_dev_pg0_dma; |
516 | int size; | 521 | int size; |
517 | struct _x_config_parms cfg; | 522 | struct _x_config_parms cfg; |
518 | struct _CONFIG_PAGE_HEADER hdr; | 523 | struct _CONFIG_PAGE_HEADER hdr; |
@@ -530,9 +535,10 @@ static int mptspi_read_spi_device_pg0(struct scsi_target *starget, | |||
530 | size += 2048; | 535 | size += 2048; |
531 | */ | 536 | */ |
532 | 537 | ||
533 | pg0 = dma_alloc_coherent(&ioc->pcidev->dev, size, &pg0_dma, GFP_KERNEL); | 538 | spi_dev_pg0 = dma_alloc_coherent(&ioc->pcidev->dev, size, &spi_dev_pg0_dma, GFP_KERNEL); |
534 | if (pg0 == NULL) { | 539 | if (spi_dev_pg0 == NULL) { |
535 | starget_printk(KERN_ERR, starget, "dma_alloc_coherent for parameters failed\n"); | 540 | starget_printk(KERN_ERR, starget, MYIOC_s_FMT |
541 | "dma_alloc_coherent for parameters failed\n", ioc->name); | ||
536 | return -EINVAL; | 542 | return -EINVAL; |
537 | } | 543 | } |
538 | 544 | ||
@@ -546,22 +552,22 @@ static int mptspi_read_spi_device_pg0(struct scsi_target *starget, | |||
546 | memset(&cfg, 0, sizeof(cfg)); | 552 | memset(&cfg, 0, sizeof(cfg)); |
547 | 553 | ||
548 | cfg.cfghdr.hdr = &hdr; | 554 | cfg.cfghdr.hdr = &hdr; |
549 | cfg.physAddr = pg0_dma; | 555 | cfg.physAddr = spi_dev_pg0_dma; |
550 | cfg.action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT; | 556 | cfg.action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT; |
551 | cfg.dir = 0; | 557 | cfg.dir = 0; |
552 | cfg.pageAddr = starget->id; | 558 | cfg.pageAddr = starget->id; |
553 | 559 | ||
554 | if (mpt_config(ioc, &cfg)) { | 560 | if (mpt_config(ioc, &cfg)) { |
555 | starget_printk(KERN_ERR, starget, "mpt_config failed\n"); | 561 | starget_printk(KERN_ERR, starget, MYIOC_s_FMT "mpt_config failed\n", ioc->name); |
556 | goto out_free; | 562 | goto out_free; |
557 | } | 563 | } |
558 | err = 0; | 564 | err = 0; |
559 | memcpy(pass_pg0, pg0, size); | 565 | memcpy(pass_pg0, spi_dev_pg0, size); |
560 | 566 | ||
561 | mptspi_print_read_nego(hd, starget, le32_to_cpu(pg0->NegotiatedParameters)); | 567 | mptspi_print_read_nego(hd, starget, le32_to_cpu(spi_dev_pg0->NegotiatedParameters)); |
562 | 568 | ||
563 | out_free: | 569 | out_free: |
564 | dma_free_coherent(&ioc->pcidev->dev, size, pg0, pg0_dma); | 570 | dma_free_coherent(&ioc->pcidev->dev, size, spi_dev_pg0, spi_dev_pg0_dma); |
565 | return err; | 571 | return err; |
566 | } | 572 | } |
567 | 573 | ||
@@ -588,11 +594,11 @@ static u32 mptspi_getRP(struct scsi_target *starget) | |||
588 | static void mptspi_read_parameters(struct scsi_target *starget) | 594 | static void mptspi_read_parameters(struct scsi_target *starget) |
589 | { | 595 | { |
590 | int nego; | 596 | int nego; |
591 | struct _CONFIG_PAGE_SCSI_DEVICE_0 pg0; | 597 | struct _CONFIG_PAGE_SCSI_DEVICE_0 spi_dev_pg0; |
592 | 598 | ||
593 | mptspi_read_spi_device_pg0(starget, &pg0); | 599 | mptspi_read_spi_device_pg0(starget, &spi_dev_pg0); |
594 | 600 | ||
595 | nego = le32_to_cpu(pg0.NegotiatedParameters); | 601 | nego = le32_to_cpu(spi_dev_pg0.NegotiatedParameters); |
596 | 602 | ||
597 | spi_iu(starget) = (nego & MPI_SCSIDEVPAGE0_NP_IU) ? 1 : 0; | 603 | spi_iu(starget) = (nego & MPI_SCSIDEVPAGE0_NP_IU) ? 1 : 0; |
598 | spi_dt(starget) = (nego & MPI_SCSIDEVPAGE0_NP_DT) ? 1 : 0; | 604 | spi_dt(starget) = (nego & MPI_SCSIDEVPAGE0_NP_DT) ? 1 : 0; |
@@ -612,12 +618,13 @@ mptscsih_quiesce_raid(MPT_SCSI_HOST *hd, int quiesce, u8 channel, u8 id) | |||
612 | { | 618 | { |
613 | MpiRaidActionRequest_t *pReq; | 619 | MpiRaidActionRequest_t *pReq; |
614 | MPT_FRAME_HDR *mf; | 620 | MPT_FRAME_HDR *mf; |
621 | MPT_ADAPTER *ioc = hd->ioc; | ||
615 | 622 | ||
616 | /* Get and Populate a free Frame | 623 | /* Get and Populate a free Frame |
617 | */ | 624 | */ |
618 | if ((mf = mpt_get_msg_frame(hd->ioc->InternalCtx, hd->ioc)) == NULL) { | 625 | if ((mf = mpt_get_msg_frame(ioc->InternalCtx, ioc)) == NULL) { |
619 | 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", |
620 | hd->ioc->name)); | 627 | ioc->name)); |
621 | return -EAGAIN; | 628 | return -EAGAIN; |
622 | } | 629 | } |
623 | pReq = (MpiRaidActionRequest_t *)mf; | 630 | pReq = (MpiRaidActionRequest_t *)mf; |
@@ -638,8 +645,8 @@ mptscsih_quiesce_raid(MPT_SCSI_HOST *hd, int quiesce, u8 channel, u8 id) | |||
638 | mpt_add_sge((char *)&pReq->ActionDataSGE, | 645 | mpt_add_sge((char *)&pReq->ActionDataSGE, |
639 | MPT_SGE_FLAGS_SSIMPLE_READ | 0, (dma_addr_t) -1); | 646 | MPT_SGE_FLAGS_SSIMPLE_READ | 0, (dma_addr_t) -1); |
640 | 647 | ||
641 | 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", |
642 | hd->ioc->name, pReq->Action, channel, id)); | 649 | ioc->name, pReq->Action, channel, id)); |
643 | 650 | ||
644 | hd->pLocal = NULL; | 651 | hd->pLocal = NULL; |
645 | hd->timer.expires = jiffies + HZ*10; /* 10 second timeout */ | 652 | hd->timer.expires = jiffies + HZ*10; /* 10 second timeout */ |
@@ -651,7 +658,7 @@ mptscsih_quiesce_raid(MPT_SCSI_HOST *hd, int quiesce, u8 channel, u8 id) | |||
651 | hd->cmdPtr = mf; | 658 | hd->cmdPtr = mf; |
652 | 659 | ||
653 | add_timer(&hd->timer); | 660 | add_timer(&hd->timer); |
654 | mpt_put_msg_frame(hd->ioc->InternalCtx, hd->ioc, mf); | 661 | mpt_put_msg_frame(ioc->InternalCtx, ioc, mf); |
655 | wait_event(hd->scandv_waitq, hd->scandv_wait_done); | 662 | wait_event(hd->scandv_waitq, hd->scandv_wait_done); |
656 | 663 | ||
657 | if ((hd->pLocal == NULL) || (hd->pLocal->completion != 0)) | 664 | if ((hd->pLocal == NULL) || (hd->pLocal->completion != 0)) |
@@ -664,6 +671,7 @@ static void mptspi_dv_device(struct _MPT_SCSI_HOST *hd, | |||
664 | struct scsi_device *sdev) | 671 | struct scsi_device *sdev) |
665 | { | 672 | { |
666 | VirtTarget *vtarget = scsi_target(sdev)->hostdata; | 673 | VirtTarget *vtarget = scsi_target(sdev)->hostdata; |
674 | MPT_ADAPTER *ioc = hd->ioc; | ||
667 | 675 | ||
668 | /* no DV on RAID devices */ | 676 | /* no DV on RAID devices */ |
669 | if (sdev->channel == 0 && | 677 | if (sdev->channel == 0 && |
@@ -673,8 +681,8 @@ static void mptspi_dv_device(struct _MPT_SCSI_HOST *hd, | |||
673 | /* If this is a piece of a RAID, then quiesce first */ | 681 | /* If this is a piece of a RAID, then quiesce first */ |
674 | if (sdev->channel == 1 && | 682 | if (sdev->channel == 1 && |
675 | mptscsih_quiesce_raid(hd, 1, vtarget->channel, vtarget->id) < 0) { | 683 | mptscsih_quiesce_raid(hd, 1, vtarget->channel, vtarget->id) < 0) { |
676 | starget_printk(KERN_ERR, scsi_target(sdev), | 684 | starget_printk(KERN_ERR, scsi_target(sdev), MYIOC_s_FMT |
677 | "Integrated RAID quiesce failed\n"); | 685 | "Integrated RAID quiesce failed\n", ioc->name); |
678 | return; | 686 | return; |
679 | } | 687 | } |
680 | 688 | ||
@@ -684,8 +692,8 @@ static void mptspi_dv_device(struct _MPT_SCSI_HOST *hd, | |||
684 | 692 | ||
685 | if (sdev->channel == 1 && | 693 | if (sdev->channel == 1 && |
686 | mptscsih_quiesce_raid(hd, 0, vtarget->channel, vtarget->id) < 0) | 694 | mptscsih_quiesce_raid(hd, 0, vtarget->channel, vtarget->id) < 0) |
687 | starget_printk(KERN_ERR, scsi_target(sdev), | 695 | starget_printk(KERN_ERR, scsi_target(sdev), MYIOC_s_FMT |
688 | "Integrated RAID resume failed\n"); | 696 | "Integrated RAID resume failed\n", ioc->name); |
689 | 697 | ||
690 | mptspi_read_parameters(sdev->sdev_target); | 698 | mptspi_read_parameters(sdev->sdev_target); |
691 | spi_display_xfer_agreement(sdev->sdev_target); | 699 | spi_display_xfer_agreement(sdev->sdev_target); |
@@ -694,28 +702,29 @@ static void mptspi_dv_device(struct _MPT_SCSI_HOST *hd, | |||
694 | 702 | ||
695 | static int mptspi_slave_alloc(struct scsi_device *sdev) | 703 | static int mptspi_slave_alloc(struct scsi_device *sdev) |
696 | { | 704 | { |
697 | MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)sdev->host->hostdata; | 705 | MPT_SCSI_HOST *hd = shost_priv(sdev->host); |
698 | VirtTarget *vtarget; | 706 | VirtTarget *vtarget; |
699 | VirtDevice *vdev; | 707 | VirtDevice *vdevice; |
700 | struct scsi_target *starget; | 708 | struct scsi_target *starget; |
709 | MPT_ADAPTER *ioc = hd->ioc; | ||
701 | 710 | ||
702 | if (sdev->channel == 1 && | 711 | if (sdev->channel == 1 && |
703 | mptscsih_is_phys_disk(hd->ioc, 0, sdev->id) == 0) | 712 | mptscsih_is_phys_disk(ioc, 0, sdev->id) == 0) |
704 | return -ENXIO; | 713 | return -ENXIO; |
705 | 714 | ||
706 | vdev = kzalloc(sizeof(VirtDevice), GFP_KERNEL); | 715 | vdevice = kzalloc(sizeof(VirtDevice), GFP_KERNEL); |
707 | if (!vdev) { | 716 | if (!vdevice) { |
708 | printk(MYIOC_s_ERR_FMT "slave_alloc kmalloc(%zd) FAILED!\n", | 717 | printk(MYIOC_s_ERR_FMT "slave_alloc kmalloc(%zd) FAILED!\n", |
709 | hd->ioc->name, sizeof(VirtDevice)); | 718 | ioc->name, sizeof(VirtDevice)); |
710 | return -ENOMEM; | 719 | return -ENOMEM; |
711 | } | 720 | } |
712 | 721 | ||
713 | vdev->lun = sdev->lun; | 722 | vdevice->lun = sdev->lun; |
714 | sdev->hostdata = vdev; | 723 | sdev->hostdata = vdevice; |
715 | 724 | ||
716 | starget = scsi_target(sdev); | 725 | starget = scsi_target(sdev); |
717 | vtarget = starget->hostdata; | 726 | vtarget = starget->hostdata; |
718 | vdev->vtarget = vtarget; | 727 | vdevice->vtarget = vtarget; |
719 | vtarget->num_luns++; | 728 | vtarget->num_luns++; |
720 | 729 | ||
721 | if (sdev->channel == 1) | 730 | if (sdev->channel == 1) |
@@ -726,8 +735,7 @@ static int mptspi_slave_alloc(struct scsi_device *sdev) | |||
726 | 735 | ||
727 | static int mptspi_slave_configure(struct scsi_device *sdev) | 736 | static int mptspi_slave_configure(struct scsi_device *sdev) |
728 | { | 737 | { |
729 | struct _MPT_SCSI_HOST *hd = | 738 | struct _MPT_SCSI_HOST *hd = shost_priv(sdev->host); |
730 | (struct _MPT_SCSI_HOST *)sdev->host->hostdata; | ||
731 | VirtTarget *vtarget = scsi_target(sdev)->hostdata; | 739 | VirtTarget *vtarget = scsi_target(sdev)->hostdata; |
732 | int ret; | 740 | int ret; |
733 | 741 | ||
@@ -755,24 +763,25 @@ static int mptspi_slave_configure(struct scsi_device *sdev) | |||
755 | static int | 763 | static int |
756 | mptspi_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *)) | 764 | mptspi_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *)) |
757 | { | 765 | { |
758 | struct _MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *) SCpnt->device->host->hostdata; | 766 | struct _MPT_SCSI_HOST *hd = shost_priv(SCpnt->device->host); |
759 | VirtDevice *vdev = SCpnt->device->hostdata; | 767 | VirtDevice *vdevice = SCpnt->device->hostdata; |
768 | MPT_ADAPTER *ioc = hd->ioc; | ||
760 | 769 | ||
761 | if (!vdev || !vdev->vtarget) { | 770 | if (!vdevice || !vdevice->vtarget) { |
762 | SCpnt->result = DID_NO_CONNECT << 16; | 771 | SCpnt->result = DID_NO_CONNECT << 16; |
763 | done(SCpnt); | 772 | done(SCpnt); |
764 | return 0; | 773 | return 0; |
765 | } | 774 | } |
766 | 775 | ||
767 | if (SCpnt->device->channel == 1 && | 776 | if (SCpnt->device->channel == 1 && |
768 | mptscsih_is_phys_disk(hd->ioc, 0, SCpnt->device->id) == 0) { | 777 | mptscsih_is_phys_disk(ioc, 0, SCpnt->device->id) == 0) { |
769 | SCpnt->result = DID_NO_CONNECT << 16; | 778 | SCpnt->result = DID_NO_CONNECT << 16; |
770 | done(SCpnt); | 779 | done(SCpnt); |
771 | return 0; | 780 | return 0; |
772 | } | 781 | } |
773 | 782 | ||
774 | if (spi_dv_pending(scsi_target(SCpnt->device))) | 783 | if (spi_dv_pending(scsi_target(SCpnt->device))) |
775 | ddvprintk(hd->ioc, scsi_print_command(SCpnt)); | 784 | ddvprintk(ioc, scsi_print_command(SCpnt)); |
776 | 785 | ||
777 | return mptscsih_qcmd(SCpnt,done); | 786 | return mptscsih_qcmd(SCpnt,done); |
778 | } | 787 | } |
@@ -829,7 +838,7 @@ static int mptspi_write_spi_device_pg1(struct scsi_target *starget, | |||
829 | struct _CONFIG_PAGE_SCSI_DEVICE_1 *pass_pg1) | 838 | struct _CONFIG_PAGE_SCSI_DEVICE_1 *pass_pg1) |
830 | { | 839 | { |
831 | struct Scsi_Host *shost = dev_to_shost(&starget->dev); | 840 | struct Scsi_Host *shost = dev_to_shost(&starget->dev); |
832 | struct _MPT_SCSI_HOST *hd = (struct _MPT_SCSI_HOST *)shost->hostdata; | 841 | struct _MPT_SCSI_HOST *hd = shost_priv(shost); |
833 | struct _MPT_ADAPTER *ioc = hd->ioc; | 842 | struct _MPT_ADAPTER *ioc = hd->ioc; |
834 | struct _CONFIG_PAGE_SCSI_DEVICE_1 *pg1; | 843 | struct _CONFIG_PAGE_SCSI_DEVICE_1 *pg1; |
835 | dma_addr_t pg1_dma; | 844 | dma_addr_t pg1_dma; |
@@ -847,7 +856,8 @@ static int mptspi_write_spi_device_pg1(struct scsi_target *starget, | |||
847 | 856 | ||
848 | pg1 = dma_alloc_coherent(&ioc->pcidev->dev, size, &pg1_dma, GFP_KERNEL); | 857 | pg1 = dma_alloc_coherent(&ioc->pcidev->dev, size, &pg1_dma, GFP_KERNEL); |
849 | if (pg1 == NULL) { | 858 | if (pg1 == NULL) { |
850 | starget_printk(KERN_ERR, starget, "dma_alloc_coherent for parameters failed\n"); | 859 | starget_printk(KERN_ERR, starget, MYIOC_s_FMT |
860 | "dma_alloc_coherent for parameters failed\n", ioc->name); | ||
851 | return -EINVAL; | 861 | return -EINVAL; |
852 | } | 862 | } |
853 | 863 | ||
@@ -876,7 +886,8 @@ static int mptspi_write_spi_device_pg1(struct scsi_target *starget, | |||
876 | mptspi_print_write_nego(hd, starget, le32_to_cpu(pg1->RequestedParameters)); | 886 | mptspi_print_write_nego(hd, starget, le32_to_cpu(pg1->RequestedParameters)); |
877 | 887 | ||
878 | if (mpt_config(ioc, &cfg)) { | 888 | if (mpt_config(ioc, &cfg)) { |
879 | starget_printk(KERN_ERR, starget, "mpt_config failed\n"); | 889 | starget_printk(KERN_ERR, starget, MYIOC_s_FMT |
890 | "mpt_config failed\n", ioc->name); | ||
880 | goto out_free; | 891 | goto out_free; |
881 | } | 892 | } |
882 | err = 0; | 893 | err = 0; |
@@ -1015,7 +1026,7 @@ static void mptspi_write_qas(struct scsi_target *starget, int qas) | |||
1015 | { | 1026 | { |
1016 | struct _CONFIG_PAGE_SCSI_DEVICE_1 pg1; | 1027 | struct _CONFIG_PAGE_SCSI_DEVICE_1 pg1; |
1017 | struct Scsi_Host *shost = dev_to_shost(&starget->dev); | 1028 | struct Scsi_Host *shost = dev_to_shost(&starget->dev); |
1018 | struct _MPT_SCSI_HOST *hd = (struct _MPT_SCSI_HOST *)shost->hostdata; | 1029 | struct _MPT_SCSI_HOST *hd = shost_priv(shost); |
1019 | VirtTarget *vtarget = starget->hostdata; | 1030 | VirtTarget *vtarget = starget->hostdata; |
1020 | u32 nego; | 1031 | u32 nego; |
1021 | 1032 | ||
@@ -1067,15 +1078,16 @@ static void mpt_work_wrapper(struct work_struct *work) | |||
1067 | struct work_queue_wrapper *wqw = | 1078 | struct work_queue_wrapper *wqw = |
1068 | container_of(work, struct work_queue_wrapper, work); | 1079 | container_of(work, struct work_queue_wrapper, work); |
1069 | struct _MPT_SCSI_HOST *hd = wqw->hd; | 1080 | struct _MPT_SCSI_HOST *hd = wqw->hd; |
1070 | struct Scsi_Host *shost = hd->ioc->sh; | 1081 | MPT_ADAPTER *ioc = hd->ioc; |
1082 | struct Scsi_Host *shost = ioc->sh; | ||
1071 | struct scsi_device *sdev; | 1083 | struct scsi_device *sdev; |
1072 | int disk = wqw->disk; | 1084 | int disk = wqw->disk; |
1073 | struct _CONFIG_PAGE_IOC_3 *pg3; | 1085 | struct _CONFIG_PAGE_IOC_3 *pg3; |
1074 | 1086 | ||
1075 | kfree(wqw); | 1087 | kfree(wqw); |
1076 | 1088 | ||
1077 | mpt_findImVolumes(hd->ioc); | 1089 | mpt_findImVolumes(ioc); |
1078 | pg3 = hd->ioc->raid_data.pIocPg3; | 1090 | pg3 = ioc->raid_data.pIocPg3; |
1079 | if (!pg3) | 1091 | if (!pg3) |
1080 | return; | 1092 | return; |
1081 | 1093 | ||
@@ -1092,24 +1104,25 @@ static void mpt_work_wrapper(struct work_struct *work) | |||
1092 | if(vtarget->id != disk) | 1104 | if(vtarget->id != disk) |
1093 | continue; | 1105 | continue; |
1094 | 1106 | ||
1095 | starget_printk(KERN_INFO, vtarget->starget, | 1107 | starget_printk(KERN_INFO, vtarget->starget, MYIOC_s_FMT |
1096 | "Integrated RAID requests DV of new device\n"); | 1108 | "Integrated RAID requests DV of new device\n", ioc->name); |
1097 | mptspi_dv_device(hd, sdev); | 1109 | mptspi_dv_device(hd, sdev); |
1098 | } | 1110 | } |
1099 | shost_printk(KERN_INFO, shost, | 1111 | shost_printk(KERN_INFO, shost, MYIOC_s_FMT |
1100 | "Integrated RAID detects new device %d\n", disk); | 1112 | "Integrated RAID detects new device %d\n", ioc->name, disk); |
1101 | scsi_scan_target(&hd->ioc->sh->shost_gendev, 1, disk, 0, 1); | 1113 | scsi_scan_target(&ioc->sh->shost_gendev, 1, disk, 0, 1); |
1102 | } | 1114 | } |
1103 | 1115 | ||
1104 | 1116 | ||
1105 | static void mpt_dv_raid(struct _MPT_SCSI_HOST *hd, int disk) | 1117 | static void mpt_dv_raid(struct _MPT_SCSI_HOST *hd, int disk) |
1106 | { | 1118 | { |
1107 | struct work_queue_wrapper *wqw = kmalloc(sizeof(*wqw), GFP_ATOMIC); | 1119 | struct work_queue_wrapper *wqw = kmalloc(sizeof(*wqw), GFP_ATOMIC); |
1120 | MPT_ADAPTER *ioc = hd->ioc; | ||
1108 | 1121 | ||
1109 | if (!wqw) { | 1122 | if (!wqw) { |
1110 | shost_printk(KERN_ERR, hd->ioc->sh, | 1123 | shost_printk(KERN_ERR, ioc->sh, MYIOC_s_FMT |
1111 | "Failed to act on RAID event for physical disk %d\n", | 1124 | "Failed to act on RAID event for physical disk %d\n", |
1112 | disk); | 1125 | ioc->name, disk); |
1113 | return; | 1126 | return; |
1114 | } | 1127 | } |
1115 | INIT_WORK(&wqw->work, mpt_work_wrapper); | 1128 | INIT_WORK(&wqw->work, mpt_work_wrapper); |
@@ -1123,7 +1136,7 @@ static int | |||
1123 | mptspi_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply) | 1136 | mptspi_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply) |
1124 | { | 1137 | { |
1125 | u8 event = le32_to_cpu(pEvReply->Event) & 0xFF; | 1138 | u8 event = le32_to_cpu(pEvReply->Event) & 0xFF; |
1126 | struct _MPT_SCSI_HOST *hd = (struct _MPT_SCSI_HOST *)ioc->sh->hostdata; | 1139 | struct _MPT_SCSI_HOST *hd = shost_priv(ioc->sh); |
1127 | 1140 | ||
1128 | if (hd && event == MPI_EVENT_INTEGRATED_RAID) { | 1141 | if (hd && event == MPI_EVENT_INTEGRATED_RAID) { |
1129 | int reason | 1142 | int reason |
@@ -1190,6 +1203,8 @@ static struct spi_function_template mptspi_transport_functions = { | |||
1190 | static struct pci_device_id mptspi_pci_table[] = { | 1203 | static struct pci_device_id mptspi_pci_table[] = { |
1191 | { PCI_VENDOR_ID_LSI_LOGIC, MPI_MANUFACTPAGE_DEVID_53C1030, | 1204 | { PCI_VENDOR_ID_LSI_LOGIC, MPI_MANUFACTPAGE_DEVID_53C1030, |
1192 | PCI_ANY_ID, PCI_ANY_ID }, | 1205 | PCI_ANY_ID, PCI_ANY_ID }, |
1206 | { PCI_VENDOR_ID_ATTO, MPI_MANUFACTPAGE_DEVID_53C1030, | ||
1207 | PCI_ANY_ID, PCI_ANY_ID }, | ||
1193 | { PCI_VENDOR_ID_LSI_LOGIC, MPI_MANUFACTPAGE_DEVID_53C1035, | 1208 | { PCI_VENDOR_ID_LSI_LOGIC, MPI_MANUFACTPAGE_DEVID_53C1035, |
1194 | PCI_ANY_ID, PCI_ANY_ID }, | 1209 | PCI_ANY_ID, PCI_ANY_ID }, |
1195 | {0} /* Terminating entry */ | 1210 | {0} /* Terminating entry */ |
@@ -1210,11 +1225,12 @@ mptspi_dv_renegotiate_work(struct work_struct *work) | |||
1210 | struct scsi_target *starget; | 1225 | struct scsi_target *starget; |
1211 | struct _CONFIG_PAGE_SCSI_DEVICE_1 pg1; | 1226 | struct _CONFIG_PAGE_SCSI_DEVICE_1 pg1; |
1212 | u32 nego; | 1227 | u32 nego; |
1228 | MPT_ADAPTER *ioc = hd->ioc; | ||
1213 | 1229 | ||
1214 | kfree(wqw); | 1230 | kfree(wqw); |
1215 | 1231 | ||
1216 | if (hd->spi_pending) { | 1232 | if (hd->spi_pending) { |
1217 | shost_for_each_device(sdev, hd->ioc->sh) { | 1233 | shost_for_each_device(sdev, ioc->sh) { |
1218 | if (hd->spi_pending & (1 << sdev->id)) | 1234 | if (hd->spi_pending & (1 << sdev->id)) |
1219 | continue; | 1235 | continue; |
1220 | starget = scsi_target(sdev); | 1236 | starget = scsi_target(sdev); |
@@ -1225,7 +1241,7 @@ mptspi_dv_renegotiate_work(struct work_struct *work) | |||
1225 | mptspi_write_spi_device_pg1(starget, &pg1); | 1241 | mptspi_write_spi_device_pg1(starget, &pg1); |
1226 | } | 1242 | } |
1227 | } else { | 1243 | } else { |
1228 | shost_for_each_device(sdev, hd->ioc->sh) | 1244 | shost_for_each_device(sdev, ioc->sh) |
1229 | mptspi_dv_device(hd, sdev); | 1245 | mptspi_dv_device(hd, sdev); |
1230 | } | 1246 | } |
1231 | } | 1247 | } |
@@ -1250,7 +1266,7 @@ mptspi_dv_renegotiate(struct _MPT_SCSI_HOST *hd) | |||
1250 | static int | 1266 | static int |
1251 | mptspi_ioc_reset(MPT_ADAPTER *ioc, int reset_phase) | 1267 | mptspi_ioc_reset(MPT_ADAPTER *ioc, int reset_phase) |
1252 | { | 1268 | { |
1253 | struct _MPT_SCSI_HOST *hd = (struct _MPT_SCSI_HOST *)ioc->sh->hostdata; | 1269 | struct _MPT_SCSI_HOST *hd = shost_priv(ioc->sh); |
1254 | int rc; | 1270 | int rc; |
1255 | 1271 | ||
1256 | rc = mptscsih_ioc_reset(ioc, reset_phase); | 1272 | rc = mptscsih_ioc_reset(ioc, reset_phase); |
@@ -1269,7 +1285,7 @@ static int | |||
1269 | mptspi_resume(struct pci_dev *pdev) | 1285 | mptspi_resume(struct pci_dev *pdev) |
1270 | { | 1286 | { |
1271 | MPT_ADAPTER *ioc = pci_get_drvdata(pdev); | 1287 | MPT_ADAPTER *ioc = pci_get_drvdata(pdev); |
1272 | struct _MPT_SCSI_HOST *hd = (struct _MPT_SCSI_HOST *)ioc->sh->hostdata; | 1288 | struct _MPT_SCSI_HOST *hd = shost_priv(ioc->sh); |
1273 | int rc; | 1289 | int rc; |
1274 | 1290 | ||
1275 | rc = mptscsih_resume(pdev); | 1291 | rc = mptscsih_resume(pdev); |
@@ -1416,7 +1432,7 @@ mptspi_probe(struct pci_dev *pdev, const struct pci_device_id *id) | |||
1416 | 1432 | ||
1417 | if (numSGE < sh->sg_tablesize) { | 1433 | if (numSGE < sh->sg_tablesize) { |
1418 | /* Reset this value */ | 1434 | /* Reset this value */ |
1419 | dprintk(ioc, printk(MYIOC_s_INFO_FMT | 1435 | dprintk(ioc, printk(MYIOC_s_DEBUG_FMT |
1420 | "Resetting sg_tablesize to %d from %d\n", | 1436 | "Resetting sg_tablesize to %d from %d\n", |
1421 | ioc->name, numSGE, sh->sg_tablesize)); | 1437 | ioc->name, numSGE, sh->sg_tablesize)); |
1422 | sh->sg_tablesize = numSGE; | 1438 | sh->sg_tablesize = numSGE; |
@@ -1424,20 +1440,21 @@ mptspi_probe(struct pci_dev *pdev, const struct pci_device_id *id) | |||
1424 | 1440 | ||
1425 | spin_unlock_irqrestore(&ioc->FreeQlock, flags); | 1441 | spin_unlock_irqrestore(&ioc->FreeQlock, flags); |
1426 | 1442 | ||
1427 | hd = (MPT_SCSI_HOST *) sh->hostdata; | 1443 | hd = shost_priv(sh); |
1428 | hd->ioc = ioc; | 1444 | hd->ioc = ioc; |
1429 | 1445 | ||
1430 | /* SCSI needs scsi_cmnd lookup table! | 1446 | /* SCSI needs scsi_cmnd lookup table! |
1431 | * (with size equal to req_depth*PtrSz!) | 1447 | * (with size equal to req_depth*PtrSz!) |
1432 | */ | 1448 | */ |
1433 | hd->ScsiLookup = kcalloc(ioc->req_depth, sizeof(void *), GFP_ATOMIC); | 1449 | ioc->ScsiLookup = kcalloc(ioc->req_depth, sizeof(void *), GFP_ATOMIC); |
1434 | if (!hd->ScsiLookup) { | 1450 | if (!ioc->ScsiLookup) { |
1435 | error = -ENOMEM; | 1451 | error = -ENOMEM; |
1436 | goto out_mptspi_probe; | 1452 | goto out_mptspi_probe; |
1437 | } | 1453 | } |
1454 | spin_lock_init(&ioc->scsi_lookup_lock); | ||
1438 | 1455 | ||
1439 | dprintk(ioc, printk(MYIOC_s_DEBUG_FMT "ScsiLookup @ %p\n", | 1456 | dprintk(ioc, printk(MYIOC_s_DEBUG_FMT "ScsiLookup @ %p\n", |
1440 | ioc->name, hd->ScsiLookup)); | 1457 | ioc->name, ioc->ScsiLookup)); |
1441 | 1458 | ||
1442 | /* Clear the TM flags | 1459 | /* Clear the TM flags |
1443 | */ | 1460 | */ |
@@ -1477,13 +1494,13 @@ mptspi_probe(struct pci_dev *pdev, const struct pci_device_id *id) | |||
1477 | 1494 | ||
1478 | /* Some versions of the firmware don't support page 0; without | 1495 | /* Some versions of the firmware don't support page 0; without |
1479 | * that we can't get the parameters */ | 1496 | * that we can't get the parameters */ |
1480 | if (hd->ioc->spi_data.sdp0length != 0) | 1497 | if (ioc->spi_data.sdp0length != 0) |
1481 | sh->transportt = mptspi_transport_template; | 1498 | sh->transportt = mptspi_transport_template; |
1482 | 1499 | ||
1483 | error = scsi_add_host (sh, &ioc->pcidev->dev); | 1500 | error = scsi_add_host (sh, &ioc->pcidev->dev); |
1484 | if(error) { | 1501 | if(error) { |
1485 | dprintk(ioc, printk(KERN_ERR MYNAM | 1502 | dprintk(ioc, printk(MYIOC_s_ERR_FMT |
1486 | "scsi_add_host failed\n")); | 1503 | "scsi_add_host failed\n", ioc->name)); |
1487 | goto out_mptspi_probe; | 1504 | goto out_mptspi_probe; |
1488 | } | 1505 | } |
1489 | 1506 | ||