Merge git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi-rc-fixes-2.6

* git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi-rc-fixes-2.6:
[SCSI] ibmvfc: Fix DMA mapping leak on memory allocation failure
[SCSI] qla2xxx: Update version number to 8.03.00-k2.
[SCSI] qla2xxx: Add checks for a valid fcport in dev-loss-tmo/terminate_rport_io callbacks.
[SCSI] qla2xxx: Correct regression in DMA-mask setting prior to allocations.
[SCSI] qla2xxx: Correct descriptions in flash manipulation routines.
[SCSI] qla2xxx: Correct regression in EH abort handling.
[SCSI] qla2xxx: Correct endianness issue during flash manipulation.
[SCSI] qla2xxx: Correct MSI-X vector allocation for single queue mode.
[SCSI] qla2xxx: Modify firmware-load order precedence for ISP81XX parts.
[SCSI] qla2xxx: Always serialize mailbox command execution.
[SCSI] qla2xxx: Ensure RISC-interrupt-enabled consistency for IS_NOPOLLING_TYPE() ISPs.
[SCSI] qla2xxx: Simplify sector-mask calculation in preparation for larger flash parts.
[SCSI] qla2xxx: Fix memory leak in error path
[SCSI] qla4xxx: do not reuse session when connecting to different target port
[SCSI] libiscsi: fix iscsi pool leak

