CV-Bowen opened a new pull request, #21871:
URL: https://github.com/apache/nuttx/pull/21871
## Summary
#21861 added the VirtIO SPI frontend, but NuttX has no device side for
it, so one NuttX instance cannot serve its SPI bus to another over
rptun.
- drivers/vhost: add the vhost (device-side) SPI backend
- Device id 45. When an rptun resource table exposes a VirtIO SPI
device in the device role, the driver opens the local SPI device
node named in the device config space (`struct vhost_spi_config_s`,
e.g. "/dev/spi0"), decodes each request in the Linux-compatible
VirtIO SPI wire format and runs it with `SPIIOC_TRANSFER`, on a
work queue. This is the same path-based binding as the in-tree
vhost-i2c.
## Impact
- New Kconfig `DRIVERS_VHOST_SPI` (depends on `SPI && SPI_EXCHANGE`),
default n.
- No change unless enabled.
## Testing
Host: Ubuntu 22.04.5 LTS x86_64, QEMU version 10.2.1, sim: cc (Ubuntu
13.1.0-8ubuntu1~22.04) 13.1.0, qemu-armv8a: aarch64-none-elf-gcc (Arm GNU
Toolchain 12.2.Rel1 (Build arm-12.24)) 12.2.1 20221205
End to end over the rptun ivshmem transport: qemu-armv8a:rpserver runs
the VirtIO SPI frontend (#21861), qemu-armv8a:rpproxy runs this backend
and forwards to a simulated M25P SPI flash (`drivers/spi/spi_flash.c`)
registered as /dev/spi0.
The resource-table entry for the SPI vdev and the test bus are not in
this PR: the rptun_ivshmem entries for i2c/spi/gpio come in a separate
rptun PR, and the /dev/spi0 test bus was a local board patch.
Overlay on both: `CONFIG_SPI`, `CONFIG_SPI_EXCHANGE`,
`CONFIG_SPI_DRIVER`, `CONFIG_SYSTEM_SPITOOL`; rpserver adds
`CONFIG_DRIVERS_VIRTIO_SPI`, rpproxy adds `CONFIG_DRIVERS_VHOST_SPI`,
`CONFIG_SPI_FLASH`, `CONFIG_SPI_FLASH_M25P`.
On the server, through virtio-spi -> rptun -> vhost-spi -> /dev/spi0:
| | without this backend | with it |
|---|---|---|
| `spi exch -b 0 -x 4 9f000000` (JEDEC ID) | no SPI vdev in the table, no
bus 0: `-b: argument invalid` | `FF 20 20 11` (M25P ID) |
| write enable, page program, read back | - | written bytes read back |
<details><summary>JEDEC ID</summary>
```
spi exch -b 0 -x 4 9f000000
Sending: 9F 00 00 00
Received: FF 20 20 11
```
</details>
<details><summary>write and read back</summary>
```
spi exch -b 0 -x 1 06
Sending: 06
Received: FF
server> spi exch -b 0 -x 8 0200001011a5c35a
Sending: 02 00 00 10 11 A5 C3 5A
Received: FF FF FF FF FF FF FF FF
server> spi exch -b 0 -x 8 0300001000000000
Sending: 03 00 00 10 00 00 00 00
Received: FF FF FF FF 11 A5 C3 5A
```
</details>
<details><summary>without the backend (the table entry is gated by
CONFIG_DRIVERS_VHOST_SPI)</summary>
```
spi exch -b 0 -x 4 9f000000
spitool: -b: argument invalid
```
</details>
Builds with 0 warnings on qemu-armv8a:rpproxy with the overlay above.
No regression in rpmsg: sim:rpserver/rpproxy and
qemu-armv8a:rpserver/rpproxy boot and pass the fixed rpmsg cases (dump, ping,
rpmsgfs; 15/15). qemu-armv8a was built with LIBC_ENVPATH and BINFMT_CHECKEXEC
disabled, which current master needs for nxinit to start nsh there; unrelated
to this change.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]