Commit graph

1153551 commits

Author SHA1 Message Date
Tomas Henzl
578797f0c8 scsi: ses: Fix slab-out-of-bounds in ses_intf_remove()
A fix for:

BUG: KASAN: slab-out-of-bounds in ses_intf_remove+0x23f/0x270 [ses]
Read of size 8 at addr ffff88a10d32e5d8 by task rmmod/12013

When edev->components is zero, accessing edev->component[0] members is
wrong.

Link: https://lore.kernel.org/r/20230202162451.15346-5-thenzl@redhat.com
Cc: stable@vger.kernel.org
Signed-off-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2023-02-21 17:32:04 -05:00
Tomas Henzl
801ab13d50 scsi: ses: Fix possible desc_ptr out-of-bounds accesses
Sanitize possible desc_ptr out-of-bounds accesses in
ses_enclosure_data_process().

Link: https://lore.kernel.org/r/20230202162451.15346-4-thenzl@redhat.com
Cc: stable@vger.kernel.org
Signed-off-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2023-02-21 17:32:04 -05:00
Tomas Henzl
db95d4df71 scsi: ses: Fix possible addl_desc_ptr out-of-bounds accesses
Sanitize possible addl_desc_ptr out-of-bounds accesses in
ses_enclosure_data_process().

Link: https://lore.kernel.org/r/20230202162451.15346-3-thenzl@redhat.com
Cc: stable@vger.kernel.org
Signed-off-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2023-02-21 17:32:03 -05:00
Tomas Henzl
9b4f5028e4 scsi: ses: Fix slab-out-of-bounds in ses_enclosure_data_process()
A fix for:

BUG: KASAN: slab-out-of-bounds in ses_enclosure_data_process+0x949/0xe30 [ses]
Read of size 1 at addr ffff88a1b043a451 by task systemd-udevd/3271

Checking after (and before in next loop) addl_desc_ptr[1] is sufficient, we
expect the size to be sanitized before first access to addl_desc_ptr[1].
Make sure we don't walk beyond end of page.

Link: https://lore.kernel.org/r/20230202162451.15346-2-thenzl@redhat.com
Cc: stable@vger.kernel.org
Signed-off-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2023-02-21 17:32:03 -05:00
Christophe JAILLET
833f7d4819 scsi: ufs: core: Fix an error handling path in ufshcd_read_desc_param()
If an error occurs, some memory may need to be freed, as in the other error
handling paths.

Before the commit in the Fixes tag, this test was done before the memory
allocation, so there was no issue.

Fixes: 16ed9d312b ("scsi: ufs: core: Remove ufshcd_map_desc_id_to_length()")
Link: https://lore.kernel.org/r/2c6e42205e5ec22e5e8c7c85c6deb8fde31c74da.1673781835.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2023-02-08 21:26:17 -05:00
Mason Zhang
36822124f9 scsi: ufs: core: Fix device management cmd timeout flow
In the UFS error handling flow, the host will send a device management cmd
(NOP OUT) to the device for link recovery. If this cmd times out and
clearing the doorbell fails, ufshcd_wait_for_dev_cmd() will do nothing and
return. hba->dev_cmd.complete struct is not set to NULL.

When this happens, if cmd has been completed by device, then we will call
complete() in __ufshcd_transfer_req_compl(). Because the complete struct is
allocated on the stack, the following crash will occur:

  ipanic_die+0x24/0x38 [mrdump]
  die+0x344/0x748
  arm64_notify_die+0x44/0x104
  do_debug_exception+0x104/0x1e0
  el1_dbg+0x38/0x54
  el1_sync_handler+0x40/0x88
  el1_sync+0x8c/0x140
  queued_spin_lock_slowpath+0x2e4/0x3c0
  __ufshcd_transfer_req_compl+0x3b0/0x1164
  ufshcd_trc_handler+0x15c/0x308
  ufshcd_host_reset_and_restore+0x54/0x260
  ufshcd_reset_and_restore+0x28c/0x57c
  ufshcd_err_handler+0xeb8/0x1b6c
  process_one_work+0x288/0x964
  worker_thread+0x4bc/0xc7c
  kthread+0x15c/0x264
  ret_from_fork+0x10/0x30

