Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/aegl/linux-2.6
[deliverable/linux.git] / drivers / scsi / qla2xxx / qla_init.c
index 401a8798ce5247f7145a5b7787e472e18057e5de..191dafd89be080763c520bfef2b41e62bba8d0f7 100644 (file)
@@ -129,14 +129,13 @@ qla2x00_initialize_adapter(scsi_qla_host_t *ha)
 int
 qla2100_pci_config(scsi_qla_host_t *ha)
 {
-       int ret;
        uint16_t w;
        uint32_t d;
        unsigned long flags;
        struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
 
        pci_set_master(ha->pdev);
-       ret = pci_set_mwi(ha->pdev);
+       pci_try_set_mwi(ha->pdev);
 
        pci_read_config_word(ha->pdev, PCI_COMMAND, &w);
        w |= (PCI_COMMAND_PARITY | PCI_COMMAND_SERR);
@@ -164,7 +163,6 @@ qla2100_pci_config(scsi_qla_host_t *ha)
 int
 qla2300_pci_config(scsi_qla_host_t *ha)
 {
-       int             ret;
        uint16_t        w;
        uint32_t        d;
        unsigned long   flags = 0;
@@ -172,7 +170,7 @@ qla2300_pci_config(scsi_qla_host_t *ha)
        struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
 
        pci_set_master(ha->pdev);
-       ret = pci_set_mwi(ha->pdev);
+       pci_try_set_mwi(ha->pdev);
 
        pci_read_config_word(ha->pdev, PCI_COMMAND, &w);
        w |= (PCI_COMMAND_PARITY | PCI_COMMAND_SERR);
@@ -250,15 +248,13 @@ qla2300_pci_config(scsi_qla_host_t *ha)
 int
 qla24xx_pci_config(scsi_qla_host_t *ha)
 {
-       int ret;
        uint16_t w;
        uint32_t d;
        unsigned long flags = 0;
        struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
-       int pcix_cmd_reg, pcie_dctl_reg;
 
        pci_set_master(ha->pdev);
-       ret = pci_set_mwi(ha->pdev);
+       pci_try_set_mwi(ha->pdev);
 
        pci_read_config_word(ha->pdev, PCI_COMMAND, &w);
        w |= (PCI_COMMAND_PARITY | PCI_COMMAND_SERR);
@@ -268,28 +264,12 @@ qla24xx_pci_config(scsi_qla_host_t *ha)
        pci_write_config_byte(ha->pdev, PCI_LATENCY_TIMER, 0x80);
 
        /* PCI-X -- adjust Maximum Memory Read Byte Count (2048). */
-       pcix_cmd_reg = pci_find_capability(ha->pdev, PCI_CAP_ID_PCIX);
-       if (pcix_cmd_reg) {
-               uint16_t pcix_cmd;
-
-               pcix_cmd_reg += PCI_X_CMD;
-               pci_read_config_word(ha->pdev, pcix_cmd_reg, &pcix_cmd);
-               pcix_cmd &= ~PCI_X_CMD_MAX_READ;
-               pcix_cmd |= 0x0008;
-               pci_write_config_word(ha->pdev, pcix_cmd_reg, pcix_cmd);
-       }
+       if (pci_find_capability(ha->pdev, PCI_CAP_ID_PCIX))
+               pcix_set_mmrbc(ha->pdev, 2048);
 
        /* PCIe -- adjust Maximum Read Request Size (2048). */
-       pcie_dctl_reg = pci_find_capability(ha->pdev, PCI_CAP_ID_EXP);
-       if (pcie_dctl_reg) {
-               uint16_t pcie_dctl;
-
-               pcie_dctl_reg += PCI_EXP_DEVCTL;
-               pci_read_config_word(ha->pdev, pcie_dctl_reg, &pcie_dctl);
-               pcie_dctl &= ~PCI_EXP_DEVCTL_READRQ;
-               pcie_dctl |= 0x4000;
-               pci_write_config_word(ha->pdev, pcie_dctl_reg, pcie_dctl);
-       }
+       if (pci_find_capability(ha->pdev, PCI_CAP_ID_EXP))
+               pcie_set_readrq(ha->pdev, 2048);
 
        /* Reset expansion ROM address decode enable */
        pci_read_config_dword(ha->pdev, PCI_ROM_ADDRESS, &d);
@@ -306,6 +286,40 @@ qla24xx_pci_config(scsi_qla_host_t *ha)
        return QLA_SUCCESS;
 }
 
+/**
+ * qla25xx_pci_config() - Setup ISP25xx PCI configuration registers.
+ * @ha: HA context
+ *
+ * Returns 0 on success.
+ */
+int
+qla25xx_pci_config(scsi_qla_host_t *ha)
+{
+       uint16_t w;
+       uint32_t d;
+
+       pci_set_master(ha->pdev);
+       pci_try_set_mwi(ha->pdev);
+
+       pci_read_config_word(ha->pdev, PCI_COMMAND, &w);
+       w |= (PCI_COMMAND_PARITY | PCI_COMMAND_SERR);
+       w &= ~PCI_COMMAND_INTX_DISABLE;
+       pci_write_config_word(ha->pdev, PCI_COMMAND, w);
+
+       /* PCIe -- adjust Maximum Read Request Size (2048). */
+       if (pci_find_capability(ha->pdev, PCI_CAP_ID_EXP))
+               pcie_set_readrq(ha->pdev, 2048);
+
+       /* Reset expansion ROM address decode enable */
+       pci_read_config_dword(ha->pdev, PCI_ROM_ADDRESS, &d);
+       d &= ~PCI_ROM_ADDRESS_ENABLE;
+       pci_write_config_dword(ha->pdev, PCI_ROM_ADDRESS, d);
+
+       ha->chip_revision = ha->pdev->revision;
+
+       return QLA_SUCCESS;
+}
+
 /**
  * qla2x00_isp_firmware() - Choose firmware image.
  * @ha: HA context
@@ -737,7 +751,9 @@ qla2x00_alloc_fw_dump(scsi_qla_host_t *ha)
                mem_size = (ha->fw_memory_size - 0x11000 + 1) *
                    sizeof(uint16_t);
        } else if (IS_FWI2_CAPABLE(ha)) {
-               fixed_size = offsetof(struct qla24xx_fw_dump, ext_mem);
+               fixed_size = IS_QLA25XX(ha) ?
+                   offsetof(struct qla25xx_fw_dump, ext_mem):
+                   offsetof(struct qla24xx_fw_dump, ext_mem);
                mem_size = (ha->fw_memory_size - 0x100000 + 1) *
                    sizeof(uint32_t);
 
@@ -833,7 +849,8 @@ qla2x00_resize_request_q(scsi_qla_host_t *ha)
                return;
 
        /* Retrieve IOCB counts available to the firmware. */
-       rval = qla2x00_get_resource_cnts(ha, NULL, NULL, NULL, &fw_iocb_cnt);
+       rval = qla2x00_get_resource_cnts(ha, NULL, NULL, NULL, &fw_iocb_cnt,
+           &ha->max_npiv_vports);
        if (rval)
                return;
        /* No point in continuing if current settings are sufficient. */
@@ -900,9 +917,15 @@ qla2x00_setup_chip(scsi_qla_host_t *ha)
                                    &ha->fw_attributes, &ha->fw_memory_size);
                                qla2x00_resize_request_q(ha);
                                ha->flags.npiv_supported = 0;
-                               if (IS_QLA24XX(ha) &&
-                                   (ha->fw_attributes & BIT_2))
+                               if ((IS_QLA24XX(ha) || IS_QLA25XX(ha)) &&
+                                   (ha->fw_attributes & BIT_2)) {
                                        ha->flags.npiv_supported = 1;
+                                       if ((!ha->max_npiv_vports) ||
+                                           ((ha->max_npiv_vports + 1) %
+                                           MAX_MULTI_ID_FABRIC))
+                                               ha->max_npiv_vports =
+                                                   MAX_NUM_VPORT_FABRIC;
+                               }
 
                                if (ql2xallocfwdump)
                                        qla2x00_alloc_fw_dump(ha);
@@ -1139,8 +1162,7 @@ qla2x00_init_rings(scsi_qla_host_t *ha)
 
        DEBUG(printk("scsi(%ld): Issue init firmware.\n", ha->host_no));
 
-       mid_init_cb->count = MAX_NUM_VPORT_FABRIC;
-       ha->max_npiv_vports = MAX_NUM_VPORT_FABRIC;
+       mid_init_cb->count = ha->max_npiv_vports;
 
        rval = qla2x00_init_firmware(ha, ha->init_cb_size);
        if (rval) {
@@ -1445,8 +1467,8 @@ qla2x00_nvram_config(scsi_qla_host_t *ha)
        uint16_t        cnt;
        uint8_t         *dptr1, *dptr2;
        init_cb_t       *icb = ha->init_cb;
-       nvram_t         *nv = (nvram_t *)ha->request_ring;
-       uint8_t         *ptr = (uint8_t *)ha->request_ring;
+       nvram_t         *nv = ha->nvram;
+       uint8_t         *ptr = ha->nvram;
        struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
 
        rval = QLA_SUCCESS;
@@ -1464,8 +1486,7 @@ qla2x00_nvram_config(scsi_qla_host_t *ha)
                chksum += *ptr++;
 
        DEBUG5(printk("scsi(%ld): Contents of NVRAM\n", ha->host_no));
-       DEBUG5(qla2x00_dump_buffer((uint8_t *)ha->request_ring,
-           ha->nvram_size));
+       DEBUG5(qla2x00_dump_buffer((uint8_t *)nv, ha->nvram_size));
 
        /* Bad NVRAM data, set defaults parameters. */
        if (chksum || nv->id[0] != 'I' || nv->id[1] != 'S' ||
@@ -1771,12 +1792,11 @@ qla2x00_alloc_fcport(scsi_qla_host_t *ha, gfp_t flags)
 {
        fc_port_t *fcport;
 
-       fcport = kmalloc(sizeof(fc_port_t), flags);
-       if (fcport == NULL)
-               return (fcport);
+       fcport = kzalloc(sizeof(fc_port_t), flags);
+       if (!fcport)
+               return NULL;
 
        /* Setup fcport template structure. */
-       memset(fcport, 0, sizeof (fc_port_t));
        fcport->ha = ha;
        fcport->vp_idx = ha->vp_idx;
        fcport->port_type = FCT_UNKNOWN;
@@ -1786,7 +1806,7 @@ qla2x00_alloc_fcport(scsi_qla_host_t *ha, gfp_t flags)
        fcport->supported_classes = FC_COS_UNSPECIFIED;
        spin_lock_init(&fcport->rport_lock);
 
-       return (fcport);
+       return fcport;
 }
 
 /*
@@ -2064,17 +2084,7 @@ qla2x00_configure_local_loop(scsi_qla_host_t *ha)
                }
 
                /* Base iIDMA settings on HBA port speed. */
-               switch (ha->link_data_rate) {
-               case PORT_SPEED_1GB:
-                       fcport->fp_speed = cpu_to_be16(BIT_15);
-                       break;
-               case PORT_SPEED_2GB:
-                       fcport->fp_speed = cpu_to_be16(BIT_14);
-                       break;
-               case PORT_SPEED_4GB:
-                       fcport->fp_speed = cpu_to_be16(BIT_13);
-                       break;
-               }
+               fcport->fp_speed = ha->link_data_rate;
 
                qla2x00_update_fcport(ha, fcport);
 
@@ -2115,38 +2125,19 @@ static void
 qla2x00_iidma_fcport(scsi_qla_host_t *ha, fc_port_t *fcport)
 {
 #define LS_UNKNOWN      2
-       static char *link_speeds[5] = { "1", "2", "?", "4" };
+       static char *link_speeds[5] = { "1", "2", "?", "4", "8" };
        int rval;
-       uint16_t port_speed, mb[6];
+       uint16_t mb[6];
 
        if (!IS_IIDMA_CAPABLE(ha))
                return;
 
-       switch (be16_to_cpu(fcport->fp_speed)) {
-       case BIT_15:
-               port_speed = PORT_SPEED_1GB;
-               break;
-       case BIT_14:
-               port_speed = PORT_SPEED_2GB;
-               break;
-       case BIT_13:
-               port_speed = PORT_SPEED_4GB;
-               break;
-       default:
-               DEBUG2(printk("scsi(%ld): %02x%02x%02x%02x%02x%02x%02x%02x -- "
-                   "unsupported FM port operating speed (%04x).\n",
-                   ha->host_no, fcport->port_name[0], fcport->port_name[1],
-                   fcport->port_name[2], fcport->port_name[3],
-                   fcport->port_name[4], fcport->port_name[5],
-                   fcport->port_name[6], fcport->port_name[7],
-                   be16_to_cpu(fcport->fp_speed)));
-               port_speed = PORT_SPEED_UNKNOWN;
-               break;
-       }
-       if (port_speed == PORT_SPEED_UNKNOWN)
+       if (fcport->fp_speed == PORT_SPEED_UNKNOWN ||
+           fcport->fp_speed > ha->link_data_rate)
                return;
 
-       rval = qla2x00_set_idma_speed(ha, fcport->loop_id, port_speed, mb);
+       rval = qla2x00_set_idma_speed(ha, fcport->loop_id, fcport->fp_speed,
+           mb);
        if (rval != QLA_SUCCESS) {
                DEBUG2(printk("scsi(%ld): Unable to adjust iIDMA "
                    "%02x%02x%02x%02x%02x%02x%02x%02x -- %04x %x %04x %04x.\n",
@@ -2154,12 +2145,12 @@ qla2x00_iidma_fcport(scsi_qla_host_t *ha, fc_port_t *fcport)
                    fcport->port_name[2], fcport->port_name[3],
                    fcport->port_name[4], fcport->port_name[5],
                    fcport->port_name[6], fcport->port_name[7], rval,
-                   port_speed, mb[0], mb[1]));
+                   fcport->fp_speed, mb[0], mb[1]));
        } else {
                DEBUG2(qla_printk(KERN_INFO, ha,
                    "iIDMA adjusted to %s GB/s on "
                    "%02x%02x%02x%02x%02x%02x%02x%02x.\n",
-                   link_speeds[port_speed], fcport->port_name[0],
+                   link_speeds[fcport->fp_speed], fcport->port_name[0],
                    fcport->port_name[1], fcport->port_name[2],
                    fcport->port_name[3], fcport->port_name[4],
                    fcport->port_name[5], fcport->port_name[6],
@@ -2481,13 +2472,12 @@ qla2x00_find_all_fabric_devs(scsi_qla_host_t *ha, struct list_head *new_fcports)
        rval = QLA_SUCCESS;
 
        /* Try GID_PT to get device list, else GAN. */
-       swl = kmalloc(sizeof(sw_info_t) * MAX_FIBRE_DEVICES, GFP_ATOMIC);
-       if (swl == NULL) {
+       swl = kcalloc(MAX_FIBRE_DEVICES, sizeof(sw_info_t), GFP_ATOMIC);
+       if (!swl) {
                /*EMPTY*/
                DEBUG2(printk("scsi(%ld): GID_PT allocations failed, fallback "
                    "on GA_NXT\n", ha->host_no));
        } else {
-               memset(swl, 0, sizeof(sw_info_t) * MAX_FIBRE_DEVICES);
                if (qla2x00_gid_pt(ha, swl) != QLA_SUCCESS) {
                        kfree(swl);
                        swl = NULL;
@@ -3339,7 +3329,8 @@ qla2x00_restart_isp(scsi_qla_host_t *ha)
 
                        spin_lock_irqsave(&ha->hardware_lock, flags);
 
-                       if (!IS_QLA24XX(ha) && !IS_QLA54XX(ha)) {
+                       if (!IS_QLA24XX(ha) && !IS_QLA54XX(ha) &&
+                           !IS_QLA25XX(ha)) {
                                /*
                                 * Disable SRAM, Instruction RAM and GP RAM
                                 * parity.
@@ -3355,7 +3346,8 @@ qla2x00_restart_isp(scsi_qla_host_t *ha)
 
                        spin_lock_irqsave(&ha->hardware_lock, flags);
 
-                       if (!IS_QLA24XX(ha) && !IS_QLA54XX(ha)) {
+                       if (!IS_QLA24XX(ha) && !IS_QLA54XX(ha) &&
+                           !IS_QLA25XX(ha)) {
                                /* Enable proper parity */
                                if (IS_QLA2300(ha))
                                        /* SRAM parity */
@@ -3484,7 +3476,7 @@ qla24xx_nvram_config(scsi_qla_host_t *ha)
 
        rval = QLA_SUCCESS;
        icb = (struct init_cb_24xx *)ha->init_cb;
-       nv = (struct nvram_24xx *)ha->request_ring;
+       nv = ha->nvram;
 
        /* Determine NVRAM starting address. */
        ha->nvram_size = sizeof(struct nvram_24xx);
@@ -3496,7 +3488,12 @@ qla24xx_nvram_config(scsi_qla_host_t *ha)
                ha->vpd_base = FA_NVRAM_VPD1_ADDR;
        }
 
-       /* Get NVRAM data and calculate checksum. */
+       /* Get VPD data into cache */
+       ha->vpd = ha->nvram + VPD_OFFSET;
+       ha->isp_ops->read_nvram(ha, (uint8_t *)ha->vpd,
+           ha->nvram_base - FA_NVRAM_FUNC0_ADDR, FA_NVRAM_VPD_SIZE * 4);
+
+       /* Get NVRAM data into cache and calculate checksum. */
        dptr = (uint32_t *)nv;
        ha->isp_ops->read_nvram(ha, (uint8_t *)dptr, ha->nvram_base,
            ha->nvram_size);
@@ -3504,8 +3501,7 @@ qla24xx_nvram_config(scsi_qla_host_t *ha)
                chksum += le32_to_cpu(*dptr++);
 
        DEBUG5(printk("scsi(%ld): Contents of NVRAM\n", ha->host_no));
-       DEBUG5(qla2x00_dump_buffer((uint8_t *)ha->request_ring,
-           ha->nvram_size));
+       DEBUG5(qla2x00_dump_buffer((uint8_t *)nv, ha->nvram_size));
 
        /* Bad NVRAM data, set defaults parameters. */
        if (chksum || nv->id[0] != 'I' || nv->id[1] != 'S' || nv->id[2] != 'P'
This page took 0.030074 seconds and 5 git commands to generate.