platform/kernel/linux-starfive.git
4 years agoscsi: qla2xxx: Fix warning after FC target reset
Viacheslav Dubeyko [Fri, 10 Apr 2020 08:07:08 +0000 (11:07 +0300)]
scsi: qla2xxx: Fix warning after FC target reset

Currently, FC target reset finishes with the warning message:

[84010.596893] ------------[ cut here ]------------
[84010.596917] WARNING: CPU: 238 PID: 279973 at ../drivers/scsi/qla2xxx/qla_target.c:6644 qlt_enable_vha+0x1d0/0x260 [qla2xxx]
[84010.596918] Modules linked in: vrf af_packet 8021q garp mrp stp llc netlink_diag target_tatlin_tblock(OEX) dm_ec(OEX) ttln_rdma(OEX) dm_frontend(OEX) nvme_rdma nvmet tcm_qla2xxx iscsi_target_mod target_core_mod at24 nvmem_core pnv_php ipmi_watchdog ipmi_ssif vmx_crypto gf128mul crct10dif_vpmsum qla2xxx rpcrdma nvme_fc powernv_flash(X) nvme_fabrics uio_pdrv_genirq mtd rtc_opal(X) ibmpowernv(X) opal_prd(X) uio scsi_transport_fc i2c_opal(X) ses enclosure ipmi_poweroff ast i2c_algo_bit ttm bmc_mcu(OEX) drm_kms_helper syscopyarea sysfillrect sysimgblt fb_sys_fops drm drm_panel_orientation_quirks agpgart nfsd auth_rpcgss nfs_acl ipmi_powernv(X) lockd ipmi_devintf ipmi_msghandler grace dummy ext4 crc16 jbd2 mbcache sd_mod rdma_ucm ib_iser rdma_cm ib_umad iw_cm ib_ipoib libiscsi scsi_transport_iscsi ib_cm
[84010.596975]  configfs mlx5_ib ib_uverbs ib_core mlx5_core crc32c_vpmsum xhci_pci xhci_hcd mpt3sas(OEX) tg3 usbcore mlxfw tls raid_class libphy scsi_transport_sas devlink ptp pps_core nvme nvme_core sunrpc dm_mirror dm_region_hash dm_log sg dm_multipath dm_mod scsi_dh_rdac scsi_dh_emc scsi_dh_alua scsi_mod autofs4
[84010.597001] Supported: Yes, External
[84010.597004] CPU: 238 PID: 279973 Comm: bash Tainted: G           OE      4.12.14-197.29-default #1 SLE15-SP1
[84010.597006] task: c000000a104c0000 task.stack: c000000b52188000
[84010.597007] NIP: d00000001ffd7f78 LR: d00000001ffd7f6c CTR: c0000000001676c0
[84010.597008] REGS: c000000b5218b910 TRAP: 0700   Tainted: G           OE       (4.12.14-197.29-default)
[84010.597008] MSR: 900000010282b033 <SF,HV,VEC,VSX,EE,FP,ME,IR,DR,RI,LE,TM[E]>
[84010.597015]   CR: 48242424  XER: 00000000
[84010.597016] CFAR: d00000001ff45d08 SOFTE: 1
               GPR00: d00000001ffd7f6c c000000b5218bb90 d00000002001b228 0000000000000102
               GPR04: 0000000000000001 0000000000000001 00013d91ed0a5e2d 0000000000000000
               GPR08: c000000007793300 0000000000000000 0000000000000000 c000000a086e7818
               GPR12: 0000000000002200 c000000007793300 0000000000000000 000000012bc937c0
               GPR16: 000000012bbf7ed0 0000000000000000 000000012bc3dd10 0000000000000000
               GPR20: 000000012bc4db28 0000010036442810 000000012bc97828 000000012bc96c70
               GPR24: 00000100365b1550 0000000000000000 00000100363f3d80 c000000be20d3080
               GPR28: c000000bda7eae00 c000000be20db7e8 c000000be20d3778 c000000be20db7e8
[84010.597042] NIP [d00000001ffd7f78] qlt_enable_vha+0x1d0/0x260 [qla2xxx]
[84010.597051] LR [d00000001ffd7f6c] qlt_enable_vha+0x1c4/0x260 [qla2xxx]
[84010.597051] Call Trace:
[84010.597061] [c000000b5218bb90] [d00000001ffd7f6c] qlt_enable_vha+0x1c4/0x260 [qla2xxx] (unreliable)
[84010.597064] [c000000b5218bc20] [d000000009820b6c] tcm_qla2xxx_tpg_enable_store+0xc4/0x130 [tcm_qla2xxx]
[84010.597067] [c000000b5218bcb0] [d0000000185d0e68] configfs_write_file+0xd0/0x190 [configfs]
[84010.597072] [c000000b5218bd00] [c0000000003d0edc] __vfs_write+0x3c/0x1e0
[84010.597074] [c000000b5218bd90] [c0000000003d2ea8] vfs_write+0xd8/0x220
[84010.597076] [c000000b5218bde0] [c0000000003d4ddc] SyS_write+0x6c/0x110
[84010.597079] [c000000b5218be30] [c00000000000b188] system_call+0x3c/0x130
[84010.597080] Instruction dump:
[84010.597082] 7d0050a8 7d084b78 7d0051ad 40c2fff4 7fa3eb78 4bf73965 60000000 7fa3eb78
[84010.597086] 4bf6dcd9 60000000 2fa30000 419eff40 <0fe000004bffff38 e95f0058 a12a0180
[84010.597090] ---[ end trace e32abaf6e6fee826 ]---

To reproduce:

echo 0x7fffffff > /sys/module/qla2xxx/parameters/logging
modprobe target_core_mod
modprobe tcm_qla2xxx
mkdir /sys/kernel/config/target/qla2xxx
mkdir /sys/kernel/config/target/qla2xxx/<port-name>
mkdir /sys/kernel/config/target/qla2xxx/<port-name>/tpgt_1
echo 1 > /sys/kernel/config/target/qla2xxx/<port-name>/tpgt_1/enable
echo 0 > /sys/kernel/config/target/qla2xxx/<port-name>/tpgt_1/enable
echo 1 > /sys/kernel/config/target/qla2xxx/<port-name>/tpgt_1/enable

SYSTEM START
kernel: pid 327:drivers/scsi/qla2xxx/qla_init.c:2174 qla2x00_initialize_adapter(): vha->flags.online 0x0
<...>
kernel: pid 327:drivers/scsi/qla2xxx/qla_os.c:3444 qla2x00_probe_one(): vha->flags.online 0x1

echo 1 > /sys/kernel/config/target/qla2xxx/21:00:00:24:ff:86:a6:2a/tpgt_1/enable
kernel: pid 348:drivers/scsi/qla2xxx/qla_init.c:6641 qla2x00_abort_isp_cleanup(): vha->flags.online 0x0, ISP_ABORT_NEEDED 0x0
<...>
kernel: pid 348:drivers/scsi/qla2xxx/qla_init.c:6998 qla2x00_restart_isp(): vha->flags.online 0x0

echo 0 > /sys/kernel/config/target/qla2xxx/21:00:00:24:ff:86:a6:2a/tpgt_1/enable
kernel: pid 348:drivers/scsi/qla2xxx/qla_init.c:6641 qla2x00_abort_isp_cleanup(): vha->flags.online 0x0, ISP_ABORT_NEEDED 0x0
<...>
kernel: pid 1404:drivers/scsi/qla2xxx/qla_os.c:1107 qla2x00_wait_for_hba_online(): base_vha->flags.online 0x0

echo 1 > /sys/kernel/config/target/qla2xxx/21:00:00:24:ff:86:a6:2a/tpgt_1/enable
kernel: pid 1404:drivers/scsi/qla2xxx/qla_os.c:1107 qla2x00_wait_for_hba_online(): base_vha->flags.online 0x0
kernel: -----------[ cut here ]-----------
kernel: WARNING: CPU: 1 PID: 1404 at drivers/scsi/qla2xxx/qla_target.c:6654 qlt_enable_vha+0x1e0/0x280 [qla2xxx]

The issue happens because no real ISP reset is executed.  The
qla2x00_abort_isp(scsi_qla_host_t *vha) function expects that
vha->flags.online will be not zero for ISP reset procedure.  This patch
sets vha->flags.online to 1 before calling ->abort_isp() for starting the
ISP reset.

Link: https://lore.kernel.org/r/1d7b21bf9f7676643239eb3d60eaca7cfa505cf0.camel@yadro.com
Reviewed-by: Roman Bolshakov <r.bolshakov@yadro.com>
Signed-off-by: Viacheslav Dubeyko <v.dubeiko@yadro.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: core: Remove 'list' entry from struct scsi_cmnd
Hannes Reinecke [Thu, 7 May 2020 06:26:42 +0000 (08:26 +0200)]
scsi: core: Remove 'list' entry from struct scsi_cmnd

Leftover from cmd_list removal.

Link: https://lore.kernel.org/r/20200507062642.100612-1-hare@suse.de
Fixes: c5a9707672fe ("scsi: core: Remove cmd_list functionality")
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>
4 years agoscsi: scsi_debug: Disallow zone sizes that are not powers of 2
Damien Le Moal [Thu, 7 May 2020 02:35:26 +0000 (11:35 +0900)]
scsi: scsi_debug: Disallow zone sizes that are not powers of 2

Allowing a non-power-of-2 zone size forces the use of direct division
operations of 64-bit sector values to obtain a zone number or number of
zones. Doing so without using do_div() leads to compilation errors on
32-bit architectures.

Devices with a zone size that is not a power of 2 do not exist today so
allowing their emulation is of limited interest as the sd driver will not
support them anyway. To fix this compilation error, instead of using
do_div() for sector values divisions, simply disallow zone size values that
are not a power of 2.

[mkp: commit desc]