Link: https://lore.kernel.org/r/20221216032532.1280-1-mason.zhang@mediatek.com
Signed-off-by: Mason Zhang <Mason.Zhang@mediatek.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2023-02-08 21:20:00 -05:00
Jiasheng Jiang
32fe45274e scsi: aic94xx: Add missing check for dma_map_single()
Add check for dma_map_single() and return error if it fails in order to
avoid invalid DMA address.

Fixes: 2908d778ab ("[SCSI] aic94xx: new driver")
Link: https://lore.kernel.org/r/20230128110832.6792-1-jiasheng@iscas.ac.cn
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Reviewed-by: Jason Yan <yanaijie@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2023-02-08 19:12:25 -05:00
Gustavo A. R. Silva
ead821268c scsi: smartpqi: Replace one-element array with flexible-array member
One-element arrays are deprecated, and we are replacing them with flexible
array members instead. So, replace one-element array with flexible-array
member in struct report_log_lun_list.

This helps with the ongoing efforts to tighten the FORTIFY_SOURCE routines
on memcpy().

Link: https://lore.kernel.org/r/Y+LJz/r6+UeLqnV3@work
Link: https://github.com/KSPP/linux/issues/79
Link: https://github.com/KSPP/linux/issues/204
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Acked-by: Don Brace <don.brace@microchip.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2023-02-08 19:03:43 -05:00
Tomas Henzl
54dd96015e scsi: mpt3sas: Fix a memory leak
Add a forgotten kfree().

Fixes: dbec4c9040 ("scsi: mpt3sas: lockless command submission")
Link: https://lore.kernel.org/r/20230207152159.18627-1-thenzl@redhat.com
Signed-off-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2023-02-08 19:02:04 -05:00
Jiapeng Chong
d48a62381a scsi: qla2xxx: Remove the unused variable wwn
Variable wwn is not used. Delete it.

drivers/scsi/qla2xxx/qla_init.c:1657:6: warning: variable 'wwn' set but not used.

Link: https://lore.kernel.org/r/20230207052234.24535-1-jiapeng.chong@linux.alibaba.com
Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2023-02-08 18:59:08 -05:00
Bart Van Assche
b62c8292d2 scsi: ufs: core: Fix kernel-doc syntax
Fix the following kernel-doc warnings:

drivers/ufs/core/ufs-mcq.c:87: warning: Function parameter or member 'hba' not described in 'ufshcd_mcq_config_mac'
drivers/ufs/core/ufs-mcq.c:87: warning: Function parameter or member 'max_active_cmds' not described in 'ufshcd_mcq_config_mac'
drivers/ufs/core/ufs-mcq.c:107: warning: Function parameter or member 'hba' not described in 'ufshcd_mcq_req_to_hwq'
drivers/ufs/core/ufs-mcq.c:107: warning: Function parameter or member 'req' not described in 'ufshcd_mcq_req_to_hwq'
drivers/ufs/core/ufs-mcq.c:128: warning: Function parameter or member 'hba' not described in 'ufshcd_mcq_decide_queue_depth'

Link: https://lore.kernel.org/r/20230202220155.561115-1-bvanassche@acm.org
Fixes: 854f84e7fe ("scsi: ufs: core: mcq: Find hardware queue to queue request")
Fixes: 2468da61ea ("scsi: ufs: core: mcq: Configure operation and runtime interface")
Fixes: 7224c80687 ("scsi: ufs: core: mcq: Calculate queue depth")
Cc: Asutosh Das <quic_asutoshd@quicinc.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Asutosh Das <quic_asutoshd@quicinc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2023-02-08 18:56:51 -05:00
Anjana Hari
88441a8d35 scsi: ufs: core: Add hibernation callbacks
Add freeze, thaw, and restore callbacks for hibernate and restore
functionality.

