OSDN Git Service

tomoyo/tomoyo-test1.git
3 years agoscsi: fdomain: Translate message to host byte status
Hannes Reinecke [Tue, 27 Apr 2021 08:30:42 +0000 (10:30 +0200)]
scsi: fdomain: Translate message to host byte status

Instead of setting the message byte translate it to the appropriate host
byte. As error recovery would return DID_ERROR for any non-zero message
byte the translation doesn't change the error handling.

Link: https://lore.kernel.org/r/20210427083046.31620-37-hare@suse.de
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: fdomain: Drop last argument to fdomain_finish_cmd()
Hannes Reinecke [Tue, 27 Apr 2021 08:30:41 +0000 (10:30 +0200)]
scsi: fdomain: Drop last argument to fdomain_finish_cmd()

Set the SCSI host status before calling fdomain_finish_cmd() and drop the
last argument to that function.

Link: https://lore.kernel.org/r/20210427083046.31620-36-hare@suse.de
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: FlashPoint: Use standard SCSI definitions
Hannes Reinecke [Tue, 27 Apr 2021 08:30:40 +0000 (10:30 +0200)]
scsi: FlashPoint: Use standard SCSI definitions

No point in having the driver providing its own definitions.

Link: https://lore.kernel.org/r/20210427083046.31620-35-hare@suse.de
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: fas216: Use get_status_byte() to avoid using Linux-specific status codes
Hannes Reinecke [Tue, 27 Apr 2021 08:30:39 +0000 (10:30 +0200)]
scsi: fas216: Use get_status_byte() to avoid using Linux-specific status codes

The driver should be using the standard SAM_STAT_ values, and not the
Linux-specific ones.

Link: https://lore.kernel.org/r/20210427083046.31620-34-hare@suse.de
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: fas216: Translate message to host byte status
Hannes Reinecke [Tue, 27 Apr 2021 08:30:38 +0000 (10:30 +0200)]
scsi: fas216: Translate message to host byte status

Instead of setting the message byte translate it to the appropriate host
byte. As error recovery would return DID_ERROR for any non-zero message
byte the translation doesn't change the error handling.

[mkp: zeroday bug report: s/SCpnt->result/SCpnt/]

Link: https://lore.kernel.org/r/20210427083046.31620-33-hare@suse.de
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: advansys: Do not set message byte in SCSI status
Hannes Reinecke [Tue, 27 Apr 2021 08:30:37 +0000 (10:30 +0200)]
scsi: advansys: Do not set message byte in SCSI status

The host byte in the SCSI status takes precedence during error recovery, so
there is no point in setting the message byte in addition to a host byte
which is not DID_OK.

Link: https://lore.kernel.org/r/20210427083046.31620-32-hare@suse.de
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: aha152x: Do not set message byte when calling scsi_done()
Hannes Reinecke [Tue, 27 Apr 2021 08:30:36 +0000 (10:30 +0200)]
scsi: aha152x: Do not set message byte when calling scsi_done()

The done() function is called with a host_byte indicating the actual error
when the message byte is set. As the host byte takes precedence during
error recovery we can drop setting the message byte if the host byte is
set, too.  The only other case is when the host byte is DID_OK, but in that
case the message byte is always COMMAND_COMPLETE (i.e. 0), so we can drop
it there, too.

Link: https://lore.kernel.org/r/20210427083046.31620-31-hare@suse.de
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: aha152x: Modify done() to use separate status bytes
Hannes Reinecke [Tue, 27 Apr 2021 08:30:35 +0000 (10:30 +0200)]
scsi: aha152x: Modify done() to use separate status bytes

Instead of passing in the combined SCSI result values, split them off into
separate status, message, and host byte values.

Link: https://lore.kernel.org/r/20210427083046.31620-30-hare@suse.de
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: acornscsi: Translate message byte to host byte
Hannes Reinecke [Tue, 27 Apr 2021 08:30:34 +0000 (10:30 +0200)]
scsi: acornscsi: Translate message byte to host byte

Instead of setting the message byte translate it to the appropriate host
byte. As error recovery would return DID_ERROR for any non-zero message
byte the translation doesn't change the error handling.  And use SCSI
result accessors while we're at it.

Link: https://lore.kernel.org/r/20210427083046.31620-29-hare@suse.de
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: acornscsi: Remove acornscsi_reportstatus()
Hannes Reinecke [Tue, 27 Apr 2021 08:30:33 +0000 (10:30 +0200)]
scsi: acornscsi: Remove acornscsi_reportstatus()

Unused.

Link: https://lore.kernel.org/r/20210427083046.31620-28-hare@suse.de
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: mesh: Translate message to host byte status
Hannes Reinecke [Tue, 27 Apr 2021 08:30:32 +0000 (10:30 +0200)]
scsi: mesh: Translate message to host byte status

Instead of setting the message byte translate it to a host byte status. As
the error recovery would map it to DID_ERROR anyway the translation doesn't
change the SCSI error handling.

Link: https://lore.kernel.org/r/20210427083046.31620-27-hare@suse.de
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: wd33c93: Translate message byte to host byte
Hannes Reinecke [Tue, 27 Apr 2021 08:30:31 +0000 (10:30 +0200)]
scsi: wd33c93: Translate message byte to host byte

Instead of setting the message byte translate it to the appropriate host
byte. As error recovery would return DID_ERROR for any non-zero message
byte the translation doesn't change the error handling.

Link: https://lore.kernel.org/r/20210427083046.31620-26-hare@suse.de
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: nsp32: Do not set message byte
Hannes Reinecke [Tue, 27 Apr 2021 08:30:30 +0000 (10:30 +0200)]
scsi: nsp32: Do not set message byte

The message byte always devolves to COMMAND_COMPLETE, so there is no point
in setting it.

Link: https://lore.kernel.org/r/20210427083046.31620-25-hare@suse.de
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: nsp32: Whitespace cleanup
Hannes Reinecke [Tue, 27 Apr 2021 08:30:29 +0000 (10:30 +0200)]
scsi: nsp32: Whitespace cleanup

[mkp: fix kernel test robot warning]

Link: https://lore.kernel.org/r/20210427083046.31620-24-hare@suse.de
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: qlogicfas408: Whitespace cleanup
Hannes Reinecke [Tue, 27 Apr 2021 08:30:27 +0000 (10:30 +0200)]
scsi: qlogicfas408: Whitespace cleanup

Link: https://lore.kernel.org/r/20210427083046.31620-22-hare@suse.de
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: qlogicfas408: make ql_pcmd() a void function
Hannes Reinecke [Tue, 27 Apr 2021 08:30:26 +0000 (10:30 +0200)]
scsi: qlogicfas408: make ql_pcmd() a void function

Make ql_pcmd() a void function and set the SCSI result directly.

[mkp: fix zeroday 'result' warning]

Link: https://lore.kernel.org/r/20210427083046.31620-21-hare@suse.de
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
fix

3 years agoscsi: dc395: Translate message bytes
Hannes Reinecke [Tue, 27 Apr 2021 08:30:25 +0000 (10:30 +0200)]
scsi: dc395: Translate message bytes

Drop message byte setting if the host byte is already set, and translate
message bytes into the related host bytes when evaluating an overrun or
underrun.

Link: https://lore.kernel.org/r/20210427083046.31620-20-hare@suse.de
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: dc395: Use standard macros to set SCSI result
Hannes Reinecke [Tue, 27 Apr 2021 08:30:24 +0000 (10:30 +0200)]
scsi: dc395: Use standard macros to set SCSI result

Use standard macros to set the SCSI result and drop the internal ones.

Link: https://lore.kernel.org/r/20210427083046.31620-19-hare@suse.de
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: core: Add scsi_msg_to_host_byte()
Hannes Reinecke [Tue, 27 Apr 2021 08:30:23 +0000 (10:30 +0200)]
scsi: core: Add scsi_msg_to_host_byte()

Add helper to convert message byte into a host byte code.

Link: https://lore.kernel.org/r/20210427083046.31620-18-hare@suse.de
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: core: Add get_{status,host}_byte() accessor functions
Hannes Reinecke [Tue, 27 Apr 2021 08:30:22 +0000 (10:30 +0200)]
scsi: core: Add get_{status,host}_byte() accessor functions

Add accessor functions for the host and status byte.

Link: https://lore.kernel.org/r/20210427083046.31620-17-hare@suse.de
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: NCR5380: Fold SCSI message ABORT onto DID_ABORT
Hannes Reinecke [Tue, 27 Apr 2021 08:30:21 +0000 (10:30 +0200)]
scsi: NCR5380: Fold SCSI message ABORT onto DID_ABORT

