[dpdk-dev] [PATCH v3 09/14] vhost: use linked-list for vDPA devices

Maxime Coquelin maxime.coquelin at redhat.com
Fri Jun 26 15:56:20 CEST 2020



On 6/26/20 3:27 PM, Maxime Coquelin wrote:
> -rte_vdpa_unregister_device(struct rte_vdpa_device *vdev)
> +rte_vdpa_unregister_device(struct rte_vdpa_device *dev)
>  {
> -	int i;
> +	struct rte_vdpa_device *cur_dev, *tmp_dev;
> +	int ret = -1;
>  
> -	for (i = 0; i < MAX_VHOST_DEVICE; i++) {
> -		if (vdev != &vdpa_devices[i])
> +	rte_spinlock_lock(&vdpa_device_list_lock);
> +	TAILQ_FOREACH_SAFE(cur_dev, &vdpa_device_list, next, tmp_dev) {
> +		if (dev != cur_dev)
>  			continue;
>  
> -		memset(vdev, 0, sizeof(struct rte_vdpa_device));
> +		TAILQ_REMOVE(&vdpa_device_list, dev, next);
> +		rte_free(dev);
>  		vdpa_device_num--;
> -
> -		return 0;
> +		ret = 0;
> +		break;
>  	}
> +	rte_spinlock_lock(&vdpa_device_list_lock);

I missed Adrian's comment about the double lock here in v2.
I'll post a v4 fixing it.

Note to self: call this API in vdpa example.

Maxime
> -	return -1;
> +	return ret;
>  }
>  



More information about the dev mailing list