]> git.ipfire.org Git - thirdparty/linux.git/log
thirdparty/linux.git
6 weeks agoscsi: ufs: core: Fix runtime suspend error deadlock
Peter Wang [Fri, 26 Sep 2025 01:29:26 +0000 (09:29 +0800)] 
scsi: ufs: core: Fix runtime suspend error deadlock

Resolve the deadlock issue during runtime suspend when an error triggers
the error handler. Prevent the deadlock by checking pm_op_in_progress
and performing a quick recovery.  This approach ensures that the error
handler does not wait indefinitely for runtime PM to resume, allowing
runtime suspend to proceed smoothly.

Signed-off-by: Peter Wang <peter.wang@mediatek.com>
Suggested-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Message-Id: <20250926012940.3933367-1-peter.wang@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 weeks agoRevert "scsi: qla2xxx: Fix memcpy() field-spanning write issue"
John Meneghini [Thu, 25 Sep 2025 13:07:29 +0000 (09:07 -0400)] 
Revert "scsi: qla2xxx: Fix memcpy() field-spanning write issue"

This reverts commit 6f4b10226b6b1e7d1ff3cdb006cf0f6da6eed71e.

We've been testing this patch and it turns out there is a significant
bug here. This leaks memory and causes a driver hang.

Link: https://lore.kernel.org/linux-scsi/yq1zfajqpec.fsf@ca-mkp.ca.oracle.com/
Signed-off-by: John Meneghini <jmeneghi@redhat.com>
Acked-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 weeks agoscsi: target: target_core_configfs: Add length check to avoid buffer overflow
Wang Haoran [Sat, 20 Sep 2025 07:44:41 +0000 (15:44 +0800)] 
scsi: target: target_core_configfs: Add length check to avoid buffer overflow

A buffer overflow arises from the usage of snprintf to write into the
buffer "buf" in target_lu_gp_members_show function located in
/drivers/target/target_core_configfs.c. This buffer is allocated with
size LU_GROUP_NAME_BUF (256 bytes).

snprintf(...) formats multiple strings into buf with the HBA name
(hba->hba_group.cg_item), a slash character, a devicename (dev->
dev_group.cg_item) and a newline character, the total formatted string
length may exceed the buffer size of 256 bytes.

Since snprintf() returns the total number of bytes that would have been
written (the length of %s/%sn ), this value may exceed the buffer length
(256 bytes) passed to memcpy(), this will ultimately cause function
memcpy reporting a buffer overflow error.

An additional check of the return value of snprintf() can avoid this
buffer overflow.

Reported-by: Wang Haoran <haoranwangsec@gmail.com>
Reported-by: ziiiro <yuanmingbuaa@gmail.com>
Signed-off-by: Wang Haoran <haoranwangsec@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 weeks agoscsi: MAINTAINERS: Update FC element owners
James Smart [Tue, 23 Sep 2025 15:38:57 +0000 (08:38 -0700)] 
scsi: MAINTAINERS: Update FC element owners

I'm relinquishing my maintainer position on the different FC elements.
I am updating them to the Emulex folk that have been watching over them
for a while.

Signed-off-by: James Smart <jsmart2021@gmail.com>
Message-Id: <20250923153857.100616-1-jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 weeks agoMerge patch series "mpt3sas: Few Enhancements and minor fixes"
Martin K. Petersen [Thu, 25 Sep 2025 02:35:14 +0000 (22:35 -0400)] 
Merge patch series "mpt3sas: Few Enhancements and minor fixes"

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

Few Enhancements and minor fixes of mpt3sas driver.

Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 weeks agoscsi: mpt3sas: Update driver version to 54.100.00.00
Ranjan Kumar [Mon, 22 Sep 2025 09:51:13 +0000 (15:21 +0530)] 
scsi: mpt3sas: Update driver version to 54.100.00.00

Updated driver version to 54.100.00.00.

Signed-off-by: Ranjan Kumar <ranjan.kumar@broadcom.com>
Message-Id: <20250922095113.281484-5-ranjan.kumar@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 weeks agoscsi: mpt3sas: Add support for 22.5 Gbps SAS link rate
Ranjan Kumar [Mon, 22 Sep 2025 09:51:12 +0000 (15:21 +0530)] 
scsi: mpt3sas: Add support for 22.5 Gbps SAS link rate

Add handling for MPI26_SAS_NEG_LINK_RATE_22_5 in
_transport_convert_phy_link_rate(). This maps the new 22.5 Gbps
negotiated rate to SAS_LINK_RATE_22_5_GBPS, to get correct PHY link
speeds.

Signed-off-by: Ranjan Kumar <ranjan.kumar@broadcom.com>
Message-Id: <20250922095113.281484-4-ranjan.kumar@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 weeks agoscsi: mpt3sas: Suppress unnecessary IOCLogInfo on CONFIG_INVALID_PAGE
Ranjan Kumar [Mon, 22 Sep 2025 09:51:11 +0000 (15:21 +0530)] 
scsi: mpt3sas: Suppress unnecessary IOCLogInfo on CONFIG_INVALID_PAGE

Avoid unconditional IOCLogInfo prints for CONFIG_INVALID_PAGE.  Log only
if MPT_DEBUG_REPLY is enabled or when loginfo represents other
errors. This reduces uncessary logging without losing useful error
reporting.

Signed-off-by: Ranjan Kumar <ranjan.kumar@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 weeks agoscsi: mpt3sas: Fix crash in transport port remove by using ioc_info()
Ranjan Kumar [Mon, 22 Sep 2025 09:51:10 +0000 (15:21 +0530)] 
scsi: mpt3sas: Fix crash in transport port remove by using ioc_info()

During mpt3sas_transport_port_remove(), messages were logged with
dev_printk() against &mpt3sas_port->port->dev. At this point the SAS
transport device may already be partially unregistered or freed, leading
to a crash when accessing its struct device.

Using ioc_info(), which logs via the PCI device (ioc->pdev->dev),
guaranteed to remain valid until driver removal.

