]> git.ipfire.org Git - thirdparty/linux.git/log
thirdparty/linux.git
2 months agoscsi: megaraid_sas: Driver version update to 07.734.00.00-rc1
Chandrakanth Patil [Wed, 2 Apr 2025 19:37:35 +0000 (01:07 +0530)] 
scsi: megaraid_sas: Driver version update to 07.734.00.00-rc1

Signed-off-by: Chandrakanth Patil <chandrakanth.patil@broadcom.com>
Link: https://lore.kernel.org/r/20250402193735.5098-2-chandrakanth.patil@broadcom.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: megaraid_sas: Block zero-length ATA VPD inquiry
Chandrakanth Patil [Wed, 2 Apr 2025 19:37:34 +0000 (01:07 +0530)] 
scsi: megaraid_sas: Block zero-length ATA VPD inquiry

A firmware bug was observed where ATA VPD inquiry commands with a
zero-length data payload were not handled and failed with a non-standard
status code of 0xf0.

Avoid sending ATA VPD inquiry commands without data payload by setting
the device no_vpd_size flag to 1. In addition, if the firmware returns a
status code of 0xf0, set scsi_cmnd->result to CHECK_CONDITION to
facilitate proper error handling.

Suggested-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Chandrakanth Patil <chandrakanth.patil@broadcom.com>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20250402193735.5098-1-chandrakanth.patil@broadcom.com
Tested-by: Ryan Lahfa <ryan@lahfa.xyz>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: scsi_transport_srp: Replace min/max nesting with clamp()
Li Haoran [Mon, 31 Mar 2025 07:55:11 +0000 (15:55 +0800)] 
scsi: scsi_transport_srp: Replace min/max nesting with clamp()

This patch replaces min(a, max(b, c)) by clamp(val, lo, hi) in the SRP
transport layer. The clamp() macro explicitly expresses the intent of
constraining a value within bounds, improving code readability.

Signed-off-by: Li Haoran <li.haoran7@zte.com.cn>
Signed-off-by: Shao Mingyin <shao.mingyin@zte.com.cn>
Link: https://lore.kernel.org/r/202503311555115618U8Md16mKpRYOIy2TOmB6@zte.com.cn
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: ufs: core: Add device level exception support
Bao D. Nguyen [Fri, 28 Mar 2025 21:46:13 +0000 (14:46 -0700)] 
scsi: ufs: core: Add device level exception support

The ufs device JEDEC specification version 4.1 adds support for the
device level exception events. To support this new device level
exception feature, expose two new sysfs nodes below to provide the user
space access to the device level exception information.

/sys/bus/platform/drivers/ufshcd/*/device_lvl_exception_count
/sys/bus/platform/drivers/ufshcd/*/device_lvl_exception_id

The device_lvl_exception_count sysfs node reports the number of device
level exceptions that have occurred since the last time this variable is
reset. Writing a value of 0 will reset it.  The device_lvl_exception_id
reports the exception ID which is the qDeviceLevelExceptionID attribute
of the device JEDEC specifications version 4.1 and later. The user space
application can query these sysfs nodes to get more information about
the device level exception.

Signed-off-by: Bao D. Nguyen <quic_nguyenb@quicinc.com>
Link: https://lore.kernel.org/r/6278d7c125b2f0cf5056f4a647a4b9c1fdd24fc7.1743198325.git.quic_nguyenb@quicinc.com
Reviewed-by: Peter Wang <peter.wang@mediatek.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Arthur Simchaev <arthur.simchaev@sandisk.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: ufs: core: Rename ufshcd_wb_presrv_usrspc_keep_vcc_on()
Bao D. Nguyen [Fri, 28 Mar 2025 20:17:11 +0000 (13:17 -0700)] 
scsi: ufs: core: Rename ufshcd_wb_presrv_usrspc_keep_vcc_on()

The ufshcd_wb_presrv_usrspc_keep_vcc_on() function has deviated from its
original implementation. The "_keep_vcc_on" part of the function name is
misleading. Rename the function to ufshcd_wb_curr_buff_threshold_check()
to improve the readability. Also, updated the comments in the function.
There is no change to the functionality.

Signed-off-by: Bao D. Nguyen <quic_nguyenb@quicinc.com>
Link: https://lore.kernel.org/r/02ae5e133f6ebf23b54d943e6d1d9de2544eb80e.1743192926.git.quic_nguyenb@quicinc.com
Reviewed-by: Avri Altman <avri.altman@sandisk.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: smartpqi: Use is_kdump_kernel() to check for kdump
Martin Wilck [Fri, 21 Mar 2025 22:33:19 +0000 (23:33 +0100)] 
scsi: smartpqi: Use is_kdump_kernel() to check for kdump

The smartpqi driver checks the reset_devices variable to determine
whether special adjustments need to be made for kdump. This has the
effect that after a regular kexec reboot, some driver parameters such as
max_transfer_size are much lower than usual. More importantly, kexec
reboot tests have revealed memory corruption caused by the driver log
being written to system memory after a kexec.

Fix this by testing is_kdump_kernel() rather than reset_devices where
appropriate.

Fixes: 058311b72f54 ("scsi: smartpqi: Add fw log to kdump")
Signed-off-by: Martin Wilck <mwilck@suse.com>
Link: https://lore.kernel.org/r/20250321223319.109250-1-mwilck@suse.com
Cc: Randy Wright <rwright@hpe.com>
Acked-by: Don Brace <don.brace@microchip.com>
Tested-by: Don Brace <don.brace@microchip.com>
Reviewed-by: Lee Duncan <lduncan@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: pm80xx: Set phy_attached to zero when device is gone
Igor Pylypiv [Wed, 19 Mar 2025 23:03:05 +0000 (23:03 +0000)] 
scsi: pm80xx: Set phy_attached to zero when device is gone

When a fatal error occurs, a phy down event may not be received to set
phy->phy_attached to zero.

Signed-off-by: Igor Pylypiv <ipylypiv@google.com>
Signed-off-by: Salomon Dushimirimana <salomondush@google.com>
Link: https://lore.kernel.org/r/20250319230305.3172920-1-salomondush@google.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoMerge patch series "ufs-exynos stability fixes for gs101"
Martin K. Petersen [Thu, 3 Apr 2025 13:58:05 +0000 (09:58 -0400)] 
Merge patch series "ufs-exynos stability fixes for gs101"

Peter Griffin <peter.griffin@linaro.org> says:

Hi folks,

This series fixes several stability issues with the upstream ufs-exynos
driver, specifically for the gs101 SoC found in Pixel 6.

The main fix is regarding the IO cache coherency setting and ensuring
that it is correctly applied depending on if the dma-coherent property
is specified in device tree. This fixes the UFS stability issues on gs101
and I would imagine will also fix issues on exynosauto platform that
seems to have similar iocc shareability bits.

Additionally the phy reference counting is fixed which allows module
load/unload to work reliably and keeps the phy state machine in sync
with the controller glue driver.

regards,

Peter

Link: https://lore.kernel.org/r/20250319-exynos-ufs-stability-fixes-v2-0-96722cc2ba1b@linaro.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: ufs: exynos: gs101: Put UFS device in reset on .suspend()
Peter Griffin [Wed, 19 Mar 2025 15:30:24 +0000 (15:30 +0000)] 
scsi: ufs: exynos: gs101: Put UFS device in reset on .suspend()

GPIO_OUT[0] is connected to the reset pin of embedded UFS device.
Before powering off the phy assert the reset signal.

This is added as a gs101 specific suspend hook so as not to have any
unintended consequences for other SoCs supported by this driver.

Signed-off-by: Peter Griffin <peter.griffin@linaro.org>
Link: https://lore.kernel.org/r/20250319-exynos-ufs-stability-fixes-v2-7-96722cc2ba1b@linaro.org
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: ufs: exynos: Move phy calls to .exit() callback
Peter Griffin [Wed, 19 Mar 2025 15:30:23 +0000 (15:30 +0000)] 
scsi: ufs: exynos: Move phy calls to .exit() callback

ufshcd_pltfrm_remove() calls ufshcd_remove(hba) which in turn calls
ufshcd_hba_exit().

By moving the phy_power_off() and phy_exit() calls to the newly created
.exit callback they get called by ufshcd_variant_hba_exit() before
ufshcd_hba_exit() turns off the regulators. This is also similar flow to
the ufs-qcom driver.

Signed-off-by: Peter Griffin <peter.griffin@linaro.org>
Link: https://lore.kernel.org/r/20250319-exynos-ufs-stability-fixes-v2-6-96722cc2ba1b@linaro.org
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: ufs: exynos: Enable PRDT pre-fetching with UFSHCD_CAP_CRYPTO
Peter Griffin [Wed, 19 Mar 2025 15:30:22 +0000 (15:30 +0000)] 
scsi: ufs: exynos: Enable PRDT pre-fetching with UFSHCD_CAP_CRYPTO

PRDT_PREFETCH_ENABLE[31] bit should be set when desctype field of
fmpsecurity0 register is type2 (double file encryption) or type3
(support for file and disk encryption). Setting this bit enables PRDT
pre-fetching on both TXPRDT and RXPRDT.

Signed-off-by: Peter Griffin <peter.griffin@linaro.org>
Link: https://lore.kernel.org/r/20250319-exynos-ufs-stability-fixes-v2-5-96722cc2ba1b@linaro.org
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: ufs: exynos: Ensure consistent phy reference counts
Peter Griffin [Wed, 19 Mar 2025 15:30:21 +0000 (15:30 +0000)] 
scsi: ufs: exynos: Ensure consistent phy reference counts

ufshcd_link_startup() can call ufshcd_vops_link_startup_notify()
multiple times when retrying. This causes the phy reference count to
keep increasing and the phy to not properly re-initialize.

If the phy has already been previously powered on, first issue a
phy_power_off() and phy_exit(), before re-initializing and powering on
again.

