On 18 Jun 2026, at 09:05, Andrew Turner <[email protected]> wrote: > > The branch main has been updated by andrew: > > URL: > https://cgit.FreeBSD.org/src/commit/?id=ea130fa32099ea7e0c03702efdec28e745ea6ef1 > > commit ea130fa32099ea7e0c03702efdec28e745ea6ef1 > Author: Sarah Walker <[email protected]> > AuthorDate: 2026-02-27 14:17:15 +0000 > Commit: Andrew Turner <[email protected]> > CommitDate: 2026-06-18 16:04:24 +0000 > > virtio_net: Use bus_dma for command/ack buffers > > 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. > > Reviewed by: andrew > Sponsored by: Arm Ltd > Differential Revision: https://reviews.freebsd.org/D55564 > —-- > [...] > @@ -523,14 +523,60 @@ vtnet_attach(device_t dev) > goto fail; > } > > + mtx_init(&sc->vtnet_hdr_mtx, device_get_nameunit(dev), > + "VirtIO Net header lock", MTX_DEF); > + > + error = bus_dma_tag_create( > + bus_get_dma_tag(dev), /* parent */ > + sizeof(uint16_t), /* alignment */ > + 0, /* boundary */ > + BUS_SPACE_MAXADDR, /* lowaddr */ > + BUS_SPACE_MAXADDR, /* highaddr */ > + NULL, NULL, /* filter, filterarg */ > + PAGE_SIZE, /* max request size */ > + 1, /* max # segments */ > + PAGE_SIZE, /* maxsegsize */ > + BUS_DMA_COHERENT, /* flags */ > + busdma_lock_mutex, /* lockfunc */ > + &sc->vtnet_hdr_mtx, /* lockarg */ > + &sc->vtnet_hdr_dmat); > + if (error) { > + device_printf(dev, "cannot create bus_dma_tag\n"); > + goto fail; > + } > + > + mtx_init(&sc->vtnet_ack_mtx, device_get_nameunit(dev), > + "VirtIO Net ACK lock", MTX_DEF); > + > + error = bus_dma_tag_create( > + bus_get_dma_tag(dev), /* parent */ > + sizeof(uint8_t), /* alignment */ > + 0, /* boundary */ > + BUS_SPACE_MAXADDR, /* lowaddr */ > + BUS_SPACE_MAXADDR, /* highaddr */ > + NULL, NULL, /* filter, filterarg */ > + sizeof(uint8_t), /* max request size */ > + 1, /* max # segments */ > + sizeof(uint8_t), /* maxsegsize */ > + BUS_DMA_COHERENT, /* flags */ > + busdma_lock_mutex, /* lockfunc */ > + &sc->vtnet_ack_mtx, /* lockarg */ > + &sc->vtnet_ack_dmat); > + if (error) { > + device_printf(dev, "cannot create bus_dma_tag\n"); > + goto fail; > + } > + > #ifdef __powerpc__ > - /* > - * Virtio uses physical addresses rather than bus addresses, so we > - * need to ask busdma to skip the iommu physical->bus mapping. At > - * present, this is only a thing on the powerpc architectures. > - */ > - bus_dma_tag_set_iommu(sc->vtnet_rx_dmat, NULL, NULL); > - bus_dma_tag_set_iommu(sc->vtnet_tx_dmat, NULL, NULL); > + /* > + * Virtio uses physical addresses rather than bus addresses, so we > + * need to ask busdma to skip the iommu physical->bus mapping. At > + * present, this is only a thing on the powerpc architectures. > + */ > + bus_dma_tag_set_iommu(sc->vtnet_rx_dmat, NULL, NULL); > + bus_dma_tag_set_iommu(sc->vtnet_tx_dmat, NULL, NULL); > + bus_dma_tag_set_iommu(sc->vtnet_hdr_dmat, NULL, NULL); > + bus_dma_tag_set_iommu(sc->vtnet_ack_dmat, NULL, NULL); > #endif
This block has been re-indented to use spaces not tabs. Jessica
