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>
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>
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>
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>
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>
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.
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>
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>
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>
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>
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>
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.
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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.
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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.
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.
-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>
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.
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.
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>
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>
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.
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.
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.
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.
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>
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:
> 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>
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>
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>
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>
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>
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>
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>
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>