]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/message/fusion/mptsas.c
Merge branch 'linus'
[linux-2.6-omap-h63xx.git] / drivers / message / fusion / mptsas.c
index f7bd8b11ed3be860feeffadc736aa6681e8d3724..09e9a9d96410942dcfe21bb2d0484ee8f0956693 100644 (file)
@@ -3,9 +3,9 @@
  *      For use with LSI Logic PCI chip/adapter(s)
  *      running LSI Logic Fusion MPT (Message Passing Technology) firmware.
  *
- *  Copyright (c) 1999-2005 LSI Logic Corporation
+ *  Copyright (c) 1999-2007 LSI Logic Corporation
  *  (mailto:mpt_linux_developer@lsil.com)
- *  Copyright (c) 2005-2006 Dell
+ *  Copyright (c) 2005-2007 Dell
  */
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
 /*
 #define my_VERSION     MPT_LINUX_VERSION_COMMON
 #define MYNAM          "mptsas"
 
+/*
+ * Reserved channel for integrated raid
+ */
+#define MPTSAS_RAID_CHANNEL    1
+
 MODULE_AUTHOR(MODULEAUTHOR);
 MODULE_DESCRIPTION(my_NAME);
 MODULE_LICENSE("GPL");
-
-static int mpt_pq_filter;
-module_param(mpt_pq_filter, int, 0);
-MODULE_PARM_DESC(mpt_pq_filter,
-               "Enable peripheral qualifier filter: enable=1  "
-               "(default=0)");
+MODULE_VERSION(my_VERSION);
 
 static int mpt_pt_clear;
 module_param(mpt_pt_clear, int, 0);
 MODULE_PARM_DESC(mpt_pt_clear,
-               "Clear persistency table: enable=1  "
+               " Clear persistency table: enable=1  "
                "(default=MPTSCSIH_PT_CLEAR=0)");
 
 static int     mptsasDoneCtx = -1;
@@ -144,7 +144,6 @@ struct mptsas_devinfo {
  * Specific details on ports, wide/narrow
  */
 struct mptsas_portinfo_details{
-       u8      port_id;        /* port number provided to transport */
        u16     num_phys;       /* number of phys belong to this port */
        u64     phy_bitmask;    /* TODO, extend support for 255 phys */
        struct sas_rphy *rphy;  /* transport layer rphy object */
@@ -247,7 +246,8 @@ static void mptsas_print_device_pg0(SasDevicePage0_t *pg0)
        printk("Parent Handle=0x%X\n" ,le16_to_cpu(pg0->ParentDevHandle));
        printk("Enclosure Handle=0x%X\n", le16_to_cpu(pg0->EnclosureHandle));
        printk("Slot=0x%X\n", le16_to_cpu(pg0->Slot));
-       printk("SAS Address=0x%llX\n", le64_to_cpu(sas_address));
+       printk("SAS Address=0x%llX\n", (unsigned long long)
+           le64_to_cpu(sas_address));
        printk("Target ID=0x%X\n", pg0->TargetID);
        printk("Bus=0x%X\n", pg0->Bus);
        /* The PhyNum field specifies the PHY number of the parent
@@ -350,10 +350,10 @@ mptsas_port_delete(struct mptsas_portinfo_details * port_details)
        port_info = port_details->port_info;
        phy_info = port_info->phy_info;
 
-       dsaswideprintk((KERN_DEBUG "%s: [%p]: port=%02d num_phys=%02d "
-               "bitmask=0x%016llX\n",
-               __FUNCTION__, port_details, port_details->port_id,
-               port_details->num_phys, port_details->phy_bitmask));
+       dsaswideprintk((KERN_DEBUG "%s: [%p]: num_phys=%02d "
+           "bitmask=0x%016llX\n", __FUNCTION__, port_details,
+           port_details->num_phys, (unsigned long long)
+           port_details->phy_bitmask));
 
        for (i = 0; i < port_info->num_phys; i++, phy_info++) {
                if(phy_info->port_details != port_details)
@@ -462,9 +462,8 @@ mptsas_setup_wide_ports(MPT_ADAPTER *ioc, struct mptsas_portinfo *port_info)
                 * phy be removed by firmware events.
                 */
                dsaswideprintk((KERN_DEBUG
-                       "%s: [%p]: port=%d deleting phy = %d\n",
-                       __FUNCTION__, port_details,
-                       port_details->port_id, i));
+                       "%s: [%p]: deleting phy = %d\n",
+                       __FUNCTION__, port_details, i));
                port_details->num_phys--;
                port_details->phy_bitmask &= ~ (1 << phy_info->phy_id);
                memset(&phy_info->attached, 0, sizeof(struct mptsas_devinfo));
