Commit graph

19134 commits

Author SHA1 Message Date
Stanley Chu
c40ad6b7fc scsi: ufs: pass device information to apply_dev_quirks
Pass UFS device information to vendor-specific variant callback
"apply_dev_quirks" because some platform vendors need to know such
information to apply special handling or quirks in specific devices.

At the same time, modify existing vendor implementations according to the
new interface for those vendor drivers which will be built-in or built as a
module alone with UFS core driver.

[mkp: clarified commit desc]

Cc: Alim Akhtar <alim.akhtar@samsung.com>
Cc: Asutosh Das <asutoshd@codeaurora.org>
Cc: Avri Altman <avri.altman@wdc.com>
Cc: Bart Van Assche <bvanassche@acm.org>
Cc: Bean Huo <beanhuo@micron.com>
Cc: Can Guo <cang@codeaurora.org>
Cc: Matthias Brugger <matthias.bgg@gmail.com>
Link: https://lore.kernel.org/r/1578726707-6596-2-git-send-email-stanley.chu@mediatek.com
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Reviewed-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2020-01-15 22:23:13 -05:00
Colin Ian King
4362269711 scsi: BusLogic: use %lX for unsigned long rather than %X
Currently the incorrect %X print format specifier is being used for several
unsigned longs.  Fix these by using %lX instead. Also join up some literal
strings that are split.

Link: https://lore.kernel.org/r/20200108193800.96706-1-colin.king@canonical.com
Addresses-Coverity: ("Invalid type in argument to printf format specifier")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Khalid Aziz <khalid@gonehiking.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2020-01-15 22:19:49 -05:00
Stanley Chu
fd1fb4d556 scsi: ufs: remove "errors" word in ufshcd_print_err_hist()
Remove "errors" word in output string by ufshcd_print_err_hist() since not
all printed targets are "errors". Sometimes they are just "events".

In addition, all events which can be treated as "errors" already have "err"
or "fail" words in their names.

Cc: Alim Akhtar <alim.akhtar@samsung.com>
Cc: Asutosh Das <asutoshd@codeaurora.org>
Cc: Avri Altman <avri.altman@wdc.com>
Cc: Bart Van Assche <bvanassche@acm.org>
Cc: Bean Huo <beanhuo@micron.com>
Cc: Can Guo <cang@codeaurora.org>
Cc: Matthias Brugger <matthias.bgg@gmail.com>
Link: https://lore.kernel.org/r/1578147968-30938-4-git-send-email-stanley.chu@mediatek.com
Reviewed-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2020-01-15 21:59:44 -05:00
Stanley Chu
a5fe372d92 scsi: ufs: add device reset history for vendor implementations
Device reset history shall be also added for vendor's device reset variant
operation implementation.

Cc: Alim Akhtar <alim.akhtar@samsung.com>
Cc: Asutosh Das <asutoshd@codeaurora.org>
Cc: Avri Altman <avri.altman@wdc.com>
Cc: Bart Van Assche <bvanassche@acm.org>
Cc: Bean Huo <beanhuo@micron.com>
Cc: Can Guo <cang@codeaurora.org>
Cc: Matthias Brugger <matthias.bgg@gmail.com>
Link: https://lore.kernel.org/r/1578147968-30938-3-git-send-email-stanley.chu@mediatek.com
Reviewed-by: Bean Huo <beanhuo@micron.com>
Reviewed-by: Asutosh Das <asutoshd@codeaurora.org>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2020-01-15 21:59:44 -05:00
Stanley Chu
645728a644 scsi: ufs: fix empty check of error history
Currently checking if an error history element is empty or not is by its
"value". In most cases, value is error code.

However this checking is not correct because some errors or events do not
specify any values in error history so values remain as 0, and this will
lead to incorrect empty checking.

Fix it by checking "timestamp" instead of "value" because timestamp will be
always assigned for all history elements

Cc: Alim Akhtar <alim.akhtar@samsung.com>
Cc: Asutosh Das <asutoshd@codeaurora.org>
Cc: Avri Altman <avri.altman@wdc.com>
Cc: Bart Van Assche <bvanassche@acm.org>
Cc: Bean Huo <beanhuo@micron.com>
Cc: Can Guo <cang@codeaurora.org>
Cc: Matthias Brugger <matthias.bgg@gmail.com>
Link: https://lore.kernel.org/r/1578147968-30938-2-git-send-email-stanley.chu@mediatek.com
Reviewed-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2020-01-15 21:59:44 -05:00
Linus Torvalds
c21ed4d9a6 SCSI fixes on 20200114
Two simple fixes in the upper drivers (so both fairly core), one in
 enclosures, which fixes replugging a device into an enclosure slot and
 one in the disk driver which fixes revalidating a drive with
 protection information (PI) to make it a non-PI drive ... previously
 we were still remembering the old PI state.  Both fixed issues are
 quite rare in the field.
 
 Signed-off-by: James E.J. Bottomley <jejb@linux.ibm.com>
 -----BEGIN PGP SIGNATURE-----
 
 iJwEABMIAEQWIQTnYEDbdso9F2cI+arnQslM7pishQUCXh3ociYcamFtZXMuYm90
 dG9tbGV5QGhhbnNlbnBhcnRuZXJzaGlwLmNvbQAKCRDnQslM7pishUvhAQDcb5gL
 fuNT0jNkQ54sKUjVKvvJP1ArmfJ1ZIub4bvkMwEA0D+Ho3iE28KOSW1NRtgTe5mz
 4Rrq64iJcAnt1PQ776U=
 =+ANJ
 -----END PGP SIGNATURE-----

Merge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi

Pull SCSI fixes from James Bottomley:
 "Two simple fixes in the upper drivers (so both fairly core), one in
  enclosures, which fixes replugging a device into an enclosure slot and
  one in the disk driver which fixes revalidating a drive with
  protection information (PI) to make it a non-PI drive ... previously
  we were still remembering the old PI state.

  Both fixed issues are quite rare in the field"

* tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi:
  scsi: enclosure: Fix stale device oops with hot replug
  scsi: sd: Clear sdkp->protection_type if disk is reformatted without PI
2020-01-14 10:14:06 -08:00
Xiang Chen
465f4edaec scsi: sd: Clear sdkp->protection_type if disk is reformatted without PI
If an attached disk with protection information enabled is reformatted
to Type 0 the revalidation code does not clear the original protection
type and subsequent accesses will keep setting RDPROTECT/WRPROTECT.

Set the protection type to 0 if the disk reports PROT_EN=0 in READ
CAPACITY(16).

[mkp: commit desc]

Fixes: fe542396da ("[SCSI] sd: Ensure we correctly disable devices with unknown protection type")
Link: https://lore.kernel.org/r/1578532344-101668-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>
2020-01-10 01:28:56 -05:00
YueHaibing
fdb827e4a3 scsi: lpfc: Make lpfc_defer_acc_rsp static
Fix sparse warning:

drivers/scsi/lpfc/lpfc_nportdisc.c:344:1: warning:
 symbol 'lpfc_defer_acc_rsp' was not declared. Should it be static?

Link: https://lore.kernel.org/r/20200107014956.41748-1-yuehaibing@huawei.com
Reported-by: Hulk Robot <hulkci@huawei.com>
Reviewed-by: James Smart <james.smart@broadcom.com>
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2020-01-10 01:23:47 -05:00
Martin K. Petersen
1c46a2cf2d block, scsi: final compat_ioctl cleanup
This series concludes the work I did for linux-5.5 on the compat_ioctl()
 cleanup, killing off fs/compat_ioctl.c and block/compat_ioctl.c by moving
 everything into drivers.
 
 Overall this would be a reduction both in complexity and line count, but
 as I'm also adding documentation the overall number of lines increases
 in the end.
 
 My plan was originally to keep the SCSI and block parts separate.
 This did not work easily because of interdependencies: I cannot
 do the final SCSI cleanup in a good way without first addressing the
 CDROM ioctls, so this is one series that I hope could be merged through
 either the block or the scsi git trees, or possibly both if you can
 pull in the same branch.
 
 The series comes in these steps:
 
 1. clean up the sg v3 interface as suggested by Linus. I have
    talked about this with Doug Gilbert as well, and he would
    rebase his sg v4 patches on top of "compat: scsi: sg: fix v3
    compat read/write interface"
 
 2. Actually moving handlers out of block/compat_ioctl.c and
    block/scsi_ioctl.c into drivers, mixed in with cleanup
    patches
 
 3. Document how to do this right. I keep getting asked about this,
    and it helps to point to some documentation file.
 
 The branch is based on another one that fixes a couple of bugs found
 during the creation of this series.
 
 Changes since v3:
   https://lore.kernel.org/lkml/20200102145552.1853992-1-arnd@arndb.de/
 
 - Move sr_compat_ioctl fixup to correct patch (Ben Hutchings)
 - Add Reviewed-by tags
 
 Changes since v2:
   https://lore.kernel.org/lkml/20191217221708.3730997-1-arnd@arndb.de/
 
 - Rebase to v5.5-rc4, which contains the earlier bugfixes
 - Fix sr_block_compat_ioctl() error handling bug found by
   Ben Hutchings
 - Fix idecd_locked_compat_ioctl() compat_ptr() bug
 - Don't try to handle HDIO_DRIVE_TASKFILE in drivers/ide
 - More documentation improvements
 
 Changes since v1:
   https://lore.kernel.org/lkml/20191211204306.1207817-1-arnd@arndb.de/
 
 - move out the bugfixes into a branch for itself
 - clean up scsi sg driver further as suggested by Christoph Hellwig
 - avoid some ifdefs by moving compat_ptr() out of asm/compat.h
 - split out the blkdev_compat_ptr_ioctl function; bug spotted by
   Ben Hutchings
 - Improve formatting of documentation
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2
 
 iQIcBAABCAAGBQJeDv8JAAoJEGCrR//JCVInh/oP/2BHdQvWONxwXXg2BLH7OJHm
 4PFoblxjNH/pwHm2PKh2uj8vUSgTHqID7NJChVgKZaZEJEJR7h26Sx60p+yTAepR
 /ysQiGameacJu2ZzKPYc4/S33Yu8cogQ5+DSz7mI9T5Yw0HSAE0JZ5xd9KIZ+/u8
 6k65ujd9kCxCgmtXrpx+7JFF0xb+urXKCvjdt2EfQ1ZmuMX5rDG/bTNg5JJ50shW
 vb7Z8hCpfW61ux8M/dgIh4WvUf0SA7FOy8WF1Km9gNhKGj41Arb2lmX1Jb4jDgjl
 DGsXQupyMVwigp5N37H3o1MamX/C8S49c16/zJQcJj64xX7WdxhE5kR8JIf+36Tf
 2l4wpaqVukXPvXkdv76Y472fKoOMZATF6kCoEPG3gXW9oxXDs5d2ofALfO3uNfLB
 PC4hzorw6bBlt67qAqERft2cxMMi9xSYfYZ8jD+eSF8WLL7xIcEazZqq8dKz7O00
 Qqx6+jzejT18av7cPfLjnupZg+mEcxDbPeuCgjrbhR8lcUI4DBu379RiTaQanvyR
 W00zwqCZWYnNJoha8u3AKsRcfL8eziF+/K9k+lCuhXeQBI4ipFJ03wAD4TWCigCS
 N7AikOdLzGVxE+2IfeCXPDKpdT6hFnjulnyDEgc/7jwHzcVF3MQBHwXiKhWHEUvT
 /AzAtKAiivp+uaMgAbzd
 =cddL
 -----END PGP SIGNATURE-----

