<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux-toradex.git/drivers/ufs/core, branch master</title>
<subtitle>Linux kernel for Apalis and Colibri modules</subtitle>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/'/>
<entry>
<title>Merge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi</title>
<updated>2026-11-18T19:21:30+00:00</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2026-11-18T19:21:30+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=27e694b84eca6c7fa0878662764567a3cc396fc2'/>
<id>27e694b84eca6c7fa0878662764567a3cc396fc2</id>
<content type='text'>
Pull SCSI fixes from James Bottomley:
 "Mostly driver fixes. The only core one is the bsg one to prevent
  copying of sense data after the task is cancelled (which could result
  in random memory writes from the kernel). ufs has the largest set of
  fixes, but they're also fairly mundane"

* tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: (21 commits)
  scsi: mpi3mr: Validate reply frame size bounds
  scsi: target: core: Parse APTPL res_type and res_scope as hex
  scsi: target: iscsi: Check for existing sessions only after authentication
  scsi: sd_zbc: Cap zone report count by buffer size
  scsi: rdac: Keep the error status when controller lookup fails
  scsi: target: Fix NULL pointer dereference in core_alua_do_port_transition()
  scsi: target: Fix NULL pointer dereference in target_dev_alua_lu_gp_store()
  scsi: ufs: qcom: Reprogram ESI after a host controller reset
  scsi: ufs: mcq: Poll OCS after sq cleanup for device management commands
  scsi: ufs: core: Skip ABORT TASK for device management commands
  scsi: leapraid: Fix init_cmd_priv error handling
  scsi: ufs: rockchip: Improve RX noise immunity
  scsi: ufs: hwmon, debugfs: Propagate runtime PM resume errors
  scsi: ufs: bsg: Abort ufs_bsg_request() when runtime resume fails
  scsi: ufs: sysfs: Propagate runtime PM resume errors
  scsi: ufs: core: Introduce ufshcd_rpm_resume_and_get() helper
  scsi: ufs: core: Restore jiffies conversion of device management timeouts
  scsi: target: iscsi: Fix hanging WRITE_PENDING commands
  scsi: Revert "scsi: target: iscsi: Fix hang for aborted WRITE_PENDING commands"
  scsi: ufs: core: Keep clock-gating hold on failed W-LUN runtime resume
  ...
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Pull SCSI fixes from James Bottomley:
 "Mostly driver fixes. The only core one is the bsg one to prevent
  copying of sense data after the task is cancelled (which could result
  in random memory writes from the kernel). ufs has the largest set of
  fixes, but they're also fairly mundane"

* tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: (21 commits)
  scsi: mpi3mr: Validate reply frame size bounds
  scsi: target: core: Parse APTPL res_type and res_scope as hex
  scsi: target: iscsi: Check for existing sessions only after authentication
  scsi: sd_zbc: Cap zone report count by buffer size
  scsi: rdac: Keep the error status when controller lookup fails
  scsi: target: Fix NULL pointer dereference in core_alua_do_port_transition()
  scsi: target: Fix NULL pointer dereference in target_dev_alua_lu_gp_store()
  scsi: ufs: qcom: Reprogram ESI after a host controller reset
  scsi: ufs: mcq: Poll OCS after sq cleanup for device management commands
  scsi: ufs: core: Skip ABORT TASK for device management commands
  scsi: leapraid: Fix init_cmd_priv error handling
  scsi: ufs: rockchip: Improve RX noise immunity
  scsi: ufs: hwmon, debugfs: Propagate runtime PM resume errors
  scsi: ufs: bsg: Abort ufs_bsg_request() when runtime resume fails
  scsi: ufs: sysfs: Propagate runtime PM resume errors
  scsi: ufs: core: Introduce ufshcd_rpm_resume_and_get() helper
  scsi: ufs: core: Restore jiffies conversion of device management timeouts
  scsi: target: iscsi: Fix hanging WRITE_PENDING commands
  scsi: Revert "scsi: target: iscsi: Fix hang for aborted WRITE_PENDING commands"
  scsi: ufs: core: Keep clock-gating hold on failed W-LUN runtime resume
  ...
</pre>
</div>
</content>
</entry>
<entry>
<title>scsi: ufs: mcq: Poll OCS after sq cleanup for device management commands</title>
<updated>2026-11-08T23:03:15+00:00</updated>
<author>
<name>Kiwoong Kim</name>
<email>kwmad.kim@samsung.com</email>
</author>
<published>2026-11-06T04:12:47+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=e510b597d8afca2e790e2b5429bc5e01e3386f65'/>
<id>e510b597d8afca2e790e2b5429bc5e01e3386f65</id>
<content type='text'>
Extend ufshcd_mcq_sq_cleanup() to poll the OCS field in the UTRD of a
device management command after a successful SQ_CUS poll. UFSHCI does not
specify the order between the OCS update and the SQ_CUS update, so OCS may
still be stale when cleanup returns. Without this poll, a late response to
a timed-out query can arrive while a retry is already in flight, leaving
the host controller with two query contexts and raising IS.UTPES.

Here is the timeline of an actual case I found with kernel 6.18:

1. The driver sent a query but the device didn't respond to it for a long
   time.

[ 7384.156142] [4:  kworker/u40:5:10671] exynos-ufs 38300000.ufs: ufshcd_mcq_sq_cleanup, hwq 0: cleanup return code (RTC) 0
[ 7384.156154] [4:  kworker/u40:5:10671] exynos-ufs 38300000.ufs: ufshcd_query_flag: Sending flag query for idn 14 failed, err = -11

