Blame SOURCES/kvm-hw-pci-host-gpex-Improve-INTX-to-gsi-routing-error-c.patch

4a2fec
From 8c777547f451a6d93ae258bbc794be6752af05c4 Mon Sep 17 00:00:00 2001
4a2fec
From: Auger Eric <eric.auger@redhat.com>
4a2fec
Date: Mon, 6 Nov 2017 17:08:45 +0100
4a2fec
Subject: [PATCH 9/9] hw/pci-host/gpex: Improve INTX to gsi routing error
4a2fec
 checking
4a2fec
4a2fec
RH-Author: Auger Eric <eric.auger@redhat.com>
4a2fec
Message-id: <1509988125-30275-5-git-send-email-eric.auger@redhat.com>
4a2fec
Patchwork-id: 77511
4a2fec
O-Subject: [RHV7.5 qemu-kvm-ma PATCH 4/4] hw/pci-host/gpex: Improve INTX to gsi routing error checking
4a2fec
Bugzilla: 1460957
4a2fec
RH-Acked-by: Alex Williamson <alex.williamson@redhat.com>
4a2fec
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
4a2fec
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
4a2fec
4a2fec
We exposed gpex_set_irq_num() for machines to set the INTx to
4a2fec
GSI routing. However if the machine forgets to call that
4a2fec
function we currently do not check the association was properly
4a2fec
done. Let's initialize gsi values to -1 and if this value is
4a2fec
found in gpex_route_intx_pin_to_irq, set the routing mode as
4a2fec
disabled.
4a2fec
4a2fec
Signed-off-by: Eric Auger <eric.auger@redhat.com>
4a2fec
Message-id: 1508776211-22175-1-git-send-email-eric.auger@redhat.com
4a2fec
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
4a2fec
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4a2fec
(cherry picked from commit 168df2dea701bbf3118bdfea7794369dfa694d3d)
4a2fec
Signed-off-by: Eric Auger <eric.auger@redhat.com>
4a2fec
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
4a2fec
---
4a2fec
 hw/pci-host/gpex.c | 10 ++++++++--
4a2fec
 1 file changed, 8 insertions(+), 2 deletions(-)
4a2fec
4a2fec
diff --git a/hw/pci-host/gpex.c b/hw/pci-host/gpex.c
4a2fec
index 4090793..edf305b 100644
4a2fec
--- a/hw/pci-host/gpex.c
4a2fec
+++ b/hw/pci-host/gpex.c
4a2fec
@@ -57,9 +57,14 @@ static PCIINTxRoute gpex_route_intx_pin_to_irq(void *opaque, int pin)
4a2fec
 {
4a2fec
     PCIINTxRoute route;
4a2fec
     GPEXHost *s = opaque;
4a2fec
+    int gsi = s->irq_num[pin];
4a2fec
 
4a2fec
-    route.mode = PCI_INTX_ENABLED;
4a2fec
-    route.irq = s->irq_num[pin];
4a2fec
+    route.irq = gsi;
4a2fec
+    if (gsi < 0) {
4a2fec
+        route.mode = PCI_INTX_DISABLED;
4a2fec
+    } else {
4a2fec
+        route.mode = PCI_INTX_ENABLED;
4a2fec
+    }
4a2fec
 
4a2fec
     return route;
4a2fec
 }
4a2fec
@@ -81,6 +86,7 @@ static void gpex_host_realize(DeviceState *dev, Error **errp)
4a2fec
     sysbus_init_mmio(sbd, &s->io_ioport);
4a2fec
     for (i = 0; i < GPEX_NUM_IRQS; i++) {
4a2fec
         sysbus_init_irq(sbd, &s->irq[i]);
4a2fec
+        s->irq_num[i] = -1;
4a2fec
     }
4a2fec
 
4a2fec
     pci->bus = pci_register_bus(dev, "pcie.0", gpex_set_irq,
4a2fec
-- 
4a2fec
1.8.3.1
4a2fec