yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-s390-bios-Decouple-channel-i-o-logic-from-virtio.patch

4ec855
From 9fa5a139c303dd7cedabafda03bcd79807b01086 Mon Sep 17 00:00:00 2001
4ec855
From: Thomas Huth <thuth@redhat.com>
4ec855
Date: Mon, 14 Oct 2019 10:06:34 +0100
4ec855
Subject: [PATCH 09/21] s390-bios: Decouple channel i/o logic from virtio
4ec855
4ec855
RH-Author: Thomas Huth <thuth@redhat.com>
4ec855
Message-id: <20191014100645.22862-7-thuth@redhat.com>
4ec855
Patchwork-id: 91779
4ec855
O-Subject: [RHEL-8.2.0 qemu-kvm PATCH v2 06/17] s390-bios: Decouple channel i/o logic from virtio
4ec855
Bugzilla: 1664376
4ec855
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
4ec855
RH-Acked-by: David Hildenbrand <david@redhat.com>
4ec855
RH-Acked-by: Jens Freimann <jfreimann@redhat.com>
4ec855
4ec855
From: "Jason J. Herne" <jjherne@linux.ibm.com>
4ec855
4ec855
Create a separate library for channel i/o related code. This decouples
4ec855
channel i/o operations from virtio and allows us to make use of them for
4ec855
the real dasd boot path.
4ec855
4ec855
Signed-off-by: Jason J. Herne <jjherne@linux.ibm.com>
4ec855
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
4ec855
Reviewed-by: Thomas Huth <thuth@redhat.com>
4ec855
Message-Id: <1554388475-18329-6-git-send-email-jjherne@linux.ibm.com>
4ec855
Signed-off-by: Thomas Huth <thuth@redhat.com>
4ec855
(cherry picked from commit 120d04103e3f870d0fcd2a23c2ada0a4a4f036cc)
4ec855
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
4ec855
---
4ec855
 pc-bios/s390-ccw/Makefile    |  2 +-
4ec855
 pc-bios/s390-ccw/cio.c       | 44 ++++++++++++++++++++++++++++++++++++++++++++
4ec855
 pc-bios/s390-ccw/cio.h       |  3 +++
4ec855
 pc-bios/s390-ccw/main.c      |  1 +
4ec855
 pc-bios/s390-ccw/netboot.mak |  2 +-
4ec855
 pc-bios/s390-ccw/netmain.c   |  1 +
4ec855
 pc-bios/s390-ccw/s390-ccw.h  |  1 -
4ec855
 pc-bios/s390-ccw/virtio.c    | 27 ++-------------------------
4ec855
 8 files changed, 53 insertions(+), 28 deletions(-)
4ec855
 create mode 100644 pc-bios/s390-ccw/cio.c
4ec855
4ec855
diff --git a/pc-bios/s390-ccw/Makefile b/pc-bios/s390-ccw/Makefile
4ec855
index 439e3cc..acca961 100644
4ec855
--- a/pc-bios/s390-ccw/Makefile
4ec855
+++ b/pc-bios/s390-ccw/Makefile
4ec855
@@ -10,7 +10,7 @@ $(call set-vpath, $(SRC_PATH)/pc-bios/s390-ccw)
4ec855
 .PHONY : all clean build-all
4ec855
 
4ec855
 OBJECTS = start.o main.o bootmap.o jump2ipl.o sclp.o menu.o \
4ec855
-	  virtio.o virtio-scsi.o virtio-blkdev.o libc.o
4ec855
+	  virtio.o virtio-scsi.o virtio-blkdev.o libc.o cio.o
4ec855
 
4ec855
 QEMU_CFLAGS := $(filter -W%, $(QEMU_CFLAGS))
4ec855
 QEMU_CFLAGS += -ffreestanding -fno-delete-null-pointer-checks -msoft-float
