Re: [PATCH 0/4] scsi: fixup dma_set_mask_and_coherent() calls

2019-02-15 Thread Christoph Hellwig
On Fri, Feb 15, 2019 at 08:43:55AM +0100, Christoph Hellwig wrote:
> On Fri, Feb 15, 2019 at 07:55:39AM +0100, Hannes Reinecke wrote:
> >> Yeah, there is a few more.  And the sad part is as of a few kernel
> >> release ago we shouldn't even need the fallback 32-bit dma mask
> >> anymore - we've cleaned up all the mess that required it.
> >>
> > Care to elaborate?
> > Can you point me to the respective commits facilitating that?
> 
> It mostly has been that way for a long time, but we still had a few
> oddball architectures checking for an exact 32-bit match in their
> arch specific direct mapping routines.  With the move to the generic
> dma-direct implementation all those got fixed.

Actually, sparc64 is still doing odd things.  I guess I'll need to
get the fixup series for that into 5.1 first before we can clean up
the mess in the drivers.


[PATCH v3] fcoe: make use of fip_mode enum complete

2019-02-15 Thread Hannes Reinecke
From: Sedat Dilek 

commit 1917d42d14b7 ("fcoe: use enum for fip_mode") introduces a separate
enum for the fip_mode that shall be used during initialisation handling
until it is passed to fcoe_ctrl_link_up to set the initial fip_state.
That change was incomplete and gcc quietly converted in various places
between the fip_mode and the fip_state enum values with implicit enum
conversions, which fortunately cannot cause any issues in the actual
code's execution.

clang however warns about these implicit enum conversions in the scsi
drivers. This commit consolidates the use of the two enums, guided by
clang's enum-conversion warnings.

This commit now completes the use of the fip_mode:
It expects and uses fip_mode in {bnx2fc,fcoe}_interface_create and
fcoe_ctlr_init, and it calls fcoe_ctrl_set_set() with the correct
values in fcoe_ctlr_link_up().
It also breaks the association between FIP_MODE_AUTO and FIP_ST_AUTO
to indicate these two enums are distinct.

Link: https://github.com/ClangBuiltLinux/linux/issues/151
Fixes: 1917d42d14b7 ("fcoe: use enum for fip_mode")
Reported-by: Dmitry Golovin "Twisted Pair in my Hair" 
CC: Lukas Bulwahn 
CC: Nick Desaulniers 
CC: Nathan Chancellor 
Suggested-by: Johannes Thumshirn 
Signed-off-by: Sedat Dilek 
Signed-off-by: Hannes Reinecke 
---
 drivers/scsi/bnx2fc/bnx2fc_fcoe.c  | 2 +-
 drivers/scsi/fcoe/fcoe.c   | 2 +-
 drivers/scsi/fcoe/fcoe_ctlr.c  | 7 +--
 drivers/scsi/fcoe/fcoe_transport.c | 2 +-
 drivers/scsi/qedf/qedf_main.c  | 2 +-
 include/scsi/libfcoe.h | 4 ++--
 6 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c 
b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
index 2e4e7159ebf9..a75e74ad1698 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
@@ -1438,7 +1438,7 @@ static struct bnx2fc_hba *bnx2fc_hba_create(struct 
cnic_dev *cnic)
 static struct bnx2fc_interface *
 bnx2fc_interface_create(struct bnx2fc_hba *hba,
struct net_device *netdev,
-   enum fip_state fip_mode)
+   enum fip_mode fip_mode)
 {
struct fcoe_ctlr_device *ctlr_dev;
struct bnx2fc_interface *interface;
diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c
index cd19be3f3405..8ba8862d3292 100644
--- a/drivers/scsi/fcoe/fcoe.c
+++ b/drivers/scsi/fcoe/fcoe.c
@@ -389,7 +389,7 @@ static int fcoe_interface_setup(struct fcoe_interface *fcoe,
  * Returns: pointer to a struct fcoe_interface or NULL on error
  */
 static struct fcoe_interface *fcoe_interface_create(struct net_device *netdev,
-   enum fip_state fip_mode)
+   enum fip_mode fip_mode)
 {
struct fcoe_ctlr_device *ctlr_dev;
struct fcoe_ctlr *ctlr;
diff --git a/drivers/scsi/fcoe/fcoe_ctlr.c b/drivers/scsi/fcoe/fcoe_ctlr.c
index 54da3166da8d..b222b300f8df 100644
--- a/drivers/scsi/fcoe/fcoe_ctlr.c
+++ b/drivers/scsi/fcoe/fcoe_ctlr.c
@@ -147,7 +147,7 @@ static void fcoe_ctlr_map_dest(struct fcoe_ctlr *fip)
  * fcoe_ctlr_init() - Initialize the FCoE Controller instance
  * @fip: The FCoE controller to initialize
  */
-void fcoe_ctlr_init(struct fcoe_ctlr *fip, enum fip_state mode)
+void fcoe_ctlr_init(struct fcoe_ctlr *fip, enum fip_mode mode)
 {
fcoe_ctlr_set_state(fip, FIP_ST_LINK_WAIT);
fip->mode = mode;
@@ -454,7 +454,10 @@ void fcoe_ctlr_link_up(struct fcoe_ctlr *fip)
mutex_unlock(&fip->ctlr_mutex);
fc_linkup(fip->lp);
} else if (fip->state == FIP_ST_LINK_WAIT) {
-   fcoe_ctlr_set_state(fip, fip->mode);
+   if (fip->mode == FIP_MODE_NON_FIP)
+   fcoe_ctlr_set_state(fip, FIP_ST_NON_FIP);
+   else
+   fcoe_ctrl_set_state(fip, FIP_ST_AUTO);
switch (fip->mode) {
default:
LIBFCOE_FIP_DBG(fip, "invalid mode %d\n", fip->mode);
diff --git a/drivers/scsi/fcoe/fcoe_transport.c 
b/drivers/scsi/fcoe/fcoe_transport.c
index f4909cd206d3..b381ab066b9c 100644
--- a/drivers/scsi/fcoe/fcoe_transport.c
+++ b/drivers/scsi/fcoe/fcoe_transport.c
@@ -873,7 +873,7 @@ static int fcoe_transport_create(const char *buffer,
int rc = -ENODEV;
struct net_device *netdev = NULL;
struct fcoe_transport *ft = NULL;
-   enum fip_state fip_mode = (enum fip_state)(long)kp->arg;
+   enum fip_mode fip_mode = (enum fip_mode)(long)kp->arg;
 
mutex_lock(&ft_mutex);
 
diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c
index 9bbc19fc190b..9f9431a4cc0e 100644
--- a/drivers/scsi/qedf/qedf_main.c
+++ b/drivers/scsi/qedf/qedf_main.c
@@ -1418,7 +1418,7 @@ static struct libfc_function_template qedf_lport_template 
= {
 
 static void qedf_fcoe_ctlr_setup(struct qedf_ctx *qedf)
 {
-   fcoe_ctlr_init(&qedf->ctlr, FIP_ST_AUTO);
+   fcoe_ctlr_init(&q

Re: [PATCH 0/4] scsi: fixup dma_set_mask_and_coherent() calls

2019-02-15 Thread John Garry

On 15/02/2019 08:08, Christoph Hellwig wrote:

On Fri, Feb 15, 2019 at 08:43:55AM +0100, Christoph Hellwig wrote:

On Fri, Feb 15, 2019 at 07:55:39AM +0100, Hannes Reinecke wrote:

Yeah, there is a few more.  And the sad part is as of a few kernel
release ago we shouldn't even need the fallback 32-bit dma mask
anymore - we've cleaned up all the mess that required it.


Care to elaborate?
Can you point me to the respective commits facilitating that?


It mostly has been that way for a long time, but we still had a few
oddball architectures checking for an exact 32-bit match in their
arch specific direct mapping routines.  With the move to the generic
dma-direct implementation all those got fixed.


I thought that many SCSI drivers were changed over to stop using the PCI 
DMA APIs at the end of last year, like this:


commit c22b332d811b90448e090c7fb487448afb039fcc
Author: Christoph Hellwig 
Date:   Wed Oct 10 18:34:51 2018 +0200

scsi: csiostor: switch to generic DMA API

Switch from the legacy PCI DMA API to the generic DMA API.

Signed-off-by: Christoph Hellwig 
Reviewed-by: Johannes Thumshirn 
Signed-off-by: Martin K. Petersen 

diff --git a/drivers/scsi/csiostor/csio_init.c 
b/drivers/scsi/csiostor/csio_init.c

index ed2dae657964..aa04e4a7aed5 100644
--- a/drivers/scsi/csiostor/csio_init.c
+++ b/drivers/scsi/csiostor/csio_init.c
@@ -210,11 +210,8 @@ csio_pci_init(struct pci_dev *pdev, int *bars)
pci_set_master(pdev);
pci_try_set_mwi(pdev);

-   if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(64))) {
-   pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64));
-   } else if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) {
-   pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
-   } else {
+   if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)) ||
+   dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32))) {
dev_err(&pdev->dev, "No suitable DMA available.\n");
goto err_release_regions;
}



Actually, sparc64 is still doing odd things.  I guess I'll need to
get the fixup series for that into 5.1 first before we can clean up
the mess in the drivers.

.






[PATCH][V2] scsi: qla2xxx: remove redundant null check on pointer sess

2019-02-15 Thread Colin King
From: Colin Ian King 

The null check on pointer sess and the subsequent call is redundant
as sess is null on all the the paths that lead to the out_term2 label.
Hence the null check and the call can be removed.  Also remove the
redundant setting of sess to NULL as this is not required now.

Detected by CoverityScan, CID#1420663 ("Logically dead code")

Signed-off-by: Colin Ian King 
---

V2: Remove the redundant settings of sess to NULL, thanks to
Dan Carpenter for spotting this.

---
 drivers/scsi/qla2xxx/qla_target.c | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_target.c 
