Patchwork [2/4] s390-ccw.img: Enhance drain_irqs().

login
register
mail settings
Submitter Cornelia Huck
Date April 23, 2013, 12:37 p.m.
Message ID <1366720634-13184-3-git-send-email-cornelia.huck@de.ibm.com>
Download mbox | patch
Permalink /patch/238900/
State New
Headers show

Comments

Cornelia Huck - April 23, 2013, 12:37 p.m.
- Use tpi + tsch to get interrupts.
- Return an error if the irb indicates problems.

Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
 pc-bios/s390-ccw/virtio.c | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

Patch

diff --git a/pc-bios/s390-ccw/virtio.c b/pc-bios/s390-ccw/virtio.c
index 79e2941..2a132f8 100644
--- a/pc-bios/s390-ccw/virtio.c
+++ b/pc-bios/s390-ccw/virtio.c
@@ -38,12 +38,27 @@  static void virtio_notify(struct subchannel_id schid)
  *             Virtio functions                *
  ***********************************************/
 
-static void drain_irqs(struct subchannel_id schid)
+static int drain_irqs(struct subchannel_id schid)
 {
     struct irb irb = {};
+    struct tpi_info tpi_info = {};
+    int r = 0;
+
     while (1) {
-        if (tsch(schid, &irb)) {
-            return;
+        if (tpi(&tpi_info)) {
+            if (tpi_info.schid.sch_no != schid.sch_no) {
+                /* should not really happen... */
+                continue;
+            }
+            if (tsch(schid, &irb)) {
+                /* Might want to differentiate error codes later on. */
+                if (irb.scsw.cstat) {
+                    r = -EIO;
+                } else if (irb.scsw.dstat != 0xc) {
+                    r = -EIO;
+                }
+                return r;
+            }
         }
     }
 }