From nobody Wed Nov 04 21:34:34 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4jKdxk5DNmz7061f for ; Wed, 04 Nov 2026 21:34:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jKdxk47Rqz4gt0 for ; Wed, 04 Nov 2026 21:34:34 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1793828074; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=tI47CbQAFKNoWYKa/28+iDx35WPy8u6QDKH8ZM7UkR4=; b=FdDfFGbuBe3uE49g7TTlDkngUrmv44yRDsob4upoJ7ebQQqTXZ5MQ/qjZA8MosB9Dohr9A DUcN1OwwVPupX6du5HJp7D2kygI5fZbOSx8XB0HUk4j5woAxfdyqsNBrX00NWN/3PGL7Op Vn0aYSlxmw+FLDgzl4upYUcR9Yd1i5jtHakMSE+l8IKXzypE2qDqB/JWH39zpcnNGCKcvB MMY0Xpntn3Ci7YyNIP2ezflJyn9/aLQjZgaMIRQbXQ8VczLEDnawQ5VonCSsSwLVmuBn6C tNe9r2+x3sMF5NzPQ1mUhjkmQLRwAtaNB84nEYYD0chqJuIZArS3sR60Wwqqvg== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1793828074; b=IXCiLHofQauzmb3NoYOtD/eIYMjjmdXP+kIXrLTOFTPmIwBZ4lzXYWR4v2/3X8S0W4zA0m STR/OiRd3OcQZ5JC7k50gaSPevhtdAMLMNzLYaHjX16YSa7/cuUYRzzcUzoK4WWfXi+AJK 5H2Cfz448JXnELrm9ZgU1k6vsGEAnDas5HwnDogYDsQfTH8iCm9iR6CPCbe4GcO46Opwf5 P6yJZSypcjUa3yk/MIAElYln8ftZAgC3dTmiYALJcXYXd3FOpbINR8j5aOR5ddVKRGzPBT yHHXs5Ao4pFnI0LF1FjPM4Ex9RryaFlOZnucI6J1vF54yFruKSH/VqL+aK+tGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1793828074; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=tI47CbQAFKNoWYKa/28+iDx35WPy8u6QDKH8ZM7UkR4=; b=lqoDoCQPQB7ef7PgMNIWyDbNR18xk2hIEwtR3U0knztQ0dBQmDtQkCq0uTc0Mwcjvt0oTC 3eSJWLS2Ew8QRSAr7m1kk41xPVrT/ZQl6D97RdfIcpd+CC4IP4jkLoaxd+t9Cra04T6IkR oGx5721irv/l1FoXrZAMB2mMOLcBl9dlMSbijcb0qD8uQwL0kQtsjAG3Jmyoahn+X3TW40 aFrExsHrcx++DpB1Zzf7/HAVXmLA3fLJ4L5D3a2CKNIHan6gaoisilTS3nKJV0F1f3ihRO L96cd+1Qo2kp5o99C8wnqd7B+tUqEd6L0p1yIxNiQjvWbwEyZl3pnhbEl2OH2A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jKdxk3NnlzKxl for ; Wed, 04 Nov 2026 21:34:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 21059 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Wed, 04 Nov 2026 21:34:34 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kyle Evans Subject: git: c67e695b8f7e - main - virtio_pci_modern: enable virtqueues before completing attach List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org List-Id: Commit messages for all branches of the src repository List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kevans X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c67e695b8f7eff84f7daa9e30eba7eb5ec552436 Auto-Submitted: auto-generated Date: Wed, 04 Nov 2026 21:34:34 +0000 Message-Id: <6aeba4ea.21059.366e5c1c@gitrepo.freebsd.org> The branch main has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=c67e695b8f7eff84f7daa9e30eba7eb5ec552436 commit c67e695b8f7eff84f7daa9e30eba7eb5ec552436 Author: Kyle Evans AuthorDate: 2026-11-04 21:31:31 +0000 Commit: Kyle Evans CommitDate: 2026-11-04 21:34:17 +0000 virtio_pci_modern: enable virtqueues before completing attach Most of our drivers setup interrupt(s) and virtqueues are enabled at that time, but nothing will currently enable them for devices that we're only going to poll. This most notably affects virtio-random, and the problem can be observed with qemu's q35 emulation and a random device attached. The q35 implementation ignores the ring unless it's enabled, so vtrnd_harvest() will consistently EAGAIN rather than contribute anything of value, but with this patch it becomes functional. This can be reproduced with a qemu invocation like so: qemu-system-x86_64 -machine q35,accel=tcg -cpu max -smp 2 -m 2G \ -drive file=FreeBSD-16.0-CURRENT-amd64-ufs.qcow2,if=virtio \ -device pcie-root-port,id=rp1,bus=pcie.0,chassis=1 \ -object rng-random,id=rng0,filename=/dev/urandom \ -device virtio-rng-pci,rng=rng0,bus=rp1 \ -display curses Reviewed by: bnovkov, kfv Sponsored by: Stormshield Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D61052 --- sys/dev/virtio/pci/virtio_pci_modern.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/sys/dev/virtio/pci/virtio_pci_modern.c b/sys/dev/virtio/pci/virtio_pci_modern.c index 6732f9ee610f..629c577b1bf4 100644 --- a/sys/dev/virtio/pci/virtio_pci_modern.c +++ b/sys/dev/virtio/pci/virtio_pci_modern.c @@ -1156,6 +1156,13 @@ vtpci_modern_probe_and_attach_child(struct vtpci_modern_softc *sc) /* Reset state for later attempt. */ vtpci_modern_child_detached(dev, child); } else { + /* + * It may be the case that the device will only be polled and + * an interrupt never configured, so enable our virtqueues here + * if they hadn't been already. + */ + vtpci_modern_enable_virtqueues(sc); + vtpci_modern_set_status(sc, VIRTIO_CONFIG_STATUS_DRIVER_OK); VIRTIO_ATTACH_COMPLETED(child); } @@ -1307,6 +1314,9 @@ vtpci_modern_enable_virtqueues(struct vtpci_modern_softc *sc) for (idx = 0; idx < sc->vtpci_common.vtpci_nvqs; idx++) { vtpci_modern_select_virtqueue(sc, idx); + if (vtpci_modern_read_common_2(sc, + VIRTIO_PCI_COMMON_Q_ENABLE) != 0) + continue; vtpci_modern_write_common_2(sc, VIRTIO_PCI_COMMON_Q_ENABLE, 1); } }