Blame SOURCES/0028-migcompat-e1000e-Work-around-7.3-msi-intr_state-fiel.patch

4a2fec
From cc306393d79691b82c1f5f660a01bf00fe0775e9 Mon Sep 17 00:00:00 2001
4a2fec
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
4a2fec
Date: Thu, 9 Feb 2017 13:06:18 +0100
4a2fec
Subject: migcompat/e1000e: Work around 7.3 msi/intr_state field
4a2fec
4a2fec
RH-Author: Dr. David Alan Gilbert <dgilbert@redhat.com>
4a2fec
Message-id: <20170209130618.20328-1-dgilbert@redhat.com>
4a2fec
Patchwork-id: 73730
4a2fec
O-Subject: [RHEL-7.4 qemu-kvm-rhev PATCH 1/1] migcompat/e1000e: Work around 7.3 msi/intr_state field
4a2fec
Bugzilla: 1420216
4a2fec
RH-Acked-by: Thomas Huth <thuth@redhat.com>
4a2fec
RH-Acked-by: Xiao Wang <jasowang@redhat.com>
4a2fec
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
4a2fec
4a2fec
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
4a2fec
4a2fec
bz: https://bugzilla.redhat.com/show_bug.cgi?id=1420216
4a2fec
brew: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=12518741
4a2fec
upstream: No, fixing downstream inconsistency
4a2fec
4a2fec
Our 7.3 e1000e model has an 'intr_state' field that's used
4a2fec
only in the cleanup of msi & msix.
4a2fec
4a2fec
e1000e was introducing in 2.7 but was backported to the 2.6 based
4a2fec
qemu-kvm-rhev 7.3 by backporting 6f3fbe4 and 103916.
4a2fec
4a2fec
During the 2.7rc's the migration structure was changed by
4a2fec
e0af5a0e8 and 66bf7d but we never pulled those into 7.3 which
4a2fec
removed the 'intr_state' field.
4a2fec
4a2fec
For compatibility add the field back (guarded by a property on 7.3)
4a2fec
and populate the values based on the source MSI state.
4a2fec
Since the flags were only used for cleanup I don't think
4a2fec
we need to pay attention to the value we receive.
4a2fec
4a2fec
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
4a2fec
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
4a2fec
(cherry picked from commit 7b3c2e676cd62e947e9b020bba9309a171e94c9e)
4a2fec
---
4a2fec
 hw/net/e1000e.c     | 21 +++++++++++++++++++++
4a2fec
 include/hw/compat.h |  4 ++++
4a2fec
 2 files changed, 25 insertions(+)
4a2fec
4a2fec
diff --git a/hw/net/e1000e.c b/hw/net/e1000e.c
4a2fec
index 2c91d07..d6ca464 100644
4a2fec
--- a/hw/net/e1000e.c
4a2fec
+++ b/hw/net/e1000e.c
4a2fec
@@ -74,6 +74,11 @@ typedef struct E1000EState {
4a2fec
 
4a2fec
     E1000ECore core;
4a2fec
 
4a2fec
+    /* 7.3 had the intr_state field that was in the original e1000e code
4a2fec
+     * but that was removed prior to 2.7's release
4a2fec
+     */
4a2fec
+    bool redhat_7_3_intr_state_enable;
4a2fec
+    uint32_t redhat_7_3_intr_state;
4a2fec
 } E1000EState;
4a2fec
 
4a2fec
 #define E1000E_MMIO_IDX     0
4a2fec
@@ -89,6 +94,10 @@ typedef struct E1000EState {
4a2fec
 #define E1000E_MSIX_TABLE   (0x0000)
4a2fec
 #define E1000E_MSIX_PBA     (0x2000)
4a2fec
 
4a2fec
+/* Values as in RHEL 7.3 build and original upstream */
4a2fec
+#define RH_E1000E_USE_MSI     BIT(0)
4a2fec
+#define RH_E1000E_USE_MSIX    BIT(1)
4a2fec
+
4a2fec
 static uint64_t
4a2fec
 e1000e_mmio_read(void *opaque, hwaddr addr, unsigned size)
4a2fec
 {
4a2fec
@@ -300,6 +309,8 @@ e1000e_init_msix(E1000EState *s)
4a2fec
     } else {
4a2fec
         if (!e1000e_use_msix_vectors(s, E1000E_MSIX_VEC_NUM)) {
4a2fec
             msix_uninit(d, &s->msix, &s->msix);
4a2fec
+        } else {
4a2fec
+            s->redhat_7_3_intr_state |= RH_E1000E_USE_MSIX;
4a2fec
         }
4a2fec
     }
4a2fec
 }
