diff options
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) | |||
867 | kfree(iommu); | 867 | kfree(iommu); |
868 | } | 868 | } |
869 | 869 | ||
870 | static int vfio_domains_have_iommu_cache(struct vfio_iommu *iommu) | ||
871 | { | ||
872 | struct vfio_domain *domain; | ||
873 | int ret = 1; | ||
874 | |||
875 | mutex_lock(&iommu->lock); | ||
876 | list_for_each_entry(domain, &iommu->domain_list, next) { | ||
877 | if (!(domain->prot & IOMMU_CACHE)) { | ||
878 | ret = 0; | ||
879 | break; | ||
880 | } | ||
881 | } | ||
882 | mutex_unlock(&iommu->lock); | ||
883 | |||
884 | return ret; | ||
885 | } | ||
886 | |||
870 | static long vfio_iommu_type1_ioctl(void *iommu_data, | 887 | static long vfio_iommu_type1_ioctl(void *iommu_data, |
871 | unsigned int cmd, unsigned long arg) | 888 | unsigned int cmd, unsigned long arg) |
872 | { | 889 | { |
@@ -878,6 +895,10 @@ static long vfio_iommu_type1_ioctl(void *iommu_data, | |||
878 | case VFIO_TYPE1_IOMMU: | 895 | case VFIO_TYPE1_IOMMU: |
879 | case VFIO_TYPE1v2_IOMMU: | 896 | case VFIO_TYPE1v2_IOMMU: |
880 | return 1; | 897 | return 1; |
898 | case VFIO_DMA_CC_IOMMU: | ||
899 | if (!iommu) | ||
900 | return 0; | ||
901 | return vfio_domains_have_iommu_cache(iommu); | ||
881 | default: | 902 | default: |
882 | return 0; | 903 | return 0; |
883 | } | 904 | } |