diff mbox series

[v3,05/16] s390-bios: Factor finding boot device out of virtio code path

Message ID 1551466776-29123-6-git-send-email-jjherne@linux.ibm.com (mailing list archive)
State New, archived
Headers show
Series s390: vfio-ccw dasd ipl support | expand

Commit Message

Jason J. Herne March 1, 2019, 6:59 p.m. UTC
Make a new routine find_boot_device to locate the boot device for all
cases, not just virtio.

The error message for the case where no boot device has been specified
and a suitable boot device cannot be auto detected was specific to
virtio devices. We update this message to remove virtio specific wording.

Signed-off-by: Jason J. Herne <jjherne@linux.ibm.com>
Reviewed-by: Farhan Ali <alifm@linux.ibm.com>
---
 pc-bios/s390-ccw/main.c  | 85 ++++++++++++++++++++++++++----------------------
 tests/boot-serial-test.c |  2 +-
 2 files changed, 47 insertions(+), 40 deletions(-)

Comments

Cornelia Huck March 4, 2019, 5:07 p.m. UTC | #1
On Fri,  1 Mar 2019 13:59:25 -0500
"Jason J. Herne" <jjherne@linux.ibm.com> wrote:

> Make a new routine find_boot_device to locate the boot device for all
> cases, not just virtio.
> 
> The error message for the case where no boot device has been specified
> and a suitable boot device cannot be auto detected was specific to
> virtio devices. We update this message to remove virtio specific wording.

...and, consequently, need to tweak the serial output boot test.

> 
> Signed-off-by: Jason J. Herne <jjherne@linux.ibm.com>
> Reviewed-by: Farhan Ali <alifm@linux.ibm.com>
> ---
>  pc-bios/s390-ccw/main.c  | 85 ++++++++++++++++++++++++++----------------------
>  tests/boot-serial-test.c |  2 +-
>  2 files changed, 47 insertions(+), 40 deletions(-)
> 
(...)
> -    IPL_assert(found, "No virtio device found");
> +    IPL_assert(found, "Boot device not found\n");

You change the output in the bios here...