[83428.295776] Oops: general protection fault, probably for non-canonical address 0x6f702f323a33312d: 0000 [#1] SMP NOPTI
[83428.295785] CPU: 145 UID: 0 PID: 113296 Comm: rmmod Kdump: loaded Tainted: G           OE       6.16.0-rc1+ #1 PREEMPT(voluntary)
[83428.295792] Tainted: [O]=OOT_MODULE, [E]=UNSIGNED_MODULE
[83428.295795] Hardware name: Dell Inc. Precision 7875 Tower/, BIOS 89.1.67 02/23/2024
[83428.295799] RIP: 0010:__dev_printk+0x1f/0x70
[83428.295805] Code: 90 90 90 90 90 90 90 90 90 90 90 0f 1f 44 00 00 49 89 d1 48 85 f6 74 52 4c 8b 46 50 4d 85 c0 74 1f 48 8b 46 68 48 85 c0 74 22 <48> 8b 08 0f b6 7f 01 48 c7 c2 db e8 42 ad 83 ef 30 e9 7b f8 ff ff
[83428.295813] RSP: 0018:ff85aeafc3137bb0 EFLAGS: 00010206
[83428.295817] RAX: 6f702f323a33312d RBX: ff4290ee81292860 RCX: 5000cca25103be32
[83428.295820] RDX: ff85aeafc3137bb8 RSI: ff4290eeb1966c00 RDI: ffffffffc1560845
[83428.295823] RBP: ff85aeafc3137c18 R08: 74726f702f303a33 R09: ff85aeafc3137bb8
[83428.295826] R10: ff85aeafc3137b18 R11: ff4290f5bd60fe68 R12: ff4290ee81290000
[83428.295830] R13: ff4290ee6e345de0 R14: ff4290ee81290000 R15: ff4290ee6e345e30
[83428.295833] FS:  00007fd9472a6740(0000) GS:ff4290f5ce96b000(0000) knlGS:0000000000000000
[83428.295837] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[83428.295840] CR2: 00007f242b4db238 CR3: 00000002372b8006 CR4: 0000000000771ef0
[83428.295844] PKRU: 55555554
[83428.295846] Call Trace:
[83428.295848]  <TASK>
[83428.295850]  _dev_printk+0x5c/0x80
[83428.295857]  ? srso_alias_return_thunk+0x5/0xfbef5
[83428.295863]  mpt3sas_transport_port_remove+0x1c7/0x420 [mpt3sas]
[83428.295882]  _scsih_remove_device+0x21b/0x280 [mpt3sas]
[83428.295894]  ? _scsih_expander_node_remove+0x108/0x140 [mpt3sas]
[83428.295906]  ? srso_alias_return_thunk+0x5/0xfbef5
[83428.295910]  mpt3sas_device_remove_by_sas_address.part.0+0x8f/0x110 [mpt3sas]
[83428.295921]  _scsih_expander_node_remove+0x129/0x140 [mpt3sas]
[83428.295933]  _scsih_expander_node_remove+0x6a/0x140 [mpt3sas]
[83428.295944]  scsih_remove+0x3f0/0x4a0 [mpt3sas]
[83428.295957]  pci_device_remove+0x3b/0xb0
[83428.295962]  device_release_driver_internal+0x193/0x200
[83428.295968]  driver_detach+0x44/0x90
[83428.295971]  bus_remove_driver+0x69/0xf0
[83428.295975]  pci_unregister_driver+0x2a/0xb0
[83428.295979]  _mpt3sas_exit+0x1f/0x300 [mpt3sas]
[83428.295991]  __do_sys_delete_module.constprop.0+0x174/0x310
[83428.295997]  ? srso_alias_return_thunk+0x5/0xfbef5
[83428.296000]  ? __x64_sys_getdents64+0x9a/0x110
[83428.296005]  ? srso_alias_return_thunk+0x5/0xfbef5
[83428.296009]  ? syscall_trace_enter+0xf6/0x1b0
[83428.296014]  do_syscall_64+0x7b/0x2c0
[83428.296019]  ? srso_alias_return_thunk+0x5/0xfbef5
[83428.296023]  entry_SYSCALL_64_after_hwframe+0x76/0x7e

Fixes: f92363d12359 ("[SCSI] mpt3sas: add new driver supporting 12GB SAS")
Signed-off-by: Ranjan Kumar <ranjan.kumar@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 weeks agoMerge patch series "Add DT-based gear and rate limiting support"
Martin K. Petersen [Thu, 25 Sep 2025 02:28:45 +0000 (22:28 -0400)] 
Merge patch series "Add DT-based gear and rate limiting support"

Ram Kumar Dwivedi <quic_rdwivedi@quicinc.com> says:

This patch series adds support for limiting the maximum high-speed
gear and rate used by the UFS controller via device tree properties.

Some platforms may have signal integrity, clock configuration, or
layout issues that prevent reliable operation at higher gears or
rates.  This is especially critical in automotive and other platforms
where stability is prioritized over peak performance.

The series follows this logical progression:

 1. Document the new DT properties in the common UFS binding

 2. Clean up existing redundant code in the qcom driver

 3. Add platform-level parsing support for the new properties

 4. Integrate the platform support in the qcom driver

This approach makes the functionality available to other UFS host
drivers and provides a cleaner, more maintainable implementation.

Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 weeks agoscsi: ufs: ufs-qcom: Add support for limiting HS gear and rate
Ram Kumar Dwivedi [Wed, 17 Sep 2025 14:09:33 +0000 (19:39 +0530)] 
scsi: ufs: ufs-qcom: Add support for limiting HS gear and rate

Add support to limit Tx/Rx gear and rate during UFS initialization based
on DT property.

Also update the phy_gear to ensure PHY calibrations align with the
required gear and rate.

Signed-off-by: Ram Kumar Dwivedi <quic_rdwivedi@quicinc.com>
Reviewed-by: Alim Akhtar <alim.akhtar@samsung.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 weeks agoscsi: ufs: pltfrm: Add DT support to limit HS gear and gear rate
Ram Kumar Dwivedi [Wed, 17 Sep 2025 14:09:32 +0000 (19:39 +0530)] 
scsi: ufs: pltfrm: Add DT support to limit HS gear and gear rate

Introduce parsing of 'limit-hs-gear' and 'limit-gear-rate' device tree
properties to restrict high-speed gear and rate during initialization.

This is useful in cases where the customer board may have signal
integrity, clock configuration or layout issues that prevent reliable
operation at higher gears. Such limitations are especially critical in
those platforms, where stability is prioritized over peak performance.

Co-developed-by: Nitin Rawat <quic_nitirawa@quicinc.com>
Signed-off-by: Nitin Rawat <quic_nitirawa@quicinc.com>
Signed-off-by: Ram Kumar Dwivedi <quic_rdwivedi@quicinc.com>
Reviewed-by: Alim Akhtar <alim.akhtar@samsung.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 weeks agoscsi: ufs: ufs-qcom: Remove redundant re-assignment to hs_rate
Ram Kumar Dwivedi [Wed, 17 Sep 2025 14:09:31 +0000 (19:39 +0530)] 
scsi: ufs: ufs-qcom: Remove redundant re-assignment to hs_rate

Remove the redundant else block that assigns PA_HS_MODE_B to hs_rate, as
it is already assigned in ufshcd_init_host_params(). This avoids
unnecessary reassignment and prevents overwriting hs_rate when it is
explicitly set to a different value.

Reviewed-by: Alim Akhtar <alim.akhtar@samsung.com>
Signed-off-by: Ram Kumar Dwivedi <quic_rdwivedi@quicinc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 weeks agoscsi: ufs: dt-bindings: Document gear and rate limit properties
Ram Kumar Dwivedi [Wed, 17 Sep 2025 14:09:30 +0000 (19:39 +0530)] 
scsi: ufs: dt-bindings: Document gear and rate limit properties

Add optional "limit-hs-gear" and "limit-rate" properties to the UFS
controller common binding. These properties allow limiting the maximum
HS gear and rate.

This is useful in cases where the customer board may have signal
integrity, clock configuration or layout issues that prevent reliable
operation at higher gears. Such limitations are especially critical in
those platforms, where stability is prioritized over peak performance.

Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Ram Kumar Dwivedi <quic_rdwivedi@quicinc.com>
Reviewed-by: Alim Akhtar <alim.akhtar@samsung.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 weeks agoscsi: ufs: core: Fix data race in CPU latency PM QoS request handling
Zhongqiu Han [Wed, 17 Sep 2025 09:41:43 +0000 (17:41 +0800)] 
scsi: ufs: core: Fix data race in CPU latency PM QoS request handling

The cpu_latency_qos_add/remove/update_request interfaces lack internal
synchronization by design, requiring the caller to ensure thread safety.
The current implementation relies on the 'pm_qos_enabled' flag, which is
insufficient to prevent concurrent access and cannot serve as a proper
synchronization mechanism. This has led to data races and list
corruption issues.

A typical race condition call trace is:

[Thread A]
ufshcd_pm_qos_exit()
  --> cpu_latency_qos_remove_request()
    --> cpu_latency_qos_apply();
      --> pm_qos_update_target()
        --> plist_del              <--(1) delete plist node
    --> memset(req, 0, sizeof(*req));
  --> hba->pm_qos_enabled = false;

[Thread B]
ufshcd_devfreq_target
  --> ufshcd_devfreq_scale
    --> ufshcd_scale_clks
      --> ufshcd_pm_qos_update     <--(2) pm_qos_enabled is true
        --> cpu_latency_qos_update_request
          --> pm_qos_update_target
            --> plist_del          <--(3) plist node use-after-free

Introduces a dedicated mutex to serialize PM QoS operations, preventing
data races and ensuring safe access to PM QoS resources, including sysfs
interface reads.

Fixes: 2777e73fc154 ("scsi: ufs: core: Add CPU latency QoS support for UFS driver")
Signed-off-by: Zhongqiu Han <zhongqiu.han@oss.qualcomm.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Tested-by: Huan Tang <tanghuan@vivo.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 weeks agoscsi: libfc: Fix potential buffer overflow in fc_ct_ms_fill()
Alok Tiwari [Mon, 15 Sep 2025 18:37:57 +0000 (11:37 -0700)] 
scsi: libfc: Fix potential buffer overflow in fc_ct_ms_fill()

The fc_ct_ms_fill() helper currently formats the OS name and version
into entry->value using "%s v%s". Since init_utsname()->sysname and
->release are unbounded strings, snprintf() may attempt to write more
than FC_FDMI_HBA_ATTR_OSNAMEVERSION_LEN bytes, triggering a
-Wformat-truncation warning with W=1.

In file included from drivers/scsi/libfc/fc_elsct.c:18:
drivers/scsi/libfc/fc_encode.h: In function ‘fc_ct_ms_fill.constprop’:
drivers/scsi/libfc/fc_encode.h:359:30: error: ‘%s’ directive output may
be truncated writing up to 64 bytes into a region of size between 62
and 126 [-Werror=format-truncation=]
  359 |                         "%s v%s",
      |                              ^~
  360 |                         init_utsname()->sysname,
  361 |                         init_utsname()->release);
      |                         ~~~~~~~~~~~~~~~~~~~~~~~
drivers/scsi/libfc/fc_encode.h:357:17: note: ‘snprintf’ output between
3 and 131 bytes into a destination of size 128
  357 |                 snprintf((char *)&entry->value,
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  358 |                         FC_FDMI_HBA_ATTR_OSNAMEVERSION_LEN,
      |                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  359 |                         "%s v%s",
      |                         ~~~~~~~~~
  360 |                         init_utsname()->sysname,
      |                         ~~~~~~~~~~~~~~~~~~~~~~~~
  361 |                         init_utsname()->release);
      |                         ~~~~~~~~~~~~~~~~~~~~~~~~

Fix this by using "%.62s v%.62s", which ensures sysname and release are
truncated to fit within the 128-byte field defined by
FC_FDMI_HBA_ATTR_OSNAMEVERSION_LEN.

[mkp: clarified commit description]

Signed-off-by: Alok Tiwari <alok.a.tiwari@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 weeks agoscsi: storvsc: Remove redundant ternary operators
Liao Yuanhong [Tue, 2 Sep 2025 13:23:46 +0000 (21:23 +0800)] 
scsi: storvsc: Remove redundant ternary operators

Remove redundant ternary operators to clean up the code.

Signed-off-by: Liao Yuanhong <liaoyuanhong@vivo.com>
Reviewed-by: Michael Kelley <mhklinux@outlook.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 weeks agoscsi: ufs: core: Change MCQ interrupt enable flow
Peter Wang [Wed, 24 Sep 2025 09:16:19 +0000 (17:16 +0800)] 
scsi: ufs: core: Change MCQ interrupt enable flow

Move the MCQ interrupt enable process to
ufshcd_mcq_make_queues_operational() to ensure that interrupts are set
correctly when making queues operational, similar to
ufshcd_make_hba_operational(). This change addresses the issue where
ufshcd_mcq_make_queues_operational() was not fully operational due to
missing interrupt enablement.

This change only affects host drivers that call
ufshcd_mcq_make_queues_operational(), i.e. ufs-mediatek.

Signed-off-by: Peter Wang <peter.wang@mediatek.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 weeks agoscsi: smartpqi: Replace kmalloc() + copy_from_user() with memdup_user()
Thorsten Blum [Mon, 22 Sep 2025 20:18:33 +0000 (22:18 +0200)] 
scsi: smartpqi: Replace kmalloc() + copy_from_user() with memdup_user()

