Skip to contentSkip to conversation

vfio/region: Clarify dma-buf failure messages

PATCH In review Cédric Le Goater 4 participants 6 messages Jul 15 – Jul 23

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vfio/region: Clarify dma-buf failure messages

The dma-buf failure messages in vfio_region_create_dma_buf() say "PCI BAR IOMMU mappings may fail", which suggests the BAR is broken. In practice, only P2P DMA is affected -- normal passthrough uses the mmap fallback.

Reword both messages to mention P2P DMA explicitly and clarify that the mmap fallback is in use. Use warn_report_err_once() at the call site so per-BAR repetition on mdev devices is suppressed.

Fixes dcf1b77e834d ("hw/vfio/region: Create dmabuf for PCI BAR per region")
Cc Nicolin Chen <[email protected]>
---
 hw/vfio/region.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
hw/vfio/region.c +5 -6
index dbde3391802691888ca31d5e329aba5ba680feb4..54ad11a6c8ed8e04fa365262ccb8bd694bdb45f7 100644
@@ -321,13 +321,12 @@ static bool vfio_region_create_dma_buf(VFIORegion *region, Error **errp)
     ret = vfio_device_get_feature(vbasedev, feature);
     if (ret < 0) {
         if (ret == -ENOTTY) {
-            warn_report_once("VFIO dma-buf not supported in kernel: "
-                             "PCI BAR IOMMU mappings may fail");
+            warn_report_once("VFIO dma-buf not supported in kernel, "
+                             "using mmap fallback, P2P DMA will not work");
             return true;
         }
-        /* P2P DMA or exposing device memory use cases are not supported. */
-        error_setg_errno(errp, -ret, "%s: failed to create dma-buf: "
-                         "PCI BAR IOMMU mappings may fail",
+        error_setg_errno(errp, -ret, "%s: dma-buf unavailable, "
+                         "using mmap fallback, P2P DMA will not work",
                          memory_region_name(region->mem));
         return false;
     }
@@ -448,7 +447,7 @@ int vfio_region_mmap(VFIORegion *region)
     }
 
     if (!vfio_region_create_dma_buf(region, &local_err)) {
-        error_report_err(local_err);
+        warn_report_err_once(local_err);
     }
 
     return 0;
Signature · 1 line
2.55.0
#1 lore raw
Quoted 39 lines · Cédric Le Goater

The dma-buf failure messages in vfio_region_create_dma_buf() say "PCI BAR IOMMU mappings may fail", which suggests the BAR is broken. In practice, only P2P DMA is affected -- normal passthrough uses the mmap fallback.

Reword both messages to mention P2P DMA explicitly and clarify that the mmap fallback is in use. Use warn_report_err_once() at the call site so per-BAR repetition on mdev devices is suppressed.

Fixes dcf1b77e834d ("hw/vfio/region: Create dmabuf for PCI BAR per region")
Cc Nicolin Chen <[email protected]>
---
  hw/vfio/region.c | 11 +++++------
  1 file changed, 5 insertions(+), 6 deletions(-)
hw/vfio/region.c +4 -5
index dbde3391802691888ca31d5e329aba5ba680feb4..54ad11a6c8ed8e04fa365262ccb8bd694bdb45f7 100644
@@ -321,13 +321,12 @@ static bool vfio_region_create_dma_buf(VFIORegion *region, Error **errp)
      ret = vfio_device_get_feature(vbasedev, feature);
      if (ret < 0) {
          if (ret == -ENOTTY) {
-            warn_report_once("VFIO dma-buf not supported in kernel: "
-                             "PCI BAR IOMMU mappings may fail");
+            warn_report_once("VFIO dma-buf not supported in kernel, "
+                             "using mmap fallback, P2P DMA will not work");
              return true;
          }
-        /* P2P DMA or exposing device memory use cases are not supported. */
-        error_setg_errno(errp, -ret, "%s: failed to create dma-buf: "
-                         "PCI BAR IOMMU mappings may fail",
+        error_setg_errno(errp, -ret, "%s: dma-buf unavailable, "
+                         "using mmap fallback, P2P DMA will not work",
                           memory_region_name(region->mem));
          return false;
      }

hw/vfio/region.c int vfio_region_mmap(VFIORegion *region) · line 453

Quoted 8 lines
hw/vfio/region.c +1 -1
@@ -448,7 +447,7 @@ int vfio_region_mmap(VFIORegion *region)
      }
 
      if (!vfio_region_create_dma_buf(region, &local_err)) {
-        error_report_err(local_err);
+        warn_report_err_once(local_err);
      }
 
      return 0;

Applied to

https://github.com/legoater/qemu vfio-next

Thanks,

C.

Reviewed-by on v1 1/1
#2 lore raw
In reply to Cédric Le Goater
Quoted 9 lines · Cédric Le Goater

