Skip to contentSkip to conversation

vhost-vdpa: print error when vhost_vdpa_alloc_domain fails

PATCH Superseded Alvaro Karsz 3 participants 7 messages Feb 1, 2023 – Feb 2, 2023

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vhost-vdpa: print error when vhost_vdpa_alloc_domain fails

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
---
 drivers/vhost/vdpa.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/vhost/vdpa.c +4 -1
index 23db92388393..56287506aa0d 100644
@@ -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_err(&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)
Signature · 6 lines
2.34.1

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
#1 lore raw
Quoted 7 lines · Alvaro Karsz

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:

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

I'm not sure this is a good idea. Userspace is not supposed to be able to trigger dev_err.

Quoted 23 lines
---
 drivers/vhost/vdpa.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/vhost/vdpa.c +4 -1
index 23db92388393..56287506aa0d 100644
@@ -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_err(&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)
Signature · 1 line
2.34.1

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

#3 lore raw
Quoted 4 lines · Alvaro Karsz
Quoted 2 lines

I'm not sure this is a good idea. Userspace is not supposed to be able to trigger dev_err.

dev_warn then?

dev_warn_once is ok.

Signature · 6 lines
MST

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
#5 lore raw

PATCH v2 1/1 vhost-vdpa: print warning when vhost_vdpa_alloc_domain fails

In reply to Alvaro Karsz

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

---
v2:
- replace dev_err with dev_warn_once.

 drivers/vhost/vdpa.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/vhost/vdpa.c +4 -1
index 23db92388393..135f8aa70fb2 100644
@@ -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)
Signature · 1 line
2.34.1
maintainer Acked-by on v2 1/1
#6 lore raw

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

Quoted 8 lines · Alvaro Karsz

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:

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

Thanks!

Quoted 27 lines

---
v2:
- replace dev_err with dev_warn_once.

 drivers/vhost/vdpa.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/vhost/vdpa.c +4 -2
index 23db92388393..135f8aa70fb2 100644
@@ -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