|
|
a19a21 |
From d90cbb55fe3ec232091a24137cab45419aac8bc5 Mon Sep 17 00:00:00 2001
|
|
|
a19a21 |
From: Thomas Huth <thuth@redhat.com>
|
|
|
a19a21 |
Date: Fri, 9 Oct 2020 10:08:44 -0400
|
|
|
a19a21 |
Subject: [PATCH 08/14] pc-bios/s390-ccw: Move the inner logic of find_subch()
|
|
|
a19a21 |
to a separate function
|
|
|
a19a21 |
|
|
|
a19a21 |
RH-Author: Thomas Huth <thuth@redhat.com>
|
|
|
a19a21 |
Message-id: <20201009100849.264994-5-thuth@redhat.com>
|
|
|
a19a21 |
Patchwork-id: 98598
|
|
|
a19a21 |
O-Subject: [RHEL-8.4.0 qemu-kvm PATCH 4/9] pc-bios/s390-ccw: Move the inner logic of find_subch() to a separate function
|
|
|
a19a21 |
Bugzilla: 1846975
|
|
|
a19a21 |
RH-Acked-by: Jens Freimann <jfreimann@redhat.com>
|
|
|
a19a21 |
RH-Acked-by: David Hildenbrand <david@redhat.com>
|
|
|
a19a21 |
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
|
|
|
a19a21 |
|
|
|
a19a21 |
Move the code to a separate function to be able to re-use it from a
|
|
|
a19a21 |
different spot later.
|
|
|
a19a21 |
|
|
|
a19a21 |
Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
|
|
|
a19a21 |
Message-Id: <20200806105349.632-5-thuth@redhat.com>
|
|
|
a19a21 |
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
|
|
|
a19a21 |
Reviewed-by: Janosch Frank <frankja@linux.ibm.com>
|
|
|
a19a21 |
Signed-off-by: Thomas Huth <thuth@redhat.com>
|
|
|
a19a21 |
(cherry picked from commit d2cf4af1f4af02f6f2d5827d9a06c31690084d3b)
|
|
|
a19a21 |
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
|
|
a19a21 |
---
|
|
|
a19a21 |
pc-bios/s390-ccw/main.c | 99 ++++++++++++++++++++++++-----------------
|
|
|
a19a21 |
1 file changed, 57 insertions(+), 42 deletions(-)
|
|
|
a19a21 |
|
|
|
a19a21 |
diff --git a/pc-bios/s390-ccw/main.c b/pc-bios/s390-ccw/main.c
|
|
|
a19a21 |
index 5e565be5b1..d6fd218074 100644
|
|
|
a19a21 |
--- a/pc-bios/s390-ccw/main.c
|
|
|
a19a21 |
+++ b/pc-bios/s390-ccw/main.c
|
|
|
a19a21 |
@@ -60,6 +60,60 @@ unsigned int get_loadparm_index(void)
|
|
|
a19a21 |
return atoui(loadparm_str);
|
|
|
a19a21 |
}
|
|
|
a19a21 |
|
|
|
a19a21 |
+static int is_dev_possibly_bootable(int dev_no, int sch_no)
|
|
|
a19a21 |
+{
|
|
|
a19a21 |
+ bool is_virtio;
|
|
|
a19a21 |
+ Schib schib;
|
|
|
a19a21 |
+ int r;
|
|
|
a19a21 |
+
|
|
|
a19a21 |
+ blk_schid.sch_no = sch_no;
|
|
|
a19a21 |
+ r = stsch_err(blk_schid, &schib);
|
|
|
a19a21 |
+ if (r == 3 || r == -EIO) {
|
|
|
a19a21 |
+ return -ENODEV;
|
|
|
a19a21 |
+ }
|
|
|
a19a21 |
+ if (!schib.pmcw.dnv) {
|
|
|
a19a21 |
+ return false;
|
|
|
a19a21 |
+ }
|
|
|
a19a21 |
+
|
|
|
a19a21 |
+ enable_subchannel(blk_schid);
|
|
|
a19a21 |
+ cutype = cu_type(blk_schid);
|
|
|
a19a21 |
+
|
|
|
a19a21 |
+ /*
|
|
|
a19a21 |
+ * Note: we always have to run virtio_is_supported() here to make
|
|
|
a19a21 |
+ * sure that the vdev.senseid data gets pre-initialized correctly
|
|
|
a19a21 |
+ */
|
|
|
a19a21 |
+ is_virtio = virtio_is_supported(blk_schid);
|
|
|
a19a21 |
+
|
|
|
a19a21 |
+ /* No specific devno given, just return whether the device is possibly bootable */
|
|
|
a19a21 |
+ if (dev_no < 0) {
|
|
|
a19a21 |
+ switch (cutype) {
|
|
|
a19a21 |
+ case CU_TYPE_VIRTIO:
|
|
|
a19a21 |
+ if (is_virtio) {
|
|
|
a19a21 |
+ /*
|
|
|
a19a21 |
+ * Skip net devices since no IPLB is created and therefore
|
|
|
a19a21 |
+ * no network bootloader has been loaded
|
|
|
a19a21 |
+ */
|
|
|
a19a21 |
+ if (virtio_get_device_type() != VIRTIO_ID_NET) {
|
|
|
a19a21 |
+ return true;
|
|
|
a19a21 |
+ }
|
|
|
a19a21 |
+ }
|
|
|
a19a21 |
+ return false;
|
|
|
a19a21 |
+ case CU_TYPE_DASD_3990:
|
|
|
a19a21 |
+ case CU_TYPE_DASD_2107:
|
|
|
a19a21 |
+ return true;
|
|
|
a19a21 |
+ default:
|
|
|
a19a21 |
+ return false;
|
|
|
a19a21 |
+ }
|
|
|
a19a21 |
+ }
|
|
|
a19a21 |
+
|
|
|
a19a21 |
+ /* Caller asked for a specific devno */
|
|
|
a19a21 |
+ if (schib.pmcw.dev == dev_no) {
|
|
|
a19a21 |
+ return true;
|
|
|
a19a21 |
+ }
|
|
|
a19a21 |
+
|
|
|
a19a21 |
+ return false;
|
|
|
a19a21 |
+}
|
|
|
a19a21 |
+
|
|
|
a19a21 |
/*
|
|
|
a19a21 |
* Find the subchannel connected to the given device (dev_no) and fill in the
|
|
|
a19a21 |
* subchannel information block (schib) with the connected subchannel's info.
|
|
|
a19a21 |
@@ -71,53 +125,14 @@ unsigned int get_loadparm_index(void)
|
|
|
a19a21 |
*/
|
|
|
a19a21 |
static bool find_subch(int dev_no)
|
|
|
a19a21 |
{
|
|
|
a19a21 |
- Schib schib;
|
|
|
a19a21 |
int i, r;
|
|
|
a19a21 |
- bool is_virtio;
|
|
|
a19a21 |
|
|
|
a19a21 |
for (i = 0; i < 0x10000; i++) {
|
|
|
a19a21 |
- blk_schid.sch_no = i;
|
|
|
a19a21 |
- r = stsch_err(blk_schid, &schib);
|
|
|
a19a21 |
- if ((r == 3) || (r == -EIO)) {
|
|
|
a19a21 |
+ r = is_dev_possibly_bootable(dev_no, i);
|
|
|
a19a21 |
+ if (r < 0) {
|
|
|
a19a21 |
break;
|
|
|
a19a21 |
}
|
|
|
a19a21 |
- if (!schib.pmcw.dnv) {
|
|
|
a19a21 |
- continue;
|
|
|
a19a21 |
- }
|
|
|
a19a21 |
-
|
|
|
a19a21 |
- enable_subchannel(blk_schid);
|
|
|
a19a21 |
- cutype = cu_type(blk_schid);
|
|
|
a19a21 |
-
|
|
|
a19a21 |
- /*
|
|
|
a19a21 |
- * Note: we always have to run virtio_is_supported() here to make
|
|
|
a19a21 |
- * sure that the vdev.senseid data gets pre-initialized correctly
|
|
|
a19a21 |
- */
|
|
|
a19a21 |
- is_virtio = virtio_is_supported(blk_schid);
|
|
|
a19a21 |
-
|
|
|
a19a21 |
- /* No specific devno given, just return 1st possibly bootable device */
|
|
|
a19a21 |
- if (dev_no < 0) {
|
|
|
a19a21 |
- switch (cutype) {
|
|
|
a19a21 |
- case CU_TYPE_VIRTIO:
|
|
|
a19a21 |
- if (is_virtio) {
|
|
|
a19a21 |
- /*
|
|
|
a19a21 |
- * Skip net devices since no IPLB is created and therefore
|
|
|
a19a21 |
- * no network bootloader has been loaded
|
|
|
a19a21 |
- */
|
|
|
a19a21 |
- if (virtio_get_device_type() != VIRTIO_ID_NET) {
|
|
|
a19a21 |
- return true;
|
|
|
a19a21 |
- }
|
|
|
a19a21 |
- }
|
|
|
a19a21 |
- continue;
|
|
|
a19a21 |
- case CU_TYPE_DASD_3990:
|
|
|
a19a21 |
- case CU_TYPE_DASD_2107:
|
|
|
a19a21 |
- return true;
|
|
|
a19a21 |
- default:
|
|
|
a19a21 |
- continue;
|
|
|
a19a21 |
- }
|
|
|
a19a21 |
- }
|
|
|
a19a21 |
-
|
|
|
a19a21 |
- /* Caller asked for a specific devno */
|
|
|
a19a21 |
- if (schib.pmcw.dev == dev_no) {
|
|
|
a19a21 |
+ if (r == true) {
|
|
|
a19a21 |
return true;
|
|
|
a19a21 |
}
|
|
|
a19a21 |
}
|
|
|
a19a21 |
--
|
|
|
a19a21 |
2.27.0
|
|
|
a19a21 |
|