platform/kernel/linux-starfive.git
3 years agoscsi: libfc: Fix array index out of bound exception
Javed Hasan [Tue, 15 Jun 2021 16:59:39 +0000 (09:59 -0700)]
scsi: libfc: Fix array index out of bound exception

Fix array index out of bound exception in fc_rport_prli_resp().

Link: https://lore.kernel.org/r/20210615165939.24327-1-jhasan@marvell.com
Signed-off-by: Javed Hasan <jhasan@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: mvsas: Use DEVICE_ATTR_RO()/RW() macro
Zhen Lei [Wed, 16 Jun 2021 03:44:19 +0000 (11:44 +0800)]
scsi: mvsas: Use DEVICE_ATTR_RO()/RW() macro

Use DEVICE_ATTR_RO()/RW() macro helper instead of plain DEVICE_ATTR(),
which makes the code a bit shorter and easier to read.

Link: https://lore.kernel.org/r/20210616034419.725-5-thunder.leizhen@huawei.com
Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: megaraid_mbox: Use DEVICE_ATTR_ADMIN_RO() macro
Zhen Lei [Wed, 16 Jun 2021 03:44:18 +0000 (11:44 +0800)]
scsi: megaraid_mbox: Use DEVICE_ATTR_ADMIN_RO() macro

Use DEVICE_ATTR_ADMIN_RO() macro helper instead of plain DEVICE_ATTR(),
which makes the code a bit shorter and easier to read.

Link: https://lore.kernel.org/r/20210616034419.725-4-thunder.leizhen@huawei.com
Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: qedf: Use DEVICE_ATTR_RO() macro
Zhen Lei [Wed, 16 Jun 2021 03:44:17 +0000 (11:44 +0800)]
scsi: qedf: Use DEVICE_ATTR_RO() macro

Use DEVICE_ATTR_RO() macro helper instead of plain DEVICE_ATTR(), which
makes the code a bit shorter and easier to read.

Link: https://lore.kernel.org/r/20210616034419.725-3-thunder.leizhen@huawei.com
Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: qedi: Use DEVICE_ATTR_RO() macro
Zhen Lei [Wed, 16 Jun 2021 03:44:16 +0000 (11:44 +0800)]
scsi: qedi: Use DEVICE_ATTR_RO() macro

Use DEVICE_ATTR_RO() macro helper instead of plain DEVICE_ATTR(), which
makes the code a bit shorter and easier to read.

Link: https://lore.kernel.org/r/20210616034419.725-2-thunder.leizhen@huawei.com
Acked-by: Manish Rangankar <mrangankar@marvell.com>
Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: message: mptfc: Switch from pci_ to dma_ API
Christophe JAILLET [Sun, 13 Jun 2021 07:10:16 +0000 (09:10 +0200)]
scsi: message: mptfc: Switch from pci_ to dma_ API

The wrappers in include/linux/pci-dma-compat.h should go away.

The patch has been generated with the coccinelle script below and has been
hand modified to replace GFP_ with a correct flag.  It has been compile
tested.

When memory is allocated in 'mptfc_GetFcDevPage0()' GFP_KERNEL can be used
because it is already used in this function and no lock is acquired in the
between.

When memory is allocated in 'mptfc_GetFcPortPage0()' and
'mptfc_GetFcPortPage1()' GFP_KERNEL can be used because they already call
'mpt_config()' which has an explicit 'might_sleep()'.

While at it, also remove some useless casting.

@@ @@
-    PCI_DMA_BIDIRECTIONAL
+    DMA_BIDIRECTIONAL

@@ @@
-    PCI_DMA_TODEVICE
+    DMA_TO_DEVICE

@@ @@
-    PCI_DMA_FROMDEVICE
+    DMA_FROM_DEVICE

@@ @@
-    PCI_DMA_NONE
+    DMA_NONE

@@
expression e1, e2, e3;
@@
-    pci_alloc_consistent(e1, e2, e3)
+    dma_alloc_coherent(&e1->dev, e2, e3, GFP_)

@@
expression e1, e2, e3;
@@
-    pci_zalloc_consistent(e1, e2, e3)
+    dma_alloc_coherent(&e1->dev, e2, e3, GFP_)

