From nobody Tue Nov 10 20:51: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 4jPJjL4hTbz6vR9p for ; Tue, 10 Nov 2026 20:51: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 4jPJjL3l7Kz4Hmx for ; Tue, 10 Nov 2026 20:51:34 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794343894; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ksX9gHvSBoQUGrK6Jh15H+CH/dARWMGzAv6s+Igtl6Q=; b=OmGsyJigdDF8aSyBXBpsvxqpWu27Wqt3F5vZFjurW/40+0fIpT4omvbyX2ofSNviqWCg/e wLZCbeL8GHb91lCTYHz4J7o+q5BrUWOUytjUq307/Mmgj0rKNj/3m0382rQ5EC6Pw0Vllp vFt0j2VWsmRmxvgadnPY7J1hNncTvxsuXFf2Z0IpPkMFdxaW/GUpO6nAzNhZ3vV2JrlKUP dpM6e2IMslGunaTzSi0gq5OYj3vohUIHeU9KPdKoFHe/Nse1LZkjdSO2ow6Va8L+z48lEz QMDt8KPORsc/VXPle9t6nP3ZtfMlPO/26rDFJLlSagvt/3E2TeXdX953EWgXmA== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794343894; b=CjiIRc4tqCC8us/VyZFCJ//2g2/rs88Cy/TXu8h6yST9r1Jvsed2OKTpP+SrTH9h40yftN YIxmOboLMxlhbqu5IfwFqMofQbFLOzMt9bn2HM7GwEobhNgz9CkOHmQ1Dptl1HWsY1ur+6 885xfMFO3JboEH+73ZxN/1jvz9MywwWvZswB20BMUat+MNUgKQ/K09SlDl0UGW/0kl5VDr GlM2VA+Vp0T4RPhevriEXQFU7qqMXvqqlIJMK4HGCzcKDZZpGkDqjmZiTbUE/Qq//nO8Pz SVYbSZm+En3dox1tIZcFtkjoORH4PgaG/VXSZaTiOR6j1jjRSbRiNjFYmRdpnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794343894; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ksX9gHvSBoQUGrK6Jh15H+CH/dARWMGzAv6s+Igtl6Q=; b=vuiKPj4UE/+x7HOJCWipCE+oWIZhDk7BAHvESxes/ckaUC51P26egP8aF8BsI/BMntQmdb NXjgswkKVPf5IcBSHmV2JkytjrmC0z4GMe/QH4kLN/e2aBdXi5qs3JyL+dJ27A73fI7jC1 M08ig4Jb9Oz1zEejVnh+d/NsAtrbfUlMj3NfgiGekkjguGbYfH0xQoMzWv70ilvG4KP6Yh 9Uj25CvSSfq34jcqgUThsB/qN6aBKNY3/1OAdIMgDmujVq9qaz3x4ut2U97B0sv3tqTQZW q4tgwoD+PX/px3IlHUKmDNDffNnHMLmlV+vzt02rHwPr+Ee9Xoji43ryz7kFSA== 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 4jPJjL3LVBzkbv for ; Tue, 10 Nov 2026 20:51:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 8eb4 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 10 Nov 2026 20:51:34 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Cc: Kyle Evans From: Colin Percival Subject: git: 61b5fa09db8d - releng/15.2 - 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 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: cperciva X-Git-Repository: src X-Git-Refname: refs/heads/releng/15.2 X-Git-Reftype: branch X-Git-Commit: 61b5fa09db8d95e38f795366135b5b13ebbd4f3b Auto-Submitted: auto-generated Date: Tue, 10 Nov 2026 20:51:34 +0000 Message-Id: <6af383d6.8eb4.54da4c5a@gitrepo.freebsd.org> The branch releng/15.2 has been updated by cperciva: URL: https://cgit.FreeBSD.org/src/commit/?id=61b5fa09db8d95e38f795366135b5b13ebbd4f3b commit 61b5fa09db8d95e38f795366135b5b13ebbd4f3b Author: Kyle Evans AuthorDate: 2026-11-05 21:53:30 +0000 Commit: Colin Percival CommitDate: 2026-11-10 20:51:19 +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. Approved by: re (cperciva) 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) (cherry picked from commit 1a10bff4ce4772bb1611c286df8728cace5dfb65) --- 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 3f30c8b68f4c..128e9c3937f0 100644 --- a/sys/dev/virtio/random/virtio_random.c +++ b/sys/dev/virtio/random/virtio_random.c @@ -47,6 +47,8 @@ #include #include +#include "virtio_if.h" + struct vtrnd_softc { device_t vtrnd_dev; uint64_t vtrnd_features; @@ -69,6 +71,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 @@ -93,6 +96,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 }; @@ -181,8 +187,6 @@ vtrnd_attach(device_t dev) sc->inactive = false; random_source_register(&random_vtrnd); - vtrnd_enqueue(sc); - fail: if (error) vtrnd_detach(dev); @@ -327,3 +331,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); +}