[PATCH 4/5] qla2xxx: Changes to support N2N logins

2017-10-11 Thread Madhani, Himanshu
From: Duane Grigsby 

If we discovered a topology that is N2N then we will issue a login
to the target. If our WWPN is bigger than the target's WWPN then we
will initiate login, otherwise we will just wait for the target
to initiate login.

Signed-off-by: Duane Grigsby 
Signed-off-by: Michael Hernandez 
Signed-off-by: Himanshu Madhani 
---
 drivers/scsi/qla2xxx/qla_def.h  |  24 +
 drivers/scsi/qla2xxx/qla_fw.h   |   4 +-
 drivers/scsi/qla2xxx/qla_gbl.h  |   4 +
 drivers/scsi/qla2xxx/qla_init.c | 135 +++-
 drivers/scsi/qla2xxx/qla_iocb.c | 195 +---
 drivers/scsi/qla2xxx/qla_isr.c  |  42 -
 drivers/scsi/qla2xxx/qla_mbx.c  |  76 
 7 files changed, 459 insertions(+), 21 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index f712c0cd46d6..01a9b8971e88 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -323,6 +323,12 @@ struct els_logo_payload {
uint8_t wwpn[WWN_SIZE];
 };
 
+struct els_plogi_payload {
+   uint8_t opcode;
+   uint8_t rsvd[3];
+   uint8_t data[112];
+};
+
 struct ct_arg {
void*iocb;
u16 nport_handle;
@@ -358,6 +364,19 @@ struct srb_iocb {
dma_addr_t els_logo_pyld_dma;
} els_logo;
struct {
+#define ELS_DCMD_PLOGI 0x3
+   uint32_t flags;
+   uint32_t els_cmd;
+   struct completion comp;
+   struct els_plogi_payload *els_plogi_pyld;
+   struct els_plogi_payload *els_resp_pyld;
+   dma_addr_t els_plogi_pyld_dma;
+   dma_addr_t els_resp_pyld_dma;
+   uint32_tfw_status[3];
+   __le16  comp_status;
+   __le16  len;
+   } els_plogi;
+   struct {
/*
 * Values for flags field below are as
 * defined in tsk_mgmt_entry struct
@@ -2349,6 +2368,7 @@ typedef struct fc_port {
uint8_t fc4_type;
uint8_t fc4f_nvme;
uint8_t scan_state;
+   uint8_t n2n_flag;
 
unsigned long last_queue_full;
unsigned long last_ramp_up;
@@ -2372,6 +2392,7 @@ typedef struct fc_port {
u8 iocb[IOCB_SIZE];
u8 current_login_state;
u8 last_login_state;
+   struct completion n2n_done;
 } fc_port_t;
 
 #define QLA_FCPORT_SCAN1
@@ -4228,6 +4249,9 @@ typedef struct scsi_qla_host {
wait_queue_head_t fcport_waitQ;
wait_queue_head_t vref_waitq;
uint8_t min_link_speed_feat;
+   uint8_t n2n_node_name[WWN_SIZE];
+   uint8_t n2n_port_name[WWN_SIZE];
+   uint16_tn2n_id;
 } scsi_qla_host_t;
 
 struct qla27xx_image_status {
diff --git a/drivers/scsi/qla2xxx/qla_fw.h b/drivers/scsi/qla2xxx/qla_fw.h
index bec641aae7b3..d5cef0727e72 100644
--- a/drivers/scsi/qla2xxx/qla_fw.h
+++ b/drivers/scsi/qla2xxx/qla_fw.h
@@ -753,9 +753,7 @@ struct els_entry_24xx {
uint8_t reserved_2;
 
uint8_t port_id[3];
-   uint8_t reserved_3;
-
-   uint16_t reserved_4;
+   uint8_t s_id[3];
 
uint16_t control_flags; /* Control flags. */
 #define ECF_PAYLOAD_DESCR_MASK (BIT_15|BIT_14|BIT_13)
diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
index 46c7822c20fc..1e35e961683f 100644
--- a/drivers/scsi/qla2xxx/qla_gbl.h
+++ b/drivers/scsi/qla2xxx/qla_gbl.h
@@ -45,6 +45,8 @@ extern int qla2x00_fabric_login(scsi_qla_host_t *, fc_port_t 
*, uint16_t *);
 extern int qla2x00_local_device_login(scsi_qla_host_t *, fc_port_t *);
 
 extern int qla24xx_els_dcmd_iocb(scsi_qla_host_t *, int, port_id_t);
+extern int qla24xx_els_dcmd2_iocb(scsi_qla_host_t *, int, fc_port_t *,
+port_id_t);
 
 extern void qla2x00_update_fcports(scsi_qla_host_t *);
 
@@ -487,6 +489,8 @@ int qla24xx_gidlist_wait(struct scsi_qla_host *, void *, 
dma_addr_t,
 uint16_t *);
 int __qla24xx_parse_gpdb(struct scsi_qla_host *, fc_port_t *,
struct port_database_24xx *);
+int qla24xx_get_port_login_templ(scsi_qla_host_t *, dma_addr_t,
+void *, uint16_t);
 
 extern int qla27xx_get_zio_threshold(scsi_qla_host_t *, uint16_t *);
 extern int qla27xx_set_zio_threshold(scsi_qla_host_t *, uint16_t);
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index 4c53199db371..b2a391f93775 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -1433,6 +1433,14 @@ qla24xx_handle_prli_done_event(struct scsi_qla_host 
*vha, struct event_arg *ea)
qla24xx_post_gpdb_work(vha, ea->fcport, 0);
break;
default:
+   if (ea->fcport->n2n_flag) {
+  

[PATCH 5/5] qla2xxx: Update driver version to 10.00.00.02-k

2017-10-11 Thread Madhani, Himanshu
From: Himanshu Madhani 

Signed-off-by: Himanshu Madhani 
---
 drivers/scsi/qla2xxx/qla_version.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/qla2xxx/qla_version.h 
b/drivers/scsi/qla2xxx/qla_version.h
index 8c4b505c9f66..b6ec02b96d3d 100644
--- a/drivers/scsi/qla2xxx/qla_version.h
+++ b/drivers/scsi/qla2xxx/qla_version.h
@@ -7,7 +7,7 @@
 /*
  * Driver version
  */
-#define QLA2XXX_VERSION  "10.00.00.01-k"
+#define QLA2XXX_VERSION  "10.00.00.02-k"
 
 #define QLA_DRIVER_MAJOR_VER   10
 #define QLA_DRIVER_MINOR_VER   0
-- 
2.12.0



[PATCH 2/5] qla2xxx: Add ATIO-Q processing for INTx mode

2017-10-11 Thread Madhani, Himanshu
From: Himanshu Madhani 

Signed-off-by: Himanshu Madhani 
---
 drivers/scsi/qla2xxx/qla_def.h|  1 +
 drivers/scsi/qla2xxx/qla_isr.c|  8 ++--
 drivers/scsi/qla2xxx/qla_target.c | 12 +---
 3 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index 486c075998f6..66d239cbbd66 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -922,6 +922,7 @@ struct mbx_cmd_32 {
 #define INTR_RSP_QUE_UPDATE_83XX   0x14
 #define INTR_ATIO_QUE_UPDATE   0x1C
 #define INTR_ATIO_RSP_QUE_UPDATE   0x1D
+#define INTR_ATIO_QUE_UPDATE_27XX  0x1E
 
 /* ISP mailbox loopback echo diagnostic error code */
 #define MBS_LB_RESET   0x17
diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
index ef7afd5eefe3..ab97fb06c239 100644
--- a/drivers/scsi/qla2xxx/qla_isr.c
+++ b/drivers/scsi/qla2xxx/qla_isr.c
@@ -3129,6 +3129,7 @@ qla24xx_intr_handler(int irq, void *dev_id)
case INTR_RSP_QUE_UPDATE_83XX:
qla24xx_process_response_queue(vha, rsp);
break;
+   case INTR_ATIO_QUE_UPDATE_27XX:
case INTR_ATIO_QUE_UPDATE:{
unsigned long flags2;
spin_lock_irqsave(>tgt.atio_lock, flags2);
@@ -3259,6 +3260,7 @@ qla24xx_msix_default(int irq, void *dev_id)
case INTR_RSP_QUE_UPDATE_83XX:
qla24xx_process_response_queue(vha, rsp);
break;
+   case INTR_ATIO_QUE_UPDATE_27XX:
case INTR_ATIO_QUE_UPDATE:{
unsigned long flags2;
spin_lock_irqsave(>tgt.atio_lock, flags2);
@@ -3347,7 +3349,8 @@ qla24xx_enable_msix(struct qla_hw_data *ha, struct 
rsp_que *rsp)
.pre_vectors = QLA_BASE_VECTORS,
};
 
-   if (QLA_TGT_MODE_ENABLED() && IS_ATIO_MSIX_CAPABLE(ha)) {
+   if (QLA_TGT_MODE_ENABLED() && (ql2xenablemsix != 0) &&
+   IS_ATIO_MSIX_CAPABLE(ha)) {
desc.pre_vectors++;
min_vecs++;
}
@@ -3432,7 +3435,8 @@ qla24xx_enable_msix(struct qla_hw_data *ha, struct 
rsp_que *rsp)
 * If target mode is enable, also request the vector for the ATIO
 * queue.
 */
-   if (QLA_TGT_MODE_ENABLED() && IS_ATIO_MSIX_CAPABLE(ha)) {
+   if (QLA_TGT_MODE_ENABLED() && (ql2xenablemsix != 0) &&
+   IS_ATIO_MSIX_CAPABLE(ha)) {
qentry = >msix_entries[QLA_ATIO_VECTOR];
rsp->msix = qentry;
qentry->handle = rsp;
diff --git a/drivers/scsi/qla2xxx/qla_target.c 
b/drivers/scsi/qla2xxx/qla_target.c
index f05cfc83c9c8..12976a25f082 100644
--- a/drivers/scsi/qla2xxx/qla_target.c
+++ b/drivers/scsi/qla2xxx/qla_target.c
@@ -6546,6 +6546,7 @@ void
 qlt_24xx_config_rings(struct scsi_qla_host *vha)
 {
struct qla_hw_data *ha = vha->hw;
+   struct init_cb_24xx *icb;
if (!QLA_TGT_MODE_ENABLED())
return;
 
@@ -6553,14 +6554,19 @@ qlt_24xx_config_rings(struct scsi_qla_host *vha)
WRT_REG_DWORD(ISP_ATIO_Q_OUT(vha), 0);
RD_REG_DWORD(ISP_ATIO_Q_OUT(vha));
 
-   if (IS_ATIO_MSIX_CAPABLE(ha)) {
+   icb = (struct init_cb_24xx *)ha->init_cb;
+
+   if ((ql2xenablemsix != 0) && IS_ATIO_MSIX_CAPABLE(ha)) {
struct qla_msix_entry *msix = >msix_entries[2];
-   struct init_cb_24xx *icb = (struct init_cb_24xx *)ha->init_cb;
 
icb->msix_atio = cpu_to_le16(msix->entry);
ql_dbg(ql_dbg_init, vha, 0xf072,
"Registering ICB vector 0x%x for atio que.\n",
msix->entry);
+   } else if (ql2xenablemsix == 0) {
+   icb->firmware_options_2 |= cpu_to_le32(BIT_26);
+   ql_dbg(ql_dbg_init, vha, 0xf07f,
+   "Registering INTx vector for ATIO.\n");
}
 }
 
@@ -6805,7 +6811,7 @@ qlt_probe_one_stage1(struct scsi_qla_host *base_vha, 
struct qla_hw_data *ha)
if (!QLA_TGT_MODE_ENABLED())
return;
 
-   if  (IS_QLA83XX(ha) || IS_QLA27XX(ha)) {
+   if  ((ql2xenablemsix == 0) || IS_QLA83XX(ha) || IS_QLA27XX(ha)) {
ISP_ATIO_Q_IN(base_vha) = >mqiobase->isp25mq.atio_q_in;
ISP_ATIO_Q_OUT(base_vha) = >mqiobase->isp25mq.atio_q_out;
} else {
-- 
2.12.0



[PATCH 3/5] qla2xxx: Allow MBC_GET_PORT_DATABASE to query and save the port states

2017-10-11 Thread Madhani, Himanshu
From: Duane Grigsby 

The MBC_GET_PORT_DATABASE command normally checks the port state
informationi. This patch allows it to save that info in the fcport
structure and ignore the check if the query flag is set.

Signed-off-by: Duane Grigsby 
Signed-off-by: Himanshu Madhani 
---
 drivers/scsi/qla2xxx/qla_def.h |  4 
 drivers/scsi/qla2xxx/qla_mbx.c | 29 ++---
 2 files changed, 26 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index 66d239cbbd66..f712c0cd46d6 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -2303,6 +2303,7 @@ typedef struct fc_port {
unsigned int send_els_logo:1;
unsigned int login_pause:1;
unsigned int login_succ:1;
+   unsigned int query:1;
 
struct work_struct nvme_del_work;
struct completion nvme_del_done;
@@ -2369,6 +2370,8 @@ typedef struct fc_port {
struct list_head gnl_entry;
struct work_struct del_work;
u8 iocb[IOCB_SIZE];
+   u8 current_login_state;
+   u8 last_login_state;
 } fc_port_t;
 
 #define QLA_FCPORT_SCAN1
@@ -4114,6 +4117,7 @@ typedef struct scsi_qla_host {
 #define QPAIR_ONLINE_CHECK_NEEDED  27
 #define SET_ZIO_THRESHOLD_NEEDED   28
 #define DETECT_SFP_CHANGE  29
+#define N2N_LOGIN_NEEDED   30
 
unsigned long   pci_flags;
 #define PFLG_DISCONNECTED  0   /* PCI device removed */
diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c
index 7f71fd378c27..71e56877e1eb 100644
--- a/drivers/scsi/qla2xxx/qla_mbx.c
+++ b/drivers/scsi/qla2xxx/qla_mbx.c
@@ -1822,17 +1822,32 @@ qla2x00_get_port_database(scsi_qla_host_t *vha, 
fc_port_t *fcport, uint8_t opt)
 
if (IS_FWI2_CAPABLE(ha)) {
uint64_t zero = 0;
+   u8 current_login_state, last_login_state;
+
pd24 = (struct port_database_24xx *) pd;
 
/* Check for logged in state. */
-   if (pd24->current_login_state != PDS_PRLI_COMPLETE &&
-   pd24->last_login_state != PDS_PRLI_COMPLETE) {
-   ql_dbg(ql_dbg_mbx, vha, 0x1051,
-   "Unable to verify login-state (%x/%x) for "
-   "loop_id %x.\n", pd24->current_login_state,
-   pd24->last_login_state, fcport->loop_id);
+   if (fcport->fc4f_nvme) {
+   current_login_state = pd24->current_login_state >> 4;
+   last_login_state = pd24->last_login_state >> 4;
+   } else {
+   current_login_state = pd24->current_login_state & 0xf;
+   last_login_state = pd24->last_login_state & 0xf;
+   }
+   fcport->current_login_state = pd24->current_login_state;
+   fcport->last_login_state = pd24->last_login_state;
+
+   /* Check for logged in state. */
+   if (current_login_state != PDS_PRLI_COMPLETE &&
+   last_login_state != PDS_PRLI_COMPLETE) {
+   ql_dbg(ql_dbg_mbx, vha, 0x119a,
+   "Unable to verify login-state (%x/%x) for loop_id 
%x.\n",
+   current_login_state, last_login_state,
+   fcport->loop_id);
rval = QLA_FUNCTION_FAILED;
-   goto gpd_error_out;
+
+   if (!fcport->query)
+   goto gpd_error_out;
}
 
if (fcport->loop_id == FC_NO_LOOP_ID ||
-- 
2.12.0



[PATCH 1/5] qla2xxx: Add module param ql2xenablemsix

2017-10-11 Thread Madhani, Himanshu
From: Himanshu Madhani 

Signed-off-by: Himanshu Madhani 
---
 drivers/scsi/qla2xxx/qla_gbl.h | 1 +
 drivers/scsi/qla2xxx/qla_isr.c | 9 ++---
 drivers/scsi/qla2xxx/qla_os.c  | 9 +
 3 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
index f852ca60c49f..46c7822c20fc 100644
--- a/drivers/scsi/qla2xxx/qla_gbl.h
+++ b/drivers/scsi/qla2xxx/qla_gbl.h
@@ -145,6 +145,7 @@ extern int ql2xmvasynctoatio;
 extern int ql2xuctrlirq;
 extern int ql2xnvmeenable;
 extern int ql2xautodetectsfp;
+extern int ql2xenablemsix;
 
 extern int qla2x00_loop_reset(scsi_qla_host_t *);
 extern void qla2x00_abort_all_cmds(scsi_qla_host_t *, int);
diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
index 9d9668aac6f6..ef7afd5eefe3 100644
--- a/drivers/scsi/qla2xxx/qla_isr.c
+++ b/drivers/scsi/qla2xxx/qla_isr.c
@@ -3486,11 +3486,14 @@ qla2x00_request_irqs(struct qla_hw_data *ha, struct 
rsp_que *rsp)
scsi_qla_host_t *vha = pci_get_drvdata(ha->pdev);
 
/* If possible, enable MSI-X. */
-   if (!IS_QLA2432(ha) && !IS_QLA2532(ha) && !IS_QLA8432(ha) &&
-   !IS_CNA_CAPABLE(ha) && !IS_QLA2031(ha) && !IS_QLAFX00(ha) &&
-   !IS_QLA27XX(ha))
+   if (ql2xenablemsix == 0 || (!IS_QLA2432(ha) && !IS_QLA2532(ha) &&
+   !IS_QLA8432(ha) && !IS_CNA_CAPABLE(ha) && !IS_QLA2031(ha) &&
+   !IS_QLAFX00(ha) && !IS_QLA27XX(ha)))
goto skip_msi;
 
+   if (ql2xenablemsix == 2)
+   goto skip_msix;
+
if (ha->pdev->subsystem_vendor == PCI_VENDOR_ID_HP &&
(ha->pdev->subsystem_device == 0x7040 ||
ha->pdev->subsystem_device == 0x7041 ||
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index 5b2437a5ea44..e69329cb3608 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -268,6 +268,15 @@ MODULE_PARM_DESC(ql2xautodetectsfp,
 "Detect SFP range and set appropriate distance.\n"
 "1 (Default): Enable\n");
 
+int ql2xenablemsix = 1;
+module_param(ql2xenablemsix, int, 0444);
+MODULE_PARM_DESC(ql2xenablemsix,
+"Set to enable MSI or MSI-X interrupt mechanism.\n"
+" Default is 1, enable MSI-X interrupt mechanism.\n"
+" 0 -- enable traditional pin-based mechanism.\n"
+" 1 -- enable MSI-X interrupt mechanism.\n"
+" 2 -- enable MSI interrupt mechanism.\n");
+
 /*
  * SCSI host template entry points
  */
-- 
2.12.0



[PATCH 0/5] qla2xxx: Patches for scsi-misc

2017-10-11 Thread Madhani, Himanshu
From: Himanshu Madhani 

Hi Martin, 

This series adds support for INTx mode for qla2xxx driver. Also,
adds support for N2N login for FC-NVMe. 

Please apply to 4.15/scsi-queue at your earliest convenience.

Thanks,
Himanshu

Duane Grigsby (2):
  qla2xxx: Allow MBC_GET_PORT_DATABASE to query and save the port states
  qla2xxx: Changes to support N2N logins

Himanshu Madhani (3):
  qla2xxx: Add module param ql2xenablemsix
  qla2xxx: Add ATIO-Q processing for INTx mode
  qla2xxx: Update driver version to 10.00.00.02-k

 drivers/scsi/qla2xxx/qla_def.h |  29 ++
 drivers/scsi/qla2xxx/qla_fw.h  |   4 +-
 drivers/scsi/qla2xxx/qla_gbl.h |   5 +
 drivers/scsi/qla2xxx/qla_init.c| 135 -
 drivers/scsi/qla2xxx/qla_iocb.c| 195 +++--
 drivers/scsi/qla2xxx/qla_isr.c |  59 +--
 drivers/scsi/qla2xxx/qla_mbx.c | 105 ++--
 drivers/scsi/qla2xxx/qla_os.c  |   9 ++
 drivers/scsi/qla2xxx/qla_target.c  |  12 ++-
 drivers/scsi/qla2xxx/qla_version.h |   2 +-
 10 files changed, 518 insertions(+), 37 deletions(-)

-- 
2.12.0



[PATCH] scsi: lpfc: fix kzalloc-simple.cocci warnings

2017-10-11 Thread Vasyl Gomonovych
drivers/scsi/lpfc/lpfc_debugfs.c:5460:22-29: WARNING: kzalloc should be used 
for phba -> nvmeio_trc, instead of kmalloc/memset
drivers/scsi/lpfc/lpfc_debugfs.c:2230:20-27: WARNING: kzalloc should be used 
for phba -> nvmeio_trc, instead of kmalloc/memset

 Use kzalloc rather than kmalloc followed by memset with 0

Generated by: scripts/coccinelle/api/alloc/kzalloc-simple.cocci

Signed-off-by: Vasyl Gomonovych 
---
 drivers/scsi/lpfc/lpfc_debugfs.c | 9 ++---
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
index d50c481..2bf5ad3 100644
--- a/drivers/scsi/lpfc/lpfc_debugfs.c
+++ b/drivers/scsi/lpfc/lpfc_debugfs.c
@@ -2227,7 +2227,7 @@
kfree(phba->nvmeio_trc);
 
/* Allocate new trace buffer and initialize */
-   phba->nvmeio_trc = kmalloc((sizeof(struct lpfc_debugfs_nvmeio_trc) *
+   phba->nvmeio_trc = kzalloc((sizeof(struct lpfc_debugfs_nvmeio_trc) *
sz), GFP_KERNEL);
if (!phba->nvmeio_trc) {
lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
@@ -2235,8 +2235,6 @@
"nvmeio_trc buffer\n");
return -ENOMEM;
}
-   memset(phba->nvmeio_trc, 0,
-  (sizeof(struct lpfc_debugfs_nvmeio_trc) * sz));
atomic_set(>nvmeio_trc_cnt, 0);
phba->nvmeio_trc_on = 0;
phba->nvmeio_trc_output_idx = 0;
@@ -5457,7 +5455,7 @@ static int lpfc_idiag_cmd_get(const char __user *buf, 
size_t nbytes,
phba->nvmeio_trc_size = lpfc_debugfs_max_nvmeio_trc;
 
/* Allocate trace buffer and initialize */
-   phba->nvmeio_trc = kmalloc(
+   phba->nvmeio_trc = kzalloc(
(sizeof(struct lpfc_debugfs_nvmeio_trc) *
phba->nvmeio_trc_size), GFP_KERNEL);
 
@@ -5467,9 +5465,6 @@ static int lpfc_idiag_cmd_get(const char __user *buf, 
size_t nbytes,
"nvmeio_trc buffer\n");
goto nvmeio_off;
}
-   memset(phba->nvmeio_trc, 0,
-  (sizeof(struct lpfc_debugfs_nvmeio_trc) *
-  phba->nvmeio_trc_size));
phba->nvmeio_trc_on = 1;
phba->nvmeio_trc_output_idx = 0;
phba->nvmeio_trc = NULL;
-- 
1.9.1



Re: [PATCH v8 03/10] md: Neither resync nor reshape while the system is frozen

2017-10-11 Thread Shaohua Li
On Wed, Oct 11, 2017 at 05:17:56PM +, Bart Van Assche wrote:
> On Tue, 2017-10-10 at 18:48 -0700, Shaohua Li wrote:
> > The problem is __md_stop_writes set some bit like MD_RECOVERY_FROZEN, which
> > will prevent md_check_recovery restarting resync/reshape. I think we need
> > preserve mddev->recovery in suspend prepare and restore after resume
> 
> Hello Shaohua,
> 
> As far as I can see __md_stop_writes() sets MD_RECOVERY_FROZEN and can set
> MD_RECOVERY_INTR. Since md_check_recovery() clears MD_RECOVERY_INTR I think
> it should be sufficient to save and restore the state of the
> MD_RECOVERY_FROZEN flag. However, when I ran the following test:
> * echo frozen > /sys/block/md0/md/sync_action
> * cat /sys/block/md0/md/sync_action
> * systemctl hibernate
> * (power on system again)
> * cat /sys/block/md0/md/sync_action
> 
> the output that appeared was as follows:
> 
> frozen
> idle 
> Does that mean that a hibernate or suspend followed by a resume is sufficient
> to clear the MD_RECOVERY_FROZEN flag for the md drivers and hence that the
> patch at the start of this e-mail thread does not need any further
> modifications?

Have no idea why it shows 'idle'. From my understanding, after resume, previous
memory is stored and MD_RECOVERY_FROZEN bit should be set. Was trying to
understand what happens.

Thanks,
Shaohua


Re: [PATCH 00/10] be2iscsi: driver update 11.4.0.1

2017-10-11 Thread Chris Leech

These all look good to me.

Acked-by: Chris Leech 

On Tue, Oct 10, 2017 at 04:18:10PM +0530, Jitendra Bhivare wrote:
> This patch is generated against for-next branch.
> 
> Jitendra Bhivare (10):
>   be2iscsi: Fix boot flags in sysfs
>   be2iscsi: Fix return value in mgmt_open_connection
>   be2iscsi: Free msi_name and disable HW intr
>   be2iscsi: Fix _modify_eq_delay buffer overflow
>   be2iscsi: Fix _get_initname buffer overflow
>   be2iscsi: Modify IOCTL to fetch user configured IQN
>   be2iscsi: Add cmd to set host data
>   be2iscsi: Fix misc static analysis errors
>   be2iscsi: Remove A-circumflex character in copyright marking
>   scsi: be2iscsi: Update driver version
> 
>  drivers/scsi/be2iscsi/be.h   |  19 ++-
>  drivers/scsi/be2iscsi/be_cmds.c  |  55 +++-
>  drivers/scsi/be2iscsi/be_cmds.h  |  48 ---
>  drivers/scsi/be2iscsi/be_iscsi.c |  54 ++--
>  drivers/scsi/be2iscsi/be_iscsi.h |   2 +-
>  drivers/scsi/be2iscsi/be_main.c  | 102 --
>  drivers/scsi/be2iscsi/be_main.h  |  49 +--
>  drivers/scsi/be2iscsi/be_mgmt.c  | 278 
> ++-
>  drivers/scsi/be2iscsi/be_mgmt.h  |  10 +-
>  9 files changed, 323 insertions(+), 294 deletions(-)
> 
> -- 
> 2.7.4
> 


Re: [PATCH v3] scsi: fc: check for rport presence in fc_block_scsi_eh

2017-10-11 Thread Martin K. Petersen

Johannes,

> Coverity-scan recently found a possible NULL pointer dereference in
> fc_block_scsi_eh() as starget_to_rport() either returns the rport for
> the startget or NULL.
>
> While it is rather unlikely to have fc_block_scsi_eh() called without
> an rport associated it's a good idea to catch potential misuses of the
> API gracefully.

Applied to 4.14/scsi-fixes. Thanks!

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH] qla2xxx: Fix uninitialize work element

2017-10-11 Thread Martin K. Petersen

Himanshu,

> From: Quinn Tran 
>
> Fixes following stack trace

Applied to 4.14/scsi-fixes. Thank you!

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH] scsi: libcxgbi: simplify task->hdr allocation for mgmt cmds

2017-10-11 Thread Martin K. Petersen

Varun,

> In case of mgmt cmds task->hdr is dereferenced after transmitting the
> pdu in iscsi_tcp_task_xmit() to handle this case current code
> increments the Tx skb reference count and frees the skb in
> cxgbi_cleanup_task(), in some error cases this results in skb leak.
>
> To fix this in case of mgmt cmds allocate a separate buffer for iSCSI
> hdr and free this buffer in cxgbi_cleanup_task().

Applied to 4.15/scsi-queue. Thanks again!

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH] scsi: cxgb4i: fix Tx skb leak

2017-10-11 Thread Martin K. Petersen

Varun,

> In case of connection reset Tx skb queue can have some skbs which are
> not transmitted so purge Tx skb queue in release_offload_resources()
> to avoid skb leak.

Applied to 4.15/scsi-queue.

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH] scsi: libcxgbi: in case of vlan pass 0 as ifindex to find route

2017-10-11 Thread Martin K. Petersen

Varun,

> In case of vlan pass 0 as ifindex to find route instead of passing
> real_dev ifindex, if we pass real_dev ifindex then
> ip_route_output_ports() and ip6_route_output() will check for route
> through real_dev not through vlan interface.

Applied to 4.15/scsi-queue. Thank you!

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH v2] scsi: logging: update description of logging_level bits

2017-10-11 Thread Martin K. Petersen

Randy,

> Update the description of 'scsi_logging_level' from 8 4-bit nibbles
> to the (pre-git) reality of 10 3-bit bitfields.

Applied to 4.15/scsi-queue. Thank you!

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH] scsi: fix doc. typo for I2O

2017-10-11 Thread Martin K. Petersen

Randy,

> Fix typo: I20 should be I2O.

Applied to 4.15/scsi-queue. Thanks!

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH 00/10] be2iscsi: driver update 11.4.0.1

2017-10-11 Thread Martin K. Petersen

Jitendra,

> This patch is generated against for-next branch.

Applied to 4.15/scsi-queue. Thank you!

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH 00/10] [SCSI] mpt3sas: Phase15 driver enhancements and fixes

2017-10-11 Thread Martin K. Petersen

Sreekanth,

> Phase15 driver enhancements and fixes.

Applied to 4.15/scsi-queue. Thank you!

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH v2] scsi: be2iscsi: Use kasprintf

2017-10-11 Thread Kyle Fortin
On Oct 11, 2017, at 11:36 AM, Himanshu Jha  wrote:
> 
> Use kasprintf instead of combination of kmalloc and sprintf.
> Also, remove BEISCSI_MSI_NAME macro used to specify size of string as
> kasprintf handles size computations.
> 
> Signed-off-by: Himanshu Jha 
> ---
> v2:
>   -remove the unnecessary macro BEISCSI_MSI_NAME. 
> 
> drivers/scsi/be2iscsi/be_main.c | 12 +---
> drivers/scsi/be2iscsi/be_main.h |  2 --
> 2 files changed, 5 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
> index b4542e7..6a9ee0e 100644
> --- a/drivers/scsi/be2iscsi/be_main.c
> +++ b/drivers/scsi/be2iscsi/be_main.c
> @@ -803,15 +803,14 @@ static int beiscsi_init_irqs(struct beiscsi_hba *phba)
> 
>   if (pcidev->msix_enabled) {
>   for (i = 0; i < phba->num_cpus; i++) {
> - phba->msi_name[i] = kzalloc(BEISCSI_MSI_NAME,
> - GFP_KERNEL);
> + phba->msi_name[i] = kasprintf(GFP_KERNEL,
> +   "beiscsi_%02x_%02x",
> +   phba->shost->host_no, i);
>   if (!phba->msi_name[i]) {
>   ret = -ENOMEM;
>   goto free_msix_irqs;
>   }
> 
> - sprintf(phba->msi_name[i], "beiscsi_%02x_%02x",
> - phba->shost->host_no, i);
>   ret = request_irq(pci_irq_vector(pcidev, i),
> be_isr_msix, 0, phba->msi_name[i],
> _context->be_eq[i]);
> @@ -824,13 +823,12 @@ static int beiscsi_init_irqs(struct beiscsi_hba *phba)
>   goto free_msix_irqs;
>   }
>   }
> - phba->msi_name[i] = kzalloc(BEISCSI_MSI_NAME, GFP_KERNEL);
> + phba->msi_name[i] = kasprintf(GFP_KERNEL, "beiscsi_mcc_%02x",
> +   phba->shost->host_no);
>   if (!phba->msi_name[i]) {
>   ret = -ENOMEM;
>   goto free_msix_irqs;
>   }
> - sprintf(phba->msi_name[i], "beiscsi_mcc_%02x",
> - phba->shost->host_no);
>   ret = request_irq(pci_irq_vector(pcidev, i), be_isr_mcc, 0,
> phba->msi_name[i], _context->be_eq[i]);
>   if (ret) {
> diff --git a/drivers/scsi/be2iscsi/be_main.h b/drivers/scsi/be2iscsi/be_main.h
> index 81ce3ff..8166de5 100644
> --- a/drivers/scsi/be2iscsi/be_main.h
> +++ b/drivers/scsi/be2iscsi/be_main.h
> @@ -155,8 +155,6 @@
> #define PAGES_REQUIRED(x) \
>   ((x < PAGE_SIZE) ? 1 :  ((x + PAGE_SIZE - 1) / PAGE_SIZE))
> 
> -#define BEISCSI_MSI_NAME 20 /* size of msi_name string */
> -
> #define MEM_DESCR_OFFSET 8
> #define BEISCSI_DEFQ_HDR 1
> #define BEISCSI_DEFQ_DATA 0
> -- 
> 2.7.4
> 

Looks good.

Reviewed-by: Kyle Fortin 



Re: [PATCH v2 1/4] scsi: ufs: Change HCI macro to actual bit position

2017-10-11 Thread Martin K. Petersen

Alim,

> Currently UFS HCI uses UFS_BIT() macro to get various bit position for
> the hardware registers status bits. Which makes code longer instead of
> shorter. This macro does not improve code readability as well.  Lets
> re-write these macro definition with the actual bit position.

Applied patches 1-4 to 4.15/scsi-queue. Thank you!

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH] scsi: libiscsi: fix shifting of DID_REQUEUE host byte

2017-10-11 Thread Martin K. Petersen

Johannes,

> The SCSI host byte should be shifted left by 16 in order to have
> scsi_decide_disposition() do the right thing (.i.e. requeue the
> command).

Applied to 4.14/scsi-fixes. Thank you!

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH 04/10] mpt3sas: Fix removal and addition of vSES device during host reset

2017-10-11 Thread Martin K. Petersen

Tomas,

> Sure, sorry for that, corrected too late in 8/10 should I resend with
> "Reviewed-by" ?

I'll fix it up.

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH] scsi: sd: add check for changing allow_restart

2017-10-11 Thread Martin K. Petersen

weiping,

> /sys/class/scsi_disk/0:2:0:0/allow_restart can be changed to 0 unexpectly by
> writing invalid string, like following:
>
> echo asdf > /sys/class/scsi_disk/0:2:0:0/allow_restart

Please switch to kstrtobool() and fix up manage_start_stop as well.

Thanks!

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH 04/10] mpt3sas: Fix removal and addition of vSES device during host reset

2017-10-11 Thread James Bottomley
On Wed, 2017-10-11 at 18:12 +0200, Tomas Henzl wrote:
> On 10/11/2017 05:56 PM, James Bottomley wrote:
> > 
> > On Wed, 2017-10-11 at 17:35 +0200, Tomas Henzl wrote:
> > > 
> > > On 10/10/2017 03:11 PM, Sreekanth Reddy wrote:
> > > > 
> > > > For Dev Handles who value is less than hba's phys count number
> > > >  driver will return HBA sas address value as a sas address.
> > > > So for Virtual SES device also driver was returning HBA sas
> > > > address
> > > > instead
> > > >  of Virtual SES sas address. So now updated the driver to
> > > > return
> > > >  Virtual SES's sas address for Virtual SES device instead of
> > > >  HBA's sas address.
> > > > 
> > > > Signed-off-by: Sreekanth Reddy 
> > > Signed-off-by: Tomas Henzl 
> > You mean Reviewed-by: I think?
> 
> Sure, sorry for that, corrected too late in 8/10
> should I resend with  "Reviewed-by" ?

It's probably OK, but please do so if there's another resend.
 Patchwork blindly captures what it sees, so the application has to be
hand modified to change Signed-off-by to Reviewed-by even if you resend
with Reviewed-by.

James



Re: [PATCH v8 03/10] md: Neither resync nor reshape while the system is frozen

2017-10-11 Thread Bart Van Assche
On Tue, 2017-10-10 at 18:48 -0700, Shaohua Li wrote:
> The problem is __md_stop_writes set some bit like MD_RECOVERY_FROZEN, which
> will prevent md_check_recovery restarting resync/reshape. I think we need
> preserve mddev->recovery in suspend prepare and restore after resume

Hello Shaohua,

As far as I can see __md_stop_writes() sets MD_RECOVERY_FROZEN and can set
MD_RECOVERY_INTR. Since md_check_recovery() clears MD_RECOVERY_INTR I think
it should be sufficient to save and restore the state of the
MD_RECOVERY_FROZEN flag. However, when I ran the following test:
* echo frozen > /sys/block/md0/md/sync_action
* cat /sys/block/md0/md/sync_action
* systemctl hibernate
* (power on system again)
* cat /sys/block/md0/md/sync_action

the output that appeared was as follows:

frozen
idle

Does that mean that a hibernate or suspend followed by a resume is sufficient
to clear the MD_RECOVERY_FROZEN flag for the md drivers and hence that the
patch at the start of this e-mail thread does not need any further
modifications?

Thanks,

Bart.

Re: [PATCH v2] scsi: logging: update description of logging_level bits

2017-10-11 Thread Kyle Fortin
Looks good.

Reviewed-by: Kyle Fortin 


[PATCH v2] scsi: logging: update description of logging_level bits

2017-10-11 Thread Randy Dunlap
From: Randy Dunlap 

Update the description of 'scsi_logging_level' from 8 4-bit nibbles
to the (pre-git) reality of 10 3-bit bitfields.

Signed-off-by: Randy Dunlap 
Reviewed-by: Kyle Fortin 
Reviewed-by: Steffen Maier 
---
 drivers/scsi/scsi_logging.h |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

v2: change 3-bit 'nibbles' to 3-bit bitfields.
add Reviewed-bys.

--- lnx-414-rc3.orig/drivers/scsi/scsi_logging.h
+++ lnx-414-rc3/drivers/scsi/scsi_logging.h
@@ -3,10 +3,10 @@
 
 
 /*
- * This defines the scsi logging feature.  It is a means by which the user
- * can select how much information they get about various goings on, and it
- * can be really useful for fault tracing.  The logging word is divided into
- * 8 nibbles, each of which describes a loglevel.  The division of things is
+ * This defines the scsi logging feature.  It is a means by which the user can
+ * select how much information they get about various goings on, and it can be
+ * really useful for fault tracing.  The logging word is divided into 10 3-bit
+ * bitfields, each of which describes a loglevel.  The division of things is
  * somewhat arbitrary, and the division of the word could be changed if it
  * were really needed for any reason.  The numbers below are the only place
  * where these are specified.  For a first go-around, 3 bits is more than



Re: [PATCH] scsi: logging_level: update bits description

2017-10-11 Thread Randy Dunlap
On 10/11/17 06:18, Steffen Maier wrote:
> 
> On 10/10/2017 09:32 PM, Kyle Fortin wrote:
>> On Oct 10, 2017, at 3:05 PM, Randy Dunlap  wrote:
>>> From: Randy Dunlap 
>>>
>>> Update the description of 'scsi_logging_level' from 8 4-bit nibbles
>>> to the (pre-git) reality of 10 3-bit 'nibbles'.
>>>
>>> Signed-off-by: Randy Dunlap 
>>> ---
>>> drivers/scsi/scsi_logging.h |    8 
>>> 1 file changed, 4 insertions(+), 4 deletions(-)
>>>
>>> --- lnx-414-rc3.orig/drivers/scsi/scsi_logging.h
>>> +++ lnx-414-rc3/drivers/scsi/scsi_logging.h
>>> @@ -3,10 +3,10 @@
>>>
>>>
>>> /*
>>> - * This defines the scsi logging feature.  It is a means by which the user
>>> - * can select how much information they get about various goings on, and it
>>> - * can be really useful for fault tracing.  The logging word is divided 
>>> into
> 
> nit pick: Why reflow and thus "change" these 3 lines even though the content 
> is the same?

Just to fit into max. of 80 characters per line. Changing it to only one long 
line
was weird.

>>> - * 8 nibbles, each of which describes a loglevel.  The division of things 
>>> is
>>> + * This defines the scsi logging feature.  It is a means by which the user 
>>> can
>>> + * select how much information they get about various goings on, and it 
>>> can be
>>> + * really useful for fault tracing.  The logging word is divided into 10 
>>> 3-bit
>>> + * 'nibbles', each of which describes a loglevel.  The division of things 
>>> is
>>
>> I think ‘bitfields' is more appropriate than ‘nibbles’ (a 4-bit construct in 
>> compute).
> 
> +1

OK.

>>>   * somewhat arbitrary, and the division of the word could be changed if it
>>>   * were really needed for any reason.  The numbers below are the only place
>>>   * where these are specified.  For a first go-around, 3 bits is more than
>>
>> Reviewed-by: Kyle Fortin 
> 
> Reviewed-by: Steffen Maier 
> 


-- 
~Randy


Re: [PATCH 10/10] mpt3sas: Bump mpt3sas driver version to v16.100.00.00

2017-10-11 Thread Tomas Henzl
On 10/10/2017 03:11 PM, Sreekanth Reddy wrote:
> Bump mpt3sas driver version to v16.100.00.00
>
> Signed-off-by: Sreekanth Reddy 

Reviewed-by: Tomas Henzl 
Tomas



Re: [PATCH 09/10] mpt3sas: Adding support for SAS3616 HBA device

2017-10-11 Thread Tomas Henzl
On 10/10/2017 03:11 PM, Sreekanth Reddy wrote:
> Adding PNP ID of Mercator i.e. SAS3616 HBA device.
> Its device ID is 0xD1 and vendor ID is 0x1000.
>
> Signed-off-by: Sreekanth Reddy 

Reviewed-by: Tomas Henzl 
Tomas



Re: [PATCH 04/10] mpt3sas: Fix removal and addition of vSES device during host reset

2017-10-11 Thread Tomas Henzl
On 10/11/2017 05:56 PM, James Bottomley wrote:
> On Wed, 2017-10-11 at 17:35 +0200, Tomas Henzl wrote:
>> On 10/10/2017 03:11 PM, Sreekanth Reddy wrote:
>>> For Dev Handles who value is less than hba's phys count number
>>>  driver will return HBA sas address value as a sas address.
>>> So for Virtual SES device also driver was returning HBA sas address
>>> instead
>>>  of Virtual SES sas address. So now updated the driver to return
>>>  Virtual SES's sas address for Virtual SES device instead of
>>>  HBA's sas address.
>>>
>>> Signed-off-by: Sreekanth Reddy 
>> Signed-off-by: Tomas Henzl 
> You mean Reviewed-by: I think?

Sure, sorry for that, corrected too late in 8/10
should I resend with  "Reviewed-by" ?

Tomas

>
> James
>



Re: [PATCH 08/10] mpt3sas: Fix possibility of using invalid Enclosure Handles for SAS device after host reset

2017-10-11 Thread Tomas Henzl
On 10/10/2017 03:11 PM, Sreekanth Reddy wrote:
> Enclosure handles are not updated after host reset.
> As a result, driver device structure is holding previously
>  assigned enclosure handle which is different from the
>  enclosure handle populated in the corresponding device page.
>
> Modified the driver to update devices enclosure handles after
>  host reset to current value, by referring the enclosure handles
>  from corresponding device pages
>
> Signed-off-by: Sreekanth Reddy 

Reviewed-by: Tomas Henzl 



Re: [PATCH 08/10] mpt3sas: Fix possibility of using invalid Enclosure Handles for SAS device after host reset

2017-10-11 Thread Tomas Henzl
On 10/10/2017 03:11 PM, Sreekanth Reddy wrote:
> Enclosure handles are not updated after host reset.
> As a result, driver device structure is holding previously
>  assigned enclosure handle which is different from the
>  enclosure handle populated in the corresponding device page.
>
> Modified the driver to update devices enclosure handles after
>  host reset to current value, by referring the enclosure handles
>  from corresponding device pages
>
> Signed-off-by: Sreekanth Reddy 
> ---
>  drivers/scsi/mpt3sas/mpt3sas_scsih.c | 117 
> ---
>  1 file changed, 81 insertions(+), 36 deletions(-)
>
> diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c 
> b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
> index 17b934b..b819914 100644
> --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
> +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
> @@ -5383,6 +5383,52 @@ _scsih_check_access_status(struct MPT3SAS_ADAPTER 
> *ioc, u64 sas_address,
>  }
>  
>  /**
> + * _scsih_get_enclosure_logicalid_chassis_slot - get device's
> + *   EnclosureLogicalID and ChassisSlot information.
> + * @ioc: per adapter object
> + * @sas_device_pg0: SAS device page0
> + * @sas_device: per sas device object
> + *
> + * Returns nothing.
> + */
> +static void
> +_scsih_get_enclosure_logicalid_chassis_slot(struct MPT3SAS_ADAPTER *ioc,
> + Mpi2SasDevicePage0_t *sas_device_pg0, struct _sas_device *sas_device)
> +{
> + Mpi2ConfigReply_t mpi_reply;
> + Mpi2SasEnclosurePage0_t enclosure_pg0;
> +
> + if (!sas_device_pg0 || !sas_device)
> + return;

This test^ implies that  sas_device_pg0 or  sas_device can be null,
is that true?

Signed-off-by: Tomas Henzl 



Re: [PATCH 07/10] mpt3sas: Display chassis slot information of the drive

2017-10-11 Thread Tomas Henzl
On 10/10/2017 03:11 PM, Sreekanth Reddy wrote:
> Display chassis slot information along with other drive location parameters
>  such as slot number and connector name in the logs; if chassis slot
>  validity bit is set in 'SAS Enclosure Page 0' while adding the drive.
>
> Signed-off-by: Sreekanth Reddy 

Signed-off-by: Tomas Henzl 

Tomas



Re: [PATCH 04/10] mpt3sas: Fix removal and addition of vSES device during host reset

2017-10-11 Thread James Bottomley
On Wed, 2017-10-11 at 17:35 +0200, Tomas Henzl wrote:
> On 10/10/2017 03:11 PM, Sreekanth Reddy wrote:
> > 
> > For Dev Handles who value is less than hba's phys count number
> >  driver will return HBA sas address value as a sas address.
> > So for Virtual SES device also driver was returning HBA sas address
> > instead
> >  of Virtual SES sas address. So now updated the driver to return
> >  Virtual SES's sas address for Virtual SES device instead of
> >  HBA's sas address.
> > 
> > Signed-off-by: Sreekanth Reddy 
> 
> Signed-off-by: Tomas Henzl 

You mean Reviewed-by: I think?

James



Re: [PATCH 06/10] mpt3sas: Updated MPI headers to v2.00.48

2017-10-11 Thread Tomas Henzl
On 10/10/2017 03:11 PM, Sreekanth Reddy wrote:
> Updated MPI headers to v2.00.48
>
> Signed-off-by: Sreekanth Reddy 

Signed-off-by: Tomas Henzl 
Tomas



Re: [PATCH 05/10] mpt3sas: Fix IO error occurs on pulling out a drive from RAID1 volume created on two SATA drive

2017-10-11 Thread Tomas Henzl
On 10/10/2017 03:11 PM, Sreekanth Reddy wrote:
> Whenever IO for raid volume fails with IOCStatus
>  "MPI2_IOCSTATUS_SCSI_IOC_TERMINATED"and SCSIStatus equal to
>  "(MPI2_SCSI_STATE_TERMINATED | MPI2_SCSI_STATE_NO_SCSI_STATUS)"
>  then return the IO to SML with "DID_RESET"
>  (i.e. retry the IO infinite times) host bytes.
>
> Earlier driver is returning the IO with "DID_SOFT_ERROR"
>  that reties the IO quickly for five times but still
>  firmware needed some more time and hence IOs were failing.
>
> Signed-off-by: Sreekanth Reddy 

Signed-off-by: Tomas Henzl 
Tomas



[PATCH v2] scsi: be2iscsi: Use kasprintf

2017-10-11 Thread Himanshu Jha
Use kasprintf instead of combination of kmalloc and sprintf.
Also, remove BEISCSI_MSI_NAME macro used to specify size of string as
kasprintf handles size computations.

Signed-off-by: Himanshu Jha 
---
v2:
   -remove the unnecessary macro BEISCSI_MSI_NAME. 

 drivers/scsi/be2iscsi/be_main.c | 12 +---
 drivers/scsi/be2iscsi/be_main.h |  2 --
 2 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index b4542e7..6a9ee0e 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -803,15 +803,14 @@ static int beiscsi_init_irqs(struct beiscsi_hba *phba)
 
if (pcidev->msix_enabled) {
for (i = 0; i < phba->num_cpus; i++) {
-   phba->msi_name[i] = kzalloc(BEISCSI_MSI_NAME,
-   GFP_KERNEL);
+   phba->msi_name[i] = kasprintf(GFP_KERNEL,
+ "beiscsi_%02x_%02x",
+ phba->shost->host_no, i);
if (!phba->msi_name[i]) {
ret = -ENOMEM;
goto free_msix_irqs;
}
 
-   sprintf(phba->msi_name[i], "beiscsi_%02x_%02x",
-   phba->shost->host_no, i);
ret = request_irq(pci_irq_vector(pcidev, i),
  be_isr_msix, 0, phba->msi_name[i],
  _context->be_eq[i]);
@@ -824,13 +823,12 @@ static int beiscsi_init_irqs(struct beiscsi_hba *phba)
goto free_msix_irqs;
}
}
-   phba->msi_name[i] = kzalloc(BEISCSI_MSI_NAME, GFP_KERNEL);
+   phba->msi_name[i] = kasprintf(GFP_KERNEL, "beiscsi_mcc_%02x",
+ phba->shost->host_no);
if (!phba->msi_name[i]) {
ret = -ENOMEM;
goto free_msix_irqs;
}
-   sprintf(phba->msi_name[i], "beiscsi_mcc_%02x",
-   phba->shost->host_no);
ret = request_irq(pci_irq_vector(pcidev, i), be_isr_mcc, 0,
  phba->msi_name[i], _context->be_eq[i]);
if (ret) {
diff --git a/drivers/scsi/be2iscsi/be_main.h b/drivers/scsi/be2iscsi/be_main.h
index 81ce3ff..8166de5 100644
--- a/drivers/scsi/be2iscsi/be_main.h
+++ b/drivers/scsi/be2iscsi/be_main.h
@@ -155,8 +155,6 @@
 #define PAGES_REQUIRED(x) \
((x < PAGE_SIZE) ? 1 :  ((x + PAGE_SIZE - 1) / PAGE_SIZE))
 
-#define BEISCSI_MSI_NAME 20 /* size of msi_name string */
-
 #define MEM_DESCR_OFFSET 8
 #define BEISCSI_DEFQ_HDR 1
 #define BEISCSI_DEFQ_DATA 0
-- 
2.7.4



Re: [PATCH 04/10] mpt3sas: Fix removal and addition of vSES device during host reset

2017-10-11 Thread Tomas Henzl
On 10/10/2017 03:11 PM, Sreekanth Reddy wrote:
> For Dev Handles who value is less than hba's phys count number
>  driver will return HBA sas address value as a sas address.
> So for Virtual SES device also driver was returning HBA sas address instead
>  of Virtual SES sas address. So now updated the driver to return
>  Virtual SES's sas address for Virtual SES device instead of
>  HBA's sas address.
>
> Signed-off-by: Sreekanth Reddy 

Signed-off-by: Tomas Henzl 



Re: [PATCH 03/10] mpt3sas: Reduce memory footprints in kdump kernel

2017-10-11 Thread Tomas Henzl
On 10/10/2017 03:11 PM, Sreekanth Reddy wrote:
> To reduce the memory footprints of the driver in kdump kernel,
>  we have made below driver setting when system boots in to kdump kernel,
>
> 1. Used single MSI-x vector.
> 2. Disable RDPQ mode.
> 3. Set sg_table_size to 32 by default.
> 4) Set SCSI IO Queue depth to 200.
>
> Signed-off-by: Sreekanth Reddy 

I think that preferred is (though not much used yet) instead of 'reset_devices'
to use a 'is_kdump_kernel()' function. 

Signed-off-by: Tomas Henzl 



Re: [PATCH 02/10] mpt3sas: Fixed memory leaks in driver

2017-10-11 Thread Tomas Henzl
On 10/10/2017 03:11 PM, Sreekanth Reddy wrote:
> Fixed below memory leak in driver,
>
> * While removing Expander devices - we are removing expander
>  device entry from the list before freeing it's child devices,
>  so while freeing child device we are finding its parent device
>  node as NULL and so we are not freeing the child device's
>  allocated data structures.
>  Updated the driver to remove the expander device from the list
>  only after freeing all its child devices.
>
> Signed-off-by: Sreekanth Reddy 

Signed-off-by: Tomas Henzl 

Tomas



Re: [PATCH 01/10] mpt3sas: Processing of Cable Exception events

2017-10-11 Thread Tomas Henzl
On 10/10/2017 03:11 PM, Sreekanth Reddy wrote:
> Earlier Active Cable Exception event with reason code
> "Cable Degraded (0x02))" was added only for Active Cable,
> Now this event is extended to Passive cable too.
> So re-arranged display message accordingly.
>
> Also added Cable Exception Event even for SAS3008 & SAS3108 HBAs
> (i.e. MPI 2.5 spec supporting HBAs) earlier this event was
> enabled only for MPI 2.6 spec supporting HBA devices.
>
> Signed-off-by: Sreekanth Reddy 

Signed-off-by: Tomas Henzl 

Tomas



[PATCH] scsi: libcxgbi: simplify task->hdr allocation for mgmt cmds

2017-10-11 Thread Varun Prakash
In case of mgmt cmds task->hdr is dereferenced after
transmitting the pdu in iscsi_tcp_task_xmit()
to handle this case current code increments the Tx skb
reference count and frees the skb in cxgbi_cleanup_task(),
in some error cases this results in skb leak.

To fix this in case of mgmt cmds allocate a separate
buffer for iSCSI hdr and free this buffer in
cxgbi_cleanup_task().

Signed-off-by: Varun Prakash 
---
 drivers/scsi/cxgbi/libcxgbi.c | 43 ---
 drivers/scsi/cxgbi/libcxgbi.h |  1 -
 2 files changed, 28 insertions(+), 16 deletions(-)

diff --git a/drivers/scsi/cxgbi/libcxgbi.c b/drivers/scsi/cxgbi/libcxgbi.c
index 8503ac9..7e81bf8 100644
--- a/drivers/scsi/cxgbi/libcxgbi.c
+++ b/drivers/scsi/cxgbi/libcxgbi.c
@@ -1889,16 +1889,13 @@ int cxgbi_conn_alloc_pdu(struct iscsi_task *task, u8 
opcode)
struct iscsi_tcp_task *tcp_task = task->dd_data;
struct cxgbi_task_data *tdata = iscsi_task_cxgbi_data(task);
struct scsi_cmnd *sc = task->sc;
+   struct cxgbi_sock *csk = cconn->cep->csk;
+   struct net_device *ndev = cdev->ports[csk->port_id];
int headroom = SKB_TX_ISCSI_PDU_HEADER_MAX;
 
tcp_task->dd_data = tdata;
task->hdr = NULL;
 
-   if (tdata->skb) {
-   kfree_skb(tdata->skb);
-   tdata->skb = NULL;
-   }
-
if (SKB_MAX_HEAD(cdev->skb_tx_rsvd) > (512 * MAX_SKB_FRAGS) &&
(opcode == ISCSI_OP_SCSI_DATA_OUT ||
 (opcode == ISCSI_OP_SCSI_CMD &&
@@ -1910,15 +1907,23 @@ int cxgbi_conn_alloc_pdu(struct iscsi_task *task, u8 
opcode)
 
tdata->skb = alloc_skb(cdev->skb_tx_rsvd + headroom, GFP_ATOMIC);
if (!tdata->skb) {
-   struct cxgbi_sock *csk = cconn->cep->csk;
-   struct net_device *ndev = cdev->ports[csk->port_id];
ndev->stats.tx_dropped++;
return -ENOMEM;
}
 
-   skb_get(tdata->skb);
skb_reserve(tdata->skb, cdev->skb_tx_rsvd);
-   task->hdr = (struct iscsi_hdr *)tdata->skb->data;
+
+   if (task->sc) {
+   task->hdr = (struct iscsi_hdr *)tdata->skb->data;
+   } else {
+   task->hdr = kzalloc(SKB_TX_ISCSI_PDU_HEADER_MAX, GFP_KERNEL);
+   if (!task->hdr) {
+   __kfree_skb(tdata->skb);
+   tdata->skb = NULL;
+   ndev->stats.tx_dropped++;
+   return -ENOMEM;
+   }
+   }
task->hdr_max = SKB_TX_ISCSI_PDU_HEADER_MAX; /* BHS + AHS */
 
/* data_out uses scsi_cmd's itt */
@@ -2062,9 +2067,9 @@ int cxgbi_conn_xmit_pdu(struct iscsi_task *task)
unsigned int datalen;
int err;
 
-   if (!skb || cxgbi_skcb_test_flag(skb, SKCBF_TX_DONE)) {
+   if (!skb) {
log_debug(1 << CXGBI_DBG_ISCSI | 1 << CXGBI_DBG_PDU_TX,
-   "task 0x%p, skb 0x%p\n", task, skb);
+   "task 0x%p\n", task);
return 0;
}
 
@@ -2076,6 +2081,7 @@ int cxgbi_conn_xmit_pdu(struct iscsi_task *task)
return -EPIPE;
}
 
+   tdata->skb = NULL;
datalen = skb->data_len;
 
/* write ppod first if using ofldq to write ppod */
@@ -2089,6 +2095,9 @@ int cxgbi_conn_xmit_pdu(struct iscsi_task *task)
/* continue. Let fl get the data */
}
 
+   if (!task->sc)
+   memcpy(skb->data, task->hdr, SKB_TX_ISCSI_PDU_HEADER_MAX);
+
err = cxgbi_sock_send_pdus(cconn->cep->csk, skb);
if (err > 0) {
int pdulen = err;
@@ -2104,7 +2113,6 @@ int cxgbi_conn_xmit_pdu(struct iscsi_task *task)
pdulen += ISCSI_DIGEST_SIZE;
 
task->conn->txdata_octets += pdulen;
-   cxgbi_skcb_set_flag(skb, SKCBF_TX_DONE);
return 0;
}
 
@@ -2113,6 +2121,7 @@ int cxgbi_conn_xmit_pdu(struct iscsi_task *task)
"task 0x%p, skb 0x%p, len %u/%u, %d EAGAIN.\n",
task, skb, skb->len, skb->data_len, err);
/* reset skb to send when we are called again */
+   tdata->skb = skb;
return err;
}
 
@@ -2120,8 +2129,7 @@ int cxgbi_conn_xmit_pdu(struct iscsi_task *task)
"itt 0x%x, skb 0x%p, len %u/%u, xmit err %d.\n",
task->itt, skb, skb->len, skb->data_len, err);
 
-   __kfree_skb(tdata->skb);
-   tdata->skb = NULL;
+   __kfree_skb(skb);
 
iscsi_conn_printk(KERN_ERR, task->conn, "xmit err %d.\n", err);
iscsi_conn_failure(task->conn, ISCSI_ERR_XMIT_FAILED);
@@ -2146,9 +2154,14 @@ void cxgbi_cleanup_task(struct iscsi_task *task)
task, tdata->skb, task->hdr_itt);
 
tcp_task->dd_data = NULL;
+
+   if (!task->sc)
+   kfree(task->hdr);
+   task->hdr = NULL;
+
/*  never reached the xmit task callout */
if 

[PATCH] scsi: cxgb4i: fix Tx skb leak

2017-10-11 Thread Varun Prakash
In case of connection reset Tx skb queue can have some
skbs which are not transmitted so purge Tx skb queue in
release_offload_resources() to avoid skb leak.

Signed-off-by: Varun Prakash 
---
 drivers/scsi/cxgbi/cxgb4i/cxgb4i.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/scsi/cxgbi/cxgb4i/cxgb4i.c 
b/drivers/scsi/cxgbi/cxgb4i/cxgb4i.c
index 1d02cf9..30d5f0e 100644
--- a/drivers/scsi/cxgbi/cxgb4i/cxgb4i.c
+++ b/drivers/scsi/cxgbi/cxgb4i/cxgb4i.c
@@ -1575,6 +1575,7 @@ static void release_offload_resources(struct cxgbi_sock 
*csk)
csk, csk->state, csk->flags, csk->tid);
 
cxgbi_sock_free_cpl_skbs(csk);
+   cxgbi_sock_purge_write_queue(csk);
if (csk->wr_cred != csk->wr_max_cred) {
cxgbi_sock_purge_wr_queue(csk);
cxgbi_sock_reset_wr_list(csk);
-- 
2.0.2



Re: [PATCH] scsi: use set_host_byte instead of open-coding it

2017-10-11 Thread Johannes Thumshirn
On Wed, Oct 11, 2017 at 03:05:40PM +0200, Steffen Maier wrote:
> Maybe I misunderstand, but doesn't set_host_byte only set the host byte but
> leave the other 3 parts untouched in c->result?
> 
> static inline void set_host_byte(struct scsi_cmnd *cmd, char status)
> {
>   cmd->result = (cmd->result & 0xff00) | (status << 16);
> }
> 
> In contrast, assigning something to c->result resets all parts.
> If so, the semantic patch would introduce a subtle semantic change.
> Unless it's guaranteed that in all the touched cases, c->result always has 0
> for status, message, and driver byte before calling set_host_byte().

Yes it does, another case I'll have to add to my coccinelle spatch, thanks for
reminding me (and I'm also doing it for set_msg_byte() and set_driver_byte(),
the status byte will be done manually probably).

> 
> Bart's suggestion also sounds nice.

Yes I'm working on implementing it currently.

> 
> FYI: Originally, I only thought about using set_host_byte in that one place
> fix of yours; I did not expect a full framework rework.

Oh well:
$ git diff --stat master..
[..]
 80 files changed, 589 insertions(+), 540 deletions(-)

Byte,
Johannes

-- 
Johannes Thumshirn  Storage
jthumsh...@suse.de+49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850


Re: [PATCH] scsi: logging_level: update bits description

2017-10-11 Thread Steffen Maier


On 10/10/2017 09:32 PM, Kyle Fortin wrote:

On Oct 10, 2017, at 3:05 PM, Randy Dunlap  wrote:

From: Randy Dunlap 

Update the description of 'scsi_logging_level' from 8 4-bit nibbles
to the (pre-git) reality of 10 3-bit 'nibbles'.

Signed-off-by: Randy Dunlap 
---
drivers/scsi/scsi_logging.h |8 
1 file changed, 4 insertions(+), 4 deletions(-)

--- lnx-414-rc3.orig/drivers/scsi/scsi_logging.h
+++ lnx-414-rc3/drivers/scsi/scsi_logging.h
@@ -3,10 +3,10 @@


/*
- * This defines the scsi logging feature.  It is a means by which the user
- * can select how much information they get about various goings on, and it
- * can be really useful for fault tracing.  The logging word is divided into


nit pick: Why reflow and thus "change" these 3 lines even though the 
content is the same?



- * 8 nibbles, each of which describes a loglevel.  The division of things is
+ * This defines the scsi logging feature.  It is a means by which the user can
+ * select how much information they get about various goings on, and it can be
+ * really useful for fault tracing.  The logging word is divided into 10 3-bit
+ * 'nibbles', each of which describes a loglevel.  The division of things is


I think ‘bitfields' is more appropriate than ‘nibbles’ (a 4-bit construct in 
compute).


+1


  * somewhat arbitrary, and the division of the word could be changed if it
  * were really needed for any reason.  The numbers below are the only place
  * where these are specified.  For a first go-around, 3 bits is more than


Reviewed-by: Kyle Fortin 


Reviewed-by: Steffen Maier 

--
Mit freundlichen Grüßen / Kind regards
Steffen Maier

Linux on z Systems Development

IBM Deutschland Research & Development GmbH
Vorsitzende des Aufsichtsrats: Martina Koederitz
Geschaeftsfuehrung: Dirk Wittkopp
Sitz der Gesellschaft: Boeblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294



Re: [PATCH] scsi: use set_host_byte instead of open-coding it

2017-10-11 Thread Steffen Maier


On 10/10/2017 05:29 PM, Johannes Thumshirn wrote:

Call set_host_byte() instead of open-coding it.

Converted using this simple Coccinelle spatch


@@
local idexpression struct scsi_cmnd *c;
expression E1;
@@

- c->result = E1 << 16;
+ set_host_byte(c, E1);


Maybe I misunderstand, but doesn't set_host_byte only set the host byte 
but leave the other 3 parts untouched in c->result?


static inline void set_host_byte(struct scsi_cmnd *cmd, char status)
{
cmd->result = (cmd->result & 0xff00) | (status << 16);
}

In contrast, assigning something to c->result resets all parts.
If so, the semantic patch would introduce a subtle semantic change.
Unless it's guaranteed that in all the touched cases, c->result always 
has 0 for status, message, and driver byte before calling set_host_byte().


Bart's suggestion also sounds nice.

FYI: Originally, I only thought about using set_host_byte in that one 
place fix of yours; I did not expect a full framework rework.


--
Mit freundlichen Grüßen / Kind regards
Steffen Maier

Linux on z Systems Development

IBM Deutschland Research & Development GmbH
Vorsitzende des Aufsichtsrats: Martina Koederitz
Geschaeftsfuehrung: Dirk Wittkopp
Sitz der Gesellschaft: Boeblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294



Re: [PATCH 12/13] kthread: Convert callback to use from_timer()

2017-10-11 Thread Petr Mladek
On Wed 2017-10-04 16:27:06, Kees Cook wrote:
> In preparation for unconditionally passing the struct timer_list pointer
> to all timer callbacks, switch kthread to use from_timer() and pass the
> timer pointer explicitly.
> 
> Cc: Andrew Morton 
> Cc: Petr Mladek 
> Cc: Tejun Heo 
> Cc: Thomas Gleixner 
> Cc: Oleg Nesterov 
> Signed-off-by: Kees Cook 

Reviewed-by: Petr Mladek 

Best Regards,
Petr


Re: [PATCH 11/13] timer: Remove expires argument from __TIMER_INITIALIZER()

2017-10-11 Thread Petr Mladek
On Wed 2017-10-04 16:27:05, Kees Cook wrote:
> The expires field is normally initialized during the first mod_timer()
> call. It was unused by all callers, so remove it from the macro.
> 
> Signed-off-by: Kees Cook 
> ---
>  include/linux/kthread.h   | 2 +-
>  include/linux/timer.h | 5 ++---
>  include/linux/workqueue.h | 2 +-
>  3 files changed, 4 insertions(+), 5 deletions(-)

I was primary interested into the change in kthread.h. But the entire
patch is simple and looks fine:

Reviewed-by: Petr Mladek 

Best Regards,
Petr


Re: [PATCH 2/2] hpsa: destroy sas transport properties before scsi_host

2017-10-11 Thread Martin Wilck
On Tue, 2017-10-10 at 23:04 +, Don Brace wrote:
> Now that Hannes's patch  9441284fbc39610c0f9ec0ed118ff85d78352906
> has been applied, this patch corrects the stack trace issue.
> 
> Would you like to re-submit this patch or would you like me to send
> it up?
> I'll run some quick tests if you do decide to send it up. 
> If you want me to send it up, you will get the credit anyway.

>From my PoV, just go ahead and re-submit. It'll be faster than me
diving into this again.

Thanks,
Martin



dick.kenn...@broadcom.com , james.sm...@broadcom.com, h...@suse.com, martin.peter...@oracle.com

2017-10-11 Thread Gomonovych, Vasyl
>From 1d3f6e197b8f9027910bf4ab1e97e69e3d77faf9 Mon Sep 17 00:00:00 2001
From: Vasyl Gomonovych 
Date: Wed, 11 Oct 2017 10:47:03 +0200
Subject: [PATCH] scsi: lpfc: fix kzalloc-simple.cocci warnings

drivers/scsi/lpfc/lpfc_debugfs.c:5460:22-29: WARNING: kzalloc should
be used for phba -> nvmeio_trc, instead of kmalloc/memset
drivers/scsi/lpfc/lpfc_debugfs.c:2230:20-27: WARNING: kzalloc should
be used for phba -> nvmeio_trc, instead of kmalloc/memset

 Use kzalloc rather than kmalloc followed by memset with 0

Generated by: scripts/coccinelle/api/alloc/kzalloc-simple.cocci
---
 drivers/scsi/lpfc/lpfc_debugfs.c | 9 ++---
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
index d50c481..2bf5ad3 100644
--- a/drivers/scsi/lpfc/lpfc_debugfs.c
+++ b/drivers/scsi/lpfc/lpfc_debugfs.c
@@ -2227,7 +2227,7 @@
 kfree(phba->nvmeio_trc);

 /* Allocate new trace buffer and initialize */
-phba->nvmeio_trc = kmalloc((sizeof(struct lpfc_debugfs_nvmeio_trc) *
+phba->nvmeio_trc = kzalloc((sizeof(struct lpfc_debugfs_nvmeio_trc) *
 sz), GFP_KERNEL);
 if (!phba->nvmeio_trc) {
 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
@@ -2235,8 +2235,6 @@
 "nvmeio_trc buffer\n");
 return -ENOMEM;
 }
-memset(phba->nvmeio_trc, 0,
-   (sizeof(struct lpfc_debugfs_nvmeio_trc) * sz));
 atomic_set(>nvmeio_trc_cnt, 0);
 phba->nvmeio_trc_on = 0;
 phba->nvmeio_trc_output_idx = 0;
@@ -5457,7 +5455,7 @@ static int lpfc_idiag_cmd_get(const char __user
*buf, size_t nbytes,
 phba->nvmeio_trc_size = lpfc_debugfs_max_nvmeio_trc;

 /* Allocate trace buffer and initialize */
-phba->nvmeio_trc = kmalloc(
+phba->nvmeio_trc = kzalloc(
 (sizeof(struct lpfc_debugfs_nvmeio_trc) *
 phba->nvmeio_trc_size), GFP_KERNEL);

@@ -5467,9 +5465,6 @@ static int lpfc_idiag_cmd_get(const char __user
*buf, size_t nbytes,
 "nvmeio_trc buffer\n");
 goto nvmeio_off;
 }
-memset(phba->nvmeio_trc, 0,
-   (sizeof(struct lpfc_debugfs_nvmeio_trc) *
-   phba->nvmeio_trc_size));
 phba->nvmeio_trc_on = 1;
 phba->nvmeio_trc_output_idx = 0;
 phba->nvmeio_trc = NULL;
-- 
1.9.1


Re: [PATCH] scsi: be2iscsi: Use kasprintf

2017-10-11 Thread Himanshu Jha
On Tue, Oct 10, 2017 at 05:54:15PM -0400, Kyle Fortin wrote:
> Hi Himanshu,
> 
> On Oct 6, 2017, at 2:57 PM, Himanshu Jha  wrote:
> > 
> > Use kasprintf instead of combination of kmalloc and sprintf.
> > 
> > Signed-off-by: Himanshu Jha 
> > ---
> > drivers/scsi/be2iscsi/be_main.c | 12 +---
> > 1 file changed, 5 insertions(+), 7 deletions(-)
> > 
> > diff --git a/drivers/scsi/be2iscsi/be_main.c 
> > b/drivers/scsi/be2iscsi/be_main.c
> > index b4542e7..6a9ee0e 100644
> > --- a/drivers/scsi/be2iscsi/be_main.c
> > +++ b/drivers/scsi/be2iscsi/be_main.c
> > @@ -803,15 +803,14 @@ static int beiscsi_init_irqs(struct beiscsi_hba *phba)
> > 
> > if (pcidev->msix_enabled) {
> > for (i = 0; i < phba->num_cpus; i++) {
> > -   phba->msi_name[i] = kzalloc(BEISCSI_MSI_NAME,
> > -   GFP_KERNEL);
> > +   phba->msi_name[i] = kasprintf(GFP_KERNEL,
> > + "beiscsi_%02x_%02x",
> > + phba->shost->host_no, i);
> > if (!phba->msi_name[i]) {
> > ret = -ENOMEM;
> > goto free_msix_irqs;
> > }
> > 
> > -   sprintf(phba->msi_name[i], "beiscsi_%02x_%02x",
> > -   phba->shost->host_no, i);
> > ret = request_irq(pci_irq_vector(pcidev, i),
> >   be_isr_msix, 0, phba->msi_name[i],
> >   _context->be_eq[i]);
> > @@ -824,13 +823,12 @@ static int beiscsi_init_irqs(struct beiscsi_hba *phba)
> > goto free_msix_irqs;
> > }
> > }
> > -   phba->msi_name[i] = kzalloc(BEISCSI_MSI_NAME, GFP_KERNEL);
> > +   phba->msi_name[i] = kasprintf(GFP_KERNEL, "beiscsi_mcc_%02x",
> > + phba->shost->host_no);
> > if (!phba->msi_name[i]) {
> > ret = -ENOMEM;
> > goto free_msix_irqs;
> > }
> > -   sprintf(phba->msi_name[i], "beiscsi_mcc_%02x",
> > -   phba->shost->host_no);
> > ret = request_irq(pci_irq_vector(pcidev, i), be_isr_mcc, 0,
> >   phba->msi_name[i], _context->be_eq[i]);
> > if (ret) {
> > -- 
> > 2.7.4
> 
> Since you are getting rid of the only use for BEISCSI_MSI_NAME within 
> drivers/scsi/be2iscsi/be_main.h, that should be removed too.

Yes, that should be removed! Thanks for pointing that out.
I will send a v2 patch with the update.

> --
> Kyle Fortin - Oracle Linux Engineering
> 
> 
> 
>