Module Name: src
Committed By: riastradh
Date: Sun Apr 16 17:57:08 UTC 2023
Modified Files:
src/sys/dev/pci: virtio_pci.c
Log Message:
virtio@pci: Fix assertion on detach.
If the child never attached in the first place, it's OK for it to not
have detached.
XXX This should not be a set of flags; this should be a state
enumeration, because some flags make no sense, like FINISHED|FAILED.
XXX This should not be asserted separately in each bus; there should
be a single place in virtio.c to assert this, uniformly in all buses.
PR kern/57357
XXX pullup-10
To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/sys/dev/pci/virtio_pci.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/pci/virtio_pci.c
diff -u src/sys/dev/pci/virtio_pci.c:1.40 src/sys/dev/pci/virtio_pci.c:1.41
--- src/sys/dev/pci/virtio_pci.c:1.40 Fri Mar 31 07:34:26 2023
+++ src/sys/dev/pci/virtio_pci.c Sun Apr 16 17:57:08 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: virtio_pci.c,v 1.40 2023/03/31 07:34:26 yamaguchi Exp $ */
+/* $NetBSD: virtio_pci.c,v 1.41 2023/04/16 17:57:08 riastradh Exp $ */
/*
* Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: virtio_pci.c,v 1.40 2023/03/31 07:34:26 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: virtio_pci.c,v 1.41 2023/04/16 17:57:08 riastradh Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -333,8 +333,11 @@ virtio_pci_detach(device_t self, int fla
if (r != 0)
return r;
- /* Check that child detached properly */
- KASSERT(ISSET(sc->sc_child_flags, VIRTIO_CHILD_DETACHED));
+ /* Check that child never attached, or detached properly */
+ KASSERTMSG(!ISSET(sc->sc_child_flags,
+ (VIRTIO_CHILD_ATTACH_FINISHED|VIRTIO_CHILD_ATTACH_FAILED)) ||
+ ISSET(sc->sc_child_flags, VIRTIO_CHILD_DETACHED),
+ "%s: child flags %x", device_xname(self), sc->sc_child_flags);
KASSERT(sc->sc_vqs == NULL);
KASSERT(psc->sc_ihs_num == 0);