2. So after the query timed out, the driver did SQ cleanup. Then the host
   controller updated the CQ tail and raised IS.CQES.  Unfortunately,
   complete() was called by the driver's ISR afterward.

3. The driver started to retry the query. In the meantime, it set OCS to
   0xF. Then the driver didn't wait for completion due to the previous
   complete() call, and just checked OCS.

[ 7384.156163] [4:  kworker/u40:5:10671] exynos-ufs 38300000.ufs: ufshcd_query_flag: Sending flag query for idn 14 failed, err = 15

4. The driver retried the query again, but the device didn't return
   anything, so the query also timed out.

[ 7385.660108] [3:  kworker/u40:5:10671] exynos-ufs 38300000.ufs: ufshcd_query_flag: Sending flag query for idn 14 failed, err = -11

5. A few seconds later, the device returned the response of the first
   query, but since the host controller was holding two query contexts and
   couldn't handle it, it raised IS.UTPES.

The same problem exists in the current code. If the query times out, the
SCSI error handler calls ufshcd_abort() -&gt; ufshcd_mcq_abort() -&gt;
ufshcd_mcq_sq_cleanup(), the request is finished, and the retry reuses the
same reserved tag, struct scsi_cmnd and devman UCD. A late CQE for the
first query then maps to the same tag and completes the retry by calling
scsi_done() too early. The retry then returns the OCS of the first query
and, if that OCS is OCS_SUCCESS, its response as well. Hence
ufshcd_mcq_sq_cleanup() must not return until the CQE of the cleaned-up
request has been processed.

The poll is limited to device management commands because
ufshcd_compl_one_cqe() copies the OCS from the CQE into the UTRD only for
them. For SCSI commands, the OCS in the UTRD stays
OCS_INVALID_COMMAND_STATUS, so polling it would always time out.

The poll waits until OCS is no longer OCS_INVALID_COMMAND_STATUS or
MCQ_POLL_US elapses. -ETIMEDOUT is returned only if OCS is still
OCS_INVALID_COMMAND_STATUS after the poll. Any other value, such as
OCS_ABORTED reported by the host controller for the cleaned-up request,
means the cleanup has completed.  The UFSHCI specification says "The host
controller shall free up any resources associated to the nexus, and shall
post a Completion Queue entry with OCS = ABORTED if clean up successful."

Each poll iteration reaps the CQ with ufshcd_mcq_poll_cqe_lock() before
reading the OCS, as ufshcd_clear_lu_cmds() does after ufshcd_clear_cmd().
This removes the dependency on interrupt delivery. Otherwise the OCS is
only updated once the interrupt handler processes the CQE, and a delayed or
lost interrupt would make the poll time out and escalate to a host reset
although the request has already been cleaned up.

The OCS is still read under hwq-&gt;cq_lock because the interrupt handler may
reap the CQE between the reap and the read. ufshcd_compl_one_cqe() updates
the OCS under that lock before it sets cmd-&gt;result and calls scsi_done().
Without the lock, cleanup could observe the new OCS and return while the
completion is still running. The abort could then finish the command and a
retry could reuse the same reserved request before the pending scsi_done()
call, which would then complete the retry prematurely.

Fixes: 8d7290348992 ("scsi: ufs: mcq: Add supporting functions for MCQ abort")
Signed-off-by: Kiwoong Kim &lt;kwmad.kim@samsung.com&gt;
Reviewed-by: Bart Van Assche &lt;bvanassche@acm.org&gt;
Reviewed-by: Bean Huo &lt;beanhuo@micron.com&gt;
Link: https://patch.msgid.link/a1af44cd90dca0dd8a9a06d09a254a4e7e0861b2.1793938245.git.kwmad.kim@samsung.com
Signed-off-by: Martin K. Petersen (Oracle) &lt;mkp@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Extend ufshcd_mcq_sq_cleanup() to poll the OCS field in the UTRD of a
device management command after a successful SQ_CUS poll. UFSHCI does not
specify the order between the OCS update and the SQ_CUS update, so OCS may
still be stale when cleanup returns. Without this poll, a late response to
a timed-out query can arrive while a retry is already in flight, leaving
the host controller with two query contexts and raising IS.UTPES.

Here is the timeline of an actual case I found with kernel 6.18:

1. The driver sent a query but the device didn't respond to it for a long
   time.

[ 7384.156142] [4:  kworker/u40:5:10671] exynos-ufs 38300000.ufs: ufshcd_mcq_sq_cleanup, hwq 0: cleanup return code (RTC) 0
[ 7384.156154] [4:  kworker/u40:5:10671] exynos-ufs 38300000.ufs: ufshcd_query_flag: Sending flag query for idn 14 failed, err = -11

2. So after the query timed out, the driver did SQ cleanup. Then the host
   controller updated the CQ tail and raised IS.CQES.  Unfortunately,
   complete() was called by the driver's ISR afterward.

3. The driver started to retry the query. In the meantime, it set OCS to
   0xF. Then the driver didn't wait for completion due to the previous
   complete() call, and just checked OCS.

[ 7384.156163] [4:  kworker/u40:5:10671] exynos-ufs 38300000.ufs: ufshcd_query_flag: Sending flag query for idn 14 failed, err = 15