Replace kmalloc() followed by copy_from_user() with memdup_user() to
simplify and improve pqi_passthru_ioctl().

Since memdup_user() already allocates memory, use kzalloc() in the else
branch instead of manually zeroing 'kernel_buffer' using memset(0).

Return early if an error occurs.  No functional changes intended.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Acked-by: Don Brace <don.brace@microchip.com>
Message-Id: <20250922201832.1697874-2-thorsten.blum@linux.dev>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 weeks agoscsi: hpsa: Replace kmalloc() + copy_from_user() with memdup_user()
Thorsten Blum [Tue, 23 Sep 2025 17:15:04 +0000 (19:15 +0200)] 
scsi: hpsa: Replace kmalloc() + copy_from_user() with memdup_user()

Replace kmalloc() followed by copy_from_user() with memdup_user() to
improve and simplify hpsa_passthru_ioctl().

Since memdup_user() already allocates memory, use kzalloc() in the else
branch instead of manually zeroing 'buff' using memset(0).

Return early if an error occurs and remove the 'out_kfree' label.

No functional changes intended.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Acked-by: Don Brace <don.brace@microchip.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 weeks agoscsi: hpsa: Fix potential memory leak in hpsa_big_passthru_ioctl()
Thorsten Blum [Fri, 19 Sep 2025 09:26:37 +0000 (11:26 +0200)] 
scsi: hpsa: Fix potential memory leak in hpsa_big_passthru_ioctl()

Replace kmalloc() followed by copy_from_user() with memdup_user() to fix
a memory leak that occurs when copy_from_user(buff[sg_used],,) fails and
the 'cleanup1:' path does not free the memory for 'buff[sg_used]'. Using
memdup_user() avoids this by freeing the memory internally.

Since memdup_user() already allocates memory, use kzalloc() in the else
branch instead of manually zeroing 'buff[sg_used]' using memset(0).

Cc: stable@vger.kernel.org
Fixes: edd163687ea5 ("[SCSI] hpsa: add driver for HP Smart Array controllers.")
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Acked-by: Don Brace <don.brace@microchip.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 weeks agoMerge patch series "Update lpfc to revision 14.4.0.11"
Martin K. Petersen [Wed, 17 Sep 2025 02:20:57 +0000 (22:20 -0400)] 
Merge patch series "Update lpfc to revision 14.4.0.11"

Justin Tee <justintee8345@gmail.com> says:

Update lpfc to revision 14.4.0.11

This patch set contains clean up of unused members in various structs,
bug fixes related to discovery and resource allocation, and updates to
handling of debugfs entries.

The patches were cut against Martin's 6.18/scsi-queue tree.

Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 weeks agoscsi: lpfc: Copyright updates for 14.4.0.11 patches
Justin Tee [Mon, 15 Sep 2025 18:08:11 +0000 (11:08 -0700)] 
scsi: lpfc: Copyright updates for 14.4.0.11 patches

Update copyrights to 2025 for files modified in the 14.4.0.11 patch set.

Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Message-ID: <20250915180811.137530-15-justintee8345@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 weeks agoscsi: lpfc: Update lpfc version to 14.4.0.11
Justin Tee [Mon, 15 Sep 2025 18:08:10 +0000 (11:08 -0700)] 
scsi: lpfc: Update lpfc version to 14.4.0.11

Update lpfc version to 14.4.0.11

Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Message-ID: <20250915180811.137530-14-justintee8345@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 weeks agoscsi: lpfc: Convert debugfs directory counts from atomic to unsigned int
Justin Tee [Mon, 15 Sep 2025 18:08:09 +0000 (11:08 -0700)] 
scsi: lpfc: Convert debugfs directory counts from atomic to unsigned int

Atomicity is not necessary for debugfs directory accounting because
vport deletion and creation is already serialized.  Creation has always
been serialized through sysfs.  Deletion is serialized via walking the
lpfc_create_vport_work_array and calling fc_vport_terminate one-by-one
for each NPIV port.

Reported-by: Al Viro <viro@zeniv.linux.org.uk>
Closes: https://lore.kernel.org/linux-fsdevel/20250702212917.GK3406663@ZenIV/
Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Message-ID: <20250915180811.137530-13-justintee8345@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 weeks agoscsi: lpfc: Clean up extraneous phba dentries
Justin Tee [Mon, 15 Sep 2025 18:08:08 +0000 (11:08 -0700)] 
scsi: lpfc: Clean up extraneous phba dentries

Because debugfs_remove recursively removes debugfs entries, the
lpfc_debugfs_terminate routine is updated to remove only the parent/root
debugfs directories.  As such, there no longer is a need to keep track
of each individual debugfs entry so clean up the unused phba dentries.

Reported-by: Al Viro <viro@zeniv.linux.org.uk>
Closes: https://lore.kernel.org/linux-fsdevel/20250702212917.GK3406663@ZenIV/
Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Message-ID: <20250915180811.137530-12-justintee8345@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 weeks agoscsi: lpfc: Use switch case statements in DIF debugfs handlers
Justin Tee [Mon, 15 Sep 2025 18:08:07 +0000 (11:08 -0700)] 
scsi: lpfc: Use switch case statements in DIF debugfs handlers

With the introduction of aux numbers for debugfs entries, there's no
need to use the if-else-if clause based on debugfs entry pointers.
Update both the lpfc_debugfs_dif_err_read and lpfc_debugfs_dif_err_write
routines to use switch case based on aux instead.

Reported-by: Al Viro <viro@zeniv.linux.org.uk>
Closes: https://lore.kernel.org/linux-fsdevel/20250702212917.GK3406663@ZenIV/
Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Message-ID: <20250915180811.137530-11-justintee8345@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 weeks agoscsi: lpfc: Fix memory leak when nvmeio_trc debugfs entry is used
Justin Tee [Mon, 15 Sep 2025 18:08:06 +0000 (11:08 -0700)] 
scsi: lpfc: Fix memory leak when nvmeio_trc debugfs entry is used

Right after phba->nvmeio_trc is kzalloc'ed, phba->nvmeio_trc is set to
NULL and the memory reference to free the kzalloc'ed memory is lost.
Remove the phba->nvmeio_trc NULL ptr assignment after kzalloc.
phba->nvmeio_trc is freed in lpfc_debugfs_terminate.

Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Message-ID: <20250915180811.137530-10-justintee8345@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 weeks agoscsi: lpfc: Define size of debugfs entry for xri rebalancing
Justin Tee [Mon, 15 Sep 2025 18:08:05 +0000 (11:08 -0700)] 
scsi: lpfc: Define size of debugfs entry for xri rebalancing

To assist in debugging lpfc_xri_rebalancing driver parameter, a debugfs
entry is used.  The debugfs file operations for xri rebalancing have
been previously implemented, but lack definition for its information
buffer size.  Similar to other pre-existing debugfs entry buffers,
define LPFC_HDWQINFO_SIZE as 8192 bytes.

Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Message-ID: <20250915180811.137530-9-justintee8345@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 weeks agoscsi: lpfc: Ensure PLOGI_ACC is sent prior to PRLI in Point to Point topology
Justin Tee [Mon, 15 Sep 2025 18:08:04 +0000 (11:08 -0700)] 
scsi: lpfc: Ensure PLOGI_ACC is sent prior to PRLI in Point to Point topology

There is a timing race condition when a PRLI may be sent on the wire
before PLOGI_ACC in Point to Point topology.  Fix by deferring REG_RPI
mbox completion handling to after PLOGI_ACC's CQE completion.  Because
the discovery state machine only sends PRLI after REG_RPI mbox
completion, PRLI is now guaranteed to be sent after PLOGI_ACC.

Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Message-ID: <20250915180811.137530-8-justintee8345@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 weeks agoscsi: lpfc: Check return status of lpfc_reset_flush_io_context during TGT_RESET
Justin Tee [Mon, 15 Sep 2025 18:08:03 +0000 (11:08 -0700)] 
scsi: lpfc: Check return status of lpfc_reset_flush_io_context during TGT_RESET

If lpfc_reset_flush_io_context fails to execute, then the wrong return
status code may be passed back to upper layers when issuing a target
reset TMF command.  Fix by checking the return status from
lpfc_reset_flush_io_context() first in order to properly return FAILED
or FAST_IO_FAIL.

Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Message-ID: <20250915180811.137530-7-justintee8345@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 weeks agoscsi: lpfc: Decrement ndlp kref after FDISC retries exhausted
Justin Tee [Mon, 15 Sep 2025 18:08:02 +0000 (11:08 -0700)] 
scsi: lpfc: Decrement ndlp kref after FDISC retries exhausted

The kref for Fabric_DID ndlps is not decremented after repeated FDISC
failures and exhausting maximum allowed retries.  This can leave the
ndlp lingering unnecessarily.  Add a test and set bit operation for the
NLP_DROPPED flag. If not previously set, then a kref is decremented. The
ndlp is freed when the remaining reference for the completing ELS is
put.

Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Message-ID: <20250915180811.137530-6-justintee8345@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 weeks agoscsi: lpfc: Remove ndlp kref decrement clause for F_Port_Ctrl in lpfc_cleanup
Justin Tee [Mon, 15 Sep 2025 18:08:01 +0000 (11:08 -0700)] 
scsi: lpfc: Remove ndlp kref decrement clause for F_Port_Ctrl in lpfc_cleanup

