Module Name:    src
Committed By:   martin
Date:           Sun Mar 26 10:36:11 UTC 2017

Modified Files:
        src/sys/dev/pci: virtio.c virtiovar.h

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/dev/pci/virtio.c
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/pci/virtiovar.h

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.c
diff -u src/sys/dev/pci/virtio.c:1.22 src/sys/dev/pci/virtio.c:1.23
--- src/sys/dev/pci/virtio.c:1.22	Sat Mar 25 18:02:06 2017
+++ src/sys/dev/pci/virtio.c	Sun Mar 26 10:36:10 2017
@@ -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 @@ virtio_init_vq(struct virtio_softc *sc, 
 	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 @@ virtio_alloc_vq(struct virtio_softc *sc,
 	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 @@ virtio_alloc_vq(struct virtio_softc *sc,
 		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 @@ virtio_features(struct virtio_softc *sc)
 	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

Index: src/sys/dev/pci/virtiovar.h
diff -u src/sys/dev/pci/virtiovar.h:1.7 src/sys/dev/pci/virtiovar.h:1.8
--- src/sys/dev/pci/virtiovar.h:1.7	Sat Mar 25 18:02:06 2017
+++ src/sys/dev/pci/virtiovar.h	Sun Mar 26 10:36:10 2017
@@ -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 @@ bus_dma_tag_t	virtio_dmat(struct virtio_
 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_ */

Reply via email to