Re: [PATCH] scsi: csiostor: remove automatic irq affinity assignment

2018-07-31 Thread Hannes Reinecke
On 07/31/2018 05:07 PM, Varun Prakash wrote:
> If number of interrupt vectors are more than num_online_cpus()
> then pci_alloc_irq_vectors_affinity() assigns cpumask based
> on num_possible_cpus() to the remaining vectors because of
> this interrupt does not generate for these vectors.
> 
> This patch fixes this issue by using pci_alloc_irq_vectors()
> instead of pci_alloc_irq_vectors_affinity().
> 
> Signed-off-by: Varun Prakash 
> ---
>  drivers/scsi/csiostor/csio_isr.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/scsi/csiostor/csio_isr.c 
> b/drivers/scsi/csiostor/csio_isr.c
> index 7c88147..8b92c59 100644
> --- a/drivers/scsi/csiostor/csio_isr.c
> +++ b/drivers/scsi/csiostor/csio_isr.c
> @@ -480,7 +480,6 @@ csio_enable_msix(struct csio_hw *hw)
>   int i, j, k, n, min, cnt;
>   int extra = CSIO_EXTRA_VECS;
>   struct csio_scsi_cpu_info *info;
> - struct irq_affinity desc = { .pre_vectors = 2 };
>  
>   min = hw->num_pports + extra;
>   cnt = hw->num_sqsets + extra;
> @@ -491,8 +490,7 @@ csio_enable_msix(struct csio_hw *hw)
>  
>   csio_dbg(hw, "FW supp #niq:%d, trying %d msix's\n", hw->cfg_niq, cnt);
>  
> - cnt = pci_alloc_irq_vectors_affinity(hw->pdev, min, cnt,
> - PCI_IRQ_MSIX | PCI_IRQ_AFFINITY, &desc);
> + cnt = pci_alloc_irq_vectors(hw->pdev, min, cnt, PCI_IRQ_MSIX);
>   if (cnt < 0)
>   return cnt;
>  
> 
Hmm.
That patch (and the reasoning leading up to it) really sound dodgy.
I'd rather fix the interrupt affinity code to handle this case correctly.
Thomas, can you help here?

Cheers,

Hannes
-- 
Dr. Hannes ReineckeTeamlead Storage & Networking
h...@suse.de   +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)


[PATCH v2 12/16] qla2xxx: Fix race between switch cmd completion and timeout

2018-07-31 Thread Himanshu Madhani
From: Quinn Tran 

Fix race condition between switch cmd completion and timeout
timer. Timer has popped triggers command free. On IOCB completion,
stale sp point was reused. Instead, an abort will be sent to FW
to nudge the command out of FW, where the normal completion
will take place.

RIP: 0010:qla2x00_chk_ms_status+0xf3/0x1b0 [qla2xxx]
Call Trace:

qla24xx_els_ct_entry.isra.15+0x1d4/0x2b0 [qla2xxx]
 qla24xx_msix_rsp_q+0x39/0xf0 [qla2xxx]
qla24xx_process_response_queue+0xbc/0x2b0 [qla2xxx]
qla24xx_msix_rsp_q+0x8a/0xf0 [qla2xxx]
__handle_irq_event_percpu+0xa0/0x1f0