In lpfc_cleanup, there is an extraneous nlp_put for NPIV ports on the
F_Port_Ctrl ndlp object.  In cases when an ABTS is issued, the
outstanding kref is needed for when a second XRI_ABORTED CQE is
received.  The final kref for the ndlp is designed to be decremented in
lpfc_sli4_els_xri_aborted instead.  Also, add a new log message to allow
for future diagnostics when debugging related issues.

Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Message-ID: <20250915180811.137530-5-justintee8345@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 weeks agoscsi: lpfc: Clean up allocated queues when queue setup mbox commands fail
Justin Tee [Mon, 15 Sep 2025 18:08:00 +0000 (11:08 -0700)] 
scsi: lpfc: Clean up allocated queues when queue setup mbox commands fail

lpfc_sli4_queue_setup() does not allocate memory and is used for
submitting CREATE_QUEUE mailbox commands.  Thus, if such mailbox
commands fail we should clean up by also freeing the memory allocated
for the queues with lpfc_sli4_queue_destroy().  Change the intended
clean up label for the lpfc_sli4_queue_setup() error case to
out_destroy_queue.

Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Message-ID: <20250915180811.137530-4-justintee8345@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 weeks agoscsi: lpfc: Abort outstanding ELS WQEs regardless of if rmmod is in progress
Justin Tee [Mon, 15 Sep 2025 18:07:59 +0000 (11:07 -0700)] 
scsi: lpfc: Abort outstanding ELS WQEs regardless of if rmmod is in progress

Driver rmmod may take a long time when in a very large SAN environment.
This is because outstanding ELS WQEs may end up taking E_D_TOV seconds
to complete causing long delays.  Speed this up by issuing aborts with
the ia bit set so that outstanding ELS WQEs complete faster.

Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Message-ID: <20250915180811.137530-3-justintee8345@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 weeks agoscsi: lpfc: Remove unused member variables in struct lpfc_hba and lpfc_vport
Justin Tee [Mon, 15 Sep 2025 18:07:58 +0000 (11:07 -0700)] 
scsi: lpfc: Remove unused member variables in struct lpfc_hba and lpfc_vport

There are variables defined in struct lpfc_hba and lpfc_vport that are
not used anywhere.  Delete the unused variables from struct lpfc_hba and
lpfc_vport.

Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Message-ID: <20250915180811.137530-2-justintee8345@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 weeks agoMerge patch series "scsi: qla2xxx: Fix incorrect sign of error code"
Martin K. Petersen [Wed, 17 Sep 2025 02:05:59 +0000 (22:05 -0400)] 
Merge patch series "scsi: qla2xxx: Fix incorrect sign of error code"

Qianfeng Rong <rongqianfeng@vivo.com> says:

qla2x00_start_sp() returns only negative error codes or QLA_SUCCESS.
Therefore, comparing its return value with positive error codes (e.g.,
if (_rval == EAGAIN)) causes logical errors.

Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 weeks agoscsi: qla2xxx: Fix incorrect sign of error code in qla_nvme_xmt_ls_rsp()
Qianfeng Rong [Fri, 5 Sep 2025 07:54:45 +0000 (15:54 +0800)] 
scsi: qla2xxx: Fix incorrect sign of error code in qla_nvme_xmt_ls_rsp()

Change the error code EAGAIN to -EAGAIN in qla_nvme_xmt_ls_rsp() to
align with qla2x00_start_sp() returning negative error codes or
QLA_SUCCESS, preventing logical errors.

Fixes: 875386b98857 ("scsi: qla2xxx: Add Unsolicited LS Request and Response Support for NVMe")
Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
Message-ID: <20250905075446.381139-4-rongqianfeng@vivo.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 weeks agoscsi: qla2xxx: Fix incorrect sign of error code in START_SP_W_RETRIES()
Qianfeng Rong [Fri, 5 Sep 2025 07:54:44 +0000 (15:54 +0800)] 
scsi: qla2xxx: Fix incorrect sign of error code in START_SP_W_RETRIES()

Change the error code EAGAIN to -EAGAIN in START_SP_W_RETRIES() to align
with qla2x00_start_sp() returning negative error codes or QLA_SUCCESS,
preventing logical errors.  Additionally, the '_rval' variable should
store negative error codes to conform to Linux kernel error code
conventions.

Fixes: 9803fb5d2759 ("scsi: qla2xxx: Fix task management cmd failure")
Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
Message-ID: <20250905075446.381139-3-rongqianfeng@vivo.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 weeks agoscsi: qla2xxx: edif: Fix incorrect sign of error code
Qianfeng Rong [Fri, 5 Sep 2025 07:54:43 +0000 (15:54 +0800)] 
scsi: qla2xxx: edif: Fix incorrect sign of error code

Change the error code EAGAIN to -EAGAIN in qla24xx_sadb_update() and
qla_edif_process_els() to align with qla2x00_start_sp() returning
negative error codes or QLA_SUCCESS, preventing logical errors.

Fixes: 0b3f3143d473 ("scsi: qla2xxx: edif: Add retry for ELS passthrough")
Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
Message-ID: <20250905075446.381139-2-rongqianfeng@vivo.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 weeks agoscsi: ufs: core: Disable timestamp functionality if not supported
Bart Van Assche [Tue, 9 Sep 2025 19:06:07 +0000 (12:06 -0700)] 
scsi: ufs: core: Disable timestamp functionality if not supported

Some Kioxia UFS 4 devices do not support the qTimestamp attribute.  Set
the UFS_DEVICE_QUIRK_NO_TIMESTAMP_SUPPORT for these devices such that no
error messages appear in the kernel log about failures to set the
qTimestamp attribute.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Avri Altman <avri.altman@sandisk.com>
Tested-by: Nitin Rawat <quic_nitirawa@quicinc.com> # on SM8650-QRD
Reviewed-by: Nitin Rawat <quic_nitirawa@quicinc.com>
Reviewed-by: Peter Wang <peter.wang@mediatek.com>
Reviewed-by: Manivannan Sadhasivam <mani@kernel.org>
Message-ID: <20250909190614.3531435-1-bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 weeks agoscsi: target: iscsi: fix typos and formatting in lio_target messages
Alok Tiwari [Wed, 10 Sep 2025 19:07:20 +0000 (12:07 -0700)] 
scsi: target: iscsi: fix typos and formatting in lio_target messages

Fix several minor issues in lio_target code and messages:

 - Correct typo "locatel" -> "locate" in error log.

 - Add missing space in pr_debug() message for better readability.

 - Fix comment typo: "contig_item" -> "config_item".

These changes improve code clarity and log readability.

Signed-off-by: Alok Tiwari <alok.a.tiwari@oracle.com>
Reviewed-by: Mike Christie <michael.christie@oracle.com>
Message-ID: <20250910190728.3783157-1-alok.a.tiwari@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 weeks agoscsi: ufs: ufs-qcom: Disable lane clocks during phy hibern8
Palash Kambar [Tue, 9 Sep 2025 05:51:49 +0000 (11:21 +0530)] 
scsi: ufs: ufs-qcom: Disable lane clocks during phy hibern8

Currently, the UFS lane clocks remain enabled even after the link enters
the Hibern8 state and are only disabled during runtime/system
suspend.This patch modifies the behavior to disable the lane clocks
during ufs_qcom_setup_clocks(), which is invoked shortly after the link
enters Hibern8 via gate work.

While hibern8_notify() offers immediate control, toggling clocks on
every transition isn't ideal due to varied contexts like clock scaling.
Since setup_clocks() manages PHY/controller resources and is invoked
soon after Hibern8 entry, it serves as a central and stable point for
clock gating.

Signed-off-by: Palash Kambar <quic_pkambar@quicinc.com>
Reviewed-by: Manivannan Sadhasivam <mani@kernel.org>
Message-ID: <20250909055149.2068737-1-quic_pkambar@quicinc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 weeks agoscsi: ufs: exynos: Correct sync pattern mask timing comment
Alok Tiwari [Sun, 7 Sep 2025 20:27:49 +0000 (13:27 -0700)] 
scsi: ufs: exynos: Correct sync pattern mask timing comment

Fix the comment for SYNC_LEN_G2 in exynos_ufs_config_sync_pattern_mask().
The actual value is 40us, not 44us, matching the configured mask timing.
This change improves code clarity and avoids potential confusion for
readers and maintainers.

No functional changes.

Signed-off-by: Alok Tiwari <alok.a.tiwari@oracle.com>
Reviewed-by: Peter Griffin <peter.griffin@linaro.org>
Message-ID: <20250907202752.3613183-1-alok.a.tiwari@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: bfa: Remove self-assignment code
Qiang Liu [Thu, 4 Sep 2025 09:35:58 +0000 (17:35 +0800)] 
scsi: bfa: Remove self-assignment code

The variable num_cqs is of type u8 and does not require be16_to_cpu
conversion, so the redundant code is removed.

Signed-off-by: Qiang Liu <liuqiang@kylinos.cn>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoMerge patch series "Simplify MCQ resource mapping"
Martin K. Petersen [Wed, 10 Sep 2025 02:53:10 +0000 (22:53 -0400)] 
Merge patch series "Simplify MCQ resource mapping"

Nitin Rawat <nitin.rawat@oss.qualcomm.com> says:

The patch series simplifies the UFS MCQ (Multi Circular Queue)
resource mapping in the Qualcomm UFS host controller driver by
replacing the complex multi-resource approach with a streamlined
single-resource implementation.

The current MCQ implementation uses multiple separate resource
mappings (RES_UFS, RES_MCQ, RES_MCQ_SQD, RES_MCQ_VS) with dynamic
resource allocation, which increases code complexity and potential for
resource mapping errors. This approach also doesn't align with the
device tree binding specification that defines a single 'mcq' memory
region.

Replace the multi-resource mapping with a single "mcq" resource that
encompasses the entire MCQ configuration space. The doorbell registers
(SQD, CQD, SQIS, CQIS) are accessed using predefined offsets relative
to the MCQ base address, providing clearer memory layout organization.

