Source-Changes-HG archive

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

[src/netbsd-8]: src/sys/dev/pci Pull up following revision(s) (requested by j...



details:   https://anonhg.NetBSD.org/src/rev/13518d56404d
branches:  netbsd-8
changeset: 939015:13518d56404d
user:      martin <martin%NetBSD.org@localhost>
date:      Wed Sep 23 14:31:46 2020 +0000

description:
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.

diffstat:

 sys/dev/pci/virtio.c |  14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diffs (46 lines):

diff -r d6d1a8b59883 -r 13518d56404d sys/dev/pci/virtio.c
--- a/sys/dev/pci/virtio.c      Sun Sep 20 10:23:05 2020 +0000
+++ b/sys/dev/pci/virtio.c      Wed Sep 23 14:31:46 2020 +0000
@@ -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 @@
 {
        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 @@
 
                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);



Home | Main Index | Thread Index | Old Index