Merge tag 'block-ioctl-cleanup-5.6' into 5.6/scsi-queue

Pull compat_ioctl cleanup from Arnd. Here's his description:

This series concludes the work I did for linux-5.5 on the compat_ioctl()
cleanup, killing off fs/compat_ioctl.c and block/compat_ioctl.c by moving
everything into drivers.

Overall this would be a reduction both in complexity and line count, but
as I'm also adding documentation the overall number of lines increases
in the end.

My plan was originally to keep the SCSI and block parts separate.
This did not work easily because of interdependencies: I cannot
do the final SCSI cleanup in a good way without first addressing the
CDROM ioctls, so this is one series that I hope could be merged through
either the block or the scsi git trees, or possibly both if you can
pull in the same branch.

The series comes in these steps:

1. clean up the sg v3 interface as suggested by Linus. I have
   talked about this with Doug Gilbert as well, and he would
   rebase his sg v4 patches on top of "compat: scsi: sg: fix v3
   compat read/write interface"

2. Actually moving handlers out of block/compat_ioctl.c and
   block/scsi_ioctl.c into drivers, mixed in with cleanup
   patches

3. Document how to do this right. I keep getting asked about this,
   and it helps to point to some documentation file.

The branch is based on another one that fixes a couple of bugs found
during the creation of this series.

Changes since v3:
  https://lore.kernel.org/lkml/20200102145552.1853992-1-arnd@arndb.de/

- Move sr_compat_ioctl fixup to correct patch (Ben Hutchings)
- Add Reviewed-by tags

Changes since v2:
  https://lore.kernel.org/lkml/20191217221708.3730997-1-arnd@arndb.de/

- Rebase to v5.5-rc4, which contains the earlier bugfixes
- Fix sr_block_compat_ioctl() error handling bug found by
  Ben Hutchings
- Fix idecd_locked_compat_ioctl() compat_ptr() bug
- Don't try to handle HDIO_DRIVE_TASKFILE in drivers/ide
- More documentation improvements

Changes since v1:
  https://lore.kernel.org/lkml/20191211204306.1207817-1-arnd@arndb.de/

- move out the bugfixes into a branch for itself
- clean up scsi sg driver further as suggested by Christoph Hellwig
- avoid some ifdefs by moving compat_ptr() out of asm/compat.h
- split out the blkdev_compat_ptr_ioctl function; bug spotted by
  Ben Hutchings
- Improve formatting of documentation

Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2020-01-10 00:14:46 -05:00
Herbert Xu
a754bd5f18 block: Allow t10-pi to be modular
Currently t10-pi can only be built into the block layer which via
crc-t10dif pulls in a whole chunk of the Crypto API.  In fact all
users of t10-pi work as modules and there is no reason for it to
always be built-in.

This patch adds a new hidden option for t10-pi that is selected
automatically based on BLK_DEV_INTEGRITY and whether the users
of t10-pi are built-in or not.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2020-01-06 20:59:04 -07:00
Christoph Hellwig
4bdc0d676a remove ioremap_nocache and devm_ioremap_nocache
ioremap has provided non-cached semantics by default since the Linux 2.6
days, so remove the additional ioremap_nocache interface.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Arnd Bergmann <arnd@arndb.de>
2020-01-06 09:45:59 +01:00
Arnd Bergmann
75c0b0e118 compat_ioctl: scsi: handle HDIO commands from drivers
The ata_sas_scsi_ioctl() function implements a number of HDIO_* commands
for SCSI devices, it is used by all libata drivers as well as a few
drivers that support SAS attached SATA drives.

The only command that is not safe for compat ioctls here is
HDIO_GET_32BIT. Change the implementation to check for in_compat_syscall()
in order to do both cases correctly, and change all callers to use it
as both native and compat callback pointers, including the indirect
callers through sas_ioctl and ata_scsi_ioctl.

Reviewed-by: Ben Hutchings <ben.hutchings@codethink.co.uk>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2020-01-03 09:42:52 +01:00
Arnd Bergmann
64cbfa9655 compat_ioctl: move cdrom commands into cdrom.c
There is no need for the special cases for the cdrom ioctls any more now,
so make sure that each cdrom driver has a .compat_ioctl() callback and
calls cdrom_compat_ioctl() directly there.

Reviewed-by: Ben Hutchings <ben.hutchings@codethink.co.uk>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2020-01-03 09:42:52 +01:00
Arnd Bergmann
d320a9551e compat_ioctl: scsi: move ioctl handling into drivers
Each driver calling scsi_ioctl() gets an equivalent compat_ioctl()
handler that implements the same commands by calling scsi_compat_ioctl().

The scsi_cmd_ioctl() and scsi_cmd_blk_ioctl() functions are compatible
at this point, so any driver that calls those can do so for both native
and compat mode, with the argument passed through compat_ptr().

With this, we can remove the entries from fs/compat_ioctl.c.  The new
code is larger, but should be easier to maintain and keep updated with
newly added commands.

Reviewed-by: Ben Hutchings <ben.hutchings@codethink.co.uk>
Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2020-01-03 09:42:32 +01:00
Arnd Bergmann
7eafd1373b compat_ioctl: add scsi_compat_ioctl
In order to move the compat handling for SCSI ioctl commands out of
fs/compat_ioctl.c into the individual drivers, we need a helper function
first to match the native ioctl handler called by sd, sr, st, etc.

Reviewed-by: Ben Hutchings <ben.hutchings@codethink.co.uk>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2020-01-03 09:33:18 +01:00
Arnd Bergmann
78ed001d9e compat: scsi: sg: fix v3 compat read/write interface
In the v5.4 merge window, a cleanup patch from Al Viro conflicted
with my rework of the compat handling for sg.c read(). Linus Torvalds
did a correct merge but pointed out that the resulting code is still
unsatisfactory.

I later noticed that the sg_new_read() function still gets the compat
mode wrong, when the 'count' argument is large enough to pass a
compat_sg_io_hdr object, but not a nativ sg_io_hdr.

To address both of these, move the definition of compat_sg_io_hdr
into a scsi/sg.h to make it visible to sg.c and rewrite the logic
for reading req_pack_id as well as the size check to a simpler
version that gets the expected results.

Fixes: c35a5cfb41 ("scsi: sg: sg_read(): simplify reading ->pack_id of userland sg_io_hdr_t")
Fixes: 98aaaec4a1 ("compat_ioctl: reimplement SG_IO handling")
Reviewed-by: Ben Hutchings <ben.hutchings@codethink.co.uk>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2020-01-03 09:32:54 +01:00
Sreekanth Reddy
c53cf10ef6 scsi: mpt3sas: Update drive version to 33.100.00.00
Update mpt3sas driver version from 32.100.00.00 to 33.100.00.00

Link: https://lore.kernel.org/r/20191226111333.26131-11-sreekanth.reddy@broadcom.com
Signed-off-by: Sreekanth Reddy <sreekanth.reddy@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2020-01-02 22:23:17 -05:00
Sreekanth Reddy
c50ed99cd5 scsi: mpt3sas: Remove usage of device_busy counter
Remove usage of device_busy counter from driver. Instead of device_busy
counter now driver uses 'nr_active' counter of request_queue to get the
number of inflight request for a LUN.

Link: https://lore.kernel.org/r/20191226111333.26131-10-sreekanth.reddy@broadcom.com
Signed-off-by: Sreekanth Reddy <sreekanth.reddy@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2020-01-02 22:23:17 -05:00
Sreekanth Reddy
c6bdb6a108 scsi: mpt3sas: Print function name in which cmd timed out
Print the function name in which MPT command got timed out. This will
facilitate debugging in which path corresponding MPT command got timeout in
first failure instance of log itself.

