iommu: flush I/O TLB if iommu_map() or iommu_unmap() fail
authorPaul Durrant <pdurrant@amazon.com>
Tue, 22 Sep 2020 08:21:55 +0000 (10:21 +0200)
committerJan Beulich <jbeulich@suse.com>
Tue, 22 Sep 2020 08:21:55 +0000 (10:21 +0200)
commit0229adb138d732f579e80c96a032b19e692d6796
treee47d428980347726420ac7722d4ab7c168242f8a
parentb5622eb62793a826098fa0bd31787fad43ad99cc
iommu: flush I/O TLB if iommu_map() or iommu_unmap() fail

This patch adds a full I/O TLB flush to the error paths of iommu_map() and
iommu_unmap().

Without this change callers need constructs such as:

rc = iommu_map/unmap(...)
err = iommu_flush(...)
if ( !rc )
  rc = err;

With this change, it can be simplified to:

rc = iommu_map/unmap(...)
if ( !rc )
  rc = iommu_flush(...)

because, if the map or unmap fails the flush will be unnecessary. This saves
a stack variable and generally makes the call sites tidier.

Signed-off-by: Paul Durrant <pdurrant@amazon.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/drivers/passthrough/iommu.c