Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 07ee8694 authored by Joerg Roedel's avatar Joerg Roedel
Browse files

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: default avatarJoerg Roedel <jroedel@suse.de>
parent 07f643a3
Loading
Loading
Loading
Loading
+14 −1
Original line number Original line Diff line number Diff line
@@ -2253,6 +2253,8 @@ static void detach_device(struct device *dev)


static int amd_iommu_add_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;
	struct amd_iommu *iommu;
	u16 devid;
	u16 devid;
	int ret;
	int ret;
@@ -2270,7 +2272,18 @@ static int amd_iommu_add_device(struct device *dev)
	}
	}
	init_iommu_group(dev);
	init_iommu_group(dev);


	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;
		dev->archdata.dma_ops = &amd_iommu_dma_ops;
	}


out:
out:
	iommu_completion_wait(iommu);
	iommu_completion_wait(iommu);