Tested on Qualcomm platforms SM8650 and SM8750 with UFS MCQ enabled.

Changes from v3:
1. Addressed Krzysztof comment to separate device tree and driver
   patch independently in different patch series. This series caters
   driver changes.
2. Addressed Manivannan's change to update commit text and remove
   redundant null check in mcq code.
3. Addressed Manivannan's to Update few offsets as fixed definition
   instead of enum.

Changes from v2:
1. Removed dt-bindings patch as existing binding supports required
   reg-names format.
2. Added patch to refactor MCQ register dump logic for new resource
   mapping.
3. Added patch to remove unused ufshcd_res_info structure from UFS core.
4. Changed reg-names from "ufs_mem" to "std" in device tree patches.
5. Reordered patches with driver changes first, then device tree changes.
6. Updated SM8750 MCQ region size from 0x2000 to 0x15000

Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: ufs: ufs-qcom: Refactor MCQ register dump logic
Nitin Rawat [Wed, 3 Sep 2025 07:48:15 +0000 (13:18 +0530)] 
scsi: ufs: ufs-qcom: Refactor MCQ register dump logic

Refactor MCQ register dump to align with the new resource mapping.  As
part of refactor, below changes are done:

 - Update ufs_qcom_dump_regs() function signature to accept direct
   base address instead of resource ID enum

 - Modify ufs_qcom_dump_mcq_hci_regs() to use hba->mcq_base and
   calculated addresses from MCQ operation info

 - Replace enum ufshcd_res with direct memory-mapped I/O addresses

Additionally remove the ufshcd_res_info structure and associated enum
ufshcd_res definitions from the UFS host controller header.  These were
previously used for MCQ resource mapping but are no longer needed
following recent refactoring to use direct base addresses instead of
multiple separate resource regions.

Signed-off-by: Nitin Rawat <quic_nitirawa@quicinc.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Manivannan Sadhasivam <mani@kernel.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: ufs: ufs-qcom: Streamline UFS MCQ resource mapping
Nitin Rawat [Wed, 3 Sep 2025 07:48:14 +0000 (13:18 +0530)] 
scsi: ufs: ufs-qcom: Streamline UFS MCQ resource mapping

The current MCQ resource configuration involves multiple resource
mappings and dynamic resource allocation.

Simplify the resource mapping by directly mapping the single "mcq"
resource from device tree to hba->mcq_base instead of mapping multiple
separate resources (RES_UFS, RES_MCQ, RES_MCQ_SQD, RES_MCQ_VS).

It also uses predefined offsets for MCQ doorbell registers (SQD, CQD,
SQIS, CQIS) relative to the MCQ base,providing clearer memory layout
clarity.

Additionally update vendor-specific register offset UFS_MEM_CQIS_VS
offset from 0x8 to 0x4008 to align with the hardware programming guide.

The new approach assumes the device tree provides a single "mcq"
resource that encompasses the entire MCQ configuration space, making the
driver more maintainable and less prone to resource mapping errors.

The change aligns the driver implementation with the device tree binding
specification, which defines a single 'mcq' memory region rather than
multiple separate regions.

Co-developed-by: Ram Kumar Dwivedi <quic_rdwivedi@quicinc.com>
Signed-off-by: Ram Kumar Dwivedi <quic_rdwivedi@quicinc.com>
Signed-off-by: Nitin Rawat <quic_nitirawa@quicinc.com>
Reviewed-by: Manivannan Sadhasivam <mani@kernel.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoMerge patch series "ufs: host: mediatek: Power Management and stability enhancements"
Martin K. Petersen [Wed, 10 Sep 2025 02:46:47 +0000 (22:46 -0400)] 
Merge patch series "ufs: host: mediatek: Power Management and stability enhancements"

Peter Wang <peter.wang@mediatek.com> says:

These patches collectively enhance the UFS host driver's reliability,
power management efficiency, and error recovery mechanisms on MediaTek
platforms. They address critical issues and introduce optimizations
that improve system stability and performance.

Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: ufs: host: mediatek: Fix device power control
Peter Wang [Wed, 3 Sep 2025 02:44:46 +0000 (10:44 +0800)] 
scsi: ufs: host: mediatek: Fix device power control

Adjust the timing of device power control to ensure low power mode (LPM)
is entered only after VCC is turned off. Prevent VCCQ/VCCQ2 from
entering LPM prematurely, ensuring proper power management and device
stability.

Signed-off-by: Peter Wang <peter.wang@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: ufs: host: mediatek: Fix unbalanced IRQ enable issue
Peter Wang [Wed, 3 Sep 2025 02:44:45 +0000 (10:44 +0800)] 
scsi: ufs: host: mediatek: Fix unbalanced IRQ enable issue

Resolve the issue of unbalanced IRQ enablement by setting the
'is_mcq_intr_enabled' flag after the first successful IRQ enablement.
Ensure proper tracking of the IRQ state and prevent potential mismatches
in IRQ handling.

Signed-off-by: Peter Wang <peter.wang@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: ufs: host: mediatek: Fix adapt issue after PA_Init
Alice Chao [Wed, 3 Sep 2025 02:44:44 +0000 (10:44 +0800)] 
scsi: ufs: host: mediatek: Fix adapt issue after PA_Init

Address the issue where the host does not send adapt to the device after
PA_Init success. Ensure the adapt process is correctly initiated for
devices with IP version MT6899 and above, resolving communication issues
between the host and device.

Signed-off-by: Alice Chao <alice.chao@mediatek.com>
Reviewed-by: Peter Wang <peter.wang@mediatek.com>
Signed-off-by: Peter Wang <peter.wang@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: ufs: host: mediatek: Return error directly on idle wait timeout
Sanjeev Y [Wed, 3 Sep 2025 02:44:43 +0000 (10:44 +0800)] 
scsi: ufs: host: mediatek: Return error directly on idle wait timeout

Optimize the recovery flow by returning an error code immediately if a
wait idle timeout occurs, rather than waiting for the link to reach the
up state. Shorten the recovery process and improve error handling
efficiency when idle state transitions fail.

Signed-off-by: Sanjeev Y <sanjeev.y@mediatek.com>
Reviewed-by: Peter Wang <peter.wang@mediatek.com>
Signed-off-by: Peter Wang <peter.wang@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: ufs: host: mediatek: Disable auto-hibern8 during power mode changes
Peter Wang [Wed, 3 Sep 2025 02:44:42 +0000 (10:44 +0800)] 
scsi: ufs: host: mediatek: Disable auto-hibern8 during power mode changes

Disable auto-hibern8 during power mode transitions to prevent unintended
entry into auto-hibern8. Restore the original auto-hibern8 timer value
after completing the power mode change to maintain system stability and
prevent potential issues during power state transitions.

Signed-off-by: Peter Wang <peter.wang@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: ufs: host: mediatek: Support UFS PHY runtime PM and correct sequence
Peter Wang [Wed, 3 Sep 2025 02:44:41 +0000 (10:44 +0800)] 
scsi: ufs: host: mediatek: Support UFS PHY runtime PM and correct sequence

Add support for UFS PHY runtime power management by probing the PHY
device and enabling its runtime PM. Ensure the correct sequence of
operations during suspend and resume: PHY suspend -> UFS suspend -> UFS
resume -> PHY resume.  Improve power management efficiency and system
stability with this enhancement.

Signed-off-by: Peter Wang <peter.wang@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: ufs: host: mediatek: Correct resume flow for LPM and MTCMOS
Alice Chao [Wed, 3 Sep 2025 02:44:40 +0000 (10:44 +0800)] 
scsi: ufs: host: mediatek: Correct resume flow for LPM and MTCMOS

Correct the system resume flow by turning MTCMOS on before setting LPM
to false. During system suspend, set LPM to true and turn MTCMOS
off. Ensure proper power management and system stability with the
updated resume sequence.

Signed-off-by: Alice Chao <alice.chao@mediatek.com>
Signed-off-by: Peter Wang <peter.wang@mediatek.com>
Reviewed-by: Peter Wang <peter.wang@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: ufs: host: mediatek: Correct system PM flow
Peter Wang [Wed, 3 Sep 2025 02:44:39 +0000 (10:44 +0800)] 
scsi: ufs: host: mediatek: Correct system PM flow

Refine the system power management (PM) flow by skipping low power mode
(LPM) and MTCMOS settings if runtime PM is already applied. Prevent
redundant operations to ensure a more efficient PM process.

Signed-off-by: Peter Wang <peter.wang@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: ufs: host: mediatek: Enhance recovery on resume failure
Peter Wang [Wed, 3 Sep 2025 02:44:38 +0000 (10:44 +0800)] 
scsi: ufs: host: mediatek: Enhance recovery on resume failure

Improve the recovery process for failed resume operations. Log the
device's power status and return 0 if both resume and recovery fail to
prevent I/O hang.

Signed-off-by: Peter Wang <peter.wang@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: ufs: host: mediatek: Enhance recovery on hibernation exit failure
Peter Wang [Wed, 3 Sep 2025 02:44:37 +0000 (10:44 +0800)] 
scsi: ufs: host: mediatek: Enhance recovery on hibernation exit failure

Improve the recovery process for hibernation exit failures. Trigger the
error handler and break the suspend operation to ensure effective
recovery from hibernation errors. Activate the error handling mechanism
by ufshcd_force_error_recovery and scheduling the error handler work.

Signed-off-by: Peter Wang <peter.wang@mediatek.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: pm80xx: Avoid -Wflex-array-member-not-at-end warnings
Gustavo A. R. Silva [Mon, 8 Sep 2025 18:42:01 +0000 (20:42 +0200)] 
scsi: pm80xx: Avoid -Wflex-array-member-not-at-end warnings