Link: https://lore.kernel.org/r/20200507023526.221574-1-damien.lemoal@wdc.com
Fixes: 98e0a689868c ("scsi: scsi_debug: Add zone_size_mb module parameter")
Fixes: f0d1cf9378bd ("scsi: scsi_debug: Add ZBC zone commands")
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: scsi_debug: Implement ZBC host-aware emulation
Damien Le Moal [Wed, 22 Apr 2020 10:42:21 +0000 (19:42 +0900)]
scsi: scsi_debug: Implement ZBC host-aware emulation

Implement ZBC host-aware device model emulation. The main changes from the
host-managed emulation are the device type (TYPE_DISK is used), relaxation
of access checks for read and write operations and different handling of a
sequential write preferred zone write pointer as mandated by the ZBC r05
specifications.

To facilitate the implementation and avoid a lot of "if" statement, the
zmodel field is added to the device information and the z_type field to the
zone state data structure.

Link: https://lore.kernel.org/r/20200422104221.378203-8-damien.lemoal@wdc.com
Tested-by: Douglas Gilbert <dgilbert@interlog.com>
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: scsi_debug: Add zone_size_mb module parameter
Damien Le Moal [Wed, 22 Apr 2020 10:42:20 +0000 (19:42 +0900)]
scsi: scsi_debug: Add zone_size_mb module parameter

Add the zone_size_mb module parameters to control the zone size of a ZBC
device. If the zone size specified is not a divisor of the device capacity,
the last zone of the device will be created as a smaller "runt" zone. This
parameter is ignored for device types other than 0x14 (zbc=2 case).

Note: for testing purposes, zone sizes that are not a power of 2 are
accepted but will result in the drive being rejected by the sd driver.

Link: https://lore.kernel.org/r/20200422104221.378203-7-damien.lemoal@wdc.com
Signed-off-by: Douglas Gilbert <dgilbert@interlog.com>
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: scsi_debug: Add zone_nr_conv module parameter
Damien Le Moal [Wed, 22 Apr 2020 10:42:19 +0000 (19:42 +0900)]
scsi: scsi_debug: Add zone_nr_conv module parameter

Allow controlling the number of conventional zones of a ZBC device with the
new zone_nr_conv module parameter. The default value is 1 and the specified
value must be less than the total number of zones of the device. This
parameter is ignored for device types other than 0x14 (zbc=2 case).

Link: https://lore.kernel.org/r/20200422104221.378203-6-damien.lemoal@wdc.com
Signed-off-by: Douglas Gilbert <dgilbert@interlog.com>
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: scsi_debug: Add zone_max_open module parameter
Damien Le Moal [Wed, 22 Apr 2020 10:42:18 +0000 (19:42 +0900)]
scsi: scsi_debug: Add zone_max_open module parameter

Add the zone_max_open module parameters to control the maximum number of
open zones of a ZBC device. This parameter is ignored for device types
other than 0x14 (zbc=2 case).

Link: https://lore.kernel.org/r/20200422104221.378203-5-damien.lemoal@wdc.com
Signed-off-by: Douglas Gilbert <dgilbert@interlog.com>
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: scsi_debug: Add ZBC module parameter
Douglas Gilbert [Wed, 22 Apr 2020 10:42:17 +0000 (19:42 +0900)]
scsi: scsi_debug: Add ZBC module parameter

Add the zbc module parameter to take either:
    0: none         (probably a conventional disk)
    1: host-aware
    2: host-managed

These values are chosen to match 'enum blk_zoned_model' found in
include/linux/blkdev.h . Instead of "none", "no" or "0" can be given.
Instead of "host-aware", "aware or "1" can be given. Instead of
"host-managed", "managed" or "2" can be given.

Note: the zbc parameter can only be given at driver/module load time; it
cannot be changed via sysfs thereafter.

At this time there is no ZBC "host-aware" implementation so that string (or
the value '1') results in a modprobe error.

Link: https://lore.kernel.org/r/20200422104221.378203-4-damien.lemoal@wdc.com
Signed-off-by: Douglas Gilbert <dgilbert@interlog.com>
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: scsi_debug: Add ZBC zone commands
Douglas Gilbert [Wed, 22 Apr 2020 10:42:16 +0000 (19:42 +0900)]
scsi: scsi_debug: Add ZBC zone commands

Add support for the 5 ZBC commands and enough functionality to emulate a
host-managed device with one conventional zone and a set of sequential
write-required zones up to the disk capacity.

Link: https://lore.kernel.org/r/20200422104221.378203-3-damien.lemoal@wdc.com
Signed-off-by: Douglas Gilbert <dgilbert@interlog.com>
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: scsi_debug: Add ZBC mode and VPD pages
Douglas Gilbert [Wed, 22 Apr 2020 10:42:15 +0000 (19:42 +0900)]
scsi: scsi_debug: Add ZBC mode and VPD pages

The ZBC standard "piggy-backs" on many, but not all, of the facilities in
SBC. Add those ZBC mode pages (plus mode parameter block descriptors
(e.g. "WP")) and VPD pages in common with SBC. Add ZBC specific VPD page
for the host-managed ZBC device type (ptype=0x14).

Link: https://lore.kernel.org/r/20200422104221.378203-2-damien.lemoal@wdc.com
Signed-off-by: Douglas Gilbert <dgilbert@interlog.com>
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: scsi_debug: Bump to version 1.89
Douglas Gilbert [Tue, 21 Apr 2020 15:14:24 +0000 (11:14 -0400)]
scsi: scsi_debug: Bump to version 1.89

The scsi_debug driver version is visible in:

   /sys/modules/scsi_debug/version

and can thus be used by user space programs to alter the features they try
to use. Since the per_host_store and zbc/zone options are significant
additions, bump the version number to 1.89 .

Link: https://lore.kernel.org/r/20200421151424.32668-9-dgilbert@interlog.com
Signed-off-by: Douglas Gilbert <dgilbert@interlog.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: scsi_debug: Re-arrange parameters alphabetically
Douglas Gilbert [Tue, 21 Apr 2020 15:14:23 +0000 (11:14 -0400)]
scsi: scsi_debug: Re-arrange parameters alphabetically

This module has a lot of parameters and when searching for one, the author
prefers them in alphabetical order. This can lead to somewhat illogical
ordering (e.g. inq_product before inq_vendor). However it is not clear what
another sensible total logical ordering would be.

Link: https://lore.kernel.org/r/20200421151424.32668-8-dgilbert@interlog.com
Signed-off-by: Douglas Gilbert <dgilbert@interlog.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: scsi_debug: Implement PRE-FETCH commands
Douglas Gilbert [Tue, 21 Apr 2020 15:14:22 +0000 (11:14 -0400)]
scsi: scsi_debug: Implement PRE-FETCH commands

Many disks implement the SCSI PRE-FETCH commands. One use case might be a
disk-to-disk compare, say between disks A and B. Then this sequence of
commands might be used: PRE-FETCH(from B, IMMED), READ(from A), VERIFY
(BYTCHK=1 on B with data returned from READ).  The PRE-FETCH (which returns
quickly due to the IMMED) fetches the data from the media into B's cache
which should speed the trailing VERIFY command. The next chunk of the
compare might be done in parallel, with A and B reversed.

The implementation tries to bring the specified range in main memory into
the cache(s) associated with this machine's CPU(s) using the
prefetch_range() function.

Link: https://lore.kernel.org/r/20200421151424.32668-7-dgilbert@interlog.com
Signed-off-by: Douglas Gilbert <dgilbert@interlog.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: scsi_debug: Improve command duration calculation
Douglas Gilbert [Tue, 21 Apr 2020 15:14:21 +0000 (11:14 -0400)]
scsi: scsi_debug: Improve command duration calculation

Previously the code did the work implied by the given SCSI command and
after that it waited for a timer based on the user specified command
duration to be exhausted before informing the mid-level that the command
was complete. For short command durations, the time to complete the work
implied by the SCSI command could be significant compared to the user
specified command duration.

For example a WRITE of 128 blocks (say 512 bytes each) on a machine that
can copy from main memory to main memory at a rate of 10 GB/sec will take
around 6.4 microseconds to do that copy.  If the user specified a command
duration of 5 microseconds (ndelay=5000), should the driver do a further
delay of 5 microseconds after the copy or return immediately because 6.4 >
5 ?

The action prior to this patch was to always do the timer based
delay. After this patch, for ndelay values less than 1 millisecond, this
driver will complete the command immediately.  And in the case where the
user specified delay was 7 microseconds, a timer delay of 600 nanoseconds
will be set ((7 - 6.4) * 1000).

Link: https://lore.kernel.org/r/20200421151424.32668-6-dgilbert@interlog.com
Signed-off-by: Douglas Gilbert <dgilbert@interlog.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: scsi_debug: Weaken rwlock around ramdisk access
Douglas Gilbert [Tue, 21 Apr 2020 15:14:20 +0000 (11:14 -0400)]
scsi: scsi_debug: Weaken rwlock around ramdisk access

The design of this driver is to do any ramdisk access on the same thread
that invoked the queuecommand() call. That is assumed to be user space
context. The command duration is implemented by setting the delay with a
high resolution timer. The hr timer's callback may well be in interrupt
context, but it doesn't touch the ramdisk. So try removing the
_irqsave()/_irqrestore() portion on the read-write lock that protects
ramdisk access.

Link: https://lore.kernel.org/r/20200421151424.32668-5-dgilbert@interlog.com
Signed-off-by: Douglas Gilbert <dgilbert@interlog.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: scsi_debug: Implement VERIFY(10), add VERIFY(16)
Douglas Gilbert [Tue, 21 Apr 2020 15:14:19 +0000 (11:14 -0400)]
scsi: scsi_debug: Implement VERIFY(10), add VERIFY(16)

With the addition of the per_host_store option, the ability to check
whether two different ramdisk images are the same or not becomes
practical. Prior to this patch VERIFY(10) always returned true (i.e.  the
SCSI GOOD status) without checking. This option adds support for BYTCHK
equal to 0, 1 and 3. If the comparison fails, then a sense key of
MISCOMPARE is returned as per the T10 standards. Also add support for the
VERIFY(16) command.

