aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/message/fusion/mptsas.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/message/fusion/mptsas.c')
-rw-r--r--drivers/message/fusion/mptsas.c73
1 files changed, 35 insertions, 38 deletions
diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
index 09e9a9d96410..f7c5e0d97890 100644
--- a/drivers/message/fusion/mptsas.c
+++ b/drivers/message/fusion/mptsas.c
@@ -83,6 +83,12 @@ MODULE_PARM_DESC(mpt_pt_clear,
83 " Clear persistency table: enable=1 " 83 " Clear persistency table: enable=1 "
84 "(default=MPTSCSIH_PT_CLEAR=0)"); 84 "(default=MPTSCSIH_PT_CLEAR=0)");
85 85
86/* scsi-mid layer global parmeter is max_report_luns, which is 511 */
87#define MPTSAS_MAX_LUN (16895)
88static int max_lun = MPTSAS_MAX_LUN;
89module_param(max_lun, int, 0);
90MODULE_PARM_DESC(max_lun, " max lun, default=16895 ");
91
86static int mptsasDoneCtx = -1; 92static int mptsasDoneCtx = -1;
87static int mptsasTaskCtx = -1; 93static int mptsasTaskCtx = -1;
88static int mptsasInternalCtx = -1; /* Used only for internal commands */ 94static int mptsasInternalCtx = -1; /* Used only for internal commands */
@@ -568,12 +574,12 @@ mptsas_target_reset(MPT_ADAPTER *ioc, VirtTarget * vtarget)
568 574
569 if (mptscsih_TMHandler(hd, 575 if (mptscsih_TMHandler(hd,
570 MPI_SCSITASKMGMT_TASKTYPE_TARGET_RESET, 576 MPI_SCSITASKMGMT_TASKTYPE_TARGET_RESET,
571 vtarget->bus_id, vtarget->target_id, 0, 0, 5) < 0) { 577 vtarget->channel, vtarget->id, 0, 0, 5) < 0) {
572 hd->tmPending = 0; 578 hd->tmPending = 0;
573 hd->tmState = TM_STATE_NONE; 579 hd->tmState = TM_STATE_NONE;
574 printk(MYIOC_s_WARN_FMT 580 printk(MYIOC_s_WARN_FMT
575 "Error processing TaskMgmt id=%d TARGET_RESET\n", 581 "Error processing TaskMgmt id=%d TARGET_RESET\n",
576 ioc->name, vtarget->target_id); 582 ioc->name, vtarget->id);
577 } 583 }
578} 584}
579 585
@@ -661,8 +667,7 @@ mptsas_target_alloc(struct scsi_target *starget)
661 struct Scsi_Host *host = dev_to_shost(&starget->dev); 667 struct Scsi_Host *host = dev_to_shost(&starget->dev);
662 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata; 668 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata;
663 VirtTarget *vtarget; 669 VirtTarget *vtarget;
664 u32 target_id; 670 u8 id, channel;
665 u32 channel;
666 struct sas_rphy *rphy; 671 struct sas_rphy *rphy;
667 struct mptsas_portinfo *p; 672 struct mptsas_portinfo *p;
668 int i; 673 int i;
@@ -673,15 +678,19 @@ mptsas_target_alloc(struct scsi_target *starget)
673 678
674 vtarget->starget = starget; 679 vtarget->starget = starget;
675 vtarget->ioc_id = hd->ioc->id; 680 vtarget->ioc_id = hd->ioc->id;
676 vtarget->tflags = MPT_TARGET_FLAGS_Q_YES|MPT_TARGET_FLAGS_VALID_INQUIRY; 681 vtarget->tflags = MPT_TARGET_FLAGS_Q_YES;
677 682 id = starget->id;
678 target_id = starget->id;
679 channel = 0; 683 channel = 0;
680 684
681 hd->Targets[target_id] = vtarget; 685 /*
682 686 * RAID volumes placed beyond the last expected port.
683 if (starget->channel == MPTSAS_RAID_CHANNEL) 687 */
688 if (starget->channel == MPTSAS_RAID_CHANNEL) {
689 for (i=0; i < hd->ioc->raid_data.pIocPg2->NumActiveVolumes; i++)
690 if (id == hd->ioc->raid_data.pIocPg2->RaidVolume[i].VolumeID)
691 channel = hd->ioc->raid_data.pIocPg2->RaidVolume[i].VolumeBus;
684 goto out; 692 goto out;
693 }
685 694
686 rphy = dev_to_rphy(starget->dev.parent); 695 rphy = dev_to_rphy(starget->dev.parent);
687 mutex_lock(&hd->ioc->sas_topology_mutex); 696 mutex_lock(&hd->ioc->sas_topology_mutex);
@@ -690,16 +699,16 @@ mptsas_target_alloc(struct scsi_target *starget)
690 if (p->phy_info[i].attached.sas_address != 699 if (p->phy_info[i].attached.sas_address !=
691 rphy->identify.sas_address) 700 rphy->identify.sas_address)
692 continue; 701 continue;
693 target_id = p->phy_info[i].attached.id; 702 id = p->phy_info[i].attached.id;
694 channel = p->phy_info[i].attached.channel; 703 channel = p->phy_info[i].attached.channel;
695 mptsas_set_starget(&p->phy_info[i], starget); 704 mptsas_set_starget(&p->phy_info[i], starget);
696 705
697 /* 706 /*
698 * Exposing hidden raid components 707 * Exposing hidden raid components
699 */ 708 */
700 if (mptscsih_is_phys_disk(hd->ioc, target_id)) { 709 if (mptscsih_is_phys_disk(hd->ioc, channel, id)) {
701 target_id = mptscsih_raid_id_to_num(hd, 710 id = mptscsih_raid_id_to_num(hd->ioc,
702 target_id); 711 channel, id);
703 vtarget->tflags |= 712 vtarget->tflags |=
704 MPT_TARGET_FLAGS_RAID_COMPONENT; 713 MPT_TARGET_FLAGS_RAID_COMPONENT;
705 } 714 }
@@ -713,8 +722,8 @@ mptsas_target_alloc(struct scsi_target *starget)
713 return -ENXIO; 722 return -ENXIO;
714 723
715 out: 724 out:
716 vtarget->target_id = target_id; 725 vtarget->id = id;
717 vtarget->bus_id = channel; 726 vtarget->channel = channel;
718 starget->hostdata = vtarget; 727 starget->hostdata = vtarget;
719 return 0; 728 return 0;
720} 729}
@@ -786,7 +795,8 @@ mptsas_slave_alloc(struct scsi_device *sdev)
786 * Exposing hidden raid components 795 * Exposing hidden raid components
787 */ 796 */
788 if (mptscsih_is_phys_disk(hd->ioc, 797 if (mptscsih_is_phys_disk(hd->ioc,
789 p->phy_info[i].attached.id)) 798 p->phy_info[i].attached.channel,
799 p->phy_info[i].attached.id))
790 sdev->no_uld_attach = 1; 800 sdev->no_uld_attach = 1;
791 mutex_unlock(&hd->ioc->sas_topology_mutex); 801 mutex_unlock(&hd->ioc->sas_topology_mutex);
792 goto out; 802 goto out;
@@ -808,13 +818,14 @@ mptsas_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
808{ 818{
809 VirtDevice *vdev = SCpnt->device->hostdata; 819 VirtDevice *vdev = SCpnt->device->hostdata;
810 820
811// scsi_print_command(SCpnt); 821 if (!vdev || !vdev->vtarget || vdev->vtarget->deleted) {
812 if (vdev->vtarget->deleted) {
813 SCpnt->result = DID_NO_CONNECT << 16; 822 SCpnt->result = DID_NO_CONNECT << 16;
814 done(SCpnt); 823 done(SCpnt);
815 return 0; 824 return 0;
816 } 825 }
817 826
827// scsi_print_command(SCpnt);
828
818 return mptscsih_qcmd(SCpnt,done); 829 return mptscsih_qcmd(SCpnt,done);
819} 830}
820 831
@@ -1976,7 +1987,7 @@ mptsas_scan_sas_topology(MPT_ADAPTER *ioc)
1976 goto out; 1987 goto out;
1977 if (!ioc->raid_data.pIocPg2->NumActiveVolumes) 1988 if (!ioc->raid_data.pIocPg2->NumActiveVolumes)
1978 goto out; 1989 goto out;
1979 for (i=0; i<ioc->raid_data.pIocPg2->NumActiveVolumes; i++) { 1990 for (i = 0; i < ioc->raid_data.pIocPg2->NumActiveVolumes; i++) {
1980 scsi_add_device(ioc->sh, MPTSAS_RAID_CHANNEL, 1991 scsi_add_device(ioc->sh, MPTSAS_RAID_CHANNEL,
1981 ioc->raid_data.pIocPg2->RaidVolume[i].VolumeID, 0); 1992 ioc->raid_data.pIocPg2->RaidVolume[i].VolumeID, 0);
1982 } 1993 }
@@ -2160,7 +2171,7 @@ mptsas_hotplug_work(struct work_struct *work)
2160 * Handling RAID components 2171 * Handling RAID components
2161 */ 2172 */
2162 if (ev->phys_disk_num_valid) { 2173 if (ev->phys_disk_num_valid) {
2163 vtarget->target_id = ev->phys_disk_num; 2174 vtarget->id = ev->phys_disk_num;
2164 vtarget->tflags |= MPT_TARGET_FLAGS_RAID_COMPONENT; 2175 vtarget->tflags |= MPT_TARGET_FLAGS_RAID_COMPONENT;
2165 mptsas_reprobe_target(starget, 1); 2176 mptsas_reprobe_target(starget, 1);
2166 break; 2177 break;
@@ -2233,7 +2244,7 @@ mptsas_hotplug_work(struct work_struct *work)
2233 */ 2244 */
2234 if (vtarget->tflags & MPT_TARGET_FLAGS_RAID_COMPONENT) { 2245 if (vtarget->tflags & MPT_TARGET_FLAGS_RAID_COMPONENT) {
2235 vtarget->tflags &= ~MPT_TARGET_FLAGS_RAID_COMPONENT; 2246 vtarget->tflags &= ~MPT_TARGET_FLAGS_RAID_COMPONENT;
2236 vtarget->target_id = ev->id; 2247 vtarget->id = ev->id;
2237 mptsas_reprobe_target(starget, 0); 2248 mptsas_reprobe_target(starget, 0);
2238 } 2249 }
2239 break; 2250 break;
@@ -2611,12 +2622,11 @@ mptsas_probe(struct pci_dev *pdev, const struct pci_device_id *id)
2611 /* set 16 byte cdb's */ 2622 /* set 16 byte cdb's */
2612 sh->max_cmd_len = 16; 2623 sh->max_cmd_len = 16;
2613 2624
2614 sh->max_id = ioc->pfacts->MaxDevices + 1; 2625 sh->max_id = ioc->pfacts[0].PortSCSIID;
2626 sh->max_lun = max_lun;
2615 2627
2616 sh->transportt = mptsas_transport_template; 2628 sh->transportt = mptsas_transport_template;
2617 2629
2618 sh->max_lun = MPT_LAST_LUN + 1;
2619 sh->max_channel = 0;
2620 sh->this_id = ioc->pfacts[0].PortSCSIID; 2630 sh->this_id = ioc->pfacts[0].PortSCSIID;
2621 2631
2622 /* Required entry. 2632 /* Required entry.
@@ -2676,19 +2686,6 @@ mptsas_probe(struct pci_dev *pdev, const struct pci_device_id *id)
2676 dprintk((MYIOC_s_INFO_FMT "ScsiLookup @ %p\n", 2686 dprintk((MYIOC_s_INFO_FMT "ScsiLookup @ %p\n",
2677 ioc->name, hd->ScsiLookup)); 2687 ioc->name, hd->ScsiLookup));
2678 2688
2679 /* Allocate memory for the device structures.
2680 * A non-Null pointer at an offset
2681 * indicates a device exists.
2682 * max_id = 1 + maximum id (hosts.h)
2683 */
2684 hd->Targets = kcalloc(sh->max_id, sizeof(void *), GFP_ATOMIC);
2685 if (!hd->Targets) {
2686 error = -ENOMEM;
2687 goto out_mptsas_probe;
2688 }
2689
2690 dprintk((KERN_INFO " vtarget @ %p\n", hd->Targets));
2691
2692 /* Clear the TM flags 2689 /* Clear the TM flags
2693 */ 2690 */
2694 hd->tmPending = 0; 2691 hd->tmPending = 0;