b/drivers/scsi/qla2xxx/qla_target.c
index 6b8c655d9eb4..33131446b327 100644
--- a/drivers/scsi/qla2xxx/qla_target.c
+++ b/drivers/scsi/qla2xxx/qla_target.c
@@ -6343,7 +6343,7 @@ static void qlt_tmr_work(struct qla_tgt *tgt,
struct atio_from_isp *a = &prm->tm_iocb2;
struct scsi_qla_host *vha = tgt->vha;
struct qla_hw_data *ha = vha->hw;
-   struct fc_port *sess = NULL;
+   struct fc_port *sess;
unsigned long flags;
uint8_t *s_id = NULL; /* to hide compiler warnings */
int rc;
@@ -6369,7 +6369,6 @@ static void qlt_tmr_work(struct qla_tgt *tgt,
goto out_term2;
} else {
if (sess->deleted) {
-   sess = NULL;
goto out_term2;
}
 
@@ -6377,7 +6376,6 @@ static void qlt_tmr_work(struct qla_tgt *tgt,
ql_dbg(ql_dbg_tgt_tmr, vha, 0xf020,
"%s: kref_get fail %8phC\n",
 __func__, sess->port_name);
-   sess = NULL;
goto out_term2;
}
}
@@ -6396,8 +6394,6 @@ static void qlt_tmr_work(struct qla_tgt *tgt,
return;
 
 out_term2:
-   if (sess)
-   ha->tgt.tgt_ops->put_sess(sess);
spin_unlock_irqrestore(&ha->tgt.sess_lock, flags);
 out_term:
qlt_send_term_exchange(ha->base_qpair, NULL, &prm->tm_iocb2, 1, 0);
-- 
2.20.1



Re: [PATCH v3] fcoe: make use of fip_mode enum complete

2019-02-15 Thread kbuild test robot
Hi Sedat,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on scsi/for-next]
[also build test ERROR on v5.0-rc4 next-20190215]
[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/Hannes-Reinecke/fcoe-make-use-of-fip_mode-enum-complete/20190215-175222
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git for-next
config: x86_64-randconfig-x017-201906 (attached as .config)
compiler: gcc-8 (Debian 8.2.0-20) 8.2.0
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64 

All errors (new ones prefixed by >>):

   drivers/scsi//fcoe/fcoe_ctlr.c: In function 'fcoe_ctlr_link_up':
>> drivers/scsi//fcoe/fcoe_ctlr.c:460:4: error: implicit declaration of 
>> function 'fcoe_ctrl_set_state'; did you mean 'fcoe_ctlr_set_state'? 
>> [-Werror=implicit-function-declaration]
   fcoe_ctrl_set_state(fip, FIP_ST_AUTO);
   ^~~
   fcoe_ctlr_set_state
   cc1: some warnings being treated as errors

vim +460 drivers/scsi//fcoe/fcoe_ctlr.c

   443  
   444  /**
   445   * fcoe_ctlr_link_up() - Start FCoE controller
   446   * @fip: The FCoE controller to start
   447   *
   448   * Called from the LLD when the network link is ready.
   449   */
   450  void fcoe_ctlr_link_up(struct fcoe_ctlr *fip)
   451  {
   452  mutex_lock(&fip->ctlr_mutex);
   453  if (fip->state == FIP_ST_NON_FIP || fip->state == FIP_ST_AUTO) {
   454  mutex_unlock(&fip->ctlr_mutex);
   455  fc_linkup(fip->lp);
   456  } else if (fip->state == FIP_ST_LINK_WAIT) {
   457  if (fip->mode == FIP_MODE_NON_FIP)
   458  fcoe_ctlr_set_state(fip, FIP_ST_NON_FIP);
   459  else
 > 460  fcoe_ctrl_set_state(fip, FIP_ST_AUTO);
   461  switch (fip->mode) {
   462  default:
   463  LIBFCOE_FIP_DBG(fip, "invalid mode %d\n", 
fip->mode);
   464  /* fall-through */
   465  case FIP_MODE_AUTO:
   466  LIBFCOE_FIP_DBG(fip, "%s", "setting AUTO 
mode.\n");
   467  /* fall-through */
   468  case FIP_MODE_FABRIC:
   469  case FIP_MODE_NON_FIP:
   470  mutex_unlock(&fip->ctlr_mutex);
   471  fc_linkup(fip->lp);
   472  fcoe_ctlr_solicit(fip, NULL);
   473  break;
   474  case FIP_MODE_VN2VN:
   475  fcoe_ctlr_vn_start(fip);
   476  mutex_unlock(&fip->ctlr_mutex);
   477  fc_linkup(fip->lp);
   478  break;
   479  }
   480  } else
   481  mutex_unlock(&fip->ctlr_mutex);
   482  }
   483  EXPORT_SYMBOL(fcoe_ctlr_link_up);
   484  

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


.config.gz
Description: application/gzip


[PATCH] scsi: megaraid_sas: return error when create DMA pool failed in megasas_alloc_cmds()

2019-02-15 Thread Jason Yan
when create DMA pool for cmd frames failed, we should return -ENOMEM,
instead of 0.
In some case in:

megasas_init_adapter_fusion()

-->megasas_alloc_cmds()
   -->megasas_create_frame_pool
  create DMA pool failed,
--> megasas_free_cmds() [1]

-->megasas_alloc_cmds_fusion()
   failed, then goto fail_alloc_cmds.
-->megasas_free_cmds() [2]

we will call megasas_free_cmds twice, [1] will kfree cmd_list,
[2] will use cmd_list.it will cause a problem:

Unable to handle kernel NULL pointer dereference at virtual address

pgd = ffc000f7
[] *pgd=001fbf893003, *pud=001fbf893003,
*pmd=001fbf894003, *pte=00606d000707
Internal error: Oops: 9605 [#1] SMP
 Modules linked in:
 CPU: 18 PID: 1 Comm: swapper/0 Not tainted
 task: ffdfb929 ti: ffdfb923c000 task.ti: ffdfb923c000
 PC is at megasas_free_cmds+0x30/0x70
 LR is at megasas_free_cmds+0x24/0x70
 ...
 Call trace:
 [] megasas_free_cmds+0x30/0x70
 [] megasas_init_adapter_fusion+0x2f4/0x4d8
 [] megasas_init_fw+0x2dc/0x760
 [] megasas_probe_one+0x3c0/0xcd8
 [] local_pci_probe+0x4c/0xb4
 [] pci_device_probe+0x11c/0x14c
 [] driver_probe_device+0x1ec/0x430
 [] __driver_attach+0xa8/0xb0
 [] bus_for_each_dev+0x74/0xc8
  [] driver_attach+0x28/0x34
 [] bus_add_driver+0x16c/0x248
 [] driver_register+0x6c/0x138
 [] __pci_register_driver+0x5c/0x6c
 [] megasas_init+0xc0/0x1a8
 [] do_one_initcall+0xe8/0x1ec
 [] kernel_init_freeable+0x1c8/0x284
 [] kernel_init+0x1c/0xe4

Signed-off-by: Jason Yan 
---
 drivers/scsi/megaraid/megaraid_sas_base.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c 
b/drivers/scsi/megaraid/megaraid_sas_base.c
index fcbff83c0097..c9811d1aa007 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -4188,6 +4188,7 @@ int megasas_alloc_cmds(struct megasas_instance *instance)
if (megasas_create_frame_pool(instance)) {
dev_printk(KERN_DEBUG, &instance->pdev->dev, "Error creating 
frame DMA pool\n");
megasas_free_cmds(instance);
+   return -ENOMEM;
}
 
return 0;
-- 
2.14.4



[PATCHv4] fcoe: make use of fip_mode enum complete

2019-02-15 Thread Hannes Reinecke
From: Sedat Dilek 

commit 1917d42d14b7 ("fcoe: use enum for fip_mode") introduces a separate
enum for the fip_mode that shall be used during initialisation handling
until it is passed to fcoe_ctrl_link_up to set the initial fip_state.
That change was incomplete and gcc quietly converted in various places
between the fip_mode and the fip_state enum values with implicit enum
conversions, which fortunately cannot cause any issues in the actual
code's execution.

clang however warns about these implicit enum conversions in the scsi
drivers. This commit consolidates the use of the two enums, guided by
clang's enum-conversion warnings.

This commit now completes the use of the fip_mode:
It expects and uses fip_mode in {bnx2fc,fcoe}_interface_create and
fcoe_ctlr_init, and it calls fcoe_ctrl_set_set() with the correct
values in fcoe_ctlr_link_up().
It also breaks the association between FIP_MODE_AUTO and FIP_ST_AUTO
to indicate these two enums are distinct.

Link: https://github.com/ClangBuiltLinux/linux/issues/151
Fixes: 1917d42d14b7 ("fcoe: use enum for fip_mode")
Reported-by: Dmitry Golovin "Twisted Pair in my Hair" 
CC: Lukas Bulwahn 
CC: Nick Desaulniers 
CC: Nathan Chancellor 
Suggested-by: Johannes Thumshirn 
Signed-off-by: Sedat Dilek 
Signed-off-by: Hannes Reinecke 
---
 drivers/scsi/bnx2fc/bnx2fc_fcoe.c  | 2 +-
 drivers/scsi/fcoe/fcoe.c   | 2 +-
 drivers/scsi/fcoe/fcoe_ctlr.c  | 7 +--
 drivers/scsi/fcoe/fcoe_transport.c | 2 +-
 drivers/scsi/qedf/qedf_main.c  | 2 +-
 include/scsi/libfcoe.h | 4 ++--
 6 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c 
b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
index 2e4e7159ebf9..a75e74ad1698 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
@@ -1438,7 +1438,7 @@ static struct bnx2fc_hba *bnx2fc_hba_create(struct 
cnic_dev *cnic)
 static struct bnx2fc_interface *
 bnx2fc_interface_create(struct bnx2fc_hba *hba,
struct net_device *netdev,
-   enum fip_state fip_mode)
+   enum fip_mode fip_mode)
 {
struct fcoe_ctlr_device *ctlr_dev;
struct bnx2fc_interface *interface;
diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c
index cd19be3f3405..8ba8862d3292 100644
--- a/drivers/scsi/fcoe/fcoe.c
+++ b/drivers/scsi/fcoe/fcoe.c
@@ -389,7 +389,7 @@ static int fcoe_interface_setup(struct fcoe_interface *fcoe,
  * Returns: pointer to a struct fcoe_interface or NULL on error
  */
 static struct fcoe_interface *fcoe_interface_create(struct net_device *netdev,
-   enum fip_state fip_mode)
+   enum fip_mode fip_mode)
 {
struct fcoe_ctlr_device *ctlr_dev;
struct fcoe_ctlr *ctlr;
diff --git a/drivers/scsi/fcoe/fcoe_ctlr.c b/drivers/scsi/fcoe/fcoe_ctlr.c
index 54da3166da8d..7dc4ffa24430 100644
--- a/drivers/scsi/fcoe/fcoe_ctlr.c
+++ b/drivers/scsi/fcoe/fcoe_ctlr.c
@@ -147,7 +147,7 @@ static void fcoe_ctlr_map_dest(struct fcoe_ctlr *fip)
  * fcoe_ctlr_init() - Initialize the FCoE Controller instance
  * @fip: The FCoE controller to initialize
  */
-void fcoe_ctlr_init(struct fcoe_ctlr *fip, enum fip_state mode)
+void fcoe_ctlr_init(struct fcoe_ctlr *fip, enum fip_mode mode)
 {
fcoe_ctlr_set_state(fip, FIP_ST_LINK_WAIT);
fip->mode = mode;
@@ -454,7 +454,10 @@ void fcoe_ctlr_link_up(struct fcoe_ctlr *fip)
mutex_unlock(&fip->ctlr_mutex);
fc_linkup(fip->lp);
} else if (fip->state == FIP_ST_LINK_WAIT) {
-   fcoe_ctlr_set_state(fip, fip->mode);
+   if (fip->mode == FIP_MODE_NON_FIP)
+   fcoe_ctlr_set_state(fip, FIP_ST_NON_FIP);
+   else
+   fcoe_ctlr_set_state(fip, FIP_ST_AUTO);
switch (fip->mode) {
default:
LIBFCOE_FIP_DBG(fip, "invalid mode %d\n", fip->mode);
diff --git a/drivers/scsi/fcoe/fcoe_transport.c 
b/drivers/scsi/fcoe/fcoe_transport.c
index f4909cd206d3..b381ab066b9c 100644
--- a/drivers/scsi/fcoe/fcoe_transport.c
+++ b/drivers/scsi/fcoe/fcoe_transport.c
@@ -873,7 +873,7 @@ static int fcoe_transport_create(const char *buffer,
int rc = -ENODEV;
struct net_device *netdev = NULL;
struct fcoe_transport *ft = NULL;
-   enum fip_state fip_mode = (enum fip_state)(long)kp->arg;
+   enum fip_mode fip_mode = (enum fip_mode)(long)kp->arg;
 
mutex_lock(&ft_mutex);
 
diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c
index 9bbc19fc190b..9f9431a4cc0e 100644
--- a/drivers/scsi/qedf/qedf_main.c
+++ b/drivers/scsi/qedf/qedf_main.c
@@ -1418,7 +1418,7 @@ static struct libfc_function_template qedf_lport_template 
= {
 
 static void qedf_fcoe_ctlr_setup(struct qedf_ctx *qedf)
 {
-   fcoe_ctlr_init(&qedf->ctlr, FIP_ST_AUTO);
+   fcoe_ctlr_init(&q

Re: [PATCH] sd: disable logical block provisioning if 'lbpme' is not set

2019-02-15 Thread Bart Van Assche
On Thu, 2019-02-14 at 22:15 +0100, Jean Delvare wrote:
> From: Hannes Reinecke 
> 
> When evaluating the 'block limits' VPD page we need to check if
> the 'lbpme' (logical block provisioning management enable) bit
> is set in the READ CAPACITY (16) output.
> If it isn't we can safely assume that we cannot use DISCARD on
> this device.
> 
> [JD: forward-ported to kernel v4.20]
> 
> Signed-off-by: Hannes Reinecke 
> Signed-off-by: Jean Delvare 
> ---
> Hannes, please double-check that my forward-port is correct.
> 
>  drivers/scsi/sd.c |   11 ++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
> 
> --- a/drivers/scsi/sd.c
> +++ b/drivers/scsi/sd.c
> @@ -411,6 +411,13 @@ provisioning_mode_store(struct device *d
>   if (mode < 0)
>   return -EINVAL;
>  
> + /*
> +  * If logical block provisioning isn't enabled we can only
> +  * select 'disable' here.
> +  */
> + if (!sdkp->lbpme && mode != SD_LBP_DISABLE)
> + return -EINVAL;
> +
>   sd_config_discard(sdkp, mode);
>  
>   return count;
> @@ -2942,8 +2949,10 @@ static void sd_read_block_limits(struct
>  
>   sdkp->max_ws_blocks = (u32)get_unaligned_be64(&buffer[36]);
>  
> - if (!sdkp->lbpme)
> + if (!sdkp->lbpme) {
> + sd_config_discard(sdkp, SD_LBP_DISABLE);
>   goto out;
> + }
>  
>   lba_count = get_unaligned_be32(&buffer[20]);
>   desc_count = get_unaligned_be32(&buffer[24]);

What is the impact of this patch on SATA SSDs? Since these SSDs do not support
logical provisioning, does this patch break trim support for these SSDs?

Bart.


kernel panic in late shutdown stage (after syncing) in _scsih_set_satl_pending() in mpt3sas

2019-02-15 Thread Michal Soltys
Hi,

This basically happens on most shutdowns (and one of the ways to
ensure it happens always is to for example change i/o schedulers
after the boot via simple udev rules).

Normally (on successful shutdown), the very last things displayed right after
sync messages are "sending message unit reset !!", followed by "message unit 
reset: success".

On kernel panic, the following trace was captured via serial console (tested 
with recent 4.19 and 4.20 kernels):

[   41.563811] systemd-shutdown[1]: All filesystems unmounted.
[   41.591078] systemd-shutdown[1]: Deactivating swaps.
[   41.618557] systemd-shutdown[1]: All swaps deactivated.
[   41.646348] systemd-shutdown[1]: Detaching loop devices.
[   41.673201] systemd-shutdown[1]: All loop devices detached.
[   41.700853] systemd-shutdown[1]: Detaching DM devices.
[   42.765286] kvm: exiting hardware virtualization
[   42.790096] sd 2:0:0:0: [sds] Synchronizing SCSI cache
[   42.814967] sd 2:0:0:0: [sds] Stopping disk
[   43.585858] sd 0:0:16:0: [sdr] Synchronizing SCSI cache
[   43.610431] sd 0:0:15:0: [sdq] Synchronizing SCSI cache
[   43.635195] sd 0:0:14:0: [sdp] Synchronizing SCSI cache
[   43.659712] sd 0:0:13:0: [sdo] Synchronizing SCSI cache
[   43.684316] sd 0:0:12:0: [sdn] Synchronizing SCSI cache
[   43.708725] sd 0:0:11:0: [sdm] Synchronizing SCSI cache
[   43.732968] sd 0:0:10:0: [sdl] Synchronizing SCSI cache
[   43.756784] sd 0:0:9:0: [sdk] Synchronizing SCSI cache
[   43.780457] sd 0:0:8:0: [sdj] Synchronizing SCSI cache
[   43.804158] sd 0:0:7:0: [sdi] Synchronizing SCSI cache
[   43.887202] sd 0:0:6:0: [sdh] Synchronizing SCSI cache
[   43.910297] sd 0:0:5:0: [sdg] Synchronizing SCSI cache
[   43.933208] sd 0:0:4:0: [sdf] Synchronizing SCSI cache
[   43.960025] sd 0:0:3:0: [sde] Synchronizing SCSI cache
[   43.986534] sd 0:0:2:0: [sdd] Synchronizing SCSI cache
[   44.012309] sd 0:0:1:0: [sdc] Synchronizing SCSI cache
[   44.038061] sd 0:0:0:0: [sdb] Synchronizing SCSI cache
[   44.059414] sd 1:0:0:0: [sda] Synchronizing SCSI cache
[   44.082177] sd 1:0:0:0: [sda] Stopping disk
[   45.131598] general protection fault:  [#1] SMP NOPTI
[   45.152880] CPU: 4 PID: 1 Comm: systemd-shutdow Tainted: GE 
4.20.7 #2
[   45.176893] Hardware name: Supermicro X9DR7/E-(J)LN4F/X9DR7/E-(J)LN4F, BIOS 
3.3 07/13/2018
[   45.201312] RIP: 0010:_scsih_set_satl_pending+0xc/0x50 [mpt3sas]
[   45.224274] Code: c3 48 c1 ee 0b b8 20 00 00 00 ba 40 00 00 00 89 41 04 89 
11 31 c0 89 71 08 c3 0f 1f 40 00 0f 1f 44 00 00 48 8b 87 f8 00 00 00 <0f> b6 10 
80 fa a1 74 09 31 c0 80 fa 85 74 02 f3 c3 48 8b 47 38 40
[   45.279464] RSP: 0018:bb31000bfd58 EFLAGS: 00010202
[   45.303230] RAX: 5d8824840b49 RBX: 9179613c47b8 RCX: 
[   45.330342] RDX: 9179613c4680 RSI:  RDI: 9179613c47b8
[   45.358839] RBP: 0d48 R08: 0002 R09: bb31000bfd24
[   45.385354] R10:  R11: 2eaf R12: 91796d4d67a8
[   45.411901] R13: 0001 R14: 91796cd87110 R15: 
[   45.438156] FS:  7f59cdc31900() GS:917d6fa0() 
knlGS:
[   45.465301] CS:  0010 DS:  ES:  CR0: 80050033
[   45.490454] CR2: 7f3caf6258dc CR3: 00046b4f0006 CR4: 001606e0
[   45.517481] Call Trace:
[   45.539085]  _scsih_flush_running_cmds+0x41/0xc0 [mpt3sas]
[   45.567700]  scsih_shutdown+0x37/0xb0 [mpt3sas]
[   45.594390]  pci_device_shutdown+0x34/0x60
[   45.619163]  device_shutdown+0x15d/0x210
[   45.644653]  kernel_power_off+0x31/0x70
[   45.668895]  __do_sys_reboot+0x18f/0x210
[   45.694431]  ? do_sigtimedwait+0x1ec/0x220
[   45.718983]  ? do_writev+0x5e/0xf0
[   45.740803]  ? do_writev+0x5e/0xf0
[   45.762389]  do_syscall_64+0x55/0xf0
[   45.783393]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
[   45.806505] RIP: 0033:0x7f59cd765686
[   45.828537] Code: 48 83 c8 ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 
00 48 63 d7 be 69 19 12 28 48 c7 c7 ad de e1 fe b8 a9 00 00 00 0f 05 <48> 3d 00 
f0 ff ff 77 02 f3 c3 48 8b 15 e1 77 2b 00 f7 d8 64 89 02
[   45.886146] RSP: 002b:7ffe18fd6c88 EFLAGS: 0206 ORIG_RAX: 
00a9
[   45.914428] RAX: ffda RBX:  RCX: 7f59cd765686
[   45.943101] RDX: 4321fedc RSI: 28121969 RDI: fee1dead
[   45.971078] RBP:  R08: 0100 R09: 0005
[   46.000322] R10: 003d R11: 0206 R12: 7ffe18fd6d20
[   46.029825] R13: 5629faff6360 R14: 7ffe18fd6dc0 R15: 7ffe18fd7018
[   46.059573] Modules linked in: nls_ascii(E) nls_cp437(E) vfat(E) fat(E) 
intel_rapl(E) sb_edac(E) x86_pkg_temp_thermal(E) intel_powerclamp(E) 
coretemp(E) kvm_intel(E) kvm(E) irqbypass(E) crct10dif_pclmul(E) 
crc32_pclmul(E) ghash_clmulni_intel(E) aesni_intel(E) aes_x86_64(E) 
crypto_simd(E) cryptd(E) glue_helper(E) intel_cstate(E) iTCO_wdt(E) 
intel_uncore(E) iTCO_vendor_support(E) snd_pcm(E) ef

Re: [PATCHv4] fcoe: make use of fip_mode enum complete

2019-02-15 Thread Nick Desaulniers
On Fri, Feb 15, 2019 at 4:19 AM Hannes Reinecke  wrote:
>
> From: Sedat Dilek 
>
> commit 1917d42d14b7 ("fcoe: use enum for fip_mode") introduces a separate
> enum for the fip_mode that shall be used during initialisation handling
> until it is passed to fcoe_ctrl_link_up to set the initial fip_state.
> That change was incomplete and gcc quietly converted in various places
> between the fip_mode and the fip_state enum values with implicit enum
> conversions, which fortunately cannot cause any issues in the actual
> code's execution.
>
> clang however warns about these implicit enum conversions in the scsi
> drivers. This commit consolidates the use of the two enums, guided by
> clang's enum-conversion warnings.
>
> This commit now completes the use of the fip_mode:
> It expects and uses fip_mode in {bnx2fc,fcoe}_interface_create and
> fcoe_ctlr_init, and it calls fcoe_ctrl_set_set() with the correct
> values in fcoe_ctlr_link_up().
> It also breaks the association between FIP_MODE_AUTO and FIP_ST_AUTO
> to indicate these two enums are distinct.
>
> Link: https://github.com/ClangBuiltLinux/linux/issues/151
> Fixes: 1917d42d14b7 ("fcoe: use enum for fip_mode")
> Reported-by: Dmitry Golovin "Twisted Pair in my Hair" 
> CC: Lukas Bulwahn 
> CC: Nick Desaulniers 
> CC: Nathan Chancellor 
> Suggested-by: Johannes Thumshirn 
> Signed-off-by: Sedat Dilek 
> Signed-off-by: Hannes Reinecke 
> ---
>  drivers/scsi/bnx2fc/bnx2fc_fcoe.c  | 2 +-
>  drivers/scsi/fcoe/fcoe.c   | 2 +-
>  drivers/scsi/fcoe/fcoe_ctlr.c  | 7 +--
>  drivers/scsi/fcoe/fcoe_transport.c | 2 +-
>  drivers/scsi/qedf/qedf_main.c  | 2 +-
>  include/scsi/libfcoe.h | 4 ++--
>  6 files changed, 11 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c 
> b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
> index 2e4e7159ebf9..a75e74ad1698 100644
> --- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
> +++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
> @@ -1438,7 +1438,7 @@ static struct bnx2fc_hba *bnx2fc_hba_create(struct 
> cnic_dev *cnic)
>  static struct bnx2fc_interface *
>  bnx2fc_interface_create(struct bnx2fc_hba *hba,
> struct net_device *netdev,
> -   enum fip_state fip_mode)
> +   enum fip_mode fip_mode)
>  {
> struct fcoe_ctlr_device *ctlr_dev;
> struct bnx2fc_interface *interface;
> diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c
> index cd19be3f3405..8ba8862d3292 100644
> --- a/drivers/scsi/fcoe/fcoe.c
> +++ b/drivers/scsi/fcoe/fcoe.c
> @@ -389,7 +389,7 @@ static int fcoe_interface_setup(struct fcoe_interface 
> *fcoe,
>   * Returns: pointer to a struct fcoe_interface or NULL on error
>   */
>  static struct fcoe_interface *fcoe_interface_create(struct net_device 
> *netdev,
> -   enum fip_state fip_mode)
> +   enum fip_mode fip_mode)
>  {
> struct fcoe_ctlr_device *ctlr_dev;
> struct fcoe_ctlr *ctlr;
> diff --git a/drivers/scsi/fcoe/fcoe_ctlr.c b/drivers/scsi/fcoe/fcoe_ctlr.c
> index 54da3166da8d..7dc4ffa24430 100644
> --- a/drivers/scsi/fcoe/fcoe_ctlr.c
> +++ b/drivers/scsi/fcoe/fcoe_ctlr.c
> @@ -147,7 +147,7 @@ static void fcoe_ctlr_map_dest(struct fcoe_ctlr *fip)
>   * fcoe_ctlr_init() - Initialize the FCoE Controller instance
>   * @fip: The FCoE controller to initialize
>   */
> -void fcoe_ctlr_init(struct fcoe_ctlr *fip, enum fip_state mode)
> +void fcoe_ctlr_init(struct fcoe_ctlr *fip, enum fip_mode mode)
>  {
> fcoe_ctlr_set_state(fip, FIP_ST_LINK_WAIT);
> fip->mode = mode;
> @@ -454,7 +454,10 @@ void fcoe_ctlr_link_up(struct fcoe_ctlr *fip)
> mutex_unlock(&fip->ctlr_mutex);
> fc_linkup(fip->lp);
> } else if (fip->state == FIP_ST_LINK_WAIT) {
> -   fcoe_ctlr_set_state(fip, fip->mode);
> +   if (fip->mode == FIP_MODE_NON_FIP)
> +   fcoe_ctlr_set_state(fip, FIP_ST_NON_FIP);
> +   else
> +   fcoe_ctlr_set_state(fip, FIP_ST_AUTO);
> switch (fip->mode) {
> default:
> LIBFCOE_FIP_DBG(fip, "invalid mode %d\n", fip->mode);
> diff --git a/drivers/scsi/fcoe/fcoe_transport.c 
> b/drivers/scsi/fcoe/fcoe_transport.c
> index f4909cd206d3..b381ab066b9c 100644
> --- a/drivers/scsi/fcoe/fcoe_transport.c
> +++ b/drivers/scsi/fcoe/fcoe_transport.c
> @@ -873,7 +873,7 @@ static int fcoe_transport_create(const char *buffer,
> int rc = -ENODEV;
> struct net_device *netdev = NULL;
> struct fcoe_transport *ft = NULL;
> -   enum fip_state fip_mode = (enum fip_state)(long)kp->arg;
> +   enum fip_mode fip_mode = (enum fip_mode)(long)kp->arg;

Thanks so much for picking this up Hannes!  Sorry I didn't comment on
this until v4, but is the intermediate cast to long (before casting
again to the enum) necessary?  Aren't va

Re: [PATCHv4] fcoe: make use of fip_mode enum complete

2019-02-15 Thread Nathan Chancellor
On Fri, Feb 15, 2019 at 01:19:20PM +0100, Hannes Reinecke wrote:
> From: Sedat Dilek 
> 
> commit 1917d42d14b7 ("fcoe: use enum for fip_mode") introduces a separate
> enum for the fip_mode that shall be used during initialisation handling
> until it is passed to fcoe_ctrl_link_up to set the initial fip_state.
> That change was incomplete and gcc quietly converted in various places
> between the fip_mode and the fip_state enum values with implicit enum
> conversions, which fortunately cannot cause any issues in the actual
> code's execution.
> 
> clang however warns about these implicit enum conversions in the scsi
> drivers. This commit consolidates the use of the two enums, guided by
> clang's enum-conversion warnings.
> 
> This commit now completes the use of the fip_mode:
> It expects and uses fip_mode in {bnx2fc,fcoe}_interface_create and
> fcoe_ctlr_init, and it calls fcoe_ctrl_set_set() with the correct
> values in fcoe_ctlr_link_up().
> It also breaks the association between FIP_MODE_AUTO and FIP_ST_AUTO
> to indicate these two enums are distinct.
> 
> Link: https://github.com/ClangBuiltLinux/linux/issues/151
> Fixes: 1917d42d14b7 ("fcoe: use enum for fip_mode")
> Reported-by: Dmitry Golovin "Twisted Pair in my Hair" 
> CC: Lukas Bulwahn 
> CC: Nick Desaulniers 
> CC: Nathan Chancellor 
> Suggested-by: Johannes Thumshirn 
> Signed-off-by: Sedat Dilek 
> Signed-off-by: Hannes Reinecke 

Reviewed-by: Nathan Chancellor 
Tested-by: Nathan Chancellor 

As a side note, I think Lukas deserves a little more credit than just a
CC, most of the commit message wording and patch content is his. At the
least, a link to the original patch:

https://lore.kernel.org/lkml/20190112053427.35696-1-lukas.bulw...@gmail.com/

Cheers,
Nathan

> ---
>  drivers/scsi/bnx2fc/bnx2fc_fcoe.c  | 2 +-
>  drivers/scsi/fcoe/fcoe.c   | 2 +-
>  drivers/scsi/fcoe/fcoe_ctlr.c  | 7 +--
>  drivers/scsi/fcoe/fcoe_transport.c | 2 +-
>  drivers/scsi/qedf/qedf_main.c  | 2 +-
>  include/scsi/libfcoe.h | 4 ++--
>  6 files changed, 11 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c 
> b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
> index 2e4e7159ebf9..a75e74ad1698 100644
> --- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
> +++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
> @@ -1438,7 +1438,7 @@ static struct bnx2fc_hba *bnx2fc_hba_create(struct 
> cnic_dev *cnic)
>  static struct bnx2fc_interface *
>  bnx2fc_interface_create(struct bnx2fc_hba *hba,
>   struct net_device *netdev,
> - enum fip_state fip_mode)
> + enum fip_mode fip_mode)
>  {
>   struct fcoe_ctlr_device *ctlr_dev;
>   struct bnx2fc_interface *interface;
> diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c
> index cd19be3f3405..8ba8862d3292 100644
> --- a/drivers/scsi/fcoe/fcoe.c
> +++ b/drivers/scsi/fcoe/fcoe.c
> @@ -389,7 +389,7 @@ static int fcoe_interface_setup(struct fcoe_interface 
> *fcoe,
>   * Returns: pointer to a struct fcoe_interface or NULL on error
>   */
>  static struct fcoe_interface *fcoe_interface_create(struct net_device 
> *netdev,
> - enum fip_state fip_mode)
> + enum fip_mode fip_mode)
>  {
>   struct fcoe_ctlr_device *ctlr_dev;
>   struct fcoe_ctlr *ctlr;
> diff --git a/drivers/scsi/fcoe/fcoe_ctlr.c b/drivers/scsi/fcoe/fcoe_ctlr.c
> index 54da3166da8d..7dc4ffa24430 100644
> --- a/drivers/scsi/fcoe/fcoe_ctlr.c
> +++ b/drivers/scsi/fcoe/fcoe_ctlr.c
> @@ -147,7 +147,7 @@ static void fcoe_ctlr_map_dest(struct fcoe_ctlr *fip)
>   * fcoe_ctlr_init() - Initialize the FCoE Controller instance
>   * @fip: The FCoE controller to initialize
>   */
> -void fcoe_ctlr_init(struct fcoe_ctlr *fip, enum fip_state mode)
> +void fcoe_ctlr_init(struct fcoe_ctlr *fip, enum fip_mode mode)
>  {
>   fcoe_ctlr_set_state(fip, FIP_ST_LINK_WAIT);
>   fip->mode = mode;
> @@ -454,7 +454,10 @@ void fcoe_ctlr_link_up(struct fcoe_ctlr *fip)
>   mutex_unlock(&fip->ctlr_mutex);
>   fc_linkup(fip->lp);
>   } else if (fip->state == FIP_ST_LINK_WAIT) {
> - fcoe_ctlr_set_state(fip, fip->mode);
> + if (fip->mode == FIP_MODE_NON_FIP)
> + fcoe_ctlr_set_state(fip, FIP_ST_NON_FIP);
> + else
> + fcoe_ctlr_set_state(fip, FIP_ST_AUTO);
>   switch (fip->mode) {
>   default:
>   LIBFCOE_FIP_DBG(fip, "invalid mode %d\n", fip->mode);
> diff --git a/drivers/scsi/fcoe/fcoe_transport.c 
> b/drivers/scsi/fcoe/fcoe_transport.c
> index f4909cd206d3..b381ab066b9c 100644
> --- a/drivers/scsi/fcoe/fcoe_transport.c
> +++ b/drivers/scsi/fcoe/fcoe_transport.c
> @@ -873,7 +873,7 @@ static int fcoe_transport_create(const char *buffer,
>   int rc = -ENODEV;
>   struct net_device *netdev = NULL;
>   struct fcoe_transport *ft = NULL;
> - e

Re: [PATCH V2 0/7] Add FOLL_LONGTERM to GUP fast and use it

2019-02-15 Thread Ira Weiny
> NOTE: This series depends on my clean up patch to remove the write parameter
> from gup_fast_permitted()[1]
> 
> HFI1, qib, and mthca, use get_user_pages_fast() due to it performance
> advantages.  These pages can be held for a significant time.  But
> get_user_pages_fast() does not protect against mapping of FS DAX pages.
> 
> Introduce FOLL_LONGTERM and use this flag in get_user_pages_fast() which
> retains the performance while also adding the FS DAX checks.  XDP has also
> shown interest in using this functionality.[2]
> 
> In addition we change get_user_pages() to use the new FOLL_LONGTERM flag and
> remove the specialized get_user_pages_longterm call.
> 
> [1] https://lkml.org/lkml/2019/2/11/237
> [2] https://lkml.org/lkml/2019/2/11/1789

Any comments on this series?  I've touched a lot of subsystems which I think
require review.

Thanks,
Ira

> 
> Ira Weiny (7):
>   mm/gup: Replace get_user_pages_longterm() with FOLL_LONGTERM
>   mm/gup: Change write parameter to flags in fast walk
>   mm/gup: Change GUP fast to use flags rather than a write 'bool'
>   mm/gup: Add FOLL_LONGTERM capability to GUP fast
>   IB/hfi1: Use the new FOLL_LONGTERM flag to get_user_pages_fast()
>   IB/qib: Use the new FOLL_LONGTERM flag to get_user_pages_fast()
>   IB/mthca: Use the new FOLL_LONGTERM flag to get_user_pages_fast()
> 
>  arch/mips/mm/gup.c  |  11 +-
>  arch/powerpc/kvm/book3s_64_mmu_hv.c |   4 +-
>  arch/powerpc/kvm/e500_mmu.c |   2 +-
>  arch/powerpc/mm/mmu_context_iommu.c |   4 +-
>  arch/s390/kvm/interrupt.c   |   2 +-
>  arch/s390/mm/gup.c  |  12 +-
>  arch/sh/mm/gup.c|  11 +-
>  arch/sparc/mm/gup.c |   9 +-
>  arch/x86/kvm/paging_tmpl.h  |   2 +-
>  arch/x86/kvm/svm.c  |   2 +-
>  drivers/fpga/dfl-afu-dma-region.c   |   2 +-
>  drivers/gpu/drm/via/via_dmablit.c   |   3 +-
>  drivers/infiniband/core/umem.c  |   5 +-
>  drivers/infiniband/hw/hfi1/user_pages.c |   5 +-
>  drivers/infiniband/hw/mthca/mthca_memfree.c |   3 +-
>  drivers/infiniband/hw/qib/qib_user_pages.c  |   8 +-
>  drivers/infiniband/hw/qib/qib_user_sdma.c   |   2 +-
>  drivers/infiniband/hw/usnic/usnic_uiom.c|   9 +-
>  drivers/media/v4l2-core/videobuf-dma-sg.c   |   6 +-
>  drivers/misc/genwqe/card_utils.c|   2 +-
>  drivers/misc/vmw_vmci/vmci_host.c   |   2 +-
>  drivers/misc/vmw_vmci/vmci_queue_pair.c |   6 +-
>  drivers/platform/goldfish/goldfish_pipe.c   |   3 +-
>  drivers/rapidio/devices/rio_mport_cdev.c|   4 +-
>  drivers/sbus/char/oradax.c  |   2 +-
>  drivers/scsi/st.c   |   3 +-
>  drivers/staging/gasket/gasket_page_table.c  |   4 +-
>  drivers/tee/tee_shm.c   |   2 +-
>  drivers/vfio/vfio_iommu_spapr_tce.c |   3 +-
>  drivers/vfio/vfio_iommu_type1.c |   3 +-
>  drivers/vhost/vhost.c   |   2 +-
>  drivers/video/fbdev/pvr2fb.c|   2 +-
>  drivers/virt/fsl_hypervisor.c   |   2 +-
>  drivers/xen/gntdev.c|   2 +-
>  fs/orangefs/orangefs-bufmap.c   |   2 +-
>  include/linux/mm.h  |  17 +-
>  kernel/futex.c  |   2 +-
>  lib/iov_iter.c  |   7 +-
>  mm/gup.c| 220 
>  mm/gup_benchmark.c  |   5 +-
>  mm/util.c   |   8 +-
>  net/ceph/pagevec.c  |   2 +-
>  net/rds/info.c  |   2 +-
>  net/rds/rdma.c  |   3 +-
>  44 files changed, 232 insertions(+), 180 deletions(-)
> 
> -- 
> 2.20.1
> 


[GIT PULL] SCSI fixes for 5.0-rc

2019-02-15 Thread James Bottomley
Two fairly small fixes: the qla one is a panic inducing use after free
and the entropy fix may seem minor but it has had huge userspace impact
thanks to an unrelated change in openssl that causes sshd to refuse
logins until it has enough entropy for the session keys, which causes
tens of minutes delay before the affected systems allow logins after
reboot.

The patch is available here:

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

The short changelog is:

Bill Kuzeja (1):
  scsi: qla2xxx: Fix panic from use after free in qla2x00_async_tm_cmd

James Bottomley (1):
  scsi: sd: fix entropy gathering for most rotational disks

And the diffstat:

 drivers/scsi/qla2xxx/qla_init.c |  4 ++--
 drivers/scsi/sd.c   | 12 +---
 2 files changed, 11 insertions(+), 5 deletions(-)

With full diff below.

James

---

diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index 364bb52ed2a6..109587e62983 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -1785,13 +1785,13 @@ qla2x00_async_tm_cmd(fc_port_t *fcport, uint32_t flags, 
uint32_t lun,
 
/* Issue Marker IOCB */
qla2x00_marker(vha, vha->hw->req_q_map[0],
-   vha->hw->rsp_q_map[0], sp->fcport->loop_id, lun,
+   vha->hw->rsp_q_map[0], fcport->loop_id, lun,
flags == TCF_LUN_RESET ? MK_SYNC_ID_LUN : MK_SYNC_ID);
}
 
 done_free_sp:
sp->free(sp);
-   sp->fcport->flags &= ~FCF_ASYNC_SENT;
+   fcport->flags &= ~FCF_ASYNC_SENT;
 done:
return rval;
 }
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index b2da8a00ec33..5464d467e23e 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -2951,9 +2951,6 @@ static void sd_read_block_characteristics(struct 
scsi_disk *sdkp)
if (rot == 1) {
blk_queue_flag_set(QUEUE_FLAG_NONROT, q);
blk_queue_flag_clear(QUEUE_FLAG_ADD_RANDOM, q);
-   } else {
-   blk_queue_flag_clear(QUEUE_FLAG_NONROT, q);
-   blk_queue_flag_set(QUEUE_FLAG_ADD_RANDOM, q);
}
 
if (sdkp->device->type == TYPE_ZBC) {
@@ -3090,6 +3087,15 @@ static int sd_revalidate_disk(struct gendisk *disk)
if (sdkp->media_present) {
sd_read_capacity(sdkp, buffer);
 
+   /*
+* set the default to rotational.  All non-rotational devices
+* support the block characteristics VPD page, which will
+* cause this to be updated correctly and any device which
+* doesn't support it should be treated as rotational.
+*/
+   blk_queue_flag_clear(QUEUE_FLAG_NONROT, q);
+   blk_queue_flag_set(QUEUE_FLAG_ADD_RANDOM, q);
+
if (scsi_device_supports_vpd(sdp)) {
sd_read_block_provisioning(sdkp);
sd_read_block_limits(sdkp);


Re: [PATCH] scsi: libsas: Fix rphy phy_identifier for PHYs with end devices attached

2019-02-15 Thread dann frazier
On Fri, Feb 15, 2019 at 12:37:57AM +0800, John Garry wrote:
> The sysfs phy_identifier attribute for a sas_end_device comes
> from the rphy phy_identifier value.
> 
> Currently this is not being set for rphys with an end device attached,
> so we see incorrect symlinks from systemd disk/by-path:
> 
> root@localhost:~# ls -l /dev/disk/by-path/
> total 0
> lrwxrwxrwx 1 root root  9 Feb 13 12:26 
> platform-HISI0162:01-sas-exp0x500e004aaa1f-phy0-lun-0 -> ../../sdb
> lrwxrwxrwx 1 root root 10 Feb 13 12:26 
> platform-HISI0162:01-sas-exp0x500e004aaa1f-phy0-lun-0-part1 -> ../../sdb1
> lrwxrwxrwx 1 root root 10 Feb 13 12:26 
> platform-HISI0162:01-sas-exp0x500e004aaa1f-phy0-lun-0-part2 -> ../../sdb2
> lrwxrwxrwx 1 root root 10 Feb 13 12:26 
> platform-HISI0162:01-sas-exp0x500e004aaa1f-phy0-lun-0-part3 -> ../../sdc3
> 
> Indeed, each sas_end_device phy_identifier value is 0:
> 
> root@localhost:/# more sys/class/sas_device/end_device-0\:0\:2/phy_identifier
> 0
> root@localhost:/# more sys/class/sas_device/end_device-0\:0\:10/phy_identifier
> 0
> 
> This patch fixes the discovery code to set the phy_identifier.
> With this, we now get proper symlinks:
> 
> root@localhost:~# ls -l /dev/disk/by-path/
> total 0
> lrwxrwxrwx 1 root root  9 Feb 13 11:53 
> platform-HISI0162:01-sas-exp0x500e004aaa1f-phy10-lun-0 -> ../../sdg
> lrwxrwxrwx 1 root root  9 Feb 13 11:53 
> platform-HISI0162:01-sas-exp0x500e004aaa1f-phy11-lun-0 -> ../../sdh
> lrwxrwxrwx 1 root root  9 Feb 13 11:53 
> platform-HISI0162:01-sas-exp0x500e004aaa1f-phy2-lun-0 -> ../../sda
> lrwxrwxrwx 1 root root 10 Feb 13 11:53 
> platform-HISI0162:01-sas-exp0x500e004aaa1f-phy2-lun-0-part1 -> ../../sda1
> lrwxrwxrwx 1 root root  9 Feb 13 11:53 
> platform-HISI0162:01-sas-exp0x500e004aaa1f-phy3-lun-0 -> ../../sdb
> lrwxrwxrwx 1 root root 10 Feb 13 11:53 
> platform-HISI0162:01-sas-exp0x500e004aaa1f-phy3-lun-0-part1 -> ../../sdb1
> lrwxrwxrwx 1 root root 10 Feb 13 11:53 
> platform-HISI0162:01-sas-exp0x500e004aaa1f-phy3-lun-0-part2 -> ../../sdb2
> lrwxrwxrwx 1 root root  9 Feb 13 11:53 
> platform-HISI0162:01-sas-exp0x500e004aaa1f-phy4-lun-0 -> ../../sdc
> lrwxrwxrwx 1 root root 10 Feb 13 11:53 
> platform-HISI0162:01-sas-exp0x500e004aaa1f-phy4-lun-0-part1 -> ../../sdc1
> lrwxrwxrwx 1 root root 10 Feb 13 11:53 
> platform-HISI0162:01-sas-exp0x500e004aaa1f-phy4-lun-0-part2 -> ../../sdc2
> lrwxrwxrwx 1 root root 10 Feb 13 11:53 
> platform-HISI0162:01-sas-exp0x500e004aaa1f-phy4-lun-0-part3 -> ../../sdc3
> lrwxrwxrwx 1 root root  9 Feb 13 11:53 
> platform-HISI0162:01-sas-exp0x500e004aaa1f-phy5-lun-0 -> ../../sdd
> lrwxrwxrwx 1 root root  9 Feb 13 11:53 
> platform-HISI0162:01-sas-exp0x500e004aaa1f-phy7-lun-0 -> ../../sde
> lrwxrwxrwx 1 root root 10 Feb 13 11:53 
> platform-HISI0162:01-sas-exp0x500e004aaa1f-phy7-lun-0-part1 -> ../../sde1
> lrwxrwxrwx 1 root root 10 Feb 13 11:53 
> platform-HISI0162:01-sas-exp0x500e004aaa1f-phy7-lun-0-part2 -> ../../sde2
> lrwxrwxrwx 1 root root 10 Feb 13 11:53 
> platform-HISI0162:01-sas-exp0x500e004aaa1f-phy7-lun-0-part3 -> ../../sde3
> lrwxrwxrwx 1 root root  9 Feb 13 11:53 
> platform-HISI0162:01-sas-exp0x500e004aaa1f-phy8-lun-0 -> ../../sdf
> lrwxrwxrwx 1 root root 10 Feb 13 11:53 
> platform-HISI0162:01-sas-exp0x500e004aaa1f-phy8-lun-0-part1 -> ../../sdf1
> lrwxrwxrwx 1 root root 10 Feb 13 11:53 
> platform-HISI0162:01-sas-exp0x500e004aaa1f-phy8-lun-0-part2 -> ../../sdf2
> lrwxrwxrwx 1 root root 10 Feb 13 11:53 
> platform-HISI0162:01-sas-exp0x500e004aaa1f-phy8-lun-0-part3 -> ../../sdf3
> 
> Fixes: 2908d778ab3e ("[SCSI] aic94xx: new driver")
> Reported-by: dann frazier 

Thanks John. Solves the problem for me as well.

Tested-by: dann frazier 

  -dann

> Signed-off-by: John Garry 
> 
> diff --git a/drivers/scsi/libsas/sas_expander.c 
> b/drivers/scsi/libsas/sas_expander.c
> index 17eb4185f29d..f21c93bbb35c 100644
> --- a/drivers/scsi/libsas/sas_expander.c
> +++ b/drivers/scsi/libsas/sas_expander.c
> @@ -828,6 +828,7 @@ static struct domain_device *sas_ex_discover_end_dev(
>   rphy = sas_end_device_alloc(phy->port);
>   if (!rphy)
>   goto out_free;
> + rphy->identify.phy_identifier = phy_id;
>  
>   child->rphy = rphy;
>   get_device(&rphy->dev);
> @@ -854,6 +855,7 @@ static struct domain_device *sas_ex_discover_end_dev(
>  
>   child->rphy = rphy;
>   get_device(&rphy->dev);
> + rphy->identify.phy_identifier = phy_id;
>   sas_fill_in_rphy(child, rphy);
>  
>   list_add_tail(&child->disco_list_node, 
> &parent->port->disco_list);


Re: [GIT PULL] SCSI fixes for 5.0-rc

2019-02-15 Thread pr-tracker-bot
The pull request you sent on Fri, 15 Feb 2019 11:17:11 -0800:

> git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git scsi-fixes

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/5ded5871030eb75017639148da0a58931dfbfc25

Thank you!

-- 
Deet-doot-dot, I am a bot.
https://korg.wiki.kernel.org/userdoc/prtracker


[PATCH] scsi: aacraid: Fix missing break in switch statement

2019-02-15 Thread Gustavo A. R. Silva
Add missing break statement and fix identation issue.

This bug was found thanks to the ongoing efforts to enable
-Wimplicit-fallthrough.

Fixes: 9cb62fa24e0d ("aacraid: Log firmware AIF messages")
Cc: sta...@vger.kernel.org
Signed-off-by: Gustavo A. R. Silva 
---
 drivers/scsi/aacraid/commsup.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/aacraid/commsup.c b/drivers/scsi/aacraid/commsup.c
index 0bdc6b0f725f..e67e032936ef 100644
--- a/drivers/scsi/aacraid/commsup.c
+++ b/drivers/scsi/aacraid/commsup.c
@@ -1303,8 +1303,9 @@ static void aac_handle_aif(struct aac_dev * dev, struct 
fib * fibptr)
  ADD : DELETE;
break;
}
-   case AifBuManagerEvent:
-   aac_handle_aif_bu(dev, aifcmd);
+   break;
+   case AifBuManagerEvent:
+   aac_handle_aif_bu(dev, aifcmd);
break;
}
 
-- 
2.20.1



Re: [RESEND PATCH] libiscsi: Fix race between iscsi_xmit_task and iscsi_complete_task

2019-02-15 Thread Lee Duncan
On 2/12/19 9:21 PM, Bob Liu wrote:
> From: Anoob Soman 
> 
> When a target sends Check Condition, whilst initiator is busy xmiting
> re-queued data, could lead to race between iscsi_complete_task() and
> iscsi_xmit_task() and eventually crashing with the following kernel
> backtrace.
> 
> [3326150.987523] ALERT: BUG: unable to handle kernel NULL pointer dereference 
> at 0078
> [3326150.987549] ALERT: IP: [] iscsi_xmit_task+0x2d/0xc0 
> [libiscsi]
> [3326150.987571] WARN: PGD 569c8067 PUD 569c9067 PMD 0
> [3326150.987582] WARN: Oops: 0002 [#1] SMP
> [3326150.987593] WARN: Modules linked in: tun nfsv3 nfs fscache dm_round_robin
> [3326150.987762] WARN: CPU: 2 PID: 8399 Comm: kworker/u32:1 Tainted: G O 
> 4.4.0+2 #1
> [3326150.987774] WARN: Hardware name: Dell Inc. PowerEdge R720/0W7JN5, BIOS 
> 2.5.4 01/22/2016
> [3326150.987790] WARN: Workqueue: iscsi_q_13 iscsi_xmitworker [libiscsi]
> [3326150.987799] WARN: task: 8801d50f3800 ti: 8801f5458000 task.ti: 
> 8801f5458000
> [3326150.987810] WARN: RIP: e030:[] [] 
> iscsi_xmit_task+0x2d/0xc0 [libiscsi]
> [3326150.987825] WARN: RSP: e02b:8801f545bdb0 EFLAGS: 00010246
> [3326150.987831] WARN: RAX: ffc3 RBX: 880282d2ab20 RCX: 
> 88026b6ac480
> [3326150.987842] WARN: RDX:  RSI: fe01 RDI: 
> 880282d2ab20
> [3326150.987852] WARN: RBP: 8801f545bdc8 R08:  R09: 
> 0008
> [3326150.987862] WARN: R10:  R11: fe88 R12: 
> 
> [3326150.987872] WARN: R13: 880282d2abe8 R14: 880282d2abd8 R15: 
> 880282d2ac08
> [3326150.987890] WARN: FS: 7f5a866b4840() GS:88028a64() 
> knlGS:
> [3326150.987900] WARN: CS: e033 DS:  ES:  CR0: 80050033
> [3326150.987907] WARN: CR2: 0078 CR3: 70244000 CR4: 
> 00042660
> [3326150.987918] WARN: Stack:
> [3326150.987924] WARN: 880282d2ad58 880282d2ab20 880282d2abe8 
> 8801f545be18
> [3326150.987938] WARN: a05cea90 880282d2abf8 88026b59cc80 
> 88026b59cc00
> [3326150.987951] WARN: 88022acf32c0 880289491800 880255a80800 
> 0400
> [3326150.987964] WARN: Call Trace:
> [3326150.987975] WARN: [] iscsi_xmitworker+0x2f0/0x360 
> [libiscsi]
> [3326150.987988] WARN: [] process_one_work+0x1fc/0x3b0
> [3326150.987997] WARN: [] worker_thread+0x2a5/0x470
> [3326150.988006] WARN: [] ? __schedule+0x648/0x870
> [3326150.988015] WARN: [] ? rescuer_thread+0x300/0x300
> [3326150.988023] WARN: [] kthread+0xd5/0xe0
> [3326150.988031] WARN: [] ? kthread_stop+0x110/0x110
> [3326150.988040] WARN: [] ret_from_fork+0x3f/0x70
> [3326150.988048] WARN: [] ? kthread_stop+0x110/0x110
> [3326150.988127] ALERT: RIP [] iscsi_xmit_task+0x2d/0xc0 
> [libiscsi]
> [3326150.988138] WARN: RSP 
> [3326150.988144] WARN: CR2: 0078
> [3326151.020366] WARN: ---[ end trace 1c60974d4678d81b ]---
> 
> Commit 6f8830f5bbab (scsi: libiscsi: add lock around task lists to fix list
> corruption regression) introduced "taskqueuelock" to fix list corruption 
> during
> the race, but this wasn't enough.
> 
> Re-setting of conn->task to NULL, could race with iscsi_xmit_task().
> iscsi_complete_task()
> {
> 
> if (conn->task == task)
> conn->task = NULL;
> }
> 
> conn->task in iscsi_xmit_task() could be NULL and so will be task.
> __iscsi_get_task(task) will crash (NullPtr de-ref), trying to access refcount.
> 
> iscsi_xmit_task()
> {
> struct iscsi_task *task = conn->task;
> 
> __iscsi_get_task(task);
> }
> 
> This commit will take extra conn->session->back_lock in iscsi_xmit_task()
> to ensure iscsi_xmit_task() waits for iscsi_complete_task(), if
> iscsi_complete_task() wins the race.
> If iscsi_xmit_task() wins the race, iscsi_xmit_task() increments 
> task->refcount
> (__iscsi_get_task) ensuring iscsi_complete_task() will not iscsi_free_task().
> 
> Signed-off-by: Anoob Soman 
> Signed-off-by: Bob Liu 
> ---
>  drivers/scsi/libiscsi.c | 6 ++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
> index b8d325ce8754..120fc520f27a 100644
> --- a/drivers/scsi/libiscsi.c
> +++ b/drivers/scsi/libiscsi.c
> @@ -1459,7 +1459,13 @@ static int iscsi_xmit_task(struct iscsi_conn *conn)
>   if (test_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx))
>   return -ENODATA;
>  
> + spin_lock_bh(&conn->session->back_lock);
> + if (conn->task == NULL) {
> + spin_unlock_bh(&conn->session->back_lock);
> + return -ENODATA;
> + }
>   __iscsi_get_task(task);
> + spin_unlock_bh(&conn->session->back_lock);
>   spin_unlock_bh(&conn->session->frwd_lock);
>   rc = conn->session->tt->xmit_task(task);
>   spin_lock_bh(&conn->session->frwd_lock);
> 

Signed-off-by: Lee Duncan 


Re: [PATCH 1/5] libiscsi: Use scsi_[gs]et_resid() where appropriate

2019-02-15 Thread Lee Duncan
On 2/8/19 1:24 PM, Bart Van Assche wrote:
> This patch does not change any functionality.
> 
> Cc: Lee Duncan 
> Cc: Chris Leech 
> Signed-off-by: Bart Van Assche 
> ---
>  drivers/scsi/libiscsi.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
> index bca3a8636c27..dd314d2b 100644
> --- a/drivers/scsi/libiscsi.c
> +++ b/drivers/scsi/libiscsi.c
> @@ -915,7 +915,7 @@ iscsi_data_in_rsp(struct iscsi_conn *conn, struct 
> iscsi_hdr *hdr,
>   if (res_count > 0 &&
>   (rhdr->flags & ISCSI_FLAG_CMD_OVERFLOW ||
>res_count <= sc->sdb.length))
> - sc->sdb.resid = res_count;
> + scsi_set_resid(sc, res_count);
>   else
>   sc->result = (DID_BAD_TARGET << 16) | rhdr->cmd_status;
>   }
> 

Reviewed-by: Lee Duncan 


Re: [LSF/MM TOPIC] : blktests: status, an expansion plan for the storage stack test framework

2019-02-15 Thread Lee Duncan
On 2/6/19 2:32 AM, Johannes Thumshirn wrote:
> On 06/02/2019 06:21, Chaitanya Kulkarni wrote:
>> Hi,
>>
>> Since discussion of the storage stack and device driver at the LSFMM 2017
>> (https://lwn.net/Articles/717699/),  Omar Sandoval introduced a new framework
>> "blktests" dedicated for Linux Kernel Block layer testing.
>> (https://lwn.net/Articles/722785/, https://github.com/osandov/blktests).
>>  
>> As Linux Kernel Block layer is central to the various file systems and 
>> underlying
>> low-level device drivers it is important to have a centralized testing 
>> framework and
>> make sure it grows with the latest block layer changed which are being added 
>> based
>> on the different device features from different device types
>> (e.g. NVMe devices with Zoned Namespace support).
>>
>> Since then blktests has grown and became go-to framework where we have 
>> integrated
>> different stand-alone test suites like SRP-tests, NVMFTESTS, NVMe Multipath 
>> tests,
>> zone block device tests, into one central framework, which has made an 
>> overall block layer
>> testing and development much easier than having to configure and execute 
>> different
>> test cases for each kernel release for different subsystems such as FS, NVMe,
>> Zone Block devices, etc). 
>>
>> Here is the list of the existing test categories:-
>>
>> ├── block                                           28 Tests
>> ├── loop                                             07 Tests
>> ├── meta                                            12 Tests
>> ├── nbd                                              02 Tests
>> ├── nvme                                           28 Tests
>> ├── nvmeof-mp                                  12 Tests
>> ├── scsi                                              06 Tests
>> ├── srp                                               13 Tests
>> └── zbd                                              05 Tests
>>  
>>9 Categories                ~110 Tests
>>
>> This project has gathered much attention and storage stack community is 
>> actively
>> participating and adding new test cases with different categories to the 
>> framework. 
>>
>> For storage track, we would like to propose a session dedicated to blktests. 
>> It is a great
>> opportunity for the storage developers to gather and have a discussion 
>> about:-
>>
>> 1. Current status of the blktests framework.
>> 2. Any new/missing features that we want to add in the blktests.
>> 3. Any new kernel features that could be used to make testing easier?
>> E.g. Implementing new features in the null_blk.c in order to have device
>> independent complete test coverage. (e.g. adding discard command for 
>> null_blk or any
>> other specific REQ_OP). Discussion about having any new tracepoint events in 
>> the block layer.
>> 4. Any new test cases/categories which are lacking in the blktests framework.
> 
> One thing I'd love to see is more hardware/driver specific tests. I'm
> sure Broadcom, Marvell, Huawei and all the others out there do have test
> suites for their HBA drivers but not a single one of these tests is
> publicly available.

I said this same thing 3 (?) years ago, but then I was told to go out
and solve it. :) Dealing with multiple manufactures could be a full-time
job.

> 
> We're also lacking tests for things like ioprio, persistent reservation,
> bcache and so on.

I have a test suite for persistent reservations, but would love help in
adding it to this test suite.

> 
> Adding support for collecting gcov information after running a test case
> would also be awesome (this is missing in xfstests as well).
> 
> So I think a session on blktests can help us get the gap closed.
> 
> Byte,
>   Johannes
> 

I also would love to attend such a session.
-- 
Lee Duncan


Re: [PATCH][V2] scsi: qla2xxx: remove redundant null check on pointer sess

2019-02-15 Thread Himanshu Madhani
Hi Colin,

On 2/15/19, 1:52 AM, "Colin King"  wrote:

External Email

From: Colin Ian King 

The null check on pointer sess and the subsequent call is redundant
as sess is null on all the the paths that lead to the out_term2 label.
Hence the null check and the call can be removed.  Also remove the
redundant setting of sess to NULL as this is not required now.

Detected by CoverityScan, CID#1420663 ("Logically dead code")

Signed-off-by: Colin Ian King 
---

V2: Remove the redundant settings of sess to NULL, thanks to
Dan Carpenter for spotting this.

---
 drivers/scsi/qla2xxx/qla_target.c | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_target.c 
b/drivers/scsi/qla2xxx/qla_target.c
index 6b8c655d9eb4..33131446b327 100644
--- a/drivers/scsi/qla2xxx/qla_target.c
+++ b/drivers/scsi/qla2xxx/qla_target.c
@@ -6343,7 +6343,7 @@ static void qlt_tmr_work(struct qla_tgt *tgt,
struct atio_from_isp *a = &prm->tm_iocb2;
struct scsi_qla_host *vha = tgt->vha;
struct qla_hw_data *ha = vha->hw;
-   struct fc_port *sess = NULL;
+   struct fc_port *sess;
unsigned long flags;
uint8_t *s_id = NULL; /* to hide compiler warnings */
int rc;
@@ -6369,7 +6369,6 @@ static void qlt_tmr_work(struct qla_tgt *tgt,
goto out_term2;
} else {
if (sess->deleted) {
-   sess = NULL;
goto out_term2;
}

@@ -6377,7 +6376,6 @@ static void qlt_tmr_work(struct qla_tgt *tgt,
ql_dbg(ql_dbg_tgt_tmr, vha, 0xf020,
"%s: kref_get fail %8phC\n",
 __func__, sess->port_name);
-   sess = NULL;
goto out_term2;
}
}
@@ -6396,8 +6394,6 @@ static void qlt_tmr_work(struct qla_tgt *tgt,
return;

 out_term2:
-   if (sess)
-   ha->tgt.tgt_ops->put_sess(sess);
spin_unlock_irqrestore(&ha->tgt.sess_lock, flags);
 out_term:
qlt_send_term_exchange(ha->base_qpair, NULL, &prm->tm_iocb2, 1, 0);
--
2.20.1

Thanks for the Patch. Looks good

Acked-by: Himanshu Madhani 




[PATCH v3 09/11] qla2xxx: Fix code indentation for qla27xx_fwdt_entry

2019-02-15 Thread Himanshu Madhani
This patch fixes following checkpatch ERROR

 ERROR: space prohibited before that ',' (ctx:WxW)

No change is functionality due to this patch.

Signed-off-by: Himanshu Madhani 
---
 drivers/scsi/qla2xxx/qla_tmpl.c | 46 -
 1 file changed, 23 insertions(+), 23 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_tmpl.c b/drivers/scsi/qla2xxx/qla_tmpl.c
index 0ccd06f11f12..f0c7c0c75ef7 100644
--- a/drivers/scsi/qla2xxx/qla_tmpl.c
+++ b/drivers/scsi/qla2xxx/qla_tmpl.c
@@ -796,29 +796,29 @@ struct qla27xx_fwdt_entry_call {
 };
 
 static struct qla27xx_fwdt_entry_call ql27xx_fwdt_entry_call_list[] = {
-   { ENTRY_TYPE_NOP, qla27xx_fwdt_entry_t0} ,
-   { ENTRY_TYPE_TMP_END, qla27xx_fwdt_entry_t255  } ,
-   { ENTRY_TYPE_RD_IOB_T1  , qla27xx_fwdt_entry_t256  } ,
-   { ENTRY_TYPE_WR_IOB_T1  , qla27xx_fwdt_entry_t257  } ,
-   { ENTRY_TYPE_RD_IOB_T2  , qla27xx_fwdt_entry_t258  } ,
-   { ENTRY_TYPE_WR_IOB_T2  , qla27xx_fwdt_entry_t259  } ,
-   { ENTRY_TYPE_RD_PCI , qla27xx_fwdt_entry_t260  } ,
-   { ENTRY_TYPE_WR_PCI , qla27xx_fwdt_entry_t261  } ,
-   { ENTRY_TYPE_RD_RAM , qla27xx_fwdt_entry_t262  } ,
-   { ENTRY_TYPE_GET_QUEUE  , qla27xx_fwdt_entry_t263  } ,
-   { ENTRY_TYPE_GET_FCE, qla27xx_fwdt_entry_t264  } ,
-   { ENTRY_TYPE_PSE_RISC   , qla27xx_fwdt_entry_t265  } ,
-   { ENTRY_TYPE_RST_RISC   , qla27xx_fwdt_entry_t266  } ,
-   { ENTRY_TYPE_DIS_INTR   , qla27xx_fwdt_entry_t267  } ,
-   { ENTRY_TYPE_GET_HBUF   , qla27xx_fwdt_entry_t268  } ,
-   { ENTRY_TYPE_SCRATCH, qla27xx_fwdt_entry_t269  } ,
-   { ENTRY_TYPE_RDREMREG   , qla27xx_fwdt_entry_t270  } ,
-   { ENTRY_TYPE_WRREMREG   , qla27xx_fwdt_entry_t271  } ,
-   { ENTRY_TYPE_RDREMRAM   , qla27xx_fwdt_entry_t272  } ,
-   { ENTRY_TYPE_PCICFG , qla27xx_fwdt_entry_t273  } ,
-   { ENTRY_TYPE_GET_SHADOW , qla27xx_fwdt_entry_t274  } ,
-   { ENTRY_TYPE_WRITE_BUF  , qla27xx_fwdt_entry_t275  } ,
-   { -1, qla27xx_fwdt_entry_other }
+   { ENTRY_TYPE_NOP,   qla27xx_fwdt_entry_t0},
+   { ENTRY_TYPE_TMP_END,   qla27xx_fwdt_entry_t255  },
+   { ENTRY_TYPE_RD_IOB_T1, qla27xx_fwdt_entry_t256  },
+   { ENTRY_TYPE_WR_IOB_T1, qla27xx_fwdt_entry_t257  },
+   { ENTRY_TYPE_RD_IOB_T2, qla27xx_fwdt_entry_t258  },
+   { ENTRY_TYPE_WR_IOB_T2, qla27xx_fwdt_entry_t259  },
+   { ENTRY_TYPE_RD_PCI,qla27xx_fwdt_entry_t260  },
+   { ENTRY_TYPE_WR_PCI,qla27xx_fwdt_entry_t261  },
+   { ENTRY_TYPE_RD_RAM,qla27xx_fwdt_entry_t262  },
+   { ENTRY_TYPE_GET_QUEUE, qla27xx_fwdt_entry_t263  },
+   { ENTRY_TYPE_GET_FCE,   qla27xx_fwdt_entry_t264  },
+   { ENTRY_TYPE_PSE_RISC,  qla27xx_fwdt_entry_t265  },
+   { ENTRY_TYPE_RST_RISC,  qla27xx_fwdt_entry_t266  },
+   { ENTRY_TYPE_DIS_INTR,  qla27xx_fwdt_entry_t267  },
+   { ENTRY_TYPE_GET_HBUF,  qla27xx_fwdt_entry_t268  },
+   { ENTRY_TYPE_SCRATCH,   qla27xx_fwdt_entry_t269  },
+   { ENTRY_TYPE_RDREMREG,  qla27xx_fwdt_entry_t270  },
+   { ENTRY_TYPE_WRREMREG,  qla27xx_fwdt_entry_t271  },
+   { ENTRY_TYPE_RDREMRAM,  qla27xx_fwdt_entry_t272  },
+   { ENTRY_TYPE_PCICFG,qla27xx_fwdt_entry_t273  },
+   { ENTRY_TYPE_GET_SHADOW,qla27xx_fwdt_entry_t274  },
+   { ENTRY_TYPE_WRITE_BUF, qla27xx_fwdt_entry_t275  },
+   { -1,   qla27xx_fwdt_entry_other }
 };
 
 static inline int (*qla27xx_find_entry(uint type))
-- 
2.12.0



[PATCH v3 10/11] qla2xxx: Add new FW dump template entry types

2019-02-15 Thread Himanshu Madhani
From: Joe Carnuccio 

This patch adds new firmware dump template entries for
ISP27XX firmware dump.

Signed-off-by: Joe Carnuccio 
Signed-off-by: Himanshu Madhani 
---
 drivers/scsi/qla2xxx/qla_tmpl.c | 191 +---
 drivers/scsi/qla2xxx/qla_tmpl.h |  26 +-
 2 files changed, 142 insertions(+), 75 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_tmpl.c b/drivers/scsi/qla2xxx/qla_tmpl.c
index f0c7c0c75ef7..9e52500caff0 100644
--- a/drivers/scsi/qla2xxx/qla_tmpl.c
+++ b/drivers/scsi/qla2xxx/qla_tmpl.c
@@ -221,7 +221,13 @@ qla27xx_skip_entry(struct qla27xx_fwdt_entry *ent, void 
*buf)
ent->hdr.driver_flags |= DRIVER_FLAG_SKIP_ENTRY;
 }
 
-static int
+static inline struct qla27xx_fwdt_entry *
+qla27xx_next_entry(struct qla27xx_fwdt_entry *ent)
+{
+   return (void *)ent + ent->hdr.size;
+}
+
+static struct qla27xx_fwdt_entry *
 qla27xx_fwdt_entry_t0(struct scsi_qla_host *vha,
struct qla27xx_fwdt_entry *ent, void *buf, ulong *len)
 {
@@ -229,10 +235,10 @@ qla27xx_fwdt_entry_t0(struct scsi_qla_host *vha,
"%s: nop [%lx]\n", __func__, *len);
qla27xx_skip_entry(ent, buf);
 
-   return false;
+   return qla27xx_next_entry(ent);
 }
 
-static int
+static struct qla27xx_fwdt_entry *
 qla27xx_fwdt_entry_t255(struct scsi_qla_host *vha,
struct qla27xx_fwdt_entry *ent, void *buf, ulong *len)
 {
@@ -241,10 +247,10 @@ qla27xx_fwdt_entry_t255(struct scsi_qla_host *vha,
qla27xx_skip_entry(ent, buf);
 
/* terminate */
-   return true;
+   return NULL;
 }
 
-static int
+static struct qla27xx_fwdt_entry *
 qla27xx_fwdt_entry_t256(struct scsi_qla_host *vha,
struct qla27xx_fwdt_entry *ent, void *buf, ulong *len)
 {
@@ -255,10 +261,10 @@ qla27xx_fwdt_entry_t256(struct scsi_qla_host *vha,
qla27xx_read_window(reg, ent->t256.base_addr, ent->t256.pci_offset,
ent->t256.reg_count, ent->t256.reg_width, buf, len);
 
-   return false;
+   return qla27xx_next_entry(ent);
 }
 
-static int
+static struct qla27xx_fwdt_entry *
 qla27xx_fwdt_entry_t257(struct scsi_qla_host *vha,
struct qla27xx_fwdt_entry *ent, void *buf, ulong *len)
 {
@@ -269,10 +275,10 @@ qla27xx_fwdt_entry_t257(struct scsi_qla_host *vha,
qla27xx_write_reg(reg, IOBASE_ADDR, ent->t257.base_addr, buf);
qla27xx_write_reg(reg, ent->t257.pci_offset, ent->t257.write_data, buf);
 
-   return false;
+   return qla27xx_next_entry(ent);
 }
 
-static int
+static struct qla27xx_fwdt_entry *
 qla27xx_fwdt_entry_t258(struct scsi_qla_host *vha,
struct qla27xx_fwdt_entry *ent, void *buf, ulong *len)
 {
@@ -284,10 +290,10 @@ qla27xx_fwdt_entry_t258(struct scsi_qla_host *vha,
qla27xx_read_window(reg, ent->t258.base_addr, ent->t258.pci_offset,
ent->t258.reg_count, ent->t258.reg_width, buf, len);
 
-   return false;
+   return qla27xx_next_entry(ent);
 }
 
-static int
+static struct qla27xx_fwdt_entry *
 qla27xx_fwdt_entry_t259(struct scsi_qla_host *vha,
struct qla27xx_fwdt_entry *ent, void *buf, ulong *len)
 {
@@ -299,10 +305,10 @@ qla27xx_fwdt_entry_t259(struct scsi_qla_host *vha,
qla27xx_write_reg(reg, ent->t259.banksel_offset, ent->t259.bank, buf);
qla27xx_write_reg(reg, ent->t259.pci_offset, ent->t259.write_data, buf);
 
-   return false;
+   return qla27xx_next_entry(ent);
 }
 
-static int
+static struct qla27xx_fwdt_entry *
 qla27xx_fwdt_entry_t260(struct scsi_qla_host *vha,
struct qla27xx_fwdt_entry *ent, void *buf, ulong *len)
 {
@@ -313,10 +319,10 @@ qla27xx_fwdt_entry_t260(struct scsi_qla_host *vha,
qla27xx_insert32(ent->t260.pci_offset, buf, len);
qla27xx_read_reg(reg, ent->t260.pci_offset, buf, len);
 
-   return false;
+   return qla27xx_next_entry(ent);
 }
 
-static int
+static struct qla27xx_fwdt_entry *
 qla27xx_fwdt_entry_t261(struct scsi_qla_host *vha,
struct qla27xx_fwdt_entry *ent, void *buf, ulong *len)
 {
@@ -326,10 +332,10 @@ qla27xx_fwdt_entry_t261(struct scsi_qla_host *vha,
"%s: wrpci [%lx]\n", __func__, *len);
qla27xx_write_reg(reg, ent->t261.pci_offset, ent->t261.write_data, buf);
 
-   return false;
+   return qla27xx_next_entry(ent);
 }
 
-static int
+static struct qla27xx_fwdt_entry *
 qla27xx_fwdt_entry_t262(struct scsi_qla_host *vha,
struct qla27xx_fwdt_entry *ent, void *buf, ulong *len)
 {
@@ -362,6 +368,11 @@ qla27xx_fwdt_entry_t262(struct scsi_qla_host *vha,
ent->t262.start_addr = start;
ent->t262.end_addr = end;
}
+   } else if (ent->t262.ram_area == T262_RAM_AREA_MISC) {
+   if (buf) {
+   ent->t262.start_addr = start;
+   ent->t262.end_addr = end;
+   }
} else {
ql_dbg(ql_dbg_misc, vha, 0xd022,
"%s: unknown area %x\n", __func__, ent->t262.ram_area);
@@ -384

[PATCH v3 07/11] qla2xxx: Prevent SysFS access when chip is down

2019-02-15 Thread Himanshu Madhani
From: Quinn Tran 

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

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

diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
index ee9f943f4d07..f8fd482a06e0 100644
--- a/drivers/scsi/qla2xxx/qla_attr.c
+++ b/drivers/scsi/qla2xxx/qla_attr.c
@@ -543,6 +543,9 @@ qla2x00_sysfs_write_vpd(struct file *filp, struct kobject 
*kobj,
if (unlikely(pci_channel_offline(ha->pdev)))
return 0;
 
+   if (qla2x00_chip_is_down(vha))
+   return 0;
+
if (!capable(CAP_SYS_ADMIN) || off != 0 || count != ha->vpd_size ||
!ha->isp_ops->write_nvram)
return 0;
-- 
2.12.0



[PATCH v3 06/11] qla2xxx: Add support for setting port speed

2019-02-15 Thread Himanshu Madhani
From: Anil Gurumurthy 

This patch adds SysFS node

1. There is a new sysfs node port_speed
2. The possible values are 2(Auto neg), 8, 16, 32
3. A value outside of the above defaults to Auto neg
4. Any update to the setting causes a link toggle
5. This feature is currently only for ISP27xx

Signed-off-by: Anil Gurumurthy 
Signed-off-by: Quinn Tran 
Signed-off-by: Himanshu Madhani 
---
 drivers/scsi/qla2xxx/qla_attr.c | 89 +
 drivers/scsi/qla2xxx/qla_def.h  |  6 +++
 drivers/scsi/qla2xxx/qla_gbl.h  |  1 +
 drivers/scsi/qla2xxx/qla_init.c |  9 +
 drivers/scsi/qla2xxx/qla_mbx.c  | 62 +++-
 5 files changed, 166 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
index 8b4dd72011bf..ee9f943f4d07 100644
--- a/drivers/scsi/qla2xxx/qla_attr.c
+++ b/drivers/scsi/qla2xxx/qla_attr.c
@@ -1632,6 +1632,92 @@ qla2x00_max_speed_sup_show(struct device *dev, struct 
device_attribute *attr,
ha->max_speed_sup ? "32Gps" : "16Gps");
 }
 
+static ssize_t
+qla2x00_port_speed_store(struct device *dev, struct device_attribute *attr,
+const char *buf, size_t count)
+{
+   struct scsi_qla_host *vha = shost_priv(dev_to_shost(dev));
+   ulong type, speed;
+   int oldspeed, rval;
+   int mode = QLA_SET_DATA_RATE_LR;
+   struct qla_hw_data *ha = vha->hw;
+
+   if (!IS_QLA27XX(vha->hw)) {
+   ql_log(ql_log_warn, vha, 0x70d8,
+   "Speed setting not supported \n");
+   return -EINVAL;
+   }
+
+   rval = kstrtol(buf, 10, &type);
+   speed = type;
+   if (type == 40 || type == 80 || type == 160 ||
+   type == 320) {
+   ql_dbg(ql_dbg_user, vha, 0x70d9,
+   "Setting will be affected after a loss of sync\n");
+   type = type/10;
+   mode = QLA_SET_DATA_RATE_NOLR;
+   }
+
+   oldspeed = ha->set_data_rate;
+
+   switch (type) {
+   case 0:
+   ha->set_data_rate = PORT_SPEED_AUTO;
+   break;
+   case 4:
+   ha->set_data_rate = PORT_SPEED_4GB;
+   break;
+   case 8:
+   ha->set_data_rate = PORT_SPEED_8GB;
+   break;
+   case 16:
+   ha->set_data_rate = PORT_SPEED_16GB;
+   break;
+   case 32:
+   ha->set_data_rate = PORT_SPEED_32GB;
+   break;
+   default:
+   ql_log(ql_log_warn, vha, 0x1199,
+   "Unrecognized speed setting:%lx. Setting Autoneg\n",
+   speed);
+   ha->set_data_rate = PORT_SPEED_AUTO;
+   }
+
+   if (qla2x00_chip_is_down(vha) || (oldspeed == ha->set_data_rate))
+   return -EINVAL;
+
+   ql_log(ql_log_info, vha, 0x70da,
+   "Setting speed to %lx Gbps \n", type);
+
+   rval = qla2x00_set_data_rate(vha, mode);
+   if (rval != QLA_SUCCESS)
+   return -EIO;
+
+   return strlen(buf);
+}
+
+static ssize_t
+qla2x00_port_speed_show(struct device *dev, struct device_attribute *attr,
+char *buf)
+{
+   struct scsi_qla_host *vha = shost_priv(dev_to_shost(dev));
+   struct qla_hw_data *ha = vha->hw;
+   ssize_t rval;
+   char *spd[7] = {"0", "0", "0", "4", "8", "16", "32"};
+
+   rval = qla2x00_get_data_rate(vha);
+   if (rval != QLA_SUCCESS) {
+   ql_log(ql_log_warn, vha, 0x70db,
+   "Unable to get port speed rval:%zd\n", rval);
+   return -EINVAL;
+   }
+
+   ql_log(ql_log_info, vha, 0x70d6,
+   "port speed:%d\n", ha->link_data_rate);
+
+   return scnprintf(buf, PAGE_SIZE, "%s\n", spd[ha->link_data_rate]);
+}
+
 /* - */
 
 static ssize_t
@@ -2128,6 +2214,8 @@ static DEVICE_ATTR_RW(ql2xexchoffld);
 static DEVICE_ATTR_RW(ql2xiniexchg);
 static DEVICE_ATTR(dif_bundle_statistics, 0444,
 qla2x00_dif_bundle_statistics_show, NULL);
+static DEVICE_ATTR(port_speed, 0644, qla2x00_port_speed_show,
+qla2x00_port_speed_store);
 
 
 struct device_attribute *qla2x00_host_attrs[] = {
@@ -2167,6 +2255,7 @@ struct device_attribute *qla2x00_host_attrs[] = {
&dev_attr_max_speed_sup,
&dev_attr_zio_threshold,
&dev_attr_dif_bundle_statistics,
+   &dev_attr_port_speed,
NULL, /* reserve for qlini_mode */
NULL, /* reserve for ql2xiniexchg */
NULL, /* reserve for ql2xexchoffld */
diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index c256ba7fba84..c0f7593666a1 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -3698,12 +3698,14 @@ struct qla_hw_data {
 #define PORT_SPEED_UNKNOWN 0x
 #define PORT_SPEED_1GB  0x00
 #define PORT_SPEED_2GB  0x01
+#define PORT_SPEED_AUTO 0x02
 #define PORT_SPEED_4GB  0x03
 #define PORT_SPEED_8GB  0x04
 #define PORT_SPEED_16GB 0x05
 #define PORT_SPEED_32GB 0x06
 #define PORT_SPEED_10GB   

[PATCH v3 00/11] qla2xxx: Misc bug fixes for the driver

2019-02-15 Thread Himanshu Madhani
Hi Martin, 

This series has misc bug fixes which includes cleanup for FC-NVMe code and
added first burst support for FC-NVMe devices. Other patches included in the
series adds new SysFS hook for setting port speed and patch to prevent access
to SysFS hook whle chip is down. 

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

Changes from v2 -> v3
o Updated patch #6 to address review comments from Bart.
o Dropped patch #8 for rework.

Changes from v1 -> v2
o Fixed 0-day kernel warning for patch #2
o Removed stale code which introduced error indicating lock was not acquired 
and not
  released in patch #7

Thanks,
Himanshu

Anil Gurumurthy (1):
  qla2xxx: Add support for setting port speed

Darren Trapp (1):
  qla2xxx: Add First Burst support for FC-NVMe devices

Himanshu Madhani (5):
  qla2xxx: Fix LUN discovery if loop id is not assigned yet by firmware
  qla2xxx: Fix unload when NVMe devices are configured
  qla2xxx: Check for FW started flag before aborting
  qla2xxx: Fix code indentation for qla27xx_fwdt_entry
  qla2xxx: Update driver version to 10.00.00.14-k

Joe Carnuccio (1):
  qla2xxx: Add new FW dump template entry types

Quinn Tran (3):
  qla2xxx: Prevent multiple ADISC commands per session
  qla2xxx: Prevent SysFS access when chip is down
  qla2xxx: Move marker request behind QPair

 drivers/scsi/qla2xxx/qla_attr.c|  92 ++
 drivers/scsi/qla2xxx/qla_def.h |  10 ++
 drivers/scsi/qla2xxx/qla_gbl.h |   5 +-
 drivers/scsi/qla2xxx/qla_init.c|  64 +-
 drivers/scsi/qla2xxx/qla_iocb.c|  55 -
 drivers/scsi/qla2xxx/qla_isr.c |   9 ++
 drivers/scsi/qla2xxx/qla_mbx.c |  85 ++---
 drivers/scsi/qla2xxx/qla_nvme.c|  47 +---
 drivers/scsi/qla2xxx/qla_nvme.h|   2 +-
 drivers/scsi/qla2xxx/qla_tmpl.c| 237 ++---
 drivers/scsi/qla2xxx/qla_tmpl.h|  26 +++-
 drivers/scsi/qla2xxx/qla_version.h |   2 +-
 12 files changed, 437 insertions(+), 197 deletions(-)

-- 
2.12.0



[PATCH v3 01/11] qla2xxx: Fix LUN discovery if loop id is not assigned yet by firmware

2019-02-15 Thread Himanshu Madhani
This patch fixes LUN discovery when loop ID is not yet assigned
by the firmware during driver load/sg_reset operations. Driver will
now search for new loop id before retrying login.

Fixes: 48acad099074 ("scsi: qla2xxx: Fix N2N link re-connect")
Cc: sta...@vger.kernel.org #4.19
Signed-off-by: Himanshu Madhani 
---
 drivers/scsi/qla2xxx/qla_init.c | 13 -
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index 8307eac796a2..cdf57eb643b3 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -644,11 +644,14 @@ static void qla24xx_handle_gnl_done_event(scsi_qla_host_t 
*vha,
break;
case DSC_LS_PORT_UNAVAIL:
default:
-   if (fcport->loop_id != FC_NO_LOOP_ID)
-   qla2x00_clear_loop_id(fcport);
-
-   fcport->loop_id = loop_id;
-   fcport->fw_login_state = DSC_LS_PORT_UNAVAIL;
+   if (fcport->loop_id == FC_NO_LOOP_ID) {
+   qla2x00_find_new_loop_id(vha, fcport);
+   fcport->fw_login_state =
+   DSC_LS_PORT_UNAVAIL;
+   }
+   ql_dbg(ql_dbg_disc, vha, 0x20e5,
+   "%s %d %8phC\n", __func__, __LINE__,
+   fcport->port_name);
qla24xx_fcport_handle_login(vha, fcport);
break;
}
-- 
2.12.0



[PATCH v3 02/11] qla2xxx: Add First Burst support for FC-NVMe devices

2019-02-15 Thread Himanshu Madhani
From: Darren Trapp 

Add Support for First Burst for FC-NVMe protocol. This
feature requires First Burst support in the firmware.

Signed-off-by: Darren Trapp 
Signed-off-by: Himanshu Madhani 
---
 drivers/scsi/qla2xxx/qla_def.h  |  4 
 drivers/scsi/qla2xxx/qla_init.c |  6 ++
 drivers/scsi/qla2xxx/qla_iocb.c |  5 -
 drivers/scsi/qla2xxx/qla_isr.c  |  9 +
 drivers/scsi/qla2xxx/qla_mbx.c  |  5 +++--
 drivers/scsi/qla2xxx/qla_nvme.c | 17 -
 drivers/scsi/qla2xxx/qla_nvme.h |  2 +-
 7 files changed, 39 insertions(+), 9 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index 80acf30fd8a5..c256ba7fba84 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -2367,7 +2367,9 @@ typedef struct fc_port {
 #define NVME_PRLI_SP_INITIATOR  BIT_5
 #define NVME_PRLI_SP_TARGET BIT_4
 #define NVME_PRLI_SP_DISCOVERY  BIT_3
+#define NVME_PRLI_SP_FIRST_BURST   BIT_0
uint8_t nvme_flag;
+   uint32_t nvme_first_burst_size;
 #define NVME_FLAG_REGISTERED 4
 #define NVME_FLAG_DELETING 2
 #define NVME_FLAG_RESETTING 1
@@ -3966,6 +3968,7 @@ struct qla_hw_data {
uint16_tfw_subminor_version;
uint16_tfw_attributes;
uint16_tfw_attributes_h;
+#define FW_ATTR_H_NVME_FBURST  BIT_1
 #define FW_ATTR_H_NVME BIT_10
 #define FW_ATTR_H_NVME_UPDATED  BIT_14
 
@@ -4260,6 +4263,7 @@ typedef struct scsi_qla_host {
uint32_tqpairs_req_created:1;
uint32_tqpairs_rsp_created:1;
uint32_tnvme_enabled:1;
+   uint32_tnvme_first_burst:1;
} flags;
 
atomic_tloop_state;
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index cdf57eb643b3..2d9336a87e42 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -1829,6 +1829,12 @@ qla24xx_handle_prli_done_event(struct scsi_qla_host 
*vha, struct event_arg *ea)
 
ea->fcport->chip_reset = vha->hw->base_qpair->chip_reset;
ea->fcport->logout_on_delete = 1;
+   ea->fcport->nvme_prli_service_param = ea->iop[0];
+   if (ea->iop[0] & NVME_PRLI_SP_FIRST_BURST)
+   ea->fcport->nvme_first_burst_size =
+   (ea->iop[1] & 0x) * 512;
+   else
+   ea->fcport->nvme_first_burst_size = 0;
qla24xx_post_gpdb_work(vha, ea->fcport, 0);
break;
default:
diff --git a/drivers/scsi/qla2xxx/qla_iocb.c b/drivers/scsi/qla2xxx/qla_iocb.c
index 2c27ae1924c5..cdac282b5bd3 100644
--- a/drivers/scsi/qla2xxx/qla_iocb.c
+++ b/drivers/scsi/qla2xxx/qla_iocb.c
@@ -2419,8 +2419,11 @@ qla24xx_prli_iocb(srb_t *sp, struct logio_entry_24xx 
*logio)
 
logio->entry_type = LOGINOUT_PORT_IOCB_TYPE;
logio->control_flags = cpu_to_le16(LCF_COMMAND_PRLI);
-   if (lio->u.logio.flags & SRB_LOGIN_NVME_PRLI)
+   if (lio->u.logio.flags & SRB_LOGIN_NVME_PRLI) {
logio->control_flags |= LCF_NVME_PRLI;
+   if (sp->vha->flags.nvme_first_burst)
+   logio->io_parameter[0] = NVME_PRLI_SP_FIRST_BURST;
+   }
 
logio->nport_handle = cpu_to_le16(sp->fcport->loop_id);
logio->port_id[0] = sp->fcport->d_id.b.al_pa;
diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
index bde9940ea7d1..b5ae76869d5b 100644
--- a/drivers/scsi/qla2xxx/qla_isr.c
+++ b/drivers/scsi/qla2xxx/qla_isr.c
@@ -1715,6 +1715,15 @@ qla24xx_logio_entry(scsi_qla_host_t *vha, struct req_que 
*req,
 
vha->hw->exch_starvation = 0;
data[0] = MBS_COMMAND_COMPLETE;
+
+   if (sp->type == SRB_PRLI_CMD) {
+   lio->u.logio.iop[0] =
+   le32_to_cpu(logio->io_parameter[0]);
+   lio->u.logio.iop[1] =
+   le32_to_cpu(logio->io_parameter[1]);
+   goto logio_done;
+   }
+
if (sp->type != SRB_LOGIN_CMD)
goto logio_done;
 
diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c
index f4adf6baee69..6c911f2e4cdb 100644
--- a/drivers/scsi/qla2xxx/qla_mbx.c
+++ b/drivers/scsi/qla2xxx/qla_mbx.c
@@ -1112,6 +1112,9 @@ qla2x00_get_fw_version(scsi_qla_host_t *vha)
if ((ha->fw_attributes_h &
(FW_ATTR_H_NVME | FW_ATTR_H_NVME_UPDATED)) &&
ql2xnvmeenable) {
+   if (ha->fw_attributes_h & FW_ATTR_H_NVME_FBURST)
+   vha->flags.nvme_first_burst = 1;
+
vha->flags.nvme_enabled = 1;
ql_log(ql_log_info, vha, 0xd302,
"%s: FC-NVMe is Enabled (0x%x)\n",
@@ -6267,8 +6270,6 @@ int __qla24xx_parse_gpdb(struct scsi_qla_host *vha, 

[PATCH v3 05/11] qla2xxx: Prevent multiple ADISC commands per session

2019-02-15 Thread Himanshu Madhani
From: Quinn Tran 

add check to allow 1 discovery command per session to be sent.

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

diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index 2d9336a87e42..ba5da365ee4a 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -471,9 +471,11 @@ qla2x00_async_adisc(struct scsi_qla_host *vha, fc_port_t 
*fcport,
 {
srb_t *sp;
struct srb_iocb *lio;
-   int rval;
+   int rval = QLA_FUNCTION_FAILED;
+
+   if (!vha->flags.online || (fcport->flags & FCF_ASYNC_SENT))
+   return rval;
 
-   rval = QLA_FUNCTION_FAILED;
fcport->flags |= FCF_ASYNC_SENT;
sp = qla2x00_get_sp(vha, fcport, GFP_KERNEL);
if (!sp)
-- 
2.12.0



[PATCH v3 11/11] qla2xxx: Update driver version to 10.00.00.14-k

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

diff --git a/drivers/scsi/qla2xxx/qla_version.h 
b/drivers/scsi/qla2xxx/qla_version.h
index 537098e8f1c1..0690dac24081 100644
--- a/drivers/scsi/qla2xxx/qla_version.h
+++ b/drivers/scsi/qla2xxx/qla_version.h
@@ -7,7 +7,7 @@
 /*
  * Driver version
  */
-#define QLA2XXX_VERSION  "10.00.00.13-k"
+#define QLA2XXX_VERSION  "10.00.00.14-k"
 
 #define QLA_DRIVER_MAJOR_VER   10
 #define QLA_DRIVER_MINOR_VER   0
-- 
2.12.0



[PATCH v3 08/11] qla2xxx: Move marker request behind QPair

2019-02-15 Thread Himanshu Madhani
From: Quinn Tran 

current code hard code marker request to use request
and response queue 0. This patch make use of the
qpair as the path to access the request/response queues.
It allows marker to be place on any hardware queues.

Signed-off-by: Quinn Tran 
Signed-off-by: Himanshu Madhani 
---
 drivers/scsi/qla2xxx/qla_gbl.h  |  4 ++--
 drivers/scsi/qla2xxx/qla_init.c | 30 ++---
 drivers/scsi/qla2xxx/qla_iocb.c | 50 +
 drivers/scsi/qla2xxx/qla_mbx.c  | 18 +++
 4 files changed, 33 insertions(+), 69 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
index 3c59006e64bb..4eefe69ca807 100644
--- a/drivers/scsi/qla2xxx/qla_gbl.h
+++ b/drivers/scsi/qla2xxx/qla_gbl.h
@@ -270,8 +270,8 @@ extern void qla24xx_build_scsi_iocbs(srb_t *, struct 
cmd_type_7 *,
uint16_t, struct req_que *);
 extern int qla2x00_start_scsi(srb_t *sp);
 extern int qla24xx_start_scsi(srb_t *sp);
-int qla2x00_marker(struct scsi_qla_host *, struct req_que *, struct rsp_que *,
-   uint16_t, uint64_t, uint8_t);
+int qla2x00_marker(struct scsi_qla_host *, struct qla_qpair *,
+uint16_t, uint64_t, uint8_t);
 extern int qla2x00_start_sp(srb_t *);
 extern int qla24xx_dif_start_scsi(srb_t *);
 extern int qla2x00_start_bidir(srb_t *, struct scsi_qla_host *, uint32_t);
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index bb9bccb734f8..a95915881c87 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -1703,8 +1703,8 @@ qla2x00_async_tm_cmd(fc_port_t *fcport, uint32_t flags, 
uint32_t lun,
lun = (uint16_t)tm_iocb->u.tmf.lun;
 
/* Issue Marker IOCB */
-   qla2x00_marker(vha, vha->hw->req_q_map[0],
-   vha->hw->rsp_q_map[0], sp->fcport->loop_id, lun,
+   qla2x00_marker(vha, vha->hw->base_qpair,
+   sp->fcport->loop_id, lun,
flags == TCF_LUN_RESET ? MK_SYNC_ID_LUN : MK_SYNC_ID);
}
 
@@ -6039,11 +6039,6 @@ qla2x00_loop_resync(scsi_qla_host_t *vha)
 {
int rval = QLA_SUCCESS;
uint32_t wait_time;
-   struct req_que *req;
-   struct rsp_que *rsp;
-
-   req = vha->req;
-   rsp = req->rsp;
 
clear_bit(ISP_ABORT_RETRY, &vha->dpc_flags);
if (vha->flags.online) {
@@ -6056,8 +6051,8 @@ qla2x00_loop_resync(scsi_qla_host_t *vha)
 * Issue a marker after FW becomes
 * ready.
 */
-   qla2x00_marker(vha, req, rsp, 0, 0,
-   MK_SYNC_ALL);
+   qla2x00_marker(vha, vha->hw->base_qpair,
+   0, 0, MK_SYNC_ALL);
vha->marker_needed = 0;
}
 
@@ -6795,8 +6790,6 @@ qla2x00_restart_isp(scsi_qla_host_t *vha)
 {
int status = 0;
struct qla_hw_data *ha = vha->hw;
-   struct req_que *req = ha->req_q_map[0];
-   struct rsp_que *rsp = ha->rsp_q_map[0];
 
/* If firmware needs to be loaded */
if (qla2x00_isp_firmware(vha)) {
@@ -6816,7 +6809,7 @@ qla2x00_restart_isp(scsi_qla_host_t *vha)
status = qla2x00_fw_ready(vha);
if (!status) {
/* Issue a marker after FW becomes ready. */
-   qla2x00_marker(vha, req, rsp, 0, 0, MK_SYNC_ALL);
+   qla2x00_marker(vha, ha->base_qpair, 0, 0, MK_SYNC_ALL);
set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags);
}
 
@@ -7871,22 +7864,15 @@ qla24xx_configure_vhba(scsi_qla_host_t *vha)
uint16_t mb[MAILBOX_REGISTER_COUNT];
struct qla_hw_data *ha = vha->hw;
struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);
-   struct req_que *req;
-   struct rsp_que *rsp;
 
if (!vha->vp_idx)
return -EINVAL;
 
rval = qla2x00_fw_ready(base_vha);
-   if (vha->qpair)
-   req = vha->qpair->req;
-   else
-   req = ha->req_q_map[0];
-   rsp = req->rsp;
 
if (rval == QLA_SUCCESS) {
clear_bit(RESET_MARKER_NEEDED, &vha->dpc_flags);
-   qla2x00_marker(vha, req, rsp, 0, 0, MK_SYNC_ALL);
+   qla2x00_marker(vha, ha->base_qpair, 0, 0, MK_SYNC_ALL);
}
 
vha->flags.management_server_logged_in = 0;
@@ -8278,8 +8264,6 @@ qla82xx_restart_isp(scsi_qla_host_t *vha)
 {
int status, rval;
struct qla_hw_data *ha = vha->hw;
-   struct req_que *req = ha->req_q_map[0];
-   struct rsp_que *rsp = ha->rsp_q_map[0];
struct scsi_qla_host *vp;
unsigned long flags;
 
@@ -8291,7 +8275,7 @@ qla82xx_restart_isp(scsi_qla

[PATCH v3 04/11] qla2xxx: Check for FW started flag before aborting

2019-02-15 Thread Himanshu Madhani
For FC-NVMe, if the fw_started flag is not set or
fcport is deleted, then do not send Abort command

Signed-off-by: Himanshu Madhani 
---
 drivers/scsi/qla2xxx/qla_nvme.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/scsi/qla2xxx/qla_nvme.c b/drivers/scsi/qla2xxx/qla_nvme.c
index 232b987e79dd..41c85da3ab32 100644
--- a/drivers/scsi/qla2xxx/qla_nvme.c
+++ b/drivers/scsi/qla2xxx/qla_nvme.c
@@ -185,6 +185,14 @@ static void qla_nvme_abort_work(struct work_struct *work)
struct qla_hw_data *ha = fcport->vha->hw;
int rval;
 
+   if (fcport)
+   ql_dbg(ql_dbg_io, fcport->vha, 0x,
+   "%s called for sp=%p, hndl=%x on fcport=%p deleted=%d\n",
+   __func__, sp, sp->handle, fcport, fcport->deleted);
+
+   if (!ha->flags.fw_started && (fcport && fcport->deleted))
+   return;
+
rval = ha->isp_ops->abort_command(sp);
 
ql_dbg(ql_dbg_io, fcport->vha, 0x212b,
-- 
2.12.0



[PATCH v3 03/11] qla2xxx: Fix unload when NVMe devices are configured

2019-02-15 Thread Himanshu Madhani
This patch fixes driver unload issue when FC-NVMe devices are
configured.

Signed-off-by: Himanshu Madhani 
---
 drivers/scsi/qla2xxx/qla_nvme.c | 22 ++
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_nvme.c b/drivers/scsi/qla2xxx/qla_nvme.c
index d6ba078d8255..232b987e79dd 100644
--- a/drivers/scsi/qla2xxx/qla_nvme.c
+++ b/drivers/scsi/qla2xxx/qla_nvme.c
@@ -607,6 +607,7 @@ static void qla_nvme_unregister_remote_port(struct 
work_struct *work)
struct fc_port *fcport = container_of(work, struct fc_port,
nvme_del_work);
struct qla_nvme_rport *qla_rport, *trport;
+   scsi_qla_host_t *base_vha;
 
if (!IS_ENABLED(CONFIG_NVME_FC))
return;
@@ -614,6 +615,15 @@ static void qla_nvme_unregister_remote_port(struct 
work_struct *work)
ql_log(ql_log_warn, NULL, 0x2112,
"%s: unregister remoteport on %p\n",__func__, fcport);
 
+   base_vha = pci_get_drvdata(fcport->vha->hw->pdev);
+   if (test_bit(PFLG_DRIVER_REMOVING, &base_vha->pci_flags)) {
+   ql_dbg(ql_dbg_disc, fcport->vha, 0x2114,
+   "%s: Notify FC-NVMe transport, set devloss=0\n",
+   __func__);
+
+   nvme_fc_set_remoteport_devloss(fcport->nvme_remote_port, 0);
+   }
+
list_for_each_entry_safe(qla_rport, trport,
&fcport->vha->nvme_rport_list, list) {
if (qla_rport->fcport == fcport) {
@@ -630,23 +640,11 @@ static void qla_nvme_unregister_remote_port(struct 
work_struct *work)
 
 void qla_nvme_delete(struct scsi_qla_host *vha)
 {
-   struct qla_nvme_rport *qla_rport, *trport;
-   fc_port_t *fcport;
int nv_ret;
 
if (!IS_ENABLED(CONFIG_NVME_FC))
return;
 
-   list_for_each_entry_safe(qla_rport, trport,
-   &vha->nvme_rport_list, list) {
-   fcport = qla_rport->fcport;
-
-   ql_log(ql_log_info, fcport->vha, 0x2114, "%s: fcport=%p\n",
-   __func__, fcport);
-
-   nvme_fc_set_remoteport_devloss(fcport->nvme_remote_port, 0);
-   }
-
if (vha->nvme_local_port) {
init_completion(&vha->nvme_del_done);
ql_log(ql_log_info, vha, 0x2116,
-- 
2.12.0



[PATCH] scsi: mpt3sas: Add missing breaks in switch statements

2019-02-15 Thread Gustavo A. R. Silva
Fix the following warnings by adding the proper missing breaks:

drivers/scsi/mpt3sas/mpt3sas_base.c: In function ‘_base_display_OEMs_branding’:
drivers/scsi/mpt3sas/mpt3sas_base.c:3548:4: warning: this statement may fall 
through [-Wimplicit-fallthrough=]
switch (ioc->pdev->subsystem_device) {
^~
drivers/scsi/mpt3sas/mpt3sas_base.c:3566:3: note: here
   case MPI2_MFGPAGE_DEVID_SAS2308_2:
   ^~~~
drivers/scsi/mpt3sas/mpt3sas_base.c:3567:4: warning: this statement may fall 
through [-Wimplicit-fallthrough=]
switch (ioc->pdev->subsystem_device) {
^~
drivers/scsi/mpt3sas/mpt3sas_base.c:3601:3: note: here
   case MPI25_MFGPAGE_DEVID_SAS3008:
   ^~~~
drivers/scsi/mpt3sas/mpt3sas_base.c:3735:4: warning: this statement may fall 
through [-Wimplicit-fallthrough=]
switch (ioc->pdev->subsystem_device) {
^~
drivers/scsi/mpt3sas/mpt3sas_base.c:3745:3: note: here
   case MPI2_MFGPAGE_DEVID_SAS2308_2:
   ^~~~
drivers/scsi/mpt3sas/mpt3sas_base.c:3746:4: warning: this statement may fall 
through [-Wimplicit-fallthrough=]
switch (ioc->pdev->subsystem_device) {
^~
drivers/scsi/mpt3sas/mpt3sas_base.c:3768:3: note: here
   default:
   ^~~

Warning level 3 was used: -Wimplicit-fallthrough=3

This patch is part of the ongoing efforts to enable
-Wimplicit-fallthrough.

Signed-off-by: Gustavo A. R. Silva 
---
 drivers/scsi/mpt3sas/mpt3sas_base.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c 
b/drivers/scsi/mpt3sas/mpt3sas_base.c
index 0a6cb8f0680c..e57774472e75 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_base.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_base.c
@@ -3563,6 +3563,7 @@ _base_display_OEMs_branding(struct MPT3SAS_ADAPTER *ioc)
 ioc->pdev->subsystem_device);
break;
}
+   break;
case MPI2_MFGPAGE_DEVID_SAS2308_2:
switch (ioc->pdev->subsystem_device) {
case MPT2SAS_INTEL_RS25GB008_SSDID:
@@ -3598,6 +3599,7 @@ _base_display_OEMs_branding(struct MPT3SAS_ADAPTER *ioc)
 ioc->pdev->subsystem_device);
break;
}
+   break;
case MPI25_MFGPAGE_DEVID_SAS3008:
switch (ioc->pdev->subsystem_device) {
case MPT3SAS_INTEL_RMS3JC080_SSDID:
@@ -3742,6 +3744,7 @@ _base_display_OEMs_branding(struct MPT3SAS_ADAPTER *ioc)
 ioc->pdev->subsystem_device);
break;
}
+   break;
case MPI2_MFGPAGE_DEVID_SAS2308_2:
switch (ioc->pdev->subsystem_device) {
case MPT2SAS_HP_2_4_INTERNAL_SSDID:
@@ -3765,6 +3768,7 @@ _base_display_OEMs_branding(struct MPT3SAS_ADAPTER *ioc)
 ioc->pdev->subsystem_device);
break;
}
+   break;
default:
ioc_info(ioc, "HP SAS HBA: Subsystem ID: 0x%X\n",
 ioc->pdev->subsystem_device);
-- 
2.20.1



[PATCH] qla2xxx: Avoid PCI IRQ affinity mapping when multiqueue is not supported.

2019-02-15 Thread Himanshu Madhani
From: Giridhar Malavali 

This patch fixes warning seen when BLK-MQ is enabled and hardware
does not support MQ. This will result into driver requesting MSIx
vectors which are equal or less than pre_desc via PCI IRQ Affinity
infrastructure.

[   19.746300] qla2xxx [:00:00.0]-0005: : QLogic Fibre Channel HBA 
Driver: 10.00.00.12-k.
[   19.746599] qla2xxx [:02:00.0]-001d: : Found an ISP2432 irq 18 
iobase 0x(ptrval).
[   20.203186] [ cut here ]
[   20.203306] WARNING: CPU: 8 PID: 268 at drivers/pci/msi.c:1273 
pci_irq_get_affinity+0xf4/0x120
[   20.203481] Modules linked in: tg3 ptp qla2xxx(+) pps_core sg libphy 
scsi_transport_fc flash loop autofs4
[   20.203700] CPU: 8 PID: 268 Comm: systemd-udevd Not tainted 
5.0.0-rc5-00358-gdf3865f #113
[   20.203830] Call Trace:
[   20.203933]  [00461bb0] __warn+0xb0/0xe0
[   20.204090]  [006c8f34] pci_irq_get_affinity+0xf4/0x120
[   20.204219]  [0068c764] blk_mq_pci_map_queues+0x24/0x120
[   20.204396]  [007162f4] scsi_map_queues+0x14/0x40
[   20.204626]  [00673654] blk_mq_update_queue_map+0x94/0xe0
[   20.204698]  [00676ce0] blk_mq_alloc_tag_set+0x120/0x300
[   20.204869]  [0071077c] scsi_add_host_with_dma+0x7c/0x300
[   20.205419]  [100ead54] qla2x00_probe_one+0x19d4/0x2640 [qla2xxx]
[   20.205621]  [006b3c88] pci_device_probe+0xc8/0x160
[   20.205697]  [00701c0c] really_probe+0x1ac/0x2e0
[   20.205770]  [00701f90] driver_probe_device+0x50/0x100
[   20.205843]  [00702134] __driver_attach+0xf4/0x120
[   20.205913]  [00700644] bus_for_each_dev+0x44/0x80
[   20.206081]  [00700c98] bus_add_driver+0x198/0x220
[   20.206300]  [00702950] driver_register+0x70/0x120
[   20.206582]  [10248224] qla2x00_module_init+0x224/0x284 [qla2xxx]
[   20.206857] ---[ end trace b1de7a3f79fab2c2 ]---

The fix is to check if the hardware does not have Multi Queue capabiltiy, use
pci_alloc_irq_vectors() call instead of pci_alloc_irq_affinity().

Fixes: f664a3cc17b7d ("scsi: kill off the legacy IO path")
Cc: sta...@vger.kernel.org #4.19
Signed-off-by: Giridhar Malavali 
Signed-off-by: Himanshu Madhani 
---
Hi Martin, 

This patch fixes issue, if BLK-MQ is enabled, driver will not map IRQ affinity
if the hardware does not support MQ. This was reported by Meelis Ross here 

https://marc.info/?l=linux-scsi&m=154980175720501&w=2

Please apply this on top of my earlier series for inclusion in 5.1/scsi-queue

https://marc.info/?l=linux-scsi&m=155027035917217&w=2

Thanks,
Himanshu
---
 drivers/scsi/qla2xxx/qla_isr.c | 2 +-
 drivers/scsi/qla2xxx/qla_os.c  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
index b5ae76869d5b..89ee82e6773b 100644
--- a/drivers/scsi/qla2xxx/qla_isr.c
+++ b/drivers/scsi/qla2xxx/qla_isr.c
@@ -3431,7 +3431,7 @@ qla24xx_enable_msix(struct qla_hw_data *ha, struct 
rsp_que *rsp)
min_vecs++;
}
 
-   if (USER_CTRL_IRQ(ha)) {
+   if (USER_CTRL_IRQ(ha) || !ha->mqiobase) {
/* user wants to control IRQ setting for target mode */
ret = pci_alloc_irq_vectors(ha->pdev, min_vecs,
ha->msix_count, PCI_IRQ_MSIX);
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index 7bf23943c815..84cd6bff8b12 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -7181,7 +7181,7 @@ static int qla2xxx_map_queues(struct Scsi_Host *shost)
scsi_qla_host_t *vha = (scsi_qla_host_t *)shost->hostdata;
struct blk_mq_queue_map *qmap = &shost->tag_set.map[0];
 
-   if (USER_CTRL_IRQ(vha->hw))
+   if (USER_CTRL_IRQ(vha->hw) || !vha->hw->mqiobase)
rc = blk_mq_map_queues(qmap);
else
rc = blk_mq_pci_map_queues(qmap, vha->hw->pdev, 0);
-- 
2.12.0



Re: qla2xxx init warning with blk_mq at drivers/pci/msi.c:1273 pci_irq_get_affinity+0xf4/0x120

2019-02-15 Thread Himanshu Madhani
Hi Meelis,


On 2/12/19, 6:37 PM, "Ming Lei"  wrote:

External Email

On Wed, Feb 13, 2019 at 5:36 AM Meelis Roos  wrote:
>
> >  I tested todays 5.0.0-rc5-00358-gdf3865f on my sparcs and a couple 
of servers that have qla2xxx
> >  FC adapter gave me this warning:
>
> Now I got a very similar one on an x86-64 server:
>
>
> [   18.472568] qla2xxx [:00:00.0]-0005: : QLogic Fibre Channel HBA 
Driver: 10.00.00.12-k.
> [   18.474272] PCI Interrupt Link [LNKD] enabled at IRQ 19
> [   18.474272] qla2xxx [:04:00.0]-001d: : Found an ISP2432 irq 19 
iobase 0x(ptrval).
> [   18.917293] scsi host3: qla2xxx
> [   18.917412] WARNING: CPU: 0 PID: 1650 at drivers/pci/msi.c:1273 
pci_irq_get_affinity+0x35/0x80
> [   18.917554] Modules linked in: qla2xxx(+) scsi_transport_fc 
i2c_nforce2 e1000 pata_amd k8temp libata i2c_core hwmon forcedeth(+) 
powernow_k8 pcspkr autofs4
> [   18.917708] CPU: 0 PID: 1650 Comm: kworker/0:3 Not tainted 
5.0.0-rc6-00013-gaa0c38cf39de #14
> [   18.917848] Hardware name: Sun Microsystems Sun Fire X4200 M2/Sun Fire 
X4200 M2, BIOS 0ABJX104 04/09/2009
> [   18.918002] Workqueue: events work_for_cpu_fn
> [   18.918082] RIP: 0010:pci_irq_get_affinity+0x35/0x80
> [   18.918164] Code: 2e 48 8b 87 b8 02 00 00 48 8d 8f b8 02 00 00 48 39 
c1 74 16 85 f6 74 4e 31 d2 eb 04 39 d6 74 46 48 8b 00 ff c2 48 39 c8 75 f2 <0f> 
0b 31 c0 c3 83 e2 02 48 c7 c0 c0 46 d5 b8 74 29 48 8b 97 b8 02
> [   18.918374] RSP: 0018:a15f4108fcb0 EFLAGS: 00010246
> [   18.918460] RAX: 95e7995f52b8 RBX:  RCX: 
95e7995f52b8
> [   18.918547] RDX: 0002 RSI: 0002 RDI: 
95e7995f5000
> [   18.918629] RBP:  R08: ff80 R09: 
95e799008e60
> [   18.918712] R10: b90b0f01 R11: a15f4108fa90 R12: 
0002
> [   18.918795] R13: 95e7995f5000 R14:  R15: 
95e7969890a8
> [   18.918878] FS:  () GS:95e79b40() 
knlGS:
> [   18.919013] CS:  0010 DS:  ES:  CR0: 80050033
> [   18.919103] CR2: 7f213fb62000 CR3: 000217dc CR4: 
06f0
> [   18.919185] Call Trace:
> [   18.919269]  blk_mq_pci_map_queues+0x32/0xc0
> [   18.919354]  blk_mq_alloc_tag_set+0x12e/0x340
> [   18.919437]  scsi_add_host_with_dma+0xa1/0x310
> [   18.919549]  qla2x00_probe_one+0x1272/0x2400 [qla2xxx]
> [   18.919632]  ? try_to_wake_up+0x2c8/0x6f0
> [   18.919710]  local_pci_probe+0x4b/0xb0
> [   18.919787]  work_for_cpu_fn+0x11/0x20
> [   18.919866]  process_one_work+0x1d1/0x360
> [   18.919943]  worker_thread+0x20e/0x3f0
> [   18.920020]  ? wq_calc_node_cpumask+0x110/0x110
> [   18.920100]  kthread+0x109/0x120
> [   18.920176]  ? kthread_create_on_node+0x60/0x60
> [   18.920256]  ret_from_fork+0x35/0x40
> [   18.920334] ---[ end trace 56ed281ce2c61e69 ]---
> [   18.926988] qla2xxx [:04:00.0]-00fb:3: QLogic QLE2460 - 
SG-(X)PCIE1FC-QF4, Sun StorageTek 4 Gb FC Enterprise PCI-Express Single Channel.
> [   18.927148] qla2xxx [:04:00.0]-00fc:3: ISP2432: PCIe (2.5GT/s x4) 
@ :04:00.0 hdma+ host#=3 fw=8.07.00 (9496).
> [   18.927757] qla2xxx [:83:00.0]-001d: : Found an ISP2432 irq 30 
iobase 0x(ptrval).
> [   19.350303] qla2xxx [:83:00.0]-00fb:4: QLogic QLE2460 - 
SG-(X)PCIE1FC-QF4, Sun StorageTek 4 Gb FC Enterprise PCI-Express Single Channel.
> [   19.350474] qla2xxx [:83:00.0]-00fc:4: ISP2432: PCIe (2.5GT/s x4) 
@ :83:00.0 hdma+ host#=4 fw=8.07.00 (9496).
> [   40.421151] qla2xxx [:04:00.0]-8038:3: Cable is unplugged...
> [   40.837159] qla2xxx [:83:00.0]-8038:4: Cable is unplugged...

We saw such issue too in which .msix_count is too small, and equal to
.pre_vectors, and Himanshu is working on it.

Thanks,
Ming Lei

Can you try patch just posted here.

https://patchwork.kernel.org/patch/10816115/

Thanks,
Himanshu



Re: [PATCH v2] scsi: sd: Optimal I/O size should be a multiple of physical block size

2019-02-15 Thread Martin K. Petersen


Christoph?

> It was reported that some devices report an OPTIMAL TRANSFER LENGTH of
> 0x blocks. That looks bogus, especially for a device with a
> 4096-byte physical block size.
>
> Ignore OPTIMAL TRANSFER LENGTH if it is not a multiple of the device's
> reported physical block size.
>
> To make the sanity checking conditionals more readable--and to
> facilitate printing warnings--relocate the checking to a helper
> function. No functional change aside from the printks.
>
> Cc: 
> Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=199759
> Reported-by: Christoph Anton Mitterer 
> Signed-off-by: Martin K. Petersen 
>
> ---
>
> v2:
>   - Added warnings as requested by hch
>   - Moved the checks to a helper function
>
> Before:
>
> NAME ALIGNMENT MIN-IO   OPT-IO PHY-SEC LOG-SEC ROTA SCHED  RQ-SIZE  RA 
> WSAME
> sda  0   4096 335539204096 5120 mq-deadline256 128   
> 32M
>
> After:
>
> NAME ALIGNMENT MIN-IO OPT-IO PHY-SEC LOG-SEC ROTA SCHED   RQ-SIZE   RA 
> WSAME
> sda  0   4096  04096 5120 mq-deadline 256 4096   
> 32M
> ---
>  drivers/scsi/sd.c | 59 +++
>  1 file changed, 50 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
> index 9aa409b38765..5dfe37b08d3b 100644
> --- a/drivers/scsi/sd.c
> +++ b/drivers/scsi/sd.c
> @@ -3048,6 +3048,55 @@ static void sd_read_security(struct scsi_disk *sdkp, 
> unsigned char *buffer)
>   sdkp->security = 1;
>  }
>  
> +/*
> + * Determine the device's preferred I/O size for reads and writes
> + * unless the reported value is unreasonably small, large, not a
> + * multiple of the physical block size, or simply garbage.
> + */
> +static bool sd_validate_opt_xfer_size(struct scsi_disk *sdkp,
> +   unsigned int dev_max)
> +{
> + struct scsi_device *sdp = sdkp->device;
> + unsigned int opt_xfer_bytes =
> + logical_to_bytes(sdp, sdkp->opt_xfer_blocks);
> +
> + if (sdkp->opt_xfer_blocks > dev_max) {
> + sd_first_printk(KERN_WARNING, sdkp,
> + "Optimal transfer size %u logical blocks " \
> + "> dev_max (%u logical blocks)\n",
> + sdkp->opt_xfer_blocks, dev_max);
> + return false;
> + }
> +
> + if (sdkp->opt_xfer_blocks > SD_DEF_XFER_BLOCKS) {
> + sd_first_printk(KERN_WARNING, sdkp,
> + "Optimal transfer size %u logical blocks " \
> + "> sd driver limit (%u logical blocks)\n",
> + sdkp->opt_xfer_blocks, SD_DEF_XFER_BLOCKS);
> + return false;
> + }
> +
> + if (opt_xfer_bytes < PAGE_SIZE) {
> + sd_first_printk(KERN_WARNING, sdkp,
> + "Optimal transfer size %u bytes < " \
> + "PAGE_SIZE (%u bytes)\n",
> + opt_xfer_bytes, (unsigned int)PAGE_SIZE);
> + return false;
> + }
> +
> + if (opt_xfer_bytes & (sdkp->physical_block_size - 1)) {
> + sd_first_printk(KERN_WARNING, sdkp,
> + "Optimal transfer size %u bytes not a " \
> + "multiple of physical block size (%u bytes)\n",
> + opt_xfer_bytes, sdkp->physical_block_size);
> + return false;
> + }
> +
> + sd_first_printk(KERN_INFO, sdkp, "Optimal transfer size %u bytes\n",
> + opt_xfer_bytes);
> + return true;
> +}
> +
>  /**
>   *   sd_revalidate_disk - called the first time a new disk is seen,
>   *   performs disk spin up, read_capacity, etc.
> @@ -3117,15 +3166,7 @@ static int sd_revalidate_disk(struct gendisk *disk)
>   dev_max = min_not_zero(dev_max, sdkp->max_xfer_blocks);
>   q->limits.max_dev_sectors = logical_to_sectors(sdp, dev_max);
>  
> - /*
> -  * Determine the device's preferred I/O size for reads and writes
> -  * unless the reported value is unreasonably small, large, or
> -  * garbage.
> -  */
> - if (sdkp->opt_xfer_blocks &&
> - sdkp->opt_xfer_blocks <= dev_max &&
> - sdkp->opt_xfer_blocks <= SD_DEF_XFER_BLOCKS &&
> - logical_to_bytes(sdp, sdkp->opt_xfer_blocks) >= PAGE_SIZE) {
> + if (sd_validate_opt_xfer_size(sdkp, dev_max)) {
>   q->limits.io_opt = logical_to_bytes(sdp, sdkp->opt_xfer_blocks);
>   rw_max = logical_to_sectors(sdp, sdkp->opt_xfer_blocks);
>   } else

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH v2 3/3] scsi: ufs: Add HI3670 SoC UFS driver support

2019-02-15 Thread Martin K. Petersen


Manivannan,

> Ping on this patch!

Applied to 5.1/scsi-queue, thanks!

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH v2] scsi: sd: block: Fix regressions in read-only block device handling

2019-02-15 Thread Martin K. Petersen


Christoph? Jens?

> Some devices come online in write protected state and switch to
> read-write once they are ready to process I/O requests. These devices
> broke with commit 20bd1d026aac ("scsi: sd: Keep disk read-only when
> re-reading partition") because we had no way to distinguish between a
> user decision to set a block_device read-only and the actual hardware
> device being write-protected.
>
> Because partitions are dropped and recreated on revalidate we are
> unable to persist any user-provided policy in hd_struct. Introduce a
> bitmap in struct gendisk to track the user configuration. This bitmap
> is updated when BLKROSET is called on a given disk or partition.
>
> A helper function, get_user_ro(), is provided to determine whether the
> ioctl has forced read-only state for a given block device. This helper
> is used by set_disk_ro() and add_partition() to ensure that both
> existing and newly created partitions will get the correct state.
>
>  - If BLKROSET sets a whole disk device read-only, all partitions will
>now end up in a read-only state.
>
>  - If BLKROSET sets a given partition read-only, that partition will
>remain read-only post revalidate.
>
>  - Otherwise both the whole disk device and any partitions will
>reflect the write protect state of the underlying device.
>
> Cc: Jeremy Cline 
> Cc: Oleksii Kurochko 
> Cc: sta...@vger.kernel.org # v4.16+
> Reported-by: Oleksii Kurochko 
> Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=201221
> Fixes: 20bd1d026aac ("scsi: sd: Keep disk read-only when re-reading 
> partition")
> Signed-off-by: Martin K. Petersen 
>
> ---
>
> v2:
>   - Track user read-only state in a bitmap
>
>   - Work around the regression that caused us to drop user
> preferences on revalidate
> ---
>  block/genhd.c | 22 +-
>  block/ioctl.c |  4 
>  block/partition-generic.c |  2 +-
>  drivers/scsi/sd.c |  4 +---
>  include/linux/genhd.h |  2 ++
>  5 files changed, 25 insertions(+), 9 deletions(-)
>
> diff --git a/block/genhd.c b/block/genhd.c
> index 1dd8fd6613b8..34667eb1d3cc 100644
> --- a/block/genhd.c
> +++ b/block/genhd.c
> @@ -1544,19 +1544,31 @@ void set_device_ro(struct block_device *bdev, int 
> flag)
>  
>  EXPORT_SYMBOL(set_device_ro);
>  
> +bool get_user_ro(struct gendisk *disk, unsigned int partno)
> +{
> + /* Is the user read-only bit set for the whole disk device? */
> + if (test_bit(0, disk->user_ro_bitmap))
> + return true;
> +
> + /* Is the user read-only bit set for this particular partition? */
> + if (test_bit(partno, disk->user_ro_bitmap))
> + return true;
> +
> + return false;
> +}
> +EXPORT_SYMBOL(get_user_ro);
> +
>  void set_disk_ro(struct gendisk *disk, int flag)
>  {
>   struct disk_part_iter piter;
>   struct hd_struct *part;
>  
> - if (disk->part0.policy != flag) {
> + if (disk->part0.policy != flag)
>   set_disk_ro_uevent(disk, flag);
> - disk->part0.policy = flag;
> - }
>  
> - disk_part_iter_init(&piter, disk, DISK_PITER_INCL_EMPTY);
> + disk_part_iter_init(&piter, disk, DISK_PITER_INCL_EMPTY_PART0);
>   while ((part = disk_part_iter_next(&piter)))
> - part->policy = flag;
> + part->policy = get_user_ro(disk, part->partno) ?: flag;
>   disk_part_iter_exit(&piter);
>  }
>  
> diff --git a/block/ioctl.c b/block/ioctl.c
> index 4825c78a6baa..41206df89485 100644
> --- a/block/ioctl.c
> +++ b/block/ioctl.c
> @@ -451,6 +451,10 @@ static int blkdev_roset(struct block_device *bdev, 
> fmode_t mode,
>   return ret;
>   if (get_user(n, (int __user *)arg))
>   return -EFAULT;
> + if (n)
> + set_bit(bdev->bd_partno, bdev->bd_disk->user_ro_bitmap);
> + else
> + clear_bit(bdev->bd_partno, bdev->bd_disk->user_ro_bitmap);
>   set_device_ro(bdev, n);
>   return 0;
>  }
> diff --git a/block/partition-generic.c b/block/partition-generic.c
> index 8e596a8dff32..c6a3c21c2496 100644
> --- a/block/partition-generic.c
> +++ b/block/partition-generic.c
> @@ -338,7 +338,7 @@ struct hd_struct *add_partition(struct gendisk *disk, int 
> partno,
>   queue_limit_discard_alignment(&disk->queue->limits, start);
>   p->nr_sects = len;
>   p->partno = partno;
> - p->policy = get_disk_ro(disk);
> + p->policy = get_user_ro(disk, partno) ?: get_disk_ro(disk);
>  
>   if (info) {
>   struct partition_meta_info *pinfo = alloc_part_info(disk);
> diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
> index 67cc439b86e4..5dfe37b08d3b 100644
> --- a/drivers/scsi/sd.c
> +++ b/drivers/scsi/sd.c
> @@ -2591,10 +2591,8 @@ sd_read_write_protect_flag(struct scsi_disk *sdkp, 
> unsigned char *buffer)
>   int res;
>   struct scsi_device *sdp = sdkp->device;
>   struct scsi_mode_data data;
> - int disk_ro = get_disk_ro(sdkp->disk);
>   int ol

Re: [RESEND PATCH] libiscsi: Fix race between iscsi_xmit_task and iscsi_complete_task

2019-02-15 Thread Martin K. Petersen


Bob,

> When a target sends Check Condition, whilst initiator is busy xmiting
> re-queued data, could lead to race between iscsi_complete_task() and
> iscsi_xmit_task() and eventually crashing with the following kernel
> backtrace.

Applied to 5.0/scsi-fixes, thanks!

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH v2] scsi: sd_zbc: Fix sd_zbc_report_zones() buffer allocation

2019-02-15 Thread Martin K. Petersen


Damien,

> The function sd_zbc_do_report_zones() issues a REPORT ZONES command
> with a buffer size calculated based on the number of zones requested
> by the caller. This value should however not exceed the capabilities
> of the hardware maximum command size, that is, should not exceed the
> max_hw_sectors limit of the device. This problem leads to failures of
> report zones commands when re-validating disks with some SAS HBAs.

Applied to 5.0/scsi-fixes, thanks!

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH] Move debug messages before sending srb preventing panic

2019-02-15 Thread Martin K. Petersen


Bill,

> When sending an srb with qla2x00_start_sp, the sp can complete and be 
> freed by the time we log the debug message saying we sent it. This can 
> cause a panic if sp gets reused quickly or when running a kernel that
> poisons freed memory.

Applied to 5.1/scsi-queue, thanks!

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH] scsi: libsas: Fix rphy phy_identifier for PHYs with end devices attached

2019-02-15 Thread Martin K. Petersen


John,

> The sysfs phy_identifier attribute for a sas_end_device comes
> from the rphy phy_identifier value.

Applied to 5.0/scsi-fixes, thank you!

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH] scsi: reset host byte in DID_NEXUS_FAILURE case

2019-02-15 Thread Martin K. Petersen


Martin,

> Up to 4.12, __scsi_error_from_host_byte() would reset the host
> byte to DID_OK for various cases including DID_NEXUS_FAILURE.
> Commit 2a842acab109 ("block: introduce new block status code type")
> replaced this function with scsi_result_to_blk_status() and removed
> the host-byte resetting code for the DID_NEXUS_FAILURE case.
> As the line set_host_byte(cmd, DID_OK) was preserved for the other
> cases, I suppose this was an editing mistake.

Applied to 5.0/scsi-fixes, thanks!

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH] sd: disable logical block provisioning if 'lbpme' is not set

2019-02-15 Thread Martin K. Petersen


Jean,

> When evaluating the 'block limits' VPD page we need to check if the
> 'lbpme' (logical block provisioning management enable) bit is set in
> the READ CAPACITY (16) output.  If it isn't we can safely assume that
> we cannot use DISCARD on this device.

That's not entirely correct. We still support devices which predate
logical block provisioning getting standardized in SBC. These devices
are typically driven by the zeroing method and don't have LBPME, nor the
LBP VPD page to key off of. Instead they are triggered by setting the
provisioning_mode via udev.

I am not sure how many of these are still around, I am hoping very
few. But I'd prefer to not break anything.

Can you describe the specific problem your patch is aiming to address?

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH][V2] scsi: qla2xxx: remove redundant null check on pointer sess

2019-02-15 Thread Martin K. Petersen


Colin,

> The null check on pointer sess and the subsequent call is redundant as
> sess is null on all the the paths that lead to the out_term2 label.
> Hence the null check and the call can be removed.  Also remove the
> redundant setting of sess to NULL as this is not required now.

Applied to 5.1/scsi-queue, thanks!

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH v3 00/11] qla2xxx: Misc bug fixes for the driver

2019-02-15 Thread Martin K. Petersen


Himanshu,

> This series has misc bug fixes which includes cleanup for FC-NVMe code
> and added first burst support for FC-NVMe devices. Other patches
> included in the series adds new SysFS hook for setting port speed and
> patch to prevent access to SysFS hook whle chip is down.

Applied to 5.1/scsi-queue, thanks!

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH] qla2xxx: Avoid PCI IRQ affinity mapping when multiqueue is not supported.

2019-02-15 Thread Martin K. Petersen


Himanshu,

> This patch fixes warning seen when BLK-MQ is enabled and hardware does
> not support MQ. This will result into driver requesting MSIx vectors
> which are equal or less than pre_desc via PCI IRQ Affinity
> infrastructure.

Applied to 5.1/scsi-queue, thanks!

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH v2 1/3] dt-bindings: ufs: Add HI3670 UFS controller binding

2019-02-15 Thread Manivannan Sadhasivam
On Fri, Jan 11, 2019 at 03:35:02PM -0600, Rob Herring wrote:
> On Sat,  5 Jan 2019 12:58:57 +0530, Manivannan Sadhasivam wrote:
> > Add devicetree binding for HI3670 UFS controller. HI3760 SoC is very
> > similar to HI3660 SoC with almost same IPs. Only major difference in terms
> > of UFS is the PHY. HI3670 has 10nm PHY. But since the original driver
> > (HI3660 UFS) cannot make HI3670 UFS functional, a separate compatible
> > is added for HI3670 without any fallback.
> > 
> > Signed-off-by: Manivannan Sadhasivam 
> > ---
> >  Documentation/devicetree/bindings/ufs/ufs-hisi.txt | 5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> > 
> 
> Reviewed-by: Rob Herring 

Martin,

Can you please take the bindings patch also? DT patch will go through
HiSi tree.

Thanks,
Mani


[PATCH -next] scsi: qedi: Remove set but not used variable 'cls_sess'

2019-02-15 Thread YueHaibing
Fixes gcc '-Wunused-but-set-variable' warning:

drivers/scsi/qedi/qedi_fw.c: In function 'qedi_tmf_resp_work':
drivers/scsi/qedi/qedi_fw.c:158:28: warning:
 variable 'cls_sess' set but not used [-Wunused-but-set-variable]

drivers/scsi/qedi/qedi_fw.c: In function 'qedi_tmf_work':
drivers/scsi/qedi/qedi_fw.c:1370:28: warning:
 variable 'cls_sess' set but not used [-Wunused-but-set-variable]

It's never used since introduction.

Signed-off-by: YueHaibing 
---
 drivers/scsi/qedi/qedi_fw.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/scsi/qedi/qedi_fw.c b/drivers/scsi/qedi/qedi_fw.c
index e2a995a6e8e7..651c3a6b74ed 100644
--- a/drivers/scsi/qedi/qedi_fw.c
+++ b/drivers/scsi/qedi/qedi_fw.c
@@ -155,12 +155,10 @@ static void qedi_tmf_resp_work(struct work_struct *work)
struct iscsi_conn *conn = qedi_conn->cls_conn->dd_data;
struct iscsi_session *session = conn->session;
struct iscsi_tm_rsp *resp_hdr_ptr;
-   struct iscsi_cls_session *cls_sess;
int rval = 0;
 
set_bit(QEDI_CONN_FW_CLEANUP, &qedi_conn->flags);
resp_hdr_ptr =  (struct iscsi_tm_rsp *)qedi_cmd->tmf_resp_buf;
-   cls_sess = iscsi_conn_to_session(qedi_conn->cls_conn);
 
iscsi_block_session(session->cls_session);
rval = qedi_cleanup_all_io(qedi, qedi_conn, qedi_cmd->task, true);
@@ -1367,7 +1365,6 @@ static void qedi_tmf_work(struct work_struct *work)
struct qedi_conn *qedi_conn = qedi_cmd->conn;
struct qedi_ctx *qedi = qedi_conn->qedi;
struct iscsi_conn *conn = qedi_conn->cls_conn->dd_data;
-   struct iscsi_cls_session *cls_sess;
struct qedi_work_map *list_work = NULL;
struct iscsi_task *mtask;
struct qedi_cmd *cmd;
@@ -1378,7 +1375,6 @@ static void qedi_tmf_work(struct work_struct *work)
 
mtask = qedi_cmd->task;
tmf_hdr = (struct iscsi_tm *)mtask->hdr;
-   cls_sess = iscsi_conn_to_session(qedi_conn->cls_conn);
set_bit(QEDI_CONN_FW_CLEANUP, &qedi_conn->flags);
 
ctask = iscsi_itt_to_task(conn, tmf_hdr->rtt);