4. The driver retried the query again, but the device didn't return
   anything, so the query also timed out.

[ 7385.660108] [3:  kworker/u40:5:10671] exynos-ufs 38300000.ufs: ufshcd_query_flag: Sending flag query for idn 14 failed, err = -11

5. A few seconds later, the device returned the response of the first
   query, but since the host controller was holding two query contexts and
   couldn't handle it, it raised IS.UTPES.

The same problem exists in the current code. If the query times out, the
SCSI error handler calls ufshcd_abort() -&gt; ufshcd_mcq_abort() -&gt;
ufshcd_mcq_sq_cleanup(), the request is finished, and the retry reuses the
same reserved tag, struct scsi_cmnd and devman UCD. A late CQE for the
first query then maps to the same tag and completes the retry by calling
scsi_done() too early. The retry then returns the OCS of the first query
and, if that OCS is OCS_SUCCESS, its response as well. Hence
ufshcd_mcq_sq_cleanup() must not return until the CQE of the cleaned-up
request has been processed.

The poll is limited to device management commands because
ufshcd_compl_one_cqe() copies the OCS from the CQE into the UTRD only for
them. For SCSI commands, the OCS in the UTRD stays
OCS_INVALID_COMMAND_STATUS, so polling it would always time out.

The poll waits until OCS is no longer OCS_INVALID_COMMAND_STATUS or
MCQ_POLL_US elapses. -ETIMEDOUT is returned only if OCS is still
OCS_INVALID_COMMAND_STATUS after the poll. Any other value, such as
OCS_ABORTED reported by the host controller for the cleaned-up request,
means the cleanup has completed.  The UFSHCI specification says "The host
controller shall free up any resources associated to the nexus, and shall
post a Completion Queue entry with OCS = ABORTED if clean up successful."

Each poll iteration reaps the CQ with ufshcd_mcq_poll_cqe_lock() before
reading the OCS, as ufshcd_clear_lu_cmds() does after ufshcd_clear_cmd().
This removes the dependency on interrupt delivery. Otherwise the OCS is
only updated once the interrupt handler processes the CQE, and a delayed or
lost interrupt would make the poll time out and escalate to a host reset
although the request has already been cleaned up.

The OCS is still read under hwq-&gt;cq_lock because the interrupt handler may
reap the CQE between the reap and the read. ufshcd_compl_one_cqe() updates
the OCS under that lock before it sets cmd-&gt;result and calls scsi_done().
Without the lock, cleanup could observe the new OCS and return while the
completion is still running. The abort could then finish the command and a
retry could reuse the same reserved request before the pending scsi_done()
call, which would then complete the retry prematurely.

Fixes: 8d7290348992 ("scsi: ufs: mcq: Add supporting functions for MCQ abort")
Signed-off-by: Kiwoong Kim &lt;kwmad.kim@samsung.com&gt;
Reviewed-by: Bart Van Assche &lt;bvanassche@acm.org&gt;
Reviewed-by: Bean Huo &lt;beanhuo@micron.com&gt;
Link: https://patch.msgid.link/a1af44cd90dca0dd8a9a06d09a254a4e7e0861b2.1793938245.git.kwmad.kim@samsung.com
Signed-off-by: Martin K. Petersen (Oracle) &lt;mkp@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>scsi: ufs: core: Skip ABORT TASK for device management commands</title>
<updated>2026-11-08T23:03:15+00:00</updated>
<author>
<name>Kiwoong Kim</name>
<email>kwmad.kim@samsung.com</email>
</author>
<published>2026-11-06T04:12:46+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=30bdadc9aa3a684cd634c7fa49740b1151e7b2e5'/>
<id>30bdadc9aa3a684cd634c7fa49740b1151e7b2e5</id>
<content type='text'>
In MCQ mode, ufshcd_mcq_abort() falls through to ufshcd_try_to_abort_task()
for all timed-out commands. However, device management commands (query,
NOP) use reserved requests and are not SCSI I/O commands.  The ABORT TASK
task management function is designed for SCSI I/O UPIUs and is not
applicable to device management UPIUs.

This is only reachable since device management commands were converted to
scsi_get_internal_cmd(); before that, a timed-out query was handled by
ufshcd_wait_for_dev_cmd() -&gt; ufshcd_clear_cmd() and never reached
ufshcd_try_to_abort_task().

Fix this by checking ufshcd_is_scsi_cmd() in ufshcd_try_to_abort_task().
For a reserved (device management) command, skip the TM path and call
ufshcd_clear_cmd() directly. ufshcd_abort() now calls
ufshcd_try_to_abort_task() for every request, so its separate
reserved-request branch is removed.

Fixes: 08b12cda6c44 ("scsi: ufs: core: Switch to scsi_get_internal_cmd()")
Reported-by: Bart Van Assche &lt;bvanassche@acm.org&gt;
Signed-off-by: Kiwoong Kim &lt;kwmad.kim@samsung.com&gt;
Reviewed-by: Bean Huo &lt;beanhuo@micron.com&gt;
Reviewed-by: Bart Van Assche &lt;bvanassche@acm.org&gt;
Link: https://patch.msgid.link/ab14d2f1414fa1a0a396f160abf8c27c404b4ec4.1793938245.git.kwmad.kim@samsung.com
Signed-off-by: Martin K. Petersen (Oracle) &lt;mkp@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
In MCQ mode, ufshcd_mcq_abort() falls through to ufshcd_try_to_abort_task()
for all timed-out commands. However, device management commands (query,
NOP) use reserved requests and are not SCSI I/O commands.  The ABORT TASK
task management function is designed for SCSI I/O UPIUs and is not
applicable to device management UPIUs.