4ec855
diff --git a/pc-bios/s390-ccw/cio.c b/pc-bios/s390-ccw/cio.c
4ec855
new file mode 100644
4ec855
index 0000000..87c6b34
4ec855
--- /dev/null
4ec855
+++ b/pc-bios/s390-ccw/cio.c
4ec855
@@ -0,0 +1,44 @@
4ec855
+/*
4ec855
+ * S390 Channel I/O
4ec855
+ *
4ec855
+ * Copyright (c) 2013 Alexander Graf <agraf@suse.de>
4ec855
+ * Copyright (c) 2019 IBM Corp.
4ec855
+ *
4ec855
+ * Author(s): Jason J. Herne <jjherne@us.ibm.com>
4ec855
+ *
4ec855
+ * This work is licensed under the terms of the GNU GPL, version 2 or (at
4ec855
+ * your option) any later version. See the COPYING file in the top-level
4ec855
+ * directory.
4ec855
+ */
4ec855
+
4ec855
+#include "libc.h"
4ec855
+#include "s390-ccw.h"
4ec855
+#include "cio.h"
4ec855
+
4ec855
+static char chsc_page[PAGE_SIZE] __attribute__((__aligned__(PAGE_SIZE)));
4ec855
+
4ec855
+int enable_mss_facility(void)
4ec855
+{
4ec855
+    int ret;
4ec855
+    ChscAreaSda *sda_area = (ChscAreaSda *) chsc_page;
4ec855
+
4ec855
+    memset(sda_area, 0, PAGE_SIZE);
4ec855
+    sda_area->request.length = 0x0400;
4ec855
+    sda_area->request.code = 0x0031;
4ec855
+    sda_area->operation_code = 0x2;
4ec855
+
4ec855
+    ret = chsc(sda_area);
4ec855
+    if ((ret == 0) && (sda_area->response.code == 0x0001)) {
4ec855
+        return 0;
4ec855
+    }
4ec855
+    return -EIO;
4ec855
+}
4ec855
+
4ec855
+void enable_subchannel(SubChannelId schid)
4ec855
+{
4ec855
+    Schib schib;
4ec855
+
4ec855
+    stsch_err(schid, &schib);
4ec855
+    schib.pmcw.ena = 1;
4ec855
+    msch(schid, &schib);
4ec855
+}
4ec855
diff --git a/pc-bios/s390-ccw/cio.h b/pc-bios/s390-ccw/cio.h
4ec855
index ed5b2cb..218fd96 100644
4ec855
--- a/pc-bios/s390-ccw/cio.h
4ec855
+++ b/pc-bios/s390-ccw/cio.h
4ec855
@@ -213,6 +213,9 @@ typedef struct irb {
4ec855
     __u32 emw[8];
4ec855
 }  __attribute__ ((packed, aligned(4))) Irb;
4ec855
 
4ec855
+int enable_mss_facility(void);
4ec855
+void enable_subchannel(SubChannelId schid);
4ec855
+
4ec855
 /*
4ec855
  * Some S390 specific IO instructions as inline
4ec855
  */
4ec855
diff --git a/pc-bios/s390-ccw/main.c b/pc-bios/s390-ccw/main.c
4ec855
index 67df421..10f04c6 100644
4ec855
--- a/pc-bios/s390-ccw/main.c
4ec855
+++ b/pc-bios/s390-ccw/main.c
4ec855
@@ -10,6 +10,7 @@
4ec855
 
4ec855
 #include "libc.h"
4ec855
 #include "s390-ccw.h"
4ec855
+#include "cio.h"
4ec855
 #include "virtio.h"
4ec855
 
4ec855
 char stack[PAGE_SIZE * 8] __attribute__((__aligned__(PAGE_SIZE)));
4ec855
diff --git a/pc-bios/s390-ccw/netboot.mak b/pc-bios/s390-ccw/netboot.mak
4ec855
index 4f64128..d17b424 100644
4ec855
--- a/pc-bios/s390-ccw/netboot.mak
4ec855
+++ b/pc-bios/s390-ccw/netboot.mak
4ec855
@@ -1,7 +1,7 @@
4ec855
 
4ec855
 SLOF_DIR := $(SRC_PATH)/roms/SLOF
4ec855
 
4ec855
-NETOBJS := start.o sclp.o virtio.o virtio-net.o jump2ipl.o netmain.o \
4ec855
+NETOBJS := start.o sclp.o cio.o virtio.o virtio-net.o jump2ipl.o netmain.o \
4ec855
 	   libnet.a libc.a
4ec855
 
4ec855
 LIBC_INC := -nostdinc -I$(SLOF_DIR)/lib/libc/include