Link: https://lore.kernel.org/r/20200421151424.32668-4-dgilbert@interlog.com
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Douglas Gilbert <dgilbert@interlog.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: scsi_debug: Add per_host_store option
Douglas Gilbert [Tue, 21 Apr 2020 15:14:18 +0000 (11:14 -0400)]
scsi: scsi_debug: Add per_host_store option

The scsi_debug driver has always been restricted to using one ramdisk image
(or none) for its storage. This means that thousands of scsi_debug devices
can be created without exhausting the host machine's RAM. The downside is
that all scsi_debug devices share the same ramdisk image. This option
changes the way a following write to the add_host parameter (or an add_host
in the module/driver invocation) operates.  For each new host that is
created while per_host_store is true, a new store (of dev-size_mb MiB) is
created and associated with all the LUs that belong to that new host. The
user (who will need root permissions) needs to take care not to exhaust all
the machine's available RAM.

One reason for doing this is to check that (partial) disk to disk copies
based on scsi_debug devices have actually copied accurately. To test this
the add_host=<n> parameter where <n> is 2 or greater can be used when the
scsi_debug module is loaded. Let us assume that /dev/sdb and /dev/sg1 are
the same scsi_debug device, while /dev/sdc and /dev/sg2 are the same
scsi_debug device. With per_host_store=1 add_host=2 they will have
different ramdisk images. Then the following pseudocode could be executed
to check if the sgh_dd copy worked:

    dd if=/dev/urandom of=/dev/sdb
    sgh_dd if=/dev/sg1 of=/dev/sg2 [plus option(s) to test]
    cmp /dev/sdb /dev/sdc

If the cmp fails then the copy has failed (or some other mechanism wrote to
/dev/sdb or /dev/sdc in the interim).

[mkp: use kstrtobool()]

Link: https://lore.kernel.org/r/20200421151424.32668-3-dgilbert@interlog.com
Signed-off-by: Douglas Gilbert <dgilbert@interlog.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: scsi_debug: Randomize command completion time
Douglas Gilbert [Tue, 21 Apr 2020 15:14:17 +0000 (11:14 -0400)]
scsi: scsi_debug: Randomize command completion time

Add a new command line option (e.g. random=1) and sysfs attribute that
causes subsequent command completion times to be between the current
command delay setting and 0. A uniformly distributed 32 bit, kernel
provided integer is used for this purpose.

Since the existing 'delay' whose units are jiffies (typically milliseconds)
and 'ndelay' (units: nanoseconds) options (and sysfs attributes) span a
range greater than 32 bits, some scaling is required.

The purpose of this patch is to widen the range of testing cases that are
visited in long running tests. Put simply: rarely struct race conditions
are more likely to be found when this facility is used.

The default is the previous case in which all command completions were
roughly equal to (if not, slightly longer) than the value given by the
'delay' or 'ndelay' settings (or their defaults).  This option's default is
equivalent to setting 'random=0' .

[mkp: use kstrtobool()]

Link: https://lore.kernel.org/r/20200421151424.32668-2-dgilbert@interlog.com
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Douglas Gilbert <dgilbert@interlog.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: dpt_i2o: Remove always false 'chan < 0' statement
Xiongfeng Wang [Wed, 29 Apr 2020 12:10:18 +0000 (20:10 +0800)]
scsi: dpt_i2o: Remove always false 'chan < 0' statement

The channel index is represented by an unsigned variable 'u32 chan'. We
don't need to check whether it is less than zero, the 'chan < 0' statement
is always false. Remove it.

Link: https://lore.kernel.org/r/1588162218-61757-1-git-send-email-wangxiongfeng2@huawei.com
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Xiongfeng Wang <wangxiongfeng2@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qedi: Check for buffer overflow in qedi_set_path()
Dan Carpenter [Tue, 28 Apr 2020 13:19:39 +0000 (16:19 +0300)]
scsi: qedi: Check for buffer overflow in qedi_set_path()

Smatch complains that the "path_data->handle" variable is user controlled.
It comes from iscsi_set_path() so that seems possible.  It's harmless to
add a limit check.

The qedi->ep_tbl[] array has qedi->max_active_conns elements (which is
always ISCSI_MAX_SESS_PER_HBA (4096) elements).  The array is allocated in
the qedi_cm_alloc_mem() function.

Link: https://lore.kernel.org/r/20200428131939.GA696531@mwanda
Fixes: ace7f46ba5fd ("scsi: qedi: Add QLogic FastLinQ offload iSCSI driver framework.")
Acked-by: Manish Rangankar <mrangankar@marvell.com>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qla2xxx: make 1-bit bit-fields unsigned int
Colin Ian King [Tue, 28 Apr 2020 10:20:13 +0000 (11:20 +0100)]
scsi: qla2xxx: make 1-bit bit-fields unsigned int

The bitfields mpi_fw_dump_reading and mpi_fw_dumped are currently signed
which is not recommended as the representation is an implementation defined
behaviour.  Fix this by making the bit-fields unsigned ints.

Link: https://lore.kernel.org/r/20200428102013.1040598-1-colin.king@canonical.com
Fixes: cbb01c2f2f63 ("scsi: qla2xxx: Fix MPI failure AEN (8200) handling")
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: core: free sgtables in case command setup fails
Johannes Thumshirn [Tue, 28 Apr 2020 10:45:55 +0000 (19:45 +0900)]
scsi: core: free sgtables in case command setup fails

In case scsi_setup_fs_cmnd() fails we're not freeing the sgtables allocated
by scsi_init_io(), thus we leak the allocated memory.

Free the sgtables allocated by scsi_init_io() in case scsi_setup_fs_cmnd()
fails.

Technically scsi_setup_scsi_cmnd() does not suffer from this problem as it
can only fail if scsi_init_io() fails, so it does not have sgtables
allocated. But to maintain symmetry and as a measure of defensive
programming, free the sgtables on scsi_setup_scsi_cmnd() failure as well.
scsi_mq_free_sgtables() has safeguards against double-freeing of memory so
this is safe to do.

While we're at it, rename scsi_mq_free_sgtables() to scsi_free_sgtables().

Link: https://bugzilla.kernel.org/show_bug.cgi?id=205595
Link: https://lore.kernel.org/r/20200428104605.8143-2-johannes.thumshirn@wdc.com
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Daniel Wagner <dwagner@suse.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: core: doc: Change function comments to kernel-doc style
André Almeida [Sun, 19 Apr 2020 05:01:48 +0000 (02:01 -0300)]
scsi: core: doc: Change function comments to kernel-doc style

Despite of functions being documented, they are not in the kernel-doc
specification, and could not be included in kernel documentation. Change
the style of functions comments to be compliant to the kernel-doc style.
When the function comments are outdated, update then.

[mkp: a few edits]

Link: https://lore.kernel.org/r/20200419050148.33371-1-andrealmeid@collabora.com
Signed-off-by: André Almeida <andrealmeid@collabora.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: ufs-qcom: Configure write booster type
Asutosh Das [Wed, 22 Apr 2020 21:41:44 +0000 (14:41 -0700)]
scsi: ufs-qcom: Configure write booster type

Enable WriteBooster for Qualcomm platform.

Link: https://lore.kernel.org/r/cd4cf745ea0b3a59c2075036e17316b97494fe65.1587591527.git.asutoshd@codeaurora.org
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Signed-off-by: Asutosh Das <asutoshd@codeaurora.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: ufs: sysfs: Add sysfs entries for write booster
Asutosh Das [Wed, 22 Apr 2020 21:41:43 +0000 (14:41 -0700)]
scsi: ufs: sysfs: Add sysfs entries for write booster

Adds unit, device, geometry descriptor sysfs entries.  Adds flags sysfs
entries for write booster.

Link: https://lore.kernel.org/r/98987ef17844292bd42c57613990a3a26c6de2b8.1587591527.git.asutoshd@codeaurora.org
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Signed-off-by: Asutosh Das <asutoshd@codeaurora.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: ufs: Add write booster feature support
Asutosh Das [Wed, 22 Apr 2020 21:41:42 +0000 (14:41 -0700)]
scsi: ufs: Add write booster feature support

The write performance of TLC NAND is considerably lower than SLC NAND.
Using SLC NAND as a WriteBooster Buffer enables the write request to be
processed with lower latency and improves the overall write performance.

Adds support for shared-buffer mode WriteBooster.

WriteBooster enable: SW enables it when clocks are scaled up, thus it's
enabled only in high load conditions.

WriteBooster disable: SW will disable the feature, when clocks are scaled
down. Thus writes would go as normal writes.

To keep the endurance of the WriteBooster Buffer at a maximum, this
load-based toggling is adopted.

Link: https://lore.kernel.org/r/2871444d9083b0e9323ef6d8ff1b544b7784adc9.1587591527.git.asutoshd@codeaurora.org
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Signed-off-by: Asutosh Das <asutoshd@codeaurora.org>
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: ufs: Use true for bool variables in ufshcd_complete_dev_init()
Jason Yan [Sun, 26 Apr 2020 09:43:05 +0000 (17:43 +0800)]
scsi: ufs: Use true for bool variables in ufshcd_complete_dev_init()

Fix the following coccicheck warning:

drivers/scsi/ufs/ufshcd.c:4140:6-14: WARNING: Assignment of 0/1 to bool
variable.

Link: https://lore.kernel.org/r/20200426094305.24083-1-yanaijie@huawei.com
Signed-off-by: Jason Yan <yanaijie@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: sr: Use {get,put}_unaligned_be*() instead of open-coding these functions
Bart Van Assche [Mon, 27 Apr 2020 01:48:44 +0000 (18:48 -0700)]
scsi: sr: Use {get,put}_unaligned_be*() instead of open-coding these functions

This patch makes the sr code slightly easier to read.

Link: https://lore.kernel.org/r/20200427014844.12109-1-bvanassche@acm.org
Cc: Merlijn Wajer <merlijn@archive.org>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: aacraid: Fix error handling paths in aac_probe_one()
Christophe JAILLET [Sun, 12 Apr 2020 09:40:39 +0000 (11:40 +0200)]
scsi: aacraid: Fix error handling paths in aac_probe_one()

