[v1,3/4] net/virtio: replace full barrier with relaxed barrier for Arm platform

Message ID 20201221142321.51606-4-joyce.kong@arm.com (mailing list archive)
State Accepted, archived
Delegated to: Maxime Coquelin
Headers
Series replace smp barriers in virtio with C11 atomic |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Joyce Kong Dec. 21, 2020, 2:23 p.m. UTC
  Relax the full write barriers to one-way barriers for virtio
control path for Arm platform

Signed-off-by: Joyce Kong <joyce.kong@arm.com>
Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
---
 drivers/net/virtio/virtio_ethdev.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Comments

Maxime Coquelin Jan. 7, 2021, 2:47 p.m. UTC | #1
On 12/21/20 3:23 PM, Joyce Kong wrote:
> Relax the full write barriers to one-way barriers for virtio
> control path for Arm platform
> 
> Signed-off-by: Joyce Kong <joyce.kong@arm.com>
> Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
> ---
>  drivers/net/virtio/virtio_ethdev.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
> index 0d91f7a50..b3e5cba70 100644
> --- a/drivers/net/virtio/virtio_ethdev.c
> +++ b/drivers/net/virtio/virtio_ethdev.c
> @@ -203,8 +203,8 @@ virtio_send_command_packed(struct virtnet_ctl *cvq,
>  		vq->vq_packed.cached_flags ^= VRING_PACKED_DESC_F_AVAIL_USED;
>  	}
>  
> -	virtio_wmb(vq->hw->weak_barriers);
> -	desc[head].flags = VRING_DESC_F_NEXT | flags;
> +	virtqueue_store_flags_packed(&desc[head], VRING_DESC_F_NEXT | flags,
> +			vq->hw->weak_barriers);
>  
>  	virtio_wmb(vq->hw->weak_barriers);
>  	virtqueue_notify(vq);
> 

Performance does not matter in the case of ctrl queue, but it is cleaner
to reuse existing helpers anyway:

Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>

Thanks,
Maxime
  

Patch

diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index 0d91f7a50..b3e5cba70 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -203,8 +203,8 @@  virtio_send_command_packed(struct virtnet_ctl *cvq,
 		vq->vq_packed.cached_flags ^= VRING_PACKED_DESC_F_AVAIL_USED;
 	}
 
-	virtio_wmb(vq->hw->weak_barriers);
-	desc[head].flags = VRING_DESC_F_NEXT | flags;
+	virtqueue_store_flags_packed(&desc[head], VRING_DESC_F_NEXT | flags,
+			vq->hw->weak_barriers);
 
 	virtio_wmb(vq->hw->weak_barriers);
 	virtqueue_notify(vq);