Re: [PATCH 11/17] lpfc: NVME Target: Base modifications

2017-01-17 Thread Hannes Reinecke
On 01/18/2017 02:20 AM, James Smart wrote:
> 
> NVME Target: Base modifications
> 
> This set of patches adds the base modifications for NVME target support
> to the lpfc driver.
> 
> The base modifications consist of:
> - Additional module parameters or configuration tuning
> - Enablement of configuration mode for NVME target. Ties into the
>   queueing model put into place by the initiator basemods patches.
> - Target-specific buffer pools, dma pools, sgl pools
> 
> Signed-off-by: Dick Kennedy 
> Signed-off-by: James Smart 
> ---
>  drivers/scsi/lpfc/lpfc.h |   6 +
>  drivers/scsi/lpfc/lpfc_attr.c| 160 ++-
>  drivers/scsi/lpfc/lpfc_crtn.h|  10 ++
>  drivers/scsi/lpfc/lpfc_debugfs.c |   7 +-
>  drivers/scsi/lpfc/lpfc_init.c| 268 
> ---
>  drivers/scsi/lpfc/lpfc_mem.c | 167 
>  drivers/scsi/lpfc/lpfc_nvmet.h   |  97 ++
>  drivers/scsi/lpfc/lpfc_sli.c | 112 +++-
>  drivers/scsi/lpfc/lpfc_sli.h |   1 +
>  drivers/scsi/lpfc/lpfc_sli4.h|   6 +
>  10 files changed, 806 insertions(+), 28 deletions(-)
>  create mode 100644 drivers/scsi/lpfc/lpfc_nvmet.h
> 
Reviewed-by: Hannes Reinecke 

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)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 10/17] lpfc: NVME Initiator: Add debugfs support

2017-01-17 Thread Hannes Reinecke
On 01/18/2017 02:20 AM, James Smart wrote:
> 
> NVME Initiator: Add debugfs support
> 
> Adds debugfs snippets to cover the new NVME initiator functionality
> 
> Signed-off-by: Dick Kennedy 
> Signed-off-by: James Smart 
> ---
>  drivers/scsi/lpfc/lpfc.h |  48 +++
>  drivers/scsi/lpfc/lpfc_ct.c  |  27 +-
>  drivers/scsi/lpfc/lpfc_debugfs.c | 775 
> ++-
>  drivers/scsi/lpfc/lpfc_debugfs.h | 150 +++-
>  drivers/scsi/lpfc/lpfc_nvme.c| 125 +++
>  drivers/scsi/lpfc/lpfc_nvme.h|   7 +
>  drivers/scsi/lpfc/lpfc_sli.c |   5 +
>  7 files changed, 1128 insertions(+), 9 deletions(-)
> 
Reviewed-by: Hannes Reinecke 

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)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 09/17] lpfc: NVME Initiator: bind to nvme_fc api

2017-01-17 Thread Hannes Reinecke
On 01/18/2017 02:20 AM, James Smart wrote:
> 
> NVME Initiator: Tie in to NVME Fabrics nvme_fc LLDD initiator api
> 
> Adds the routines to:
> - register and deregister the FC port as a nvme-fc initiator localport
> - register and deregister remote FC ports as a nvme-fc remoteport.
> - binding of nvme queues to adapter WQs
> - send/perform NVME LS's
> - send/perform NVME FCP initiator io operations
> 
> Signed-off-by: Dick Kennedy 
> Signed-off-by: James Smart 
> ---
>  drivers/scsi/lpfc/Makefile |7 +-
>  drivers/scsi/lpfc/lpfc.h   |5 +
>  drivers/scsi/lpfc/lpfc_crtn.h  |9 +
>  drivers/scsi/lpfc/lpfc_ct.c|2 +-
>  drivers/scsi/lpfc/lpfc_els.c   |4 +-
>  drivers/scsi/lpfc/lpfc_hbadisc.c   |   15 +-
>  drivers/scsi/lpfc/lpfc_init.c  |   20 +-
>  drivers/scsi/lpfc/lpfc_nportdisc.c |4 +-
>  drivers/scsi/lpfc/lpfc_nvme.c  | 2249 
> 
>  drivers/scsi/lpfc/lpfc_nvme.h  |6 +
>  drivers/scsi/lpfc/lpfc_sli.c   |   21 +-
>  drivers/scsi/lpfc/lpfc_sli4.h  |1 +
>  drivers/scsi/lpfc/lpfc_vport.c |   16 +-
>  13 files changed, 2339 insertions(+), 20 deletions(-)
>  create mode 100644 drivers/scsi/lpfc/lpfc_nvme.c
> 
Reviewed-by: Hannes Reinecke 

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)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 08/17] lpfc: NVME Initiator: Merge into FC discovery

2017-01-17 Thread Hannes Reinecke
On 01/18/2017 02:20 AM, James Smart wrote:
> 
> NVME Initiator: Merge into FC discovery
> 
> Adds NVME PRLI support and Nameserver registrations and Queries for NVME
> 
> Signed-off-by: Dick Kennedy 
> Signed-off-by: James Smart 
> ---
>  drivers/scsi/lpfc/lpfc.h   |   6 +-
>  drivers/scsi/lpfc/lpfc_ct.c| 441 
> +++--
>  drivers/scsi/lpfc/lpfc_disc.h  |  19 +-
>  drivers/scsi/lpfc/lpfc_els.c   | 320 +++
>  drivers/scsi/lpfc/lpfc_hbadisc.c   | 169 +++---
>  drivers/scsi/lpfc/lpfc_hw.h|  77 +--
>  drivers/scsi/lpfc/lpfc_hw4.h   |  43 
>  drivers/scsi/lpfc/lpfc_nportdisc.c | 198 +++--
>  8 files changed, 938 insertions(+), 335 deletions(-)
> 
Reviewed-by: Hannes Reinecke 

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)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 05/17] lpfc: NVME Initiator: Base modifications Part D

2017-01-17 Thread Hannes Reinecke
On 01/18/2017 02:20 AM, James Smart wrote:
> 
> NVME Initiator: Base modifications
> 
> This is part D of parts A..F.
> 
> Part D is the 2nd half of the mods to lpfc_init.c. This is the location
> of most of changes for the following:
> - sli3 ring vs sli4 wq splits
> - buffer pools are allocated/freed
> - sgl pools allocated/freed
> - adapter resources split up
> - queue config decided and enacted
> - receive buffer management
> 
> *
> 
> Refer to Part A for a description of base modifications
> 
> Signed-off-by: Dick Kennedy 
> Signed-off-by: James Smart 
> ---
>  drivers/scsi/lpfc/lpfc_init.c | 1088 
> +++--
>  1 file changed, 616 insertions(+), 472 deletions(-)
> 
Reviewed-by: Hannes Reinecke 

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)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 04/17] lpfc: NVME Initiator: Base modifications Part C

2017-01-17 Thread Hannes Reinecke
On 01/18/2017 02:20 AM, James Smart wrote:
> 
> NVME Initiator: Base modifications
> 
> This is part C of parts A..F.
> 
> Part C is the 1st half of the mods to lpfc_init.c. This is the location
> of most of changes for the following:
> - sli3 ring vs sli4 wq splits
> - buffer pools are allocated/freed
> - sgl pools allocated/freed
> - adapter resources split up
> - queue config decided and enacted
> - receive buffer management
> 
> *
> 
> Refer to Part A for a description of base modifications
> 
> Signed-off-by: Dick Kennedy 
> Signed-off-by: James Smart 
> ---
[ .. ]
> @@ -3315,16 +3421,121 @@ lpfc_sli4_xri_sgl_update(struct lpfc_hba *phba)
[ .. ]
> + if (phba->sli4_hba.nvme_xri_cnt > phba->sli4_hba.nvme_xri_max) {
> + /* max nvme xri shrunk below the allocated nvme buffers */
> + nvme_xri_cnt = phba->sli4_hba.nvme_xri_cnt -
> + phba->sli4_hba.nvme_xri_max;
> + /* release the extra allocated nvme buffers */
> + for (i = 0; i < nvme_xri_cnt; i++) {
> + list_remove_head(_sgl_list, lpfc_ncmd,
> +  struct lpfc_nvme_buf, list);
> + if (lpfc_ncmd) {
> + pci_pool_free(phba->lpfc_sg_dma_buf_pool,
> +   lpfc_ncmd->data,
> +   lpfc_ncmd->dma_handle);
> + kfree(lpfc_ncmd);
> + }
> + }
> + spin_lock_irq(>nvme_buf_list_get_lock);
> + phba->sli4_hba.nvme_xri_cnt -= nvme_xri_cnt;
> + spin_unlock_irq(>nvme_buf_list_get_lock);
> + }
> +
Unsafe.
'nvme_xri_cnt' is updated under the lock, but not tested with the lock
held. Please fix.

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)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 03/17] lpfc: NVME Initiator: Base modifications Part B

2017-01-17 Thread Hannes Reinecke
On 01/18/2017 02:20 AM, James Smart wrote:
> 
> NVME Initiator: Base modifications
> 
> This is part B of parts A..F.
> 
> Part B is limited to lpfc_attr.c: lpfc attribute modifications
> 
> *
> 
> Refer to Part A for a description of base modifications
> 
> Signed-off-by: Dick Kennedy 
> Signed-off-by: James Smart 
> ---
>  drivers/scsi/lpfc/lpfc_attr.c | 448 
> ++
>  1 file changed, 405 insertions(+), 43 deletions(-)
> 
Reviewed-by: Hannes Reinecke 

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)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 02/17] lpfc: NVME Initiator: Base modifications Part A

