From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ilya Maximets Subject: [PATCH 1/3] net/virtio: fix improper read barriers on packed Tx cleanup Date: Thu, 24 Jan 2019 19:59:00 +0300 Message-ID: <20190124165902.24178-2-i.maximets@samsung.com> References: <20190124165902.24178-1-i.maximets@samsung.com> Content-Type: text/plain; charset="utf-8" Cc: Tiwei Bie , Zhihong Wang , Jens Freimann , Ilya Maximets , stable@dpdk.org To: dev@dpdk.org, Maxime Coquelin , "Michael S . Tsirkin" Return-path: Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by dpdk.org (Postfix) with ESMTP id EEF1A58FA for ; Thu, 24 Jan 2019 17:59:16 +0100 (CET) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20190124165915euoutp012090ad5f40bcd0bbe0186d5e536d894a~811qRHuqF3017130171euoutp01E for ; Thu, 24 Jan 2019 16:59:15 +0000 (GMT) In-Reply-To: <20190124165902.24178-1-i.maximets@samsung.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Read barrier must be implied between reading descriptor flags and descriptor id. Otherwise, in case of reordering, we could read wrong descriptor id. For the reference, similar barrier for split rings is the read barrier between VIRTQUEUE_NUSED (reading the used->idx) and the call to the virtio_xmit_cleanup(). Additionally removed double update of 'used_idx'. It's enough to set it in the end of the loop. Fixes: 892dc798fa9c ("net/virtio: implement Tx path for packed queues") Cc: stable@dpdk.org Signed-off-by: Ilya Maximets --- drivers/net/virtio/virtio_rxtx.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c index cc476b898..63e4370e4 100644 --- a/drivers/net/virtio/virtio_rxtx.c +++ b/drivers/net/virtio/virtio_rxtx.c @@ -234,7 +234,7 @@ virtio_xmit_cleanup_packed(struct virtqueue *vq, int num) used_idx = vq->vq_used_cons_idx; while (num-- && desc_is_used(&desc[used_idx], vq)) { - used_idx = vq->vq_used_cons_idx; + virtio_rmb(vq->hw->weak_barriers); id = desc[used_idx].id; dxp = &vq->vq_descx[id]; vq->vq_used_cons_idx += dxp->ndescs; @@ -1940,7 +1940,6 @@ virtio_xmit_pkts_packed(void *tx_queue, struct rte_mbuf **tx_pkts, /* Positive value indicates it need free vring descriptors */ if (unlikely(need > 0)) { - virtio_rmb(hw->weak_barriers); need = RTE_MIN(need, (int)nb_pkts); virtio_xmit_cleanup_packed(vq, need); need = slots - vq->vq_free_cnt; -- 2.17.1