This is only reachable since device management commands were converted to
scsi_get_internal_cmd(); before that, a timed-out query was handled by
ufshcd_wait_for_dev_cmd() -&gt; ufshcd_clear_cmd() and never reached
ufshcd_try_to_abort_task().

Fix this by checking ufshcd_is_scsi_cmd() in ufshcd_try_to_abort_task().
For a reserved (device management) command, skip the TM path and call
ufshcd_clear_cmd() directly. ufshcd_abort() now calls
ufshcd_try_to_abort_task() for every request, so its separate
reserved-request branch is removed.

Fixes: 08b12cda6c44 ("scsi: ufs: core: Switch to scsi_get_internal_cmd()")
Reported-by: Bart Van Assche &lt;bvanassche@acm.org&gt;
Signed-off-by: Kiwoong Kim &lt;kwmad.kim@samsung.com&gt;
Reviewed-by: Bean Huo &lt;beanhuo@micron.com&gt;
Reviewed-by: Bart Van Assche &lt;bvanassche@acm.org&gt;
Link: https://patch.msgid.link/ab14d2f1414fa1a0a396f160abf8c27c404b4ec4.1793938245.git.kwmad.kim@samsung.com
Signed-off-by: Martin K. Petersen (Oracle) &lt;mkp@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Merge tag 'devm_kmalloc_obj-v7.4-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux</title>
<updated>2026-11-08T22:55:54+00:00</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2026-11-08T22:55:54+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=e0d8e8de8bcb1ef7b749033b5af5518ba8df7bec'/>
<id>e0d8e8de8bcb1ef7b749033b5af5518ba8df7bec</id>
<content type='text'>
Pull devm_kmalloc_obj conversion from Kees Cook:

 - treewide refresh of kmalloc_obj() conversions

 - devm_kmalloc_obj conversion rules added to Coccinelle scripting

 - treewide conversion of devm_kmalloc() family to devm_kmalloc_obj()

* tag 'devm_kmalloc_obj-v7.4-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux:
  treewide: Convert devm_kmalloc() family to the devm_kmalloc_obj() family
  coccinelle: kmalloc_obj: Include devm_kmalloc_obj conversion rules
  treewide: refresh kmalloc_obj() conversions
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Pull devm_kmalloc_obj conversion from Kees Cook:

 - treewide refresh of kmalloc_obj() conversions

 - devm_kmalloc_obj conversion rules added to Coccinelle scripting

 - treewide conversion of devm_kmalloc() family to devm_kmalloc_obj()

* tag 'devm_kmalloc_obj-v7.4-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux:
  treewide: Convert devm_kmalloc() family to the devm_kmalloc_obj() family
  coccinelle: kmalloc_obj: Include devm_kmalloc_obj conversion rules
  treewide: refresh kmalloc_obj() conversions
</pre>
</div>
</content>
</entry>
<entry>
<title>treewide: Convert devm_kmalloc() family to the devm_kmalloc_obj() family</title>
<updated>2026-11-06T05:55:50+00:00</updated>
<author>
<name>Kees Cook</name>
<email>kees+treewide@kernel.org</email>
</author>
<published>2026-10-29T06:16:33+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=4dd10fbbeb9c33709edc89916e19c03c780a0751'/>
<id>4dd10fbbeb9c33709edc89916e19c03c780a0751</id>
<content type='text'>
Mirroring the earlier kmalloc_obj() conversion, convert the
device-managed allocators over to the type-based API using the now
updated scripts/coccinelle/api/kmalloc_objs.cocci. The size is derived
from the type rather than written out as a sizeof(), and the result is
a pointer to that type rather than void *, so a mismatch between the
size requested and the variable assigned becomes a build error instead
of being silently accepted.

The conversions break down as:

	6713	devm_kzalloc_obj()
	1749	devm_kzalloc_objs()
	 307	devm_kzalloc_flex()
	  91	devm_kmalloc_objs()
	  82	devm_kmalloc_obj()
	   2	devm_kmalloc_flex()

The rules deliberately leave alone allocations sized by a string or a
byte-sized type, or assigned to a pointer to a byte-sized type, since
those are byte buffers rather than objects. Allocations sized by a
multi-byte integer type are only converted when they are assigned to a
pointer to that same type, and allocations of pointers to integers or of
void pointers are left alone too. After this change, 528 files still
call devm_kmalloc(), devm_kzalloc(), devm_kcalloc(), or
devm_kmalloc_array().

Build tested with allmodconfig on x86_64, arm64, i386, arm, riscv, s390,
m68k, mips, parisc, sparc, loongarch, arc, xtensa, and openrisc with GCC
16.2.0 with no new warnings.

Signed-off-by: Kees Cook &lt;kees+treewide@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Mirroring the earlier kmalloc_obj() conversion, convert the
device-managed allocators over to the type-based API using the now
updated scripts/coccinelle/api/kmalloc_objs.cocci. The size is derived
from the type rather than written out as a sizeof(), and the result is
a pointer to that type rather than void *, so a mismatch between the
size requested and the variable assigned becomes a build error instead
of being silently accepted.

