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

   ## Summary
   
   virtio-snd fixes for buffer accounting and SMP:
   
   - report AUDIO_CALLBACK_UNDERRUN when a completed buffer shows less than
     one period of latency
   - protect cache_buffers with the driver lock (updated from send and
     notify paths, read by AUDIOIOC_GETLATENCY)
   - limit the period count to what fits in the virtqueue, and use two
     descriptors per period instead of three
   - finish using a buffer before handing it back with
     AUDIO_CALLBACK_DEQUEUE, which may free it on another CPU
   - call the upper half without holding the driver lock; it can enqueue
     the next buffer from the callback and take the lock again
   - only report formats that map to an AUDIO_SUBFMT, and add U8
   - allocate buffers with kumm in protected builds; fix an error log that
     named the wrong driver
   
   The first commit only fixes existing nxstyle errors in virtio-snd.c.
   
   ## Impact
   
   virtio-snd only. AUDIOIOC_GETBUFFERINFO now returns the period count
   actually used, which can be smaller than
   CONFIG_DRIVERS_VIRTIO_SND_BUFFER_COUNT on small virtqueues.
   
   ## 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
   
   Playback through QEMU's virtio-sound into a wav file, nxplayer
   `playraw /dev/zero 2 16 48000` on `/dev/audio/pcm0p`, then `stop`:
   
   ```
   qemu-system-aarch64 -cpu cortex-a53 -nographic \
     -machine virt,virtualization=on,gic-version=3 \
     -global virtio-mmio.force-legacy=false \
     -audiodev wav,id=snd0,path=out.wav \
     -device virtio-sound-device,audiodev=snd0,bus=virtio-mmio-bus.0 \
     -kernel ./nuttx
   ```
   
   | config | played | audio in out.wav | result |
   |---|---|---|---|
   | `qemu-armv8a:netnsh` (1 CPU) | 5 s | 4.6 s, same as master | no assert; 
`free` after `quit` same as master |
   | `qemu-armv8a:netnsh_smp` (`-smp 4`) | 10 s | 9.2 s, same as master | no 
assert; `free` after `quit` same as master |
   
   <details><summary>nxplayer, -smp 4</summary>
   
   ```
   nsh> nxplayer
   NxPlayer version 1.05
   h for commands, q to exit
   nxplayer> device /dev/audio/pcm0p
   nxplayer> playraw /dev/zero 2 16 48000
   nxplayer> stop
   nxplayer> quit
   nsh> free
         total       used       free    maxused    maxfree  nused  nfree name
     129814528     225176  129589352     291376  129572720     91      7 Umem
   ```
   </details>
   
   The underrun callback and the buffer-count limit are not exercised by
   this setup (QEMU drains the queue steadily and the default virtqueue is
   large enough).
   
   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