diff options
author | Alex Williamson <alex.williamson@redhat.com> | 2014-02-26 11:38:37 -0700 |
---|---|---|
committer | Alex Williamson <alex.williamson@redhat.com> | 2014-02-26 11:38:37 -0700 |
commit | aa429318279b90192f35a97e9ccdc1e83b3a9624 (patch) | |
tree | b27ec47dd53413e02c81376f80c10fd57ba4a334 /drivers/vfio | |
parent | 1ef3e2bc04223ff956dc62abaf2dff1f3322a431 (diff) | |
download | linux-stable-aa429318279b90192f35a97e9ccdc1e83b3a9624.tar.gz linux-stable-aa429318279b90192f35a97e9ccdc1e83b3a9624.tar.bz2 linux-stable-aa429318279b90192f35a97e9ccdc1e83b3a9624.zip |
vfio/type1: Add extension to test DMA cache coherence of IOMMU
Now that the type1 IOMMU backend can support IOMMU_CACHE, we need to
be able to test whether coherency is currently enforced. Add an
extension for this.
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Diffstat (limited to 'drivers/vfio')
-rw-r--r-- | drivers/vfio/vfio_iommu_type1.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c index 8c7bb9befdab..1f90344d3e2c 100644 --- a/drivers/vfio/vfio_iommu_type1.c +++ b/drivers/vfio/vfio_iommu_type1.c @@ -867,6 +867,23 @@ static void vfio_iommu_type1_release(void *iommu_data) kfree(iommu); } +static int vfio_domains_have_iommu_cache(struct vfio_iommu *iommu) +{ + struct vfio_domain *domain; + int ret = 1; + + mutex_lock(&iommu->lock); + list_for_each_entry(domain, &iommu->domain_list, next) { + if (!(domain->prot & IOMMU_CACHE)) { + ret = 0; + break; + } + } + mutex_unlock(&iommu->lock); + + return ret; +} + static long vfio_iommu_type1_ioctl(void *iommu_data, unsigned int cmd, unsigned long arg) { @@ -878,6 +895,10 @@ static long vfio_iommu_type1_ioctl(void *iommu_data, case VFIO_TYPE1_IOMMU: case VFIO_TYPE1v2_IOMMU: return 1; + case VFIO_DMA_CC_IOMMU: + if (!iommu) + return 0; + return vfio_domains_have_iommu_cache(iommu); default: return 0; } |