2017-01-17 Thread Hannes Reinecke
On 01/18/2017 02:20 AM, James Smart wrote:
> 
> NVME Initiator: Base modifications
> 
> This is part A of parts A..F.
> 
> Part A is the bulk of the file list changed by the modifications as
> most mods are small-ish. Changes may be for any aspect below.
> 
> *
> 
> This set of patches (6 parts) adds base modifications for NVME initiator
> support to the lpfc driver.
> 
> The base modifications consist of:
> - Formal split of SLI3 rings from SLI-4 WQs (sometimes referred to as
>   rings as well) as implementation now widely varies between the two.
> - Addition of configuration modes:
>SCSI initiator only; NVME initiator only; NVME target only; and
>SCSI and NVME initiator.
>The configuration mode drives overall adapter configuration,
>offloads enabled, and resource splits.
>NVME support is only available on SLI-4 devices and newer fw.
> - Implements the following based on configuration mode:
>   - Exchange resources are split by protocol; Obviously, if only
>  1 mode, then no split occurs. Default is 50/50. module attribute
>  allows tuning.
>   - Each protocol has it's own set of queues, but share interrupt
> vectors.
>  SCSI:
>SLI3 devices have few queues and the original style of queue
>  allocation remains.
>SLI4 devices piggy back on an "io-channel" concept that
>  eventually needs to merge with scsi-mq/blk-mq support (it is
>underway).  For now, the paradigm continues as it existed
>prior. io channel allocates N msix and N WQs (N=4 default)
>and either round robins or uses cpu # modulo N for scheduling.
>A bunch of module parameters allow the configuration to be
>tuned.
>  NVME (initiator):
>Allocates an msix per cpu (or whatever pci_alloc_irq_vectors
>  gets)
>Allocates a WQ per cpu, and maps the WQs to msix on a WQ #
>  modulo msix vector count basis.
>Module parameters exist to cap/control the config if desired.
>   - Each protocol has its own buffer and dma pools.
> 
> Unfortunately, it was very difficult to break out the above into
> functional patches. A such, they are presented as a 6-patch set to
> keep email size reasonable. All patches in the set must be applied to
> create a functional unit.
> 
> Signed-off-by: Dick Kennedy 
> Signed-off-by: James Smart 
> ---
>  drivers/scsi/lpfc/lpfc.h   |  77 ++--
>  drivers/scsi/lpfc/lpfc_attr.h  |   1 +
>  drivers/scsi/lpfc/lpfc_bsg.c   |  37 ++--
>  drivers/scsi/lpfc/lpfc_crtn.h  |  44 -
>  drivers/scsi/lpfc/lpfc_disc.h  |   1 +
>  drivers/scsi/lpfc/lpfc_els.c   |  56 
>  drivers/scsi/lpfc/lpfc_hbadisc.c   | 148 +++---
>  drivers/scsi/lpfc/lpfc_hw.h|   5 +-
>  drivers/scsi/lpfc/lpfc_hw4.h   | 183 
> +++--
>  drivers/scsi/lpfc/lpfc_logmsg.h|   4 +
>  drivers/scsi/lpfc/lpfc_mbox.c  |  47 ++
>  drivers/scsi/lpfc/lpfc_mem.c   | 111 --
>  drivers/scsi/lpfc/lpfc_nportdisc.c |   9 +-
>  drivers/scsi/lpfc/lpfc_nvme.h  |  87 ++
>  drivers/scsi/lpfc/lpfc_scsi.c  | 140 +++-
>  drivers/scsi/lpfc/lpfc_scsi.h  |  18 ++--
>  drivers/scsi/lpfc/lpfc_sli.h   |  37 ++--
>  drivers/scsi/lpfc/lpfc_sli4.h  |  75 +++
>  drivers/scsi/lpfc/lpfc_version.h   |   1 +
>  drivers/scsi/lpfc/lpfc_vport.c |   3 +
>  20 files changed, 854 insertions(+), 230 deletions(-)
>  create mode 100644 drivers/scsi/lpfc/lpfc_nvme.h
> 
[ .. ]
> @@ -605,7 +610,7 @@ lpfc_sli4_fcp_xri_aborted(struct lpfc_hba *phba,
>  }
>  
>  /**
> - * lpfc_sli4_post_scsi_sgl_list - Post blocks of scsi buffer sgls from a list
> + * lpfc_sli4_post_scsi_sgl_list - Psot blocks of scsi buffer sgls from a list
>   * @phba: pointer to lpfc hba data structure.
>   * @post_sblist: pointer to the scsi buffer list.
>   *

Psot?

> @@ -734,7 +739,7 @@ lpfc_sli4_post_scsi_sgl_list(struct lpfc_hba *phba,
>  }
>  
>  /**
> - * lpfc_sli4_repost_scsi_sgl_list - Repost all the allocated scsi buffer sgls
> + * lpfc_sli4_repost_scsi_sgl_list - Repsot all the allocated scsi buffer sgls
>   * @phba: pointer to lpfc hba data structure.
>   *
>   * This routine walks the list of scsi buffers that have been allocated and

Repsot? The reverse of 'Psot'?

[ .. ]
> @@ -1133,7 +1138,7 @@ lpfc_release_scsi_buf(struct lpfc_hba *phba, struct 
> lpfc_scsi_buf *psb)
>   *
>   * This routine does the pci dma mapping for scatter-gather list of scsi cmnd
>   * field of @lpfc_cmd for device with SLI-3 interface spec. This routine 
> scans
> - * through sg elements and format the bde. This routine also initializes all
> + * through sg elements and format the bdea. This routine also initializes all
>   * IOCB fields which are dependent on scsi command request buffer.
>   *
>   * Return codes:


Re: [PATCH 01/17] lpfc: Use new pci_alloc_irq_vectors() interface

2017-01-17 Thread Hannes Reinecke
On 01/18/2017 02:20 AM, James Smart wrote:
> 
> Move to new pci_alloc_irq_vectors() interface for intx/msi/msix
> 
> Note: io channel paradigm remains, for now.
> 
> Signed-off-by: Dick Kennedy 
> Signed-off-by: James Smart 
> ---
>  drivers/scsi/lpfc/lpfc_init.c | 227 
> --
>  1 file changed, 154 insertions(+), 73 deletions(-)
> 
Reviewed-by: Hannes Reinecke 

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)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Hello linux

2017-01-17 Thread Ashish Sood
Hello linux  http://eurofiduciaire.fr/checkcookie.php?doesnt=2s2d4h2ww4vyfwe


Ashish Sood
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH -next] scsi: be2iscsi: Use GFP_ATOMIC under spin lock

2017-01-17 Thread Jitendra Bhivare
> -Original Message-
> From: Wei Yongjun [mailto:weiyj...@gmail.com]
> Sent: Thursday, January 12, 2017 7:52 PM
> To: Subbu Seetharaman; Ketan Mukadam; Jitendra Bhivare; James E.J.
> Bottomley; Martin K. Petersen
> Cc: Wei Yongjun; linux-scsi@vger.kernel.org
> Subject: [PATCH -next] scsi: be2iscsi: Use GFP_ATOMIC under spin lock
>
> From: Wei Yongjun 
>
> A spin lock is taken here so we should use GFP_ATOMIC.
>
> Fixes: 987132167f4b ("scsi: be2iscsi: Fix for crash in
beiscsi_eh_device_reset")
> Signed-off-by: Wei Yongjun 
> ---
>  drivers/scsi/be2iscsi/be_main.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/scsi/be2iscsi/be_main.c
b/drivers/scsi/be2iscsi/be_main.c
> index 6372613..c9b9daa 100644
> --- a/drivers/scsi/be2iscsi/be_main.c
> +++ b/drivers/scsi/be2iscsi/be_main.c
> @@ -294,7 +294,7 @@ static int beiscsi_eh_device_reset(struct scsi_cmnd
> *sc)
>   beiscsi_conn = conn->dd_data;
>   phba = beiscsi_conn->phba;
>
> - inv_tbl = kzalloc(sizeof(*inv_tbl), GFP_KERNEL);
> + inv_tbl = kzalloc(sizeof(*inv_tbl), GFP_ATOMIC);
>   if (!inv_tbl) {
>   spin_unlock_bh(>frwd_lock);
>   beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_EH,

Reviewed-by: Jitendra Bhivare 
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 13/17] lpfc: NVME Target: Merge into FC discovery

2017-01-17 Thread James Smart

NVME Target: Merge into FC discovery

Adds NVME PRLI handling and Nameserver registrations for NVME

Signed-off-by: Dick Kennedy 
Signed-off-by: James Smart 
---
 drivers/scsi/lpfc/lpfc_ct.c|  8 +++-
 drivers/scsi/lpfc/lpfc_els.c   | 34 ++
 drivers/scsi/lpfc/lpfc_hbadisc.c   | 27 +++
 drivers/scsi/lpfc/lpfc_nportdisc.c | 35 ---
 4 files changed, 92 insertions(+), 12 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_ct.c b/drivers/scsi/lpfc/lpfc_ct.c
index 6aba862..d52b8bc 100644
--- a/drivers/scsi/lpfc/lpfc_ct.c
+++ b/drivers/scsi/lpfc/lpfc_ct.c
@@ -1433,7 +1433,13 @@ lpfc_ns_cmd(struct lpfc_vport *vport, int cmdcode,
if (((phba->cfg_enable_fc4_type == LPFC_ENABLE_BOTH) ||
 (phba->cfg_enable_fc4_type == LPFC_ENABLE_NVME)) &&
(context == FC_TYPE_NVME)) {
-   lpfc_nvme_update_localport(vport);
+   if ((vport == phba->pport) && phba->nvmet_support) {
+   CtReq->un.rff.fbits = (FC4_FEATURE_TARGET |
+   FC4_FEATURE_NVME_DISC);
+   /* todo: update targetport attributes */
+   } else {
+   lpfc_nvme_update_localport(vport);
+   }
CtReq->un.rff.type_code = context;
 
} else if (((phba->cfg_enable_fc4_type == LPFC_ENABLE_BOTH) ||
diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c
index 6d2b163..d40fcc8 100644
--- a/drivers/scsi/lpfc/lpfc_els.c
+++ b/drivers/scsi/lpfc/lpfc_els.c
@@ -2214,7 +2214,13 @@ lpfc_issue_els_prli(struct lpfc_vport *vport, struct 
lpfc_nodelist *ndlp,
!phba->nvmet_support)
bf_set(prli_fba, npr_nvme, 1);
 
-   bf_set(prli_init, npr_nvme, 1);
+   if (phba->nvmet_support) {
+   bf_set(prli_tgt, npr_nvme, 1);
+   bf_set(prli_disc, npr_nvme, 1);
+
+   } else {
+   bf_set(prli_init, npr_nvme, 1);
+   }
npr_nvme->word1 = cpu_to_be32(npr_nvme->word1);
npr_nvme->word4 = cpu_to_be32(npr_nvme->word4);
elsiocb->iocb_flag |= LPFC_PRLI_NVME_REQ;
@@ -2626,8 +2632,11 @@ lpfc_cmpl_els_logo(struct lpfc_hba *phba, struct 
lpfc_iocbq *cmdiocb,
phba->pport->fc_myDID = 0;
 
if ((phba->cfg_enable_fc4_type == LPFC_ENABLE_BOTH) ||
-   (phba->cfg_enable_fc4_type == LPFC_ENABLE_NVME))
-   lpfc_nvme_update_localport(phba->pport);
+   (phba->cfg_enable_fc4_type == LPFC_ENABLE_NVME)) {
+   if (!phba->nvmet_support)
+   lpfc_nvme_update_localport(phba->pport);
+   /* todo: tgt: update targetport attributes */
+   }
 
mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
if (mbox) {
@@ -4408,7 +4417,22 @@ lpfc_els_rsp_prli_acc(struct lpfc_vport *vport, struct 
lpfc_iocbq *oldiocb,
bf_set(prli_type_code, npr_nvme, PRLI_NVME_TYPE);
bf_set(prli_estabImagePair, npr_nvme, 0);  /* Should be 0 */
bf_set(prli_acc_rsp_code, npr_nvme, PRLI_REQ_EXECUTED);
-   bf_set(prli_init, npr_nvme, 1);
+   if (phba->nvmet_support) {
+   bf_set(prli_tgt, npr_nvme, 1);
+   bf_set(prli_disc, npr_nvme, 1);
+   if (phba->cfg_nvme_enable_fb) {
+   bf_set(prli_fba, npr_nvme, 1);
+
+   /* TBD.  Target mode needs to post buffers
+* that support the configured first burst
+* byte size.
+*/
+   bf_set(prli_fb_sz, npr_nvme,
+  phba->cfg_nvmet_fb_size);
+   }
+   } else {
+   bf_set(prli_init, npr_nvme, 1);
+   }
 
lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_DISC,
 "6015 NVME issue PRLI ACC word1 x%08x "
@@ -5827,6 +5851,8 @@ lpfc_rscn_recovery_check(struct lpfc_vport *vport)
(ndlp->nlp_state == NLP_STE_UNUSED_NODE) ||
!lpfc_rscn_payload_check(vport, ndlp->nlp_DID))
continue;
+   if (vport->phba->nvmet_support)
+   continue;
lpfc_disc_state_machine(vport, ndlp, NULL,
NLP_EVT_DEVICE_RECOVERY);
lpfc_cancel_retry_delay_tmo(vport, ndlp);
diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c 

[PATCH 14/17] lpfc: NVME Target: bind to nvmet_fc api

2017-01-17 Thread James Smart

NVME Target: Tie in to NVME Fabrics nvmet_fc LLDD target api

Adds the routines to:
- register and deregister the FC port as a nvmet-fc targetport
- binding of nvme queues to adapter WQs
- receipt and passing of NVME LS's to transport, sending transport response
- receipt of NVME FCP CMD IUs, processing FCP target io data transmission
  commands; transmission of FCP io response.
- Abort operations for tgt io exchanges.

Signed-off-by: Dick Kennedy 
Signed-off-by: James Smart 
---
 drivers/scsi/lpfc/Makefile   |2 +-
 drivers/scsi/lpfc/lpfc_crtn.h|8 +
 drivers/scsi/lpfc/lpfc_ct.c  |2 +-
 drivers/scsi/lpfc/lpfc_els.c |5 +-
 drivers/scsi/lpfc/lpfc_hbadisc.c |   10 +-
 drivers/scsi/lpfc/lpfc_init.c|2 +-
 drivers/scsi/lpfc/lpfc_nvmet.c   | 1365 ++
 drivers/scsi/lpfc/lpfc_sli.c |8 +-
 8 files changed, 1390 insertions(+), 12 deletions(-)
 create mode 100644 drivers/scsi/lpfc/lpfc_nvmet.c

diff --git a/drivers/scsi/lpfc/Makefile b/drivers/scsi/lpfc/Makefile
index cd7e1fc..30a6a35 100644
--- a/drivers/scsi/lpfc/Makefile
+++ b/drivers/scsi/lpfc/Makefile
@@ -31,4 +31,4 @@ obj-$(CONFIG_SCSI_LPFC) := lpfc.o
 lpfc-objs := lpfc_mem.o lpfc_sli.o lpfc_ct.o lpfc_els.o \
lpfc_hbadisc.o  lpfc_init.o lpfc_mbox.o lpfc_nportdisc.o   \
lpfc_scsi.o lpfc_attr.o lpfc_vport.o lpfc_debugfs.o lpfc_bsg.o \
-   lpfc_nvme.o
+   lpfc_nvme.o lpfc_nvmet.o
diff --git a/drivers/scsi/lpfc/lpfc_crtn.h b/drivers/scsi/lpfc/lpfc_crtn.h
index 271335e..46bc6fd 100644
--- a/drivers/scsi/lpfc/lpfc_crtn.h
+++ b/drivers/scsi/lpfc/lpfc_crtn.h
@@ -546,6 +546,14 @@ int lpfc_nvme_register_port(struct lpfc_vport *vport,
 int lpfc_nvme_create_localport(struct lpfc_vport *vport);
 void lpfc_nvme_destroy_localport(struct lpfc_vport *vport);
 void lpfc_nvme_update_localport(struct lpfc_vport *vport);
+int lpfc_nvmet_create_targetport(struct lpfc_hba *phba);
+int lpfc_nvmet_update_targetport(struct lpfc_hba *phba);
+void lpfc_nvmet_destroy_targetport(struct lpfc_hba *phba);
+void lpfc_nvmet_unsol_ls_event(struct lpfc_hba *phba,
+   struct lpfc_sli_ring *pring, struct lpfc_iocbq *piocb);
+void lpfc_nvmet_unsol_fcp_event(struct lpfc_hba *phba,
+   struct lpfc_sli_ring *pring,
+   struct rqb_dmabuf *nvmebuf, uint64_t isr_ts);
 void lpfc_nvme_mod_param_dep(struct lpfc_hba *phba);
 void lpfc_nvme_abort_fcreq_cmpl(struct lpfc_hba *phba,
struct lpfc_iocbq *cmdiocb,
diff --git a/drivers/scsi/lpfc/lpfc_ct.c b/drivers/scsi/lpfc/lpfc_ct.c
index d52b8bc..b494930 100644
--- a/drivers/scsi/lpfc/lpfc_ct.c
+++ b/drivers/scsi/lpfc/lpfc_ct.c
@@ -1436,7 +1436,7 @@ lpfc_ns_cmd(struct lpfc_vport *vport, int cmdcode,
if ((vport == phba->pport) && phba->nvmet_support) {
CtReq->un.rff.fbits = (FC4_FEATURE_TARGET |
FC4_FEATURE_NVME_DISC);
-   /* todo: update targetport attributes */
+   lpfc_nvmet_update_targetport(phba);
} else {
lpfc_nvme_update_localport(vport);
}
diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c
index d40fcc8..ec2580e 100644
--- a/drivers/scsi/lpfc/lpfc_els.c
+++ b/drivers/scsi/lpfc/lpfc_els.c
@@ -2633,9 +2633,10 @@ lpfc_cmpl_els_logo(struct lpfc_hba *phba, struct 
lpfc_iocbq *cmdiocb,
 
if ((phba->cfg_enable_fc4_type == LPFC_ENABLE_BOTH) ||
(phba->cfg_enable_fc4_type == LPFC_ENABLE_NVME)) {
-   if (!phba->nvmet_support)
+   if (phba->nvmet_support)
+   lpfc_nvmet_update_targetport(phba);
+   else
lpfc_nvme_update_localport(phba->pport);
-   /* todo: tgt: update targetport attributes */
}
 
mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c
index cc4462b..79a9b78 100644
--- a/drivers/scsi/lpfc/lpfc_hbadisc.c
+++ b/drivers/scsi/lpfc/lpfc_hbadisc.c
@@ -914,9 +914,10 @@ lpfc_linkdown(struct lpfc_hba *phba)
 
if ((phba->cfg_enable_fc4_type == LPFC_ENABLE_BOTH) ||
(phba->cfg_enable_fc4_type == LPFC_ENABLE_NVME)) {
-   if (!phba->nvmet_support)
+   if (phba->nvmet_support)
+   lpfc_nvmet_update_targetport(phba);
+   else
lpfc_nvme_update_localport(vports[i]);
-   /* todo: tgt: update targetport attributes */
}
}
 

[PATCH 08/17] lpfc: NVME Initiator: Merge into FC discovery

2017-01-17 Thread James Smart

NVME Initiator: Merge into FC discovery

Adds NVME PRLI support and Nameserver registrations and Queries for NVME

Signed-off-by: Dick Kennedy 
Signed-off-by: James Smart 
---
 drivers/scsi/lpfc/lpfc.h   |   6 +-
 drivers/scsi/lpfc/lpfc_ct.c| 441 +++--
 drivers/scsi/lpfc/lpfc_disc.h  |  19 +-
 drivers/scsi/lpfc/lpfc_els.c   | 320 +++
 drivers/scsi/lpfc/lpfc_hbadisc.c   | 169 +++---
 drivers/scsi/lpfc/lpfc_hw.h|  77 +--
 drivers/scsi/lpfc/lpfc_hw4.h   |  43 
 drivers/scsi/lpfc/lpfc_nportdisc.c | 198 +++--
 8 files changed, 938 insertions(+), 335 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
index 3fad85e..72b4614 100644
--- a/drivers/scsi/lpfc/lpfc.h
+++ b/drivers/scsi/lpfc/lpfc.h
@@ -123,6 +123,8 @@ struct perf_prof {
uint16_t wqidx[40];
 };
 
+#define LPFC_FC4_TYPE_BITMASK  0x0100
+
 /* Provide DMA memory definitions the driver uses per port instance. */
 struct lpfc_dmabuf {
struct list_head list;
@@ -390,7 +392,8 @@ struct lpfc_vport {
int32_t stopped;   /* HBA has not been restarted since last ERATT */
uint8_t fc_linkspeed;   /* Link speed after last READ_LA */
 
-   uint32_t num_disc_nodes;/*in addition to hba_state */
+   uint32_t num_disc_nodes;/* in addition to hba_state */
+   uint32_t gidft_inp; /* cnt of outstanding GID_FTs */
 
uint32_t fc_nlp_cnt;/* outstanding NODELIST requests */
uint32_t fc_rscn_id_cnt;/* count of RSCNs payloads in list */
@@ -443,7 +446,6 @@ struct lpfc_vport {
uint32_t cfg_max_scsicmpl_time;
uint32_t cfg_tgt_queue_depth;
uint32_t cfg_first_burst_size;
-
uint32_t dev_loss_tmo_changed;
 
struct fc_vport *fc_vport;
diff --git a/drivers/scsi/lpfc/lpfc_ct.c b/drivers/scsi/lpfc/lpfc_ct.c
index 4ac03b1..23d6a3c 100644
--- a/drivers/scsi/lpfc/lpfc_ct.c
+++ b/drivers/scsi/lpfc/lpfc_ct.c
@@ -40,8 +40,9 @@
 #include "lpfc_sli4.h"
 #include "lpfc_nl.h"
 #include "lpfc_disc.h"
-#include "lpfc_scsi.h"
 #include "lpfc.h"
+#include "lpfc_scsi.h"
+#include "lpfc_nvme.h"
 #include "lpfc_logmsg.h"
 #include "lpfc_crtn.h"
 #include "lpfc_version.h"
@@ -453,8 +454,73 @@ lpfc_find_vport_by_did(struct lpfc_hba *phba, uint32_t 
did) {
return NULL;
 }
 
+static void
+lpfc_prep_node_fc4type(struct lpfc_vport *vport, uint32_t Did, uint8_t 
fc4_type)
+{
+   struct lpfc_nodelist *ndlp;
+
+   if ((vport->port_type != LPFC_NPIV_PORT) ||
+   !(vport->ct_flags & FC_CT_RFF_ID) || !vport->cfg_restrict_login) {
+
+   ndlp = lpfc_setup_disc_node(vport, Did);
+
+   if (ndlp && NLP_CHK_NODE_ACT(ndlp)) {
+   /* By default, the driver expects to support FCP FC4 */
+   if (fc4_type == FC_TYPE_FCP)
+   ndlp->nlp_fc4_type |= NLP_FC4_FCP;
+
+   if (fc4_type == FC_TYPE_NVME)
+   ndlp->nlp_fc4_type |= NLP_FC4_NVME;
+
+   lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
+"0238 Process x%06x NameServer Rsp "
+"Data: x%x x%x x%x x%x\n", Did,
+ndlp->nlp_flag, ndlp->nlp_fc4_type,
+vport->fc_flag,
+vport->fc_rscn_id_cnt);
+   } else
+   lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
+"0239 Skip x%06x NameServer Rsp "
+"Data: x%x x%x\n", Did,
+vport->fc_flag,
+vport->fc_rscn_id_cnt);
+
+   } else {
+   if (!(vport->fc_flag & FC_RSCN_MODE) ||
+   lpfc_rscn_payload_check(vport, Did)) {
+   /*
+* This NPortID was previously a FCP target,
+* Don't even bother to send GFF_ID.
+*/
+   ndlp = lpfc_findnode_did(vport, Did);
+   if (ndlp && NLP_CHK_NODE_ACT(ndlp))
+   ndlp->nlp_fc4_type = fc4_type;
+
+   if (ndlp && NLP_CHK_NODE_ACT(ndlp)) {
+   ndlp->nlp_fc4_type = fc4_type;
+
+   if (ndlp->nlp_type & NLP_FCP_TARGET)
+   lpfc_setup_disc_node(vport, Did);
+
+   else if (lpfc_ns_cmd(vport, SLI_CTNS_GFF_ID,
+   0, Did) == 0)
+   vport->num_disc_nodes++;
+
+   else
+  

[PATCH 17/17] lpfc: Update lpfc version to 11.2.0.7

2017-01-17 Thread James Smart

Update lpfc version to 11.2.0.7

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 4e46ce4..9dfdab1 100644
--- a/drivers/scsi/lpfc/lpfc_version.h
+++ b/drivers/scsi/lpfc/lpfc_version.h
@@ -18,7 +18,7 @@
  * included with this package. *
  ***/
 
-#define LPFC_DRIVER_VERSION "11.2.0.4"
+#define LPFC_DRIVER_VERSION "11.2.0.7"
 #define LPFC_DRIVER_NAME   "lpfc"
 #define LPFCMGMT_NAME  "lpfcmgmt"
 
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 09/17] lpfc: NVME Initiator: bind to nvme_fc api

2017-01-17 Thread James Smart

NVME Initiator: Tie in to NVME Fabrics nvme_fc LLDD initiator api

Adds the routines to:
- register and deregister the FC port as a nvme-fc initiator localport
- register and deregister remote FC ports as a nvme-fc remoteport.
- binding of nvme queues to adapter WQs
- send/perform NVME LS's
- send/perform NVME FCP initiator io operations

Signed-off-by: Dick Kennedy 
Signed-off-by: James Smart 
---
 drivers/scsi/lpfc/Makefile |7 +-
 drivers/scsi/lpfc/lpfc.h   |5 +
 drivers/scsi/lpfc/lpfc_crtn.h  |9 +
 drivers/scsi/lpfc/lpfc_ct.c|2 +-
 drivers/scsi/lpfc/lpfc_els.c   |4 +-
 drivers/scsi/lpfc/lpfc_hbadisc.c   |   15 +-
 drivers/scsi/lpfc/lpfc_init.c  |   20 +-
 drivers/scsi/lpfc/lpfc_nportdisc.c |4 +-
 drivers/scsi/lpfc/lpfc_nvme.c  | 2249 
 drivers/scsi/lpfc/lpfc_nvme.h  |6 +
 drivers/scsi/lpfc/lpfc_sli.c   |   21 +-
 drivers/scsi/lpfc/lpfc_sli4.h  |1 +
 drivers/scsi/lpfc/lpfc_vport.c |   16 +-
 13 files changed, 2339 insertions(+), 20 deletions(-)
 create mode 100644 drivers/scsi/lpfc/lpfc_nvme.c

diff --git a/drivers/scsi/lpfc/Makefile b/drivers/scsi/lpfc/Makefile
index e2516ba..cd7e1fc 100644
--- a/drivers/scsi/lpfc/Makefile
+++ b/drivers/scsi/lpfc/Makefile
@@ -28,6 +28,7 @@ endif
 
 obj-$(CONFIG_SCSI_LPFC) := lpfc.o
 
-lpfc-objs := lpfc_mem.o lpfc_sli.o lpfc_ct.o lpfc_els.o lpfc_hbadisc.o \
-   lpfc_init.o lpfc_mbox.o lpfc_nportdisc.o lpfc_scsi.o lpfc_attr.o \
-   lpfc_vport.o lpfc_debugfs.o lpfc_bsg.o
+lpfc-objs := lpfc_mem.o lpfc_sli.o lpfc_ct.o lpfc_els.o \
+   lpfc_hbadisc.o  lpfc_init.o lpfc_mbox.o lpfc_nportdisc.o   \
+   lpfc_scsi.o lpfc_attr.o lpfc_vport.o lpfc_debugfs.o lpfc_bsg.o \
+   lpfc_nvme.o
diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
index 72b4614..1dae886 100644
--- a/drivers/scsi/lpfc/lpfc.h
+++ b/drivers/scsi/lpfc/lpfc.h
@@ -123,6 +123,11 @@ struct perf_prof {
uint16_t wqidx[40];
 };
 
+/*
+ * Provide for FC4 TYPE x28 - NVME.  The
+ * bit mask for FCP and NVME is 0x8 identically
+ * because they are 32 bit positions distance.
+ */
 #define LPFC_FC4_TYPE_BITMASK  0x0100
 
 /* Provide DMA memory definitions the driver uses per port instance. */
diff --git a/drivers/scsi/lpfc/lpfc_crtn.h b/drivers/scsi/lpfc/lpfc_crtn.h
index 4b7decb..8592d6d 100644
--- a/drivers/scsi/lpfc/lpfc_crtn.h
+++ b/drivers/scsi/lpfc/lpfc_crtn.h
@@ -531,4 +531,13 @@ struct lpfc_scsi_buf *lpfc_get_scsi_buf(struct lpfc_hba 
*phba,
struct lpfc_nodelist *ndlp);
 
 /* NVME interfaces. */
+void lpfc_nvme_unregister_port(struct lpfc_nodelist *ndlp);
+int lpfc_nvme_register_port(struct lpfc_vport *vport,
+   struct lpfc_nodelist *ndlp);
+int lpfc_nvme_create_localport(struct lpfc_vport *vport);
+void lpfc_nvme_destroy_localport(struct lpfc_vport *vport);
+void lpfc_nvme_update_localport(struct lpfc_vport *vport);
 void lpfc_nvme_mod_param_dep(struct lpfc_hba *phba);
+void lpfc_nvme_abort_fcreq_cmpl(struct lpfc_hba *phba,
+   struct lpfc_iocbq *cmdiocb,
+   struct lpfc_wcqe_complete *abts_cmpl);
diff --git a/drivers/scsi/lpfc/lpfc_ct.c b/drivers/scsi/lpfc/lpfc_ct.c
index 23d6a3c..ed285fc 100644
--- a/drivers/scsi/lpfc/lpfc_ct.c
+++ b/drivers/scsi/lpfc/lpfc_ct.c
@@ -1412,7 +1412,7 @@ lpfc_ns_cmd(struct lpfc_vport *vport, int cmdcode,
if (((phba->cfg_enable_fc4_type == LPFC_ENABLE_BOTH) ||
 (phba->cfg_enable_fc4_type == LPFC_ENABLE_NVME)) &&
(context == FC_TYPE_NVME)) {
-   /* todo: init: revise localport nvme attributes */
+   lpfc_nvme_update_localport(vport);
CtReq->un.rff.type_code = context;
 
} else if (((phba->cfg_enable_fc4_type == LPFC_ENABLE_BOTH) ||
diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c
index 3d915ee..6d2b163 100644
--- a/drivers/scsi/lpfc/lpfc_els.c
+++ b/drivers/scsi/lpfc/lpfc_els.c
@@ -2625,7 +2625,9 @@ lpfc_cmpl_els_logo(struct lpfc_hba *phba, struct 
lpfc_iocbq *cmdiocb,
!(vport->fc_flag & FC_PT2PT_PLOGI)) {
phba->pport->fc_myDID = 0;
 
-   /* todo: init: revise localport nvme attributes */
+   if ((phba->cfg_enable_fc4_type == LPFC_ENABLE_BOTH) ||
+   (phba->cfg_enable_fc4_type == LPFC_ENABLE_NVME))
+   lpfc_nvme_update_localport(phba->pport);
 
mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
if (mbox) {
diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c
index 55a16f2..291a4cb 100644
--- a/drivers/scsi/lpfc/lpfc_hbadisc.c
+++ b/drivers/scsi/lpfc/lpfc_hbadisc.c
@@ -912,7 +912,9 @@ lpfc_linkdown(struct lpfc_hba *phba)
 

[PATCH 15/17] lpfc: NVME Target: Add debugfs support

2017-01-17 Thread James Smart

NVME Target: Add debugfs support

Adds debugfs snippets to cover the new NVME target functionality

Signed-off-by: Dick Kennedy 
Signed-off-by: James Smart 
---
 drivers/scsi/lpfc/lpfc_debugfs.c | 387 ++-
 drivers/scsi/lpfc/lpfc_nvmet.c   | 279 +++-
 drivers/scsi/lpfc/lpfc_nvmet.h   |  13 ++
 3 files changed, 674 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
index 92f82c2..abd4b83 100644
--- a/drivers/scsi/lpfc/lpfc_debugfs.c
+++ b/drivers/scsi/lpfc/lpfc_debugfs.c
@@ -47,6 +47,7 @@
 #include "lpfc.h"
 #include "lpfc_scsi.h"
 #include "lpfc_nvme.h"
+#include "lpfc_nvmet.h"
 #include "lpfc_logmsg.h"
 #include "lpfc_crtn.h"
 #include "lpfc_vport.h"
@@ -537,11 +538,13 @@ lpfc_debugfs_nodelist_data(struct lpfc_vport *vport, char 
*buf, int size)
int len = 0;
int cnt;
struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
+   struct lpfc_hba  *phba = vport->phba;
struct lpfc_nodelist *ndlp;
unsigned char *statep;
struct nvme_fc_local_port *localport;
struct lpfc_nvme_lport *lport;
struct lpfc_nvme_rport *rport;
+   struct lpfc_nvmet_tgtport *tgtp;
struct nvme_fc_remote_port *nrport;
 
cnt = (LPFC_NODELIST_SIZE / LPFC_NODELIST_ENTRY_SIZE);
@@ -620,6 +623,26 @@ lpfc_debugfs_nodelist_data(struct lpfc_vport *vport, char 
*buf, int size)
}
spin_unlock_irq(shost->host_lock);
 
+   if (phba->nvmet_support && phba->targetport && (vport == phba->pport)) {
+   tgtp = (struct lpfc_nvmet_tgtport *)phba->targetport->private;
+   len += snprintf(buf+len, size-len,
+   "\nNVME Targetport Entry ...\n");
+
+   /* Port state is only one of two values for now. */
+   if (phba->targetport->port_id)
+   statep = "REGISTERED";
+   else
+   statep = "INIT";
+   len += snprintf(buf+len, size-len,
+   "TGT WWNN x%llx WWPN x%llx State %s\n",
+   wwn_to_u64(vport->fc_nodename.u.wwn),
+   wwn_to_u64(vport->fc_portname.u.wwn),
+   statep);
+   len += snprintf(buf+len, size-len,
+   "Targetport DID x%06x\n",
+   phba->targetport->port_id);
+   goto out_exit;
+   }
len += snprintf(buf+len, size-len, "\nNVME Lport/Rport Entries ...\n");
 
localport = vport->localport;
@@ -711,9 +734,75 @@ static int
 lpfc_debugfs_nvmestat_data(struct lpfc_vport *vport, char *buf, int size)
 {
struct lpfc_hba   *phba = vport->phba;
+   struct lpfc_nvmet_tgtport *tgtp;
int len = 0;
 
-   if (phba->nvmet_support == 0) {
+   if (phba->nvmet_support) {
+   if (!phba->targetport)
+   return len;
+   tgtp = (struct lpfc_nvmet_tgtport *)phba->targetport->private;
+   len += snprintf(buf+len, size-len,
+   "\nNVME Targetport Statistics\n");
+
+   len += snprintf(buf+len, size-len,
+   "LS: Rcv %08x Drop %08x Abort %08x\n",
+   atomic_read(>rcv_ls_req_in),
+   atomic_read(>rcv_ls_req_drop),
+   atomic_read(>xmt_ls_abort));
+   if (atomic_read(>rcv_ls_req_in) !=
+   atomic_read(>rcv_ls_req_out)) {
+   len += snprintf(buf+len, size-len,
+   "Rcv LS: in %08x != out %08x\n",
+   atomic_read(>rcv_ls_req_in),
+   atomic_read(>rcv_ls_req_out));
+   }
+
+   len += snprintf(buf+len, size-len,
+   "LS: Xmt %08x Drop %08x Cmpl %08x Err %08x\n",
+   atomic_read(>xmt_ls_rsp),
+   atomic_read(>xmt_ls_drop),
+   atomic_read(>xmt_ls_rsp_cmpl),
+   atomic_read(>xmt_ls_rsp_error));
+
+   len += snprintf(buf+len, size-len,
+   "FCP: Rcv %08x Drop %08x\n",
+   atomic_read(>rcv_fcp_cmd_in),
+   atomic_read(>rcv_fcp_cmd_drop));
+
+   if (atomic_read(>rcv_fcp_cmd_in) !=
+   atomic_read(>rcv_fcp_cmd_out)) {
+   len += snprintf(buf+len, size-len,
+   "Rcv FCP: in %08x != out %08x\n",
+   atomic_read(>rcv_fcp_cmd_in),
+   atomic_read(>rcv_fcp_cmd_out));
+   

[PATCH 16/17] lpfc: Update copyrights

2017-01-17 Thread James Smart

Update copyrights to 2017 for all files touched in this patch set

Signed-off-by: Dick Kennedy 
Signed-off-by: James Smart 
---
 drivers/scsi/lpfc/Makefile | 2 +-
 drivers/scsi/lpfc/lpfc.h   | 2 +-
 drivers/scsi/lpfc/lpfc_attr.c  | 2 +-
 drivers/scsi/lpfc/lpfc_attr.h  | 2 +-
 drivers/scsi/lpfc/lpfc_bsg.c   | 2 +-
 drivers/scsi/lpfc/lpfc_crtn.h  | 2 +-
 drivers/scsi/lpfc/lpfc_ct.c| 2 +-
 drivers/scsi/lpfc/lpfc_debugfs.c   | 2 +-
 drivers/scsi/lpfc/lpfc_debugfs.h   | 2 +-
 drivers/scsi/lpfc/lpfc_disc.h  | 2 +-
 drivers/scsi/lpfc/lpfc_els.c   | 2 +-
 drivers/scsi/lpfc/lpfc_hbadisc.c   | 2 +-
 drivers/scsi/lpfc/lpfc_hw.h| 2 +-
 drivers/scsi/lpfc/lpfc_hw4.h   | 2 +-
 drivers/scsi/lpfc/lpfc_init.c  | 2 +-
 drivers/scsi/lpfc/lpfc_logmsg.h| 2 +-
 drivers/scsi/lpfc/lpfc_mbox.c  | 2 +-
 drivers/scsi/lpfc/lpfc_mem.c   | 2 +-
 drivers/scsi/lpfc/lpfc_nportdisc.c | 4 ++--
 drivers/scsi/lpfc/lpfc_nvme.c  | 2 +-
 drivers/scsi/lpfc/lpfc_nvme.h  | 2 +-
 drivers/scsi/lpfc/lpfc_nvmet.c | 4 ++--
 drivers/scsi/lpfc/lpfc_nvmet.h | 2 +-
 drivers/scsi/lpfc/lpfc_scsi.c  | 2 +-
 drivers/scsi/lpfc/lpfc_scsi.h  | 2 +-
 drivers/scsi/lpfc/lpfc_sli.c   | 2 +-
 drivers/scsi/lpfc/lpfc_sli.h   | 2 +-
 drivers/scsi/lpfc/lpfc_sli4.h  | 2 +-
 drivers/scsi/lpfc/lpfc_version.h   | 2 +-
 drivers/scsi/lpfc/lpfc_vport.c | 2 +-
 30 files changed, 32 insertions(+), 32 deletions(-)

diff --git a/drivers/scsi/lpfc/Makefile b/drivers/scsi/lpfc/Makefile
index 30a6a35..fc93163 100644
--- a/drivers/scsi/lpfc/Makefile
+++ b/drivers/scsi/lpfc/Makefile
@@ -1,7 +1,7 @@
 #/***
 # * This file is part of the Emulex Linux Device Driver for *
 # * Fibre Channel Host Bus Adapters.*
-# * Copyright (C) 2004-2012 Emulex.  All rights reserved.   *
+# * Copyright (C) 2004-2017 Emulex.  All rights reserved.   *
 # * EMULEX and SLI are trademarks of Emulex.*
 # * www.emulex.com  *
 # * *
diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
index 92dd0a4..d6df03e 100644
--- a/drivers/scsi/lpfc/lpfc.h
+++ b/drivers/scsi/lpfc/lpfc.h
@@ -1,7 +1,7 @@
 /***
  * This file is part of the Emulex Linux Device Driver for *
  * Fibre Channel Host Bus Adapters.*
- * Copyright (C) 2004-2016 Emulex.  All rights reserved.   *
+ * Copyright (C) 2004-2017 Emulex.  All rights reserved.   *
  * EMULEX and SLI are trademarks of Emulex.*
  * www.emulex.com  *
  * Portions Copyright (C) 2004-2005 Christoph Hellwig  *
diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c
index 5ace3ed..618a786 100644
--- a/drivers/scsi/lpfc/lpfc_attr.c
+++ b/drivers/scsi/lpfc/lpfc_attr.c
@@ -1,7 +1,7 @@
 /***
  * This file is part of the Emulex Linux Device Driver for *
  * Fibre Channel Host Bus Adapters.*
- * Copyright (C) 2004-2016 Emulex.  All rights reserved.   *
+ * Copyright (C) 2004-2017 Emulex.  All rights reserved.   *
  * EMULEX and SLI are trademarks of Emulex.*
  * www.emulex.com  *
  * Portions Copyright (C) 2004-2005 Christoph Hellwig  *
diff --git a/drivers/scsi/lpfc/lpfc_attr.h b/drivers/scsi/lpfc/lpfc_attr.h
index 95c6b83..3033166 100644
--- a/drivers/scsi/lpfc/lpfc_attr.h
+++ b/drivers/scsi/lpfc/lpfc_attr.h
@@ -1,7 +1,7 @@
 /***
  * This file is part of the Emulex Linux Device Driver for *
  * Fibre Channel Host Bus Adapters.*
- * Copyright (C) 2004-2016 Emulex.  All rights reserved.   *
+ * Copyright (C) 2004-2017 Emulex.  All rights reserved.   *
  * EMULEX and SLI are trademarks of Emulex.*
  * www.emulex.com  *
  * Portions Copyright (C) 2004-2005 Christoph Hellwig  *
diff --git a/drivers/scsi/lpfc/lpfc_bsg.c b/drivers/scsi/lpfc/lpfc_bsg.c
index 1e88b35..7d50752 100644
--- a/drivers/scsi/lpfc/lpfc_bsg.c
+++ b/drivers/scsi/lpfc/lpfc_bsg.c
@@ -1,7 +1,7 @@
 /***
  * This file is part of the Emulex Linux Device Driver for *
  * Fibre Channel Host Bus Adapters.*
- * Copyright (C) 2009-2015 Emulex.  All rights reserved.   *
+ * 

[PATCH 10/17] lpfc: NVME Initiator: Add debugfs support

2017-01-17 Thread James Smart

NVME Initiator: Add debugfs support

Adds debugfs snippets to cover the new NVME initiator functionality

Signed-off-by: Dick Kennedy 
Signed-off-by: James Smart 
---
 drivers/scsi/lpfc/lpfc.h |  48 +++
 drivers/scsi/lpfc/lpfc_ct.c  |  27 +-
 drivers/scsi/lpfc/lpfc_debugfs.c | 775 ++-
 drivers/scsi/lpfc/lpfc_debugfs.h | 150 +++-
 drivers/scsi/lpfc/lpfc_nvme.c| 125 +++
 drivers/scsi/lpfc/lpfc_nvme.h|   7 +
 drivers/scsi/lpfc/lpfc_sli.c |   5 +
 7 files changed, 1128 insertions(+), 9 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
index 1dae886..e2e3313 100644
--- a/drivers/scsi/lpfc/lpfc.h
+++ b/drivers/scsi/lpfc/lpfc.h
@@ -458,6 +458,9 @@ struct lpfc_vport {
 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
struct dentry *debug_disc_trc;
struct dentry *debug_nodelist;
+   struct dentry *debug_nvmestat;
+   struct dentry *debug_nvmektime;
+   struct dentry *debug_cpucheck;
struct dentry *vport_debugfs_root;
struct lpfc_debugfs_trc *disc_trc;
atomic_t disc_trc_cnt;
@@ -1089,6 +1092,51 @@ struct lpfc_hba {
 #define LPFC_TRANSGRESSION_LOW_RXPOWER 0x4000
uint16_t sfp_alarm;
uint16_t sfp_warning;
+
+#ifdef CONFIG_SCSI_LPFC_DEBUG_FS
+#define LPFC_CHECK_CPU_CNT32
+   uint32_t cpucheck_rcv_io[LPFC_CHECK_CPU_CNT];
+   uint32_t cpucheck_xmt_io[LPFC_CHECK_CPU_CNT];
+   uint32_t cpucheck_cmpl_io[LPFC_CHECK_CPU_CNT];
+   uint32_t cpucheck_ccmpl_io[LPFC_CHECK_CPU_CNT];
+   uint16_t cpucheck_on;
+#define LPFC_CHECK_OFF 0
+#define LPFC_CHECK_NVME_IO 1
+   uint16_t ktime_on;
+   uint64_t ktime_data_samples;
+   uint64_t ktime_status_samples;
+   uint64_t ktime_last_cmd;
+   uint64_t ktime_seg1_total;
+   uint64_t ktime_seg1_min;
+   uint64_t ktime_seg1_max;
+   uint64_t ktime_seg2_total;
+   uint64_t ktime_seg2_min;
+   uint64_t ktime_seg2_max;
+   uint64_t ktime_seg3_total;
+   uint64_t ktime_seg3_min;
+   uint64_t ktime_seg3_max;
+   uint64_t ktime_seg4_total;
+   uint64_t ktime_seg4_min;
+   uint64_t ktime_seg4_max;
+   uint64_t ktime_seg5_total;
+   uint64_t ktime_seg5_min;
+   uint64_t ktime_seg5_max;
+   uint64_t ktime_seg6_total;
+   uint64_t ktime_seg6_min;
+   uint64_t ktime_seg6_max;
+   uint64_t ktime_seg7_total;
+   uint64_t ktime_seg7_min;
+   uint64_t ktime_seg7_max;
+   uint64_t ktime_seg8_total;
+   uint64_t ktime_seg8_min;
+   uint64_t ktime_seg8_max;
+   uint64_t ktime_seg9_total;
+   uint64_t ktime_seg9_min;
+   uint64_t ktime_seg9_max;
+   uint64_t ktime_seg10_total;
+   uint64_t ktime_seg10_min;
+   uint64_t ktime_seg10_max;
+#endif
 };
 
 static inline struct Scsi_Host *
diff --git a/drivers/scsi/lpfc/lpfc_ct.c b/drivers/scsi/lpfc/lpfc_ct.c
index ed285fc..6aba862 100644
--- a/drivers/scsi/lpfc/lpfc_ct.c
+++ b/drivers/scsi/lpfc/lpfc_ct.c
@@ -465,6 +465,10 @@ lpfc_prep_node_fc4type(struct lpfc_vport *vport, uint32_t 
Did, uint8_t fc4_type)
ndlp = lpfc_setup_disc_node(vport, Did);
 
if (ndlp && NLP_CHK_NODE_ACT(ndlp)) {
+   lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT,
+   "Parse GID_FTrsp: did:x%x flg:x%x x%x",
+   Did, ndlp->nlp_flag, vport->fc_flag);
+
/* By default, the driver expects to support FCP FC4 */
if (fc4_type == FC_TYPE_FCP)
ndlp->nlp_fc4_type |= NLP_FC4_FCP;
@@ -478,16 +482,24 @@ lpfc_prep_node_fc4type(struct lpfc_vport *vport, uint32_t 
Did, uint8_t fc4_type)
 ndlp->nlp_flag, ndlp->nlp_fc4_type,
 vport->fc_flag,
 vport->fc_rscn_id_cnt);
-   } else
+   } else {
+   lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT,
+   "Skip1 GID_FTrsp: did:x%x flg:x%x cnt:%d",
+   Did, vport->fc_flag, vport->fc_rscn_id_cnt);
+
lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
 "0239 Skip x%06x NameServer Rsp "
 "Data: x%x x%x\n", Did,
 vport->fc_flag,
 vport->fc_rscn_id_cnt);
-
+   }
} else {
if (!(vport->fc_flag & FC_RSCN_MODE) ||
lpfc_rscn_payload_check(vport, Did)) {
+   lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT,
+   "Query GID_FTrsp: did:x%x flg:x%x cnt:%d",
+   Did, vport->fc_flag, vport->fc_rscn_id_cnt);
+
 

[PATCH 12/17] lpfc: NVME Target: Receive buffer updates

2017-01-17 Thread James Smart

NVME Target: Receive buffer updates

Allocates buffer pools and configures adapter interfaces to handle
receive buffer (asynchronous FCP CMD ius, first burst data)
from the adapter. Splits by protocol, etc.

Signed-off-by: Dick Kennedy 
Signed-off-by: James Smart 
---
 drivers/scsi/lpfc/lpfc.h  |   3 +
 drivers/scsi/lpfc/lpfc_attr.c |  86 +-
 drivers/scsi/lpfc/lpfc_crtn.h |   1 +
 drivers/scsi/lpfc/lpfc_hw4.h  | 274 +++
 drivers/scsi/lpfc/lpfc_init.c | 264 +-
 drivers/scsi/lpfc/lpfc_mbox.c |  87 ++
 drivers/scsi/lpfc/lpfc_sli.c  | 608 +-
 drivers/scsi/lpfc/lpfc_sli4.h |  11 +
 8 files changed, 1313 insertions(+), 21 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
index 791a661..92dd0a4 100644
--- a/drivers/scsi/lpfc/lpfc.h
+++ b/drivers/scsi/lpfc/lpfc.h
@@ -774,8 +774,11 @@ struct lpfc_hba {
uint32_t cfg_nvme_max_hw_queue;
uint32_t cfg_nvmet_max_hw_queue;
uint32_t cfg_nvme_posted_buf;
+   uint32_t cfg_nvmet_mrq;
+   uint32_t cfg_nvmet_mrq_post;
uint32_t cfg_enable_nvmet;
uint32_t cfg_nvme_enable_fb;
+   uint32_t cfg_nvmet_fb_size;
uint32_t cfg_total_seg_cnt;
uint32_t cfg_sg_seg_cnt;
uint32_t cfg_sg_dma_buf_size;
diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c
index 2f4ebc7..5ace3ed 100644
--- a/drivers/scsi/lpfc/lpfc_attr.c
+++ b/drivers/scsi/lpfc/lpfc_attr.c
@@ -58,6 +58,10 @@
 #define LPFC_MIN_DEVLOSS_TMO   1
 #define LPFC_MAX_DEVLOSS_TMO   255
 
+#define LPFC_DEF_MRQ_POST  128
+#define LPFC_MIN_MRQ_POST  32
+#define LPFC_MAX_MRQ_POST  512
+
 /*
  * Write key size should be multiple of 4. If write key is changed
  * make sure that library write key is also changed.
@@ -3288,6 +3292,24 @@ LPFC_ATTR_R(suppress_rsp, 1, 0, 1,
"Enable suppress rsp feature is firmware supports it");
 
 /*
+ * lpfc_nvmet_mrq: Specify number of RQ pairs for processing NVMET cmds
+ * lpfc_nvmet_mrq = 1  use a single RQ pair
+ * lpfc_nvmet_mrq >= 2  use specified RQ pairs for MRQ
+ *
+ */
+LPFC_ATTR_R(nvmet_mrq,
+   1, 1, 16,
+   "Specify number of RQ pairs for processing NVMET cmds");
+
+/*
+ * lpfc_nvmet_mrq_post: Specify number buffers to post on every MRQ
+ *
+ */
+LPFC_ATTR_R(nvmet_mrq_post, LPFC_DEF_MRQ_POST,
+   LPFC_MIN_MRQ_POST, LPFC_MAX_MRQ_POST,
+   "Specify number of buffers to post on every MRQ");
+
+/*
  * lpfc_enable_fc4_type: Defines what FC4 types are supported.
  * Supported Values:  1 - register just FCP
  *2 - register just NVME
@@ -4664,13 +4686,28 @@ LPFC_VPORT_ATTR_RW(first_burst_size, 0, 0, 65536,
   "First burst size for Targets that support first burst");
 
 /*
-* lpfc_nvme_enable_fb: Enable NVME first burst on I and T functions.
-* For the Initiator (I), enabling this parameter means that an NVME
-* PRLI response with FBA enabled and an FB_SIZE set to a nonzero value
-* will be processed by the initiator for subsequent NVME FCP IO.
+* lpfc_nvmet_fb_size: NVME Target mode supported first burst size.
+* When the driver is configured as an NVME target, this value is
+* communicated to the NVME initiator in the PRLI response.  It is
+* used only when the lpfc_nvme_enable_fb and lpfc_nvmet_support
+* parameters are set and the target is sending the PRLI RSP.
 * Parameter supported on physical port only - no NPIV support.
-* Value range is [0,1]. Default value is 0 (disabled).
+* Value range is [0,65536]. Default value is 0.
 */
+LPFC_ATTR_RW(nvmet_fb_size, 0, 0, 65536,
+"NVME Target mode first burst size in 512B increments.");
+
+/*
+ * lpfc_nvme_enable_fb: Enable NVME first burst on I and T functions.
+ * For the Initiator (I), enabling this parameter means that an NVMET
+ * PRLI response with FBA enabled and an FB_SIZE set to a nonzero value will be
+ * processed by the initiator for subsequent NVME FCP IO. For the target
+ * function (T), enabling this parameter qualifies the lpfc_nvmet_fb_size
+ * driver parameter as the target function's first burst size returned to the
+ * initiator in the target's NVME PRLI response. Parameter supported on 
physical
+ * port only - no NPIV support.
+ * Value range is [0,1]. Default value is 0 (disabled).
+ */
 LPFC_ATTR_RW(nvme_enable_fb, 0, 0, 1,
 "Enable First Burst feature on I and T functions.");
 
@@ -5156,7 +5193,10 @@ struct device_attribute *lpfc_hba_attrs[] = {
_attr_lpfc_nvme_max_hw_queue,
_attr_lpfc_nvmet_max_hw_queue,
_attr_lpfc_nvme_posted_buf,
+   _attr_lpfc_nvmet_mrq,
+   _attr_lpfc_nvmet_mrq_post,
_attr_lpfc_nvme_enable_fb,
+   _attr_lpfc_nvmet_fb_size,
_attr_lpfc_enable_bg,
_attr_lpfc_soft_wwnn,
_attr_lpfc_soft_wwpn,
@@ -6193,9 +6233,12 @@ lpfc_get_cfgparam(struct lpfc_hba *phba)

[PATCH 11/17] lpfc: NVME Target: Base modifications

2017-01-17 Thread James Smart

NVME Target: Base modifications

This set of patches adds the base modifications for NVME target support
to the lpfc driver.

The base modifications consist of:
- Additional module parameters or configuration tuning
- Enablement of configuration mode for NVME target. Ties into the
  queueing model put into place by the initiator basemods patches.
- Target-specific buffer pools, dma pools, sgl pools

Signed-off-by: Dick Kennedy 
Signed-off-by: James Smart 
---
 drivers/scsi/lpfc/lpfc.h |   6 +
 drivers/scsi/lpfc/lpfc_attr.c| 160 ++-
 drivers/scsi/lpfc/lpfc_crtn.h|  10 ++
 drivers/scsi/lpfc/lpfc_debugfs.c |   7 +-
 drivers/scsi/lpfc/lpfc_init.c| 268 ---
 drivers/scsi/lpfc/lpfc_mem.c | 167 
 drivers/scsi/lpfc/lpfc_nvmet.h   |  97 ++
 drivers/scsi/lpfc/lpfc_sli.c | 112 +++-
 drivers/scsi/lpfc/lpfc_sli.h |   1 +
 drivers/scsi/lpfc/lpfc_sli4.h|   6 +
 10 files changed, 806 insertions(+), 28 deletions(-)
 create mode 100644 drivers/scsi/lpfc/lpfc_nvmet.h

diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
index e2e3313..791a661 100644
--- a/drivers/scsi/lpfc/lpfc.h
+++ b/drivers/scsi/lpfc/lpfc.h
@@ -741,6 +741,7 @@ struct lpfc_hba {
uint8_t  fcp_embed_io;
uint8_t  nvme_support;  /* Firmware supports NVME */
uint8_t  nvmet_support; /* driver supports NVMET */
+#define LPFC_NVMET_MAX_PORTS   32
uint8_t  mds_diags_support;
 
/* HBA Config Parameters */
@@ -771,7 +772,9 @@ struct lpfc_hba {
uint32_t cfg_nvme_io_channel;
uint32_t cfg_fcp_max_hw_queue;
uint32_t cfg_nvme_max_hw_queue;
+   uint32_t cfg_nvmet_max_hw_queue;
uint32_t cfg_nvme_posted_buf;
+   uint32_t cfg_enable_nvmet;
uint32_t cfg_nvme_enable_fb;
uint32_t cfg_total_seg_cnt;
uint32_t cfg_sg_seg_cnt;
@@ -824,6 +827,7 @@ struct lpfc_hba {
 #define LPFC_ENABLE_NVME 2
 #define LPFC_ENABLE_BOTH 3
uint32_t io_channel;/* max of fcp or nvme io channels */
+   struct nvmet_fc_target_port *targetport;
lpfc_vpd_t vpd; /* vital product data */
 
struct pci_dev *pcidev;
@@ -1102,6 +1106,8 @@ struct lpfc_hba {
uint16_t cpucheck_on;
 #define LPFC_CHECK_OFF 0
 #define LPFC_CHECK_NVME_IO 1
+#define LPFC_CHECK_NVMET_RCV   2
+#define LPFC_CHECK_NVMET_IO4
uint16_t ktime_on;
uint64_t ktime_data_samples;
uint64_t ktime_status_samples;
diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c
index 72949f5..2f4ebc7 100644
--- a/drivers/scsi/lpfc/lpfc_attr.c
+++ b/drivers/scsi/lpfc/lpfc_attr.c
@@ -46,6 +46,7 @@
 #include "lpfc.h"
 #include "lpfc_scsi.h"
 #include "lpfc_nvme.h"
+#include "lpfc_nvmet.h"
 #include "lpfc_logmsg.h"
 #include "lpfc_version.h"
 #include "lpfc_compat.h"
@@ -139,6 +140,7 @@ lpfc_nvme_info_show(struct device *dev, struct 
device_attribute *attr,
struct Scsi_Host *shost = class_to_shost(dev);
struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata;
struct lpfc_hba   *phba = vport->phba;
+   struct lpfc_nvmet_tgtport *tgtp;
struct nvme_fc_local_port *localport;
struct lpfc_nvme_lport *lport;
struct lpfc_nvme_rport *rport;
@@ -150,6 +152,92 @@ lpfc_nvme_info_show(struct device *dev, struct 
device_attribute *attr,
len += snprintf(buf, PAGE_SIZE, "NVME Disabled\n");
return len;
}
+   if (phba->nvmet_support) {
+   if (!phba->targetport) {
+   len = snprintf(buf, PAGE_SIZE,
+   "NVME Target: x%llx is not allocated\n",
+   wwn_to_u64(vport->fc_portname.u.wwn));
+   return len;
+   }
+   /* Port state is only one of two values for now. */
+   if (phba->targetport->port_id)
+   statep = "REGISTERED";
+   else
+   statep = "INIT";
+   len += snprintf(buf + len, PAGE_SIZE - len,
+   "NVME Target: Enabled  State %s\n",
+   statep);
+   len += snprintf(buf + len, PAGE_SIZE - len,
+   "%s%d WWPN x%llx WWNN x%llx DID x%06x\n",
+   "NVME Target: lpfc",
+   phba->brd_no,
+   wwn_to_u64(vport->fc_portname.u.wwn),
+   wwn_to_u64(vport->fc_nodename.u.wwn),
+   phba->targetport->port_id);
+
+   len += snprintf(buf + len, PAGE_SIZE,
+   "\nNVME Target: Statistics\n");
+   tgtp = (struct lpfc_nvmet_tgtport *)phba->targetport->private;
+   len += 

[PATCH 06/17] lpfc: NVME Initiator: Base modifications Part E

2017-01-17 Thread James Smart

NVME Initiator: Base modifications

This is part E of parts A..F.

Part E is limited to lpfc_sli.c. This is the location of most of changes
for the following:
- sli3 ring vs sli4 wq splits
- io abort interfaces
- actual queuing routines and use of dma and sgl pools
- service routines to create/delete queues

*

Refer to Part A for a description of base modifications

Signed-off-by: Dick Kennedy 
Signed-off-by: James Smart 
---
 drivers/scsi/lpfc/lpfc_sli.c | 1508 ++
 1 file changed, 1093 insertions(+), 415 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
index d977a472..076810d 100644
--- a/drivers/scsi/lpfc/lpfc_sli.c
+++ b/drivers/scsi/lpfc/lpfc_sli.c
@@ -34,14 +34,17 @@
 #include 
 #include 
 
+#include 
+
 #include "lpfc_hw4.h"
 #include "lpfc_hw.h"
 #include "lpfc_sli.h"
 #include "lpfc_sli4.h"
 #include "lpfc_nl.h"
 #include "lpfc_disc.h"
-#include "lpfc_scsi.h"
 #include "lpfc.h"
+#include "lpfc_scsi.h"
+#include "lpfc_nvme.h"
 #include "lpfc_crtn.h"
 #include "lpfc_logmsg.h"
 #include "lpfc_compat.h"
@@ -67,14 +70,17 @@ static struct lpfc_iocbq 
*lpfc_sli4_els_wcqe_to_rspiocbq(struct lpfc_hba *,
 struct lpfc_iocbq *);
 static void lpfc_sli4_send_seq_to_ulp(struct lpfc_vport *,
  struct hbq_dmabuf *);
-static int lpfc_sli4_fp_handle_wcqe(struct lpfc_hba *, struct lpfc_queue *,
+static int lpfc_sli4_fp_handle_cqe(struct lpfc_hba *, struct lpfc_queue *,
struct lpfc_cqe *);
-static int lpfc_sli4_post_els_sgl_list(struct lpfc_hba *, struct list_head *,
+static int lpfc_sli4_post_sgl_list(struct lpfc_hba *, struct list_head *,
   int);
 static void lpfc_sli4_hba_handle_eqe(struct lpfc_hba *, struct lpfc_eqe *,
uint32_t);
 static bool lpfc_sli4_mbox_completions_pending(struct lpfc_hba *phba);
 static bool lpfc_sli4_process_missed_mbox_completions(struct lpfc_hba *phba);
+static int lpfc_sli4_abort_nvme_io(struct lpfc_hba *phba,
+  struct lpfc_sli_ring *pring,
+  struct lpfc_iocbq *cmdiocb);
 
 static IOCB_t *
 lpfc_get_iocb_from_iocbq(struct lpfc_iocbq *iocbq)
@@ -386,11 +392,10 @@ lpfc_sli4_cq_get(struct lpfc_queue *q)
/*
 * insert barrier for instruction interlock : data from the hardware
 * must have the valid bit checked before it can be copied and acted
-* upon. Speculative instructions were allowing a bcopy at the start
-* of lpfc_sli4_fp_handle_wcqe(), which is called immediately
-* after our return, to copy data before the valid bit check above
-* was done. As such, some of the copied data was stale. The barrier
-* ensures the check is before any data is copied.
+* upon. Given what was seen in lpfc_sli4_cq_get() of speculative
+* instructions allowing action on content before valid bit checked,
+* add barrier here as well. May not be needed as "content" is a
+* single 32-bit entity here (vs multi word structure for cq's).
 */
mb();
return cqe;
@@ -456,7 +461,7 @@ lpfc_sli4_cq_release(struct lpfc_queue *q, bool arm)
  * on @q then this function will return -ENOMEM.
  * The caller is expected to hold the hbalock when calling this routine.
  **/
-static int
+int
 lpfc_sli4_rq_put(struct lpfc_queue *hq, struct lpfc_queue *dq,
 struct lpfc_rqe *hrqe, struct lpfc_rqe *drqe)
 {
@@ -602,7 +607,7 @@ __lpfc_sli_get_iocbq(struct lpfc_hba *phba)
  *
  * Returns sglq ponter = success, NULL = Failure.
  **/
-static struct lpfc_sglq *
+struct lpfc_sglq *
 __lpfc_clear_active_sglq(struct lpfc_hba *phba, uint16_t xritag)
 {
struct lpfc_sglq *sglq;
@@ -902,7 +907,7 @@ lpfc_set_rrq_active(struct lpfc_hba *phba, struct 
lpfc_nodelist *ndlp,
 }
 
 /**
- * __lpfc_sli_get_sglq - Allocates an iocb object from sgl pool
+ * __lpfc_sli_get_els_sglq - Allocates an iocb object from sgl pool
  * @phba: Pointer to HBA context object.
  * @piocb: Pointer to the iocbq.
  *
@@ -911,10 +916,10 @@ lpfc_set_rrq_active(struct lpfc_hba *phba, struct 
lpfc_nodelist *ndlp,
  * list is not empty then it is successful, it returns pointer to the newly
  * allocated sglq object else it returns NULL.
  **/
-static struct lpfc_sglq *
-__lpfc_sli_get_sglq(struct lpfc_hba *phba, struct lpfc_iocbq *piocbq)
+struct lpfc_sglq *
+__lpfc_sli_get_els_sglq(struct lpfc_hba *phba, struct lpfc_iocbq *piocbq)
 {
-   struct list_head *lpfc_sgl_list = >sli4_hba.lpfc_sgl_list;
+   struct list_head *lpfc_els_sgl_list = >sli4_hba.lpfc_els_sgl_list;
struct lpfc_sglq *sglq = NULL;
struct lpfc_sglq *start_sglq = NULL;
struct lpfc_scsi_buf *lpfc_cmd;
@@ -938,18 +943,21 @@ __lpfc_sli_get_sglq(struct lpfc_hba 

[PATCH 02/17] lpfc: NVME Initiator: Base modifications Part A

2017-01-17 Thread James Smart

NVME Initiator: Base modifications

This is part A of parts A..F.

Part A is the bulk of the file list changed by the modifications as
most mods are small-ish. Changes may be for any aspect below.

*

This set of patches (6 parts) adds base modifications for NVME initiator
support to the lpfc driver.

The base modifications consist of:
- Formal split of SLI3 rings from SLI-4 WQs (sometimes referred to as
  rings as well) as implementation now widely varies between the two.
- Addition of configuration modes:
   SCSI initiator only; NVME initiator only; NVME target only; and
   SCSI and NVME initiator.
   The configuration mode drives overall adapter configuration,
   offloads enabled, and resource splits.
   NVME support is only available on SLI-4 devices and newer fw.
- Implements the following based on configuration mode:
  - Exchange resources are split by protocol; Obviously, if only
 1 mode, then no split occurs. Default is 50/50. module attribute
 allows tuning.
  - Each protocol has it's own set of queues, but share interrupt
vectors.
 SCSI:
   SLI3 devices have few queues and the original style of queue
 allocation remains.
   SLI4 devices piggy back on an "io-channel" concept that
 eventually needs to merge with scsi-mq/blk-mq support (it is
 underway).  For now, the paradigm continues as it existed
 prior. io channel allocates N msix and N WQs (N=4 default)
 and either round robins or uses cpu # modulo N for scheduling.
 A bunch of module parameters allow the configuration to be
 tuned.
 NVME (initiator):
   Allocates an msix per cpu (or whatever pci_alloc_irq_vectors
 gets)
   Allocates a WQ per cpu, and maps the WQs to msix on a WQ #
 modulo msix vector count basis.
   Module parameters exist to cap/control the config if desired.
  - Each protocol has its own buffer and dma pools.

Unfortunately, it was very difficult to break out the above into
functional patches. A such, they are presented as a 6-patch set to
keep email size reasonable. All patches in the set must be applied to
create a functional unit.

Signed-off-by: Dick Kennedy 
Signed-off-by: James Smart 
---
 drivers/scsi/lpfc/lpfc.h   |  77 ++--
 drivers/scsi/lpfc/lpfc_attr.h  |   1 +
 drivers/scsi/lpfc/lpfc_bsg.c   |  37 ++--
 drivers/scsi/lpfc/lpfc_crtn.h  |  44 -
 drivers/scsi/lpfc/lpfc_disc.h  |   1 +
 drivers/scsi/lpfc/lpfc_els.c   |  56 
 drivers/scsi/lpfc/lpfc_hbadisc.c   | 148 +++---
 drivers/scsi/lpfc/lpfc_hw.h|   5 +-
 drivers/scsi/lpfc/lpfc_hw4.h   | 183 +++--
 drivers/scsi/lpfc/lpfc_logmsg.h|   4 +
 drivers/scsi/lpfc/lpfc_mbox.c  |  47 ++
 drivers/scsi/lpfc/lpfc_mem.c   | 111 --
 drivers/scsi/lpfc/lpfc_nportdisc.c |   9 +-
 drivers/scsi/lpfc/lpfc_nvme.h  |  87 ++
 drivers/scsi/lpfc/lpfc_scsi.c  | 140 +++-
 drivers/scsi/lpfc/lpfc_scsi.h  |  18 ++--
 drivers/scsi/lpfc/lpfc_sli.h   |  37 ++--
 drivers/scsi/lpfc/lpfc_sli4.h  |  75 +++
 drivers/scsi/lpfc/lpfc_version.h   |   1 +
 drivers/scsi/lpfc/lpfc_vport.c |   3 +
 20 files changed, 854 insertions(+), 230 deletions(-)
 create mode 100644 drivers/scsi/lpfc/lpfc_nvme.h

diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
index 6593b07..3fad85e 100644
--- a/drivers/scsi/lpfc/lpfc.h
+++ b/drivers/scsi/lpfc/lpfc.h
@@ -20,6 +20,7 @@
  ***/
 
 #include 
+#include 
 
 #if defined(CONFIG_DEBUG_FS) && !defined(CONFIG_SCSI_LPFC_DEBUG_FS)
 #define CONFIG_SCSI_LPFC_DEBUG_FS
@@ -53,6 +54,7 @@ struct lpfc_sli2_slim;
 #define LPFC_MAX_SG_SEG_CNT4096/* sg element count per scsi cmnd */
 #define LPFC_MAX_SGL_SEG_CNT   512 /* SGL element count per scsi cmnd */
 #define LPFC_MAX_BPL_SEG_CNT   4096/* BPL element count per scsi cmnd */
+#define LPFC_MIN_NVME_SEG_CNT  254
 
 #define LPFC_MAX_SGE_SIZE   0x8000 /* Maximum data allowed in a SGE */
 #define LPFC_IOCB_LIST_CNT 2250/* list of IOCBs for fast-path usage. */
@@ -114,6 +116,13 @@ enum lpfc_polling_flags {
DISABLE_FCP_RING_INT= 0x2
 };
 
+struct perf_prof {
+   uint16_t cmd_cpu[40];
+   uint16_t rsp_cpu[40];
+   uint16_t qh_cpu[40];
+   uint16_t wqidx[40];
+};
+
 /* Provide DMA memory definitions the driver uses per port instance. */
 struct lpfc_dmabuf {
struct list_head list;
@@ -131,10 +140,24 @@ struct lpfc_dma_pool {
 struct hbq_dmabuf {
struct lpfc_dmabuf hbuf;
struct lpfc_dmabuf dbuf;
-   uint32_t size;
+   uint16_t total_size;
+   uint16_t bytes_recv;
uint32_t tag;
struct lpfc_cq_event cq_event;
unsigned long time_stamp;
+ 

[PATCH 07/17] lpfc: NVME Initiator: Base modifications Part F

2017-01-17 Thread James Smart

NVME Initiator: Base modifications

This is part F of parts A..F.

Part F is limited to lpfc_debugfs.[ch]. It contains the modifications in
the existing debugfs snippets to work with the base modifications.

*

Refer to Part A for a description of base modifications

Signed-off-by: Dick Kennedy 
Signed-off-by: James Smart 
---
 drivers/scsi/lpfc/lpfc_debugfs.c | 535 +--
 drivers/scsi/lpfc/lpfc_debugfs.h |  69 ++---
 2 files changed, 324 insertions(+), 280 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
index a63542b..a94ba2d 100644
--- a/drivers/scsi/lpfc/lpfc_debugfs.c
+++ b/drivers/scsi/lpfc/lpfc_debugfs.c
@@ -283,7 +283,7 @@ lpfc_debugfs_hbqinfo_data(struct lpfc_hba *phba, char *buf, 
int size)
spin_lock_irq(>hbalock);
 
/* toggle between multiple hbqs, if any */
-   i = lpfc_sli_hbq_count();
+   i = lpfc_sli_hbq_count(phba);
if (i > 1) {
 lpfc_debugfs_last_hbq++;
 if (lpfc_debugfs_last_hbq >= i)
@@ -484,20 +484,23 @@ lpfc_debugfs_dumpHostSlim_data(struct lpfc_hba *phba, 
char *buf, int size)
off += (8 * sizeof(uint32_t));
}
 
-   for (i = 0; i < 4; i++) {
-   pgpp = >port_gp[i];
-   pring = >ring[i];
-   len +=  snprintf(buf+len, size-len,
-"Ring %d: CMD GetInx:%d (Max:%d Next:%d "
-"Local:%d flg:x%x)  RSP PutInx:%d Max:%d\n",
-i, pgpp->cmdGetInx, pring->sli.sli3.numCiocb,
-pring->sli.sli3.next_cmdidx,
-pring->sli.sli3.local_getidx,
-pring->flag, pgpp->rspPutInx,
-pring->sli.sli3.numRiocb);
-   }
-
if (phba->sli_rev <= LPFC_SLI_REV3) {
+   for (i = 0; i < 4; i++) {
+   pgpp = >port_gp[i];
+   pring = >sli3_ring[i];
+   len +=  snprintf(buf+len, size-len,
+"Ring %d: CMD GetInx:%d "
+"(Max:%d Next:%d "
+"Local:%d flg:x%x)  "
+"RSP PutInx:%d Max:%d\n",
+i, pgpp->cmdGetInx,
+pring->sli.sli3.numCiocb,
+pring->sli.sli3.next_cmdidx,
+pring->sli.sli3.local_getidx,
+pring->flag, pgpp->rspPutInx,
+pring->sli.sli3.numRiocb);
+   }
+
word0 = readl(phba->HAregaddr);
word1 = readl(phba->CAregaddr);
word2 = readl(phba->HSregaddr);
@@ -531,10 +534,11 @@ lpfc_debugfs_nodelist_data(struct lpfc_vport *vport, char 
*buf, int size)
int cnt;
struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
struct lpfc_nodelist *ndlp;
-   unsigned char *statep, *name;
+   unsigned char *statep;
 
cnt = (LPFC_NODELIST_SIZE / LPFC_NODELIST_ENTRY_SIZE);
 
+   len += snprintf(buf+len, size-len, "\nFCP Nodelist Entries ...\n");
spin_lock_irq(shost->host_lock);
list_for_each_entry(ndlp, >fc_nodes, nlp_listp) {
if (!cnt) {
@@ -574,36 +578,32 @@ lpfc_debugfs_nodelist_data(struct lpfc_vport *vport, char 
*buf, int size)
default:
statep = "UNKNOWN";
}
-   len +=  snprintf(buf+len, size-len, "%s DID:x%06x ",
-   statep, ndlp->nlp_DID);
-   name = (unsigned char *)>nlp_portname;
-   len +=  snprintf(buf+len, size-len,
-   "WWPN %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x ",
-   *name, *(name+1), *(name+2), *(name+3),
-   *(name+4), *(name+5), *(name+6), *(name+7));
-   name = (unsigned char *)>nlp_nodename;
-   len +=  snprintf(buf+len, size-len,
-   "WWNN %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x ",
-   *name, *(name+1), *(name+2), *(name+3),
-   *(name+4), *(name+5), *(name+6), *(name+7));
+   len += snprintf(buf+len, size-len, "%s DID:x%06x ",
+   statep, ndlp->nlp_DID);
+   len += snprintf(buf+len, size-len,
+   "WWPN x%llx ",
+   wwn_to_u64(ndlp->nlp_portname.u.wwn));
+   len += snprintf(buf+len, size-len,
+   "WWNN x%llx ",
+   wwn_to_u64(ndlp->nlp_nodename.u.wwn));
if (ndlp->nlp_flag & NLP_RPI_REGISTERED)
-

[PATCH 04/17] lpfc: NVME Initiator: Base modifications Part C

2017-01-17 Thread James Smart

NVME Initiator: Base modifications

This is part C of parts A..F.

Part C is the 1st half of the mods to lpfc_init.c. This is the location
of most of changes for the following:
- sli3 ring vs sli4 wq splits
- buffer pools are allocated/freed
- sgl pools allocated/freed
- adapter resources split up
- queue config decided and enacted
- receive buffer management

*

Refer to Part A for a description of base modifications

Signed-off-by: Dick Kennedy 
Signed-off-by: James Smart 
---
 drivers/scsi/lpfc/lpfc_init.c | 1086 +++--
 1 file changed, 724 insertions(+), 362 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
index 7a17bd0..ca54beb 100644
--- a/drivers/scsi/lpfc/lpfc_init.c
+++ b/drivers/scsi/lpfc/lpfc_init.c
@@ -34,6 +34,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -46,8 +47,9 @@
 #include "lpfc_sli4.h"
 #include "lpfc_nl.h"
 #include "lpfc_disc.h"
-#include "lpfc_scsi.h"
 #include "lpfc.h"
+#include "lpfc_scsi.h"
+#include "lpfc_nvme.h"
 #include "lpfc_logmsg.h"
 #include "lpfc_crtn.h"
 #include "lpfc_vport.h"
@@ -87,6 +89,7 @@ static struct scsi_transport_template 
*lpfc_transport_template = NULL;
 static struct scsi_transport_template *lpfc_vport_transport_template = NULL;
 static DEFINE_IDR(lpfc_hba_index);
 
+
 /**
  * lpfc_config_port_prep - Perform lpfc initialization prior to config port
  * @phba: pointer to lpfc hba data structure.
@@ -499,12 +502,10 @@ lpfc_config_port_post(struct lpfc_hba *phba)
phba->link_state = LPFC_LINK_DOWN;
 
/* Only process IOCBs on ELS ring till hba_state is READY */
-   if (psli->ring[psli->extra_ring].sli.sli3.cmdringaddr)
-   psli->ring[psli->extra_ring].flag |= LPFC_STOP_IOCB_EVENT;
-   if (psli->ring[psli->fcp_ring].sli.sli3.cmdringaddr)
-   psli->ring[psli->fcp_ring].flag |= LPFC_STOP_IOCB_EVENT;
-   if (psli->ring[psli->next_ring].sli.sli3.cmdringaddr)
-   psli->ring[psli->next_ring].flag |= LPFC_STOP_IOCB_EVENT;
+   if (psli->sli3_ring[LPFC_EXTRA_RING].sli.sli3.cmdringaddr)
+   psli->sli3_ring[LPFC_EXTRA_RING].flag |= LPFC_STOP_IOCB_EVENT;
+   if (psli->sli3_ring[LPFC_FCP_RING].sli.sli3.cmdringaddr)
+   psli->sli3_ring[LPFC_FCP_RING].flag |= LPFC_STOP_IOCB_EVENT;
 
/* Post receive buffers for desired rings */
if (phba->sli_rev != 3)
@@ -892,7 +893,7 @@ lpfc_hba_free_post_buf(struct lpfc_hba *phba)
lpfc_sli_hbqbuf_free_all(phba);
else {
/* Cleanup preposted buffers on the ELS ring */
-   pring = >ring[LPFC_ELS_RING];
+   pring = >sli3_ring[LPFC_ELS_RING];
spin_lock_irq(>hbalock);
list_splice_init(>postbufq, );
spin_unlock_irq(>hbalock);
@@ -925,32 +926,43 @@ static void
 lpfc_hba_clean_txcmplq(struct lpfc_hba *phba)
 {
struct lpfc_sli *psli = >sli;
+   struct lpfc_queue *qp = NULL;
struct lpfc_sli_ring *pring;
LIST_HEAD(completions);
int i;
 
-   for (i = 0; i < psli->num_rings; i++) {
-   pring = >ring[i];
-   if (phba->sli_rev >= LPFC_SLI_REV4)
-   spin_lock_irq(>ring_lock);
-   else
+   if (phba->sli_rev != LPFC_SLI_REV4) {
+   for (i = 0; i < psli->num_rings; i++) {
+   pring = >sli3_ring[i];
spin_lock_irq(>hbalock);
-   /* At this point in time the HBA is either reset or DOA. Either
-* way, nothing should be on txcmplq as it will NEVER complete.
-*/
-   list_splice_init(>txcmplq, );
-   pring->txcmplq_cnt = 0;
-
-   if (phba->sli_rev >= LPFC_SLI_REV4)
-   spin_unlock_irq(>ring_lock);
-   else
+   /* At this point in time the HBA is either reset or DOA
+* Nothing should be on txcmplq as it will
+* NEVER complete.
+*/
+   list_splice_init(>txcmplq, );
+   pring->txcmplq_cnt = 0;
spin_unlock_irq(>hbalock);
 
+   lpfc_sli_abort_iocb_ring(phba, pring);
+   }
/* Cancel all the IOCBs from the completions list */
-   lpfc_sli_cancel_iocbs(phba, , IOSTAT_LOCAL_REJECT,
- IOERR_SLI_ABORTED);
+   lpfc_sli_cancel_iocbs(phba, ,
+ IOSTAT_LOCAL_REJECT, IOERR_SLI_ABORTED);
+   return;
+   }
+   list_for_each_entry(qp, >sli4_hba.lpfc_wq_list, wq_list) {
+   pring = qp->pring;
+   if (!pring)
+   continue;
+   spin_lock_irq(>ring_lock);
+   

[PATCH 05/17] lpfc: NVME Initiator: Base modifications Part D

2017-01-17 Thread James Smart

NVME Initiator: Base modifications

This is part D of parts A..F.

Part D is the 2nd half of the mods to lpfc_init.c. This is the location
of most of changes for the following:
- sli3 ring vs sli4 wq splits
- buffer pools are allocated/freed
- sgl pools allocated/freed
- adapter resources split up
- queue config decided and enacted
- receive buffer management

*

Refer to Part A for a description of base modifications

Signed-off-by: Dick Kennedy 
Signed-off-by: James Smart 
---
 drivers/scsi/lpfc/lpfc_init.c | 1088 +++--
 1 file changed, 616 insertions(+), 472 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
index ca54beb..ea12eca 100644
--- a/drivers/scsi/lpfc/lpfc_init.c
+++ b/drivers/scsi/lpfc/lpfc_init.c
@@ -7876,14 +7876,14 @@ lpfc_sli4_queue_create(struct lpfc_hba *phba)
 void
 lpfc_sli4_queue_destroy(struct lpfc_hba *phba)
 {
-   int idx;
+   int idx, numwq;
 
if (phba->cfg_fof)
lpfc_fof_queue_destroy(phba);
 
if (phba->sli4_hba.hba_eq != NULL) {
/* Release HBA event queue */
-   for (idx = 0; idx < phba->cfg_fcp_io_channel; idx++) {
+   for (idx = 0; idx < phba->io_channel; idx++) {
if (phba->sli4_hba.hba_eq[idx] != NULL) {
lpfc_sli4_queue_free(
phba->sli4_hba.hba_eq[idx]);
@@ -7907,9 +7907,22 @@ lpfc_sli4_queue_destroy(struct lpfc_hba *phba)
phba->sli4_hba.fcp_cq = NULL;
}
 
+   if (phba->sli4_hba.nvme_cq != NULL) {
+   /* Release NVME completion queue */
+   for (idx = 0; idx < phba->cfg_nvme_io_channel; idx++) {
+   if (phba->sli4_hba.nvme_cq[idx] != NULL) {
+   lpfc_sli4_queue_free(
+   phba->sli4_hba.nvme_cq[idx]);
+   phba->sli4_hba.nvme_cq[idx] = NULL;
+   }
+   }
+   kfree(phba->sli4_hba.nvme_cq);
+   phba->sli4_hba.nvme_cq = NULL;
+   }
+
if (phba->sli4_hba.fcp_wq != NULL) {
/* Release FCP work queue */
-   for (idx = 0; idx < phba->cfg_fcp_io_channel; idx++) {
+   for (idx = 0; idx < phba->cfg_fcp_max_hw_queue; idx++) {
if (phba->sli4_hba.fcp_wq[idx] != NULL) {
lpfc_sli4_queue_free(
phba->sli4_hba.fcp_wq[idx]);
@@ -7920,12 +7933,32 @@ lpfc_sli4_queue_destroy(struct lpfc_hba *phba)
phba->sli4_hba.fcp_wq = NULL;
}
 
+   if (phba->sli4_hba.nvme_wq != NULL) {
+   /* Release NVME work queue */
+   numwq = phba->cfg_nvme_max_hw_queue;
+   for (idx = 0; idx < numwq; idx++) {
+   if (phba->sli4_hba.nvme_wq[idx] != NULL) {
+   lpfc_sli4_queue_free(
+   phba->sli4_hba.nvme_wq[idx]);
+   phba->sli4_hba.nvme_wq[idx] = NULL;
+   }
+   }
+   kfree(phba->sli4_hba.nvme_wq);
+   phba->sli4_hba.nvme_wq = NULL;
+   }
+
/* Release FCP CQ mapping array */
if (phba->sli4_hba.fcp_cq_map != NULL) {
kfree(phba->sli4_hba.fcp_cq_map);
phba->sli4_hba.fcp_cq_map = NULL;
}
 
+   /* Release NVME CQ mapping array */
+   if (phba->sli4_hba.nvme_cq_map != NULL) {
+   kfree(phba->sli4_hba.nvme_cq_map);
+   phba->sli4_hba.nvme_cq_map = NULL;
+   }
+
/* Release mailbox command work queue */
if (phba->sli4_hba.mbx_wq != NULL) {
lpfc_sli4_queue_free(phba->sli4_hba.mbx_wq);
@@ -7938,6 +7971,12 @@ lpfc_sli4_queue_destroy(struct lpfc_hba *phba)
phba->sli4_hba.els_wq = NULL;
}
 
+   /* Release ELS work queue */
+   if (phba->sli4_hba.nvmels_wq != NULL) {
+   lpfc_sli4_queue_free(phba->sli4_hba.nvmels_wq);
+   phba->sli4_hba.nvmels_wq = NULL;
+   }
+
/* Release unsolicited receive queue */
if (phba->sli4_hba.hdr_rq != NULL) {
lpfc_sli4_queue_free(phba->sli4_hba.hdr_rq);
@@ -7954,15 +7993,83 @@ lpfc_sli4_queue_destroy(struct lpfc_hba *phba)
phba->sli4_hba.els_cq = NULL;
}
 
+   /* Release NVME LS complete queue */
+   if (phba->sli4_hba.nvmels_cq != NULL) {
+   lpfc_sli4_queue_free(phba->sli4_hba.nvmels_cq);
+   phba->sli4_hba.nvmels_cq = NULL;
+   }
+
/* Release mailbox command complete queue */
if (phba->sli4_hba.mbx_cq != NULL) {
lpfc_sli4_queue_free(phba->sli4_hba.mbx_cq);
phba->sli4_hba.mbx_cq = NULL;
   

[PATCH 03/17] lpfc: NVME Initiator: Base modifications Part B

2017-01-17 Thread James Smart

NVME Initiator: Base modifications

This is part B of parts A..F.

Part B is limited to lpfc_attr.c: lpfc attribute modifications

*

Refer to Part A for a description of base modifications

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

diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c
index 50cf402..72949f5 100644
--- a/drivers/scsi/lpfc/lpfc_attr.c
+++ b/drivers/scsi/lpfc/lpfc_attr.c
@@ -35,14 +35,17 @@
 #include 
 #include 
 
+#include 
+
 #include "lpfc_hw4.h"
 #include "lpfc_hw.h"
 #include "lpfc_sli.h"
 #include "lpfc_sli4.h"
 #include "lpfc_nl.h"
 #include "lpfc_disc.h"
-#include "lpfc_scsi.h"
 #include "lpfc.h"
+#include "lpfc_scsi.h"
+#include "lpfc_nvme.h"
 #include "lpfc_logmsg.h"
 #include "lpfc_version.h"
 #include "lpfc_compat.h"
@@ -50,9 +53,9 @@
 #include "lpfc_vport.h"
 #include "lpfc_attr.h"
 
-#define LPFC_DEF_DEVLOSS_TMO 30
-#define LPFC_MIN_DEVLOSS_TMO 1
-#define LPFC_MAX_DEVLOSS_TMO 255
+#define LPFC_DEF_DEVLOSS_TMO   30
+#define LPFC_MIN_DEVLOSS_TMO   1
+#define LPFC_MAX_DEVLOSS_TMO   255
 
 /*
  * Write key size should be multiple of 4. If write key is changed
@@ -130,6 +133,124 @@ lpfc_enable_fip_show(struct device *dev, struct 
device_attribute *attr,
 }
 
 static ssize_t
+lpfc_nvme_info_show(struct device *dev, struct device_attribute *attr,
+   char *buf)
+{
+   struct Scsi_Host *shost = class_to_shost(dev);
+   struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata;
+   struct lpfc_hba   *phba = vport->phba;
+   struct nvme_fc_local_port *localport;
+   struct lpfc_nvme_lport *lport;
+   struct lpfc_nvme_rport *rport;
+   struct nvme_fc_remote_port *nrport;
+   char *statep;
+   int len = 0;
+
+   if (!(phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME)) {
+   len += snprintf(buf, PAGE_SIZE, "NVME Disabled\n");
+   return len;
+   }
+
+   localport = vport->localport;
+   if (!localport) {
+   len = snprintf(buf, PAGE_SIZE,
+   "NVME Initiator x%llx is not allocated\n",
+   wwn_to_u64(vport->fc_portname.u.wwn));
+   return len;
+   }
+   len = snprintf(buf, PAGE_SIZE, "NVME Initiator Enabled\n");
+
+   spin_lock_irq(shost->host_lock);
+   lport = (struct lpfc_nvme_lport *)localport->private;
+
+   /* Port state is only one of two values for now. */
+   if (localport->port_id)
+   statep = "ONLINE";
+   else
+   statep = "UNKNOWN ";
+
+   len += snprintf(buf + len, PAGE_SIZE - len,
+   "%s%d WWPN x%llx WWNN x%llx DID x%06x %s\n",
+   "NVME LPORT lpfc",
+   phba->brd_no,
+   wwn_to_u64(vport->fc_portname.u.wwn),
+   wwn_to_u64(vport->fc_nodename.u.wwn),
+   localport->port_id, statep);
+
+   list_for_each_entry(rport, >rport_list, list) {
+   /* local short-hand pointer. */
+   nrport = rport->remoteport;
+
+   /* Port state is only one of two values for now. */
+   switch (nrport->port_state) {
+   case FC_OBJSTATE_ONLINE:
+   statep = "ONLINE";
+   break;
+   case FC_OBJSTATE_UNKNOWN:
+   statep = "UNKNOWN ";
+   break;
+   default:
+   statep = "UNSUPPORTED";
+   break;
+   }
+
+   /* Tab in to show lport ownership. */
+   len += snprintf(buf + len, PAGE_SIZE - len,
+   "NVME RPORT   ");
+   if (phba->brd_no >= 10)
+   len += snprintf(buf + len, PAGE_SIZE - len, " ");
+
+   len += snprintf(buf + len, PAGE_SIZE - len, "WWPN x%llx ",
+   nrport->port_name);
+   len += snprintf(buf + len, PAGE_SIZE - len, "WWNN x%llx ",
+   nrport->node_name);
+   len += snprintf(buf + len, PAGE_SIZE - len, "DID x%06x ",
+   nrport->port_id);
+
+   switch (nrport->port_role) {
+   case FC_PORT_ROLE_NVME_INITIATOR:
+   len +=  snprintf(buf + len, PAGE_SIZE - len,
+"INITIATOR ");
+   break;
+   case FC_PORT_ROLE_NVME_TARGET:
+   len +=  snprintf(buf + len, PAGE_SIZE - len,
+"TARGET ");
+   break;
+   case FC_PORT_ROLE_NVME_DISCOVERY:
+   len +=  snprintf(buf + len, PAGE_SIZE - 

[PATCH 00/17] lpfc: Add NVME Fabrics support

2017-01-17 Thread James Smart

This patch set add support for NVME over Fabrics FC transport.

The internals of the driver are reworked to support being either:
a SCSI initiator; a NVME intiator; both a SCSI initiator and a
NVME initiator; or a NVME target. More background on the internals
is given in patch2 - for the nvme initiator base modifications.

The driver effectively has parallel NVME and SCSI stacks that
utilize their own set of resources. They intersect only at the 
hardware level, mainly in the interrupt handling.

A few new files are added to support the interfaces of the
FC transport LLDD api for NVME fabrics.

The patches were cut against 1/17 scsi.git tree, misc branch.
** THEY ARE INTENDED FOR THE SCSI.GIT TREE, MISC BRANCH **

To avoid fuzz, the following patches should also be present on
top of the branch:
https://git.kernel.org/cgit/linux/kernel/git/jejb/scsi.git/commit/?h=fixes=cd60be4916ae689387d04b86b6fc15931e4c95ae
http://www.spinics.net/lists/linux-scsi/msg103766.html

The lpfc version in the linux-block.git tree is rather old. I have a
recipe for how to get it to a version that syncs with the
scsi.git/misc tree so that these patches can apply there as well.
Contact me if you would like it.

-- james


James Smart (17):
  lpfc: Move to new pci_alloc_irq_vectors() interface for intx/msi/msix
  lpfc: NVME Initiator: Base modifications Part A
  lpfc: NVME Initiator: Base modifications Part B
  lpfc: NVME Initiator: Base modifications Part C
  lpfc: NVME Initiator: Base modifications Part D
  lpfc: NVME Initiator: Base modifications Part E
  lpfc: NVME Initiator: Base modifications Part F
  lpfc: NVME Initiator: Merge into FC discovery
  lpfc: NVME Initiator: bind to nvme_fc api
  lpfc: NVME Initiator: Add debugfs support
  lpfc: NVME Target: Base modifications
  lpfc: NVME Target: Receive buffer updates
  lpfc: NVME Target: Merge into FC discovery
  lpfc: NVME Target: bind to nvmet_fc api
  lpfc: NVME Target: Add debugfs support
  lpfc: Update copyrights
  lpfc: Update lpfc version to 11.2.0.7

 drivers/scsi/lpfc/Makefile |9 +-
 drivers/scsi/lpfc/lpfc.h   |  147 +-
 drivers/scsi/lpfc/lpfc_attr.c  |  664 -
 drivers/scsi/lpfc/lpfc_attr.h  |3 +-
 drivers/scsi/lpfc/lpfc_bsg.c   |   39 +-
 drivers/scsi/lpfc/lpfc_crtn.h  |   74 +-
 drivers/scsi/lpfc/lpfc_ct.c|  470 +++---
 drivers/scsi/lpfc/lpfc_debugfs.c   | 1692 +
 drivers/scsi/lpfc/lpfc_debugfs.h   |  215 ++-
 drivers/scsi/lpfc/lpfc_disc.h  |   22 +-
 drivers/scsi/lpfc/lpfc_els.c   |  405 +++--
 drivers/scsi/lpfc/lpfc_hbadisc.c   |  345 +++--
 drivers/scsi/lpfc/lpfc_hw.h|   84 +-
 drivers/scsi/lpfc/lpfc_hw4.h   |  502 ++-
 drivers/scsi/lpfc/lpfc_init.c  | 2887 +---
 drivers/scsi/lpfc/lpfc_logmsg.h|6 +-
 drivers/scsi/lpfc/lpfc_mbox.c  |  136 +-
 drivers/scsi/lpfc/lpfc_mem.c   |  280 +++-
 drivers/scsi/lpfc/lpfc_nportdisc.c |  240 ++-
 drivers/scsi/lpfc/lpfc_nvme.c  | 2374 +
 drivers/scsi/lpfc/lpfc_nvme.h  |  100 ++
 drivers/scsi/lpfc/lpfc_nvmet.c | 1640 
 drivers/scsi/lpfc/lpfc_nvmet.h |  110 ++
 drivers/scsi/lpfc/lpfc_scsi.c  |  142 +-
 drivers/scsi/lpfc/lpfc_scsi.h  |   20 +-
 drivers/scsi/lpfc/lpfc_sli.c   | 2250 ++--
 drivers/scsi/lpfc/lpfc_sli.h   |   40 +-
 drivers/scsi/lpfc/lpfc_sli4.h  |   95 +-
 drivers/scsi/lpfc/lpfc_version.h   |5 +-
 drivers/scsi/lpfc/lpfc_vport.c |   19 +-
 30 files changed, 12774 insertions(+), 2241 deletions(-)
 create mode 100644 drivers/scsi/lpfc/lpfc_nvme.c
 create mode 100644 drivers/scsi/lpfc/lpfc_nvme.h
 create mode 100644 drivers/scsi/lpfc/lpfc_nvmet.c
 create mode 100644 drivers/scsi/lpfc/lpfc_nvmet.h

-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 01/17] lpfc: Use new pci_alloc_irq_vectors() interface

2017-01-17 Thread James Smart

Move to new pci_alloc_irq_vectors() interface for intx/msi/msix

Note: io channel paradigm remains, for now.

Signed-off-by: Dick Kennedy 
Signed-off-by: James Smart 
---
 drivers/scsi/lpfc/lpfc_init.c | 227 --
 1 file changed, 154 insertions(+), 73 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
index 4776fd8..7a17bd0 100644
--- a/drivers/scsi/lpfc/lpfc_init.c
+++ b/drivers/scsi/lpfc/lpfc_init.c
@@ -8485,16 +8485,14 @@ lpfc_sli4_pci_mem_unset(struct lpfc_hba *phba)
  * @phba: pointer to lpfc hba data structure.
  *
  * This routine is invoked to enable the MSI-X interrupt vectors to device
- * with SLI-3 interface specs. The kernel function pci_enable_msix_exact()
- * is called to enable the MSI-X vectors. Note that pci_enable_msix_exact(),
- * once invoked, enables either all or nothing, depending on the current
- * availability of PCI vector resources. The device driver is responsible
+ * with SLI-3 interface specs. The kernel function pci_alloc_irq_vectors()
+ * is called to enable the MSI-X vectors. The device driver is responsible
  * for calling the individual request_irq() to register each MSI-X vector
  * with a interrupt handler, which is done in this function. Note that
  * later when device is unloading, the driver should always call free_irq()
  * on all MSI-X vectors it has done request_irq() on before calling
- * pci_disable_msix(). Failure to do so results in a BUG_ON() and a device
- * will be left with MSI-X enabled and leaks its vectors.
+ * pci_free_irq_vectors(). Failure to do so results in a BUG_ON() and a
+ * device will be left with MSI-X enabled and leaks its vectors.
  *
  * Return codes
  *   0 - successful
@@ -8503,21 +8501,33 @@ lpfc_sli4_pci_mem_unset(struct lpfc_hba *phba)
 static int
 lpfc_sli_enable_msix(struct lpfc_hba *phba)
 {
-   int rc, i;
+   int vectors, rc, i;
LPFC_MBOXQ_t *pmb;
+   unsigned int irq_flags;
+   uint32_t min_cnt;
 
/* Set up MSI-X multi-message vectors */
for (i = 0; i < LPFC_MSIX_VECTORS; i++)
phba->msix_entries[i].entry = i;
 
/* Configure MSI-X capability structure */
-   rc = pci_enable_msix_exact(phba->pcidev, phba->msix_entries,
-  LPFC_MSIX_VECTORS);
-   if (rc) {
+   /* Allocate explicitly LPFC_MSIX_VECTORS number of vectors */
+   min_cnt = LPFC_MSIX_VECTORS;
+   irq_flags = PCI_IRQ_MSIX;
+   vectors = pci_alloc_irq_vectors(phba->pcidev, min_cnt,
+   LPFC_MSIX_VECTORS, irq_flags);
+   if (vectors < 0) {
lpfc_printf_log(phba, KERN_INFO, LOG_INIT,
-   "0420 PCI enable MSI-X failed (%d)\n", rc);
+   "0420 PCI enable MSI-X failed (%d)\n",
+   vectors);
+   rc = -1;
goto vec_fail_out;
}
+
+   /* Complete the MSIX vector setup. */
+   for (i = 0; i < LPFC_MSIX_VECTORS; i++)
+   phba->msix_entries[i].vector = pci_irq_vector(phba->pcidev, i);
+
for (i = 0; i < LPFC_MSIX_VECTORS; i++)
lpfc_printf_log(phba, KERN_INFO, LOG_INIT,
"0477 MSI-X entry[%d]: vector=x%x "
@@ -8593,7 +8603,7 @@ lpfc_sli_enable_msix(struct lpfc_hba *phba)
 
 msi_fail_out:
/* Unconfigure MSI-X capability structure */
-   pci_disable_msix(phba->pcidev);
+   pci_free_irq_vectors(phba->pcidev);
 
 vec_fail_out:
return rc;
@@ -8615,7 +8625,7 @@ lpfc_sli_disable_msix(struct lpfc_hba *phba)
for (i = 0; i < LPFC_MSIX_VECTORS; i++)
free_irq(phba->msix_entries[i].vector, phba);
/* Disable MSI-X */
-   pci_disable_msix(phba->pcidev);
+   pci_free_irq_vectors(phba->pcidev);
 
return;
 }
@@ -8625,10 +8635,10 @@ lpfc_sli_disable_msix(struct lpfc_hba *phba)
  * @phba: pointer to lpfc hba data structure.
  *
  * This routine is invoked to enable the MSI interrupt mode to device with
- * SLI-3 interface spec. The kernel function pci_enable_msi() is called to
- * enable the MSI vector. The device driver is responsible for calling the
- * request_irq() to register MSI vector with a interrupt the handler, which
- * is done in this function.
+ * SLI-3 interface spec. The kernel function pci_alloc_irq_vectors() is
+ * called to enable the MSI vector. The device driver is responsible for
+ * calling the request_irq() to register MSI vector with a interrupt the
+ * handler, which is done in this function.
  *
  * Return codes
  * 0 - successful
@@ -8637,10 +8647,18 @@ lpfc_sli_disable_msix(struct lpfc_hba *phba)
 static int
 lpfc_sli_enable_msi(struct lpfc_hba *phba)
 {
-   int rc;
+   int vector, rc;
+   unsigned int irq_flags;
+
+   /* The adapter supports all these modes and wants the irq affinity.
+* 

Re: [PATCH v2 08/12] qla2xxx: Add framework for Async fabric discovery.

2017-01-17 Thread Bart Van Assche
On Mon, 2017-01-16 at 12:35 -0800, Himanshu Madhani wrote:
> +  /*
> +   * return FC_CTELS_STATUS_OK and leave the decoding of the ELS/CT
> +   * fc payload  to the caller
> +   */
> +
> +  bsg_reply->reply_data.ctels_reply.status = FC_CTELS_STATUS_OK;
> +  bsg_job->reply_len = sizeof(struct fc_bsg_reply);

smatch reports the following for the above code:

drivers/scsi/qla2xxx/qla_isr.c:1456: qla2x00_ct_entry() warn: inconsistent 
indenting

Please use tabs instead of spaces for indentation. That is sufficient to
suppress that warning.

Thanks,

Bart.--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 08/12] qla2xxx: Add framework for Async fabric discovery.

2017-01-17 Thread Madhani, Himanshu


On 1/17/17, 2:27 PM, "Bart Van Assche"  wrote:

>%phC

Yes. It looks like typo in the message. 

Will update this patch with other sparse warnings fixes.

Thanks,
Himanshu
> 


Re: [PATCH v2 08/12] qla2xxx: Add framework for Async fabric discovery.

2017-01-17 Thread Bart Van Assche
On Mon, 2017-01-16 at 12:35 -0800, Himanshu Madhani wrote:
> -   kref_get(>sess_kref);
> +   if (!kref_get_unless_zero(>sess_kref)) {
> +   ql_dbg(ql_dbg_tgt_tmr, vha, 0x,
> +   "%s: kref_get fail %8pHC \n",
> +    __func__, sess->port_name);
> +   sess = NULL;
> +   goto out_term2;
> +   }
> }

As far as I know %pH is not a valid conversion identifier. Was perhaps
%phC intended?.

Bart.--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 08/12] qla2xxx: Add framework for Async fabric discovery.

2017-01-17 Thread Bart Van Assche
On Mon, 2017-01-16 at 12:35 -0800, Himanshu Madhani wrote:
>  /*
>   * Adds an extra ref to allow to drop hw lock after adding sess to the list.
>   * Caller must put it.
> @@ -839,93 +1103,65 @@ static struct fc_port *qlt_create_sess(
>   bool local)
>  {
>   struct qla_hw_data *ha = vha->hw;
> - struct fc_port *sess;
> + struct fc_port *sess = fcport;
>   unsigned long flags;
>  
> - /* Check to avoid double sessions */
> - spin_lock_irqsave(>tgt.sess_lock, flags);
> - list_for_each_entry(sess, >vp_fcports, list) {
> - if (!memcmp(sess->port_name, fcport->port_name, WWN_SIZE)) {
> - ql_dbg(ql_dbg_tgt_mgt, vha, 0xf005,
> - "Double sess %p found (s_id %x:%x:%x, "
> - "loop_id %d), updating to d_id %x:%x:%x, "
> - "loop_id %d", sess, sess->d_id.b.domain,
> - sess->d_id.b.al_pa, sess->d_id.b.area,
> - sess->loop_id, fcport->d_id.b.domain,
> - fcport->d_id.b.al_pa, fcport->d_id.b.area,
> - fcport->loop_id);
> -
> - /* Cannot undelete at this point */
> - if (sess->deleted == QLA_SESS_DELETION_IN_PROGRESS) {
> - spin_unlock_irqrestore(>tgt.sess_lock,
> - flags);
> - return NULL;
> - }
> -
> - if (sess->deleted)
> - qlt_undelete_sess(sess);
> -
> - if (!sess->se_sess) {
> - if 
> (ha->tgt.tgt_ops->check_initiator_node_acl(vha,
> - >port_name[0], sess) < 0) {
> - 
> spin_unlock_irqrestore(>tgt.sess_lock, flags);
> - return NULL;
> - }
> - }
> -
> - kref_get(>sess_kref);
> - ha->tgt.tgt_ops->update_sess(sess, fcport->d_id, 
> fcport->loop_id,
> - (fcport->flags & 
> FCF_CONF_COMP_SUPPORTED));
> -
> - if (sess->local && !local)
> - sess->local = 0;
> -
> - qlt_do_generation_tick(vha, >generation);
> -
> - spin_unlock_irqrestore(>tgt.sess_lock, flags);
> + if (vha->vha_tgt.qla_tgt && vha->vha_tgt.qla_tgt->tgt_stop)
> + return NULL;
>  
> - return sess;
> + if (fcport->se_sess) {
> + if (!kref_get_unless_zero(>sess_kref)) {
> + ql_dbg(ql_dbg_disc, vha, 0x,
> + "%s: kref_get_unless_zero failed for %8phC\n",
> + __func__, sess->port_name);
> + return NULL;
>   }
> - }
> - spin_unlock_irqrestore(>tgt.sess_lock, flags);
> -
> - sess = kzalloc(sizeof(*sess), GFP_KERNEL);
> - if (!sess) {
> - ql_dbg(ql_dbg_tgt_mgt, vha, 0xf04a,
> - "qla_target(%u): session allocation failed, all commands "
> - "from port %8phC will be refused", vha->vp_idx,
> - fcport->port_name);
> -
> - return NULL;
> + return fcport;
>   }
>   sess->tgt = vha->vha_tgt.qla_tgt;
> - sess->vha = vha;
> - sess->d_id = fcport->d_id;
> - sess->loop_id = fcport->loop_id;
>   sess->local = local;
> - kref_init(>sess_kref);
> - INIT_LIST_HEAD(>del_list_entry);
>  
> - /* Under normal circumstances we want to logout from firmware when
> + /*
> +  * Under normal circumstances we want to logout from firmware when
>* session eventually ends and release corresponding nport handle.
>* In the exception cases (e.g. when new PLOGI is waiting) corresponding
> -  * code will adjust these flags as necessary. */
> +  * code will adjust these flags as necessary.
> +  */
>   sess->logout_on_delete = 1;
>   sess->keep_nport_handle = 0;
> + sess->logout_completed = 0;
>  
> - ql_dbg(ql_dbg_tgt_mgt, vha, 0xf006,
> - "Adding sess %p to tgt %p via ->check_initiator_node_acl()\n",
> - sess, vha->vha_tgt.qla_tgt);
> + if (ha->tgt.tgt_ops->check_initiator_node_acl(vha,
> + >port_name[0], sess) < 0) {
> + ql_dbg(ql_dbg_tgt_mgt, vha, 0x,
> + "(%d) %8phC check_initiator_node_acl failed\n",
> + vha->vp_idx, fcport->port_name);
> + return NULL;
> + } else {
> + kref_init(>sess_kref);
> + /*
> +  * Take an extra reference to ->sess_kref here to handle
> +  * fc_port access across ->tgt.sess_lock reaquire.
> +  */
> + if (!kref_get_unless_zero(>sess_kref)) {
> + ql_dbg(ql_dbg_disc, vha, 

Re: [PATCH v2 08/12] qla2xxx: Add framework for Async fabric discovery.

2017-01-17 Thread Bart Van Assche
On Mon, 2017-01-16 at 12:35 -0800, Himanshu Madhani wrote:
> -static void
> +void
>  qla2x00_async_iocb_timeout(void *data)
>  {
>   srb_t *sp = (srb_t *)data;
>   fc_port_t *fcport = sp->fcport;
> + struct srb_iocb *lio = >u.iocb_cmd;
> + struct event_arg ea;
>  
>   ql_dbg(ql_dbg_disc, fcport->vha, 0x2071,
> - "Async-%s timeout - hdl=%x portid=%02x%02x%02x.\n",
> + "Async-%s timeout - hdl=%x portid=%02x%02x%02x %8phC.\n",
>   sp->name, sp->handle, fcport->d_id.b.domain, fcport->d_id.b.area,
> - fcport->d_id.b.al_pa);
> + fcport->d_id.b.al_pa, fcport->port_name);
>  
> - fcport->flags &= ~FCF_ASYNC_SENT;
> - if (sp->type == SRB_LOGIN_CMD) {
> - struct srb_iocb *lio = >u.iocb_cmd;
> - qla2x00_post_async_logout_work(fcport->vha, fcport, NULL);
> + if (fcport)
> + fcport->flags &= ~FCF_ASYNC_SENT;

This code triggers a new static checker warning because the fcport pointer
is dereferenced before it is used. Please review the code.

Thanks,

Bart.--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] scsi: mpt3sas: fix hang on ata passthru commands

2017-01-17 Thread Martin K. Petersen
> "Christoph" == Christoph Hellwig  writes:

Christoph> On Tue, Jan 17, 2017 at 07:43:51PM +0530, Sreekanth Reddy wrote:
>> [Sreekanth] Just for readability purpose, can use use "if
>> (test_bit(0, _device_priv_data->ata_command_pending)" instead of
>> "if (sas_device_priv_data->ata_command_pending)".  Since while
>> setting & clearing the bit we are using atomic bit operations. I
>> don't see any issue functionality wise.

Christoph> I agree.  Also while we're into nitpicking - it would be good
Christoph> to give bit 0 of the bitmap a name instead of hardcoding the
Christoph> 0.

I tweaked the test case. We can name the bit later if more flags are
needed (and in that case the ata_command_pending would need to get
renamed too).

In any case. This issue has taken waaay too long to get resolved so the
patch is now queued up in 4.10/scsi-fixes.

Thanks everyone!

-- 
Martin K. Petersen  Oracle Linux Engineering
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Bug 151631] "Synchronizing SCSI cache" fails during(and delays) reboot/shutdown

2017-01-17 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=151631

--- Comment #10 from Vyacheslav Dikonov  ---
One further observation. The drive was attached to an USB2 controller 

00:1d.0 USB controller: Intel Corporation 82801DB/DBL/DBM (ICH4/ICH4-L/ICH4-M)
USB UHCI Controller

through an USB hub, which has  both USB2 and USB3 ports. The bug occurs when I
try to reattach the hdd to the same type of ports. The HDD works when I change
the type of ports (USB2 > USB3 or USB3 > USB2). It happens again if I do not
change the type of connection. It might be a different USB-related problem, but
the error message is the same "Synchronize Cache(10) failed"

-- 
You are receiving this mail because:
You are the assignee for the bug.
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3 00/10] qla2xxx: Bug fixes for driver.

2017-01-17 Thread Bart Van Assche
On 12/23/2016 06:06 PM, Himanshu Madhani wrote:
> Hi Bart,
> 
> Here's updated series of bug fixes for target code in the driver.
> Please consider this for target-pending.

Hello Himanshu,

Thanks for the patches. I have queued these patches for v4.10-rc5. But
since the qla2xxx driver code triggers several static checker warnings,
I would appreciate if you could have a look at the four patches I just
posted to address these warnings.

Bart.
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] lpfc: fix lpfc_wwn_set return code check

2017-01-17 Thread James Smart

When I reversed the patch to re-add the lpfc_soft_wwn parameter feature,
it re-added code that had a long-standing bug. (that's what I
get I guess :)

As Dan Carpenter pointed out - error checks looked at wrong polarity.
0 is success, -errno is failure. Updated checks.

-- james

Signed-off-by: James Smart 
Reported-by: Dan Carpenter 
---
 drivers/scsi/lpfc/lpfc_attr.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c
index 6c104d7..50cf402 100644
--- a/drivers/scsi/lpfc/lpfc_attr.c
+++ b/drivers/scsi/lpfc/lpfc_attr.c
@@ -2150,7 +2150,7 @@ lpfc_soft_wwpn_store(struct device *dev, struct 
device_attribute *attr,
phba->soft_wwn_enable = 0;
 
rc = lpfc_wwn_set(buf, cnt, wwpn);
-   if (!rc) {
+   if (rc) {
/* not able to set wwpn, unlock it */
phba->soft_wwn_enable = 1;
return rc;
@@ -2231,7 +2231,7 @@ lpfc_soft_wwnn_store(struct device *dev, struct 
device_attribute *attr,
return -EINVAL;
 
rc = lpfc_wwn_set(buf, cnt, wwnn);
-   if (!rc) {
+   if (rc) {
/* Allow wwnn to be set many times, as long as the enable
 * is set. However, once the wwpn is set, everything locks.
 */
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] scsi: lpfc: Replace BUG() with BUG_ON()

2017-01-17 Thread James Smart

Good by me.

-- james

Signed-off-by: James Smart 


On 12/24/2016 2:51 AM, Shyam Saini wrote:

Replace BUG() with BUG_ON() using coccinelle

Signed-off-by: Shyam Saini 
---
  drivers/scsi/lpfc/lpfc_els.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c
index 27f0cbb..ede14f1 100644
--- a/drivers/scsi/lpfc/lpfc_els.c
+++ b/drivers/scsi/lpfc/lpfc_els.c
@@ -8855,8 +8855,7 @@ lpfc_cmpl_fabric_iocb(struct lpfc_hba *phba, struct 
lpfc_iocbq *cmdiocb,
  {
struct ls_rjt stat;
  
-	if ((cmdiocb->iocb_flag & LPFC_IO_FABRIC) != LPFC_IO_FABRIC)

-   BUG();
+   BUG_ON((cmdiocb->iocb_flag & LPFC_IO_FABRIC) != LPFC_IO_FABRIC);
  
  	switch (rspiocb->iocb.ulpStatus) {

case IOSTAT_NPORT_RJT:


--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Bug 151631] "Synchronizing SCSI cache" fails during(and delays) reboot/shutdown

2017-01-17 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=151631

Vyacheslav Dikonov  changed:

   What|Removed |Added

 CC||sdico...@mail.ru

--- Comment #9 from Vyacheslav Dikonov  ---
I am experiencing the Synchronize Cache problem with both 4.4.43 and 4.8.17.
My dmesg yields:

[  428.593067] sd 5:0:0:0: [sdd] Synchronizing SCSI cache
[  428.716643] sd 5:0:0:0: [sdd] Synchronize Cache(10) failed: Result:
hostbyte=DID_ERROR driverbyte=DRIVER_OK

When I try to attach an external USB3 drive (over an USB2 interface). It work
well for the first time, but later, after I unmount and disconnect it, any
subsequent attempt to attacj the same hdd results in this bug. The disk cannot
be mounted for the second time. Fs is reiserfs. It happens with kernel 4.4.43
too,

-- 
You are receiving this mail because:
You are the assignee for the bug.
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/4] nvme: use blk_rq_payload_bytes

2017-01-17 Thread Sagi Grimberg



@@ -1014,9 +1013,9 @@ static int nvme_rdma_map_data(struct nvme_rdma_queue 
*queue,
}



Christoph, a little above here we still look at blk_rq_bytes(),
shouldn't that look at blk_rq_payload_bytes() too?


if (count == 1) {
-   if (rq_data_dir(rq) == WRITE &&
-   map_len <= nvme_rdma_inline_data_size(queue) &&
-   nvme_rdma_queue_idx(queue))
+   if (rq_data_dir(rq) == WRITE && nvme_rdma_queue_idx(queue) &&
+   blk_rq_payload_bytes(rq) <=
+   nvme_rdma_inline_data_size(queue))
return nvme_rdma_map_sg_inline(queue, req, c);

if (dev->pd->flags & IB_PD_UNSAFE_GLOBAL_RKEY)

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH V2] mpt3sas: disable ASPM for MPI2 controllers

2017-01-17 Thread ojab

On 2017/01/17 14:15, Sreekanth Reddy wrote:

On Tue, Jan 17, 2017 at 4:13 AM, ojab  wrote:

On 2017/01/16 14:03, ojab wrote:


On 2017/01/16 13:31, Sreekanth Reddy wrote:


On Mon, Jan 16, 2017 at 6:15 PM, ojab  wrote:


On 2017/01/16 12:36, Sreekanth Reddy wrote:



Ojab,

I am checking internally with our FW team and Architect to known
whether they aware/observed any issues similar to this (since this
issue is nothing to do with driver).

Meanwhile is it possible to provide us the PCI config space and FW
logs when issue occurs?




AFAIU FW log is enabled when `logging_level=0x3f8` is passed to the
module,
right?



This is a driver logging_level. Firmware logs can be collected using
UART logs.



According to the user guide (from

https://www.broadcom.com/products/storage/host-bus-adapters/sas-9217-8i#documentation)
my 9217-8i requires 1.8V UART which I don't have at hand, I'll try to do
something on the weekend.
Is anything needed except connecting UART to gather required info?


…actually I have compatible USB UART here. What should be done to get FW
log? I've tried to reboot with UART connected (9600N1) but got no output.


You have to use, 115200 instead of 9600 baud rate.

No output using 115200 8N1 either.
If I connect Bus Pirate to the pins and enable baud autodetect, I see 
something like

>Calculated: 117647 bps
>Estimated:  115200 bps
on reboot and firmware/bios upgrade, but there is no text at all.
Right now I have IT firmware installed, `sas2flash -list` shows
>Adapter Selected is a LSI SAS: SAS2308_2(D1)
>
>Controller Number  : 0
>Controller : SAS2308_2(D1)
>PCI Address: 00:02:00:00
>SAS Address: 500605b-0-05a6-c320
>NVDATA Version (Default)   : 14.01.00.06
>NVDATA Version (Persistent): 14.01.00.06
>Firmware Product ID: 0x2214 (IT)
>Firmware Version   : 20.00.07.00
>NVDATA Vendor  : LSI
>NVDATA Product ID  : SAS9207-8i
>BIOS Version   : 07.39.02.00
>UEFI BSD Version   : 07.27.01.01
>FCODE Version  : N/A
>Board Name : SAS9207-8i
>Board Assembly : N/A
>Board Tracer Number: N/A

//wbr ojab



Thanks,
Sreekanth



//wbr ojab




Anyway, right now various MPI2 HBAs doesn't work with ASPM enabled, so
can this patch be applied in the meantime while we're debugging the
issue further? Even if this issue can be properly fixed by FW update,
this workaround will be needed for HBAs with affected FW versions.

//wbr ojab





Where can I find info about PCI config space?



You can get PCI config space info from lspci command.



//wbr ojab




Thanks,
Sreekanth

On Mon, Jan 16, 2017 at 5:37 PM, ojab  wrote:



On 2017/01/06 15:48, Sreekanth Reddy wrote:




On Fri, Jan 6, 2017 at 7:24 AM, Martin K. Petersen
 wrote:

Matin, We need some time to review this patch. I will provide my
review comments by end of next week.


ping?

//wbr ojab




Thanks,
Sreekanth






--
To unsubscribe from this list: send the line "unsubscribe
linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html




--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html



--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html




--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html




--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [bug report] scsi: lpfc: Reinstate lpfc_soft_wwn parameter

2017-01-17 Thread Martin K. Petersen
> "Dan" == Dan Carpenter  writes:

Dan> The patch 352e5fd10598: "scsi: lpfc: Reinstate lpfc_soft_wwn
Dan> parameter" from Dec 30, 2016, leads to the following static checker
Dan> warning:

Dan>drivers/scsi/lpfc/lpfc_attr.c:2156 lpfc_soft_wwpn_store() info:
Dan> return a literal instead of 'rc'

James?

-- 
Martin K. Petersen  Oracle Linux Engineering
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 0/2] sd fixes for zoned block devices

2017-01-17 Thread Martin K. Petersen
> "Damien" == Damien Le Moal  writes:

Damien> 2 small fixes in this series: (1) Fix sd_read_cache_type so that
Damien> DPOFUA is not disabled for zoned block devices supporting it.
Damien> (2) Ignore the zoned field of the block device characteristics
Damien> page for host-managed zoned block devices as there is no good
Damien> match defined explicitely for HM by the standard.

Damien> Damien Le Moal (2): sd: Fix wrong DPOFUA disable in
Damien> sd_read_cache_type sd: Ignore zoned field for host-managed
Damien> devices

Applied to 4.10/scsi-fixes.

-- 
Martin K. Petersen  Oracle Linux Engineering
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] bfa: fix wrongly initialized variable in bfad_im_bsg_els_ct_request()

2017-01-17 Thread Martin K. Petersen
> "Johannes" == Johannes Thumshirn  writes:

Johannes> Commit 01e0e15c8b3b ("scsi: don't use fc_bsg_job::request and
Johannes> fc_bsg_job::reply directly") introduced a typo, which causes
Johannes> that the bsg_request variable in bfad_im_bsg_els_ct_request()
Johannes> is initialized to itself instead of pointing to the bsg job's
Johannes> request.

Applied to 4.10/scsi-fixes.

-- 
Martin K. Petersen  Oracle Linux Engineering
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] Set elsiocb contexts to NULL after freeing it

2017-01-17 Thread Martin K. Petersen
> "Johannes" == Johannes Thumshirn  writes:

Johannes> Dick, James, any comments? I'd really like to get this in soon
Johannes> as it solves customer issues.

Ping?

-- 
Martin K. Petersen  Oracle Linux Engineering
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] ses: Fix SAS device detection in enclosure

2017-01-17 Thread Martin K. Petersen
> "Ewan" == Ewan D Milne  writes:

Ewan> The call to scsi_is_sas_rphy() needs to be made on the SAS
Ewan> end_device, not on the SCSI device.

Applied to 4.10/scsi-fixes.

-- 
Martin K. Petersen  Oracle Linux Engineering
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: aacraid: kernel: AAC: Host adapter dead -1 (bisected)

2017-01-17 Thread Dave Carroll
> 
> 
> Hi.
> 
> There is a bug with handling of adaptec raid cards (in my case it is Adaptec
> 3405) where kernel logs hundreds of "AAC: Host adapter dead -1"
> messages.
> 
> Bug was reported previously on lkml but there was no progres in solving it.
> 
> There is also bugzilla entry:
> https://bugzilla.kernel.org/show_bug.cgi?id=151661
> 
> I've bisected that to commit bellow and indeed, reverting it from kernel
> 4.9.3 makes messages go away.
> 
> Could anyone at microsemi look at this regression?
> 
> Thanks

Hi Arkadiusz,

Thanks for your effort in determining the cause of the issue. It makes sense 
now that the patch should have been included in controller specific code, 
rather than common code.

I will prepare a patch for this, and if you are willing to test it, that would 
be great!

Thanks, -Dave

> 
> commit 78cbccd3bd683c295a44af8050797dc4a41376ff
> Author: Raghava Aditya Renukunta
> 
> Date:   Mon Apr 25 23:32:37 2016 -0700
> 
> aacraid: Fix for KDUMP driver hang
> 
> When KDUMP is triggered the driver first talks to the firmware in INTX
> mode, but the adapter firmware is still in MSIX mode. Therefore the
> first
> driver command hangs since the driver is waiting for an INTX response
> and
> firmware gives a MSIX response. If when the OS is installed on a RAID
> drive created by the adapter KDUMP will hang since the driver does not
> receive a response in sync mode.
> 
> Fixed by: Change the firmware to INTX mode if it is in MSIX mode before
> sending the first sync command.
> 
> Cc: sta...@vger.kernel.org
> Signed-off-by: Raghava Aditya Renukunta
> 
> Reviewed-by: Johannes Thumshirn 
> Signed-off-by: Martin K. Petersen 
> 
> my hardware:
> 02:0e.0 RAID bus controller [0104]: Adaptec AAC-RAID [9005:0285]
> Subsystem: Adaptec 3405 [9005:02bb]
> Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop-
> ParErr-
> Stepping+ SERR+ FastB2B- DisINTx-
> Status: Cap+ 66MHz+ UDF- FastB2B- ParErr- DEVSEL=medium >TAbort-
> SERR-  Latency: 32 (250ns min, 250ns max), Cache Line Size: 4 bytes
> Interrupt: pin A routed to IRQ 18
> Region 0: Memory at fba0 (64-bit, non-prefetchable) [size=2M]
> [virtual] Expansion ROM at fbc0 [disabled] [size=256K]
> Capabilities: [c0] Power Management version 2
> Flags: PMEClk- DSI- D1+ D2- AuxCurrent=0mA
> PME(D0-,D1-,D2-,D3hot-,D3cold-)
> Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=0 PME-
> Capabilities: [d0] MSI: Enable- Count=1/2 Maskable- 64bit+
> Address:   Data: 
> Capabilities: [e0] PCI-X non-bridge device
> Command: DPERE- ERO- RBC=512 OST=4
> Status: Dev=02:0e.0 64bit+ 133MHz+ SCD- USC- DC=bridge
> DMMRBC=1024 DMOST=4 DMCRS=16 RSCEM- 266MHz- 533MHz-
> Kernel driver in use: aacraid
> Kernel modules: aacraid
> 
> [1.956009] Adaptec aacraid driver 1.2-1[41066]-ms
> [2.164584] AAC0: kernel 5.2-0[17342] Aug  4 2010
> [2.164633] AAC0: monitor 5.2-0[17342]
> [2.164676] AAC0: bios 5.2-0[17342]
> [2.164719] AAC0: serial 7C46114103A
> [2.164761] AAC0: Non-DASD support enabled.
> [2.164804] AAC0: 64bit support enabled.
> [2.164846] AAC0: 64 Bit DAC enabled
> [2.177929] scsi host6: aacraid
> 
> 
> --
> Arkadiusz Miśkiewicz, arekm / ( maven.pl | pld-linux.org )


Re: [PATCH 08/22] qla2xxx: Refactore target code to remove symbol dependency

2017-01-17 Thread Dr. Greg Wettstein
On Dec 16, 12:17am, Christoph Hellwig wrote:
} Subject: Re: [PATCH 08/22] qla2xxx: Refactore target code to remove symbol

Good morning, I hope the week is going well for everyone.

Really late to this thread but am just getting caught d up after the
holidays and putting out fires.

> On Thu, Dec 15, 2016 at 08:50:39PM +, Tran, Quinn wrote:
>
> > Christoph, Qlogic was asked to support other Target Stack (SC ST)
> > using the same qla2xxx.ko upstream driver.  I had mentioned this
> > during the last 2015 LSF get together.  Hopefully, that gives a
> > better context.  The understanding that came away was Qlogic do
> > what is needed to provide this support without creating any dead
> > code.

> Right.  And what you're doing here is to create tons of pointless
> and dead code.  If you can support something else without clearly
> making the in-kernel version worse it's all fine.  This patch on the
> other hand is complete crap and totally unacceptable in this form.

It would be helpful to get an architectural overview of how Qlogic is
proposing to interface SCST to the in-kernel Qlogic target driver
code.  Are you going to follow a model of having an analogue of
tcm_qla2xxx for SCST?

We've been running for 3-4 years on the SCST target interface driver
we wrote to allow us to use the in-kernel Qlogic target driver code
with SCST.  We used the model of implementing the interface in
something we referred to as the scst_qla2xxx module and the model
seems solid.  There was a bit of an impedance mismatch but the changes
to the core kernel code were negligible.

Our code is being scheduled for an upgrade to 4.4 and to chase down
what have been reports about issues on 4 GBPS Qlogic cards.  Any
notion of a timeframe on the Cavium/Qlogic based solution?

Have a good day.

Dr. Greg

}-- End of excerpt from Christoph Hellwig

As always,
Dr. G.W. Wettstein, Ph.D.   Enjellic Systems Development, LLC.
4206 N. 19th Ave.   Specializing in information infra-structure
Fargo, ND  58102development.
PH: 701-281-1686
FAX: 701-281-3949   EMAIL: g...@enjellic.com
--
"Try to remove the color-problem by restarting your computer several
 times."
-- Microsoft-Internet Explorer
   README.TXT
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3 00/10] qla2xxx: Bug fixes for driver.

2017-01-17 Thread Bart Van Assche
On Fri, 2016-12-23 at 18:06 -0800, Himanshu Madhani wrote:
> Here's updated series of bug fixes for target code in the driver.
> Please consider this for target-pending.

Hello Himanshu,

Thanks for the patches. I have queued these patches for v4.10-rc5. But since
the qla2xxx driver code triggers several static checker warnings, I would
appreciate if you could have a look at the four patches I just posted to
address these warnings.

Bart.--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: aacraid: kernel: AAC: Host adapter dead -1 (bisected)

2017-01-17 Thread Arkadiusz Miskiewicz
On Tuesday 17 of January 2017, Dave Carroll wrote:
> > Hi.
> > 
> > There is a bug with handling of adaptec raid cards (in my case it is
> > Adaptec 3405) where kernel logs hundreds of "AAC: Host adapter dead -1"
> > messages.
> > 
> > Bug was reported previously on lkml but there was no progres in solving
> > it.
> > 
> > There is also bugzilla entry:
> > https://bugzilla.kernel.org/show_bug.cgi?id=151661
> > 
> > I've bisected that to commit bellow and indeed, reverting it from kernel
> > 4.9.3 makes messages go away.
> > 
> > Could anyone at microsemi look at this regression?
> > 
> > Thanks
> 
> Hi Arkadiusz,
> 
> Thanks for your effort in determining the cause of the issue. It makes
> sense now that the patch should have been included in controller specific
> code, rather than common code.
> 
> I will prepare a patch for this, and if you are willing to test it, that
> would be great!

Great!

I have dedicated machine for testing this, so yes - I'll test.

-- 
Arkadiusz Miśkiewicz, arekm / ( maven.pl | pld-linux.org )
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 00/12] qla2xxx: Feature updates for target.

2017-01-17 Thread Madhani, Himanshu
Hi Bart, 




On 1/17/17, 8:56 AM, "Bart Van Assche"  wrote:

>On Mon, 2017-01-16 at 12:35 -0800, Himanshu Madhani wrote:
>> Please consider this updated series for inclusion in target-pending.
>
>Hello Himanshu,
>
>What kernel have these patches been generated against? These patches
>neither apply cleanly on top of kernel v4.10-rc1 nor on top of kernel
>v4.10-rc4.

These were tested on top of 4.10-rc3 + target Bug fixes series that is pending 
to be included.
 


Here’s link for the target bug fixes series. 

http://www.spinics.net/lists/target-devel/msg13801.html

>
>Bart.


Re: [PATCH v2 00/12] qla2xxx: Feature updates for target.

2017-01-17 Thread Bart Van Assche
On Mon, 2017-01-16 at 12:35 -0800, Himanshu Madhani wrote:
> Please consider this updated series for inclusion in target-pending.

Hello Himanshu,

What kernel have these patches been generated against? These patches
neither apply cleanly on top of kernel v4.10-rc1 nor on top of kernel
v4.10-rc4.

Bart.--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [LSF/MM TOPIC][LSF/MM ATTEND] NAPI polling for block drivers

2017-01-17 Thread Sagi Grimberg



So it looks like we are super not efficient because most of the
times we catch 1
completion per interrupt and the whole point is that we need to find
more! This fio
is single threaded with QD=32 so I'd expect that we be somewhere in
8-31 almost all
the time... I also tried QD=1024, histogram is still the same.


It looks like it takes you longer to submit an I/O than to service an
interrupt,


Well, with irq-poll we do practically nothing in the interrupt handler,
only schedule irq-poll. Note that the latency measures are only from
the point the interrupt arrives and the point we actually service it
by polling for completions.


so increasing queue depth in the singe-threaded case doesn't
make much difference. You might want to try multiple threads per core
with QD, say, 32


This is how I ran, QD=32.
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [LSF/MM TOPIC][LSF/MM ATTEND] NAPI polling for block drivers

2017-01-17 Thread Johannes Thumshirn
On Tue, Jan 17, 2017 at 06:15:43PM +0200, Sagi Grimberg wrote:
> Oh, and the current code that was tested can be found at:
> 
> git://git.infradead.org/nvme.git nvme-irqpoll

Just for the record, all tests you've run are with the upper irq_poll_budget of
256 [1]?

We (Hannes and me) recently stumbed accross this when trying to poll for more
than 256 queue entries in the drivers we've been testing.

Did your system load reduce with irq polling? In theory it should but I have
seen increases with AHCI at least according to fio. IIRC Hannes saw decreases
with his SAS HBA tests, as expected.

[1] lib/irq_poll.c:13

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
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [LSF/MM TOPIC][LSF/MM ATTEND] NAPI polling for block drivers

2017-01-17 Thread Sagi Grimberg



Just for the record, all tests you've run are with the upper irq_poll_budget of
256 [1]?


Yes, but that's the point, I never ever reach this budget because
I'm only processing 1-2 completions per interrupt.


We (Hannes and me) recently stumbed accross this when trying to poll for more
than 256 queue entries in the drivers we've been testing.


What do you mean by stumbed? irq-poll should be agnostic to the fact
that drivers can poll more than their given budget?


Did your system load reduce with irq polling? In theory it should but I have
seen increases with AHCI at least according to fio. IIRC Hannes saw decreases
with his SAS HBA tests, as expected.


I didn't see any reduction. When I tested on a single cpu core (to
simplify for a single queue) the cpu was at 100% cpu but got less iops
(which makes sense, a single cpu-core is not enough to max out the nvme
device, at least not the core I'm using). Before irqpoll I got
~230 KIOPs on a single cpu-core and after irqpoll I got ~205 KIOPs
which is consistent with the ~10% iops decrease I've reported in the
original submission.
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [LSF/MM TOPIC][LSF/MM ATTEND] NAPI polling for block drivers

2017-01-17 Thread Sagi Grimberg

Oh, and the current code that was tested can be found at:

git://git.infradead.org/nvme.git nvme-irqpoll
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/2] virtio_scsi: Implement fc_host

2017-01-17 Thread Michael S. Tsirkin
On Tue, Jan 17, 2017 at 10:05:00PM +0800, Fam Zheng wrote:
> On Tue, 01/17 14:17, Paolo Bonzini wrote:
> > 
> > 
> > On 16/01/2017 18:26, Fam Zheng wrote:
> > >> Is the endianness correct for big-endian host here?
> > >
> > > I think so. The fc_host sysfs uses u64 to represent port_name and 
> > > node_name,
> > > this patch does the same, so using virtio_* helpers for these fields 
> > > should
> > > handle the endianness correctly.
> > 
> > I was suspicious about it because they are defined as "u8 x[8]" in the
> > virtio_scsi_config struct.  So you would need to read with
> > virtio_cread_bytes and pass the result to wwn_to_u64.
> > 
> > For example, if you have 0x500123456789abcd this would be
> > 
> > 0x50 0x01 0x23 0x45 0x67 0x89 0xab 0cd
> > 
> > in virtio_scsi_config, and then virtio_cread64 would read it as a
> > little-endian u64, 0xcdab896745230150.  Maybe your QEMU patch is also
> > writing things as little-endian 64-bit integers, rather than 8-element
> > arrays of bytes?
> 
> Yes, they all used 64-bit integers in a "less surprising" endian. I think 
> there
> is an endianness conecpt to WWN, as in 0x500123456789abcd; and there is an
> native endianness to virtio, which is little-endian. If we use a "u8 x[8]" 
> type
> in the spec and want the WWN's MSB, namely the 0x50 stuff, to be the first 
> byte,
> is it worth to explicitly document that to avoid confusion?
> 
> Fam

Can't hurt, for sure.

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [LSF/MM TOPIC][LSF/MM ATTEND] NAPI polling for block drivers

2017-01-17 Thread Sagi Grimberg

Hey, so I made some initial analysis of whats going on with
irq-poll.

First, I sampled how much time it takes before we
get the interrupt in nvme_irq and the initial visit
to nvme_irqpoll_handler. I ran a single threaded fio
with QD=32 of 4K reads. This is two displays of a
histogram of the latency (ns):
--
[1]
queue = b'nvme0q1'
 usecs   : count distribution
 0 -> 1  : 7310 
||
 2 -> 3  : 11   | 
 |
 4 -> 7  : 10   | 
 |
 8 -> 15 : 20   | 
 |
16 -> 31 : 0| 
 |
32 -> 63 : 0| 
 |
64 -> 127: 1| 
 |


[2]
queue = b'nvme0q1'
 usecs   : count distribution
 0 -> 1  : 7309 
||
 2 -> 3  : 14   | 
 |
 4 -> 7  : 7| 
 |
 8 -> 15 : 17   | 
 |


We can see that most of the time our latency is pretty good (<1ns) but with
huge tail latencies (some 8-15 ns and even one in 32-63 ns).
**NOTE, in order to reduce the tracing impact on performance I sampled
for every 100 interrupts.

I also sampled for a multiple threads/queues with QD=32 of 4K reads.
This is a collection of histograms for 5 queues (5 fio threads):
queue = b'nvme0q1'
 usecs   : count distribution
 0 -> 1  : 701 
||
 2 -> 3  : 177  |** 
 |
 4 -> 7  : 56   |*** 
 |
 8 -> 15 : 24   |* 
 |
16 -> 31 : 6| 
 |
32 -> 63 : 1| 
 |


queue = b'nvme0q2'
 usecs   : count distribution
 0 -> 1  : 412 
||
 2 -> 3  : 52   |* 
 |
 4 -> 7  : 19   |* 
 |
 8 -> 15 : 13   |* 
 |
16 -> 31 : 5| 
 |


queue = b'nvme0q3'
 usecs   : count distribution
 0 -> 1  : 381 
||
 2 -> 3  : 74   |*** 
 |
 4 -> 7  : 26   |** 
 |
 8 -> 15 : 12   |* 
 |
16 -> 31 : 3| 
 |
32 -> 63 : 0| 
 |
64 -> 127: 0| 
 |
   128 -> 255: 1| 
 |


queue = b'nvme0q4'
 usecs   : count distribution
 0 -> 1  : 386 
||
 2 -> 3  : 63   |** 
 |
 4 -> 7  : 30   |*** 
 |
 8 -> 15 : 11   |* 
 |
16 -> 31 : 7| 
 |
32 -> 63 : 1| 
 |


queue = b'nvme0q5'
 usecs   : count distribution
 0 -> 1  : 384 
||
 2 -> 3  : 69   |*** 
 |
 4 -> 7  : 25   |** 
 |
 8 -> 15 : 15   |* 
 |
16 -> 31 : 3| 
 |


Overall looks pretty much the same but some more samples with tails...

Next, I sampled how many completions we are able to consume per interrupt.
Two exaples of histograms of how many completions we take per interrupt.
--
queue = b'nvme0q1'
 completed : count distribution
0  : 0||
1  : 11690||
2  : 46   ||
3  : 1||

queue = b'nvme0q1'
 completed : count distribution
0  : 0||
1  : 944  ||
2  : 8||
--

So it looks like we are super not efficient because most of the times we 
catch 1
completion per interrupt and the whole point is that we need to find 
more! This fio
is single threaded with QD=32 so I'd expect that we be somewhere in 8-31 
almost all

the time... I also tried QD=1024, histogram is still the same.
**NOTE: Here I also sampled for every 100 interrupts.


I'll try to run the counter on the current nvme driver and see what I get.



I attached the bpf scripts I wrote (nvme-trace-irq, nvme-count-comps)
with hope that someone is interested enough to try and reproduce these
numbers on his/hers setup and maybe suggest some other useful tracing
we can do.

Prerequisites:
1. iovisor is needed for python bpf support.
  $ echo "deb [trusted=yes] https://repo.iovisor.org/apt/xenial 

Re: [LSF/MM TOPIC][LSF/MM ATTEND] NAPI polling for block drivers

2017-01-17 Thread Sagi Grimberg



--
[1]
queue = b'nvme0q1'
 usecs   : count distribution
 0 -> 1  : 7310 ||
 2 -> 3  : 11   |  |
 4 -> 7  : 10   |  |
 8 -> 15 : 20   |  |
16 -> 31 : 0|  |
32 -> 63 : 0|  |
64 -> 127: 1|  |

[2]
queue = b'nvme0q1'
 usecs   : count distribution
 0 -> 1  : 7309 ||
 2 -> 3  : 14   |  |
 4 -> 7  : 7|  |
 8 -> 15 : 17   |  |



Rrr, email made the histograms look funky (tabs vs. spaces...)
The count is what's important anyways...

Just adding that I used an Intel P3500 nvme device.


We can see that most of the time our latency is pretty good (<1ns) but with
huge tail latencies (some 8-15 ns and even one in 32-63 ns).


Obviously is micro-seconds and not nano-seconds (I wish...)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2] ata: xgene: Enable NCQ support for APM X-Gene SATA controller hardware v1.1

2017-01-17 Thread Rameshwar Sahu
Hi Tejun,

On Fri, Nov 18, 2016 at 3:15 PM, Rameshwar Prasad Sahu  wrote:
> This patch enables NCQ support for APM X-Gene SATA controller hardware v1.1
> that was broken with hardware v1.0. Second thing, here we should not assume
> XGENE_AHCI_V2 always in case of having valid _CID in ACPI table. I need to
> remove this assumption because V1_1 also has a valid _CID for backward
> compatibly with v1.
>
> v2 changes:
> 1. Changed patch description
>
> Signed-off-by: Rameshwar Prasad Sahu 
> ---
>  drivers/ata/ahci_xgene.c |   14 --
>  1 files changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/ata/ahci_xgene.c b/drivers/ata/ahci_xgene.c
> index 73b19b2..8b88be9 100644
> --- a/drivers/ata/ahci_xgene.c
> +++ b/drivers/ata/ahci_xgene.c
> @@ -87,6 +87,7 @@
>
>  enum xgene_ahci_version {
> XGENE_AHCI_V1 = 1,
> +   XGENE_AHCI_V1_1,
> XGENE_AHCI_V2,
>  };
>
> @@ -734,6 +735,7 @@ static struct scsi_host_template ahci_platform_sht = {
>  #ifdef CONFIG_ACPI
>  static const struct acpi_device_id xgene_ahci_acpi_match[] = {
> { "APMC0D0D", XGENE_AHCI_V1},
> +   { "APMC0D67", XGENE_AHCI_V1_1},
> { "APMC0D32", XGENE_AHCI_V2},
> {},
>  };
> @@ -742,6 +744,7 @@ MODULE_DEVICE_TABLE(acpi, xgene_ahci_acpi_match);
>
>  static const struct of_device_id xgene_ahci_of_match[] = {
> {.compatible = "apm,xgene-ahci", .data = (void *) XGENE_AHCI_V1},
> +   {.compatible = "apm,xgene-ahci-v1-1", .data = (void *) 
> XGENE_AHCI_V1_1},
> {.compatible = "apm,xgene-ahci-v2", .data = (void *) XGENE_AHCI_V2},
> {},
>  };
> @@ -755,8 +758,7 @@ static int xgene_ahci_probe(struct platform_device *pdev)
> struct resource *res;
> const struct of_device_id *of_devid;
> enum xgene_ahci_version version = XGENE_AHCI_V1;
> -   const struct ata_port_info *ppi[] = { _ahci_v1_port_info,
> - _ahci_v2_port_info };
> +   const struct ata_port_info *ppi;
> int rc;
>
> hpriv = ahci_platform_get_resources(pdev);
> @@ -821,8 +823,6 @@ static int xgene_ahci_probe(struct platform_device *pdev)
> dev_warn(>dev, "%s: Error reading 
> device info. Assume version1\n",
> __func__);
> version = XGENE_AHCI_V1;
> -   } else if (info->valid & ACPI_VALID_CID) {
> -   version = XGENE_AHCI_V2;
> }
> }
> }
> @@ -858,18 +858,20 @@ skip_clk_phy:
>
> switch (version) {
> case XGENE_AHCI_V1:
> +   ppi = _ahci_v1_port_info;
> hpriv->flags = AHCI_HFLAG_NO_NCQ;
> break;
> case XGENE_AHCI_V2:
> +   ppi = _ahci_v2_port_info;
> hpriv->flags |= AHCI_HFLAG_YES_FBS;
> hpriv->irq_handler = xgene_ahci_irq_intr;
> break;
> default:
> +   ppi = _ahci_v1_port_info;
> break;
> }
>
> -   rc = ahci_platform_init_host(pdev, hpriv, ppi[version - 1],
> -_platform_sht);
> +   rc = ahci_platform_init_host(pdev, hpriv, ppi, _platform_sht);
> if (rc)
> goto disable_resources;
>
> --
> 1.7.1
>

Any comments on this patch ??
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] ses: Fix SAS device detection in enclosure

2017-01-17 Thread James Bottomley
On Mon, 2017-01-09 at 16:33 -0500, Ewan D. Milne wrote:
> From: "Ewan D. Milne" 
> 
> The call to scsi_is_sas_rphy() needs to be made on the
> SAS end_device, not on the SCSI device.
> 
> Fixes: 835831c57e9b ("ses: use scsi_is_sas_rphy instead of
> is_sas_attached")
> Reviewed-by: Johannes Thumshirn 
> Signed-off-by: Ewan D. Milne 

Yes, looks good to me as well

Reviewed-by: James Bottomley 


--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] scsi: mpt3sas: fix hang on ata passthru commands

2017-01-17 Thread James Bottomley
On Tue, 2017-01-17 at 19:43 +0530, Sreekanth Reddy wrote:
> On Tue, Jan 17, 2017 at 1:31 AM, James Bottomley
>  wrote:
> > From 91d249409546569444897a1ffde65c421e064899 Mon Sep 17 00:00:00
> > 2001
> > From: James Bottomley 
> > Date: Sun, 1 Jan 2017 09:39:24 -0800
> > Subject: [PATCH] scsi: mpt3sas: fix hang on ata passthrough
> > commands
> > 
> > mpt3sas has a firmware failure where it can only handle one pass
> > through ATA command at a time.  If another comes in, contrary to
> > the
> > SAT standard, it will hang until the first one completes (causing
> > long
> > commands like secure erase to timeout).  The original fix was to
> > block
> > the device when an ATA command came in, but this caused a
> > regression
> > with
> > 
> > commit 669f044170d8933c3d66d231b69ea97cb8447338
> > Author: Bart Van Assche 
> > Date:   Tue Nov 22 16:17:13 2016 -0800
> > 
> > scsi: srp_transport: Move queuecommand() wait code to SCSI core
> > 
> > So fix the original fix of the secure erase timeout by properly
> > returning SAM_STAT_BUSY like the SAT recommends.  The original
> > patch
> > also had a concurrency problem since scsih_qcmd is lockless at that
> > point (this is fixed by using atomic bitops to set and test the
> > flag).
> > 
> > Fixes: 18f6084a989ba1b (mpt3sas: Fix secure erase premature
> > termination)
> > Signed-off-by: James Bottomley <
> > james.bottom...@hansenpartnership.com>
> > 
> > ---
> > 
> > v2 - use bitops for lockless atomicity
> > v3 - update description, change function name
> > ---
> >  drivers/scsi/mpt3sas/mpt3sas_base.h  | 12 +++
> >  drivers/scsi/mpt3sas/mpt3sas_scsih.c | 40 +++-
> > 
> >  2 files changed, 38 insertions(+), 14 deletions(-)
> > 
> > diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.h
> > b/drivers/scsi/mpt3sas/mpt3sas_base.h
> > index 394fe13..dcb33f4 100644
> > --- a/drivers/scsi/mpt3sas/mpt3sas_base.h
> > +++ b/drivers/scsi/mpt3sas/mpt3sas_base.h
> > @@ -393,6 +393,7 @@ struct MPT3SAS_TARGET {
> >   * @eedp_enable: eedp support enable bit
> >   * @eedp_type: 0(type_1), 1(type_2), 2(type_3)
> >   * @eedp_block_length: block size
> > + * @ata_command_pending: SATL passthrough outstanding for device
> >   */
> >  struct MPT3SAS_DEVICE {
> > struct MPT3SAS_TARGET *sas_target;
> > @@ -404,6 +405,17 @@ struct MPT3SAS_DEVICE {
> > u8  ignore_delay_remove;
> > /* Iopriority Command Handling */
> > u8  ncq_prio_enable;
> > +   /*
> > +* Bug workaround for SATL handling: the mpt2/3sas firmware
> > +* doesn't return BUSY or TASK_SET_FULL for subsequent
> > +* commands while a SATL pass through is in operation as
> > the
> > +* spec requires, it simply does nothing with them until
> > the
> > +* pass through completes, causing them possibly to timeout
> > if
> > +* the passthrough is a long executing command (like format
> > or
> > +* secure erase).  This variable allows us to do the right
> > +* thing while a SATL command is pending.
> > +*/
> > +   unsigned long ata_command_pending;
> > 
> >  };
> > 
> > diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
> > b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
> > index b5c966e..830e2c1 100644
> > --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
> > +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
> > @@ -3899,9 +3899,18 @@ _scsih_temp_threshold_events(struct
> > MPT3SAS_ADAPTER *ioc,
> > }
> >  }
> > 
> > -static inline bool ata_12_16_cmd(struct scsi_cmnd *scmd)
> > +static int _scsih_set_satl_pending(struct scsi_cmnd *scmd, bool
> > pending)
> >  {
> > -   return (scmd->cmnd[0] == ATA_12 || scmd->cmnd[0] ==
> > ATA_16);
> > +   struct MPT3SAS_DEVICE *priv = scmd->device->hostdata;
> > +
> > +   if  (scmd->cmnd[0] != ATA_12 && scmd->cmnd[0] != ATA_16)
> > +   return 0;
> > +
> > +   if (pending)
> > +   return test_and_set_bit(0, 
> > ->ata_command_pending);
> > +
> > +   clear_bit(0, >ata_command_pending);
> > +   return 0;
> >  }
> > 
> >  /**
> > @@ -3925,9 +3934,7 @@ _scsih_flush_running_cmds(struct
> > MPT3SAS_ADAPTER *ioc)
> > if (!scmd)
> > continue;
> > count++;
> > -   if (ata_12_16_cmd(scmd))
> > -   scsi_internal_device_unblock(scmd->device,
> > -  
> >  SDEV_RUNNING);
> > +   _scsih_set_satl_pending(scmd, false);
> > mpt3sas_base_free_smid(ioc, smid);
> > scsi_dma_unmap(scmd);
> > if (ioc->pci_error_recovery)
> > @@ -4063,13 +4070,6 @@ scsih_qcmd(struct Scsi_Host *shost, struct
> > scsi_cmnd *scmd)
> > if (ioc->logging_level & MPT_DEBUG_SCSI)
> > scsi_print_command(scmd);
> > 
> > -   /*
> > -   

Re: [PATCH 1/2] qed: Add support for hardware offloaded FCoE.

2017-01-17 Thread kbuild test robot
Hi Arun,

[auto build test WARNING on net-next/master]
[also build test WARNING on v4.10-rc4 next-20170117]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Dupuis-Chad/Add-QLogic-FastLinQ-FCoE-qedf-driver/20170117-052438
config: i386-randconfig-c0-01172134 (attached as .config)
compiler: gcc-4.9 (Debian 4.9.4-2) 4.9.4
reproduce:
# save the attached .config to linux build tree
make ARCH=i386 

All warnings (new ones prefixed by >>):

   In file included from drivers/net/ethernet/qlogic/qed/qed.h:49:0,
from drivers/net/ethernet/qlogic/qed/qed_cxt.c:44:
>> include/linux/qed/qed_if.h:428:37: warning: 'struct qed_dcbx_get' declared 
>> inside parameter list
 void (*dcbx_aen)(void *dev, struct qed_dcbx_get *get, u32 mib_type);
^
>> include/linux/qed/qed_if.h:428:37: warning: its scope is only this 
>> definition or declaration, which is probably not what you want
--
   In file included from drivers/net/ethernet/qlogic/qed/qed.h:49:0,
from drivers/net/ethernet/qlogic/qed/qed_dcbx.c:41:
>> include/linux/qed/qed_if.h:428:37: warning: 'struct qed_dcbx_get' declared 
>> inside parameter list
 void (*dcbx_aen)(void *dev, struct qed_dcbx_get *get, u32 mib_type);
^
>> include/linux/qed/qed_if.h:428:37: warning: its scope is only this 
>> definition or declaration, which is probably not what you want
   drivers/net/ethernet/qlogic/qed/qed_dcbx.c: In function 'qed_dcbx_aen':
   drivers/net/ethernet/qlogic/qed/qed_dcbx.c:873:42: error: 'struct 
qed_dcbx_info' has no member named 'get'
  op->dcbx_aen(cookie, >p_dcbx_info->get, mib_type);
 ^
   drivers/net/ethernet/qlogic/qed/qed_dcbx.c: In function 
'qed_dcbx_mib_update_event':
   drivers/net/ethernet/qlogic/qed/qed_dcbx.c:902:2: error: implicit 
declaration of function 'qed_dcbx_get_params' 
[-Werror=implicit-function-declaration]
 qed_dcbx_get_params(p_hwfn, p_ptt, _hwfn->p_dcbx_info->get, type);
 ^
   drivers/net/ethernet/qlogic/qed/qed_dcbx.c:902:57: error: 'struct 
qed_dcbx_info' has no member named 'get'
 qed_dcbx_get_params(p_hwfn, p_ptt, _hwfn->p_dcbx_info->get, type);
^
   cc1: some warnings being treated as errors

vim +428 include/linux/qed/qed_if.h

   412  u8  name[QED_DRV_VER_STR_SIZE];
   413  };
   414  
   415  #define ILT_PAGE_SIZE_TCFC 0x8000 /* 32KB */
   416  
   417  struct qed_int_info {
   418  struct msix_entry   *msix;
   419  u8  msix_cnt;
   420  
   421  /* This should be updated by the protocol driver */
   422  u8  used_cnt;
   423  };
   424  
   425  struct qed_common_cb_ops {
   426  void(*link_update)(void *dev,
   427 struct qed_link_output   *link);
 > 428  void(*dcbx_aen)(void *dev, struct qed_dcbx_get *get, u32 
 > mib_type);
   429  };
   430  
   431  struct qed_selftest_ops {
   432  /**
   433   * @brief selftest_interrupt - Perform interrupt test
   434   *
   435   * @param cdev
   436   *

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip


Re: [PATCH] scsi: mpt3sas: fix hang on ata passthru commands

2017-01-17 Thread Christoph Hellwig
On Tue, Jan 17, 2017 at 07:43:51PM +0530, Sreekanth Reddy wrote:
> [Sreekanth] Just for readability purpose, can use use "if (test_bit(0,
> _device_priv_data->ata_command_pending)"
>  instead of "if (sas_device_priv_data->ata_command_pending)".
> Since while setting & clearing the bit we are using atomic bit
> operations. I don't see any issue functionality wise.

I agree.  Also while we're into nitpicking - it would be good to
give bit 0 of the bitmap a name instead of hardcoding the 0.

Except for these patch looks fine:

Reviewed-by: Christoph Hellwig 
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH V2] mpt3sas: disable ASPM for MPI2 controllers

2017-01-17 Thread Sreekanth Reddy
On Tue, Jan 17, 2017 at 4:13 AM, ojab  wrote:
> On 2017/01/16 14:03, ojab wrote:
>>
>> On 2017/01/16 13:31, Sreekanth Reddy wrote:
>>>
>>> On Mon, Jan 16, 2017 at 6:15 PM, ojab  wrote:

 On 2017/01/16 12:36, Sreekanth Reddy wrote:
>
>
> Ojab,
>
> I am checking internally with our FW team and Architect to known
> whether they aware/observed any issues similar to this (since this
> issue is nothing to do with driver).
>
> Meanwhile is it possible to provide us the PCI config space and FW
> logs when issue occurs?



 AFAIU FW log is enabled when `logging_level=0x3f8` is passed to the
 module,
 right?
>>>
>>>
>>> This is a driver logging_level. Firmware logs can be collected using
>>> UART logs.
>>
>>
>> According to the user guide (from
>>
>> https://www.broadcom.com/products/storage/host-bus-adapters/sas-9217-8i#documentation)
>> my 9217-8i requires 1.8V UART which I don't have at hand, I'll try to do
>> something on the weekend.
>> Is anything needed except connecting UART to gather required info?
>
> …actually I have compatible USB UART here. What should be done to get FW
> log? I've tried to reboot with UART connected (9600N1) but got no output.

You have to use, 115200 instead of 9600 baud rate.

Thanks,
Sreekanth

>
> //wbr ojab
>
>
>>
>> Anyway, right now various MPI2 HBAs doesn't work with ASPM enabled, so
>> can this patch be applied in the meantime while we're debugging the
>> issue further? Even if this issue can be properly fixed by FW update,
>> this workaround will be needed for HBAs with affected FW versions.
>>
>> //wbr ojab
>>
>>
>>>
 Where can I find info about PCI config space?
>>>
>>>
>>> You can get PCI config space info from lspci command.
>>>

 //wbr ojab
>
>
>
> Thanks,
> Sreekanth
>
> On Mon, Jan 16, 2017 at 5:37 PM, ojab  wrote:
>>
>>
>> On 2017/01/06 15:48, Sreekanth Reddy wrote:
>>>
>>>
>>>
>>> On Fri, Jan 6, 2017 at 7:24 AM, Martin K. Petersen
>>>  wrote:
>>>
>>> Matin, We need some time to review this patch. I will provide my
>>> review comments by end of next week.
>>>
>> ping?
>>
>> //wbr ojab
>>>
>>>
>>>
>>> Thanks,
>>> Sreekanth
>>
>>
>>
>>
> --
> To unsubscribe from this list: send the line "unsubscribe
> linux-scsi" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

>>> --
>>> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
>>> the body of a message to majord...@vger.kernel.org
>>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>>
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
>> the body of a message to majord...@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] scsi: mpt3sas: fix hang on ata passthru commands

2017-01-17 Thread Sreekanth Reddy
On Tue, Jan 17, 2017 at 1:31 AM, James Bottomley
 wrote:
> From 91d249409546569444897a1ffde65c421e064899 Mon Sep 17 00:00:00 2001
> From: James Bottomley 
> Date: Sun, 1 Jan 2017 09:39:24 -0800
> Subject: [PATCH] scsi: mpt3sas: fix hang on ata passthrough commands
>
> mpt3sas has a firmware failure where it can only handle one pass
> through ATA command at a time.  If another comes in, contrary to the
> SAT standard, it will hang until the first one completes (causing long
> commands like secure erase to timeout).  The original fix was to block
> the device when an ATA command came in, but this caused a regression
> with
>
> commit 669f044170d8933c3d66d231b69ea97cb8447338
> Author: Bart Van Assche 
> Date:   Tue Nov 22 16:17:13 2016 -0800
>
> scsi: srp_transport: Move queuecommand() wait code to SCSI core
>
> So fix the original fix of the secure erase timeout by properly
> returning SAM_STAT_BUSY like the SAT recommends.  The original patch
> also had a concurrency problem since scsih_qcmd is lockless at that
> point (this is fixed by using atomic bitops to set and test the flag).
>
> Fixes: 18f6084a989ba1b (mpt3sas: Fix secure erase premature termination)
> Signed-off-by: James Bottomley 
>
> ---
>
> v2 - use bitops for lockless atomicity
> v3 - update description, change function name
> ---
>  drivers/scsi/mpt3sas/mpt3sas_base.h  | 12 +++
>  drivers/scsi/mpt3sas/mpt3sas_scsih.c | 40 
> +++-
>  2 files changed, 38 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.h 
> b/drivers/scsi/mpt3sas/mpt3sas_base.h
> index 394fe13..dcb33f4 100644
> --- a/drivers/scsi/mpt3sas/mpt3sas_base.h
> +++ b/drivers/scsi/mpt3sas/mpt3sas_base.h
> @@ -393,6 +393,7 @@ struct MPT3SAS_TARGET {
>   * @eedp_enable: eedp support enable bit
>   * @eedp_type: 0(type_1), 1(type_2), 2(type_3)
>   * @eedp_block_length: block size
> + * @ata_command_pending: SATL passthrough outstanding for device
>   */
>  struct MPT3SAS_DEVICE {
> struct MPT3SAS_TARGET *sas_target;
> @@ -404,6 +405,17 @@ struct MPT3SAS_DEVICE {
> u8  ignore_delay_remove;
> /* Iopriority Command Handling */
> u8  ncq_prio_enable;
> +   /*
> +* Bug workaround for SATL handling: the mpt2/3sas firmware
> +* doesn't return BUSY or TASK_SET_FULL for subsequent
> +* commands while a SATL pass through is in operation as the
> +* spec requires, it simply does nothing with them until the
> +* pass through completes, causing them possibly to timeout if
> +* the passthrough is a long executing command (like format or
> +* secure erase).  This variable allows us to do the right
> +* thing while a SATL command is pending.
> +*/
> +   unsigned long ata_command_pending;
>
>  };
>
> diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c 
> b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
> index b5c966e..830e2c1 100644
> --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
> +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
> @@ -3899,9 +3899,18 @@ _scsih_temp_threshold_events(struct MPT3SAS_ADAPTER 
> *ioc,
> }
>  }
>
> -static inline bool ata_12_16_cmd(struct scsi_cmnd *scmd)
> +static int _scsih_set_satl_pending(struct scsi_cmnd *scmd, bool pending)
>  {
> -   return (scmd->cmnd[0] == ATA_12 || scmd->cmnd[0] == ATA_16);
> +   struct MPT3SAS_DEVICE *priv = scmd->device->hostdata;
> +
> +   if  (scmd->cmnd[0] != ATA_12 && scmd->cmnd[0] != ATA_16)
> +   return 0;
> +
> +   if (pending)
> +   return test_and_set_bit(0, >ata_command_pending);
> +
> +   clear_bit(0, >ata_command_pending);
> +   return 0;
>  }
>
>  /**
> @@ -3925,9 +3934,7 @@ _scsih_flush_running_cmds(struct MPT3SAS_ADAPTER *ioc)
> if (!scmd)
> continue;
> count++;
> -   if (ata_12_16_cmd(scmd))
> -   scsi_internal_device_unblock(scmd->device,
> -   SDEV_RUNNING);
> +   _scsih_set_satl_pending(scmd, false);
> mpt3sas_base_free_smid(ioc, smid);
> scsi_dma_unmap(scmd);
> if (ioc->pci_error_recovery)
> @@ -4063,13 +4070,6 @@ scsih_qcmd(struct Scsi_Host *shost, struct scsi_cmnd 
> *scmd)
> if (ioc->logging_level & MPT_DEBUG_SCSI)
> scsi_print_command(scmd);
>
> -   /*
> -* Lock the device for any subsequent command until command is
> -* done.
> -*/
> -   if (ata_12_16_cmd(scmd))
> -   scsi_internal_device_block(scmd->device);
> -
> sas_device_priv_data = scmd->device->hostdata;
> if (!sas_device_priv_data || !sas_device_priv_data->sas_target) {
> scmd->result = 

Re: [PATCH 2/2] virtio_scsi: Implement fc_host

2017-01-17 Thread Fam Zheng
On Tue, 01/17 14:17, Paolo Bonzini wrote:
> 
> 
> On 16/01/2017 18:26, Fam Zheng wrote:
> >> Is the endianness correct for big-endian host here?
> >
> > I think so. The fc_host sysfs uses u64 to represent port_name and node_name,
> > this patch does the same, so using virtio_* helpers for these fields should
> > handle the endianness correctly.
> 
> I was suspicious about it because they are defined as "u8 x[8]" in the
> virtio_scsi_config struct.  So you would need to read with
> virtio_cread_bytes and pass the result to wwn_to_u64.
> 
> For example, if you have 0x500123456789abcd this would be
> 
>   0x50 0x01 0x23 0x45 0x67 0x89 0xab 0cd
> 
> in virtio_scsi_config, and then virtio_cread64 would read it as a
> little-endian u64, 0xcdab896745230150.  Maybe your QEMU patch is also
> writing things as little-endian 64-bit integers, rather than 8-element
> arrays of bytes?

Yes, they all used 64-bit integers in a "less surprising" endian. I think there
is an endianness conecpt to WWN, as in 0x500123456789abcd; and there is an
native endianness to virtio, which is little-endian. If we use a "u8 x[8]" type
in the spec and want the WWN's MSB, namely the 0x50 stuff, to be the first byte,
is it worth to explicitly document that to avoid confusion?

Fam
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/2] virtio_scsi: Implement fc_host

2017-01-17 Thread Paolo Bonzini


On 16/01/2017 18:26, Fam Zheng wrote:
>> Is the endianness correct for big-endian host here?
>
> I think so. The fc_host sysfs uses u64 to represent port_name and node_name,
> this patch does the same, so using virtio_* helpers for these fields should
> handle the endianness correctly.

I was suspicious about it because they are defined as "u8 x[8]" in the
virtio_scsi_config struct.  So you would need to read with
virtio_cread_bytes and pass the result to wwn_to_u64.

For example, if you have 0x500123456789abcd this would be

0x50 0x01 0x23 0x45 0x67 0x89 0xab 0cd

in virtio_scsi_config, and then virtio_cread64 would read it as a
little-endian u64, 0xcdab896745230150.  Maybe your QEMU patch is also
writing things as little-endian 64-bit integers, rather than 8-element
arrays of bytes?

Paolo

> Maybe we should use u64 in struct virtio_scsi_config as well?
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[ANOUNCE] New open-fcoe release v1.0.32

2017-01-17 Thread Johannes Thumshirn
Hi,

I've tagged a new release v1.0.32 of fcoe-utils at
https://github.com/morbidrsa/fcoe-utils/

There's not much news here's the git log:
Chad Dupuis (1):
  fcoemon: Add retry mechanism during fip vlan discovery if socket fails to 
open.

Chris Leech (2):
  fcoeadm: --target segfault with other FC storage present
  sanmac isn't required

Hannes Reinecke (3):
  fcoemon: fixup log_nlmsg_error()
  fcoemon: Add debugging message for 'recv'
  Fallback to default MAC address for FIP

Johannes Thumshirn (2):
  fcoeadm: Fix possible buffer overflows
  fcoe-utils: increment fcoe-utils version to 1.0.32

Milan P. Gandhi (3):
  fcoemon.c: Add a check to verify if dcbd is to be initialized, else do 
not try to connect to dcbd/lldpad
  fix a minor typo in fcoeadm_display.c, fcoemon.h and fcping.c
  Print an error upon failure in memory allocation for struct pollfd

-- 
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
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] scsi: mpt3sas: fix hang on ata passthru commands

2017-01-17 Thread Ingo Molnar

* Martin K. Petersen  wrote:

> > "James" == James Bottomley  
> > writes:
> 
> James> Subject: [PATCH] scsi: mpt3sas: fix hang on ata passthrough
> James> commands
> 
> James> mpt3sas has a firmware failure where it can only handle one pass
> James> through ATA command at a time.  If another comes in, contrary to
> James> the SAT standard, it will hang until the first one completes
> James> (causing long commands like secure erase to timeout).  The
> James> original fix was to block the device when an ATA command came in,
> James> but this caused a regression with
> 
> Broadcom folks: Please test and ack as soon as possible so we can get
> this fix queued up.
> 
> Ingo: Since you appear to have hardware, it would be great if you could
> test James' v3 (https://patchwork.kernel.org/patch/9519383/). Sorry for
> the inconvenience.

As per the interdiff below v2->v3 did not change the code in any way, only the 
name of the function and a comment, so you can add this to v3 as well:

  Reported-by: Ingo Molnar 
  Tested-by: Ingo Molnar 

Thanks,

Ingo

diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c 
b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
index 6f9b4c051e4d..830e2c10ba02 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
@@ -3899,7 +3899,7 @@ _scsih_temp_threshold_events(struct MPT3SAS_ADAPTER *ioc,
}
 }
 
-static int set_satl_pending(struct scsi_cmnd *scmd, bool pending)
+static int _scsih_set_satl_pending(struct scsi_cmnd *scmd, bool pending)
 {
struct MPT3SAS_DEVICE *priv = scmd->device->hostdata;
 
@@ -3934,7 +3934,7 @@ _scsih_flush_running_cmds(struct MPT3SAS_ADAPTER *ioc)
if (!scmd)
continue;
count++;
-   set_satl_pending(scmd, false);
+   _scsih_set_satl_pending(scmd, false);
mpt3sas_base_free_smid(ioc, smid);
scsi_dma_unmap(scmd);
if (ioc->pci_error_recovery)
@@ -4084,7 +4084,9 @@ scsih_qcmd(struct Scsi_Host *shost, struct scsi_cmnd 
*scmd)
}
 
/*
-* Bug work around for firmware SATL handling
+* Bug work around for firmware SATL handling.  The loop
+* is based on atomic operations and ensures consistency
+* since we're lockless at this point
 */
do {
if (sas_device_priv_data->ata_command_pending) {
@@ -4092,7 +4094,7 @@ scsih_qcmd(struct Scsi_Host *shost, struct scsi_cmnd 
*scmd)
scmd->scsi_done(scmd);
return 0;
}
-   } while (set_satl_pending(scmd, true));
+   } while (_scsih_set_satl_pending(scmd, true));
 
sas_target_priv_data = sas_device_priv_data->sas_target;
 
@@ -4661,7 +4663,7 @@ _scsih_io_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 
msix_index, u32 reply)
if (scmd == NULL)
return 1;
 
-   set_satl_pending(scmd, false);
+   _scsih_set_satl_pending(scmd, false);
 
mpi_request = mpt3sas_base_get_msg_frame(ioc, smid);
 
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html