From: Lu Baolu <baolu...@linux.intel.com> PCIe spec defines Max PASID Width per-device. Since a PASID is only used with IOMMU enabled, this patch introduces a PASID max variable on the per-device IOMMU data. It will be used for limiting PASID allocation in that PASID table is per-device.
Signed-off-by: Lu Baolu <baolu...@linux.intel.com> Signed-off-by: Jacob Pan <jacob.jun....@linux.intel.com> --- drivers/iommu/intel/iommu.c | 4 +++- include/linux/iommu.h | 13 +++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index 50666d250b36..881f8361eca2 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -2602,8 +2602,10 @@ static struct dmar_domain *dmar_insert_one_dev_info(struct intel_iommu *iommu, if (sm_supported(iommu)) { if (pasid_supported(iommu)) { int features = pci_pasid_features(pdev); - if (features >= 0) + if (features >= 0) { info->pasid_supported = features | 1; + iommu_set_dev_pasid_max(&pdev->dev, pci_max_pasids(pdev)); + } } if (info->ats_supported && ecap_prs(iommu->ecap) && diff --git a/include/linux/iommu.h b/include/linux/iommu.h index de0c57a567c8..369f05c2a4e2 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -364,6 +364,7 @@ struct iommu_fault_param { * @fwspec: IOMMU fwspec data * @iommu_dev: IOMMU device this device is linked to * @priv: IOMMU Driver private data + * @pasid_max Max PASID value supported by this device * * TODO: migrate other per device data pointers under iommu_dev_data, e.g. * struct iommu_group *iommu_group; @@ -375,8 +376,20 @@ struct dev_iommu { struct iommu_fwspec *fwspec; struct iommu_device *iommu_dev; void *priv; + unsigned int pasid_max; }; +static inline void iommu_set_dev_pasid_max(struct device *dev, + unsigned int max) +{ + struct dev_iommu *param = dev->iommu; + + if (WARN_ON(!param)) + return; + + param->pasid_max = max; +} + int iommu_device_register(struct iommu_device *iommu, const struct iommu_ops *ops, struct device *hwdev); -- 2.25.1 _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu