Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/pci Setup virtqueues after registering them to virti...



details:   https://anonhg.NetBSD.org/src/rev/3946cf480d5f
branches:  trunk
changeset: 374019:3946cf480d5f
user:      yamaguchi <yamaguchi%NetBSD.org@localhost>
date:      Sat Mar 25 02:59:23 2023 +0000

description:
Setup virtqueues after registering them to virtio_softc

diffstat:

 sys/dev/pci/virtio.c |  25 ++++++++++++++-----------
 1 files changed, 14 insertions(+), 11 deletions(-)

diffs (67 lines):

diff -r 3937a6273c04 -r 3946cf480d5f sys/dev/pci/virtio.c
--- a/sys/dev/pci/virtio.c      Fri Mar 24 16:58:24 2023 +0000
+++ b/sys/dev/pci/virtio.c      Sat Mar 25 02:59:23 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: virtio.c,v 1.68 2023/03/24 13:32:19 yamaguchi Exp $    */
+/*     $NetBSD: virtio.c,v 1.69 2023/03/25 02:59:23 yamaguchi Exp $    */
 
 /*
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: virtio.c,v 1.68 2023/03/24 13:32:19 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: virtio.c,v 1.69 2023/03/25 02:59:23 yamaguchi Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -865,10 +865,6 @@ virtio_alloc_vq(struct virtio_softc *sc,
 
        virtio_reset_vq(sc, vq);
 
-       /* set the vq address */
-       sc->sc_ops->setup_queue(sc, vq->vq_index,
-           vq->vq_dmamap->dm_segs[0].ds_addr);
-
        aprint_verbose_dev(sc->sc_dev,
            "allocated %zu byte for virtqueue %d for %s, size %d\n",
            allocsize, vq->vq_index, name, vq_num);
@@ -1301,6 +1297,7 @@ virtio_child_attach_finish(struct virtio
     virtio_callback config_change,
     int req_flags)
 {
+       size_t i;
        int r;
 
 #ifdef DIAGNOSTIC
@@ -1309,11 +1306,11 @@ virtio_child_attach_finish(struct virtio
        KASSERT((req_flags & VIRTIO_ASSERT_FLAGS) != VIRTIO_ASSERT_FLAGS);
 #undef VIRTIO_ASSERT_FLAGS
 
-       for (size_t _i = 0; _i < nvqs; _i++){
-               KASSERT(vqs[_i].vq_index == _i);
-               KASSERT(vqs[_i].vq_intrhand != NULL);
-               KASSERT(vqs[_i].vq_done == NULL ||
-                   vqs[_i].vq_intrhand == virtio_vq_done);
+       for (i = 0; i < nvqs; i++){
+               KASSERT(vqs[i].vq_index == i);
+               KASSERT(vqs[i].vq_intrhand != NULL);
+               KASSERT(vqs[i].vq_done == NULL ||
+                   vqs[i].vq_intrhand == virtio_vq_done);
        }
 #endif
 
@@ -1325,6 +1322,12 @@ virtio_child_attach_finish(struct virtio
        sc->sc_intrhand = virtio_vq_intr;
        sc->sc_flags = req_flags;
 
+       /* set the vq address */
+       for (i = 0; i < nvqs; i++) {
+               sc->sc_ops->setup_queue(sc, vqs[i].vq_index,
+                   vqs[i].vq_dmamap->dm_segs[0].ds_addr);
+       }
+
        r = sc->sc_ops->alloc_interrupts(sc);
        if (r != 0) {
                aprint_error_dev(sc->sc_dev,



Home | Main Index | Thread Index | Old Index