提交 be1af02b 编写于 作者: S Suravee Suthikulpanit 提交者: Joerg Roedel

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: NSuravee Suthikulpanit <suravee.suthikulpanit@amd.com>
Signed-off-by: NVasant Hegde <vasant.hegde@amd.com>
Link: https://lore.kernel.org/r/20220825063939.8360-6-vasant.hegde@amd.comSigned-off-by: NJoerg Roedel <jroedel@suse.de>
上级 43312b71
...@@ -1694,7 +1694,7 @@ static void pdev_iommuv2_disable(struct pci_dev *pdev) ...@@ -1694,7 +1694,7 @@ static void pdev_iommuv2_disable(struct pci_dev *pdev)
pci_disable_pasid(pdev); pci_disable_pasid(pdev);
} }
static int pdev_iommuv2_enable(struct pci_dev *pdev) static int pdev_pri_ats_enable(struct pci_dev *pdev)
{ {
int ret; int ret;
...@@ -1757,11 +1757,19 @@ static int attach_device(struct device *dev, ...@@ -1757,11 +1757,19 @@ static int attach_device(struct device *dev,
struct iommu_domain *def_domain = iommu_get_dma_domain(dev); struct iommu_domain *def_domain = iommu_get_dma_domain(dev);
ret = -EINVAL; ret = -EINVAL;
if (def_domain->type != IOMMU_DOMAIN_IDENTITY)
/*
* In case of using AMD_IOMMU_V1 page table mode and the device
* is enabling for PPR/ATS support (using v2 table),
* we need to make sure that the domain type is identity map.
*/
if ((amd_iommu_pgtable == AMD_IOMMU_V1) &&
def_domain->type != IOMMU_DOMAIN_IDENTITY) {
goto out; goto out;
}
if (dev_data->iommu_v2) { if (dev_data->iommu_v2) {
if (pdev_iommuv2_enable(pdev) != 0) if (pdev_pri_ats_enable(pdev) != 0)
goto out; goto out;
dev_data->ats.enabled = true; dev_data->ats.enabled = true;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册