aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-01-20 17:17:04 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2017-01-20 17:17:04 -0500
commit5116226496e898ae3ddbe540ca5ff4f843c56bbe (patch)
tree25deb9fa568f2f7d52cfe7c59120684120064bd1 /drivers/scsi
parente3737b9145636e884d7185176cbe76a3f2c645e2 (diff)
parent300af14bdb28157090f0c6f89d244fda940082da (diff)
Merge branch 'scsi-target-for-v4.10' of git://git.kernel.org/pub/scm/linux/kernel/git/bvanassche/linux
Pull SCSI target fixes from Bart Van Assche: - two small fixes for the ibmvscsis driver - ten patches with bug fixes for the target mode of the qla2xxx driver - four patches that avoid that the "sparse" and "smatch" static analyzer tools report false positives for the qla2xxx code base * 'scsi-target-for-v4.10' of git://git.kernel.org/pub/scm/linux/kernel/git/bvanassche/linux: qla2xxx: Disable out-of-order processing by default in firmware qla2xxx: Fix erroneous invalid handle message qla2xxx: Reduce exess wait during chip reset qla2xxx: Terminate exchange if corrupted qla2xxx: Fix crash due to null pointer access qla2xxx: Collect additional information to debug fw dump qla2xxx: Reset reserved field in firmware options to 0 qla2xxx: Set tcm_qla2xxx version to automatically track qla2xxx version qla2xxx: Include ATIO queue in firmware dump when in target mode qla2xxx: Fix wrong IOCB type assumption qla2xxx: Avoid that building with W=1 triggers complaints about set-but-not-used variables qla2xxx: Move two arrays from header files to .c files qla2xxx: Declare an array with file scope static qla2xxx: Fix indentation ibmvscsis: Fix sleeping in interrupt context ibmvscsis: Fix max transfer length
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c7
-rw-r--r--drivers/scsi/qla2xxx/qla_attr.c3
-rw-r--r--drivers/scsi/qla2xxx/qla_def.h3
-rw-r--r--drivers/scsi/qla2xxx/qla_init.c4
-rw-r--r--drivers/scsi/qla2xxx/qla_isr.c4
-rw-r--r--drivers/scsi/qla2xxx/qla_mbx.c37
-rw-r--r--drivers/scsi/qla2xxx/qla_nx.c5
-rw-r--r--drivers/scsi/qla2xxx/qla_nx.h3
-rw-r--r--drivers/scsi/qla2xxx/qla_nx2.c17
-rw-r--r--drivers/scsi/qla2xxx/qla_nx2.h17
-rw-r--r--drivers/scsi/qla2xxx/qla_os.c16
-rw-r--r--drivers/scsi/qla2xxx/qla_target.c57
-rw-r--r--drivers/scsi/qla2xxx/qla_target.h22
-rw-r--r--drivers/scsi/qla2xxx/qla_tmpl.c24
-rw-r--r--drivers/scsi/qla2xxx/tcm_qla2xxx.c4
-rw-r--r--drivers/scsi/qla2xxx/tcm_qla2xxx.h1
16 files changed, 158 insertions, 66 deletions
diff --git a/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c b/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c
index 8fb5c54c7dd3..99b747cedbeb 100644
--- a/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c
+++ b/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c
@@ -46,6 +46,7 @@
46 46
47#define INITIAL_SRP_LIMIT 800 47#define INITIAL_SRP_LIMIT 800
48#define DEFAULT_MAX_SECTORS 256 48#define DEFAULT_MAX_SECTORS 256
49#define MAX_TXU 1024 * 1024
49 50
50static uint max_vdma_size = MAX_H_COPY_RDMA; 51static uint max_vdma_size = MAX_H_COPY_RDMA;
51 52
@@ -1391,7 +1392,7 @@ static long ibmvscsis_adapter_info(struct scsi_info *vscsi,
1391 } 1392 }
1392 1393
1393 info = dma_alloc_coherent(&vscsi->dma_dev->dev, sizeof(*info), &token, 1394 info = dma_alloc_coherent(&vscsi->dma_dev->dev, sizeof(*info), &token,
1394 GFP_KERNEL); 1395 GFP_ATOMIC);
1395 if (!info) { 1396 if (!info) {
1396 dev_err(&vscsi->dev, "bad dma_alloc_coherent %p\n", 1397 dev_err(&vscsi->dev, "bad dma_alloc_coherent %p\n",
1397 iue->target); 1398 iue->target);
@@ -1443,7 +1444,7 @@ static long ibmvscsis_adapter_info(struct scsi_info *vscsi,
1443 info->mad_version = cpu_to_be32(MAD_VERSION_1); 1444 info->mad_version = cpu_to_be32(MAD_VERSION_1);
1444 info->os_type = cpu_to_be32(LINUX); 1445 info->os_type = cpu_to_be32(LINUX);
1445 memset(&info->port_max_txu[0], 0, sizeof(info->port_max_txu)); 1446 memset(&info->port_max_txu[0], 0, sizeof(info->port_max_txu));
1446 info->port_max_txu[0] = cpu_to_be32(128 * PAGE_SIZE); 1447 info->port_max_txu[0] = cpu_to_be32(MAX_TXU);
1447 1448
1448 dma_wmb(); 1449 dma_wmb();
1449 rc = h_copy_rdma(sizeof(*info), vscsi->dds.window[LOCAL].liobn, 1450 rc = h_copy_rdma(sizeof(*info), vscsi->dds.window[LOCAL].liobn,
@@ -1509,7 +1510,7 @@ static int ibmvscsis_cap_mad(struct scsi_info *vscsi, struct iu_entry *iue)
1509 } 1510 }
1510 1511
1511 cap = dma_alloc_coherent(&vscsi->dma_dev->dev, olen, &token, 1512 cap = dma_alloc_coherent(&vscsi->dma_dev->dev, olen, &token,
1512 GFP_KERNEL); 1513 GFP_ATOMIC);
1513 if (!cap) { 1514 if (!cap) {
1514 dev_err(&vscsi->dev, "bad dma_alloc_coherent %p\n", 1515 dev_err(&vscsi->dev, "bad dma_alloc_coherent %p\n",
1515 iue->target); 1516 iue->target);
diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
index 83f8527c0363..f201f4099620 100644
--- a/drivers/scsi/qla2xxx/qla_attr.c
+++ b/drivers/scsi/qla2xxx/qla_attr.c
@@ -761,7 +761,6 @@ qla2x00_issue_logo(struct file *filp, struct kobject *kobj,
761 struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj, 761 struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
762 struct device, kobj))); 762 struct device, kobj)));
763 int type; 763 int type;
764 int rval = 0;
765 port_id_t did; 764 port_id_t did;
766 765
767 type = simple_strtol(buf, NULL, 10); 766 type = simple_strtol(buf, NULL, 10);
@@ -775,7 +774,7 @@ qla2x00_issue_logo(struct file *filp, struct kobject *kobj,
775 774
776 ql_log(ql_log_info, vha, 0x70e4, "%s: %d\n", __func__, type); 775 ql_log(ql_log_info, vha, 0x70e4, "%s: %d\n", __func__, type);
777 776
778 rval = qla24xx_els_dcmd_iocb(vha, ELS_DCMD_LOGO, did); 777 qla24xx_els_dcmd_iocb(vha, ELS_DCMD_LOGO, did);
779 return count; 778 return count;
780} 779}
781 780
diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index 1549aace296a..5b1287a63c49 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -1556,7 +1556,8 @@ typedef struct {
1556struct atio { 1556struct atio {
1557 uint8_t entry_type; /* Entry type. */ 1557 uint8_t entry_type; /* Entry type. */
1558 uint8_t entry_count; /* Entry count. */ 1558 uint8_t entry_count; /* Entry count. */
1559 uint8_t data[58]; 1559 __le16 attr_n_length;
1560 uint8_t data[56];
1560 uint32_t signature; 1561 uint32_t signature;
1561#define ATIO_PROCESSED 0xDEADDEAD /* Signature */ 1562#define ATIO_PROCESSED 0xDEADDEAD /* Signature */
1562}; 1563};
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index 632d5f30386a..7b6317c8c2e9 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -1191,7 +1191,7 @@ qla24xx_reset_risc(scsi_qla_host_t *vha)
1191 1191
1192 /* Wait for soft-reset to complete. */ 1192 /* Wait for soft-reset to complete. */
1193 RD_REG_DWORD(&reg->ctrl_status); 1193 RD_REG_DWORD(&reg->ctrl_status);
1194 for (cnt = 0; cnt < 6000000; cnt++) { 1194 for (cnt = 0; cnt < 60; cnt++) {
1195 barrier(); 1195 barrier();
1196 if ((RD_REG_DWORD(&reg->ctrl_status) & 1196 if ((RD_REG_DWORD(&reg->ctrl_status) &
1197 CSRX_ISP_SOFT_RESET) == 0) 1197 CSRX_ISP_SOFT_RESET) == 0)
@@ -1234,7 +1234,7 @@ qla24xx_reset_risc(scsi_qla_host_t *vha)
1234 RD_REG_DWORD(&reg->hccr); 1234 RD_REG_DWORD(&reg->hccr);
1235 1235
1236 RD_REG_WORD(&reg->mailbox0); 1236 RD_REG_WORD(&reg->mailbox0);
1237 for (cnt = 6000000; RD_REG_WORD(&reg->mailbox0) != 0 && 1237 for (cnt = 60; RD_REG_WORD(&reg->mailbox0) != 0 &&
1238 rval == QLA_SUCCESS; cnt--) { 1238 rval == QLA_SUCCESS; cnt--) {
1239 barrier(); 1239 barrier();
1240 if (cnt) 1240 if (cnt)
diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
index 54e1223b66d7..dc88a09f9043 100644
--- a/drivers/scsi/qla2xxx/qla_isr.c
+++ b/drivers/scsi/qla2xxx/qla_isr.c
@@ -2492,6 +2492,10 @@ qla2x00_error_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, sts_entry_t *pkt)
2492 if (pkt->entry_status & RF_BUSY) 2492 if (pkt->entry_status & RF_BUSY)
2493 res = DID_BUS_BUSY << 16; 2493 res = DID_BUS_BUSY << 16;
2494 2494
2495 if (pkt->entry_type == NOTIFY_ACK_TYPE &&
2496 pkt->handle == QLA_TGT_SKIP_HANDLE)
2497 return;
2498
2495 sp = qla2x00_get_sp_from_handle(vha, func, req, pkt); 2499 sp = qla2x00_get_sp_from_handle(vha, func, req, pkt);
2496 if (sp) { 2500 if (sp) {
2497 sp->done(ha, sp, res); 2501 sp->done(ha, sp, res);
diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c
index 2819ceb96041..67f64db390b0 100644
--- a/drivers/scsi/qla2xxx/qla_mbx.c
+++ b/drivers/scsi/qla2xxx/qla_mbx.c
@@ -10,7 +10,7 @@
10#include <linux/delay.h> 10#include <linux/delay.h>
11#include <linux/gfp.h> 11#include <linux/gfp.h>
12 12
13struct rom_cmd { 13static struct rom_cmd {
14 uint16_t cmd; 14 uint16_t cmd;
15} rom_cmds[] = { 15} rom_cmds[] = {
16 { MBC_LOAD_RAM }, 16 { MBC_LOAD_RAM },
@@ -101,12 +101,12 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp)
101 return QLA_FUNCTION_TIMEOUT; 101 return QLA_FUNCTION_TIMEOUT;
102 } 102 }
103 103
104 /* if PCI error, then avoid mbx processing.*/ 104 /* if PCI error, then avoid mbx processing.*/
105 if (test_bit(PCI_ERR, &base_vha->dpc_flags)) { 105 if (test_bit(PCI_ERR, &base_vha->dpc_flags)) {
106 ql_log(ql_log_warn, vha, 0x1191, 106 ql_log(ql_log_warn, vha, 0x1191,
107 "PCI error, exiting.\n"); 107 "PCI error, exiting.\n");
108 return QLA_FUNCTION_TIMEOUT; 108 return QLA_FUNCTION_TIMEOUT;
109 } 109 }
110 110
111 reg = ha->iobase; 111 reg = ha->iobase;
112 io_lock_on = base_vha->flags.init_done; 112 io_lock_on = base_vha->flags.init_done;
@@ -323,20 +323,33 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp)
323 } 323 }
324 } else { 324 } else {
325 325
326 uint16_t mb0; 326 uint16_t mb[8];
327 uint32_t ictrl; 327 uint32_t ictrl, host_status, hccr;
328 uint16_t w; 328 uint16_t w;
329 329
330 if (IS_FWI2_CAPABLE(ha)) { 330 if (IS_FWI2_CAPABLE(ha)) {
331 mb0 = RD_REG_WORD(&reg->isp24.mailbox0); 331 mb[0] = RD_REG_WORD(&reg->isp24.mailbox0);
332 mb[1] = RD_REG_WORD(&reg->isp24.mailbox1);
333 mb[2] = RD_REG_WORD(&reg->isp24.mailbox2);
334 mb[3] = RD_REG_WORD(&reg->isp24.mailbox3);
335 mb[7] = RD_REG_WORD(&reg->isp24.mailbox7);
332 ictrl = RD_REG_DWORD(&reg->isp24.ictrl); 336 ictrl = RD_REG_DWORD(&reg->isp24.ictrl);
337 host_status = RD_REG_DWORD(&reg->isp24.host_status);
338 hccr = RD_REG_DWORD(&reg->isp24.hccr);
339
340 ql_log(ql_log_warn, vha, 0x1119,
341 "MBX Command timeout for cmd %x, iocontrol=%x jiffies=%lx "
342 "mb[0-3]=[0x%x 0x%x 0x%x 0x%x] mb7 0x%x host_status 0x%x hccr 0x%x\n",
343 command, ictrl, jiffies, mb[0], mb[1], mb[2], mb[3],
344 mb[7], host_status, hccr);
345
333 } else { 346 } else {
334 mb0 = RD_MAILBOX_REG(ha, &reg->isp, 0); 347 mb[0] = RD_MAILBOX_REG(ha, &reg->isp, 0);
335 ictrl = RD_REG_WORD(&reg->isp.ictrl); 348 ictrl = RD_REG_WORD(&reg->isp.ictrl);
349 ql_dbg(ql_dbg_mbx + ql_dbg_buffer, vha, 0x1119,
350 "MBX Command timeout for cmd %x, iocontrol=%x jiffies=%lx "
351 "mb[0]=0x%x\n", command, ictrl, jiffies, mb[0]);
336 } 352 }
337 ql_dbg(ql_dbg_mbx + ql_dbg_buffer, vha, 0x1119,
338 "MBX Command timeout for cmd %x, iocontrol=%x jiffies=%lx "
339 "mb[0]=0x%x\n", command, ictrl, jiffies, mb0);
340 ql_dump_regs(ql_dbg_mbx + ql_dbg_buffer, vha, 0x1019); 353 ql_dump_regs(ql_dbg_mbx + ql_dbg_buffer, vha, 0x1019);
341 354
342 /* Capture FW dump only, if PCI device active */ 355 /* Capture FW dump only, if PCI device active */
@@ -684,7 +697,6 @@ qla_set_exlogin_mem_cfg(scsi_qla_host_t *vha, dma_addr_t phys_addr)
684 mbx_cmd_t mc; 697 mbx_cmd_t mc;
685 mbx_cmd_t *mcp = &mc; 698 mbx_cmd_t *mcp = &mc;
686 struct qla_hw_data *ha = vha->hw; 699 struct qla_hw_data *ha = vha->hw;
687 int configured_count;
688 700
689 ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x111a, 701 ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x111a,
690 "Entered %s.\n", __func__); 702 "Entered %s.\n", __func__);
@@ -707,7 +719,6 @@ qla_set_exlogin_mem_cfg(scsi_qla_host_t *vha, dma_addr_t phys_addr)
707 /*EMPTY*/ 719 /*EMPTY*/
708 ql_dbg(ql_dbg_mbx, vha, 0x111b, "Failed=%x.\n", rval); 720 ql_dbg(ql_dbg_mbx, vha, 0x111b, "Failed=%x.\n", rval);
709 } else { 721 } else {
710 configured_count = mcp->mb[11];
711 ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x118c, 722 ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x118c,
712 "Done %s.\n", __func__); 723 "Done %s.\n", __func__);
713 } 724 }
diff --git a/drivers/scsi/qla2xxx/qla_nx.c b/drivers/scsi/qla2xxx/qla_nx.c
index 54380b434b30..0a1723cc08cf 100644
--- a/drivers/scsi/qla2xxx/qla_nx.c
+++ b/drivers/scsi/qla2xxx/qla_nx.c
@@ -42,6 +42,11 @@ static int qla82xx_crb_table_initialized;
42 (crb_addr_xform[QLA82XX_HW_PX_MAP_CRB_##name] = \ 42 (crb_addr_xform[QLA82XX_HW_PX_MAP_CRB_##name] = \
43 QLA82XX_HW_CRB_HUB_AGT_ADR_##name << 20) 43 QLA82XX_HW_CRB_HUB_AGT_ADR_##name << 20)
44 44
45const int MD_MIU_TEST_AGT_RDDATA[] = {
46 0x410000A8, 0x410000AC,
47 0x410000B8, 0x410000BC
48};
49
45static void qla82xx_crb_addr_transform_setup(void) 50static void qla82xx_crb_addr_transform_setup(void)
46{ 51{
47 qla82xx_crb_addr_transform(XDMA); 52 qla82xx_crb_addr_transform(XDMA);
diff --git a/drivers/scsi/qla2xxx/qla_nx.h b/drivers/scsi/qla2xxx/qla_nx.h
index 6201dce3553b..77624eac95a4 100644
--- a/drivers/scsi/qla2xxx/qla_nx.h
+++ b/drivers/scsi/qla2xxx/qla_nx.h
@@ -1176,8 +1176,7 @@ struct qla82xx_md_entry_queue {
1176#define MD_MIU_TEST_AGT_ADDR_LO 0x41000094 1176#define MD_MIU_TEST_AGT_ADDR_LO 0x41000094
1177#define MD_MIU_TEST_AGT_ADDR_HI 0x41000098 1177#define MD_MIU_TEST_AGT_ADDR_HI 0x41000098
1178 1178
1179static const int MD_MIU_TEST_AGT_RDDATA[] = { 0x410000A8, 0x410000AC, 1179extern const int MD_MIU_TEST_AGT_RDDATA[4];
1180 0x410000B8, 0x410000BC };
1181 1180
1182#define CRB_NIU_XG_PAUSE_CTL_P0 0x1 1181#define CRB_NIU_XG_PAUSE_CTL_P0 0x1
1183#define CRB_NIU_XG_PAUSE_CTL_P1 0x8 1182#define CRB_NIU_XG_PAUSE_CTL_P1 0x8
diff --git a/drivers/scsi/qla2xxx/qla_nx2.c b/drivers/scsi/qla2xxx/qla_nx2.c
index 007192d7bad8..dc1ec9b61027 100644
--- a/drivers/scsi/qla2xxx/qla_nx2.c
+++ b/drivers/scsi/qla2xxx/qla_nx2.c
@@ -15,6 +15,23 @@
15 15
16#define TIMEOUT_100_MS 100 16#define TIMEOUT_100_MS 100
17 17
18static const uint32_t qla8044_reg_tbl[] = {
19 QLA8044_PEG_HALT_STATUS1,
20 QLA8044_PEG_HALT_STATUS2,
21 QLA8044_PEG_ALIVE_COUNTER,
22 QLA8044_CRB_DRV_ACTIVE,
23 QLA8044_CRB_DEV_STATE,
24 QLA8044_CRB_DRV_STATE,
25 QLA8044_CRB_DRV_SCRATCH,
26 QLA8044_CRB_DEV_PART_INFO1,
27 QLA8044_CRB_IDC_VER_MAJOR,
28 QLA8044_FW_VER_MAJOR,
29 QLA8044_FW_VER_MINOR,
30 QLA8044_FW_VER_SUB,
31 QLA8044_CMDPEG_STATE,
32 QLA8044_ASIC_TEMP,
33};
34
18/* 8044 Flash Read/Write functions */ 35/* 8044 Flash Read/Write functions */
19uint32_t 36uint32_t
20qla8044_rd_reg(struct qla_hw_data *ha, ulong addr) 37qla8044_rd_reg(struct qla_hw_data *ha, ulong addr)
diff --git a/drivers/scsi/qla2xxx/qla_nx2.h b/drivers/scsi/qla2xxx/qla_nx2.h
index 02fe3c4cdf55..83c1b7e17c80 100644
--- a/drivers/scsi/qla2xxx/qla_nx2.h
+++ b/drivers/scsi/qla2xxx/qla_nx2.h
@@ -535,23 +535,6 @@ enum qla_regs {
535#define CRB_CMDPEG_CHECK_RETRY_COUNT 60 535#define CRB_CMDPEG_CHECK_RETRY_COUNT 60
536#define CRB_CMDPEG_CHECK_DELAY 500 536#define CRB_CMDPEG_CHECK_DELAY 500
537 537
538static const uint32_t qla8044_reg_tbl[] = {
539 QLA8044_PEG_HALT_STATUS1,
540 QLA8044_PEG_HALT_STATUS2,
541 QLA8044_PEG_ALIVE_COUNTER,
542 QLA8044_CRB_DRV_ACTIVE,
543 QLA8044_CRB_DEV_STATE,
544 QLA8044_CRB_DRV_STATE,
545 QLA8044_CRB_DRV_SCRATCH,
546 QLA8044_CRB_DEV_PART_INFO1,
547 QLA8044_CRB_IDC_VER_MAJOR,
548 QLA8044_FW_VER_MAJOR,
549 QLA8044_FW_VER_MINOR,
550 QLA8044_FW_VER_SUB,
551 QLA8044_CMDPEG_STATE,
552 QLA8044_ASIC_TEMP,
553};
554
555/* MiniDump Structures */ 538/* MiniDump Structures */
556 539
557/* Driver_code is for driver to write some info about the entry 540/* Driver_code is for driver to write some info about the entry
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index ad4edc13ebcf..0a000ecf0881 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -3662,7 +3662,7 @@ qla2x00_mem_alloc(struct qla_hw_data *ha, uint16_t req_len, uint16_t rsp_len,
3662 sizeof(struct ct6_dsd), 0, 3662 sizeof(struct ct6_dsd), 0,
3663 SLAB_HWCACHE_ALIGN, NULL); 3663 SLAB_HWCACHE_ALIGN, NULL);
3664 if (!ctx_cachep) 3664 if (!ctx_cachep)
3665 goto fail_free_gid_list; 3665 goto fail_free_srb_mempool;
3666 } 3666 }
3667 ha->ctx_mempool = mempool_create_slab_pool(SRB_MIN_REQ, 3667 ha->ctx_mempool = mempool_create_slab_pool(SRB_MIN_REQ,
3668 ctx_cachep); 3668 ctx_cachep);
@@ -3815,7 +3815,7 @@ qla2x00_mem_alloc(struct qla_hw_data *ha, uint16_t req_len, uint16_t rsp_len,
3815 ha->loop_id_map = kzalloc(BITS_TO_LONGS(LOOPID_MAP_SIZE) * sizeof(long), 3815 ha->loop_id_map = kzalloc(BITS_TO_LONGS(LOOPID_MAP_SIZE) * sizeof(long),
3816 GFP_KERNEL); 3816 GFP_KERNEL);
3817 if (!ha->loop_id_map) 3817 if (!ha->loop_id_map)
3818 goto fail_async_pd; 3818 goto fail_loop_id_map;
3819 else { 3819 else {
3820 qla2x00_set_reserved_loop_ids(ha); 3820 qla2x00_set_reserved_loop_ids(ha);
3821 ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0123, 3821 ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0123,
@@ -3824,6 +3824,8 @@ qla2x00_mem_alloc(struct qla_hw_data *ha, uint16_t req_len, uint16_t rsp_len,
3824 3824
3825 return 0; 3825 return 0;
3826 3826
3827fail_loop_id_map:
3828 dma_pool_free(ha->s_dma_pool, ha->async_pd, ha->async_pd_dma);
3827fail_async_pd: 3829fail_async_pd:
3828 dma_pool_free(ha->s_dma_pool, ha->ex_init_cb, ha->ex_init_cb_dma); 3830 dma_pool_free(ha->s_dma_pool, ha->ex_init_cb, ha->ex_init_cb_dma);
3829fail_ex_init_cb: 3831fail_ex_init_cb:
@@ -3851,6 +3853,10 @@ fail_free_ms_iocb:
3851 dma_pool_free(ha->s_dma_pool, ha->ms_iocb, ha->ms_iocb_dma); 3853 dma_pool_free(ha->s_dma_pool, ha->ms_iocb, ha->ms_iocb_dma);
3852 ha->ms_iocb = NULL; 3854 ha->ms_iocb = NULL;
3853 ha->ms_iocb_dma = 0; 3855 ha->ms_iocb_dma = 0;
3856
3857 if (ha->sns_cmd)
3858 dma_free_coherent(&ha->pdev->dev, sizeof(struct sns_cmd_pkt),
3859 ha->sns_cmd, ha->sns_cmd_dma);
3854fail_dma_pool: 3860fail_dma_pool:
3855 if (IS_QLA82XX(ha) || ql2xenabledif) { 3861 if (IS_QLA82XX(ha) || ql2xenabledif) {
3856 dma_pool_destroy(ha->fcp_cmnd_dma_pool); 3862 dma_pool_destroy(ha->fcp_cmnd_dma_pool);
@@ -3868,10 +3874,12 @@ fail_free_nvram:
3868 kfree(ha->nvram); 3874 kfree(ha->nvram);
3869 ha->nvram = NULL; 3875 ha->nvram = NULL;
3870fail_free_ctx_mempool: 3876fail_free_ctx_mempool:
3871 mempool_destroy(ha->ctx_mempool); 3877 if (ha->ctx_mempool)
3878 mempool_destroy(ha->ctx_mempool);
3872 ha->ctx_mempool = NULL; 3879 ha->ctx_mempool = NULL;
3873fail_free_srb_mempool: 3880fail_free_srb_mempool:
3874 mempool_destroy(ha->srb_mempool); 3881 if (ha->srb_mempool)
3882 mempool_destroy(ha->srb_mempool);
3875 ha->srb_mempool = NULL; 3883 ha->srb_mempool = NULL;
3876fail_free_gid_list: 3884fail_free_gid_list:
3877 dma_free_coherent(&ha->pdev->dev, qla2x00_gid_list_size(ha), 3885 dma_free_coherent(&ha->pdev->dev, qla2x00_gid_list_size(ha),
diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c
index bff9689f5ca9..e4fda84b959e 100644
--- a/drivers/scsi/qla2xxx/qla_target.c
+++ b/drivers/scsi/qla2xxx/qla_target.c
@@ -668,11 +668,9 @@ static int qlt_reset(struct scsi_qla_host *vha, void *iocb, int mcmd)
668{ 668{
669 struct qla_hw_data *ha = vha->hw; 669 struct qla_hw_data *ha = vha->hw;
670 struct qla_tgt_sess *sess = NULL; 670 struct qla_tgt_sess *sess = NULL;
671 uint32_t unpacked_lun, lun = 0;
672 uint16_t loop_id; 671 uint16_t loop_id;
673 int res = 0; 672 int res = 0;
674 struct imm_ntfy_from_isp *n = (struct imm_ntfy_from_isp *)iocb; 673 struct imm_ntfy_from_isp *n = (struct imm_ntfy_from_isp *)iocb;
675 struct atio_from_isp *a = (struct atio_from_isp *)iocb;
676 unsigned long flags; 674 unsigned long flags;
677 675
678 loop_id = le16_to_cpu(n->u.isp24.nport_handle); 676 loop_id = le16_to_cpu(n->u.isp24.nport_handle);
@@ -725,11 +723,7 @@ static int qlt_reset(struct scsi_qla_host *vha, void *iocb, int mcmd)
725 "loop_id %d)\n", vha->host_no, sess, sess->port_name, 723 "loop_id %d)\n", vha->host_no, sess, sess->port_name,
726 mcmd, loop_id); 724 mcmd, loop_id);
727 725
728 lun = a->u.isp24.fcp_cmnd.lun; 726 return qlt_issue_task_mgmt(sess, 0, mcmd, iocb, QLA24XX_MGMT_SEND_NACK);
729 unpacked_lun = scsilun_to_int((struct scsi_lun *)&lun);
730
731 return qlt_issue_task_mgmt(sess, unpacked_lun, mcmd,
732 iocb, QLA24XX_MGMT_SEND_NACK);
733} 727}
734 728
735/* ha->tgt.sess_lock supposed to be held on entry */ 729/* ha->tgt.sess_lock supposed to be held on entry */
@@ -3067,7 +3061,7 @@ static int __qlt_send_term_imm_notif(struct scsi_qla_host *vha,
3067 3061
3068 pkt->entry_type = NOTIFY_ACK_TYPE; 3062 pkt->entry_type = NOTIFY_ACK_TYPE;
3069 pkt->entry_count = 1; 3063 pkt->entry_count = 1;
3070 pkt->handle = QLA_TGT_SKIP_HANDLE | CTIO_COMPLETION_HANDLE_MARK; 3064 pkt->handle = QLA_TGT_SKIP_HANDLE;
3071 3065
3072 nack = (struct nack_to_isp *)pkt; 3066 nack = (struct nack_to_isp *)pkt;
3073 nack->ox_id = ntfy->ox_id; 3067 nack->ox_id = ntfy->ox_id;
@@ -3110,6 +3104,9 @@ static void qlt_send_term_imm_notif(struct scsi_qla_host *vha,
3110#if 0 /* Todo */ 3104#if 0 /* Todo */
3111 if (rc == -ENOMEM) 3105 if (rc == -ENOMEM)
3112 qlt_alloc_qfull_cmd(vha, imm, 0, 0); 3106 qlt_alloc_qfull_cmd(vha, imm, 0, 0);
3107#else
3108 if (rc) {
3109 }
3113#endif 3110#endif
3114 goto done; 3111 goto done;
3115 } 3112 }
@@ -6457,12 +6454,29 @@ qlt_24xx_process_atio_queue(struct scsi_qla_host *vha, uint8_t ha_locked)
6457 if (!vha->flags.online) 6454 if (!vha->flags.online)
6458 return; 6455 return;
6459 6456
6460 while (ha->tgt.atio_ring_ptr->signature != ATIO_PROCESSED) { 6457 while ((ha->tgt.atio_ring_ptr->signature != ATIO_PROCESSED) ||
6458 fcpcmd_is_corrupted(ha->tgt.atio_ring_ptr)) {
6461 pkt = (struct atio_from_isp *)ha->tgt.atio_ring_ptr; 6459 pkt = (struct atio_from_isp *)ha->tgt.atio_ring_ptr;
6462 cnt = pkt->u.raw.entry_count; 6460 cnt = pkt->u.raw.entry_count;
6463 6461
6464 qlt_24xx_atio_pkt_all_vps(vha, (struct atio_from_isp *)pkt, 6462 if (unlikely(fcpcmd_is_corrupted(ha->tgt.atio_ring_ptr))) {
6465 ha_locked); 6463 /*
6464 * This packet is corrupted. The header + payload
6465 * can not be trusted. There is no point in passing
6466 * it further up.
6467 */
6468 ql_log(ql_log_warn, vha, 0xffff,
6469 "corrupted fcp frame SID[%3phN] OXID[%04x] EXCG[%x] %64phN\n",
6470 pkt->u.isp24.fcp_hdr.s_id,
6471 be16_to_cpu(pkt->u.isp24.fcp_hdr.ox_id),
6472 le32_to_cpu(pkt->u.isp24.exchange_addr), pkt);
6473
6474 adjust_corrupted_atio(pkt);
6475 qlt_send_term_exchange(vha, NULL, pkt, ha_locked, 0);
6476 } else {
6477 qlt_24xx_atio_pkt_all_vps(vha,
6478 (struct atio_from_isp *)pkt, ha_locked);
6479 }
6466 6480
6467 for (i = 0; i < cnt; i++) { 6481 for (i = 0; i < cnt; i++) {
6468 ha->tgt.atio_ring_index++; 6482 ha->tgt.atio_ring_index++;
@@ -6545,6 +6559,13 @@ qlt_24xx_config_nvram_stage1(struct scsi_qla_host *vha, struct nvram_24xx *nv)
6545 6559
6546 /* Disable Full Login after LIP */ 6560 /* Disable Full Login after LIP */
6547 nv->host_p &= cpu_to_le32(~BIT_10); 6561 nv->host_p &= cpu_to_le32(~BIT_10);
6562
6563 /*
6564 * clear BIT 15 explicitly as we have seen at least
6565 * a couple of instances where this was set and this
6566 * was causing the firmware to not be initialized.
6567 */
6568 nv->firmware_options_1 &= cpu_to_le32(~BIT_15);
6548 /* Enable target PRLI control */ 6569 /* Enable target PRLI control */
6549 nv->firmware_options_2 |= cpu_to_le32(BIT_14); 6570 nv->firmware_options_2 |= cpu_to_le32(BIT_14);
6550 } else { 6571 } else {
@@ -6560,9 +6581,6 @@ qlt_24xx_config_nvram_stage1(struct scsi_qla_host *vha, struct nvram_24xx *nv)
6560 return; 6581 return;
6561 } 6582 }
6562 6583
6563 /* out-of-order frames reassembly */
6564 nv->firmware_options_3 |= BIT_6|BIT_9;
6565
6566 if (ha->tgt.enable_class_2) { 6584 if (ha->tgt.enable_class_2) {
6567 if (vha->flags.init_done) 6585 if (vha->flags.init_done)
6568 fc_host_supported_classes(vha->host) = 6586 fc_host_supported_classes(vha->host) =
@@ -6629,11 +6647,17 @@ qlt_81xx_config_nvram_stage1(struct scsi_qla_host *vha, struct nvram_81xx *nv)
6629 /* Disable ini mode, if requested */ 6647 /* Disable ini mode, if requested */
6630 if (!qla_ini_mode_enabled(vha)) 6648 if (!qla_ini_mode_enabled(vha))
6631 nv->firmware_options_1 |= cpu_to_le32(BIT_5); 6649 nv->firmware_options_1 |= cpu_to_le32(BIT_5);
6632
6633 /* Disable Full Login after LIP */ 6650 /* Disable Full Login after LIP */
6634 nv->firmware_options_1 &= cpu_to_le32(~BIT_13); 6651 nv->firmware_options_1 &= cpu_to_le32(~BIT_13);
6635 /* Enable initial LIP */ 6652 /* Enable initial LIP */
6636 nv->firmware_options_1 &= cpu_to_le32(~BIT_9); 6653 nv->firmware_options_1 &= cpu_to_le32(~BIT_9);
6654 /*
6655 * clear BIT 15 explicitly as we have seen at
6656 * least a couple of instances where this was set
6657 * and this was causing the firmware to not be
6658 * initialized.
6659 */
6660 nv->firmware_options_1 &= cpu_to_le32(~BIT_15);
6637 if (ql2xtgt_tape_enable) 6661 if (ql2xtgt_tape_enable)
6638 /* Enable FC tape support */ 6662 /* Enable FC tape support */
6639 nv->firmware_options_2 |= cpu_to_le32(BIT_12); 6663 nv->firmware_options_2 |= cpu_to_le32(BIT_12);
@@ -6658,9 +6682,6 @@ qlt_81xx_config_nvram_stage1(struct scsi_qla_host *vha, struct nvram_81xx *nv)
6658 return; 6682 return;
6659 } 6683 }
6660 6684
6661 /* out-of-order frames reassembly */
6662 nv->firmware_options_3 |= BIT_6|BIT_9;
6663
6664 if (ha->tgt.enable_class_2) { 6685 if (ha->tgt.enable_class_2) {
6665 if (vha->flags.init_done) 6686 if (vha->flags.init_done)
6666 fc_host_supported_classes(vha->host) = 6687 fc_host_supported_classes(vha->host) =
diff --git a/drivers/scsi/qla2xxx/qla_target.h b/drivers/scsi/qla2xxx/qla_target.h
index f26c5f60eedd..0824a8164a24 100644
--- a/drivers/scsi/qla2xxx/qla_target.h
+++ b/drivers/scsi/qla2xxx/qla_target.h
@@ -427,13 +427,33 @@ struct atio_from_isp {
427 struct { 427 struct {
428 uint8_t entry_type; /* Entry type. */ 428 uint8_t entry_type; /* Entry type. */
429 uint8_t entry_count; /* Entry count. */ 429 uint8_t entry_count; /* Entry count. */
430 uint8_t data[58]; 430 __le16 attr_n_length;
431#define FCP_CMD_LENGTH_MASK 0x0fff
432#define FCP_CMD_LENGTH_MIN 0x38
433 uint8_t data[56];
431 uint32_t signature; 434 uint32_t signature;
432#define ATIO_PROCESSED 0xDEADDEAD /* Signature */ 435#define ATIO_PROCESSED 0xDEADDEAD /* Signature */
433 } raw; 436 } raw;
434 } u; 437 } u;
435} __packed; 438} __packed;
436 439
440static inline int fcpcmd_is_corrupted(struct atio *atio)
441{
442 if (atio->entry_type == ATIO_TYPE7 &&
443 (le16_to_cpu(atio->attr_n_length & FCP_CMD_LENGTH_MASK) <
444 FCP_CMD_LENGTH_MIN))
445 return 1;
446 else
447 return 0;
448}
449
450/* adjust corrupted atio so we won't trip over the same entry again. */
451static inline void adjust_corrupted_atio(struct atio_from_isp *atio)
452{
453 atio->u.raw.attr_n_length = cpu_to_le16(FCP_CMD_LENGTH_MIN);
454 atio->u.isp24.fcp_cmnd.add_cdb_len = 0;
455}
456
437#define CTIO_TYPE7 0x12 /* Continue target I/O entry (for 24xx) */ 457#define CTIO_TYPE7 0x12 /* Continue target I/O entry (for 24xx) */
438 458
439/* 459/*
diff --git a/drivers/scsi/qla2xxx/qla_tmpl.c b/drivers/scsi/qla2xxx/qla_tmpl.c
index 36935c9ed669..8a58ef3adab4 100644
--- a/drivers/scsi/qla2xxx/qla_tmpl.c
+++ b/drivers/scsi/qla2xxx/qla_tmpl.c
@@ -433,6 +433,18 @@ qla27xx_fwdt_entry_t263(struct scsi_qla_host *vha,
433 count++; 433 count++;
434 } 434 }
435 } 435 }
436 } else if (QLA_TGT_MODE_ENABLED() &&
437 ent->t263.queue_type == T263_QUEUE_TYPE_ATIO) {
438 struct qla_hw_data *ha = vha->hw;
439 struct atio *atr = ha->tgt.atio_ring;
440
441 if (atr || !buf) {
442 length = ha->tgt.atio_q_length;
443 qla27xx_insert16(0, buf, len);
444 qla27xx_insert16(length, buf, len);
445 qla27xx_insertbuf(atr, length * sizeof(*atr), buf, len);
446 count++;
447 }
436 } else { 448 } else {
437 ql_dbg(ql_dbg_misc, vha, 0xd026, 449 ql_dbg(ql_dbg_misc, vha, 0xd026,
438 "%s: unknown queue %x\n", __func__, ent->t263.queue_type); 450 "%s: unknown queue %x\n", __func__, ent->t263.queue_type);
@@ -676,6 +688,18 @@ qla27xx_fwdt_entry_t274(struct scsi_qla_host *vha,
676 count++; 688 count++;
677 } 689 }
678 } 690 }
691 } else if (QLA_TGT_MODE_ENABLED() &&
692 ent->t274.queue_type == T274_QUEUE_TYPE_ATIO_SHAD) {
693 struct qla_hw_data *ha = vha->hw;
694 struct atio *atr = ha->tgt.atio_ring_ptr;
695
696 if (atr || !buf) {
697 qla27xx_insert16(0, buf, len);
698 qla27xx_insert16(1, buf, len);
699 qla27xx_insert32(ha->tgt.atio_q_in ?
700 readl(ha->tgt.atio_q_in) : 0, buf, len);
701 count++;
702 }
679 } else { 703 } else {
680 ql_dbg(ql_dbg_misc, vha, 0xd02f, 704 ql_dbg(ql_dbg_misc, vha, 0xd02f,
681 "%s: unknown queue %x\n", __func__, ent->t274.queue_type); 705 "%s: unknown queue %x\n", __func__, ent->t274.queue_type);
diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
index 6643f6fc7795..d925910be761 100644
--- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c
+++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
@@ -1800,7 +1800,7 @@ static ssize_t tcm_qla2xxx_wwn_version_show(struct config_item *item,
1800{ 1800{
1801 return sprintf(page, 1801 return sprintf(page,
1802 "TCM QLOGIC QLA2XXX NPIV capable fabric module %s on %s/%s on " 1802 "TCM QLOGIC QLA2XXX NPIV capable fabric module %s on %s/%s on "
1803 UTS_RELEASE"\n", TCM_QLA2XXX_VERSION, utsname()->sysname, 1803 UTS_RELEASE"\n", QLA2XXX_VERSION, utsname()->sysname,
1804 utsname()->machine); 1804 utsname()->machine);
1805} 1805}
1806 1806
@@ -1906,7 +1906,7 @@ static int tcm_qla2xxx_register_configfs(void)
1906 int ret; 1906 int ret;
1907 1907
1908 pr_debug("TCM QLOGIC QLA2XXX fabric module %s on %s/%s on " 1908 pr_debug("TCM QLOGIC QLA2XXX fabric module %s on %s/%s on "
1909 UTS_RELEASE"\n", TCM_QLA2XXX_VERSION, utsname()->sysname, 1909 UTS_RELEASE"\n", QLA2XXX_VERSION, utsname()->sysname,
1910 utsname()->machine); 1910 utsname()->machine);
1911 1911
1912 ret = target_register_template(&tcm_qla2xxx_ops); 1912 ret = target_register_template(&tcm_qla2xxx_ops);
diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.h b/drivers/scsi/qla2xxx/tcm_qla2xxx.h
index 37e026a4823d..cf8430be183b 100644
--- a/drivers/scsi/qla2xxx/tcm_qla2xxx.h
+++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.h
@@ -1,7 +1,6 @@
1#include <target/target_core_base.h> 1#include <target/target_core_base.h>
2#include <linux/btree.h> 2#include <linux/btree.h>
3 3
4#define TCM_QLA2XXX_VERSION "v0.1"
5/* length of ASCII WWPNs including pad */ 4/* length of ASCII WWPNs including pad */
6#define TCM_QLA2XXX_NAMELEN 32 5#define TCM_QLA2XXX_NAMELEN 32
7/* 6/*