Comment out unused field 'residual_count' in a couple of structures, and
with this, fix the following -Wflex-array-member-not-at-end warnings:

drivers/scsi/pm8001/pm8001_hwi.h:342:33: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
drivers/scsi/pm8001/pm80xx_hwi.h:561:32: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]

Reviewed-by: Jack Wang <jinpu.wang@ionos.com>
Reviewed-by: John Garry <john.g.garry@oracle.com>
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: ufs: ufs-qcom: Align programming sequence of Shared ICE for UFS controller v5
Palash Kambar [Mon, 18 Aug 2025 04:09:05 +0000 (09:39 +0530)] 
scsi: ufs: ufs-qcom: Align programming sequence of Shared ICE for UFS controller v5

Disabling the AES core in Shared ICE is not supported during power
collapse for UFS Host Controller v5.0, which may lead to data errors
after Hibern8 exit. To comply with hardware programming guidelines and
avoid this issue, issue a sync reset to ICE upon power collapse exit.

Hence follow below steps to reset the ICE upon exiting power collapse
and align with Hw programming guide.

a. Assert the ICE sync reset by setting both SYNC_RST_SEL and
   SYNC_RST_SW bits in UFS_MEM_ICE_CFG

b. Deassert the reset by clearing SYNC_RST_SW in  UFS_MEM_ICE_CFG

Signed-off-by: Palash Kambar <quic_pkambar@quicinc.com>
Reviewed-by: Manivannan Sadhasivam <mani@kernel.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: scsi_debug: Replace kzalloc() + copy_from_user() with memdup_user_nul()
Thorsten Blum [Fri, 5 Sep 2025 10:31:45 +0000 (12:31 +0200)] 
scsi: scsi_debug: Replace kzalloc() + copy_from_user() with memdup_user_nul()

Replace kzalloc() followed by copy_from_user() with memdup_user_nul() to
improve and simplify sdebug_error_write().

No functional changes intended.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: lpfc: Use int type to store negative error codes
Qianfeng Rong [Thu, 4 Sep 2025 13:23:51 +0000 (21:23 +0800)] 
scsi: lpfc: Use int type to store negative error codes

Change the 'ret' variable in lpfc_sli4_issue_wqe() from uint32_t to int,
as it needs to store either negative error codes or zero returned by
lpfc_sli4_wq_put().

Storing the negative error codes in unsigned type, doesn't cause an
issue at runtime but can be confusing.  Additionally, assigning negative
error codes to unsigned type may trigger a GCC warning when the
-Wsign-conversion flag is enabled.

No effect on runtime.

Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
Reviewed-by: Justin Tee <justin.tee@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: target: iscsi: Use int type to store negative value
Qianfeng Rong [Tue, 2 Sep 2025 12:50:14 +0000 (20:50 +0800)] 
scsi: target: iscsi: Use int type to store negative value

Change the 'ret' variable in iscsit_tmr_task_reassign() from u64 to int,
as it needs to store either negative value or zero returned by
iscsit_find_cmd_for_recovery().

Storing the negative error codes in unsigned type, or performing equality
comparisons (e.g., ret == -2), doesn't cause an issue at runtime [1] but
can be confusing.  Additionally, assigning negative error codes to
unsigned type may trigger a GCC warning when the -Wsign-conversion flag
is enabled.

No effect on runtime.

Link: https://lore.kernel.org/all/x3wogjf6vgpkisdhg3abzrx7v7zktmdnfmqeih5kosszmagqfs@oh3qxrgzkikf/
Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
Reviewed-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: ufs: core: Move the tracing enumeration types into a new file
Bart Van Assche [Fri, 29 Aug 2025 15:38:16 +0000 (08:38 -0700)] 
scsi: ufs: core: Move the tracing enumeration types into a new file

The <ufs/ufs.h> header file defines constants and data structures
related to the UFS standard. Move the enumeration types related to
tracing into a new header file because these are not defined in the UFS
standard. An intended side effect of this patch is that the tracing
enumeration types are no longer visible to UFS host drivers.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Link: https://lore.kernel.org/r/20250829153841.2201700-1-bvanassche@acm.org
Reviewed-by: Avri Altman <avri.altman@sandisk.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: qla2xxx: Use secs_to_jiffies() instead of msecs_to_jiffies()
Thorsten Blum [Thu, 28 Aug 2025 16:11:53 +0000 (18:11 +0200)] 
scsi: qla2xxx: Use secs_to_jiffies() instead of msecs_to_jiffies()

Use secs_to_jiffies() instead of msecs_to_jiffies() and avoid scaling
'ratov_j' to milliseconds.

No functional changes intended.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Link: https://lore.kernel.org/r/20250828161153.3676-2-thorsten.blum@linux.dev
Reviewed-by: Himanshu Madhani <hmadhani2024@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: csiostor: Fix some spelling errors
Xichao Zhao [Wed, 27 Aug 2025 12:16:11 +0000 (20:16 +0800)] 
scsi: csiostor: Fix some spelling errors

Fix spelling errors in some comments.

Signed-off-by: Xichao Zhao <zhao.xichao@vivo.com>
Link: https://lore.kernel.org/r/20250827121611.497547-1-zhao.xichao@vivo.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: fc: Avoid -Wflex-array-member-not-at-end warnings
Gustavo A. R. Silva [Wed, 27 Aug 2025 06:10:53 +0000 (08:10 +0200)] 
scsi: fc: Avoid -Wflex-array-member-not-at-end warnings

-Wflex-array-member-not-at-end has been introduced in GCC-14, and we are
getting ready to enable it, globally.

So, in order to avoid ending up with a flexible-array member in the
middle of multiple other structs, we use the '__struct_group()' helper
to create a new tagged 'struct fc_df_desc_fpin_reg_hdr'.  This structure
groups together all the members of the flexible 'struct
fc_df_desc_fpin_reg' except the flexible array.

As a result, the array is effectively separated from the rest of the
members without modifying the memory layout of the flexible structure.
We then change the type of the middle struct members currently causing
trouble from 'struct fc_df_desc_fpin_reg' to 'struct
fc_df_desc_fpin_reg_hdr'.

We also want to ensure that in case new members need to be added to the
flexible structure, they are always included within the newly created
tagged struct. For this, we use '_Static_assert()'. This ensures that
the memory layout for both the flexible structure and the new tagged
struct is the same after any changes.

This approach avoids having to implement 'struct fc_df_desc_fpin_reg_hdr'
as a completely separate structure, thus preventing having to maintain
two independent but basically identical structures, closing the door
to potential bugs in the future.

The above is also done for flexible structures 'struct fc_els_rdf' and
'struct fc_els_rdf_resp'

So, with these changes, fix the following warnings:
drivers/scsi/lpfc/lpfc_hw4.h:4936:41: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
drivers/scsi/lpfc/lpfc_hw4.h:4942:41: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
drivers/scsi/lpfc/lpfc_hw4.h:4947:41: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Link: https://lore.kernel.org/r/aK6hbQLyQlvlySf8@kspp
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Justin Tee <justin.tee@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: pm8001: Use int instead of u32 to store error codes
Qianfeng Rong [Tue, 26 Aug 2025 09:32:42 +0000 (17:32 +0800)] 
scsi: pm8001: Use int instead of u32 to store error codes

Use int instead of u32 for 'ret' variable to store negative error codes
returned by PM8001_CHIP_DISP->set_nvmd_req().

Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
Link: https://lore.kernel.org/r/20250826093242.230344-1-rongqianfeng@vivo.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: sd: Make sd_revalidate_disk() return void
Abinash Singh [Mon, 25 Aug 2025 18:39:40 +0000 (00:09 +0530)] 
scsi: sd: Make sd_revalidate_disk() return void

The sd_revalidate_disk() function currently returns 0 for both success
and memory allocation failure. Since none of its callers use the return
value, this return code is both unnecessary and potentially misleading.

Change the return type of sd_revalidate_disk() from int to void
and remove all return value handling. This makes the function
semantics clearer and avoids confusion about unused return codes.

Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Signed-off-by: Abinash Singh <abinashsinghlalotra@gmail.com>
Link: https://lore.kernel.org/r/20250825183940.13211-4-abinashsinghlalotra@gmail.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: sd: Remove redundant printk() after kmalloc() failure
Abinash Singh [Mon, 25 Aug 2025 18:39:39 +0000 (00:09 +0530)] 
scsi: sd: Remove redundant printk() after kmalloc() failure

The SCSI disk driver prints a warning when kmalloc() fails in
sd_revalidate_disk(). This is redundant because the page allocator
already reports failures unless __GFP_NOWARN is used. Keeping the extra
message only adds noise to the kernel log.

Remove the unnecessary sd_printk() call. Control flow is unchanged.

Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Signed-off-by: Abinash Singh <abinashsinghlalotra@gmail.com>
Link: https://lore.kernel.org/r/20250825183940.13211-3-abinashsinghlalotra@gmail.com
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: sd: Fix build warning in sd_revalidate_disk()
Abinash Singh [Mon, 25 Aug 2025 18:39:38 +0000 (00:09 +0530)] 
scsi: sd: Fix build warning in sd_revalidate_disk()

A build warning was triggered due to excessive stack usage in
sd_revalidate_disk():

drivers/scsi/sd.c: In function ‘sd_revalidate_disk.isra’:
drivers/scsi/sd.c:3824:1: warning: the frame size of 1160 bytes is larger than 1024 bytes [-Wframe-larger-than=]

This is caused by a large local struct queue_limits (~400B) allocated on
the stack. Replacing it with a heap allocation using kmalloc()
significantly reduces frame usage. Kernel stack is limited (~8 KB), and
allocating large structs on the stack is discouraged.  As the function
already performs heap allocations (e.g. for buffer), this change fits
well.