Link: https://lore.kernel.org/r/20230202161045.3956-2-quic_ahari@quicinc.com
Signed-off-by: Anjana Hari <quic_ahari@quicinc.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2023-02-08 18:52:18 -05:00
Greg Kroah-Hartman
ad0e4e2fab scsi: snic: Fix memory leak with using debugfs_lookup()
When calling debugfs_lookup() the result must have dput() called on it,
otherwise the memory will leak over time.  To make things simpler, just
call debugfs_lookup_and_remove() instead which handles all of the logic at
once.

Link: https://lore.kernel.org/r/20230202141009.2290380-1-gregkh@linuxfoundation.org
Cc: Karan Tilak Kumar <kartilak@cisco.com>
Cc: Sesidhar Baddela <sebaddel@cisco.com>
Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: linux-scsi@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2023-02-08 18:49:59 -05:00
Bjorn Andersson
339aa12218 scsi: ufs: core: Limit DMA alignment check
The three DMA memory regions allocated for the host memory space are
documented to require alignment of 128, 1024, and 1024 respectively, but
the returned address is checked for PAGE_SIZE alignment.

In the case where these allocations are serviced by e.g. the Arm SMMU, the
size and alignment will be determined by its supported page sizes. In most
cases SZ_4K and a few larger sizes are available.

In the typical configuration this does not cause problems, but in the event
that the system PAGE_SIZE is increased beyond 4k, it's no longer reasonable
to expect that the allocation will be PAGE_SIZE aligned.

Limit the DMA alignment check to the actual alignment requirements written
in the comments in the code, to avoid the UFS core refusing to initialize
with such configuration.

Link: https://lore.kernel.org/r/20230201034917.1902330-1-quic_bjorande@quicinc.com
Signed-off-by: Bjorn Andersson <quic_bjorande@quicinc.com>
Reviewed-by: Manivannan Sadhasivam <mani@kernel.org>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Asutosh Das <quic_asutoshd@quicinc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2023-02-08 18:49:48 -05:00
Randy Dunlap
cf065a7da5 scsi: Documentation: Correct spelling
Correct spelling problems for Documentation/scsi/ as reported by codespell.

Link: https://lore.kernel.org/r/20230129231053.20863-8-rdunlap@infradead.org
Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: linux-doc@vger.kernel.org
Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: linux-scsi@vger.kernel.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2023-02-08 18:49:48 -05:00
Randy Dunlap
685d5ef436 scsi: Documentation: Correct spelling
Correct spelling problems for Documentation/scsi/ ChangeLogs as reported by
codespell.

Link: https://lore.kernel.org/r/20230129231053.20863-7-rdunlap@infradead.org
Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: linux-doc@vger.kernel.org
Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: linux-scsi@vger.kernel.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2023-02-08 18:49:48 -05:00
Randy Dunlap
c57ac5748b scsi: target: Documentation: Correct spelling
Correct spelling problems for Documentation/target/ as reported by
codespell.

Link: https://lore.kernel.org/r/20230127064005.1558-29-rdunlap@infradead.org
Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: linux-scsi@vger.kernel.org
Cc: target-devel@vger.kernel.org
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: linux-doc@vger.kernel.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2023-02-08 18:49:48 -05:00
Kees Cook
7ab734fc75 scsi: aacraid: Allocate cmd_priv with scsicmd
The aac_priv() helper assumes that the private cmd area immediately follows
struct scsi_cmnd. Allocate this space as part of scsicmd, else there is a
risk of heap overflow. Seen with GCC 13:

../drivers/scsi/aacraid/aachba.c: In function 'aac_probe_container':
../drivers/scsi/aacraid/aachba.c:841:26: warning: array subscript 16 is outside array bounds of 'void[392]' [-Warray-bounds=]
  841 |         status = cmd_priv->status;
      |                          ^~
