Page MenuHomeFreeBSD

virtio_net: Use bus_dma for command/ack buffers
ClosedPublic

Authored by sarah.walker2_arm.com on Feb 27 2026, 4:00 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, May 14, 1:28 PM
Unknown Object (File)
Thu, May 14, 4:48 AM
Unknown Object (File)
Thu, May 14, 3:37 AM
Unknown Object (File)
Thu, May 14, 12:46 AM
Unknown Object (File)
Wed, May 13, 5:36 PM
Unknown Object (File)
Mon, May 4, 4:35 PM
Unknown Object (File)
Mon, Apr 27, 2:21 PM
Unknown Object (File)
Mon, Apr 27, 1:53 PM

Details

Summary

While the majority of virtio platforms will be fully coherent, some may
require cache maintenance or other specific device memory handling (eg for
secure partitioning). Using bus_dma allows for these usecases.

The virtio buffers are marked as coherent; this should ensure that sync
calls are no-ops in the common cases.

Sponsored by: Arm Ltd

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

br added inline comments.
sys/dev/virtio/network/if_vtnet.c
531

is not it too large alignment? it panics somewhere in IOMMU code

Should the dma sync operations be BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD and BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE given virtio may read from & write to the buffer.

Change header tag alignment size.

I get this

panic: alignment failed: ctx 0xffffffd0010d0e80 start 0x20c000 offset 3ca align 0x4
cpuid = 0
time = 1772453498
KDB: stack backtrace:
db_trace_self() at db_trace_self
db_fetch_ksymtab() at db_fetch_ksymtab+0x142
kdb_backtrace() at kdb_backtrace+0x2c
vpanic() at vpanic+0x16e
panic() at panic+0x26
iommu_domain_fini() at iommu_domain_fini+0x36a
iommu_is_buswide_ctx() at iommu_is_buswide_ctx+0x806
bus_dmamap_load() at bus_dmamap_load+0x6e
vtmmio_attach() at vtmmio_attach+0x779c
vtmmio_attach() at vtmmio_attach+0x739a
vtmmio_attach() at vtmmio_attach+0x65b2
vtmmio_attach() at vtmmio_attach+0x574a
ether_ioctl() at ether_ioctl+0x1a0
vtmmio_attach() at vtmmio_attach+0x593a
in_control_ioctl() at in_control_ioctl+0x9ac
rtnl_ifaces_destroy() at rtnl_ifaces_destroy+0x1a1e
rtnl_register_messages() at rtnl_register_messages+0x2a0
nl_send() at nl_send+0x3ca
nl_taskqueue_handler() at nl_taskqueue_handler+0x34e
taskqueue_run() at taskqueue_run+0x1f0
taskqueue_thread_loop() at taskqueue_thread_loop+0xd4
fork_exit() at fork_exit+0x68
fork_trampoline() at fork_trampoline+0xa
KDB: enter: panic
[ thread pid 0 tid 100062 ]
Stopped at      kdb_enter+0x3a: sd      zero,-948(s1)
db>
This revision is now accepted and ready to land.Mon, Apr 27, 10:52 AM