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

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