virtio_blk: Limit use of indirect descriptors

Pass 0 as the number of indirect descriptors when they are not
supported.

This fixes an issue on the Arm FVP model where we don't negotiate
them, however pass a number of segments greater than
VIRTIO_MAX_INDIRECT. This leads to virtqueue_alloc failing and
virtio_blk failing to attach.

Reviewed by:	Harry Moulton <harry.moulton@arm.com>
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D50909
This commit is contained in:
Andrew Turner 2025-06-23 13:27:10 +01:00
parent 0a5b763d98
commit cbc2e34613

View file

@ -699,10 +699,14 @@ vtblk_alloc_virtqueue(struct vtblk_softc *sc)
{
device_t dev;
struct vq_alloc_info vq_info;
int indir_segs;
dev = sc->vtblk_dev;
VQ_ALLOC_INFO_INIT(&vq_info, sc->vtblk_max_nsegs,
indir_segs = 0;
if (sc->vtblk_flags & VTBLK_FLAG_INDIRECT)
indir_segs = sc->vtblk_max_nsegs;
VQ_ALLOC_INFO_INIT(&vq_info, indir_segs,
vtblk_vq_intr, sc, &sc->vtblk_vq,
"%s request", device_get_nameunit(dev));