Universal Flash Storage (UFS) is a flash-based mobile storage device that provides high performance, low power, and high reliability compared to eMMC. Unlike eMMC, which uses a parallel bus, UFS uses a high-speed, multi-lane serial bus to improve performance. The serial interface of UFS uses LVDS differential signaling, which enables high-speed signal transmission with high noise immunity and low voltage. UFS follows the UFS specification of the JEDEC standard, which is currently up to version 4.0. Fuchsia's UFS driver is based on the UFS specification version 3.1.
UFS: https://www.jedec.org/document_search?search_api_views_fulltext=jesd220f UFSHCI: https://www.jedec.org/standards-documents/docs/jesd223e
The layered architecture of UFS uses the M-PHY physical layer and the UniPro link layer, with the UFS Transfer Protocol (UTP) transport layer on top. It also adopts a SCSI architecture model and command protocol that supports multiple simultaneous commands and command queues on top of the UTP transport layer. The layered architecture of UFS consists of three layers: UFS Application Layer(UAP), UFS Transport Protocol Layer (UTP), and UFS InterConnect Layer (UIC). The UFS driver is implemented according to this layered architecture.
The UAP layer consists of the UFS Command Set Layer (UCS), Device Manager, and Task Manager.
UTP layer uses UFS Protocol Information Unit (UPIU) for message delivery between UAP layer and UFS Interconnect (UIC) layer. The UTP layer wraps information from the UAP layer in a UPIU and delivers it to the UFS device.
The lowest layer, the UIC layer, handles the connection between the UFS host interface and the UFS device. The UIC layer automatically detects and recovers I/O errors through the UniPro link layer, and provides reliable data transfer through the M-PHY physical layer.
$ fx set core.x64 --with //src/devices/block/drivers/ufs:tests
$ fx test ufs-unit-tests
Currently, the only device that supports a PCI-based UFS host controller is the Samsung Galaxy Book S(NT767XCL) with an Intel Lakefield CPU(i5-L16G7). The Galaxy Book S has 512GB of eUFS 3.0 storage. Fuchsia has not been ported to the Galaxy Book S yet, so we are running Fuchsia on QEMU (which works on the Galaxy Book S) as an alternative. We are using KVM I/O Passthrough to bind a real UFS device (eUFS) to QEMU Fuchsia.
------------------------ | Fushsia + UFS driver | |--------------| : | | QEMU | : | |--------------| : ---- I/O Passthrough | Linux | : | |--------------| : | | Galaxy Book S + eUFS | ------------------------
To use eUFS I/O passthrough, you need to proceed as follows
dmesg | grep DMAR
.GRUB_CMDLINE_LINUX_DEFAULT="quiet splash intel_iommu=on iommu=pt"
sudo update-grub
$ cat /sys/bus/pci/devices/0000:00:12.5/vendor 0x8086 $ cat /sys/bus/pci/devices/0000:00:12.5/device 0x98fa
$ ls /sys/bus/pci/drivers/ufshcd 0000:00:12.5 bind module new_id remove_id uevent unbind
$ echo 0000:00:12.5 | sudo tee /sys/bus/pci/drivers/ufshcd/unbind 0000:00:12.5 $ echo 8086 98fa | sudo tee /sys/bus/pci/drivers/vfio-pci/new_id 8086 98fa
sudo fx qemu -N -k -m 4096 -- -device vfio-pci,host=00:12.5,x-no-kvm-intx=on