The conversions break down as:

	6713	devm_kzalloc_obj()
	1749	devm_kzalloc_objs()
	 307	devm_kzalloc_flex()
	  91	devm_kmalloc_objs()
	  82	devm_kmalloc_obj()
	   2	devm_kmalloc_flex()

The rules deliberately leave alone allocations sized by a string or a
byte-sized type, or assigned to a pointer to a byte-sized type, since
those are byte buffers rather than objects. Allocations sized by a
multi-byte integer type are only converted when they are assigned to a
pointer to that same type, and allocations of pointers to integers or of
void pointers are left alone too. After this change, 528 files still
call devm_kmalloc(), devm_kzalloc(), devm_kcalloc(), or
devm_kmalloc_array().

Build tested with allmodconfig on x86_64, arm64, i386, arm, riscv, s390,
m68k, mips, parisc, sparc, loongarch, arc, xtensa, and openrisc with GCC
16.2.0 with no new warnings.

Signed-off-by: Kees Cook &lt;kees+treewide@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>scsi: ufs: hwmon, debugfs: Propagate runtime PM resume errors</title>
<updated>2026-11-05T03:22:27+00:00</updated>
<author>
<name>Stanley Jhu</name>
<email>stanleyjhu@google.com</email>
</author>
<published>2026-10-29T07:08:40+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=9eb89611d95914e47cec62826e4000396df0f953'/>
<id>9eb89611d95914e47cec62826e4000396df0f953</id>
<content type='text'>
ufs_hwmon_read(), ufs_hwmon_write(), and ufs_debugfs_get_user_access()
resume the UFS device W-LUN with ufshcd_rpm_get_sync() and ignore its
return value. For example, for a hwmon temperature read:

 1. The W-LUN is runtime suspended.
 2. User space reads temp1_input of the UFS hwmon device.
 3. ufs_hwmon_read() calls ufshcd_rpm_get_sync().
 4. The W-LUN runtime resume fails and the W-LUN stays suspended.
 5. ufshcd_rpm_get_sync() returns a negative errno, which is ignored.
 6. ufs_hwmon_read() sends an attribute query UPIU while the W-LUN is
    still suspended.

ufs_hwmon_write() and the debugfs writers that use
ufs_debugfs_get_user_access() (exception_event_mask and tx_eq_ctrl) follow
the same sequence.

Convert all three call sites to ufshcd_rpm_resume_and_get() and release
hba-&gt;host_sem before returning the error, ahead of __acquire(ufs_debugfs)
in ufs_debugfs_get_user_access().

Fixes: b294ff3e3449 ("scsi: ufs: core: Enable power management for wlun")
Fixes: e88e2d32200a ("scsi: ufs: core: Probe for temperature notification support")
Fixes: adbabdcf0db0 ("scsi: ufs: core: Add support to retrain TX Equalization via debugfs")
Cc: stable@vger.kernel.org # needs "scsi: ufs: core: Introduce ufshcd_rpm_resume_and_get() helper"
Signed-off-by: Stanley Jhu &lt;stanleyjhu@google.com&gt;
Reviewed-by: Bart Van Assche &lt;bvanassche@acm.org&gt;
Reviewed-by: Peter Wang &lt;peter.wang@mediatek.com&gt;
Link: https://patch.msgid.link/20261029040003.2100003-6-stanleyjhu@google.com
Signed-off-by: Martin K. Petersen (Oracle) &lt;mkp@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
ufs_hwmon_read(), ufs_hwmon_write(), and ufs_debugfs_get_user_access()
resume the UFS device W-LUN with ufshcd_rpm_get_sync() and ignore its
return value. For example, for a hwmon temperature read:

 1. The W-LUN is runtime suspended.
 2. User space reads temp1_input of the UFS hwmon device.
 3. ufs_hwmon_read() calls ufshcd_rpm_get_sync().
 4. The W-LUN runtime resume fails and the W-LUN stays suspended.
 5. ufshcd_rpm_get_sync() returns a negative errno, which is ignored.
 6. ufs_hwmon_read() sends an attribute query UPIU while the W-LUN is
    still suspended.

ufs_hwmon_write() and the debugfs writers that use
ufs_debugfs_get_user_access() (exception_event_mask and tx_eq_ctrl) follow
the same sequence.

Convert all three call sites to ufshcd_rpm_resume_and_get() and release
hba-&gt;host_sem before returning the error, ahead of __acquire(ufs_debugfs)
in ufs_debugfs_get_user_access().

Fixes: b294ff3e3449 ("scsi: ufs: core: Enable power management for wlun")
Fixes: e88e2d32200a ("scsi: ufs: core: Probe for temperature notification support")
Fixes: adbabdcf0db0 ("scsi: ufs: core: Add support to retrain TX Equalization via debugfs")
Cc: stable@vger.kernel.org # needs "scsi: ufs: core: Introduce ufshcd_rpm_resume_and_get() helper"
Signed-off-by: Stanley Jhu &lt;stanleyjhu@google.com&gt;
Reviewed-by: Bart Van Assche &lt;bvanassche@acm.org&gt;
Reviewed-by: Peter Wang &lt;peter.wang@mediatek.com&gt;
Link: https://patch.msgid.link/20261029040003.2100003-6-stanleyjhu@google.com
Signed-off-by: Martin K. Petersen (Oracle) &lt;mkp@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>scsi: ufs: bsg: Abort ufs_bsg_request() when runtime resume fails</title>
<updated>2026-11-05T03:22:27+00:00</updated>
<author>
<name>Stanley Jhu</name>
<email>stanleyjhu@google.com</email>
</author>
<published>2026-10-29T07:08:39+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=2b8541edf7c43f0294c45d2e687bbc1288292f4e'/>
<id>2b8541edf7c43f0294c45d2e687bbc1288292f4e</id>
<content type='text'>
ufs_bsg_request() resumes the UFS device W-LUN with ufshcd_rpm_get_sync()
and ignores its return value:

 1. The W-LUN is runtime suspended.
 2. User space submits a BSG request.
 3. ufs_bsg_request() calls ufshcd_rpm_get_sync().
 4. The W-LUN runtime resume fails and the W-LUN stays suspended.
 5. ufshcd_rpm_get_sync() returns a negative errno, which is ignored.
 6. ufs_bsg_request() dispatches the BSG command while the W-LUN is
    still suspended.

