aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iommu/amd_iommu.c
diff options
context:
space:
mode:
authorJoerg Roedel <joerg.roedel@amd.com>2011-12-07 06:01:36 -0500
committerJoerg Roedel <joerg.roedel@amd.com>2011-12-15 05:15:29 -0500
commit52efdb89d60a0f19949129a08af3437a7aab70be (patch)
treef2925a431bd88e68532b205b173ee293b174df84 /drivers/iommu/amd_iommu.c
parent46277b75da1b6c57159496d536acc2e9352a7ee0 (diff)
iommu/amd: Add amd_iommu_device_info() function
This function can be used to find out which features necessary for IOMMUv2 usage are available on a given device. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Diffstat (limited to 'drivers/iommu/amd_iommu.c')
-rw-r--r--drivers/iommu/amd_iommu.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
index d5074f428423..03944e76b700 100644
--- a/drivers/iommu/amd_iommu.c
+++ b/drivers/iommu/amd_iommu.c
@@ -3565,3 +3565,46 @@ void amd_iommu_enable_device_erratum(struct pci_dev *pdev, u32 erratum)
3565 dev_data->errata |= (1 << erratum); 3565 dev_data->errata |= (1 << erratum);
3566} 3566}
3567EXPORT_SYMBOL(amd_iommu_enable_device_erratum); 3567EXPORT_SYMBOL(amd_iommu_enable_device_erratum);
3568
3569int amd_iommu_device_info(struct pci_dev *pdev,
3570 struct amd_iommu_device_info *info)
3571{
3572 int max_pasids;
3573 int pos;
3574
3575 if (pdev == NULL || info == NULL)
3576 return -EINVAL;
3577
3578 if (!amd_iommu_v2_supported())
3579 return -EINVAL;
3580
3581 memset(info, 0, sizeof(*info));
3582
3583 pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_ATS);
3584 if (pos)
3585 info->flags |= AMD_IOMMU_DEVICE_FLAG_ATS_SUP;
3586
3587 pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_PRI);
3588 if (pos)
3589 info->flags |= AMD_IOMMU_DEVICE_FLAG_PRI_SUP;
3590
3591 pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_PASID);
3592 if (pos) {
3593 int features;
3594
3595 max_pasids = 1 << (9 * (amd_iommu_max_glx_val + 1));
3596 max_pasids = min(max_pasids, (1 << 20));
3597
3598 info->flags |= AMD_IOMMU_DEVICE_FLAG_PASID_SUP;
3599 info->max_pasids = min(pci_max_pasids(pdev), max_pasids);
3600
3601 features = pci_pasid_features(pdev);
3602 if (features & PCI_PASID_CAP_EXEC)
3603 info->flags |= AMD_IOMMU_DEVICE_FLAG_EXEC_SUP;
3604 if (features & PCI_PASID_CAP_PRIV)
3605 info->flags |= AMD_IOMMU_DEVICE_FLAG_PRIV_SUP;
3606 }
3607
3608 return 0;
3609}
3610EXPORT_SYMBOL(amd_iommu_device_info);