From nobody Thu Nov 05 21:57:36 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 4jLGPx3tr9z6yP2n for ; Thu, 05 Nov 2026 21:57:41 +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 4jLGPx20Rcz4Zln for ; Thu, 05 Nov 2026 21:57:41 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1793915861; 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=lqu31dmdHj7jTQqbtUpaacJ4QgF1P3g2hVRNMfoHYbs=; b=d04lJ2nyCyfJ1Brd3pBSOLBSyE9Vvn9xfon7zlewa1Zd3+naAxvP0RBWDWD3jspW4zGmmo UE4Iks7PSQml3iYYyRIXQHzIGceD7+D0prXp7dty4gGVGBlM53K9ESFQd+3Lv+fR0y7d6l Br8/W02yzfnCa6rcool0+LihYfcoZ3TCw38uVCfZ263oRTYXtiqvnm7K5eP9gOywlOPtN0 FmFH6GHRxSZt7jBwbP754OGf6JpLVSgCTkxG05eZmTFaTPhxAPWZe50NIo3yQcr027HeV9 kZ0bUFz55Zqq+tseIhCbV0as/d5JTenVRqdJoXI/VwVhyDw9z97y/dCsI/w4sg== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1793915861; b=FvyG7zjWlOniy+Kpy4zDd3Gru6jYkvnGZCbK0HcNVOaXA88bJNEMTIVQzIJl617OUyBwAc qqNPd8G8YTDVYFZT2XOVA6HTfunphjHzIEYRXRNMqzWoIHeLwOKxorEPQTNEPK5HvKCNVA Z5dokNLTrmJyBRYkIEvXBTmEmqfcCuwbOpSSk4u0YvWLWXcHsnEob1fZ95YFmyC+nZqGXN ylZPk4g39rHsOlDk0qVql4N1A0zj5UuLs+Q+J267HpYd1+nqcrF1EaMJ2Ia16mHGG3Ov8d ft5bpsUAt09wc9EpuqJaHXM7gjhIgM8K7/9wRf4KWal29slPkbJtcUpKW86Ykw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1793915861; 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=lqu31dmdHj7jTQqbtUpaacJ4QgF1P3g2hVRNMfoHYbs=; b=XnT3gahax39stT22/ne7MSFKeX8p/oh7kEteMCr6w7ttiH40AcireapBXXcrZM9bB3h6h2 uH9Tj6g+x15Jw+atZxNvz4oqcC/Fp2tV0yHbkaTcZC1xMMIZOeqzBBHtL2ZqV3a89rJCUU Rz2CCoz1Xv/+KxvayHkM91AqAdhKtIeGYL89P8eZKQ+mm9Xn8BlhGcxtm0A3h0zP2u9bY1 ns6jxitPanYEekH0xmyKBFYQNIanOwajeBN4lYQEtWw3H1BSE1/zTayGTnKZRbyMVvu87h XPDA3cocMpaY8818jkbtrQdQqRq93KGeR6qfjvEom1l58+FHWAL+VypU25/+gg== 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 4jLGPx112fz17hV for ; Thu, 05 Nov 2026 21:57:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 27d1f by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Thu, 05 Nov 2026 21:57:36 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kyle Evans Subject: git: 12f90bbd3029 - main - 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/main X-Git-Reftype: branch X-Git-Commit: 12f90bbd3029fedea93e9bb0b1f02c3afafe237b Auto-Submitted: auto-generated Date: Thu, 05 Nov 2026 21:57:36 +0000 Message-Id: <6aecfbd0.27d1f.12d5908a@gitrepo.freebsd.org> The branch main has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=12f90bbd3029fedea93e9bb0b1f02c3afafe237b commit 12f90bbd3029fedea93e9bb0b1f02c3afafe237b Author: Kyle Evans AuthorDate: 2026-11-05 21:53:30 +0000 Commit: Kyle Evans CommitDate: 2026-11-05 21:53:30 +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. Differential Revision: https://reviews.freebsd.org/D61228 --- 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 774221bd2bfd..75addaaf322f 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 != 0) { /* Parent will free the virtqueue. */ @@ -340,3 +344,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); +}