platform/kernel/linux-starfive.git
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>
3 years agoscsi: hisi_sas: Speed up error handling when internal abort timeout occurs
Luo Jiaxing [Mon, 7 Jun 2021 09:29:39 +0000 (17:29 +0800)]
scsi: hisi_sas: Speed up error handling when internal abort timeout occurs

If an internal task abort timeout occurs, the controller has developed a
fault, and needs to be reset to be recovered.

When this occurs during error handling, the current policy is to allow
error handling to continue, and the inevitable nexus ha reset will handle
the required reset.

However various steps of error handling need to taken before this happens.
These also involve some level of HW interaction, which will also fail with
various timeouts.

Speed up this process by recording a HW fault bit for an internal abort
timeout - when this is set, just automatically error any HW interaction,
and essentially go straight to clear nexus ha (to reset the controller).

Link: https://lore.kernel.org/r/1623058179-80434-6-git-send-email-john.garry@huawei.com
Signed-off-by: Luo Jiaxing <luojiaxing@huawei.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: hisi_sas: Reset controller for internal abort timeout
Luo Jiaxing [Mon, 7 Jun 2021 09:29:38 +0000 (17:29 +0800)]
scsi: hisi_sas: Reset controller for internal abort timeout

If an internal task abort timeout occurs, the controller has developed a
fault, and needs to be reset to be recovered. However if a timeout occurs
during SCSI error handling, issuing a controller reset immediately may
conflict with the error handling.

To handle internal abort in these two scenarios, only queue the reset when
not in an error handling function. In the case of a timeout during error
handling, do nothing and rely on the inevitable ha nexus reset to reset the
controller.

Link: https://lore.kernel.org/r/1623058179-80434-5-git-send-email-john.garry@huawei.com
Signed-off-by: Luo Jiaxing <luojiaxing@huawei.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: hisi_sas: Include HZ in timer macros
Luo Jiaxing [Mon, 7 Jun 2021 09:29:37 +0000 (17:29 +0800)]
scsi: hisi_sas: Include HZ in timer macros

Include HZ in timer macros to make the code more concise.

Link: https://lore.kernel.org/r/1623058179-80434-4-git-send-email-john.garry@huawei.com
Signed-off-by: Luo Jiaxing <luojiaxing@huawei.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: hisi_sas: Run I_T nexus resets in parallel for clear nexus reset
Luo Jiaxing [Mon, 7 Jun 2021 09:29:36 +0000 (17:29 +0800)]
scsi: hisi_sas: Run I_T nexus resets in parallel for clear nexus reset

For a clear nexus reset operation, the I_T nexus resets are executed
serially for each device. For devices attached through an expander, this
may take 2s per device; so, in total, could take a long time.

Reduce the total time by running the I_T nexus resets in parallel through
async operations.

Link: https://lore.kernel.org/r/1623058179-80434-3-git-send-email-john.garry@huawei.com
Signed-off-by: Luo Jiaxing <luojiaxing@huawei.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: hisi_sas: Put a limit of link reset retries
Luo Jiaxing [Mon, 7 Jun 2021 09:29:35 +0000 (17:29 +0800)]
scsi: hisi_sas: Put a limit of link reset retries

If an OOB event is received but the phy still fails to come up, a link
reset will be issued repeatedly at an interval of 20s until the phy comes
up.

Set a limit for link reset issue retries to avoid printing the timeout
message endlessly.

Link: https://lore.kernel.org/r/1623058179-80434-2-git-send-email-john.garry@huawei.com
Signed-off-by: Luo Jiaxing <luojiaxing@huawei.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: qedi: Fix host removal with running sessions
Mike Christie [Wed, 9 Jun 2021 19:27:09 +0000 (14:27 -0500)]
scsi: qedi: Fix host removal with running sessions

qedi_clear_session_ctx() could race with the in-kernel or userspace driven
recovery/removal and we could access a NULL conn or do a double free.