Link: https://lore.kernel.org/r/20191226111333.26131-9-sreekanth.reddy@broadcom.com
Signed-off-by: Sreekanth Reddy <sreekanth.reddy@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2020-01-02 22:23:17 -05:00
Sreekanth Reddy
5b061980e3 scsi: mpt3sas: Optimize mpt3sas driver logging
This improves mpt3sas driver default debug information collection and
allows for a higher percentage of issues being able to be resolved with a
first-time data capture.  However, this improvement to balance the amount
of debug data captured with the performance of driver.

Enabled below print messages with out affecting the IO performance,

1. When task abort TM is received then print IO commands's timeout value
   and how much time this command has been outstanding.

2. Whenever hard reset occurs then print from where this hard reset has
   been issued.

3. Failure message should be displayed for failure scenarios without any
   logging level.

4. Added a print after driver successfully register or unregistered a
   target drive with the SML. This print will be useful for debugging the
   issue where the drive addition or deletion is hanging at SML.

5. During driver load time print request, reply, sense and config page
   pool's information such as its address, length and size. Also printed
   sg_tablesize information.

Link: https://lore.kernel.org/r/20191226111333.26131-8-sreekanth.reddy@broadcom.com
Signed-off-by: Sreekanth Reddy <sreekanth.reddy@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2020-01-02 22:23:17 -05:00
Sreekanth Reddy
c597771894 scsi: mpt3sas: print in which path firmware fault occurred
When Firmware fault occurs then print in which path firmware fault has
occurred. This will be useful while debugging the firmware fault issues.

Link: https://lore.kernel.org/r/20191226111333.26131-7-sreekanth.reddy@broadcom.com
Signed-off-by: Sreekanth Reddy <sreekanth.reddy@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2020-01-02 22:23:17 -05:00
Sreekanth Reddy
fce0aa0879 scsi: mpt3sas: Handle CoreDump state from watchdog thread
Watchdog thread polls for IOC state every 1 second.  If it detects that IOC
state is in CoreDump state then it immediately stops the IOs and also
clears the outstanding commands issued to the HBA firmware and then it will
poll for IOC state to be out of CoreDump state and once it detects that IOC
state is changed from CoreDump state to Fault state (or) CoreDumpTOSec
number of seconds are elapsed then it will issue host reset operation and
moves the IOC state to Operational state and resumes the IOs.

Whenever any TM is received from SML then if driver detects the IOC state
is in CoreDump state then it will wait for CoreDump state to be cleared and
will host reset operation.

Link: https://lore.kernel.org/r/20191226111333.26131-6-sreekanth.reddy@broadcom.com
Signed-off-by: Sreekanth Reddy <sreekanth.reddy@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2020-01-02 22:23:16 -05:00
Sreekanth Reddy
e8c2307e6a scsi: mpt3sas: Add support IOCs new state named COREDUMP
New feature is added in HBA firmware where it copies the collected firmware
logs in flash region named 'CoreDump' whenever HBA firmware faults occur.

For copying the logs to CoreDump flash region firmware needs some time and
hence it has introduced a new IOC state named "CoreDump" State.

Whenever driver detects the CoreDump state then it means that some firmware
fault has occurred and firmware is copying the logs to the coredump flash
region. During this time driver should not perform any operation with the
HBA, driver should wait for HBA firmware to move the IOC state from
'CoreDump' state to 'Fault' state once it's done with copying the logs to
coredump region. Once driver detects the Fault state then it will issue the
diag reset/host reset operation to move the IOC state from Fault to
Operational state.

Here the valid IOC state transactions w.r.t to this CoreDump state feature,

Operational -> Fault:
The IOC transitions to the Fault state when an operational error occurs AND
CoreDump is not supported (or disabled) by the firmware(FW).

Operational -> CoreDump:
The IOC transitions to the CoreDump state when an operational error occurs
AND CoreDump is supported & enabled by the FW.

CoreDump -> Fault:
A transition from CoreDump state to Fault state happens when the FW
completes the CoreDump collection.

CoreDump -> Reset:
A transition out of the CoreDump state happens when the host sets the Reset
Adapter bit in the System Diagnostic Register (Hard Reset). This reset
action indicates that CoreDump took longer than the host time out.

Firmware informs the driver about the maximum time that driver has to wait
for firmware to transition the IOC state from 'CoreDump' to 'FAULT' state
through 'CoreDumpTOSec' field of ManufacturingPage11 page. if this
'CoreDumpTOSec' field value is zero then driver will wait for max 15
seconds.

Driver informs the HBA firmware that it supports this new IOC state named
'CoreDump' state by enabling COREDUMP_ENABLE flag in ConfigurationFlags
field of ioc init request message.

Current patch handles the CoreDump state only during HBA initialization and
release scenarios where watchdog thread (which polls the IOC state in every
one second) is disabled.  Next subsequent patch handle the CoreDump state
when watchdog thread is enabled.

During HBA initialization or release execution time if driver detects the
CoreDump state then driver will wait for maximum CoreDumpTOSec value
seconds for FW to copy the logs. After that it will issue the diag reset
operation to move the IOC state to Operational state.

Link: https://lore.kernel.org/r/20191226111333.26131-5-sreekanth.reddy@broadcom.com
Signed-off-by: Sreekanth Reddy <sreekanth.reddy@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2020-01-02 22:23:16 -05:00
Sreekanth Reddy
36c6c7f75b scsi: mpt3sas: renamed _base_after_reset_handler function
Renamed _base_after_reset_handler function to
_base_clear_outstanding_commands so that it can be used in multiple
scenarios with suitable name which matches with the operation it does.

Also renamed its child functions. No functional changes.

Link: https://lore.kernel.org/r/20191226111333.26131-4-sreekanth.reddy@broadcom.com
Signed-off-by: Sreekanth Reddy <sreekanth.reddy@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2020-01-02 22:23:16 -05:00
Sreekanth Reddy
d3f623ae8e scsi: mpt3sas: Add support for NVMe shutdown
Introduce function _scsih_nvme_shutdown() to issue IO Unit Control message
to IOC firmware with operation code 'shutdown'. This causes IOC firmware to
issue NVMe shutdown commands to all NVMe drives attached to it.

NVMe Shutdown:

NVMe devices need to have a specific shutdown sequence performed before
power is removed. For this, the IOC firmware needs to be notified when the
system is being shutdown. So during the system shutdown time, driver issues
an IO Unit Control request with operation code MPI26_CTRL_OP_SHUTDOWN to
inform firmware that a shutdown is initiated.

This shutdown command is issued only if NVMe devices are attached to the
controller.

