Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 15 Jun 2018 16:19:11 +0000 (UTC)
From:      Ruslan Bukin <br@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r335211 - head/sys/dev/virtio/mmio
Message-ID:  <201806151619.w5FGJB87006894@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: br
Date: Fri Jun 15 16:19:10 2018
New Revision: 335211
URL: https://svnweb.freebsd.org/changeset/base/335211

Log:
  Make virtio queue re-initialization steps to be similar to
  original initialization, so we don't miss few registers to
  configure.
  
  This fixes vtnet(4) operation with QEMU's virtio-net-device.
  
  Tested in QEMU with FreeBSD/RISC-V.
  
  Reviewed by:	bryanv
  Sponsored by:	DARPA, AFRL
  Differential Revision:	https://reviews.freebsd.org/D15821

Modified:
  head/sys/dev/virtio/mmio/virtio_mmio.c

Modified: head/sys/dev/virtio/mmio/virtio_mmio.c
==============================================================================
--- head/sys/dev/virtio/mmio/virtio_mmio.c	Fri Jun 15 16:18:39 2018	(r335210)
+++ head/sys/dev/virtio/mmio/virtio_mmio.c	Fri Jun 15 16:19:10 2018	(r335211)
@@ -512,7 +512,8 @@ vtmmio_alloc_virtqueues(device_t dev, int flags, int n
 	if (sc->vtmmio_vqs == NULL)
 		return (ENOMEM);
 
-	vtmmio_write_config_4(sc, VIRTIO_MMIO_GUEST_PAGE_SIZE, 1 << PAGE_SHIFT);
+	vtmmio_write_config_4(sc, VIRTIO_MMIO_GUEST_PAGE_SIZE,
+	    (1 << PAGE_SHIFT));
 
 	for (idx = 0; idx < nvqs; idx++) {
 		vqx = &sc->vtmmio_vqs[idx];
@@ -537,10 +538,10 @@ vtmmio_alloc_virtqueues(device_t dev, int flags, int n
 		    VIRTIO_MMIO_VRING_ALIGN);
 #if 0
 		device_printf(dev, "virtqueue paddr 0x%08lx\n",
-				(uint64_t)virtqueue_paddr(vq));
+		    (uint64_t)virtqueue_paddr(vq));
 #endif
 		vtmmio_write_config_4(sc, VIRTIO_MMIO_QUEUE_PFN,
-			virtqueue_paddr(vq) >> PAGE_SHIFT);
+		    virtqueue_paddr(vq) >> PAGE_SHIFT);
 
 		vqx->vtv_vq = *info->vqai_vq = vq;
 		vqx->vtv_no_intr = info->vqai_intr == NULL;
@@ -592,6 +593,9 @@ vtmmio_reinit(device_t dev, uint64_t features)
 
 	vtmmio_negotiate_features(dev, features);
 
+	vtmmio_write_config_4(sc, VIRTIO_MMIO_GUEST_PAGE_SIZE,
+	    (1 << PAGE_SHIFT));
+
 	for (idx = 0; idx < sc->vtmmio_nvqs; idx++) {
 		error = vtmmio_reinit_virtqueue(sc, idx);
 		if (error)
@@ -766,6 +770,13 @@ vtmmio_reinit_virtqueue(struct vtmmio_softc *sc, int i
 	if (error)
 		return (error);
 
+	vtmmio_write_config_4(sc, VIRTIO_MMIO_QUEUE_NUM, size);
+	vtmmio_write_config_4(sc, VIRTIO_MMIO_QUEUE_ALIGN,
+	    VIRTIO_MMIO_VRING_ALIGN);
+#if 0
+	device_printf(sc->dev, "virtqueue paddr 0x%08lx\n",
+	    (uint64_t)virtqueue_paddr(vq));
+#endif
 	vtmmio_write_config_4(sc, VIRTIO_MMIO_QUEUE_PFN,
 	    virtqueue_paddr(vq) >> PAGE_SHIFT);
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201806151619.w5FGJB87006894>