diff options
author | Joerg Roedel <jroedel@suse.de> | 2015-05-28 19:41:42 +0300 |
---|---|---|
committer | Joerg Roedel <jroedel@suse.de> | 2015-06-11 10:42:23 +0300 |
commit | 07ee86948c9111d49583be462500042fedfecb4a (patch) | |
tree | 38fb5b5b3b10d6c92316165b7e98fa59b983d058 /drivers | |
parent | 07f643a35d6b50f0f091444f07db1353188e787e (diff) | |
download | linux-07ee86948c9111d49583be462500042fedfecb4a.tar.xz |
iommu/amd: Put IOMMUv2 devices in a direct mapped domain
A device that might be used for HSA needs to be in a direct
mapped domain so that all DMA-API mappings stay alive when
the IOMMUv2 stack is used.
Signed-off-by: Joerg Roedel <jroedel@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/iommu/amd_iommu.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c index 188b81d56ac4..623be17e28d7 100644 --- a/drivers/iommu/amd_iommu.c +++ b/drivers/iommu/amd_iommu.c @@ -2253,6 +2253,8 @@ static void detach_device(struct device *dev) static int amd_iommu_add_device(struct device *dev) { + struct iommu_dev_data *dev_data; + struct iommu_domain *domain; struct amd_iommu *iommu; u16 devid; int ret; @@ -2270,7 +2272,18 @@ static int amd_iommu_add_device(struct device *dev) } init_iommu_group(dev); - dev->archdata.dma_ops = &amd_iommu_dma_ops; + dev_data = get_dev_data(dev); + if (dev_data && dev_data->iommu_v2) + iommu_request_dm_for_dev(dev); + + /* Domains are initialized for this device - have a look what we ended up with */ + domain = iommu_get_domain_for_dev(dev); + if (domain->type == IOMMU_DOMAIN_IDENTITY) { + dev_data->passthrough = true; + dev->archdata.dma_ops = &nommu_dma_ops; + } else { + dev->archdata.dma_ops = &amd_iommu_dma_ops; + } out: iommu_completion_wait(iommu); |