If 'scsi_host_alloc()' or 'kcalloc()' fail, 'error' is known to be 0. Set
it explicitly to -ENOMEM before branching to the error handling path.

While at it, remove 2 useless assignments to 'error'. These values are
overwridden a few lines later.

Link: https://lore.kernel.org/r/20200412094039.8822-1-christophe.jaillet@wanadoo.fr
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: sgiwd93: Remove unneeded semicolon in sgiwd93.c
Jason Yan [Tue, 21 Apr 2020 03:40:29 +0000 (11:40 +0800)]
scsi: sgiwd93: Remove unneeded semicolon in sgiwd93.c

Fix the following coccicheck warning:

drivers/scsi/sgiwd93.c:190:2-3: Unneeded semicolon

Link: https://lore.kernel.org/r/20200421034029.28030-1-yanaijie@huawei.com
Signed-off-by: Jason Yan <yanaijie@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qla4xxx: Remove unneeded semicolon in ql4_os.c
Jason Yan [Tue, 21 Apr 2020 03:40:38 +0000 (11:40 +0800)]
scsi: qla4xxx: Remove unneeded semicolon in ql4_os.c

Fix the following coccicheck warning:

drivers/scsi/qla4xxx/ql4_os.c:969:3-4: Unneeded semicolon

Link: https://lore.kernel.org/r/20200421034038.28113-1-yanaijie@huawei.com
Signed-off-by: Jason Yan <yanaijie@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: isci: Use true, false for bool variables
Jason Yan [Tue, 21 Apr 2020 03:40:50 +0000 (11:40 +0800)]
scsi: isci: Use true, false for bool variables

Fix the following coccicheck warning:

drivers/scsi/isci/isci.h:515:1-12: WARNING: Assignment of 0/1 to bool
variable
drivers/scsi/isci/isci.h:503:1-12: WARNING: Assignment of 0/1 to bool
variable
drivers/scsi/isci/isci.h:509:1-12: WARNING: Assignment of 0/1 to bool
variable

Link: https://lore.kernel.org/r/20200421034050.28193-1-yanaijie@huawei.com
Signed-off-by: Jason Yan <yanaijie@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: bnx2fc: Remove unneeded semicolon in bnx2fc_fcoe.c
Jason Yan [Tue, 21 Apr 2020 03:40:19 +0000 (11:40 +0800)]
scsi: bnx2fc: Remove unneeded semicolon in bnx2fc_fcoe.c

Fix the following coccicheck warning:

drivers/scsi/bnx2fc/bnx2fc_fcoe.c:948:4-5: Unneeded semicolon
drivers/scsi/bnx2fc/bnx2fc_fcoe.c:968:4-5: Unneeded semicolon

Link: https://lore.kernel.org/r/20200421034019.27949-1-yanaijie@huawei.com
Signed-off-by: Jason Yan <yanaijie@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: bfa: Remove unneeded semicolon in bfa_fcs_rport.c
Jason Yan [Tue, 21 Apr 2020 03:39:57 +0000 (11:39 +0800)]
scsi: bfa: Remove unneeded semicolon in bfa_fcs_rport.c

Fix the following coccicheck warning:

drivers/scsi/bfa/bfa_fcs_rport.c:2452:2-3: Unneeded semicolon
drivers/scsi/bfa/bfa_fcs_rport.c:1578:3-4: Unneeded semicolon

Link: https://lore.kernel.org/r/20200421033957.27783-1-yanaijie@huawei.com
Signed-off-by: Jason Yan <yanaijie@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: bfa: Remove set but not used variable 'fchs'
YueHaibing [Sat, 18 Apr 2020 07:10:57 +0000 (07:10 +0000)]
scsi: bfa: Remove set but not used variable 'fchs'

Fixes gcc '-Wunused-but-set-variable' warning:

drivers/scsi/bfa/bfa_svc.c: In function 'uf_recv':
drivers/scsi/bfa/bfa_svc.c:5520:17: warning:
 variable 'fchs' set but not used [-Wunused-but-set-variable]
  struct fchs_s *fchs;
                 ^

Link: https://lore.kernel.org/r/20200418071057.96699-1-yuehaibing@huawei.com
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: snic: Make snic_io_exch_ver_cmpl_handler() return void
Jason Yan [Sat, 18 Apr 2020 07:06:15 +0000 (15:06 +0800)]
scsi: snic: Make snic_io_exch_ver_cmpl_handler() return void

This function does not need a return value since no callers depend on
it. Make it return void.

This also fixes the coccicheck warning:

drivers/scsi/snic/snic_ctl.c:163:5-8: Unneeded variable: "ret". Return
"0" on line 228

Link: https://lore.kernel.org/r/20200418070615.11603-1-yanaijie@huawei.com
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Jason Yan <yanaijie@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: mpt3sas: Remove NULL check before freeing function
Jason Yan [Sat, 18 Apr 2020 09:58:50 +0000 (17:58 +0800)]
scsi: mpt3sas: Remove NULL check before freeing function

Fix the following coccicheck warning:

drivers/scsi/mpt3sas/mpt3sas_base.c:4906:3-19: WARNING: NULL check
before some freeing functions is not needed.

Link: https://lore.kernel.org/r/20200418095850.34883-1-yanaijie@huawei.com
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Jason Yan <yanaijie@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: ipr: Remove NULL check before freeing function
Jason Yan [Sat, 18 Apr 2020 09:59:03 +0000 (17:59 +0800)]
scsi: ipr: Remove NULL check before freeing function

Fix the following coccicheck warning:

drivers/scsi/ipr.c:9533:2-18: WARNING: NULL check before some freeing
functions is not needed.

Link: https://lore.kernel.org/r/20200418095903.35118-1-yanaijie@huawei.com
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Jason Yan <yanaijie@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: bfa: Remove unneeded semicolon in bfa_fcs_lport_ns_sm_online()
Jason Yan [Sat, 18 Apr 2020 07:05:53 +0000 (15:05 +0800)]
scsi: bfa: Remove unneeded semicolon in bfa_fcs_lport_ns_sm_online()

Fix the following coccicheck warning:

drivers/scsi/bfa/bfa_fcs_lport.c:4361:3-4: Unneeded semicolon

Link: https://lore.kernel.org/r/20200418070553.11262-1-yanaijie@huawei.com
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Jason Yan <yanaijie@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: pmcraid: Replace dma_pool_malloc with dma_pool_zalloc
Wu Bo [Sat, 18 Apr 2020 08:07:21 +0000 (16:07 +0800)]
scsi: pmcraid: Replace dma_pool_malloc with dma_pool_zalloc

Replace dma_pool_malloc with dma_pool_zalloc to make the code more concise
in pmcraid_allocate_control_blocks() function.

Link: https://lore.kernel.org/r/1587197241-274646-1-git-send-email-wubo40@huawei.com
Signed-off-by: Wu Bo <wubo40@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: target: iscsi: Remove the iscsi_data_count structure
Maurizio Lombardi [Fri, 24 Apr 2020 11:39:13 +0000 (13:39 +0200)]
scsi: target: iscsi: Remove the iscsi_data_count structure

This patch removes the iscsi_data_count structure and the
iscsit_do_rx_data() function because they are used only by rx_data()

Link: https://lore.kernel.org/r/20200424113913.17237-1-mlombard@redhat.com
Reviewed-by: Mike Christie <mchristi@redhat.com>
Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: core: Avoid calling synchronize_rcu() for each device in scsi_host_block()
Ming Lei [Thu, 23 Apr 2020 02:07:13 +0000 (10:07 +0800)]
scsi: core: Avoid calling synchronize_rcu() for each device in scsi_host_block()

scsi_host_block() calls scsi_internal_device_block() for each scsi_device and
scsi_internal_device_block() calls blk_mq_quiesce_queue() for each LUN.

Since synchronize_rcu() is called from blk_mq_quiesce_queue(), this can cause
substantial slowdowns on systems with many LUNs.

Use scsi_internal_device_block_nowait() to implement scsi_host_block() so it
is sufficient to run synchronize_rcu() once. This is safe since SCSI does not
set the BLK_MQ_F_BLOCKING flag.

[mkp: commit desc and comment tweaks]

Link: https://lore.kernel.org/r/20200423020713.332743-1-ming.lei@redhat.com
Cc: Steffen Maier <maier@linux.ibm.com>
Cc: Bart Van Assche <bvanassche@acm.org>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Dexuan Cui <decui@microsoft.com>
Cc: Hannes Reinecke <hare@suse.de>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: BusLogic: Remove conversion to bool in blogic_inquiry()
Jason Yan [Tue, 21 Apr 2020 03:41:20 +0000 (11:41 +0800)]
scsi: BusLogic: Remove conversion to bool in blogic_inquiry()

The '!=' expression itself is bool, no need to convert it to bool again.
This fixes the following coccicheck warning:

drivers/scsi/BusLogic.c:2240:46-51: WARNING: conversion to bool not
needed here

Link: https://lore.kernel.org/r/20200421034120.28433-1-yanaijie@huawei.com
Acked-by: Khalid Aziz <khalid@gonehiking.org>
Signed-off-by: Jason Yan <yanaijie@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: megaraid: Use true, false for bool variables
Jason Yan [Tue, 21 Apr 2020 03:41:11 +0000 (11:41 +0800)]
scsi: megaraid: Use true, false for bool variables

Fix the following coccicheck warning:

drivers/scsi/megaraid/megaraid_sas_fusion.c:4242:6-16: WARNING:
Assignment of 0/1 to bool variable
drivers/scsi/megaraid/megaraid_sas_fusion.c:4786:1-29: WARNING:
Assignment of 0/1 to bool variable
drivers/scsi/megaraid/megaraid_sas_fusion.c:4791:1-29: WARNING:
Assignment of 0/1 to bool variable
drivers/scsi/megaraid/megaraid_sas_fusion.c:4716:1-29: WARNING:
Assignment of 0/1 to bool variable
drivers/scsi/megaraid/megaraid_sas_fusion.c:4721:1-29: WARNING:
Assignment of 0/1 to bool variable

