Skip to content

Commit a1deee9

Browse files
yiliu1765joergroedel
authored andcommitted
iommu/vt-d: Add iommu_domain_did() to get did
domain_id_iommu() does not support SVA type and identity type domains. Add iommu_domain_did() to support all domain types. Signed-off-by: Yi Liu <yi.l.liu@intel.com> Link: https://lore.kernel.org/r/20241107122234.7424-7-yi.l.liu@intel.com Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com> Signed-off-by: Joerg Roedel <jroedel@suse.de>
1 parent d93cf86 commit a1deee9

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

drivers/iommu/intel/iommu.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,13 @@ static inline struct dmar_domain *to_dmar_domain(struct iommu_domain *dom)
806806
return container_of(dom, struct dmar_domain, domain);
807807
}
808808

809+
/*
810+
* Domain ID reserved for pasid entries programmed for first-level
811+
* only and pass-through transfer modes.
812+
*/
813+
#define FLPT_DEFAULT_DID 1
814+
#define NUM_RESERVED_DID 2
815+
809816
/* Retrieve the domain ID which has allocated to the domain */
810817
static inline u16
811818
domain_id_iommu(struct dmar_domain *domain, struct intel_iommu *iommu)
@@ -816,6 +823,15 @@ domain_id_iommu(struct dmar_domain *domain, struct intel_iommu *iommu)
816823
return info->did;
817824
}
818825

826+
static inline u16
827+
iommu_domain_did(struct iommu_domain *domain, struct intel_iommu *iommu)
828+
{
829+
if (domain->type == IOMMU_DOMAIN_SVA ||
830+
domain->type == IOMMU_DOMAIN_IDENTITY)
831+
return FLPT_DEFAULT_DID;
832+
return domain_id_iommu(to_dmar_domain(domain), iommu);
833+
}
834+
819835
/*
820836
* 0: readable
821837
* 1: writable

drivers/iommu/intel/pasid.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,6 @@
2222
#define is_pasid_enabled(entry) (((entry)->lo >> 3) & 0x1)
2323
#define get_pasid_dir_size(entry) (1 << ((((entry)->lo >> 9) & 0x7) + 7))
2424

25-
/*
26-
* Domain ID reserved for pasid entries programmed for first-level
27-
* only and pass-through transfer modes.
28-
*/
29-
#define FLPT_DEFAULT_DID 1
30-
#define NUM_RESERVED_DID 2
31-
3225
#define PASID_FLAG_NESTED BIT(1)
3326
#define PASID_FLAG_PAGE_SNOOP BIT(2)
3427

0 commit comments

Comments
 (0)