CV-Bowen opened a new pull request, #21872:
URL: https://github.com/apache/nuttx/pull/21872

   ## Summary
   
   #21861 added the VirtIO GPIO frontend, but NuttX has no device side for
   it, so one NuttX instance cannot serve its GPIO lines to another over
   rptun.
   
   - drivers/vhost: add the vhost (device-side) GPIO backend
     - Device id 41. When an rptun resource table exposes a VirtIO GPIO
       device in the device role, the driver forwards line requests
       (get/set direction, get/set value, set IRQ type) from the request
       virtqueue to a local ioexpander, and with `IOEXPANDER_INT_ENABLE` offers
       `VIRTIO_GPIO_F_IRQ` and reports local pin interrupts on the event
       virtqueue.
     - The ioexpander comes from `vhost_gpio_get_ioe(bus)`, implemented by
       the board, with the bus index taken from the device config space
       (`struct vhost_gpio_config_s`).
   
   ## Impact
   
   - New Kconfig `DRIVERS_VHOST_GPIO` (depends on `IOEXPANDER`),
     default n.
   - New board hook `vhost_gpio_get_ioe()` in `include/nuttx/vhost/vhost.h`;
     a board that enables `DRIVERS_VHOST_GPIO` must provide it.
   - 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 GPIO frontend (#21861) and exposes lines 0 and 1 through
   `gpio_lower_half()` as /dev/gpio0 (output) and /dev/gpio1 (input);
   qemu-armv8a:rpproxy runs this backend, with `vhost_gpio_get_ioe(0)`
   returning `ioe_dummy`.
   
   The GPIO entry in the rptun ivshmem resource table and both board hooks
   were a local test patch; the table entries come in a separate rptun PR.
   Overlay on both: `CONFIG_IOEXPANDER`, `CONFIG_IOEXPANDER_DUMMY`
   (selects `IOEXPANDER_INT_ENABLE`, so the event queue is set up),
   `CONFIG_DEV_GPIO`; rpserver adds `CONFIG_DRIVERS_VIRTIO_GPIO`,
   `CONFIG_GPIO_LOWER_HALF`, `CONFIG_EXAMPLES_GPIO`; rpproxy adds
   `CONFIG_DRIVERS_VHOST_GPIO`.
   
   On the server, through virtio-gpio -> rptun -> vhost-gpio -> ioe_dummy:
   
   <details><summary>gpio write/verify and read</summary>
   
   ```
   server> gpio -o 1 /dev/gpio0
   
   Driver: /dev/gpio0
   
     Output pin:    Value=0
   
     Writing:       Value=1
   
     Verify:        Value=1
   
   server> gpio -o 0 /dev/gpio0
   
   Driver: /dev/gpio0
   
     Output pin:    Value=1
   
     Writing:       Value=0
   
     Verify:        Value=0
   
   server> gpio /dev/gpio1
   
   Driver: /dev/gpio1
   
     Input pin:     Value=0
   
   server> 
   ```
   </details>
   
   <details><summary>virtio dump on the server: the request queue completed 
every request (no IRQ line was requested, so the event queue stayed 
idle)</summary>
   
   ```
     [GPIO] id=41 vdev=0x4047cf18 driver=0x40461e40 priv=0x404ab198
   
   VQ: virtio_gpio_event - size=32; free=32; queued=0; desc_head_idx=0; 
available_idx=0; avail.idx=0; used_cons_idx=0; used.idx=0; avail.flags=0x0; 
used.flags=0x0
   
   
   VQ: virtio_gpio_req - size=32; free=32; queued=0; desc_head_idx=0; 
available_idx=0; avail.idx=5; used_cons_idx=5; used.idx=5; avail.flags=0x0; 
used.flags=0x0
   
   
   ```
   </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]

Reply via email to