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

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