thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone
ddf19c
From 04d4e7eda95316b64ea9dc0f4ca8801d531652e7 Mon Sep 17 00:00:00 2001
ddf19c
From: Cornelia Huck <cohuck@redhat.com>
ddf19c
Date: Tue, 23 Jun 2020 09:25:41 -0400
ddf19c
Subject: [PATCH 07/12] s390x/css: Refactor the css_queue_crw() routine
ddf19c
ddf19c
RH-Author: Cornelia Huck <cohuck@redhat.com>
ddf19c
Message-id: <20200623092543.358315-8-cohuck@redhat.com>
ddf19c
Patchwork-id: 97700
ddf19c
O-Subject: [RHEL-8.3.0 qemu-kvm PATCH 7/9] s390x/css: Refactor the css_queue_crw() routine
ddf19c
Bugzilla: 1660916
ddf19c
RH-Acked-by: Claudio Imbrenda <cimbrend@redhat.com>
ddf19c
RH-Acked-by: David Hildenbrand <david@redhat.com>
ddf19c
RH-Acked-by: Thomas Huth <thuth@redhat.com>
ddf19c
ddf19c
From: Eric Farman <farman@linux.ibm.com>
ddf19c
ddf19c
We have a use case (vfio-ccw) where a CRW is already built and
ddf19c
ready to use.  Rather than teasing out the components just to
ddf19c
reassemble it later, let's rework this code so we can queue a
ddf19c
fully-qualified CRW directly.
ddf19c
ddf19c
Signed-off-by: Eric Farman <farman@linux.ibm.com>
ddf19c
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
ddf19c
Message-Id: <20200505125757.98209-6-farman@linux.ibm.com>
ddf19c
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
ddf19c
(cherry picked from commit f6dde1b012e678aa64339520ef7519ec04026cf1)
ddf19c
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
ddf19c
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
ddf19c
---
ddf19c
 hw/s390x/css.c         | 44 ++++++++++++++++++++++++++++--------------
ddf19c
 include/hw/s390x/css.h |  1 +
ddf19c
 2 files changed, 30 insertions(+), 15 deletions(-)
ddf19c
ddf19c
diff --git a/hw/s390x/css.c b/hw/s390x/css.c
ddf19c
index 71fd3f9a00..a8de8a0c84 100644
ddf19c
--- a/hw/s390x/css.c
ddf19c
+++ b/hw/s390x/css.c
ddf19c
@@ -2170,30 +2170,23 @@ void css_subch_assign(uint8_t cssid, uint8_t ssid, uint16_t schid,
ddf19c
     }
ddf19c
 }
ddf19c
 
ddf19c
-void css_queue_crw(uint8_t rsc, uint8_t erc, int solicited,
ddf19c
-                   int chain, uint16_t rsid)
ddf19c
+void css_crw_add_to_queue(CRW crw)
ddf19c
 {
ddf19c
     CrwContainer *crw_cont;
ddf19c
 
ddf19c
-    trace_css_crw(rsc, erc, rsid, chain ? "(chained)" : "");
ddf19c
+    trace_css_crw((crw.flags & CRW_FLAGS_MASK_RSC) >> 8,
ddf19c
+                  crw.flags & CRW_FLAGS_MASK_ERC,
ddf19c
+                  crw.rsid,
ddf19c
+                  (crw.flags & CRW_FLAGS_MASK_C) ? "(chained)" : "");
ddf19c
+
ddf19c
     /* TODO: Maybe use a static crw pool? */
ddf19c
     crw_cont = g_try_new0(CrwContainer, 1);
ddf19c
     if (!crw_cont) {
ddf19c
         channel_subsys.crws_lost = true;
ddf19c
         return;
ddf19c
     }
ddf19c
-    crw_cont->crw.flags = (rsc << 8) | erc;
ddf19c
-    if (solicited) {
ddf19c
-        crw_cont->crw.flags |= CRW_FLAGS_MASK_S;
ddf19c
-    }
ddf19c
-    if (chain) {
ddf19c
-        crw_cont->crw.flags |= CRW_FLAGS_MASK_C;
ddf19c
-    }
ddf19c
-    crw_cont->crw.rsid = rsid;
ddf19c
-    if (channel_subsys.crws_lost) {
ddf19c
-        crw_cont->crw.flags |= CRW_FLAGS_MASK_R;
ddf19c
-        channel_subsys.crws_lost = false;
ddf19c
-    }
ddf19c
+
ddf19c
+    crw_cont->crw = crw;
ddf19c
 
ddf19c
     QTAILQ_INSERT_TAIL(&channel_subsys.pending_crws, crw_cont, sibling);
ddf19c
 
ddf19c
@@ -2204,6 +2197,27 @@ void css_queue_crw(uint8_t rsc, uint8_t erc, int solicited,
ddf19c
     }
ddf19c
 }
ddf19c
 
ddf19c
+void css_queue_crw(uint8_t rsc, uint8_t erc, int solicited,
ddf19c
+                   int chain, uint16_t rsid)
ddf19c
+{
ddf19c
+    CRW crw;
ddf19c
+
ddf19c
+    crw.flags = (rsc << 8) | erc;
ddf19c
+    if (solicited) {
ddf19c
+        crw.flags |= CRW_FLAGS_MASK_S;
ddf19c
+    }
ddf19c
+    if (chain) {
ddf19c
+        crw.flags |= CRW_FLAGS_MASK_C;
ddf19c
+    }
ddf19c
+    crw.rsid = rsid;
ddf19c
+    if (channel_subsys.crws_lost) {
ddf19c
+        crw.flags |= CRW_FLAGS_MASK_R;
ddf19c
+        channel_subsys.crws_lost = false;
ddf19c
+    }
ddf19c
+
ddf19c
+    css_crw_add_to_queue(crw);
ddf19c
+}
ddf19c
+
ddf19c
 void css_generate_sch_crws(uint8_t cssid, uint8_t ssid, uint16_t schid,
ddf19c
                            int hotplugged, int add)
ddf19c
 {
ddf19c
diff --git a/include/hw/s390x/css.h b/include/hw/s390x/css.h
ddf19c
index 7e3a5e7433..08c869ab0a 100644
ddf19c
--- a/include/hw/s390x/css.h
ddf19c
+++ b/include/hw/s390x/css.h
ddf19c
@@ -205,6 +205,7 @@ void copy_scsw_to_guest(SCSW *dest, const SCSW *src);
ddf19c
 void css_inject_io_interrupt(SubchDev *sch);
ddf19c
 void css_reset(void);
ddf19c
 void css_reset_sch(SubchDev *sch);
ddf19c
+void css_crw_add_to_queue(CRW crw);
ddf19c
 void css_queue_crw(uint8_t rsc, uint8_t erc, int solicited,
ddf19c
                    int chain, uint16_t rsid);
ddf19c
 void css_generate_sch_crws(uint8_t cssid, uint8_t ssid, uint16_t schid,
ddf19c
-- 
ddf19c
2.27.0
ddf19c