Skip to content

Commit a0c47f2

Browse files
hegdevasantjoergroedel
authored andcommitted
iommu/amd: Introduce iommu_dev_data.max_pasids
This variable will track the number of PASIDs supported by the device. If IOMMU or device doesn't support PASID then it will be zero. This will be used while allocating GCR3 table to decide required number of PASID table levels. Also in PASID bind path it will use this variable to check whether device supports PASID or not. Signed-off-by: Vasant Hegde <[email protected]> Reviewed-by: Jason Gunthorpe <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Joerg Roedel <[email protected]>
1 parent 7c5b717 commit a0c47f2

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

drivers/iommu/amd/amd_iommu_types.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,7 @@ struct iommu_dev_data {
813813
struct device *dev;
814814
u16 devid; /* PCI Device ID */
815815

816+
u32 max_pasids; /* Max supported PASIDs */
816817
u32 flags; /* Holds AMD_IOMMU_DEVICE_FLAG_<*> */
817818
int ats_qdep;
818819
u8 ats_enabled :1; /* ATS state */

drivers/iommu/amd/iommu.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2104,6 +2104,7 @@ static struct iommu_device *amd_iommu_probe_device(struct device *dev)
21042104
{
21052105
struct iommu_device *iommu_dev;
21062106
struct amd_iommu *iommu;
2107+
struct iommu_dev_data *dev_data;
21072108
int ret;
21082109

21092110
if (!check_device(dev))
@@ -2130,6 +2131,17 @@ static struct iommu_device *amd_iommu_probe_device(struct device *dev)
21302131
iommu_dev = &iommu->iommu;
21312132
}
21322133

2134+
/*
2135+
* If IOMMU and device supports PASID then it will contain max
2136+
* supported PASIDs, else it will be zero.
2137+
*/
2138+
dev_data = dev_iommu_priv_get(dev);
2139+
if (amd_iommu_pasid_supported() && dev_is_pci(dev) &&
2140+
pdev_pasid_supported(dev_data)) {
2141+
dev_data->max_pasids = min_t(u32, iommu->iommu.max_pasids,
2142+
pci_max_pasids(to_pci_dev(dev)));
2143+
}
2144+
21332145
iommu_completion_wait(iommu);
21342146

21352147
return iommu_dev;

0 commit comments

Comments
 (0)