The dma-buf failure messages in vfio_region_create_dma_buf() say "PCI BAR IOMMU mappings may fail", which suggests the BAR is broken. In practice, only P2P DMA is affected -- normal passthrough uses the mmap fallback.

Reword both messages to mention P2P DMA explicitly and clarify that the mmap fallback is in use. Use warn_report_err_once() at the call site so per-BAR repetition on mdev devices is suppressed.

Quoted 6 lines
Fixes dcf1b77e834d ("hw/vfio/region: Create dmabuf for PCI BAR per region")
Cc Nicolin Chen <[email protected]>
---
  hw/vfio/region.c | 11 +++++------
  1 file changed, 5 insertions(+), 6 deletions(-)
#3 lore raw
In reply to Cédric Le Goater
Quoted 10 lines · Cédric Le Goater

The dma-buf failure messages in vfio_region_create_dma_buf() say "PCI BAR IOMMU mappings may fail", which suggests the BAR is broken. In practice, only P2P DMA is affected -- normal passthrough uses the mmap fallback.

Reword both messages to mention P2P DMA explicitly and clarify that the mmap fallback is in use. Use warn_report_err_once() at the call site so per-BAR repetition on mdev devices is suppressed.

Fixes dcf1b77e834d ("hw/vfio/region: Create dmabuf for PCI BAR per region")

FWIW (it's applied to master branch already), this is commit 8cfaf22668c, not dcf1b77e834d.

Thanks,

/mjt

#4 lore raw
Quoted 6 lines · Michael Tokarev
Quoted 5 lines · Cédric Le Goater

The dma-buf failure messages in vfio_region_create_dma_buf() say "PCI BAR IOMMU mappings may fail", which suggests the BAR is broken. In practice, only P2P DMA is affected -- normal passthrough uses the mmap fallback.

Quoted 9 lines
Quoted 5 lines

Reword both messages to mention P2P DMA explicitly and clarify that the mmap fallback is in use. Use warn_report_err_once() at the call site so per-BAR repetition on mdev devices is suppressed.

Fixes dcf1b77e834d ("hw/vfio/region: Create dmabuf for PCI BAR per region")

FWIW (it's applied to master branch already), this is commit 8cfaf22668c, not dcf1b77e834d.

My bad, dcf1b77e834d is the same commit in an old local vfio-next branch :/ I sent a scripts/checkpatch update to catch these.

Thanks,

C.

Reviewed-by on v1 1/1
#5 lore raw
In reply to Cédric Le Goater
Quoted 39 lines · Cédric Le Goater

The dma-buf failure messages in vfio_region_create_dma_buf() say "PCI BAR IOMMU mappings may fail", which suggests the BAR is broken. In practice, only P2P DMA is affected -- normal passthrough uses the mmap fallback.

Reword both messages to mention P2P DMA explicitly and clarify that the mmap fallback is in use. Use warn_report_err_once() at the call site so per-BAR repetition on mdev devices is suppressed.

Fixes dcf1b77e834d ("hw/vfio/region: Create dmabuf for PCI BAR per region")
Cc Nicolin Chen <[email protected]>
---
  hw/vfio/region.c | 11 +++++------
  1 file changed, 5 insertions(+), 6 deletions(-)
hw/vfio/region.c +4 -5
index dbde3391802691888ca31d5e329aba5ba680feb4..54ad11a6c8ed8e04fa365262ccb8bd694bdb45f7 100644
@@ -321,13 +321,12 @@ static bool vfio_region_create_dma_buf(VFIORegion *region, Error **errp)
      ret = vfio_device_get_feature(vbasedev, feature);
      if (ret < 0) {
          if (ret == -ENOTTY) {
-            warn_report_once("VFIO dma-buf not supported in kernel: "
-                             "PCI BAR IOMMU mappings may fail");
+            warn_report_once("VFIO dma-buf not supported in kernel, "
+                             "using mmap fallback, P2P DMA will not work");
              return true;
          }
-        /* P2P DMA or exposing device memory use cases are not supported. */
-        error_setg_errno(errp, -ret, "%s: failed to create dma-buf: "
-                         "PCI BAR IOMMU mappings may fail",
+        error_setg_errno(errp, -ret, "%s: dma-buf unavailable, "
+                         "using mmap fallback, P2P DMA will not work",
                           memory_region_name(region->mem));
          return false;
      }

hw/vfio/region.c int vfio_region_mmap(VFIORegion *region) · line 453

Quoted 8 lines
hw/vfio/region.c +1 -1
@@ -448,7 +447,7 @@ int vfio_region_mmap(VFIORegion *region)
      }
 
      if (!vfio_region_create_dma_buf(region, &local_err)) {
-        error_report_err(local_err);
+        warn_report_err_once(local_err);
      }
 
      return 0;