commit ba0f09b0dbd81f04d8621377c72a93ab1bd34ada Author: Bart Van Assche Date: Mon Mar 25 15:47:54 2024 -0700 scsi: core: Improve the code for showing commands in debugfs Some but not all command information is cleared by scsi_end_request(). As an example, if scsi_show_rq() is called after a SCSI command has been allocated and before SCMD_INITIALIZED is set, .cmnd holds the CDB of a previous command. Showing that information in debugfs is confusing. Hence this patch that restricts the information shown in debugfs to valid information. Signed-off-by: Bart Van Assche Link: https://lore.kernel.org/r/20240325224755.1477910-3-bvanassche@acm.org Signed-off-by: Martin K. Petersen commit 9972c02a806772f61ff0da7c3740be4ef0600553 Author: Bart Van Assche Date: Mon Mar 25 15:47:53 2024 -0700 scsi: core: Introduce scsi_cmd_list_info() Slightly improve code readability by introducing a helper function for deriving the list information and by using guard() + return instead of goto + explicit unlock + return. Signed-off-by: Bart Van Assche Link: https://lore.kernel.org/r/20240325224755.1477910-2-bvanassche@acm.org Signed-off-by: Martin K. Petersen commit a2530eb748fff3966d3b20d1be81393fb403ec51 Author: Randy Dunlap Date: Sun Apr 7 19:54:25 2024 -0700 scsi: scsi_transport_srp: Fix a couple of kernel-doc warnings Add a struct short description and a function return value to prevent kernel-doc warnings: scsi_transport_srp.h:77: warning: missing initial short description on line: * struct srp_function_template scsi_transport_srp.h:132: warning: No description found for return value of 'srp_chkready' Signed-off-by: Randy Dunlap Link: https://lore.kernel.org/r/20240408025425.18778-9-rdunlap@infradead.org Reviewed-by: Bart Van Assche Signed-off-by: Martin K. Petersen commit 007c04e535262417f8206b1bc0aaf1744467430c Author: Randy Dunlap Date: Sun Apr 7 19:54:24 2024 -0700 scsi: scsi_transport_fc: Add kernel-doc for function return Add function return value to prevent a kernel-doc warning: scsi_transport_fc.h:780: warning: No description found for return value of 'fc_remote_port_chkready' Signed-off-by: Randy Dunlap Link: https://lore.kernel.org/r/20240408025425.18778-8-rdunlap@infradead.org Signed-off-by: Martin K. Petersen commit 8d523f0f5383a4f6ae74b6ccf3e0ec953a56dec6 Author: Randy Dunlap Date: Sun Apr 7 19:54:23 2024 -0700 scsi: core: Add function return kernel-doc for 2 functions Add missing function return values to prevent kernel-doc warnings: scsi.h:75: warning: No description found for return value of 'scsi_status_is_check_condition' scsi.h:202: warning: No description found for return value of 'scsi_status_is_good' Signed-off-by: Randy Dunlap Link: https://lore.kernel.org/r/20240408025425.18778-7-rdunlap@infradead.org Reviewed-by: Bart Van Assche Signed-off-by: Martin K. Petersen commit d9c91182414524f1fa0f30584eb90f8211724bdb Author: Randy Dunlap Date: Sun Apr 7 19:54:22 2024 -0700 scsi: libfcoe: Fix a slew of kernel-doc warnings Fix all kernel-doc warnings in : libfcoe.h:163: warning: Function parameter or struct member 'ctlr' not described in 'fcoe_ctlr_priv' libfcoe.h:163: warning: Excess function parameter 'cltr' description in 'fcoe_ctlr_priv' libfcoe.h:163: warning: No description found for return value of 'fcoe_ctlr_priv' libfcoe.h:218: warning: Function parameter or struct member 'fd_flags' not described in 'fcoe_fcf' libfcoe.h:218: warning: Excess struct member 'event' description in 'fcoe_fcf' libfcoe.h:240: warning: Function parameter or struct member 'rdata' not described in 'fcoe_rport' libfcoe.h:273: warning: No description found for return value of 'is_fip_mode' libfcoe.h:332: warning: Function parameter or struct member 'crc_eof_page' not described in 'fcoe_percpu_s' libfcoe.h:332: warning: Function parameter or struct member 'lock' not described in 'fcoe_percpu_s' libfcoe.h:332: warning: Excess struct member 'page' description in 'fcoe_percpu_s' libfcoe.h:362: warning: Function parameter or struct member 'data_src_addr' not described in 'fcoe_port' libfcoe.h:362: warning: Function parameter or struct member 'get_netdev' not described in 'fcoe_port' libfcoe.h:362: warning: Excess struct member 'data_srt_addr' description in 'fcoe_port' libfcoe.h:369: warning: No description found for return value of 'fcoe_get_netdev' libfcoe.h:386: warning: missing initial short description on line: * struct netdev_list libfcoe.h:393: warning: expecting prototype for struct netdev_list. Prototype was for struct fcoe_netdev_mapping instead Signed-off-by: Randy Dunlap Link: https://lore.kernel.org/r/20240408025425.18778-6-rdunlap@infradead.org Signed-off-by: Martin K. Petersen commit 11d99e91846a1c751173c8f21953bd755e7ae4df Author: Randy Dunlap Date: Sun Apr 7 19:54:21 2024 -0700 scsi: iser: Fix @read_stag kernel-doc warning Correct kernel-doc comments for struct iser_ctrl to prevent warnings: iser.h:76: warning: Function parameter or struct member 'read_stag' not described in 'iser_ctrl' iser.h:76: warning: Excess struct member 'reaf_stag' description in 'iser_ctrl' Signed-off-by: Randy Dunlap Link: https://lore.kernel.org/r/20240408025425.18778-5-rdunlap@infradead.org Acked-by: Sagi Grimberg Reviewed-by: Max Gurtovoy Signed-off-by: Martin K. Petersen commit fcf8829fd993348af9f498e486af0a209996f548 Author: Randy Dunlap Date: Sun Apr 7 19:54:20 2024 -0700 scsi: core: Add kernel-doc for scsi_msg_to_host_byte() Add entries for missing documentation to prevent kernel-doc warnings: scsi_cmnd.h:365: warning: Function parameter or struct member 'cmd' not described in 'scsi_msg_to_host_byte' scsi_cmnd.h:365: warning: Function parameter or struct member 'msg' not described in 'scsi_msg_to_host_byte' Signed-off-by: Randy Dunlap Link: https://lore.kernel.org/r/20240408025425.18778-4-rdunlap@infradead.org Reviewed-by: Bart Van Assche Signed-off-by: Martin K. Petersen commit 293fcea539b5dbfa9d9b73c1e60ae171a393fb9b Author: Randy Dunlap Date: Sun Apr 7 19:54:19 2024 -0700 scsi: documentation: Clean up overview - Change http to https where the latter works - Drop references to I2O (Intelligent I/O) - Use lore.kernel.org instead of marc.info for email links - Update the location of the scsi_debug documentation Signed-off-by: Randy Dunlap Link: https://lore.kernel.org/r/20240408025425.18778-3-rdunlap@infradead.org Signed-off-by: Martin K. Petersen commit c3bf7774fa24f9c919947cd20dd7211bdf98b113 Author: Randy Dunlap Date: Sun Apr 7 19:54:18 2024 -0700 scsi: documentation: Clean up scsi_mid_low_api.rst - Update the format (txt to rst) and location of this document (archive.org to docs.kernel.org) - Change url to URL - Spell out "lk" (Linux Kernel) Signed-off-by: Randy Dunlap Link: https://lore.kernel.org/r/20240408025425.18778-2-rdunlap@infradead.org Signed-off-by: Martin K. Petersen commit eab302e89f3d736715bae94d032a20b2a6f5403e Author: Li Zhijian Date: Tue Mar 19 14:31:19 2024 +0800 scsi: snic: Convert sprintf() family to sysfs_emit() family Per filesystems/sysfs.rst, show() should only use sysfs_emit() or sysfs_emit_at() when formatting the value to be returned to user space. coccinelle complains that there are still a couple of functions that use snprintf(). Convert them to sysfs_emit(). sprintf() and scnprintf() will be converted as well if they have. Generally, this patch is generated by make coccicheck M= MODE=patch \ COCCI=scripts/coccinelle/api/device_attr_show.cocci No functional change intended CC: Karan Tilak Kumar CC: Sesidhar Baddela CC: James E.J. Bottomley CC: Martin K. Petersen CC: linux-scsi@vger.kernel.org Signed-off-by: Li Zhijian Link: https://lore.kernel.org/r/20240319063132.1588443-12-lizhijian@fujitsu.com Reviewed-by: Karan Tilak Kumar Signed-off-by: Martin K. Petersen commit 9bd8e41358a52ff2be312a0ab7bd6426ba4c6fe3 Author: Colin Ian King Date: Sat Apr 6 16:50:29 2024 +0100 scsi: FlashPoint: Remove redundant assignment to pointer currTar_Info Pointer currTar_Info is being assigned a value that is never read, it is being re-assigned a few lines later in the start of a following do-while loop. The assignment is redundant and can be removed. Signed-off-by: Colin Ian King Link: https://lore.kernel.org/r/20240406155029.2593439-1-colin.i.king@gmail.com Signed-off-by: Martin K. Petersen commit 6c19ecf4ad1dce85640355210579c34cc4790013 Author: Prasad Pandit Date: Mon Apr 8 10:31:10 2024 +0530 scsi: aic7xxx: Indent kconfig help text Fix indentation of config option's help text by adding leading spaces. Generally help text is indented by two more spaces beyond the leading tab <\t> character. It helps Kconfig parsers to read file without error. Signed-off-by: Prasad Pandit Link: https://lore.kernel.org/r/20240408050110.3679890-1-ppandit@redhat.com Signed-off-by: Martin K. Petersen commit 1bf1f5756f3b867dace269185fc646c5e0dbc2e7 Author: Prasad Pandit Date: Thu Mar 21 16:54:38 2024 +0530 scsi: qla2xxx: Indent help text Fix indentation of config option's help text by adding leading spaces. Generally help text is indented by couple of spaces more beyond the leading tab <\t> character. It helps Kconfig parsers to read file without error. Signed-off-by: Prasad Pandit Link: https://lore.kernel.org/r/20240321112438.1759347-1-ppandit@redhat.com Signed-off-by: Martin K. Petersen commit ca91259b775f6fd98ae5d23bb4eec101d468ba8d Author: Bart Van Assche Date: Mon Mar 25 15:44:17 2024 -0700 scsi: core: Fix handling of SCMD_FAIL_IF_RECOVERING There is code in the SCSI core that sets the SCMD_FAIL_IF_RECOVERING flag but there is no code that clears this flag. Instead of only clearing SCMD_INITIALIZED in scsi_end_request(), clear all flags. It is never necessary to preserve any command flags inside scsi_end_request(). Cc: stable@vger.kernel.org Fixes: 310bcaef6d7e ("scsi: core: Support failing requests while recovering") Signed-off-by: Bart Van Assche Link: https://lore.kernel.org/r/20240325224417.1477135-1-bvanassche@acm.org Signed-off-by: Martin K. Petersen commit e75f7555e1e7e9029f8c125c2923afe5b707f547 Author: Prasad Pandit Date: Mon Mar 11 17:41:27 2024 +0530 scsi: megaraid: Indent Kconfig option help text Fix indentation of megaraid options help text by adding leading spaces. Generally help text is indented by couple of spaces more beyond the leading tab <\t> character. Signed-off-by: Prasad Pandit Link: https://lore.kernel.org/r/20240311121127.1281159-1-ppandit@redhat.com Signed-off-by: Martin K. Petersen commit 28fc2bd2c7298d647fcbab7b11532a1f5fda7470 Author: Arnd Bergmann Date: Thu Apr 4 18:14:58 2024 +0200 scsi: cxlflash: Fix function pointer cast warnings Calling a function through an incompatible pointer type causes breaks kcfi, so clang warns about the assignments: drivers/scsi/cxlflash/main.c:3498:3: error: cast from 'int (*)(struct cxlflash_cfg *, struct ht_cxlflash_lun_provision *)' to 'hioctl' (aka 'int (*)(struct cxlflash_cfg *, void *)') converts to incompatible function type [-Werror,-Wcast-function-type-strict] 3498 | (hioctl)cxlflash_lun_provision }, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/scsi/cxlflash/main.c:3500:3: error: cast from 'int (*)(struct cxlflash_cfg *, struct ht_cxlflash_afu_debug *)' to 'hioctl' (aka 'int (*)(struct cxlflash_cfg *, void *)') converts to incompatible function type [-Werror,-Wcast-function-type-strict] 3500 | (hioctl)cxlflash_afu_debug }, | ^~~~~~~~~~~~~~~~~~~~~~~~~~ Address these by changing the functions to have the correct type and replace the function pointer cast with a cast of its argument. Link: https://lore.kernel.org/lkml/20240326145140.3257163-6-arnd@kernel.org/ Signed-off-by: Arnd Bergmann Link: https://lore.kernel.org/r/20240404161524.3473857-1-arnd@kernel.org Signed-off-by: Martin K. Petersen commit 33507b3964f136ea1592718cb81885c8f9354f65 Author: Manivannan Sadhasivam Date: Wed Apr 3 18:50:04 2024 +0530 scsi: ufs: qcom: Add sanity checks for gear/lane values during ICC scaling Let's add the checks to warn the user if the ICC scaling is not supported for the gear/lane values and also fallback to the max value if that's the case. Signed-off-by: Manivannan Sadhasivam Link: https://lore.kernel.org/r/20240403-ufs-icc-fix-v2-2-958412a5eb45@linaro.org Reviewed-by: Andrew Halaney Signed-off-by: Martin K. Petersen commit 8db8f6ce556af60ca9a9fd5e826d369ded70fcc7 Author: Manivannan Sadhasivam Date: Wed Apr 3 18:50:03 2024 +0530 scsi: ufs: qcom: Add missing interconnect bandwidth values for Gear 5 These entries are necessary to scale the interconnect bandwidth while operating in Gear 5. Cc: Amit Pundir Fixes: 03ce80a1bb86 ("scsi: ufs: qcom: Add support for scaling interconnects") Tested-by: Amit Pundir Signed-off-by: Manivannan Sadhasivam Link: https://lore.kernel.org/r/20240403-ufs-icc-fix-v2-1-958412a5eb45@linaro.org Signed-off-by: Martin K. Petersen commit 4a0166d55edd4a64c22acae2125300aa7f88ec78 Author: Uwe Kleine-König Date: Fri Mar 29 22:11:44 2024 +0100 scsi: mac_scsi: Mark driver struct with __refdata to prevent section mismatch As described in the added code comment, a reference to .exit.text is ok for drivers registered via module_platform_driver_probe(). Make this explicit to prevent the following section mismatch warning WARNING: modpost: drivers/scsi/mac_scsi: section mismatch in reference: mac_scsi_driver+0x8 (section: .data) -> mac_scsi_remove (section: .exit.text) that triggers on an allmodconfig W=1 build. Signed-off-by: Uwe Kleine-König Link: https://lore.kernel.org/r/e41d10906948a980e985f6065485445d9bbbd2f7.1711746359.git.u.kleine-koenig@pengutronix.de Signed-off-by: Martin K. Petersen commit bb8520996fe1482d6104b2212aba966de49ba2b2 Author: Uwe Kleine-König Date: Fri Mar 29 22:11:43 2024 +0100 scsi: atari_scsi: Mark driver struct with __refdata to prevent section mismatch As described in the added code comment, a reference to .exit.text is ok for drivers registered via module_platform_driver_probe(). Make this explicit to prevent the following section mismatch warning WARNING: modpost: drivers/scsi/atari_scsi: section mismatch in reference: atari_scsi_driver+0x8 (section: .data) -> atari_scsi_remove (section: .exit.text) that triggers on an allmodconfig W=1 build. Signed-off-by: Uwe Kleine-König Link: https://lore.kernel.org/r/0170bda7ac0be3d8b694dca1b2f079fb17d9539b.1711746359.git.u.kleine-koenig@pengutronix.de Signed-off-by: Martin K. Petersen commit e70d4cce89238d04515cce4931e20017672ffd35 Author: Uwe Kleine-König Date: Fri Mar 29 22:11:42 2024 +0100 scsi: a4000t: Mark driver struct with __refdata to prevent section mismatch As described in the added code comment, a reference to .exit.text is ok for drivers registered via module_platform_driver_probe(). Make this explicit to prevent the following section mismatch warning WARNING: modpost: drivers/scsi/a4000t: section mismatch in reference: amiga_a4000t_scsi_driver+0x8 (section: .data) -> amiga_a4000t_scsi_remove (section: .exit.text) that triggers on an allmodconfig W=1 build. Signed-off-by: Uwe Kleine-König Link: https://lore.kernel.org/r/743c3cfaf12b9f61f66afa5529ac126c856e4d11.1711746359.git.u.kleine-koenig@pengutronix.de Signed-off-by: Martin K. Petersen commit e81bb6f59b35adae545162928bc7a80cb01cda0f Author: Uwe Kleine-König Date: Fri Mar 29 22:11:41 2024 +0100 scsi: a3000: Mark driver struct with __refdata to prevent section mismatch As described in the added code comment, a reference to .exit.text is ok for drivers registered via module_platform_driver_probe(). Make this explicit to prevent the following section mismatch warning WARNING: modpost: drivers/scsi/a3000: section mismatch in reference: amiga_a3000_scsi_driver+0x8 (section: .data) -> amiga_a3000_scsi_remove (section: .exit.text) that triggers on an allmodconfig W=1 build. Signed-off-by: Uwe Kleine-König Link: https://lore.kernel.org/r/c7222ad7f0baaff78b19f16e789726d42515f025.1711746359.git.u.kleine-koenig@pengutronix.de Signed-off-by: Martin K. Petersen commit 356a8ce7cd5037fa0863c2ac83a35c8ebf6e0e02 Author: Andrew Halaney Date: Fri Mar 29 15:46:53 2024 -0500 scsi: ufs: core: Remove unnecessary wmb() prior to writing run/stop regs Currently a wmb() is used to ensure that writes to the UTP_TASK_REQ_LIST_BASE* regs are completed prior to following writes to the run/stop registers. wmb() ensures that the write completes, but completion doesn't mean that it isn't stored in a buffer somewhere. The recommendation for ensuring the bits have taken effect on the device is to perform a read back to force it to make it all the way to the device. This is documented in device-io.rst and a talk by Will Deacon on this can be seen over here: https://youtu.be/i6DayghhA8Q?si=MiyxB5cKJXSaoc01&t=1678 But, none of that is necessary here. All of the writel()/readl()'s here are to the same endpoint, so they will be ordered. There's no subsequent delay() etc that requires it to have taken effect already, so no readback is necessary here. For that reason just drop the wmb() altogether. Fixes: 897efe628d7e ("scsi: ufs: add missing memory barriers") Signed-off-by: Andrew Halaney Link: https://lore.kernel.org/r/20240329-ufs-reset-ensure-effect-before-delay-v5-11-181252004586@redhat.com Reviewed-by: Bart Van Assche Reviewed-by: Manivannan Sadhasivam Signed-off-by: Martin K. Petersen commit d3fb9a24a6023c744d498f5b4d575517726a42b4 Author: Andrew Halaney Date: Fri Mar 29 15:46:52 2024 -0500 scsi: ufs: core: Remove unnecessary wmb() after ringing doorbell Currently, the doorbell is written to and a wmb() is used to commit it immediately. wmb() ensures that the write completes before following writes occur, but completion doesn't mean that it isn't stored in a buffer somewhere. The recommendation for ensuring this bit has taken effect on the device is to perform a read back to force it to make it all the way to the device. This is documented in device-io.rst and a talk by Will Deacon on this can be seen over here: https://youtu.be/i6DayghhA8Q?si=MiyxB5cKJXSaoc01&t=1678 But, completion and taking effect aren't necessary to guarantee here. There's already other examples of the doorbell being rung that don't do this. The writel() of the doorbell guarantees prior writes by this thread (to the request being setup for example) complete prior to the ringing of the doorbell, and the following wait_for_completion_io_timeout() doesn't require any special memory barriers either. With that in mind, just remove the wmb() altogether here. Fixes: ad1a1b9cd67a ("scsi: ufs: commit descriptors before setting the doorbell") Signed-off-by: Andrew Halaney Link: https://lore.kernel.org/r/20240329-ufs-reset-ensure-effect-before-delay-v5-10-181252004586@redhat.com Reviewed-by: Bart Van Assche Reviewed-by: Manivannan Sadhasivam Signed-off-by: Martin K. Petersen commit 4bf3855497b60765ca03b983d064b25e99b97657 Author: Andrew Halaney Date: Fri Mar 29 15:46:51 2024 -0500 scsi: ufs: core: Perform read back after disabling UIC_COMMAND_COMPL Currently, the UIC_COMMAND_COMPL interrupt is disabled and a wmb() is used to complete the register write before any following writes. wmb() ensures the writes complete in that order, but completion doesn't mean that it isn't stored in a buffer somewhere. The recommendation for ensuring this bit has taken effect on the device is to perform a read back to force it to make it all the way to the device. This is documented in device-io.rst and a talk by Will Deacon on this can be seen over here: https://youtu.be/i6DayghhA8Q?si=MiyxB5cKJXSaoc01&t=1678 Let's do that to ensure the bit hits the device. Because the wmb()'s purpose wasn't to add extra ordering (on top of the ordering guaranteed by writel()/readl()), it can safely be removed. Fixes: d75f7fe495cf ("scsi: ufs: reduce the interrupts for power mode change requests") Reviewed-by: Bart Van Assche Reviewed-by: Can Guo Reviewed-by: Manivannan Sadhasivam Signed-off-by: Andrew Halaney Link: https://lore.kernel.org/r/20240329-ufs-reset-ensure-effect-before-delay-v5-9-181252004586@redhat.com Signed-off-by: Martin K. Petersen commit e4a628877119bd40164a651d20321247b6f94a8b Author: Andrew Halaney Date: Fri Mar 29 15:46:50 2024 -0500 scsi: ufs: core: Perform read back after disabling interrupts Currently, interrupts are cleared and disabled prior to registering the interrupt. An mb() is used to complete the clear/disable writes before the interrupt is registered. mb() ensures that the write completes, but completion doesn't mean that it isn't stored in a buffer somewhere. The recommendation for ensuring these bits have taken effect on the device is to perform a read back to force it to make it all the way to the device. This is documented in device-io.rst and a talk by Will Deacon on this can be seen over here: https://youtu.be/i6DayghhA8Q?si=MiyxB5cKJXSaoc01&t=1678 Let's do that to ensure these bits hit the device. Because the mb()'s purpose wasn't to add extra ordering (on top of the ordering guaranteed by writel()/readl()), it can safely be removed. Fixes: 199ef13cac7d ("scsi: ufs: avoid spurious UFS host controller interrupts") Reviewed-by: Manivannan Sadhasivam Reviewed-by: Bart Van Assche Reviewed-by: Can Guo Signed-off-by: Andrew Halaney Link: https://lore.kernel.org/r/20240329-ufs-reset-ensure-effect-before-delay-v5-8-181252004586@redhat.com Signed-off-by: Martin K. Petersen commit 408e28086f1c7a6423efc79926a43d7001902fae Author: Andrew Halaney Date: Fri Mar 29 15:46:49 2024 -0500 scsi: ufs: core: Perform read back after writing UTP_TASK_REQ_LIST_BASE_H Currently, the UTP_TASK_REQ_LIST_BASE_L/UTP_TASK_REQ_LIST_BASE_H regs are written to and then completed with an mb(). mb() ensures that the write completes, but completion doesn't mean that it isn't stored in a buffer somewhere. The recommendation for ensuring these bits have taken effect on the device is to perform a read back to force it to make it all the way to the device. This is documented in device-io.rst and a talk by Will Deacon on this can be seen over here: https://youtu.be/i6DayghhA8Q?si=MiyxB5cKJXSaoc01&t=1678 Let's do that to ensure the bits hit the device. Because the mb()'s purpose wasn't to add extra ordering (on top of the ordering guaranteed by writel()/readl()), it can safely be removed. Fixes: 88441a8d355d ("scsi: ufs: core: Add hibernation callbacks") Reviewed-by: Manivannan Sadhasivam Reviewed-by: Bart Van Assche Reviewed-by: Can Guo Signed-off-by: Andrew Halaney Link: https://lore.kernel.org/r/20240329-ufs-reset-ensure-effect-before-delay-v5-7-181252004586@redhat.com Signed-off-by: Martin K. Petersen commit b715c55daf598aac8fa339048e4ca8a0916b332e Author: Andrew Halaney Date: Fri Mar 29 15:46:48 2024 -0500 scsi: ufs: cdns-pltfrm: Perform read back after writing HCLKDIV Currently, HCLKDIV is written to and then completed with an mb(). mb() ensures that the write completes, but completion doesn't mean that it isn't stored in a buffer somewhere. The recommendation for ensuring this bit has taken effect on the device is to perform a read back to force it to make it all the way to the device. This is documented in device-io.rst and a talk by Will Deacon on this can be seen over here: https://youtu.be/i6DayghhA8Q?si=MiyxB5cKJXSaoc01&t=1678 Let's do that to ensure the bit hits the device. Because the mb()'s purpose wasn't to add extra ordering (on top of the ordering guaranteed by writel()/readl()), it can safely be removed. Fixes: d90996dae8e4 ("scsi: ufs: Add UFS platform driver for Cadence UFS") Reviewed-by: Manivannan Sadhasivam Signed-off-by: Andrew Halaney Link: https://lore.kernel.org/r/20240329-ufs-reset-ensure-effect-before-delay-v5-6-181252004586@redhat.com Reviewed-by: Bart Van Assche Signed-off-by: Martin K. Petersen commit d9488511b3ac7eb48a91bc5eded7027525525e03 Author: Andrew Halaney Date: Fri Mar 29 15:46:47 2024 -0500 scsi: ufs: qcom: Perform read back after writing CGC enable Currently, the CGC enable bit is written and then an mb() is used to ensure that completes before continuing. mb() ensures that the write completes, but completion doesn't mean that it isn't stored in a buffer somewhere. The recommendation for ensuring this bit has taken effect on the device is to perform a read back to force it to make it all the way to the device. This is documented in device-io.rst and a talk by Will Deacon on this can be seen over here: https://youtu.be/i6DayghhA8Q?si=MiyxB5cKJXSaoc01&t=1678 Let's do that to ensure the bit hits the device. Because the mb()'s purpose wasn't to add extra ordering (on top of the ordering guaranteed by writel()/readl()), it can safely be removed. Reviewed-by: Manivannan Sadhasivam Reviewed-by: Can Guo Fixes: 81c0fc51b7a7 ("ufs-qcom: add support for Qualcomm Technologies Inc platforms") Signed-off-by: Andrew Halaney Link: https://lore.kernel.org/r/20240329-ufs-reset-ensure-effect-before-delay-v5-5-181252004586@redhat.com Signed-off-by: Martin K. Petersen commit 823150ecf04f958213cf3bf162187cd1a91c885c Author: Andrew Halaney Date: Fri Mar 29 15:46:46 2024 -0500 scsi: ufs: qcom: Perform read back after writing unipro mode Currently, the QUNIPRO_SEL bit is written to and then an mb() is used to ensure that completes before continuing. mb() ensures that the write completes, but completion doesn't mean that it isn't stored in a buffer somewhere. The recommendation for ensuring this bit has taken effect on the device is to perform a read back to force it to make it all the way to the device. This is documented in device-io.rst and a talk by Will Deacon on this can be seen over here: https://youtu.be/i6DayghhA8Q?si=MiyxB5cKJXSaoc01&t=1678 But, there's really no reason to even ensure completion before continuing. The only requirement here is that this write is ordered to this endpoint (which readl()/writel() guarantees already). For that reason the mb() can be dropped altogether without anything forcing completion. Fixes: f06fcc7155dc ("scsi: ufs-qcom: add QUniPro hardware support and power optimizations") Signed-off-by: Andrew Halaney Link: https://lore.kernel.org/r/20240329-ufs-reset-ensure-effect-before-delay-v5-4-181252004586@redhat.com Reviewed-by: Manivannan Sadhasivam Signed-off-by: Martin K. Petersen commit 95d26dda90df29ceb0dd23a3158cb7f0bd1a5efb Author: Andrew Halaney Date: Fri Mar 29 15:46:45 2024 -0500 scsi: ufs: qcom: Remove unnecessary mb() after writing testbus config Currently, the testbus configuration is written and completed with an mb(). mb() ensures that the write completes, but completion doesn't mean that it isn't stored in a buffer somewhere. The recommendation for ensuring this bit has taken effect on the device is to perform a read back to force it to make it all the way to the device. This is documented in device-io.rst and a talk by Will Deacon on this can be seen over here: https://youtu.be/i6DayghhA8Q?si=MiyxB5cKJXSaoc01&t=1678 But, there's really no reason to even ensure completion before continuing. The only requirement here is that this write is ordered to this endpoint (which readl()/writel() guarantees already). For that reason the mb() can be dropped altogether without anything forcing completion. Fixes: 9c46b8676271 ("scsi: ufs-qcom: dump additional testbus registers") Signed-off-by: Andrew Halaney Link: https://lore.kernel.org/r/20240329-ufs-reset-ensure-effect-before-delay-v5-3-181252004586@redhat.com Reviewed-by: Manivannan Sadhasivam Signed-off-by: Martin K. Petersen commit a862fafa263aea0f427d51aca6ff7fd9eeaaa8bd Author: Andrew Halaney Date: Fri Mar 29 15:46:44 2024 -0500 scsi: ufs: qcom: Perform read back after writing REG_UFS_SYS1CLK_1US Currently after writing to REG_UFS_SYS1CLK_1US a mb() is used to ensure that write has gone through to the device. mb() ensures that the write completes, but completion doesn't mean that it isn't stored in a buffer somewhere. The recommendation for ensuring this bit has taken effect on the device is to perform a read back to force it to make it all the way to the device. This is documented in device-io.rst and a talk by Will Deacon on this can be seen over here: https://youtu.be/i6DayghhA8Q?si=MiyxB5cKJXSaoc01&t=1678 Let's do that to ensure the bit hits the device. Because the mb()'s purpose wasn't to add extra ordering (on top of the ordering guaranteed by writel()/readl()), it can safely be removed. Fixes: f06fcc7155dc ("scsi: ufs-qcom: add QUniPro hardware support and power optimizations") Reviewed-by: Can Guo Signed-off-by: Andrew Halaney Link: https://lore.kernel.org/r/20240329-ufs-reset-ensure-effect-before-delay-v5-2-181252004586@redhat.com Reviewed-by: Manivannan Sadhasivam Signed-off-by: Martin K. Petersen commit c4d28e06b0c94636f6e35d003fa9ebac0a94e1ae Author: Andrew Halaney Date: Fri Mar 29 15:46:43 2024 -0500 scsi: ufs: qcom: Perform read back after writing reset bit Currently, the reset bit for the UFS provided reset controller (used by its phy) is written to, and then a mb() happens to try and ensure that hit the device. Immediately afterwards a usleep_range() occurs. mb() ensures that the write completes, but completion doesn't mean that it isn't stored in a buffer somewhere. The recommendation for ensuring this bit has taken effect on the device is to perform a read back to force it to make it all the way to the device. This is documented in device-io.rst and a talk by Will Deacon on this can be seen over here: https://youtu.be/i6DayghhA8Q?si=MiyxB5cKJXSaoc01&t=1678 Let's do that to ensure the bit hits the device. By doing so and guaranteeing the ordering against the immediately following usleep_range(), the mb() can safely be removed. Fixes: 81c0fc51b7a7 ("ufs-qcom: add support for Qualcomm Technologies Inc platforms") Reviewed-by: Manivannan Sadhasivam Reviewed-by: Can Guo Signed-off-by: Andrew Halaney Link: https://lore.kernel.org/r/20240329-ufs-reset-ensure-effect-before-delay-v5-1-181252004586@redhat.com Signed-off-by: Martin K. Petersen commit 9282899e1e7e245c464f5996119fb06d48b97d4a Author: Krzysztof Kozlowski Date: Thu Mar 28 21:45:50 2024 +0100 scsi: ufs: core: Drop driver owner initialization Core in scsi_register_driver() already sets the .owner, so driver does not need to. Signed-off-by: Krzysztof Kozlowski Link: https://lore.kernel.org/r/20240328-b4-module-owner-scsi-v1-6-c86cb4f6e91c@linaro.org Signed-off-by: Martin K. Petersen commit 2ee2d99fe4498d786e6773687bddba24c6684e6e Author: Krzysztof Kozlowski Date: Thu Mar 28 21:45:49 2024 +0100 scsi: st: Drop driver owner initialization Core in scsi_register_driver() already sets the .owner, so driver does not need to. Signed-off-by: Krzysztof Kozlowski Link: https://lore.kernel.org/r/20240328-b4-module-owner-scsi-v1-5-c86cb4f6e91c@linaro.org Signed-off-by: Martin K. Petersen commit dc916f7f0f5e3dac09b631f786f6488111d462ca Author: Krzysztof Kozlowski Date: Thu Mar 28 21:45:48 2024 +0100 scsi: sr: Drop driver owner initialization Core in scsi_register_driver() already sets the .owner, so driver does not need to. Signed-off-by: Krzysztof Kozlowski Link: https://lore.kernel.org/r/20240328-b4-module-owner-scsi-v1-4-c86cb4f6e91c@linaro.org Signed-off-by: Martin K. Petersen commit 8d326b243c111a782d4cf4737844fdfe96e30545 Author: Krzysztof Kozlowski Date: Thu Mar 28 21:45:47 2024 +0100 scsi: ses: Drop driver owner initialization Core in scsi_register_driver() already sets the .owner, so driver does not need to. Signed-off-by: Krzysztof Kozlowski Link: https://lore.kernel.org/r/20240328-b4-module-owner-scsi-v1-3-c86cb4f6e91c@linaro.org Signed-off-by: Martin K. Petersen commit aef9e48726841b33066b585df0e2957bbc0f5862 Author: Krzysztof Kozlowski Date: Thu Mar 28 21:45:46 2024 +0100 scsi: sd: Drop driver owner initialization Core in scsi_register_driver() already sets the .owner, so driver does not need to. Signed-off-by: Krzysztof Kozlowski Link: https://lore.kernel.org/r/20240328-b4-module-owner-scsi-v1-2-c86cb4f6e91c@linaro.org Signed-off-by: Martin K. Petersen commit 65a09ba2693681da53099a0f41b7fb6d5ebbead5 Author: Krzysztof Kozlowski Date: Thu Mar 28 21:45:45 2024 +0100 scsi: core: Store owner from modules with scsi_register_driver() Modules registering driver with scsi_driver_register() might forget to set .owner field. The field is used by some of other kernel parts for reference counting (try_module_get()), so it is expected that drivers will set it. Solve the problem by moving this task away from the drivers to the core scsi code, just like we did for platform_driver in commit 9447057eaff8 ("platform_device: use a macro instead of platform_driver_register"). Signed-off-by: Krzysztof Kozlowski Link: https://lore.kernel.org/r/20240328-b4-module-owner-scsi-v1-1-c86cb4f6e91c@linaro.org Signed-off-by: Martin K. Petersen commit 4e64bbba5352382feb2b6041b26eeb69e96949a9 Author: Krzysztof Kozlowski Date: Wed Mar 27 18:49:21 2024 +0100 scsi: qla2xxx: Drop driver owner assignment PCI core in pci_register_driver() already sets the .owner, so driver does not need to. Signed-off-by: Krzysztof Kozlowski Link: https://lore.kernel.org/r/20240327174921.519830-2-krzysztof.kozlowski@linaro.org Signed-off-by: Martin K. Petersen commit ca0e1b9afbc93e1c189e420030d8bd489972a2a4 Author: Krzysztof Kozlowski Date: Wed Mar 27 18:49:20 2024 +0100 scsi: csiostor: Drop driver owner assignment PCI core in pci_register_driver() already sets the .owner, so driver does not need to. Signed-off-by: Krzysztof Kozlowski Link: https://lore.kernel.org/r/20240327174921.519830-1-krzysztof.kozlowski@linaro.org Signed-off-by: Martin K. Petersen commit 0ff10cb7f81818120b15ddd5d24e09c4af31e04d Author: Damien Le Moal Date: Wed Mar 27 11:01:22 2024 +0900 scsi: libsas: Fix declaration of ncq priority attributes Commit b4d3ddd2df75 ("scsi: libsas: Define NCQ Priority sysfs attributes for SATA devices") introduced support for ATA NCQ priority control for ATA devices managed by libsas. This commit introduces the ncq_prio_supported and ncq_prio_enable sysfs device attributes to discover and control the use of this features, similarly to libata. However, libata publicly declares these device attributes and export them for use in ATA low level drivers. This leads to a compilation error when libsas and libata are built-in due to the double definition: ld: drivers/ata/libata-sata.o:/home/Linux/scsi/drivers/ata/libata-sata.c:900: multiple definition of `dev_attr_ncq_prio_supported'; drivers/scsi/libsas/sas_ata.o:/home/Linux/scsi/drivers/scsi/libsas/sas_ata.c:984: first defined here ld: drivers/ata/libata-sata.o:/home/Linux/scsi/drivers/ata/libata-sata.c:1026: multiple definition of `dev_attr_ncq_prio_enable'; drivers/scsi/libsas/sas_ata.o:/home/Linux/scsi/drivers/scsi/libsas/sas_ata.c:1022: first defined here Resolve this problem by directly declaring the libsas attributes instead of using the DEVICE_ATTR() macro. And for good measure, the device attribute variables are also renamed. Reported-by: Geert Uytterhoeven Fixes: b4d3ddd2df75 ("scsi: libsas: Define NCQ Priority sysfs attributes for SATA devices") Signed-off-by: Damien Le Moal Link: https://lore.kernel.org/r/20240327020122.439424-1-dlemoal@kernel.org Reviewed-by: John Garry Signed-off-by: Martin K. Petersen commit a6888d623eae6dcae0ab8a587d68fabeb18f854e Author: Alice Chao Date: Fri Mar 15 16:34:48 2024 +0800 scsi: ufs: mediatek: Support rtff in PM flow Add mtcmos control function and config. Signed-off-by: Alice Chao Reviewed-by: Peter Wang Acked-by: Chun-Hung Wu Signed-off-by: Peter Wang Link: https://lore.kernel.org/r/20240315083448.7185-8-peter.wang@mediatek.com Signed-off-by: Martin K. Petersen commit b28820a82b7a70d8dbd04f8f4469bcf8497dd217 Author: Peter Wang Date: Fri Mar 15 16:34:47 2024 +0800 scsi: ufs: mediatek: Support mphy reset Reset mphy when resetting host. Backup mphy setting after mphy reset control get. Restore mphy setting after mphy reset. Acked-by: Chun-Hung Wu Signed-off-by: Peter Wang Link: https://lore.kernel.org/r/20240315083448.7185-7-peter.wang@mediatek.com Signed-off-by: Martin K. Petersen commit 3a887a382838384757c3487263619ec5162424f2 Author: Po-Wen Kao Date: Fri Mar 15 16:34:46 2024 +0800 scsi: ufs: mediatek: Rename host power control API Mediatek host power includes two parts: 1. ufshci power, which is the main power of ufs host controller. 2. ufshci crypto sram power, which is the power of ufs crypto engine. The host power control is actually controlling crypto sram power. Rename it. Signed-off-by: Po-Wen Kao Acked-by: Chun-Hung Wu Reviewed-by: Peter Wang Signed-off-by: Peter Wang Reviewed-by: Avri Altman Link: https://lore.kernel.org/r/20240315083448.7185-6-peter.wang@mediatek.com Signed-off-by: Martin K. Petersen commit 4bd07f0596be9c4c72300c8bdf04d0bbdbf804b0 Author: Po-Wen Kao Date: Fri Mar 15 16:34:45 2024 +0800 scsi: ufs: mediatek: UFS mtk sip command reconstruct Move sip command and associated define to a new sip header file. Signed-off-by: Po-Wen Kao Acked-by: Chun-Hung Wu Reviewed-by: Peter Wang Signed-off-by: Peter Wang Link: https://lore.kernel.org/r/20240315083448.7185-5-peter.wang@mediatek.com Signed-off-by: Martin K. Petersen commit 46bd3e31d74b4c6ccd064e82cdfcdd24fa3114b6 Author: Po-Wen Kao Date: Fri Mar 15 16:34:44 2024 +0800 scsi: ufs: mediatek: Add UFS_MTK_CAP_DISABLE_MCQ Add new mediatek host cap UFS_MTK_CAP_DISABLE_MCQ to allow disabling MCQ feature by assigning dts boolean property "mediatek,ufs-disable-mcq". Signed-off-by: Po-Wen Kao Reviewed-by: Peter Wang Acked-by: Chun-Hung Wu Signed-off-by: Peter Wang Reviewed-by: Avri Altman Link: https://lore.kernel.org/r/20240315083448.7185-4-peter.wang@mediatek.com Signed-off-by: Martin K. Petersen commit e7b3c64a2a9485c134c1b23b8ebeda004b48de74 Author: Peter Wang Date: Fri Mar 15 16:34:43 2024 +0800 scsi: ufs: mediatek: TX skew fix Fix Mediatek TX skew issue by checking dts setting and vendor/model. Then set PA_TACTIVATE to 8. Signed-off-by: Peter Wang Acked-by: Chun-Hung Wu Reviewed-by: Avri Altman Link: https://lore.kernel.org/r/20240315083448.7185-3-peter.wang@mediatek.com Signed-off-by: Martin K. Petersen commit 1c5e7221bb67d7702532ada40461b7824a6dab07 Author: Peter Wang Date: Fri Mar 15 16:34:42 2024 +0800 scsi: ufs: mediatek: Fix vsx/vccqx control logic VSX (the upper layer of VCCQ/VCCQ2) should: 1. Always set to hpm mode if ufs device is active. 2. Enter lpm mode only if ufs device is not active. VCCQX should: 1. Keep hpm mode if vccq and vccq2 not set in dts. 2. Keep hpm mode if vcc not set in dts keep vcc always on. 3. Keep hpm if broken vcc keep vcc always on and not allow vccq lpm. 4. Except upper case, can enter lpm mode if ufs device is not active. Acked-by: Chun-Hung Wu Signed-off-by: Peter Wang Link: https://lore.kernel.org/r/20240315083448.7185-2-peter.wang@mediatek.com Signed-off-by: Martin K. Petersen commit 829dce7e12c28936aafa476fc1ff1e9adb6f1268 Author: Ranjan Kumar Date: Wed Mar 13 15:37:46 2024 +0530 scsi: mpi3mr: Driver version update to 8.8.1.0.50 Update driver version to 8.8.1.0.50. Signed-off-by: Ranjan Kumar Link: https://lore.kernel.org/r/20240313100746.128951-8-ranjan.kumar@broadcom.com Signed-off-by: Martin K. Petersen commit 57a80be5ec6f08edbcd615dd0c3f2478d091813d Author: Ranjan Kumar Date: Wed Mar 13 15:37:45 2024 +0530 scsi: mpi3mr: Update MPI Headers to revision 31 Update MPI Headers to revision 31. Signed-off-by: Ranjan Kumar Signed-off-by: Sathya Prakash Link: https://lore.kernel.org/r/20240313100746.128951-7-ranjan.kumar@broadcom.com Signed-off-by: Martin K. Petersen commit 0a2714b787b91176e7d4f005dcef8d177efdff8a Author: Ranjan Kumar Date: Wed Mar 13 15:37:44 2024 +0530 scsi: mpi3mr: Debug ability improvements Update driver to include OS type in fault/reset reason code. MPI request sent through ioctl now automatically dumped on timeout. Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202403081903.q3Dq54zZ-lkp@intel.com/ Signed-off-by: Ranjan Kumar Signed-off-by: Sathya Prakash Link: https://lore.kernel.org/r/20240313100746.128951-6-ranjan.kumar@broadcom.com Signed-off-by: Martin K. Petersen commit e8a5a3c3eb58c6639a9c259e23d82ff3ca6622d4 Author: Ranjan Kumar Date: Wed Mar 13 15:37:43 2024 +0530 scsi: mpi3mr: Set the WriteSame Divert Capability in the IOCInit MPI Request Modify driver to set the Write Same Divert Capability bit in the IOCInit message for the firmware to know that the driver is capable of diverting certain Write Same commands as defined by the MPI specification. Signed-off-by: Ranjan Kumar Signed-off-by: Sathya Prakash Link: https://lore.kernel.org/r/20240313100746.128951-5-ranjan.kumar@broadcom.com Signed-off-by: Martin K. Petersen commit 31ec576ee06a788687834b4b0adbb17023a5a059 Author: Ranjan Kumar Date: Wed Mar 13 15:37:42 2024 +0530 scsi: mpi3mr: Clear ioctl blocking flag for an unresponsive controller The driver uses a controller-wide flag to block ioctls when a controller reset is in progress. This flag is set before controller reset is initiated and cleared after the reset has completed. Make the driver clear the controller-wide block ioctls flag after a controller reset fails and the controller is marked unrecoverable. Signed-off-by: Ranjan Kumar Signed-off-by: Sumit Saxena Link: https://lore.kernel.org/r/20240313100746.128951-4-ranjan.kumar@broadcom.com Signed-off-by: Martin K. Petersen commit a18f4c58372da9395a059c9105d7df23ab0097d9 Author: Ranjan Kumar Date: Wed Mar 13 15:37:41 2024 +0530 scsi: mpi3mr: Set MPI request flags appropriately The 'flags' variable inside an MPI request is a bitfield and should consequently be updated using a bitwise OR operation. Signed-off-by: Ranjan Kumar Signed-off-by: Sathya Prakash Link: https://lore.kernel.org/r/20240313100746.128951-3-ranjan.kumar@broadcom.com Signed-off-by: Martin K. Petersen commit dd896a6b0a0d3939c1ba070f46bec42cbb7573eb Author: Ranjan Kumar Date: Wed Mar 13 15:37:40 2024 +0530 scsi: mpi3mr: Block devices are not removed even when VDs are offlined The driver did not remove the virtual disk that was exposed as hidden and offline after the controller was reset. Drive is removed from OS when firmware sends "device added" event with hidden bit set or access status indicating inability to accept I/Os. Signed-off-by: Ranjan Kumar Signed-off-by: Sathya Prakash Link: https://lore.kernel.org/r/20240313100746.128951-2-ranjan.kumar@broadcom.com Signed-off-by: Martin K. Petersen commit 996a24b99d63df08caf89fc03f4783279424788f Author: Avri Altman Date: Sat Mar 9 10:11:02 2024 +0200 scsi: ufs: Reuse compose_devman_upiu Move some code fragments into ufshcd_prepare_req_desc_hdr() so it can be used throughout. Signed-off-by: Avri Altman Link: https://lore.kernel.org/r/20240309081104.5006-5-avri.altman@wdc.com Reviewed-by: Bart Van Assche Reviewed-by: Bean Huo Signed-off-by: Martin K. Petersen commit 5b59a68dac9ac72538fd742c7d20d2734cbc6cf2 Author: Avri Altman Date: Sat Mar 9 10:11:01 2024 +0200 scsi: ufs: Reuse compose_dev_cmd Move out some of the dev_cmd initializations so they can be used elsewhere. Reviewed-by: Bart Van Assche Reviewed-by: Bean Huo Signed-off-by: Avri Altman Link: https://lore.kernel.org/r/20240309081104.5006-4-avri.altman@wdc.com Signed-off-by: Martin K. Petersen commit 71aabb747d5f90c1b10b55eabdadd97529bfe165 Author: Avri Altman Date: Sat Mar 9 10:11:00 2024 +0200 scsi: ufs: core: Reuse exec_dev_cmd Move out the actual command issue from exec_dev_cmd it can be used elsewhere. While at it, remove a redundant "lrbp->cmd = NULL" assignment. Also, the device management commands that are originated from the ufs-bsg code path, are being traced now, which wasn't the case before. Signed-off-by: Avri Altman Link: https://lore.kernel.org/r/20240309081104.5006-3-avri.altman@wdc.com Reviewed-by: Bart Van Assche Reviewed-by: Bean Huo Signed-off-by: Martin K. Petersen commit ddfd7f051f4e14959b893ac8ba7c081a0691197c Author: Avri Altman Date: Sat Mar 9 10:10:59 2024 +0200 scsi: ufs: core: Reuse device management locking code Group those 3 calls that repeat for every device management command into lock and unlock handlers. Reviewed-by: Bean Huo Reviewed-by: Bart Van Assche Signed-off-by: Avri Altman Link: https://lore.kernel.org/r/20240309081104.5006-2-avri.altman@wdc.com Signed-off-by: Martin K. Petersen commit 92a59bc85c118cd4d6212d57fdc53b15056370da Author: John Garry Date: Fri Mar 8 11:43:39 2024 +0000 scsi: isci: Use LIBSAS_SHT_BASE Use standard template for scsi_host_template structure to reduce duplication. Reviewed-by: Jason Yan Signed-off-by: John Garry Link: https://lore.kernel.org/r/20240308114339.1340549-7-john.g.garry@oracle.com Reviewed-by: Igor Pylypiv Signed-off-by: Martin K. Petersen commit f1604214fdc7d449d008751c39d453dd9b52e65a Author: John Garry Date: Fri Mar 8 11:43:38 2024 +0000 scsi: mvsas: Use LIBSAS_SHT_BASE Use standard template for scsi_host_template structure to reduce duplication. Signed-off-by: John Garry Link: https://lore.kernel.org/r/20240308114339.1340549-6-john.g.garry@oracle.com Reviewed-by: Igor Pylypiv Reviewed-by: Jason Yan Signed-off-by: Martin K. Petersen commit 30993a6b27ef5eb22fef0884fdb7e3b8926a4deb Author: John Garry Date: Fri Mar 8 11:43:37 2024 +0000 scsi: aic94xx: Use LIBSAS_SHT_BASE Use standard template for scsi_host_template structure to reduce duplication. Reviewed-by: Jason Yan Signed-off-by: John Garry Link: https://lore.kernel.org/r/20240308114339.1340549-5-john.g.garry@oracle.com Reviewed-by: Igor Pylypiv Signed-off-by: Martin K. Petersen commit d53e4d77568abf5cf135f65b0ed369a6d73af3e9 Author: John Garry Date: Fri Mar 8 11:43:36 2024 +0000 scsi: hisi_sas: Use LIBSAS_SHT_BASE_NO_SLAVE_INIT Use standard template for scsi_host_template structure to reduce duplication. Reviewed-by: Jason Yan Signed-off-by: John Garry Link: https://lore.kernel.org/r/20240308114339.1340549-4-john.g.garry@oracle.com Reviewed-by: Igor Pylypiv Signed-off-by: Martin K. Petersen commit ad802f7f27fc9f8a2dd463b815d10aca8a3cc668 Author: John Garry Date: Fri Mar 8 11:43:35 2024 +0000 scsi: pm8001: Use LIBSAS_SHT_BASE Use standard template for scsi_host_template structure to reduce duplication. Signed-off-by: John Garry Link: https://lore.kernel.org/r/20240308114339.1340549-3-john.g.garry@oracle.com Reviewed-by: Igor Pylypiv Reviewed-by: Jason Yan Signed-off-by: Martin K. Petersen commit bcd39f639e9e10e2b2d63604ec7c011cd21e52c1 Author: John Garry Date: Fri Mar 8 11:43:34 2024 +0000 scsi: libsas: Add LIBSAS_SHT_BASE There is much duplication in the scsi_host_template structure for the drivers which use libsas. Similar to how a standard template is used in libata with __ATA_BASE_SHT, create a standard template in LIBSAS_SHT_BASE. Don't set a default for max_sectors at SCSI_DEFAULT_MAX_SECTORS, as scsi_host_alloc() will default to this value automatically. Even though some drivers don't set proc_name, it won't make much difference to set as DRV_NAME. Also add LIBSAS_SHT_BASE_NO_SLAVE_INIT for the hisi_sas drivers which have custom .slave_alloc and .slave_configure methods. Reviewed-by: Jason Yan Signed-off-by: John Garry Link: https://lore.kernel.org/r/20240308114339.1340549-2-john.g.garry@oracle.com Reviewed-by: Igor Pylypiv Signed-off-by: Martin K. Petersen commit c65c4360b3a0a8ecc1f2122620204a33d965966e Author: Igor Pylypiv Date: Thu Mar 7 13:44:18 2024 -0800 scsi: isci: Add libsas SATA sysfs attributes group The added sysfs attributes group enables the configuration of NCQ Priority feature for HBAs that rely on libsas to manage SATA devices. Reviewed-by: John Garry Reviewed-by: Damien Le Moal Reviewed-by: Jason Yan Reviewed-by: Hannes Reinecke Reviewed-by: Niklas Cassel Signed-off-by: Igor Pylypiv Link: https://lore.kernel.org/r/20240307214418.3812290-8-ipylypiv@google.com Signed-off-by: Martin K. Petersen commit 14cc341229fc11657115481e5b5c214856c38724 Author: Igor Pylypiv Date: Thu Mar 7 13:44:17 2024 -0800 scsi: aic94xx: Add libsas SATA sysfs attributes group The added sysfs attributes group enables the configuration of NCQ Priority feature for HBAs that rely on libsas to manage SATA devices. Reviewed-by: John Garry Reviewed-by: Damien Le Moal Reviewed-by: Jason Yan Reviewed-by: Hannes Reinecke Signed-off-by: Igor Pylypiv Link: https://lore.kernel.org/r/20240307214418.3812290-7-ipylypiv@google.com Reviewed-by: Niklas Cassel Signed-off-by: Martin K. Petersen commit a23971e8ff0c43d47e1772b62c2916ff0b768fca Author: Igor Pylypiv Date: Thu Mar 7 13:44:16 2024 -0800 scsi: hisi_sas: Add libsas SATA sysfs attributes group The added sysfs attributes group enables the configuration of NCQ Priority feature for HBAs that rely on libsas to manage SATA devices. Omitted hisi_sas_v1_hw.c because v1 HW doesn't support SATA. Reviewed-by: John Garry Reviewed-by: Damien Le Moal Reviewed-by: Jason Yan Reviewed-by: Hannes Reinecke Signed-off-by: Igor Pylypiv Link: https://lore.kernel.org/r/20240307214418.3812290-6-ipylypiv@google.com Reviewed-by: Niklas Cassel Signed-off-by: Martin K. Petersen commit 95ee29a7b3792c855530848f070c332ce83e54cd Author: Igor Pylypiv Date: Thu Mar 7 13:44:15 2024 -0800 scsi: mvsas: Add libsas SATA sysfs attributes group The added sysfs attributes group enables the configuration of NCQ Priority feature for HBAs that rely on libsas to manage SATA devices. Reviewed-by: John Garry Reviewed-by: Damien Le Moal Reviewed-by: Jason Yan Reviewed-by: Hannes Reinecke Signed-off-by: Igor Pylypiv Link: https://lore.kernel.org/r/20240307214418.3812290-5-ipylypiv@google.com Reviewed-by: Niklas Cassel Signed-off-by: Martin K. Petersen commit 9fa095ae65472a3fb82ac5e27a31abf2ede74ae8 Author: Igor Pylypiv Date: Thu Mar 7 13:44:14 2024 -0800 scsi: pm80xx: Add libsas SATA sysfs attributes group The added sysfs attributes group enables the configuration of NCQ Priority feature for HBAs that rely on libsas to manage SATA devices. Acked-by: Jack Wang Reviewed-by: John Garry Reviewed-by: Damien Le Moal Reviewed-by: Jason Yan Reviewed-by: Hannes Reinecke Reviewed-by: Niklas Cassel Signed-off-by: Igor Pylypiv Link: https://lore.kernel.org/r/20240307214418.3812290-4-ipylypiv@google.com Signed-off-by: Martin K. Petersen commit b4d3ddd2df7531e35c5f4e0b048d0999851747ae Author: Igor Pylypiv Date: Thu Mar 7 13:44:13 2024 -0800 scsi: libsas: Define NCQ Priority sysfs attributes for SATA devices libata sysfs attributes cannot be used for libsas-managed SATA devices because the ata_port location is different for libsas. Defined sysfs attributes (visible for SATA devices only): - /sys/block/sda/device/ncq_prio_enable - /sys/block/sda/device/ncq_prio_supported The newly defined attributes will pass the correct ata_port to libata helper functions. Reviewed-by: John Garry Reviewed-by: Damien Le Moal Reviewed-by: Jason Yan Signed-off-by: Igor Pylypiv Link: https://lore.kernel.org/r/20240307214418.3812290-3-ipylypiv@google.com Reviewed-by: Niklas Cassel Signed-off-by: Martin K. Petersen commit abeded46bc1922e2249f6665654b5d81e7c5e1f1 Author: Igor Pylypiv Date: Thu Mar 7 13:44:12 2024 -0800 scsi: ata: libata-sata: Factor out NCQ Priority configuration helpers Export libata NCQ Priority configuration helpers to be reused for libsas managed SATA devices. Switched locking from spin_lock_irq() to spin_lock_irqsave(). In the future someone might call these helper functions when interrupts are disabled. spin_unlock_irq() could lead to a premature re-enabling of interrupts, whereas spin_unlock_irqrestore() restores the interrupt state to its condition prior to the spin_lock_irqsave() call. Acked-by: Damien Le Moal Reviewed-by: Jason Yan Reviewed-by: Hannes Reinecke Signed-off-by: Igor Pylypiv Link: https://lore.kernel.org/r/20240307214418.3812290-2-ipylypiv@google.com Reviewed-by: Niklas Cassel Signed-off-by: Martin K. Petersen commit 855ce06f9104e8b4b336807f3c941381bf845eb1 Author: Justin Stitt Date: Tue Mar 5 23:34:42 2024 +0000 scsi: wd33c93: Replace deprecated strncpy() with strscpy() @p1 is assigned to @setup_buffer and then we manually assign a NUL-byte at the first index. This renders the following strlen() call useless. Moreover, we don't need to reassign p1 to setup_buffer for any reason -- neither do we need to manually set a NUL-byte at the end. strscpy() resolves all this code making it easier to read. Even considering the path where @str is falsey, the manual NUL-byte assignment is useless as setup_buffer is declared with static storage duration in the top-level scope which should NUL-initialize the whole buffer. Reviewed-by: Kees Cook Signed-off-by: Justin Stitt Link: https://lore.kernel.org/r/20240305-strncpy-drivers-scsi-mpi3mr-mpi3mr_fw-c-v3-7-5b78a13ff984@google.com Signed-off-by: Martin K. Petersen commit 8fd4c9c8e1f33b76c02b0cb0421abafb1cf91e6b Author: Justin Stitt Date: Tue Mar 5 23:34:41 2024 +0000 scsi: smartpqi: Replace deprecated strncpy() with strscpy() buffer->driver_version is sized 32: | struct bmic_host_wellness_driver_version { | ... | char driver_version[32]; ... the source string "Linux " + DRIVER_VERISON is sized at 16. There's really no bug in the existing code since the buffers are sized appropriately with great care taken to manually NUL-terminate the destination buffer. Nonetheless, let's make the swap over to strscpy() for robustness' (and readability's) sake. Reviewed-by: Kees Cook Signed-off-by: Justin Stitt Link: https://lore.kernel.org/r/20240305-strncpy-drivers-scsi-mpi3mr-mpi3mr_fw-c-v3-6-5b78a13ff984@google.com Signed-off-by: Martin K. Petersen commit 1b60c86dd9928688469a9dd09582538aead85d32 Author: Justin Stitt Date: Tue Mar 5 23:34:40 2024 +0000 scsi: devinfo: Replace strncpy() and manual pad Depending on the state of @compatible, we are going to do different things with our @to buffer. When @compatible is true we want a NUL-term'd and NUL-padded destination buffer. Conversely, if @compatible is false we just want a space-padded destination buffer (no NUL-term required). As per: /** * scsi_dev_info_list_add_keyed - add one dev_info list entry. * @compatible: if true, null terminate short strings. Otherwise space pad. ... Note that we can't easily use strtomem_pad() here as the size of the @to buffer is unknown to the compiler due to indirection layers. Now, the intent of the code is more clear (I probably didn't even need to add a comment -- that's how clear it is). Reviewed-by: Kees Cook Signed-off-by: Justin Stitt Link: https://lore.kernel.org/r/20240305-strncpy-drivers-scsi-mpi3mr-mpi3mr_fw-c-v3-5-5b78a13ff984@google.com Signed-off-by: Martin K. Petersen commit 4f94864d210f31d9247e5189b2af368dcc05c395 Author: Justin Stitt Date: Tue Mar 5 23:34:39 2024 +0000 scsi: qla4xxx: Replace deprecated strncpy() with strscpy() Replace 3 instances of strncpy in ql4_mbx.c No bugs exist in the current implementation as some care was taken to ensure the write length was decreased by one to leave some space for a NUL-byte. However, instead of using strncpy(dest, src, LEN-1) we can opt for strscpy(dest, src, sizeof(dest)) which will result in NUL-termination as well. It should be noted that the entire chap_table is zero-allocated so the NUL-padding provided by strncpy is not needed. While here, I noticed that MIN_CHAP_SECRET_LEN was not used anywhere. Since strscpy gives us the number of bytes copied into the destination buffer (or an -E2BIG) we can check both for an error during copying and also for a non-length compliant secret. Add a new jump label so we can properly clean up our chap_table should we have to abort due to bad secret. The third instance in this file involves some more peculiar handling of strings: | uint32_t mbox_cmd[MBOX_REG_COUNT]; | ... | memset(&mbox_cmd, 0, sizeof(mbox_cmd)); | ... | mbox_cmd[0] = MBOX_CMD_SET_PARAM; | if (param == SET_DRVR_VERSION) { | mbox_cmd[1] = SET_DRVR_VERSION; | strncpy((char *)&mbox_cmd[2], QLA4XXX_DRIVER_VERSION, | MAX_DRVR_VER_LEN - 1); mbox_cmd has a size of 8: | #define MBOX_REG_COUNT 8 ... and its type width is 4 bytes. Hence, we have 32 bytes to work with here. The first 4 bytes are used as a flag for the MBOX_CMD_SET_PARAM. The next 4 bytes are used for SET_DRVR_VERSION. We now have 32-8=24 bytes remaining -- which thankfully is what MAX_DRVR_VER_LEN is equal to | #define MAX_DRVR_VER_LEN 24 ... and the thing we're copying into this pseudo-string buffer is | #define QLA4XXX_DRIVER_VERSION "5.04.00-k6" ... which is great because its less than 24 bytes (therefore we aren't truncating the source). All to say, there's no bug in the existing implementation (yay!) but we can clean the code up a bit by using strscpy(). In ql4_os.c, there aren't any strncpy() uses to replace but there are some existing strscpy() calls that could be made more idiomatic. Where possible, use strscpy(dest, src, sizeof(dest)). Note that chap_rec->password has a size of ISCSI_CHAP_AUTH_SECRET_MAX_LEN | #define ISCSI_CHAP_AUTH_SECRET_MAX_LEN 256 ... while the current strscpy usage uses QL4_CHAP_MAX_SECRET_LEN | #define QL4_CHAP_MAX_SECRET_LEN 100 ... however since chap_table->secret was set and bounded properly in its string assignment its probably safe here to switch over to sizeof(). | struct iscsi_chap_rec { ... | char username[ISCSI_CHAP_AUTH_NAME_MAX_LEN]; | uint8_t password[ISCSI_CHAP_AUTH_SECRET_MAX_LEN]; ... | }; | strscpy(chap_rec->password, chap_table->secret, | QL4_CHAP_MAX_SECRET_LEN); Reviewed-by: Kees Cook Signed-off-by: Justin Stitt Link: https://lore.kernel.org/r/20240305-strncpy-drivers-scsi-mpi3mr-mpi3mr_fw-c-v3-4-5b78a13ff984@google.com Signed-off-by: Martin K. Petersen commit 2303149d584feade8074295b717451b36ac63307 Author: Justin Stitt Date: Tue Mar 5 23:34:38 2024 +0000 scsi: qedf: Replace deprecated strncpy() with strscpy() We expect slowpath_params.name to be NUL-terminated based on its future usage with other string APIs: | static int qed_slowpath_start(struct qed_dev *cdev, | struct qed_slowpath_params *params) ... | strscpy(drv_version.name, params->name, | MCP_DRV_VER_STR_SIZE - 4); Moreover, NUL-padding is not necessary as the only use for this slowpath name parameter is to copy into the drv_version.name field. Also, let's prefer using strscpy(src, dest, sizeof(src)) in two instances (one of which is outside of the scsi system but it is trivial and related to this patch). We can see the drv_version.name size here: | struct qed_mcp_drv_version { | u32 version; | u8 name[MCP_DRV_VER_STR_SIZE - 4]; | }; Reviewed-by: Kees Cook Signed-off-by: Justin Stitt Link: https://lore.kernel.org/r/20240305-strncpy-drivers-scsi-mpi3mr-mpi3mr_fw-c-v3-3-5b78a13ff984@google.com Signed-off-by: Martin K. Petersen commit b7e9712a02e869d2c15a3a2284b078771fd484d7 Author: Justin Stitt Date: Tue Mar 5 23:34:37 2024 +0000 scsi: mpt3sas: Replace deprecated strncpy() with strscpy() The replacement in mpt3sas_base.c is a trivial one because desc is already zero-initialized meaning there is no functional change here. For mpt3sas_transport.c, we know edev is zero-initialized as well while manufacture_reply comes from dma_alloc_coherent(). No functional change here either. For all cases, use the more idiomatic strscpy() usage of: strscpy(dest, src, sizeof(dest)) Reviewed-by: Kees Cook Signed-off-by: Justin Stitt Link: https://lore.kernel.org/r/20240305-strncpy-drivers-scsi-mpi3mr-mpi3mr_fw-c-v3-2-5b78a13ff984@google.com Signed-off-by: Martin K. Petersen commit 8c8e2422bde198efa57566d768400f73cc485aad Author: Justin Stitt Date: Tue Mar 5 23:34:36 2024 +0000 scsi: mpi3mr: Replace deprecated strncpy() with assignments Really, there's no bug with the current code. Let's just ditch strncpy() all together. We can just copy the const strings instead of reserving room on the stack. Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings [1] Link: https://manpages.debian.org/testing/linux-manual-4.8/strscpy.9.en.html [2] Link: https://github.com/KSPP/linux/issues/90 Cc: linux-hardening@vger.kernel.org Reviewed-by: Kees Cook Signed-off-by: Justin Stitt Link: https://lore.kernel.org/r/20240305-strncpy-drivers-scsi-mpi3mr-mpi3mr_fw-c-v3-1-5b78a13ff984@google.com Signed-off-by: Martin K. Petersen