* [PATCH v2] scsi: ufs: docs: Describe how to test with QEMU
@ 2026-10-12 12:00 Stanley Jhu
2026-10-12 12:05 ` Bean Huo
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Stanley Jhu @ 2026-10-12 12:00 UTC (permalink / raw)
To: Martin K. Petersen, James E.J. Bottomley, Jonathan Corbet
Cc: Bart Van Assche, Alim Akhtar, Shuah Khan, Randy Dunlap, Jeuk Kim,
Bean Huo, linux-scsi, linux-doc, linux-kernel
QEMU emulates a UFS host controller and logical units, but the kernel
tree does not mention it, so developers without UFS hardware have no
documented way to exercise the UFS core.
Add a short section with the required kernel options, an example QEMU
command line, and what the emulation does not cover.
Signed-off-by: Stanley Jhu <stanleyjhu@google.com>
---
Changes in v2:
- State the minimum QEMU versions for ufs and mcq=on (Bean Huo)
- Mark /dev/sda as an example (Bean Huo)
- Say the emulation accepts but does not model the link startup,
hibernate, DME and power mode UIC commands, and that DME and power
mode need QEMU 11.1 (Bean Huo)
v1: https://lore.kernel.org/all/20261011103319.820657-1-stanleyjhu@google.com/
Documentation/scsi/ufs.rst | 38 ++++++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+)
diff --git a/Documentation/scsi/ufs.rst b/Documentation/scsi/ufs.rst
index a7b2b2ed1c3a..06f1b9b4e8dd 100644
--- a/Documentation/scsi/ufs.rst
+++ b/Documentation/scsi/ufs.rst
@@ -19,6 +19,7 @@ Universal Flash Storage
3.4 SCSI Error handling
4. BSG Support
5. UFS Reference Clock Frequency configuration
+ 6. Testing with QEMU
1. Overview
@@ -208,3 +209,40 @@ the UFS specification. UFS subsystem will attempt to read the value when
executing common controller initialization. If the value is available, UFS
subsystem will ensure the bRefClkFreq attribute of the UFS storage device is
set accordingly and will modify it if there is a mismatch.
+
+6. Testing with QEMU
+====================
+
+QEMU emulates a UFS host controller as a PCI device named "ufs" and
+logical units named "ufs-lu". This can be used to test changes to the
+UFS core and to ufshcd-pci without UFS hardware.
+
+The "ufs" and "ufs-lu" devices are available since QEMU 8.2, and the
+"mcq" property since QEMU 9.1.
+
+Enable the following kernel options on top of the architecture
+defconfig::
+
+ CONFIG_SCSI_UFSHCD=y
+ CONFIG_SCSI_UFSHCD_PCI=y
+ CONFIG_BLK_DEV_SD=y
+
+Example for an arm64 guest with one 1 GiB logical unit::
+
+ qemu-img create -f raw ufs.img 1G
+ qemu-system-aarch64 -M virt -cpu max -smp 4 -m 2G -nographic \
+ -kernel arch/arm64/boot/Image -initrd rootfs.cpio.gz \
+ -append "console=ttyAMA0" \
+ -drive file=ufs.img,if=none,id=lu0,format=raw \
+ -device ufs,id=ufs0,serial=0001,mcq=on \
+ -device ufs-lu,drive=lu0,bus=ufs0,lun=0
+
+The logical unit appears as a SCSI disk (for example /dev/sda). Drop
+"mcq=on" to test the single doorbell mode instead of MCQ. The same
+-device options work with qemu-system-x86_64.
+
+The emulation accepts the link startup and hibernate enter/exit UIC
+commands and, since QEMU 11.1, DME get/set and the power mode change
+sequence, but it does not model UniPro, M-PHY or the resulting link
+state. Clock gating hardware and vendor host drivers are not exercised
+either. Changes in those areas still need testing on real hardware.
--
2.56.0.385.gd3acb90ef8-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH v2] scsi: ufs: docs: Describe how to test with QEMU
2026-10-12 12:00 [PATCH v2] scsi: ufs: docs: Describe how to test with QEMU Stanley Jhu
@ 2026-10-12 12:05 ` Bean Huo
2026-10-12 12:08 ` Stanley Jhu
2026-10-14 2:58 ` Martin K. Petersen
2 siblings, 0 replies; 4+ messages in thread
From: Bean Huo @ 2026-10-12 12:05 UTC (permalink / raw)
To: Stanley Jhu, Martin K. Petersen, James E.J. Bottomley,
Jonathan Corbet
Cc: Bart Van Assche, Alim Akhtar, Shuah Khan, Randy Dunlap, Jeuk Kim,
linux-scsi, linux-doc, linux-kernel
On Mon, 2026-10-12 at 20:00 +0800, Stanley Jhu wrote:
> +QEMU emulates a UFS host controller as a PCI device named "ufs" and
> +logical units named "ufs-lu". This can be used to test changes to the
> +UFS core and to ufshcd-pci without UFS hardware.
> +
> +The "ufs" and "ufs-lu" devices are available since QEMU 8.2, and the
> +"mcq" property since QEMU 9.1.
Thanks for v2. The 8.2 and 9.1 versions match the QEMU history.
Reviewed-by: Bean Huo <beanhuo@micron.com>
thanks,
Bean
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] scsi: ufs: docs: Describe how to test with QEMU
2026-10-12 12:00 [PATCH v2] scsi: ufs: docs: Describe how to test with QEMU Stanley Jhu
2026-10-12 12:05 ` Bean Huo
@ 2026-10-12 12:08 ` Stanley Jhu
2026-10-14 2:58 ` Martin K. Petersen
2 siblings, 0 replies; 4+ messages in thread
From: Stanley Jhu @ 2026-10-12 12:08 UTC (permalink / raw)
To: Martin K. Petersen, James E.J. Bottomley, Jonathan Corbet
Cc: Bart Van Assche, Alim Akhtar, Shuah Khan, Randy Dunlap, Jeuk Kim,
Bean Huo, linux-scsi, linux-doc, linux-kernel
I missed Alim's tag on v1 [1] when sending v2. The v2 changes are
wording fixes only, so carrying it over:
Reviewed-by: Alim Akhtar <alim.akhtar@samsung.com>
[1] https://lore.kernel.org/all/000001dd5a07$2fb3b400$8f1b1c00$@samsung.com/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] scsi: ufs: docs: Describe how to test with QEMU
2026-10-12 12:00 [PATCH v2] scsi: ufs: docs: Describe how to test with QEMU Stanley Jhu
2026-10-12 12:05 ` Bean Huo
2026-10-12 12:08 ` Stanley Jhu
@ 2026-10-14 2:58 ` Martin K. Petersen
2 siblings, 0 replies; 4+ messages in thread
From: Martin K. Petersen @ 2026-10-14 2:58 UTC (permalink / raw)
To: Stanley Jhu
Cc: Martin K. Petersen, James E.J. Bottomley, Jonathan Corbet,
Bart Van Assche, Alim Akhtar, Shuah Khan, Randy Dunlap, Jeuk Kim,
Bean Huo, linux-scsi, linux-doc, linux-kernel
Stanley,
> QEMU emulates a UFS host controller and logical units, but the kernel
> tree does not mention it, so developers without UFS hardware have no
> documented way to exercise the UFS core.
Applied to 7.4/scsi-staging, thanks!
--
Martin K. Petersen
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-10-14 2:58 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-12 12:00 [PATCH v2] scsi: ufs: docs: Describe how to test with QEMU Stanley Jhu
2026-10-12 12:05 ` Bean Huo
2026-10-12 12:08 ` Stanley Jhu
2026-10-14 2:58 ` Martin K. Petersen
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.