In file included from ../include/linux/resource_ext.h:11,
                 from ../include/linux/pci.h:40,
                 from ../drivers/scsi/aacraid/aachba.c:22:
In function 'kmalloc',
    inlined from 'kzalloc' at ../include/linux/slab.h:720:9,
    inlined from 'aac_probe_container' at ../drivers/scsi/aacraid/aachba.c:821:30:
../include/linux/slab.h:580:24: note: at offset 392 into object of size 392 allocated by 'kmalloc_trace'
  580 |                 return kmalloc_trace(
      |                        ^~~~~~~~~~~~~~
  581 |                                 kmalloc_caches[kmalloc_type(flags)][index],
      |                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  582 |                                 flags, size);
      |                                 ~~~~~~~~~~~~

Fixes: 76a3451b64 ("scsi: aacraid: Move the SCSI pointer to private command data")
Link: https://lore.kernel.org/r/20230128000409.never.976-kees@kernel.org
Cc: Bart Van Assche <bvanassche@acm.org>
Cc: Hannes Reinecke <hare@suse.de>
Cc: Himanshu Madhani <himanshu.madhani@oracle.com>
Cc: Adaptec OEM Raid Solutions <aacraid@microsemi.com>
Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: linux-scsi@vger.kernel.org
Cc: stable@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Vegard Nossum <vegard.nossum@oracle.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2023-02-08 18:49:48 -05:00
Martin K. Petersen
67e6216d9c Merge patch series "ufs: host: ufs-qcom: Add support for SM8550"
Abel Vesa <abel.vesa@linaro.org> says:

This patchset adds UFS HC support for the new Qualcomm SM8550 SoC.

Link: https://lore.kernel.org/r/20230119151406.4168685-1-abel.vesa@linaro.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2023-02-08 18:06:39 -05:00
Abel Vesa
b8c2038911 scsi: ufs: qcom: dt-bindings: Add SM8550 compatible string
Document the compatible string for the UFS found on SM8550.

Signed-off-by: Abel Vesa <abel.vesa@linaro.org>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Acked-by: Manivannan Sadhasivam <mani@kernel.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2023-02-08 18:05:23 -05:00
Abel Vesa
9c02aa24bf scsi: ufs: ufs-qcom: Clear qunipro_g4_sel for HW version major 5
On SM8550, depending on the Qunipro, we can run with G5 or G4.  For now,
when the major version is 5 or above, we go with G5.  Therefore, we need to
specifically tell UFS HC that.

Signed-off-by: Abel Vesa <abel.vesa@linaro.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2023-02-08 18:05:22 -05:00
Arnd Bergmann
49f262bc3c scsi: ufs: qcom: fix platform_msi_domain_free_irqs() reference
The newly added MSI support is mostly hidden inside of an #ifdef,
except for one line that now causes a build failure when MSI
is disabled:

drivers/ufs/host/ufs-qcom.c: In function 'ufs_qcom_remove':
drivers/ufs/host/ufs-qcom.c:1698:9: error: implicit declaration of function 'platform_msi_domain_free_irqs' [-Werror=i]
 1698 |         platform_msi_domain_free_irqs(hba->dev);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Above that, the symbol that guards the other call was recently removed, so
that is all dead code at the moment.

Remove the incorrect #ifdef and instead of a Kconfig dependency to only
allow building the driver when CONFIG_GENERIC_MSI_IRQ is enabled. This
symbol is always present when PCI_MSI or ARM_GIC_V3_ITS are enabled, both
of which should be present on kernels that can run on Qualcomm SoCs.

The 'select RESET_CONTROLLER' in combination with this dependency
unfortunately causes a dependency loop and this is a user-visible symbol,
so it's better to change both to 'depends on'.

