Module Name:    src
Committed By:   yamaguchi
Date:           Wed May 27 11:24:31 UTC 2020

Modified Files:
        src/sys/dev/pci: virtio_pci.c

Log Message:
Fix to allocate resources actuall used around interrupts


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/dev/pci/virtio_pci.c

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_pci.c
diff -u src/sys/dev/pci/virtio_pci.c:1.10 src/sys/dev/pci/virtio_pci.c:1.11
--- src/sys/dev/pci/virtio_pci.c:1.10	Mon May 25 07:52:16 2020
+++ src/sys/dev/pci/virtio_pci.c	Wed May 27 11:24:31 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: virtio_pci.c,v 1.10 2020/05/25 07:52:16 yamaguchi Exp $ */
+/* $NetBSD: virtio_pci.c,v 1.11 2020/05/27 11:24:31 yamaguchi Exp $ */
 
 /*
  * Copyright (c) 2010 Minoura Makoto.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: virtio_pci.c,v 1.10 2020/05/25 07:52:16 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: virtio_pci.c,v 1.11 2020/05/27 11:24:31 yamaguchi Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -677,12 +677,16 @@ virtio_pci_setup_interrupts(struct virti
 		counts[PCI_INTR_TYPE_INTX] = 1;
 	} else {
 		/* Try MSI-X first and INTx second */
-		if (sc->sc_child_mq &&
-		    sc->sc_nvqs > (nmsix - VIRTIO_MSIX_QUEUE_VECTOR_INDEX)) {
-			nmsix = 2;
+		if (sc->sc_nvqs + VIRTIO_MSIX_QUEUE_VECTOR_INDEX <= nmsix) {
+			nmsix = sc->sc_nvqs + VIRTIO_MSIX_QUEUE_VECTOR_INDEX;
+		} else {
 			sc->sc_child_mq = false;
 		}
 
+		if (sc->sc_child_mq == false) {
+			nmsix = 2;
+		}
+
 		max_type = PCI_INTR_TYPE_MSIX;
 		counts[PCI_INTR_TYPE_MSIX] = nmsix;
 		counts[PCI_INTR_TYPE_MSI] = 0;

Reply via email to