Signed-off-by: Quinn Tran 
Signed-off-by: Himanshu Madhani 
---
 drivers/scsi/qla2xxx/qla_def.h  |  1 +
 drivers/scsi/qla2xxx/qla_gbl.h  |  2 +-
 drivers/scsi/qla2xxx/qla_init.c | 75 ++---
 3 files changed, 58 insertions(+), 20 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index 40bcf938cf4f..0fc563572fad 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -313,6 +313,7 @@ struct srb_cmd {
 #define SRB_CRC_CTX_DMA_VALID  BIT_2   /* DIF: context DMA valid */
 #define SRB_CRC_PROT_DMA_VALID BIT_4   /* DIF: prot DMA valid */
 #define SRB_CRC_CTX_DSD_VALID  BIT_5   /* DIF: dsd_list valid */
+#define SRB_WAKEUP_ON_COMP BIT_6
 
 /* To identify if a srb is of T10-CRC type. @sp => srb_t pointer */
 #define IS_PROT_IO(sp) (sp->flags & SRB_CRC_CTX_DSD_VALID)
diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
index 00fbd49a9a7a..6f2a37220a55 100644
--- a/drivers/scsi/qla2xxx/qla_gbl.h
+++ b/drivers/scsi/qla2xxx/qla_gbl.h
@@ -213,7 +213,7 @@ extern int qla24xx_post_upd_fcport_work(struct 
scsi_qla_host *, fc_port_t *);
 void qla2x00_handle_login_done_event(struct scsi_qla_host *, fc_port_t *,
uint16_t *);
 int qla24xx_post_gnl_work(struct scsi_qla_host *, fc_port_t *);
-int qla24xx_async_abort_cmd(srb_t *);
+int qla24xx_async_abort_cmd(srb_t *, bool);
 int qla24xx_post_relogin_work(struct scsi_qla_host *vha);
 
 /*
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index e92f60a73bc3..b5c1a1dea087 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -50,16 +50,15 @@ qla2x00_sp_timeout(struct timer_list *t)
 {
srb_t *sp = from_timer(sp, t, u.iocb_cmd.timer);
struct srb_iocb *iocb;
-   scsi_qla_host_t *vha = sp->vha;
struct req_que *req;
unsigned long flags;
 
-   spin_lock_irqsave(&vha->hw->hardware_lock, flags);
-   req = vha->hw->req_q_map[0];
+   spin_lock_irqsave(sp->qpair->qp_lock_ptr, flags);
+   req = sp->qpair->req;
req->outstanding_cmds[sp->handle] = NULL;
iocb = &sp->u.iocb_cmd;
+   spin_unlock_irqrestore(sp->qpair->qp_lock_ptr, flags);
iocb->timeout(sp);
-   spin_unlock_irqrestore(&vha->hw->hardware_lock, flags);
 }
 
 void
@@ -100,6 +99,8 @@ qla2x00_async_iocb_timeout(void *data)
srb_t *sp = data;
fc_port_t *fcport = sp->fcport;
struct srb_iocb *lio = &sp->u.iocb_cmd;
+   int rc, h;
+   unsigned long flags;
 
if (fcport) {
ql_dbg(ql_dbg_disc, fcport->vha, 0x2071,
@@ -114,11 +115,26 @@ qla2x00_async_iocb_timeout(void *data)
 
switch (sp->type) {
case SRB_LOGIN_CMD:
-   /* Retry as needed. */
-   lio->u.logio.data[0] = MBS_COMMAND_ERROR;
-   lio->u.logio.data[1] = lio->u.logio.flags & SRB_LOGIN_RETRIED ?
-   QLA_LOGIO_LOGIN_RETRIED : 0;
-   sp->done(sp, QLA_FUNCTION_TIMEOUT);
+   rc = qla24xx_async_abort_cmd(sp, false);
+   if (rc) {
+   /* Retry as needed. */
+   lio->u.logio.data[0] = MBS_COMMAND_ERROR;
+   lio->u.logio.data[1] =
+   lio->u.logio.flags & SRB_LOGIN_RETRIED ?
+   QLA_LOGIO_LOGIN_RETRIED : 0;
+   spin_lock_irqsave(sp->qpair->qp_lock_ptr, flags);
+   for (h = 1; h < sp->qpair->req->num_outstanding_cmds;
+   h++) {
+   if (sp->qpair->req->outstanding_cmds[h] ==
+   sp) {
+   sp->qpair->req->outstanding_cmds[h] =
+   NULL;
+   break;
+   }
+   }
+   spin_unlock_irqrestore(sp->qpair->qp_lock_ptr, flags);
+   sp->done(sp, QLA_FUNCTION_TIMEOUT);
+   }
break;
case SRB_LOGOUT_CMD:
case SRB_CT_PTHRU_CMD:
@@ -127,7 +143,21 @@ qla2x00_async_iocb_timeout(void *data)
case SRB_NACK_PRLI:
case SRB_NACK_LOGO:
case SRB_CTRL_VP:
-   sp->done(sp, QLA_FUNCT

[PATCH v2 08/16] qla2xxx: Fix session state stuck in Get Port DB

2018-07-31 Thread Himanshu Madhani
From: Quinn Tran 

This patch sets discovery state back to GNL (Get
Name List) when session is stuck at GPDB (Get Port
DataBase). This will allow state machine to retry
login and move session state ahead in discovery.

Signed-off-by: Quinn Tran 
Signed-off-by: Himanshu Madhani 
---
 drivers/scsi/qla2xxx/qla_init.c | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index 4a89aa93c315..f94335301c70 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -1152,9 +1152,12 @@ void qla24xx_handle_gpdb_event(scsi_qla_host_t *vha, 
struct event_arg *ea)
case PDS_PLOGI_COMPLETE:
case PDS_PRLI_PENDING:
case PDS_PRLI2_PENDING:
-   ql_dbg(ql_dbg_disc, vha, 0x20d5, "%s %d %8phC relogin needed\n",
-   __func__, __LINE__, fcport->port_name);
-   set_bit(RELOGIN_NEEDED, &vha->dpc_flags);
+   /* Set discovery state back to GNL to Relogin attempt */
+   if (qla_dual_mode_enabled(vha) ||
+   qla_ini_mode_enabled(vha)) {
+   fcport->disc_state = DSC_GNL;
+   set_bit(RELOGIN_NEEDED, &vha->dpc_flags);
+   }
return;
case PDS_LOGO_PENDING:
case PDS_PORT_UNAVAILABLE:
-- 
2.12.0



[PATCH v2 11/16] qla2xxx: Fix Management Server NPort handle reservation logic

2018-07-31 Thread Himanshu Madhani
From: Quinn Tran 

After selecting the NPort handle/loop_id, set a bit
in the loop_id_map to prevent others from selecting the same
NPort handle.

Signed-off-by: Quinn Tran 
Signed-off-by: Himanshu Madhani 
---
 drivers/scsi/qla2xxx/qla_gbl.h  |  1 +
 drivers/scsi/qla2xxx/qla_init.c | 28 
 drivers/scsi/qla2xxx/qla_mid.c  |  2 +-
 drivers/scsi/qla2xxx/qla_os.c   |  3 ++-
 4 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
index f68eb6096559..00fbd49a9a7a 100644
--- a/drivers/scsi/qla2xxx/qla_gbl.h
+++ b/drivers/scsi/qla2xxx/qla_gbl.h
@@ -118,6 +118,7 @@ extern int qla2x00_post_async_prlo_done_work(struct 
scsi_qla_host *,
 fc_port_t *, uint16_t *);
 int qla_post_iidma_work(struct scsi_qla_host *vha, fc_port_t *fcport);
 void qla_do_iidma_work(struct scsi_qla_host *vha, fc_port_t *fcport);
+int qla2x00_reserve_mgmt_server_loop_id(scsi_qla_host_t *);
 /*
  * Global Data in qla_os.c source file.
  */
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index 7a984f5e6f11..e92f60a73bc3 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -5615,6 +5615,34 @@ qla2x00_find_new_loop_id(scsi_qla_host_t *vha, fc_port_t 
*dev)
 }
 
 
+/* FW does not set aside Loop id for MGMT Server/FAh */
+int
+qla2x00_reserve_mgmt_server_loop_id(scsi_qla_host_t *vha)
+{
+   int loop_id = FC_NO_LOOP_ID;
+   int lid = NPH_MGMT_SERVER - vha->vp_idx;
+   unsigned long flags;
+   struct qla_hw_data *ha = vha->hw;
+
+   if (vha->vp_idx == 0) {
+   set_bit(NPH_MGMT_SERVER, ha->loop_id_map);
+   return NPH_MGMT_SERVER;
+   }
+
+   /* pick id from high and work down to low */
+   spin_lock_irqsave(&ha->vport_slock, flags);
+   for (; lid > 0; lid--) {
+   if (!test_bit(lid, vha->hw->loop_id_map)) {
+   set_bit(lid, vha->hw->loop_id_map);
+   loop_id = lid;
+   break;
+   }
+   }
+   spin_unlock_irqrestore(&ha->vport_slock, flags);
+
+   return loop_id;
+}
+
 /*
  * qla2x00_fabric_login
  * Issue fabric login command.
diff --git a/drivers/scsi/qla2xxx/qla_mid.c b/drivers/scsi/qla2xxx/qla_mid.c
index f6f0a759a7c2..14bc88bc4a5a 100644
--- a/drivers/scsi/qla2xxx/qla_mid.c
+++ b/drivers/scsi/qla2xxx/qla_mid.c
@@ -485,7 +485,7 @@ qla24xx_create_vhost(struct fc_vport *fc_vport)
"Couldn't allocate vp_id.\n");
goto create_vhost_failed;
}
-   vha->mgmt_svr_loop_id = NPH_MGMT_SERVER;
+   vha->mgmt_svr_loop_id = qla2x00_reserve_mgmt_server_loop_id(vha);
 
vha->dpc_flags = 0L;
 
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index 04e0c7f51e68..48d1003c8178 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -3048,7 +3048,8 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct 
pci_device_id *id)
host = base_vha->host;
base_vha->req = req;
if (IS_QLA2XXX_MIDTYPE(ha))
-   base_vha->mgmt_svr_loop_id = NPH_MGMT_SERVER;
+   base_vha->mgmt_svr_loop_id =
+   qla2x00_reserve_mgmt_server_loop_id(base_vha);
else
base_vha->mgmt_svr_loop_id = MANAGEMENT_SERVER +
base_vha->vp_idx;
-- 
2.12.0



[PATCH v2 03/16] qla2xxx: Fix login retry count

2018-07-31 Thread Himanshu Madhani
From: Quinn Tran 

Login retry count was not properly decrementing,
which lead to endless login retry.

Signed-off-by: Quinn Tran 
Signed-off-by: Himanshu Madhani 
---
 drivers/scsi/qla2xxx/qla_gs.c | 16 +++
 drivers/scsi/qla2xxx/qla_init.c   | 23 +++---
 drivers/scsi/qla2xxx/qla_mbx.c|  1 +
 drivers/scsi/qla2xxx/qla_os.c | 90 ---
 drivers/scsi/qla2xxx/qla_target.c |  3 +-
 5 files changed, 70 insertions(+), 63 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_gs.c b/drivers/scsi/qla2xxx/qla_gs.c
index 4bc2b66b299f..5139a3577bb3 100644
--- a/drivers/scsi/qla2xxx/qla_gs.c
+++ b/drivers/scsi/qla2xxx/qla_gs.c
@@ -3475,6 +3475,14 @@ void qla24xx_handle_gpnid_event(scsi_qla_host_t *vha, 
struct event_arg *ea)
fcport->rscn_gen++;
fcport->scan_state = QLA_FCPORT_FOUND;
fcport->flags |= FCF_FABRIC_DEVICE;
+   if (fcport->login_retry == 0) {
+   fcport->login_retry =
+   vha->hw->login_retry_count;
+   ql_dbg(ql_dbg_disc, vha, 0x,
+   "Port login retry %8phN, lid 0x%04x 
cnt=%d.\n",
+   fcport->port_name, fcport->loop_id,
+   fcport->login_retry);
+   }
switch (fcport->disc_state) {
case DSC_LOGIN_COMPLETE:
/* recheck session is still intact. */
@@ -3967,6 +3975,14 @@ void qla24xx_async_gnnft_done(scsi_qla_host_t *vha, 
srb_t *sp)
} else {
if (fcport->rscn_rcvd ||
fcport->disc_state != DSC_LOGIN_COMPLETE) {
+   if (fcport->login_retry == 0) {
+   fcport->login_retry =
+   vha->hw->login_retry_count;
+   ql_dbg(ql_dbg_disc, vha, 0x20a3,
+   "Port login retry %8phN, lid 0x%04x 
retry cnt=%d.\n",
+   fcport->port_name, fcport->loop_id,
+   fcport->login_retry);
+   }
fcport->rscn_rcvd = 0;
qla24xx_fcport_handle_login(vha, fcport);
}
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index 17c679102fcc..848ffd602e0b 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -213,8 +213,6 @@ qla2x00_async_login(struct scsi_qla_host *vha, fc_port_t 
*fcport,
if (fcport->fc4f_nvme)
lio->u.logio.flags |= SRB_LOGIN_SKIP_PRLI;
 
-   if (data[1] & QLA_LOGIO_LOGIN_RETRIED)
-   lio->u.logio.flags |= SRB_LOGIN_RETRIED;
}
 
rval = qla2x00_start_sp(sp);
@@ -485,7 +483,6 @@ static void qla24xx_handle_gnl_done_event(scsi_qla_host_t 
*vha,
 
if (ea->rc) { /* rval */
if (fcport->login_retry == 0) {
-   fcport->login_retry = vha->hw->login_retry_count;
ql_dbg(ql_dbg_disc, vha, 0x20de,
"GNL failed Port login retry %8phN, retry 
cnt=%d.\n",
fcport->port_name, fcport->login_retry);
@@ -1255,11 +1252,10 @@ int qla24xx_fcport_handle_login(struct scsi_qla_host 
*vha, fc_port_t *fcport)
return 0;
}
 
-   if (fcport->login_retry > 0)
-   fcport->login_retry--;
 
switch (fcport->disc_state) {
case DSC_DELETED:
+   fcport->login_retry--;
wwn = wwn_to_u64(fcport->node_name);
if (wwn == 0) {
ql_dbg(ql_dbg_disc, vha, 0x,
@@ -1272,6 +1268,7 @@ int qla24xx_fcport_handle_login(struct scsi_qla_host 
*vha, fc_port_t *fcport)
__func__, __LINE__, fcport->port_name);
qla24xx_post_gnl_work(vha, fcport);
} else {
+   fcport->login_retry--;
qla_chk_n2n_b4_login(vha, fcport);
}
break;
@@ -1288,6 +1285,7 @@ int qla24xx_fcport_handle_login(struct scsi_qla_host 
*vha, fc_port_t *fcport)
break;
 
case DSC_LOGIN_FAILED:
+   fcport->login_retry--;
ql_dbg(ql_dbg_disc, vha, 0x20d0,
"%s %d %8phC post gidpn\n",
__func__, __LINE__, fcport->port_name);
@@ -1302,6 +1300,7 @@ int qla24xx_fcport_handle_login(struct scsi_qla_host 
*vha, fc_port_t *fcport)
ql_dbg(ql_dbg_disc, vha, 0x20d1,
"%s %d %8phC post adisc\n",
__func__, __LI

[PATCH v2 10/16] qla2xxx: Flush mailbox commands on chip reset

2018-07-31 Thread Himanshu Madhani
From: Quinn Tran 

Flush pending mailbox commands on chip reset.  Wake up
command that's waiting for an interrupt and wait for
mailbox counters to go to zero.

Signed-off-by: Quinn Tran 
Signed-off-by: Himanshu Madhani 
---
 drivers/scsi/qla2xxx/qla_def.h  |  5 +
 drivers/scsi/qla2xxx/qla_init.c | 21 -
 drivers/scsi/qla2xxx/qla_mbx.c  | 50 +
 drivers/scsi/qla2xxx/qla_os.c   |  3 +++
 4 files changed, 74 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index ee4d1f4fdf95..40bcf938cf4f 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -3598,6 +3598,7 @@ struct qla_hw_data {
uint32_tdetected_lr_sfp:1;
uint32_tusing_lr_setting:1;
uint32_trida_fmt2:1;
+   uint32_tpurge_mbox:1;
} flags;
 
uint16_t max_exchg;
@@ -3843,6 +3844,9 @@ struct qla_hw_data {
int port_down_retry_count;
uint8_t mbx_count;
uint8_t aen_mbx_count;
+   atomic_tnum_pend_mbx_stage1;
+   atomic_tnum_pend_mbx_stage2;
+   atomic_tnum_pend_mbx_stage3;
 
uint32_tlogin_retry_count;
/* SNS command interfaces. */
@@ -4156,6 +4160,7 @@ struct qla_hw_data {
struct work_struct board_disable;
 
struct mr_data_fx00 mr;
+   uint32_t chip_reset;
 
struct qlt_hw_data tgt;
int allow_cna_fw_dump;
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index f94335301c70..7a984f5e6f11 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -6282,6 +6282,7 @@ qla2x00_abort_isp_cleanup(scsi_qla_host_t *vha)
ql_log(ql_log_info, vha, 0x00af,
"Performing ISP error recovery - ha=%p.\n", ha);
 
+   ha->flags.purge_mbox = 1;
/* For ISP82XX, reset_chip is just disabling interrupts.
 * Driver waits for the completion of the commands.
 * the interrupts need to be enabled.
@@ -6296,13 +6297,31 @@ qla2x00_abort_isp_cleanup(scsi_qla_host_t *vha)
ha->current_topology = 0;
ha->flags.fw_started = 0;
ha->flags.fw_init_done = 0;
-   ha->base_qpair->chip_reset++;
+   ha->chip_reset++;
+   ha->base_qpair->chip_reset = ha->chip_reset;
for (i = 0; i < ha->max_qpairs; i++) {
if (ha->queue_pair_map[i])
ha->queue_pair_map[i]->chip_reset =
ha->base_qpair->chip_reset;
}
 
+   /* purge MBox commands */
+   if (atomic_read(&ha->num_pend_mbx_stage3)) {
+   clear_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags);
+   complete(&ha->mbx_intr_comp);
+   }
+
+   i = 0;
+   while (atomic_read(&ha->num_pend_mbx_stage3) ||
+   atomic_read(&ha->num_pend_mbx_stage2) ||
+   atomic_read(&ha->num_pend_mbx_stage1)) {
+   msleep(20);
+   i++;
+   if (i > 50)
+   break;
+   }
+   ha->flags.purge_mbox = 0;
+
atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME);
if (atomic_read(&vha->loop_state) != LOOP_DOWN) {
atomic_set(&vha->loop_state, LOOP_DOWN);
diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c
index 17537f0b3b54..10847cdca093 100644
--- a/drivers/scsi/qla2xxx/qla_mbx.c
+++ b/drivers/scsi/qla2xxx/qla_mbx.c
@@ -110,6 +110,7 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t 
*mcp)
unsigned long   wait_time;
struct qla_hw_data *ha = vha->hw;
scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev);
+   u32 chip_reset;
 
 
ql_dbg(ql_dbg_mbx, vha, 0x1000, "Entered %s.\n", __func__);
@@ -140,7 +141,7 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t 
*mcp)
 
rval = QLA_SUCCESS;
abort_active = test_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags);
-
+   chip_reset = ha->chip_reset;
 
if (ha->flags.pci_channel_io_perm_failure) {
ql_log(ql_log_warn, vha, 0x1003,
@@ -167,6 +168,7 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t 
*mcp)
return QLA_FUNCTION_TIMEOUT;
}
 
+   atomic_inc(&ha->num_pend_mbx_stage1);
/*
 * Wait for active mailbox commands to finish by waiting at most tov
 * seconds. This is to serialize actual issuing of mailbox cmds during
@@ -177,8 +179,14 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t 
*mcp)
ql_log(ql_log_warn, vha, 0xd035,
"Cmd access timeout, cmd=0x%x, Exiting.\n",
mcp->mb[0]);
+   atomic_dec(&ha->num_pend_mbx_stage1);
return QLA_FUNCTION_TIMEOUT;
}
+   atomic_dec(&ha->num_pend_mbx_stage1);
+   if (ha->flags.purge_mbox || chip_reset !=

[PATCH v2 02/16] qla2xxx: Fix N2N link re-connect

2018-07-31 Thread Himanshu Madhani
From: Quinn Tran 

In case of N2N connect, when sg_regset for bus/device/host
was causing driver and firmware state to go out of sync.
This patch fixes this link instablity when reconnect is
attempted after link flap.

Signed-off-by: Quinn Tran 
Signed-off-by: Himanshu Madhani 
---
 drivers/scsi/qla2xxx/qla_def.h|   3 +-
 drivers/scsi/qla2xxx/qla_init.c   | 226 +-
 drivers/scsi/qla2xxx/qla_iocb.c   |  15 ++-
 drivers/scsi/qla2xxx/qla_isr.c|   3 +-
 drivers/scsi/qla2xxx/qla_mbx.c|  27 +
 drivers/scsi/qla2xxx/qla_os.c |   5 +
 drivers/scsi/qla2xxx/qla_target.c |   9 ++
 7 files changed, 180 insertions(+), 108 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index 9442e18aef6f..ee4d1f4fdf95 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -377,6 +377,7 @@ struct srb_iocb {
 #define SRB_LOGIN_COND_PLOGI   BIT_1
 #define SRB_LOGIN_SKIP_PRLIBIT_2
 #define SRB_LOGIN_NVME_PRLIBIT_3
+#define SRB_LOGIN_PRLI_ONLYBIT_4
uint16_t data[2];
u32 iop[2];
} logio;
@@ -4236,7 +4237,7 @@ typedef struct scsi_qla_host {
 #define FCOE_CTX_RESET_NEEDED  18  /* Initiate FCoE context reset */
 #define MPI_RESET_NEEDED   19  /* Initiate MPI FW reset */
 #define ISP_QUIESCE_NEEDED 20  /* Driver need some quiescence */
-#define FREE_BIT 21
+#define N2N_LINK_RESET 21
 #define PORT_UPDATE_NEEDED 22
 #define FX00_RESET_RECOVERY23
 #define FX00_TARGET_SCAN   24
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index 1de78697dc0d..17c679102fcc 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -160,6 +160,22 @@ qla2x00_async_login_sp_done(void *ptr, int res)
sp->free(sp);
 }
 
+static inline bool
+fcport_is_smaller(fc_port_t *fcport)
+{
+   if (wwn_to_u64(fcport->port_name) <
+   wwn_to_u64(fcport->vha->port_name))
+   return true;
+   else
+   return false;
+}
+
+static inline bool
+fcport_is_bigger(fc_port_t *fcport)
+{
+   return !fcport_is_smaller(fcport);
+}
+
 int
 qla2x00_async_login(struct scsi_qla_host *vha, fc_port_t *fcport,
 uint16_t *data)
@@ -189,13 +205,18 @@ qla2x00_async_login(struct scsi_qla_host *vha, fc_port_t 
*fcport,
qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha) + 2);
 
