Module Name: src
Committed By: martin
Date: Wed Sep 23 14:31:47 UTC 2020
Modified Files:
src/sys/dev/pci [netbsd-8]: virtio.c
Log Message:
Pull up following revision(s) (requested by jakllsch in ticket #1609):
sys/dev/pci/virtio_pci.c: revision 1.13 (patch)
(applied to sys/dev/pci/virtio.c)
Ensure MSI-X is disabled if allocation of MSI-X interrupts fail.
The virtio device config space moves out from under us when MSI-X
remains enabled, and/or INTx interrupts are masked if we don't ensure
this.
This un-breaks virtio devices that run out of MSI-X interrupts.
Particularly a problem on uniproc x86, where there are only 8 or 9
vectors available, allowing for only about 4 virtio devices to use
MSI-X.
To generate a diff of this commit:
cvs rdiff -u -r1.28.2.2 -r1.28.2.3 src/sys/dev/pci/virtio.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.c
diff -u src/sys/dev/pci/virtio.c:1.28.2.2 src/sys/dev/pci/virtio.c:1.28.2.3
--- src/sys/dev/pci/virtio.c:1.28.2.2 Sun Sep 20 10:14:20 2020
+++ src/sys/dev/pci/virtio.c Wed Sep 23 14:31:46 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: virtio.c,v 1.28.2.2 2020/09/20 10:14:20 martin Exp $ */
+/* $NetBSD: virtio.c,v 1.28.2.3 2020/09/23 14:31:46 martin Exp $ */
/*
* Copyright (c) 2010 Minoura Makoto.
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: virtio.c,v 1.28.2.2 2020/09/20 10:14:20 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: virtio.c,v 1.28.2.3 2020/09/23 14:31:46 martin Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -280,10 +280,13 @@ virtio_setup_interrupts(struct virtio_so
{
device_t self = sc->sc_dev;
pci_chipset_tag_t pc = sc->sc_pa.pa_pc;
+ pcitag_t tag = sc->sc_pa.pa_tag;
int error;
int nmsix;
+ int off;
int counts[PCI_INTR_TYPE_SIZE];
pci_intr_type_t max_type;
+ pcireg_t ctl;
nmsix = pci_msix_count(sc->sc_pa.pa_pc, sc->sc_pa.pa_tag);
aprint_debug_dev(self, "pci_msix_count=%d\n", nmsix);
@@ -338,6 +341,13 @@ virtio_setup_interrupts(struct virtio_so
sc->sc_ihs_num = 1;
sc->sc_config_offset = VIRTIO_CONFIG_DEVICE_CONFIG_NOMSI;
+
+ error = pci_get_capability(pc, tag, PCI_CAP_MSIX, &off, NULL);
+ if (error != 0) {
+ ctl = pci_conf_read(pc, tag, off + PCI_MSIX_CTL);
+ ctl &= ~PCI_MSIX_CTL_ENABLE;
+ pci_conf_write(pc, tag, off + PCI_MSIX_CTL, ctl);
+ }
}
KASSERT(sc->sc_soft_ih == NULL);