@@ -479,7 +478,7 @@ mptsas_setup_wide_ports(MPT_ADAPTER *ioc, struct mptsas_portinfo *port_info)
        for (i = 0 ; i < port_info->num_phys ; i++, phy_info++) {
                sas_address = phy_info->attached.sas_address;
                dsaswideprintk((KERN_DEBUG "phy_id=%d sas_address=0x%018llX\n",
-                       i, sas_address));
+                   i, (unsigned long long)sas_address));
                if (!sas_address)
                        continue;
                port_details = phy_info->port_details;
@@ -493,14 +492,13 @@ mptsas_setup_wide_ports(MPT_ADAPTER *ioc, struct mptsas_portinfo *port_info)
                                goto out;
                        port_details->num_phys = 1;
                        port_details->port_info = port_info;
-                       port_details->port_id = ioc->port_serial_number++;
                        if (phy_info->phy_id < 64 )
                                port_details->phy_bitmask |=
                                    (1 << phy_info->phy_id);
                        phy_info->sas_port_add_phy=1;
                        dsaswideprintk((KERN_DEBUG "\t\tForming port\n\t\t"
-                               "phy_id=%d sas_address=0x%018llX\n",
-                               i, sas_address));
+                           "phy_id=%d sas_address=0x%018llX\n",
+                           i, (unsigned long long)sas_address));
                        phy_info->port_details = port_details;
                }
 
@@ -516,8 +514,9 @@ mptsas_setup_wide_ports(MPT_ADAPTER *ioc, struct mptsas_portinfo *port_info)
                        if (phy_info_cmp->port_details == port_details )
                                continue;
                        dsaswideprintk((KERN_DEBUG
-                               "\t\tphy_id=%d sas_address=0x%018llX\n",
-                               j, phy_info_cmp->attached.sas_address));
+                           "\t\tphy_id=%d sas_address=0x%018llX\n",
+                           j, (unsigned long long)
+                           phy_info_cmp->attached.sas_address));
                        if (phy_info_cmp->port_details) {
                                port_details->rphy =
                                    mptsas_get_rphy(phy_info_cmp);
@@ -525,12 +524,8 @@ mptsas_setup_wide_ports(MPT_ADAPTER *ioc, struct mptsas_portinfo *port_info)
                                    mptsas_get_port(phy_info_cmp);
                                port_details->starget =
                                    mptsas_get_starget(phy_info_cmp);
-                               port_details->port_id =
-                                       phy_info_cmp->port_details->port_id;
                                port_details->num_phys =
                                        phy_info_cmp->port_details->num_phys;
-//                             port_info->port_serial_number--;
-                               ioc->port_serial_number--;
                                if (!phy_info_cmp->port_details->num_phys)
                                        kfree(phy_info_cmp->port_details);
                        } else
@@ -554,11 +549,10 @@ mptsas_setup_wide_ports(MPT_ADAPTER *ioc, struct mptsas_portinfo *port_info)
                if (!port_details)
                        continue;
                dsaswideprintk((KERN_DEBUG
-                       "%s: [%p]: phy_id=%02d port_id=%02d num_phys=%02d "
-                       "bitmask=0x%016llX\n",
-                       __FUNCTION__,
-                       port_details, i, port_details->port_id,
-                       port_details->num_phys, port_details->phy_bitmask));
+                   "%s: [%p]: phy_id=%02d num_phys=%02d "
+                   "bitmask=0x%016llX\n", __FUNCTION__,
+                   port_details, i, port_details->num_phys,
+                   (unsigned long long)port_details->phy_bitmask));
                dsaswideprintk((KERN_DEBUG"\t\tport = %p rphy=%p\n",
                        port_details->port, port_details->rphy));
        }