Link: https://lore.kernel.org/r/20230126211831.2274211-1-arnd@kernel.org
Fixes: 519b6274a7 ("scsi: ufs: qcom: Add MCQ ESI config vendor specific ops")
Fixes: 13e7accb81 ("genirq: Get rid of GENERIC_MSI_IRQ_DOMAIN")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Manivannan Sadhasivam <mani@kernel.org>
Acked-by: Can Guo <quic_cang@quicinc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2023-02-03 20:16:51 -05:00
Martin K. Petersen
5adca38c0b Merge patch series "Enable DMA clustering in the UFS driver"
Bart Van Assche <bvanassche@acm.org> says:

The third patch in this series enables DMA clustering in the UFS
driver since UFS host controllers support DMA clustering. The first
two patches fix bugs in the Exynos host controller driver.

Link: https://lore.kernel.org/r/20230112234215.2630817-1-bvanassche@acm.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2023-01-23 21:38:10 -05:00
Bart Van Assche
13f87983fb scsi: ufs: core: Enable DMA clustering
All UFS host controllers support DMA clustering. Hence enable DMA
clustering.

Notes:

 - The max_segment_size parameter implements the 256 KiB limit for the
   PRDT. The dma_boundary parameter represents a boundary that must not be
   crossed by DMA scatter/gather lists. I'm not aware of any restrictions
   on DMA scatter/gather lists in the UFSHCI specification other than the
   256 KiB limit for the PRDT and the 32-bit address restriction for
   controllers that only support 32-bits DMA. The latter restriction is
   already handled by ufshcd_set_dma_mask().

 - Without patch "scsi: ufs: exynos: Fix the maximum segment size", this
   patch breaks support for the Exynos controller.