Signed-off-by: Peter Griffin <peter.griffin@linaro.org>
Link: https://lore.kernel.org/r/20250319-exynos-ufs-stability-fixes-v2-4-96722cc2ba1b@linaro.org
Fixes: 3d73b200f989 ("scsi: ufs: ufs-exynos: Change ufs phy control sequence")
Cc: stable@vger.kernel.org
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: ufs: exynos: Disable iocc if dma-coherent property isn't set
Peter Griffin [Wed, 19 Mar 2025 15:30:20 +0000 (15:30 +0000)] 
scsi: ufs: exynos: Disable iocc if dma-coherent property isn't set

If dma-coherent property isn't set then descriptors are non-cacheable
and the iocc shareability bits should be disabled. Without this UFS can
end up in an incompatible configuration and suffer from random cache
related stability issues.

Suggested-by: Bart Van Assche <bvanassche@acm.org>
Fixes: cc52e15397cc ("scsi: ufs: ufs-exynos: Support ExynosAuto v9 UFS")
Signed-off-by: Peter Griffin <peter.griffin@linaro.org>
Link: https://lore.kernel.org/r/20250319-exynos-ufs-stability-fixes-v2-3-96722cc2ba1b@linaro.org
Cc: Chanho Park <chanho61.park@samsung.com>
Cc: stable@vger.kernel.org
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: ufs: exynos: Move UFS shareability value to drvdata
Peter Griffin [Wed, 19 Mar 2025 15:30:19 +0000 (15:30 +0000)] 
scsi: ufs: exynos: Move UFS shareability value to drvdata

gs101 I/O coherency shareability bits differ from exynosauto SoC. To
support both SoCs move this info the SoC drvdata.

Currently both the value and mask are the same for both gs101 and
exynosauto, thus we use the same value.

Signed-off-by: Peter Griffin <peter.griffin@linaro.org>
Link: https://lore.kernel.org/r/20250319-exynos-ufs-stability-fixes-v2-2-96722cc2ba1b@linaro.org
Fixes: d11e0a318df8 ("scsi: ufs: exynos: Add support for Tensor gs101 SoC")
Cc: stable@vger.kernel.org
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: ufs: exynos: Ensure pre_link() executes before exynos_ufs_phy_init()
Peter Griffin [Wed, 19 Mar 2025 15:30:18 +0000 (15:30 +0000)] 
scsi: ufs: exynos: Ensure pre_link() executes before exynos_ufs_phy_init()

Ensure clocks are enabled before configuring unipro. Additionally move
the pre_link() hook before the exynos_ufs_phy_init() calls. This means
the register write sequence more closely resembles the ordering of the
downstream driver.

Signed-off-by: Peter Griffin <peter.griffin@linaro.org>
Link: https://lore.kernel.org/r/20250319-exynos-ufs-stability-fixes-v2-1-96722cc2ba1b@linaro.org
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: iscsi: Fix missing scsi_host_put() in error path
Miaoqian Lin [Tue, 18 Mar 2025 09:43:43 +0000 (17:43 +0800)] 
scsi: iscsi: Fix missing scsi_host_put() in error path

Add goto to ensure scsi_host_put() is called in all error paths of
iscsi_set_host_param() function. This fixes a potential memory leak when
strlen() check fails.

Fixes: ce51c8170084 ("scsi: iscsi: Add strlen() check in iscsi_if_set{_host}_param()")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
Link: https://lore.kernel.org/r/20250318094344.91776-1-linmq006@gmail.com
Reviewed-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: ufs: core: Fix a race condition related to device commands
Bart Van Assche [Fri, 14 Mar 2025 22:51:50 +0000 (15:51 -0700)] 
scsi: ufs: core: Fix a race condition related to device commands

There is a TOCTOU race in ufshcd_compl_one_cqe(): hba->dev_cmd.complete may
be cleared from another thread after it has been checked and before it is
used. Fix this race by moving the device command completion from the stack
of the device command submitter into struct ufs_hba. This patch fixes the
following kernel crash:

Unable to handle kernel NULL pointer dereference at virtual address 0000000000000008
Call trace:
 _raw_spin_lock_irqsave+0x34/0x80
 complete+0x24/0xb8
 ufshcd_compl_one_cqe+0x13c/0x4f0
 ufshcd_mcq_poll_cqe_lock+0xb4/0x108
 ufshcd_intr+0x2f4/0x444
 __handle_irq_event_percpu+0xbc/0x250
 handle_irq_event+0x48/0xb0

Fixes: 5a0b0cb9bee7 ("[SCSI] ufs: Add support for sending NOP OUT UPIU")
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Link: https://lore.kernel.org/r/20250314225206.1487838-1-bvanassche@acm.org
Reviewed-by: Peter Wang <peter.wang@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: hisi_sas: Fix I/O errors caused by hardware port ID changes
Xingui Yang [Wed, 12 Mar 2025 09:51:35 +0000 (17:51 +0800)] 
scsi: hisi_sas: Fix I/O errors caused by hardware port ID changes

The hw port ID of phy may change when inserting disks in batches, causing
the port ID in hisi_sas_port and itct to be inconsistent with the hardware,
resulting in I/O errors. The solution is to set the device state to gone to
intercept I/O sent to the device, and then execute linkreset to discard and
find the disk to re-update its information.

Signed-off-by: Xingui Yang <yangxingui@huawei.com>
Link: https://lore.kernel.org/r/20250312095135.3048379-3-yangxingui@huawei.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: hisi_sas: Enable force phy when SATA disk directly connected
Xingui Yang [Wed, 12 Mar 2025 09:51:34 +0000 (17:51 +0800)] 
scsi: hisi_sas: Enable force phy when SATA disk directly connected

when a SATA disk is directly connected the SAS controller determines the
disk to which I/Os are delivered based on the port ID in the DQ entry.

When many phys are disconnected and reconnect, the port ID of phys were
changed and used by other link, resulting in I/O being sent to incorrect
disk. Data inconsistency on the SATA disk may occur during I/O retries
using the old port ID. So enable force phy, then force the command to be
executed in a certain phy, and if the actual phy ID of the port does not
match the phy configured in the command, the chip will stop delivering the
I/O to disk.

Fixes: ce60689e12dd ("scsi: hisi_sas: add v3 code to send ATA frame")
Signed-off-by: Xingui Yang <yangxingui@huawei.com>
Link: https://lore.kernel.org/r/20250312095135.3048379-2-yangxingui@huawei.com
Reviewed-by: Yihang Li <liyihang9@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: st: Tighten the page format heuristics with MODE SELECT
Kai Mäkisara [Tue, 11 Mar 2025 11:25:16 +0000 (13:25 +0200)] 
scsi: st: Tighten the page format heuristics with MODE SELECT

In the days when SCSI-2 was emerging, some drives did claim SCSI-2 but did
not correctly implement it. The st driver first tries MODE SELECT with the
page format bit set to set the block descriptor.  If not successful, the
non-page format is tried.

The test only tests the sense code and this triggers also from illegal
parameter in the parameter list. The test is limited to "old" devices and
made more strict to remove false alarms.

Signed-off-by: Kai Mäkisara <Kai.Makisara@kolumbus.fi>
Link: https://lore.kernel.org/r/20250311112516.5548-4-Kai.Makisara@kolumbus.fi
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: st: ERASE does not change tape location
Kai Mäkisara [Tue, 11 Mar 2025 11:25:15 +0000 (13:25 +0200)] 
scsi: st: ERASE does not change tape location

The SCSI ERASE command erases from the current position onwards.  Don't
clear the position variables.

Signed-off-by: Kai Mäkisara <Kai.Makisara@kolumbus.fi>
Link: https://lore.kernel.org/r/20250311112516.5548-3-Kai.Makisara@kolumbus.fi
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: st: Fix array overflow in st_setup()
Kai Mäkisara [Tue, 11 Mar 2025 11:25:14 +0000 (13:25 +0200)] 
scsi: st: Fix array overflow in st_setup()

Change the array size to follow parms size instead of a fixed value.

Reported-by: Chenyuan Yang <chenyuan0y@gmail.com>
Closes: https://lore.kernel.org/linux-scsi/CALGdzuoubbra4xKOJcsyThdk5Y1BrAmZs==wbqjbkAgmKS39Aw@mail.gmail.com/
Signed-off-by: Kai Mäkisara <Kai.Makisara@kolumbus.fi>
Link: https://lore.kernel.org/r/20250311112516.5548-2-Kai.Makisara@kolumbus.fi
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: target: tcm_loop: Fix wrong abort tag
Guixin Liu [Thu, 13 Mar 2025 01:47:27 +0000 (09:47 +0800)] 
scsi: target: tcm_loop: Fix wrong abort tag

When the tcm_loop_nr_hw_queues is set to a value greater than 1, the
tags of requests in the block layer are no longer unique. This may lead
to erroneous aborting of commands with the same tag. The issue can be
resolved by using blk_mq_unique_tag to generate globally unique
identifiers by combining the hardware queue index and per-queue tags.

Fixes: 6375f8908255 ("tcm_loop: Fixup tag handling")
Signed-off-by: Guixin Liu <kanie@linux.alibaba.com>
Link: https://lore.kernel.org/r/20250313014728.105849-1-kanie@linux.alibaba.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: lpfc: Restore clearing of NLP_UNREG_INP in ndlp->nlp_flag
Ewan D. Milne [Mon, 17 Mar 2025 16:37:31 +0000 (12:37 -0400)] 
scsi: lpfc: Restore clearing of NLP_UNREG_INP in ndlp->nlp_flag

