platform/kernel/linux-rpi.git
5 years agoscsi: qedf: Use a separate completion for cleanup commands
Chad Dupuis [Tue, 26 Mar 2019 07:38:39 +0000 (00:38 -0700)]
scsi: qedf: Use a separate completion for cleanup commands

 - If a TMF and cleanup are issued at the same time they could cause a call
   trace if issued against the same xid as the io_req->tm_done completion
   is used for both.

 - Set and clear cleanup bit in cleanup routine.

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>
5 years agoscsi: qedf: Modify abort and tmf handler to handle edge condition and flush
Saurav Kashyap [Tue, 26 Mar 2019 07:38:38 +0000 (00:38 -0700)]
scsi: qedf: Modify abort and tmf handler to handle edge condition and flush

An I/O can be in any state when flush is called, it can be in abort,
waiting for abort, RRQ send and waiting or TMF send.

 - HZ can be different on different architecture, correctly set abort
   timeout value.

 - Flush can complete the I/Os prematurely, handle refcount for aborted
   I/Os and for which RRQ is pending.

 - Differentiate LUN/TARGET reset, as cleanup needs to be send to firmware
   accordingly.

 - Add flush mutex to sync cleanup call from abort and flush routine.

 - Clear abort/outstanding bit on timeout.

Signed-off-by: Shyam Sundar <shyam.sundar@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>
5 years agoscsi: qedf: Modify flush routine to handle all I/Os and TMF
Shyam Sundar [Tue, 26 Mar 2019 07:38:37 +0000 (00:38 -0700)]
scsi: qedf: Modify flush routine to handle all I/Os and TMF

The purpose of flush routine is to cleanup I/Os to the firmware and
complete them to scsi middle layer. This routine is invoked before
connection is uploaded because of rport going away.

 - Don't process any I/Os, aborts, TMFs coming when flush in progress.

 - Add flags to handle cleanup and release of I/Os because flush can
   prematurely complete I/Os.

 - Original command can get completed to driver when cleanup for same is
   posted to firmware, handle this condition.

 - Modify flush to handle I/Os in all the states like abort, TMF, RRQ and
   timeouts.

Signed-off-by: Shyam Sundar <ssundar@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>
5 years agoscsi: qedf: Simplify s/g list mapping
Chad Dupuis [Tue, 26 Mar 2019 07:38:36 +0000 (00:38 -0700)]
scsi: qedf: Simplify s/g list mapping

When mapping the pages from a scatter/gather list from the SCSI layer we
only need to follow these rules:

 - Max SGEs for each I/O request is 256
 - No size limit on each SGE
 - No need to split OS provided SGEs to 4K before sending to firmware.
 - Slow SGE is applicable only when:
   - There are > 8 SGEs and any middle SGE is less than a page size (4K)

Make necessary changes so that driver follows these rules. Applicable only
for Write requests (not for Read requests). No need to check SGE address
alignment requirements (first, middle or last) before declaring slow SGE.

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>
5 years agoscsi: qedf: Add missing return in qedf_post_io_req() in the fcport offload check
Chad Dupuis [Tue, 26 Mar 2019 07:38:35 +0000 (00:38 -0700)]
scsi: qedf: Add missing return in qedf_post_io_req() in the fcport offload check

Fixes the following crash as the return was missing from the check if an
fcport is offloaded. If we hit this code we continue to try to post an
invalid task which can lead to the crash:

