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