[dpdk-dev] [PATCH] virtio: use volatile to get used->idx in the loop

Xie, Huawei huawei.xie at intel.com
Wed Jun 1 07:40:08 CEST 2016


On 5/30/2016 4:20 PM, Yuanhan Liu wrote:
> On Wed, May 25, 2016 at 12:16:41AM +0800, Huawei Xie wrote:
>> 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 <huawei.xie at intel.com>
>> ---
>>  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))) {
> I'm wondering maybe we could fix VIRTQUEUE_NUSED (which has no such
> qualifier) and use this macro here?
>
> If you check the reference of that macro, you might find similar
> issues, say, it is also used inside the while-loop of
> virtio_recv_mergeable_pkts().
>
> 	--yliu
>  
>

Yes, seems it has same issue though haven't confirmed with asm code.


More information about the dev mailing list