Link: https://lore.kernel.org/r/20200421034111.28353-1-yanaijie@huawei.com
Acked-by: Chandrakanth Patil <chandrakanth.patil@broadcom.com>
Signed-off-by: Jason Yan <yanaijie@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: mpt3sas: Update mpt3sas version to 33.101.00.00
Suganath Prabu [Thu, 23 Apr 2020 07:23:16 +0000 (03:23 -0400)]
scsi: mpt3sas: Update mpt3sas version to 33.101.00.00

Update mpt3sas driver version from 33.100.00.00 to 33.101.00.00.

Link: https://lore.kernel.org/r/1587626596-1044-6-git-send-email-suganath-prabu.subramani@broadcom.com
Signed-off-by: Suganath Prabu <suganath-prabu.subramani@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: mpt3sas: Handle RDPQ DMA allocation in same 4G region
Suganath Prabu [Thu, 23 Apr 2020 07:23:15 +0000 (03:23 -0400)]
scsi: mpt3sas: Handle RDPQ DMA allocation in same 4G region

For INVADER_SERIES, each set of 8 reply queues (0 - 7, 8 - 15,..), and for
VENTURA_SERIES, each set of 16 reply queues (0 - 15, 16 - 31,..) need to be
within the same 4 GB boundary. Driver uses limitation of VENTURA_SERIES to
manage INVADER_SERIES as well. The driver is allocating the DMA able
memory for RDPQs accordingly.

1) At driver load, set DMA mask to 64 and allocate memory for RDPQs

2) Check if allocated resources for RDPQ are in the same 4GB range

3) If #2 is true, continue with 64 bit DMA and go to #6

4) If #2 is false, then free all the resources from #1

5) Set DMA mask to 32 and allocate RDPQs

6) Proceed with driver loading and other allocations

Link: https://lore.kernel.org/r/1587626596-1044-5-git-send-email-suganath-prabu.subramani@broadcom.com
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Suganath Prabu <suganath-prabu.subramani@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: mpt3sas: Separate out RDPQ allocation to new function
Suganath Prabu [Thu, 23 Apr 2020 07:23:14 +0000 (03:23 -0400)]
scsi: mpt3sas: Separate out RDPQ allocation to new function

For readability separate out RDPQ allocations to new function
base_alloc_rdpq_dma_pool().

Link: https://lore.kernel.org/r/1587626596-1044-4-git-send-email-suganath-prabu.subramani@broadcom.com
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Suganath Prabu <suganath-prabu.subramani@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: mpt3sas: Rename function name is_MSB_are_same
Suganath Prabu [Thu, 23 Apr 2020 07:23:13 +0000 (03:23 -0400)]
scsi: mpt3sas: Rename function name is_MSB_are_same

Rename is_MSB_are_same() to mpt3sas_check_same_4gb_region() for better
readability.

Link: https://lore.kernel.org/r/1587626596-1044-3-git-send-email-suganath-prabu.subramani@broadcom.com
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Suganath Prabu <suganath-prabu.subramani@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: mpt3sas: Don't change the DMA coherent mask after allocations
Christoph Hellwig [Thu, 23 Apr 2020 07:23:12 +0000 (03:23 -0400)]
scsi: mpt3sas: Don't change the DMA coherent mask after allocations

The DMA layer does not allow changing the DMA coherent mask after there are
outstanding allocations.

Link: https://lore.kernel.org/r/1587626596-1044-2-git-send-email-suganath-prabu.subramani@broadcom.com
Reported-by: Abdul Haleem <abdhalee@linux.vnet.ibm.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Suganath Prabu <suganath-prabu.subramani@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: bnx2fc: Add missing annotation for bnx2fc_abts_cleanup()
Jules Irenge [Sat, 11 Apr 2020 00:19:31 +0000 (01:19 +0100)]
scsi: bnx2fc: Add missing annotation for bnx2fc_abts_cleanup()

Sparse reports the following warning:

  warning: context imbalance in bnx2fc_abts_cleanup() - unexpected unlock

The root cause is the missing annotation at bnx2fc_abts_cleanup(). Add the
missing __must_hold(&tgt->tgt_lock) annotation.

Link: https://lore.kernel.org/r/20200411001933.10072-8-jbi.octave@gmail.com
Signed-off-by: Jules Irenge <jbi.octave@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: aic7xxx: Remove unnecessary NULL checks before kfree
Alex Dewar [Fri, 3 Apr 2020 16:47:11 +0000 (17:47 +0100)]
scsi: aic7xxx: Remove unnecessary NULL checks before kfree

There are a number of places in the aic7xxx driver where a NULL check is
performed before a kfree(). However, kfree() already performs NULL checks
so this is unnecessary. Remove the checks.

Issue identified with Coccinelle.

Link: https://lore.kernel.org/r/20200403164712.49579-1-alex.dewar@gmx.co.uk
Signed-off-by: Alex Dewar <alex.dewar@gmx.co.uk>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: aic7xxx: Use kzalloc() instead of kmalloc()+memset()
Alex Dewar [Fri, 3 Apr 2020 16:36:10 +0000 (17:36 +0100)]
scsi: aic7xxx: Use kzalloc() instead of kmalloc()+memset()

There are a couple of places where kzalloc() could be used directly instead
of calling kmalloc() then memset(). Replace them.

Link: https://lore.kernel.org/r/20200403163611.46756-1-alex.dewar@gmx.co.uk
Signed-off-by: Alex Dewar <alex.dewar@gmx.co.uk>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: cxgb4i: Remove superfluous null check
Xu Wang [Thu, 2 Apr 2020 11:08:32 +0000 (19:08 +0800)]
scsi: cxgb4i: Remove superfluous null check

In do_abort_rpl_rss, the null check of 'clk' is not needed.

Link: https://lore.kernel.org/r/20200402110832.12712-1-vulab@iscas.ac.cn
Signed-off-by: Xu Wang <vulab@iscas.ac.cn>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qla2xxx: Fix MPI failure AEN (8200) handling
Arun Easi [Tue, 31 Mar 2020 10:40:13 +0000 (03:40 -0700)]
scsi: qla2xxx: Fix MPI failure AEN (8200) handling

Today, upon an MPI failure AEN, on top of collecting an MPI dump, a regular
firmware dump is also taken and then chip reset. This is disruptive to IOs
and not required. Make the firmware dump collection, followed by chip
reset, optional (not done by default).

Firmware dump buffer and MPI dump buffer are independent of each
other with this change and each can have dump that was taken at two
different times for two different issues. The MPI dump is saved in a
separate buffer and is retrieved differently from firmware dump.

To collect full dump on MPI failure AEN, a module parameter is
introduced:
    ql2xfulldump_on_mpifail (default: 0)

Link: https://lore.kernel.org/r/20200331104015.24868-2-njavali@marvell.com
Reported-by: kbuild test robot <lkp@intel.com>
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Arun Easi <aeasi@marvell.com>
Signed-off-by: Nilesh Javali <njavali@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: lpfc: remove duplicate unloading checks
James Smart [Tue, 21 Apr 2020 20:33:54 +0000 (13:33 -0700)]
scsi: lpfc: remove duplicate unloading checks

During code reviews several instances of duplicate module unloading checks
were found.

Remove the duplicate checks.

Link: https://lore.kernel.org/r/20200421203354.49420-1-jsmart2021@gmail.com
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: mpt3sas: use true,false for bool variables
Jason Yan [Tue, 21 Apr 2020 03:41:01 +0000 (11:41 +0800)]
scsi: mpt3sas: use true,false for bool variables

Fix the following coccicheck warning:

drivers/scsi/mpt3sas/mpt3sas_base.c:416:6-14: WARNING: Assignment of 0/1
to bool variable
drivers/scsi/mpt3sas/mpt3sas_base.c:485:2-10: WARNING: Assignment of 0/1
to bool variable

Link: https://lore.kernel.org/r/20200421034101.28273-1-yanaijie@huawei.com
Acked-by: Suganath Prabu <suganath-prabu.subramani@broadcom.com>
Signed-off-by: Jason Yan <yanaijie@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: fcoe: remove unneeded semicolon in fcoe.c
Jason Yan [Tue, 21 Apr 2020 03:40:08 +0000 (11:40 +0800)]
scsi: fcoe: remove unneeded semicolon in fcoe.c

Fix the following coccicheck warning:

drivers/scsi/fcoe/fcoe.c:1918:3-4: Unneeded semicolon
drivers/scsi/fcoe/fcoe.c:1930:3-4: Unneeded semicolon

Link: https://lore.kernel.org/r/20200421034008.27865-1-yanaijie@huawei.com
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Jason Yan <yanaijie@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: ufs-qcom: remove unneeded variable 'ret'
Jason Yan [Sat, 18 Apr 2020 07:06:25 +0000 (15:06 +0800)]
scsi: ufs-qcom: remove unneeded variable 'ret'

Fix the following coccicheck warning:

drivers/scsi/ufs/ufs-qcom.c:575:5-8: Unneeded variable: "ret". Return
"0" on line 590

Link: https://lore.kernel.org/r/20200418070625.11756-1-yanaijie@huawei.com
Reported-by: Hulk Robot <hulkci@huawei.com>
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Jason Yan <yanaijie@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: st: remove unneeded variable 'result' in st_release()
Jason Yan [Sat, 18 Apr 2020 07:06:05 +0000 (15:06 +0800)]
scsi: st: remove unneeded variable 'result' in st_release()

Also remove a strange '^L' after this function.

Fix the following coccicheck warning:

drivers/scsi/st.c:1460:5-11: Unneeded variable: "result". Return "0" on
line 1473

Link: https://lore.kernel.org/r/20200418070605.11450-1-yanaijie@huawei.com
Reported-by: Hulk Robot <hulkci@huawei.com>
Acked-by: Kai Mäkisara <kai.makisara@kolumbus.fi>
Signed-off-by: Jason Yan <yanaijie@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qedf: Get dev info after updating the params
Saurav Kashyap [Thu, 16 Apr 2020 08:43:14 +0000 (01:43 -0700)]
scsi: qedf: Get dev info after updating the params

