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
The following reply was made to PR kern/58049; it has been noted by GNATS.
From: Jason Thorpe <thorpej%me.com@localhost>
To: Tetsuya Isaki <isaki%pastel-flower.jp@localhost>
Cc: kern-bug-people%netbsd.org@localhost,
gnats-admin%netbsd.org@localhost,
netbsd-bugs%netbsd.org@localhost,
gnats-bugs%netbsd.org@localhost
Subject: Re: kern/58049: vioif(4) panics if the virtq size is too small
Date: Mon, 18 Mar 2024 08:51:45 -0700
> On Mar 18, 2024, at 6:00 AM, isaki%pastel-flower.jp@localhost wrote:
>=20
> 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,
>=20
> for (;;) {
> int slot, r;
> + bool need_defrag;
> +
> r =3D virtio_enqueue_prep(vsc, vq, &slot);
> if (r =3D=3D EAGAIN) {
> txc->txc_no_free_slots =3D true;
> @@ -2014,8 +2016,17 @@ vioif_send_common_locked(struct ifnet *ifp, =
struct vioif_netqueue *netq,
> map =3D &netq->netq_maps[slot];
> KASSERT(map->vnm_mbuf =3D=3D NULL);
>=20
> + need_defrag =3D false;
> r =3D vioif_net_load_mbuf(vsc, map, m, BUS_DMA_WRITE);
> if (r !=3D 0) {
> + need_defrag =3D true;
> + } else if (map->vnm_mbuf_map->dm_nsegs >=3D 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