[PATCH 4/5] vdpa: set dma mask for vDPA device

Jason Wang posted 5 patches 2 years, 8 months ago
There is a newer version of this series
[PATCH 4/5] vdpa: set dma mask for vDPA device
Posted by Jason Wang 2 years, 8 months ago
Setting DMA mask for vDPA device in case that there are virtqueue that
is not backed by DMA so the vDPA device could be advertised as the DMA
device that is used by DMA API for software emulated virtqueues.

Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 drivers/vdpa/vdpa.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/vdpa/vdpa.c b/drivers/vdpa/vdpa.c
index 8ef7aa1365cc..6821b2850bbb 100644
--- a/drivers/vdpa/vdpa.c
+++ b/drivers/vdpa/vdpa.c
@@ -39,6 +39,11 @@ static int vdpa_dev_probe(struct device *d)
 	u32 max_num, min_num = 1;
 	int ret = 0;
 
+	d->dma_mask = &d->coherent_dma_mask;
+	ret = dma_set_mask_and_coherent(d, DMA_BIT_MASK(64));
+	if (ret)
+		return ret;
+
 	max_num = ops->get_vq_num_max(vdev);
 	if (ops->get_vq_num_min)
 		min_num = ops->get_vq_num_min(vdev);
-- 
2.25.1
RE: [PATCH 4/5] vdpa: set dma mask for vDPA device
Posted by Eli Cohen 2 years, 8 months ago
> From: Jason Wang <jasowang@redhat.com>
> Sent: Wednesday, 11 January 2023 8:28
> To: mst@redhat.com; jasowang@redhat.com
> Cc: Eli Cohen <elic@nvidia.com>; gdawar@amd.com;
> virtualization@lists.linux-foundation.org; linux-kernel@vger.kernel.org;
> tanuj.kamde@amd.com
> Subject: [PATCH 4/5] vdpa: set dma mask for vDPA device
> 
> Setting DMA mask for vDPA device in case that there are virtqueue that
> is not backed by DMA so the vDPA device could be advertised as the DMA
> device that is used by DMA API for software emulated virtqueues.
> 
> Signed-off-by: Jason Wang <jasowang@redhat.com>
Reviewed-by: Eli Cohen <elic@nvidia.com>
Tested-by: <elic@nvidia.com>
> ---
>  drivers/vdpa/vdpa.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/vdpa/vdpa.c b/drivers/vdpa/vdpa.c
> index 8ef7aa1365cc..6821b2850bbb 100644
> --- a/drivers/vdpa/vdpa.c
> +++ b/drivers/vdpa/vdpa.c
> @@ -39,6 +39,11 @@ static int vdpa_dev_probe(struct device *d)
>  	u32 max_num, min_num = 1;
>  	int ret = 0;
> 
> +	d->dma_mask = &d->coherent_dma_mask;
> +	ret = dma_set_mask_and_coherent(d, DMA_BIT_MASK(64));
> +	if (ret)
> +		return ret;
> +
>  	max_num = ops->get_vq_num_max(vdev);
>  	if (ops->get_vq_num_min)
>  		min_num = ops->get_vq_num_min(vdev);
> --
> 2.25.1