From nobody Mon Nov 09 03:14:25 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 4jNFJ15Gb5z70S5m for ; Mon, 09 Nov 2026 03:14:25 +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 4jNFJ1231sz3GBm for ; Mon, 09 Nov 2026 03:14:25 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794194065; 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=GxW/mGP8C+NzkzPEOPeEFPW5P/6eWojMFBWuZAcvokQ=; b=Ety3UZhkKUL1CqZjZ/+daYU2FP3KaoN0U5PXz82/r3TJPkvd0XV9G9u3U2SkIhV9hF4HYJ n1jBB5cbOnjbZoY2fxi46bHeaqELjvcZUjxMETg7mHpWTsOEh0xRg+4uPFoSzOi8OcdmYg 3hSdT0lB/3uglypz3k0jgKkH4eKKlmWxW55yKGyY6DYAVIbjJtkcgsGkFeLo5knpCFExR/ mZ54MbBm27A2J1UixhFvKw4Ue2lfjoqYRkxJe1uoLt/Iinv6TZSHR/Yf+0lVCz9VOlSoUK b1isL24WxvTV1R+2RdLolTyRJs8bTegw+Ibbcc0b02eVESnwcwGjbnFQ+o3ZsA== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794194065; b=n3PMxr+0I9VCur10Npv4JT9iwi0ME/f1/3/fH0dtoEZVSBLtngQ4oxmzyUBccucdW3+tUH O6+Emxp6T1UZvxxcCTp+ymj/v97Dmh1qivhJ+4CKmKnnnMXcXYRa7bDW+SdDIBWTbBkdrN px7PFUXH4CXHrDO4gLTdixhCPqWo7pt23pmsPlwcd+tX9UCpiihYetTsVwTuQoEGC1INYJ pGnNhk5OuGPje5X33ac5U6iQmU9EcicrDyEHL4x2B2PMNXgUDBCDkFSMSFq0jyWWgHH/90 gOX34ZIkVNU2tt49AFEChueN6NH/yWWoSesAfbBx4kcl/ckBIJJHHpW3kNE5dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794194065; 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=GxW/mGP8C+NzkzPEOPeEFPW5P/6eWojMFBWuZAcvokQ=; b=jVAko8afwYq2Xrxj9xPkJNd4OyBypb5p3WsBhdyd20mx+iSEyVedpPnwEWSMNva5wvTDHH ZC9Ew8smeqdRIH65Qx2MbKRJnu6O3elA1dn+/pEE3d8UFN/D1CmT6VKqCtrL/0LhXNGzDO OBJeREPbA4ytA3f1vsGQbl3gTqXHtT7eviMMF7MXZMzR9PJFMow9NibNn63PITC0ZREGMh V8e5DV0hrYzg1ScReMJGN5UTfsdHlmgiIx6mg+7NDcA3eEU7B6rKkiAaS5n0nwgDHESjUa c+lZ+pLMF/pzkjXidccmwyKBokhLiPyDpwL9gtd1/D+24teIFvdkI/17Ddq41g== 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 4jNFJ119QbzKx0 for ; Mon, 09 Nov 2026 03:14:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 10b05 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Mon, 09 Nov 2026 03:14:25 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kyle Evans Subject: git: b3563d1d49e8 - stable/14 - virtio_random: defer first enqueue until after DRIVER_OK 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/stable/14 X-Git-Reftype: branch X-Git-Commit: b3563d1d49e89ed8486b2e9a73c573ecf281821d Auto-Submitted: auto-generated Date: Mon, 09 Nov 2026 03:14:25 +0000 Message-Id: <6af13a91.10b05.101c816c@gitrepo.freebsd.org> The branch stable/14 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=b3563d1d49e89ed8486b2e9a73c573ecf281821d commit b3563d1d49e89ed8486b2e9a73c573ecf281821d Author: Kyle Evans AuthorDate: 2026-11-05 21:53:30 +0000 Commit: Kyle Evans CommitDate: 2026-11-09 03:14:13 +0000 virtio_random: defer first enqueue until after DRIVER_OK According to the virtio spec: > The driver MUST NOT send any buffer available notifications to the > device before setting DRIVER_OK. DRIVER_OK isn't set until after attach completes, so defer the first enqueue. We haven't found any problems as a result of this to the best of my knowledge: q35 and other devices that we *have* been used with will apparently check when we go DRIVER_OK. Tested with q35 virtio-random, which still works. Reported by: llm-postcr Reviewed by: kfv, markj Fixes: f1c5a2e3a62505 ("virtio_random: Pipeline fetching the data") Sponsored by: Stormshield Sponsored by: Klara, Inc. (cherry picked from commit 12f90bbd3029fedea93e9bb0b1f02c3afafe237b) --- sys/dev/virtio/random/virtio_random.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/sys/dev/virtio/random/virtio_random.c b/sys/dev/virtio/random/virtio_random.c index 0cffcc3962e6..51b671852b7c 100644 --- a/sys/dev/virtio/random/virtio_random.c +++ b/sys/dev/virtio/random/virtio_random.c @@ -48,6 +48,8 @@ #include #include +#include "virtio_if.h" + struct vtrnd_softc { device_t vtrnd_dev; uint64_t vtrnd_features; @@ -70,6 +72,7 @@ static int vtrnd_setup_features(struct vtrnd_softc *); static int vtrnd_alloc_virtqueue(struct vtrnd_softc *); static int vtrnd_harvest(struct vtrnd_softc *, void *, size_t *); static void vtrnd_enqueue(struct vtrnd_softc *sc); +static int vtrnd_attach_completed(device_t); static unsigned vtrnd_read(void *, unsigned); #define VTRND_FEATURES 0 @@ -94,6 +97,9 @@ static device_method_t vtrnd_methods[] = { DEVMETHOD(device_detach, vtrnd_detach), DEVMETHOD(device_shutdown, vtrnd_shutdown), + /* Virtio methods. */ + DEVMETHOD(virtio_attach_completed, vtrnd_attach_completed), + DEVMETHOD_END }; @@ -182,8 +188,6 @@ vtrnd_attach(device_t dev) sc->inactive = false; random_source_register(&random_vtrnd); - vtrnd_enqueue(sc); - fail: if (error != 0) { /* Parent will free the virtqueue. */ @@ -341,3 +345,13 @@ vtrnd_read(void *buf, unsigned usz) return (sz); } + +static int +vtrnd_attach_completed(device_t dev) +{ + struct vtrnd_softc *sc; + + sc = device_get_softc(dev); + vtrnd_enqueue(sc); + return (0); +}