commit 15600159bcc6abbeae6b33a849bef90dca28b78f Author: Martin K. Petersen Date: Thu Jan 26 22:06:08 2023 -0500 scsi: Revert "scsi: core: map PQ=1, PDT=other values to SCSI_SCAN_TARGET_PRESENT" This reverts commit 948e922fc44611ee2de0c89583ca958cb5307d36. Not all targets that return PQ=1 and PDT=0 should be ignored. While the SCSI spec is vague in this department, there appears to be a critical mass of devices which rely on devices being accessible with this combination of reported values. Fixes: 948e922fc446 ("scsi: core: map PQ=1, PDT=other values to SCSI_SCAN_TARGET_PRESENT") Link: https://lore.kernel.org/r/yq1lelrleqr.fsf@ca-mkp.ca.oracle.com Acked-by: Bart Van Assche Acked-by: Martin Wilck Acked-by: Hannes Reinecke Signed-off-by: Martin K. Petersen commit 2542fc9578d49b3b376231269d4c7c7d4cffd62a Author: Bart Van Assche Date: Wed Jan 25 11:43:11 2023 -0800 scsi: core: Fix the scsi_device_put() might_sleep annotation Although most calls of scsi_device_put() happen from non-atomic context, alua_rtpg_queue() calls this function from atomic context if alua_rtpg_queue() itself is called from atomic context. alua_rtpg_queue() is always called from contexts where the caller must hold at least one reference to the scsi device in question. This means that the reference taken by alua_rtpg_queue() itself can't be the last one, and thus can be dropped without entering the code path in which scsi_device_put() might actually sleep. Hence move the might_sleep() annotation from scsi_device_put() into scsi_device_dev_release(). [1] https://lore.kernel.org/linux-scsi/b49e37d5-edfb-4c56-3eeb-62c7d5855c00@linux.ibm.com/ [2] https://lore.kernel.org/linux-scsi/55c35e64-a7d4-9072-46fd-e8eae6a90e96@linux.ibm.com/ Note: a significant part of the above description was written by Martin Wilck. Fixes: f93ed747e2c7 ("scsi: core: Release SCSI devices synchronously") Cc: Martin Wilck Cc: Steffen Maier Cc: Hannes Reinecke Cc: Sachin Sant Cc: Benjamin Block Reported-by: Steffen Maier Signed-off-by: Bart Van Assche Reviewed-by: Martin Wilck Link: https://lore.kernel.org/r/20230125194311.249553-1-bvanassche@acm.org Signed-off-by: Martin K. Petersen commit 0bfe63d075789456e9589457b29d6f9c279e3252 Author: Bart Van Assche Date: Wed Jan 18 10:05:57 2023 -0800 scsi: device_handler: alua: Remove a might_sleep() annotation The might_sleep() annotation in alua_rtpg_queue() is not correct since the command completion code may call this function from atomic context. Calling alua_rtpg_queue() from atomic context in the command completion path is fine since request submitters must hold an sdev reference until command execution has completed. This patch fixes the following kernel complaint: BUG: sleeping function called from invalid context at drivers/scsi/device_handler/scsi_dh_alua.c:992 Call Trace: dump_stack_lvl+0xac/0x100 __might_resched+0x284/0x2c8 alua_rtpg_queue+0x3c/0x98 [scsi_dh_alua] alua_check+0x122/0x250 [scsi_dh_alua] alua_check_sense+0x172/0x228 [scsi_dh_alua] scsi_check_sense+0x8a/0x2e0 scsi_decide_disposition+0x286/0x298 scsi_complete+0x6a/0x108 blk_complete_reqs+0x6e/0x88 __do_softirq+0x13e/0x6b8 __irq_exit_rcu+0x14a/0x170 irq_exit_rcu+0x22/0x50 do_ext_irq+0x10a/0x1d0 Link: https://lore.kernel.org/r/20230118180557.1212577-1-bvanassche@acm.org Reported-by: Steffen Maier Reviewed-by: Martin Wilck Tested-by: Steffen Maier Signed-off-by: Bart Van Assche Signed-off-by: Martin K. Petersen commit f484a794e4ee2a9ce61f52a78e810ac45f3fe3b3 Author: Mike Christie Date: Tue Jan 17 13:39:37 2023 -0600 scsi: iscsi_tcp: Fix UAF during login when accessing the shost ipaddress If during iscsi_sw_tcp_session_create() iscsi_tcp_r2tpool_alloc() fails, userspace could be accessing the host's ipaddress attr. If we then free the session via iscsi_session_teardown() while userspace is still accessing the session we will hit a use after free bug. Set the tcp_sw_host->session after we have completed session creation and can no longer fail. Link: https://lore.kernel.org/r/20230117193937.21244-3-michael.christie@oracle.com Signed-off-by: Mike Christie Reviewed-by: Lee Duncan Acked-by: Ding Hui Signed-off-by: Martin K. Petersen commit 6f1d64b13097e85abda0f91b5638000afc5f9a06 Author: Mike Christie Date: Tue Jan 17 13:39:36 2023 -0600 scsi: iscsi_tcp: Fix UAF during logout when accessing the shost ipaddress Bug report and analysis from Ding Hui. During iSCSI session logout, if another task accesses the shost ipaddress attr, we can get a KASAN UAF report like this: [ 276.942144] BUG: KASAN: use-after-free in _raw_spin_lock_bh+0x78/0xe0 [ 276.942535] Write of size 4 at addr ffff8881053b45b8 by task cat/4088 [ 276.943511] CPU: 2 PID: 4088 Comm: cat Tainted: G E 6.1.0-rc8+ #3 [ 276.943997] Hardware name: VMware, Inc. VMware Virtual Platform/440BX Desktop Reference Platform, BIOS 6.00 11/12/2020 [ 276.944470] Call Trace: [ 276.944943] [ 276.945397] dump_stack_lvl+0x34/0x48 [ 276.945887] print_address_description.constprop.0+0x86/0x1e7 [ 276.946421] print_report+0x36/0x4f [ 276.947358] kasan_report+0xad/0x130 [ 276.948234] kasan_check_range+0x35/0x1c0 [ 276.948674] _raw_spin_lock_bh+0x78/0xe0 [ 276.949989] iscsi_sw_tcp_host_get_param+0xad/0x2e0 [iscsi_tcp] [ 276.951765] show_host_param_ISCSI_HOST_PARAM_IPADDRESS+0xe9/0x130 [scsi_transport_iscsi] [ 276.952185] dev_attr_show+0x3f/0x80 [ 276.953005] sysfs_kf_seq_show+0x1fb/0x3e0 [ 276.953401] seq_read_iter+0x402/0x1020 [ 276.954260] vfs_read+0x532/0x7b0 [ 276.955113] ksys_read+0xed/0x1c0 [ 276.955952] do_syscall_64+0x38/0x90 [ 276.956347] entry_SYSCALL_64_after_hwframe+0x63/0xcd [ 276.956769] RIP: 0033:0x7f5d3a679222 [ 276.957161] Code: c0 e9 b2 fe ff ff 50 48 8d 3d 32 c0 0b 00 e8 a5 fe 01 00 0f 1f 44 00 00 f3 0f 1e fa 64 8b 04 25 18 00 00 00 85 c0 75 10 0f 05 <48> 3d 00 f0 ff ff 77 56 c3 0f 1f 44 00 00 48 83 ec 28 48 89 54 24 [ 276.958009] RSP: 002b:00007ffc864d16a8 EFLAGS: 00000246 ORIG_RAX: 0000000000000000 [ 276.958431] RAX: ffffffffffffffda RBX: 0000000000020000 RCX: 00007f5d3a679222 [ 276.958857] RDX: 0000000000020000 RSI: 00007f5d3a4fe000 RDI: 0000000000000003 [ 276.959281] RBP: 00007f5d3a4fe000 R08: 00000000ffffffff R09: 0000000000000000 [ 276.959682] R10: 0000000000000022 R11: 0000000000000246 R12: 0000000000020000 [ 276.960126] R13: 0000000000000003 R14: 0000000000000000 R15: 0000557a26dada58 [ 276.960536] [ 276.961357] Allocated by task 2209: [ 276.961756] kasan_save_stack+0x1e/0x40 [ 276.962170] kasan_set_track+0x21/0x30 [ 276.962557] __kasan_kmalloc+0x7e/0x90 [ 276.962923] __kmalloc+0x5b/0x140 [ 276.963308] iscsi_alloc_session+0x28/0x840 [scsi_transport_iscsi] [ 276.963712] iscsi_session_setup+0xda/0xba0 [libiscsi] [ 276.964078] iscsi_sw_tcp_session_create+0x1fd/0x330 [iscsi_tcp] [ 276.964431] iscsi_if_create_session.isra.0+0x50/0x260 [scsi_transport_iscsi] [ 276.964793] iscsi_if_recv_msg+0xc5a/0x2660 [scsi_transport_iscsi] [ 276.965153] iscsi_if_rx+0x198/0x4b0 [scsi_transport_iscsi] [ 276.965546] netlink_unicast+0x4d5/0x7b0 [ 276.965905] netlink_sendmsg+0x78d/0xc30 [ 276.966236] sock_sendmsg+0xe5/0x120 [ 276.966576] ____sys_sendmsg+0x5fe/0x860 [ 276.966923] ___sys_sendmsg+0xe0/0x170 [ 276.967300] __sys_sendmsg+0xc8/0x170 [ 276.967666] do_syscall_64+0x38/0x90 [ 276.968028] entry_SYSCALL_64_after_hwframe+0x63/0xcd [ 276.968773] Freed by task 2209: [ 276.969111] kasan_save_stack+0x1e/0x40 [ 276.969449] kasan_set_track+0x21/0x30 [ 276.969789] kasan_save_free_info+0x2a/0x50 [ 276.970146] __kasan_slab_free+0x106/0x190 [ 276.970470] __kmem_cache_free+0x133/0x270 [ 276.970816] device_release+0x98/0x210 [ 276.971145] kobject_cleanup+0x101/0x360 [ 276.971462] iscsi_session_teardown+0x3fb/0x530 [libiscsi] [ 276.971775] iscsi_sw_tcp_session_destroy+0xd8/0x130 [iscsi_tcp] [ 276.972143] iscsi_if_recv_msg+0x1bf1/0x2660 [scsi_transport_iscsi] [ 276.972485] iscsi_if_rx+0x198/0x4b0 [scsi_transport_iscsi] [ 276.972808] netlink_unicast+0x4d5/0x7b0 [ 276.973201] netlink_sendmsg+0x78d/0xc30 [ 276.973544] sock_sendmsg+0xe5/0x120 [ 276.973864] ____sys_sendmsg+0x5fe/0x860 [ 276.974248] ___sys_sendmsg+0xe0/0x170 [ 276.974583] __sys_sendmsg+0xc8/0x170 [ 276.974891] do_syscall_64+0x38/0x90 [ 276.975216] entry_SYSCALL_64_after_hwframe+0x63/0xcd We can easily reproduce by two tasks: 1. while :; do iscsiadm -m node --login; iscsiadm -m node --logout; done 2. while :; do cat \ /sys/devices/platform/host*/iscsi_host/host*/ipaddress; done iscsid | cat --------------------------------+--------------------------------------- |- iscsi_sw_tcp_session_destroy | |- iscsi_session_teardown | |- device_release | |- iscsi_session_release ||- dev_attr_show |- kfree | |- show_host_param_ | ISCSI_HOST_PARAM_IPADDRESS | |- iscsi_sw_tcp_host_get_param | |- r/w tcp_sw_host->session (UAF) |- iscsi_host_remove | |- iscsi_host_free | Fix the above bug by splitting the session removal into 2 parts: 1. removal from iSCSI class which includes sysfs and removal from host tracking. 2. freeing of session. During iscsi_tcp host and session removal we can remove the session from sysfs then remove the host from sysfs. At this point we know userspace is not accessing the kernel via sysfs so we can free the session and host. Link: https://lore.kernel.org/r/20230117193937.21244-2-michael.christie@oracle.com Signed-off-by: Mike Christie Reviewed-by: Lee Duncan Acked-by: Ding Hui Signed-off-by: Martin K. Petersen commit ba81043753fffbc2ad6e0c5ff2659f12ac2f46b4 Author: Johan Hovold Date: Mon Jan 16 17:12:01 2023 +0100 scsi: ufs: core: Fix devfreq deadlocks There is a lock inversion and rwsem read-lock recursion in the devfreq target callback which can lead to deadlocks. Specifically, ufshcd_devfreq_scale() already holds a clk_scaling_lock read lock when toggling the write booster, which involves taking the dev_cmd mutex before taking another clk_scaling_lock read lock. This can lead to a deadlock if another thread: 1) tries to acquire the dev_cmd and clk_scaling locks in the correct order, or 2) takes a clk_scaling write lock before the attempt to take the clk_scaling read lock a second time. Fix this by dropping the clk_scaling_lock before toggling the write booster as was done before commit 0e9d4ca43ba8 ("scsi: ufs: Protect some contexts from unexpected clock scaling"). While the devfreq callbacks are already serialised, add a second serialising mutex to handle the unlikely case where a callback triggered through the devfreq sysfs interface is racing with a request to disable clock scaling through the UFS controller 'clkscale_enable' sysfs attribute. This could otherwise lead to the write booster being left disabled after having disabled clock scaling. Also take the new mutex in ufshcd_clk_scaling_allow() to make sure that any pending write booster update has completed on return. Note that this currently only affects Qualcomm platforms since commit 87bd05016a64 ("scsi: ufs: core: Allow host driver to disable wb toggling during clock scaling"). The lock inversion (i.e. 1 above) was reported by lockdep as: ====================================================== WARNING: possible circular locking dependency detected 6.1.0-next-20221216 #211 Not tainted ------------------------------------------------------ kworker/u16:2/71 is trying to acquire lock: ffff076280ba98a0 (&hba->dev_cmd.lock){+.+.}-{3:3}, at: ufshcd_query_flag+0x50/0x1c0 but task is already holding lock: ffff076280ba9cf0 (&hba->clk_scaling_lock){++++}-{3:3}, at: ufshcd_devfreq_scale+0x2b8/0x380 which lock already depends on the new lock. [ +0.011606] the existing dependency chain (in reverse order) is: -> #1 (&hba->clk_scaling_lock){++++}-{3:3}: lock_acquire+0x68/0x90 down_read+0x58/0x80 ufshcd_exec_dev_cmd+0x70/0x2c0 ufshcd_verify_dev_init+0x68/0x170 ufshcd_probe_hba+0x398/0x1180 ufshcd_async_scan+0x30/0x320 async_run_entry_fn+0x34/0x150 process_one_work+0x288/0x6c0 worker_thread+0x74/0x450 kthread+0x118/0x120 ret_from_fork+0x10/0x20 -> #0 (&hba->dev_cmd.lock){+.+.}-{3:3}: __lock_acquire+0x12a0/0x2240 lock_acquire.part.0+0xcc/0x220 lock_acquire+0x68/0x90 __mutex_lock+0x98/0x430 mutex_lock_nested+0x2c/0x40 ufshcd_query_flag+0x50/0x1c0 ufshcd_query_flag_retry+0x64/0x100 ufshcd_wb_toggle+0x5c/0x120 ufshcd_devfreq_scale+0x2c4/0x380 ufshcd_devfreq_target+0xf4/0x230 devfreq_set_target+0x84/0x2f0 devfreq_update_target+0xc4/0xf0 devfreq_monitor+0x38/0x1f0 process_one_work+0x288/0x6c0 worker_thread+0x74/0x450 kthread+0x118/0x120 ret_from_fork+0x10/0x20 other info that might help us debug this: Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(&hba->clk_scaling_lock); lock(&hba->dev_cmd.lock); lock(&hba->clk_scaling_lock); lock(&hba->dev_cmd.lock); *** DEADLOCK *** Fixes: 0e9d4ca43ba8 ("scsi: ufs: Protect some contexts from unexpected clock scaling") Cc: stable@vger.kernel.org # 5.12 Cc: Can Guo Tested-by: Andrew Halaney Signed-off-by: Johan Hovold Reviewed-by: Bart Van Assche Link: https://lore.kernel.org/r/20230116161201.16923-1-johan+linaro@kernel.org Signed-off-by: Martin K. Petersen commit bbbd25499100c810ceaf5193c3cfcab9f7402a33 Author: Alexey V. Vissarionov Date: Wed Jan 18 06:12:55 2023 +0300 scsi: hpsa: Fix allocation size for scsi_host_alloc() The 'h' is a pointer to struct ctlr_info, so it's just 4 or 8 bytes, while the structure itself is much bigger. Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: edd163687ea5 ("hpsa: add driver for HP Smart Array controllers.") Link: https://lore.kernel.org/r/20230118031255.GE15213@altlinux.org Signed-off-by: Alexey V. Vissarionov Acked-by: Don Brace Signed-off-by: Martin K. Petersen commit 85e182b48a33a44f3e0cfe6e7ee9da15baa0afce Author: Johan Hovold Date: Mon Jan 16 17:42:36 2023 +0100 scsi: ufs: qcom: dt-bindings: Allow 'dma-coherent' property UFS controllers may be cache coherent and must be marked as such in the devicetree to avoid data corruption. This is specifically needed on recent Qualcomm platforms like SC8280XP. Reviewed-by: Rob Herring Reviewed-by: Bjorn Andersson Signed-off-by: Johan Hovold Link: https://lore.kernel.org/r/20230116164236.18958-1-johan+linaro@kernel.org Signed-off-by: Martin K. Petersen commit 54c51253b3d5544943fc3ec072cd0194915bac30 Author: Tom Rix Date: Fri Jan 13 20:37:24 2023 -0500 scsi: qla2xxx: Make qla_trim_buf() and __qla_adjust_buf() static Smatch reports: drivers/scsi/qla2xxx/qla_mid.c:1189:6: warning: symbol 'qla_trim_buf' was not declared. Should it be static? drivers/scsi/qla2xxx/qla_mid.c:1221:6: warning: symbol '__qla_adjust_buf' was not declared. Should it be static? These functions are only used in qla_mid.c, so they should be static. Fixes: 1f8f9c34127e ("scsi: qla2xxx: edif: Reduce memory usage during low I/O") Signed-off-by: Tom Rix Link: https://lore.kernel.org/r/20230114013724.3943580-1-trix@redhat.com Signed-off-by: Martin K. Petersen commit a3e2e248fd77a00931320875910ef73e071ac7dd Author: Fabio M. De Francesco Date: Tue Jan 3 19:25:56 2023 +0100 scsi: ipr: Replace kmap() with kmap_local_page() The use of kmap() is deprecated in favor of kmap_local_page(). There are two main problems with kmap(): (1) It comes with an overhead as the mapping space is restricted and protected by a global lock for synchronization and (2) it also requires global TLB invalidation when the kmap’s pool wraps and it might block when the mapping space is fully utilized until a slot becomes available. With kmap_local_page() the mappings are per thread, CPU local, can take page faults, and can be called from any context (including interrupts). It is faster than kmap() in kernels with HIGHMEM enabled. Furthermore, the tasks can be preempted and, when they are scheduled to run again, the kernel virtual addresses are restored and still valid. Therefore, replace kmap() with kmap_local_page() in ipr_copy_ucode_buffer() and, instead of open-coding local mappings + memcpy() + local un-mappings, use the better suited memcpy_to_page() helper. Suggested-by: Ira Weiny Signed-off-by: Fabio M. De Francesco Link: https://lore.kernel.org/r/20230103182556.29080-1-fmdefrancesco@gmail.com Signed-off-by: Martin K. Petersen commit 7edd053b3327a3d4e3378c9f932cf959d3249c7f Author: Fabio M. De Francesco Date: Tue Jan 3 18:31:31 2023 +0100 scsi: ips: Replace kmap_atomic() with kmap_local_page() kmap_atomic() is deprecated in favor of kmap_local_page(). Therefore, replace kmap_atomic() with kmap_local_page() in ips_is_passthru(). In the meantime remove an unnecessary comment, align code, and remove spaces. kmap_atomic() is implemented like a kmap_local_page() which also disables page-faults and preemption (the latter only for !PREEMPT_RT kernels). The code within the mapping/unmapping in ips_is_passthru() is already in atomic context because of a call to local_irq_save() and kmap_local_page() can be called in atomic context too (including interrupts). Therefore, a mere replacement of the old API with the new one is all it is required (i.e., there is no need to explicitly add any calls to pagefault_disable() and/or preempt_disable()). Suggested-by: Ira Weiny Signed-off-by: Fabio M. De Francesco Reviewed-by: Ira Weiny Link: https://lore.kernel.org/r/20230103173131.21259-1-fmdefrancesco@gmail.com Signed-off-by: Martin K. Petersen commit 1eeedfad9a14898dd1522a6c77d8b33ac2e4b780 Author: Paul Menzel Date: Tue Jan 3 16:04:37 2023 +0100 scsi: mpt3sas: Demote log level for trace buffer allocation to info Linux logs the error below: $ dmesg --level=err | grep mpt [ 7.647675] mpt3sas_cm0: Trace buffer memory 2048 KB allocated This state does not denote an error condition (and also no warning), so demote the level from error to info. Cc: it+linux-scsi@molgen.mpg.de Signed-off-by: Paul Menzel Link: https://lore.kernel.org/r/20230103150438.45922-1-pmenzel@molgen.mpg.de Signed-off-by: Martin K. Petersen commit d794a23113b1a198e3d05f144aeba5b6ac87fe99 Author: Arnd Bergmann Date: Tue Jan 17 18:00:15 2023 +0100 scsi: qla2xxx: Fix printk() format string Printing a size_t value that is the result of the sizeof() operator requires using the %z format string modifier to avoid a warning on 32-bit architectures: drivers/scsi/qla2xxx/qla_mid.c: In function 'qla_create_buf_pool': drivers/scsi/qla2xxx/qla_mid.c:1094:51: error: format '%ld' expects argument of type 'long int', but argument 5 has type 'unsigned int' [-Werror=format=] 1094 | "Failed to allocate buf_map(%ld).\n", sz * sizeof(unsigned long)); | ~~^ ~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | | long int unsigned int | %d Fixes: 82d8dfd2a238 ("scsi: qla2xxx: edif: Fix performance dip due to lock contention") Signed-off-by: Arnd Bergmann Reviewed-by: Bart Van Assche Reviewed-by: Himanshu Madhani > Reviewed-by: Nick Desaulniers Link: https://lore.kernel.org/r/20230117170029.2387516-1-arnd@kernel.org Signed-off-by: Martin K. Petersen commit fd5df558c31e2212b5bdd7a71afcc48f3e2c62dd Author: Alim Akhtar Date: Sat Jan 14 13:32:47 2023 +0530 scsi: MAINTAINERS: Add entry for Exynos UFS driver Add maintainer entry for Exynos UFS driver. Signed-off-by: Alim Akhtar Reviewed-by: Bart Van Assche Link: https://lore.kernel.org/r/20230114080247.601312-1-alim.akhtar@samsung.com Signed-off-by: Martin K. Petersen commit 3730bea883cd8f74fd9b2b31d51665c74cf73362 Author: Alim Akhtar Date: Sat Jan 14 07:50:10 2023 +0530 scsi: ufs: ufs: Remove duplicate entry PA_GRANULARITY is duplicated, delete one of the entries. Signed-off-by: Alim Akhtar Reviewed-by: Bart Van Assche Link: https://lore.kernel.org/r/20230114022010.27088-1-alim.akhtar@samsung.com Signed-off-by: Martin K. Petersen commit a9a3629592ab7442a2e9d40281420b51c453ea9b Author: Kees Cook Date: Thu Jan 5 21:32:00 2023 -0800 scsi: megaraid_sas: Add flexible array member for SGLs struct MPI2_RAID_SCSI_IO_REQUEST ends with a single SGL, but expects to copy multiple. Add a flexible array member so the compiler can reason about the size of the memcpy(). This will avoid the run-time false positive warning: memcpy: detected field-spanning write (size 128) of single field "&r1_cmd->io_request->SGL" at drivers/scsi/megaraid/megaraid_sas_fusion.c:3326 (size 16) This change results in no binary output differences. Reported-by: Holger Kiehl Link: https://lore.kernel.org/all/88de8faa-56c4-693d-2d3-67152ee72057@diagnostix.dwd.de/ Cc: Kashyap Desai Cc: Sumit Saxena Cc: Shivasharan S Cc: "James E.J. Bottomley" Cc: "Martin K. Petersen" Cc: megaraidlinux.pdl@broadcom.com Cc: linux-scsi@vger.kernel.org Link: https://lore.kernel.org/r/20230106053153.never.999-kees@kernel.org Signed-off-by: Kees Cook Tested-by: Holger Kiehl Signed-off-by: Martin K. Petersen commit 946a10511f6588c20bbd312be15d64cc3c3fc796 Author: Mike Christie Date: Thu Dec 29 13:01:54 2022 -0600 scsi: core: Remove scsi_execute_req()/scsi_execute() functions scsi_execute() and scsi_execute_req() are no longer used so remove them. Signed-off-by: Mike Christie Reviewed-by: John Garry Reviewed-by: Bart Van Assche Reviewed-by: Christoph Hellwig Signed-off-by: Martin K. Petersen commit 1035c9893f15e801456dddd547ea52ae8f6a1e1f Author: Mike Christie Date: Thu Dec 29 13:01:53 2022 -0600 scsi: cxlflash: Convert to scsi_execute_cmd() scsi_execute() is going to be removed. Convert cxlflash to use scsi_execute_cmd(). [mkp: roll in fix for issue reported by sfr] Signed-off-by: Mike Christie Reviewed-by: John Garry Reviewed-by: Bart Van Assche Reviewed-by: Christoph Hellwig Signed-off-by: Martin K. Petersen commit e335795f27d0ab5260e4681f14be8f8c915ac1a7 Author: Mike Christie Date: Thu Dec 29 13:01:52 2022 -0600 scsi: target: target_core_pscsi: Convert to scsi_execute_cmd() scsi_execute_req() is going to be removed. Convert pscsi to scsi_execute_cmd(). Signed-off-by: Mike Christie Reviewed-by: John Garry Reviewed-by: Bart Van Assche Reviewed-by: Christoph Hellwig Signed-off-by: Martin K. Petersen commit 5314ce761fbf3bef2b5aae5e5562e782a5026e7c Author: Mike Christie Date: Thu Dec 29 13:01:51 2022 -0600 scsi: virtio_scsi: Convert to scsi_execute_cmd() scsi_execute_req() is going to be removed. Convert virtio_scsi to scsi_execute_cmd(). Signed-off-by: Mike Christie Reviewed-by: John Garry Reviewed-by: Bart Van Assche Reviewed-by: Christoph Hellwig Signed-off-by: Martin K. Petersen commit 49d33b6245d91a2ca20755cd4edf86dd0e49649e Author: Mike Christie Date: Thu Dec 29 13:01:50 2022 -0600 scsi: sr: Convert to scsi_execute_cmd() scsi_execute*() is going to be removed. Convert sr to scsi_execute_cmd(). Signed-off-by: Mike Christie Reviewed-by: John Garry Reviewed-by: Bart Van Assche Reviewed-by: Christoph Hellwig Signed-off-by: Martin K. Petersen commit ae4145a5f25e56b0248b38f913c5cc370cde723a Author: Mike Christie Date: Thu Dec 29 13:01:49 2022 -0600 scsi: ses: Convert to scsi_execute_cmd() scsi_execute_req() is going to be removed. Convert ses to scsi_execute_cmd(). Signed-off-by: Mike Christie Reviewed-by: John Garry Reviewed-by: Bart Van Assche Reviewed-by: Christoph Hellwig Signed-off-by: Martin K. Petersen commit 6ff236e847aa7817a985122ccef7e0f422eb8564 Author: Mike Christie Date: Thu Dec 29 13:01:48 2022 -0600 scsi: zbc: Convert to scsi_execute_cmd() scsi_execute_req() is going to be removed. Conver zbc to scsi_execute_cmd(). Signed-off-by: Mike Christie Reviewed-by: John Garry Reviewed-by: Bart Van Assche Reviewed-by: Christoph Hellwig Signed-off-by: Martin K. Petersen commit af16cd63d9d3b790ecfce3c053595a98f181e025 Author: Mike Christie Date: Thu Dec 29 13:01:47 2022 -0600 scsi: sd: Convert to scsi_execute_cmd() scsi_execute*() is going to be removed. Convert sd_mod to use scsi_execute_cmd(). Signed-off-by: Mike Christie Reviewed-by: John Garry Reviewed-by: Bart Van Assche Reviewed-by: Christoph Hellwig Signed-off-by: Martin K. Petersen commit c9ee828aad6919b7eee7ef2059489c7221edf68a Author: Mike Christie Date: Thu Dec 29 13:01:46 2022 -0600 scsi: spi: Convert to scsi_execute_cmd() scsi_execute() is going to be removed. Convert to the SPI class to scsi_execute_cmd(). Signed-off-by: Mike Christie Reviewed-by: John Garry Reviewed-by: Bart Van Assche Reviewed-by: Christoph Hellwig Signed-off-by: Martin K. Petersen commit 7dfe0b5e7ca67c659475883712c1d0449f900f9c Author: Mike Christie Date: Thu Dec 29 13:01:45 2022 -0600 scsi: core: Convert to scsi_execute_cmd() scsi_execute_req() is going to be removed. Convert SCSI midlayer to scsi_execute_cmd(). Signed-off-by: Mike Christie Reviewed-by: John Garry Reviewed-by: Bart Van Assche Reviewed-by: Christoph Hellwig Signed-off-by: Martin K. Petersen commit 31fc28c6b13eedb6da2c60414088c007432436d1 Author: Mike Christie Date: Thu Dec 29 13:01:44 2022 -0600 scsi: scsi_dh: Convert to scsi_execute_cmd() scsi_execute() is going to be removed. Convert the scsi_dh users to scsi_execute_cmd(). Signed-off-by: Mike Christie Reviewed-by: John Garry Reviewed-by: Bart Van Assche Reviewed-by: Christoph Hellwig Signed-off-by: Martin K. Petersen commit ed226f0889a3c79d059564ba3fc1dcf5825f655c Author: Mike Christie Date: Thu Dec 29 13:01:43 2022 -0600 scsi: ch: Convert to scsi_execute_cmd() scsi_execute_req() is going to be removed. Convert ch to scsi_execute_cmd(). Signed-off-by: Mike Christie Reviewed-by: John Garry Reviewed-by: Bart Van Assche Reviewed-by: Christoph Hellwig Signed-off-by: Martin K. Petersen commit 08e95a2ba4bbbb968e7ee0cc946e7d2c51742e92 Author: Mike Christie Date: Thu Dec 29 13:01:42 2022 -0600 scsi: hwmon: drivetemp: Convert to scsi_execute_cmd() scsi_execute_req() is going to be removed. Convert drivetemp to scsi_execute_cmd(). Signed-off-by: Mike Christie Reviewed-by: John Garry Reviewed-by: Bart Van Assche Reviewed-by: Christoph Hellwig Signed-off-by: Martin K. Petersen commit 5fa7b072677513e934242eab85772c0bfc84859b Author: Mike Christie Date: Thu Dec 29 13:01:41 2022 -0600 scsi: ata: libata-scsi: Convert to scsi_execute_cmd() scsi_execute_req() is going to be removed. Convert libata to scsi_execute_cmd(). Signed-off-by: Mike Christie Reviewed-by: John Garry Reviewed-by: Bart Van Assche Acked-by: Damien Le Moal Reviewed-by: Christoph Hellwig Signed-off-by: Martin K. Petersen commit d0949565811f0896c1c7e781ab2ad99d34273fdf Author: Mike Christie Date: Thu Dec 29 13:01:40 2022 -0600 scsi: core: Add struct for args to execution functions Move the SCSI execution functions to use a struct for passing in optional args. This commit adds the new struct, temporarily converts scsi_execute() and scsi_execute_req() ands a new helper, scsi_execute_cmd(), which takes the scsi_exec_args struct. There should be no change in behavior. We no longer allow users to pass in any request->rq_flags value, but they were only passing in RQF_PM which we do support by allowing users to pass in the BLK_MQ_REQ flags used by blk_mq_alloc_request(). Subsequent commits will convert scsi_execute() and scsi_execute_req() users to the new helpers then remove scsi_execute() and scsi_execute_req(). Signed-off-by: Mike Christie Reviewed-by: Bart Van Assche Reviewed-by: Christoph Hellwig Reviewed-by: John Garry Signed-off-by: Martin K. Petersen commit 519b6274a7775f5fe00a086f189efb8f063467d1 Author: Can Guo Date: Wed Dec 14 19:06:22 2022 -0800 scsi: ufs: qcom: Add MCQ ESI config vendor specific ops Add MCQ ESI config vendor specific ops. Co-developed-by: Asutosh Das Signed-off-by: Asutosh Das Signed-off-by: Can Guo Reviewed-by: Bart Van Assche Signed-off-by: Martin K. Petersen commit e02288e0265fe316a16d48ec6dd7b7fd54d66e3e Author: Can Guo Date: Wed Dec 14 19:06:21 2022 -0800 scsi: ufs: core: mcq: Add Event Specific Interrupt enable and config functions Add and export two functions to enable ESI and config ESI base addresses. The calls to these exported functions will be added by the next patch in this series. Signed-off-by: Can Guo Reviewed-by: Bart Van Assche Signed-off-by: Martin K. Petersen commit edb0db05607ce05a5e0df00518b58a811e9f548e Author: Can Guo Date: Wed Dec 14 19:06:20 2022 -0800 scsi: ufs: core: Add Event Specific Interrupt configuration vendor specific ops As Event Specific Interrupt message format is not defined in UFSHCI JEDEC specs, and the ESI handling highly depends on how the format is designed, hence add a vendor specific ops such that SoC vendors can configure their own ESI handlers. If ESI vops is not provided or returning error, go with the legacy (central) interrupt way. Signed-off-by: Can Guo Reviewed-by: Bart Van Assche Signed-off-by: Martin K. Petersen commit eacb139b77ff75b973cb99573b33a7adb1f4ca38 Author: Asutosh Das Date: Fri Jan 13 12:48:52 2023 -0800 scsi: ufs: core: mcq: Enable multi-circular queue Enable MCQ in the Host Controller. Signed-off-by: Asutosh Das Reviewed-by: Bart Van Assche Reviewed-by: Manivannan Sadhasivam Reviewed-by: Stanley Chu Signed-off-by: Martin K. Petersen commit ed975065c31c2a0372e13c19e8140b69814a98ba Author: Asutosh Das Date: Fri Jan 13 12:48:51 2023 -0800 scsi: ufs: core: mcq: Add completion support in poll Complete CQE requests in poll. Assumption is that several poll completion may happen in different CPUs for the same completion queue. Hence a spin lock protection is added. Co-developed-by: Can Guo Signed-off-by: Can Guo Signed-off-by: Asutosh Das Reviewed-by: Bart Van Assche Reviewed-by: Manivannan Sadhasivam Reviewed-by: Stanley Chu Signed-off-by: Martin K. Petersen commit f87b2c41822aad09aadac31b8ba22c0c0e639eee Author: Asutosh Das Date: Fri Jan 13 12:48:50 2023 -0800 scsi: ufs: mcq: Add completion support of a CQE Add support for completing requests from Completion Queue. Some host controllers support vendor specific registers that provide a bitmap of all CQs which have at least one completed CQE. Add this support. The MCQ specification doesn't provide the Task Tag or its equivalent in the Completion Queue Entry. So use an indirect method to find the Task Tag from the Completion Queue Entry. Co-developed-by: Can Guo Signed-off-by: Can Guo Signed-off-by: Asutosh Das Reviewed-by: Bart Van Assche Reviewed-by: Manivannan Sadhasivam Reviewed-by: Stanley Chu Signed-off-by: Martin K. Petersen commit c30d8d010b5efd1d526ae94c9fbbfc0f74cec9fe Author: Asutosh Das Date: Fri Jan 13 12:48:49 2023 -0800 scsi: ufs: core: Prepare for completion in MCQ Modify completion path APIs and add completion queue entry. Co-developed-by: Can Guo Signed-off-by: Can Guo Signed-off-by: Asutosh Das Reviewed-by: Bart Van Assche Reviewed-by: Manivannan Sadhasivam Reviewed-by: Stanley Chu Signed-off-by: Martin K. Petersen commit 854f84e7feebc0c5a63e4c1f29ddf201fd2a57bc Author: Asutosh Das Date: Fri Jan 13 12:48:48 2023 -0800 scsi: ufs: core: mcq: Find hardware queue to queue request Add support to find the hardware queue on which the request would be queued. Since the very first queue is to serve device commands, an offset of 1 is added to the index of the hardware queue. Co-developed-by: Can Guo Signed-off-by: Can Guo Signed-off-by: Asutosh Das Reviewed-by: Bart Van Assche Reviewed-by: Manivannan Sadhasivam Signed-off-by: Martin K. Petersen commit 22a2d563de1425ea294e9abfa104dbf20c83a28a Author: Asutosh Das Date: Fri Jan 13 12:48:47 2023 -0800 scsi: ufs: core: Prepare ufshcd_send_command() for MCQ Add support to send commands using multiple submission queues in MCQ mode. Modify the functions that use ufshcd_send_command(). Co-developed-by: Can Guo Signed-off-by: Can Guo Signed-off-by: Asutosh Das Reviewed-by: Bart Van Assche Reviewed-by: Manivannan Sadhasivam Reviewed-by: Stanley Chu Signed-off-by: Martin K. Petersen commit 0d33728fc0e77adeea95de6e53cf26a4f741e594 Author: Asutosh Das Date: Fri Jan 13 12:48:46 2023 -0800 scsi: ufs: core: mcq: Use shared tags for MCQ mode Enable shared tags for MCQ. For UFS, this should not have a huge performance impact. It however simplifies the MCQ implementation and reuses most of the existing code in the issue and completion path. Also add multiple queue mapping to map_queue(). Co-developed-by: Can Guo Signed-off-by: Can Guo Signed-off-by: Asutosh Das Reviewed-by: Bart Van Assche Reviewed-by: Manivannan Sadhasivam Reviewed-by: Stanley Chu Signed-off-by: Martin K. Petersen commit 2468da61ea095162067ed408824298ba9c3661c8 Author: Asutosh Das Date: Fri Jan 13 12:48:45 2023 -0800 scsi: ufs: core: mcq: Configure operation and runtime interface Runtime and operation registers are defined per Submission and Completion queue. The location of these registers is not defined in the spec; meaning the offsets and stride may vary for different HC vendors. Establish the stride, base address, and doorbell address offsets from vendor host driver and program it. Co-developed-by: Can Guo Signed-off-by: Can Guo Signed-off-by: Asutosh Das Reviewed-by: Manivannan Sadhasivam Reviewed-by: Bart Van Assche Signed-off-by: Martin K. Petersen commit 4682abfae2eb3a1c138130cfd6d71411d81aaa00 Author: Asutosh Das Date: Fri Jan 13 12:48:44 2023 -0800 scsi: ufs: core: mcq: Allocate memory for MCQ mode To read the bqueuedepth, the device descriptor is fetched in Single Doorbell Mode. This allocated memory may not be enough for MCQ mode because the number of tags supported in MCQ mode may be larger than in SDB mode. Hence, release the memory allocated in SDB mode and allocate memory for MCQ mode operation. Define the UFS hardware queue and Completion Queue Entry. Co-developed-by: Can Guo Signed-off-by: Can Guo Signed-off-by: Asutosh Das Reviewed-by: Manivannan Sadhasivam Reviewed-by: Bart Van Assche Signed-off-by: Martin K. Petersen commit 7224c806876e46cfaf46b1c90da8d5c2e1f2108f Author: Asutosh Das Date: Fri Jan 13 12:48:43 2023 -0800 scsi: ufs: core: mcq: Calculate queue depth The UFS device defines the supported queuedepth by bqueuedepth which has a max value of 256. The HC defines MAC (Max Active Commands) that defines the max number of commands that in flight to the UFS device. Calculate and configure the nutrs based on both these values. Co-developed-by: Can Guo Signed-off-by: Can Guo Signed-off-by: Asutosh Das Reviewed-by: Manivannan Sadhasivam Reviewed-by: Bart Van Assche Reviewed-by: Stanley Chu Signed-off-by: Martin K. Petersen commit c263b4ef737e622e2a908c58ca4bb68a89376387 Author: Asutosh Das Date: Fri Jan 13 12:48:42 2023 -0800 scsi: ufs: core: mcq: Configure resource regions Define the MCQ resources and add support to ioremap the resource regions. Co-developed-by: Can Guo Signed-off-by: Can Guo Signed-off-by: Asutosh Das Reviewed-by: Manivannan Sadhasivam Reviewed-by: Bart Van Assche Reviewed-by: Stanley Chu Signed-off-by: Martin K. Petersen commit 57b1c0ef89ac9d9e7475df7843aeb7672ebcd197 Author: Asutosh Das Date: Fri Jan 13 12:48:41 2023 -0800 scsi: ufs: core: mcq: Add support to allocate multiple queues Multi-circular queue (MCQ) has been added in UFSHC v4.0 standard in addition to the Single Doorbell mode. The MCQ mode supports multiple submission and completion queues. Add support to allocate and configure the queues. Add module parameters support to configure the queues. Co-developed-by: Can Guo Signed-off-by: Can Guo Signed-off-by: Asutosh Das Reviewed-by: Bart Van Assche Reviewed-by: Manivannan Sadhasivam Signed-off-by: Martin K. Petersen commit 0cab4023ec7b49b18145f74ab8389678d6d58878 Author: Asutosh Das Date: Fri Jan 13 12:48:40 2023 -0800 scsi: ufs: core: Defer adding host to SCSI if MCQ is supported If MCQ support is present, enabling it after MCQ support has been configured would require reallocating tags and memory. It would also free up the already allocated memory in Single Doorbell Mode. So defer invoking scsi_add_host() until MCQ is configured. Co-developed-by: Can Guo Signed-off-by: Can Guo Signed-off-by: Asutosh Das Reviewed-by: Bart Van Assche Reviewed-by: Manivannan Sadhasivam Signed-off-by: Martin K. Petersen commit 305a357d3595d39be7c001f72e135bc94cbd85da Author: Asutosh Das Date: Fri Jan 13 12:48:39 2023 -0800 scsi: ufs: core: Introduce multi-circular queue capability Add support to check for MCQ capability in the UFSHC. Add a module parameter to disable MCQ if needed. Co-developed-by: Can Guo Signed-off-by: Can Guo Signed-off-by: Asutosh Das Reviewed-by: Bart Van Assche Reviewed-by: Manivannan Sadhasivam Reviewed-by: Stanley Chu Signed-off-by: Martin K. Petersen commit 6e1d850acff9477ae4c18a73c19ef52841ac2010 Author: Asutosh Das Date: Fri Jan 13 12:48:38 2023 -0800 scsi: ufs: core: Probe for EXT_IID support Task Tag is limited to 8 bits and this restricts the number of active I/Os to 255. In multi-circular queue mode, this may not be enough. The specification provides EXT_IID which can be used to increase the number of I/Os if the UFS device and UFSHC support it. This patch adds support to probe for EXT_IID support in UFS device and UFSHC. Co-developed-by: Can Guo Signed-off-by: Can Guo Signed-off-by: Asutosh Das Reviewed-by: Bart Van Assche Reviewed-by: Avri Altman Reviewed-by: Manivannan Sadhasivam Reviewed-by: Stanley Chu Signed-off-by: Martin K. Petersen commit 64b6deadc938b37717aa1338715cb7ef5e7d444c Author: Kees Cook Date: Thu Jan 5 15:30:46 2023 -0800 scsi: uapi: Replace 0-length array with flexible array Zero-length arrays are deprecated[1]. Replace struct fc_bsg_host_vendor_reply's "vendor_rsp" 0-length array with a flexible array. Detected with GCC 13, using -fstrict-flex-arrays=3: drivers/scsi/qla2xxx/qla_isr.c: In function 'qla25xx_process_bidir_status_iocb.isra': drivers/scsi/qla2xxx/qla_isr.c:3117:54: warning: array subscript 0 is outside array bounds of '__u32[0]' {aka 'unsigned int[]'} [-Warray-bounds=] 3117 | bsg_reply->reply_data.vendor_reply.vendor_rsp[0] = rval; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ In file included from drivers/scsi/qla2xxx/qla_def.h:34, from drivers/scsi/qla2xxx/qla_isr.c:6: include/uapi/scsi/scsi_bsg_fc.h:219:15: note: while referencing 'vendor_rsp' 219 | __u32 vendor_rsp[0]; | ^~~~~~~~~~ [1] https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays Cc: Martin K. Petersen Cc: Dan Williams Cc: "Gustavo A. R. Silva" Signed-off-by: Kees Cook Reviewed-by: Gustavo A. R. Silva Link: https://lore.kernel.org/r/20230105233042.never.913-kees@kernel.org Signed-off-by: Martin K. Petersen commit 84ed64b1a7a7fcd507598dee7708c1f225123711 Author: Maurizio Lombardi Date: Tue Jan 10 13:53:10 2023 +0100 scsi: target: core: Fix warning on RT kernels Calling spin_lock_irqsave() does not disable the interrupts on realtime kernels, remove the warning and replace assert_spin_locked() with lockdep_assert_held(). Signed-off-by: Maurizio Lombardi Reviewed-by: Christoph Hellwig Link: https://lore.kernel.org/r/20230110125310.55884-1-mlombard@redhat.com Signed-off-by: Martin K. Petersen commit 201e0a7c7f36ccb70b532e04ea2f48031f219e74 Author: Kees Cook Date: Wed Jan 4 17:11:50 2023 -0800 scsi: mvumi: Replace 1-element arrays with flexible array members One-element arrays (and multi-element arrays being treated as dynamically sized) are deprecated[1] and are being replaced with flexible array members in support of the ongoing efforts to tighten the FORTIFY_SOURCE routines on memcpy(), correctly instrument array indexing with UBSAN_BOUNDS, and to globally enable -fstrict-flex-arrays=3. Replace one-element arrays with flexible-array member in struct mvumi_msg_frame, struct mvumi_rsp_frame, and struct mvumi_hs_header, adjusting the explicit sizing calculations at the same time. This results in no functional differences in binary output. An explicit add is now folded into the size calculation: │ mov 0x1070(%r14),%eax │ - add $0x4,%eax │ - movabs $0xfffffffdc,%rbx │ + movabs $0xfffffffe0,%rbx │ add %rax,%rbx [1] https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays Cc: "James E.J. Bottomley" Cc: "Martin K. Petersen" Cc: "Gustavo A. R. Silva" Cc: linux-scsi@vger.kernel.org Signed-off-by: Kees Cook Reviewed-by: Gustavo A. R. Silva Link: https://lore.kernel.org/r/20230105011143.never.569-kees@kernel.org Signed-off-by: Martin K. Petersen commit 45b379f20bc0fecccad63c25bfe28d75d6bc5b0d Author: Kees Cook Date: Wed Jan 4 16:48:01 2023 -0800 scsi: 3w-sas: Replace 1-element arrays with flexible array members One-element arrays (and multi-element arrays being treated as dynamically sized) are deprecated[1] and are being replaced with flexible array members in support of the ongoing efforts to tighten the FORTIFY_SOURCE routines on memcpy(), correctly instrument array indexing with UBSAN_BOUNDS, and to globally enable -fstrict-flex-arrays=3. Replace one-element arrays with flexible-array member in TW_Ioctl_Buf_Apache and TW_Param_Apache, adjusting the explicit sizing calculations at the same time. This results in no differences in binary output. [1] https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays Cc: Adam Radford Cc: "James E.J. Bottomley" Cc: "Martin K. Petersen" Cc: "Gustavo A. R. Silva" Cc: linux-scsi@vger.kernel.org Signed-off-by: Kees Cook Reviewed-by: Gustavo A. R. Silva Link: https://lore.kernel.org/r/20230105004757.never.017-kees@kernel.org Signed-off-by: Martin K. Petersen commit f58c89700630da6554b24fd3df293a24874c10c1 Author: Yihang Li Date: Wed Jan 4 12:03:20 2023 +0800 scsi: hisi_sas: Set a port invalid only if there are no devices attached when refreshing port id Currently the driver sets the port invalid if one phy in the port is not enabled, which may cause issues in expander situation. In directly attached situation, if phy up doesn't occur in time when refreshing port id, the port is incorrectly set to invalid which will also cause disk lost. Therefore set a port invalid only if there are no devices attached to the port. Signed-off-by: Yihang Li Signed-off-by: Xiang Chen Link: https://lore.kernel.org/r/1672805000-141102-3-git-send-email-chenxiang66@hisilicon.com Signed-off-by: Martin K. Petersen commit 037b48057e8b485a8d72f808122796aeadbbee32 Author: Xingui Yang Date: Wed Jan 4 12:03:19 2023 +0800 scsi: hisi_sas: Use abort task set to reset SAS disks when discovered Currently clear task set is used to abort all commands remaining in the disk when the SAS disk is discovered, and if the disk is discovered by two initiators, other I_T nexuses are also affected. So use abort task set instead and take effect only on the specified I_T nexus. Signed-off-by: Xingui Yang Signed-off-by: Xiang Chen Link: https://lore.kernel.org/r/1672805000-141102-2-git-send-email-chenxiang66@hisilicon.com Signed-off-by: Martin K. Petersen commit 191b5a38771d9e92eae62ad76f70628952c757ef Author: Justin Tee Date: Mon Jan 9 15:33:17 2023 -0800 scsi: lpfc: Copyright updates for 14.2.0.10 patches Update copyrights to 2023 for files modified in the 14.2.0.10 patch set. Signed-off-by: Justin Tee Signed-off-by: Martin K. Petersen commit 41cf6bbe3d998f580e6f23dd2d07823399b0a5dc Author: Justin Tee Date: Mon Jan 9 15:33:16 2023 -0800 scsi: lpfc: Update lpfc version to 14.2.0.10 Update lpfc version to 14.2.0.10 Signed-off-by: Justin Tee Signed-off-by: Martin K. Petersen commit 96fb8c34e5c12361d1966768bf9aadc935600c62 Author: Justin Tee Date: Mon Jan 9 15:33:15 2023 -0800 scsi: lpfc: Introduce new attention types for lpfc_sli4_async_fc_evt() handler Define new FC Link ACQE with new attention types 0x8 (Link Activation Failure) and 0x9 (Link Reset Protocol Event). Both attention types are meant to be informational-only type ACQEs with no action required. 0x8 is reported for diagnostic purposes, while 0x9 is posted during a normal link up transition when activating BB Credit Recovery feature. As such, modify lpfc_sli4_async_fc_evt() logic to log the attention types according to its severity and early return when informational-only attention types are encountered. Signed-off-by: Justin Tee Signed-off-by: Martin K. Petersen commit f1d2337d3e58955ecbbf392ba09fabb3e72db945 Author: Justin Tee Date: Mon Jan 9 15:33:14 2023 -0800 scsi: lpfc: Reinitialize internal VMID data structures after FLOGI completion After enabling VMID, an issue LIP test was erasing fabric switch VMID information. Introduce a lpfc_reinit_vmid() routine, which reinitializes all VMID data structures upon FLOGI completion in fabric topology. Signed-off-by: Justin Tee Signed-off-by: Martin K. Petersen commit 21681b81b9ae548c5dae7ae00d931197a27f480c Author: Justin Tee Date: Mon Jan 9 15:33:13 2023 -0800 scsi: lpfc: Fix use-after-free KFENCE violation during sysfs firmware write During the sysfs firmware write process, a use-after-free read warning is logged from the lpfc_wr_object() routine: BUG: KFENCE: use-after-free read in lpfc_wr_object+0x235/0x310 [lpfc] Use-after-free read at 0x0000000000cf164d (in kfence-#111): lpfc_wr_object+0x235/0x310 [lpfc] lpfc_write_firmware.cold+0x206/0x30d [lpfc] lpfc_sli4_request_firmware_update+0xa6/0x100 [lpfc] lpfc_request_firmware_upgrade_store+0x66/0xb0 [lpfc] kernfs_fop_write_iter+0x121/0x1b0 new_sync_write+0x11c/0x1b0 vfs_write+0x1ef/0x280 ksys_write+0x5f/0xe0 do_syscall_64+0x59/0x90 entry_SYSCALL_64_after_hwframe+0x63/0xcd The driver accessed wr_object pointer data, which was initialized into mailbox payload memory, after the mailbox object was released back to the mailbox pool. Fix by moving the mailbox free calls to the end of the routine ensuring that we don't reference internal mailbox memory after release. Signed-off-by: Justin Tee Signed-off-by: Martin K. Petersen commit c051f1a424a15b73c493090a9f1c0273398b1637 Author: Justin Tee Date: Mon Jan 9 15:33:12 2023 -0800 scsi: lpfc: Exit PRLI completion handling early if ndlp not in PRLI_ISSUE state In a large SAN testing configuration, frequent target port toggle tests are occasionally resulting in missing lun path rediscoveries. An outstanding PRLI can be inflight when a target RSCN dissappearance occurs, causing the driver to retry PRLIs using invalid rpi contexts. Fix by verifying that an ndlp's state was not restarted from PRLI_ISSUE due to an intermediate RSCN. If not in a valid state, early exit PRLI completion handling. The last follow up RSCN indicating target reappearance retriggers PLOGI/PRLI with a valid rpi context and is expected to succeed in LUN path rediscovery. Signed-off-by: Justin Tee Signed-off-by: Martin K. Petersen commit ecdf4ddf4eb7a9135abdb358e98a8e6c1e8effe6 Author: Justin Tee Date: Mon Jan 9 15:33:11 2023 -0800 scsi: lpfc: Remove duplicate ndlp kref decrement in lpfc_cleanup_rpis() With faulty cables in PT2PT topology, an unintentional ndlp double kref decrement can occur. If a FLOGI request is outstanding before the link goes down, the missing FLOGI_ACC causes an F_Port ndlp to remain in the UNUSED state. During link down, lpfc_cleanup_rpis() is called and decrements an ndlp kref. Additionally, when the driver later decides to abort the FLOGI, the FLOGI completion handler decrements the ndlp kref a second time. Remove duplicate clean up logic in lpfc_cleanup_rpis() because the updated FLOGI completion handler already handles the ndlp kref decrement. Signed-off-by: Justin Tee Signed-off-by: Martin K. Petersen commit f81395570e6c08ec1ef11eda433856c1a6805077 Author: Justin Tee Date: Mon Jan 9 15:33:10 2023 -0800 scsi: lpfc: Remove redundant clean up code in disable_vport() The disable_vport() path calls the discovery state machine on all ndlps, puts them into NPR state, and then calls lpfc_cleanup_rpis() with the remove flag set. This unintentionally decrements an ndlp's kref twice and can result in premature release of an ndlp because lpfc_dev_loss_tmo_handler() triggers clean up of the ndlp again later. Remove redundant code in disable_vport() that sets all the ndlps to NPR, and change the call to lpfc_cleanup_rpis() to not remove the ndlps. lpfc_dev_loss_tmo_handler() will handle final removal of the ndlps. Signed-off-by: Justin Tee Signed-off-by: Martin K. Petersen commit b5c894cf430e779826612cf2acb508d78bf210ce Author: Justin Tee Date: Mon Jan 9 15:33:09 2023 -0800 scsi: lpfc: Set max DMA segment size to HBA supported SGE length During I/O, the following warning message occasionally appears: DMA-API: lpfc 0000:04:00.0: mapping sg segment longer than device claims to support [len=131072] [max=65536] The HBA is capable of supporting 131,072 bytes, so notify DMA layer via the dma_set_max_seg_size() API during hba initialization. Signed-off-by: Justin Tee Signed-off-by: Martin K. Petersen commit 7ab07683aa4ccf324dc369808ceb0b138d590f07 Author: Justin Tee Date: Mon Jan 9 15:33:08 2023 -0800 scsi: lpfc: Resolve miscellaneous variable set but not used compiler warnings The local variables called curr_data are incremented, but not actually used for anything so they are removed. The return value of lpfc_sli4_poll_eq is not used anywhere and is not called outside of lpfc_sli.c. Thus, its declaration is removed from lpfc_crtn.h Also, lpfc_sli4_poll_eq's path argument is not used in the routine so it is removed along with corresponding macros. Signed-off-by: Justin Tee Signed-off-by: Martin K. Petersen commit 1f7b5f94f8d0c97f9b6d10e5ba47e15459ff74ff Author: Justin Tee Date: Mon Jan 9 15:33:07 2023 -0800 scsi: lpfc: Replace outdated strncpy() with strscpy() The kernel test robot pointed out non-NULL terminated string possibilities when using strncpy() in lpfc_xcvr_data_show() routine. Although we manually set the NULL character after strncpy(), strncpy() usage is outdated. Replace all strncpy() usages with the preferred strscpy() API. Reported-by: kernel test robot Signed-off-by: Justin Tee Signed-off-by: Martin K. Petersen commit 6058304a66baae4470188337700392d6404079b3 Author: Justin Tee Date: Mon Jan 9 15:33:06 2023 -0800 scsi: lpfc: Fix space indentation in lpfc_xcvr_data_show() The kernel test robot detected inconsistent indentations for an if statement block in the lpfc_xcvr_data_show() routine. This patch reduces the extraneous tabs used for the if statement block in question. Reported-by: kernel test robot Signed-off-by: Justin Tee Signed-off-by: Martin K. Petersen commit f7d1ba350fb3bca7b158d6cb9963acc1cf00d729 Author: Nilesh Javali Date: Wed Dec 21 20:39:33 2022 -0800 scsi: qla2xxx: Update version to 10.02.08.200-k Signed-off-by: Nilesh Javali Signed-off-by: Martin K. Petersen commit 1d201c81d4cc6840735bbcc99e6031503e5cf3b8 Author: Shreyas Deodhar Date: Wed Dec 21 20:39:32 2022 -0800 scsi: qla2xxx: Select qpair depending on which CPU post_cmd() gets called In current I/O path, Tx and Rx may not be processed on same CPU. This may lead to thrashing and optimum performance may not be achieved. Pick qpair such that Tx and Rx are processed on same CPU. Signed-off-by: Shreyas Deodhar Signed-off-by: Nilesh Javali Signed-off-by: Martin K. Petersen commit 2f5fab1b6c3a8efc93ba52c28539c45a8d0142ad Author: Quinn Tran Date: Wed Dec 21 20:39:31 2022 -0800 scsi: qla2xxx: edif: Fix clang warning clang warning: drivers/scsi/qla2xxx/qla_edif_bsg.h:93:12: warning: field remote_pid within 'struct app_pinfo_req' is less aligned than 'port_id_t' and is usually due to 'struct app_pinfo_req' being packed, which can lead to unaligned accesses [-Wunaligned-access] port_id_t remote_pid; ^ 2 warnings generated. Remove u32 field in remote_pid to silence warning. Reported-by: kernel test robot Fixes: 7ebb336e45ef ("scsi: qla2xxx: edif: Add start + stop bsgs") Signed-off-by: Quinn Tran Signed-off-by: Nilesh Javali Signed-off-by: Martin K. Petersen commit 1f8f9c34127e9fae20c29a2b57f56fd47dbb43e4 Author: Quinn Tran Date: Wed Dec 21 20:39:30 2022 -0800 scsi: qla2xxx: edif: Reduce memory usage during low I/O For edif, each I/O requires a secondary buffer to carry the FCP cmnd. During high traffic time, these buffers are cached in the qpair. As traffic dies down, these buffers will be trimmed as needed. If traffic is reduced to none over 2 consecutive intervals, then these buffers will be further trimmed. Free FCP cmnd buffers to reduce memory usage during slow I/O time. Signed-off-by: Quinn Tran Signed-off-by: Nilesh Javali Signed-off-by: Martin K. Petersen commit 129a7c40294fd4ab9e9bccf76e8002818f492d8a Author: Quinn Tran Date: Wed Dec 21 20:39:29 2022 -0800 scsi: qla2xxx: edif: Fix stall session after app start For N2N, qla2x00_wait_for_sess_deletion call flushes a session which accidentally clear the scan_flag and thus prevents re-login to occur and causes session to stall. Use session delete to avoid the accidental clearing of scan_flag. Signed-off-by: Quinn Tran Signed-off-by: Nilesh Javali Signed-off-by: Martin K. Petersen commit 82d8dfd2a238261e06759ee792417dc99b93d60d Author: Quinn Tran Date: Wed Dec 21 20:39:28 2022 -0800 scsi: qla2xxx: edif: Fix performance dip due to lock contention User experienced performance dip on measuring IOPS while EDIF enabled. During I/O time, driver uses dma_pool_zalloc() call to allocate a chunk of memory. This call contains a lock behind the scene which contribute to lock contention. Save the allocated memory for reuse and avoid the lock. Signed-off-by: Quinn Tran Signed-off-by: Nilesh Javali Reviewed-by: Himanshu Madhani Signed-off-by: Martin K. Petersen commit 430eef03a763e5e76a371ba6d02779ae4a64b6ea Author: Quinn Tran Date: Wed Dec 21 20:39:27 2022 -0800 scsi: qla2xxx: Relocate/rename vp map There is no functional change in this patch. VP map resource is renamed and relocated so it is not viewed as just a target mode resource. Signed-off-by: Quinn Tran Signed-off-by: Nilesh Javali Reviewed-by: Himanshu Madhani Signed-off-by: Martin K. Petersen commit 87f6dafd50fb6d7214c32596a11b983138b09123 Author: Quinn Tran Date: Wed Dec 21 20:39:26 2022 -0800 scsi: qla2xxx: Remove dead code (GNN ID) Remove stale/unused code (GNN ID). Signed-off-by: Quinn Tran Signed-off-by: Nilesh Javali Reviewed-by: Himanshu Madhani Signed-off-by: Martin K. Petersen commit b9d87b60aaeb08ded3a8cfd4538085e6e2bc814f Author: Quinn Tran Date: Wed Dec 21 20:39:25 2022 -0800 scsi: qla2xxx: Remove dead code (GPNID) Remove stale unused code for GPNID. Signed-off-by: Quinn Tran Signed-off-by: Nilesh Javali Reviewed-by: Himanshu Madhani Signed-off-by: Martin K. Petersen commit efd1bd12a04d7fffcb31662298e5e3e814bff49c Author: Quinn Tran Date: Wed Dec 21 20:39:24 2022 -0800 scsi: qla2xxx: Remove dead code Removing drport field and FCPORT_UPDATE_NEEDED signals. Signed-off-by: Quinn Tran Signed-off-by: Nilesh Javali Reviewed-by: Himanshu Madhani Signed-off-by: Martin K. Petersen commit 8fe66badf036d7505f9f4a03420d39b3ad819965 Author: Dan Carpenter Date: Thu Jan 5 13:53:35 2023 +0300 scsi: libsas: Fix an error code in sas_ata_add_dev() This code accidentally returns success instead of -ENOMEM. Fixes: 7cc7646b4b24 ("scsi: libsas: Factor out sas_ata_add_dev()") Link: https://lore.kernel.org/r/Y7asLxzVwQ56G+ya@kili Signed-off-by: Dan Carpenter Reviewed-by: Jason Yan Signed-off-by: Martin K. Petersen commit e2cb6e8db69e96c1514c2992e2d4fd6c8c1b8820 Author: Bean Huo Date: Sun Jan 8 23:40:57 2023 +0100 scsi: ufs: core: bsg: Fix cast to restricted __be16 warning Fix the following sparse endianness warning: "sparse warnings: drivers/ufs/core/ufs_bsg.c:91:25: sparse: sparse: cast to restricted __be16." For consistency with endianness annotations of other UFS data structures, change __u16/32 to __be16/32 in UFS ARPMB data structures. Fixes: 6ff265fc5ef6 ("scsi: ufs: core: bsg: Add advanced RPMB support in ufs_bsg") Reported-by: kernel test robot Signed-off-by: Bean Huo Reviewed-by: Bart Van Assche Signed-off-by: Martin K. Petersen commit f3e57da528127febae7eb03d9c87408d572b0fd8 Author: Bean Huo Date: Sun Jan 8 23:40:56 2023 +0100 scsi: core: Fix invisible definition compilation warning In 'include/ufs/ufshcd.h' file, 'enum dma_data_direction' will be used, which is defined in linux/dma-direction.h, however, this header file is not included in ufshcd.h, thus causing the following compilation warning: "warning: ‘enum dma_data_direction’ declared inside parameter list will not be visible outside of this definition or declaration" Fix this warning by including 'linux/dma-direction.h'. Fixes: 6ff265fc5ef6 ("scsi: ufs: core: bsg: Add advanced RPMB support in ufs_bsg") Reported-by: Xiaosen He Reported-by: Bart Van Assche Signed-off-by: Bean Huo Reviewed-by: Bart Van Assche Signed-off-by: Martin K. Petersen commit 5e87c51f186ef70b17201f97db11044e3e7ffa46 Author: Bean Huo Date: Sun Jan 8 23:40:55 2023 +0100 scsi: ufs: core: bsg: Fix sometimes-uninitialized warnings Compilation complains that two possible variables are used without initialization: drivers/ufs/core/ufs_bsg.c:112:6: warning: variable 'sg_cnt' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized] drivers/ufs/core/ufs_bsg.c:112:6: warning: variable 'sg_list' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized] Fix both warnings by adding initialization with sg_cnt = 0, sg_list = NULL. Fixes: 6ff265fc5ef6 ("scsi: ufs: core: bsg: Add advanced RPMB support in ufs_bsg") Signed-off-by: Bean Huo Reported-by: kernel test robot Reported-by: Xiaosen He Reviewed-by: Alim Akhtar Reviewed-by: Nick Desaulniers Reviewed-by: Bart Van Assche Signed-off-by: Martin K. Petersen commit 679062c65b2c7824b5bf6cef9d286ef101466122 Author: Deepak R Varma Date: Fri Dec 9 01:41:43 2022 +0530 scsi: pm8001: Use sysfs_emit() in show function callbacks According to Documentation/filesystems/sysfs.rst, the show() callback function of kobject attributes should use sysfs_emit() instead of the sprintf() family of functions. Issue identified using the coccinelle device_attr_show.cocci script. Link: https://lore.kernel.org/r/Y5JE/xI2NNbnox/A@qemulion Signed-off-by: Deepak R Varma Acked-by: Jack Wang Signed-off-by: Martin K. Petersen commit 39beef59128f6cf6a5d49e4c0dfd69dabe50b0c5 Author: Manivannan Sadhasivam Date: Thu Dec 22 19:40:01 2022 +0530 scsi: MAINTAINERS: Add myself as the maintainer for Qcom UFS drivers Qcom UFS drivers are left unmaintained till now. I'd like to step up to maintain the drivers and the binding. Acked-by: Bjorn Andersson Signed-off-by: Manivannan Sadhasivam Signed-off-by: Martin K. Petersen commit 2c407fe97015a063855fa518bd790f024f818277 Author: Manivannan Sadhasivam Date: Thu Dec 22 19:40:00 2022 +0530 scsi: ufs: ufs-qcom: Add support for finding max gear on new platforms Starting from Qcom UFS version 4.0, vendor specific REG_UFS_PARAM0 register can be used to determine the maximum gear supported by the controller. Suggested-by: Can Guo Reviewed-by: Andrew Halaney Tested-by: Andrew Halaney # Qdrive3/sa8540p-ride Signed-off-by: Manivannan Sadhasivam Signed-off-by: Martin K. Petersen commit baf5ddac90dc1983bc376b7ca6fe1afde702ff29 Author: Manivannan Sadhasivam Date: Thu Dec 22 19:39:59 2022 +0530 scsi: ufs: ufs-qcom: Add support for reinitializing the UFS device Starting from Qualcomm UFS version 4, the UFS device needs to be reinitialized after switching to maximum gear by the UFS core. Hence, add support for it by enabling the UFSHCD_QUIRK_REINIT_AFTER_MAX_GEAR_SWITCH quirk, implementing reinit_notify() callback and using the agreed gear speed for setting the PHY mode. Suggested-by: Can Guo Tested-by: Andrew Halaney # Qdrive3/sa8540p-ride Signed-off-by: Manivannan Sadhasivam Signed-off-by: Martin K. Petersen commit c270986527f9fccb140826cbf3eff2cb1fccf463 Author: Manivannan Sadhasivam Date: Thu Dec 22 19:39:58 2022 +0530 scsi: ufs: ufs-qcom: Factor out the logic finding the HS Gear In the preparation of adding support for new gears, move the logic that finds the gear for each platform to a new function. This helps with code readability and also allows the logic to be used in other places of the driver in future. While at it, make it clear that this driver only supports symmetric gear setting (hs_tx_gear == hs_rx_gear). Reviewed-by: Andrew Halaney Tested-by: Andrew Halaney # Qdrive3/sa8540p-ride Signed-off-by: Manivannan Sadhasivam Signed-off-by: Martin K. Petersen commit 96a7141da33207672d7a354c885d65af4f0f9b6c Author: Manivannan Sadhasivam Date: Thu Dec 22 19:39:57 2022 +0530 scsi: ufs: core: Add support for reinitializing the UFS device Some platforms like Qcom, requires the UFS device to be reinitialized after switching to maximum gear speed. So add support for that in UFS core by introducing a new quirk (UFSHCD_CAP_REINIT_AFTER_MAX_GEAR_SWITCH) and doing the reinitialization, if the quirk is enabled by the controller driver. Suggested-by: Can Guo Tested-by: Andrew Halaney # Qdrive3/sa8540p-ride Signed-off-by: Manivannan Sadhasivam Reviewed-by: Bart Van Assche Signed-off-by: Martin K. Petersen commit c2c38c573a2e6184f9acd10e98305d3cb5f1c62b Author: Manivannan Sadhasivam Date: Thu Dec 22 19:39:56 2022 +0530 scsi: ufs: core: Add reinit_notify() callback reinit_notify() callback can be used by the UFS controller drivers to perform changes required for UFSHCD reinit that can happen during max gear switch. Tested-by: Andrew Halaney # Qdrive3/sa8540p-ride Signed-off-by: Manivannan Sadhasivam Reviewed-by: Bart Van Assche Signed-off-by: Martin K. Petersen commit 7959587f3284bf163e4f1baff3c6fa71fc6a55b1 Author: Manivannan Sadhasivam Date: Thu Dec 22 19:39:55 2022 +0530 scsi: ufs: ufs-qcom: Fix the Qcom register name for offset 0xD0 On newer UFS revisions, the register at offset 0xD0 is called, REG_UFS_PARAM0. Since the existing register, RETRY_TIMER_REG is not used anywhere, it is safe to use the new name. Reviewed-by: Andrew Halaney Reviewed-by: Asutosh Das Tested-by: Andrew Halaney # Qdrive3/sa8540p-ride Signed-off-by: Manivannan Sadhasivam Signed-off-by: Martin K. Petersen commit 132b027205ef94a1d933d0f08a4109b1e321bda2 Author: Manivannan Sadhasivam Date: Thu Dec 22 19:39:54 2022 +0530 scsi: ufs: ufs-qcom: Use dev_err_probe() for printing probe error Make use of dev_err_probe() for printing the probe error. Reviewed-by: Andrew Halaney Reviewed-by: Asutosh Das Tested-by: Andrew Halaney # Qdrive3/sa8540p-ride Signed-off-by: Manivannan Sadhasivam Signed-off-by: Martin K. Petersen commit 18fe2ab79bcf00c17d00460ca3f8c179d0aa87a4 Author: Manivannan Sadhasivam Date: Thu Dec 22 19:39:53 2022 +0530 scsi: ufs: ufs-qcom: Use bitfields where appropriate Use bitfield macros where appropriate to simplify the driver. Reviewed-by: Dmitry Baryshkov Reviewed-by: Asutosh Das Tested-by: Andrew Halaney # Qdrive3/sa8540p-ride Signed-off-by: Manivannan Sadhasivam Signed-off-by: Martin K. Petersen commit a98c2183e81d746d8d4d4443359a7c2876a14e3f Author: Manivannan Sadhasivam Date: Thu Dec 22 19:39:52 2022 +0530 scsi: ufs: ufs-qcom: Remove unnecessary WARN_ON() In the reset assert and deassert callbacks, the supplied "id" is not used at all and only the HBA reset is performed all the time. So there is no reason to use a WARN_ON() on the "id". Reviewed-by: Andrew Halaney Reviewed-by: Asutosh Das Tested-by: Andrew Halaney # Qdrive3/sa8540p-ride Signed-off-by: Manivannan Sadhasivam Signed-off-by: Martin K. Petersen commit 031312dbc6950a6a661f2f9ecfbc21fbc2e0e3e3 Author: Manivannan Sadhasivam Date: Thu Dec 22 19:39:51 2022 +0530 scsi: ufs: ufs-qcom: Remove unnecessary goto statements A goto statement in an error path is useful if the function needs to do cleanup other than returning the error code. But in this driver, goto statements are used for just returning the error code in many places. This really makes it hard to read the code. Get rid of those goto statements and just return the error code directly. Reviewed-by: Dmitry Baryshkov Reviewed-by: Asutosh Das Tested-by: Andrew Halaney # Qdrive3/sa8540p-ride Signed-off-by: Manivannan Sadhasivam Signed-off-by: Martin K. Petersen commit f590c2554c7764a91e83f29347a1e27c4d9f1335 Author: Nilesh Javali Date: Mon Dec 19 03:07:48 2022 -0800 scsi: qla2xxx: Update version to 10.02.08.100-k Signed-off-by: Nilesh Javali Reviewed-by: Himanshu Madhani Signed-off-by: Martin K. Petersen commit 1e27648c848235046cfd83e656c1c0d360861f25 Author: Nilesh Javali Date: Mon Dec 19 03:07:47 2022 -0800 scsi: qla2xxx: Fix IOCB resource check warning Make qla_get_iocbs_resource() static to fix the warning: >> drivers/scsi/qla2xxx/qla_iocb.c:3820:5: warning: no previous prototype for >> 'qla_get_iocbs_resource' [-Wmissing-prototypes] 3820 | int qla_get_iocbs_resource(struct srb *sp) | ^~~~~~~~~~~~~~~~~~~~~~ Reported-by: kernel test robot Signed-off-by: Nilesh Javali Signed-off-by: Martin K. Petersen commit d676a9e3d9efb7e93df460bcf4c445496c16314f Author: Saurav Kashyap Date: Mon Dec 19 03:07:46 2022 -0800 scsi: qla2xxx: Remove increment of interface err cnt Residual underrun is not an interface error, hence no need to increment that count. Fixes: dbf1f53cfd23 ("scsi: qla2xxx: Implementation to get and manage host, target stats and initiator port") Cc: stable@vger.kernel.org Signed-off-by: Saurav Kashyap Signed-off-by: Nilesh Javali Reviewed-by: Himanshu Madhani Signed-off-by: Martin K. Petersen commit 3fbc74feb642deb688cc97f76d40b7287ddd4cb1 Author: Quinn Tran Date: Mon Dec 19 03:07:45 2022 -0800 scsi: qla2xxx: Fix erroneous link down If after an adapter reset the appearance of link is not recovered, the devices are not rediscovered. This is result of a race condition between adapter reset (abort_isp) and the topology scan. During adapter reset, the ABORT_ISP_ACTIVE flag is set. Topology scan usually occurred after adapter reset. In this case, the topology scan came earlier than usual where it ran into problem due to ABORT_ISP_ACTIVE flag was still set. kernel: qla2xxx [0000:13:00.0]-1005:1: Cmd 0x6a aborted with timeout since ISP Abort is pending kernel: qla2xxx [0000:13:00.0]-28a0:1: MBX_GET_PORT_NAME failed, No FL Port. kernel: qla2xxx [0000:13:00.0]-286b:1: qla2x00_configure_loop: exiting normally. local port wwpn 51402ec0123d9a80 id 012300) kernel: qla2xxx [0000:13:00.0]-8017:1: ADAPTER RESET SUCCEEDED nexus=1:0:15. Allow adapter reset to complete before any scan can start. Cc: stable@vger.kernel.org Signed-off-by: Quinn Tran Signed-off-by: Nilesh Javali Reviewed-by: Himanshu Madhani Signed-off-by: Martin K. Petersen commit 7e8a936a2d0f98dd6e5d05d4838affabe606cabc Author: Quinn Tran Date: Mon Dec 19 03:07:44 2022 -0800 scsi: qla2xxx: Remove unintended flag clearing FCF_ASYNC_SENT flag is used in session management. This flag is cleared in task management path by accident. Remove unintended flag clearing. Fixes: 388a49959ee4 ("scsi: qla2xxx: Fix panic from use after free in qla2x00_async_tm_cmd") Cc: stable@vger.kernel.org Signed-off-by: Quinn Tran Signed-off-by: Nilesh Javali Reviewed-by: Himanshu Madhani Signed-off-by: Martin K. Petersen commit 40f5b1b9a4af2917f97bd98f277baebad8cde323 Author: Quinn Tran Date: Mon Dec 19 03:07:43 2022 -0800 scsi: qla2xxx: Fix stalled login If a login failed due to low FW resources, the session can stall and will not be connected. Reset session state to allow relogin logic to redrive the connection. Signed-off-by: Quinn Tran Signed-off-by: Nilesh Javali Reviewed-by: Himanshu Madhani Signed-off-by: Martin K. Petersen commit 5f63a163ed2f12c34dd4ae9b2757962ec7bb86e5 Author: Quinn Tran Date: Mon Dec 19 03:07:42 2022 -0800 scsi: qla2xxx: Fix exchange oversubscription for management commands Add resource checking for management (non-I/O) commands. Fixes: 89c72f4245a8 ("scsi: qla2xxx: Add IOCB resource tracking") Signed-off-by: Quinn Tran Signed-off-by: Nilesh Javali Signed-off-by: Martin K. Petersen commit 41e5afe51f75f2858f5563145348f6c26d307b8f Author: Quinn Tran Date: Mon Dec 19 03:07:41 2022 -0800 scsi: qla2xxx: Fix exchange oversubscription In large environment, it is possible to experience command timeout and escalation of path recovery. Currently the driver does not track the number of exchanges/commands sent to FW. If there is a delay for commands at the head of the queue, then this will create back pressure for commands at the back of the queue. Check for exchange availability before command submission. Fixes: 89c72f4245a8 ("scsi: qla2xxx: Add IOCB resource tracking") Signed-off-by: Quinn Tran Signed-off-by: Nilesh Javali Reviewed-by: Himanshu Madhani Signed-off-by: Martin K. Petersen commit c75e6aef5039830cce5d4cf764dd204522f89e6b Author: Arun Easi Date: Mon Dec 19 03:07:40 2022 -0800 scsi: qla2xxx: Fix DMA-API call trace on NVMe LS requests The following message and call trace was seen with debug kernels: DMA-API: qla2xxx 0000:41:00.0: device driver failed to check map error [device address=0x00000002a3ff38d8] [size=1024 bytes] [mapped as single] WARNING: CPU: 0 PID: 2930 at kernel/dma/debug.c:1017 check_unmap+0xf42/0x1990 Call Trace: debug_dma_unmap_page+0xc9/0x100 qla_nvme_ls_unmap+0x141/0x210 [qla2xxx] Remove DMA mapping from the driver altogether, as it is already done by FC layer. This prevents the warning. Fixes: c85ab7d9e27a ("scsi: qla2xxx: Fix missed DMA unmap for NVMe ls requests") Cc: stable@vger.kernel.org Signed-off-by: Arun Easi Signed-off-by: Nilesh Javali Reviewed-by: Himanshu Madhani Signed-off-by: Martin K. Petersen commit b1ae65c082f74536ec292b15766f2846f0238373 Author: Quinn Tran Date: Mon Dec 19 03:07:39 2022 -0800 scsi: qla2xxx: Fix link failure in NPIV environment User experienced symptoms of adapter failure in NPIV environment. NPIV hosts were allowed to trigger chip reset back to back due to NPIV link state being slow to come online. Fix link failure in NPIV environment by removing NPIV host from directly being able to perform chip reset. kernel: qla2xxx [0000:04:00.1]-6009:261: Loop down - aborting ISP. kernel: qla2xxx [0000:04:00.1]-6009:262: Loop down - aborting ISP. kernel: qla2xxx [0000:04:00.1]-6009:281: Loop down - aborting ISP. kernel: qla2xxx [0000:04:00.1]-6009:285: Loop down - aborting ISP Fixes: 0d6e61bc6a4f ("[SCSI] qla2xxx: Correct various NPIV issues.") Cc: stable@vger.kernel.org Signed-off-by: Quinn Tran Signed-off-by: Nilesh Javali Reviewed-by: Himanshu Madhani Signed-off-by: Martin K. Petersen commit 0c227dc22ca18856055983f27594feb2e0149965 Author: Shreyas Deodhar Date: Mon Dec 19 03:07:38 2022 -0800 scsi: qla2xxx: Check if port is online before sending ELS CT Ping and ELS cmds fail for NVMe targets. Check if port is online before sending ELS instead of sending login. Cc: stable@vger.kernel.org Signed-off-by: Shreyas Deodhar Signed-off-by: Nilesh Javali Reviewed-by: Himanshu Madhani Signed-off-by: Martin K. Petersen commit df7320bac37e837f43883a51ce879c07c4429180 Author: Zhe Wang Date: Fri Dec 9 20:41:21 2022 +0800 scsi: ufs: ufs-unisoc: Add support for Unisoc UFS host controller Add driver code for Unisoc UFS host controller, along with UFS initialization. Signed-off-by: Zhe Wang Reviewed-by: Bart Van Assche Signed-off-by: Martin K. Petersen commit aa67971b2736e1eb0e09bb71212f4ccd536b0a63 Author: Zhe Wang Date: Fri Dec 9 20:41:20 2022 +0800 scsi: ufs: dt-bindings: Add document for Unisoc UFS host controller Add Unisoc ums9620 UFS host controller devicetree document. Signed-off-by: Zhe Wang Reviewed-by: Krzysztof Kozlowski Signed-off-by: Martin K. Petersen commit a67aad57d9aee41180aff36e54cb72fe4b8d5a5a Author: Xingui Yang Date: Wed Dec 21 01:52:03 2022 +0000 scsi: libsas: Grab the ATA port lock in sas_ata_device_link_abort() Grab the ATA port lock in sas_ata_device_link_abort() before calling ata_link_abort() as outlined in this function's locking requirements. Fixes: 44112922674b ("scsi: libsas: Add sas_ata_device_link_abort()") Signed-off-by: Xingui Yang Reviewed-by: John Garry Reviewed-by: Jason Yan Signed-off-by: Martin K. Petersen commit ea44242bbfcde2993fb27ec7c3ad5ab5cc39e438 Author: Jason Yan Date: Thu Dec 15 12:09:25 2022 +0800 scsi: hisi_sas: Fix tag freeing for reserved tags The reserved tags were put in the lower region of the tagset in commit f7d190a94e35 ("scsi: hisi_sas: Put reserved tags in lower region of tagset"). However, only the allocate function was changed, freeing was not handled. This resulted in a failure to boot: [ 33.467345] hisi_sas_v3_hw 0000:b4:02.0: task exec: failed[-132]! [ 33.473413] sas: Executing internal abort failed 5000000000000603 (-132) [ 33.480088] hisi_sas_v3_hw 0000:b4:02.0: I_T nexus reset: internal abort (-132) [ 33.657336] hisi_sas_v3_hw 0000:b4:02.0: task exec: failed[-132]! [ 33.663403] ata7.00: failed to IDENTIFY (I/O error, err_mask=0x40) [ 35.787344] hisi_sas_v3_hw 0000:b4:04.0: task exec: failed[-132]! [ 35.793411] sas: Executing internal abort failed 5000000000000703 (-132) [ 35.800084] hisi_sas_v3_hw 0000:b4:04.0: I_T nexus reset: internal abort (-132) [ 35.977335] hisi_sas_v3_hw 0000:b4:04.0: task exec: failed[-132]! [ 35.983403] ata10.00: failed to IDENTIFY (I/O error, err_mask=0x40) [ 35.989643] ata10.00: revalidation failed (errno=-5) Fixes: f7d190a94e35 ("scsi: hisi_sas: Put reserved tags in lower region of tagset") Cc: John Garry Cc: Xiang Chen Signed-off-by: Jason Yan Reviewed-by: John Garry Acked-by: Xiang Chen Signed-off-by: Martin K. Petersen commit 16ed9d312b42180242476d159dd2fab05129029a Author: Arthur Simchaev Date: Sun Dec 11 15:05:11 2022 +0200 scsi: ufs: core: Remove ufshcd_map_desc_id_to_length() There shouldn't be any restriction of the descriptor size (not the descriptor id for that matter) up to QUERY_DESC_MAX_SIZE. According to the spec, the caller can use any descriptor size, and it is up to the device to return the actual size. Therefore there shouldn't be any sizes hardcoded in the kernel, nor any need to cache it, hence the ufshcd_map_desc_id_to_length() function is redundant. Always read the descriptors with QUERY_DESC_MAX_SIZE size. Reviewed-by: Bart Van Assche Reviewed-by: Bean Huo Suggested-by: Bean Huo Signed-off-by: Arthur Simchaev Signed-off-by: Martin K. Petersen commit 01a0d515b7d93f6f5259c0333e48ac0ed8f0aa92 Author: Arthur Simchaev Date: Sun Dec 11 15:05:10 2022 +0200 scsi: ufs: core: Remove len parameter from ufshcd_set_active_icc_lvl() len argument is not used anymore in ufshcd_set_active_icc_lvl() function. Signed-off-by: Arthur Simchaev Reviewed-by: Bart Van Assche Reviewed-by: Bean Huo Signed-off-by: Martin K. Petersen commit f2a89b071b26b79abbe892ce88c4d674d1f21f63 Author: Arthur Simchaev Date: Sun Dec 11 15:05:09 2022 +0200 scsi: ufs: core: Remove redundant desc_size variable from hba Always read the descriptor with QUERY_DESC_MAX_SIZE. According to the spec, the device returns the actual size. Signed-off-by: Arthur Simchaev Reviewed-by: Bean Huo Reviewed-by: Bart Van Assche Signed-off-by: Martin K. Petersen commit 358ae02f47783c1d2a8033e50563ea1a9d176c15 Author: Arthur Simchaev Date: Sun Dec 11 15:05:08 2022 +0200 scsi: ufs: core: Remove redundant wb check We used to use the extended-feature field in the device descriptor as an indication that the device supported UFS 2.2 or later. Remove that as this check is specifically done few lines above. Signed-off-by: Arthur Simchaev Reviewed-by: Bart Van Assche Reviewed-by: Bean Huo Reviewed-by: Stanley Chu Signed-off-by: Martin K. Petersen commit ada1e653a5eae7361d95781ed812caa0c8e07dbb Author: Eric Biggers Date: Thu Dec 8 15:43:58 2022 -0800 scsi: ufs: core: Allow UFS host drivers to override the sg entry size Modify the UFSHCD core to allow 'struct ufshcd_sg_entry' to be variable-length. The default is the standard length, but variants can override ufs_hba::sg_entry_size with a larger value if there are vendor-specific fields following the standard ones. This is needed to support inline encryption with ufs-exynos (FMP). Cc: Eric Biggers Reviewed-by: Avri Altman Signed-off-by: Eric Biggers [ bvanassche: edited commit message and introduced CONFIG_SCSI_UFS_VARIABLE_SG_ENTRY_SIZE ] Signed-off-by: Bart Van Assche Signed-off-by: Martin K. Petersen commit b434ecfb73ee84fbc5996d0784a4436e75b8d0fe Author: Bart Van Assche Date: Thu Dec 8 15:43:57 2022 -0800 scsi: ufs: core: Pass the clock scaling timeout as an argument Prepare for adding an additional ufshcd_clock_scaling_prepare() call with a different timeout. Reviewed-by: Avri Altman Signed-off-by: Bart Van Assche Signed-off-by: Martin K. Petersen commit 2000bc309703b34ab776c7c00dfb5865721eb257 Author: Bart Van Assche Date: Thu Dec 8 15:43:56 2022 -0800 scsi: ufs: core: Reduce the clock scaling latency Wait at most 20 ms before rechecking the doorbells instead of waiting for a potentially long time between doorbell checks. Reviewed-by: Avri Altman Reviewed-by: Stanley Chu Signed-off-by: Bart Van Assche Signed-off-by: Martin K. Petersen commit 1026f7d366785d0a1edae731a3d06e9924c3e71d Author: Andrew Halaney Date: Thu Dec 1 17:08:10 2022 -0600 scsi: ufs: ufs-qcom: Use dev_err() where possible dev_err() statements are better to use than pr_err(), so switch to those. In a similar vein, the check on the dev_req_params pointer here is not needed, the two places this function is called never pass in a NULL pointer, so instead of using dev_err() there just remove it. Signed-off-by: Andrew Halaney Reviewed-by: Manivannan Sadhasivam Reviewed-by: Asutosh Das Signed-off-by: Martin K. Petersen commit e4ce23fba366e5b0629b13d9c42e68fab7fda002 Author: Andrew Halaney Date: Thu Dec 1 17:08:09 2022 -0600 scsi: ufs: ufs-qcom: Remove usage of dbg_print_en This bitmask is unconditionally set in the current driver, so all conditionals using it can be considered bit rot. Let's take the current default conditional path everywhere and remove dbg_print_en from the driver. Signed-off-by: Andrew Halaney Reviewed-by: Manivannan Sadhasivam Reviewed-by: Asutosh Das Signed-off-by: Martin K. Petersen commit 50a427a00c85995009a134d443949e5128a84191 Author: Andrew Halaney Date: Thu Dec 1 17:08:08 2022 -0600 scsi: ufs: ufs-qcom: Clean up dbg_register_dump The current implementation has abstractions that don't give any benefits. The print_fn callback (and its only callback implementation, ufs_qcom_dump_regs_wrapper()) was only used by ufs_qcom_print_hw_debug_reg_all() and just multiplies len by 4 before calling ufshcd_dump_regs(). ufs_qcom_print_hw_debug_reg_all() is only called by ufs_qcom_dump_dbg_regs(). There's no real gain in those abstractions, so let's just do the work directly in ufs_qcom_dump_dbg_regs() (the dbg_register_dump callback). Signed-off-by: Andrew Halaney Reviewed-by: Manivannan Sadhasivam Reviewed-by: Asutosh Das Signed-off-by: Martin K. Petersen commit 921a880827498e501921bf034012a97e554550d2 Author: Andrew Halaney Date: Thu Dec 1 17:08:07 2022 -0600 scsi: ufs: ufs-qcom: Drop unnecessary NULL checks This code path is only called through one function, and the HBA struct is already accessed in ufshcd_vops_dbg_register_dump() prior to calling so there is no way for it to be NULL. Likewise, the print_fn callback is always supplied within this driver and is always provided. Signed-off-by: Andrew Halaney Reviewed-by: Manivannan Sadhasivam Reviewed-by: Asutosh Das Signed-off-by: Martin K. Petersen commit 6ff265fc5ef660499e0edc4641647e99eed3f519 Author: Bean Huo Date: Thu Dec 1 15:04:37 2022 +0100 scsi: ufs: core: bsg: Add advanced RPMB support in ufs_bsg Add advanced RPMB support in ufs_bsg: 1. According to the UFS specification, only one RPMB operation can be performed at any time. We can ensure this by using reserved slot and its dev_cmd sync operation protection mechanism. 2. For Advanced RPMB, RPMB metadata is packaged in an EHS (Extra Header Segment) of a command UPIU, and the corresponding reply EHS (from the device) should also be returned to the user space. bsg_job->request and bsg_job->reply allow us to pass and return EHS from/back to userspace. Compared to normal/legacy RPMB, the advantages of advanced RPMB are: 1. The data length in the Advanced RPMB data read/write command can be larger than 4KB. For the legacy RPMB, the data length in a single RPMB data transfer is 256 bytes. 2. All of the advanced RPMB operations will be a single command. For legacy RPMB, take the read write-counter value as an example, you need two commands (first SECURITY PROTOCOL OUT, then second SECURITY PROTOCOL IN). Signed-off-by: Bean Huo Reviewed-by: Avri Altman Signed-off-by: Martin K. Petersen commit a4b1c9b9b38c92da099aba234c96e818f8d2e4dd Author: Bean Huo Date: Thu Dec 1 15:04:36 2022 +0100 scsi: ufs: core: Pass EHS length into ufshcd_prepare_req_desc_hdr() We need to fill in the total EHS length in UTP Transfer Request Descriptor. Add this functionality to ufshcd_prepare_req_desc_hdr(). Signed-off-by: Bean Huo Reviewed-by: Avri Altman Signed-off-by: Martin K. Petersen commit f6b9d0fe5c0573ddd0cbf3071a2003897325c86c Author: Bean Huo Date: Thu Dec 1 15:04:35 2022 +0100 scsi: ufs: core: Advanced RPMB detection Check UFS Advanced RPMB LU enablement during ufshcd_lu_init(). Signed-off-by: Bean Huo Signed-off-by: Martin K. Petersen commit 7a4df79d0bfd6d7b4af0badf6254af5e4157094b Author: Bean Huo Date: Thu Dec 1 15:04:34 2022 +0100 scsi: ufs: core: Split ufshcd_map_sg() Take out the "map scatter-gather list to prdt" part of the code in ufshcd_map_sg() and split it into a new function ufshcd_sgl_to_prdt(). Signed-off-by: Bean Huo Reviewed-by: Avri Altman Signed-off-by: Martin K. Petersen commit 765ab00dac2c37070d8a4209e017ae81e1d8e9bb Author: Bean Huo Date: Thu Dec 1 15:04:33 2022 +0100 scsi: ufs: bsg: Clean up ufs_bsg_request() Move sg_copy_from_buffer() below its associated case statement. Signed-off-by: Bean Huo Reviewed-by: Avri Altman Signed-off-by: Martin K. Petersen commit 64d4864714c2cd2af35b48ab5b28a28ee863219a Author: Bean Huo Date: Thu Dec 1 15:04:32 2022 +0100 scsi: ufs: bsg: Remove unnecessary length checkup Remove checks on job->request_len and job->reply_len because msgcode checks in a subseqent commit will rule out malicious requests. Signed-off-by: Bean Huo Acked-by: Avri Altman Signed-off-by: Martin K. Petersen commit 3f5145a6152388ca612461ca96db4f995fa816d2 Author: Bean Huo Date: Thu Dec 1 15:04:31 2022 +0100 scsi: ufs: bsg: Let result in struct ufs_bsg_reply be signed int According to the comments in struct ufs_bsg_reply and its usage, the result should be signed int, not __u32. Signed-off-by: Bean Huo Signed-off-by: Martin K. Petersen commit 5d39b77c33b19089351f74a524fbb828c7d8ba81 Author: Jason Yan Date: Wed Dec 14 21:38:08 2022 +0800 scsi: libsas: Factor out sas_ex_add_dev() Factor out sas_ex_add_dev() to be consistent with sas_ata_add_dev() and unify the error handling. Cc: John Garry Signed-off-by: Jason Yan Reviewed-by: John Garry Signed-off-by: Martin K. Petersen commit 7cc7646b4b24430437e0cff104fadeafd470a7ce Author: Jason Yan Date: Wed Dec 14 21:38:07 2022 +0800 scsi: libsas: Factor out sas_ata_add_dev() Factor out sas_ata_add_dev() and put it in sas_ata.c since it is a SATA related interface. Also follow the standard coding style to define an inline empty function when CONFIG_SCSI_SAS_ATA is not enabled. Cc: John Garry Signed-off-by: Jason Yan Reviewed-by: John Garry Signed-off-by: Martin K. Petersen commit 8d2c9d25b725a699479d388da7e116d1d2bc0ea1 Author: Jason Yan Date: Wed Dec 14 21:38:06 2022 +0800 scsi: libsas: Remove useless dev_list delete in sas_ex_discover_end_dev() The domain device 'child' is allocated in sas_ex_discover_end_dev() and used to be added to the dev_list in this function. After the following two fixes the device is added to the disco_list instead. As a result, the list_del() and locking left behind is now redundant. Fixes: 87c8331fcf72 ("[SCSI] libsas: prevent domain rediscovery competing with ata error handling") Fixes: 92625f9bff38 ("[SCSI] libsas: restore scan order") Cc: John Garry Signed-off-by: Jason Yan Reviewed-by: John Garry Signed-off-by: Martin K. Petersen commit ffebb38efee3e6bbcccd0b7babf0ede8890794cd Author: Jason Yan Date: Wed Dec 14 21:38:05 2022 +0800 scsi: libsas: Change the coding style of sas_discover_sata() The coding style where calling this interface is inconsistent with other interfaces for SATA devices. The standard style for other SATA interfaces is like: #ifdefine CONFIG_SCSI_SAS_ATA void sas_ata_task_abort(struct sas_task *task); #else static inline void sas_ata_task_abort(struct sas_task *task) { } #endif And the callers does not have to do things like "#ifdefine CONFIG_SCSI_SAS_ATA" and may call the interface directly. So follow the standard style here. Cc: John Garry Signed-off-by: Jason Yan Reviewed-by: Jack Wang Reviewed-by: John Garry Signed-off-by: Martin K. Petersen commit 6c90466e2803d93ed47a980fbf184d35e012d895 Author: Jason Yan Date: Wed Dec 14 21:38:04 2022 +0800 scsi: libsas: Move sas_get_ata_command_set() up to save the declaration There is a sas_get_ata_command_set() declaration above sas_get_ata_info() to make it compile. However, this function is defined in the same file. Move it up to save the forward declaration. Also remove the variable 'fis' which is not needed in this function. Cc: John Garry Signed-off-by: Jason Yan Reviewed-by: John Garry Reviewed-by: Jack Wang Signed-off-by: Martin K. Petersen commit 1a5665fc8d7a000671ebd3fe69c6f9acf1e0dcd9 Author: Peter Wang Date: Thu Dec 8 15:25:20 2022 +0800 scsi: ufs: core: WLUN suspend SSU/enter hibern8 fail recovery When SSU/enter hibern8 fail in WLUN suspend flow, trigger the error handler and return busy to break the suspend. Otherwise the consumer will get stuck in runtime suspend status. Fixes: b294ff3e3449 ("scsi: ufs: core: Enable power management for wlun") Signed-off-by: Peter Wang Link: https://lore.kernel.org/r/20221208072520.26210-1-peter.wang@mediatek.com Reviewed-by: Stanley Chu Reviewed-by: Bart Van Assche Reviewed-by: Adrian Hunter Signed-off-by: Martin K. Petersen commit c411a42fb91f452509c312e4dda713699a22a995 Author: John Garry Date: Tue Dec 13 14:21:22 2022 +0000 scsi: scsi_debug: Delete unreachable code in inquiry_vpd_b0() The 2nd return statement in inquiry_vpd_b0() is unreachable, so delete it. Signed-off-by: John Garry Link: https://lore.kernel.org/r/20221213142122.1011886-1-john.g.garry@oracle.com Reviewed-by: Jason Yan Signed-off-by: Martin K. Petersen commit f0a43ba6c66cc0688e2748d986a1459fdd3442ef Author: Shin'ichiro Kawasaki Date: Wed Dec 7 11:36:59 2022 +0900 scsi: mpi3mr: Refer CONFIG_SCSI_MPI3MR in Makefile When Kconfig item CONFIG_SCSI_MPI3MR was introduced for mpi3mr driver, the Makefile of the driver was not modified to refer the Kconfig item. As a result, mpi3mr.ko is built regardless of the Kconfig item value y or m. Also, if 'make localmodconfig' can not find the Kconfig item in the Makefile, then it does not generate CONFIG_SCSI_MPI3MR=m even when mpi3mr.ko is loaded on the system. Refer to the Kconfig item to avoid the issues. Fixes: c4f7ac64616e ("scsi: mpi3mr: Add mpi30 Rev-R headers and Kconfig") Signed-off-by: Shin'ichiro Kawasaki Link: https://lore.kernel.org/r/20221207023659.2411785-1-shinichiro.kawasaki@wdc.com Reviewed-by: Damien Le Moal Acked-by: Sathya Prakash Veerichetty Signed-off-by: Martin K. Petersen commit d0b9025540ef57cc4464ab2fc64ed8ddc49b5658 Author: Hannes Reinecke Date: Tue Dec 6 14:13:45 2022 +0100 scsi: core: scsi_error: Do not queue pointless abort workqueue functions If a host template doesn't implement the .eh_abort_handler() there is no point in queueing the abort workqueue function; all it does is invoking SCSI EH anyway. So return 'FAILED' from scsi_abort_command() if the .eh_abort_handler() is not implemented and save us from having to wait for the abort workqueue function to complete. Cc: Niklas Cassel Cc: Damien Le Moal Cc: John Garry Signed-off-by: Hannes Reinecke [niklas: moved the check to the top of scsi_abort_command()] Signed-off-by: Niklas Cassel Link: https://lore.kernel.org/r/20221206131346.2045375-1-niklas.cassel@wdc.com Reviewed-by: John Garry Signed-off-by: Martin K. Petersen commit 67ff3d0a49f3d445c3922e30a54e03c161da561e Author: Michael Kelley Date: Sun Dec 4 11:52:44 2022 -0800 scsi: storvsc: Fix swiotlb bounce buffer leak in confidential VM storvsc_queuecommand() maps the scatter/gather list using scsi_dma_map(), which in a confidential VM allocates swiotlb bounce buffers. If the I/O submission fails in storvsc_do_io(), the I/O is typically retried by higher level code, but the bounce buffer memory is never freed. The mostly like cause of I/O submission failure is a full VMBus channel ring buffer, which is not uncommon under high I/O loads. Eventually enough bounce buffer memory leaks that the confidential VM can't do any I/O. The same problem can arise in a non-confidential VM with kernel boot parameter swiotlb=force. Fix this by doing scsi_dma_unmap() in the case of an I/O submission error, which frees the bounce buffer memory. Fixes: 743b237c3a7b ("scsi: storvsc: Add Isolation VM support for storvsc driver") Signed-off-by: Michael Kelley Link: https://lore.kernel.org/r/1670183564-76254-1-git-send-email-mikelley@microsoft.com Tested-by: Dexuan Cui Reviewed-by: Dexuan Cui Reviewed-by: Tianyu Lan Signed-off-by: Martin K. Petersen commit a3be19b91ea7121d388084e8c07f5b1b982eb40c Author: Wenchao Hao Date: Sat Nov 26 09:07:52 2022 +0800 scsi: iscsi: Fix multiple iSCSI session unbind events sent to userspace It was observed that the kernel would potentially send ISCSI_KEVENT_UNBIND_SESSION multiple times. Introduce 'target_state' in iscsi_cls_session() to make sure session will send only one unbind session event. This introduces a regression wrt. the issue fixed in commit 13e60d3ba287 ("scsi: iscsi: Report unbind session event when the target has been removed"). If iscsid dies for any reason after sending an unbind session to kernel, once iscsid is restarted, the kernel's ISCSI_KEVENT_UNBIND_SESSION event is lost and userspace is then unable to logout. However, the session is actually in invalid state (its target_id is INVALID) so iscsid should not sync this session during restart. Consequently we need to check the session's target state during iscsid restart. If session is in unbound state, do not sync this session and perform session teardown. This is OK because once a session is unbound, we can not recover it any more (mainly because its target id is INVALID). Signed-off-by: Wenchao Hao Link: https://lore.kernel.org/r/20221126010752.231917-1-haowenchao@huawei.com Reviewed-by: Mike Christie Reviewed-by: Wu Bo Signed-off-by: Martin K. Petersen commit d347a951906b506c485ee9ffb76fe473b41f3e10 Author: Sreekanth Reddy Date: Fri Nov 11 15:52:46 2022 +0530 scsi: mpi3mr: Remove usage of dma_get_required_mask() API Remove the usage of dma_get_required_mask() API. Directly set the DMA mask to 63/64 if the system is a 64bit machine. Signed-off-by: Sreekanth Reddy Link: https://lore.kernel.org/r/20221111102246.19995-2-sreekanth.reddy@broadcom.com Signed-off-by: Martin K. Petersen commit 06e472acf964649a58b7de35fc9cdc3151acb970 Author: Sreekanth Reddy Date: Fri Oct 28 14:46:55 2022 +0530 scsi: mpt3sas: Remove usage of dma_get_required_mask() API Remove the usage of dma_get_required_mask() API. Directly set the DMA mask to 63/64 if the system is a 64bit machine. Signed-off-by: Sreekanth Reddy Link: https://lore.kernel.org/r/20221028091655.17741-2-sreekanth.reddy@broadcom.com Reviewed-by: Christoph Hellwig Signed-off-by: Martin K. Petersen