Fixes: 804e498e0496 ("sd: convert to the atomic queue limits API")
Cc: stable@vger.kernel.org
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Abinash Singh <abinashsinghlalotra@gmail.com>
Link: https://lore.kernel.org/r/20250825183940.13211-2-abinashsinghlalotra@gmail.com
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: ufs: exynos: fsd: Gate ref_clk and put UFS device in reset on suspend
Bharat Uppal [Thu, 21 Aug 2025 05:39:23 +0000 (11:09 +0530)] 
scsi: ufs: exynos: fsd: Gate ref_clk and put UFS device in reset on suspend

On FSD platform, gating the reference clock (ref_clk) and putting the
UFS device in reset by asserting the reset signal during UFS suspend,
improves the power savings and ensures the PHY is fully turned off.

These operations are added as FSD specific suspend hook to avoid
unintended side effects on other SoCs supported by this driver.

Co-developed-by: Nimesh Sati <nimesh.sati@samsung.com>
Signed-off-by: Nimesh Sati <nimesh.sati@samsung.com>
Signed-off-by: Bharat Uppal <bharat.uppal@samsung.com>
Link: https://lore.kernel.org/r/20250821053923.69411-1-bharat.uppal@samsung.com
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: pm80xx: Fix race condition caused by static variables
Francisco Gutierrez [Wed, 23 Jul 2025 18:35:43 +0000 (18:35 +0000)] 
scsi: pm80xx: Fix race condition caused by static variables

Eliminate the use of static variables within the log pull implementation
to resolve a race condition and prevent data gaps when pulling logs from
multiple controllers in parallel, ensuring each operation is properly
isolated.

Signed-off-by: Francisco Gutierrez <frankramirez@google.com>
Link: https://lore.kernel.org/r/20250723183543.1443301-1-frankramirez@google.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoMerge patch series "mpi3mr: bug fixes and minor updates"
Martin K. Petersen [Tue, 26 Aug 2025 01:40:27 +0000 (21:40 -0400)] 
Merge patch series "mpi3mr: bug fixes and minor updates"

Chandrakanth Patil <chandrakanth.patil@broadcom.com> says:

This series contains mpi3mr driver fixes and minor updates.

Link: https://lore.kernel.org/r/20250820084138.228471-1-chandrakanth.patil@broadcom.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: mpi3mr: Update driver version to 8.15.0.5.50
Chandrakanth Patil [Wed, 20 Aug 2025 08:41:38 +0000 (14:11 +0530)] 
scsi: mpi3mr: Update driver version to 8.15.0.5.50

Bump driver version to 8.15.0.5.50 to match the latest release.

Signed-off-by: Chandrakanth Patil <chandrakanth.patil@broadcom.com>
Link: https://lore.kernel.org/r/20250820084138.228471-7-chandrakanth.patil@broadcom.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: mpi3mr: Fix premature TM timeouts on virtual drives
Chandrakanth Patil [Wed, 20 Aug 2025 08:41:37 +0000 (14:11 +0530)] 
scsi: mpi3mr: Fix premature TM timeouts on virtual drives

Task Management to virtual drives may timeout prematurely when using a
static default timeout.

Read Abort and Reset timeouts from Device Page 0 and apply the maximum
of the firmware value and the default.

This fixes premature TM failures on virtual drives.

Signed-off-by: Chandrakanth Patil <chandrakanth.patil@broadcom.com>
Link: https://lore.kernel.org/r/20250820084138.228471-6-chandrakanth.patil@broadcom.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: mpi3mr: Update MPI headers to revision 37
Chandrakanth Patil [Wed, 20 Aug 2025 08:41:36 +0000 (14:11 +0530)] 
scsi: mpi3mr: Update MPI headers to revision 37

Sync MPI header files to revision 37 to match current firmware/spec
definitions.

No functional change.

Signed-off-by: Chandrakanth Patil <chandrakanth.patil@broadcom.com>
Link: https://lore.kernel.org/r/20250820084138.228471-5-chandrakanth.patil@broadcom.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: mpi3mr: Fix I/O failures during controller reset
Chandrakanth Patil [Wed, 20 Aug 2025 08:41:35 +0000 (14:11 +0530)] 
scsi: mpi3mr: Fix I/O failures during controller reset

I/Os can race with controller reset and fail.

Block requests at the mid layer when reset starts using
scsi_host_block(), and resume with scsi_host_unblock() after reset
completes.

Signed-off-by: Chandrakanth Patil <chandrakanth.patil@broadcom.com>
Link: https://lore.kernel.org/r/20250820084138.228471-4-chandrakanth.patil@broadcom.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: mpi3mr: Fix controller init failure on fault during queue creation
Chandrakanth Patil [Wed, 20 Aug 2025 08:41:34 +0000 (14:11 +0530)] 
scsi: mpi3mr: Fix controller init failure on fault during queue creation

Firmware can enter a transient fault while creating operational queues.
The driver fails the load immediately.

Add a retry loop that checks controller status and history bit after
queue creation. If either indicates a fault, retry init up to a set
limit before failing.

Signed-off-by: Chandrakanth Patil <chandrakanth.patil@broadcom.com>
Link: https://lore.kernel.org/r/20250820084138.228471-3-chandrakanth.patil@broadcom.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: mpi3mr: Fix device loss during enclosure reboot due to zero link speed
Chandrakanth Patil [Wed, 20 Aug 2025 08:41:33 +0000 (14:11 +0530)] 
scsi: mpi3mr: Fix device loss during enclosure reboot due to zero link speed

During enclosure reboot or expander reset, firmware may report a link
speed of 0 in "Device Add" events while the link is still coming up.
The driver drops such devices, leaving them missing even after the link
recovers.

Fix this by treating link speed 0 as 1.5 Gbps during device addition so
the device is exposed to the OS. The actual link speed will be updated
later when link-up events arrive.

Signed-off-by: Chandrakanth Patil <chandrakanth.patil@broadcom.com>
Link: https://lore.kernel.org/r/20250820084138.228471-2-chandrakanth.patil@broadcom.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: aic94xx: Remove redundant code
Qiang Liu [Tue, 19 Aug 2025 02:30:06 +0000 (10:30 +0800)] 
scsi: aic94xx: Remove redundant code

Assigning ssp_task.retry_count to itself has no effect.

Signed-off-by: Qiang Liu <liuqiang@kylinos.cn>
Link: https://lore.kernel.org/r/20250819023006.15216-1-liuqiangneo@163.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: myrs: Fix dma_alloc_coherent() error check
Thomas Fourier [Fri, 25 Jul 2025 08:31:06 +0000 (10:31 +0200)] 
scsi: myrs: Fix dma_alloc_coherent() error check

Check for NULL return value with dma_alloc_coherent(), because DMA
address is not always set by dma_alloc_coherent() on failure.

Fixes: 77266186397c ("scsi: myrs: Add Mylex RAID controller (SCSI interface)")
Signed-off-by: Thomas Fourier <fourier.thomas@gmail.com>
Link: https://lore.kernel.org/r/20250725083112.43975-2-fourier.thomas@gmail.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: lpfc: use min() to improve code
Qianfeng Rong [Fri, 15 Aug 2025 12:16:05 +0000 (20:16 +0800)] 
scsi: lpfc: use min() to improve code

Use min_t() to reduce the code in lpfc_sli4_driver_resource_setup() and
lpfc_nvme_prep_io_cmd(), and improve readability.

Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
Link: https://lore.kernel.org/r/20250815121609.384914-4-rongqianfeng@vivo.com
Reviewed-by: Justin Tee <justin.tee@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: hpsa: use min()/min_t() to improve code
Qianfeng Rong [Fri, 15 Aug 2025 12:16:04 +0000 (20:16 +0800)] 
scsi: hpsa: use min()/min_t() to improve code

Use min()/min_t() to reduce the code in complete_scsi_command() and
hpsa_vpd_page_supported(), and improve readability.

Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
Link: https://lore.kernel.org/r/20250815121609.384914-3-rongqianfeng@vivo.com
Acked-by: Don Brace <don.brace@microchip.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: ufs: core: Reduce the size of struct ufshcd_lrb
Bart Van Assche [Tue, 19 Aug 2025 15:43:49 +0000 (08:43 -0700)] 
scsi: ufs: core: Reduce the size of struct ufshcd_lrb

The size of the data structures that are used in the hot path matters
for performance (IOPS). Hence this patch that reduces the size of struct
ufshcd_lrb on 64-bit systems by 16 bytes. The size of this data
structure is reduced from 152 to 136 bytes.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Link: https://lore.kernel.org/r/20250819154356.2256952-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: ufs: core: Only collect timestamps if monitoring is enabled
Bart Van Assche [Tue, 19 Aug 2025 15:39:50 +0000 (08:39 -0700)] 
scsi: ufs: core: Only collect timestamps if monitoring is enabled

Every ktime_get() call in the hot path has a measurable impact on IOPS.
Hence, only collect timestamps if the monitoring functionality is
enabled.

