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

   ## Summary
   
   Fixes and small improvements in drivers/virtio, in commit order:
   
   - `drivers/virtio: use _emerg() instead of syslog(LOG_EMERG)`: the device
     dump functions, including virtio-i2c and virtio-spi.
   - `virtio/serial: use uart_spinlock to protect virtqueue and ring buffer`:
     `priv->lock` only guarded the virtqueue, so the uart ring buffer indices
     touched by the rxready/txdone callbacks were unprotected against the
     upper half on SMP. Use the (recursive) uart lock for both.
   - `drivers/virtio/virtio-input: name the tablet device in the dump`: it is
     reported as "unknown".
   - `drivers/virtio/virtio-rpmb: map the frames and answer EXT_CSD`: the
     ioctl treats every command as `MMC_IOC_MULTI_CMD`, sizes a stack array
     from the caller's `num_of_cmds` and hands the caller's buffers to the
     virtqueue unmapped. Dispatch on the command, accept 2 to 3 frames, map
     them with `virtio_map_buf()`, and answer `MMC_IOC_CMD` opcode 8 (EXT_CSD)
     from the capacity/max_wr_cnt in the config space.
   - `drivers/virtio: poll to unstick the serial TX ring from interrupt
     context`: `uart_write()` from interrupt/wdog context busy-waits with
     interrupts off, so the TX completion interrupt that would drain the ring
     never comes and the CPU deadlocks once the ring is full. Reap completions
     inline while waiting.
   - `drivers/virtio/virtio-net: leave room for the 802.1Q tag in the frame
     buffer`: with `CONFIG_NET_VLAN` a full-sized tagged frame is 4 bytes
     longer than `CONFIG_NET_ETH_PKTSIZE` and `virtio_net_send()` drops it with
     -EINVAL.
   
   ## Impact
   
   Driver internals only; no API, Kconfig or defconfig change. virtio-rpmb now
   rejects `MMC_IOC_MULTI_CMD` requests with fewer than 2 or more than 3
   frames, and other ioctls with -ENOTTY instead of misreading their argument.
   
   ## 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
   
   **virtio-rpmb.** `qemu-armv8a:rpserver` + `CONFIG_DRIVERS_VIRTIO_RPMB=y` and
   `qemu-armv8a:rpproxy` + `CONFIG_DRIVERS_VHOST_RPMB=y`, linked by
   rptun_ivshmem (its resource table already carries the RPMB vdev). Test-only,
   not in this PR: the proxy registers a fake `/dev/mmcsd0rpmb` that answers
   EXT_CSD (RPMB size 4, REL_WR_SEC_C 2) and turns a request frame into a
   GET_COUNTER response echoing the nonce with write_counter 0x1234; a
   program on the server reads EXT_CSD with `MMC_IOC_CMD` and sends a
   GET_WRITE_COUNTER frame with `MMC_IOC_MULTI_CMD`.
   
   | | EXT_CSD | GET_WRITE_COUNTER |
   |---|---|---|
   | master | the server hangs in the ioctl | ret 0, but resp 0x0000, counter 
0, nonce empty (the backend got an all-zero request) |
   | this PR | size=4 relwr=2 | resp=0x0200 counter=0x1234 nonce=P224NONCE |
   
   **VLAN.** Two `qemu-armv8a:netnsh` + `CONFIG_NET_VLAN=y
   CONFIG_NETDEV_PHY_IOCTL=y CONFIG_NET_LL_GUARDSIZE=36`, joined by a QEMU
   socket netdev:
   
   ```
   qemu-system-aarch64 -cpu cortex-a53 -nographic \
     -machine virt,virtualization=on,gic-version=3 -serial mon:stdio \
     -netdev socket,id=n0,listen=127.0.0.1:<port> \
     -device 
virtio-net-device,netdev=n0,bus=virtio-mmio-bus.0,mac=52:54:00:12:34:56 \
     -kernel nuttx
   # second instance: connect=127.0.0.1:<port>, mac=...:57
   
   nsh> vconfig add eth0 100
   nsh> ifconfig eth0.100 192.168.100.<1|2> netmask 255.255.255.0
   nsh> ifup eth0.100
   nsh> ping -c 3 -s <1400|1472> 192.168.100.1
   ```
   
   | | `-s 1400` | `-s 1472` (1518-byte tagged frame) |
   |---|---|---|
   | master | 3/3 | 0/3 |
   | this PR | 3/3 | 3/3 |
   
   **virtio-serial.** sim:rpserver (`/dev/ttyV0`, virtio-serial) +
   sim:rpproxy (vhost-serial). Test-only: the proxy's `/dev/ttyVH0` is a FIFO
   (`nx_mkfifo` in sim_bringup, sim UART disabled) so vhost-serial loops back
   what it receives; on the server `cat /dev/ttyV0 &` then
   `echo P224SERIAL<n> > /dev/ttyV0` twice. Both lines come back on master and
   at every commit of this PR. The interrupt-context deadlock fixed by the TX
   poll commit was not reproduced here.
   
   The tablet dump and the `_emerg()` change were build-checked only.
   
   **Baseline.** No regression in rpmsg: sim:rpserver/rpproxy and 
qemu-armv8a:rpserver/rpproxy boot and pass the fixed rpmsg cases (dump, ping, 
rpmsgfs; 15/15). No regression in virtio: qemu-armv8a:netnsh boot and pass the 
fixed virtio cases (rng, blk on mmio and pci, net, 9p; 24/24). 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. checkpatch 
passes.
   


-- 
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