Skip to content

Commit 760f41d

Browse files
Jacob Panjoergroedel
authored andcommitted
iommu/vt-d: Remove virtual command interface
Virtual command interface was introduced to allow using host PASIDs inside VMs. It is unused and abandoned due to architectural change. With this patch, we can safely remove this feature and the related helpers. Link: https://lore.kernel.org/r/20230210230206.3160144-2-jacob.jun.pan@linux.intel.com Signed-off-by: Jacob Pan <jacob.jun.pan@linux.intel.com> Reviewed-by: Kevin Tian <kevin.tian@intel.com> Reviewed-by: Jason Gunthorpe <jgg@nvidia.com> Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com> Link: https://lore.kernel.org/r/20230322200803.869130-2-jacob.jun.pan@linux.intel.com Signed-off-by: Joerg Roedel <jroedel@suse.de>
1 parent c33fcc1 commit 760f41d

4 files changed

Lines changed: 0 additions & 91 deletions

File tree

drivers/iommu/intel/cap_audit.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ static inline void check_dmar_capabilities(struct intel_iommu *a,
5454
CHECK_FEATURE_MISMATCH(a, b, ecap, slts, ECAP_SLTS_MASK);
5555
CHECK_FEATURE_MISMATCH(a, b, ecap, nwfs, ECAP_NWFS_MASK);
5656
CHECK_FEATURE_MISMATCH(a, b, ecap, slads, ECAP_SLADS_MASK);
57-
CHECK_FEATURE_MISMATCH(a, b, ecap, vcs, ECAP_VCS_MASK);
5857
CHECK_FEATURE_MISMATCH(a, b, ecap, smts, ECAP_SMTS_MASK);
5958
CHECK_FEATURE_MISMATCH(a, b, ecap, pds, ECAP_PDS_MASK);
6059
CHECK_FEATURE_MISMATCH(a, b, ecap, dit, ECAP_DIT_MASK);
@@ -101,7 +100,6 @@ static int cap_audit_hotplug(struct intel_iommu *iommu, enum cap_audit_type type
101100
CHECK_FEATURE_MISMATCH_HOTPLUG(iommu, ecap, slts, ECAP_SLTS_MASK);
102101
CHECK_FEATURE_MISMATCH_HOTPLUG(iommu, ecap, nwfs, ECAP_NWFS_MASK);
103102
CHECK_FEATURE_MISMATCH_HOTPLUG(iommu, ecap, slads, ECAP_SLADS_MASK);
104-
CHECK_FEATURE_MISMATCH_HOTPLUG(iommu, ecap, vcs, ECAP_VCS_MASK);
105103
CHECK_FEATURE_MISMATCH_HOTPLUG(iommu, ecap, smts, ECAP_SMTS_MASK);
106104
CHECK_FEATURE_MISMATCH_HOTPLUG(iommu, ecap, pds, ECAP_PDS_MASK);
107105
CHECK_FEATURE_MISMATCH_HOTPLUG(iommu, ecap, dit, ECAP_DIT_MASK);

drivers/iommu/intel/dmar.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -993,8 +993,6 @@ static int map_iommu(struct intel_iommu *iommu, struct dmar_drhd_unit *drhd)
993993
warn_invalid_dmar(phys_addr, " returns all ones");
994994
goto unmap;
995995
}
996-
if (ecap_vcs(iommu->ecap))
997-
iommu->vccap = dmar_readq(iommu->reg + DMAR_VCCAP_REG);
998996

999997
/* the registers might be more than one page */
1000998
map_size = max_t(int, ecap_max_iotlb_offset(iommu->ecap),

drivers/iommu/intel/iommu.c

Lines changed: 0 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1722,9 +1722,6 @@ static void free_dmar_iommu(struct intel_iommu *iommu)
17221722
if (ecap_prs(iommu->ecap))
17231723
intel_svm_finish_prq(iommu);
17241724
}
1725-
if (vccap_pasid(iommu->vccap))
1726-
ioasid_unregister_allocator(&iommu->pasid_allocator);
1727-
17281725
#endif
17291726
}
17301727

@@ -2797,85 +2794,6 @@ static int copy_translation_tables(struct intel_iommu *iommu)
27972794
return ret;
27982795
}
27992796