We should be using iscsi_host_remove() to start the removal process from
the driver. It will start the in-kernel recovery and notify userspace that
the driver's scsi_hosts are being removed. iscsid will then drive the
session removal like is done when the logout command is run. When the
sessions are removed, iscsi_host_remove() will return so qedi can finish
knowing there are no running sessions and no new sessions will be allowed.

This also fixes an issue where we check for a NULL conn after already
accessing it introduced in commit 27e986289e73 ("scsi: iscsi: Drop suspend
calls from ep_disconnect") by just removing the function completely.

Link: https://lore.kernel.org/r/20210609192709.5094-1-michael.christie@oracle.com
Fixes: 27e986289e73 ("scsi: iscsi: Drop suspend calls from ep_disconnect")
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: mpi3mr: Fix error handling in mpi3mr_setup_isr()
Dan Carpenter [Wed, 9 Jun 2021 09:27:14 +0000 (12:27 +0300)]
scsi: mpi3mr: Fix error handling in mpi3mr_setup_isr()

The pci_alloc_irq_vectors_affinity() function returns negative error codes
or it returns a number between the minimum vectors (1 in this case) and
max_vectors.  It won't return zero.  Because "i" is a u16 then the error
handling won't work.  And also if it did work the error code was not set.

Really "max_vectors" can be an int as well because we're doing a min_t() on
int type.  The other change is that it's better to remove unnecessary
initialization so that static checkers can warn us if there are ever
uninitialized variable bugs introduced in the future.

I changed the error code from -1 (-EPERM) if the kmalloc() failed to
-ENOMEM.  And on success path I changed it from "return retval;" to "return
0;" which shouldn't affect the compiled code but makes it more readable.

Link: https://lore.kernel.org/r/YMCJcnmSI4kOIyv/@mwanda
Fixes: 824a156633df ("scsi: mpi3mr: Base driver code")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: mpi3mr: Delete unnecessary NULL check
Dan Carpenter [Wed, 9 Jun 2021 09:26:02 +0000 (12:26 +0300)]
scsi: mpi3mr: Delete unnecessary NULL check

The "mrioc->intr_info" pointer can't be NULL, but if it could then the
second iteration through the loop would Oops.  Let's delete the confusing
and impossible NULL check.

Link: https://lore.kernel.org/r/YMCJKgykDYtyvY44@mwanda
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: mpi3mr: Fix a double free
Tomas Henzl [Tue, 8 Jun 2021 14:57:12 +0000 (16:57 +0200)]
scsi: mpi3mr: Fix a double free

Fix a double free, scsi_tgt_priv_data will be freed in
mpi3mr_target_destroy() so remove the kfree() from mpi3mr_target_alloc().
I've also removed few unneeded initialisations.

Link: https://lore.kernel.org/r/20210608145712.16386-1-thenzl@redhat.com
Acked-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: ufs: core: Fix a possible use before initialization case
Can Guo [Wed, 9 Jun 2021 08:24:00 +0000 (01:24 -0700)]
scsi: ufs: core: Fix a possible use before initialization case

In ufshcd_exec_dev_cmd(), if error happens before lrpb is initialized, then
we should bail out instead of letting trace record the error.

Link: https://lore.kernel.org/r/1623227044-22635-1-git-send-email-cang@codeaurora.org
Fixes: a45f937110fa ("scsi: ufs: Optimize host lock on transfer requests send/compl paths")
Reported-by: kernel test robot <lkp@intel.com>
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Can Guo <cang@codeaurora.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: ufs: core: Use UPIU query trace in devman_upiu_cmd()
Bean Huo [Mon, 31 May 2021 10:43:08 +0000 (12:43 +0200)]
scsi: ufs: core: Use UPIU query trace in devman_upiu_cmd()

Since devman_upiu_cmd() is not COMMAND UPIU, and doesn't have CDB, it is
better to use UPIU query trace, which provides more helpful information for
issue troubleshooting.

Link: https://lore.kernel.org/r/20210531104308.391842-5-huobean@gmail.com
Reviewed-by: Can Guo <cang@codeaurora.org>
Signed-off-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: ufs: core: Capture command trace only for the cmd != NULL case
Bean Huo [Mon, 31 May 2021 10:43:07 +0000 (12:43 +0200)]
scsi: ufs: core: Capture command trace only for the cmd != NULL case

For the query request, we already have query_trace, but in
ufshcd_send_command(), there will add two more redundant traces. Since
lrbp->cmd is NULL in the query request, the two trace events below provide
nothing except the tag and DB. Instead of letting them take up the limited
trace ring buffer, it’s better not to print these traces in case of cmd ==
NULL.

ufshcd_command: send_req: ff3b0000.ufs: tag: 28, DB: 0x0, size: -1, IS: 0, LBA: 18446744073709551615, opcode: 0x0 (0x0), group_id: 0x0
ufshcd_command: dev_complete: ff3b0000.ufs: tag: 28, DB: 0x0, size: -1, IS: 0, LBA: 18446744073709551615, opcode: 0x0 (0x0), group_id: 0x0

Link: https://lore.kernel.org/r/20210531104308.391842-4-huobean@gmail.com
Reviewed-by: Can Guo <cang@codeaurora.org>
Signed-off-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: ufs: core: Let UPIU completion trace print RSP UPIU header
Bean Huo [Mon, 31 May 2021 10:43:06 +0000 (12:43 +0200)]
scsi: ufs: core: Let UPIU completion trace print RSP UPIU header

The current UPIU completion event trace still prints the COMMAND UPIU
header, rather than the RSP UPIU header. This makes UPIU command trace
useless in problem shooting in case we receive a trace log from the
customer/field.

There are two important fields in RSP UPIU:

 1. The response field, which indicates the UFS defined overall success or
    failure of the series of Command, Data and RESPONSE UPIU’s that make up
    the execution of a task.

2. The Status field, which contains the command set specific status for a
    specific command issued by the initiator device.

Before this commit, the UPIU paired trace events:

ufshcd_upiu: send_req: fe3b0000.ufs: HDR:01 20 00 1c 00 00 00 00 00 00 00 00, CDB:3b e1 00 00 00 00 00 00 30 00 00 00 00 00 00 00
ufshcd_upiu: complete_rsp: fe3b0000.ufs: HDR:01 20 00 1c 00 00 00 00 00 00 00 00, CDB:3b e1 00 00 00 00 00 00 30 00 00 00 00 00 00 00

After this commit:

ufshcd_upiu: send_req: fe3b0000.ufs: HDR:01 20 00 1c 00 00 00 00 00 00 00 00, CDB:3b e1 00 00 00 00 00 00 30 00 00 00 00 00 00 00
ufshcd_upiu: complete_rsp: fe3b0000.ufs: HDR:21 00 00 1c 00 00 00 00 00 00 00 00, CDB:3b e1 00 00 00 00 00 00 30 00 00 00 00 00 00 00

Link: https://lore.kernel.org/r/20210531104308.391842-3-huobean@gmail.com
Reviewed-by: Can Guo <cang@codeaurora.org>
Signed-off-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: ufs: core: Clean up ufshcd_add_command_trace()
Bean Huo [Mon, 31 May 2021 10:43:05 +0000 (12:43 +0200)]
scsi: ufs: core: Clean up ufshcd_add_command_trace()

To consistent with trace event print, convert the value of the variable
'lba' from a block layer sector address to a logical block adress.

Link: https://lore.kernel.org/r/20210531104308.391842-2-huobean@gmail.com
Suggested-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Can Guo <cang@codeaurora.org>
Signed-off-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: ufs: core: Remove repeated word in comment
Keoseong Park [Fri, 4 Jun 2021 02:40:38 +0000 (11:40 +0900)]
scsi: ufs: core: Remove repeated word in comment

Remove repeated word "for" in comment.

Link: https://lore.kernel.org/r/1891546521.01622777101796.JavaMail.epsvc@epcpadp3
Signed-off-by: Keoseong Park <keosung.park@samsung.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>