The message byte can take only two values, COMMAND_COMPLETE and ABORT.  So
we can easily map ABORT to DID_ABORT and not set the message byte.

Link: https://lore.kernel.org/r/20210427083046.31620-16-hare@suse.de
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: core: Drop the now obsolete driver_byte definitions
Hannes Reinecke [Tue, 27 Apr 2021 08:30:20 +0000 (10:30 +0200)]
scsi: core: Drop the now obsolete driver_byte definitions

The driver_byte field in the result is now unused, so we can drop the
definitions.

Link: https://lore.kernel.org/r/20210427083046.31620-15-hare@suse.de
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: xen-scsifront: Compability status handling
Hannes Reinecke [Tue, 27 Apr 2021 08:30:19 +0000 (10:30 +0200)]
scsi: xen-scsifront: Compability status handling

The Xen guest might run against arbitrary backends, so the driver might
receive a status with driver_byte set. Map these errors to DID_ERROR to be
consistent with recent changes.

Link: https://lore.kernel.org/r/20210427083046.31620-14-hare@suse.de
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: xen-scsiback: Use DID_ERROR instead of DRIVER_ERROR
Hannes Reinecke [Tue, 27 Apr 2021 08:30:18 +0000 (10:30 +0200)]
scsi: xen-scsiback: Use DID_ERROR instead of DRIVER_ERROR

DRIVER_ERROR was supposed to signal an error generated by the driver, which
xen-scsiback arguably isn't. Also the driver bytes don't have a detailed
error recovery, so we should rather return DID_ERROR instead of
DRIVER_ERROR.

Link: https://lore.kernel.org/r/20210427083046.31620-13-hare@suse.de
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: core: Use DID_TIME_OUT instead of DRIVER_TIMEOUT
Hannes Reinecke [Tue, 27 Apr 2021 08:30:17 +0000 (10:30 +0200)]
scsi: core: Use DID_TIME_OUT instead of DRIVER_TIMEOUT

Set DID_TIME_OUT instead of DRIVER_TIMEOUT when a command
is finally marked as failed after error recovery.

Link: https://lore.kernel.org/r/20210427083046.31620-12-hare@suse.de
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: core: Do not use DRIVER_INVALID
Hannes Reinecke [Tue, 27 Apr 2021 08:30:16 +0000 (10:30 +0200)]
scsi: core: Do not use DRIVER_INVALID

There is no point in returning DID_ABORT together with DRIVER_INVALID, as
the caller couldn't care less where the abort originated.  So drop the use
of DRIVER_INVALID.

Link: https://lore.kernel.org/r/20210427083046.31620-11-hare@suse.de
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: core: Kill DRIVER_SENSE
Hannes Reinecke [Tue, 27 Apr 2021 08:30:15 +0000 (10:30 +0200)]
scsi: core: Kill DRIVER_SENSE

Replace the check for DRIVER_SENSE with a check for
scsi_status_is_check_condition().

Audit all callsites to ensure the SAM status is set correctly. For
backwards compability move the DRIVER_SENSE definition to sg.h, and update
sg, bsg, and scsi_ioctl to set the DRIVER_SENSE driver_status whenever
SAM_STAT_CHECK_CONDITION is present.

[mkp: fix zeroday srp warning]

Link: https://lore.kernel.org/r/20210427083046.31620-10-hare@suse.de
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
fix

3 years agoscsi: core: Introduce scsi_status_is_check_condition()
Hannes Reinecke [Tue, 27 Apr 2021 08:30:14 +0000 (10:30 +0200)]
scsi: core: Introduce scsi_status_is_check_condition()

Add a helper function scsi_status_is_check_condition() to encapsulate the
frequent checks for SAM_STAT_CHECK_CONDITION.

Link: https://lore.kernel.org/r/20210427083046.31620-9-hare@suse.de
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: core: Introduce scsi_build_sense()
Hannes Reinecke [Tue, 27 Apr 2021 08:30:13 +0000 (10:30 +0200)]
scsi: core: Introduce scsi_build_sense()

Introduce scsi_build_sense() as a wrapper around scsi_build_sense_buffer()
to format the buffer and set the correct SCSI status.

Link: https://lore.kernel.org/r/20210427083046.31620-8-hare@suse.de
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: core: Stop using DRIVER_ERROR
Hannes Reinecke [Tue, 27 Apr 2021 08:30:12 +0000 (10:30 +0200)]
scsi: core: Stop using DRIVER_ERROR

Return the actual error code in __scsi_execute() (which, according to the
documentation, should have happened anyway).  And audit all callers to cope
with negative return values from __scsi_execute() and friends.

[mkp: resolve conflict and return bool]

Link: https://lore.kernel.org/r/20210427083046.31620-7-hare@suse.de
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: scsi_dh_alua: Check for negative result value
Hannes Reinecke [Tue, 27 Apr 2021 08:30:11 +0000 (10:30 +0200)]
scsi: scsi_dh_alua: Check for negative result value

scsi_execute() will now return a negative error if there was an error prior
to command submission; evaluate that instead if checking for DRIVER_ERROR.

[mkp: build fix]

Link: https://lore.kernel.org/r/20210427083046.31620-6-hare@suse.de
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: core: Reshuffle response handling in scsi_mode_sense()
Hannes Reinecke [Tue, 27 Apr 2021 08:30:10 +0000 (10:30 +0200)]
scsi: core: Reshuffle response handling in scsi_mode_sense()

Reshuffle response handling in scsi_mode_sense() to make the code easier to
follow.

[mkp: fix build]

Link: https://lore.kernel.org/r/20210427083046.31620-5-hare@suse.de
Suggested-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: core: Fixup calling convention for scsi_mode_sense()
Hannes Reinecke [Tue, 27 Apr 2021 08:30:09 +0000 (10:30 +0200)]
scsi: core: Fixup calling convention for scsi_mode_sense()

The description for scsi_mode_sense() claims to return the number of valid
bytes on success, which is not what the code does.  Additionally there is
no gain in returning the SCSI status, as everything the callers do is to
check against scsi_result_is_good(), which is what scsi_mode_sense() does
already.  So change the calling convention to return a standard error code
on failure, and 0 on success, and adapt the description and all callers.

Link: https://lore.kernel.org/r/20210427083046.31620-4-hare@suse.de
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: scsi_ioctl: Return error code when blk_rq_map_kern() fails
Hannes Reinecke [Tue, 27 Apr 2021 08:30:08 +0000 (10:30 +0200)]
scsi: scsi_ioctl: Return error code when blk_rq_map_kern() fails

The callers of sg_scsi_ioctl() already check for negative return values, so
we can drop the usage of DRIVER_ERROR and return the error from
blk_rq_map_kern() instead.

Link: https://lore.kernel.org/r/20210427083046.31620-3-hare@suse.de
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: st: Return error code in st_scsi_execute()
Hannes Reinecke [Tue, 27 Apr 2021 08:30:07 +0000 (10:30 +0200)]
scsi: st: Return error code in st_scsi_execute()

The callers to st_scsi_execute() already check for negative return values,
so we can drop the use of DRIVER_ERROR and return the actual error code.

Link: https://lore.kernel.org/r/20210427083046.31620-2-hare@suse.de
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Acked-by: Kai Mäkisara <kai.makisara@kolumbus.fi>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: ufs: Suppress false positive unhandled interrupt messages
Bart Van Assche [Wed, 19 May 2021 20:20:57 +0000 (13:20 -0700)]
scsi: ufs: Suppress false positive unhandled interrupt messages

From ufshcd_transfer_req_compl():

    Resetting interrupt aggregation counters first and reading the
    DOOR_BELL afterward allows us to handle all the completed requests.  In
    order to prevent other interrupts starvation the DB is read once after
    reset. The down side of this solution is the possibility of false
    interrupt if device completes another request after resetting
    aggregation and before reading the DB.

Prevent that ufshcd_intr() reports a false positive "Unhandled interrupt"
message if the above scenario is triggered.

Link: https://lore.kernel.org/r/20210519202058.12634-2-bvanassche@acm.org
Cc: Stanley Chu <stanley.chu@mediatek.com>
Cc: Can Guo <cang@codeaurora.org>
Cc: Bean Huo <beanhuo@micron.com>
Cc: Jaegeuk Kim <jaegeuk@kernel.org>
Cc: Asutosh Das <asutoshd@codeaurora.org>
Suggested-by: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: mpt3sas: Handle firmware faults during second half of IOC init
Suganath Prabu S [Tue, 18 May 2021 05:16:25 +0000 (10:46 +0530)]
scsi: mpt3sas: Handle firmware faults during second half of IOC init

