diff mbox series

[v2] vhost-vdpa: print warning when vhost_vdpa_alloc_domain fails

Message ID 20230202084212.1328530-1-alvaro.karsz@solid-run.com (mailing list archive)
State Not Applicable
Headers show
Series [v2] vhost-vdpa: print warning when vhost_vdpa_alloc_domain fails | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch

Commit Message

Alvaro Karsz Feb. 2, 2023, 8:42 a.m. UTC
Add a print explaining why vhost_vdpa_alloc_domain failed if the device
is not IOMMU cache coherent capable.

Without this print, we have no hint why the operation failed.

For example:

$ virsh start <domain>
	error: Failed to start domain <domain>
	error: Unable to open '/dev/vhost-vdpa-<idx>' for vdpa device:
	       Unknown error 524

Suggested-by: Eugenio Perez Martin <eperezma@redhat.com>
Signed-off-by: Alvaro Karsz <alvaro.karsz@solid-run.com>

---
v2:
	- replace dev_err with dev_warn_once.

 drivers/vhost/vdpa.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Eugenio Perez Martin Feb. 2, 2023, 7:01 p.m. UTC | #1
On Thu, Feb 2, 2023 at 9:42 AM Alvaro Karsz <alvaro.karsz@solid-run.com> wrote:
>
> Add a print explaining why vhost_vdpa_alloc_domain failed if the device
> is not IOMMU cache coherent capable.
>
> Without this print, we have no hint why the operation failed.
>
> For example:
>
> $ virsh start <domain>
>         error: Failed to start domain <domain>
>         error: Unable to open '/dev/vhost-vdpa-<idx>' for vdpa device:
>                Unknown error 524
>
> Suggested-by: Eugenio Perez Martin <eperezma@redhat.com>
> Signed-off-by: Alvaro Karsz <alvaro.karsz@solid-run.com>
>

Acked-by: Eugenio Pérez Martin <eperezma@redhat.com>

Thanks!

> ---
> v2:
>         - replace dev_err with dev_warn_once.
>
>  drivers/vhost/vdpa.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c
> index 23db92388393..135f8aa70fb2 100644
> --- a/drivers/vhost/vdpa.c
> +++ b/drivers/vhost/vdpa.c
> @@ -1151,8 +1151,11 @@ static int vhost_vdpa_alloc_domain(struct vhost_vdpa *v)
>         if (!bus)
>                 return -EFAULT;
>
> -       if (!device_iommu_capable(dma_dev, IOMMU_CAP_CACHE_COHERENCY))
> +       if (!device_iommu_capable(dma_dev, IOMMU_CAP_CACHE_COHERENCY)) {
> +               dev_warn_once(&v->dev,
> +                             "Failed to allocate domain, device is not IOMMU cache coherent capable\n");
>                 return -ENOTSUPP;
> +       }
>
>         v->domain = iommu_domain_alloc(bus);
>         if (!v->domain)
> --
> 2.34.1
>
diff mbox series

Patch

diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c
index 23db92388393..135f8aa70fb2 100644
--- a/drivers/vhost/vdpa.c
+++ b/drivers/vhost/vdpa.c
@@ -1151,8 +1151,11 @@  static int vhost_vdpa_alloc_domain(struct vhost_vdpa *v)
 	if (!bus)
 		return -EFAULT;
 
-	if (!device_iommu_capable(dma_dev, IOMMU_CAP_CACHE_COHERENCY))
+	if (!device_iommu_capable(dma_dev, IOMMU_CAP_CACHE_COHERENCY)) {
+		dev_warn_once(&v->dev,
+			      "Failed to allocate domain, device is not IOMMU cache coherent capable\n");
 		return -ENOTSUPP;
+	}
 
 	v->domain = iommu_domain_alloc(bus);
 	if (!v->domain)