From nobody Wed Nov 04 21:34:33 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 4jKdxj4FTzz705y5 for ; Wed, 04 Nov 2026 21:34:33 +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 4jKdxj2vQrz4h81 for ; Wed, 04 Nov 2026 21:34:33 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1793828073; 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=F6jQbD1g2Gte/SW+nGZXEWHNOM9kUrbTmFBUphdcWag=; b=rtezngQJnCwPud2MYa4Q/bXzicUjQAygMMLiSoaAj3iptkoARbfsJ7JESdc3F7lsxzeJLL 4JF99pfIAqUVgxKUxLYd93Ho4iIenV4UKmINETM2b2x+xMGSBB30Vv3z0Gif5+2OwkWBmE zPJSzuT25egIdh/I6H2k4FcDzIoorWnrKIU99cLlNauXCaXchYEex6rBBWQsA5gNsWYiip wWdg6gRyXOUsvefR8QgSeBS49AJYotv9XukxVFKZNHtjs1XGmL5puTw0Q8vUDy8sUST9ei g4HTqqXlOhsAx4nc9T08h1NzLBl2TTeba5+aOJwtjymM8VwNlzUZL+157ZdppA== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1793828073; b=Zh67ln080ZhL6pZaOtRgS+te6kDOnu+LPPGgVgtDjPwddVAHKH91MlxyJs9pS/vCKIimq/ 0Et3kajz+KbpnqwbMlwfsa0SpSVToXrBJtFIct9VNiOmzaOe1fumKPqf+UXaXsvMdeeGkh TSzaola4SxqcwsBTvdmA3yiV5EzFFNihfPl3NFR1GTbJU1qkkniW0mo9L6mXgyl00YuEAN 0mIu6ypN+vslpCsbtnhuGUNtwcoGGU3lq4aHQy7V2DTwLNgUG93qaIqWfs2RLSQWrOYXw8 iHAThCO2qSwSH8gfdVp7KMM7DvvF/X5oJMCdjspy1iJHQQTDKsjsHF+ecS6R2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1793828073; 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=F6jQbD1g2Gte/SW+nGZXEWHNOM9kUrbTmFBUphdcWag=; b=MY4IXCHEllmaPZPGD1fQcMNWjgT70Co9pYF/R0rvvu4ciXdbLa++m88CKvCPjVCfV/mrkr jkMraXtqwv/mJPCreBOT1bIhnTAXRONlBA4VkNcenLJ81hSrHNcZGYf6nI6BipGJ+qTNxX 5Bl3jjCOtt6OuOjPCJ7Gq4yF0PZ4Iufpi/fnJAbhn4faIl5+OwE6LWFTJUZn1aAJucESny BeFy0ZZfuztbhJH330E4uQ13jA498wpFJ+yoXlc/P83WWhye0CPsT9P2tEo1mZ3yoK2Pd4 k5LfUw99OGNDRRzIoDclmdiFrzmoFehkiWdgQ8iupm+hQ/7tmi5+C46myHZD6w== 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 4jKdxj2Xh6zKk1 for ; Wed, 04 Nov 2026 21:34:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 21d21 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Wed, 04 Nov 2026 21:34:33 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kyle Evans Subject: git: cce522853aae - main - virtio_random: stop on detach, don't poll 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: cce522853aae3da45b131c2522dd2510edf083e7 Auto-Submitted: auto-generated Date: Wed, 04 Nov 2026 21:34:33 +0000 Message-Id: <6aeba4e9.21d21.1cffd6da@gitrepo.freebsd.org> The branch main has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=cce522853aae3da45b131c2522dd2510edf083e7 commit cce522853aae3da45b131c2522dd2510edf083e7 Author: Kyle Evans AuthorDate: 2026-11-04 21:31:31 +0000 Commit: Kyle Evans CommitDate: 2026-11-04 21:33:33 +0000 virtio_random: stop on detach, don't poll If the device is hung, then polling will block the detach and hang us. Stop it and drain the queue instead. This fixes a hang on detach in some circumstances without the upcoming virtio_pci_modern fix. Reviewed by: bnovkov, kfv Sponsored by: Stormshield Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D61051 --- sys/dev/virtio/random/virtio_random.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/sys/dev/virtio/random/virtio_random.c b/sys/dev/virtio/random/virtio_random.c index a253db5535dc..774221bd2bfd 100644 --- a/sys/dev/virtio/random/virtio_random.c +++ b/sys/dev/virtio/random/virtio_random.c @@ -201,7 +201,7 @@ static int vtrnd_detach(device_t dev) { struct vtrnd_softc *sc; - uint32_t rdlen; + int last; sc = device_get_softc(dev); KASSERT( @@ -215,8 +215,14 @@ vtrnd_detach(device_t dev) } random_source_deregister(&random_vtrnd); - /* clear the queue */ - virtqueue_poll(sc->vtrnd_vq, &rdlen); + /* + * Just reset the device; if it's hanging, for some reason, then polling + * may put us in a bad position. + */ + virtio_stop(dev); + last = 0; + while (virtqueue_drain(sc->vtrnd_vq, &last) != NULL) + ; atomic_store_explicit(&g_vtrnd_softc, NULL, memory_order_release); sglist_free(sc->vtrnd_sg);