Use ufshcd_rpm_resume_and_get() and jump to out_complete on error so the
BSG job is completed via bsg_job_done() with the failure code without
dropping an unacquired runtime PM reference.

Fixes: b294ff3e3449 ("scsi: ufs: core: Enable power management for wlun")
Cc: stable@vger.kernel.org # needs "scsi: ufs: core: Introduce ufshcd_rpm_resume_and_get() helper"
Signed-off-by: Stanley Jhu &lt;stanleyjhu@google.com&gt;
Reviewed-by: Bart Van Assche &lt;bvanassche@acm.org&gt;
Reviewed-by: Peter Wang &lt;peter.wang@mediatek.com&gt;
Link: https://patch.msgid.link/20261029040003.2100003-5-stanleyjhu@google.com
Signed-off-by: Martin K. Petersen (Oracle) &lt;mkp@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
ufs_bsg_request() resumes the UFS device W-LUN with ufshcd_rpm_get_sync()
and ignores its return value:

 1. The W-LUN is runtime suspended.
 2. User space submits a BSG request.
 3. ufs_bsg_request() calls ufshcd_rpm_get_sync().
 4. The W-LUN runtime resume fails and the W-LUN stays suspended.
 5. ufshcd_rpm_get_sync() returns a negative errno, which is ignored.
 6. ufs_bsg_request() dispatches the BSG command while the W-LUN is
    still suspended.

Use ufshcd_rpm_resume_and_get() and jump to out_complete on error so the
BSG job is completed via bsg_job_done() with the failure code without
dropping an unacquired runtime PM reference.

Fixes: b294ff3e3449 ("scsi: ufs: core: Enable power management for wlun")
Cc: stable@vger.kernel.org # needs "scsi: ufs: core: Introduce ufshcd_rpm_resume_and_get() helper"
Signed-off-by: Stanley Jhu &lt;stanleyjhu@google.com&gt;
Reviewed-by: Bart Van Assche &lt;bvanassche@acm.org&gt;
Reviewed-by: Peter Wang &lt;peter.wang@mediatek.com&gt;
Link: https://patch.msgid.link/20261029040003.2100003-5-stanleyjhu@google.com
Signed-off-by: Martin K. Petersen (Oracle) &lt;mkp@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>scsi: ufs: sysfs: Propagate runtime PM resume errors</title>
<updated>2026-11-05T03:22:27+00:00</updated>
<author>
<name>Stanley Jhu</name>
<email>stanleyjhu@google.com</email>
</author>
<published>2026-10-29T07:08:38+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=93891d1c486efcef2267c32e6e73ca2fd243704e'/>
<id>93891d1c486efcef2267c32e6e73ca2fd243704e</id>
<content type='text'>
All 14 ufshcd_rpm_get_sync() callers in ufs-sysfs.c resume the UFS device
W-LUN and ignore the return value. For example, for a UFS descriptor read:

 1. The W-LUN is runtime suspended.
 2. User space reads a UFS descriptor attribute in sysfs.
 3. ufs_sysfs_read_desc_param() calls ufshcd_rpm_get_sync().
 4. The W-LUN runtime resume fails and the W-LUN stays suspended.
 5. ufshcd_rpm_get_sync() returns a negative errno, which is ignored.
 6. ufs_sysfs_read_desc_param() sends a query UPIU while the W-LUN is
    still suspended.

The other sysfs callers follow the same sequence. They send other query
UPIUs, or read a host register in ufshcd_read_hci_reg().

Switch all 14 sysfs callers to ufshcd_rpm_resume_and_get() and return the
error after releasing any held buffer and hba-&gt;host_sem.