Commit 32566a6f1ae5 ("scsi: lpfc: Remove NLP_RELEASE_RPI flag from nodelist
structure") introduced a regression with SLI-3 adapters (e.g. LPe12000 8Gb)
where a Link Down / Link Up such as caused by disabling an host FC switch
port would result in the devices remaining in the transport-offline state
and multipath reporting them as failed.  This problem was not seen with
newer SLI-4 adapters.

The problem was caused by portions of the patch which removed the functions
__lpfc_sli_rpi_release() and lpfc_sli_rpi_release() and all their callers.
This was presumably because with the removal of the NLP_RELEASE_RPI flag
there was no need to free the rpi.

However, __lpfc_sli_rpi_release() and lpfc_sli_rpi_release() which calls it
reset the NLP_UNREG_INP flag. And, lpfc_sli_def_mbox_cmpl() has a path
where __lpfc_sli_rpi_release() was called in a particular case where
NLP_UNREG_INP was not otherwise cleared because of other conditions.

Restoring the else clause of this conditional and simply clearing the
NLP_UNREG_INP flag appears to resolve the problem with SLI-3 adapters.  It
should be noted that the code path in question is not specific to SLI-3,
but there are other SLI-4 code paths which may have masked the issue.

Fixes: 32566a6f1ae5 ("scsi: lpfc: Remove NLP_RELEASE_RPI flag from nodelist structure")
Cc: stable@vger.kernel.org
Tested-by: Marco Patalano <mpatalan@redhat.com>
Signed-off-by: Ewan D. Milne <emilne@redhat.com>
Link: https://lore.kernel.org/r/20250317163731.356873-1-emilne@redhat.com
Reviewed-by: Justin Tee <justin.tee@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: hisi_sas: Fixed failure to issue vendor specific commands
Xingui Yang [Thu, 20 Feb 2025 09:00:11 +0000 (17:00 +0800)] 
scsi: hisi_sas: Fixed failure to issue vendor specific commands

At present, we determine the protocol through the cmd type, but other cmd
types, such as vendor-specific commands, default to the PIO protocol.  This
strategy often causes the execution of different vendor-specific commands
to fail. In fact, for these commands, a better way is to use the protocol
configured by the command's tf to determine its protocol.

Fixes: 6f2ff1a1311e ("hisi_sas: add v2 path to send ATA command")
Signed-off-by: Xingui Yang <yangxingui@huawei.com>
Link: https://lore.kernel.org/r/20250220090011.313848-1-liyihang9@huawei.com
Reviewed-by: Yihang Li <liyihang9@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: fnic: Remove unnecessary NUL-terminations
Thorsten Blum [Fri, 14 Mar 2025 22:16:26 +0000 (23:16 +0100)] 
scsi: fnic: Remove unnecessary NUL-terminations

strscpy_pad() already NUL-terminates 'data' at the corresponding
indexes. Remove any unnecessary NUL-terminations.

No functional changes intended.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Link: https://lore.kernel.org/r/20250314221626.43174-2-thorsten.blum@linux.dev
Reviewed-by: Karan Tilak Kumar <kartilak@cisco.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: fnic: Remove redundant flush_workqueue() calls
Chen Ni [Wed, 12 Mar 2025 07:43:20 +0000 (15:43 +0800)] 
scsi: fnic: Remove redundant flush_workqueue() calls

destroy_workqueue() already drains the queue before destroying it, so
there is no need to flush it explicitly.

Remove the redundant flush_workqueue() calls.

This was generated with coccinelle:

@@
expression E;
@@
- flush_workqueue(E);
  destroy_workqueue(E);

Signed-off-by: Chen Ni <nichen@iscas.ac.cn>
Link: https://lore.kernel.org/r/20250312074320.1430175-1-nichen@iscas.ac.cn
Reviewed-by: Karan Tilak Kumar <kartilak@cisco.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 months agoscsi: core: Use a switch statement when attaching VPD pages
Chaohai Chen [Wed, 26 Feb 2025 06:58:02 +0000 (14:58 +0800)] 
scsi: core: Use a switch statement when attaching VPD pages

The original code used if statements to update discovered VPD pages when
found. This had the side-effect of not breaking the loop when a page was
found.

Use an idiomatic switch statement instead.

Signed-off-by: Chaohai Chen <wdhh6@aliyun.com>
Link: https://lore.kernel.org/r/20250226065802.234144-1-wdhh6@aliyun.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 months agoMerge patch series "scsi: ufs: renesas: Add support for R-Car S4-8 ES1.2"
Martin K. Petersen [Tue, 11 Mar 2025 01:36:30 +0000 (21:36 -0400)] 
Merge patch series "scsi: ufs: renesas: Add support for R-Car S4-8 ES1.2"

Geert Uytterhoeven <geert+renesas@glider.be> says:

Hi all,

Initialization of the UFS controller on R-Car S4-8 ES1.0 requires only
static values.  However, other UFS controller variants (R-Car S4-8 ES 1.2)
require dynamic values, like those obtained from E-FUSE, and downloading
firmware.

Hence this patch series refactors the initialization code to prepare for
this, and adds support for the UFS controller on R-Car S4-8 ES1.2.
The accompanying DTS change is available at [1].

This has been tested on:
  - Renesas Spider with R-Car S4-8 ES1.0 (broken before/after),
  - Renesas S4 Starter Kit with R-Car S4-8 ES1.2 (works after).

Thanks for your comments!

[1] "[PATCH] arm64: dts: renesas: r8a779f4: Add UFS tuning parameters in
     E-FUSE"
    https://lore.kernel.org/3e4fca228eb049d54a1ae520104558505dbdf803.1741179629.git.geert+renesas@glider.be
[2] "[PATCH v2 0/5] scsi: ufs: renesas: Refactor code for other UFS
     controller"
    https://lore.kernel.org/20240709023550.1750333-1-yoshihiro.shimoda.uh@renesas.com
[3] "[PATCH 0/5] scsi: ufs: renesas: Refactor code for other UFS
     controller"
    https://lore.kernel.org/20240708120931.1703956-1-yoshihiro.shimoda.uh@renesas.com

Link: https://lore.kernel.org/r/cover.1741179611.git.geert+renesas@glider.be
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 months agoscsi: ufs: renesas: Add initialization code for R-Car S4-8 ES1.2
Yoshihiro Shimoda [Wed, 5 Mar 2025 13:34:15 +0000 (14:34 +0100)] 
scsi: ufs: renesas: Add initialization code for R-Car S4-8 ES1.2

Add initialization code for R-Car S4-8 ES1.2 to improve transfer stability.
Using the new code requires downloading firmware and reading calibration
data from E-FUSE.  If either fails, the driver falls back to the old
initialization code.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Co-developed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/97d83709495c764b2456d4d25846f5f48197cad0.1741179611.git.geert+renesas@glider.be
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 months agoscsi: ufs: renesas: Add reusable functions
Yoshihiro Shimoda [Wed, 5 Mar 2025 13:34:14 +0000 (14:34 +0100)] 
scsi: ufs: renesas: Add reusable functions

Since some settings can be reused on other UFS controller (R-Car S4-8
ES1.2), add reusable functions.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/446d67b751a96645799de3aeefec539735aa78c8.1741179611.git.geert+renesas@glider.be
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 months agoscsi: ufs: renesas: Refactor 0x10ad/0x10af PHY settings
Yoshihiro Shimoda [Wed, 5 Mar 2025 13:34:13 +0000 (14:34 +0100)] 
scsi: ufs: renesas: Refactor 0x10ad/0x10af PHY settings

Extract specific PHY setting of the 0x10a[df] registers into a new
function.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/110eafd1ee24f9db0285a5e2bca224e35962268a.1741179611.git.geert+renesas@glider.be
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 months agoscsi: ufs: renesas: Remove register control helper function
Yoshihiro Shimoda [Wed, 5 Mar 2025 13:34:12 +0000 (14:34 +0100)] 
scsi: ufs: renesas: Remove register control helper function

After refactoring the code, ufs_renesas_reg_control() is no longer needed,
because all operations are simple and can be called directly.  Remove the
ufs_renesas_reg_control() helper function, and call udelay() directly.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/69500e4c18be1ca1de360f9e797e282ffef04004.1741179611.git.geert+renesas@glider.be
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 months agoscsi: ufs: renesas: Add register read to remove save/set/restore
Yoshihiro Shimoda [Wed, 5 Mar 2025 13:34:11 +0000 (14:34 +0100)] 
scsi: ufs: renesas: Add register read to remove save/set/restore

Add support for returning read register values from
ufs_renesas_reg_control(), so ufs_renesas_set_phy() can use the existing
ufs_renesas_write_phy() helper.  Remove the now unused code to save to,
set, and restore from a static array inside ufs_renesas_reg_control().

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/9fa240a9dc0308d6675138f8434eccb77f051650.1741179611.git.geert+renesas@glider.be
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 months agoscsi: ufs: renesas: Replace init data by init code
Yoshihiro Shimoda [Wed, 5 Mar 2025 13:34:10 +0000 (14:34 +0100)] 
scsi: ufs: renesas: Replace init data by init code

Since initialization of the UFS controller on R-Car S4-8 ES1.0 requires
only static values, the driver uses initialization data stored in the const
ufs_param[] array.  However, other UFS controller variants (R-Car S4-8
ES1.2) require dynamic values, like those obtained from E-FUSE.  Refactor
the initialization code to prepare for this.

This also reduces kernel size by almost 30 KiB.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/3520e27ac7ff512de6508f630eee3c1689a7c73d.1741179611.git.geert+renesas@glider.be
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 months agoscsi: ufs: dt-bindings: renesas,ufs: Add calibration data
Geert Uytterhoeven [Wed, 5 Mar 2025 13:34:09 +0000 (14:34 +0100)] 
scsi: ufs: dt-bindings: renesas,ufs: Add calibration data

On R-Car S4-8 ES1.2, the E-FUSE block contains PLL and AFE tuning
parameters for the Universal Flash Storage controller.  Document the
related NVMEM properties, and update the example.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/2f337169f8183d48b7d94ee13565fea804aade84.1741179611.git.geert+renesas@glider.be
Acked-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 months agoscsi: mpi3mr: Task Abort EH Support
Chandrakanth Patil [Tue, 4 Mar 2025 19:14:53 +0000 (00:44 +0530)] 
scsi: mpi3mr: Task Abort EH Support

Add Task Abort support to handle SCSI command timeouts, ensuring recovery
and cleanup of timed-out commands. This completes the error handling
framework for mpi3mr driver, which already includes device reset, target
reset, bus reset, and host reset.

Co-developed-by: Sathya Prakash <sathya.prakash@broadcom.com>
Signed-off-by: Sathya Prakash <sathya.prakash@broadcom.com>
Signed-off-by: Chandrakanth Patil <chandrakanth.patil@broadcom.com>
Link: https://lore.kernel.org/r/20250304191453.12994-1-chandrakanth.patil@broadcom.com
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 months agoscsi: storvsc: Don't report the host packet status as the hv status
Roman Kisel [Tue, 4 Mar 2025 00:09:40 +0000 (16:09 -0800)] 
scsi: storvsc: Don't report the host packet status as the hv status

The log statement reports the packet status code as the hv status code
which causes confusion when debugging as "hv" might refer to a hypervisor,
and sometimes to the host part of the Hyper-V virtualization stack.

Fix the name of the datum being logged to clearly indicate the component
reporting the error. Also log it in hexadecimal everywhere for consistency.

Signed-off-by: Roman Kisel <romank@linux.microsoft.com>
Link: https://lore.kernel.org/r/20250304000940.9557-2-romank@linux.microsoft.com
Reviewed-by: Easwar Hariharan <eahariha@linux.microsoft.com>
Reviewed-by: Michael Kelley <mhklinux@outlook.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 months agoscsi: isci: Make most module parameters static
Dr. David Alan Gilbert [Sun, 9 Mar 2025 14:50:44 +0000 (14:50 +0000)] 
scsi: isci: Make most module parameters static

Most of the module parameters are only used locally in the same C file; so
static them.

Signed-off-by: Dr. David Alan Gilbert <linux@treblig.org>
Link: https://lore.kernel.org/r/20250309145044.38586-1-linux@treblig.org
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 months agoscsi: megaraid_sas: Make most module parameters static
Dr. David Alan Gilbert [Sun, 9 Mar 2025 14:33:48 +0000 (14:33 +0000)] 
scsi: megaraid_sas: Make most module parameters static

Most of the module parameters are only used locally in the same C file; so
static them.

Signed-off-by: Dr. David Alan Gilbert <linux@treblig.org>
Link: https://lore.kernel.org/r/20250309143348.32896-1-linux@treblig.org
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 months agoscsi: fnic: Remove unnecessary spinlock locking and unlocking
Karan Tilak Kumar [Sat, 1 Mar 2025 01:37:12 +0000 (17:37 -0800)] 
scsi: fnic: Remove unnecessary spinlock locking and unlocking

Remove unnecessary locking and unlocking of spinlock in
fdls_schedule_oxid_free_retry_work().  This will shorten the time in the
critical section.

Suggested-by: Dan Carpenter <dan.carpenter@linaro.org>
Fixes: a63e78eb2b0f ("scsi: fnic: Add support for fabric based solicited requests and responses")
Reviewed-by: Sesidhar Baddela <sebaddel@cisco.com>
Reviewed-by: Arulprabhu Ponnusamy <arulponn@cisco.com>
Reviewed-by: Gian Carlo Boffa <gcboffa@cisco.com>
Reviewed-by: Arun Easi <aeasi@cisco.com>
Tested-by: Karan Tilak Kumar <kartilak@cisco.com>
Signed-off-by: Karan Tilak Kumar <kartilak@cisco.com>
Link: https://lore.kernel.org/r/20250301013712.3115-2-kartilak@cisco.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 months agoscsi: fnic: Replace fnic->lock_flags with local flags
Karan Tilak Kumar [Sat, 1 Mar 2025 01:37:11 +0000 (17:37 -0800)] 
scsi: fnic: Replace fnic->lock_flags with local flags

Replace fnic->lock_flags with local variable for usage with spinlocks in
fdls_schedule_oxid_free_retry_work().

Suggested-by: Dan Carpenter <dan.carpenter@linaro.org>
Fixes: a63e78eb2b0f ("scsi: fnic: Add support for fabric based solicited requests and responses")
Reviewed-by: Sesidhar Baddela <sebaddel@cisco.com>
Reviewed-by: Arulprabhu Ponnusamy <arulponn@cisco.com>
Reviewed-by: Gian Carlo Boffa <gcboffa@cisco.com>
Reviewed-by: Arun Easi <aeasi@cisco.com>
Signed-off-by: Karan Tilak Kumar <kartilak@cisco.com>
Link: https://lore.kernel.org/r/20250301013712.3115-1-kartilak@cisco.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 months agoscsi: fnic: Replace use of sizeof with standard usage
Karan Tilak Kumar [Tue, 25 Feb 2025 21:50:56 +0000 (13:50 -0800)] 
scsi: fnic: Replace use of sizeof with standard usage

Remove cast and replace use of sizeof(struct) with standard usage of
sizeof.

Suggested-by: Dan Carpenter <dan.carpenter@linaro.org>
Fixes: a63e78eb2b0f ("scsi: fnic: Add support for fabric based solicited requests and responses")
Reviewed-by: Sesidhar Baddela <sebaddel@cisco.com>
Reviewed-by: Arulprabhu Ponnusamy <arulponn@cisco.com>
Reviewed-by: Gian Carlo Boffa <gcboffa@cisco.com>
Reviewed-by: Arun Easi <aeasi@cisco.com>
Signed-off-by: Karan Tilak Kumar <kartilak@cisco.com>
Link: https://lore.kernel.org/r/20250225215056.4899-1-kartilak@cisco.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 months agoscsi: fnic: Fix indentation and remove unnecessary parenthesis
Karan Tilak Kumar [Tue, 25 Feb 2025 21:50:13 +0000 (13:50 -0800)] 
scsi: fnic: Fix indentation and remove unnecessary parenthesis

Fix indentation in fdls_disc.c to fix kernel test robot warnings.
Remove unnecessary parentheses to fix checkpatch check.

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/r/202502141403.1PcpwyJp-lkp@intel.com/
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/r/202502141403.1PcpwyJp-lkp@intel.com/
Fixes: a63e78eb2b0f ("scsi: fnic: Add support for fabric based solicited requests and responses")
Reviewed-by: Sesidhar Baddela <sebaddel@cisco.com>
Reviewed-by: Arulprabhu Ponnusamy <arulponn@cisco.com>
Reviewed-by: Gian Carlo Boffa <gcboffa@cisco.com>
Reviewed-by: Arun Easi <aeasi@cisco.com>
Signed-off-by: Karan Tilak Kumar <kartilak@cisco.com>
Link: https://lore.kernel.org/r/20250225215013.4875-1-kartilak@cisco.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 months agoscsi: fnic: Remove unnecessary debug print
Karan Tilak Kumar [Tue, 25 Feb 2025 21:49:09 +0000 (13:49 -0800)] 
scsi: fnic: Remove unnecessary debug print

Remove unnecessary debug print from fdls_schedule_oxid_free_retry_work.  As
suggested by Dan, this information is already present in stack traces, and
the kernel is not expected to fail small allocations.

Suggested-by: Dan Carpenter <dan.carpenter@linaro.org>
Fixes: a63e78eb2b0f ("scsi: fnic: Add support for fabric based solicited requests and responses")
Reviewed-by: Sesidhar Baddela <sebaddel@cisco.com>
Reviewed-by: Arulprabhu Ponnusamy <arulponn@cisco.com>
Reviewed-by: Gian Carlo Boffa <gcboffa@cisco.com>
Reviewed-by: Arun Easi <aeasi@cisco.com>
Signed-off-by: Karan Tilak Kumar <kartilak@cisco.com>
Link: https://lore.kernel.org/r/20250225214909.4853-1-kartilak@cisco.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 months agoscsi: target: Replace deprecated strncpy() with strscpy()
Thorsten Blum [Sun, 2 Mar 2025 22:56:41 +0000 (23:56 +0100)] 
scsi: target: Replace deprecated strncpy() with strscpy()

strncpy() is deprecated for NUL-terminated destination buffers; use
strscpy() instead. The destination buffer db_root is only used with "%s"
format strings and must therefore be NUL-terminated, but not NUL-padded.

Use scnprintf() because snprintf() could return a value >= DB_ROOT_LEN
and lead to an out-of-bounds access. This doesn't happen because count
is explicitly checked against DB_ROOT_LEN before. However, scnprintf()
always returns the number of characters actually written to the string
buffer, which is always within the bounds of db_root_stage, and should
be preferred over snprintf().

The size parameter of strscpy() is optional and since DB_ROOT_LEN is the
size of the destination buffer, it can be removed. Remove it to simplify
the code.

Compile-tested only.

Link: https://github.com/KSPP/linux/issues/90
Link: https://github.com/KSPP/linux/issues/105
Cc: linux-hardening@vger.kernel.org
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Link: https://lore.kernel.org/r/20250302225641.245127-2-thorsten.blum@linux.dev
Reviewed-by: Kees Cook <kees@kernel.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 months agoscsi: logging: Fix scsi_logging_level bounds
Nicolas Bouchinet [Mon, 24 Feb 2025 09:58:19 +0000 (10:58 +0100)] 
scsi: logging: Fix scsi_logging_level bounds

Bound scsi_logging_level sysctl writings between SYSCTL_ZERO and
SYSCTL_INT_MAX.

The proc_handler has thus been updated to proc_dointvec_minmax.

Signed-off-by: Nicolas Bouchinet <nicolas.bouchinet@ssi.gouv.fr>
Link: https://lore.kernel.org/r/20250224095826.16458-5-nicolas.bouchinet@clip-os.org
Reviewed-by: Joel Granados <joel.granados@kernel.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 months agoscsi: scsi_error: Add comments to scsi_check_sense()
Damien Le Moal [Fri, 28 Feb 2025 03:17:51 +0000 (12:17 +0900)] 
scsi: scsi_error: Add comments to scsi_check_sense()

Add a comment block describing the COMPLETED case with ASC/ASCQ 0x55/0xA
to mention that it relates to command duration limits very special
policy 0xD command completion.

Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
Link: https://lore.kernel.org/r/20250228031751.12083-1-dlemoal@kernel.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 months agoscsi: mpt3sas: Fix buffer overflow in mpt3sas_send_mctp_passthru_req()
Dan Carpenter [Fri, 28 Feb 2025 09:37:28 +0000 (12:37 +0300)] 
scsi: mpt3sas: Fix buffer overflow in mpt3sas_send_mctp_passthru_req()

The "sz" argument in mpt3sas_check_cmd_timeout() is the number of u32, not
the number of bytes.  We dump that many u32 values to dmesg.  Passing the
number of bytes will lead to a read overflow.  Divide by 4 to get the
correct value.

Fixes: c72be4b5bb7c ("scsi: mpt3sas: Add support for MCTP Passthrough commands")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Link: https://lore.kernel.org/r/02b0d4ff-961c-49ae-921a-5cc469edf93c@stanley.mountain
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 months agoscsi: lpfc: Fix spelling mistake 'Toplogy' -> 'Topology'
Colin Ian King [Thu, 27 Feb 2025 22:50:46 +0000 (22:50 +0000)] 
scsi: lpfc: Fix spelling mistake 'Toplogy' -> 'Topology'

There is a spelling mistake in a lpfc_printf_log message. Fix it.

Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
Link: https://lore.kernel.org/r/20250227225046.660865-1-colin.i.king@gmail.com
Reviewed-by: Justin Tee <justin.tee@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 months agoscsi: lpfc: Convert timeouts to secs_to_jiffies()
Easwar Hariharan [Tue, 25 Feb 2025 20:17:16 +0000 (20:17 +0000)] 
scsi: lpfc: Convert timeouts to secs_to_jiffies()

Commit b35108a51cf7 ("jiffies: Define secs_to_jiffies()") introduced
secs_to_jiffies().  As the value here is a multiple of 1000, use
secs_to_jiffies() instead of msecs_to_jiffies() to avoid the multiplication

This is converted using scripts/coccinelle/misc/secs_to_jiffies.cocci with
the following Coccinelle rules:

@depends on patch@
expression E;
@@

-msecs_to_jiffies(E * 1000)
+secs_to_jiffies(E)

-msecs_to_jiffies(E * MSEC_PER_SEC)
+secs_to_jiffies(E)

While here, convert some timeouts that are denominated in seconds
manually.

[mkp: Fix compilation error]

Signed-off-by: Easwar Hariharan <eahariha@linux.microsoft.com>
Link: https://lore.kernel.org/r/20250225-converge-secs-to-jiffies-part-two-v3-2-a43967e36c88@linux.microsoft.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 months agoscsi: hisi_sas: Remove incorrect ACPI_PTR annotations
Arnd Bergmann [Tue, 25 Feb 2025 16:36:27 +0000 (17:36 +0100)] 
scsi: hisi_sas: Remove incorrect ACPI_PTR annotations

Building with W=1 shows a warning about sas_v2_acpi_match being unused when
CONFIG_OF is disabled:

    drivers/scsi/hisi_sas/hisi_sas_v2_hw.c:3635:36: error: unused variable 'sas_v2_acpi_match' [-Werror,-Wunused-const-variable]

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20250225163637.4169300-1-arnd@kernel.org
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 months agoscsi: ufs: rockchip: Simplify bool conversion
Jiapeng Chong [Wed, 26 Feb 2025 02:11:57 +0000 (10:11 +0800)] 
scsi: ufs: rockchip: Simplify bool conversion

./drivers/ufs/host/ufs-rockchip.c:268:70-75: WARNING: conversion to bool not needed here.

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=19055
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
Link: https://lore.kernel.org/r/20250226021157.77934-1-jiapeng.chong@linux.alibaba.com
Acked-by: Shawn Lin <shawn.lin@rock-chips.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 months agoscsi: ufs: rockchip: Fix devm_clk_bulk_get_all_enabled() return value
Shawn Lin [Wed, 26 Feb 2025 06:52:13 +0000 (14:52 +0800)] 
scsi: ufs: rockchip: Fix devm_clk_bulk_get_all_enabled() return value

A positive value is for the number of clocks obtained if assigned.

Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
Link: https://lore.kernel.org/r/1740552733-182527-1-git-send-email-shawn.lin@rock-chips.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 months agoscsi: ufs: rockchip: Fix spelling mistake 'susped' -> 'suspend'
Colin Ian King [Tue, 25 Feb 2025 10:11:42 +0000 (10:11 +0000)] 
scsi: ufs: rockchip: Fix spelling mistake 'susped' -> 'suspend'

There is a spelling mistake in a dev_err message. Fix it.

Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
Link: https://lore.kernel.org/r/20250225101142.161474-1-colin.i.king@gmail.com
Acked-by: Shawn Lin <shawn.lin@rock-chips.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 months agoscsi: scsi_debug: Fix uninitialized variable use
Arnd Bergmann [Tue, 25 Feb 2025 09:56:47 +0000 (10:56 +0100)] 
scsi: scsi_debug: Fix uninitialized variable use

It appears that a typo has made it into the newly added code

drivers/scsi/scsi_debug.c:3035:3: error: variable 'len' is uninitialized when used here [-Werror,-Wuninitialized]
 3035 |                 len += resp_compression_m_pg(ap, pcontrol, target, devip->tape_dce);
      |                 ^~~

Replace the '+=' with the intended '=' here.

Fixes: 568354b24c7d ("scsi: scsi_debug: Add compression mode page for tapes")
Acked-by: Kai Mäkisara <kai.makisara@kolumbus.fi>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20250225095651.2636811-1-arnd@kernel.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 months agoscsi: core: Fix missing lock protection
Chaohai Chen [Fri, 21 Feb 2025 03:07:55 +0000 (11:07 +0800)] 
scsi: core: Fix missing lock protection

async_scan_lock is designed to protect the scanning_hosts list, but there
is no protection here.

Signed-off-by: Chaohai Chen <wdhh66@163.com>
Link: https://lore.kernel.org/r/20250221030755.219277-1-wdhh66@163.com
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 months agoscsi: scsi_debug: Do not sleep in atomic sections
Bart Van Assche [Mon, 24 Feb 2025 11:55:17 +0000 (11:55 +0000)] 
scsi: scsi_debug: Do not sleep in atomic sections

Function stop_qc_helper() is called while the debug_scsi_cmd lock is held,
and from here we may call cancel_work_sync(), which may sleep.

Sleeping in atomic sections is not allowed.

Hence change the cancel_work_sync() call into a cancel_work() call.

However now it is not possible to know if the work callback is running when
we return. This is relevant for eh_abort_handler handling, as the semantics
of that callback are that success means that we do not keep a reference to
the scsi_cmnd - now this is not possible. So return FAIL when we are unsure
if the callback still running.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
jpg: return FAILED from scsi_debug_abort() when possible callback running
Signed-off-by: John Garry <john.g.garry@oracle.com>
Link: https://lore.kernel.org/r/20250224115517.495899-5-john.g.garry@oracle.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 months agoscsi: scsi_debug: Simplify command handling
Bart Van Assche [Mon, 24 Feb 2025 11:55:16 +0000 (11:55 +0000)] 
scsi: scsi_debug: Simplify command handling

Simplify command handling by moving struct sdebug_defer into the private
SCSI command data instead of allocating it separately. The only functional
change is that aborting a SCSI command now fails and is retried at a later
time if the completion handler can't be cancelled.

See also commit 1107c7b24ee3 ("scsi: scsi_debug: Dynamically allocate
sdebug_queued_cmd").

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: John Garry <john.g.garry@oracle.com>
Link: https://lore.kernel.org/r/20250224115517.495899-4-john.g.garry@oracle.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 months agoscsi: scsi_debug: Remove a reference to in_use_bm
Bart Van Assche [Mon, 24 Feb 2025 11:55:15 +0000 (11:55 +0000)] 
scsi: scsi_debug: Remove a reference to in_use_bm

Commit f1437cd1e535 ("scsi: scsi_debug: Drop sdebug_queue") removed the
'in_use_bm' struct member. Hence remove a reference to that struct member
from the procfs host info file.

Fixes: f1437cd1e535 ("scsi: scsi_debug: Drop sdebug_queue")
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: John Garry <john.g.garry@oracle.com>
Link: https://lore.kernel.org/r/20250224115517.495899-3-john.g.garry@oracle.com
Reviewed-by: John Garry <john.g.garry@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 months agoscsi: scsi_debug: Remove sdebug_device_access_info
John Garry [Mon, 24 Feb 2025 11:55:14 +0000 (11:55 +0000)] 
scsi: scsi_debug: Remove sdebug_device_access_info

This structure is not used, so delete it.

It was originally intended for supporting checking for atomic writes
overlapping with ongoing reads and writes, but that support never got
added.

SBC-4 r22 section 4.29.3.2 "Performing operations during an atomic write
operation" describes two methods of handling overlapping atomic writes.
Currently the only method supported is for the ongoing read or write to
complete.

Signed-off-by: John Garry <john.g.garry@oracle.com>
Link: https://lore.kernel.org/r/20250224115517.495899-2-john.g.garry@oracle.com
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 months agoscsi: qla2xxx: Fix typos in a comment
Yuichiro Tsuji [Mon, 24 Feb 2025 07:59:07 +0000 (16:59 +0900)] 
scsi: qla2xxx: Fix typos in a comment

Fix typos in a comment.

hapens -> happens
recommeds -> recommends

Signed-off-by: Yuichiro Tsuji <yuichtsu@amazon.com>
Link: https://lore.kernel.org/r/20250224075907.2505-1-yuichtsu@amazon.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 months agoscsi: mpt3sas: Fix spelling mistake "receveid" -> "received"
Colin Ian King [Fri, 21 Feb 2025 08:32:53 +0000 (08:32 +0000)] 
scsi: mpt3sas: Fix spelling mistake "receveid" -> "received"

There is a spelling mistake in a ioc_err message. Fix it.

Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
Link: https://lore.kernel.org/r/20250221083253.77496-1-colin.i.king@gmail.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 months agoMerge patch series "mpi3mr: Few Enhancements and minor fixes"
Martin K. Petersen [Tue, 25 Feb 2025 01:03:00 +0000 (20:03 -0500)] 
Merge patch series "mpi3mr: Few Enhancements and minor fixes"

Ranjan Kumar <ranjan.kumar@broadcom.com> says:

Few Enhancements and minor fixes of mpi3mr driver.

Link: https://lore.kernel.org/r/20250220142528.20837-1-ranjan.kumar@broadcom.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 months agoscsi: mpi3mr: Update driver version to 8.13.0.5.50
Ranjan Kumar [Thu, 20 Feb 2025 14:25:28 +0000 (19:55 +0530)] 
scsi: mpi3mr: Update driver version to 8.13.0.5.50

Update driver version to 8.13.0.5.50

Signed-off-by: Ranjan Kumar <ranjan.kumar@broadcom.com>
Link: https://lore.kernel.org/r/20250220142528.20837-5-ranjan.kumar@broadcom.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 months agoscsi: mpi3mr: Check admin reply queue from Watchdog
Ranjan Kumar [Thu, 20 Feb 2025 14:25:27 +0000 (19:55 +0530)] 
scsi: mpi3mr: Check admin reply queue from Watchdog

Admin reply processing can be called from multiple contexts. The driver
uses an atomic flag for synchronization among multiple threads/context for
draining the admin replies.

Upon entering the admin processing routine, the driver will set the atomic
flag and start reply processing. When exiting the routine, the driver
resets the flag. However, there is a race condition when one thread (Thread
1) has processed replies and is about to reset the flag but in the meantime
few more replies are posted and another thread (Thread 2) is called to
process replies. Since the synchronization flag is still set, Thread 2 will
return without processing replies and those new replies will not be
flushed.

Make the watchdog thread monitor cases where admin ISR/poll call returns
due to another thread processing admin replies. If such an instance is
found, make driver call admin ISR to drain replies (if any).

Co-developed-by: Sumit Saxena <sumit.saxena@broadcom.com>
Signed-off-by: Sumit Saxena <sumit.saxena@broadcom.com>
Signed-off-by: Ranjan Kumar <ranjan.kumar@broadcom.com>
Link: https://lore.kernel.org/r/20250220142528.20837-4-ranjan.kumar@broadcom.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 months agoscsi: mpi3mr: Update timestamp only for supervisor IOCs
Ranjan Kumar [Thu, 20 Feb 2025 14:25:26 +0000 (19:55 +0530)] 
scsi: mpi3mr: Update timestamp only for supervisor IOCs

The driver issues the time stamp update command periodically. Even if the
command fails with supervisor only IOC Status.

Instead check the Non-Supervisor capability bit reported by IOC as part of
IOC Facts.

Co-developed-by: Sumit Saxena <sumit.saxena@broadcom.com>
Signed-off-by: Sumit Saxena <sumit.saxena@broadcom.com>
Signed-off-by: Ranjan Kumar <ranjan.kumar@broadcom.com>
Link: https://lore.kernel.org/r/20250220142528.20837-3-ranjan.kumar@broadcom.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 months agoscsi: mpi3mr: Update MPI Headers to revision 35
Ranjan Kumar [Thu, 20 Feb 2025 14:25:25 +0000 (19:55 +0530)] 
scsi: mpi3mr: Update MPI Headers to revision 35

Update MPI Headers to revision 35

Co-developed-by: Prayas Patel <prayas.patel@broadcom.com>
Signed-off-by: Prayas Patel <prayas.patel@broadcom.com>
Signed-off-by: Ranjan Kumar <ranjan.kumar@broadcom.com>
Link: https://lore.kernel.org/r/20250220142528.20837-2-ranjan.kumar@broadcom.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 months agoMerge patch series "scsi: scsi_debug: Add more tape support"
Martin K. Petersen [Tue, 25 Feb 2025 00:24:54 +0000 (19:24 -0500)] 
Merge patch series "scsi: scsi_debug: Add more tape support"

Kai Mäkisara <Kai.Makisara@kolumbus.fi> says:

Currently, the scsi_debug driver can create tape devices and the st
driver attaches to those. Nothing much can be done with the tape devices
because scsi_debug does not have support for the tape-specific commands
and features. These patches add some more tape support to the scsi_debug
driver. The end result is simulated drives with a tape having one or two
partitions (one partition is created initially).

The tape is implemented as fixed number (10 000) of 8-byte units.
The first four bytes of a unit contain the type of the unit (data
block, filemark or end-of-data mark). If the units is a data block,
the first four bytes also contain the block length and the remaining
four bytes the first bytes of written data. This allows the user
to use tags to see that the read block is what it was supposed to be.

The following SCSI operations are added or modified:
FORMAT MEDIUM
- added
LOCATE
- added
MODE SELECT
- modified to allow use without page(s) (just header and block descriptor)
  - store density and block size
- partition page added
MODE SENSE
- modified to allow use without page(s) (just header and block descriptor)
  - set density and block size
- partition page added
READ BLOCK LIMITS
- added
READ POSITION
- added
READ
- added tape support for READ (6)
REWIND
- modified to set the tape position
SPACE
- added
START STOP (LOAD)
- modified to return New Medium Unit Attention if tape loaded (not
  according to the standard, but enables testing this UA)
WRITE
- added tape support for WRITE (6)
WRITE FILEMARKS
- added

Link: https://lore.kernel.org/r/20250213092636.2510-1-Kai.Makisara@kolumbus.fi
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 months agoMerge patch series "Initial support for RK3576 UFS controller"
Martin K. Petersen [Tue, 25 Feb 2025 00:24:14 +0000 (19:24 -0500)] 
Merge patch series "Initial support for RK3576 UFS controller"

Shawn Lin <shawn.lin@rock-chips.com> says:

This patchset adds initial UFS controller supprt for RK3576 SoC.
Patch 1 is the dt-bindings. Patch 2-4 deal with rpm and spm support
in advanced suggested by Ulf. Patch 5 exports two new APIs for host
driver. Patch 6 and 7 are the host driver and dtsi support.

Link: https://lore.kernel.org/r/1738736156-119203-1-git-send-email-shawn.lin@rock-chips.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 months agoscsi: arm64: dts: rockchip: Add UFS support for RK3576 SoC
Shawn Lin [Wed, 5 Feb 2025 06:15:56 +0000 (14:15 +0800)] 
scsi: arm64: dts: rockchip: Add UFS support for RK3576 SoC

Add ufshc node to rk3576.dtsi, so the board using UFS could enable it.

Acked-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
Link: https://lore.kernel.org/r/1738736156-119203-8-git-send-email-shawn.lin@rock-chips.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 months agoscsi: ufs: rockchip: Initial support for UFS
Shawn Lin [Wed, 5 Feb 2025 06:15:55 +0000 (14:15 +0800)] 
scsi: ufs: rockchip: Initial support for UFS

RK3576 SoC contains a UFS controller, add initial support for it.
The features are:

  1. support UFS 2.0 features
  2. High speed up to HS-G3
  3. 2RX-2TX lanes
  4. auto H8 entry and exit

Software limitation:

  1. HCE procedure: enable controller->enable intr->dme_reset->dme_enable
  2. disable unipro timeout values before power mode change

[mkp: fix build errors]

Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
Link: https://lore.kernel.org/r/1738736156-119203-7-git-send-email-shawn.lin@rock-chips.com
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 months agoscsi: ufs: core: Export ufshcd_dme_reset() and ufshcd_dme_enable()
Shawn Lin [Wed, 5 Feb 2025 06:15:54 +0000 (14:15 +0800)] 
scsi: ufs: core: Export ufshcd_dme_reset() and ufshcd_dme_enable()

These two APIs will be used by glue driver if they need a different HCE
process.

Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
Link: https://lore.kernel.org/r/1738736156-119203-6-git-send-email-shawn.lin@rock-chips.com
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 months agoscsi: ufs: dt-bindings: Document Rockchip UFS host controller
Shawn Lin [Wed, 5 Feb 2025 06:15:50 +0000 (14:15 +0800)] 
scsi: ufs: dt-bindings: Document Rockchip UFS host controller

Document Rockchip UFS host controller for RK3576 SoC.

Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
Link: https://lore.kernel.org/r/1738736156-119203-2-git-send-email-shawn.lin@rock-chips.com
Acked-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 months agopmdomain: rockchip: Fix build error
Ulf Hansson [Mon, 24 Feb 2025 12:05:29 +0000 (13:05 +0100)] 
pmdomain: rockchip: Fix build error

To resolve the build error with undefined reference to
`arm_smccc_1_1_get_conduit', let's add a build dependency to
HAVE_ARM_SMCCC_DISCOVERY.

Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Fixes: 61eeb9678789 ("pmdomain: rockchip: Check if SMC could be handled by TA")
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
3 months agoscsi: scsi_debug: Add support for partitioning the tape
Kai Mäkisara [Thu, 13 Feb 2025 09:26:36 +0000 (11:26 +0200)] 
scsi: scsi_debug: Add support for partitioning the tape

This patch adds support for MEDIUM PARTITION PAGE in MODE SELECT and the
FORMAT MEDIUM command for tapes. After these additions, the virtual tape
can be partitioned containing either one or two partitions. The POFM flag
in the mode page is set, meaning that the FORMAT MEDIUM command must be
used to create the partitioning defined in the mode page.

Signed-off-by: Kai Mäkisara <Kai.Makisara@kolumbus.fi>
Link: https://lore.kernel.org/r/20250213092636.2510-8-Kai.Makisara@kolumbus.fi
Reviewed-by: John Meneghini <jmeneghi@redhat.com>
Tested-by: John Meneghini <jmeneghi@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 months agoscsi: scsi_debug: Reset tape setting at device reset
Kai Mäkisara [Thu, 13 Feb 2025 09:26:35 +0000 (11:26 +0200)] 
scsi: scsi_debug: Reset tape setting at device reset

Set tape block size, density and compression to default values when the
device is reset (either directly or via target, bus or host reset).

Signed-off-by: Kai Mäkisara <Kai.Makisara@kolumbus.fi>
Link: https://lore.kernel.org/r/20250213092636.2510-7-Kai.Makisara@kolumbus.fi
Reviewed-by: John Meneghini <jmeneghi@redhat.com>
Tested-by: John Meneghini <jmeneghi@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 months agoscsi: scsi_debug: Add compression mode page for tapes
Kai Mäkisara [Thu, 13 Feb 2025 09:26:34 +0000 (11:26 +0200)] 
scsi: scsi_debug: Add compression mode page for tapes

Add support for compression mode page. The compression status
is saved and returned. No UA is generated.

Signed-off-by: Kai Mäkisara <Kai.Makisara@kolumbus.fi>
Link: https://lore.kernel.org/r/20250213092636.2510-6-Kai.Makisara@kolumbus.fi
Reviewed-by: John Meneghini <jmeneghi@redhat.com>
Tested-by: John Meneghini <jmeneghi@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 months agoscsi: scsi_debug: Add read support and update locate for tapes
Kai Mäkisara [Thu, 13 Feb 2025 09:26:33 +0000 (11:26 +0200)] 
scsi: scsi_debug: Add read support and update locate for tapes

Support for the READ (6) and SPACE (6) commands for tapes based on the
previous write patch is added. The LOCATE (10) command is updated to use
the written data.

Signed-off-by: Kai Mäkisara <Kai.Makisara@kolumbus.fi>
Link: https://lore.kernel.org/r/20250213092636.2510-5-Kai.Makisara@kolumbus.fi
Reviewed-by: John Meneghini <jmeneghi@redhat.com>
Tested-by: John Meneghini <jmeneghi@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 months agoscsi: scsi_debug: Add write support with block lengths and 4 bytes of data
Kai Mäkisara [Thu, 13 Feb 2025 09:26:32 +0000 (11:26 +0200)] 
scsi: scsi_debug: Add write support with block lengths and 4 bytes of data

The tape is implemented as fixed number (10 000) of 8-byte units.  The
first four bytes of a unit contains the type of the unit (data block,
filemark or end-of-data mark). If the units is a data block, the first four
bytes contain the block length and the remaining four bytes the first bytes
of written data. This allows the user to use tags to see that the read
block is what it was supposed to be.

The tape can contain two partitions. Initially it is formatted as one
partition consisting of all 10 000 units.

This patch adds the WRITE(6) command for tapes and the WRITE FILEMARKS (6)
command. The REWIND command is updated.

Signed-off-by: Kai Mäkisara <Kai.Makisara@kolumbus.fi>
Link: https://lore.kernel.org/r/20250213092636.2510-4-Kai.Makisara@kolumbus.fi
Reviewed-by: John Meneghini <jmeneghi@redhat.com>
Tested-by: John Meneghini <jmeneghi@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 months agoscsi: scsi_debug: Add READ BLOCK LIMITS and modify LOAD for tapes
Kai Mäkisara [Thu, 13 Feb 2025 09:26:31 +0000 (11:26 +0200)] 
scsi: scsi_debug: Add READ BLOCK LIMITS and modify LOAD for tapes

The changes:

 - Add READ BLOCK LIMITS (512 - 1048576 bytes)

 - Make LOAD send New Media UA (not correct by the standard, but makes
   possible to test also this UA)

Signed-off-by: Kai Mäkisara <Kai.Makisara@kolumbus.fi>
Link: https://lore.kernel.org/r/20250213092636.2510-3-Kai.Makisara@kolumbus.fi
Reviewed-by: John Meneghini <jmeneghi@redhat.com>
Tested-by: John Meneghini <jmeneghi@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 months agoscsi: scsi_debug: First fixes for tapes
Kai Mäkisara [Thu, 13 Feb 2025 09:26:30 +0000 (11:26 +0200)] 
scsi: scsi_debug: First fixes for tapes

Patch includes the following:

 - Enable MODE SENSE/SELECT without actual page (to read/write only the
   Block Descriptor)

 - Store the density code and block size in the Block Descriptor (only
   short version for tapes)

 - Fix REWIND not to use the wrong page filling function

Signed-off-by: Kai Mäkisara <Kai.Makisara@kolumbus.fi>
Link: https://lore.kernel.org/r/20250213092636.2510-2-Kai.Makisara@kolumbus.fi
Reviewed-by: John Meneghini <jmeneghi@redhat.com>
Tested-by: John Meneghini <jmeneghi@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 months agoMerge patch series "Support Multi-frequency scale for UFS"
Martin K. Petersen [Fri, 21 Feb 2025 03:11:11 +0000 (22:11 -0500)] 
Merge patch series "Support Multi-frequency scale for UFS"

Ziqi Chen <quic_ziqichen@quicinc.com> says:

With OPP V2 enabled, devfreq can scale clocks amongst multiple frequency
plans. However, the gear speed is only toggled between min and max during
clock scaling. Enable multi-level gear scaling by mapping clock frequencies
to gear speeds, so that when devfreq scales clock frequencies we can put
the UFS link at the appropraite gear speeds accordingly.

This series has been tested on below platforms -
sm8550 mtp + UFS3.1
SM8650 MTP + UFS3.1
SM8750 MTP + UFS4.0

Tested-by: Neil Armstrong <neil.armstrong@linaro.org> # on SM8550-QRD
Tested-by: Neil Armstrong <neil.armstrong@linaro.org> # on SM8550-HDK
Tested-by: Neil Armstrong <neil.armstrong@linaro.org> # on SM8650-HDK
Link: https://lore.kernel.org/r/20250213080008.2984807-1-quic_ziqichen@quicinc.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 months agoscsi: ABI: sysfs-driver-ufs: Add missing UFS sysfs attributes
Ziqi Chen [Thu, 13 Feb 2025 08:00:08 +0000 (16:00 +0800)] 
scsi: ABI: sysfs-driver-ufs: Add missing UFS sysfs attributes

Add UFS driver sysfs attributes clkscale_enable, clkgate_enable and
clkgate_delay_ms to this document.

Signed-off-by: Ziqi Chen <quic_ziqichen@quicinc.com>
Link: https://lore.kernel.org/r/20250213080008.2984807-9-quic_ziqichen@quicinc.com
Reviewed-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 months agoscsi: ufs: core: Toggle Write Booster during clock scaling base on gear speed
Can Guo [Thu, 13 Feb 2025 08:00:07 +0000 (16:00 +0800)] 
scsi: ufs: core: Toggle Write Booster during clock scaling base on gear speed

During clock scaling, Write Booster is toggled on or off based on whether
the clock is scaled up or down. However, with OPP V2 powered multi-level
gear scaling, the gear can be scaled amongst multiple gear speeds, e.g., it
may scale down from G5 to G4, or from G4 to G2. To provide flexibilities,
add a new field for clock scaling such that during clock scaling Write
Booster can be enabled or disabled based on gear speeds but not based on
scaling up or down.

Signed-off-by: Can Guo <quic_cang@quicinc.com>
Co-developed-by: Ziqi Chen <quic_ziqichen@quicinc.com>
Signed-off-by: Ziqi Chen <quic_ziqichen@quicinc.com>
Link: https://lore.kernel.org/r/20250213080008.2984807-8-quic_ziqichen@quicinc.com
Reviewed-by: Bean Huo <beanhuo@micron.com>
Tested-by: Neil Armstrong <neil.armstrong@linaro.org>
Reviewed-by: Peter Wang <peter.wang@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 months agoscsi: ufs: core: Check if scaling up is required when disable clkscale
Ziqi Chen [Thu, 13 Feb 2025 08:00:06 +0000 (16:00 +0800)] 
scsi: ufs: core: Check if scaling up is required when disable clkscale

When disabling clkscale via the clkscale_enable sysfs entry, UFS driver
shall perform scaling up once regardless. Check if scaling up is required
or not first to avoid repetitive work.

Signed-off-by: Ziqi Chen <quic_ziqichen@quicinc.com>
Co-developed-by: Can Guo <quic_cang@quicinc.com>
Signed-off-by: Can Guo <quic_cang@quicinc.com>
Link: https://lore.kernel.org/r/20250213080008.2984807-7-quic_ziqichen@quicinc.com
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Tested-by: Neil Armstrong <neil.armstrong@linaro.org>
Reviewed-by: Bean Huo <beanhuo@micron.com>
Reviewed-by: Peter Wang <peter.wang@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 months agoscsi: ufs: core: Enable multi-level gear scaling
Can Guo [Thu, 13 Feb 2025 08:00:05 +0000 (16:00 +0800)] 
scsi: ufs: core: Enable multi-level gear scaling

With OPP V2 enabled, devfreq can scale clocks amongst multiple frequency
plans. However, the gear speed is only toggled between min and max during
clock scaling. Enable multi-level gear scaling by mapping clock frequencies
to gear speeds, so that when devfreq scales clock frequencies we can put
the UFS link at the appropriate gear speeds accordingly.

Signed-off-by: Can Guo <quic_cang@quicinc.com>
Co-developed-by: Ziqi Chen <quic_ziqichen@quicinc.com>
Signed-off-by: Ziqi Chen <quic_ziqichen@quicinc.com>
Link: https://lore.kernel.org/r/20250213080008.2984807-6-quic_ziqichen@quicinc.com
Reviewed-by: Bean Huo <beanhuo@micron.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Tested-by: Neil Armstrong <neil.armstrong@linaro.org>
Reviewed-by: Peter Wang <peter.wang@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 months agoscsi: ufs: qcom: Implement the freq_to_gear_speed() vop
Can Guo [Thu, 13 Feb 2025 08:00:04 +0000 (16:00 +0800)] 
scsi: ufs: qcom: Implement the freq_to_gear_speed() vop

Implement the freq_to_gear_speed() vop to map the unipro core clock
frequency to the corresponding maximum supported gear speed.

Signed-off-by: Can Guo <quic_cang@quicinc.com>
Co-developed-by: Ziqi Chen <quic_ziqichen@quicinc.com>
Signed-off-by: Ziqi Chen <quic_ziqichen@quicinc.com>
Link: https://lore.kernel.org/r/20250213080008.2984807-5-quic_ziqichen@quicinc.com
Reviewed-by: Bean Huo <beanhuo@micron.com>
Tested-by: Neil Armstrong <neil.armstrong@linaro.org>
Reviewed-by: Peter Wang <peter.wang@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 months agoscsi: ufs: core: Add a vop to map clock frequency to gear speed
Can Guo [Thu, 13 Feb 2025 08:00:03 +0000 (16:00 +0800)] 
scsi: ufs: core: Add a vop to map clock frequency to gear speed

Add a vop to map UFS host controller clock frequencies to the corresponding
maximum supported UFS high speed gear speeds. During clock scaling, we can
map the target clock frequency, demanded by devfreq, to the maximum
supported gear speed, so that devfreq can scale the gear to the highest
gear speed supported at the target clock frequency, instead of just scaling
up/down the gear between the min and max gear speeds.

Co-developed-by: Ziqi Chen <quic_ziqichen@quicinc.com>
Signed-off-by: Ziqi Chen <quic_ziqichen@quicinc.com>
Signed-off-by: Can Guo <quic_cang@quicinc.com>
Link: https://lore.kernel.org/r/20250213080008.2984807-4-quic_ziqichen@quicinc.com
Reviewed-by: Bean Huo <beanhuo@micron.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Tested-by: Neil Armstrong <neil.armstrong@linaro.org>
Reviewed-by: Peter Wang <peter.wang@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 months agoscsi: ufs: qcom: Pass target_freq to clk scale pre and post change
Can Guo [Thu, 13 Feb 2025 08:00:02 +0000 (16:00 +0800)] 
scsi: ufs: qcom: Pass target_freq to clk scale pre and post change

Instead of only two frequencies, if OPP V2 is used, the UFS devfreq clock
scaling may scale the clock among multiple frequencies. In the case of
scaling up, the devfreq may decide to scale the clock to an intermediate
freq based on load, but the clock scale up pre change operation uses
settings for the max clock freq unconditionally. Fix it by passing the
target_freq to clock scale up pre change so that the correct settings for
the target_freq can be used.

In the case of scaling down, the clock scale down post change operation is
doing fine, because it reads the actual clock rate to tell freq, but to
keep symmetry with clock scale up pre change operation, just use the
target_freq instead of reading clock rate.

Signed-off-by: Can Guo <quic_cang@quicinc.com>
Co-developed-by: Ziqi Chen <quic_ziqichen@quicinc.com>
Signed-off-by: Ziqi Chen <quic_ziqichen@quicinc.com>
Link: https://lore.kernel.org/r/20250213080008.2984807-3-quic_ziqichen@quicinc.com
Reviewed-by: Bean Huo <beanhuo@micron.com>
Tested-by: Neil Armstrong <neil.armstrong@linaro.org>
Reviewed-by: Peter Wang <peter.wang@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 months agoscsi: ufs: core: Pass target_freq to clk_scale_notify() vop
Can Guo [Thu, 13 Feb 2025 08:00:01 +0000 (16:00 +0800)] 
scsi: ufs: core: Pass target_freq to clk_scale_notify() vop

Instead of only two frequencies, if OPP V2 is used, the UFS devfreq clock
scaling may scale the clock among multiple frequencies, so just passing
up/down to vop clk_scale_notify() is not enough to cover the intermediate
clock freqs between the min and max freqs. Hence pass the target_freq,
which will be used in successive commits, to clk_scale_notify() to allow
the vop to perform corresponding configurations with regard to the clock
freqs.

Signed-off-by: Can Guo <quic_cang@quicinc.com>
Co-developed-by: Ziqi Chen <quic_ziqichen@quicinc.com>
Signed-off-by: Ziqi Chen <quic_ziqichen@quicinc.com>
Link: https://lore.kernel.org/r/20250213080008.2984807-2-quic_ziqichen@quicinc.com
Reviewed-by: Bean Huo <beanhuo@micron.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Tested-by: Neil Armstrong <neil.armstrong@linaro.org>
Reviewed-by: Peter Wang <peter.wang@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 months agoMerge patch series "mpt3sas driver udpates"
Martin K. Petersen [Fri, 21 Feb 2025 02:47:48 +0000 (21:47 -0500)] 
Merge patch series "mpt3sas driver udpates"

Shivasharan S <shivasharan.srikanteshwara@broadcom.com> says:

This patch series adds support for the MCTP passthrough function over
the MPI interface for management commands.  Also fix issue related to
task management handling during IOCTL timeout.

Link: https://lore.kernel.org/r/1739410016-27503-1-git-send-email-shivasharan.srikanteshwara@broadcom.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 months agoscsi: mpt3sas: update driver version to 52.100.00.00
Shivasharan S [Thu, 13 Feb 2025 01:26:56 +0000 (17:26 -0800)] 
scsi: mpt3sas: update driver version to 52.100.00.00

Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Link: https://lore.kernel.org/r/1739410016-27503-6-git-send-email-shivasharan.srikanteshwara@broadcom.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 months agoscsi: mpt3sas: Send a diag reset if target reset fails
Shivasharan S [Thu, 13 Feb 2025 01:26:55 +0000 (17:26 -0800)] 
scsi: mpt3sas: Send a diag reset if target reset fails

When an IOCTL times out and driver issues a target reset, if firmware
fails the task management elevate the recovery by issuing a diag reset to
controller.

Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Link: https://lore.kernel.org/r/1739410016-27503-5-git-send-email-shivasharan.srikanteshwara@broadcom.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 months agoscsi: mpt3sas: Report driver capability as part of IOCINFO command
Shivasharan S [Thu, 13 Feb 2025 01:26:54 +0000 (17:26 -0800)] 
scsi: mpt3sas: Report driver capability as part of IOCINFO command

Add a new capability field to report the MCTP passthrough support to
applications.

Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Link: https://lore.kernel.org/r/1739410016-27503-4-git-send-email-shivasharan.srikanteshwara@broadcom.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 months agoscsi: mpt3sas: Add support for MCTP Passthrough commands
Shivasharan S [Thu, 13 Feb 2025 01:26:53 +0000 (17:26 -0800)] 
scsi: mpt3sas: Add support for MCTP Passthrough commands

The MPI specification defines support for sending MCTP management commands
as a passthrough function to the IOC. Add support for driver to discover
the IOC capability to support MCTP passthrough function. Driver will
support applications and kernel modules to send MPT commands containing the
MCTP passthrough request to firmware through an MPI request.

Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Signed-off-by: Sathya Prakash <sathya.prakash@broadcom.com>
Link: https://lore.kernel.org/r/1739410016-27503-3-git-send-email-shivasharan.srikanteshwara@broadcom.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 months agoscsi: mpt3sas: Update MPI headers to 02.00.62 version
Shivasharan S [Thu, 13 Feb 2025 01:26:52 +0000 (17:26 -0800)] 
scsi: mpt3sas: Update MPI headers to 02.00.62 version

Updated MPI header files to version 02.00.62.

Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Link: https://lore.kernel.org/r/1739410016-27503-2-git-send-email-shivasharan.srikanteshwara@broadcom.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 months agoscsi: ufs: qcom: Remove dead code in ufs_qcom_cfg_timers()
Bao D. Nguyen [Wed, 19 Feb 2025 17:16:06 +0000 (09:16 -0800)] 
scsi: ufs: qcom: Remove dead code in ufs_qcom_cfg_timers()

Since 'commit 104cd58d9af8 ("scsi: ufs: qcom: Remove support for host
controllers older than v2.0")', some of the parameters passed into the
ufs_qcom_cfg_timers() function have become dead code. Clean up
ufs_qcom_cfg_timers() function to improve the readability.

Signed-off-by: Bao D. Nguyen <quic_nguyenb@quicinc.com>
Link: https://lore.kernel.org/r/547c484ce80fe3624ee746954b84cae28bd38a09.1739985266.git.quic_nguyenb@quicinc.com
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 months agopmdomain: rockchip: Check if SMC could be handled by TA
Shawn Lin [Wed, 19 Feb 2025 00:58:09 +0000 (08:58 +0800)] 
pmdomain: rockchip: Check if SMC could be handled by TA

Non-existent trusted-firmware could lead to SMC calls into some unset
location, that breaks the system. Let's check that it's supported before
executing the SMC.

Reported-by: Steven Price <steven.price@arm.com>
Suggested-by: Heiko Stuebner <heiko@sntech.de>
Fixes: 58ebba35ddab ("pmdomain: rockchip: Add smc call to inform firmware")
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
Reviewed-by: Heiko Stuebner <heiko@sntech.de>
Tested-by: Steven Price <steven.price@arm.com>
Link: https://lore.kernel.org/r/1739926689-151827-1-git-send-email-shawn.lin@rock-chips.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
3 months agoscsi: mpt3sas: Fix a locking bug in an error path
Bart Van Assche [Mon, 10 Feb 2025 20:39:36 +0000 (12:39 -0800)] 
scsi: mpt3sas: Fix a locking bug in an error path

Call mutex_unlock(&ioc->hostdiag_unlock_mutex) once from error paths
instead of twice.

This patch fixes the following Clang -Wthread-safety errors:

drivers/scsi/mpt3sas/mpt3sas_base.c:8085:2: error: mutex 'ioc->hostdiag_unlock_mutex' is not held on every path through here [-Werror,-Wthread-safety-analysis]
 8085 |         pci_cfg_access_unlock(ioc->pdev);
      |         ^
drivers/scsi/mpt3sas/mpt3sas_base.c:8019:2: note: mutex acquired here
 8019 |         mutex_lock(&ioc->hostdiag_unlock_mutex);
      |         ^
./include/linux/mutex.h:171:26: note: expanded from macro 'mutex_lock'
  171 | #define mutex_lock(lock) mutex_lock_nested(lock, 0)
      |                          ^
drivers/scsi/mpt3sas/mpt3sas_base.c:8085:2: error: mutex 'ioc->hostdiag_unlock_mutex' is not held on every path through here [-Werror,-Wthread-safety-analysis]
 8085 |         pci_cfg_access_unlock(ioc->pdev);
      |         ^
drivers/scsi/mpt3sas/mpt3sas_base.c:8019:2: note: mutex acquired here
 8019 |         mutex_lock(&ioc->hostdiag_unlock_mutex);
      |         ^
./include/linux/mutex.h:171:26: note: expanded from macro 'mutex_lock'
  171 | #define mutex_lock(lock) mutex_lock_nested(lock, 0)
      |                          ^
drivers/scsi/mpt3sas/mpt3sas_base.c:8087:2: error: releasing mutex 'ioc->hostdiag_unlock_mutex' that was not held [-Werror,-Wthread-safety-analysis]
 8087 |         mutex_unlock(&ioc->hostdiag_unlock_mutex);
      |         ^

Cc: Ranjan Kumar <ranjan.kumar@broadcom.com>
Fixes: c0767560b012 ("scsi: mpt3sas: Reload SBR without rebooting HBA")
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Link: https://lore.kernel.org/r/20250210203936.2946494-3-bvanassche@acm.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>