[PATCH v8 0/4] hw/ufs: Add Universal Flash Storage (UFS) support

Jeuk Kim posted 4 patches 9 months, 1 week ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/cover.1690446561.git.jeuk20.kim@samsung.com
Maintainers: "Michael S. Tsirkin" <mst@redhat.com>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, Paolo Bonzini <pbonzini@redhat.com>, Jeuk Kim <jeuk20.kim@samsung.com>, Kevin Wolf <kwolf@redhat.com>, Hanna Reitz <hreitz@redhat.com>, Fam Zheng <fam@euphon.net>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, "Daniel P. Berrangé" <berrange@redhat.com>, Thomas Huth <thuth@redhat.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Laurent Vivier <lvivier@redhat.com>
There is a newer version of this series
MAINTAINERS              |    7 +
docs/specs/pci-ids.rst   |    2 +
hw/Kconfig               |    1 +
hw/meson.build           |    1 +
hw/ufs/Kconfig           |    4 +
hw/ufs/lu.c              | 1445 ++++++++++++++++++++++++++++++++++++
hw/ufs/meson.build       |    1 +
hw/ufs/trace-events      |   58 ++
hw/ufs/trace.h           |    1 +
hw/ufs/ufs.c             | 1494 ++++++++++++++++++++++++++++++++++++++
hw/ufs/ufs.h             |  131 ++++
include/block/ufs.h      | 1090 +++++++++++++++++++++++++++
include/hw/pci/pci.h     |    1 +
include/hw/pci/pci_ids.h |    1 +
include/scsi/constants.h |    1 +
meson.build              |    1 +
tests/qtest/meson.build  |    1 +
tests/qtest/ufs-test.c   |  573 +++++++++++++++
18 files changed, 4813 insertions(+)
create mode 100644 hw/ufs/Kconfig
create mode 100644 hw/ufs/lu.c
create mode 100644 hw/ufs/meson.build
create mode 100644 hw/ufs/trace-events
create mode 100644 hw/ufs/trace.h
create mode 100644 hw/ufs/ufs.c
create mode 100644 hw/ufs/ufs.h
create mode 100644 include/block/ufs.h
create mode 100644 tests/qtest/ufs-test.c
[PATCH v8 0/4] hw/ufs: Add Universal Flash Storage (UFS) support
Posted by Jeuk Kim 9 months, 1 week ago
Since v7:
In ufs-test.c, make the following changes
- Change TIMEOUT from 5 to 10 (Thomas's review comment)
- Rename the temporary file to "qemu-ufs.XXXX" (Thomas's review comment)
- Use "-blockdev" instead of "-drive" (Stefan's review comment)

Since v6:
- Add tests/qtest/ufs-test.c to test ufs initialisation and I/O
- Add struct UtpTaskReqDesc to include/block/ufs.h
- Fix ufs_log2() logic
- Fix ufs-lu to use 4K as default block size to match the ufs spec

Since I created a new file, tests/qtest/ufs-test.c, I added Laurent Vivier to the cc list.
Thank you.

Since v5:
- Fix to print an error message instead of a segmentation fault
  when no drive property is specified for a ufs-lu device

Since v4:
Addressed review comment from Stefan Hajnoczi. The fixes are as
follows.
- Keep u->reg fields in host endian (Removed little-endian helper 
  functions from MemoryRegionOps)
- Remove unnecessary NULL checks for g_new and g_malloc0
- Replace DEFINE_PROP_DRIVE_IOTHREAD -> DEFINE_PROP_DRIVE

In case you were wondering, ufs and ufs-lu have been tested for the
following behaviours.
1. Checked ufs device recognition in Windows10 environment
2. Verified ufs device recognition in Ubuntu 22.04 environment
3. Verified io behaviour via fio in Ubuntu 22.04 environment
4. Verified query request via ufs-tools in Ubuntu 22.04 environment

Since v3:
- Replace softmmu_ss -> system_ss in meson

Since v2:
Addressed review comment from Stefan Hajnoczi. The main fixes are as
follows.
- Use of SPDX licence identifiers
- fixed endianness error
- removed memory leak
- fixed DMA error handling logic

Since v1:
- use macros of "hw/registerfields.h" (Addressed Philippe's review
  comments)

This patch series adds support for a new PCI-based UFS device.

The UFS pci device id (PCI_DEVICE_ID_REDHAT_UFS) is not registered
in the Linux kernel yet, so it does not work right away, but I confirmed
that it works with Linux when the UFS pci device id is registered.

I have also verified that it works with Windows 10.

Jeuk Kim (4):
  hw/ufs: Initial commit for emulated Universal-Flash-Storage
  hw/ufs: Support for Query Transfer Requests
  hw/ufs: Support for UFS logical unit
  tests/qtest: Introduce tests for UFS

 MAINTAINERS              |    7 +
 docs/specs/pci-ids.rst   |    2 +
 hw/Kconfig               |    1 +
 hw/meson.build           |    1 +
 hw/ufs/Kconfig           |    4 +
 hw/ufs/lu.c              | 1445 ++++++++++++++++++++++++++++++++++++
 hw/ufs/meson.build       |    1 +
 hw/ufs/trace-events      |   58 ++
 hw/ufs/trace.h           |    1 +
 hw/ufs/ufs.c             | 1494 ++++++++++++++++++++++++++++++++++++++
 hw/ufs/ufs.h             |  131 ++++
 include/block/ufs.h      | 1090 +++++++++++++++++++++++++++
 include/hw/pci/pci.h     |    1 +
 include/hw/pci/pci_ids.h |    1 +
 include/scsi/constants.h |    1 +
 meson.build              |    1 +
 tests/qtest/meson.build  |    1 +
 tests/qtest/ufs-test.c   |  573 +++++++++++++++
 18 files changed, 4813 insertions(+)
 create mode 100644 hw/ufs/Kconfig
 create mode 100644 hw/ufs/lu.c
 create mode 100644 hw/ufs/meson.build
 create mode 100644 hw/ufs/trace-events
 create mode 100644 hw/ufs/trace.h
 create mode 100644 hw/ufs/ufs.c
 create mode 100644 hw/ufs/ufs.h
 create mode 100644 include/block/ufs.h
 create mode 100644 tests/qtest/ufs-test.c

-- 
2.34.1
Re: [PATCH v8 0/4] hw/ufs: Add Universal Flash Storage (UFS) support
Posted by Stefan Hajnoczi 9 months, 1 week ago
On Thu, Jul 27, 2023 at 05:45:17PM +0900, Jeuk Kim wrote:
> Since v7:
> In ufs-test.c, make the following changes
> - Change TIMEOUT from 5 to 10 (Thomas's review comment)
> - Rename the temporary file to "qemu-ufs.XXXX" (Thomas's review comment)
> - Use "-blockdev" instead of "-drive" (Stefan's review comment)
> 
> Since v6:
> - Add tests/qtest/ufs-test.c to test ufs initialisation and I/O
> - Add struct UtpTaskReqDesc to include/block/ufs.h
> - Fix ufs_log2() logic
> - Fix ufs-lu to use 4K as default block size to match the ufs spec
> 
> Since I created a new file, tests/qtest/ufs-test.c, I added Laurent Vivier to the cc list.
> Thank you.
> 
> Since v5:
> - Fix to print an error message instead of a segmentation fault
>   when no drive property is specified for a ufs-lu device
> 
> Since v4:
> Addressed review comment from Stefan Hajnoczi. The fixes are as
> follows.
> - Keep u->reg fields in host endian (Removed little-endian helper 
>   functions from MemoryRegionOps)
> - Remove unnecessary NULL checks for g_new and g_malloc0
> - Replace DEFINE_PROP_DRIVE_IOTHREAD -> DEFINE_PROP_DRIVE
> 
> In case you were wondering, ufs and ufs-lu have been tested for the
> following behaviours.
> 1. Checked ufs device recognition in Windows10 environment
> 2. Verified ufs device recognition in Ubuntu 22.04 environment
> 3. Verified io behaviour via fio in Ubuntu 22.04 environment
> 4. Verified query request via ufs-tools in Ubuntu 22.04 environment
> 
> Since v3:
> - Replace softmmu_ss -> system_ss in meson
> 
> Since v2:
> Addressed review comment from Stefan Hajnoczi. The main fixes are as
> follows.
> - Use of SPDX licence identifiers
> - fixed endianness error
> - removed memory leak
> - fixed DMA error handling logic
> 
> Since v1:
> - use macros of "hw/registerfields.h" (Addressed Philippe's review
>   comments)
> 
> This patch series adds support for a new PCI-based UFS device.
> 
> The UFS pci device id (PCI_DEVICE_ID_REDHAT_UFS) is not registered
> in the Linux kernel yet, so it does not work right away, but I confirmed
> that it works with Linux when the UFS pci device id is registered.
> 
> I have also verified that it works with Windows 10.
> 
> Jeuk Kim (4):
>   hw/ufs: Initial commit for emulated Universal-Flash-Storage
>   hw/ufs: Support for Query Transfer Requests
>   hw/ufs: Support for UFS logical unit
>   tests/qtest: Introduce tests for UFS

Thank you!

QEMU is currently in freeze for the 8.1 release. I have merged your
patches on my block-next branch. I will send the pull request when
qemu.git/master opens again after freeze around August 15th or 22nd (see
https://wiki.qemu.org/Planning/8.1).

You are the maintainer for hw/ufs/ so you can send pull requests in the
future. Please continue to send your own patches to qemu-devel to give
others in the community an opportunity to review them. If no one reviews
your patches, then I think it's fair to include them in your own pull
requests after a week. There is a diagram of the development model here:
https://wiki.qemu.org/Contribute/DevelopmentProcess

Please also read the documentation about maintainers:
https://gitlab.com/qemu-project/qemu/-/blob/master/docs/devel/maintainers.rst

If you'd rather not send pull requests yourself, you can CC me on UFS
patches that you'd like to have merged and I'll include them in my block
tree pull requests.

Thanks,
Stefan
Re: [PATCH v8 0/4] hw/ufs: Add Universal Flash Storage (UFS) support
Posted by Stefan Hajnoczi 9 months, 1 week ago
On Thu, Jul 27, 2023 at 05:45:17PM +0900, Jeuk Kim wrote:
> Since v7:
> In ufs-test.c, make the following changes
> - Change TIMEOUT from 5 to 10 (Thomas's review comment)
> - Rename the temporary file to "qemu-ufs.XXXX" (Thomas's review comment)
> - Use "-blockdev" instead of "-drive" (Stefan's review comment)
> 
> Since v6:
> - Add tests/qtest/ufs-test.c to test ufs initialisation and I/O
> - Add struct UtpTaskReqDesc to include/block/ufs.h
> - Fix ufs_log2() logic
> - Fix ufs-lu to use 4K as default block size to match the ufs spec
> 
> Since I created a new file, tests/qtest/ufs-test.c, I added Laurent Vivier to the cc list.
> Thank you.
> 
> Since v5:
> - Fix to print an error message instead of a segmentation fault
>   when no drive property is specified for a ufs-lu device
> 
> Since v4:
> Addressed review comment from Stefan Hajnoczi. The fixes are as
> follows.
> - Keep u->reg fields in host endian (Removed little-endian helper 
>   functions from MemoryRegionOps)
> - Remove unnecessary NULL checks for g_new and g_malloc0
> - Replace DEFINE_PROP_DRIVE_IOTHREAD -> DEFINE_PROP_DRIVE
> 
> In case you were wondering, ufs and ufs-lu have been tested for the
> following behaviours.
> 1. Checked ufs device recognition in Windows10 environment
> 2. Verified ufs device recognition in Ubuntu 22.04 environment
> 3. Verified io behaviour via fio in Ubuntu 22.04 environment
> 4. Verified query request via ufs-tools in Ubuntu 22.04 environment
> 
> Since v3:
> - Replace softmmu_ss -> system_ss in meson
> 
> Since v2:
> Addressed review comment from Stefan Hajnoczi. The main fixes are as
> follows.
> - Use of SPDX licence identifiers
> - fixed endianness error
> - removed memory leak
> - fixed DMA error handling logic
> 
> Since v1:
> - use macros of "hw/registerfields.h" (Addressed Philippe's review
>   comments)
> 
> This patch series adds support for a new PCI-based UFS device.
> 
> The UFS pci device id (PCI_DEVICE_ID_REDHAT_UFS) is not registered
> in the Linux kernel yet, so it does not work right away, but I confirmed
> that it works with Linux when the UFS pci device id is registered.
> 
> I have also verified that it works with Windows 10.
> 
> Jeuk Kim (4):
>   hw/ufs: Initial commit for emulated Universal-Flash-Storage
>   hw/ufs: Support for Query Transfer Requests
>   hw/ufs: Support for UFS logical unit
>   tests/qtest: Introduce tests for UFS
> 
>  MAINTAINERS              |    7 +
>  docs/specs/pci-ids.rst   |    2 +
>  hw/Kconfig               |    1 +
>  hw/meson.build           |    1 +
>  hw/ufs/Kconfig           |    4 +
>  hw/ufs/lu.c              | 1445 ++++++++++++++++++++++++++++++++++++
>  hw/ufs/meson.build       |    1 +
>  hw/ufs/trace-events      |   58 ++
>  hw/ufs/trace.h           |    1 +
>  hw/ufs/ufs.c             | 1494 ++++++++++++++++++++++++++++++++++++++
>  hw/ufs/ufs.h             |  131 ++++
>  include/block/ufs.h      | 1090 +++++++++++++++++++++++++++
>  include/hw/pci/pci.h     |    1 +
>  include/hw/pci/pci_ids.h |    1 +
>  include/scsi/constants.h |    1 +
>  meson.build              |    1 +
>  tests/qtest/meson.build  |    1 +
>  tests/qtest/ufs-test.c   |  573 +++++++++++++++
>  18 files changed, 4813 insertions(+)
>  create mode 100644 hw/ufs/Kconfig
>  create mode 100644 hw/ufs/lu.c
>  create mode 100644 hw/ufs/meson.build
>  create mode 100644 hw/ufs/trace-events
>  create mode 100644 hw/ufs/trace.h
>  create mode 100644 hw/ufs/ufs.c
>  create mode 100644 hw/ufs/ufs.h
>  create mode 100644 include/block/ufs.h
>  create mode 100644 tests/qtest/ufs-test.c
> 
> -- 
> 2.34.1
> 

Thanks, applied to my block-next tree:
https://gitlab.com/stefanha/qemu/commits/block-next

Stefan