Fixes: aef80fd1da32 ("scsi: ufs: sysfs: Resume the proper SCSI device")
Fixes: b9d104465a6c ("scsi: ufs: Prepare to add HCI capabilities sysfs")
Fixes: 600edc6620a4 ("scsi: ufs: sysfs: Make max_number_of_rtt read-write")
Fixes: 6c4148ce7cc1 ("scsi: ufs: wb: Add explicit flush sysfs attribute")
Fixes: 500d4b742e0c ("scsi: ufs: core: Add WB buffer resize support")
Fixes: ae7795a8c258 ("scsi: ufs: core: Add HID support")
Fixes: 1fd2e77b8897 ("scsi: ufs: core: Add device level exception support")
Cc: stable@vger.kernel.org # needs "scsi: ufs: core: Introduce ufshcd_rpm_resume_and_get() helper"
Signed-off-by: Stanley Jhu &lt;stanleyjhu@google.com&gt;
Reviewed-by: Bart Van Assche &lt;bvanassche@acm.org&gt;
Reviewed-by: Peter Wang &lt;peter.wang@mediatek.com&gt;
Link: https://patch.msgid.link/20261029040003.2100003-4-stanleyjhu@google.com
Signed-off-by: Martin K. Petersen (Oracle) &lt;mkp@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
All 14 ufshcd_rpm_get_sync() callers in ufs-sysfs.c resume the UFS device
W-LUN and ignore the return value. For example, for a UFS descriptor read:

 1. The W-LUN is runtime suspended.
 2. User space reads a UFS descriptor attribute in sysfs.
 3. ufs_sysfs_read_desc_param() calls ufshcd_rpm_get_sync().
 4. The W-LUN runtime resume fails and the W-LUN stays suspended.
 5. ufshcd_rpm_get_sync() returns a negative errno, which is ignored.
 6. ufs_sysfs_read_desc_param() sends a query UPIU while the W-LUN is
    still suspended.

The other sysfs callers follow the same sequence. They send other query
UPIUs, or read a host register in ufshcd_read_hci_reg().

Switch all 14 sysfs callers to ufshcd_rpm_resume_and_get() and return the
error after releasing any held buffer and hba-&gt;host_sem.

Fixes: aef80fd1da32 ("scsi: ufs: sysfs: Resume the proper SCSI device")
Fixes: b9d104465a6c ("scsi: ufs: Prepare to add HCI capabilities sysfs")
Fixes: 600edc6620a4 ("scsi: ufs: sysfs: Make max_number_of_rtt read-write")
Fixes: 6c4148ce7cc1 ("scsi: ufs: wb: Add explicit flush sysfs attribute")
Fixes: 500d4b742e0c ("scsi: ufs: core: Add WB buffer resize support")
Fixes: ae7795a8c258 ("scsi: ufs: core: Add HID support")
Fixes: 1fd2e77b8897 ("scsi: ufs: core: Add device level exception support")
Cc: stable@vger.kernel.org # needs "scsi: ufs: core: Introduce ufshcd_rpm_resume_and_get() helper"
Signed-off-by: Stanley Jhu &lt;stanleyjhu@google.com&gt;
Reviewed-by: Bart Van Assche &lt;bvanassche@acm.org&gt;
Reviewed-by: Peter Wang &lt;peter.wang@mediatek.com&gt;
Link: https://patch.msgid.link/20261029040003.2100003-4-stanleyjhu@google.com
Signed-off-by: Martin K. Petersen (Oracle) &lt;mkp@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>scsi: ufs: core: Introduce ufshcd_rpm_resume_and_get() helper</title>
<updated>2026-11-05T03:22:27+00:00</updated>
<author>
<name>Stanley Jhu</name>
<email>stanleyjhu@google.com</email>
</author>
<published>2026-10-29T07:08:37+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=cbab12e5b4a7f49d5add4301de275351269cd431'/>
<id>cbab12e5b4a7f49d5add4301de275351269cd431</id>
<content type='text'>
ufshcd_clkscale_enable_store() and ufshcd_auto_hibern8_update() resume the
UFS device W-LUN with ufshcd_rpm_get_sync() and ignore its return value.

For clkscale_enable:

 1. The W-LUN is runtime suspended and clock scaling is disabled.
 2. User space writes 1 to clkscale_enable.
 3. ufshcd_clkscale_enable_store() calls ufshcd_rpm_get_sync().
 4. The W-LUN runtime resume fails and the W-LUN stays suspended.
 5. ufshcd_rpm_get_sync() returns a negative errno, which is ignored.
 6. ufshcd_clkscale_enable_store() enables clock scaling and resumes
    devfreq while the W-LUN is still suspended.

For auto_hibern8:

 1. The W-LUN starts a runtime suspend.
 2. User space writes a new value to auto_hibern8.
 3. ufshcd_auto_hibern8_update() sees that the W-LUN is not yet
    suspended and calls ufshcd_rpm_get_sync().
 4. ufshcd_rpm_get_sync() waits for the runtime suspend to finish and
    then runs the W-LUN runtime resume.
 5. The W-LUN runtime resume fails and the W-LUN stays suspended.
 6. ufshcd_rpm_get_sync() returns a negative errno, which is ignored.
 7. ufshcd_auto_hibern8_update() writes REG_AUTO_HIBERNATE_IDLE_TIMER
    while the W-LUN is still suspended.

Add ufshcd_rpm_resume_and_get() wrapping pm_runtime_resume_and_get() so
failed resumes drop the usage reference automatically, and return early in
ufshcd_clkscale_enable_store() and ufshcd_auto_hibern8_update() when it
fails.

Fixes: b294ff3e3449 ("scsi: ufs: core: Enable power management for wlun")
Cc: stable@vger.kernel.org
Signed-off-by: Stanley Jhu &lt;stanleyjhu@google.com&gt;
Reviewed-by: Bart Van Assche &lt;bvanassche@acm.org&gt;
Reviewed-by: Peter Wang &lt;peter.wang@mediatek.com&gt;
Link: https://patch.msgid.link/20261029040003.2100003-3-stanleyjhu@google.com
Signed-off-by: Martin K. Petersen (Oracle) &lt;mkp@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
ufshcd_clkscale_enable_store() and ufshcd_auto_hibern8_update() resume the
UFS device W-LUN with ufshcd_rpm_get_sync() and ignore its return value.

