From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 66C2C567F for ; Wed, 25 May 2016 10:11:30 +0200 (CEST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP; 25 May 2016 01:11:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,363,1459839600"; d="scan'208";a="974093362" Received: from dpdk15.sh.intel.com ([10.239.129.25]) by fmsmga001.fm.intel.com with ESMTP; 25 May 2016 01:11:28 -0700 From: Huawei Xie To: dev@dpdk.org Cc: stephen@networkplumber.org, konstantin.ananyev@intel.com, thomas.monjalon@6wind.com, Huawei Xie Date: Wed, 25 May 2016 00:16:41 +0800 Message-Id: <1464106601-981-1-git-send-email-huawei.xie@intel.com> X-Mailer: git-send-email 1.8.1.4 Subject: [dpdk-dev] [PATCH] virtio: use volatile to get used->idx in the loop X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 May 2016 08:11:30 -0000 There is no external function call or any barrier in the loop, the used->idx would only be retrieved once. Signed-off-by: Huawei Xie --- drivers/net/virtio/virtio_ethdev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c index c3fb628..f6d6305 100644 --- a/drivers/net/virtio/virtio_ethdev.c +++ b/drivers/net/virtio/virtio_ethdev.c @@ -204,7 +204,8 @@ virtio_send_command(struct virtqueue *vq, struct virtio_pmd_ctrl *ctrl, usleep(100); } - while (vq->vq_used_cons_idx != vq->vq_ring.used->idx) { + while (vq->vq_used_cons_idx != + *((volatile uint16_t *)(&vq->vq_ring.used->idx))) { uint32_t idx, desc_idx, used_idx; struct vring_used_elem *uep; -- 1.8.1.4