+100 -44
+3 -1
drivers/scsi/ibmvscsi/ibmvfc.c
··· 1322 1322 &evt->ext_list_token); 1323 1323 1324 1324 if (!evt->ext_list) { 1325 - scmd_printk(KERN_ERR, scmd, "Can't allocate memory for scatterlist\n"); 1325 + scsi_dma_unmap(scmd); 1326 + if (vhost->log_level > IBMVFC_DEFAULT_LOG_LEVEL) 1327 + scmd_printk(KERN_ERR, scmd, "Can't allocate memory for scatterlist\n"); 1326 1328 return -ENOMEM; 1327 1329 } 1328 1330 }
+1
drivers/scsi/libiscsi.c
··· 1981 1981 kfree(q->pool[i]); 1982 1982 if (q->pool) 1983 1983 kfree(q->pool); 1984 + kfree(q->queue); 1984 1985 } 1985 1986 EXPORT_SYMBOL_GPL(iscsi_pool_free); 1986 1987
+6
drivers/scsi/qla2xxx/qla_attr.c
··· 1016 1016 struct Scsi_Host *host = rport_to_shost(rport); 1017 1017 fc_port_t *fcport = *(fc_port_t **)rport->dd_data; 1018 1018 1019 + if (!fcport) 1020 + return; 1021 + 1019 1022 qla2x00_abort_fcport_cmds(fcport); 1020 1023 1021 1024 /* ··· 1035 1032 qla2x00_terminate_rport_io(struct fc_rport *rport) 1036 1033 { 1037 1034 fc_port_t *fcport = *(fc_port_t **)rport->dd_data; 1035 + 1036 + if (!fcport) 1037 + return; 1038 1038 1039 1039 /* 1040 1040 * At this point all fcport's software-states are cleared. Perform any
+1
drivers/scsi/qla2xxx/qla_gbl.h
··· 34 34 extern void qla81xx_update_fw_options(scsi_qla_host_t *); 35 35 extern int qla2x00_load_risc(struct scsi_qla_host *, uint32_t *); 36 36 extern int qla24xx_load_risc(scsi_qla_host_t *, uint32_t *); 37 + extern int qla81xx_load_risc(scsi_qla_host_t *, uint32_t *); 37 38 38 39 extern int qla2x00_loop_resync(scsi_qla_host_t *); 39 40
+47 -6
drivers/scsi/qla2xxx/qla_init.c
··· 3562 3562 WRT_REG_DWORD(&reg->hccr, HCCRX_REL_RISC_PAUSE); 3563 3563 RD_REG_DWORD(&reg->hccr); 3564 3564 spin_unlock_irqrestore(&ha->hardware_lock, flags); 3565 + 3566 + if (IS_NOPOLLING_TYPE(ha)) 3567 + ha->isp_ops->enable_intrs(ha); 3565 3568 } 3566 3569 3567 3570 /* On sparc systems, obtain port and node WWN from firmware ··· 3850 3847 uint32_t i; 3851 3848 struct qla_hw_data *ha = vha->hw; 3852 3849 struct req_que *req = ha->req_q_map[0]; 3850 + 3851 + qla_printk(KERN_INFO, ha, 3852 + "FW: Loading from flash (%x)...\n", ha->flt_region_fw); 3853 + 3853 3854 rval = QLA_SUCCESS; 3854 3855 3855 3856 segments = FA_RISC_CODE_SEGMENTS; ··· 4029 4022 return QLA_FUNCTION_FAILED; 4030 4023 } 4031 4024 4032 - int 4033 - qla24xx_load_risc(scsi_qla_host_t *vha, uint32_t *srisc_addr) 4025 + static int 4026 + qla24xx_load_risc_blob(scsi_qla_host_t *vha, uint32_t *srisc_addr) 4034 4027 { 4035 4028 int rval; 4036 4029 int segments, fragment; ··· 4050 4043 qla_printk(KERN_ERR, ha, "Firmware images can be retrieved " 4051 4044 "from: " QLA_FW_URL ".\n"); 4052 4045 4053 - /* Try to load RISC code from flash. */ 4054 - qla_printk(KERN_ERR, ha, "Attempting to load (potentially " 4055 - "outdated) firmware from flash.\n"); 4056 - return qla24xx_load_risc_flash(vha, srisc_addr); 4046 + return QLA_FUNCTION_FAILED; 4057 4047 } 4048 + 4049 + qla_printk(KERN_INFO, ha, 4050 + "FW: Loading via request-firmware...\n"); 4058 4051 4059 4052 rval = QLA_SUCCESS; 4060 4053 ··· 4138 4131 4139 4132 fail_fw_integrity: 4140 4133 return QLA_FUNCTION_FAILED; 4134 + } 4135 + 4136 + int 4137 + qla24xx_load_risc(scsi_qla_host_t *vha, uint32_t *srisc_addr) 4138 + { 4139 + int rval; 4140 + 4141 + /* 4142 + * FW Load priority: 4143 + * 1) Firmware via request-firmware interface (.bin file). 4144 + * 2) Firmware residing in flash. 4145 + */ 4146 + rval = qla24xx_load_risc_blob(vha, srisc_addr); 4147 + if (rval == QLA_SUCCESS) 4148 + return rval; 4149 + 4150 + return qla24xx_load_risc_flash(vha, srisc_addr); 4151 + } 4152 + 4153 + int 4154 + qla81xx_load_risc(scsi_qla_host_t *vha, uint32_t *srisc_addr) 4155 + { 4156 + int rval; 4157 + 4158 + /* 4159 + * FW Load priority: 4160 + * 1) Firmware residing in flash. 4161 + * 2) Firmware via request-firmware interface (.bin file). 4162 + */ 4163 + rval = qla24xx_load_risc_flash(vha, srisc_addr); 4164 + if (rval == QLA_SUCCESS) 4165 + return rval; 4166 + 4167 + return qla24xx_load_risc_blob(vha, srisc_addr); 4141 4168 } 4142 4169 4143 4170 void
+5
drivers/scsi/qla2xxx/qla_isr.c
··· 1868 1868 static int 1869 1869 qla24xx_enable_msix(struct qla_hw_data *ha, struct rsp_que *rsp) 1870 1870 { 1871 + #define MIN_MSIX_COUNT 2 1871 1872 int i, ret; 1872 1873 struct msix_entry *entries; 1873 1874 struct qla_msix_entry *qentry; ··· 1884 1883 1885 1884 ret = pci_enable_msix(ha->pdev, entries, ha->msix_count); 1886 1885 if (ret) { 1886 + if (ret < MIN_MSIX_COUNT) 1887 + goto msix_failed; 1888 + 1887 1889 qla_printk(KERN_WARNING, ha, 1888 1890 "MSI-X: Failed to enable support -- %d/%d\n" 1889 1891 " Retry with %d vectors\n", ha->msix_count, ret, ret); 1890 1892 ha->msix_count = ret; 1891 1893 ret = pci_enable_msix(ha->pdev, entries, ha->msix_count); 1892 1894 if (ret) { 1895 + msix_failed: 1893 1896 qla_printk(KERN_WARNING, ha, "MSI-X: Failed to enable" 1894 1897 " support, giving up -- %d/%d\n", 1895 1898 ha->msix_count, ret);
+6 -10
drivers/scsi/qla2xxx/qla_mbx.c
··· 58 58 * seconds. This is to serialize actual issuing of mailbox cmds during 59 59 * non ISP abort time. 60 60 */ 61 - if (!abort_active) { 62 - if (!wait_for_completion_timeout(&ha->mbx_cmd_comp, 63 - mcp->tov * HZ)) { 64 - /* Timeout occurred. Return error. */ 65 - DEBUG2_3_11(printk("%s(%ld): cmd access timeout. " 66 - "Exiting.\n", __func__, base_vha->host_no)); 67 - return QLA_FUNCTION_TIMEOUT; 68 - } 61 + if (!wait_for_completion_timeout(&ha->mbx_cmd_comp, mcp->tov * HZ)) { 62 + /* Timeout occurred. Return error. */ 63 + DEBUG2_3_11(printk("%s(%ld): cmd access timeout. " 64 + "Exiting.\n", __func__, base_vha->host_no)); 65 + return QLA_FUNCTION_TIMEOUT; 69 66 } 70 67 71 68 ha->flags.mbox_busy = 1; ··· 262 265 } 263 266 264 267 /* Allow next mbx cmd to come in. */ 265 - if (!abort_active) 266 - complete(&ha->mbx_cmd_comp); 268 + complete(&ha->mbx_cmd_comp); 267 269 268 270 if (rval) { 269 271 DEBUG2_3_11(printk("%s(%ld): **** FAILED. mbx0=%x, mbx1=%x, "
+12 -10
drivers/scsi/qla2xxx/qla_os.c
··· 65 65 66 66 static void qla2x00_free_device(scsi_qla_host_t *); 67 67 68 - static void qla2x00_config_dma_addressing(scsi_qla_host_t *ha); 69 - 70 68 int ql2xfdmienable=1; 71 69 module_param(ql2xfdmienable, int, S_IRUGO|S_IRUSR); 72 70 MODULE_PARM_DESC(ql2xfdmienable, ··· 798 800 if (ha->isp_ops->abort_command(vha, sp, req)) { 799 801 DEBUG2(printk("%s(%ld): abort_command " 800 802 "mbx failed.\n", __func__, vha->host_no)); 803 + ret = FAILED; 801 804 } else { 802 805 DEBUG3(printk("%s(%ld): abort_command " 803 806 "mbx success.\n", __func__, vha->host_no)); ··· 1240 1241 * supported addressing method. 1241 1242 */ 1242 1243 static void 1243 - qla2x00_config_dma_addressing(scsi_qla_host_t *vha) 1244 + qla2x00_config_dma_addressing(struct qla_hw_data *ha) 1244 1245 { 1245 - struct qla_hw_data *ha = vha->hw; 1246 1246 /* Assume a 32bit DMA mask. */ 1247 1247 ha->flags.enable_64bit_addressing = 0; 1248 1248 ··· 1478 1480 .reset_adapter = qla24xx_reset_adapter, 1479 1481 .nvram_config = qla81xx_nvram_config, 1480 1482 .update_fw_options = qla81xx_update_fw_options, 1481 - .load_risc = qla24xx_load_risc, 1483 + .load_risc = qla81xx_load_risc, 1482 1484 .pci_info_str = qla24xx_pci_info_str, 1483 1485 .fw_version_str = qla24xx_fw_version_str, 1484 1486 .intr_handler = qla24xx_intr_handler, ··· 1867 1869 1868 1870 set_bit(0, (unsigned long *) ha->vp_idx_map); 1869 1871 1872 + qla2x00_config_dma_addressing(ha); 1870 1873 ret = qla2x00_mem_alloc(ha, req_length, rsp_length, &req, &rsp); 1871 1874 if (!ret) { 1872 1875 qla_printk(KERN_WARNING, ha, ··· 1887 1888 "[ERROR] Failed to allocate memory for scsi_host\n"); 1888 1889 1889 1890 ret = -ENOMEM; 1891 + qla2x00_mem_free(ha); 1892 + qla2x00_free_que(ha, req, rsp); 1890 1893 goto probe_hw_failed; 1891 1894 } 1892 1895 1893 1896 pci_set_drvdata(pdev, base_vha); 1894 - 1895 - qla2x00_config_dma_addressing(base_vha); 1896 1897 1897 1898 host = base_vha->host; 1898 1899 base_vha->req_ques[0] = req->id; ··· 1916 1917 /* Set up the irqs */ 1917 1918 ret = qla2x00_request_irqs(ha, rsp); 1918 1919 if (ret) 1919 - goto probe_failed; 1920 - 1920 + goto probe_init_failed; 1921 1921 /* Alloc arrays of request and response ring ptrs */ 1922 1922 if (!qla2x00_alloc_queues(ha)) { 1923 1923 qla_printk(KERN_WARNING, ha, 1924 1924 "[ERROR] Failed to allocate memory for queue" 1925 1925 " pointers\n"); 1926 - goto probe_failed; 1926 + goto probe_init_failed; 1927 1927 } 1928 1928 ha->rsp_q_map[0] = rsp; 1929 1929 ha->req_q_map[0] = req; ··· 1994 1996 ha->isp_ops->fw_version_str(base_vha, fw_str)); 1995 1997 1996 1998 return 0; 1999 + 2000 + probe_init_failed: 2001 + qla2x00_free_que(ha, req, rsp); 2002 + ha->max_queues = 0; 1997 2003 1998 2004 probe_failed: 1999 2005 qla2x00_free_device(base_vha);
+9 -14
drivers/scsi/qla2xxx/qla_sup.c
··· 944 944 if (!ha->fdt_wrt_disable) 945 945 return; 946 946 947 - /* Disable flash write-protection. */ 947 + /* Disable flash write-protection, first clear SR protection bit */ 948 948 qla24xx_write_flash_dword(ha, flash_conf_addr(ha, 0x101), 0); 949 - /* Some flash parts need an additional zero-write to clear bits.*/ 949 + /* Then write zero again to clear remaining SR bits.*/ 950 950 qla24xx_write_flash_dword(ha, flash_conf_addr(ha, 0x101), 0); 951 951 } 952 952 ··· 980 980 uint32_t dwords) 981 981 { 982 982 int ret; 983 - uint32_t liter, miter; 983 + uint32_t liter; 984 984 uint32_t sec_mask, rest_addr; 985 - uint32_t fdata, findex; 985 + uint32_t fdata; 986 986 dma_addr_t optrom_dma; 987 987 void *optrom = NULL; 988 - uint32_t *s, *d; 989 988 struct qla_hw_data *ha = vha->hw; 990 989 991 990 ret = QLA_SUCCESS; ··· 1002 1003 } 1003 1004 1004 1005 rest_addr = (ha->fdt_block_size >> 2) - 1; 1005 - sec_mask = (ha->optrom_size >> 2) - (ha->fdt_block_size >> 2); 1006 + sec_mask = ~rest_addr; 1006 1007 1007 1008 qla24xx_unprotect_flash(ha); 1008 1009 1009 1010 for (liter = 0; liter < dwords; liter++, faddr++, dwptr++) { 1010 - 1011 - findex = faddr; 1012 - fdata = (findex & sec_mask) << 2; 1011 + fdata = (faddr & sec_mask) << 2; 1013 1012 1014 1013 /* Are we at the beginning of a sector? */ 1015 - if ((findex & rest_addr) == 0) { 1014 + if ((faddr & rest_addr) == 0) { 1016 1015 /* Do sector unprotect. */ 1017 1016 if (ha->fdt_unprotect_sec_cmd) 1018 1017 qla24xx_write_flash_dword(ha, ··· 1021 1024 (fdata & 0xff00) |((fdata << 16) & 1022 1025 0xff0000) | ((fdata >> 16) & 0xff)); 1023 1026 if (ret != QLA_SUCCESS) { 1024 - DEBUG9(qla_printk("Unable to flash sector: " 1027 + DEBUG9(qla_printk("Unable to erase sector: " 1025 1028 "address=%x.\n", faddr)); 1026 1029 break; 1027 1030 } ··· 1030 1033 /* Go with burst-write. */ 1031 1034 if (optrom && (liter + OPTROM_BURST_DWORDS) <= dwords) { 1032 1035 /* Copy data to DMA'ble buffer. */ 1033 - for (miter = 0, s = optrom, d = dwptr; 1034 - miter < OPTROM_BURST_DWORDS; miter++, s++, d++) 1035 - *s = cpu_to_le32(*d); 1036 + memcpy(optrom, dwptr, OPTROM_BURST_SIZE); 1036 1037 1037 1038 ret = qla2x00_load_ram(vha, optrom_dma, 1038 1039 flash_data_addr(ha, faddr),
+1 -1
drivers/scsi/qla2xxx/qla_version.h
··· 7 7 /* 8 8 * Driver version 9 9 */ 10 - #define QLA2XXX_VERSION "8.03.00-k1" 10 + #define QLA2XXX_VERSION "8.03.00-k2" 11 11 12 12 #define QLA_DRIVER_MAJOR_VER 8 13 13 #define QLA_DRIVER_MINOR_VER 3
+1
drivers/scsi/qla4xxx/ql4_def.h
··· 244 244 uint8_t ip_addr[ISCSI_IPADDR_SIZE]; 245 245 uint8_t iscsi_name[ISCSI_NAME_SIZE]; /* 72 x48 */ 246 246 uint8_t iscsi_alias[0x20]; 247 + uint8_t isid[6]; 247 248 }; 248 249 249 250 /*
+8 -2
drivers/scsi/qla4xxx/ql4_init.c
··· 342 342 DEBUG2(printk("scsi%ld: %s: Looking for ddb[%d]\n", ha->host_no, 343 343 __func__, fw_ddb_index)); 344 344 list_for_each_entry(ddb_entry, &ha->ddb_list, list) { 345 - if (memcmp(ddb_entry->iscsi_name, fw_ddb_entry->iscsi_name, 346 - ISCSI_NAME_SIZE) == 0) { 345 + if ((memcmp(ddb_entry->iscsi_name, fw_ddb_entry->iscsi_name, 346 + ISCSI_NAME_SIZE) == 0) && 347 + (ddb_entry->tpgt == 348 + le32_to_cpu(fw_ddb_entry->tgt_portal_grp)) && 349 + (memcmp(ddb_entry->isid, fw_ddb_entry->isid, 350 + sizeof(ddb_entry->isid)) == 0)) { 347 351 found++; 348 352 break; 349 353 } ··· 434 430 435 431 ddb_entry->port = le16_to_cpu(fw_ddb_entry->port); 436 432 ddb_entry->tpgt = le32_to_cpu(fw_ddb_entry->tgt_portal_grp); 433 + memcpy(ddb_entry->isid, fw_ddb_entry->isid, sizeof(ddb_entry->isid)); 434 + 437 435 memcpy(&ddb_entry->iscsi_name[0], &fw_ddb_entry->iscsi_name[0], 438 436 min(sizeof(ddb_entry->iscsi_name), 439 437 sizeof(fw_ddb_entry->iscsi_name)));