Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1522686
| From | Eric Auger <eric.auger@redhat.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [RFC v3 10/10] vfio/type1: Get MSI cookie |
| Date | 2016-11-15 14:20 +0100 |
| Message-ID | <sDLOy-5pg-31@gated-at.bofh.it> (permalink) |
| References | <sDLER-5lG-1@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
When attaching a group to the container, handle the group's
reserved regions and particularly the IOMMU_RESV_MSI region
which requires an IOVA allocator to be initialized through
the iommu_get_msi_cookie API. This will allow the MSI IOVAs
to be transparently allocated on MSI controller's compose().
Signed-off-by: Eric Auger <eric.auger@redhat.com>
---
drivers/vfio/vfio_iommu_type1.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c
index 2ba1942..701d8a8 100644
--- a/drivers/vfio/vfio_iommu_type1.c
+++ b/drivers/vfio/vfio_iommu_type1.c
@@ -36,6 +36,7 @@
#include <linux/uaccess.h>
#include <linux/vfio.h>
#include <linux/workqueue.h>
+#include <linux/dma-iommu.h>
#define DRIVER_VERSION "0.2"
#define DRIVER_AUTHOR "Alex Williamson <alex.williamson@redhat.com>"
@@ -734,6 +735,27 @@ static void vfio_test_domain_fgsp(struct vfio_domain *domain)
__free_pages(pages, order);
}
+static int vfio_iommu_handle_resv_regions(struct iommu_domain *domain,
+ struct iommu_group *group)
+{
+ struct list_head group_resv_regions;
+ struct iommu_resv_region *region, *next;
+ int ret = 0;
+
+ INIT_LIST_HEAD(&group_resv_regions);
+ iommu_get_group_resv_regions(group, &group_resv_regions);
+ list_for_each_entry(region, &group_resv_regions, list) {
+ if (region->prot & IOMMU_RESV_MSI) {
+ ret = iommu_get_msi_cookie(domain, region->start);
+ if (ret)
+ break;
+ }
+ }
+ list_for_each_entry_safe(region, next, &group_resv_regions, list)
+ kfree(region);
+ return ret;
+}
+
static int vfio_iommu_type1_attach_group(void *iommu_data,
struct iommu_group *iommu_group)
{
@@ -834,6 +856,10 @@ static int vfio_iommu_type1_attach_group(void *iommu_data,
if (ret)
goto out_detach;
+ ret = vfio_iommu_handle_resv_regions(domain->domain, iommu_group);
+ if (ret)
+ goto out_detach;
+
list_add(&domain->next, &iommu->domain_list);
mutex_unlock(&iommu->lock);
--
1.9.1
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[RFC v3 00/10] KVM PCIe/MSI passthrough on ARM/ARM64 and IOVA reserved regions Eric Auger <eric.auger@redhat.com> - 2016-11-15 14:10 +0100 [RFC v3 02/10] iommu: Rename iommu_dm_regions into iommu_resv_regions Eric Auger <eric.auger@redhat.com> - 2016-11-15 14:10 +0100 [RFC v3 01/10] iommu/dma: Allow MSI-only cookies Eric Auger <eric.auger@redhat.com> - 2016-11-15 14:10 +0100 [RFC v3 05/10] iommu: Do not map reserved regions Eric Auger <eric.auger@redhat.com> - 2016-11-15 14:20 +0100 [RFC v3 08/10] iommu/vt-d: Implement reserved region get/put callbacks Eric Auger <eric.auger@redhat.com> - 2016-11-15 14:20 +0100 [RFC v3 10/10] vfio/type1: Get MSI cookie Eric Auger <eric.auger@redhat.com> - 2016-11-15 14:20 +0100 [RFC v3 09/10] iommu/arm-smmu: Implement reserved region get/put callbacks Eric Auger <eric.auger@redhat.com> - 2016-11-15 14:20 +0100 [RFC v3 03/10] iommu: Add new reserved IOMMU attributes Eric Auger <eric.auger@redhat.com> - 2016-11-15 14:20 +0100 [RFC v3 06/10] iommu: iommu_get_group_resv_regions Eric Auger <eric.auger@redhat.com> - 2016-11-15 14:20 +0100 [RFC v3 07/10] iommu: Implement reserved_regions iommu-group sysfs file Eric Auger <eric.auger@redhat.com> - 2016-11-15 14:20 +0100 [RFC v3 04/10] iommu: iommu_alloc_resv_region Eric Auger <eric.auger@redhat.com> - 2016-11-15 14:20 +0100 Re: [RFC v3 00/10] KVM PCIe/MSI passthrough on ARM/ARM64 and IOVA reserved regions Auger Eric <eric.auger@redhat.com> - 2016-11-18 09:40 +0100 RE: [RFC v3 00/10] KVM PCIe/MSI passthrough on ARM/ARM64 and IOVA reserved regions Bharat Bhushan <bharat.bhushan@nxp.com> - 2016-11-18 11:10 +0100
csiph-web