An update to pf params can change the devinfo. Get updated device
information.

[mkp: updated error message spotted by Sergei Shtylyov]

Link: https://lore.kernel.org/r/20200416084314.18851-10-skashyap@marvell.com
Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qedf: Fix crash when MFW calls for protocol stats while function is still probing
Chad Dupuis [Thu, 16 Apr 2020 08:43:13 +0000 (01:43 -0700)]
scsi: qedf: Fix crash when MFW calls for protocol stats while function is still probing

The MFW may make a call to qed and then to qedf for protocol statistics
while the function is still probing.  If this happens it's possible that
some members of the struct qedf_ctx may not be fully initialized which can
result in a NULL pointer dereference or general protection fault.

To prevent this, add a new flag call QEDF_PROBING and set it when the
__qedf_probe() function is active. Then in the qedf_get_protocol_tlv_data()
function we can check if the function is still probing and return
immediantely before any uninitialized structures can be touched.

Link: https://lore.kernel.org/r/20200416084314.18851-9-skashyap@marvell.com
Signed-off-by: Chad Dupuis <cdupuis@marvell.com>
Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qedf: Add schedule recovery handler
Chad Dupuis [Thu, 16 Apr 2020 08:43:12 +0000 (01:43 -0700)]
scsi: qedf: Add schedule recovery handler

Implement recovery handler to be used by QED to signal the need for
recovery to come out of an error condition like ramrod struck and firmware
context reset.

Link: https://lore.kernel.org/r/20200416084314.18851-8-skashyap@marvell.com
Signed-off-by: Chad Dupuis <cdupuis@marvell.com>
Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qedf: Implement callback for bw_update
Saurav Kashyap [Thu, 16 Apr 2020 08:43:11 +0000 (01:43 -0700)]
scsi: qedf: Implement callback for bw_update

Add support for the common qed bw_update callback to qedf.  This function
is called whenever there is a reported change in the bandwidth and updates
corresponding values in sysfs.

Link: https://lore.kernel.org/r/20200416084314.18851-7-skashyap@marvell.com
Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qed: Send BW update notifications to the protocol drivers
Sudarsana Reddy Kalluru [Thu, 16 Apr 2020 08:43:10 +0000 (01:43 -0700)]
scsi: qed: Send BW update notifications to the protocol drivers

Management firmware (MFW) sends a notification whenever there is a change
in the bandwidth values. Add driver support for sending this notification
to the upper layer drivers (e.g., qedf).

Link: https://lore.kernel.org/r/20200416084314.18851-6-skashyap@marvell.com
Signed-off-by: Sudarsana Reddy Kalluru <skalluru@marvell.com>
Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qedf: Honor status qualifier in FCP_RSP per spec
Javed Hasan [Thu, 16 Apr 2020 08:43:09 +0000 (01:43 -0700)]
scsi: qedf: Honor status qualifier in FCP_RSP per spec

Handle scope and qualifier on SAM_STAT_TASK_SET_FULL or SAM_STAT_BUSY

[mkp: added braces to fix sparse complaint]

Link: https://lore.kernel.org/r/20200416084314.18851-5-skashyap@marvell.com
Signed-off-by: Javed Hasan <jhasan@marvell.com>
Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qedf: Acquire rport_lock for resetting the delay_timestamp
Javed Hasan [Thu, 16 Apr 2020 08:43:08 +0000 (01:43 -0700)]
scsi: qedf: Acquire rport_lock for resetting the delay_timestamp

Retry delay timestamp is updated in queuecommand as well as in
qedf_scsi_completion routine. Protect it using lock.

Link: https://lore.kernel.org/r/20200416084314.18851-4-skashyap@marvell.com
Signed-off-by: Javed Hasan <jhasan@marvell.com>
Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qedf: Increase the upper limit of retry delay
Javed Hasan [Thu, 16 Apr 2020 08:43:07 +0000 (01:43 -0700)]
scsi: qedf: Increase the upper limit of retry delay

Max time to hold the IO in case of SAM_STAT_TASK_SET_FULL or SAM_STAT_BUSY.

Link: https://lore.kernel.org/r/20200416084314.18851-3-skashyap@marvell.com
Signed-off-by: Javed Hasan <jhasan@marvell.com>
Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qedf: Keep track of num of pending flogi
Saurav Kashyap [Thu, 16 Apr 2020 08:43:06 +0000 (01:43 -0700)]
scsi: qedf: Keep track of num of pending flogi

If a port is brought down for an extended period of time, the fipvlan
counter gets exhausted and the driver will fall back to default VLAN 1002
and call fcoe_ctlr_link_up to log in. However, the switch will discard the
FLOGI attempt because the VLAN is now different.

Keep track of the number of FLOGI attempts and if a threshold of
QEDF_FLOGI_RETRY_CNT is exceeded, perform a context soft reset.

Link: https://lore.kernel.org/r/20200416084314.18851-2-skashyap@marvell.com
Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: mvsas: remove unused symbol 'mvs_th'
Jason Yan [Wed, 15 Apr 2020 08:50:53 +0000 (16:50 +0800)]
scsi: mvsas: remove unused symbol 'mvs_th'

This symbol has no users so remove it.

Link: https://lore.kernel.org/r/20200415085053.7633-1-yanaijie@huawei.com
Signed-off-by: Jason Yan <yanaijie@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: mvsas: make mvst_host_attrs static
Jason Yan [Wed, 15 Apr 2020 08:50:44 +0000 (16:50 +0800)]
scsi: mvsas: make mvst_host_attrs static

Fix the following sparse warning:

drivers/scsi/mvsas/mv_init.c:28:25: warning: symbol 'mvst_host_attrs' was
not declared. Should it be static?

Link: https://lore.kernel.org/r/20200415085044.7460-1-yanaijie@huawei.com
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Jason Yan <yanaijie@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qedi: make qedi_ll2_buf_size static
Jason Yan [Wed, 15 Apr 2020 08:50:29 +0000 (16:50 +0800)]
scsi: qedi: make qedi_ll2_buf_size static

Fix the following sparse warning:

drivers/scsi/qedi/qedi_main.c:44:6: warning: symbol 'qedi_ll2_buf_size' was
not declared. Should it be static?

Link: https://lore.kernel.org/r/20200415085029.7170-1-yanaijie@huawei.com
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Jason Yan <yanaijie@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: ufs: full reinit upon resume if link was off
Asutosh Das [Tue, 14 Apr 2020 06:14:48 +0000 (23:14 -0700)]
scsi: ufs: full reinit upon resume if link was off

During suspend, if the link is put to off, it would require a full
initialization during resume. This patch resets and restores both the host
and the card during initialization, otherwise host-only reset and restore
would fail occasionally.

Link: https://lore.kernel.org/r/1586844892-22720-1-git-send-email-cang@codeaurora.org
Reviewed-by: Bean Huo <beanhuo@micron.com>
Reviewed-by: Alim Akhtar <alim.akhtar@samsung.com>
Acked-by: Stanley Chu <stanley.chu@mediatek.com>
Acked-by: Avri Altman <Avri.Altman@wdc.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>
4 years agoscsi: fnic: make vnic_wq_get_ctrl and vnic_wq_alloc_ring static
Jason Yan [Wed, 15 Apr 2020 09:38:09 +0000 (17:38 +0800)]
scsi: fnic: make vnic_wq_get_ctrl and vnic_wq_alloc_ring static

Fix the following sparse warning:

drivers/scsi/fnic/vnic_wq.c:28:5: warning: symbol 'vnic_wq_get_ctrl' was
not declared. Should it be static?
drivers/scsi/fnic/vnic_wq.c:40:5: warning: symbol 'vnic_wq_alloc_ring'
was not declared. Should it be static?

Link: https://lore.kernel.org/r/20200415093809.9365-3-yanaijie@huawei.com
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Jason Yan <yanaijie@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: fnic: make fnic_list and fnic_list_lock static
Jason Yan [Wed, 15 Apr 2020 09:38:08 +0000 (17:38 +0800)]
scsi: fnic: make fnic_list and fnic_list_lock static

Fix the following sparse warning:

drivers/scsi/fnic/fnic_main.c:52:1: warning: symbol 'fnic_list' was not
declared. Should it be static?
drivers/scsi/fnic/fnic_main.c:53:1: warning: symbol 'fnic_list_lock' was
not declared. Should it be static?

Link: https://lore.kernel.org/r/20200415093809.9365-2-yanaijie@huawei.com
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Jason Yan <yanaijie@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: fnic: make some symbols static
Jason Yan [Wed, 15 Apr 2020 09:38:07 +0000 (17:38 +0800)]
scsi: fnic: make some symbols static

Fix the following sparse warning:

drivers/scsi/fnic/vnic_dev.c:257:5: warning: symbol 'vnic_dev_cmd1' was
not declared. Should it be static?
drivers/scsi/fnic/vnic_dev.c:319:5: warning: symbol 'vnic_dev_cmd2' was
not declared. Should it be static?
drivers/scsi/fnic/vnic_dev.c:414:5: warning: symbol
'vnic_dev_init_devcmd1' was not declared. Should it be static?
drivers/scsi/fnic/vnic_dev.c:425:5: warning: symbol
'vnic_dev_init_devcmd2' was not declared. Should it be static?
drivers/scsi/fnic/vnic_dev.c:495:6: warning: symbol
'vnic_dev_deinit_devcmd2' was not declared. Should it be static?
drivers/scsi/fnic/vnic_dev.c:506:5: warning: symbol
'vnic_dev_cmd_no_proxy' was not declared. Should it be static?

Link: https://lore.kernel.org/r/20200415093809.9365-1-yanaijie@huawei.com
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Jason Yan <yanaijie@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: libsas: Add missing annotation for sas_ata_qc_issue()
Jules Irenge [Sat, 11 Apr 2020 00:19:30 +0000 (01:19 +0100)]
scsi: libsas: Add missing annotation for sas_ata_qc_issue()

