Page MenuHomeFreeBSD

Reinitialize virtqueues
ClosedPublic

Authored by br on Jun 15 2018, 11:57 AM.
Tags
None
Referenced Files
Unknown Object (File)
Mar 12 2024, 4:14 PM
Unknown Object (File)
Jan 22 2024, 2:47 AM
Unknown Object (File)
Dec 19 2023, 8:55 PM
Unknown Object (File)
Dec 4 2023, 3:46 PM
Unknown Object (File)
Dec 1 2023, 6:49 PM
Unknown Object (File)
Nov 8 2023, 9:30 PM
Unknown Object (File)
Nov 7 2023, 10:43 AM
Unknown Object (File)
Oct 21 2023, 12:57 AM
Subscribers

Details

Summary

Reinitialize all the registers

This fixes vtnet operation with virtio-net-device of latest QEMU.

Test Plan

Tested with MMIO bus on FreeBSD/RISC-V:

qemu-system-riscv64 -machine virt -m 2048M -kernel bbl -nographic -netdev tap,ifname=tap0,script=no,id=net0 -device virtio-net-device,netdev=net0 -smp cpus=8

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

br edited the test plan for this revision. (Show Details)

Teardown virtqueues before RESET in virtio PCI bus driver as well

I don't follow why qemu clearing "pointers" means that we realloc the virtqueues in the guest. The host virtqueue state is reinitialized as part of the reinit process. Also, what do you believe has "recently" changed in qemu's virtio_reset? The blame shows very little changes in the last several years.

I didn't write the MMIO driver and am not as familiar the spec, but perhaps your issue is because vtmmio_reinit_virtqueue() does not replicate all the steps that vtmmio_alloc_virtqueues() perform. Namely, it is missing

		vtmmio_write_config_4(sc, VIRTIO_MMIO_QUEUE_NUM, size);
		vtmmio_write_config_4(sc, VIRTIO_MMIO_QUEUE_ALIGN,
		    VIRTIO_MMIO_VRING_ALIGN);

that I could see being otherwise reset by qemu because of a reset status.

Reinitialize virtqueue registers

br retitled this revision from Reinitialize virtqueues after RESET to Reinitialize virtqueues.Jun 15 2018, 2:11 PM
br edited the summary of this revision. (Show Details)
br edited the test plan for this revision. (Show Details)

I don't follow why qemu clearing "pointers" means that we realloc the virtqueues in the guest. The host virtqueue state is reinitialized as part of the reinit process. Also, what do you believe has "recently" changed in qemu's virtio_reset? The blame shows very little changes in the last several years.

I didn't write the MMIO driver and am not as familiar the spec, but perhaps your issue is because vtmmio_reinit_virtqueue() does not replicate all the steps that vtmmio_alloc_virtqueues() perform. Namely, it is missing

		vtmmio_write_config_4(sc, VIRTIO_MMIO_QUEUE_NUM, size);
		vtmmio_write_config_4(sc, VIRTIO_MMIO_QUEUE_ALIGN,
		    VIRTIO_MMIO_VRING_ALIGN);

that I could see being otherwise reset by qemu because of a reset status.

Thanks. I missed this

bryanv added inline comments.
sys/dev/virtio/mmio/virtio_mmio.c
768 ↗(On Diff #43812)

This seems reasonable, although it might make sense to move this after the virtqueue_reinit to keep the pattern similar to the virtqueue_alloc in vtmmio_alloc_virtqueues.

This revision is now accepted and ready to land.Jun 15 2018, 3:29 PM
This revision was automatically updated to reflect the committed changes.