4ec855
diff --git a/pc-bios/s390-ccw/netmain.c b/pc-bios/s390-ccw/netmain.c
4ec855
index d60e84f..4e1b8cf 100644
4ec855
--- a/pc-bios/s390-ccw/netmain.c
4ec855
+++ b/pc-bios/s390-ccw/netmain.c
4ec855
@@ -32,6 +32,7 @@
4ec855
 #include <time.h>
4ec855
 
4ec855
 #include "s390-ccw.h"
4ec855
+#include "cio.h"
4ec855
 #include "virtio.h"
4ec855
 
4ec855
 #define DEFAULT_BOOT_RETRIES 10
4ec855
diff --git a/pc-bios/s390-ccw/s390-ccw.h b/pc-bios/s390-ccw/s390-ccw.h
4ec855
index 241c6d0..b39ee5d 100644
4ec855
--- a/pc-bios/s390-ccw/s390-ccw.h
4ec855
+++ b/pc-bios/s390-ccw/s390-ccw.h
4ec855
@@ -72,7 +72,6 @@ unsigned long virtio_load_direct(ulong rec_list1, ulong rec_list2,
4ec855
 bool virtio_is_supported(SubChannelId schid);
4ec855
 void virtio_blk_setup_device(SubChannelId schid);
4ec855
 int virtio_read(ulong sector, void *load_addr);
4ec855
-int enable_mss_facility(void);
4ec855
 u64 get_clock(void);
4ec855
 ulong get_second(void);
4ec855
 
4ec855
diff --git a/pc-bios/s390-ccw/virtio.c b/pc-bios/s390-ccw/virtio.c
4ec855
index cdb66f4..aa9da72 100644
4ec855
--- a/pc-bios/s390-ccw/virtio.c
4ec855
+++ b/pc-bios/s390-ccw/virtio.c
4ec855
@@ -10,6 +10,7 @@
4ec855
 
4ec855
 #include "libc.h"
4ec855
 #include "s390-ccw.h"
4ec855
+#include "cio.h"
4ec855
 #include "virtio.h"
4ec855
 #include "virtio-scsi.h"
4ec855
 #include "bswap.h"
4ec855
@@ -20,8 +21,6 @@ static VRing block[VIRTIO_MAX_VQS];
4ec855
 static char ring_area[VIRTIO_RING_SIZE * VIRTIO_MAX_VQS]
4ec855
                      __attribute__((__aligned__(PAGE_SIZE)));
4ec855
 
4ec855
-static char chsc_page[PAGE_SIZE] __attribute__((__aligned__(PAGE_SIZE)));
4ec855
-
4ec855
 static VDev vdev = {
4ec855
     .nr_vqs = 1,
4ec855
     .vrings = block,
4ec855
@@ -94,14 +93,9 @@ static int run_ccw(VDev *vdev, int cmd, void *ptr, int len)
4ec855
 {
4ec855
     Ccw1 ccw = {};
4ec855
     CmdOrb orb = {};
4ec855
-    Schib schib;
4ec855
     int r;
4ec855
 
4ec855
-    /* start command processing */
4ec855
-    stsch_err(vdev->schid, &schib);
4ec855
-    /* enable the subchannel for IPL device */
4ec855
-    schib.pmcw.ena = 1;
4ec855
-    msch(vdev->schid, &schib);
4ec855
+    enable_subchannel(vdev->schid);
4ec855
 
4ec855
     /* start subchannel command */
4ec855
     orb.fmt = 1;
4ec855
@@ -343,20 +337,3 @@ bool virtio_is_supported(SubChannelId schid)
4ec855
     }
4ec855
     return false;
4ec855
 }
4ec855
-
4ec855
-int enable_mss_facility(void)
4ec855
-{
4ec855
-    int ret;
4ec855
-    ChscAreaSda *sda_area = (ChscAreaSda *) chsc_page;
4ec855
-
4ec855
-    memset(sda_area, 0, PAGE_SIZE);
4ec855
-    sda_area->request.length = 0x0400;
4ec855
-    sda_area->request.code = 0x0031;
4ec855
-    sda_area->operation_code = 0x2;
4ec855
-
4ec855
-    ret = chsc(sda_area);
4ec855
-    if ((ret == 0) && (sda_area->response.code == 0x0001)) {
4ec855
-        return 0;
4ec855
-    }
4ec855
-    return -EIO;
4ec855
-}
4ec855
-- 
4ec855
1.8.3.1
4ec855