Sparse reports a warning at sas_ata_qc_issue()

warning: context imbalance in sas_ata_qc_issue() - unexpected unlock
The root cause is the missing annotation at sas_ata_qc_issue()

Add the missing __must_hold(ap->lock) annotation

Link: https://lore.kernel.org/r/20200411001933.10072-7-jbi.octave@gmail.com
Reviewed-by: John Garry <john.garry@huawei.com>
Signed-off-by: Jules Irenge <jbi.octave@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: ipr: remove unneeded semicolon
Jason Yan [Mon, 13 Apr 2020 08:28:22 +0000 (16:28 +0800)]
scsi: ipr: remove unneeded semicolon

Fix the following coccicheck warning:

drivers/scsi/ipr.c:1167:2-3: Unneeded semicolon

Link: https://lore.kernel.org/r/20200413082822.24356-1-yanaijie@huawei.com
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Jason Yan <yanaijie@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qla1280: make qla1280_firmware_mutex and qla1280_fw_tbl static
Jason Yan [Thu, 9 Apr 2020 08:49:10 +0000 (16:49 +0800)]
scsi: qla1280: make qla1280_firmware_mutex and qla1280_fw_tbl static

Fix the following sparse warning:

drivers/scsi/qla1280.c:529:1: warning: symbol 'qla1280_firmware_mutex'
was not declared. Should it be static?
drivers/scsi/qla1280.c:538:15: warning: symbol 'qla1280_fw_tbl' was not
declared. Should it be static?

Link: https://lore.kernel.org/r/20200409084910.44336-1-yanaijie@huawei.com
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Jason Yan <yanaijie@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: megaraid: make two symbols static in megaraid_sas_base.c
Jason Yan [Tue, 7 Apr 2020 09:28:27 +0000 (17:28 +0800)]
scsi: megaraid: make two symbols static in megaraid_sas_base.c

Fix the following sparse warning:

drivers/scsi/megaraid/megaraid_sas_base.c:84:5: warning: symbol
'rdpq_enable' was not declared. Should it be static?
drivers/scsi/megaraid/megaraid_sas_base.c:92:14: warning: symbol
'scmd_timeout' was not declared. Should it be static?

Link: https://lore.kernel.org/r/20200407092827.18074-5-yanaijie@huawei.com
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Jason Yan <yanaijie@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: megaraid: make some symbols static in megaraid_sas_fusion.c
Jason Yan [Tue, 7 Apr 2020 09:28:26 +0000 (17:28 +0800)]
scsi: megaraid: make some symbols static in megaraid_sas_fusion.c

Fix the following sparse warning:

drivers/scsi/megaraid/megaraid_sas_fusion.c:180:1: warning: symbol
'megasas_enable_intr_fusion' was not declared. Should it be static?
drivers/scsi/megaraid/megaraid_sas_fusion.c:202:1: warning: symbol
'megasas_disable_intr_fusion' was not declared. Should it be static?
drivers/scsi/megaraid/megaraid_sas_fusion.c:4233:6: warning: symbol
'megasas_refire_mgmt_cmd' was not declared. Should it be static?

Link: https://lore.kernel.org/r/20200407092827.18074-4-yanaijie@huawei.com
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Jason Yan <yanaijie@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: megaraid: make some symbols static in megaraid_sas_fp.c
Jason Yan [Tue, 7 Apr 2020 09:28:25 +0000 (17:28 +0800)]
scsi: megaraid: make some symbols static in megaraid_sas_fp.c

Fix the following sparse warning:

drivers/scsi/megaraid/megaraid_sas_fp.c:88:5: warning: symbol
'mega_div64_32' was not declared. Should it be static?
drivers/scsi/megaraid/megaraid_sas_fp.c:370:5: warning: symbol
'MR_GetSpanBlock' was not declared. Should it be static?
drivers/scsi/megaraid/megaraid_sas_fp.c:420:5: warning: symbol
'mr_spanset_get_span_block' was not declared. Should it be static?
drivers/scsi/megaraid/megaraid_sas_fp.c:645:4: warning: symbol 'get_arm'
was not declared. Should it be static?
drivers/scsi/megaraid/megaraid_sas_fp.c:788:4: warning: symbol
'MR_GetPhyParams' was not declared. Should it be static?
drivers/scsi/megaraid/megaraid_sas_fp.c:1345:4: warning: symbol
'megasas_get_best_arm_pd' was not declared. Should it be static?

Link: https://lore.kernel.org/r/20200407092827.18074-3-yanaijie@huawei.com
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Jason Yan <yanaijie@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: megaraid: make two symbols static in megaraid_mbox.c
Jason Yan [Tue, 7 Apr 2020 09:28:24 +0000 (17:28 +0800)]
scsi: megaraid: make two symbols static in megaraid_mbox.c

Fix the following sparse warning:

drivers/scsi/megaraid/megaraid_mbox.c:305:5: warning: symbol
'dev_attr_megaraid_mbox_app_hndl' was not declared. Should it be static?
drivers/scsi/megaraid/megaraid_mbox.c:315:5: warning: symbol
'dev_attr_megaraid_mbox_ld' was not declared. Should it be static?

Link: https://lore.kernel.org/r/20200407092827.18074-2-yanaijie@huawei.com
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Jason Yan <yanaijie@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: bfa: bfad.c: make max_rport_logins static
Jason Yan [Tue, 7 Apr 2020 03:22:02 +0000 (11:22 +0800)]
scsi: bfa: bfad.c: make max_rport_logins static

Fix the following sparse warning:

drivers/scsi/bfa/bfad.c:53:17: warning: symbol 'max_rport_logins' was
not declared. Should it be static?

Link: https://lore.kernel.org/r/20200407032202.36789-8-yanaijie@huawei.com
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Jason Yan <yanaijie@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: bfa: bfad_attr.c: make two funcitons static
Jason Yan [Tue, 7 Apr 2020 03:22:01 +0000 (11:22 +0800)]
scsi: bfa: bfad_attr.c: make two funcitons static

Fix the following sparse warning:

drivers/scsi/bfa/bfad_attr.c:441:1: warning: symbol
'bfad_im_issue_fc_host_lip' was not declared. Should it be static?
drivers/scsi/bfa/bfad_attr.c:566:1: warning: symbol
'bfad_im_vport_set_symbolic_name' was not declared. Should it be static?

Link: https://lore.kernel.org/r/20200407032202.36789-7-yanaijie@huawei.com
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Jason Yan <yanaijie@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: bfa: bfa_ioc_ct.c: make two funcitons static
Jason Yan [Tue, 7 Apr 2020 03:22:00 +0000 (11:22 +0800)]
scsi: bfa: bfa_ioc_ct.c: make two funcitons static

Fix the following sparse warning:

drivers/scsi/bfa/bfa_ioc_ct.c:368:1: warning: symbol
'bfa_ioc_ct2_lpu_read_stat' was not declared. Should it be static?
drivers/scsi/bfa/bfa_ioc_ct.c:748:1: warning: symbol
'bfa_ioc_ct2_mac_reset' was not declared. Should it be static?

Link: https://lore.kernel.org/r/20200407032202.36789-6-yanaijie@huawei.com
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Jason Yan <yanaijie@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: bfa: bfa_fcs_lport.c: make bfa_fcport_get_loop_attr() static
Jason Yan [Tue, 7 Apr 2020 03:21:59 +0000 (11:21 +0800)]
scsi: bfa: bfa_fcs_lport.c: make bfa_fcport_get_loop_attr() static

Fix the following sparse warning:

drivers/scsi/bfa/bfa_fcs_lport.c:1287:1: warning: symbol
'bfa_fcport_get_loop_attr' was not declared. Should it be static?

Link: https://lore.kernel.org/r/20200407032202.36789-5-yanaijie@huawei.com
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Jason Yan <yanaijie@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: bfa: bfa_fcpim.c: make two functions static
Jason Yan [Tue, 7 Apr 2020 03:21:58 +0000 (11:21 +0800)]
scsi: bfa: bfa_fcpim.c: make two functions static

Fix the following sparse warning:

drivers/scsi/bfa/bfa_fcpim.c:440:1: warning: symbol
'bfa_ioim_profile_comp' was not declared. Should it be static?
drivers/scsi/bfa/bfa_fcpim.c:457:1: warning: symbol
'bfa_ioim_profile_start' was not declared. Should it be static?

Link: https://lore.kernel.org/r/20200407032202.36789-4-yanaijie@huawei.com
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Jason Yan <yanaijie@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: bfa: bfa_core.c: make bfa_isr_rspq() static
Jason Yan [Tue, 7 Apr 2020 03:21:57 +0000 (11:21 +0800)]
scsi: bfa: bfa_core.c: make bfa_isr_rspq() static

Fix the following sparse warning:

drivers/scsi/bfa/bfa_core.c:712:1: warning: symbol 'bfa_isr_rspq' was
not declared. Should it be static?

Link: https://lore.kernel.org/r/20200407032202.36789-3-yanaijie@huawei.com
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Jason Yan <yanaijie@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: bfa: bfa_svc.c: make two functions static
Jason Yan [Tue, 7 Apr 2020 03:21:56 +0000 (11:21 +0800)]
scsi: bfa: bfa_svc.c: make two functions static

Fix the following sparse warning:

drivers/scsi/bfa/bfa_svc.c:4288:1: warning: symbol
'bfa_fcport_ddportenable' was not declared. Should it be static?
drivers/scsi/bfa/bfa_svc.c:4297:1: warning: symbol
'bfa_fcport_ddportdisable' was not declared. Should it be static?

Link: https://lore.kernel.org/r/20200407032202.36789-2-yanaijie@huawei.com
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Jason Yan <yanaijie@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: gdth: Make __gdth_execute static
Wang Hai [Tue, 7 Apr 2020 16:21:14 +0000 (12:21 -0400)]
scsi: gdth: Make __gdth_execute static

Fix sparse warning:

drivers/scsi/gdth.c:332:5: warning:
 symbol '__gdth_execute' was not declared. Should it be static?