sp->done = qla2x00_async_login_sp_done;
-   lio->u.logio.flags |= SRB_LOGIN_COND_PLOGI;
+   if (N2N_TOPO(fcport->vha->hw) && fcport_is_bigger(fcport)) {
+   lio->u.logio.flags |= SRB_LOGIN_PRLI_ONLY;
+   } else {
+   lio->u.logio.flags |= SRB_LOGIN_COND_PLOGI;
 
-   if (fcport->fc4f_nvme)
-   lio->u.logio.flags |= SRB_LOGIN_SKIP_PRLI;
+   if (fcport->fc4f_nvme)
+   lio->u.logio.flags |= SRB_LOGIN_SKIP_PRLI;
+
+   if (data[1] & QLA_LOGIO_LOGIN_RETRIED)
+   lio->u.logio.flags |= SRB_LOGIN_RETRIED;
+   }
 
-   if (data[1] & QLA_LOGIO_LOGIN_RETRIED)
-   lio->u.logio.flags |= SRB_LOGIN_RETRIED;
rval = qla2x00_start_sp(sp);
if (rval != QLA_SUCCESS) {
fcport->flags |= FCF_LOGIN_NEEDED;
@@ -497,15 +518,18 @@ static void qla24xx_handle_gnl_done_event(scsi_qla_host_t 
*vha,
for (i = 0; i < n; i++) {
e = &vha->gnl.l[i];
wwn = wwn_to_u64(e->port_name);
+   id.b.domain = e->port_id[2];
+   id.b.area = e->port_id[1];
+   id.b.al_pa = e->port_id[0];
+   id.b.rsvd_1 = 0;
 
if (memcmp((u8 *)&wwn, fcport->port_name, WWN_SIZE))
continue;
 
+   if (IS_SW_RESV_ADDR(id))
+   continue;
+
found = 1;
-   id.b.domain = e->port_id[2];
-   id.b.area = e->port_id[1];
-   id.b.al_pa = e->port_id[0];
-   id.b.rsvd_1 = 0;
 
loop_id = le16_to_cpu(e->nport_handle);
loop_id = (loop_id & 0x7fff);
@@ -518,14 +542,18 @@ static void qla24xx_handle_gnl_done_event(scsi_qla_host_t 
*vha,
fcport->d_id.b.domain, fcport->d_id.b.area,
fcport->d_id.b.al_pa, loop_id, fcport->loop_id);
 
-   if ((id.b24 != fcport->d_id.b24) ||
-   ((fcport->loop_id != FC_NO_LOOP_ID) &&
-   (fcport->loop_id != loop_id))) {
-   ql_dbg(ql_dbg_disc, vha, 0x20e3,
-   "%s %d %8phC post del sess\n",
-   __func__, __LINE__, fcport->port_name);
-   qlt_schedule_sess_for_deletion(fcport);
-   return;
+   switch (fcport->disc_state) {
+   case DSC_DELETE_PEND:
+   case DSC_DELETED:
+

[PATCH v2 13/16] qla2xxx: Fix stalled relogin

2018-07-31 Thread Himanshu Madhani
This patch sets and clears FCF_ASYNC_{SENT|ACTIVE} flags to
prevent stalling of relogin attempt. Once flag are correctly
set/cleared, relogin timer can retry relogin attempt for driver
to continue login.

Fixes: fa83e65885b9 ("scsi: qla2xxx: ensure async flags are reset correctly")
Cc: sta...@vger.kernel.org #4.17
Signed-off-by: Himanshu Madhani 
---
 drivers/scsi/qla2xxx/qla_init.c | 2 +-
 drivers/scsi/qla2xxx/qla_iocb.c | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index b5c1a1dea087..a0c730bed312 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -431,7 +431,7 @@ qla2x00_async_adisc_sp_done(void *ptr, int res)
"Async done-%s res %x %8phC\n",
sp->name, res, sp->fcport->port_name);
 
-   sp->fcport->flags &= ~FCF_ASYNC_SENT;
+   sp->fcport->flags &= ~(FCF_ASYNC_SENT | FCF_ASYNC_ACTIVE);
 
memset(&ea, 0, sizeof(ea));
ea.event = FCME_ADISC_DONE;
diff --git a/drivers/scsi/qla2xxx/qla_iocb.c b/drivers/scsi/qla2xxx/qla_iocb.c
index e1ff2e27e59f..ba14db8d0b8d 100644
--- a/drivers/scsi/qla2xxx/qla_iocb.c
+++ b/drivers/scsi/qla2xxx/qla_iocb.c
@@ -2634,6 +2634,7 @@ qla24xx_els_dcmd2_iocb(scsi_qla_host_t *vha, int 
els_opcode,
ql_dbg(ql_dbg_io, vha, 0x3073,
"Enter: PLOGI portid=%06x\n", fcport->d_id.b24);
 
+   fcport->flags |= FCF_ASYNC_SENT;
sp->type = SRB_ELS_DCMD;
sp->name = "ELS_DCMD";
sp->fcport = fcport;
-- 
2.12.0



[PATCH v2 16/16] qla2xxx: Update driver version to 10.00.00.08-k

2018-07-31 Thread 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 1ad7582220c3..3850b28518e5 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.07-k"
+#define QLA2XXX_VERSION  "10.00.00.08-k"
 
 #define QLA_DRIVER_MAJOR_VER   10
 #define QLA_DRIVER_MINOR_VER   0
-- 
2.12.0



[PATCH v2 01/16] qla2xxx: Cleanup for N2N code

2018-07-31 Thread Himanshu Madhani
Signed-off-by: Himanshu Madhani 
---
 drivers/scsi/qla2xxx/qla_init.c | 112 
 drivers/scsi/qla2xxx/qla_iocb.c |  25 -
 2 files changed, 137 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index 7b675243bd16..1de78697dc0d 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -4687,110 +4687,6 @@ qla2x00_configure_loop(scsi_qla_host_t *vha)
 }
 
 /*
- * N2N Login
- * Updates Fibre Channel Device Database with local loop devices.
- *
- * Input:
- * ha = adapter block pointer.
- *
- * Returns:
- */
-static int qla24xx_n2n_handle_login(struct scsi_qla_host *vha,
-   fc_port_t *fcport)
-{
-   struct qla_hw_data *ha = vha->hw;
-   int res = QLA_SUCCESS, rval;
-   int greater_wwpn = 0;
-   int logged_in = 0;
-
-   if (ha->current_topology != ISP_CFG_N)
-   return res;
-
-   if (wwn_to_u64(vha->port_name) >
-   wwn_to_u64(vha->n2n_port_name)) {
-   ql_dbg(ql_dbg_disc, vha, 0x2002,
-   "HBA WWPN is greater %llx > target %llx\n",
-   wwn_to_u64(vha->port_name),
-   wwn_to_u64(vha->n2n_port_name));
-   greater_wwpn = 1;
-   fcport->d_id.b24 = vha->n2n_id;
-   }
-
-   fcport->loop_id = vha->loop_id;
-   fcport->fc4f_nvme = 0;
-   fcport->query = 1;
-
-   ql_dbg(ql_dbg_disc, vha, 0x4001,
-   "Initiate N2N login handler: HBA port_id=%06x loopid=%d\n",
-   fcport->d_id.b24, vha->loop_id);
-
-   /* Fill in member data. */
-   if (!greater_wwpn) {
-   rval = qla2x00_get_port_database(vha, fcport, 0);
-   ql_dbg(ql_dbg_disc, vha, 0x1051,
-   "Remote login-state (%x/%x) port_id=%06x loop_id=%x, 
rval=%d\n",
-   fcport->current_login_state, fcport->last_login_state,
-   fcport->d_id.b24, fcport->loop_id, rval);
-
-   if (((fcport->current_login_state & 0xf) == 0x4) ||
-   ((fcport->current_login_state & 0xf) == 0x6))
-   logged_in = 1;
-   }
-
-   if (logged_in || greater_wwpn) {
-   if (!vha->nvme_local_port && vha->flags.nvme_enabled)
-   qla_nvme_register_hba(vha);
-
-   /* Set connected N_Port d_id */
-   if (vha->flags.nvme_enabled)
-   fcport->fc4f_nvme = 1;
-
-   fcport->scan_state = QLA_FCPORT_FOUND;
-   fcport->fw_login_state = DSC_LS_PORT_UNAVAIL;
-   fcport->disc_state = DSC_GNL;
-   fcport->n2n_flag = 1;
-   fcport->flags = 3;
-   vha->hw->flags.gpsc_supported = 0;
-
-   if (greater_wwpn) {
-   ql_dbg(ql_dbg_disc, vha, 0x20e5,
-   "%s %d PLOGI ELS %8phC\n",
-   __func__, __LINE__, fcport->port_name);
-
-   res = qla24xx_els_dcmd2_iocb(vha, ELS_DCMD_PLOGI,
-   fcport, fcport->d_id);
-   }
-
-   if (res != QLA_SUCCESS) {
-   ql_log(ql_log_info, vha, 0xd04d,
-   "PLOGI Failed: portid=%06x - retrying\n",
-   fcport->d_id.b24);
-   res = QLA_SUCCESS;
-   } else {
-   /* State 0x6 means FCP PRLI complete */
-   if ((fcport->current_login_state & 0xf) == 0x6) {
-   ql_dbg(ql_dbg_disc, vha, 0x2118,
-   "%s %d %8phC post GPDB work\n",
-   __func__, __LINE__, fcport->port_name);
-   fcport->chip_reset =
-   vha->hw->base_qpair->chip_reset;
-   qla24xx_post_gpdb_work(vha, fcport, 0);
-   } else {
-   ql_dbg(ql_dbg_disc, vha, 0x2118,
-   "%s %d %8phC post NVMe PRLI\n",
-   __func__, __LINE__, fcport->port_name);
-   qla24xx_post_prli_work(vha, fcport);
-   }
-   }
-   } else {
-   /* Wait for next database change */
-   set_bit(N2N_LOGIN_NEEDED, &vha->dpc_flags);
-   }
-
-   return res;
-}
-
-/*
  * qla2x00_configure_local_loop
  * Updates Fibre Channel Device Database with local loop devices.
  *
@@ -4847,14 +4743,6 @@ qla2x00_configure_local_loop(scsi_qla_host_t *vha)
}
new_fcport->flags &= ~FCF_FABRIC_DEVICE;
 
-   /* Inititae N2N login. */
-   if (test_and_clear_bit(N2N_LOGIN_NEEDED, &vha->dpc_flags)) {
-   rval = qla24xx_n2n_handle_login(vha, new_fcport);
-   if (rval != QLA_SUCCESS)
-  

[PATCH v2 06/16] qla2xxx: Silent erroneous message

2018-07-31 Thread Himanshu Madhani
From: Quinn Tran 

Driver uses shadow pointer instead of Mirror pointer
for firmware dump collection. Skip those entries for
Mirror pointers for Request/Response queue from
firmware dump template reading.

Following messages are printed in log messages

 qla27xx_fwdt_entry_t268: unknown buffer 4
 qla27xx_fwdt_entry_t268: unknown buffer 5

This patch fixes these error message by adding skip_entry() to
not read them from template.

Signed-off-by: Quinn Tran 
Signed-off-by: Himanshu Madhani 
---
 drivers/scsi/qla2xxx/qla_tmpl.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/drivers/scsi/qla2xxx/qla_tmpl.c b/drivers/scsi/qla2xxx/qla_tmpl.c
index b170eb54aab5..0ccd06f11f12 100644
--- a/drivers/scsi/qla2xxx/qla_tmpl.c
+++ b/drivers/scsi/qla2xxx/qla_tmpl.c
@@ -571,6 +571,15 @@ qla27xx_fwdt_entry_t268(struct scsi_qla_host *vha,
}
break;
 
+   case T268_BUF_TYPE_REQ_MIRROR:
+   case T268_BUF_TYPE_RSP_MIRROR:
+   /*
+* Mirror pointers are not implemented in the
+* driver, instead shadow pointers are used by
+* the drier. Skip these entries.
+*/
+   qla27xx_skip_entry(ent, buf);
+   break;
default:
ql_dbg(ql_dbg_async, vha, 0xd02b,
"%s: unknown buffer %x\n", __func__, ent->t268.buf_type);
-- 
2.12.0



[PATCH v2 07/16] qla2xxx: Fix redundant fc_rport registration

2018-07-31 Thread Himanshu Madhani
From: Quinn Tran 

Prevent multiple registration with transport layer for
the same remote port.

Signed-off-by: Quinn Tran 
Signed-off-by: Himanshu Madhani 
---
 drivers/scsi/qla2xxx/qla_init.c | 25 +++--
 1 file changed, 11 insertions(+), 14 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index 79738294b069..4a89aa93c315 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -5001,6 +5001,9 @@ qla2x00_reg_remote_port(scsi_qla_host_t *vha, fc_port_t 
*fcport)
struct fc_rport *rport;
unsigned long flags;
 
+   if (atomic_read(&fcport->state) == FCS_ONLINE)
+   return;
+
rport_ids.node_name = wwn_to_u64(fcport->node_name);
rport_ids.port_name = wwn_to_u64(fcport->port_name);
rport_ids.port_id = fcport->d_id.b.domain << 16 |
@@ -5056,25 +5059,18 @@ qla2x00_update_fcport(scsi_qla_host_t *vha, fc_port_t 
*fcport)
if (IS_SW_RESV_ADDR(fcport->d_id))
return;
 
-   ql_dbg(ql_dbg_disc, vha, 0x20ef, "%s %8phC\n",
-   __func__, fcport->port_name);
-
-   if (IS_QLAFX00(vha->hw)) {
-   qla2x00_set_fcport_state(fcport, FCS_ONLINE);
-   } else {
-   fcport->flags &= ~(FCF_LOGIN_NEEDED | FCF_ASYNC_SENT);
-   fcport->disc_state = DSC_LOGIN_COMPLETE;
-   fcport->deleted = 0;
-   fcport->logout_on_delete = 1;
-   fcport->login_retry = vha->hw->login_retry_count;
-   qla2x00_set_fcport_state(fcport, FCS_ONLINE);
-   }
+   fcport->flags &= ~(FCF_LOGIN_NEEDED | FCF_ASYNC_SENT);
+   fcport->disc_state = DSC_LOGIN_COMPLETE;
+   fcport->deleted = 0;
+   fcport->logout_on_delete = 1;
+   fcport->login_retry = vha->hw->login_retry_count;
 
-   qla2x00_set_fcport_state(fcport, FCS_ONLINE);
qla2x00_iidma_fcport(vha, fcport);
 
if (fcport->fc4f_nvme) {
qla_nvme_register_remote(vha, fcport);
+   fcport->disc_state = DSC_LOGIN_COMPLETE;
+   qla2x00_set_fcport_state(fcport, FCS_ONLINE);
return;
}
 
@@ -5115,6 +5111,7 @@ qla2x00_update_fcport(scsi_qla_host_t *vha, fc_port_t 
*fcport)
qla24xx_post_gpsc_work(vha, fcport);
}
}
+   qla2x00_set_fcport_state(fcport, FCS_ONLINE);
 }
 
 /*
-- 
2.12.0



[PATCH v2 00/16] qla2xxx: Updates for the driver

2018-07-31 Thread Himanshu Madhani
Hi Martin,

This patch series addresses issue with N2N connection for FCP and FC-NVMe by
moving login to state machine and handle various state change.

Please apply this series to 4.19/scsi-queue at your earliest.

Changes from v1 -> v2
o Rebased on 4.19/scsi-queue

Thanks,
Himanshu 

Himanshu Madhani (3):
  qla2xxx: Cleanup for N2N code
  qla2xxx: Fix stalled relogin
  qla2xxx: Update driver version to 10.00.00.08-k

Quinn Tran (13):
  qla2xxx: Fix N2N link re-connect
  qla2xxx: Fix login retry count
  qla2xxx: Add longer window for Chip reset
  qla2xxx: Prevent SysFS access when chip is down
  qla2xxx: Silent erroneous message
  qla2xxx: Fix redundant fc_rport registration
  qla2xxx: Fix session state stuck in Get Port DB
  qla2xxx: Fix unintended Logout
  qla2xxx: Flush mailbox commands on chip reset
  qla2xxx: Fix Management Server NPort handle reservation logic
  qla2xxx: Fix race between switch cmd completion and timeout
  qla2xxx: Save frame payload size from ICB
  qla2xxx: Migrate NVME N2N handling into state machine

 drivers/scsi/qla2xxx/qla_attr.c|  33 +-
 drivers/scsi/qla2xxx/qla_dbg.c |   3 +
 drivers/scsi/qla2xxx/qla_def.h |  22 +-
 drivers/scsi/qla2xxx/qla_fw.h  |   5 +
 drivers/scsi/qla2xxx/qla_gbl.h |   6 +-
 drivers/scsi/qla2xxx/qla_gs.c  |  67 +++-
 drivers/scsi/qla2xxx/qla_init.c| 728 +++--
 drivers/scsi/qla2xxx/qla_inline.h  |   8 +-
 drivers/scsi/qla2xxx/qla_iocb.c| 153 +---
 drivers/scsi/qla2xxx/qla_isr.c |   3 +-
 drivers/scsi/qla2xxx/qla_mbx.c | 155 +---
 drivers/scsi/qla2xxx/qla_mid.c |   2 +-
 drivers/scsi/qla2xxx/qla_nvme.c|  15 +-
 drivers/scsi/qla2xxx/qla_nvme.h|   2 +-
 drivers/scsi/qla2xxx/qla_os.c  | 133 ---
 drivers/scsi/qla2xxx/qla_target.c  |  15 +-
 drivers/scsi/qla2xxx/qla_tmpl.c|  13 +-
 drivers/scsi/qla2xxx/qla_version.h |   2 +-
 drivers/scsi/qla2xxx/tcm_qla2xxx.c |   3 -
 19 files changed, 888 insertions(+), 480 deletions(-)

-- 
2.12.0



[PATCH v2 14/16] qla2xxx: Save frame payload size from ICB

2018-07-31 Thread Himanshu Madhani
From: Quinn Tran 

Save frame payload size from init control block.  This
field/data is used to register with switch data base.
This allow the init control block temp buf to be reuse

Signed-off-by: Quinn Tran 
Signed-off-by: Himanshu Madhani 
---
 drivers/scsi/qla2xxx/qla_def.h  | 1 +
 drivers/scsi/qla2xxx/qla_gs.c   | 4 +---
 drivers/scsi/qla2xxx/qla_init.c | 6 +++---
 3 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index 0fc563572fad..d1ff1b8f1ae5 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -3848,6 +3848,7 @@ struct qla_hw_data {
atomic_tnum_pend_mbx_stage1;
atomic_tnum_pend_mbx_stage2;
atomic_tnum_pend_mbx_stage3;
+   uint16_tframe_payload_size;
 
uint32_tlogin_retry_count;
/* SNS command interfaces. */
diff --git a/drivers/scsi/qla2xxx/qla_gs.c b/drivers/scsi/qla2xxx/qla_gs.c
index 5139a3577bb3..af9a75df6700 100644
--- a/drivers/scsi/qla2xxx/qla_gs.c
+++ b/drivers/scsi/qla2xxx/qla_gs.c
@@ -2134,9 +2134,7 @@ qla2x00_fdmiv2_rhba(scsi_qla_host_t *vha)
/* MAX CT Payload Length */
eiter = entries + size;
eiter->type = cpu_to_be16(FDMI_HBA_MAXIMUM_CT_PAYLOAD_LENGTH);
-   eiter->a.max_ct_len = IS_FWI2_CAPABLE(ha) ?
-   le16_to_cpu(icb24->frame_payload_size) :
-   le16_to_cpu(ha->init_cb->frame_payload_size);
+   eiter->a.max_ct_len = cpu_to_be32(ha->frame_payload_size);
eiter->a.max_ct_len = cpu_to_be32(eiter->a.max_ct_len);
eiter->len = cpu_to_be16(4 + 4);
size += 4 + 4;
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index a0c730bed312..924fe4265590 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -4417,7 +4417,7 @@ qla2x00_nvram_config(scsi_qla_host_t *vha)
cnt = (uint8_t *)icb->reserved_3 - (uint8_t *)icb->add_firmware_options;
while (cnt--)
*dptr1++ = *dptr2++;
-
+   ha->frame_payload_size = le16_to_cpu(icb->frame_payload_size);
/* Use alternate WWN? */
if (nv->host_p[1] & BIT_7) {
memcpy(icb->node_name, nv->alternate_node_name, WWN_SIZE);
@@ -6892,7 +6892,7 @@ qla24xx_nvram_config(scsi_qla_host_t *vha)
(uint8_t *)&icb->interrupt_delay_timer;
while (cnt--)
*dptr1++ = *dptr2++;
-
+   ha->frame_payload_size = le16_to_cpu(icb->frame_payload_size);
/*
 * Setup driver NVRAM options.
 */
@@ -7948,7 +7948,7 @@ qla81xx_nvram_config(scsi_qla_host_t *vha)
 
/* Use extended-initialization control block. */
memcpy(ha->ex_init_cb, &nv->ex_version, sizeof(*ha->ex_init_cb));
-
+   ha->frame_payload_size = le16_to_cpu(icb->frame_payload_size);
/*
 * Setup driver NVRAM options.
 */
-- 
2.12.0



[PATCH v2 09/16] qla2xxx: Fix unintended Logout

2018-07-31 Thread Himanshu Madhani
From: Quinn Tran 

During normal IO, FW can return IO with 'port unavailble' status.
Driver would send a LOGO to remote port for session resync.  On
an off chance, a PLOGI could arrive before sending the LOGO.
This patch will skip sendiing LOGO, if a PLOGI just came in.

Signed-off-by: Quinn Tran 
Signed-off-by: Himanshu Madhani 
---
 drivers/scsi/qla2xxx/qla_target.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/qla2xxx/qla_target.c 
b/drivers/scsi/qla2xxx/qla_target.c
index 4f9c315813df..f9036004f179 100644
--- a/drivers/scsi/qla2xxx/qla_target.c
+++ b/drivers/scsi/qla2xxx/qla_target.c
@@ -986,8 +986,9 @@ void qlt_free_session_done(struct work_struct *work)
 
logo.id = sess->d_id;
logo.cmd_count = 0;
+   if (!own)
+   qlt_send_first_logo(vha, &logo);
sess->send_els_logo = 0;
-   qlt_send_first_logo(vha, &logo);
}
 
if (sess->logout_on_delete && sess->loop_id != FC_NO_LOOP_ID) {
-- 
2.12.0



[PATCH v2 15/16] qla2xxx: Migrate NVME N2N handling into state machine

2018-07-31 Thread Himanshu Madhani
From: Quinn Tran 

This patch fixes regression introduced for the N2N support
for FC-NVMe. For FC-NVMe with N2N connection, instead of FW
initiating the Login, Driver starts Login process.  This
patch migrate that new process from a standalone path into
existing session management state machine. With this state
change now driver will not wait for pull NPort ID from FW.

Fixes: edd05de197592 ("scsi: qla2xxx: Changes to support N2N logins")
Signed-off-by: Quinn Tran 
Signed-off-by: Himanshu Madhani 
---
 drivers/scsi/qla2xxx/qla_def.h |  12 +-
 drivers/scsi/qla2xxx/qla_fw.h  |   5 +
 drivers/scsi/qla2xxx/qla_gbl.h |   3 +-
 drivers/scsi/qla2xxx/qla_gs.c  |  47 +---
 drivers/scsi/qla2xxx/qla_init.c| 229 ++---
 drivers/scsi/qla2xxx/qla_inline.h  |   2 -
 drivers/scsi/qla2xxx/qla_iocb.c| 112 +-
 drivers/scsi/qla2xxx/qla_mbx.c |  77 ++---
 drivers/scsi/qla2xxx/qla_nvme.c|  15 ++-
 drivers/scsi/qla2xxx/qla_nvme.h|   2 +-
 drivers/scsi/qla2xxx/qla_os.c  |  32 --
 drivers/scsi/qla2xxx/tcm_qla2xxx.c |   3 -
 12 files changed, 413 insertions(+), 126 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index d1ff1b8f1ae5..a03e12797f30 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -398,6 +398,8 @@ struct srb_iocb {
struct completion comp;
struct els_plogi_payload *els_plogi_pyld;
struct els_plogi_payload *els_resp_pyld;
+   u32 tx_size;
+   u32 rx_size;
dma_addr_t els_plogi_pyld_dma;
dma_addr_t els_resp_pyld_dma;
uint32_tfw_status[3];
@@ -2312,6 +2314,7 @@ enum fcport_mgt_event {
FCME_ADISC_DONE,
FCME_GNNID_DONE,
FCME_GFPNID_DONE,
+   FCME_ELS_PLOGI_DONE,
 };
 
 enum rscn_addr_format {
@@ -2408,6 +2411,7 @@ typedef struct fc_port {
struct ct_sns_desc ct_desc;
enum discovery_state disc_state;
enum login_state fw_login_state;
+   unsigned long dm_login_expire;
unsigned long plogi_nack_done_deadline;
 
u32 login_gen, last_login_gen;
@@ -2418,7 +2422,8 @@ typedef struct fc_port {
u8 iocb[IOCB_SIZE];
u8 current_login_state;
u8 last_login_state;
-   struct completion n2n_done;
+   u16 n2n_link_reset_cnt;
+   u16 n2n_chip_reset;
 } fc_port_t;
 
 #define QLA_FCPORT_SCAN1
@@ -3228,6 +3233,7 @@ enum qla_work_type {
QLA_EVT_GFPNID,
QLA_EVT_SP_RETRY,
QLA_EVT_IIDMA,
+   QLA_EVT_ELS_PLOGI,
 };
 
 
@@ -3600,6 +3606,7 @@ struct qla_hw_data {
uint32_tusing_lr_setting:1;
uint32_trida_fmt2:1;
uint32_tpurge_mbox:1;
+   uint32_tn2n_bigger:1;
} flags;
 
uint16_t max_exchg;
@@ -3908,6 +3915,9 @@ struct qla_hw_data {
int exchoffld_size;
int exchoffld_count;
 
+   /* n2n */
+   struct els_plogi_payload plogi_els_payld;
+
void*swl;
 
/* These are used by mailbox operations. */
diff --git a/drivers/scsi/qla2xxx/qla_fw.h b/drivers/scsi/qla2xxx/qla_fw.h
index 5d8688e5bc7c..50c1e6c62e31 100644
--- a/drivers/scsi/qla2xxx/qla_fw.h
+++ b/drivers/scsi/qla2xxx/qla_fw.h
@@ -1366,6 +1366,11 @@ struct vp_rpt_id_entry_24xx {
/* format 1 fabric */
uint8_t vpstat1_subcode; /* vp_status=1 subcode */
uint8_t flags;
+#define TOPO_MASK  0xE
+#define TOPO_FL0x2
+#define TOPO_N2N   0x4
+#define TOPO_F 0x6
+
uint16_t fip_flags;
uint8_t rsv2[12];
 
diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
index 6f2a37220a55..035ab18bd534 100644
--- a/drivers/scsi/qla2xxx/qla_gbl.h
+++ b/drivers/scsi/qla2xxx/qla_gbl.h
@@ -45,8 +45,7 @@ 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 int qla24xx_els_dcmd2_iocb(scsi_qla_host_t *, int, fc_port_t *, bool);
 
 extern void qla2x00_update_fcports(scsi_qla_host_t *);
 
diff --git a/drivers/scsi/qla2xxx/qla_gs.c b/drivers/scsi/qla2xxx/qla_gs.c
index af9a75df6700..3a93a9389a49 100644
--- a/drivers/scsi/qla2xxx/qla_gs.c
+++ b/drivers/scsi/qla2xxx/qla_gs.c
@@ -3384,19 +3384,40 @@ int qla24xx_post_gpnid_work(struct scsi_qla_host *vha, 
port_id_t *id)
 
 void qla24xx_sp_unmap(scsi_qla_host_t *vha, srb_t *sp)
 {
-   if (sp->u.iocb_cmd.u.ctarg.req) {
-   dma_free_coherent(&vha->hw->pde

[PATCH v2 04/16] qla2xxx: Add longer window for Chip reset

2018-07-31 Thread Himanshu Madhani
From: Quinn Tran 

The qla2x00_reset_active only cover the window of
turning the chip off, add check to cover Chip on.

Signed-off-by: Quinn Tran 
Signed-off-by: Himanshu Madhani 
---
 drivers/scsi/qla2xxx/qla_dbg.c  | 3 +++
 drivers/scsi/qla2xxx/qla_tmpl.c | 4 +++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/qla2xxx/qla_dbg.c b/drivers/scsi/qla2xxx/qla_dbg.c
index 5fd44c50bbac..c7533fa7f46e 100644
--- a/drivers/scsi/qla2xxx/qla_dbg.c
+++ b/drivers/scsi/qla2xxx/qla_dbg.c
@@ -1130,6 +1130,7 @@ qla24xx_fw_dump(scsi_qla_host_t *vha, int hardware_locked)
ha->fw_dump);
goto qla24xx_fw_dump_failed;
}
+   QLA_FW_STOPPED(ha);
fw = &ha->fw_dump->isp.isp24;
qla2xxx_prep_dump(ha, ha->fw_dump);
 
@@ -1384,6 +1385,7 @@ qla25xx_fw_dump(scsi_qla_host_t *vha, int hardware_locked)
ha->fw_dump);
goto qla25xx_fw_dump_failed;
}
+   QLA_FW_STOPPED(ha);
fw = &ha->fw_dump->isp.isp25;
qla2xxx_prep_dump(ha, ha->fw_dump);
ha->fw_dump->version = htonl(2);
@@ -2036,6 +2038,7 @@ qla83xx_fw_dump(scsi_qla_host_t *vha, int hardware_locked)
"request...\n", ha->fw_dump);
goto qla83xx_fw_dump_failed;
}
+   QLA_FW_STOPPED(ha);
fw = &ha->fw_dump->isp.isp83;
qla2xxx_prep_dump(ha, ha->fw_dump);
 
diff --git a/drivers/scsi/qla2xxx/qla_tmpl.c b/drivers/scsi/qla2xxx/qla_tmpl.c
index 731ca0d8520a..b170eb54aab5 100644
--- a/drivers/scsi/qla2xxx/qla_tmpl.c
+++ b/drivers/scsi/qla2xxx/qla_tmpl.c
@@ -1028,8 +1028,10 @@ qla27xx_fwdump(scsi_qla_host_t *vha, int hardware_locked)
ql_log(ql_log_warn, vha, 0xd300,
"Firmware has been previously dumped (%p),"
" -- ignoring request\n", vha->hw->fw_dump);
-   else
+   else {
+   QLA_FW_STOPPED(vha->hw);
qla27xx_execute_fwdt_template(vha);
+   }
 
 #ifndef __CHECKER__
if (!hardware_locked)
-- 
2.12.0



[PATCH v2 05/16] qla2xxx: Prevent SysFS access when chip is down

2018-07-31 Thread Himanshu Madhani
From: Quinn Tran 

Prevent user from sending commands through SysFS while
FW is not running or reset is in progress.

Signed-off-by: Quinn Tran 
Signed-off-by: Himanshu Madhani 
---
 drivers/scsi/qla2xxx/qla_attr.c   | 33 +++--
 drivers/scsi/qla2xxx/qla_init.c   |  2 +-
 drivers/scsi/qla2xxx/qla_inline.h |  6 ++
 3 files changed, 34 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
index 89a4999fa631..cc04caf83bd3 100644
--- a/drivers/scsi/qla2xxx/qla_attr.c
+++ b/drivers/scsi/qla2xxx/qla_attr.c
@@ -518,6 +518,9 @@ qla2x00_sysfs_write_vpd(struct file *filp, struct kobject 
*kobj,
if (unlikely(pci_channel_offline(ha->pdev)))
return 0;
 
+   if (qla2x00_chip_is_down(vha))
+   return 0;
+
if (!capable(CAP_SYS_ADMIN) || off != 0 || count != ha->vpd_size ||
!ha->isp_ops->write_nvram)
return 0;
@@ -570,7 +573,7 @@ qla2x00_sysfs_read_sfp(struct file *filp, struct kobject 
*kobj,
if (!capable(CAP_SYS_ADMIN) || off != 0 || count < SFP_DEV_SIZE)
return 0;
 
-   if (qla2x00_reset_active(vha))
+   if (qla2x00_chip_is_down(vha))
return 0;
 
rval = qla2x00_read_sfp_dev(vha, buf, count);
@@ -733,6 +736,15 @@ qla2x00_issue_logo(struct file *filp, struct kobject *kobj,
int type;
port_id_t did;
 
+   if (!capable(CAP_SYS_ADMIN))
+   return 0;
+
+   if (unlikely(pci_channel_offline(vha->hw->pdev)))
+   return 0;
+
+   if (qla2x00_chip_is_down(vha))
+   return 0;
+
type = simple_strtol(buf, NULL, 10);
 
did.b.domain = (type & 0x00ff) >> 16;
@@ -771,6 +783,12 @@ qla2x00_sysfs_read_xgmac_stats(struct file *filp, struct 
kobject *kobj,
if (!capable(CAP_SYS_ADMIN) || off != 0 || count > XGMAC_DATA_SIZE)
return 0;
 
+   if (unlikely(pci_channel_offline(ha->pdev)))
+   return 0;
+
+   if (qla2x00_chip_is_down(vha))
+   return 0;
+
if (ha->xgmac_data)
goto do_read;
 
@@ -825,6 +843,9 @@ qla2x00_sysfs_read_dcbx_tlv(struct file *filp, struct 
kobject *kobj,
if (ha->dcbx_tlv)
goto do_read;
 
+   if (qla2x00_chip_is_down(vha))
+   return 0;
+
ha->dcbx_tlv = dma_alloc_coherent(&ha->pdev->dev, DCBX_TLV_DATA_SIZE,
&ha->dcbx_tlv_dma, GFP_KERNEL);
if (!ha->dcbx_tlv) {
@@ -1036,7 +1057,7 @@ qla2x00_link_state_show(struct device *dev, struct 
device_attribute *attr,
vha->device_flags & DFLG_NO_CABLE)
len = scnprintf(buf, PAGE_SIZE, "Link Down\n");
else if (atomic_read(&vha->loop_state) != LOOP_READY ||
-   qla2x00_reset_active(vha))
+   qla2x00_chip_is_down(vha))
len = scnprintf(buf, PAGE_SIZE, "Unknown Link State\n");
else {
len = scnprintf(buf, PAGE_SIZE, "Link Up - ");
@@ -1163,7 +1184,7 @@ qla2x00_beacon_store(struct device *dev, struct 
device_attribute *attr,
if (IS_QLA2100(ha) || IS_QLA2200(ha))
return -EPERM;
 
-   if (test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags)) {
+   if (qla2x00_chip_is_down(vha)) {
ql_log(ql_log_warn, vha, 0x707a,
"Abort ISP active -- ignoring beacon request.\n");
return -EBUSY;
@@ -1350,7 +1371,7 @@ qla2x00_thermal_temp_show(struct device *dev,
scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
uint16_t temp = 0;
 
-   if (qla2x00_reset_active(vha)) {
+   if (qla2x00_chip_is_down(vha)) {
ql_log(ql_log_warn, vha, 0x70dc, "ISP reset active.\n");
goto done;
}
@@ -1381,7 +1402,7 @@ qla2x00_fw_state_show(struct device *dev, struct 
device_attribute *attr,
return scnprintf(buf, PAGE_SIZE, "0x%x\n", pstate);
}
 
-   if (qla2x00_reset_active(vha))
+   if (qla2x00_chip_is_down(vha))
ql_log(ql_log_warn, vha, 0x707c,
"ISP reset active.\n");
else if (!vha->hw->flags.eeh_busy)
@@ -1840,7 +1861,7 @@ qla2x00_get_fc_host_stats(struct Scsi_Host *shost)
if (unlikely(pci_channel_offline(ha->pdev)))
goto done;
 
-   if (qla2x00_reset_active(vha))
+   if (qla2x00_chip_is_down(vha))
goto done;
 
stats = dma_zalloc_coherent(&ha->pdev->dev, sizeof(*stats),
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index 848ffd602e0b..79738294b069 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -7016,7 +7016,7 @@ uint8_t qla27xx_find_valid_image(struct scsi_qla_host 
*vha)
ha->active_image = QLA27XX_SECONDARY_IMAGE;
}
 
-   ql_dbg(ql_dbg_init, vha, 0x018f, "%s image\n",
+   ql_dbg(ql_dbg_init + ql_dbg_verbose, vha, 0x018f, "%s

[PATCH 3/8] lpfc: Fix list corruption on the completion queue.

2018-07-31 Thread James Smart
Enabling list_debug showed the drivers txcmplq was suffering list
corruption. The systems will eventually crash because the
iocb free list gets crossed linked with the prings txcmplq.
Most systems will run for a while after the corruption, but will
eventually crash when a scsi eh reset occurs and the txcmplq is
attempted to be flushed. The flush gets stuck in an endless loop.

The problem is the abort handler does not hold the sli4 ring lock while
validating the IO so the IO could complete while the driver is still
preping the abort.  The erroneously generated, abort when it completes,
has pointers to the original io that has already completed, and the
io manipulation (for the second time) corrupts the list.

Correct by taking the ring lock early in the abort handler so the
erroneous abort won't be sent if the io has/is completing.

Signed-off-by: Dick Kennedy 
Signed-off-by: James Smart 
---
 drivers/scsi/lpfc/lpfc_scsi.c | 44 +++
 1 file changed, 36 insertions(+), 8 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
index 25ef2b6ccc34..51ce244cf10a 100644
--- a/drivers/scsi/lpfc/lpfc_scsi.c
+++ b/drivers/scsi/lpfc/lpfc_scsi.c
@@ -4727,7 +4727,7 @@ lpfc_abort_handler(struct scsi_cmnd *cmnd)
struct lpfc_scsi_buf *lpfc_cmd;
IOCB_t *cmd, *icmd;
int ret = SUCCESS, status = 0;
-   struct lpfc_sli_ring *pring_s4;
+   struct lpfc_sli_ring *pring_s4 = NULL;
int ret_val;
unsigned long flags;
DECLARE_WAIT_QUEUE_HEAD_ONSTACK(waitq);
@@ -4757,8 +4757,25 @@ lpfc_abort_handler(struct scsi_cmnd *cmnd)
}
 
iocb = &lpfc_cmd->cur_iocbq;
+   if (phba->sli_rev == LPFC_SLI_REV4) {
+   if (!(phba->cfg_fof) ||
+   (!(iocb->iocb_flag & LPFC_IO_FOF))) {
+   pring_s4 =
+   phba->sli4_hba.fcp_wq[iocb->hba_wqidx]->pring;
+   } else {
+   iocb->hba_wqidx = 0;
+   pring_s4 = phba->sli4_hba.oas_wq->pring;
+   }
+   if (!pring_s4) {
+   ret = FAILED;
+   goto out_unlock;
+   }
+   spin_lock(&pring_s4->ring_lock);
+   }
/* the command is in process of being cancelled */
if (!(iocb->iocb_flag & LPFC_IO_ON_TXCMPLQ)) {
+   if (phba->sli_rev == LPFC_SLI_REV4)
+   spin_unlock(&pring_s4->ring_lock);
spin_unlock_irqrestore(&phba->hbalock, flags);
lpfc_printf_vlog(vport, KERN_WARNING, LOG_FCP,
"3169 SCSI Layer abort requested I/O has been "
@@ -4772,6 +4789,8 @@ lpfc_abort_handler(struct scsi_cmnd *cmnd)
 * see the completion before the eh fired. Just return SUCCESS.
 */
if (lpfc_cmd->pCmd != cmnd) {
+   if (phba->sli_rev == LPFC_SLI_REV4)
+   spin_unlock(&pring_s4->ring_lock);
lpfc_printf_vlog(vport, KERN_WARNING, LOG_FCP,
"3170 SCSI Layer abort requested I/O has been "
"completed by LLD.\n");
@@ -4784,6 +4803,8 @@ lpfc_abort_handler(struct scsi_cmnd *cmnd)
if (iocb->iocb_flag & LPFC_DRIVER_ABORTED) {
lpfc_printf_vlog(vport, KERN_WARNING, LOG_FCP,
 "3389 SCSI Layer I/O Abort Request is pending\n");
+   if (phba->sli_rev == LPFC_SLI_REV4)
+   spin_unlock(&pring_s4->ring_lock);
spin_unlock_irqrestore(&phba->hbalock, flags);
goto wait_for_cmpl;
}
@@ -4791,6 +4812,8 @@ lpfc_abort_handler(struct scsi_cmnd *cmnd)
abtsiocb = __lpfc_sli_get_iocbq(phba);
if (abtsiocb == NULL) {
ret = FAILED;
+   if (phba->sli_rev == LPFC_SLI_REV4)
+   spin_unlock(&pring_s4->ring_lock);
goto out_unlock;
}
 
@@ -4828,14 +4851,9 @@ lpfc_abort_handler(struct scsi_cmnd *cmnd)
 
abtsiocb->iocb_cmpl = lpfc_sli_abort_fcp_cmpl;
abtsiocb->vport = vport;
+   lpfc_cmd->waitq = &waitq;
if (phba->sli_rev == LPFC_SLI_REV4) {
-   pring_s4 = lpfc_sli4_calc_ring(phba, abtsiocb);
-   if (pring_s4 == NULL) {
-   ret = FAILED;
-   goto out_unlock;
-   }
/* Note: both hbalock and ring_lock must be set here */
-   spin_lock(&pring_s4->ring_lock);
ret_val = __lpfc_sli_issue_iocb(phba, pring_s4->ringno,
abtsiocb, 0);
spin_unlock(&pring_s4->ring_lock);
@@ -4848,6 +4866,17 @@ lpfc_abort_handler(struct scsi_cmnd *cmnd)
 
 
if (ret_val == IOCB_ERROR) {
+   if (phba->sli_rev == LPFC_SLI_REV4)
+   spin_lock_irqsave(&pring_s4->ring_lock, flags);
+   el

[PATCH 7/8] lpfc: Remove lpfc_enable_pbde as module parameter

2018-07-31 Thread James Smart
Enablement of the PBDE optimization brought out some
incompatible behaviors under error scenarios.

Best to disable and remove the PBDE optimization.

Signed-off-by: Dick Kennedy 
Signed-off-by: James Smart 
---
 drivers/scsi/lpfc/lpfc_attr.c | 12 ++--
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c
index 514513f837a8..5a25553415f8 100644
--- a/drivers/scsi/lpfc/lpfc_attr.c
+++ b/drivers/scsi/lpfc/lpfc_attr.c
@@ -5387,14 +5387,6 @@ LPFC_BBCR_ATTR_RW(enable_bbcr, 1, 0, 1, "Enable BBC 
Recovery");
  */
 LPFC_ATTR_RW(enable_dpp, 1, 0, 1, "Enable Direct Packet Push");
 
-/*
- * lpfc_enable_pbde: Enable PBDE on PRISM - G7
- *   0  = PBDE on G7 disabled
- *   1  = PBDE on G7 enabled (default)
- * Value range is [0,1]. Default value is 1
- */
-LPFC_ATTR_R(enable_pbde, 1, 0, 1, "Enable PBDE support on PRISM");
-
 struct device_attribute *lpfc_hba_attrs[] = {
&dev_attr_nvme_info,
&dev_attr_bg_info,
@@ -5506,7 +5498,6 @@ struct device_attribute *lpfc_hba_attrs[] = {
&dev_attr_lpfc_enable_mds_diags,
&dev_attr_lpfc_enable_bbcr,
&dev_attr_lpfc_enable_dpp,
-   &dev_attr_lpfc_enable_pbde,
NULL,
 };
 
@@ -6541,7 +6532,6 @@ lpfc_get_cfgparam(struct lpfc_hba *phba)
lpfc_nvme_io_channel_init(phba, lpfc_nvme_io_channel);
lpfc_enable_bbcr_init(phba, lpfc_enable_bbcr);
lpfc_enable_dpp_init(phba, lpfc_enable_dpp);
-   lpfc_enable_pbde_init(phba, lpfc_enable_pbde);
 
if (phba->sli_rev != LPFC_SLI_REV4) {
/* NVME only supported on SLI4 */
@@ -6558,6 +6548,8 @@ lpfc_get_cfgparam(struct lpfc_hba *phba)
phba->cfg_auto_imax = 0;
phba->initial_imax = phba->cfg_fcp_imax;
 
+   phba->cfg_enable_pbde = 0;
+
/* A value of 0 means use the number of CPUs found in the system */
if (phba->cfg_fcp_io_channel == 0)
phba->cfg_fcp_io_channel = phba->sli4_hba.num_present_cpu;
-- 
2.13.1



[PATCH 8/8] lpfc: update driver version to 12.0.0.6

2018-07-31 Thread James Smart
Update the driver version to 12.0.0.6

Signed-off-by: Dick Kennedy 
Signed-off-by: James Smart 
---
 drivers/scsi/lpfc/lpfc_version.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/lpfc/lpfc_version.h b/drivers/scsi/lpfc/lpfc_version.h
index a669af45fce7..501249509af4 100644
--- a/drivers/scsi/lpfc/lpfc_version.h
+++ b/drivers/scsi/lpfc/lpfc_version.h
@@ -20,7 +20,7 @@
  * included with this package. *
  ***/
 
-#define LPFC_DRIVER_VERSION "12.0.0.5"
+#define LPFC_DRIVER_VERSION "12.0.0.6"
 #define LPFC_DRIVER_NAME   "lpfc"
 
 /* Used for SLI 2/3 */
-- 
2.13.1



[PATCH 2/8] lpfc: Fix sysfs Speed value on CNA ports

2018-07-31 Thread James Smart
CNA ports were showing speed as "unknown" even if the link
is up.

Add speed decoding for FCOE-based adapters

Signed-off-by: Dick Kennedy 
Signed-off-by: James Smart 
---
 drivers/scsi/lpfc/lpfc_attr.c | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c
index 23a5a298d60e..514513f837a8 100644
--- a/drivers/scsi/lpfc/lpfc_attr.c
+++ b/drivers/scsi/lpfc/lpfc_attr.c
@@ -5927,6 +5927,24 @@ lpfc_get_host_speed(struct Scsi_Host *shost)
fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN;
break;
}
+   } else if (lpfc_is_link_up(phba) && (phba->hba_flag & HBA_FCOE_MODE)) {
+   switch (phba->fc_linkspeed) {
+   case LPFC_ASYNC_LINK_SPEED_10GBPS:
+   fc_host_speed(shost) = FC_PORTSPEED_10GBIT;
+   break;
+   case LPFC_ASYNC_LINK_SPEED_25GBPS:
+   fc_host_speed(shost) = FC_PORTSPEED_25GBIT;
+   break;
+   case LPFC_ASYNC_LINK_SPEED_40GBPS:
+   fc_host_speed(shost) = FC_PORTSPEED_40GBIT;
+   break;
+   case LPFC_ASYNC_LINK_SPEED_100GBPS:
+   fc_host_speed(shost) = FC_PORTSPEED_100GBIT;
+   break;
+   default:
+   fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN;
+   break;
+   }
} else
fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN;
 
-- 
2.13.1



[PATCH 6/8] lpfc: Correct LCB ACCept payload

2018-07-31 Thread James Smart
After memory allocation for the LCB response frame, the memory
wasn't zero initialized, and not all fields are set. Thus garbage
shows up in the payload.

Fix by zeroing the memory at allocation.
Also properly set the Capability field based on duration support.

Signed-off-by: Dick Kennedy 
Signed-off-by: James Smart 
---
 drivers/scsi/lpfc/lpfc_els.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c
index df655f1284d0..4dda969e947c 100644
--- a/drivers/scsi/lpfc/lpfc_els.c
+++ b/drivers/scsi/lpfc/lpfc_els.c
@@ -5662,6 +5662,7 @@ lpfc_els_lcb_rsp(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
lcb_res = (struct fc_lcb_res_frame *)
(((struct lpfc_dmabuf *)elsiocb->context2)->virt);
 
+   memset(lcb_res, 0, sizeof(struct fc_lcb_res_frame));
icmd = &elsiocb->iocb;
icmd->ulpContext = lcb_context->rx_id;
icmd->unsli3.rcvsli3.ox_id = lcb_context->ox_id;
@@ -5670,6 +5671,7 @@ lpfc_els_lcb_rsp(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
*((uint32_t *)(pcmd)) = ELS_CMD_ACC;
lcb_res->lcb_sub_command = lcb_context->sub_command;
lcb_res->lcb_type = lcb_context->type;
+   lcb_res->capability = lcb_context->capability;
lcb_res->lcb_frequency = lcb_context->frequency;
lcb_res->lcb_duration = lcb_context->duration;
elsiocb->iocb_cmpl = lpfc_cmpl_els_rsp;
-- 
2.13.1



[PATCH 0/8] lpfc updates for 12.0.0.6

2018-07-31 Thread James Smart
This patch contains lpfc bug fixes 

The patches were cut against the Martin's 4.19/scsi-queue tree

James Smart (8):
  lpfc: Fix ELS abort on SLI-3 adapters
  lpfc: Fix sysfs Speed value on CNA ports
  lpfc: Fix list corruption on the completion queue.
  lpfc: Fix driver crash when re-registering NVME rports.
  lpfc: Limit tracking of tgt queue depth in fast path
  lpfc: Correct LCB ACCept payload
  lpfc: Remove lpfc_enable_pbde as module parameter
  lpfc: update driver version to 12.0.0.6

 drivers/scsi/lpfc/lpfc_attr.c  |  30 ++
 drivers/scsi/lpfc/lpfc_disc.h  |   3 +
 drivers/scsi/lpfc/lpfc_els.c   |   2 +
 drivers/scsi/lpfc/lpfc_nportdisc.c |   9 +--
 drivers/scsi/lpfc/lpfc_nvme.c  |  63 
 drivers/scsi/lpfc/lpfc_nvme.h  |   1 +
 drivers/scsi/lpfc/lpfc_scsi.c  | 118 +
 drivers/scsi/lpfc/lpfc_scsi.h  |   2 +
 drivers/scsi/lpfc/lpfc_sli.c   |  16 -
 drivers/scsi/lpfc/lpfc_version.h   |   2 +-
 10 files changed, 164 insertions(+), 82 deletions(-)

-- 
2.13.1



[PATCH 1/8] lpfc: Fix ELS abort on SLI-3 adapters

2018-07-31 Thread James Smart
For ABORT_XRI_CN command, firmware identifies XRI to abort by
IOTAG and RPI combination. For ELS aborts, driver specifies
IOTAG correctly but RPI is not specified.

Fix by setting RPI in WQE.

Signed-off-by: Dick Kennedy 
Signed-off-by: James Smart 
---
 drivers/scsi/lpfc/lpfc_nportdisc.c |  3 +++
 drivers/scsi/lpfc/lpfc_sli.c   | 16 ++--
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_nportdisc.c 
b/drivers/scsi/lpfc/lpfc_nportdisc.c
index 1f0a7d7dbc54..843e765db86d 100644
--- a/drivers/scsi/lpfc/lpfc_nportdisc.c
+++ b/drivers/scsi/lpfc/lpfc_nportdisc.c
@@ -1062,6 +1062,9 @@ lpfc_rcv_logo_plogi_issue(struct lpfc_vport *vport, 
struct lpfc_nodelist *ndlp,
 {
struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
 
+   /* Retrieve RPI from LOGO IOCB. RPI is used for CMD_ABORT_XRI_CN */
+   if (vport->phba->sli_rev == LPFC_SLI_REV3)
+   ndlp->nlp_rpi = cmdiocb->iocb.ulpIoTag;
/* software abort outstanding PLOGI */
lpfc_els_abort(vport->phba, ndlp);
 
diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
index 72500dcb13a9..9830bdb6e072 100644
--- a/drivers/scsi/lpfc/lpfc_sli.c
+++ b/drivers/scsi/lpfc/lpfc_sli.c
@@ -10703,6 +10703,12 @@ lpfc_sli_abort_els_cmpl(struct lpfc_hba *phba, struct 
lpfc_iocbq *cmdiocb,
 
spin_lock_irq(&phba->hbalock);
if (phba->sli_rev < LPFC_SLI_REV4) {
+   if (irsp->ulpCommand == CMD_ABORT_XRI_CX &&
+   irsp->ulpStatus == IOSTAT_LOCAL_REJECT &&
+   irsp->un.ulpWord[4] == IOERR_ABORT_REQUESTED) {
+   spin_unlock_irq(&phba->hbalock);
+   goto release_iocb;
+   }
if (abort_iotag != 0 &&
abort_iotag <= phba->sli.last_iotag)
abort_iocb =
@@ -10724,6 +10730,7 @@ lpfc_sli_abort_els_cmpl(struct lpfc_hba *phba, struct 
lpfc_iocbq *cmdiocb,
 
spin_unlock_irq(&phba->hbalock);
}
+release_iocb:
lpfc_sli_release_iocbq(phba, cmdiocb);
return;
 }
@@ -10780,6 +10787,7 @@ lpfc_sli_abort_iotag_issue(struct lpfc_hba *phba, 
struct lpfc_sli_ring *pring,
IOCB_t *iabt = NULL;
int retval;
unsigned long iflags;
+   struct lpfc_nodelist *ndlp;
 
lockdep_assert_held(&phba->hbalock);
 
@@ -10810,9 +10818,13 @@ lpfc_sli_abort_iotag_issue(struct lpfc_hba *phba, 
struct lpfc_sli_ring *pring,
if (phba->sli_rev == LPFC_SLI_REV4) {
iabt->un.acxri.abortIoTag = cmdiocb->sli4_xritag;
iabt->un.acxri.abortContextTag = cmdiocb->iotag;
-   }
-   else
+   } else {
iabt->un.acxri.abortIoTag = icmd->ulpIoTag;
+   if (pring->ringno == LPFC_ELS_RING) {
+   ndlp = (struct lpfc_nodelist *)(cmdiocb->context1);
+   iabt->un.acxri.abortContextTag = ndlp->nlp_rpi;
+   }
+   }
iabt->ulpLe = 1;
iabt->ulpClass = icmd->ulpClass;
 
-- 
2.13.1



[PATCH 5/8] lpfc: Limit tracking of tgt queue depth in fast path

2018-07-31 Thread James Smart
Performance is effected when target queue depth is tracked.
An atomic counter is incremented on the submission path which
competes with it being decremented on the completion path.
In addition multiple CPUs can simultaniously be manipulating
this counter for the same ndlp.

Reduce the overhead by only performing the target increment/decrement
when the target queue depth is less than the overall adapter depth,
thus is actually meaningful.

Signed-off-by: Dick Kennedy 
Signed-off-by: James Smart 
---
 drivers/scsi/lpfc/lpfc_disc.h  |  3 ++
 drivers/scsi/lpfc/lpfc_nportdisc.c |  6 
 drivers/scsi/lpfc/lpfc_nvme.c  | 41 -
 drivers/scsi/lpfc/lpfc_nvme.h  |  1 +
 drivers/scsi/lpfc/lpfc_scsi.c  | 74 ++
 drivers/scsi/lpfc/lpfc_scsi.h  |  2 ++
 6 files changed, 74 insertions(+), 53 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_disc.h b/drivers/scsi/lpfc/lpfc_disc.h
index 376f02819f20..28e2b60fc5c0 100644
--- a/drivers/scsi/lpfc/lpfc_disc.h
+++ b/drivers/scsi/lpfc/lpfc_disc.h
@@ -150,6 +150,9 @@ struct lpfc_node_rrq {
unsigned long rrq_stop_time;
 };
 
+#define lpfc_ndlp_check_qdepth(phba, ndlp) \
+   (ndlp->cmd_qdepth < phba->sli4_hba.max_cfg_param.max_xri)
+
 /* Defines for nlp_flag (uint32) */
 #define NLP_IGNR_REG_CMPL  0x0001 /* Rcvd rscn before we cmpl reg login */
 #define NLP_REG_LOGIN_SEND 0x0002   /* sent reglogin to adapter */
diff --git a/drivers/scsi/lpfc/lpfc_nportdisc.c 
b/drivers/scsi/lpfc/lpfc_nportdisc.c
index 843e765db86d..bd9bce9d9974 100644
--- a/drivers/scsi/lpfc/lpfc_nportdisc.c
+++ b/drivers/scsi/lpfc/lpfc_nportdisc.c
@@ -1985,12 +1985,6 @@ lpfc_cmpl_prli_prli_issue(struct lpfc_vport *vport, 
struct lpfc_nodelist *ndlp,
if (bf_get_be32(prli_disc, nvpr))
ndlp->nlp_type |= NLP_NVME_DISCOVERY;
 
-   /* This node is an NVME target.  Adjust the command
-* queue depth on this node to not exceed the available
-* xris.
-*/
-   ndlp->cmd_qdepth = phba->sli4_hba.nvme_xri_max;
-
/*
 * If prli_fba is set, the Target supports FirstBurst.
 * If prli_fb_sz is 0, the FirstBurst size is unlimited,
diff --git a/drivers/scsi/lpfc/lpfc_nvme.c b/drivers/scsi/lpfc/lpfc_nvme.c
index 32053424d546..028462e5994d 100644
--- a/drivers/scsi/lpfc/lpfc_nvme.c
+++ b/drivers/scsi/lpfc/lpfc_nvme.c
@@ -1135,9 +1135,6 @@ lpfc_nvme_io_cmd_wqe_cmpl(struct lpfc_hba *phba, struct 
lpfc_iocbq *pwqeIn,
else
lpfc_ncmd->flags &= ~LPFC_SBUF_XBUSY;
 
-   if (ndlp && NLP_CHK_NODE_ACT(ndlp))
-   atomic_dec(&ndlp->cmd_pending);
-
/* Update stats and complete the IO.  There is
 * no need for dma unprep because the nvme_transport
 * owns the dma address.
@@ -1546,17 +1543,19 @@ lpfc_nvme_fcp_io_submit(struct nvme_fc_local_port 
*pnvme_lport,
/* The node is shared with FCP IO, make sure the IO pending count does
 * not exceed the programmed depth.
 */
-   if ((atomic_read(&ndlp->cmd_pending) >= ndlp->cmd_qdepth) &&
-   !expedite) {
-   lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_IOERR,
-"6174 Fail IO, ndlp qdepth exceeded: "
-"idx %d DID %x pend %d qdepth %d\n",
-lpfc_queue_info->index, ndlp->nlp_DID,
-atomic_read(&ndlp->cmd_pending),
-ndlp->cmd_qdepth);
-   atomic_inc(&lport->xmt_fcp_qdepth);
-   ret = -EBUSY;
-   goto out_fail;
+   if (lpfc_ndlp_check_qdepth(phba, ndlp)) {
+   if ((atomic_read(&ndlp->cmd_pending) >= ndlp->cmd_qdepth) &&
+   !expedite) {
+   lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_IOERR,
+"6174 Fail IO, ndlp qdepth exceeded: "
+"idx %d DID %x pend %d qdepth %d\n",
+lpfc_queue_info->index, ndlp->nlp_DID,
+atomic_read(&ndlp->cmd_pending),
+ndlp->cmd_qdepth);
+   atomic_inc(&lport->xmt_fcp_qdepth);
+   ret = -EBUSY;
+   goto out_fail;
+   }
}
 
lpfc_ncmd = lpfc_get_nvme_buf(phba, ndlp, expedite);
@@ -1614,8 +1613,6 @@ lpfc_nvme_fcp_io_submit(struct nvme_fc_local_port 
*pnvme_lport,
goto out_free_nvme_buf;
}
 
-   atomic_inc(&ndlp->cmd_pending);
-
lpfc_nvmeio_data(phba, "NVME FCP XMIT: xri x%x idx %d to %06x\n",
 lpfc_ncmd->cur_iocbq.sli4_xritag,
 lpfc_queue_info->index, 

[PATCH 4/8] lpfc: Fix driver crash when re-registering NVME rports.

2018-07-31 Thread James Smart
During remote port loss fault testing, the driver crashed
with the following trace:

general protection fault:  [#1] SMP
RIP: ... lpfc_nvme_register_port+0x250/0x480 [lpfc]
Call Trace:
 lpfc_nlp_state_cleanup+0x1b3/0x7a0 [lpfc]
 lpfc_nlp_set_state+0xa6/0x1d0 [lpfc]
 lpfc_cmpl_prli_prli_issue+0x213/0x440
 lpfc_disc_state_machine+0x7e/0x1e0 [lpfc]
 lpfc_cmpl_els_prli+0x18a/0x200 [lpfc]
 lpfc_sli_sp_handle_rspiocb+0x3b5/0x6f0 [lpfc]
 lpfc_sli_handle_slow_ring_event_s4+0x161/0x240 [lpfc]
 lpfc_work_done+0x948/0x14c0 [lpfc]
 lpfc_do_work+0x16f/0x180 [lpfc]
 kthread+0xc9/0xe0
 ret_from_fork+0x55/0x80

After registering a new remoteport, the driver is pulling an
ndlp pointer from the lpfc rport associated with the private
area of a newly registered remoteport. The private area is
uninitialized, so it's garbage.

Correct by pulling the the lpfc rport pointer from the entering
ndlp point, then ndlp value from at rport. Note the entering
ndlp may be replacing by the rport->ndlp due to an address
change swap.

Signed-off-by: Dick Kennedy 
Signed-off-by: James Smart 
---
 drivers/scsi/lpfc/lpfc_nvme.c | 22 ++
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_nvme.c b/drivers/scsi/lpfc/lpfc_nvme.c
index 4cc6783b6a9f..32053424d546 100644
--- a/drivers/scsi/lpfc/lpfc_nvme.c
+++ b/drivers/scsi/lpfc/lpfc_nvme.c
@@ -2687,7 +2687,7 @@ lpfc_nvme_register_port(struct lpfc_vport *vport, struct 
lpfc_nodelist *ndlp)
struct lpfc_nvme_rport *oldrport;
struct nvme_fc_remote_port *remote_port;
struct nvme_fc_port_info rpinfo;
-   struct lpfc_nodelist *prev_ndlp;
+   struct lpfc_nodelist *prev_ndlp = NULL;
 
lpfc_printf_vlog(ndlp->vport, KERN_INFO, LOG_NVME_DISC,
 "6006 Register NVME PORT. DID x%06x nlptype x%x\n",
@@ -2736,23 +2736,29 @@ lpfc_nvme_register_port(struct lpfc_vport *vport, 
struct lpfc_nodelist *ndlp)
spin_unlock_irq(&vport->phba->hbalock);
rport = remote_port->private;
if (oldrport) {
+   /* New remoteport record does not guarantee valid
+* host private memory area.
+*/
+   prev_ndlp = oldrport->ndlp;
if (oldrport == remote_port->private) {
-   /* Same remoteport.  Just reuse. */
+   /* Same remoteport - ndlp should match.
+* Just reuse.
+*/
lpfc_printf_vlog(ndlp->vport, KERN_INFO,
 LOG_NVME_DISC,
 "6014 Rebinding lport to "
 "remoteport %p wwpn 0x%llx, "
-"Data: x%x x%x %p x%x x%06x\n",
+"Data: x%x x%x %p %p x%x 
x%06x\n",
 remote_port,
 remote_port->port_name,
 remote_port->port_id,
 remote_port->port_role,
+prev_ndlp,
 ndlp,
 ndlp->nlp_type,
 ndlp->nlp_DID);
return 0;
}
-   prev_ndlp = rport->ndlp;
 
/* Sever the ndlp<->rport association
 * before dropping the ndlp ref from
@@ -2786,13 +2792,13 @@ lpfc_nvme_register_port(struct lpfc_vport *vport, 
struct lpfc_nodelist *ndlp)
lpfc_printf_vlog(vport, KERN_INFO,
 LOG_NVME_DISC | LOG_NODE,
 "6022 Binding new rport to "
-"lport %p Remoteport %p  WWNN 0x%llx, "
+"lport %p Remoteport %p rport %p WWNN 0x%llx, "
 "Rport WWPN 0x%llx DID "
-"x%06x Role x%x, ndlp %p\n",
-lport, remote_port,
+"x%06x Role x%x, ndlp %p prev_ndlp %p\n",
+lport, remote_port, rport,
 rpinfo.node_name, rpinfo.port_name,
 rpinfo.port_id, rpinfo.port_role,
-ndlp);
+ndlp, prev_ndlp);
} else {
lpfc_printf_vlog(vport, KERN_ERR,
 LOG_NVME_DISC | LOG_NODE,
-- 
2.13.1



[PATCH] scsi: csiostor: remove automatic irq affinity assignment

2018-07-31 Thread Varun Prakash
If number of interrupt vectors are more than num_online_cpus()
then pci_alloc_irq_vectors_affinity() assigns cpumask based
on num_possible_cpus() to the remaining vectors because of
this interrupt does not generate for these vectors.

This patch fixes this issue by using pci_alloc_irq_vectors()
instead of pci_alloc_irq_vectors_affinity().

Signed-off-by: Varun Prakash 
---
 drivers/scsi/csiostor/csio_isr.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/scsi/csiostor/csio_isr.c b/drivers/scsi/csiostor/csio_isr.c
index 7c88147..8b92c59 100644
--- a/drivers/scsi/csiostor/csio_isr.c
+++ b/drivers/scsi/csiostor/csio_isr.c
@@ -480,7 +480,6 @@ csio_enable_msix(struct csio_hw *hw)
int i, j, k, n, min, cnt;
int extra = CSIO_EXTRA_VECS;
struct csio_scsi_cpu_info *info;
-   struct irq_affinity desc = { .pre_vectors = 2 };
 
min = hw->num_pports + extra;
cnt = hw->num_sqsets + extra;
@@ -491,8 +490,7 @@ csio_enable_msix(struct csio_hw *hw)
 
csio_dbg(hw, "FW supp #niq:%d, trying %d msix's\n", hw->cfg_niq, cnt);
 
-   cnt = pci_alloc_irq_vectors_affinity(hw->pdev, min, cnt,
-   PCI_IRQ_MSIX | PCI_IRQ_AFFINITY, &desc);
+   cnt = pci_alloc_irq_vectors(hw->pdev, min, cnt, PCI_IRQ_MSIX);
if (cnt < 0)
return cnt;
 
-- 
2.0.2



Re: FCOE vn2vn memory leaks in 4.14

2018-07-31 Thread ard
Hi,

On Tue, Jul 31, 2018 at 10:38:06AM +0200, Johannes Thumshirn wrote:
> So I've fixed one use-after-free and one memory leak, but the one you
> reported is still on the TODO list.

Wow, thanks...

> Long story short, I can reproduce it here and I'm working on it.
> 
> Thanks for your patience,
Thank you for being so pro-active, seriously. I wanted to look at
it some more, but heatwave, no airco and a festival in between
:-(.

Anyway, I got a PC and an odroid Xu4 (ARM) for testing now.

Regards,
Ard van Breemen
-- 
.signature not found


Re: FCOE vn2vn memory leaks in 4.14

2018-07-31 Thread Johannes Thumshirn
On Fri, Jul 27, 2018 at 12:49:55AM +0200, ard wrote:
> Actually already got there from my arm dump, but they are different in 
> backtrace.
> Anyway:
> root@antec:~# grep -c fc_rport_create kmemleak.txt
> 44
> So 44 * 512 bytes leaked in that path. And an extra thing: "it was leaked in" 
> libfc and not libfcoe.
> Or just like the bug report we were leaking fc_rport_priv.
> But one thing I don't understand (yet) is why the fc_rport_create happens 
> while
> we already have a port.
> 
> Anyway, I will continue bug hunting. It's night, and the temperature has 
> dropped to 29.8 .

So I've fixed one use-after-free and one memory leak, but the one you
reported is still on the TODO list.

Long story short, I can reproduce it here and I'm working on it.

Thanks for your patience,
   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