Skip to contentSkip to conversation

s390-ccw: Fix ipl failure.

PATCH Superseded Cornelia Huck 2 participants 3 messages Aug 30, 2013

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 s390-ccw: Fix ipl failure.

Hi Alex,

here's a simple patch that makes starting from a dataplane-backed device on a fast LPAR work for me. I make some assumptions on the host behaviour, but I think it's fine for that very simple implementation (and it certainly works better than before :)

Could you either take or ack this patch? I can also prepare a pull request.

Cornelia Huck (1):
s390-ccw.img: Fix waiting for virtio processing.

 pc-bios/s390-ccw/virtio.c | 10 +++++++---
 pc-bios/s390-ccw/virtio.h |  1 +
 2 files changed, 8 insertions(+), 3 deletions(-)
Signature · 1 line
1.8.3.4
#1 lore raw

PATCH 1/1 s390-ccw.img: Fix waiting for virtio processing.

The guest side must not manipulate the index for the used buffers. Instead, remember the state of the used buffer locally and wait until it has moved.

---
 pc-bios/s390-ccw/virtio.c | 10 +++++++---
 pc-bios/s390-ccw/virtio.h |  1 +
 2 files changed, 8 insertions(+), 3 deletions(-)
pc-bios/s390-ccw/virtio.c +7 -3
index 49f2d29..03f6fde 100644
@@ -150,8 +150,6 @@ static void vring_send_buf(struct vring *vr, void *p, int len, int flags)
     if (!(flags & VRING_DESC_F_NEXT)) {
         vr->avail->idx++;
     }
-
-    vr->used->idx = vr->next_idx;
 }
 
 static u64 get_clock(void)
@@ -180,7 +178,13 @@ static int vring_wait_reply(struct vring *vr, int timeout)
     struct subchannel_id schid = vr->schid;
     int r = 0;
 
-    while (vr->used->idx == vr->next_idx) {
+    vr->used_idx = vr->used->idx;
+    /*
+     * Wait until the used index has moved.
+     * Note: This is only race-free if the host doesn't start draining
+     * the queue out of its own accord.
+     */
+    while (vr->used->idx == vr->used_idx) {
         vring_notify(schid);
         if (timeout && (get_second() >= target_second)) {
             r = 1;
pc-bios/s390-ccw/virtio.h +1 -0
index 86fdd57..772a63f 100644
@@ -115,6 +115,7 @@ struct vring_used {
 struct vring {
     unsigned int num;
     int next_idx;
+    int used_idx;
     struct vring_desc *desc;
     struct vring_avail *avail;
     struct vring_used *used;
Signature · 1 line
1.8.3.4
#2 lore raw

Re: [Qemu-devel] [PATCH] s390-ccw.img: Fix waiting for virtio processing.

Il 30/08/2013 09:59, Cornelia Huck ha scritto:

pc-bios/s390-ccw/virtio.c static int vring_wait_reply(struct vring *vr, int timeout) · line 187

Quoted 7 lines
pc-bios/s390-ccw/virtio.c +7 -0
+    vr->used_idx = vr->used->idx;
+    /*
+     * Wait until the used index has moved.
+     * Note: This is only race-free if the host doesn't start draining
+     * the queue out of its own accord.
+     */
+    while (vr->used->idx == vr->used_idx) {

Can you instead initialize vr->used_idx in virtio_setup_block, and then update it _after_ the while loop? This would be race-free.

Paolo