For clkscale_enable:

 1. The W-LUN is runtime suspended and clock scaling is disabled.
 2. User space writes 1 to clkscale_enable.
 3. ufshcd_clkscale_enable_store() calls ufshcd_rpm_get_sync().
 4. The W-LUN runtime resume fails and the W-LUN stays suspended.
 5. ufshcd_rpm_get_sync() returns a negative errno, which is ignored.
 6. ufshcd_clkscale_enable_store() enables clock scaling and resumes
    devfreq while the W-LUN is still suspended.

For auto_hibern8:

 1. The W-LUN starts a runtime suspend.
 2. User space writes a new value to auto_hibern8.
 3. ufshcd_auto_hibern8_update() sees that the W-LUN is not yet
    suspended and calls ufshcd_rpm_get_sync().
 4. ufshcd_rpm_get_sync() waits for the runtime suspend to finish and
    then runs the W-LUN runtime resume.
 5. The W-LUN runtime resume fails and the W-LUN stays suspended.
 6. ufshcd_rpm_get_sync() returns a negative errno, which is ignored.
 7. ufshcd_auto_hibern8_update() writes REG_AUTO_HIBERNATE_IDLE_TIMER
    while the W-LUN is still suspended.

Add ufshcd_rpm_resume_and_get() wrapping pm_runtime_resume_and_get() so
failed resumes drop the usage reference automatically, and return early in
ufshcd_clkscale_enable_store() and ufshcd_auto_hibern8_update() when it
fails.

Fixes: b294ff3e3449 ("scsi: ufs: core: Enable power management for wlun")
Cc: stable@vger.kernel.org
Signed-off-by: Stanley Jhu &lt;stanleyjhu@google.com&gt;
Reviewed-by: Bart Van Assche &lt;bvanassche@acm.org&gt;
Reviewed-by: Peter Wang &lt;peter.wang@mediatek.com&gt;
Link: https://patch.msgid.link/20261029040003.2100003-3-stanleyjhu@google.com
Signed-off-by: Martin K. Petersen (Oracle) &lt;mkp@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>scsi: ufs: core: Restore jiffies conversion of device management timeouts</title>
<updated>2026-11-05T03:22:27+00:00</updated>
<author>
<name>Stanley Jhu</name>
<email>stanleyjhu@google.com</email>
</author>
<published>2026-10-29T07:08:36+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=ebf5cab0dd223a36a09742a91be4fea97e46c816'/>
<id>ebf5cab0dd223a36a09742a91be4fea97e46c816</id>
<content type='text'>
Before commit 08b12cda6c44 ("scsi: ufs: core: Switch to
scsi_get_internal_cmd()"), ufshcd_wait_for_dev_cmd() converted the
millisecond timeout with msecs_to_jiffies() before waiting for the
command. That commit moved the timeout to the block layer and assigns the
millisecond value to rq-&gt;timeout as is, but rq-&gt;timeout is in jiffies. A
1500 ms query timeout (QUERY_REQ_TIMEOUT_DEFAULT) becomes 6 s with
CONFIG_HZ=250 and 15 s with CONFIG_HZ=100, and NOP_OUT_TIMEOUT and
ADVANCED_RPMB_REQ_TIMEOUT grow the same way.

Restore the conversion with msecs_to_jiffies().

Fixes: 08b12cda6c44 ("scsi: ufs: core: Switch to scsi_get_internal_cmd()")
Cc: stable@vger.kernel.org # v6.19+
Signed-off-by: Stanley Jhu &lt;stanleyjhu@google.com&gt;
Reviewed-by: Bart Van Assche &lt;bvanassche@acm.org&gt;
Reviewed-by: Peter Wang &lt;peter.wang@mediatek.com&gt;
Link: https://patch.msgid.link/20261029040003.2100003-2-stanleyjhu@google.com
Signed-off-by: Martin K. Petersen (Oracle) &lt;mkp@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Before commit 08b12cda6c44 ("scsi: ufs: core: Switch to
scsi_get_internal_cmd()"), ufshcd_wait_for_dev_cmd() converted the
millisecond timeout with msecs_to_jiffies() before waiting for the
command. That commit moved the timeout to the block layer and assigns the
millisecond value to rq-&gt;timeout as is, but rq-&gt;timeout is in jiffies. A
1500 ms query timeout (QUERY_REQ_TIMEOUT_DEFAULT) becomes 6 s with
CONFIG_HZ=250 and 15 s with CONFIG_HZ=100, and NOP_OUT_TIMEOUT and
ADVANCED_RPMB_REQ_TIMEOUT grow the same way.

Restore the conversion with msecs_to_jiffies().

Fixes: 08b12cda6c44 ("scsi: ufs: core: Switch to scsi_get_internal_cmd()")
Cc: stable@vger.kernel.org # v6.19+
Signed-off-by: Stanley Jhu &lt;stanleyjhu@google.com&gt;
Reviewed-by: Bart Van Assche &lt;bvanassche@acm.org&gt;
Reviewed-by: Peter Wang &lt;peter.wang@mediatek.com&gt;
Link: https://patch.msgid.link/20261029040003.2100003-2-stanleyjhu@google.com
Signed-off-by: Martin K. Petersen (Oracle) &lt;mkp@kernel.org&gt;
</pre>
</div>
</content>
</entry>
</feed>
