virtio_blk: Fix initialisation of dump request structure

Commit c8c37141 ("virtio_blk: Use bus_dma for command/ack buffer
allocations") failed to update initialisation of the dedicated dump
request structure. This caused a panic on attempting to dump core to a
virtio_blk device.

Reviewed by:	asomers
Sponsored by:	Arm Ltd
Pull Request:	https://reviews.freebsd.org/D56156
This commit is contained in:
Sarah Walker
2026-04-09 11:52:05 +01:00
committed by Andrew Turner
parent aacf448007
commit f54209510b
+38 -24
View File
@@ -931,26 +931,8 @@ vtblk_hdr_load_callback(void *arg, bus_dma_segment_t *segs, int nsegs,
}
static int
vtblk_request_prealloc(struct vtblk_softc *sc)
vtblk_create_request(struct vtblk_softc *sc, struct vtblk_request *req)
{
struct vtblk_request *req;
int i, nreqs;
nreqs = virtqueue_size(sc->vtblk_vq);
/*
* Preallocate sufficient requests to keep the virtqueue full. Each
* request consumes VTBLK_MIN_SEGMENTS or more descriptors so reduce
* the number allocated when indirect descriptors are not available.
*/
if ((sc->vtblk_flags & VTBLK_FLAG_INDIRECT) == 0)
nreqs /= VTBLK_MIN_SEGMENTS;
for (i = 0; i < nreqs; i++) {
req = malloc(sizeof(struct vtblk_request), M_DEVBUF, M_NOWAIT);
if (req == NULL)
return (ENOMEM);
req->vbr_sc = sc;
if (bus_dmamap_create(sc->vtblk_dmat, 0, &req->vbr_mapp))
@@ -979,10 +961,6 @@ vtblk_request_prealloc(struct vtblk_softc *sc)
req, BUS_DMA_NOWAIT))
goto error_hdr_unload;
sc->vtblk_request_count++;
vtblk_request_enqueue(sc, req);
}
return (0);
error_hdr_unload:
@@ -994,11 +972,47 @@ vtblk_request_prealloc(struct vtblk_softc *sc)
error_destroy:
bus_dmamap_destroy(sc->vtblk_dmat, req->vbr_mapp);
error_free:
free(req, M_DEVBUF);
return (ENOMEM);
}
static int
vtblk_request_prealloc(struct vtblk_softc *sc)
{
struct vtblk_request *req;
int i, nreqs;
int error;
nreqs = virtqueue_size(sc->vtblk_vq);
/*
* Preallocate sufficient requests to keep the virtqueue full. Each
* request consumes VTBLK_MIN_SEGMENTS or more descriptors so reduce
* the number allocated when indirect descriptors are not available.
*/
if ((sc->vtblk_flags & VTBLK_FLAG_INDIRECT) == 0)
nreqs /= VTBLK_MIN_SEGMENTS;
for (i = 0; i < nreqs; i++) {
req = malloc(sizeof(struct vtblk_request), M_DEVBUF, M_NOWAIT);
if (req == NULL)
return (ENOMEM);
error = vtblk_create_request(sc, req);
if (error) {
free(req, M_DEVBUF);
return (error);
}
sc->vtblk_request_count++;
vtblk_request_enqueue(sc, req);
}
error = vtblk_create_request(sc, &sc->vtblk_dump_request);
return (error);
}
static void
vtblk_request_free(struct vtblk_softc *sc)
{