If a firmware fault occurs while scanning the devices during IOC
initialization then the driver issues the hard reset operation to recover
the IOC. However, the driver is not issuing a Port enable request
message as part of hard reset operation during IOC initialization.  Due to
this, the driver will not receive get any device discovery-related events
and hence devices will not be accessible.

Teach the driver to gracefully handle firmware faults while scanning for
target devices during IOC initialization. Make the driver issue a port
enable request message as part of hard reset operation. This permits
receiving device discovery-related events from the firmware after the hard
reset operation completes.

Link: https://lore.kernel.org/r/20210518051625.1596742-4-suganath-prabu.subramani@broadcom.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: mpt3sas: Handle firmware faults during first half of IOC init
Suganath Prabu S [Tue, 18 May 2021 05:16:24 +0000 (10:46 +0530)]
scsi: mpt3sas: Handle firmware faults during first half of IOC init

During first half of IOC initialization (i.e.  before going for device
scanning), if any firmware fault occurs then driver is aborting the IOC
initialization operation.

Modify the driver to issue a diag reset operation to recover IOC from fault
state and reinitialize the IOC.

Link: https://lore.kernel.org/r/20210518051625.1596742-3-suganath-prabu.subramani@broadcom.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: mpt3sas: Fix deadlock while cancelling the running firmware event
Suganath Prabu S [Tue, 18 May 2021 05:16:23 +0000 (10:46 +0530)]
scsi: mpt3sas: Fix deadlock while cancelling the running firmware event

Do not cancel current running firmware event work if the event type is
different from MPT3SAS_REMOVE_UNRESPONDING_DEVICES.  Otherwise a deadlock
can be observed while cancelling the current firmware event work if a hard
reset operation is called as part of processing the current event.

Link: https://lore.kernel.org/r/20210518051625.1596742-2-suganath-prabu.subramani@broadcom.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: core: Cap scsi_host cmd_per_lun at can_queue
John Garry [Wed, 19 May 2021 14:31:02 +0000 (22:31 +0800)]
scsi: core: Cap scsi_host cmd_per_lun at can_queue

The sysfs handling function sdev_store_queue_depth() enforces that the sdev
queue depth cannot exceed shost can_queue. The initial sdev queue depth
comes from shost cmd_per_lun. However, the LLDD may manually set
cmd_per_lun to be larger than can_queue, which leads to an initial sdev
queue depth greater than can_queue.

