Skip to content

Commit be1af02

Browse files
ssuthiku-amdjoergroedel
authored andcommitted
iommu/amd: Update sanity check when enable PRI/ATS for IOMMU v1 table
Currently, PPR/ATS can be enabled only if the domain is type identity mapping. However, when allowing the IOMMU v2 page table to be used for DMA-API, the check is no longer valid. Update the sanity check to only apply for when using AMD_IOMMU_V1 page table mode. Signed-off-by: Suravee Suthikulpanit <[email protected]> Signed-off-by: Vasant Hegde <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Joerg Roedel <[email protected]>
1 parent 43312b7 commit be1af02

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

drivers/iommu/amd/iommu.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1694,7 +1694,7 @@ static void pdev_iommuv2_disable(struct pci_dev *pdev)
16941694
pci_disable_pasid(pdev);
16951695
}
16961696

1697-
static int pdev_iommuv2_enable(struct pci_dev *pdev)
1697+
static int pdev_pri_ats_enable(struct pci_dev *pdev)
16981698
{
16991699
int ret;
17001700

@@ -1757,11 +1757,19 @@ static int attach_device(struct device *dev,
17571757
struct iommu_domain *def_domain = iommu_get_dma_domain(dev);
17581758

17591759
ret = -EINVAL;
1760-
if (def_domain->type != IOMMU_DOMAIN_IDENTITY)
1760+
1761+
/*
1762+
* In case of using AMD_IOMMU_V1 page table mode and the device
1763+
* is enabling for PPR/ATS support (using v2 table),
1764+
* we need to make sure that the domain type is identity map.
1765+
*/
1766+
if ((amd_iommu_pgtable == AMD_IOMMU_V1) &&
1767+
def_domain->type != IOMMU_DOMAIN_IDENTITY) {
17611768
goto out;
1769+
}
17621770

17631771
if (dev_data->iommu_v2) {
1764-
if (pdev_iommuv2_enable(pdev) != 0)
1772+
if (pdev_pri_ats_enable(pdev) != 0)
17651773
goto out;
17661774

17671775
dev_data->ats.enabled = true;

0 commit comments

Comments
 (0)