Received: from eggs.gnu.org ([2001:4830:134:3::10]:33815) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VKC9J-000877-BY for qemu-devel@nongnu.org; Thu, 12 Sep 2013 15:02:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VKC9B-0007dw-7x for qemu-devel@nongnu.org; Thu, 12 Sep 2013 15:01:53 -0400 Received: from e06smtp16.uk.ibm.com ([195.75.94.112]:59554) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VKC9A-0007db-WF for qemu-devel@nongnu.org; Thu, 12 Sep 2013 15:01:45 -0400 Received: from /spool/local by e06smtp16.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 12 Sep 2013 19:54:33 +0100 Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by d06dlp01.portsmouth.uk.ibm.com (Postfix) with ESMTP id 24BA717D8062 for ; Thu, 12 Sep 2013 20:01:49 +0100 (BST) Received: from d06av10.portsmouth.uk.ibm.com (d06av10.portsmouth.uk.ibm.com [9.149.37.251]) by b06cxnps3074.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r8CJ1Tlm66125852 for ; Thu, 12 Sep 2013 19:01:29 GMT Received: from d06av10.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av10.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id r8CJ1eGU018268 for ; Thu, 12 Sep 2013 13:01:41 -0600 From: Christian Borntraeger Date: Thu, 12 Sep 2013 21:01:58 +0200 Message-Id: <1379012521-26750-4-git-send-email-borntraeger@de.ibm.com> In-Reply-To: <1379012521-26750-1-git-send-email-borntraeger@de.ibm.com> References: <1379012521-26750-1-git-send-email-borntraeger@de.ibm.com> Subject: [Qemu-devel] [PULLv2 3/6] s390/ipl: Fix waiting for virtio processing List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: Cornelia Huck , Christian Borntraeger , Alexander Graf , qemu-devel From: Cornelia Huck 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. Signed-off-by: Cornelia Huck Acked-by: Alexander Graf Signed-off-by: Christian Borntraeger --- pc-bios/s390-ccw/virtio.c | 7 ++++--- pc-bios/s390-ccw/virtio.h | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pc-bios/s390-ccw/virtio.c b/pc-bios/s390-ccw/virtio.c index 49f2d29..4d6e48f 100644 --- a/pc-bios/s390-ccw/virtio.c +++ b/pc-bios/s390-ccw/virtio.c @@ -123,6 +123,7 @@ static void vring_init(struct vring *vr, unsigned int num, void *p, /* We're running with interrupts off anyways, so don't bother */ vr->used->flags = VRING_USED_F_NO_NOTIFY; vr->used->idx = 0; + vr->used_idx = 0; debug_print_addr("init vr", vr); } @@ -150,8 +151,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 +179,8 @@ 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) { + /* Wait until the used index has moved. */ + while (vr->used->idx == vr->used_idx) { vring_notify(schid); if (timeout && (get_second() >= target_second)) { r = 1; @@ -189,6 +189,7 @@ static int vring_wait_reply(struct vring *vr, int timeout) yield(); } + vr->used_idx = vr->used->idx; vr->next_idx = 0; vr->desc[0].len = 0; vr->desc[0].flags = 0; diff --git a/pc-bios/s390-ccw/virtio.h b/pc-bios/s390-ccw/virtio.h index 86fdd57..772a63f 100644 --- a/pc-bios/s390-ccw/virtio.h +++ b/pc-bios/s390-ccw/virtio.h @@ -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; -- 1.8.3.1