All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Huth <thuth@redhat.com>
To: qemu-s390x@nongnu.org,
	Christian Borntraeger <borntraeger@linux.ibm.com>,
	Eric Farman <farman@linux.ibm.com>
Cc: qemu-devel@nongnu.org, Cornelia Huck <cohuck@redhat.com>,
	Janosch Frank <frankja@linux.ibm.com>
Subject: [PATCH 06/12] pc-bios/s390-ccw/virtio: Set missing status bits while initializing
Date: Tue, 28 Jun 2022 15:10:26 +0200	[thread overview]
Message-ID: <20220628131032.213986-7-thuth@redhat.com> (raw)
In-Reply-To: <20220628131032.213986-1-thuth@redhat.com>

According chapter "3.1.1 Driver Requirements: Device Initialization"
of the Virtio specification (v1.1), a driver for a device has to set
the ACKNOWLEDGE and DRIVER bits in the status field after resetting
the device. The s390-ccw bios skipped these steps so far and seems
like QEMU never cared. Anyway, it's better to follow the spec, so
let's set these bits now in the right spots, too.

Acked-by: Christian Borntraeger <borntraeger@linux.ibm.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Reviewed-by: Eric Farman <farman@linux.ibm.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 pc-bios/s390-ccw/virtio.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/pc-bios/s390-ccw/virtio.c b/pc-bios/s390-ccw/virtio.c
index 5d2c6e3381..4e85a2eb82 100644
--- a/pc-bios/s390-ccw/virtio.c
+++ b/pc-bios/s390-ccw/virtio.c
@@ -220,7 +220,7 @@ int virtio_run(VDev *vdev, int vqid, VirtioCmd *cmd)
 void virtio_setup_ccw(VDev *vdev)
 {
     int i, rc, cfg_size = 0;
-    unsigned char status = VIRTIO_CONFIG_S_DRIVER_OK;
+    uint8_t status;
     struct VirtioFeatureDesc {
         uint32_t features;
         uint8_t index;
@@ -234,6 +234,10 @@ void virtio_setup_ccw(VDev *vdev)
 
     run_ccw(vdev, CCW_CMD_VDEV_RESET, NULL, 0, false);
 
+    status = VIRTIO_CONFIG_S_ACKNOWLEDGE;
+    rc = run_ccw(vdev, CCW_CMD_WRITE_STATUS, &status, sizeof(status), false);
+    IPL_assert(rc == 0, "Could not write ACKNOWLEDGE status to host");
+
     switch (vdev->senseid.cu_model) {
     case VIRTIO_ID_NET:
         vdev->nr_vqs = 2;
@@ -253,6 +257,11 @@ void virtio_setup_ccw(VDev *vdev)
     default:
         panic("Unsupported virtio device\n");
     }
+
+    status |= VIRTIO_CONFIG_S_DRIVER;
+    rc = run_ccw(vdev, CCW_CMD_WRITE_STATUS, &status, sizeof(status), false);
+    IPL_assert(rc == 0, "Could not write DRIVER status to host");
+
     IPL_assert(
         run_ccw(vdev, CCW_CMD_READ_CONF, &vdev->config, cfg_size, false) == 0,
        "Could not get block device configuration");
@@ -291,9 +300,10 @@ void virtio_setup_ccw(VDev *vdev)
             run_ccw(vdev, CCW_CMD_SET_VQ, &info, sizeof(info), false) == 0,
             "Cannot set VQ info");
     }
-    IPL_assert(
-        run_ccw(vdev, CCW_CMD_WRITE_STATUS, &status, sizeof(status), false) == 0,
-        "Could not write status to host");
+
+    status |= VIRTIO_CONFIG_S_DRIVER_OK;
+    rc = run_ccw(vdev, CCW_CMD_WRITE_STATUS, &status, sizeof(status), false);
+    IPL_assert(rc == 0, "Could not write DRIVER_OK status to host");
 }
 
 bool virtio_is_supported(SubChannelId schid)
-- 
2.31.1



  parent reply	other threads:[~2022-06-28 13:16 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-28 13:10 [PATCH 00/12] s390-ccw bios fixes and clean-ups Thomas Huth
2022-06-28 13:10 ` [PATCH 01/12] pc-bios/s390-ccw: Add a proper prototype for main() Thomas Huth
2022-07-01 14:52   ` Eric Farman
2022-06-28 13:10 ` [PATCH 02/12] pc-bios/s390-ccw/virtio: Introduce a macro for the DASD block size Thomas Huth
2022-06-28 13:21   ` Cornelia Huck
2022-07-01 14:53     ` Eric Farman
2022-07-02  6:25     ` Thomas Huth
2022-07-04  6:39       ` Cornelia Huck
2022-06-28 13:10 ` [PATCH 03/12] pc-bios/s390-ccw/bootmap: Improve the guessing logic in zipl_load_vblk() Thomas Huth
2022-07-01 15:36   ` Eric Farman
2022-07-02  6:28     ` Thomas Huth
2022-06-28 13:10 ` [PATCH 04/12] pc-bios/s390-ccw/virtio-blkdev: Simplify/fix virtio_ipl_disk_is_valid() Thomas Huth
2022-07-01 18:22   ` Eric Farman
2022-06-28 13:10 ` [PATCH 05/12] pc-bios/s390-ccw/virtio-blkdev: Remove virtio_assume_scsi() Thomas Huth
2022-07-01 18:25   ` Eric Farman
2022-06-28 13:10 ` Thomas Huth [this message]
2022-06-28 13:10 ` [PATCH 07/12] pc-bios/s390-ccw/virtio: Read device config after feature negotiation Thomas Huth
2022-06-28 13:25   ` Cornelia Huck
2022-07-01 18:38   ` Eric Farman
2022-06-28 13:10 ` [PATCH 08/12] pc-bios/s390-ccw/virtio: Beautify the code for reading virtqueue configuration Thomas Huth
2022-06-28 13:26   ` Cornelia Huck
2022-07-01 18:38   ` Eric Farman
2022-06-28 13:10 ` [PATCH 09/12] pc-bios/s390-ccw: Split virtio-scsi code from virtio_blk_setup_device() Thomas Huth
2022-07-01 20:25   ` Eric Farman
2022-06-28 13:10 ` [PATCH 10/12] pc-bios/s390-ccw/virtio-blkdev: Request the right feature bits Thomas Huth
2022-06-28 13:10 ` [PATCH 11/12] pc-bios/s390-ccw/virtio: Remove "extern" keyword from prototypes Thomas Huth
2022-06-28 13:34   ` Cornelia Huck
2022-06-28 13:10 ` [PATCH 12/12] pc-bios/s390-ccw/netboot.mak: Ignore Clang's warnings about GNU extensions Thomas Huth

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220628131032.213986-7-thuth@redhat.com \
    --to=thuth@redhat.com \
    --cc=borntraeger@linux.ibm.com \
    --cc=cohuck@redhat.com \
    --cc=farman@linux.ibm.com \
    --cc=frankja@linux.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-s390x@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.