netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] vhost-vdpa: print error when vhost_vdpa_alloc_domain fails
@ 2023-02-01 15:20 Alvaro Karsz
  2023-02-01 15:52 ` Michael S. Tsirkin
  2023-02-02  8:42 ` [PATCH v2] vhost-vdpa: print warning " Alvaro Karsz
  0 siblings, 2 replies; 7+ messages in thread
From: Alvaro Karsz @ 2023-02-01 15:20 UTC (permalink / raw)
  To: mst, jasowang
  Cc: virtualization, kvm, netdev, Alvaro Karsz, Eugenio Perez Martin

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(-)

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


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] vhost-vdpa: print error when vhost_vdpa_alloc_domain fails
  2023-02-01 15:20 [PATCH] vhost-vdpa: print error when vhost_vdpa_alloc_domain fails Alvaro Karsz
@ 2023-02-01 15:52 ` Michael S. Tsirkin
  2023-02-01 15:54   ` Alvaro Karsz
  2023-02-02  8:42 ` [PATCH v2] vhost-vdpa: print warning " Alvaro Karsz
  1 sibling, 1 reply; 7+ messages in thread
From: Michael S. Tsirkin @ 2023-02-01 15:52 UTC (permalink / raw)
  To: Alvaro Karsz; +Cc: jasowang, virtualization, kvm, netdev, Eugenio Perez Martin

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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] vhost-vdpa: print error when vhost_vdpa_alloc_domain fails
  2023-02-01 15:52 ` Michael S. Tsirkin
@ 2023-02-01 15:54   ` Alvaro Karsz
  2023-02-01 16:03     ` Michael S. Tsirkin
  0 siblings, 1 reply; 7+ messages in thread
From: Alvaro Karsz @ 2023-02-01 15:54 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: jasowang, virtualization, kvm, netdev, Eugenio Perez Martin

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

dev_warn then?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] vhost-vdpa: print error when vhost_vdpa_alloc_domain fails
  2023-02-01 15:54   ` Alvaro Karsz
@ 2023-02-01 16:03     ` Michael S. Tsirkin
  2023-02-01 16:51       ` Alvaro Karsz
  0 siblings, 1 reply; 7+ messages in thread
From: Michael S. Tsirkin @ 2023-02-01 16:03 UTC (permalink / raw)
  To: Alvaro Karsz; +Cc: jasowang, virtualization, kvm, netdev, Eugenio Perez Martin

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.

-- 
MST


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] vhost-vdpa: print error when vhost_vdpa_alloc_domain fails
  2023-02-01 16:03     ` Michael S. Tsirkin
@ 2023-02-01 16:51       ` Alvaro Karsz
  0 siblings, 0 replies; 7+ messages in thread
From: Alvaro Karsz @ 2023-02-01 16:51 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: jasowang, virtualization, kvm, netdev, Eugenio Perez Martin

> > dev_warn then?
>
> dev_warn_once is ok.

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2] vhost-vdpa: print warning when vhost_vdpa_alloc_domain fails
  2023-02-01 15:20 [PATCH] vhost-vdpa: print error when vhost_vdpa_alloc_domain fails Alvaro Karsz
  2023-02-01 15:52 ` Michael S. Tsirkin
@ 2023-02-02  8:42 ` Alvaro Karsz
  2023-02-02 19:01   ` Eugenio Perez Martin
  1 sibling, 1 reply; 7+ messages in thread
From: Alvaro Karsz @ 2023-02-02  8:42 UTC (permalink / raw)
  To: mst, jasowang
  Cc: virtualization, kvm, netdev, Alvaro Karsz, Eugenio Perez Martin

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(-)

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


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] vhost-vdpa: print warning when vhost_vdpa_alloc_domain fails
  2023-02-02  8:42 ` [PATCH v2] vhost-vdpa: print warning " Alvaro Karsz
@ 2023-02-02 19:01   ` Eugenio Perez Martin
  0 siblings, 0 replies; 7+ messages in thread
From: Eugenio Perez Martin @ 2023-02-02 19:01 UTC (permalink / raw)
  To: Alvaro Karsz; +Cc: mst, jasowang, virtualization, kvm, netdev

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
>


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-02-02 19:03 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-01 15:20 [PATCH] vhost-vdpa: print error when vhost_vdpa_alloc_domain fails Alvaro Karsz
2023-02-01 15:52 ` Michael S. Tsirkin
2023-02-01 15:54   ` Alvaro Karsz
2023-02-01 16:03     ` Michael S. Tsirkin
2023-02-01 16:51       ` Alvaro Karsz
2023-02-02  8:42 ` [PATCH v2] vhost-vdpa: print warning " Alvaro Karsz
2023-02-02 19:01   ` Eugenio Perez Martin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).