Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev Remove the virtio child driver finalisation check KA...



details:   https://anonhg.NetBSD.org/src/rev/3cb0fc93c256
branches:  trunk
changeset: 950206:3cb0fc93c256
user:      reinoud <reinoud%NetBSD.org@localhost>
date:      Wed Jan 20 21:59:48 2021 +0000

description:
Remove the virtio child driver finalisation check KASSERT that, while it
should never trigger, a possible bug in a child driver shouldn't have to panic
the kernel. Instead report the internal error.

diffstat:

 sys/dev/acpi/virtio_acpi.c    |  10 ++--------
 sys/dev/fdt/virtio_mmio_fdt.c |  10 ++--------
 sys/dev/pci/virtio.c          |  13 +++++++++++--
 sys/dev/pci/virtio_pci.c      |  10 ++--------
 sys/dev/pci/virtiovar.h       |   3 ++-
 5 files changed, 19 insertions(+), 27 deletions(-)

diffs (151 lines):

diff -r 2bc62cf0901b -r 3cb0fc93c256 sys/dev/acpi/virtio_acpi.c
--- a/sys/dev/acpi/virtio_acpi.c        Wed Jan 20 21:39:09 2021 +0000
+++ b/sys/dev/acpi/virtio_acpi.c        Wed Jan 20 21:59:48 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: virtio_acpi.c,v 1.5 2021/01/20 19:46:48 reinoud Exp $ */
+/* $NetBSD: virtio_acpi.c,v 1.6 2021/01/20 21:59:48 reinoud Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: virtio_acpi.c,v 1.5 2021/01/20 19:46:48 reinoud Exp $");
+__KERNEL_RCSID(0, "$NetBSD: virtio_acpi.c,v 1.6 2021/01/20 21:59:48 reinoud Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -168,12 +168,6 @@
        if (virtio_attach_failed(vsc))
                return 0;
 
-       /*
-        * Make sure child drivers initialize interrupts via call
-        * to virtio_child_attach_finish().
-        */
-       KASSERT(msc->sc_ih != NULL);
-
        return 0;
 }
 
diff -r 2bc62cf0901b -r 3cb0fc93c256 sys/dev/fdt/virtio_mmio_fdt.c
--- a/sys/dev/fdt/virtio_mmio_fdt.c     Wed Jan 20 21:39:09 2021 +0000
+++ b/sys/dev/fdt/virtio_mmio_fdt.c     Wed Jan 20 21:59:48 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: virtio_mmio_fdt.c,v 1.5 2021/01/20 19:46:48 reinoud Exp $ */
+/* $NetBSD: virtio_mmio_fdt.c,v 1.6 2021/01/20 21:59:48 reinoud Exp $ */
 
 /*
  * Copyright (c) 2018 Jonathan A. Kollasch
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: virtio_mmio_fdt.c,v 1.5 2021/01/20 19:46:48 reinoud Exp $");
+__KERNEL_RCSID(0, "$NetBSD: virtio_mmio_fdt.c,v 1.6 2021/01/20 21:59:48 reinoud Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -128,12 +128,6 @@
        if (virtio_attach_failed(vsc))
                return 0;
 
-       /*
-        * Make sure child drivers initialize interrupts via call
-        * to virtio_child_attach_finish().
-        */
-       KASSERT(msc->sc_ih != NULL);
-
        return 0;
 }
 
diff -r 2bc62cf0901b -r 3cb0fc93c256 sys/dev/pci/virtio.c
--- a/sys/dev/pci/virtio.c      Wed Jan 20 21:39:09 2021 +0000
+++ b/sys/dev/pci/virtio.c      Wed Jan 20 21:59:48 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: virtio.c,v 1.43 2021/01/20 19:46:48 reinoud Exp $      */
+/*     $NetBSD: virtio.c,v 1.44 2021/01/20 21:59:48 reinoud Exp $      */
 
 /*
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: virtio.c,v 1.43 2021/01/20 19:46:48 reinoud Exp $");
+__KERNEL_RCSID(0, "$NetBSD: virtio.c,v 1.44 2021/01/20 21:59:48 reinoud Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -1084,6 +1084,7 @@
 {
        int r;
 
+       sc->sc_finished_called = true;
        r = sc->sc_ops->setup_interrupts(sc);
        if (r != 0) {
                aprint_error_dev(sc->sc_dev, "failed to setup interrupts\n");
@@ -1187,6 +1188,14 @@
                aprint_error_dev(self, "virtio configuration failed\n");
                return 1;
        }
+
+       /* sanity check */
+       if (!sc->sc_finished_called) {
+               aprint_error_dev(self, "virtio internal error, child driver "
+                       "signaled OK but didn't initialize interrupts\n");
+               return 1;
+       }
+
        return 0;
 }
 
diff -r 2bc62cf0901b -r 3cb0fc93c256 sys/dev/pci/virtio_pci.c
--- a/sys/dev/pci/virtio_pci.c  Wed Jan 20 21:39:09 2021 +0000
+++ b/sys/dev/pci/virtio_pci.c  Wed Jan 20 21:59:48 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: virtio_pci.c,v 1.15 2021/01/20 19:46:48 reinoud Exp $ */
+/* $NetBSD: virtio_pci.c,v 1.16 2021/01/20 21:59:48 reinoud 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.15 2021/01/20 19:46:48 reinoud Exp $");
+__KERNEL_RCSID(0, "$NetBSD: virtio_pci.c,v 1.16 2021/01/20 21:59:48 reinoud Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -351,12 +351,6 @@
        if (virtio_attach_failed(sc))
                return 0;
 
-       /*
-        * Make sure child drivers initialize interrupts via call
-        * to virtio_child_attach_finish().
-        */
-       KASSERT(psc->sc_ihs_num != 0);
-
        return 0;
 }
 
diff -r 2bc62cf0901b -r 3cb0fc93c256 sys/dev/pci/virtiovar.h
--- a/sys/dev/pci/virtiovar.h   Wed Jan 20 21:39:09 2021 +0000
+++ b/sys/dev/pci/virtiovar.h   Wed Jan 20 21:59:48 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: virtiovar.h,v 1.17 2021/01/20 19:46:48 reinoud Exp $   */
+/*     $NetBSD: virtiovar.h,v 1.18 2021/01/20 21:59:48 reinoud Exp $   */
 
 /*
  * Copyright (c) 2010 Minoura Makoto.
@@ -171,6 +171,7 @@
        uint64_t                sc_active_features;
        bool                    sc_indirect;
        bool                    sc_version_1;
+       bool                    sc_finished_called;
 
        int                     sc_nvqs; /* set by child */
        struct virtqueue        *sc_vqs; /* set by child */



Home | Main Index | Thread Index | Old Index