See also commit 1d8613a23f3c ("scsi: ufs: core: Introduce HBA
performance monitor sysfs nodes").

Cc: Can Guo <cang@codeaurora.org>
Cc: Bean Huo <beanhuo@micron.com>
Cc: Daejun Park <daejun7.park@samsung.com>
Reviewed-by: Peter Wang <peter.wang@mediatek.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Link: https://lore.kernel.org/r/20250819153958.2255907-1-bvanassche@acm.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: qla2xxx: Fix memcpy() field-spanning write issue
Gustavo A. R. Silva [Wed, 13 Aug 2025 20:07:44 +0000 (16:07 -0400)] 
scsi: qla2xxx: Fix memcpy() field-spanning write issue

purex_item.iocb is defined as a 64-element u8 array, but 64 is the
minimum size and it can be allocated larger. This makes it a standard
empty flex array.

This was motivated by field-spanning write warnings during FPIN testing:

https://lore.kernel.org/linux-nvme/20250709211919.49100-1-bgurney@redhat.com/

  >  kernel: memcpy: detected field-spanning write (size 60) of single field
  >  "((uint8_t *)fpin_pkt + buffer_copy_offset)"
  >  at drivers/scsi/qla2xxx/qla_isr.c:1221 (size 44)

I removed the outer wrapper from the iocb flex array, so that it can be
linked to 'purex_item.size' with '__counted_by'.

These changes remove the default minimum 64-byte allocation, requiring
further changes.

  In 'struct scsi_qla_host' the embedded 'default_item' is now followed
  by '__default_item_iocb[QLA_DEFAULT_PAYLOAD_SIZE]' to reserve space
  that will be used as 'default_item.iocb'. This is wrapped using the
  'TRAILING_OVERLAP()' macro helper, which effectively creates a union
  between flexible-array member 'default_item.iocb' and
  '__default_item_iocb'.

  Since 'struct pure_item' now contains a flexible-array member, the
  helper must be placed at the end of 'struct scsi_qla_host' to prevent
  a '-Wflex-array-member-not-at-end' warning.

  'qla24xx_alloc_purex_item()' is adjusted to no longer expect the
  default minimum size to be part of 'sizeof(struct purex_item)', the
  entire flexible array size is added to the structure size for
  allocation.

This also slightly changes the layout of the purex_item struct, as
2-bytes of padding are added between 'size' and 'iocb'. The resulting
size is the same, but iocb is shifted 2-bytes (the original 'purex_item'
structure was padded at the end, after the 64-byte defined array size).
I don't think this is a problem.

Tested-by: Bryan Gurney <bgurney@redhat.com>
Co-developed-by: Chris Leech <cleech@redhat.com>
Signed-off-by: Chris Leech <cleech@redhat.com>
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Link: https://lore.kernel.org/r/20250813200744.17975-10-bgurney@redhat.com
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: scsi_debug: Use vcalloc() to simplify code
Qianfeng Rong [Wed, 6 Aug 2025 12:46:33 +0000 (20:46 +0800)] 
scsi: scsi_debug: Use vcalloc() to simplify code

Use vcalloc() instead of vmalloc() followed by bitmap_zero() to simplify
the function sdebug_add_store().

Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
Link: https://lore.kernel.org/r/20250806124633.383426-3-rongqianfeng@vivo.com
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: ipr: Use vmalloc_array() to simplify code
Qianfeng Rong [Wed, 6 Aug 2025 12:46:32 +0000 (20:46 +0800)] 
scsi: ipr: Use vmalloc_array() to simplify code

Use vmalloc_array() instead of vmalloc() to simplify the function
ipr_alloc_dump().

Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
Link: https://lore.kernel.org/r/20250806124633.383426-2-rongqianfeng@vivo.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: hpsa: Fix incorrect comment format
Cryolitia PukNgae [Wed, 6 Aug 2025 03:13:16 +0000 (11:13 +0800)] 
scsi: hpsa: Fix incorrect comment format

Comments should not have a leading plus sign.

Signed-off-by: Cryolitia PukNgae <cryolitia@uniontech.com>
Link: https://lore.kernel.org/r/20250806-scsi_typo-v1-1-ec353a303b31@uniontech.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoMerge patch series "scsi: pm80xx: Fix expander support"
Martin K. Petersen [Wed, 20 Aug 2025 01:50:44 +0000 (21:50 -0400)] 
Merge patch series "scsi: pm80xx: Fix expander support"

Niklas Cassel <cassel@kernel.org> says:

Hello all,

Some recent patches broke expander support for the pm80xx driver.

The first two patches in this series make sure that expanders work with
the pm80xx driver again.

It also fixes a bug in pm8001_abort_task() that was found through code
review.

There is also some patches that make the pm80xx driver more robust, so it
is less likely that the expander support will break again in the future.

There is also some minor changes to some other libsas drivers to make use
of the new dev_parent_is_expander() helper.

Please test and review.

Kind regards,
Niklas

Link: https://lore.kernel.org/r/20250814173215.1765055-12-cassel@kernel.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: pm80xx: Use pm80xx_get_local_phy_id() to access phy array
Niklas Cassel [Thu, 14 Aug 2025 17:32:25 +0000 (19:32 +0200)] 
scsi: pm80xx: Use pm80xx_get_local_phy_id() to access phy array

While the current code is perfectly fine (because we verify that the
device is directly attached before using attached_phy to index the
pm8001_ha->phy array), let's use the pm80xx_get_local_phy_id() helper
anyway, to reduce the chance that someone will copy paste this pattern
to other parts of the driver.

Note that in this specific case, we still need to keep the check that
the device is not behind an expander, because we do not want to clear
attached_phy of the expander if a device behind the expander disappears
(as that would disable all the other devices behind the expander).

However, if it is the expander itself that disappears, attached_phy will
be cleared, just like it would for any other directly attached device.

Signed-off-by: Niklas Cassel <cassel@kernel.org>
Link: https://lore.kernel.org/r/20250814173215.1765055-22-cassel@kernel.org
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Igor Pylypiv <ipylypiv@google.com>
Acked-by: Jack Wang <jinpu.wang@ionos.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: pm80xx: Fix pm8001_abort_task() for chip_8006 when using an expander
Niklas Cassel [Thu, 14 Aug 2025 17:32:24 +0000 (19:32 +0200)] 
scsi: pm80xx: Fix pm8001_abort_task() for chip_8006 when using an expander

For a direct attached device, attached_phy contains the local phy id.
For a device behind an expander, attached_phy contains the remote phy
id, not the local phy id.

The pm8001_ha->phy array only contains the phys of the HBA.  It does not
contain the phys of the expander.

Thus, you cannot use attached_phy to index the pm8001_ha->phy array,
without first verifying that the device is directly attached.

Use the pm80xx_get_local_phy_id() helper to make sure that we use the
local phy id to index the array, regardless if the device is directly
attached or not.

Fixes: 869ddbdcae3b ("scsi: pm80xx: corrected SATA abort handling sequence.")
Reviewed-by: Igor Pylypiv <ipylypiv@google.com>
Signed-off-by: Niklas Cassel <cassel@kernel.org>
Link: https://lore.kernel.org/r/20250814173215.1765055-21-cassel@kernel.org
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: pm80xx: Add helper function to get the local phy id
Niklas Cassel [Thu, 14 Aug 2025 17:32:23 +0000 (19:32 +0200)] 
scsi: pm80xx: Add helper function to get the local phy id

Avoid duplicated code by adding a helper to get the local phy id.

No functional changes intended.

Signed-off-by: Niklas Cassel <cassel@kernel.org>
Link: https://lore.kernel.org/r/20250814173215.1765055-20-cassel@kernel.org
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: pm80xx: Use dev_parent_is_expander() helper
Niklas Cassel [Thu, 14 Aug 2025 17:32:22 +0000 (19:32 +0200)] 
scsi: pm80xx: Use dev_parent_is_expander() helper

Make use of the dev_parent_is_expander() helper.

Signed-off-by: Niklas Cassel <cassel@kernel.org>
Link: https://lore.kernel.org/r/20250814173215.1765055-19-cassel@kernel.org
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: John Garry <john.g.garry@oracle.com>
Reviewed-by: Igor Pylypiv <ipylypiv@google.com>
Acked-by: Jack Wang <jinpu.wang@ionos.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: mvsas: Use dev_parent_is_expander() helper
Niklas Cassel [Thu, 14 Aug 2025 17:32:21 +0000 (19:32 +0200)] 
scsi: mvsas: Use dev_parent_is_expander() helper

Make use of the dev_parent_is_expander() helper.

Signed-off-by: Niklas Cassel <cassel@kernel.org>
Link: https://lore.kernel.org/r/20250814173215.1765055-18-cassel@kernel.org
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: John Garry <john.g.garry@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: isci: Use dev_parent_is_expander() helper
Niklas Cassel [Thu, 14 Aug 2025 17:32:20 +0000 (19:32 +0200)] 
scsi: isci: Use dev_parent_is_expander() helper

Make use of the dev_parent_is_expander() helper.

Signed-off-by: Niklas Cassel <cassel@kernel.org>
Link: https://lore.kernel.org/r/20250814173215.1765055-17-cassel@kernel.org
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: John Garry <john.g.garry@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: hisi_sas: Use dev_parent_is_expander() helper
Niklas Cassel [Thu, 14 Aug 2025 17:32:19 +0000 (19:32 +0200)] 
scsi: hisi_sas: Use dev_parent_is_expander() helper

Make use of the dev_parent_is_expander() helper.

Signed-off-by: Niklas Cassel <cassel@kernel.org>
Link: https://lore.kernel.org/r/20250814173215.1765055-16-cassel@kernel.org
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: John Garry <john.g.garry@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 months agoscsi: libsas: Add dev_parent_is_expander() helper
Niklas Cassel [Thu, 14 Aug 2025 17:32:18 +0000 (19:32 +0200)] 
scsi: libsas: Add dev_parent_is_expander() helper

Many libsas drivers check if the parent of the device is an expander.
Create a helper that the libsas drivers will use in follow up commits.

Suggested-by: Damien Le Moal <dlemoal@kernel.org>
Signed-off-by: Niklas Cassel <cassel@kernel.org>
Link: https://lore.kernel.org/r/20250814173215.1765055-15-cassel@kernel.org
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: John Garry <john.g.garry@oracle.com>
Reviewed-by: Jason Yan <yanaijie@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>