2800-
#ifdef CONFIG_INTEL_IOMMU_SVM
2801-
static ioasid_t intel_vcmd_ioasid_alloc(ioasid_t min, ioasid_t max, void *data)
2802-
{
2803-
struct intel_iommu *iommu = data;
2804-
ioasid_t ioasid;
2805-
2806-
if (!iommu)
2807-
return INVALID_IOASID;
2808-
/*
2809-
* VT-d virtual command interface always uses the full 20 bit
2810-
* PASID range. Host can partition guest PASID range based on
2811-
* policies but it is out of guest's control.
2812-
*/
2813-
if (min < PASID_MIN || max > intel_pasid_max_id)
2814-
return INVALID_IOASID;
2815-
2816-
if (vcmd_alloc_pasid(iommu, &ioasid))
2817-
return INVALID_IOASID;
2818-
2819-
return ioasid;
2820-
}
2821-
2822-
static void intel_vcmd_ioasid_free(ioasid_t ioasid, void *data)
2823-
{
2824-
struct intel_iommu *iommu = data;
2825-
2826-
if (!iommu)
2827-
return;
2828-
/*
2829-
* Sanity check the ioasid owner is done at upper layer, e.g. VFIO
2830-
* We can only free the PASID when all the devices are unbound.
2831-
*/
2832-
if (ioasid_find(NULL, ioasid, NULL)) {
2833-
pr_alert("Cannot free active IOASID %d\n", ioasid);
2834-
return;
2835-
}
2836-
vcmd_free_pasid(iommu, ioasid);
2837-
}
2838-
2839-
static void register_pasid_allocator(struct intel_iommu *iommu)
2840-
{
2841-
/*
2842-
* If we are running in the host, no need for custom allocator
2843-
* in that PASIDs are allocated from the host system-wide.
2844-
*/
2845-
if (!cap_caching_mode(iommu->cap))
2846-
return;
2847-
2848-
if (!sm_supported(iommu)) {
2849-
pr_warn("VT-d Scalable Mode not enabled, no PASID allocation\n");
2850-
return;
2851-
}
2852-
2853-
/*
2854-
* Register a custom PASID allocator if we are running in a guest,
2855-
* guest PASID must be obtained via virtual command interface.
2856-
* There can be multiple vIOMMUs in each guest but only one allocator
2857-
* is active. All vIOMMU allocators will eventually be calling the same
2858-
* host allocator.
2859-
*/
2860-
if (!vccap_pasid(iommu->vccap))
2861-
return;
2862-
2863-
pr_info("Register custom PASID allocator\n");
2864-
iommu->pasid_allocator.alloc = intel_vcmd_ioasid_alloc;
2865-
iommu->pasid_allocator.free = intel_vcmd_ioasid_free;
2866-
iommu->pasid_allocator.pdata = (void *)iommu;
2867-
if (ioasid_register_allocator(&iommu->pasid_allocator)) {
2868-
pr_warn("Custom PASID allocator failed, scalable mode disabled\n");
2869-
/*
2870-
* Disable scalable mode on this IOMMU if there
2871-
* is no custom allocator. Mixing SM capable vIOMMU
2872-
* and non-SM vIOMMU are not supported.
2873-
*/
2874-
intel_iommu_sm = 0;
2875-
}
2876-
}
2877-
#endif
2878-
28792797
static int __init init_dmars(void)
28802798
{
28812799
struct dmar_drhd_unit *drhd;
@@ -2964,9 +2882,6 @@ static int __init init_dmars(void)
29642882
*/
29652883
for_each_active_iommu(iommu, drhd) {
29662884
iommu_flush_write_buffer(iommu);
2967-
#ifdef CONFIG_INTEL_IOMMU_SVM
2968-
register_pasid_allocator(iommu);
2969-
#endif
29702885
iommu_set_root_entry(iommu);
29712886
}
29722887

drivers/iommu/intel/iommu.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@
198198
#define ecap_flts(e) (((e) >> 47) & 0x1)
199199
#define ecap_slts(e) (((e) >> 46) & 0x1)
200200
#define ecap_slads(e) (((e) >> 45) & 0x1)
201-
#define ecap_vcs(e) (((e) >> 44) & 0x1)
202201
#define ecap_smts(e) (((e) >> 43) & 0x1)
203202
#define ecap_dit(e) (((e) >> 41) & 0x1)
204203
#define ecap_pds(e) (((e) >> 42) & 0x1)
@@ -676,7 +675,6 @@ struct intel_iommu {
676675
unsigned char prq_name[16]; /* Name for PRQ interrupt */
677676
unsigned long prq_seq_number;
678677
struct completion prq_complete;
679-
struct ioasid_allocator_ops pasid_allocator; /* Custom allocator for PASIDs */
680678
#endif
681679
struct iopf_queue *iopf_queue;
682680
unsigned char iopfq_name[16];

0 commit comments

Comments
 (0)