(...)
> diff --git a/tests/boot-serial-test.c b/tests/boot-serial-test.c
> index 58a48f3..9daf2cb 100644
> --- a/tests/boot-serial-test.c
> +++ b/tests/boot-serial-test.c
> @@ -112,7 +112,7 @@ static testdef_t tests[] = {
>      { "sparc", "SS-4", "", "MB86904" },
>      { "sparc", "SS-600MP", "", "TMS390Z55" },
>      { "sparc64", "sun4u", "", "UltraSPARC" },
> -    { "s390x", "s390-ccw-virtio", "", "virtio device" },
> +    { "s390x", "s390-ccw-virtio", "", "device" },

...and therefore need to change the expected string here. Question: is
that ok ("device" looks a bit generic), or would "Boot device" be a
better match?

>      { "m68k", "mcf5208evb", "", "TT", sizeof(kernel_mcf5208), kernel_mcf5208 },
>      { "microblaze", "petalogix-s3adsp1800", "", "TT",
>        sizeof(kernel_pls3adsp1800), kernel_pls3adsp1800 },

Otherwise, looks good.
Thomas Huth March 4, 2019, 7:26 p.m. UTC | #2
On 04/03/2019 18.07, Cornelia Huck wrote:
> On Fri,  1 Mar 2019 13:59:25 -0500
> "Jason J. Herne" <jjherne@linux.ibm.com> wrote:
> 
>> Make a new routine find_boot_device to locate the boot device for all
>> cases, not just virtio.
>>
>> The error message for the case where no boot device has been specified
>> and a suitable boot device cannot be auto detected was specific to
>> virtio devices. We update this message to remove virtio specific wording.
> 
> ...and, consequently, need to tweak the serial output boot test.
> 
>>
>> Signed-off-by: Jason J. Herne <jjherne@linux.ibm.com>
>> Reviewed-by: Farhan Ali <alifm@linux.ibm.com>
>> ---
>>  pc-bios/s390-ccw/main.c  | 85 ++++++++++++++++++++++++++----------------------
>>  tests/boot-serial-test.c |  2 +-
>>  2 files changed, 47 insertions(+), 40 deletions(-)
>>
> (...)
>> -    IPL_assert(found, "No virtio device found");
>> +    IPL_assert(found, "Boot device not found\n");
> 
> You change the output in the bios here...
> 
> (...)
>> diff --git a/tests/boot-serial-test.c b/tests/boot-serial-test.c
>> index 58a48f3..9daf2cb 100644
>> --- a/tests/boot-serial-test.c
>> +++ b/tests/boot-serial-test.c
>> @@ -112,7 +112,7 @@ static testdef_t tests[] = {
>>      { "sparc", "SS-4", "", "MB86904" },
>>      { "sparc", "SS-600MP", "", "TMS390Z55" },
>>      { "sparc64", "sun4u", "", "UltraSPARC" },
>> -    { "s390x", "s390-ccw-virtio", "", "virtio device" },
>> +    { "s390x", "s390-ccw-virtio", "", "device" },
> 
> ...and therefore need to change the expected string here. Question: is
> that ok ("device" looks a bit generic), or would "Boot device" be a
> better match?

Just "device" should be OK. The exact string in the boot-serial-test
does not matter too much, as long as it comes from the same print statement.

 Thomas
Cornelia Huck March 5, 2019, 8:38 a.m. UTC | #3
On Mon, 4 Mar 2019 20:26:17 +0100
Thomas Huth <thuth@redhat.com> wrote:

> On 04/03/2019 18.07, Cornelia Huck wrote:
> > On Fri,  1 Mar 2019 13:59:25 -0500
> > "Jason J. Herne" <jjherne@linux.ibm.com> wrote:
> >   
> >> Make a new routine find_boot_device to locate the boot device for all
> >> cases, not just virtio.
> >>
> >> The error message for the case where no boot device has been specified
> >> and a suitable boot device cannot be auto detected was specific to
> >> virtio devices. We update this message to remove virtio specific wording.  
> > 
> > ...and, consequently, need to tweak the serial output boot test.
> >   
> >>
> >> Signed-off-by: Jason J. Herne <jjherne@linux.ibm.com>
> >> Reviewed-by: Farhan Ali <alifm@linux.ibm.com>
> >> ---
> >>  pc-bios/s390-ccw/main.c  | 85 ++++++++++++++++++++++++++----------------------
> >>  tests/boot-serial-test.c |  2 +-
> >>  2 files changed, 47 insertions(+), 40 deletions(-)
> >>  
> > (...)  
> >> -    IPL_assert(found, "No virtio device found");
> >> +    IPL_assert(found, "Boot device not found\n");  
> > 
> > You change the output in the bios here...
> > 
> > (...)  
> >> diff --git a/tests/boot-serial-test.c b/tests/boot-serial-test.c
> >> index 58a48f3..9daf2cb 100644
> >> --- a/tests/boot-serial-test.c
> >> +++ b/tests/boot-serial-test.c
> >> @@ -112,7 +112,7 @@ static testdef_t tests[] = {
> >>      { "sparc", "SS-4", "", "MB86904" },
> >>      { "sparc", "SS-600MP", "", "TMS390Z55" },
> >>      { "sparc64", "sun4u", "", "UltraSPARC" },
> >> -    { "s390x", "s390-ccw-virtio", "", "virtio device" },
> >> +    { "s390x", "s390-ccw-virtio", "", "device" },  
> > 
> > ...and therefore need to change the expected string here. Question: is
> > that ok ("device" looks a bit generic), or would "Boot device" be a
> > better match?  
> 
> Just "device" should be OK. The exact string in the boot-serial-test
> does not matter too much, as long as it comes from the same print statement.

Ok, makes sense.

Reviewed-by: Cornelia Huck <cohuck@redhat.com>
diff mbox series

Patch

diff --git a/pc-bios/s390-ccw/main.c b/pc-bios/s390-ccw/main.c
index 7e3f65e..5b2b941 100644
--- a/pc-bios/s390-ccw/main.c
+++ b/pc-bios/s390-ccw/main.c
@@ -55,17 +55,18 @@  unsigned int get_loadparm_index(void)
  * NOTE: The global variable blk_schid is updated to contain the subchannel
  * information.
  */
-static bool find_dev(Schib *schib, int dev_no)
+static bool find_subch(int dev_no)
 {
+    Schib schib;
     int i, r;
 
     for (i = 0; i < 0x10000; i++) {
         blk_schid.sch_no = i;
-        r = stsch_err(blk_schid, schib);
+        r = stsch_err(blk_schid, &schib);
         if ((r == 3) || (r == -EIO)) {
             break;
         }
-        if (!schib->pmcw.dnv) {
+        if (!schib.pmcw.dnv) {
             continue;
         }
 
@@ -77,7 +78,7 @@  static bool find_dev(Schib *schib, int dev_no)
             continue;
         }
 
-        if ((dev_no < 0) || (schib->pmcw.dev == dev_no)) {
+        if ((dev_no < 0) || (schib.pmcw.dev == dev_no)) {
             return true;
         }
     }
@@ -133,56 +134,61 @@  static void boot_setup(void)
     have_iplb = store_iplb(&iplb);
 }
 
-static void virtio_setup(void)
+static void find_boot_device(void)
 {
-    Schib schib;
-    int ssid;
-    bool found = false;
-    uint16_t dev_no;
     VDev *vdev = virtio_get_device();
-    QemuIplParameters *early_qipl = (QemuIplParameters *)QIPL_ADDRESS;
-
-    memcpy(&qipl, early_qipl, sizeof(QemuIplParameters));
+    int ssid;
+    bool found;
 
-    if (have_iplb) {
-        switch (iplb.pbt) {
-        case S390_IPL_TYPE_CCW:
-            dev_no = iplb.ccw.devno;
-            debug_print_int("device no. ", dev_no);
-            blk_schid.ssid = iplb.ccw.ssid & 0x3;
-            debug_print_int("ssid ", blk_schid.ssid);
-            found = find_dev(&schib, dev_no);
-            break;
-        case S390_IPL_TYPE_QEMU_SCSI:
-            vdev->scsi_device_selected = true;
-            vdev->selected_scsi_device.channel = iplb.scsi.channel;
-            vdev->selected_scsi_device.target = iplb.scsi.target;
-            vdev->selected_scsi_device.lun = iplb.scsi.lun;
-            blk_schid.ssid = iplb.scsi.ssid & 0x3;
-            found = find_dev(&schib, iplb.scsi.devno);
-            break;
-        default:
-            panic("List-directed IPL not supported yet!\n");
-        }
-        menu_setup();
-    } else {
+    if (!have_iplb) {
         for (ssid = 0; ssid < 0x3; ssid++) {
             blk_schid.ssid = ssid;
-            found = find_dev(&schib, -1);
+            found = find_subch(-1);
             if (found) {
-                break;
+                return;
             }
         }
+        panic("Could not find a suitable boot device (none specified)\n");
+    }
+
+    switch (iplb.pbt) {
+    case S390_IPL_TYPE_CCW:
+        debug_print_int("device no. ", iplb.ccw.devno);
+        blk_schid.ssid = iplb.ccw.ssid & 0x3;
+        debug_print_int("ssid ", blk_schid.ssid);
+        found = find_subch(iplb.ccw.devno);
+        break;
+    case S390_IPL_TYPE_QEMU_SCSI:
+        vdev->scsi_device_selected = true;
+        vdev->selected_scsi_device.channel = iplb.scsi.channel;
+        vdev->selected_scsi_device.target = iplb.scsi.target;
+        vdev->selected_scsi_device.lun = iplb.scsi.lun;
+        blk_schid.ssid = iplb.scsi.ssid & 0x3;
+        found = find_subch(iplb.scsi.devno);
+        break;
+    default:
+        panic("List-directed IPL not supported yet!\n");
     }
 
-    IPL_assert(found, "No virtio device found");
+    IPL_assert(found, "Boot device not found\n");
+}
+
+static void virtio_setup(void)
+{
+    VDev *vdev = virtio_get_device();
+    QemuIplParameters *early_qipl = (QemuIplParameters *)QIPL_ADDRESS;
+
+    memcpy(&qipl, early_qipl, sizeof(QemuIplParameters));
+
+    if (have_iplb) {
+        menu_setup();
+    }
 
     if (virtio_get_device_type() == VIRTIO_ID_NET) {
         sclp_print("Network boot device detected\n");
         vdev->netboot_start_addr = qipl.netboot_start_addr;
     } else {
         virtio_blk_setup_device(blk_schid);
-
         IPL_assert(virtio_ipl_disk_is_valid(), "No valid IPL device detected");
     }
 }
@@ -192,8 +198,9 @@  int main(void)
     sclp_setup();
     css_setup();
     boot_setup();
-    virtio_setup();
+    find_boot_device();
 
+    virtio_setup();
     zipl_load(); /* no return */
 
     panic("Failed to load OS from hard disk\n");
diff --git a/tests/boot-serial-test.c b/tests/boot-serial-test.c
index 58a48f3..9daf2cb 100644
--- a/tests/boot-serial-test.c
+++ b/tests/boot-serial-test.c
@@ -112,7 +112,7 @@  static testdef_t tests[] = {
     { "sparc", "SS-4", "", "MB86904" },
     { "sparc", "SS-600MP", "", "TMS390Z55" },
     { "sparc64", "sun4u", "", "UltraSPARC" },
-    { "s390x", "s390-ccw-virtio", "", "virtio device" },
+    { "s390x", "s390-ccw-virtio", "", "device" },
     { "m68k", "mcf5208evb", "", "TT", sizeof(kernel_mcf5208), kernel_mcf5208 },
     { "microblaze", "petalogix-s3adsp1800", "", "TT",
       sizeof(kernel_pls3adsp1800), kernel_pls3adsp1800 },