diff mbox series

vhost-vdpa: print error when vhost_vdpa_alloc_domain fails

Message ID 20230201152018.1270226-1-alvaro.karsz@solid-run.com (mailing list archive)
State New, archived
Headers show
Series vhost-vdpa: print error when vhost_vdpa_alloc_domain fails | expand

Commit Message

Alvaro Karsz Feb. 1, 2023, 3:20 p.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>
---
 drivers/vhost/vdpa.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Michael S. Tsirkin Feb. 1, 2023, 3:52 p.m. UTC | #1
On Wed, Feb 01, 2023 at 05:20:18PM +0200, Alvaro Karsz 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>

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

> ---
>  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..56287506aa0d 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_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)
> -- 
> 2.34.1
Alvaro Karsz Feb. 1, 2023, 3:54 p.m. UTC | #2
> I'm not sure this is a good idea. Userspace is not supposed to be
> able to trigger dev_err.

dev_warn then?
Michael S. Tsirkin Feb. 1, 2023, 4:03 p.m. UTC | #3
On Wed, Feb 01, 2023 at 05:54:53PM +0200, Alvaro Karsz wrote:
> > 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.
Alvaro Karsz Feb. 1, 2023, 4:51 p.m. UTC | #4
> > dev_warn then?
>
> dev_warn_once is ok.

Ok, thanks
I'll send a new version tomorrow.
diff mbox series

Patch

diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c
index 23db92388393..56287506aa0d 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_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)