@@ -651,16 +645,13 @@ mptsas_sas_enclosure_pg0(MPT_ADAPTER *ioc, struct mptsas_enclosure *enclosure,
 static int
 mptsas_slave_configure(struct scsi_device *sdev)
 {
-       struct Scsi_Host        *host = sdev->host;
-       MPT_SCSI_HOST           *hd = (MPT_SCSI_HOST *)host->hostdata;
 
-       /*
-        * RAID volumes placed beyond the last expected port.
-        * Ignore sending sas mode pages in that case..
-        */
-       if (sdev->channel < hd->ioc->num_ports)
-               sas_read_port_mode_page(sdev);
+       if (sdev->channel == MPTSAS_RAID_CHANNEL)
+               goto out;
+
+       sas_read_port_mode_page(sdev);
 
+ out:
        return mptscsih_slave_configure(sdev);
 }
 
@@ -689,10 +680,7 @@ mptsas_target_alloc(struct scsi_target *starget)
 
        hd->Targets[target_id] = vtarget;
 
-       /*
-        * RAID volumes placed beyond the last expected port.
-        */
-       if (starget->channel == hd->ioc->num_ports)
+       if (starget->channel == MPTSAS_RAID_CHANNEL)
                goto out;
 
        rphy = dev_to_rphy(starget->dev.parent);
@@ -743,7 +731,7 @@ mptsas_target_destroy(struct scsi_target *starget)
        if (!starget->hostdata)
                return;
 
-       if (starget->channel == hd->ioc->num_ports)
+       if (starget->channel == MPTSAS_RAID_CHANNEL)
                goto out;
 
        rphy = dev_to_rphy(starget->dev.parent);
@@ -783,10 +771,7 @@ mptsas_slave_alloc(struct scsi_device *sdev)
        starget = scsi_target(sdev);
        vdev->vtarget = starget->hostdata;
 
-       /*
-        * RAID volumes placed beyond the last expected port.
-        */
-       if (sdev->channel == hd->ioc->num_ports)
+       if (sdev->channel == MPTSAS_RAID_CHANNEL)
                goto out;
 
        rphy = dev_to_rphy(sdev->sdev_target->dev.parent);
@@ -869,6 +854,10 @@ static int mptsas_get_linkerrors(struct sas_phy *phy)
        dma_addr_t dma_handle;
        int error;
 
+       /* FIXME: only have link errors on local phys */
+       if (!scsi_is_sas_phy_local(phy))
+               return -EINVAL;
+
        hdr.PageVersion = MPI_SASPHY1_PAGEVERSION;
        hdr.ExtPageLength = 0;
        hdr.PageNumber = 1 /* page number 1*/;
@@ -941,6 +930,10 @@ static int mptsas_phy_reset(struct sas_phy *phy, int hard_reset)
        unsigned long timeleft;
        int error = -ERESTARTSYS;
 
+       /* FIXME: fusion doesn't allow non-local phy reset */
+       if (!scsi_is_sas_phy_local(phy))
+               return -EINVAL;
+
        /* not implemented for expanders */
        if (phy->identify.target_port_protocols & SAS_PROTOCOL_SMP)
                return -ENXIO;
@@ -1587,9 +1580,6 @@ static int mptsas_probe_one_phy(struct device *dev,
 
        if (!phy_info->phy) {
 
-               if (local)
-                       phy->local_attached = 1;
-
                error = sas_phy_add(phy);
                if (error) {
                        sas_phy_free(phy);
@@ -1608,11 +1598,7 @@ static int mptsas_probe_one_phy(struct device *dev,
        if (phy_info->sas_port_add_phy) {
 
                if (!port) {
-                       port = sas_port_alloc(dev,
-                           phy_info->port_details->port_id);
-                       dsaswideprintk((KERN_DEBUG
-                           "sas_port_alloc: port=%p dev=%p port_id=%d\n",
-                           port, dev, phy_info->port_details->port_id));
+                       port = sas_port_alloc_num(dev);
                        if (!port) {
                                error = -ENOMEM;
                                goto out;
@@ -1625,6 +1611,9 @@ static int mptsas_probe_one_phy(struct device *dev,
                                goto out;
                        }
                        mptsas_set_port(phy_info, port);
+                       dsaswideprintk((KERN_DEBUG
+                           "sas_port_alloc: port=%p dev=%p port_id=%d\n",
+                           port, dev, port->port_identifier));
                }
                dsaswideprintk((KERN_DEBUG "sas_port_add_phy: phy_id=%d\n",
                    phy_info->phy_id));
@@ -1660,14 +1649,18 @@ static int mptsas_probe_one_phy(struct device *dev,
 
                        for (i = 0; i < port_info->num_phys; i++)
                                if (port_info->phy_info[i].identify.sas_address ==
-                                   identify.sas_address)
+                                   identify.sas_address) {
+                                       sas_port_mark_backlink(port);
                                        goto out;
+                               }
 
                } else if (scsi_is_sas_rphy(parent)) {
                        struct sas_rphy *parent_rphy = dev_to_rphy(parent);
                        if (identify.sas_address ==
-                           parent_rphy->identify.sas_address)
+                           parent_rphy->identify.sas_address) {
+                               sas_port_mark_backlink(port);
                                goto out;
+                       }
                }
 
                switch (identify.device_type) {
@@ -1736,7 +1729,6 @@ mptsas_probe_hba_phys(MPT_ADAPTER *ioc)
                hba = NULL;
        }
        mutex_unlock(&ioc->sas_topology_mutex);
-       ioc->num_ports = port_info->num_phys;
 
        for (i = 0; i < port_info->num_phys; i++) {
                mptsas_sas_phy_pg0(ioc, &port_info->phy_info[i],
@@ -1939,7 +1931,8 @@ mptsas_delete_expander_phys(MPT_ADAPTER *ioc)
                                        expander_sas_address)
                                        continue;
 #ifdef MPT_DEBUG_SAS_WIDE
-                               dev_printk(KERN_DEBUG, &port->dev, "delete\n");
+                               dev_printk(KERN_DEBUG, &port->dev,
+                                   "delete port (%d)\n", port->port_identifier);
 #endif
                                sas_port_delete(port);
                                mptsas_port_delete(phy_info->port_details);
@@ -1984,7 +1977,7 @@ mptsas_scan_sas_topology(MPT_ADAPTER *ioc)
        if (!ioc->raid_data.pIocPg2->NumActiveVolumes)
                goto out;
        for (i=0; i<ioc->raid_data.pIocPg2->NumActiveVolumes; i++) {
-               scsi_add_device(ioc->sh, ioc->num_ports,
+               scsi_add_device(ioc->sh, MPTSAS_RAID_CHANNEL,
                    ioc->raid_data.pIocPg2->RaidVolume[i].VolumeID, 0);
        }
  out:
@@ -2015,9 +2008,10 @@ __mptsas_discovery_work(MPT_ADAPTER *ioc)
  *(Mutex LOCKED)
  */
 static void
-mptsas_discovery_work(void * arg)
+mptsas_discovery_work(struct work_struct *work)
 {
-       struct mptsas_discovery_event *ev = arg;
+       struct mptsas_discovery_event *ev =
+               container_of(work, struct mptsas_discovery_event, work);
        MPT_ADAPTER *ioc = ev->ioc;
 
        mutex_lock(&ioc->sas_discovery_mutex);
@@ -2077,9 +2071,9 @@ mptsas_find_phyinfo_by_target(MPT_ADAPTER *ioc, u32 id)
  * Work queue thread to clear the persitency table
  */
 static void
-mptsas_persist_clear_table(void * arg)
+mptsas_persist_clear_table(struct work_struct *work)
 {
-       MPT_ADAPTER *ioc = (MPT_ADAPTER *)arg;
+       MPT_ADAPTER *ioc = container_of(work, MPT_ADAPTER, sas_persist_task);
 
        mptbase_sas_persist_operation(ioc, MPI_SAS_OP_CLEAR_NOT_PRESENT);
 }
@@ -2087,8 +2081,10 @@ mptsas_persist_clear_table(void * arg)
 static void
 mptsas_reprobe_lun(struct scsi_device *sdev, void *data)
 {
+       int rc;
+
        sdev->no_uld_attach = data ? 1 : 0;
-       scsi_device_reprobe(sdev);
+       rc = scsi_device_reprobe(sdev);
 }
 
 static void
@@ -2102,9 +2098,10 @@ mptsas_reprobe_target(struct scsi_target *starget, int uld_attach)
  * Work queue thread to handle SAS hotplug events
  */
 static void
-mptsas_hotplug_work(void *arg)
+mptsas_hotplug_work(struct work_struct *work)
 {
-       struct mptsas_hotplug_event *ev = arg;
+       struct mptsas_hotplug_event *ev =
+               container_of(work, struct mptsas_hotplug_event, work);
        MPT_ADAPTER *ioc = ev->ioc;
        struct mptsas_phyinfo *phy_info;
        struct sas_rphy *rphy;
@@ -2185,7 +2182,8 @@ mptsas_hotplug_work(void *arg)
                       ioc->name, ds, ev->channel, ev->id, phy_info->phy_id);
 
 #ifdef MPT_DEBUG_SAS_WIDE
-               dev_printk(KERN_DEBUG, &port->dev, "delete\n");
+               dev_printk(KERN_DEBUG, &port->dev,
+                   "delete port (%d)\n", port->port_identifier);
 #endif
                sas_port_delete(port);
                mptsas_port_delete(phy_info->port_details);
@@ -2289,35 +2287,26 @@ mptsas_hotplug_work(void *arg)
                mptsas_set_rphy(phy_info, rphy);
                break;
        case MPTSAS_ADD_RAID:
-               sdev = scsi_device_lookup(
-                       ioc->sh,
-                       ioc->num_ports,
-                       ev->id,
-                       0);
+               sdev = scsi_device_lookup(ioc->sh, MPTSAS_RAID_CHANNEL,
+                   ev->id, 0);
                if (sdev) {
                        scsi_device_put(sdev);
                        break;
                }
                printk(MYIOC_s_INFO_FMT
                       "attaching raid volume, channel %d, id %d\n",
-                      ioc->name, ioc->num_ports, ev->id);
-               scsi_add_device(ioc->sh,
-                       ioc->num_ports,
-                       ev->id,
-                       0);
+                      ioc->name, MPTSAS_RAID_CHANNEL, ev->id);
+               scsi_add_device(ioc->sh, MPTSAS_RAID_CHANNEL, ev->id, 0);
                mpt_findImVolumes(ioc);
                break;
        case MPTSAS_DEL_RAID:
-               sdev = scsi_device_lookup(
-                       ioc->sh,
-                       ioc->num_ports,
-                       ev->id,
-                       0);
+               sdev = scsi_device_lookup(ioc->sh, MPTSAS_RAID_CHANNEL,
+                   ev->id, 0);
                if (!sdev)
                        break;
                printk(MYIOC_s_INFO_FMT
                       "removing raid volume, channel %d, id %d\n",
-                      ioc->name, ioc->num_ports, ev->id);
+                      ioc->name, MPTSAS_RAID_CHANNEL, ev->id);
                vdevice = sdev->hostdata;
                vdevice->vtarget->deleted = 1;
                mptsas_target_reset(ioc, vdevice->vtarget);
@@ -2358,7 +2347,7 @@ mptsas_send_sas_event(MPT_ADAPTER *ioc,
                        break;
                }
 
-               INIT_WORK(&ev->work, mptsas_hotplug_work, ev);
+               INIT_WORK(&ev->work, mptsas_hotplug_work);
                ev->ioc = ioc;
                ev->handle = le16_to_cpu(sas_event_data->DevHandle);
                ev->parent_handle =
@@ -2383,7 +2372,7 @@ mptsas_send_sas_event(MPT_ADAPTER *ioc,
         * Persistent table is full.
         */
                INIT_WORK(&ioc->sas_persist_task,
-                   mptsas_persist_clear_table, (void *)ioc);
+                   mptsas_persist_clear_table);
                schedule_work(&ioc->sas_persist_task);
                break;
        case MPI_EVENT_SAS_DEV_STAT_RC_SMART_DATA:
@@ -2412,7 +2401,7 @@ mptsas_send_raid_event(MPT_ADAPTER *ioc,
                return;
        }
 
-       INIT_WORK(&ev->work, mptsas_hotplug_work, ev);
+       INIT_WORK(&ev->work, mptsas_hotplug_work);
        ev->ioc = ioc;
        ev->id = raid_event_data->VolumeID;
        ev->event_type = MPTSAS_IGNORE_EVENT;
@@ -2491,7 +2480,7 @@ mptsas_send_discovery_event(MPT_ADAPTER *ioc,
        ev = kzalloc(sizeof(*ev), GFP_ATOMIC);
        if (!ev)
                return;
-       INIT_WORK(&ev->work, mptsas_discovery_work, ev);
+       INIT_WORK(&ev->work, mptsas_discovery_work);
        ev->ioc = ioc;
        schedule_work(&ev->work);
 };
@@ -2528,8 +2517,7 @@ mptsas_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *reply)
                break;
        case MPI_EVENT_PERSISTENT_TABLE_FULL:
                INIT_WORK(&ioc->sas_persist_task,
-                   mptsas_persist_clear_table,
-                   (void *)ioc);
+                   mptsas_persist_clear_table);
                schedule_work(&ioc->sas_persist_task);
                break;
         case MPI_EVENT_SAS_DISCOVERY:
@@ -2723,7 +2711,6 @@ mptsas_probe(struct pci_dev *pdev, const struct pci_device_id *id)
        hd->timer.data = (unsigned long) hd;
        hd->timer.function = mptscsih_timer_expired;
 
-       hd->mpt_pq_filter = mpt_pq_filter;
        ioc->sas_data.ptClear = mpt_pt_clear;
 
        if (ioc->sas_data.ptClear==1) {
@@ -2731,12 +2718,6 @@ mptsas_probe(struct pci_dev *pdev, const struct pci_device_id *id)
                    ioc, MPI_SAS_OP_CLEAR_ALL_PERSISTENT);
        }
 
-       ddvprintk((MYIOC_s_INFO_FMT
-               "mpt_pq_filter %x mpt_pq_filter %x\n",
-               ioc->name,
-               mpt_pq_filter,
-               mpt_pq_filter));
-
        init_waitqueue_head(&hd->scandv_waitq);
        hd->scandv_wait_done = 0;
        hd->last_queue_full = 0;