4a2fec
@@ -471,6 +482,8 @@ static void e1000e_pci_realize(PCIDevice *pci_dev, Error **errp)
4a2fec
     ret = msi_init(PCI_DEVICE(s), 0xD0, 1, true, false, NULL);
4a2fec
     if (ret) {
4a2fec
         trace_e1000e_msi_init_fail(ret);
4a2fec
+    } else {
4a2fec
+        s->redhat_7_3_intr_state |= RH_E1000E_USE_MSI;
4a2fec
     }
4a2fec
 
4a2fec
     if (e1000e_add_pm_capability(pci_dev, e1000e_pmrb_offset,
4a2fec
@@ -592,6 +605,11 @@ static const VMStateDescription e1000e_vmstate_intr_timer = {
4a2fec
     VMSTATE_STRUCT_ARRAY(_f, _s, _num, 0,                           \
4a2fec
                          e1000e_vmstate_intr_timer, E1000IntrDelayTimer)
4a2fec
 
4a2fec
+static bool rhel_7_3_check(void *opaque, int version_id)
4a2fec
+{
4a2fec
+    return ((E1000EState *)opaque)->redhat_7_3_intr_state_enable;
4a2fec
+}
4a2fec
+
4a2fec
 static const VMStateDescription e1000e_vmstate = {
4a2fec
     .name = "e1000e",
4a2fec
     .version_id = 1,
4a2fec
@@ -603,6 +621,7 @@ static const VMStateDescription e1000e_vmstate = {
4a2fec
         VMSTATE_MSIX(parent_obj, E1000EState),
4a2fec
 
4a2fec
         VMSTATE_UINT32(ioaddr, E1000EState),
4a2fec
+        VMSTATE_UINT32_TEST(redhat_7_3_intr_state, E1000EState, rhel_7_3_check),
4a2fec
         VMSTATE_UINT32(core.rxbuf_min_shift, E1000EState),
4a2fec
         VMSTATE_UINT8(core.rx_desc_len, E1000EState),
4a2fec
         VMSTATE_UINT32_ARRAY(core.rxbuf_sizes, E1000EState,
4a2fec
@@ -651,6 +670,8 @@ static PropertyInfo e1000e_prop_disable_vnet,
4a2fec
 
4a2fec
 static Property e1000e_properties[] = {
4a2fec
     DEFINE_NIC_PROPERTIES(E1000EState, conf),
4a2fec
+    DEFINE_PROP_BOOL("__redhat_e1000e_7_3_intr_state", E1000EState,
4a2fec
+                        redhat_7_3_intr_state_enable, false),
4a2fec
     DEFINE_PROP_SIGNED("disable_vnet_hdr", E1000EState, disable_vnet, false,
4a2fec
                         e1000e_prop_disable_vnet, bool),
4a2fec
     DEFINE_PROP_SIGNED("subsys_ven", E1000EState, subsys_ven,
4a2fec
diff --git a/include/hw/compat.h b/include/hw/compat.h
4a2fec
index bb138cd..56cefc9 100644
4a2fec
--- a/include/hw/compat.h
4a2fec
+++ b/include/hw/compat.h
4a2fec
@@ -407,6 +407,10 @@
4a2fec
         .driver   = "virtio-pci",\
4a2fec
         .property = "x-pcie-pm-init",\
4a2fec
         .value    = "off",\
4a2fec
+    },{ /* HW_COMPAT_RHEL7_3 */ \
4a2fec
+        .driver   = "e1000e",\
4a2fec
+        .property = "__redhat_e1000e_7_3_intr_state",\
4a2fec
+        .value    = "on",\
4a2fec
     },
4a2fec
 
4a2fec
 #endif /* HW_COMPAT_H */
4a2fec
-- 
4a2fec
1.8.3.1
4a2fec