The history of the dma_boundary parameter in the UFS driver is as
follows:

 * The initial UFS driver did not set the dma_boundary parameter.

 * Commit 4dd4130a72 ("scsi: make sure all drivers set the use_clustering
   flag") set the .use_clustering flag.

 * Commit 4af14d113b ("scsi: remove the use_clustering flag") removed the
   use_clustering flag and set the dma_boundary parameter instead.

Cc: Avri Altman <avri.altman@wdc.com>
Cc: Alim Akhtar <alim.akhtar@samsung.com>
Cc: Kiwoong Kim <kwmad.kim@samsung.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Reviewed-by: Alim Akhtar <alim.akhtar@samsung.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2023-01-23 21:35:54 -05:00
Bart Van Assche
9a80bc5deb scsi: ufs: exynos: Fix the maximum segment size
Prepare for enabling DMA clustering and also for supporting PAGE_SIZE !=
4096 by declaring explicitly that the maximum segment size is 4096 bytes
for Exynos UFS host controllers. Add this code in
exynos_ufs_hce_enable_notify() such that it happens after scsi_host_alloc()
and before __scsi_init_queue() is called by the LUN scanning code.

Cc: Alim Akhtar <alim.akhtar@samsung.com>
Cc: Kiwoong Kim <kwmad.kim@samsung.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Alim Akhtar <alim.akhtar@samsung.com>
Tested-by: Alim Akhtar <alim.akhtar@samsung.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2023-01-23 21:35:54 -05:00
Bart Van Assche
86bd0c4a2a scsi: ufs: exynos: Fix DMA alignment for PAGE_SIZE != 4096
The Exynos UFS controller only supports scatter/gather list elements that
are aligned on a 4 KiB boundary. Fix DMA alignment in case PAGE_SIZE !=
4096. Rename UFSHCD_QUIRK_ALIGN_SG_WITH_PAGE_SIZE into
UFSHCD_QUIRK_4KB_DMA_ALIGNMENT.

Cc: Kiwoong Kim <kwmad.kim@samsung.com>
Fixes: 2b2bfc8aa5 ("scsi: ufs: Introduce a quirk to allow only page-aligned sg entries")
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Alim Akhtar <alim.akhtar@samsung.com>
Tested-by: Alim Akhtar <alim.akhtar@samsung.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2023-01-23 21:35:54 -05:00
Deepak R Varma
5a5ef64f28 scsi: qla2xxx: Simplify if condition evaluation
A logical evaluation of type (!A || A && B) can be simplified as (!A || B).
Improvement by suggested by excluded_middle.cocci Coccinelel semantic
patch.

Link: https://lore.kernel.org/r/Y7+oJuah0MgEW0PQ@ubun2204.myguest.virtualbox.org
Signed-off-by: Deepak R Varma <drv@mailo.com>
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2023-01-23 21:18:16 -05:00
Deepak R Varma
4fd6297373 scsi: qla2xxx: Use a variable for repeated mem_size computation
Use a variable to compute memory size to be allocated once instead of
repeatedly computing it at different locations in the function. Issue
identified using the array_size_dup Coccinelle semantic patch.

Link: https://lore.kernel.org/r/Y7spwF8HTt0c0l7y@ubun2204.myguest.virtualbox.org
Signed-off-by: Deepak R Varma <drv@mailo.com>
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2023-01-23 21:15:02 -05:00
Randy Dunlap
2aa0f83edb scsi: elx: libefc_sli: Use "/*" for non-kernel-doc comment
Don't use "/**" to begin non-kernel-doc comments.  Prevent a kernel-doc
warning:

drivers/scsi/elx/libefc_sli/sli4.c:13: warning: cannot understand function prototype: 'struct sli4_asic_entry_t sli4_asic_table[] = '

Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Cc: James Smart <james.smart@broadcom.com>
Cc: Ram Vegesna <ram.vegesna@broadcom.com>
Cc: target-devel@vger.kernel.org
Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Link: https://lore.kernel.org/r/20230117070151.29339-1-rdunlap@infradead.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2023-01-23 20:53:43 -05:00
Johan Hovold
85e182b48a 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 <robh@kernel.org>
Reviewed-by: Bjorn Andersson <andersson@kernel.org>
Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
Link: https://lore.kernel.org/r/20230116164236.18958-1-johan+linaro@kernel.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2023-01-18 18:48:43 -05:00
Tom Rix
54c51253b3 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: 1f8f9c3412 ("scsi: qla2xxx: edif: Reduce memory usage during low I/O")
Signed-off-by: Tom Rix <trix@redhat.com>
Link: https://lore.kernel.org/r/20230114013724.3943580-1-trix@redhat.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2023-01-18 18:46:21 -05:00
Fabio M. De Francesco
a3e2e248fd 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 <ira.weiny@intel.com>
Signed-off-by: Fabio M. De Francesco <fmdefrancesco@gmail.com>
Link: https://lore.kernel.org/r/20230103182556.29080-1-fmdefrancesco@gmail.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2023-01-18 18:43:50 -05:00
Fabio M. De Francesco
7edd053b33 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 <ira.weiny@intel.com>
Signed-off-by: Fabio M. De Francesco <fmdefrancesco@gmail.com>
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Link: https://lore.kernel.org/r/20230103173131.21259-1-fmdefrancesco@gmail.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2023-01-18 18:41:12 -05:00
Paul Menzel
1eeedfad9a 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 <pmenzel@molgen.mpg.de>
Link: https://lore.kernel.org/r/20230103150438.45922-1-pmenzel@molgen.mpg.de
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2023-01-18 18:39:15 -05:00
Arnd Bergmann
d794a23113 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: 82d8dfd2a2 ("scsi: qla2xxx: edif: Fix performance dip due to lock contention")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Himanshu Madhani <himansnhu.madhani@oracle.com <mailto:himansnhu.madhani@oracle.com>>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Link: https://lore.kernel.org/r/20230117170029.2387516-1-arnd@kernel.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2023-01-18 18:34:41 -05:00
Alim Akhtar
fd5df558c3 scsi: MAINTAINERS: Add entry for Exynos UFS driver
Add maintainer entry for Exynos UFS driver.

Signed-off-by: Alim Akhtar <alim.akhtar@samsung.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Link: https://lore.kernel.org/r/20230114080247.601312-1-alim.akhtar@samsung.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2023-01-18 18:25:53 -05:00
Alim Akhtar
3730bea883 scsi: ufs: ufs: Remove duplicate entry
PA_GRANULARITY is duplicated, delete one of the entries.

Signed-off-by: Alim Akhtar <alim.akhtar@samsung.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Link: https://lore.kernel.org/r/20230114022010.27088-1-alim.akhtar@samsung.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2023-01-18 18:24:24 -05:00
Kees Cook
a9a3629592 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 <Holger.Kiehl@dwd.de>
Link: https://lore.kernel.org/all/88de8faa-56c4-693d-2d3-67152ee72057@diagnostix.dwd.de/
Cc: Kashyap Desai <kashyap.desai@broadcom.com>
Cc: Sumit Saxena <sumit.saxena@broadcom.com>
Cc: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
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 <keescook@chromium.org>
Tested-by: Holger Kiehl <Holger.Kiehl@dwd.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2023-01-18 18:22:22 -05:00
Martin K. Petersen
0c0d806908 Merge patch series "scsi: Add struct for args to execution functions"
Mike Christie <michael.christie@oracle.com> says:

The following patches were made over Martin's scsi-staging/next
branch.  They add a struct that contains optinal arguments to the
scsi_execute* functions. This will be needed for the patches that
allow the SCSI passthrough users to control retries because I'm adding
a new optional argument. I separated the 2 sets to make it easier to
review and post.

Link: https://lore.kernel.org/r/20221229190154.7467-1-michael.christie@oracle.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2023-01-18 18:15:20 -05:00
Mike Christie
946a10511f 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 <michael.christie@oracle.com>
Reviewed-by: John Garry <john.g.garry@oracle.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2023-01-18 18:11:49 -05:00
Mike Christie
1035c9893f 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 <michael.christie@oracle.com>
Reviewed-by: John Garry <john.g.garry@oracle.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2023-01-18 18:11:19 -05:00
Mike Christie
e335795f27 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 <michael.christie@oracle.com>
Reviewed-by: John Garry <john.g.garry@oracle.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2023-01-13 21:34:09 -05:00
Mike Christie
5314ce761f 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 <michael.christie@oracle.com>
Reviewed-by: John Garry <john.g.garry@oracle.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2023-01-13 21:34:09 -05:00
Mike Christie
49d33b6245 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 <michael.christie@oracle.com>
Reviewed-by: John Garry <john.g.garry@oracle.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2023-01-13 21:34:09 -05:00
Mike Christie
ae4145a5f2 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 <michael.christie@oracle.com>
Reviewed-by: John Garry <john.g.garry@oracle.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2023-01-13 21:34:09 -05:00
Mike Christie
6ff236e847 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 <michael.christie@oracle.com>
Reviewed-by: John Garry <john.g.garry@oracle.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2023-01-13 21:34:09 -05:00
Mike Christie
af16cd63d9 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 <michael.christie@oracle.com>
Reviewed-by: John Garry <john.g.garry@oracle.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2023-01-13 21:34:09 -05:00
Mike Christie
c9ee828aad 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 <michael.christie@oracle.com>
Reviewed-by: John Garry <john.g.garry@oracle.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2023-01-13 21:34:09 -05:00
Mike Christie
7dfe0b5e7c 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 <michael.christie@oracle.com>
Reviewed-by: John Garry <john.g.garry@oracle.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2023-01-13 21:34:09 -05:00
Mike Christie
31fc28c6b1 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 <michael.christie@oracle.com>
Reviewed-by: John Garry <john.g.garry@oracle.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2023-01-13 21:34:08 -05:00