Such an issue was reported in [0], which caused a hang. That has since been
fixed in commit fc09acb7de31 ("scsi: scsi_debug: Fix cmd_per_lun, set to
max_queue").

Stop this possibly happening for other drivers by capping shost cmd_per_lun
at shost can_queue.

[0] https://lore.kernel.org/linux-scsi/YHaez6iN2HHYxYOh@T590/

Link: https://lore.kernel.org/r/1621434662-173079-1-git-send-email-john.garry@huawei.com
Reviewed-by: Ming Lei <ming.lei@redhat.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: lpfc: Update lpfc version to 12.8.0.10
James Smart [Fri, 14 May 2021 19:55:59 +0000 (12:55 -0700)]
scsi: lpfc: Update lpfc version to 12.8.0.10

Update lpfc version to 12.8.0.10

Link: https://lore.kernel.org/r/20210514195559.119853-12-jsmart2021@gmail.com
Co-developed-by: Justin Tee <justin.tee@broadcom.com>
Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: lpfc: Reregister FPIN types if ELS_RDF is received from fabric controller
James Smart [Fri, 14 May 2021 19:55:58 +0000 (12:55 -0700)]
scsi: lpfc: Reregister FPIN types if ELS_RDF is received from fabric controller

FC-LS-5 specifies that a received RDF implies a possible change to fabric
supported diagnostic functions. Endpoints are to re-perform the RDF
exchange with the fabric to enable possible new features or adapt to
changes in values.

This patch adds the logic to RDF receive to re-perform the RDF exchange
with the switch.

Link: https://lore.kernel.org/r/20210514195559.119853-11-jsmart2021@gmail.com
Co-developed-by: Justin Tee <justin.tee@broadcom.com>
Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: lpfc: Add a option to enable interlocked ABTS before job completion
James Smart [Fri, 14 May 2021 19:55:57 +0000 (12:55 -0700)]
scsi: lpfc: Add a option to enable interlocked ABTS before job completion

Default behavior for the driver, when aborting an I/O, is to terminate the
I/O with the adapter. The adapter will initiate an ABTS to terminate the
exchange on the link and mark the exchange is terminated so that no further
use of the sgl or any traffic for the exchange is worked on. Completion on
the Abort is then posted to the driver, which as the I/O is terminated can
complete the I/O to the OS. This completion may occur prior to the ABTS
handshake completing on the wire. The ABTS handshake can take a long time
to complete with timeouts and retries reaching 60+ seconds. Note: if
retries fail, LOGO occurs.

Some devices want to ensure that the ABTS handshake fully completes (this
device has fully ack'd it) before the I/O completion is posted back to the
OS, where a failed I/O may be retried via a different path.

To support this behavior, an option was added to the driver to change I/O
completion from the Abort cmd completion to the Exchange termination (aka
ABTS) completion.

Link: https://lore.kernel.org/r/20210514195559.119853-10-jsmart2021@gmail.com
Co-developed-by: Justin Tee <justin.tee@broadcom.com>
Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: lpfc: Fix crash when lpfc_sli4_hba_setup() fails to initialize the SGLs
James Smart [Fri, 14 May 2021 19:55:56 +0000 (12:55 -0700)]
scsi: lpfc: Fix crash when lpfc_sli4_hba_setup() fails to initialize the SGLs

The driver is encountering a crash in lpfc_free_iocb_list() while
performing initial attachment.

Code review found this to be an errant failure path that was taken, jumping
to a tag that then referenced structures that were uninitialized.

Fix the failure path.

Link: https://lore.kernel.org/r/20210514195559.119853-9-jsmart2021@gmail.com
Co-developed-by: Justin Tee <justin.tee@broadcom.com>
Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: lpfc: Ignore GID-FT response that may be received after a link flip
James Smart [Fri, 14 May 2021 19:55:55 +0000 (12:55 -0700)]
scsi: lpfc: Ignore GID-FT response that may be received after a link flip

When a link bounce happens, there is a possibility that responses to
requests posted prior to the link bounce could be received. This is
problematic as the counter to track reglogin completion after link up can
become out of sync with the real state.

As there is no reason to process a request made in a prior link up context,
eliminate all the disturbance by tagging the request with the event_tag
maintained by the SLI Port for the link. The event_tag will change on every
link state transition.  As long as the tag matches the current event_tag,
the response can be processed. If it doesn't match, just discard the
response.

Link: https://lore.kernel.org/r/20210514195559.119853-8-jsmart2021@gmail.com
Co-developed-by: Justin Tee <justin.tee@broadcom.com>
Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: lpfc: Fix node handling for Fabric Controller and Domain Controller
James Smart [Fri, 14 May 2021 19:55:54 +0000 (12:55 -0700)]
scsi: lpfc: Fix node handling for Fabric Controller and Domain Controller

During link bounce testing, RPI counts were seen to differ from the number
of nodes. For fabric and domain controllers, a temporary RPI is assigned,
but the code isn't registering it. If the nodes do go away, such as on link
down, the temporary RPI isn't being released.

Change the way these two fabric services are managed, make them behave like
any other remote port. Register the RPI and register with the transport.
Never leave the nodes in a NPR or UNUSED state where their RPI is in limbo.
This allows them to follow normal dev_loss_tmo handling, RPI refcounting,
and normal removal rules. It also allows fabric I/Os to use the RPI for
traffic requests.

Note: There is some logic that still has a couple of exceptions when the
Domain controller (0xfffcXX). There are cases where the fabric won't have a
valid login but will send RDP. Other times, it will it send a LOGO then an
RDP. It makes for ad-hoc behavior to manage the node. Exceptions are
documented in the code.

Link: https://lore.kernel.org/r/20210514195559.119853-7-jsmart2021@gmail.com
Co-developed-by: Justin Tee <justin.tee@broadcom.com>
Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: lpfc: Fix Node recovery when driver is handling simultaneous PLOGIs
James Smart [Fri, 14 May 2021 19:55:53 +0000 (12:55 -0700)]
scsi: lpfc: Fix Node recovery when driver is handling simultaneous PLOGIs

When lpfc is handling a solicited and unsolicited PLOGI with another
initiator, the remote initiator is never recovered. The node for the
initiator is erroneouosly removed and all resources released.

In lpfc_cmpl_els_plogi(), when lpfc_els_retry() returns a failure code, the
driver is calling the state machine with a device remove event because the
remote port is not currently registered with the SCSI or NVMe
transports. The issue is that on a PLOGI "collision" the driver correctly
aborts the solicited PLOGI and allows the unsolicited PLOGI to complete the
process, but this process is interrupted with a device_rm event.

Introduce logic in the PLOGI completion to capture the PLOGI collision
event and jump out of the routine.  This will avoid removal of the node.
If there is no collision, the normal node removal will occur.

Fixes:  52edb2caf675 ("scsi: lpfc: Remove ndlp when a PLOGI/ADISC/PRLI/REG_RPI ultimately fails")
Cc: <stable@vger.kernel.org> # v5.11+
Link: https://lore.kernel.org/r/20210514195559.119853-6-jsmart2021@gmail.com
Co-developed-by: Justin Tee <justin.tee@broadcom.com>
Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: lpfc: Add ndlp kref accounting for resume RPI path
James Smart [Fri, 14 May 2021 19:55:52 +0000 (12:55 -0700)]
scsi: lpfc: Add ndlp kref accounting for resume RPI path

The driver is crashing due to a bad pointer during driver load due in an
adisc acc receive routine. The driver is missing node get/put in the
mbx_resume_rpi paths.

Fix by adding the proper gets and puts into the resume_rpi path.

Link: https://lore.kernel.org/r/20210514195559.119853-5-jsmart2021@gmail.com
Co-developed-by: Justin Tee <justin.tee@broadcom.com>
Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: lpfc: Fix "Unexpected timeout" error in direct attach topology
James Smart [Fri, 14 May 2021 19:55:51 +0000 (12:55 -0700)]
scsi: lpfc: Fix "Unexpected timeout" error in direct attach topology

An 'unexpected timeout' message may be seen in a point-2-point topology.
The message occurs when a PLOGI is received before the driver is notified
of FLOGI completion. The FLOGI completion failure causes discovery to be
triggered for a second time. The discovery timer is restarted but no new
discovery activity is initiated, thus the timeout message eventually
appears.

In point-2-point, when discovery has progressed before the FLOGI completion
is processed, it is not a failure. Add code to FLOGI completion to detect
that discovery has progressed and exit the FLOGI handling (noop'ing it).

Link: https://lore.kernel.org/r/20210514195559.119853-4-jsmart2021@gmail.com
Co-developed-by: Justin Tee <justin.tee@broadcom.com>
Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: lpfc: Fix non-optimized ERSP handling
James Smart [Fri, 14 May 2021 19:55:50 +0000 (12:55 -0700)]
scsi: lpfc: Fix non-optimized ERSP handling

When processing an NVMe ERSP IU which didn't match the optimized CQE-only
path, the status was being left to the WQE status. WQE status is non-zero
as it is indicating a non-optimized completion that needs to be handled by
the driver.

Fix by clearing the status field when falling into the non-optimized
case. Log message added to track optimized vs non-optimized debug.

Link: https://lore.kernel.org/r/20210514195559.119853-3-jsmart2021@gmail.com
Co-developed-by: Justin Tee <justin.tee@broadcom.com>
Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: lpfc: Fix unreleased RPIs when NPIV ports are created
James Smart [Fri, 14 May 2021 19:55:49 +0000 (12:55 -0700)]
scsi: lpfc: Fix unreleased RPIs when NPIV ports are created

While testing NPIV and watching logins and used RPI levels, it was seen the
used RPI count was much higher than the number of remote ports discovered.

Code inspection showed that remote port removals on any NPIV instance are
releasing the RPI, but not performing an UNREG_RPI with the adapter thus
the reference counting never fully drops and the RPI is never fully
released. This was happening on NPIV nodes due to a log of fabric ELS's to
fabric addresses. This lack of UNREG_RPI was introduced by a prior node
rework patch that performed the UNREG_RPI as part of node cleanup.

To resolve the issue, do the following:

 - Restore the RPI release code, but move the location to so that it is in
   line with the new node cleanup design.

 - NPIV ports now release the RPI and drop the node when the caller sets
   the NLP_RELEASE_RPI flag.

 - Set the NLP_RELEASE_RPI flag in node cleanup which will trigger a
   release of RPI to free pool.

 - Ensure there's an UNREG_RPI at LOGO completion so that RPI release is
   completed.

 - Stop offline_prep from skipping nodes that are UNUSED. The RPI may
   not have been released.

 - Stop the default RPI handling in lpfc_cmpl_els_rsp() for SLI4.

 - Fixed up debugfs RPI displays for better debugging.

Fixes: a70e63eee1c1 ("scsi: lpfc: Fix NPIV Fabric Node reference counting")
Link: https://lore.kernel.org/r/20210514195559.119853-2-jsmart2021@gmail.com
Cc: <stable@vger.kernel.org> # v5.11+
Co-developed-by: Justin Tee <justin.tee@broadcom.com>
Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: scsi_dh_alua: Retry RTPG on a different path after failure
Martin Wilck [Fri, 14 May 2021 15:32:14 +0000 (17:32 +0200)]
scsi: scsi_dh_alua: Retry RTPG on a different path after failure

If an RTPG fails, we can't infer anything wrt. the state of the ports in
the port group except that we were unable to reach the one port on which
the RTPG had failed. "offline" is just a secondary port state, which means
that we can't infer the state of any port in the PG from the failure (in
fact, even the failed port might still be in "active/optimized" primary
port access state).

Therefore, when we encounter an RTPG failure, we should retry the RTPG on a
different port. This avoids falsely setting port states to offline for
unreachable ports. To do this, ports on which an RTPG has failed are
temporarily set to "disabled" to avoid repeating the failed I/O on the same
target port. Once the RTPG has either succeeded on one port or failed on
all ports of the PG, the ports are enabled again.

Link: https://lore.kernel.org/r/20210514153214.5626-1-mwilck@suse.com
Signed-off-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: qla2xxx: Remove redundant assignment to rval
Jiapeng Chong [Mon, 10 May 2021 10:40:06 +0000 (18:40 +0800)]
scsi: qla2xxx: Remove redundant assignment to rval

Variable rval is set to QLA_SUCCESS but this value is never read as it is
overwritten later on. Hence it is a redundant assignment and can be
removed.

Clean up the following clang-analyzer warning:

drivers/scsi/qla2xxx/qla_init.c:4359:2: warning: Value stored to 'rval'
is never read [clang-analyzer-deadcode.DeadStores].

Link: https://lore.kernel.org/r/1620643206-127930-1-git-send-email-jiapeng.chong@linux.alibaba.com
Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: ufs: ufs-exynos: Make a const array static, makes object smaller
Colin Ian King [Wed, 5 May 2021 19:01:04 +0000 (20:01 +0100)]
scsi: ufs: ufs-exynos: Make a const array static, makes object smaller

Don't populate the const array granularity_tbl on the stack but instead
make it static. Makes the object code smaller by 190 bytes:

Before:
   text    data     bss     dec     hex filename
  25563    6908       0   32471    7ed7 ./drivers/scsi/ufs/ufs-exynos.o

After:
   text    data     bss     dec     hex filename
  25213    7068       0   32281    7e19 ./drivers/scsi/ufs/ufs-exynos.o

(gcc version 10.3.0)

Link: https://lore.kernel.org/r/20210505190104.70112-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: fas216: Use fallthrough pseudo-keyword
Wei Ming Chen [Tue, 18 May 2021 13:18:23 +0000 (21:18 +0800)]
scsi: fas216: Use fallthrough pseudo-keyword

Replace /*FALLTHROUGH*/ comment with pseudo-keyword macro 'fallthrough'.

Link: https://lore.kernel.org/r/20210518131823.2586-1-jj251510319013@gmail.com
Signed-off-by: Wei Ming Chen <jj251510319013@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: ufs: core: Clean up whitespace
Keoseong Park [Tue, 18 May 2021 12:12:17 +0000 (21:12 +0900)]
scsi: ufs: core: Clean up whitespace

checkpatch reports the following errors:

ERROR: space prohibited before that ',' (ctx:WxW)
#945: FILE: drivers/scsi/ufs/ufshcd.h:945:
+int ufshcd_init(struct ufs_hba * , void __iomem * , unsigned int);
                                  ^

ERROR: space prohibited before that ',' (ctx:WxW)
#945: FILE: drivers/scsi/ufs/ufshcd.h:945:
+int ufshcd_init(struct ufs_hba * , void __iomem * , unsigned int);
                                                   ^
Remove unnecessary whitespace in ufshcd.h.

Link: https://lore.kernel.org/r/2038148563.21621340102306.JavaMail.epsvc@epcpadp3
Signed-off-by: Keoseong Park <keosung.park@samsung.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: Fix spelling mistakes in header files
Zhen Lei [Mon, 17 May 2021 09:59:45 +0000 (17:59 +0800)]
scsi: Fix spelling mistakes in header files

Fix some spelling mistakes in comments:

  pathes ==> paths
  Resouce ==> Resource
  retreived ==> retrieved
  recevied ==> received
  interruped ==> interrupted

[mkp: kept 'keep-alives' and 'busses']

Link: https://lore.kernel.org/r/20210517095945.7363-1-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: core: Remove leading spaces in Kconfig
Juerg Haefliger [Mon, 17 May 2021 09:58:35 +0000 (11:58 +0200)]
scsi: core: Remove leading spaces in Kconfig

Remove leading spaces before tabs in Kconfig file(s) by running the
following command:

  $ find drivers/scsi -name 'Kconfig*' | xargs sed -r -i 's/^[ ]+\t/\t/'

Link: https://lore.kernel.org/r/20210517095835.81733-1-juergh@canonical.com
Signed-off-by: Juerg Haefliger <juerg.haefliger@canonical.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: target: tcmu: Fix boolreturn.cocci warnings
kernel test robot [Sat, 15 May 2021 23:03:58 +0000 (07:03 +0800)]
scsi: target: tcmu: Fix boolreturn.cocci warnings

drivers/target/target_core_user.c:1424:9-10: WARNING: return of 0/1 in function 'tcmu_handle_completions' with return type bool

 Return statements in functions returning bool should use
 true/false instead of 1/0.

Generated by: scripts/coccinelle/misc/boolreturn.cocci

Link: https://lore.kernel.org/r/20210515230358.GA97544@60d1edce16e0
Fixes: 9814b55cde05 ("scsi: target: tcmu: Return from tcmu_handle_completions() if cmd_id not found")
CC: Bodo Stroesser <bostroesser@gmail.com>
Reported-by: kernel test robot <lkp@intel.com>
Acked-by: Bodo Stroesser <bostroesser@gmail.com>
Signed-off-by: kernel test robot <lkp@intel.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: ufs: Use designated initializers in ufs_pm_lvl_states[]
Bart Van Assche [Wed, 19 May 2021 20:20:58 +0000 (13:20 -0700)]
scsi: ufs: Use designated initializers in ufs_pm_lvl_states[]

The comments in the enum ufs_pm_level definition are redundant. Remove the
comments from the ufs_pm_level enum and use designated initializers in the
ufs_pm_lvl_states[] definition instead.

Link: https://lore.kernel.org/r/20210519202058.12634-3-bvanassche@acm.org
Cc: Stanley Chu <stanley.chu@mediatek.com>
Cc: Can Guo <cang@codeaurora.org>
Cc: Bean Huo <beanhuo@micron.com>
Cc: Jaegeuk Kim <jaegeuk@kernel.org>
Cc: Asutosh Das <asutoshd@codeaurora.org>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: hisi_sas: Propagate errors in interrupt_init_v1_hw()
Sergey Shtylyov [Wed, 19 May 2021 19:20:15 +0000 (22:20 +0300)]
scsi: hisi_sas: Propagate errors in interrupt_init_v1_hw()

After commit 6c11dc060427 ("scsi: hisi_sas: Fix IRQ checks") we have the
error codes returned by platform_get_irq() ready for the propagation
upsream in interrupt_init_v1_hw() -- that will fix still broken deferred
probing. Let's propagate the error codes from devm_request_irq() as well
since I don't see the reason to override them with -ENOENT...

Link: https://lore.kernel.org/r/49ba93a3-d427-7542-d85a-b74fe1a33a73@omp.ru
Acked-by: John Garry <john.garry@huawei.com>
Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: bfa: Fix inconsistent indenting
Jiapeng Chong [Fri, 21 May 2021 09:46:08 +0000 (17:46 +0800)]
scsi: bfa: Fix inconsistent indenting

Eliminate the follow smatch warning:

drivers/scsi/bfa/bfa_svc.c:3176 bfa_fcport_send_enable() warn:
inconsistent indenting.

Link: https://lore.kernel.org/r/1621590368-72041-1-git-send-email-jiapeng.chong@linux.alibaba.com
Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: bfa: Fix typo
zuoqilin [Fri, 21 May 2021 09:21:53 +0000 (17:21 +0800)]
scsi: bfa: Fix typo

Change 'chnage' to 'change'.

Link: https://lore.kernel.org/r/20210521092153.379-1-zuoqilin1@163.com
Signed-off-by: zuoqilin <zuoqilin@yulong.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: pmcraid: Fix typos
zuoqilin [Fri, 21 May 2021 08:28:08 +0000 (16:28 +0800)]
scsi: pmcraid: Fix typos

Change "avaibale" and "avaible" to "available".

Link: https://lore.kernel.org/r/20210521082808.1925-1-zuoqilin1@163.com
Signed-off-by: zuoqilin <zuoqilin@yulong.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: scsi_transport_fc: Remove double FC_FPORT_DELETED in mask creation
Daniel Wagner [Thu, 20 May 2021 07:31:27 +0000 (09:31 +0200)]
scsi: scsi_transport_fc: Remove double FC_FPORT_DELETED in mask creation

Remove the double listed FC_FPORT_DELETING from the mask creation.

Commit 260f4aeddb48 ("scsi: scsi_transport_fc: return -EBUSY for deleted
vport") added VC_VPORT_DELETING to the flag masks. This is not necessary as
FC_FPORT_DEL is defined as VC_FPORT_DELETED | FC_FPORT_DELETING.

Link: https://lore.kernel.org/r/20210520073127.132456-1-dwagner@suse.de
Cc: Hannes Reinecke <hare@suse.de>
Signed-off-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: arcmsr: Update driver version to v1.50.00.05-20210429
ching Huang [Thu, 20 May 2021 07:13:49 +0000 (15:13 +0800)]
scsi: arcmsr: Update driver version to v1.50.00.05-20210429

Update driver version to v1.50.00.05-20210429.

Link: https://lore.kernel.org/r/d0c6dc6431f0e46db6583dc0d04d7983b420d4da.camel@areca.com.tw
Signed-off-by: ching Huang <ching2048@areca.com.tw>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: arcmsr: Fix doorbell status being updated late on ARC-1886
ching Huang [Thu, 20 May 2021 06:55:15 +0000 (14:55 +0800)]
scsi: arcmsr: Fix doorbell status being updated late on ARC-1886

It is possible for the IOP to be delayed in updating the doorbell
status. The doorbell status should not be 0 so loop until the value
changes.

Link: https://lore.kernel.org/r/afdfdf7eabecf14632492c4987a6b9ac6312a7ad.camel@areca.com.tw
Signed-off-by: ching Huang <ching2048@areca.com.tw>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: qedf: Use vzalloc() instead of vmalloc()/memset(0)
Yang Yingliang [Tue, 18 May 2021 13:20:18 +0000 (21:20 +0800)]
scsi: qedf: Use vzalloc() instead of vmalloc()/memset(0)

Use vzalloc() instead of vmalloc() and memset(0) to simpify the code.

Link: https://lore.kernel.org/r/20210518132018.1312995-1-yangyingliang@huawei.com
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: ufs: ufs-exynos: Move definitions from .h to .c
Bart Van Assche [Sun, 9 May 2021 21:38:17 +0000 (14:38 -0700)]
scsi: ufs: ufs-exynos: Move definitions from .h to .c

In the Linux kernel definitions of data structures should occur in .c
files. Hence move the exynos7_uic_attr definition from a .h into a .c
file. Additionally, declare exynos_ufs_drvs static. This patch fixes the
following two sparse warnings:

drivers/scsi/ufs/ufs-exynos.h:248:28: warning: symbol 'exynos_ufs_drvs' was not declared. Should it be static?
drivers/scsi/ufs/ufs-exynos.h:250:28: warning: symbol 'exynos7_uic_attr' was not declared. Should it be static?

Link: https://lore.kernel.org/r/20210509213817.4348-1-bvanassche@acm.org
Cc: Alim Akhtar <alim.akhtar@samsung.com>
Cc: Kiwoong Kim <kwmad.kim@samsung.com>
Reviewed-by: Alim Akhtar <alim.akhtar@samsung.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: 3w-9xxx: Fix endianness issues in command packets
Samuel Holland [Tue, 27 Apr 2021 23:59:15 +0000 (18:59 -0500)]
scsi: 3w-9xxx: Fix endianness issues in command packets

The controller expects all data it sends/receives to be little-endian.
Therefore, the packet struct definitions should use the __le16/32/64
types. Once those are correct, sparse reports several issues with the
driver code, which are fixed here as well.

The main issue observed was at the call to scsi_set_resid(), where the
byteswapped parameter would eventually trigger the alignment check at
drivers/scsi/sd.c:2009. At that point, the kernel would continuously
complain about an "Unaligned partial completion", and no further I/O could
occur.

This gets the controller working on big endian powerpc64.

Link: https://lore.kernel.org/r/20210427235915.39211-4-samuel@sholland.org
Signed-off-by: Samuel Holland <samuel@sholland.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: 3w-9xxx: Reduce scope of structure packing
Samuel Holland [Tue, 27 Apr 2021 23:59:14 +0000 (18:59 -0500)]
scsi: 3w-9xxx: Reduce scope of structure packing

Currently, all command packet structs used by this driver are packed.
However, only one (TW_SG_Entry) actually needs to be packed, because it
uses 64-bit addresses at 32-bit alignment. To improve the quality of
generated code, stop packing all of the other command packet structs.  This
requires adjusting the type of one misaligned "reserved" member.

After this change, pahole reports that only one type had its layout change:
the tw_compat_info member of TW_Device_Extension is now naturally aligned.

Link: https://lore.kernel.org/r/20210427235915.39211-3-samuel@sholland.org
Signed-off-by: Samuel Holland <samuel@sholland.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: 3w-9xxx: Use flexible array members to avoid struct padding
Samuel Holland [Tue, 27 Apr 2021 23:59:13 +0000 (18:59 -0500)]
scsi: 3w-9xxx: Use flexible array members to avoid struct padding

In preparation for removing the "#pragma pack(1)" from the driver, fix all
instances where a trailing array member could be replaced by a flexible
array member. Since a flexible array member has zero size, it introduces no
padding, whether or not the struct is packed.

Link: https://lore.kernel.org/r/20210427235915.39211-2-samuel@sholland.org
Signed-off-by: Samuel Holland <samuel@sholland.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: be2iscsi: Remove redundant initialization
Nigel Christian [Thu, 13 May 2021 22:20:32 +0000 (17:20 -0500)]
scsi: be2iscsi: Remove redundant initialization

The nested for loop variables i and j in beiscsi_free_mem() are initialized
twice. The values outside of the loops are redundant and can be removed.

Addresses-Coverity: ("Unused value")
Link: https://lore.kernel.org/r/YJ2mMHNqAgTNVVj+@fedora
Signed-off-by: Nigel Christian <nigel.l.christian@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: ufs: core: Remove redundant parenthesis
Keoseong Park [Thu, 13 May 2021 08:53:20 +0000 (17:53 +0900)]
scsi: ufs: core: Remove redundant parenthesis

Remove unnecessary parenthesis in ufshcd_is_wb_flags() and
ufshcd_is_wbattrs().

Link: https://lore.kernel.org/r/1891546521.01620896402035.JavaMail.epsvc@epcpadp3
Signed-off-by: Keoseong Park <keosung.park@samsung.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: ufs: core: Remove usfhcd_is_*_pm() macros
Bart Van Assche [Thu, 13 May 2021 17:12:29 +0000 (10:12 -0700)]
scsi: ufs: core: Remove usfhcd_is_*_pm() macros

Remove these macros to make the UFS driver source code easier to read.
These macros were introduced by commit 57d104c153d3 ("ufs: add UFS power
management support").

Link: https://lore.kernel.org/r/20210513171229.7439-1-bvanassche@acm.org
Cc: Can Guo <cang@codeaurora.org>
Cc: Alim Akhtar <alim.akhtar@samsung.com>
Cc: Avri Altman <avri.altman@wdc.com>
Cc: Stanley Chu <stanley.chu@mediatek.com>
Cc: Bean Huo <beanhuo@micron.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Acked-by: Avri Altman <avri.altman@wdc.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: bfa: Remove some unused variables
Christophe JAILLET [Tue, 20 Apr 2021 18:48:41 +0000 (20:48 +0200)]
scsi: bfa: Remove some unused variables

'lp' is unused, it is just declared and zeroed

Remove it.

Link: https://lore.kernel.org/r/d10ccee35e35bf33d651f2e0163034d7c451520b.1618944442.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: target: core: Add the VERSION DESCRIPTOR fields to the INQUIRY data
Konstantin Shelekhin [Thu, 13 May 2021 19:28:04 +0000 (22:28 +0300)]
scsi: target: core: Add the VERSION DESCRIPTOR fields to the INQUIRY data

Extend the standard INQUIRY data to 96 bytes and fill in the VERSION
DESCRIPTOR fields.

The layout follows SPC-4:

 - SCSI architecture standard
 - SCSI transport protocol standard
 - SCSI primary command set standard
 - SCSI device type command set standard

All version descriptor values are defined as "no version claimed" because
some initiators fail to recognize anything else.

[mkp: whitespace]

Link: https://lore.kernel.org/r/20210513192804.1252142-3-k.shelekhin@yadro.com
Reviewed-by: Roman Bolshakov <r.bolshakov@yadro.com>
Signed-off-by: Konstantin Shelekhin <k.shelekhin@yadro.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: target: core: Bump INQUIRY VERSION to SPC-4
Konstantin Shelekhin [Thu, 13 May 2021 19:28:03 +0000 (22:28 +0300)]
scsi: target: core: Bump INQUIRY VERSION to SPC-4

Bump the SCSI primary command set standard to SPC-4. The upcoming version
descriptors will report newer SCSI standards (like SBC-3) that are not
defined in SPC-3.

Link: https://lore.kernel.org/r/20210513192804.1252142-2-k.shelekhin@yadro.com
Reviewed-by: Roman Bolshakov <r.bolshakov@yadro.com>
Signed-off-by: Konstantin Shelekhin <k.shelekhin@yadro.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: target: core: Add configurable IEEE Company ID attribute
Sergey Samoylenko [Tue, 20 Apr 2021 18:59:20 +0000 (21:59 +0300)]
scsi: target: core: Add configurable IEEE Company ID attribute

Implement an attribute which provides a way to set a company specific WWN
in configfs via:

  target/core/$backstore/$name/wwn/company_id

The Open Fabrics Alliance ID 001405h remains the default.

Link: https://lore.kernel.org/r/20210420185920.42431-3-s.samoylenko@yadro.com
Signed-off-by: Sergey Samoylenko <s.samoylenko@yadro.com>
Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: target: core: Unify NAA identifier generation
Sergey Samoylenko [Tue, 20 Apr 2021 18:59:19 +0000 (21:59 +0300)]
scsi: target: core: Unify NAA identifier generation

Both the INQUIRY handling and the XCOPY implementation provide functions to
generate an NAA designator. In addition, these functions are poorly named:

 - spc_parse_naa_6h_vendor_specific()
 - target_xcopy_gen_naa_ieee()

Introduce a common NAA 6 designator generation function,
spc_gen_naa_6h_vendor_specific().

Link: https://lore.kernel.org/r/20210420185920.42431-2-s.samoylenko@yadro.com
Signed-off-by: Sergey Samoylenko <s.samoylenko@yadro.com>
Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: target: sbp_target: Remove redundant assignment to pg_size
Jiapeng Chong [Thu, 13 May 2021 10:49:37 +0000 (18:49 +0800)]
scsi: target: sbp_target: Remove redundant assignment to pg_size

Variable pg_size is set to '0x100 << pg_size', but this value is never read
and it is not used later on. Hence it is a redundant assignment and can be
removed.

Clean up the following clang-analyzer warning:

drivers/target/sbp/sbp_target.c:1264:3: warning: Value stored to
'pg_size' is never read [clang-analyzer-deadcode.DeadStores].

Link: https://lore.kernel.org/r/1620902977-57076-1-git-send-email-jiapeng.chong@linux.alibaba.com
Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: message: fusion: Remove redundant assignment to rc
Jiapeng Chong [Wed, 12 May 2021 10:12:07 +0000 (18:12 +0800)]
scsi: message: fusion: Remove redundant assignment to rc

Variable rc is set to '-1', but this value is never read as it is
overwritten later. Hence it is a redundant assignment and can be removed.

Clean up the following clang-analyzer warning:

drivers/message/fusion/mptbase.c:6996:2: warning: Value stored to 'rc'
is never read [clang-analyzer-deadcode.DeadStores].

Link: https://lore.kernel.org/r/1620814327-25427-1-git-send-email-jiapeng.chong@linux.alibaba.com
Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: ibmvfc: Reinit target retries
Brian King [Tue, 11 May 2021 18:12:20 +0000 (13:12 -0500)]
scsi: ibmvfc: Reinit target retries

If rport target discovery commands fail for some reason, they get retried
up to a set number of retries. Once the retry limit is exceeded, the target
is deleted. In order to delete the target, we either need to do an implicit
logout or a move login. In the move login case, if the move login fails, we
want to retry it. This ensures the retry counter gets reinitialized so the
move login will get retried.

Link: https://lore.kernel.org/r/1620756740-7045-4-git-send-email-brking@linux.vnet.ibm.com
Signed-off-by: Brian King <brking@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: ibmvfc: Avoid move login if fast fail is enabled
Brian King [Tue, 11 May 2021 18:12:19 +0000 (13:12 -0500)]
scsi: ibmvfc: Avoid move login if fast fail is enabled

If fast fail is enabled and we encounter a WWPN moving from one port id to
another port id with I/O outstanding, if we use the move login MAD,
although it will work, it will leave any outstanding I/O still outstanding
to the old port id. Eventually, the SCSI command timers will fire and we
will abort these commands, however, this is generally much longer than the
fast fail timeout, which can lead to I/O operations being outstanding for a
long time. This patch changes the behavior to avoid the move login if fast
fail is enabled. Once terminate_rport_io cleans up the rport, then we force
the target back through the delete process, which re-drives the implicit
logout, then kicks us back into discovery where we will discover the WWPN
at the new location and do a PLOGI to it.

Link: https://lore.kernel.org/r/1620756740-7045-3-git-send-email-brking@linux.vnet.ibm.com
Signed-off-by: Brian King <brking@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: ibmvfc: Handle move login failure
Brian King [Tue, 11 May 2021 18:12:18 +0000 (13:12 -0500)]
scsi: ibmvfc: Handle move login failure

When service is being performed on an SVC with NPIV enabled, the WWPN of
the canister / node being serviced fails over to the another canister /
node. This looks to the ibmvfc driver as a WWPN moving from one SCSI ID to
another. The driver will first attempt to do an implicit logout of the old
SCSI ID. If this works, we simply delete the rport at the old location and
add an rport at the new location and the FC transport class handles
everything. However, if there is I/O outstanding, this implicit logout will
fail, in which case we will send a "move login" request to the VIOS. This
will cancel any outstanding I/O to that port, logout the port, and PLOGI
the new port. Recently we've encountered a scenario where the move login
fails. This was resulting in an attempted plogi to the new scsi id, without
the old scsi id getting logged out, which is a VIOS protocol violation. To
solve this, we want to keep tracking the old scsi id as the current scsi
id. That way, once terminate_rport_io cancels the outstanding i/o, it will
send us back through to do an implicit logout of the old scsi id, rather
than the new scsi id, and then we can plogi the new scsi id.

Link: https://lore.kernel.org/r/1620756740-7045-2-git-send-email-brking@linux.vnet.ibm.com
Signed-off-by: Brian King <brking@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: target: tcmu: Rename TCM_DEV_BIT_PLUGGED to TCMU_DEV_BIT_PLUGGED
Bodo Stroesser [Wed, 12 May 2021 14:06:54 +0000 (16:06 +0200)]
scsi: target: tcmu: Rename TCM_DEV_BIT_PLUGGED to TCMU_DEV_BIT_PLUGGED

The bit definition TCM_DEV_BIT_PLUGGED should correctly be named
TCMU_DEV_BIT_PLUGGED, since all other bits in the same bitfield have prefix
TCMU_.

Link: https://lore.kernel.org/r/20210512140654.31249-1-bostroesser@gmail.com
Signed-off-by: Bodo Stroesser <bostroesser@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: core: Fix a comment in function scsi_host_dev_release()
Xiang Chen [Mon, 10 May 2021 11:35:26 +0000 (19:35 +0800)]
scsi: core: Fix a comment in function scsi_host_dev_release()

Commit 3be8828fc507 ("scsi: core: Avoid that ATA error handling can
trigger a kernel hang or oops") moved rcu to scsi_cmnd instead of
shost. Modify "shost->rcu" to "scmd->rcu" in a comment.

Link: https://lore.kernel.org/r/1620646526-193154-1-git-send-email-chenxiang66@hisilicon.com
Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: qedf: Drop unnecessary NULL checks after container_of()
Guenter Roeck [Mon, 10 May 2021 04:12:11 +0000 (21:12 -0700)]
scsi: qedf: Drop unnecessary NULL checks after container_of()

The result of container_of() operations is never NULL unless the embedded
element is the first element of the structure, which is not the case here.
The NULL checks are therefore unnecessary and misleading. Remove them.

The changes in this patch were made automatically using the following
Coccinelle script.

@@
type t;
identifier v;
statement s;
@@

<+...
(
  t v = container_of(...);
|
  v = container_of(...);
)
  ...
  when != v
- if (\( !v \| v == NULL \) ) s
...+>

Link: https://lore.kernel.org/r/20210510041211.2051325-1-linux@roeck-us.net
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: target: iscsi: Drop unnecessary container_of()
Guenter Roeck [Mon, 10 May 2021 04:08:17 +0000 (21:08 -0700)]
scsi: target: iscsi: Drop unnecessary container_of()

The structure pointer passed to container_of() is never NULL; that was
already checked. That means that the result of container_of() operations
on it is also never NULL, even though se_node_acl is the first element
of the structure embedding it. On top of that, it is misleading to perform
a NULL check on the result of container_of() because the position of the
contained element could change, which would make the test invalid.
Remove the unnecessary NULL check.

As it turns out, the container_of operation was only made for the purpose
of the NULL check. If the container_of is actually needed, it is repeated
later. Remove the container_of operation as well.

The NULL check was identified and removed with the following Coccinelle
script.

@@
type t;
identifier v;
statement s;
@@

<+...
(
  t v = container_of(...);
|
  v = container_of(...);
)
  ...
  when != v
- if (\( !v \| v == NULL \) ) s
...+>

Link: https://lore.kernel.org/r/20210510040817.2050266-1-linux@roeck-us.net
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Hou Pu <houpu@bytedance.com>
Cc: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: scsi_debug: Drop if with an always false condition
Uwe Kleine-König [Thu, 6 May 2021 20:32:06 +0000 (22:32 +0200)]
scsi: scsi_debug: Drop if with an always false condition

to_sdebug_host() is a container_of operation, so it never returns NULL.

Link: https://lore.kernel.org/r/20210506203206.254258-1-u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: snic: Fix an error message
Christophe JAILLET [Thu, 6 May 2021 18:38:20 +0000 (20:38 +0200)]
scsi: snic: Fix an error message

'ret' is known to be 0 here. No error code is available so just remove
'ret' from the error message.

While at it, change the word "Queuing" into "Init" which looks more
appropriate.

Link: https://lore.kernel.org/r/3b9d5d767e09d03a07bede293a6ba32e3735cd1a.1620326191.git.christophe.jaillet@wanadoo.fr
Fixes: c8806b6c9e82 ("snic: driver for Cisco SCSI HBA")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: target: cxgbit: Unmap DMA buffer before calling target_execute_cmd()
Varun Prakash [Wed, 14 Apr 2021 12:39:09 +0000 (18:09 +0530)]
scsi: target: cxgbit: Unmap DMA buffer before calling target_execute_cmd()

Instead of calling dma_unmap_sg() after completing WRITE I/O, call
dma_unmap_sg() before calling target_execute_cmd() to sync the DMA buffer.

Link: https://lore.kernel.org/r/1618403949-3443-1-git-send-email-varun@chelsio.com
Cc: <stable@vger.kernel.org> # 5.4+
Signed-off-by: Varun Prakash <varun@chelsio.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: ufs: core: Introduce HBA performance monitor sysfs nodes
Can Guo [Thu, 22 Apr 2021 02:28:39 +0000 (19:28 -0700)]
scsi: ufs: core: Introduce HBA performance monitor sysfs nodes

Add a new sysfs group which has nodes to monitor data/request transfer
performance. This sysfs group has nodes showing total sectors/requests
transferred, total busy time spent and max/min/avg/sum latencies. This
group can be enhanced later to show more UFS driver layer performance
statistics data during runtime.

Link: https://lore.kernel.org/r/1619058521-35307-2-git-send-email-cang@codeaurora.org
Reviewed-by: Daejun Park <daejun7.park@samsung.com>
Acked-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Can Guo <cang@codeaurora.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: aacraid: Replace one-element array with flexible-array member
Gustavo A. R. Silva [Wed, 21 Apr 2021 18:56:11 +0000 (13:56 -0500)]
scsi: aacraid: Replace one-element array with flexible-array member

There is a regular need in the kernel to provide a way to declare having a
dynamically sized set of trailing elements in a structure. Kernel code
should always use “flexible array members”[1] for these cases. The older
style of one-element or zero-length arrays should no longer be used[2].

Refactor the code according to the use of a flexible-array member in struct
aac_raw_io2 instead of one-element array, and use the struct_size() helper.

Also, this helps with the ongoing efforts to enable -Warray-bounds by
fixing the following warnings:

drivers/scsi/aacraid/aachba.c: In function ‘aac_build_sgraw2’:
drivers/scsi/aacraid/aachba.c:3970:18: warning: array subscript 1 is above array bounds of ‘struct sge_ieee1212[1]’ [-Warray-bounds]
 3970 |     if (rio2->sge[j].length % (i*PAGE_SIZE)) {
      |         ~~~~~~~~~^~~
drivers/scsi/aacraid/aachba.c:3974:27: warning: array subscript 1 is above array bounds of ‘struct sge_ieee1212[1]’ [-Warray-bounds]
 3974 |     nseg_new += (rio2->sge[j].length / (i*PAGE_SIZE));
      |                  ~~~~~~~~~^~~
drivers/scsi/aacraid/aachba.c:4011:28: warning: array subscript 1 is above array bounds of ‘struct sge_ieee1212[1]’ [-Warray-bounds]
 4011 |   for (j = 0; j < rio2->sge[i].length / (pages * PAGE_SIZE); ++j) {
      |                   ~~~~~~~~~^~~
drivers/scsi/aacraid/aachba.c:4012:24: warning: array subscript 1 is above array bounds of ‘struct sge_ieee1212[1]’ [-Warray-bounds]
 4012 |    addr_low = rio2->sge[i].addrLow + j * pages * PAGE_SIZE;
      |               ~~~~~~~~~^~~
drivers/scsi/aacraid/aachba.c:4014:33: warning: array subscript 1 is above array bounds of ‘struct sge_ieee1212[1]’ [-Warray-bounds]
 4014 |    sge[pos].addrHigh = rio2->sge[i].addrHigh;
      |                        ~~~~~~~~~^~~
drivers/scsi/aacraid/aachba.c:4015:28: warning: array subscript 1 is above array bounds of ‘struct sge_ieee1212[1]’ [-Warray-bounds]
 4015 |    if (addr_low < rio2->sge[i].addrLow)
      |                   ~~~~~~~~~^~~

[1] https://en.wikipedia.org/wiki/Flexible_array_member
[2] https://www.kernel.org/doc/html/v5.9/process/deprecated.html#zero-length-and-one-element-arrays

Link: https://github.com/KSPP/linux/issues/79
Link: https://github.com/KSPP/linux/issues/109
Link: https://lore.kernel.org/lkml/60414244.ur4%2FkI+fBF1ohKZs%25lkp@intel.com/
Link: https://lore.kernel.org/r/20210421185611.GA105224@embeddedor
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Build-tested-by: kernel test robot <lkp@intel.com>
3 years agoscsi: ufs: sysfs: Resume the proper SCSI device
Asutosh Das [Sat, 24 Apr 2021 00:20:17 +0000 (17:20 -0700)]
scsi: ufs: sysfs: Resume the proper SCSI device

Resume the SCSI device described by the unit descriptor instead of the HBA.

Link: https://lore.kernel.org/r/889bb20c47cc1ae5e40390f533712b704000345b.1619223249.git.asutoshd@codeaurora.org
Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>
Reviewed-by: Can Guo <cang@codeaurora.org>
Signed-off-by: Asutosh Das <asutoshd@codeaurora.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: ufs: core: Enable power management for wlun
Asutosh Das [Sat, 24 Apr 2021 00:20:16 +0000 (17:20 -0700)]
scsi: ufs: core: Enable power management for wlun

During runtime-suspend of ufs host, the SCSI devices are already suspended
and so are the queues associated with them. However, the ufs host sends SSU
(START_STOP_UNIT) to the wlun during runtime-suspend.

During the process blk_queue_enter() checks if the queue is not in suspended
state. If so, it waits for the queue to resume, and never comes out of
it. Commit 52abca64fd94 ("scsi: block: Do not accept any requests while
suspended") adds the check to see if the queue is in suspended state in
blk_queue_enter().

Call trace:
 __switch_to+0x174/0x2c4
 __schedule+0x478/0x764
 schedule+0x9c/0xe0
 blk_queue_enter+0x158/0x228
 blk_mq_alloc_request+0x40/0xa4
 blk_get_request+0x2c/0x70
 __scsi_execute+0x60/0x1c4
 ufshcd_set_dev_pwr_mode+0x124/0x1e4
 ufshcd_suspend+0x208/0x83c
 ufshcd_runtime_suspend+0x40/0x154
 ufshcd_pltfrm_runtime_suspend+0x14/0x20
 pm_generic_runtime_suspend+0x28/0x3c
 __rpm_callback+0x80/0x2a4
 rpm_suspend+0x308/0x614
 rpm_idle+0x158/0x228
 pm_runtime_work+0x84/0xac
 process_one_work+0x1f0/0x470
 worker_thread+0x26c/0x4c8
 kthread+0x13c/0x320
 ret_from_fork+0x10/0x18

Fix this by registering ufs device wlun as a SCSI driver and registering it
for block runtime-pm. Also make this a supplier for all other LUNs. This
way the wlun device suspends after all the consumers and resumes after HBA
resumes. This also registers a new SCSI driver for rpmb wlun. This new
driver is mostly used to clear rpmb uac.

[mkp: resolve merge conflict with 5.13-rc1 and fix doc warning]

Fixed smatch warnings:
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/4662c462e79e3e7f541f54f88f8993f421026d83.1619223249.git.asutoshd@codeaurora.org
Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>
Co-developed-by: Can Guo <cang@codeaurora.org>
Signed-off-by: Can Guo <cang@codeaurora.org>
Signed-off-by: Asutosh Das <asutoshd@codeaurora.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: qla4xxx: Simplify conditional
Wan Jiabing [Wed, 14 Apr 2021 12:17:26 +0000 (20:17 +0800)]
scsi: qla4xxx: Simplify conditional

Fix the following coccicheck warning:

./drivers/scsi/qla4xxx/ql4_83xx.c:475:23-25: WARNING !A || A && B is
equivalent to !A || B

Link: https://lore.kernel.org/r/20210414121726.12503-1-wanjiabing@vivo.com
Signed-off-by: Wan Jiabing <wanjiabing@vivo.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: arcmsr: Update driver version to v1.50.00.04-20210414
ching Huang [Fri, 16 Apr 2021 03:58:02 +0000 (11:58 +0800)]
scsi: arcmsr: Update driver version to v1.50.00.04-20210414

Update driver version to v1.50.00.04-20210414.

Link: https://lore.kernel.org/r/1ca5474a5c6fea59bf13cdf84f7bd17f0b20f562.camel@areca.com.tw
Signed-off-by: ching Huang <ching2048@areca.com.tw>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: arcmsr: Fix the wrong CDB payload report to IOP
ching Huang [Fri, 16 Apr 2021 03:44:57 +0000 (11:44 +0800)]
scsi: arcmsr: Fix the wrong CDB payload report to IOP

This patch fixes the wrong CDB payload report to IOP.

Link: https://lore.kernel.org/r/d2c97df3c817595c6faf582839316209022f70da.camel@areca.com.tw
Signed-off-by: ching Huang <ching2048@areca.com.tw>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: megaraid_sas: Use DEFINE_SPINLOCK() for spinlock
Shixin Liu [Mon, 29 Mar 2021 09:45:32 +0000 (17:45 +0800)]
scsi: megaraid_sas: Use DEFINE_SPINLOCK() for spinlock

spinlock can be initialized automatically with DEFINE_SPINLOCK() rather
than explicitly calling spin_lock_init().

Link: https://lore.kernel.org/r/20210329094532.4165147-1-liushixin2@huawei.com
Acked-by: Sumit Saxena <sumit.saxena@broadcom.com>
Signed-off-by: Shixin Liu <liushixin2@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>