Link: https://lore.kernel.org/r/1586276474-34480-1-git-send-email-wanghai38@huawei.com
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Wang Hai <wanghai38@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qla2xxx: Use ARRAY_SIZE() instead of open-coding it
Bart Van Assche [Mon, 13 Apr 2020 02:13:59 +0000 (19:13 -0700)]
scsi: qla2xxx: Use ARRAY_SIZE() instead of open-coding it

This patch does not change any functionality.

Link: https://lore.kernel.org/r/20200413021359.21725-1-bvanassche@acm.org
Cc: Nilesh Javali <njavali@marvell.com>
Cc: Quinn Tran <qutran@marvell.com>
Cc: Himanshu Madhani <himanshu.madhani@oracle.com>
Cc: Martin Wilck <mwilck@suse.com>
Cc: Daniel Wagner <dwagner@suse.de>
Cc: Roman Bolshakov <r.bolshakov@yadro.com>
Reviewed-by: Daniel Wagner <dwagner@suse.de>
Reviewed-by: Roman Bolshakov <r.bolshakov@yadro.com>
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qla2xxx: Split qla2x00_configure_local_loop()
Bart Van Assche [Sun, 5 Apr 2020 22:59:05 +0000 (15:59 -0700)]
scsi: qla2xxx: Split qla2x00_configure_local_loop()

The size of the function qla2x00_configure_local_loop() hurts its
readability. Hence split that function. This patch does not change any
functionality.

Link: https://lore.kernel.org/r/20200405225905.17171-1-bvanassche@acm.org
Cc: Nilesh Javali <njavali@marvell.com>
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>
Reviewed-by: Roman Bolshakov <r.bolshakov@yadro.com>
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
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>
4 years agoscsi: qedi: Fix termination timeouts in session logout
Nilesh Javali [Wed, 8 Apr 2020 06:43:32 +0000 (23:43 -0700)]
scsi: qedi: Fix termination timeouts in session logout

The destroy connection ramrod timed out during session logout.  Fix the
wait delay for graceful vs abortive termination as per the FW requirements.

Link: https://lore.kernel.org/r/20200408064332.19377-7-mrangankar@marvell.com
Reviewed-by: Lee Duncan <lduncan@suse.com>
Signed-off-by: Nilesh Javali <njavali@marvell.com>
Signed-off-by: Manish Rangankar <mrangankar@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qedi: Add modules param to enable qed iSCSI debug
Manish Rangankar [Wed, 8 Apr 2020 06:43:31 +0000 (23:43 -0700)]
scsi: qedi: Add modules param to enable qed iSCSI debug

Add module parameter to enable debug messages specific to iSCSI functions.

Link: https://lore.kernel.org/r/20200408064332.19377-6-mrangankar@marvell.com
Reviewed-by: Lee Duncan <lduncan@suse.com>
Signed-off-by: Manish Rangankar <mrangankar@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qedi: Do not flush offload work if ARP not resolved
Nilesh Javali [Wed, 8 Apr 2020 06:43:30 +0000 (23:43 -0700)]
scsi: qedi: Do not flush offload work if ARP not resolved

For an unreachable target, offload_work is not initialized and the endpoint
state is set to OFLDCONN_NONE. This results in a WARN_ON due to the check
of the work function field being set to zero.

------------[ cut here ]------------
WARNING: CPU: 24 PID: 18587 at ../kernel/workqueue.c:3037 __flush_work+0x1c1/0x1d0
:
Hardware name: HPE ProLiant DL380 Gen10/ProLiant DL380 Gen10, BIOS U30 02/01/2020
RIP: 0010:__flush_work+0x1c1/0x1d0
Code: ba 6d 00 03 80 c9 f0 eb b6 48 c7 c7 20 ee 6c a4 e8 52 d3 04 00 0f 0b 31 c0 e9 d1 fe ff
ff 48 c7 c7 20 ee 6c a4 e8 3d d3 04 00 <0f> 0b 31 c0 e9 bc fe ff ff e8 11 f3 f
 00 31 f6
RSP: 0018:ffffac5a8cd47a80 EFLAGS: 00010282
RAX: 0000000000000024 RBX: ffff98d68c1fcaf0 RCX: 0000000000000000
RDX: 0000000000000000 RSI: ffff98ce9fd99898 RDI: ffff98ce9fd99898
RBP: ffff98d68c1fcbc0 R08: 00000000000006fa R09: 0000000000000001
R10: ffffac5a8cd47b50 R11: 0000000000000001 R12: 0000000000000000
R13: 000000000000489b R14: ffff98d68c1fc800 R15: ffff98d692132c00
FS:  00007f65f7f62280(0000) GS:ffff98ce9fd80000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007ffd2435e880 CR3: 0000000809334003 CR4: 00000000007606e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
PKRU: 55555554
Call Trace:
 ? class_create_release+0x40/0x40
 ? klist_put+0x2c/0x80
 qedi_ep_disconnect+0xdd/0x400 [qedi]
 iscsi_if_ep_disconnect.isra.20+0x59/0x70 [scsi_transport_iscsi]
 iscsi_if_rx+0x129b/0x1670 [scsi_transport_iscsi]
 ? __netlink_lookup+0xe7/0x160
 netlink_unicast+0x21d/0x300
 netlink_sendmsg+0x30f/0x430
 sock_sendmsg+0x5b/0x60
 ____sys_sendmsg+0x1e2/0x240
 ? copy_msghdr_from_user+0xd9/0x160
 ___sys_sendmsg+0x88/0xd0
 ? ___sys_recvmsg+0xa2/0xe0
 ? hrtimer_try_to_cancel+0x25/0x100
 ? do_nanosleep+0x9c/0x170
 ? __sys_sendmsg+0x5e/0xa0
 __sys_sendmsg+0x5e/0xa0
 do_syscall_64+0x60/0x1f0
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x7f65f6f16107
Code: 64 89 02 48 c7 c0 ff ff ff ff eb b9 0f 1f 80 00 00 00 00 8b 05 aa d2 2b 00 48 63 d2 48
63 ff 85 c0 75 18 b8 2e 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 59 f3 c3 0f 1f 8
    0 00 00 00 00 53 48 89 f3 48
 RSP: 002b:00007ffd24367ca8 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
 RAX: ffffffffffffffda RBX: 000055a7aeaaf110 RCX: 00007f65f6f16107
 RDX: 0000000000000000 RSI: 00007ffd24367cc0 RDI: 0000000000000003
 RBP: 0000000000000070 R08: 0000000000000000 R09: 0000000000000000
 R10: 000000000000075c R11: 0000000000000246 R12: 00007ffd24367cc0
 R13: 000055a7ae560008 R14: 00007ffd24367db0 R15: 0000000000000000
 ---[ end trace 54f499c05d41f8bb ]---

Only flush if the connection endpoint state if different from
OFLDCONN_NONE.

[mkp: clarified commit desc]

Link: https://lore.kernel.org/r/20200408064332.19377-5-mrangankar@marvell.com
Reviewed-by: Lee Duncan <lduncan@suse.com>
Signed-off-by: Nilesh Javali <njavali@marvell.com>
Signed-off-by: Manish Rangankar <mrangankar@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qedi: Use correct msix count for fastpath vectors
Manish Rangankar [Wed, 8 Apr 2020 06:43:29 +0000 (23:43 -0700)]
scsi: qedi: Use correct msix count for fastpath vectors

Use MSI-X count provided by qed.

Link: https://lore.kernel.org/r/20200408064332.19377-4-mrangankar@marvell.com
Reviewed-by: Lee Duncan <lduncan@suse.com>
Signed-off-by: Manish Rangankar <mrangankar@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qedi: Avoid unnecessary endpoint allocation on link down
Manish Rangankar [Wed, 8 Apr 2020 06:43:28 +0000 (23:43 -0700)]
scsi: qedi: Avoid unnecessary endpoint allocation on link down

No need to allocate and deallocate endpoint memory if the physical link is
down.

Link: https://lore.kernel.org/r/20200408064332.19377-3-mrangankar@marvell.com
Reviewed-by: Lee Duncan <lduncan@suse.com>
Signed-off-by: Manish Rangankar <mrangankar@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qedi: Remove additional char from boot target iqnname
Manish Rangankar [Wed, 8 Apr 2020 06:43:27 +0000 (23:43 -0700)]
scsi: qedi: Remove additional char from boot target iqnname

While parsing the iSCSI TLV data to MFW request, a newline was added to the
firmware boot target iqnname string. Because of this, we were getting the
following error even after the boot target was successfully logged in:

"[qedi_get_protocol_tlv_data:1197]:1: Boot target not set"

Remove the trailing newline.

[mkp: clarified commit desc]

Link: https://lore.kernel.org/r/20200408064332.19377-2-mrangankar@marvell.com
Reviewed-by: Lee Duncan <lduncan@suse.com>
Signed-off-by: Manish Rangankar <mrangankar@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qedf: Simplify mutex_unlock() usage
Daniel Wagner [Fri, 3 Apr 2020 09:27:17 +0000 (11:27 +0200)]
scsi: qedf: Simplify mutex_unlock() usage

The commit 6d1368e8f987 ("scsi: qedf: fixup locking in
qedf_restart_rport()") introduced the lock. Though the lock protects
only the fc_rport_create() call. Thus, we can move the mutex unlock up
before the if statement and drop the else body.

Link: https://lore.kernel.org/r/20200403092717.19779-1-dwagner@suse.de
Cc: Hannes Reinecke <hare@suse.com>
Cc: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: docs: fusion: get rid of a doc build warning
Mauro Carvalho Chehab [Wed, 8 Apr 2020 15:46:15 +0000 (17:46 +0200)]
scsi: docs: fusion: get rid of a doc build warning

Use a table for the enum list, to avoid this warning:

./drivers/message/fusion/mptbase.c:5058: WARNING: Definition list ends without a blank line; unexpected unindent.

Link: https://lore.kernel.org/r/9ca049c2d25689c56448afddf4f0d1e619fa87f7.1586359676.git.mchehab+huawei@kernel.org
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>