During each NVMe device addition, driver reads pcie device page2 to get
shutdown latency (e.g. drive's RTD3 Entry Latency) and updates the max
latency value among the added NVMe drives in ioc->max_shutdown_latency.
This is used as the timeout value for IO Unit Control command at the time
of shutdown.

When a NVMe drive is removed and its shutdown latency matches which
ioc->max_shutdown_latency then ioc->max_shutdown_latency is updated to next
max value (by iterating over the list of available devices).  If the
shutdown latency is 0, then default timeout is set to six seconds.

Link: https://lore.kernel.org/r/20191226111333.26131-3-sreekanth.reddy@broadcom.com
Signed-off-by: Sreekanth Reddy <sreekanth.reddy@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2020-01-02 22:23:16 -05:00
Sreekanth Reddy
1ade26b616 scsi: mpt3sas: Update MPI Headers to v02.00.57
Update MPI Headers to version 02.00.57.

Link: https://lore.kernel.org/r/20191226111333.26131-2-sreekanth.reddy@broadcom.com
Signed-off-by: Sreekanth Reddy <sreekanth.reddy@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2020-01-02 22:23:16 -05:00
Stanley Chu
5d74e18edd scsi: ufs-mediatek: configure and enable clk-gating
Enable clk-gating with customized delayed timer value in MediaTek Chipsets.

Cc: Alim Akhtar <alim.akhtar@samsung.com>
Cc: Avri Altman <avri.altman@wdc.com>
Cc: Bart Van Assche <bvanassche@acm.org>
Cc: Bean Huo <beanhuo@micron.com>
Cc: Can Guo <cang@codeaurora.org>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: Matthias Brugger <matthias.bgg@gmail.com>
Link: https://lore.kernel.org/r/1577683950-1702-7-git-send-email-stanley.chu@mediatek.com
Reviewed-by: Alim Akhtar <alim.akhtar@samsung.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2020-01-02 21:57:45 -05:00
Stanley Chu
8588c6b032 scsi: ufs-mediatek: configure customized auto-hibern8 timer
Configure customized auto-hibern8 timer in MediaTek Chipsets.

Cc: Alim Akhtar <alim.akhtar@samsung.com>
Cc: Avri Altman <avri.altman@wdc.com>
Cc: Bart Van Assche <bvanassche@acm.org>
Cc: Bean Huo <beanhuo@micron.com>
Cc: Can Guo <cang@codeaurora.org>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: Matthias Brugger <matthias.bgg@gmail.com>
Link: https://lore.kernel.org/r/1577683950-1702-6-git-send-email-stanley.chu@mediatek.com
Reviewed-by: Alim Akhtar <alim.akhtar@samsung.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2020-01-02 21:57:45 -05:00
Stanley Chu
ba7af5ec51 scsi: ufs: export ufshcd_auto_hibern8_update for vendor usage
Export ufshcd_auto_hibern8_update to allow vendors to use common interface
to customize auto-hibernate timer.

Cc: Alim Akhtar <alim.akhtar@samsung.com>
Cc: Avri Altman <avri.altman@wdc.com>
Cc: Bart Van Assche <bvanassche@acm.org>
Cc: Bean Huo <beanhuo@micron.com>
Cc: Can Guo <cang@codeaurora.org>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: Matthias Brugger <matthias.bgg@gmail.com>
Link: https://lore.kernel.org/r/1577683950-1702-5-git-send-email-stanley.chu@mediatek.com
Reviewed-by: Asutosh Das <asutoshd@codeaurora.org>
Reviewed-by: Alim Akhtar <alim.akhtar@samsung.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2020-01-02 21:57:45 -05:00
Stanley Chu
97347214bc scsi: ufs-mediatek: introduce reference clock control
Introduce reference clock control in MediaTek Chipset in order to disable
it if it is not necessary by UFS device to save system power.

Currently reference clock can be disabled during system suspend, runtime
suspend and clock-gating after link enters hibernate state.

Cc: Alim Akhtar <alim.akhtar@samsung.com>
Cc: Avri Altman <avri.altman@wdc.com>
Cc: Bart Van Assche <bvanassche@acm.org>
Cc: Bean Huo <beanhuo@micron.com>
Cc: Can Guo <cang@codeaurora.org>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: Matthias Brugger <matthias.bgg@gmail.com>
Link: https://lore.kernel.org/r/1577683950-1702-4-git-send-email-stanley.chu@mediatek.com
Reviewed-by: Alim Akhtar <alim.akhtar@samsung.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2020-01-02 21:57:45 -05:00
Stanley Chu
b0d077ed38 scsi: ufs-mediatek: add device reset implementation
Add device reset vops implementation in MediaTek UFS driver.

Cc: Alim Akhtar <alim.akhtar@samsung.com>
Cc: Avri Altman <avri.altman@wdc.com>
Cc: Bart Van Assche <bvanassche@acm.org>
Cc: Bean Huo <beanhuo@micron.com>
Cc: Can Guo <cang@codeaurora.org>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: Matthias Brugger <matthias.bgg@gmail.com>
Link: https://lore.kernel.org/r/1577683950-1702-3-git-send-email-stanley.chu@mediatek.com
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2020-01-02 21:57:44 -05:00
Nishad Kamdar
6ee090ea04 scsi: ufs: sysfs: Use the correct style for SPDX License Identifier
This patch corrects the SPDX License Identifier style in header file
related to UFS Host Controller. It assigns explicit block comment to the
SPDX License Identifier.

Changes made by using a script provided by Joe Perches here:
https://lkml.org/lkml/2019/2/7/46.

Link: https://lore.kernel.org/r/5ca6287665fe52d8f40062e0eab8561d2b7a5b40.1577511720.git.nishadkamdar@gmail.com
Suggested-by: Joe Perches <joe@perches.com>
Signed-off-by: Nishad Kamdar <nishadkamdar@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2020-01-02 21:57:44 -05:00
Nishad Kamdar
fae35c14c4 scsi: mylex: Use the correct style for SPDX License Identifier
This patch corrects the SPDX License Identifier style in header files
related to Mylex DAC960/DAC1100 PCI RAID Controllers. It assigns explicit
block comment to the SPDX License Identifier.

Changes made by using a script provided by Joe Perches here:
https://lkml.org/lkml/2019/2/7/46.

Link: https://lore.kernel.org/r/88332ad390f985bdebb9f2adaf2d499b0a639753.1577511720.git.nishadkamdar@gmail.com
Suggested-by: Joe Perches <joe@perches.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Nishad Kamdar <nishadkamdar@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2020-01-02 21:57:44 -05:00
Bart Van Assche
0dd0dec167 scsi: ufs: Remove the SCSI timeout handler
The UFS SCSI timeout handler was needed to compensate that
ufshcd_queuecommand() could return SCSI_MLQUEUE_HOST_BUSY for a long
time. Commit a276c19e3e98 ("scsi: ufs: Avoid busy-waiting by eliminating
tag conflicts") fixed this so the timeout handler is no longer necessary.

See also commit f550c65b54 ("scsi: ufs: implement scsi host timeout handler").

Cc: Bean Huo <beanhuo@micron.com>
Cc: Can Guo <cang@codeaurora.org>
Cc: Avri Altman <avri.altman@wdc.com>
Cc: Stanley Chu <stanley.chu@mediatek.com>
Cc: Tomas Winkler <tomas.winkler@intel.com>
Link: https://lore.kernel.org/r/20191224220248.30138-7-bvanassche@acm.org
Reviewed-by: Can Guo <cang@codeaurora.org>
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>
2020-01-02 21:57:44 -05:00
Bart Van Assche
eacf36f5be scsi: ufs: Fix a race condition in the tracing code
Starting execution of a command before tracing a command may cause the
completion handler to free data while it is being traced. Fix this race by
tracing a command before it is submitted.

Cc: Bean Huo <beanhuo@micron.com>
Cc: Can Guo <cang@codeaurora.org>
Cc: Avri Altman <avri.altman@wdc.com>
Cc: Stanley Chu <stanley.chu@mediatek.com>
Cc: Tomas Winkler <tomas.winkler@intel.com>
Link: https://lore.kernel.org/r/20191224220248.30138-5-bvanassche@acm.org
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>
2020-01-02 21:57:44 -05:00
Bart Van Assche
1b21b8f008 scsi: ufs: Make ufshcd_prepare_utp_scsi_cmd_upiu() easier to read
Since the lrbp->cmd expression occurs multiple times, introduce a new local
variable to hold that pointer. This patch does not change any
functionality.

Cc: Bean Huo <beanhuo@micron.com>
Cc: Can Guo <cang@codeaurora.org>
Cc: Avri Altman <avri.altman@wdc.com>
Cc: Stanley Chu <stanley.chu@mediatek.com>
Cc: Tomas Winkler <tomas.winkler@intel.com>
Link: https://lore.kernel.org/r/20191224220248.30138-4-bvanassche@acm.org
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Reviewed-by: Can Guo <cang@codeaurora.org>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2020-01-02 21:57:44 -05:00
Bart Van Assche
e4d2add7fd scsi: ufs: Make ufshcd_add_command_trace() easier to read
Since the lrbp->cmd expression occurs multiple times, introduce a new local
variable to hold that pointer. This patch does not change any
functionality.

Cc: Bean Huo <beanhuo@micron.com>
Cc: Can Guo <cang@codeaurora.org>
Cc: Avri Altman <avri.altman@wdc.com>
Cc: Stanley Chu <stanley.chu@mediatek.com>
Cc: Tomas Winkler <tomas.winkler@intel.com>
Link: https://lore.kernel.org/r/20191224220248.30138-3-bvanassche@acm.org
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Reviewed-by: Can Guo <cang@codeaurora.org>
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>
2020-01-02 21:57:44 -05:00
Bart Van Assche
68c9fcfd4a scsi: ufs: Fix indentation in ufshcd_query_attr_retry()
Remove a space that occurs after a tab.

Cc: Bean Huo <beanhuo@micron.com>
Cc: Can Guo <cang@codeaurora.org>
Cc: Avri Altman <avri.altman@wdc.com>
Cc: Stanley Chu <stanley.chu@mediatek.com>
Cc: Tomas Winkler <tomas.winkler@intel.com>
Link: https://lore.kernel.org/r/20191224220248.30138-2-bvanassche@acm.org
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Reviewed-by: Can Guo <cang@codeaurora.org>
Reviewed-by: Alim Akhar <alim.akhtar@samsung.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2020-01-02 21:57:44 -05:00
Stanley Chu
7c486d91f3 scsi: ufs: use ufshcd_vops_dbg_register_dump for vendor specific dumps
We already have ufshcd_vops_dbg_register_dump() thus all
"hba->vops->dbg_register_dump" references can be replaced by it.

Link: https://lore.kernel.org/r/1577192466-20762-3-git-send-email-stanley.chu@mediatek.com
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Can Guo <cang@codeaurora.org>
Reviewed-by: Alim Akhtar <alim.akhtar@samsung.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2020-01-02 21:57:35 -05:00
Stanley Chu
03e1d28edd scsi: ufs: unify scsi_block_requests usage
Currently UFS driver has ufshcd_scsi_block_requests() with reference
counter mechanism to avoid possible racing of blocking and unblocking
requests flow. Unify all users in UFS driver to use the same function.

Link: https://lore.kernel.org/r/1577192466-20762-2-git-send-email-stanley.chu@mediatek.com
Reviewed-by: Can Guo <cang@codeaurora.org>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Alim Akhtar <alim.akhtar@samsung.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2020-01-02 21:57:16 -05:00
Damien Le Moal
dbfc5626d9 scsi: sd_zbc: Rename sd_zbc_check_zones()
Now that the block layer implement zone checks on revalidate,
sd_zbc_check_zones() is reduced getting the zone size and verifying the
device capacity for device with RC_BASIS=0. Be clear about this by renaming
sd_zbc_check_zones() to sd_zbc_check_capacity() and updating the function
description and comments.

Link: https://lore.kernel.org/r/20191220075823.400072-3-damien.lemoal@wdc.com
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2020-01-02 21:53:31 -05:00
Damien Le Moal
19aaa40723 scsi: sd_zbc: Simplify sd_zbc_check_zones()
Now that the block layer generic zone revalidation code in
blk_revalidate_disk_zones() checks for power of 2 zone size, there is no
need to do it in sd_zbc_check_zones(). Remove this check.

Link: https://lore.kernel.org/r/20191220075823.400072-2-damien.lemoal@wdc.com
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2020-01-02 21:53:31 -05:00
Bart Van Assche
a9c4ae1086 scsi: qla2xxx: Use get_unaligned_*() instead of open-coding these functions
This patch improves readability and does not change any functionality.

Cc: Himanshu Madhani <hmadhani@marvell.com>
Cc: Quinn Tran <qutran@marvell.com>
Cc: Martin Wilck <mwilck@suse.com>
Cc: Daniel Wagner <dwagner@suse.de>
Cc: Roman Bolshakov <r.bolshakov@yadro.com>
Link: https://lore.kernel.org/r/20191219005050.40193-1-bvanassche@acm.org
Reviewed-by: Daniel Wagner <dwagner@suse.de>
Reviewed-by: Roman Bolshakov <r.bolshakov@yadro.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2020-01-02 21:53:31 -05:00
Bart Van Assche
3f5f7335e5 scsi: qla2xxx: Fix the endianness of the qla82xx_get_fw_size() return type
Since qla82xx_get_fw_size() returns a number in CPU-endian format, change
its return type from __le32 into u32. This patch does not change any
functionality.

Fixes: 9c2b297572 ("[SCSI] qla2xxx: Support for loading Unified ROM Image (URI) format firmware file.")
Cc: Himanshu Madhani <hmadhani@marvell.com>
Cc: Quinn Tran <qutran@marvell.com>
Cc: Martin Wilck <mwilck@suse.com>
Cc: Daniel Wagner <dwagner@suse.de>
Cc: Roman Bolshakov <r.bolshakov@yadro.com>
Link: https://lore.kernel.org/r/20191219004905.39586-1-bvanassche@acm.org
Reviewed-by: Daniel Wagner <dwagner@suse.de>
Reviewed-by: Roman Bolshakov <r.bolshakov@yadro.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2020-01-02 21:53:30 -05:00
Bart Van Assche
a27747a207 scsi: qla2xxx: Improve readability of the code that handles qla_flt_header
Declare qla_hw_data.flt as a qla_flt_header pointer instead of as a void
pointer. Add a zero-length array at the end of struct qla_flt_header to
make it clear that qla_flt_header and qla_flt_region are contiguous. This
patch removes several casts but does not change any functionality.

Cc: Himanshu Madhani <hmadhani@marvell.com>
Cc: Quinn Tran <qutran@marvell.com>
Cc: Martin Wilck <mwilck@suse.com>
Cc: Daniel Wagner <dwagner@suse.de>
Cc: Roman Bolshakov <r.bolshakov@yadro.com>
Link: https://lore.kernel.org/r/20191219004706.39039-1-bvanassche@acm.org
Reviewed-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2020-01-02 21:53:30 -05:00
Linus Torvalds
bf8d1cd438 SCSI fixes on 20191227
Four fixes and one spelling update, all in drivers: 2 in lpfc and the
 rest in mp3sas, cxgbi and target.
 
 Signed-off-by: James E.J. Bottomley <jejb@linux.ibm.com>
 -----BEGIN PGP SIGNATURE-----
 
 iJwEABMIAEQWIQTnYEDbdso9F2cI+arnQslM7pishQUCXgaIWSYcamFtZXMuYm90
 dG9tbGV5QGhhbnNlbnBhcnRuZXJzaGlwLmNvbQAKCRDnQslM7pishb2SAP45hS5T
 owI8lIt+jMBnYG3k/66EleVdqMOcvtm9ewDN2gD/eW1LBz6uPzPn07gLB3V4TTTZ
 rI8lfohhWJwRAHjvL8A=
 =nxXW
 -----END PGP SIGNATURE-----

Merge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi

Pull SCSI fixes from James Bottomley:
 "Four fixes and one spelling update, all in drivers: two in lpfc and
  the rest in mp3sas, cxgbi and target"

* tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi:
  scsi: target/iblock: Fix protection error with blocks greater than 512B
  scsi: libcxgbi: fix NULL pointer dereference in cxgbi_device_destroy()
  scsi: lpfc: fix spelling mistakes of asynchronous
  scsi: lpfc: fix build failure with DEBUGFS disabled
  scsi: mpt3sas: Fix double free in attach error handling
2019-12-27 17:28:41 -08:00
John Garry
b3e3d4c618 scsi: libsas: Tidy SAS address print format
Currently we use a mixture of %016llx, %llx, and %16llx when printing a SAS
address.

Since the most significant nibble of the SAS address is always 5 - as per
standard - this formatting is not so important; but some fake SAS addresses
for SATA devices may not be. And we have mangled/invalid address to
consider also. And it's better to be consistent in the code, so use a fixed
format.

The SAS address is a fixed size at 64b, so we want to 0 byte extend to 16
nibbles, so use %016llx globally.

Also make some prints to be explicitly hex, and tidy some whitespace issue.

Link: https://lore.kernel.org/r/1576758957-227350-1-git-send-email-john.garry@huawei.com
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2019-12-21 13:42:42 -05:00
James Smart
6d67e84733 scsi: lpfc: Update lpfc version to 12.6.0.3
Update lpfc version to 12.6.0.3

Link: https://lore.kernel.org/r/20191218235808.31922-11-jsmart2021@gmail.com
Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2019-12-21 13:42:42 -05:00
James Smart
c438d0628a scsi: lpfc: Fix improper flag check for IO type
Current driver code looks at iocb types and uses a "==" comparison on the
flags to determine type. If another flag were set, it would disrupt the
comparison.

Fix by converting to a bitwise & operation.

Link: https://lore.kernel.org/r/20191218235808.31922-10-jsmart2021@gmail.com
Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2019-12-21 13:42:42 -05:00
James Smart
999fbbceb8 scsi: lpfc: Fix MDS Latency Diagnostics Err-drop rates
When running Cisco-MDS diagnostics which perform driver-level frame loop
back, the switch is reporting errors. Diagnostic has a limit on latency
that is not being met by the driver.

The requirement of Latency frames is that they should be responded back by
the host with a maximum delay of few hundreds of microseconds. If the
switch doesn't get response frames within this time frame, it fails the
test.

Test is failing as the lpfc-wq workqueue was overwhelmed by the packet rate
and in some cases, the work element yielded to other kernel elements.

To resolve, reduce the outstanding load allowed by the adapter. This
ensures the driver spends a reasonable amount of time doing loopback and
can do so such that latency values can be met.  Load is managed by reducing
the number of receive buffers posted such that the link can be
backpressured to reduce load.

Link: https://lore.kernel.org/r/20191218235808.31922-9-jsmart2021@gmail.com
Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2019-12-21 13:42:42 -05:00
James Smart
0b4391946d scsi: lpfc: Fix unmap of dpp bars affecting next driver load
When unattaching, the driver did not unmap the DPP bar. This caused the
next load of the driver, which attempts to enable wc, to not work correctly
and wc to be disabled due to an address mapping overlap.

Fix by unmapping on unattach.

Link: https://lore.kernel.org/r/20191218235808.31922-8-jsmart2021@gmail.com
Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2019-12-21 13:42:42 -05:00
James Smart
a052ce848d scsi: lpfc: Fix disablement of FC-AL on lpe35000 models
The order of the flags/checks for adapters where FC-AL is supported
erroneously excluded lpe35000 adapter models.  Also noted that the G7 flags
for Loop and Persistent topology are incorrect. They should follow the
rules as G6.

Rework the logic to enable LPe35000 FC-AL support.  Collapse G7 support
logic to the same rules as G6.

Link: https://lore.kernel.org/r/20191218235808.31922-7-jsmart2021@gmail.com
Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2019-12-21 13:42:42 -05:00
James Smart
9a20cc10fa scsi: lpfc: Fix ras_log via debugfs
/sys/kernel/debug/lpfc/fn0/ras_log always shows the same ras_log even if
there are link bounce events triggered via issue_lip

Dynamic FW logging had logic that prematurely breaks from the buffer
filling loop.

Fix the check for buffer overrun by looking before copying and restricting
copy length to the remaining buffer.  When copying, ensure space for NULL
character is left in the buffer.  While in the routine - ensure the buffer
is cleared before adding elements.

Link: https://lore.kernel.org/r/20191218235808.31922-6-jsmart2021@gmail.com
Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2019-12-21 13:42:42 -05:00
James Smart
e3ba04c9ba scsi: lpfc: Fix Fabric hostname registration if system hostname changes
There are reports of multiple ports on the same system displaying different
hostnames in fabric FDMI displays.

Currently, the driver registers the hostname at initialization and obtains
the hostname via init_utsname()->nodename queried at the time the FC link
comes up. Unfortunately, if the machine hostname is updated after
initialization, such as via DHCP or admin command, the value registered
initially will be incorrect.

Fix by having the driver save the hostname that was registered with FDMI.
The driver then runs a heartbeat action that will check the hostname.  If
the name changes, reregister the FMDI data.

The hostname is used in RSNN_NN, FDMI RPA and FDMI RHBA.

Link: https://lore.kernel.org/r/20191218235808.31922-5-jsmart2021@gmail.com
Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2019-12-21 13:42:42 -05:00
James Smart
f3d0a8acc5 scsi: lpfc: Fix missing check for CSF in Write Object Mbox Rsp
When the WriteObject mailbox response has change_status set to is 0x2
(Firmware Reset) or 0x04 (Port Migration Reset), the CSF field should also
be checked to see if a fw reset is sufficient to enable all new features in
the updated firmware image. If not, a fw reset would start the new
firmware, but with a feature level equal to existing firmware.  To enable
the new features, a chip reset/pci slot reset would be required.

Check the CSF bit when change_status is 0x2 or 0x4 to know whether to
perform a pci bus reset or fw reset.

Link: https://lore.kernel.org/r/20191218235808.31922-4-jsmart2021@gmail.com
Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2019-12-21 13:42:42 -05:00
James Smart
df9166bfa7 scsi: lpfc: Fix: Rework setting of fdmi symbolic node name registration
This patch reworks the fdmi symbolic node name data for the following two
issues:

 - Correcting extraneous periods following the DV and HN fdmi data fields.

 - Avoiding buffer overflow issues when formatting the data.

The fix to the fist issue is to just remove the characters.

The fix to the second issue has all data being staged in temporary storage
before being moved to the real buffer.

Link: https://lore.kernel.org/r/20191218235808.31922-3-jsmart2021@gmail.com
Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2019-12-21 13:42:41 -05:00
James Smart
be0709e449 scsi: lpfc: Fix incomplete NVME discovery when target
NVMe device re-discovery does not complete. Dev_loss_tmo messages seen on
initiator after recovery from a link disturbance.

The failing case is the following:

When the driver (as a NVME target) receives a PLOGI, the driver initiates
an "unreg rpi" mailbox command. While the mailbox command is in progress,
the driver requests that an ACC be sent to the initiator. The target's ACC
is received by the initiator and the initiator then transmits a PLOGI. The
driver receives the PLOGI prior to receiving the completion for the PLOGI
response WQE that sent the ACC. (Different delivery sources from the hw so
the race is very possible). Given the PLOGI is prior to the ACC completion
(signifying PLOGI exchange complete), the driver LS_RJT's the PRLI. The
"unreg rpi" mailbox then completes. Since PRLI has been received, the
driver transmits a PLOGI to restart discovery, which the initiator then
ACC's.  If the driver processes the (re)PLOGI ACC prior to the completing
the handling for the earlier ACC it sent the intiators original PLOGI,
there is no state change for completion of the (re)PLOGI. The ndlp remains
in "PLOGI Sent" and the initiator continues sending PRLI's which are
rejected by the target until timeout or retry is reached.

Fix by: When in target mode, defer sending an ACC for the received PLOGI
until unreg RPI completes.

Link: https://lore.kernel.org/r/20191218235808.31922-2-jsmart2021@gmail.com
Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2019-12-21 13:42:41 -05:00
Himanshu Madhani
5a2673267a scsi: qla2xxx: Update driver version to 10.01.00.22-k
Link: https://lore.kernel.org/r/20191217220617.28084-15-hmadhani@marvell.com
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2019-12-21 13:42:41 -05:00
Quinn Tran
641e0efddc scsi: qla2xxx: Fix mtcp dump collection failure
MTCP dump failed due to MB Reg 10 was picking garbage data from stack
memory.

Fixes: 81178772b6 ("[SCSI] qla2xxx: Implemetation of mctp.")
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20191217220617.28084-14-hmadhani@marvell.com
Signed-off-by: Quinn Tran <qutran@marvell.com>
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2019-12-21 13:42:41 -05:00
Quinn Tran
e1217dc3ed scsi: qla2xxx: Fix stuck session in GNL
Fix race condition between GNL completion processing and GNL request. Late
submission of GNL request was not seen by the GNL completion thread. This
patch will re-submit the GNL request for late submission fcport.

Link: https://lore.kernel.org/r/20191217220617.28084-13-hmadhani@marvell.com
Signed-off-by: Quinn Tran <qutran@marvell.com>
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2019-12-21 13:42:41 -05:00
Quinn Tran
118f01e7d9 scsi: qla2xxx: Fix RIDA Format-2
This patch fixes offset for Format-2 data structure for Report ID
Acquisition. This caused driver to set remote_nport_id to 0x0000 in N2N
configuration. In a scenario where initiator's WWPN is higher than target's
WWPN, driver will assign 0x00 as target nport-id, which results into login
failure.

Link: https://lore.kernel.org/r/20191217220617.28084-12-hmadhani@marvell.com
Signed-off-by: Quinn Tran <qutran@marvell.com>
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2019-12-21 13:42:41 -05:00
Quinn Tran
f994c6d168 scsi: qla2xxx: Consolidate fabric scan
Consolidate scan for fabric loop and fabric topologies into a single scan.

Link: https://lore.kernel.org/r/20191217220617.28084-11-hmadhani@marvell.com
Signed-off-by: Quinn Tran <qutran@marvell.com>
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2019-12-21 13:42:41 -05:00
Shyam Sundar
17e64648aa scsi: qla2xxx: Correct fcport flags handling
This patch fixes some instances of FCF_ASYNC_{SENT|ACTIVE} flag setting and
clearning were missing.

Link: https://lore.kernel.org/r/20191217220617.28084-10-hmadhani@marvell.com
Signed-off-by: Shyam Sundar <ssundar@marvell.com>
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2019-12-21 13:42:41 -05:00
Quinn Tran
8aaac2d7da scsi: qla2xxx: Fix stuck login session using prli_pend_timer
Session is stuck if driver sees FW has received a PRLI. Driver allows FW to
finish with processing of PRLI by checking back with FW at a later time to
see if the PRLI has finished. Instead, driver failed to push forward after
re-checking PRLI completion.

Fixes: ce0ba496dc ("scsi: qla2xxx: Fix stuck login session")
Cc: stable@vger.kernel.org # 5.3
Link: https://lore.kernel.org/r/20191217220617.28084-9-hmadhani@marvell.com
Signed-off-by: Quinn Tran <qutran@marvell.com>
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2019-12-21 13:42:01 -05:00
Quinn Tran
3dae220595 scsi: qla2xxx: Use common routine to free fcport struct
This patch does not change any any functionality.

Link: https://lore.kernel.org/r/20191217220617.28084-8-hmadhani@marvell.com
Signed-off-by: Quinn Tran <qutran@marvell.com>
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2019-12-19 22:42:45 -05:00
Joe Carnuccio
425215647f scsi: qla2xxx: Add D-Port Diagnostic reason explanation logs
This patch adds more details when D-Port diag async event is generated by
the firmware.

Link: https://lore.kernel.org/r/20191217220617.28084-7-hmadhani@marvell.com
Signed-off-by: Joe Carnuccio <joe.carnuccio@cavium.com>
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2019-12-19 22:42:44 -05:00
Himanshu Madhani
89eb2e7e79 scsi: qla2xxx: Fix update_fcport for current_topology
logout_on_delete flag should not be set if the topology is Loop. This patch
fixes unintentional logout during loop topology.

Link: https://lore.kernel.org/r/20191217220617.28084-6-hmadhani@marvell.com
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2019-12-19 22:42:44 -05:00
Shyam Sundar
96a0eb7164 scsi: qla2xxx: Cleanup unused async_logout_done
This patch removes unused qla2x00_async_logout_done from the code.

Link: https://lore.kernel.org/r/20191217220617.28084-5-hmadhani@marvell.com
Signed-off-by: Shyam Sundar <ssundar@marvell.com>
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2019-12-19 22:42:44 -05:00
Shyam Sundar
27258a5771 scsi: qla2xxx: Add a shadow variable to hold disc_state history of fcport
This patch adds a shadow variable to hold disc_state history for the fcport
and prints state transition when the logging is enabled.

Link: https://lore.kernel.org/r/20191217220617.28084-4-hmadhani@marvell.com
Signed-off-by: Shyam Sundar <ssundar@marvell.com>
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2019-12-19 22:42:44 -05:00
Quinn Tran
f57a010735 scsi: qla2xxx: Fix fabric scan hang
On timeout, SRB pointer was cleared from outstanding command array and
dropped.  It was not allowed to go through the done process and cleanup.
This patch will abort the SRB where FW will return it with an error status
and resume the normal cleanup.

Link: https://lore.kernel.org/r/20191217220617.28084-3-hmadhani@marvell.com
Signed-off-by: Quinn Tran <qutran@marvell.com>
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2019-12-19 22:42:44 -05:00
Himanshu Madhani
3c75ad1d87 scsi: qla2xxx: Remove defer flag to indicate immeadiate port loss
During cable pull test case, if the port is disconnected for time larger
than devloss timeout, driver does not mark path offline.  In such case,
instead of notifying SCSI-ML of loop down, driver goes into endless loop of
device relogin because defer flag is set.

With newer handling of device relogin in driver discovery, defer flag is
now redundant. This patch removes defer flag and cleans up code handling
port lost indication to SCSI-ML.

Link: https://lore.kernel.org/r/20191217220617.28084-2-hmadhani@marvell.com
Signed-off-by: Quinn Tran <qtran@marvell.com>
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2019-12-19 22:42:44 -05:00
Thomas Hellstrom
d8dd7d7681 scsi: vmw_pvscsi: Silence dma mapping errors
These errors typically occur with swiotlb when the swiotlb buffer is full.
But they are transient and would typically unnecessarily worry a user.
Instead of errors, print debug messages.

Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Link: https://lore.kernel.org/r/20191203193052.7583-2-thomas_os@shipmail.org
Acked-by: Jim Gill <jgill@vmware.com>
Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2019-12-19 22:42:44 -05:00
Thomas Hellstrom
f4652752a4 scsi: vmw_pvscsi: Fix swiotlb operation
With swiotlb, the first byte of the sense buffer may in some cases be
uninitialized since we use DMA_FROM_DEVICE, and the device incorrectly
doesn't clear it. In those cases, clear it after DMA unmapping.

Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Link: https://lore.kernel.org/r/20191203193052.7583-1-thomas_os@shipmail.org
Suggested-by: Vishal Bhakta <vbhakta@vmware.com>
Acked-by: Jim Gill <jgill@vmware.com>
Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2019-12-19 22:42:44 -05:00
Nathan Chancellor
a808a04c86 scsi: csiostor: Adjust indentation in csio_device_reset
Clang warns:

../drivers/scsi/csiostor/csio_scsi.c:1386:3: warning: misleading
indentation; statement is not part of the previous 'if'
[-Wmisleading-indentation]
         csio_lnodes_exit(hw, 1);
         ^
../drivers/scsi/csiostor/csio_scsi.c:1382:2: note: previous statement is
here
        if (*buf != '1')
        ^
1 warning generated.

This warning occurs because there is a space after the tab on this
line.  Remove it so that the indentation is consistent with the Linux
kernel coding style and clang no longer warns.

Fixes: a3667aaed5 ("[SCSI] csiostor: Chelsio FCoE offload driver")
Link: https://github.com/ClangBuiltLinux/linux/issues/818
Link: https://lore.kernel.org/r/20191218014726.8455-1-natechancellor@gmail.com
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2019-12-19 22:42:44 -05:00
Nathan Chancellor
4dbc96ad65 scsi: aic7xxx: Adjust indentation in ahc_find_syncrate
Clang warns:

../drivers/scsi/aic7xxx/aic7xxx_core.c:2317:5: warning: misleading
indentation; statement is not part of the previous 'if'
[-Wmisleading-indentation]
                        if ((syncrate->sxfr_u2 & ST_SXFR) != 0)
                        ^
../drivers/scsi/aic7xxx/aic7xxx_core.c:2310:4: note: previous statement
is here
                        if (syncrate == &ahc_syncrates[maxsync])
                        ^
1 warning generated.

This warning occurs because there is a space amongst the tabs on this
line. Remove it so that the indentation is consistent with the Linux kernel
coding style and clang no longer warns.

This has been a problem since the beginning of git history hence no fixes
tag.

Link: https://github.com/ClangBuiltLinux/linux/issues/817
Link: https://lore.kernel.org/r/20191218014220.52746-1-natechancellor@gmail.com
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2019-12-19 22:08:55 -05:00
Nathan Chancellor
aa8679736a scsi: qla4xxx: Adjust indentation in qla4xxx_mem_free
Clang warns:

../drivers/scsi/qla4xxx/ql4_os.c:4148:3: warning: misleading
indentation; statement is not part of the previous 'if'
[-Wmisleading-indentation]
         if (ha->fw_dump)
         ^
../drivers/scsi/qla4xxx/ql4_os.c:4144:2: note: previous statement is
here
        if (ha->queues)
        ^
1 warning generated.

This warning occurs because there is a space after the tab on this
line.  Remove it so that the indentation is consistent with the Linux
kernel coding style and clang no longer warns.

Fixes: 068237c87c ("[SCSI] qla4xxx: Capture minidump for ISP82XX on firmware failure")
Link: https://github.com/ClangBuiltLinux/linux/issues/819
Link: https://lore.kernel.org/r/20191218015252.20890-1-natechancellor@gmail.com
Acked-by: Manish Rangankar <mrangankar@marvell.com>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2019-12-19 22:08:55 -05:00
Chen Zhou
0c3dbdeb72 scsi: initio: make initio_state_7() static
Fix sparse warning:

drivers/scsi/initio.c:1643:5: warning: symbol 'initio_state_7' was not declared. Should it be static?

Link: https://lore.kernel.org/r/20191217134309.41649-1-chenzhou10@huawei.com
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Chen Zhou <chenzhou10@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2019-12-19 22:08:54 -05:00
Chen Zhou
4aca8fe771 scsi: ibmvscsi_tgt: remove set but not used variables 'iue' and 'sd'
Fixes gcc '-Wunused-but-set-variable' warning:

drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c: In function ibmvscsis_send_messages:
drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c:1888:19: warning: variable iue set but not used [-Wunused-but-set-variable]
drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c: In function ibmvscsis_queue_data_in:
drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c:3806:8: warning: variable sd set but not used [-Wunused-but-set-variable]

Link: https://lore.kernel.org/r/20191213064042.161840-1-chenzhou10@huawei.com
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Chen Zhou <chenzhou10@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2019-12-19 22:08:54 -05:00
Chen Zhou
08fcc87bd0 scsi: sym53c8xx: fix typos in comments
Fix the typo "GPOI" -> "GPIO" in comment.

Link: https://lore.kernel.org/r/20191212023556.72618-1-chenzhou10@huawei.com
Signed-off-by: Chen Zhou <chenzhou10@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2019-12-19 22:08:54 -05:00
Bart Van Assche
43d23b94e5 scsi: core: Fix a compiler warning triggered by the SCSI logging code
This patch fixes the following compiler warning:

In file included from drivers/scsi/scsi_error.c:46:
drivers/scsi/scsi_error.c: In function 'scsi_eh_target_reset':
drivers/scsi/scsi_logging.h:65:81: warning: suggest braces around empty body in an 'if' statement [-Wempty-body]
   65 | LOGGING(SCSI_LOG_ERROR_SHIFT, SCSI_LOG_ERROR_BITS, LEVEL,CMD);
      |                                                              ^

drivers/scsi/scsi_error.c:1562:4: note: in expansion of macro 'SCSI_LOG_ERROR_RECOVERY'
 1562 |    SCSI_LOG_ERROR_RECOVERY(3,
      |    ^~~~~~~~~~~~~~~~~~~~~~~

Link: https://lore.kernel.org/r/20191209174205.190025-1-bvanassche@acm.org
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2019-12-19 22:08:54 -05:00
Sheeba B
0786669c31 scsi: ufs: Power off hook for Cadence UFS driver
Attach power off hook to Cadence UFS driver.

Link: https://lore.kernel.org/r/1576491432-631-1-git-send-email-sheebab@cadence.com
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Reviewed-by: Alim Akhtar <alim.akhtar@samsung.com>
Signed-off-by: Sheeba B <sheebab@cadence.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2019-12-19 22:08:54 -05:00
Stanley Chu
8b0bbf002a scsi: ufs: disable interrupt during clock-gating
Similar to suspend, ufshcd interrupt can be disabled since there won't be
any host controller transaction expected till clocks ungated.

Link: https://lore.kernel.org/r/1575721321-8071-3-git-send-email-stanley.chu@mediatek.com
Reviewed-by: Asutosh Das <asutoshd@codeaurora.org>
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2019-12-19 22:08:54 -05:00
Stanley Chu
dcb6cec508 scsi: ufs: disable irq before disabling clocks
During suspend flow, interrupt shall be disabled before disabling clocks to
avoid potential system hang due to accessing host registers after host
clocks are disabled.

For example, if an interrupt comes with IRQF_IRQPOLL flag configured with
the misrouted interrupt recovery feature enabled, ufshcd ISR may be
triggered even if nothing shall be done for UFS. In this case, system hang
may happen if UFS interrupt status register is accessed with host clocks
disabled.

Link: https://lore.kernel.org/r/1575721321-8071-2-git-send-email-stanley.chu@mediatek.com
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2019-12-19 22:08:54 -05:00
Dan Carpenter
dc30c9e6d6 scsi: ufs: Simplify a condition
We know that "check_for_bkops" is non-zero on this side of the || because
it was checked on the other side.

Link: https://lore.kernel.org/r/20191213104935.wgpq2epaz6zh5zus@kili.mountain
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2019-12-19 22:08:53 -05:00
Dan Carpenter
bb14dd1564 scsi: ufs: Unlock on a couple error paths
We introduced a few new error paths, but we can't return directly, we first
have to unlock "hba->clk_scaling_lock" first.

Fixes: a276c19e3e98 ("scsi: ufs: Avoid busy-waiting by eliminating tag conflicts")
Link: https://lore.kernel.org/r/20191213104828.7i64cpoof26rc4fw@kili.mountain
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2019-12-19 22:08:53 -05:00
Sheeba B
e89fbc7feb scsi: ufs: Update L4 attributes on manual hibern8 exit in Cadence UFS.
Backup L4 attributes duirng manual hibern8 entry and restore the L4
attributes on manual hibern8 exit as per JESD220C.

Link: https://lore.kernel.org/r/1575606303-10917-1-git-send-email-sheebab@cadence.com
Reviewed-by: Alim Akhtar <alim.akhtar@samsung.com>
Tested-by: Vignesh Raghavendra <vigneshr@ti.com>
Signed-off-by: Sheeba B <sheebab@cadence.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2019-12-19 22:08:53 -05:00
Can Guo
5231d38c16 scsi: ufs: Do not free irq in suspend
Since ufshcd irq resource is allocated with the device resource management
aware IRQ request implementation, we don't really need to free up irq
during suspend, disabling it during suspend and reenabling it during resume
should be good enough.

Link: https://lore.kernel.org/r/0101016ed3d69793-22918f99-23bf-495d-8a36-a9c108d1cbce-000000@us-west-2.amazonses.com
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Can Guo <cang@codeaurora.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2019-12-19 22:08:53 -05:00
Can Guo
0834253734 scsi: ufs: Do not clear the DL layer timers
During power mode change, PACP_PWR_Req frame sends PAPowerModeUserData
parameters (and they are considered valid by device if Flags[4] -
UserDataValid bit is set in the same frame).  Currently we don't set these
PAPowerModeUserData parameters and hardware always sets UserDataValid bit
which would clear all the DL layer timeout values of the peer device after
the power mode change.

This change sets the PAPowerModeUserData[0..5] to UniPro specification
recommended default values, in addition we are also setting the relevant
DME_LOCAL_* timer attributes as required by UFS HCI specification.

Link: https://lore.kernel.org/r/0101016ed3d688a4-cfaeb1c9-238b-46c4-9c89-d48c410ba325-000000@us-west-2.amazonses.com
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Reviewed-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Can Guo <cang@codeaurora.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2019-12-19 22:08:53 -05:00
Can Guo
17c7d35f14 scsi: ufs: Release clock if DMA map fails
In queuecommand path, if DMA map fails, it bails out with clock held.  In
this case, release the clock to keep its usage paired.

[mkp: applied by hand]

Link: https://lore.kernel.org/r/0101016ed3d66395-1b7e7fce-b74d-42ca-a88a-4db78b795d3b-000000@us-west-2.amazonses.com
Reviewed-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Can Guo <cang@codeaurora.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2019-12-19 22:08:53 -05:00
Can Guo
a3a7639172 scsi: ufs: Use DBD setting in mode sense
UFS standard requires DBD field to be set to 1 in MODE SENSE(10).

Some card vendors are more strict and check the DBD field, hence respond
with CHECK_CONDITION (Sense key set to ILLEGAL_REQUEST and ASC set to
INVALID FIELD IN CDB).  When host sends MODE SENSE for page caching, as a
result of the CHECK_CONDITION response, host assumes that the device
doesn't support the cache feature and doesn't send SYNCHRONIZE_CACHE
commands to flush the device cache. This can result in data corruption in
case of sudden power down when there is data stored in the device cache.

This patch fixes the DBD field setting as required in UFS standard.

Link: https://lore.kernel.org/r/0101016ed3d657e4-32a6dd52-1505-4312-97ff-2bd3bee59eb7-000000@us-west-2.amazonses.com
Reviewed-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Can Guo <cang@codeaurora.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2019-12-19 22:08:52 -05:00
Can Guo
0ec9691334 scsi: core: Adjust DBD setting in MODE SENSE for caching mode page per LLD
UFS JEDEC standards require DBD field to be set to 1 in mode sense
command.  This patch allows LLD to define the setting of DBD, if
required.

Link: https://lore.kernel.org/r/0101016ed3d643f9-ffd45d6c-c593-4a13-a18f-a32da3d3bb97-000000@us-west-2.amazonses.com
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Signed-off-by: Can Guo <cang@codeaurora.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2019-12-19 22:08:52 -05:00
Can Guo
2df74b6985 scsi: ufs: Complete pending requests in host reset and restore path
In UFS host reset and restore path, before probe, we stop and start the
host controller once. After host controller is stopped, the pending
requests, if any, are cleared from the doorbell, but no completion IRQ
would be raised due to the hba is stopped.  These pending requests shall be
completed along with the first NOP_OUT command (as it is the first command
which can raise a transfer completion IRQ) sent during probe.  Since the
OCSs of these pending requests are not SUCCESS (because they are not yet
literally finished), their UPIUs shall be dumped. When there are multiple
pending requests, the UPIU dump can be overwhelming and may lead to
stability issues because it is in atomic context.  Therefore, before probe,
complete these pending requests right after host controller is stopped and
silence the UPIU dump from them.

Link: https://lore.kernel.org/r/1574751214-8321-5-git-send-email-cang@qti.qualcomm.com
Reviewed-by: Alim Akhtar <alim.akhtar@samsung.com>
Reviewed-by: Bean Huo <beanhuo@micron.com>
Tested-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Can Guo <cang@codeaurora.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2019-12-19 22:08:52 -05:00
Can Guo
74a527a2ab scsi: ufs: Avoid messing up the compl_time_stamp of lrbs
To be on the safe side, do not touch lrb after clearing its slot in the
lrb_in_use bitmap to avoid messing up the next task which would possibly
occupy this lrb.

[mkp: applied by hand]

Link: https://lore.kernel.org/r/1574751214-8321-4-git-send-email-cang@qti.qualcomm.com
Reviewed by: Avri Altman <avri.altman@wdc.com>
Reviewed-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Can Guo <cang@codeaurora.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2019-12-19 22:08:52 -05:00
Can Guo
a7ef6f029a scsi: ufs: Update VCCQ2 and VCCQ min/max voltage hard codes
Per UFS 3.0 JEDEC standard, the VCCQ2 min voltage is 1.7v and the VCCQ
voltage range is 1.14v ~ 1.26v. Update their hard codes accordingly to make
sure they work in a safe range compliant for ver 1.0/1.1/2.0/2.1/3.0 UFS
devices.

Link: https://lore.kernel.org/r/1574751214-8321-3-git-send-email-cang@qti.qualcomm.com
Reviewed-by: Bean Huo <beanhuo@micron.com>
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Signed-off-by: Can Guo <cang@codeaurora.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2019-12-19 22:08:52 -05:00
Asutosh Das
24366c2afb scsi: ufs: Recheck bkops level if bkops is disabled
bkops level should be rechecked upon receiving an exception.  Currently the
level is being cached and never updated.

Update bkops each time the level is checked.  Also do not use the cached
bkops level value if it is disabled and then enabled.

Fixes: afdfff59a0 (scsi: ufs: handle non spec compliant bkops behaviour by device)
Link: https://lore.kernel.org/r/1574751214-8321-2-git-send-email-cang@qti.qualcomm.com
Reviewed-by: Bean Huo <beanhuo@micron.com>
Reviewed-by: Alim Akhtar <alim.akhtar@samsung.com>
Tested-by: Alim Akhtar <alim.akhtar@samsung.com>
Signed-off-by: Asutosh Das <asutoshd@codeaurora.org>
Signed-off-by: Can Guo <cang@codeaurora.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2019-12-19 22:08:52 -05:00
Bart Van Assche
69a6c269c0 scsi: ufs: Use blk_{get,put}_request() to allocate and free TMFs
Manage TMF tags with blk_{get,put}_request() instead of
ufshcd_get_tm_free_slot() / ufshcd_put_tm_slot(). Store a per-request
completion pointer in request.end_io_data instead of using a waitqueue to
report TMF completion.

Cc: Can Guo <cang@codeaurora.org>
Cc: Stanley Chu <stanley.chu@mediatek.com>
Cc: Avri Altman <avri.altman@wdc.com>
Cc: Tomas Winkler <tomas.winkler@intel.com>
Link: https://lore.kernel.org/r/20191209181309.196233-3-bvanassche@acm.org
Tested-by: Bean Huo <beanhuo@micron.com>
Reviewed-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>
2019-12-19 22:08:52 -05:00
Bart Van Assche
7252a36030 scsi: ufs: Avoid busy-waiting by eliminating tag conflicts
Instead of tracking which tags are in use in the ufs_hba.lrb_in_use
bitmask, rely on the block layer tag allocation mechanism. This patch
removes the following busy-waiting loop if ufshcd_issue_devman_upiu_cmd()
and the block layer accidentally allocate the same tag for a SCSI request:

 * ufshcd_queuecommand() returns SCSI_MLQUEUE_HOST_BUSY.

 * The SCSI core requeues the SCSI command.

Cc: Can Guo <cang@codeaurora.org>
Cc: Stanley Chu <stanley.chu@mediatek.com>
Cc: Avri Altman <avri.altman@wdc.com>
Cc: Tomas Winkler <tomas.winkler@intel.com>
Link: https://lore.kernel.org/r/20191209181309.196233-2-bvanassche@acm.org
Tested-by: Bean Huo <beanhuo@micron.com>
Reviewed-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>
2019-12-19 22:08:51 -05:00
Kars de Jong
bd40726153 scsi: esp_scsi: Add support for FSC chip
The FSC (NCR53CF9x-2 / SYM53CF9x-2) has a different family code than QLogic
or Emulex parts. This caused it to be detected as a FAS100A.

Unforunately, this meant the configuration of the CONFIG3 register was
incorrect. This causes data transfer issues with FAST-SCSI targets.

The FSC also has the CONFIG4 register. It can be used to enable a feature
called Active Negation which should always be enabled according to the data
manual.

Link: https://lore.kernel.org/r/20191119202021.28720-3-jongk@linux-m68k.org
Reviewed-by: Finn Thain <fthain@telegraphics.com.au>
Signed-off-by: Kars de Jong <jongk@linux-m68k.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2019-12-19 22:08:51 -05:00
Kars de Jong
2086faae3c scsi: esp_scsi: Correct ordering of PCSCSI definition in esp_rev enum
The order of the definitions in the esp_rev enum is important. The values
are used in comparisons for chip features.

Add a comment to the enum explaining this.

Also, the actual values for the enum fields are irrelevant, so remove the
explicit values (suggested by Geert Uytterhoeven). This makes adding a new
field in the middle of the enum easier.

Finally, move the PCSCSI definition to the right place in the enum. In its
previous location, at the end of the enum, the wrong values are written to
the CONFIG3 register when used with FAST-SCSI targets.

Link: https://lore.kernel.org/r/20191119202021.28720-2-jongk@linux-m68k.org
Signed-off-by: Kars de Jong <jongk@linux-m68k.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2019-12-19 22:08:51 -05:00
Varun Prakash
71482fde70 scsi: libcxgbi: fix NULL pointer dereference in cxgbi_device_destroy()
If cxgb4i_ddp_init() fails then cdev->cdev2ppm will be NULL, so add a check
for NULL pointer before dereferencing it.

Link: https://lore.kernel.org/r/1576676731-3068-1-git-send-email-varun@chelsio.com
Signed-off-by: Varun Prakash <varun@chelsio.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2019-12-19 18:48:26 -05:00