Cast to volatile is done when reading avail index and writing
the used index. This would not be necessary if proper barriers
are used.

Now that the read barrier has been added, we can remove these
cast to volatile.

Signed-off-by: Maxime Coquelin <maxime.coque...@redhat.com>
---
 lib/librte_vhost/virtio_net.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c
index 679ce388b..eab1a5b4c 100644
--- a/lib/librte_vhost/virtio_net.c
+++ b/lib/librte_vhost/virtio_net.c
@@ -114,7 +114,7 @@ flush_shadow_used_ring_split(struct virtio_net *dev, struct 
vhost_virtqueue *vq)
 
        vhost_log_cache_sync(dev, vq);
 
-       *(volatile uint16_t *)&vq->used->idx += vq->shadow_used_idx;
+       vq->used->idx += vq->shadow_used_idx;
        vq->shadow_used_idx = 0;
        vhost_log_used_vring(dev, vq, offsetof(struct vring_used, idx),
                sizeof(vq->used->idx));
@@ -794,7 +794,7 @@ virtio_dev_rx_split(struct virtio_net *dev, struct 
vhost_virtqueue *vq,
        struct buf_vector buf_vec[BUF_VECTOR_MAX];
        uint16_t avail_head;
 
-       avail_head = *((volatile uint16_t *)&vq->avail->idx);
+       avail_head = vq->avail->idx;
 
        /*
         * The ordering between avail index and
@@ -1379,8 +1379,7 @@ virtio_dev_tx_split(struct virtio_net *dev, struct 
vhost_virtqueue *vq,
                }
        }
 
-       free_entries = *((volatile uint16_t *)&vq->avail->idx) -
-                       vq->last_avail_idx;
+       free_entries = vq->avail->idx - vq->last_avail_idx;
        if (free_entries == 0)
                return 0;
 
-- 
2.17.2

Reply via email to