NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: kern/58049: vioif(4) panics if the virtq size is too small



> On Mar 18, 2024, at 6:00 AM, isaki%pastel-flower.jp@localhost wrote:
> 
> How about the attached patch?  It works to me.

This looks mostly fine but I have one question...

> --- src/sys/dev/pci/if_vioif.c
> +++ src/sys/dev/pci/if_vioif.c
> @@ -1993,6 +1993,8 @@ vioif_send_common_locked(struct ifnet *ifp, struct vioif_netqueue *netq,
> 
> for (;;) {
> int slot, r;
> + bool need_defrag;
> +
> r = virtio_enqueue_prep(vsc, vq, &slot);
> if (r == EAGAIN) {
> txc->txc_no_free_slots = true;
> @@ -2014,8 +2016,17 @@ vioif_send_common_locked(struct ifnet *ifp, struct vioif_netqueue *netq,
> map = &netq->netq_maps[slot];
> KASSERT(map->vnm_mbuf == NULL);
> 
> + need_defrag = false;
> r = vioif_net_load_mbuf(vsc, map, m, BUS_DMA_WRITE);
> if (r != 0) {
> + need_defrag = true;
> + } else if (map->vnm_mbuf_map->dm_nsegs >= vq->vq_maxnsegs) {
> + /* loaded but too many segments for VirtQ */

When the DMA map is created, do we not yet know the max number of segments?  Or is the problem that different queues might have different segment counts and the DMA maps are shared between them?  In a perfect world, this extra test isn't needed because the bus_dma back-end honors the device's maximum segment count.

-- thorpej



Home | Main Index | Thread Index | Old Index