yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-s390x-css-Refactor-the-css_queue_crw-routine.patch

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