@@
expression e1, e2, e3, e4;
@@
-    pci_free_consistent(e1, e2, e3, e4)
+    dma_free_coherent(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-    pci_map_single(e1, e2, e3, e4)
+    dma_map_single(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-    pci_unmap_single(e1, e2, e3, e4)
+    dma_unmap_single(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4, e5;
@@
-    pci_map_page(e1, e2, e3, e4, e5)
+    dma_map_page(&e1->dev, e2, e3, e4, e5)

@@
expression e1, e2, e3, e4;
@@
-    pci_unmap_page(e1, e2, e3, e4)
+    dma_unmap_page(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-    pci_map_sg(e1, e2, e3, e4)
+    dma_map_sg(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-    pci_unmap_sg(e1, e2, e3, e4)
+    dma_unmap_sg(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-    pci_dma_sync_single_for_cpu(e1, e2, e3, e4)
+    dma_sync_single_for_cpu(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-    pci_dma_sync_single_for_device(e1, e2, e3, e4)
+    dma_sync_single_for_device(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-    pci_dma_sync_sg_for_cpu(e1, e2, e3, e4)
+    dma_sync_sg_for_cpu(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-    pci_dma_sync_sg_for_device(e1, e2, e3, e4)
+    dma_sync_sg_for_device(&e1->dev, e2, e3, e4)

@@
expression e1, e2;
@@
-    pci_dma_mapping_error(e1, e2)
+    dma_mapping_error(&e1->dev, e2)

@@
expression e1, e2;
@@
-    pci_set_dma_mask(e1, e2)
+    dma_set_mask(&e1->dev, e2)

@@
expression e1, e2;
@@
-    pci_set_consistent_dma_mask(e1, e2)
+    dma_set_coherent_mask(&e1->dev, e2)

Link: https://lore.kernel.org/r/95afc589713ade2110e7812159ce3e9ab453ec18.1623568121.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: be2iscsi: Fix some missing space in some messages
Christophe JAILLET [Sat, 12 Jun 2021 07:18:47 +0000 (09:18 +0200)]
scsi: be2iscsi: Fix some missing space in some messages

Fix a few style issues reported by checkpatch.pl:

 - Avoid duplicated word in comment.

 - Add missing space in messages.

 - Unneeded continuation line character.

 - Unneeded extra spaces.

 - Unneeded log message after memory allocation failure.

Link: https://lore.kernel.org/r/8cb62f0eb96ec7ce7a73fe97cb4490dd5121ecff.1623482155.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: be2iscsi: Fix an error handling path in beiscsi_dev_probe()
Christophe JAILLET [Sat, 12 Jun 2021 07:18:34 +0000 (09:18 +0200)]
scsi: be2iscsi: Fix an error handling path in beiscsi_dev_probe()

If an error occurs after a pci_enable_pcie_error_reporting() call, it must
be undone by a corresponding pci_disable_pcie_error_reporting() call, as
already done in the remove function.

Link: https://lore.kernel.org/r/77adb02cfea7f1364e5603ecf3930d8597ae356e.1623482155.git.christophe.jaillet@wanadoo.fr
Fixes: 3567f36a09d1 ("[SCSI] be2iscsi: Fix AER handling in driver")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: ufs: Fix build warning without CONFIG_PM
YueHaibing [Thu, 17 Jun 2021 03:13:26 +0000 (11:13 +0800)]
scsi: ufs: Fix build warning without CONFIG_PM

drivers/scsi/ufs/ufshcd.c:9770:12: warning: ‘ufshcd_rpmb_resume’ defined but not used [-Wunused-function]
 static int ufshcd_rpmb_resume(struct device *dev)
            ^~~~~~~~~~~~~~~~~~
drivers/scsi/ufs/ufshcd.c:9037:12: warning: ‘ufshcd_wl_runtime_resume’ defined but not used [-Wunused-function]
 static int ufshcd_wl_runtime_resume(struct device *dev)
            ^~~~~~~~~~~~~~~~~~~~~~~~
drivers/scsi/ufs/ufshcd.c:9017:12: warning: ‘ufshcd_wl_runtime_suspend’ defined but not used [-Wunused-function]
 static int ufshcd_wl_runtime_suspend(struct device *dev)
            ^~~~~~~~~~~~~~~~~~~~~~~~~

Move it into #ifdef block to fix this.

Link: https://lore.kernel.org/r/20210617031326.36908-1-yuehaibing@huawei.com
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: bnx2fc: Remove meaningless bnx2fc_abts_cleanup() return value assignment
SeongJae Park [Fri, 18 Jun 2021 16:45:14 +0000 (16:45 +0000)]
scsi: bnx2fc: Remove meaningless bnx2fc_abts_cleanup() return value assignment

Commit 122c81c563b0 ("scsi: bnx2fc: Return failure if io_req is already in
ABTS processing") made bnx2fc_eh_abort() return FAILED when io_req was
alrady in ABTS processing, regardless of the return value of
bnx2fc_abts_cleanup().  However, the change left the assignment of the
return value of bnx2fc_abts_cleanup(). Remove this.

This issue was discovered and resolved using Coverity Static Analysis
Security Testing (SAST) by Synopsys, Inc.

Link: https://lore.kernel.org/r/20210618164514.6299-1-sj38.park@gmail.com
Fixes: 122c81c563b0 ("scsi: bnx2fc: Return failure if io_req is already in ABTS processing")
Acked-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: SeongJae Park <sjpark@amazon.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: qla2xxx: Add heartbeat check
Quinn Tran [Sat, 19 Jun 2021 05:24:27 +0000 (22:24 -0700)]
scsi: qla2xxx: Add heartbeat check

Use "no-op" mailbox command to check if the adapter firmware is still
responsive.

Link: https://lore.kernel.org/r/20210619052427.6440-1-njavali@marvell.com
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Quinn Tran <qutran@marvell.com>
Signed-off-by: Nilesh Javali <njavali@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: virtio_scsi: Do not overwrite SCSI status
Hannes Reinecke [Tue, 22 Jun 2021 09:11:53 +0000 (11:11 +0200)]
scsi: virtio_scsi: Do not overwrite SCSI status

When a sense code is present we should not override the SAM status; the
driver already sets it based on the response from the hypervisor.

In addition we should only copy the sense buffer if one is actually
provided by the hypervisor.

Link: https://lore.kernel.org/r/20210622091153.29231-1-hare@suse.de
Fixes: 464a00c9e0ad ("scsi: core: Kill DRIVER_SENSE")
Tested-by: Guenter Roeck <linux@roeck-us.net>
Tested-by: Jiri Slaby <jirislaby@kernel.org>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: libsas: Add LUN number check in .slave_alloc callback
Yufen Yu [Tue, 22 Jun 2021 03:40:37 +0000 (11:40 +0800)]
scsi: libsas: Add LUN number check in .slave_alloc callback

Offlining a SATA device connected to a hisi SAS controller and then
scanning the host will result in detecting 255 non-existent devices:

  # lsscsi
  [2:0:0:0]    disk    ATA      Samsung SSD 860  2B6Q  /dev/sda
  [2:0:1:0]    disk    ATA      WDC WD2003FYYS-3 1D01  /dev/sdb
  [2:0:2:0]    disk    SEAGATE  ST600MM0006      B001  /dev/sdc
  # echo "offline" > /sys/block/sdb/device/state
  # echo "- - -" > /sys/class/scsi_host/host2/scan
  # lsscsi
  [2:0:0:0]    disk    ATA      Samsung SSD 860  2B6Q  /dev/sda
  [2:0:1:0]    disk    ATA      WDC WD2003FYYS-3 1D01  /dev/sdb
  [2:0:1:1]    disk    ATA      WDC WD2003FYYS-3 1D01  /dev/sdh
  ...
  [2:0:1:255]  disk    ATA      WDC WD2003FYYS-3 1D01  /dev/sdjb

After a REPORT LUN command issued to the offline device fails, the SCSI
midlayer tries to do a sequential scan of all devices whose LUN number is
not 0. However, SATA does not support LUN numbers at all.

Introduce a generic sas_slave_alloc() handler which will return -ENXIO for
SATA devices if the requested LUN number is larger than 0 and make libsas
drivers use this function as their .slave_alloc callback.

Link: https://lore.kernel.org/r/20210622034037.1467088-1-yuyufen@huawei.com
Reported-by: Wu Bo <wubo40@huawei.com>
Suggested-by: John Garry <john.garry@huawei.com>
Reviewed-by: John Garry <john.garry@huawei.com>
Reviewed-by: Jason Yan <yanaijie@huawei.com>
Signed-off-by: Yufen Yu <yuyufen@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: core: Inline scsi_mq_alloc_queue()
Bart Van Assche [Tue, 22 Jun 2021 02:46:54 +0000 (19:46 -0700)]
scsi: core: Inline scsi_mq_alloc_queue()

Since scsi_mq_alloc_queue() only has one caller, inline it. This change was
suggested by Christoph Hellwig.

Link: https://lore.kernel.org/r/20210622024654.12543-1-bvanassche@acm.org
Cc: Christoph Hellwig <hch@lst.de>
Cc: Ming Lei <ming.lei@redhat.com>
Cc: Ed Tsai <ed.tsai@mediatek.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: aic7xxx: Fix unintentional sign extension issue on left shift of u8
Colin Ian King [Mon, 21 Jun 2021 15:17:27 +0000 (16:17 +0100)]
scsi: aic7xxx: Fix unintentional sign extension issue on left shift of u8

The shifting of the u8 integer returned fom ahc_inb(ahc, port+3) by 24 bits
to the left will be promoted to a 32 bit signed int and then sign-extended
to a u64. In the event that the top bit of the u8 is set then all then all
the upper 32 bits of the u64 end up as also being set because of the
sign-extension. Fix this by casting the u8 values to a u64 before the 24
bit left shift.

[ This dates back to 2002, I found the offending commit from the git
history git://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git,
commit f58eb66c0b0a ("Update aic7xxx driver to 6.2.10...") ]

Link: https://lore.kernel.org/r/20210621151727.20667-1-colin.king@canonical.com
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Addresses-Coverity: ("Unintended sign extension")

3 years agoscsi: elx: efct: Fix vport list linkage in LIO backend
James Smart [Sat, 19 Jun 2021 15:57:29 +0000 (08:57 -0700)]
scsi: elx: efct: Fix vport list linkage in LIO backend

vport is linked onto the driver's vport list at allocation, but failure
path fails to remove it from the list.

Change location of linkage until after complete vport completion.

Link: https://lore.kernel.org/r/20210619155729.20049-1-jsmart2021@gmail.com
Fixes: 692e5d73a811 ("scsi: elx: efct: LIO backend interface routines")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Co-developed-by: Ram Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: Ram Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: James Smart <james.smart@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: elx: libefc_sli: Fix ANDing with zero bit value
James Smart [Sat, 19 Jun 2021 15:56:41 +0000 (08:56 -0700)]
scsi: elx: libefc_sli: Fix ANDing with zero bit value

Flags value is being set to a constant and ANDed with 0 which always
results in 0.

Remove the assignment line.

Link: https://lore.kernel.org/r/20210619155641.19942-1-jsmart2021@gmail.com
Fixes: 1628f5b4976f ("scsi: elx: libefc_sli: Populate and post different WQEs")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Co-developed-by: Ram Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: Ram Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: James Smart <james.smart@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: aha1740: Avoid over-read of sense buffer
Kees Cook [Wed, 16 Jun 2021 21:24:37 +0000 (14:24 -0700)]
scsi: aha1740: Avoid over-read of sense buffer

In preparation for FORTIFY_SOURCE performing compile-time and run-time
field bounds checking for memcpy(), memmove(), and memset(), avoid
intentionally reading across neighboring array fields.

SCtmp->sense_buffer is 96 bytes, but ecbptr->sense is 14 bytes. Instead of
over-reading ecbptr->sense, copy only the actual contents and zero pad the
remaining bytes, avoiding potential over-reads.

Link: https://lore.kernel.org/r/20210616212437.1727088-1-keescook@chromium.org
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: arcmsr: Avoid over-read of sense buffer
Kees Cook [Wed, 16 Jun 2021 21:24:28 +0000 (14:24 -0700)]
scsi: arcmsr: Avoid over-read of sense buffer

In preparation for FORTIFY_SOURCE performing compile-time and run-time
field bounds checking for memcpy(), memmove(), and memset(), avoid
intentionally reading across neighboring array fields.

pcmd->sense_buffer is 96 bytes, and was being manually zero-filled.
However, struct SENSE_DATA is 18 bytes, with ccb->arcmsr_cdb.SenseData only
being 15 bytes, resulting in a 3 byte over-read.

Copy only the contents of ccb->arcmsr_cdb.SenseData and zero fill the
remainder, avoiding potential over-reads.

Link: https://lore.kernel.org/r/20210616212428.1726958-1-keescook@chromium.org
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: ips: Avoid over-read of sense buffer
Kees Cook [Wed, 16 Jun 2021 21:24:08 +0000 (14:24 -0700)]
scsi: ips: Avoid over-read of sense buffer

In preparation for FORTIFY_SOURCE performing compile-time and run-time
field bounds checking for memcpy() avoid intentionally reading across
neighboring array fields.

scb->scsi_cmd->sense_buffer is 96 bytes:
#define SCSI_SENSE_BUFFERSIZE        96

tapeDCDB->sense_info is 56 bytes:
typedef struct {
   ...
   uint8_t   sense_info[56];
} IPS_DCDB_TABLE_TAPE, ...

scb->dcdb.sense_info is 64 bytes:
typedef struct {
   ...
   uint8_t   sense_info[64];
   ...
} IPS_DCDB_TABLE, ...

Copying 96 bytes from either was copying beyond the end of the respective
buffers, leading to potential memory content exposures. Correctly copy the
actual buffer contents and zero pad the remaining bytes.

Link: https://lore.kernel.org/r/20210616212408.1726812-1-keescook@chromium.org
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: ufs: ufs-mediatek: Add missing of_node_put() in ufs_mtk_probe()
Zou Wei [Thu, 17 Jun 2021 11:32:02 +0000 (19:32 +0800)]
scsi: ufs: ufs-mediatek: Add missing of_node_put() in ufs_mtk_probe()

The function is missing a of_node_put() on node. Fix this by adding the
call before returning.

Link: https://lore.kernel.org/r/1623929522-4389-1-git-send-email-zou_wei@huawei.com
Reported-by: Hulk Robot <hulkci@huawei.com>
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Zou Wei <zou_wei@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: elx: libefc: Fix IRQ restore in efc_domain_dispatch_frame()
Dan Carpenter [Fri, 18 Jun 2021 13:43:59 +0000 (16:43 +0300)]
scsi: elx: libefc: Fix IRQ restore in efc_domain_dispatch_frame()

Calling a nested spin_lock_irqsave() will overwrite the original "flags" so
that they can not be enabled again at the end.

Link: https://lore.kernel.org/r/YMyjH16k4M1yEmmU@mwanda
Fixes: 3146240f19bf ("scsi: elx: libefc: FC Domain state machine interfaces")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: elx: libefc: Fix less than zero comparison of a unsigned int
Colin Ian King [Wed, 16 Jun 2021 17:04:01 +0000 (18:04 +0100)]
scsi: elx: libefc: Fix less than zero comparison of a unsigned int

The comparison of the u32 variable rc to less than zero always false
because it is unsigned. Fix this by making it an int.

Link: https://lore.kernel.org/r/20210616170401.15831-1-colin.king@canonical.com
Fixes: 202bfdffae27 ("scsi: elx: libefc: FC node ELS and state handling")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Addresses-Coverity: ("Unsigned compared against 0")

3 years agoscsi: elx: efct: Fix pointer error checking in debugfs init
James Smart [Fri, 18 Jun 2021 23:30:04 +0000 (16:30 -0700)]
scsi: elx: efct: Fix pointer error checking in debugfs init

debugfs_create_xxx routines, which return pointers, are being checked for
error by looking for NULL values. The routines may return pointer-munged
-Exxx codes, so they should be using IS_ERR() to adapt.

There are two cases:

 - The first case is on initial directory creation, which actually doesn't
   need to be checked. So remove the check.

 - Creation of the sessions subdirectory. Modify this creation to create
   under the initial directory created, and fix failure check.

Link: https://lore.kernel.org/r/20210618233004.83769-1-jsmart2021@gmail.com
Fixes: 4df84e846624 ("scsi: elx: efct: Driver initialization routines")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: elx: efct: Fix is_originator return code type
James Smart [Fri, 18 Jun 2021 23:15:24 +0000 (16:15 -0700)]
scsi: elx: efct: Fix is_originator return code type

efct_hw_iotype_is_originator() is returning a negative (-EIO) status which
doesn't make sense for a u8 function type.

Reviewing the code, the function only needs to return true/false, thus a
bool status is most appropriate.

Change the function return type and patch up the one callee as the bool
inverses the if check.

Link: https://lore.kernel.org/r/20210618231524.83179-1-jsmart2021@gmail.com
Fixes: 4df84e846624 ("scsi: elx: efct: Driver initialization routines")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: elx: efct: Fix link error for _bad_cmpxchg
James Smart [Fri, 18 Jun 2021 17:40:50 +0000 (10:40 -0700)]
scsi: elx: efct: Fix link error for _bad_cmpxchg

cmpxchg is being used on a bool type, which is requiring architecture
support that isn't compatible with a bool.

Convert variable abort_in_progress from bool to int.

Link: https://lore.kernel.org/r/20210618174050.80302-1-jsmart2021@gmail.com
Fixes: ebc076b3eddc ("scsi: elx: efct: Tie into kernel Kconfig and build process")
Reported-by: kernel test robot <lkp@intel.com>
Co-developed-by: Ram Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: Ram Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: elx: efct: Eliminate unnecessary boolean check in efct_hw_command_cancel()
Nathan Chancellor [Thu, 17 Jun 2021 06:31:23 +0000 (23:31 -0700)]
scsi: elx: efct: Eliminate unnecessary boolean check in efct_hw_command_cancel()

clang warns:

drivers/scsi/elx/efct/efct_hw.c:1523:17: warning: address of array
'ctx->buf' will always evaluate to 'true' [-Wpointer-bool-conversion]
                              (!ctx->buf ? U32_MAX : *((u32 *)ctx->buf)));
                               ~~~~~~^~~

buf is an array in the middle of a struct so deferencing it is not a
problem as long as ctx is not NULL. Eliminate the check, which fixes the
warning.

Link: https://github.com/ClangBuiltLinux/linux/issues/1398
Link: https://lore.kernel.org/r/20210617063123.21239-1-nathan@kernel.org
Fixes: 580c0255e4ef ("scsi: elx: efct: RQ buffer, memory pool allocation and deallocation APIs")
Reviewed-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: elx: efct: Do not use id uninitialized in efct_lio_setup_session()
Nathan Chancellor [Thu, 17 Jun 2021 06:17:21 +0000 (23:17 -0700)]
scsi: elx: efct: Do not use id uninitialized in efct_lio_setup_session()

clang warns:

drivers/scsi/elx/efct/efct_lio.c:1216:24: warning: variable 'id' is
uninitialized when used here [-Wuninitialized]
                      se_sess, node, id);
                                     ^~

Shuffle the debug print after id's initialization so that the actual value
is printed.

Link: https://github.com/ClangBuiltLinux/linux/issues/1397
Link: https://lore.kernel.org/r/20210617061721.2405511-1-nathan@kernel.org
Fixes: 692e5d73a811 ("scsi: elx: efct: LIO backend interface routines")
Reviewed-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: elx: efct: Fix error handling in efct_hw_init()
Wei Yongjun [Thu, 17 Jun 2021 02:48:37 +0000 (02:48 +0000)]
scsi: elx: efct: Fix error handling in efct_hw_init()

Fix to return negative error code -ENOMEM from the error handling case
instead of 0. Also fix typo in error message.

Link: https://lore.kernel.org/r/20210617024837.1023069-1-weiyongjun1@huawei.com
Fixes: 4df84e846624 ("scsi: elx: efct: Driver initialization routines")
Reported-by: Hulk Robot <hulkci@huawei.com>
Reviewed-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: elx: efct: Remove redundant initialization of variable lun
Colin Ian King [Wed, 16 Jun 2021 17:16:21 +0000 (18:16 +0100)]
scsi: elx: efct: Remove redundant initialization of variable lun

The variable "lun" is being initialized with a value that is never read, it
is being updated later on. The assignment is redundant and can be removed.

Link: https://lore.kernel.org/r/20210616171621.16176-1-colin.king@canonical.com
Reviewed-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Addresses-Coverity: ("Unused value")

3 years agoscsi: elx: efct: Fix spelling mistake "Unexected" -> "Unexpected"
Colin Ian King [Wed, 16 Jun 2021 14:26:37 +0000 (15:26 +0100)]
scsi: elx: efct: Fix spelling mistake "Unexected" -> "Unexpected"

There is a spelling mistake in a efc_log_info message. Fix it.

Link: https://lore.kernel.org/r/20210616142637.12706-1-colin.king@canonical.com
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: lpfc: Fix build error in lpfc_scsi.c
James Smart [Fri, 18 Jun 2021 17:18:42 +0000 (10:18 -0700)]
scsi: lpfc: Fix build error in lpfc_scsi.c

Integration with VMID patches resulted in a build error when
CONFIG_DEBUG_FS is disabled and driver option CONFIG_SCSI_LPFC_DEBUG_FS is
disabled.

It results in an undefined variable:
lpfc_scsi:5595:3: error: 'uuid' undeclared (first use in this function); did you mean 'upid'?

Link: https://lore.kernel.org/r/20210618171842.79710-1-jsmart2021@gmail.com
Fixes: 33c79741deaf ("scsi: lpfc: vmid: Introduce VMID in I/O path")
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: target: iscsi: Remove redundant continue statement
Colin Ian King [Thu, 17 Jun 2021 11:43:47 +0000 (12:43 +0100)]
scsi: target: iscsi: Remove redundant continue statement

The continue statement at the end of a loop has no effect, remove it.

Link: https://lore.kernel.org/r/20210617114347.10247-1-colin.king@canonical.com
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Addresses-Coverity: ("Continue has no effect")

3 years agoscsi: qla4xxx: Remove redundant continue statement
Colin Ian King [Thu, 17 Jun 2021 07:37:43 +0000 (08:37 +0100)]
scsi: qla4xxx: Remove redundant continue statement

The continue statement at the end of a for-loop has no effect, remove it.

Link: https://lore.kernel.org/r/20210617073743.151008-1-colin.king@canonical.com
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Addresses-Coverity: ("Continue has no effect")

3 years agoscsi: ppa: Switch to use module_parport_driver()
Andy Shevchenko [Wed, 16 Jun 2021 14:25:40 +0000 (17:25 +0300)]
scsi: ppa: Switch to use module_parport_driver()

Switch to use module_parport_driver() to reduce boilerplate code.

Link: https://lore.kernel.org/r/20210616142540.45676-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: imm: Switch to use module_parport_driver()
Andy Shevchenko [Wed, 16 Jun 2021 14:24:29 +0000 (17:24 +0300)]
scsi: imm: Switch to use module_parport_driver()

Switch to use module_parport_driver() to reduce boilerplate code.

Link: https://lore.kernel.org/r/20210616142429.45373-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: mpt3sas: Fix error return value in _scsih_expander_add()
Zhen Lei [Fri, 14 May 2021 08:13:00 +0000 (16:13 +0800)]
scsi: mpt3sas: Fix error return value in _scsih_expander_add()

When an expander does not contain any 'phys', an appropriate error code -1
should be returned, as done elsewhere in this function. However, we
currently do not explicitly assign this error code to 'rc'. As a result, 0
was incorrectly returned.

Link: https://lore.kernel.org/r/20210514081300.6650-1-thunder.leizhen@huawei.com
Fixes: f92363d12359 ("[SCSI] mpt3sas: add new driver supporting 12GB SAS")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: mpt3sas: Fix Coverity reported issue
Suganath Prabu S [Fri, 18 Jun 2021 15:55:06 +0000 (21:25 +0530)]
scsi: mpt3sas: Fix Coverity reported issue

Fix the structurally dead code (UNREACHABLE) type of error reported by
Coverity.

Link: https://lore.kernel.org/r/20210618155506.2609112-1-suganath-prabu.subramani@broadcom.com
Reported-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Suganath Prabu S <suganath-prabu.subramani@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: mpi3mr: Make some symbols static
Yang Yingliang [Fri, 4 Jun 2021 07:14:07 +0000 (15:14 +0800)]
scsi: mpi3mr: Make some symbols static

Fix the following warnings:

  drivers/scsi/mpi3mr/mpi3mr_os.c:24:5: warning: symbol 'prot_mask' was not declared. Should it be static?
  drivers/scsi/mpi3mr/mpi3mr_os.c:28:5: warning: symbol 'prot_guard_mask' was not declared. Should it be static?
  drivers/scsi/mpi3mr/mpi3mr_os.c:31:5: warning: symbol 'logging_level' was not declared. Should it be static?

Link: https://lore.kernel.org/r/20210604071407.1360742-1-yangyingliang@huawei.com
Reported-by: Hulk Robot <hulkci@huawei.com>
Acked-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: mpi3mr: Fix error return code in mpi3mr_init_ioc()
Yang Yingliang [Thu, 3 Jun 2021 15:16:53 +0000 (23:16 +0800)]
scsi: mpi3mr: Fix error return code in mpi3mr_init_ioc()

Fix to return a negative error code from the error handling case instead of
0 as done elsewhere in this function.

Link: https://lore.kernel.org/r/20210603151653.711020-1-yangyingliang@huawei.com
Fixes: fb9b04574f14 ("scsi: mpi3mr: Add support for recovering controller")
Fixes: 824a156633df ("scsi: mpi3mr: Base driver code")
Reported-by: Hulk Robot <hulkci@huawei.com>
Acked-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: mpi3mr: Fix missing unlock on error
Yang Yingliang [Thu, 3 Jun 2021 15:28:03 +0000 (23:28 +0800)]
scsi: mpi3mr: Fix missing unlock on error

Goto unlock path before return from function in the error handling case.

Link: https://lore.kernel.org/r/20210603152803.717505-1-yangyingliang@huawei.com
Fixes: c9566231cfaf ("scsi: mpi3mr: Create operational request and reply queue pair")
Reported-by: Hulk Robot <hulkci@huawei.com>
Acked-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: elx: efct: Tie into kernel Kconfig and build process
James Smart [Tue, 1 Jun 2021 23:55:12 +0000 (16:55 -0700)]
scsi: elx: efct: Tie into kernel Kconfig and build process

This final patch ties the efct driver into the kernel Kconfig and build
linkages in the drivers/scsi directory.

Link: https://lore.kernel.org/r/20210601235512.20104-32-jsmart2021@gmail.com
Reported-by: kernel test robot <lkp@intel.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Daniel Wagner <dwagner@suse.de>
Co-developed-by: Ram Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: Ram Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: elx: efct: Add Makefile and Kconfig for efct driver
James Smart [Tue, 1 Jun 2021 23:55:11 +0000 (16:55 -0700)]
scsi: elx: efct: Add Makefile and Kconfig for efct driver

Add efct driver Kconfig and Makefiles.

Link: https://lore.kernel.org/r/20210601235512.20104-31-jsmart2021@gmail.com
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Daniel Wagner <dwagner@suse.de>
Co-developed-by: Ram Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: Ram Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: elx: efct: Transport class host interface support
James Smart [Tue, 1 Jun 2021 23:55:10 +0000 (16:55 -0700)]
scsi: elx: efct: Transport class host interface support

Integration with the scsi_fc_transport host interfaces.

Link: https://lore.kernel.org/r/20210601235512.20104-30-jsmart2021@gmail.com
Reviewed-by: Daniel Wagner <dwagner@suse.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Co-developed-by: Ram Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: Ram Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: elx: efct: Transport and hardware teardown routines
James Smart [Tue, 1 Jun 2021 23:55:09 +0000 (16:55 -0700)]
scsi: elx: efct: Transport and hardware teardown routines

Implement routines to detach transport and hardware objects.

Link: https://lore.kernel.org/r/20210601235512.20104-29-jsmart2021@gmail.com
Reviewed-by: Daniel Wagner <dwagner@suse.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Co-developed-by: Ram Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: Ram Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: elx: efct: Link and host statistics
James Smart [Tue, 1 Jun 2021 23:55:08 +0000 (16:55 -0700)]
scsi: elx: efct: Link and host statistics

Add routines to retrieve link stats and host stats, add firmware update
helper routines.

Link: https://lore.kernel.org/r/20210601235512.20104-28-jsmart2021@gmail.com
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Daniel Wagner <dwagner@suse.de>
Co-developed-by: Ram Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: Ram Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: elx: efct: Hardware I/O submission routines
James Smart [Tue, 1 Jun 2021 23:55:07 +0000 (16:55 -0700)]
scsi: elx: efct: Hardware I/O submission routines

Routines that write I/O to work queue, send SRRs and raw frames.

Link: https://lore.kernel.org/r/20210601235512.20104-27-jsmart2021@gmail.com
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Daniel Wagner <dwagner@suse.de>
Co-developed-by: Ram Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: Ram Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: elx: efct: LIO backend interface routines
James Smart [Tue, 1 Jun 2021 23:55:06 +0000 (16:55 -0700)]
scsi: elx: efct: LIO backend interface routines

Add LIO backend template registration and template functions.

Link: https://lore.kernel.org/r/20210601235512.20104-26-jsmart2021@gmail.com
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Daniel Wagner <dwagner@suse.de>
Co-developed-by: Ram Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: Ram Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: elx: efct: SCSI I/O handling routines
James Smart [Tue, 1 Jun 2021 23:55:05 +0000 (16:55 -0700)]
scsi: elx: efct: SCSI I/O handling routines

Routines for SCSI transport IO alloc, build and send I/O.

Link: https://lore.kernel.org/r/20210601235512.20104-25-jsmart2021@gmail.com
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Daniel Wagner <dwagner@suse.de>
Co-developed-by: Ram Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: Ram Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: elx: efct: Unsolicited FC frame processing routines
James Smart [Tue, 1 Jun 2021 23:55:04 +0000 (16:55 -0700)]
scsi: elx: efct: Unsolicited FC frame processing routines

Add routines to handle unsolicited FC frames.

Link: https://lore.kernel.org/r/20210601235512.20104-24-jsmart2021@gmail.com
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Daniel Wagner <dwagner@suse.de>
Co-developed-by: Ram Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: Ram Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: elx: efct: Hardware queues processing
James Smart [Tue, 1 Jun 2021 23:55:03 +0000 (16:55 -0700)]
scsi: elx: efct: Hardware queues processing

Add driver definitions for:

 - Routines for EQ, CQ, WQ and RQ processing.

 - Routines for I/O object pool allocation and deallocation.

Link: https://lore.kernel.org/r/20210601235512.20104-23-jsmart2021@gmail.com
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Daniel Wagner <dwagner@suse.de>
Co-developed-by: Ram Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: Ram Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: elx: efct: Hardware I/O and SGL initialization
James Smart [Tue, 1 Jun 2021 23:55:02 +0000 (16:55 -0700)]
scsi: elx: efct: Hardware I/O and SGL initialization

Add driver definitions for:

 - Routines to create I/O interfaces (wqs, etc), SGL initialization, and
   configure hardware features.

Link: https://lore.kernel.org/r/20210601235512.20104-22-jsmart2021@gmail.com
Reviewed-by: Daniel Wagner <dwagner@suse.de>
Co-developed-by: Ram Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: Ram Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: elx: efct: RQ buffer, memory pool allocation and deallocation APIs
James Smart [Tue, 1 Jun 2021 23:55:01 +0000 (16:55 -0700)]
scsi: elx: efct: RQ buffer, memory pool allocation and deallocation APIs

Add driver definitions for:

 - RQ data buffer allocation and deallocate.

 - Memory pool allocation and deallocation APIs.

 - Mailbox command submission and completion routines.

Link: https://lore.kernel.org/r/20210601235512.20104-21-jsmart2021@gmail.com
Reviewed-by: Daniel Wagner <dwagner@suse.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Co-developed-by: Ram Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: Ram Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: elx: efct: Hardware queue creation and deletion
James Smart [Tue, 1 Jun 2021 23:55:00 +0000 (16:55 -0700)]
scsi: elx: efct: Hardware queue creation and deletion

Add routines for queue creation, deletion, and configuration.

Link: https://lore.kernel.org/r/20210601235512.20104-20-jsmart2021@gmail.com
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Daniel Wagner <dwagner@suse.de>
Co-developed-by: Ram Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: Ram Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: elx: efct: Driver initialization routines
James Smart [Tue, 1 Jun 2021 23:54:59 +0000 (16:54 -0700)]
scsi: elx: efct: Driver initialization routines

Add driver definitions for:

 - Emulex FC Target driver init, attach and hardware setup routines.

Link: https://lore.kernel.org/r/20210601235512.20104-19-jsmart2021@gmail.com
Reviewed-by: Daniel Wagner <dwagner@suse.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Co-developed-by: Ram Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: Ram Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: elx: efct: Data structures and defines for hw operations
James Smart [Tue, 1 Jun 2021 23:54:58 +0000 (16:54 -0700)]
scsi: elx: efct: Data structures and defines for hw operations

Start the population of the efct target mode driver.  The driver is
contained in the drivers/scsi/elx/efct subdirectory.

Create the efct directory and start population of the driver by adding
SLI-4 configuration parameters, data structures for configuring SLI-4
queues, converting from OS to SLI-4 IO requests, and handling async events.

Link: https://lore.kernel.org/r/20210601235512.20104-18-jsmart2021@gmail.com
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Daniel Wagner <dwagner@suse.de>
Co-developed-by: Ram Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: Ram Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: elx: libefc: Register discovery objects with hardware
James Smart [Tue, 1 Jun 2021 23:54:57 +0000 (16:54 -0700)]
scsi: elx: libefc: Register discovery objects with hardware

Add library interface definitions for:

 - Registrations for VFI, VPI and RPI.

Link: https://lore.kernel.org/r/20210601235512.20104-17-jsmart2021@gmail.com
Reviewed-by: Daniel Wagner <dwagner@suse.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Co-developed-by: Ram Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: Ram Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: elx: libefc: Extended link Service I/O handling
James Smart [Tue, 1 Jun 2021 23:54:56 +0000 (16:54 -0700)]
scsi: elx: libefc: Extended link Service I/O handling

Add library interface definitions for:

 - Functions to build and send ELS/CT/BLS commands and responses.

Link: https://lore.kernel.org/r/20210601235512.20104-16-jsmart2021@gmail.com
Reviewed-by: Daniel Wagner <dwagner@suse.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Co-developed-by: Ram Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: Ram Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: elx: libefc: FC node ELS and state handling
James Smart [Tue, 1 Jun 2021 23:54:55 +0000 (16:54 -0700)]
scsi: elx: libefc: FC node ELS and state handling

Add library interface definitions for:

 - FC node PRLI handling and state management.

Link: https://lore.kernel.org/r/20210601235512.20104-15-jsmart2021@gmail.com
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Daniel Wagner <dwagner@suse.de>
Co-developed-by: Ram Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: Ram Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: elx: libefc: Fabric node state machine interfaces
James Smart [Tue, 1 Jun 2021 23:54:54 +0000 (16:54 -0700)]
scsi: elx: libefc: Fabric node state machine interfaces

Add library interface definitions for:

 - Fabric node initialization and logins.

 - Name/Directory Services node.

 - Fabric Controller node to process rscn events.

These are all interactions with remote ports that correspond to well-known
fabric entities

Link: https://lore.kernel.org/r/20210601235512.20104-14-jsmart2021@gmail.com
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Daniel Wagner <dwagner@suse.de>
Co-developed-by: Ram Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: Ram Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: elx: libefc: Remote node state machine interfaces
James Smart [Tue, 1 Jun 2021 23:54:53 +0000 (16:54 -0700)]
scsi: elx: libefc: Remote node state machine interfaces

Add library interface definitions for:

 - Remote node (aka remote port) allocation, initializaion and destroy
   routines.

Link: https://lore.kernel.org/r/20210601235512.20104-13-jsmart2021@gmail.com
Reviewed-by: Daniel Wagner <dwagner@suse.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Co-developed-by: Ram Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: Ram Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: elx: libefc: SLI and FC PORT state machine interfaces
James Smart [Tue, 1 Jun 2021 23:54:52 +0000 (16:54 -0700)]
scsi: elx: libefc: SLI and FC PORT state machine interfaces

Add library interface definitions for:

 - SLI and FC port (aka n_port_id) registration, allocation and
   deallocation.

Link: https://lore.kernel.org/r/20210601235512.20104-12-jsmart2021@gmail.com
Reviewed-by: Daniel Wagner <dwagner@suse.de>
Co-developed-by: Ram Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: Ram Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: elx: libefc: FC Domain state machine interfaces
James Smart [Tue, 1 Jun 2021 23:54:51 +0000 (16:54 -0700)]
scsi: elx: libefc: FC Domain state machine interfaces

Add library interface definitions for:

 - FC Domain registration, allocation and deallocation sequence

Link: https://lore.kernel.org/r/20210601235512.20104-11-jsmart2021@gmail.com
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Daniel Wagner <dwagner@suse.de>
Co-developed-by: Ram Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: Ram Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: elx: libefc: Emulex FC discovery library APIs and definitions
James Smart [Tue, 1 Jun 2021 23:54:50 +0000 (16:54 -0700)]
scsi: elx: libefc: Emulex FC discovery library APIs and definitions

Add library interface definitions for:

 - SLI/Local FC port objects

 - efc_domain_s: FC domain (aka fabric) objects

 - efc_node_s: FC node (aka remote ports) objects

Link: https://lore.kernel.org/r/20210601235512.20104-10-jsmart2021@gmail.com
Reviewed-by: Daniel Wagner <dwagner@suse.de>
Co-developed-by: Ram Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: Ram Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: elx: libefc: Generic state machine framework
James Smart [Tue, 1 Jun 2021 23:54:49 +0000 (16:54 -0700)]
scsi: elx: libefc: Generic state machine framework

Start the population of the libefc library.

The library will contain common tasks usable by a target or initiator
driver. The library will also contain a FC discovery state machine
interface.

Creates the library directory and add definitions for the discovery state
machine interface.

Link: https://lore.kernel.org/r/20210601235512.20104-9-jsmart2021@gmail.com
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Daniel Wagner <dwagner@suse.de>
Co-developed-by: Ram Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: Ram Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: elx: libefc_sli: APIs to setup SLI library
James Smart [Tue, 1 Jun 2021 23:54:48 +0000 (16:54 -0700)]
scsi: elx: libefc_sli: APIs to setup SLI library

Add APIs to initialize the library, initialize the SLI Port, reset
firmware, terminate the SLI Port, and terminate the library.

Link: https://lore.kernel.org/r/20210601235512.20104-8-jsmart2021@gmail.com
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Daniel Wagner <dwagner@suse.de>
Co-developed-by: Ram Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: Ram Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: elx: libefc_sli: BMBX routines and SLI config commands
James Smart [Tue, 1 Jun 2021 23:54:47 +0000 (16:54 -0700)]
scsi: elx: libefc_sli: BMBX routines and SLI config commands

Add routines to create mailbox commands used during adapter initialization
and add APIs to issue mailbox commands to the adapter through the bootstrap
mailbox register.

Link: https://lore.kernel.org/r/20210601235512.20104-7-jsmart2021@gmail.com
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Daniel Wagner <dwagner@suse.de>
Co-developed-by: Ram Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: Ram Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: elx: libefc_sli: Populate and post different WQEs
James Smart [Tue, 1 Jun 2021 23:54:46 +0000 (16:54 -0700)]
scsi: elx: libefc_sli: Populate and post different WQEs

Add service routines to create different WQEs and add APIs to issue iread,
iwrite, treceive, tsend and other work queue entries.

Link: https://lore.kernel.org/r/20210601235512.20104-6-jsmart2021@gmail.com
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Daniel Wagner <dwagner@suse.de>
Co-developed-by: Ram Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: Ram Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: elx: libefc_sli: Queue create/destroy/parse routines
James Smart [Tue, 1 Jun 2021 23:54:45 +0000 (16:54 -0700)]
scsi: elx: libefc_sli: Queue create/destroy/parse routines

Add service routines to create mailbox commands and add APIs to
create/destroy/parse SLI-4 EQ, CQ, RQ and MQ queues.

Link: https://lore.kernel.org/r/20210601235512.20104-5-jsmart2021@gmail.com
Reviewed-by: Daniel Wagner <dwagner@suse.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Co-developed-by: Ram Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: Ram Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: elx: libefc_sli: Data structures and defines for mbox commands
James Smart [Tue, 1 Jun 2021 23:54:44 +0000 (16:54 -0700)]
scsi: elx: libefc_sli: Data structures and defines for mbox commands

Add definitions for SLI-4 mailbox commands and responses.

Link: https://lore.kernel.org/r/20210601235512.20104-4-jsmart2021@gmail.com
Reviewed-by: Daniel Wagner <dwagner@suse.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Co-developed-by: Ram Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: Ram Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: elx: libefc_sli: SLI Descriptors and Queue entries
James Smart [Tue, 1 Jun 2021 23:54:43 +0000 (16:54 -0700)]
scsi: elx: libefc_sli: SLI Descriptors and Queue entries

Continue the libefc_sli SLI-4 library population.

Add SLI-4 Data structures and defines for:

 - Buffer Descriptors (BDEs)

 - Scatter/Gather List elements (SGEs)

 - Queues and their Entry Descriptions for: Event Queues (EQs), Completion
   Queues (CQs), Receive Queues (RQs), and the Mailbox Queue (MQ).

Link: https://lore.kernel.org/r/20210601235512.20104-3-jsmart2021@gmail.com
Reviewed-by: Daniel Wagner <dwagner@suse.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Co-developed-by: Ram Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: Ram Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: elx: libefc_sli: SLI-4 register offsets and field definitions
James Smart [Tue, 1 Jun 2021 23:54:42 +0000 (16:54 -0700)]
scsi: elx: libefc_sli: SLI-4 register offsets and field definitions

This is the initial patch for the new Emulex target mode SCSI driver.

 - Create the new Emulex source level directory drivers/scsi/elx and add
   the directory to the MAINTAINERS file.

 - Create the first library subdirectory drivers/scsi/elx/libefc_sli.  This
   library is a SLI-4 interface library.

 - Start the population of the libefc_sli library with definitions of SLI-4
   hardware register offsets and definitions.

Link: https://lore.kernel.org/r/20210601235512.20104-2-jsmart2021@gmail.com
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Daniel Wagner <dwagner@suse.de>
Co-developed-by: Ram Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: Ram Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: pm8001: Remove unnecessary OOM message
Zhen Lei [Thu, 10 Jun 2021 09:46:05 +0000 (17:46 +0800)]
scsi: pm8001: Remove unnecessary OOM message

Fixes scripts/checkpatch.pl warning:
WARNING: Possible unnecessary 'out of memory' message

Remove it can help us save a bit of memory.

Also change the return error code from "-1" to "-ENOMEM".

Link: https://lore.kernel.org/r/20210610094605.16672-2-thunder.leizhen@huawei.com
Acked-by: Jack Wang <jinpu.wang@ionos.com>
Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: qla2xxx: Use list_move_tail() instead of list_del()/list_add_tail()
Baokun Li [Wed, 9 Jun 2021 07:23:21 +0000 (15:23 +0800)]
scsi: qla2xxx: Use list_move_tail() instead of list_del()/list_add_tail()

Using list_move_tail() instead of list_del() + list_add_tail().

Link: https://lore.kernel.org/r/20210609072321.1356896-1-libaokun1@huawei.com
Reported-by: Hulk Robot <hulkci@huawei.com>
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Baokun Li <libaokun1@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: ufs-mediatek: Create reset control device_link
Peter Wang [Wed, 2 Jun 2021 02:42:00 +0000 (10:42 +0800)]
scsi: ufs-mediatek: Create reset control device_link

Mediatek UFS reset function relies on Reset Control provided by
reset-ti-syscon. To make Mediatek Reset Control work properly, select
reset-ti-syscon to ensure it is being built.

In addition, establish device_link to wait until reset-ti-syscon
initialization is complete during UFS probing.

Link: https://lore.kernel.org/r/1622601720-22466-1-git-send-email-peter.wang@mediatek.com
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Peter Wang <peter.wang@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: qla2xxx: Remove duplicate declarations
Shaokun Zhang [Mon, 24 May 2021 08:03:22 +0000 (16:03 +0800)]
scsi: qla2xxx: Remove duplicate declarations

qla2x00_post_uevent_work(), qla2x00_free_fcport() and ql2xexlogins are
declared multiple times. Remove the duplicates.

Link: https://lore.kernel.org/r/1621843402-34828-1-git-send-email-zhangshaokun@hisilicon.com
Cc: Nilesh Javali <njavali@marvell.com>
Cc: GR-QLogic-Storage-Upstream@marvell.com
Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Shaokun Zhang <zhangshaokun@hisilicon.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: lpfc: Use list_move_tail() instead of list_del()/list_add_tail()
Zou Wei [Tue, 8 Jun 2021 00:51:33 +0000 (08:51 +0800)]
scsi: lpfc: Use list_move_tail() instead of list_del()/list_add_tail()

Using list_move_tail() instead of list_del() + list_add_tail().

Link: https://lore.kernel.org/r/1623113493-49384-1-git-send-email-zou_wei@huawei.com
Reported-by: Hulk Robot <hulkci@huawei.com>
Reviewed-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Zou Wei <zou_wei@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: storvsc: Correctly handle multiple flags in srb_status
Michael Kelley [Fri, 4 Jun 2021 17:21:03 +0000 (10:21 -0700)]
scsi: storvsc: Correctly handle multiple flags in srb_status

Hyper-V is observed to sometimes set multiple flags in the srb_status, such
as ABORTED and ERROR. Current code in storvsc_handle_error() handles only a
single flag being set, and does nothing when multiple flags are set.  Fix
this by changing the case statement into a series of "if" statements
testing individual flags. The functionality for handling each flag is
unchanged.

Link: https://lore.kernel.org/r/1622827263-12516-3-git-send-email-mikelley@microsoft.com
Signed-off-by: Michael Kelley <mikelley@microsoft.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: storvsc: Update error logging
Michael Kelley [Fri, 4 Jun 2021 17:21:02 +0000 (10:21 -0700)]
scsi: storvsc: Update error logging

When an I/O error is reported by the underlying Hyper-V host, current code
provides details only when the logging level is set to WARN, making it more
difficult to diagnose problems in live customer situations. Fix this by
reporting details at ERROR level, which is the default.  Also add more
information, including the Hyper-V error code, and the tag # so that the
message can be matched with messages at the SCSI and blk-mq levels.

Also, sense information logging is inconsistent and duplicative. The
existence of sense info is first logged at WARN level, and then full sense
info is logged at ERROR level. Fix this by removing the logging of the
existence of sense info, and change the logging of full sense info to WARN
level in favor of letting the generic SCSI layer handle such logging. With
the change to WARN level, it's no longer necessary to filter out as noise
any NOT READY sense info generated by the virtual DVD device.

Link: https://lore.kernel.org/r/1622827263-12516-2-git-send-email-mikelley@microsoft.com
Signed-off-by: Michael Kelley <mikelley@microsoft.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: storvsc: Miscellaneous code cleanups
Michael Kelley [Fri, 4 Jun 2021 17:21:01 +0000 (10:21 -0700)]
scsi: storvsc: Miscellaneous code cleanups

As general cleanup and in preparation for subsequent patches:

 - Use min() instead of open coding.

 - Use set_host_byte() instead of open coding access to scsi_status
   field.

 - Collapse nested "if" statements to reduce indentation.

 - Fix other indentation.

 - Remove extra blank lines.

No functional changes.

[mkp: dropped status_byte() which no longer exists]

Link: https://lore.kernel.org/r/1622827263-12516-1-git-send-email-mikelley@microsoft.com
Signed-off-by: Michael Kelley <mikelley@microsoft.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: lpfc: vmid: Introduce VMID in I/O path
Gaurav Srivastava [Tue, 8 Jun 2021 04:35:56 +0000 (10:05 +0530)]
scsi: lpfc: vmid: Introduce VMID in I/O path

Introduce the VMID in the I/O path. Check if the VMID is enabled and if
the I/O belongs to a VM or not.

Link: https://lore.kernel.org/r/20210608043556.274139-14-muneendra.kumar@broadcom.com
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Gaurav Srivastava <gaurav.srivastava@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Muneendra Kumar <muneendra.kumar@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: lpfc: vmid: Add QFPA and VMID timeout check in worker thread
Gaurav Srivastava [Tue, 8 Jun 2021 04:35:55 +0000 (10:05 +0530)]
scsi: lpfc: vmid: Add QFPA and VMID timeout check in worker thread

Add a periodic check for issuing of QFPA command and VMID timeout in the
worker thread. The inactivity timeout check is added via the timer
function.

Link: https://lore.kernel.org/r/20210608043556.274139-13-muneendra.kumar@broadcom.com
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Gaurav Srivastava <gaurav.srivastava@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Muneendra Kumar <muneendra.kumar@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: lpfc: vmid: Timeout implementation for VMID
Gaurav Srivastava [Tue, 8 Jun 2021 04:35:54 +0000 (10:05 +0530)]
scsi: lpfc: vmid: Timeout implementation for VMID

Implement timeout functionality for the VMID. After the set time period of
inactivity, the VMID is deregistered from the switch.

Link: https://lore.kernel.org/r/20210608043556.274139-12-muneendra.kumar@broadcom.com
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Gaurav Srivastava <gaurav.srivastava@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Muneendra Kumar <muneendra.kumar@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: lpfc: vmid: Append the VMID to the wqe before sending
Gaurav Srivastava [Tue, 8 Jun 2021 04:35:53 +0000 (10:05 +0530)]
scsi: lpfc: vmid: Append the VMID to the wqe before sending

Add the VMID in wqe before sending out the request. The type of VMID
depends on the configured type and is checked before being appended.

Link: https://lore.kernel.org/r/20210608043556.274139-11-muneendra.kumar@broadcom.com
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Gaurav Srivastava <gaurav.srivastava@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Muneendra Kumar <muneendra.kumar@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: lpfc: vmid: Implement CT commands for appid
Gaurav Srivastava [Tue, 8 Jun 2021 04:35:52 +0000 (10:05 +0530)]
scsi: lpfc: vmid: Implement CT commands for appid

Implement CT commands for registering and deregistering the appid for the
application. Also, a small change in decrementing the ndlp ref counter has
been added.

Link: https://lore.kernel.org/r/20210608043556.274139-10-muneendra.kumar@broadcom.com
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Gaurav Srivastava <gaurav.srivastava@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Muneendra Kumar <muneendra.kumar@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: lpfc: vmid: Functions to manage VMIDs
Gaurav Srivastava [Tue, 8 Jun 2021 04:35:51 +0000 (10:05 +0530)]
scsi: lpfc: vmid: Functions to manage VMIDs

Implement routines to save, retrieve, and remove the VMIDs from the data
structure. A hash table is used to save the VMIDs and the corresponding
UUIDs associated with the application/VMs.

Link: https://lore.kernel.org/r/20210608043556.274139-9-muneendra.kumar@broadcom.com
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Gaurav Srivastava <gaurav.srivastava@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Muneendra Kumar <muneendra.kumar@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: lpfc: vmid: Implement ELS commands for appid
Gaurav Srivastava [Tue, 8 Jun 2021 04:35:50 +0000 (10:05 +0530)]
scsi: lpfc: vmid: Implement ELS commands for appid

Implement ELS commands QFPA and UVEM for the priority tagging appid
support.

Link: https://lore.kernel.org/r/20210608043556.274139-8-muneendra.kumar@broadcom.com
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Gaurav Srivastava <gaurav.srivastava@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Muneendra Kumar <muneendra.kumar@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: lpfc: vmid: Add support for VMID in mailbox command
Gaurav Srivastava [Tue, 8 Jun 2021 04:35:49 +0000 (10:05 +0530)]
scsi: lpfc: vmid: Add support for VMID in mailbox command

Add supporting datastructures for mailbox command which helps in
determining if the firmware supports appid. Allocate resources for VMID at
initialization time and clean them up on removal.

Link: https://lore.kernel.org/r/20210608043556.274139-7-muneendra.kumar@broadcom.com
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Gaurav Srivastava <gaurav.srivastava@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Muneendra Kumar <muneendra.kumar@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: lpfc: vmid: VMID parameter initialization
Gaurav Srivastava [Tue, 8 Jun 2021 04:35:48 +0000 (10:05 +0530)]
scsi: lpfc: vmid: VMID parameter initialization

Initialize parameters such as type of VMID, max number of VMIDs supported
and timeout value for the VMID registration based on the user input.

Link: https://lore.kernel.org/r/20210608043556.274139-6-muneendra.kumar@broadcom.com
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Gaurav Srivastava <gaurav.srivastava@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Muneendra Kumar <muneendra.kumar@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: lpfc: vmid: Add datastructure for supporting VMID in lpfc
Gaurav Srivastava [Tue, 8 Jun 2021 04:35:47 +0000 (10:05 +0530)]
scsi: lpfc: vmid: Add datastructure for supporting VMID in lpfc

Add the primary datastructures needed to implement VMID in the lpfc
driver. Maintain the capability, current state, and hash table for the
vmid/appid along with other information. This implementation supports the
two versions of vmid implementation (app header and priority tagging).

Link: https://lore.kernel.org/r/20210608043556.274139-5-muneendra.kumar@broadcom.com
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Gaurav Srivastava <gaurav.srivastava@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Muneendra Kumar <muneendra.kumar@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: nvme: Added a new sysfs attribute appid_store
Muneendra Kumar [Tue, 8 Jun 2021 04:35:46 +0000 (10:05 +0530)]
scsi: nvme: Added a new sysfs attribute appid_store

Add a new sysfs attribute, appid_store, which can be used to set the
application identifier in the blkcg associated with a cgroup id.

Below is the interface provided to set the app_id:

  echo "<cgroupid>:<appid>" >> /sys/class/fc/fc_udev_device/appid_store

  echo "457E:100000109b521d27" >> /sys/class/fc/fc_udev_device/appid_store

Link: https://lore.kernel.org/r/20210608043556.274139-4-muneendra.kumar@broadcom.com
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Muneendra Kumar <muneendra.kumar@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: blkcg: Add app identifier support for blkcg
Muneendra Kumar [Tue, 8 Jun 2021 04:35:45 +0000 (10:05 +0530)]
scsi: blkcg: Add app identifier support for blkcg

Add a unique application identifier (i.e fc_app_id member) in blkcg. This
allows identification of traffic belonging to an specific both on the host
and in the fabric infrastructure. As an example, this allows the storage
stack to uniquely identify traffic belong to particular virtual machine.

Link: https://lore.kernel.org/r/20210608043556.274139-3-muneendra.kumar@broadcom.com
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Acked-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Muneendra Kumar <muneendra.kumar@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: cgroup: Add cgroup_get_from_id()
Muneendra Kumar [Tue, 8 Jun 2021 04:35:44 +0000 (10:05 +0530)]
scsi: cgroup: Add cgroup_get_from_id()

Add a new function, cgroup_get_from_id(), to retrieve the cgroup associated
with a cgroup id. Also export the function cgroup_get_e_css() as this is
needed in blk-cgroup.h.

Link: https://lore.kernel.org/r/20210608043556.274139-2-muneendra.kumar@broadcom.com
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Acked-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Muneendra Kumar <muneendra.kumar@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: fc: FDMI enhancement
Javed Hasan [Thu, 3 Jun 2021 12:16:23 +0000 (05:16 -0700)]
scsi: fc: FDMI enhancement

Added RHBA and RPA attributes type and length.

As per FC_GC_7 document section "Table 400 – Attribute Entry Types and
associated Values" ASCII type attributes length can be vary from "4 to 256
byte".  If we keep all RHBA ASCII attributes length 256 then total length
is going upto 2750, which is far more than 2048 (max frame size).

In libfc we do have logic to split FCP commands but not for CT commands.
Practically all version/names get covered with in 64 bytes except OS name,
for that we need 128 bytes.  Hence length of all RBHA ASCII attributes
is reduced to 64 bytes and 128 bytes in case of OS name.

RPA attributes total length is within frame size.

Link: https://lore.kernel.org/r/20210603121623.10084-6-jhasan@marvell.com
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Javed Hasan <jhasan@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: libfc: FDMI enhancements
Javed Hasan [Thu, 3 Jun 2021 12:16:22 +0000 (05:16 -0700)]
scsi: libfc: FDMI enhancements

Add all the attributes for FDMI.

Fall back mechanism is added in between FDMI V2 and FDMI V1 attributes. In
case FDMI get fails for V2 attributes we fall back to V1 attributes.

Link: https://lore.kernel.org/r/20210603121623.10084-5-jhasan@marvell.com
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Javed Hasan <jhasan@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: libfc: Add FDMI-2 attributes
Javed Hasan [Thu, 3 Jun 2021 12:16:21 +0000 (05:16 -0700)]
scsi: libfc: Add FDMI-2 attributes

Add all attributes for RHBA and RPA registration.

Fallback mechanism is added between RBHA V2 and RHBA V1 attributes. In case
RHBA get fails for V2 attributes we fall back to V1 attribute registration.

Link: https://lore.kernel.org/r/20210603121623.10084-4-jhasan@marvell.com
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Javed Hasan <jhasan@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: qedf: Add vendor identifier attribute
Javed Hasan [Thu, 3 Jun 2021 12:16:20 +0000 (05:16 -0700)]
scsi: qedf: Add vendor identifier attribute

Link: https://lore.kernel.org/r/20210603121623.10084-3-jhasan@marvell.com
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Javed Hasan <jhasan@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: libfc: Initialisation of RHBA and RPA attributes
Javed Hasan [Thu, 3 Jun 2021 12:16:19 +0000 (05:16 -0700)]
scsi: libfc: Initialisation of RHBA and RPA attributes

Initialize RHBA and RPA attributes.

Link: https://lore.kernel.org/r/20210603121623.10084-2-jhasan@marvell.com
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Javed Hasan <jhasan@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: libfc: Correct the condition check and invalid argument passed
Javed Hasan [Thu, 3 Jun 2021 10:14:04 +0000 (03:14 -0700)]
scsi: libfc: Correct the condition check and invalid argument passed

Incorrect condition check was leading to data corruption.

Link: https://lore.kernel.org/r/20210603101404.7841-3-jhasan@marvell.com
Fixes: 8fd9efca86d0 ("scsi: libfc: Work around -Warray-bounds warning")
CC: stable@vger.kernel.org
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Javed Hasan <jhasan@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: fc: Correct RHBA attributes length
Javed Hasan [Thu, 3 Jun 2021 10:14:03 +0000 (03:14 -0700)]
scsi: fc: Correct RHBA attributes length

As per the FC-GS-5 specification, attribute lengths of node_name and
manufacturer should in range of "4 to 64 Bytes" only.

Link: https://lore.kernel.org/r/20210603101404.7841-2-jhasan@marvell.com
Fixes: e721eb0616f6 ("scsi: scsi_transport_fc: Match HBA Attribute Length with HBAAPI V2.0 definitions")
CC: stable@vger.kernel.org
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Javed Hasan <jhasan@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>