Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/pci Provide an accessor for the pci attach args of a...



details:   https://anonhg.NetBSD.org/src/rev/cb3d0bb54f06
branches:  trunk
changeset: 352330:cb3d0bb54f06
user:      martin <martin%NetBSD.org@localhost>
date:      Sun Mar 26 10:36:10 2017 +0000

description:
Provide an accessor for the pci attach args of a virtio device (if
available - future non-pci attachments may return NULL).
Sparc64 MD code needs this to match the OF node of the virtio device
for boot device recognition.

diffstat:

 sys/dev/pci/virtio.c    |  20 +++++++++++++++++---
 sys/dev/pci/virtiovar.h |   3 ++-
 2 files changed, 19 insertions(+), 4 deletions(-)

diffs (82 lines):

diff -r cf80fe7fccdd -r cb3d0bb54f06 sys/dev/pci/virtio.c
--- a/sys/dev/pci/virtio.c      Sat Mar 25 23:58:35 2017 +0000
+++ b/sys/dev/pci/virtio.c      Sun Mar 26 10:36:10 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: virtio.c,v 1.22 2017/03/25 18:02:06 jdolecek Exp $     */
+/*     $NetBSD: virtio.c,v 1.23 2017/03/26 10:36:10 martin Exp $       */
 
 /*
  * Copyright (c) 2010 Minoura Makoto.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: virtio.c,v 1.22 2017/03/25 18:02:06 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: virtio.c,v 1.23 2017/03/26 10:36:10 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -844,11 +844,14 @@
        if (vq->vq_indirect != NULL) {
                struct vring_desc *vd;
 
+printf("vq_size: %d, vq_maxnsegs: %d\n", vq_size, vq->vq_maxnsegs);
+
                for (i = 0; i < vq_size; i++) {
                        vd = vq->vq_indirect;
                        vd += vq->vq_maxnsegs * i;
-                       for (j = 0; j < vq->vq_maxnsegs-1; j++)
+                       for (j = 0; j < vq->vq_maxnsegs-1; j++) {
                                vd[j].next = j + 1;
+                       }
                }
        }
 
@@ -914,6 +917,8 @@
        else
                allocsize3 = 0;
        allocsize = allocsize1 + allocsize2 + allocsize3;
+printf("virtio: allocsize1: %d, allocsize2: %d, allocsize3: %d\n",
+   allocsize1, allocsize2, allocsize3);
 
        /* alloc and map the memory */
        r = bus_dmamem_alloc(sc->sc_dmat, allocsize, VIRTIO_PAGE_SIZE, 0,
@@ -968,6 +973,8 @@
                vq->vq_indirectoffset = allocsize1 + allocsize2;
                vq->vq_indirect = (void*)(((char*)vq->vq_desc)
                                          + vq->vq_indirectoffset);
+printf("virtio: vq_indirectoffset: %d, vq_indirect: %p\n",
+    vq->vq_indirectoffset, vq->vq_indirect);
        }
        vq->vq_bytesize = allocsize;
        vq->vq_maxsegsize = maxsegsize;
@@ -1460,6 +1467,13 @@
        return sc->sc_features;
 }
 
+struct pci_attach_args *
+virtio_pci_attach_args(struct virtio_softc *sc)
+{
+       return &sc->sc_pa;
+}
+
+
 MODULE(MODULE_CLASS_DRIVER, virtio, "pci");
  
 #ifdef _MODULE
diff -r cf80fe7fccdd -r cb3d0bb54f06 sys/dev/pci/virtiovar.h
--- a/sys/dev/pci/virtiovar.h   Sat Mar 25 23:58:35 2017 +0000
+++ b/sys/dev/pci/virtiovar.h   Sun Mar 26 10:36:10 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: virtiovar.h,v 1.7 2017/03/25 18:02:06 jdolecek Exp $   */
+/*     $NetBSD: virtiovar.h,v 1.8 2017/03/26 10:36:10 martin Exp $     */
 
 /*
  * Copyright (c) 2010 Minoura Makoto.
@@ -213,5 +213,6 @@
 device_t       virtio_child(struct virtio_softc *);
 int            virtio_intrhand(struct virtio_softc *);
 uint32_t       virtio_features(struct virtio_softc *);
+struct pci_attach_args *virtio_pci_attach_args(struct virtio_softc *);
 
 #endif /* _DEV_PCI_VIRTIOVAR_H_ */



Home | Main Index | Thread Index | Old Index