[30259.616411] [0000:61:00.3]:[qedf_post_io_req:989]:3: Session not offloaded yet.
[30259.616413] [0000:61:00.3]:[qedf_upload_connection:1340]:3: Uploading connection port_id=490020.
[30259.623769] BUG: unable to handle kernel NULL pointer dereference at 0000000000000198
[30259.631645] IP: [<ffffffffc035b1ed>] qedf_init_task.isra.16+0x3d/0x450 [qedf]
[30259.638816] PGD 0
[30259.640841] Oops: 0000 [#1] SMP
[30259.644098] Modules linked in: fuse xt_CHECKSUM iptable_mangle ipt_MASQUERADE nf_nat_masquerade_ipv4 iptable_nat nf_nat_ipv4 nf_nat nf_conntrack_ipv4 nf_defrag_ipv4 xt_conntrack nf_conntrack ipt_REJECT nf_reject_ipv4 tun bridge stp llc ebtable_filter ebtables devlink ip6table_filter ip6_tables iptable_filter vfat fat ib_isert iscsi_target_mod ib_srpt target_core_mod ib_srp scsi_transport_srp ib_ipoib ib_ucm ib_umad dm_service_time skx_edac intel_powerclamp coretemp intel_rapl iosf_mbi kvm_intel kvm irqbypass crc32_pclmul ghash_clmulni_intel aesni_intel rpcrdma sunrpc rdma_ucm ib_uverbs lrw gf128mul ib_iser rdma_cm iw_cm ib_cm libiscsi scsi_transport_iscsi qedr(OE) glue_helper ablk_helper cryptd ib_core dm_round_robin joydev pcspkr ipmi_ssif ses enclosure ipmi_si ipmi_devintf ipmi_msghandler mei_me
[30259.715529]  mei sg hpilo hpwdt shpchp wmi lpc_ich acpi_power_meter dm_multipath ip_tables xfs libcrc32c sd_mod crc_t10dif crct10dif_generic uas usb_storage mgag200 qedf(OE) i2c_algo_bit libfcoe drm_kms_helper libfc syscopyarea sysfillrect scsi_transport_fc qede(OE) sysimgblt fb_sys_fops ptp ttm pps_core drm qed(OE) smartpqi crct10dif_pclmul crct10dif_common crc32c_intel i2c_core scsi_transport_sas scsi_tgt dm_mirror dm_region_hash dm_log dm_mod
[30259.754237] CPU: 9 PID: 977 Comm: kdmwork-253:7 Kdump: loaded Tainted: G        W  OE  ------------   3.10.0-862.el7.x86_64 #1
[30259.765664] Hardware name: HPE Synergy 480 Gen10/Synergy 480 Gen10 Compute Module, BIOS I42 04/04/2018
[30259.775000] task: ffff8c801efd0000 ti: ffff8c801efd8000 task.ti: ffff8c801efd8000
[30259.782505] RIP: 0010:[<ffffffffc035b1ed>]  [<ffffffffc035b1ed>] qedf_init_task.isra.16+0x3d/0x450 [qedf]
[30259.792116] RSP: 0018:ffff8c801efdbbb0  EFLAGS: 00010046
[30259.797444] RAX: 0000000000000000 RBX: ffffa7f1450948d8 RCX: ffff8c7fe5bc40c8
[30259.804600] RDX: ffff8c800715b300 RSI: ffffa7f1450948d8 RDI: ffff8c80169c2480
[30259.811755] RBP: ffff8c801efdbc30 R08: 00000000000000ae R09: ffff8c800a314540
[30259.818911] R10: ffff8c7fe5bc40c8 R11: ffff8c801efdb8ae R12: 0000000000000000
[30259.826068] R13: ffff8c800715b300 R14: ffff8c80169c2480 R15: ffff8c8005da28e0
[30259.833223] FS:  0000000000000000(0000) GS:ffff8c803f840000(0000) knlGS:0000000000000000
[30259.841338] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[30259.847100] CR2: 0000000000000198 CR3: 000000081242e000 CR4: 00000000007607e0
[30259.854256] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[30259.861412] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
[30259.868568] PKRU: 00000000
[30259.871278] Call Trace:
[30259.873737]  [<ffffffffc035c948>] qedf_post_io_req+0x148/0x680 [qedf]
[30259.880201]  [<ffffffffc035d070>] qedf_queuecommand+0x1f0/0x240 [qedf]
[30259.886749]  [<ffffffffa329b050>] scsi_dispatch_cmd+0xb0/0x240
[30259.892600]  [<ffffffffa32a45bc>] scsi_request_fn+0x4cc/0x680
[30259.898364]  [<ffffffffa3118ad9>] __blk_run_queue+0x39/0x50
[30259.903954]  [<ffffffffa3114393>] __elv_add_request+0xd3/0x260
[30259.909805]  [<ffffffffa311baf0>] blk_insert_cloned_request+0xf0/0x1b0
[30259.916358]  [<ffffffffc010b622>] map_request+0x142/0x220 [dm_mod]
[30259.922560]  [<ffffffffc010b716>] map_tio_request+0x16/0x40 [dm_mod]
[30259.928932]  [<ffffffffa2ebb1f5>] kthread_worker_fn+0x85/0x180
[30259.934782]  [<ffffffffa2ebb170>] ? kthread_stop+0xf0/0xf0
[30259.940284]  [<ffffffffa2ebae31>] kthread+0xd1/0xe0
[30259.945176]  [<ffffffffa2ebad60>] ? insert_kthread_work+0x40/0x40
[30259.951290]  [<ffffffffa351f61d>] ret_from_fork_nospec_begin+0x7/0x21
[30259.957750]  [<ffffffffa2ebad60>] ? insert_kthread_work+0x40/0x40
[30259.963860] Code: fe 41 55 49 89 d5 41 54 53 48 89 f3 48 83 ec 58 4c 8b 67 28 4c 8b 4e 18 65 48 8b 04 25 28 00 00 00 48 89 45 d0 31 c0 4c 8b 7e 58 <49> 8b 84 24 98 01 00 00 48 8b 00 f6 80 31 01 00 00 10 0f 85 0b
[30259.983372] RIP  [<ffffffffc035b1ed>] qedf_init_task.isra.16+0x3d/0x450 [qedf]
[30259.990630]  RSP <ffff8c801efdbbb0>
[30259.994127] CR2: 0000000000000198

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>
5 years agoscsi: qedf: Correct xid range overlap between offloaded requests and libfc requests
Chad Dupuis [Tue, 26 Mar 2019 07:38:34 +0000 (00:38 -0700)]
scsi: qedf: Correct xid range overlap between offloaded requests and libfc requests

There is currently an overlap where exchange IDs between what is used for
offloaded commands and by libfc for ELS commands.  Correct this so that
exchange ID range is:

Offloaded requests: 0 to 0xfff
libfc requests: 0x1000 to 0xfffe

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>
5 years agoscsi: qedf: Do not retry ELS request if qedf_alloc_cmd fails
Chad Dupuis [Tue, 26 Mar 2019 07:38:33 +0000 (00:38 -0700)]
scsi: qedf: Do not retry ELS request if qedf_alloc_cmd fails

If we cannot allocate an ELS middlepath request, simply fail instead of
trying to delay and then reallocate.  This delay logic is causing soft
lockup messages:

NMI watchdog: BUG: soft lockup - CPU#2 stuck for 22s! [kworker/2:1:7639]
Modules linked in: xt_CHECKSUM ipt_MASQUERADE nf_nat_masquerade_ipv4 tun devlink ip6t_rpfilter ipt_REJECT nf_reject_ipv4 ip6t_REJECT nf_reject_ipv6 xt_conntrack ip_set nfnetlink ebtable_nat ebtable_broute bridge stp llc ip6table_nat nf_conntrack_ipv6 nf_defrag_ipv6 nf_nat_ipv6 ip6table_mangle ip6table_security ip6table_raw iptable_nat nf_conntrack_ipv4 nf_defrag_ipv4 nf_nat_ipv4 nf_nat nf_conntrack iptable_mangle iptable_security iptable_raw ebtable_filter ebtables ip6table_filter ip6_tables iptable_filter dm_service_time vfat fat rpcrdma sunrpc ib_isert iscsi_target_mod ib_iser libiscsi scsi_transport_iscsi ib_srpt target_core_mod ib_srp scsi_transport_srp ib_ipoib rdma_ucm ib_ucm ib_uverbs ib_umad rdma_cm ib_cm iw_cm sb_edac intel_powerclamp coretemp intel_rapl iosf_mbi kvm_intel kvm
irqbypass crc32_pclmul ghash_clmulni_intel aesni_intel lrw gf128mul glue_helper ablk_helper cryptd iTCO_wdt iTCO_vendor_support qedr(OE) ib_core joydev ipmi_ssif pcspkr hpilo hpwdt sg ipmi_si ipmi_devintf ipmi_msghandler ioatdma shpchp lpc_ich wmi dca acpi_power_meter dm_multipath ip_tables xfs libcrc32c sd_mod crc_t10dif crct10dif_generic qedf(OE) libfcoe mgag200 libfc i2c_algo_bit drm_kms_helper scsi_transport_fc qede(OE) syscopyarea sysfillrect sysimgblt fb_sys_fops ttm qed(OE) drm crct10dif_pclmul e1000e crct10dif_common crc32c_intel scsi_tgt hpsa i2c_core ptp scsi_transport_sas pps_core dm_mirror dm_region_hash dm_log dm_mod
CPU: 2 PID: 7639 Comm: kworker/2:1 Kdump: loaded Tainted: G           OEL ------------   3.10.0-861.el7.x86_64 #1
Hardware name: HP ProLiant DL580 Gen9/ProLiant DL580 Gen9, BIOS U17 07/21/2016
Workqueue: qedf_2_dpc qedf_handle_rrq [qedf]
task: ffff959edd628fd0 ti: ffff959ed6f08000 task.ti: ffff959ed6f08000
RIP: 0010:[<ffffffff8355913a>]  [<ffffffff8355913a>] delay_tsc+0x3a/0x60
RSP: 0018:ffff959ed6f0bd30  EFLAGS: 00000246
RAX: 000000008ef5f791 RBX: 5f646d635f666465 RCX: 0000025b8ededa2f
RDX: 000000000000025b RSI: 0000000000000002 RDI: 0000000000217d1e
RBP: ffff959ed6f0bd30 R08: ffffffffc079aae8 R09: 0000000000000200
R10: ffffffffc07952c6 R11: 0000000000000000 R12: 6c6c615f66646571
R13: ffff959ed6f0bcc8 R14: ffff959ed6f0bd08 R15: ffff959e00000028
FS:  0000000000000000(0000) GS:ffff959eff480000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f4117fa1eb0 CR3: 0000002039e66000 CR4: 00000000003607e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
[<ffffffff8355907d>] __const_udelay+0x2d/0x30
[<ffffffffc079444a>] qedf_initiate_els+0x13a/0x450 [qedf]
[<ffffffffc0794210>] ? qedf_srr_compl+0x2a0/0x2a0 [qedf]
[<ffffffffc0795337>] qedf_send_rrq+0x127/0x230 [qedf]
[<ffffffffc078ed55>] qedf_handle_rrq+0x15/0x20 [qedf]
[<ffffffff832b2dff>] process_one_work+0x17f/0x440
[<ffffffff832b3ac6>] worker_thread+0x126/0x3c0
[<ffffffff832b39a0>] ? manage_workers.isra.24+0x2a0/0x2a0
[<ffffffff832bae31>] kthread+0xd1/0xe0
[<ffffffff832bad60>] ? insert_kthread_work+0x40/0x40
[<ffffffff8391f637>] ret_from_fork_nospec_begin+0x21/0x21
[<ffffffff832bad60>] ? insert_kthread_work+0x40/0x40

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>
5 years agoscsi: MAINTAINERS: Add maintainer for MediaTek UFS driver
Stanley Chu [Wed, 27 Mar 2019 06:27:05 +0000 (14:27 +0800)]
scsi: MAINTAINERS: Add maintainer for MediaTek UFS driver

Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: qla2xxx: Simplify conditional check again
Nathan Chancellor [Tue, 26 Mar 2019 22:04:46 +0000 (15:04 -0700)]
scsi: qla2xxx: Simplify conditional check again

Clang warns when it sees a logical not on the left side of a conditional
statement because it thinks the logical not should be applied to the whole
statement, not just the left side:

drivers/scsi/qla2xxx/qla_nx.c:3703:7: warning: logical not is only
applied to the left hand side of this comparison
[-Wlogical-not-parentheses]

This particular instance was already fixed by commit 0bfe7d3cae58 ("scsi:
qla2xxx: Simplify conditional check") upstream but it was reintroduced by
commit 3695310e37b4 ("scsi: qla2xxx: Update flash read/write routine") in
the 5.2/scsi-queue.

Fixes: 3695310e37b4 ("scsi: qla2xxx: Update flash read/write routine")
Link: https://github.com/ClangBuiltLinux/linux/issues/80
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: sd: Inline sd_probe_part2()
Bart Van Assche [Wed, 20 Mar 2019 20:09:20 +0000 (13:09 -0700)]
scsi: sd: Inline sd_probe_part2()

Make sd_probe() easier to read by inlining sd_probe_part2(). This patch
does not change any functionality.

Cc: Lee Duncan <lduncan@suse.com>
Cc: Hannes Reinecke <hare@suse.com>
Cc: Luis Chamberlain <mcgrof@kernel.org>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: sd: Rely on the driver core for asynchronous probing
Bart Van Assche [Wed, 20 Mar 2019 20:09:19 +0000 (13:09 -0700)]
scsi: sd: Rely on the driver core for asynchronous probing

As explained during the 2018 LSF/MM session about increasing SCSI disk
probing concurrency, the problems with the current probing approach are as
follows:

- The driver core is unaware of asynchronous SCSI LUN probing.
  wait_for_device_probe() waits for all asynchronous probes except
  asynchronous SCSI disk probes.

- There is unnecessary serialization between sd_probe() and sd_remove().
  This can lead to a deadlock.

Hence this patch that modifies the sd driver such that it uses the driver
core framework for asynchronous probing. The async domains and
get_device()/put_device() pairs that became superfluous due to this change
are removed.

This patch does not affect the time needed for loading the scsi_debug
kernel module with parameters delay=0 and max_luns=256.

This patch depends on commit ef0ff68351be ("driver core: Probe devices
asynchronously instead of the driver") that went upstream in kernel version
v5.1-rc1.

Cc: Lee Duncan <lduncan@suse.com>
Cc: Hannes Reinecke <hare@suse.com>
Cc: Luis Chamberlain <mcgrof@kernel.org>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: mpt3sas: fix indentation issue
Colin Ian King [Wed, 20 Mar 2019 16:50:00 +0000 (16:50 +0000)]
scsi: mpt3sas: fix indentation issue

There are a couple of statements that are incorrectly indented, fix these.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: libcxgbi: remove uninitialized variable len
Colin Ian King [Sat, 16 Mar 2019 22:57:09 +0000 (22:57 +0000)]
scsi: libcxgbi: remove uninitialized variable len

The variable len is not being inintialized and the uninitialized value is
being returned. However, this return path is never reached because the
default case in the switch statement returns -ENOSYS.  Clean up the code by
replacing the return -ENOSYS with a break for the default case and
returning -ENOSYS at the end of the function.  This allows len to be
removed.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: target: alua: fix the tg_pt_gps_count
tangwenji [Wed, 27 Mar 2019 13:59:06 +0000 (21:59 +0800)]
scsi: target: alua: fix the tg_pt_gps_count

Reducing the count should be alua_tg_pt_gps_count instead of
alua_tg_pt_gps_counter when free alua group.

Signed-off-by: tangwenji <tang.wenji@zte.com.cn>
Reviewed-by: Mike Christie <mchristi@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: gdth: Only call dma_free_coherent when buf is not NULL in ioc_general
Nathan Chancellor [Thu, 7 Mar 2019 23:18:39 +0000 (16:18 -0700)]
scsi: gdth: Only call dma_free_coherent when buf is not NULL in ioc_general

When building with -Wsometimes-uninitialized, Clang warns:

drivers/scsi/gdth.c:3662:6: warning: variable 'paddr' is used
uninitialized whenever 'if' condition is false
[-Wsometimes-uninitialized]

Don't attempt to call dma_free_coherent when buf is NULL (meaning that
we never called dma_alloc_coherent and initialized paddr), which avoids
this warning.

Link: https://github.com/ClangBuiltLinux/linux/issues/402
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: pm8001: remove set but not used variables 'param, sas_ha'
YueHaibing [Sat, 23 Mar 2019 02:15:59 +0000 (02:15 +0000)]
scsi: pm8001: remove set but not used variables 'param, sas_ha'

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

drivers/scsi/pm8001/pm8001_hwi.c: In function 'mpi_smp_completion':
drivers/scsi/pm8001/pm8001_hwi.c:2901:6: warning:
 variable 'param' set but not used [-Wunused-but-set-variable]

drivers/scsi/pm8001/pm8001_hwi.c: In function 'pm8001_bytes_dmaed':
drivers/scsi/pm8001/pm8001_hwi.c:3247:24: warning:
 variable 'sas_ha' set but not used [-Wunused-but-set-variable]

They're never used since introduction, so can be removed.

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Acked-by: Jack Wang <jinpu.wang@cloud.ionos.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: qla4xxx: avoid freeing unallocated dma memory
Arnd Bergmann [Fri, 22 Mar 2019 14:25:03 +0000 (15:25 +0100)]
scsi: qla4xxx: avoid freeing unallocated dma memory

Clang -Wuninitialized notices that on is_qla40XX we never allocate any DMA
memory in get_fw_boot_info() but attempt to free it anyway:

drivers/scsi/qla4xxx/ql4_os.c:5915:7: error: variable 'buf_dma' is used uninitialized whenever 'if' condition is false
      [-Werror,-Wsometimes-uninitialized]
                if (!(val & 0x07)) {
                    ^~~~~~~~~~~~~
drivers/scsi/qla4xxx/ql4_os.c:5985:47: note: uninitialized use occurs here
        dma_free_coherent(&ha->pdev->dev, size, buf, buf_dma);
                                                     ^~~~~~~
drivers/scsi/qla4xxx/ql4_os.c:5915:3: note: remove the 'if' if its condition is always true
                if (!(val & 0x07)) {
                ^~~~~~~~~~~~~~~~~~~
drivers/scsi/qla4xxx/ql4_os.c:5885:20: note: initialize the variable 'buf_dma' to silence this warning
        dma_addr_t buf_dma;
                          ^
                           = 0

Skip the call to dma_free_coherent() here.

Fixes: 2a991c215978 ("[SCSI] qla4xxx: Boot from SAN support for open-iscsi")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: lpfc: avoid uninitialized variable warning
Arnd Bergmann [Fri, 22 Mar 2019 14:25:49 +0000 (15:25 +0100)]
scsi: lpfc: avoid uninitialized variable warning

clang -Wuninitialized incorrectly sees a variable being used without
initialization:

drivers/scsi/lpfc/lpfc_nvme.c:2102:37: error: variable 'localport' is uninitialized when used here
      [-Werror,-Wuninitialized]
                lport = (struct lpfc_nvme_lport *)localport->private;
                                                  ^~~~~~~~~
drivers/scsi/lpfc/lpfc_nvme.c:2059:38: note: initialize the variable 'localport' to silence this warning
        struct nvme_fc_local_port *localport;
                                            ^
                                             = NULL
1 error generated.

This is clearly in dead code, as the condition leading up to it is always
false when CONFIG_NVME_FC is disabled, and the variable is always
initialized when nvme_fc_register_localport() got called successfully.

Change the preprocessor conditional to the equivalent C construct, which
makes the code more readable and gets rid of the warning.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: James Smart <james.smart@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: lpfc: change snprintf to scnprintf for possible overflow
Silvio Cesare [Thu, 21 Mar 2019 16:44:32 +0000 (09:44 -0700)]
scsi: lpfc: change snprintf to scnprintf for possible overflow

Change snprintf to scnprintf. There are generally two cases where using
snprintf causes problems.

1) Uses of size += snprintf(buf, SIZE - size, fmt, ...)
In this case, if snprintf would have written more characters than what the
buffer size (SIZE) is, then size will end up larger than SIZE. In later
uses of snprintf, SIZE - size will result in a negative number, leading
to problems. Note that size might already be too large by using
size = snprintf before the code reaches a case of size += snprintf.

2) If size is ultimately used as a length parameter for a copy back to user
space, then it will potentially allow for a buffer overflow and information
disclosure when size is greater than SIZE. When the size is used to index
the buffer directly, we can have memory corruption. This also means when
size = snprintf... is used, it may also cause problems since size may become
large.  Copying to userspace is mitigated by the HARDENED_USERCOPY kernel
configuration.

The solution to these issues is to use scnprintf which returns the number of
characters actually written to the buffer, so the size variable will never
exceed SIZE.

Signed-off-by: Silvio Cesare <silvio.cesare@gmail.com>
Signed-off-by: Willy Tarreau <w@1wt.eu>
Signed-off-by: James Smart <james.smart@broadcom.com>
Cc: Dick Kennedy <dick.kennedy@broadcom.com>
Cc: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Greg KH <greg@kroah.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: ufs-mediatek: Add missing MODULE_* information
Anders Roxell [Thu, 21 Mar 2019 13:24:44 +0000 (14:24 +0100)]
scsi: ufs-mediatek: Add missing MODULE_* information

When building the ufs-mediatek module the following warning shows up:

WARNING: modpost: missing MODULE_LICENSE() in
  drivers/scsi/ufs/ufs-mediatek.o

Rework to add MODULE_LICENSE,MODULE_AUTHOR and MODULE_DESCRIPTION.

Fixes: ddd90623ce26 ("scsi: ufs-mediatek: Add UFS support for Mediatek SoC chips")
Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: ufs-mediatek: Fix platform_no_drv_owner.cocci warnings
YueHaibing [Thu, 21 Mar 2019 01:45:17 +0000 (01:45 +0000)]
scsi: ufs-mediatek: Fix platform_no_drv_owner.cocci warnings

Remove .owner field if calls are used which set it automatically
Generated by: scripts/coccinelle/api/platform_no_drv_owner.cocci

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: target: iscsi: Free conn_ops when zalloc_cpumask_var failed
tangwenji [Wed, 20 Mar 2019 14:14:44 +0000 (22:14 +0800)]
scsi: target: iscsi: Free conn_ops when zalloc_cpumask_var failed

It should not free cpumask but free conn->conn_ops when zalloc_cpumask_var
failed.

Signed-off-by: tangwenji <tang.wenji@zte.com.cn>
Reviewed-by: Mike Christie <mchristi@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: target: iscsi: Fix np_ip_proto and np_sock_type in iscsit_setup_np
tangwenji [Wed, 13 Mar 2019 14:56:38 +0000 (22:56 +0800)]
scsi: target: iscsi: Fix np_ip_proto and np_sock_type in iscsit_setup_np

In the switch, np_ip_proto and np_sock_type set different values according
to np_network_transport, and then uniformly assign values, so the previous
values are overwritten.

Signed-off-by: tangwenji <tang.wenji@zte.com.cn>
Reviewed-by: Mike Christie <mchristi@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: target: fix unsigned comparision with less than zero
Colin Ian King [Wed, 20 Mar 2019 16:37:09 +0000 (16:37 +0000)]
scsi: target: fix unsigned comparision with less than zero

Currently an error return is being assigned to an unsigned size_t varianle
and then checked if the result is less than zero which will always be
false.  Fix this by making ret ssize_t rather than a size_t.

Fixes: 0322913cab79 ("scsi: target: Add device product id and revision configfs attributes")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: Mike Christie <mchristi@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: ufs-mediatek: Avoid using ret uninitialized in ufs_mtk_setup_clocks
Nathan Chancellor [Wed, 20 Mar 2019 18:03:40 +0000 (11:03 -0700)]
scsi: ufs-mediatek: Avoid using ret uninitialized in ufs_mtk_setup_clocks

When building with -Wsometimes-uninitialized, Clang warns:

drivers/scsi/ufs/ufs-mediatek.c:112:7: warning: variable 'ret' is used
uninitialized whenever 'if' condition is false
[-Wsometimes-uninitialized]
                if (on)
                    ^~
drivers/scsi/ufs/ufs-mediatek.c:120:9: note: uninitialized use occurs
here
        return ret;
               ^~~
drivers/scsi/ufs/ufs-mediatek.c:112:3: note: remove the 'if' if its
condition is always true
                if (on)
                ^~~~~~~
drivers/scsi/ufs/ufs-mediatek.c:108:7: warning: variable 'ret' is used
uninitialized whenever 'if' condition is false
[-Wsometimes-uninitialized]
                if (!on)
                    ^~~
drivers/scsi/ufs/ufs-mediatek.c:120:9: note: uninitialized use occurs
here
        return ret;
               ^~~
drivers/scsi/ufs/ufs-mediatek.c:108:3: note: remove the 'if' if its
condition is always true
                if (!on)
                ^~~~~~~~
drivers/scsi/ufs/ufs-mediatek.c:96:9: note: initialize the variable
'ret' to silence this warning
        int ret;
               ^
                = 0
2 warnings generated.

Remove the default case and initialize ret to -EINVAL to properly fix
this warning.

Fixes: ddd90623ce26 ("scsi: ufs-mediatek: Add UFS support for Mediatek SoC chips")
Link: https://github.com/ClangBuiltLinux/linux/issues/426
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: ufs-mediatek: Make some symbols static
YueHaibing [Wed, 20 Mar 2019 14:24:58 +0000 (22:24 +0800)]
scsi: ufs-mediatek: Make some symbols static

Fix sparse warnings:

drivers/scsi/ufs/ufs-mediatek.c:19:6: warning: symbol 'ufs_mtk_cfg_unipro_cg' was not declared. Should it be static?
drivers/scsi/ufs/ufs-mediatek.c:55:5: warning: symbol 'ufs_mtk_bind_mphy' was not declared. Should it be static?
drivers/scsi/ufs/ufs-mediatek.c:342:27: warning: symbol 'ufs_mtk_of_match' was not declared. Should it be static?

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Reviewed-by: Mukesh Ojha <mojha@codeaurora.org>
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: lpfc: Fixup eq_clr_intr references
James Smart [Wed, 20 Mar 2019 17:44:22 +0000 (10:44 -0700)]
scsi: lpfc: Fixup eq_clr_intr references

Declaring interrupt clear routines as inline is bogus as they are used as
an indirect pointer.

Remove the inline references.

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>
5 years agoscsi: lpfc: Fix build error
James Bottomley [Thu, 21 Mar 2019 00:02:04 +0000 (20:02 -0400)]
scsi: lpfc: Fix build error

You can't declare a function inline in a header if it doesn't have a body
available to the compiler. So realistically you either don't declare it
inline or you make it a static inline in the header.  I think the latter
applies in this case, so this should be the fix

Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Acked-by: James Smart <james.smart@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: mvumi: Stop using plain integer as NULL pointer
YueHaibing [Sat, 16 Feb 2019 10:01:30 +0000 (18:01 +0800)]
scsi: mvumi: Stop using plain integer as NULL pointer

Fix following sparse warning:

drivers/scsi/mvumi.c:1797:48: warning: Using plain integer as NULL pointer
drivers/scsi/mvumi.c:2143:50: warning: Using plain integer as NULL pointer
drivers/scsi/mvumi.c:755:58: warning: Using plain integer as NULL pointer

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: qedi: Remove set but not used variable 'cls_sess'
YueHaibing [Sat, 16 Feb 2019 07:39:06 +0000 (07:39 +0000)]
scsi: qedi: Remove set but not used variable 'cls_sess'

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

drivers/scsi/qedi/qedi_fw.c: In function 'qedi_tmf_resp_work':
drivers/scsi/qedi/qedi_fw.c:158:28: warning:
 variable 'cls_sess' set but not used [-Wunused-but-set-variable]

drivers/scsi/qedi/qedi_fw.c: In function 'qedi_tmf_work':
drivers/scsi/qedi/qedi_fw.c:1370:28: warning:
 variable 'cls_sess' set but not used [-Wunused-but-set-variable]

It's never used since introduction.

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: be2iscsi: lpfc: fix typo
Matteo Croce [Fri, 4 Jan 2019 21:38:54 +0000 (22:38 +0100)]
scsi: be2iscsi: lpfc: fix typo

Fix spelling mistake: "lenght" -> "length"

Signed-off-by: Matteo Croce <mcroce@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: qla2xxx: Fix a small typo in qla_bsg.c
Milan P. Gandhi [Tue, 12 Mar 2019 12:53:15 +0000 (18:23 +0530)]
scsi: qla2xxx: Fix a small typo in qla_bsg.c

Fixed a typo for 'iiDMA' cmd in qla_bsg.c.

Signed-off-by: Milan P. Gandhi <mgandhi@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: qla2xxx: Fix comment alignment in qla_bsg.c
Milan P. Gandhi [Tue, 12 Mar 2019 12:51:11 +0000 (18:21 +0530)]
scsi: qla2xxx: Fix comment alignment in qla_bsg.c

Fixed a minor formatting issue with comment section in qla_bsg.c

Signed-off-by: Milan P. Gandhi <mgandhi@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: mptfusion: remove set, but not used, variables
YueHaibing [Wed, 20 Feb 2019 12:56:14 +0000 (12:56 +0000)]
scsi: mptfusion: remove set, but not used, variables

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

drivers/message/fusion/mptspi.c: In function 'mptspi_writeIOCPage4':
drivers/message/fusion/mptspi.c:262:9: warning:
 variable 'frameOffset' set but not used [-Wunused-but-set-variable]

drivers/message/fusion/mptspi.c:261:9: warning:
 variable 'req_idx' set but not used [-Wunused-but-set-variable]

They're never used and can be removed.

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: mptfusion: mark expected switch fall-through
Gustavo A. R. Silva [Mon, 11 Feb 2019 22:45:30 +0000 (16:45 -0600)]
scsi: mptfusion: mark expected switch fall-through

In preparation to enabling -Wimplicit-fallthrough, mark switch cases where
we are expecting to fall through.

This patch fixes the following warning:

drivers/message/fusion/mptbase.c: In function  mptbase_reply :
drivers/message/fusion/mptbase.c:643:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
   if (event != MPI_EVENT_EVENT_CHANGE)
      ^
drivers/message/fusion/mptbase.c:646:2: note: here
  case MPI_FUNCTION_CONFIG:
  ^~~~

Warning level 3 was used: -Wimplicit-fallthrough=3

Notice that, in this particular case, the code comment is modified in
accordance with what GCC is expecting to find.

This patch is part of the ongoing efforts to enable
-Wimplicit-fallthrough.

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: mptfusion: fix indentation issues
Colin Ian King [Thu, 7 Feb 2019 12:44:07 +0000 (12:44 +0000)]
scsi: mptfusion: fix indentation issues

There are several statements and code blocks there are incorrectly
indented. Fix these.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: mvsas: clean up a few indentation issues
Colin Ian King [Sat, 2 Feb 2019 10:30:35 +0000 (10:30 +0000)]
scsi: mvsas: clean up a few indentation issues

There are a few statements that are not indented correctly, so fix
these. Also add empty line between variable declaration and first
statements in functions. Also remove whitespace between * and mvi_dev to
clean up a cppcheck warning.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: qlogicfas408: clean up a couple of indentation issues
Colin Ian King [Wed, 23 Jan 2019 13:10:04 +0000 (13:10 +0000)]
scsi: qlogicfas408: clean up a couple of indentation issues

An if statement is indented correctly and an outb statement has a redundant
empty comment and incorrect indentation. Fix these.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: dpt_i2o: clean up indentation issues, remove spaces
Colin Ian King [Wed, 23 Jan 2019 12:53:19 +0000 (12:53 +0000)]
scsi: dpt_i2o: clean up indentation issues, remove spaces

There are several lines where the indentation has an extra space, fix this
by removing the spaces.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: atp870u: clean up code style and indentation issues
Colin Ian King [Tue, 22 Jan 2019 15:10:30 +0000 (15:10 +0000)]
scsi: atp870u: clean up code style and indentation issues

Clean up { brace to fix cppcheck warning. Remove some trailing spaces at
end of a statement.  Also clean up an indentation issue.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: ufs-mediatek: Add UFS support for Mediatek SoC chips
Stanley Chu [Sat, 16 Mar 2019 05:04:47 +0000 (13:04 +0800)]
scsi: ufs-mediatek: Add UFS support for Mediatek SoC chips

This patch adds UFS support for MediaTek SoC chips.

Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: phy: mediatek: Add UFS M-PHY driver
Stanley Chu [Sat, 16 Mar 2019 05:04:46 +0000 (13:04 +0800)]
scsi: phy: mediatek: Add UFS M-PHY driver

Add UFS M-PHY driver on MediaTek chipsets.

Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Reviewed-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: dt-bindings: ufs: Add document for ufs-mediatek
Stanley Chu [Sat, 16 Mar 2019 05:04:45 +0000 (13:04 +0800)]
scsi: dt-bindings: ufs: Add document for ufs-mediatek

Add UFS and UFS PHY node document for Mediatek SoC chips.

Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: dt-bindings: phy: Add document for phy-mtk-ufs
Stanley Chu [Sat, 16 Mar 2019 05:04:44 +0000 (13:04 +0800)]
scsi: dt-bindings: phy: Add document for phy-mtk-ufs

Add UFS M-PHY node document for MediaTek SoC chips.

Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: ufs-hisi: Re-factor ufshcd_get_pwr_dev_param
Stanley Chu [Sat, 16 Mar 2019 05:04:43 +0000 (13:04 +0800)]
scsi: ufs-hisi: Re-factor ufshcd_get_pwr_dev_param

ufshcd_get_pwr_dev_param function and ufs_dev_params struct have been
relocated to ufs core. Switch ufs-hisi to the common interface.

Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Acked-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: ufs-qcom: Re-factor ufshcd_get_pwr_dev_param
Stanley Chu [Sat, 16 Mar 2019 05:04:42 +0000 (13:04 +0800)]
scsi: ufs-qcom: Re-factor ufshcd_get_pwr_dev_param

ufshcd_get_pwr_dev_param function and ufs_dev_params struct have been
relocated to ufs core. Switch ufs-qcom to the common interface.

Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Acked-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: ufs: Introduce ufshcd_get_pwr_dev_param
Stanley Chu [Sat, 16 Mar 2019 05:04:41 +0000 (13:04 +0800)]
scsi: ufs: Introduce ufshcd_get_pwr_dev_param

ufshcd_get_pwr_dev_param defines an interface for power mode management
currently used by both ufs-qcom and ufs-hisi. Move the interface to ufs
core so every driver can take advantage of it.

Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Acked-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: smartpqi: Use HCTX_TYPE_DEFAULT for blk_mq_tag_set->map
Dongli Zhang [Tue, 12 Mar 2019 01:00:31 +0000 (09:00 +0800)]
scsi: smartpqi: Use HCTX_TYPE_DEFAULT for blk_mq_tag_set->map

Use HCTX_TYPE_DEFAULT instead of 0 to avoid hardcoding.

Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: qla2xxx: Use HCTX_TYPE_DEFAULT for blk_mq_tag_set->map
Dongli Zhang [Tue, 12 Mar 2019 01:00:30 +0000 (09:00 +0800)]
scsi: qla2xxx: Use HCTX_TYPE_DEFAULT for blk_mq_tag_set->map

Use HCTX_TYPE_DEFAULT instead of 0 to avoid hardcoding.

Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: virtio_scsi: Use HCTX_TYPE_DEFAULT for blk_mq_tag_set->map
Dongli Zhang [Tue, 12 Mar 2019 01:00:29 +0000 (09:00 +0800)]
scsi: virtio_scsi: Use HCTX_TYPE_DEFAULT for blk_mq_tag_set->map

Use HCTX_TYPE_DEFAULT instead of 0 to avoid hardcoding.

Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: core: Use HCTX_TYPE_DEFAULT for blk_mq_tag_set->map
Dongli Zhang [Tue, 12 Mar 2019 01:00:28 +0000 (09:00 +0800)]
scsi: core: Use HCTX_TYPE_DEFAULT for blk_mq_tag_set->map

Use HCTX_TYPE_DEFAULT instead of 0 to avoid hardcoding.

Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: ufs: fix a missing check of devm_reset_control_get
Kangjie Lu [Fri, 15 Mar 2019 07:11:56 +0000 (02:11 -0500)]
scsi: ufs: fix a missing check of devm_reset_control_get

devm_reset_control_get could fail, so the fix checks its return value and
passes the error code upstream in case it fails.

Signed-off-by: Kangjie Lu <kjlu@umn.edu>
Acked-by: Avri Altman <avri.altman@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: pm8001: clean up various indentation issues
Colin Ian King [Sun, 17 Mar 2019 18:15:32 +0000 (18:15 +0000)]
scsi: pm8001: clean up various indentation issues

There are several lines of code where the indentation is at an incorrect
level; fix these.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Jack Wang <jinpu.wang@cloud.ionos.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: NCR5380: Remove set but unused variable
Finn Thain [Thu, 7 Mar 2019 21:49:02 +0000 (08:49 +1100)]
scsi: NCR5380: Remove set but unused variable

Cc: Michael Schmitz <schmitzmic@gmail.com>
Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: NCR5380: Avoid compiler warning when -Wimplicit-fallthrough is enabled
Finn Thain [Thu, 7 Mar 2019 21:49:02 +0000 (08:49 +1100)]
scsi: NCR5380: Avoid compiler warning when -Wimplicit-fallthrough is enabled

Adjust comments accordingly.

Cc: Gustavo A. R. Silva <gustavo@embeddedor.com>
Cc: Michael Schmitz <schmitzmic@gmail.com>
Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: core: Remove OSD include files
Bart Van Assche [Tue, 19 Mar 2019 03:06:42 +0000 (20:06 -0700)]
scsi: core: Remove OSD include files

All code from which the OSD include files were included has been removed.
Hence also remove the include files themselves. See also commit
19fcae3d4f2d ("scsi: remove the SCSI OSD library").

Cc: Christoph Hellwig <hch@lst.de>
Cc: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: core: remove the scsi_ioctl_reset export
Christoph Hellwig [Fri, 15 Mar 2019 08:44:19 +0000 (09:44 +0100)]
scsi: core: remove the scsi_ioctl_reset export

This function is only used inside the SCSI midlayer.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: core: reshuffle no_scsi2_lun_in_cdb for better alignment
Hannes Reinecke [Tue, 26 Feb 2019 15:00:39 +0000 (16:00 +0100)]
scsi: core: reshuffle no_scsi2_lun_in_cdb for better alignment

no_scsi2_lun_in_cdb declares a new bitfield, but we should rather move
it to the existing bitfield for better alignment.

Signed-off-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: lpfc: Update lpfc version to 12.2.0.1
James Smart [Tue, 12 Mar 2019 23:30:33 +0000 (16:30 -0700)]
scsi: lpfc: Update lpfc version to 12.2.0.1

Update lpfc version to 12.2.0.0

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>
5 years agoscsi: lpfc: Update Copyright in driver version
James Smart [Tue, 12 Mar 2019 23:30:32 +0000 (16:30 -0700)]
scsi: lpfc: Update Copyright in driver version

Revise driver copyright message to show 2019.  Update couple of files
modified by 12.2.0.1 patch set.

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>
5 years agoscsi: lpfc: Enhance 6072 log string
James Smart [Tue, 12 Mar 2019 23:30:31 +0000 (16:30 -0700)]
scsi: lpfc: Enhance 6072 log string

Update the 6072 log message string to print the whole 32 bits of the
extended status.

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>
5 years agoscsi: lpfc: Fix duplicate log message numbers
James Smart [Tue, 12 Mar 2019 23:30:30 +0000 (16:30 -0700)]
scsi: lpfc: Fix duplicate log message numbers

Driver had duplicated log message numbers making debug difficult.

Make all messages unique.

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>
5 years agoscsi: lpfc: Specify node affinity for queue memory allocation
James Smart [Tue, 12 Mar 2019 23:30:29 +0000 (16:30 -0700)]
scsi: lpfc: Specify node affinity for queue memory allocation

Change the SLI4 queue creation code to use NUMA node based memory
allocation based on the cpu the queues will be related to.

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>
5 years agoscsi: lpfc: Reduce memory footprint for lpfc_queue
James Smart [Tue, 12 Mar 2019 23:30:28 +0000 (16:30 -0700)]
scsi: lpfc: Reduce memory footprint for lpfc_queue

Currently the driver maintains a sideband structure which has a pointer for
each queue element. However, at 8 bytes per pointer, and up to 4k elements
per queue, and 100s of queues, this can take up a lot of memory.

Convert the driver to using an access routine that calculates the element
address based on its index rather than using the pointer table.

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>
5 years agoscsi: lpfc: Add loopback testing to trunking mode
James Smart [Tue, 12 Mar 2019 23:30:27 +0000 (16:30 -0700)]
scsi: lpfc: Add loopback testing to trunking mode

When in trunking mode, the adapter can be placed into diagnostic mode and
each link in the trunk tested via loopback.

Add support to the driver to perform per-link loopback testing when in
trunking mode.

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>
5 years agoscsi: lpfc: Fix link speed reporting for 4-link trunk
James Smart [Tue, 12 Mar 2019 23:30:26 +0000 (16:30 -0700)]
scsi: lpfc: Fix link speed reporting for 4-link trunk

Driver is using uint16_t and is encountering an overflow of the 16bits when
calculating link speed.

Fix by using a u32 type.

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>
5 years agoscsi: lpfc: Fix handling of trunk links state reporting
James Smart [Tue, 12 Mar 2019 23:30:25 +0000 (16:30 -0700)]
scsi: lpfc: Fix handling of trunk links state reporting

If all the trunk links drop and a single link resumes, the link_state is
not properly reported. When trunked, the driver receives two async
cqes. One acqe reports the trunk link states, which the driver records.
The other cqe reports the overall state of the trunk. In the failing case,
the trunk link state acqe preceeds the overall trunk link state acqe. The
trunk link state acqe, as it's an "up" transition, calls a code path which
ensures a down transition before moving to the up state.  The down
transition had a side effect of clearing the just-saved trunk link states.

Fix by not clearing the trunk link states if we've already transitioned
to a down state.

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>
5 years agoscsi: lpfc: Fix protocol support on G6 and G7 adapters
James Smart [Tue, 12 Mar 2019 23:30:24 +0000 (16:30 -0700)]
scsi: lpfc: Fix protocol support on G6 and G7 adapters

Invalid test is allowing Loop to be a supported topology on G6 and G7
adapters. The chips do not support loop as their link speeds prohibit loop
per standard.

Correct the conditional so that loop is not reported.

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>
5 years agoscsi: lpfc: Correct boot bios information to FDMI registration
James Smart [Tue, 12 Mar 2019 23:30:23 +0000 (16:30 -0700)]
scsi: lpfc: Correct boot bios information to FDMI registration

The driver is currently reporting the firmware revision not the actual boot
bios version in FDMI data.

Modify the driver to obtain the boot bios version from the adapter and use
that data in the FMDI data sent to the switch.

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>
5 years agoscsi: lpfc: Fix HDMI2 registration string for symbolic name
James Smart [Tue, 12 Mar 2019 23:30:22 +0000 (16:30 -0700)]
scsi: lpfc: Fix HDMI2 registration string for symbolic name

The switch is rejecting FDMI2 registration for symbolic name.  There is a
"\n" in the name string, which the switch dislikes thus rejects the
registration.

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>
5 years agoscsi: lpfc: Fix fc4type information for FDMI
James Smart [Tue, 12 Mar 2019 23:30:21 +0000 (16:30 -0700)]
scsi: lpfc: Fix fc4type information for FDMI

The driver is reporting support for NVME even when not configured for NVME
operation.

Fix (and make more readable) when NVME protocol support is indicated.

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>
5 years agoscsi: lpfc: Fix FDMI manufacturer attribute value
James Smart [Tue, 12 Mar 2019 23:30:20 +0000 (16:30 -0700)]
scsi: lpfc: Fix FDMI manufacturer attribute value

The FDMI manufacturer value being reported on Linux is inconsistent with
other OS's.

Set the value to "Emulex Corporation" for consistency.

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>
5 years agoscsi: lpfc: Fix io lost on host resets
James Smart [Tue, 12 Mar 2019 23:30:19 +0000 (16:30 -0700)]
scsi: lpfc: Fix io lost on host resets

If the driver undergoes repeated host resets it starts losing exchange
structures and eventually returns SCSI_MLQUEUE_HOST_BUSY and does not
recover. The offline path is not reclaiming the outstanding ios on the fcp
pring txcmplq before calling lpfc_destroy_multixripool, which causes the
txmcplq to be reinit and the resources lost.

Flush the fcp rings before destroying the multixripools.

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>
5 years agoscsi: lpfc: Fix mailbox hang on adapter init
James Smart [Tue, 12 Mar 2019 23:30:18 +0000 (16:30 -0700)]
scsi: lpfc: Fix mailbox hang on adapter init

The adapter initialization sequence enables interrupts, initializes the
adapter link_state to LINK_DOWN, then issues commands to initialize the
adapter. The interrupt handler on the adapter validates the link_state (has
to be at least LINK_DOWN) and if invalid, will discard the interrupting
event.

In most cases, there is not a command completion, thus an interrupt until
the initialization commands have been sent which is post the setting of
state to LINK_DOWN.  However, in cases of firmware reset, the reset will
modify the link_state to an invalid value (indicating a reset of the
adapter) and there occasionally are cases where the adapter will generate
an asynchronous event which shares the eq/cq used for mailbox commands. In
the failure case, an interrupt is generated immediately after enabling them
due to the async event.  As link_state is invalid, the eq is list and the
CQ not serviced.  At this point link_state is initialized and the mailbox
command sent.  As the CQ has not been serviced, it is not armed, so no
interrupt event is generated when the mailbox command completes.

Modify the initialization sequence so that interrupts are enabled after
link_state is properly initialized, which avoids the race condition with
the async event.

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>
5 years agoscsi: lpfc: Fix driver crash in target reset handler
James Smart [Tue, 12 Mar 2019 23:30:17 +0000 (16:30 -0700)]
scsi: lpfc: Fix driver crash in target reset handler

It's possible for the scsi error handler to fire and call the target reset
handler simultaneously to the driver logging out and relogging into the
system.  If hit just right, the re-login may not have fully re-established
the remote port and the rdata->pnod structure may be null.

Check for NULL in the reset handler and return failure if NULL.

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>
5 years agoscsi: lpfc: Correct localport timeout duration error
James Smart [Tue, 12 Mar 2019 23:30:16 +0000 (16:30 -0700)]
scsi: lpfc: Correct localport timeout duration error

Current code incorrectly specifies a completion wait timeout duration in 5
jiffies, when it should have been 5 seconds.

Fix the adjust for units for the completion timeout call.

[mkp: manual merge]

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>
5 years agoscsi: lpfc: Convert bootstrap mbx polling from msleep to udelay
James Smart [Tue, 12 Mar 2019 23:30:15 +0000 (16:30 -0700)]
scsi: lpfc: Convert bootstrap mbx polling from msleep to udelay

Current code is using msleep when polling for hw ready. Unfortunately the
msleep routine isn't very accurate on rescheduling. In fact, on a busy
systems which reset the adapter, it became 10s of seconds before it was
rescheduled.

Fix by busy waiting using udelay. As we're now busy waiting, significantly
reduce the wait time so that we can exit the pool loop as soon as possible.

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>
5 years agoscsi: lpfc: Coordinate adapter error handling with offline handling
James Smart [Tue, 12 Mar 2019 23:30:14 +0000 (16:30 -0700)]
scsi: lpfc: Coordinate adapter error handling with offline handling

The driver periodically checks for adapter error in a background thread. If
the thread detects an error, the adapter will be reset including the
deletion and reallocation of workqueues on the adapter.  Simultaneously,
there may be a user-space request to offline the adapter which may try to
do many of the same steps, in parallel, on a different thread. As memory
was deallocated while unexpected, the parallel offline request hit a bad
pointer.

Add coordination between the two threads.  The error recovery thread has
precedence. So, when an error is detected, a flag is set on the adapter to
indicate the error thread is terminating the adapter. But, before doing
that work, it will look for a flag that is set by the offline flow, and if
set, will wait for it to complete before then processing the error handling
path.  Similarly, in the offline thread, it first checks for whether the
error thread is resetting the adapter, and if so, will then wait for the
error thread to finish. Only after it has finished, will it set its flag
and offline the adapter.

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>
5 years agoscsi: lpfc: Stop adapter if pci errors detected
James Smart [Tue, 12 Mar 2019 23:30:13 +0000 (16:30 -0700)]
scsi: lpfc: Stop adapter if pci errors detected

In a couple of cases, the driver detected a pci error (via pci device state
or via failed register reads) but didn't take any action to disable the
device.  Additionally, the driver is ignoring the status of pci
configuration space reads.

Having the driver take the adapter offline whenever the pci error is
detected.  Pay attention to pci_config_space_read status and return failure
if an error is seen.

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>
5 years agoscsi: lpfc: Fix deadlock due to nested hbalock call
James Smart [Tue, 12 Mar 2019 23:30:12 +0000 (16:30 -0700)]
scsi: lpfc: Fix deadlock due to nested hbalock call

If an adapter fails, causing a board reset, the board reset routine
lpfc_hba_down_s4() takes the hbalock out then calls
lpfc_nvmet_ctxbuf_post() who then tries to take out the same lock.  As the
context lists are now protected under the buf_list_locks, there is no need
for the hbalock to be held by the board reset routine.

Fix by no longer taking the hbalock in the board reset routine.

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>
5 years agoscsi: lpfc: Fix nvmet handling of first burst cmd
James Smart [Tue, 12 Mar 2019 23:30:11 +0000 (16:30 -0700)]
scsi: lpfc: Fix nvmet handling of first burst cmd

With negative test injection, the driver is receiving a command with first
burst enabled, meaning Sequence initiative is not passed with the command
frame. The driver notes the condition and discards the frame.  However the
driver calls the incorrect buffer free routine, resulting in a NULL pointer
reference.

For hbq buffer free, convert to using lpfc_rq_buf_free().

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>
5 years agoscsi: lpfc: Fix lpfc_nvmet_mrq attribute handling when 0
James Smart [Tue, 12 Mar 2019 23:30:10 +0000 (16:30 -0700)]
scsi: lpfc: Fix lpfc_nvmet_mrq attribute handling when 0

Currently, when lpfc_nvmet_mrq is 0 it could mean 2 different things
depending on when its looked at. If at module load time it specifies the
default number of hardware queues to allocate, with 0 meaning default to
the number of CPUs. But post module load, a value of zero means to disable
mrq use.

Changed the driver so that enablement of mrq is based on whether nvme
target mode is enabled or not. When enabled, mrq is enabled.  Thus, the
cfg_nvemt_mrq field only specifies the number of mrq queues to enable, with
0 defaulting to the number of cpus.

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>
5 years agoscsi: lpfc: Fix nvmet async receive buffer replenishment
James Smart [Tue, 12 Mar 2019 23:30:09 +0000 (16:30 -0700)]
scsi: lpfc: Fix nvmet async receive buffer replenishment

Under circustances with high load, the driver is running out of async
receive buffers which may result in one of the following messages:

0:6401 RQE Error x13, posted 226 err_cnt 0: 925c6050 925c604e 925c5d54

or

0:2885 Port Status Event: port status reg 0x81800000,
       port smphr reg 0xc000, error 1=0x52004a01, error 2=0x0

The driver is waiting for full io completion before returning receive
buffers to the adapter. There is no need for such a relationship.

Whenever a new command is received from the wire, the driver will have two
contexts - an io context (ctxp) and a receive buffer context.  In current
code, the receive buffer context stays 1:1 with the io and won't be
reposted to the hardware until the io completes. There is no need for such
a relationship.

Change the driver so that up on successful handing of the command to the
transport, where the transport has copied what it needed thus the buffer is
returned to the driver, have the driver immediately repost the buffer to
the hardware. If the command cannot be successfully handed to the transport
as transport resources are temporarily busy, have the driver allocate a new
and separate receive buffer and post it to the hardware so that hardware
can continue while the command is queued for the transport.

When an io is complete, the transport returns the io context to the driver,
and the driver may be waiting for more contexts, thus immediately reuse the
io context. In this path, there was a buffer posted when the receive buffer
was queued waiting for an io context so a replacement is not needed in the
new code additions. Thus, exempt this the context reuse case from the
buffer reposting.

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>
5 years agoscsi: lpfc: Fix location of SCSI ktime counters
James Smart [Tue, 12 Mar 2019 23:30:08 +0000 (16:30 -0700)]
scsi: lpfc: Fix location of SCSI ktime counters

The debug ktime counters that trace an io were inadvertently not placed in
the common section of an io buffer. Thus, they generate an invalid opcode
error when accessed.

Move the ktime counters into the common area.

Fixes: 0794d601d174 ("scsi: lpfc: Implement common IO buffers between NVME and SCSI")
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>
5 years agoscsi: lpfc: Fix SLI3 commands being issued on SLI4 devices
James Smart [Tue, 12 Mar 2019 23:30:07 +0000 (16:30 -0700)]
scsi: lpfc: Fix SLI3 commands being issued on SLI4 devices

During debug, it was seen that the driver is issuing commands specific to
SLI3 on SLI4 devices. Although the adapter correctly rejected the command,
this should not be done.

Revise the code to stop sending these commands on a SLI4 adapter.

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>
5 years agoscsi: lpfc: Fix use-after-free mailbox cmd completion
James Smart [Tue, 12 Mar 2019 23:30:06 +0000 (16:30 -0700)]
scsi: lpfc: Fix use-after-free mailbox cmd completion

When unloading the driver, mailbox commands may be sent without holding a
reference on the ndlp. By the time the mailbox command completes, the ndlp
may have reduced its ref counts and been freed.  The problem was reported
by KASAN.

While unregistering due to driver unload, have the completion noop'd by
setting the ndlp context NULL'd. Due to the unload, no further action was
necessary.  Also, while reviewing this path, the generic nulling of the
context after handling should be slightly moved.

Reported by: Bart Van Assche <bvanassche@acm.org>
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>
5 years agoscsi: lpfc: Resolve irq-unsafe lockdep heirarchy warning in lpfc_io_free
James Smart [Tue, 12 Mar 2019 23:30:05 +0000 (16:30 -0700)]
scsi: lpfc: Resolve irq-unsafe lockdep heirarchy warning in lpfc_io_free

A patch in the 12.2.0.0 set caused a new lockdep warning:

  WARNING: SOFTIRQ-safe -> SOFTIRQ-unsafe lock order detected
  5.0.0-rc8-next-20190301-dbg+ #1 Not tainted

  Possible interrupt unsafe locking scenario:
       CPU0                    CPU1
       ----                    ----
  lock(&(&qp->io_buf_list_put_lock)->rlock);
                               local_irq_disable();
                               lock(&(&phba->hbalock)->rlock);
                               lock(&(&qp->io_buf_list_put_lock)->rlock);
  <Interrupt>
    lock(&(&phba->hbalock)->rlock);

see: https://www.spinics.net/lists/linux-scsi/msg128389.html

In summary, the new patch added taking the io_buf_list_put_lock while under
an irq-disabled hbalock. This created a lock heirarchy dependent upon irq
being disabled, and there are paths that take the io_buf_list_put_lock
without disabling irq.

Looking at the lpfc_io_free routine, which is where the new heirarchy was
introduced, there is no reason to be taking out the hbalock and raising
irq, as the functionality is replaced by the io_buf_list_xxx locks.

Resolve by removing the hbalock/irq calls in lpfc_io_free.

Fixes: 5e5b511d8bfa ("scsi: lpfc: Partition XRI buffer list across Hardware Queues")
Reported-by: Bart Van Assche <bvanassche@acm.org>
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>
5 years agoscsi: lpfc: Resolve inconsistent check of hdwq in lpfc_scsi_cmd_iocb_cmpl
James Smart [Tue, 12 Mar 2019 23:30:04 +0000 (16:30 -0700)]
scsi: lpfc: Resolve inconsistent check of hdwq in lpfc_scsi_cmd_iocb_cmpl

A prior patch which added support for non-uniform allocation of MSIX
vectors now causes a smatch complaint:

 drivers/scsi/lpfc/lpfc_scsi.c:3674 lpfc_scsi_cmd_iocb_cmpl()
   error: we previously assumed 'phba->sli4_hba.hdwq' could be
          null (see line 3667)

Resolve by removing the unnecessary check for a NULL hdwq table.

Fixes 6a828b0f6192: ("scsi: lpfc: Support non-uniform allocation of MSIX vectors to hardware queues")
Reported-by: Dan Carpenter <dan.carpenter@oracle.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>
5 years agoscsi: qla2xxx: Update driver version to 10.01.00.15-k
Himanshu Madhani [Tue, 12 Mar 2019 18:08:23 +0000 (11:08 -0700)]
scsi: qla2xxx: Update driver version to 10.01.00.15-k

This version includes support for ISP28XX.

Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: qla2xxx: Secure flash update support for ISP28XX
Michael Hernandez [Tue, 12 Mar 2019 18:08:22 +0000 (11:08 -0700)]
scsi: qla2xxx: Secure flash update support for ISP28XX

This patch adds support for Secure flash update with ISP28xx.

Signed-off-by: Michael Hernandez <mhernandez@marvell.com>
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: qla2xxx: Add 28xx flash primary/secondary status/image mechanism
Joe Carnuccio [Tue, 12 Mar 2019 18:08:21 +0000 (11:08 -0700)]
scsi: qla2xxx: Add 28xx flash primary/secondary status/image mechanism

Includes the following:
- correction to 27xx image status struct;
- factoring of 27xx image status validating routines to make common;
- image status generation compare that works across zero wrap;
- bsg interface to report current active images (as loaded by driver).

Signed-off-by: Joe Carnuccio <joe.carnuccio@cavium.com>
Signed-off-by: Mike Hernandez <mhernandez@marvell.com>
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: qla2xxx: Simplification of register address used in qla_tmpl.c
Joe Carnuccio [Tue, 12 Mar 2019 18:08:20 +0000 (11:08 -0700)]
scsi: qla2xxx: Simplification of register address used in qla_tmpl.c

Reduce stack space on each fwdt routine by eliminating local variable reg.

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>
5 years agoscsi: qla2xxx: Correction and improvement to fwdt processing
Joe Carnuccio [Tue, 12 Mar 2019 18:08:19 +0000 (11:08 -0700)]
scsi: qla2xxx: Correction and improvement to fwdt processing

This patch cleans up and fixes firmware dump template processing. These
changes are added to support newer features for ISP27XX/ISP28XX.

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>
5 years agoscsi: qla2xxx: Update flash read/write routine
Joe Carnuccio [Tue, 12 Mar 2019 18:08:18 +0000 (11:08 -0700)]
scsi: qla2xxx: Update flash read/write routine

This patch makes following changes to flash access routines:

- update return type for read_optrom
- use void instead of uint32_t * for buffer parameter in read
  and write optrom routines
- fix flash/nvram addressing

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>
5 years agoscsi: qla2xxx: Add support for multiple fwdump templates/segments
Joe Carnuccio [Tue, 12 Mar 2019 18:08:17 +0000 (11:08 -0700)]
scsi: qla2xxx: Add support for multiple fwdump templates/segments

This patch adds multipe firmware dump template and segments support for
ISP27XX/28XX.

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>
5 years agoscsi: qla2xxx: Cleanups for NVRAM/Flash read/write path
Joe Carnuccio [Tue, 12 Mar 2019 18:08:16 +0000 (11:08 -0700)]
scsi: qla2xxx: Cleanups for NVRAM/Flash read/write path

This patch does following:

 - Clean up NVRAM code.
 - Optimizes reading of primary/secondary flash image validation.
 - Remove 0xff mask and make correct width in FLT structure.
 - Use endian macros to assign static fields in fwdump header.
 - Correct fdwt checksum calculation.
 - Simplify ql_dump_buffer() interface usage.
 - Add endianizers to 27xx firmware image validator.
 - fixes compiler warnings for big endian architecture.

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>
5 years agoscsi: qla2xxx: Correctly report max/min supported speeds
Joe Carnuccio [Tue, 12 Mar 2019 18:08:15 +0000 (11:08 -0700)]
scsi: qla2xxx: Correctly report max/min supported speeds

This patch fixes reported speed for min_link and max_supported speed. Also
rename sysfs nodes link_speed and max_supported to be consistent with
{min|max}_suuported_speed.

Signed-off-by: Joe Carnuccio <joe.carnuccio@cavium.com>
Signed-off-by: Mike Hernandez <mhernandez@marvell.com>
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: qla2xxx: Add Serdes support for ISP28XX
Joe Carnuccio [Tue, 12 Mar 2019 18:08:14 +0000 (11:08 -0700)]
scsi: qla2xxx: Add Serdes support for ISP28XX

This patch adds sysfs node for serdes_version and also cleans up port_speed
display.

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>
5 years agoscsi: qla2xxx: Add Device ID for ISP28XX
Joe Carnuccio [Tue, 12 Mar 2019 18:08:13 +0000 (11:08 -0700)]
scsi: qla2xxx: Add Device ID for ISP28XX

This patch adds PCI device ID ISP28XX for Gen7 support.  Also signature
determination for primary/secondary flash image for ISP27XX/28XX is aded as
part of Gen7 support.

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>
5 years agoscsi: qla2xxx: Fix routine qla27xx_dump_{mpi|ram}()
Joe Carnuccio [Tue, 12 Mar 2019 18:08:12 +0000 (11:08 -0700)]
scsi: qla2xxx: Fix routine qla27xx_dump_{mpi|ram}()

This patch fixes qla27xx_dump_{mpi|ram} api for ISP27XX.

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>