Skip to content

Commit 4d54409

Browse files
Joelgranadosjoergroedel
authored andcommitted
iommu/vt-d: Separate page request queue from SVM
IO page faults are no longer dependent on CONFIG_INTEL_IOMMU_SVM. Move all Page Request Queue (PRQ) functions that handle prq events to a new file in drivers/iommu/intel/prq.c. The page_req_des struct is now declared in drivers/iommu/intel/prq.c. No functional changes are intended. This is a preparation patch to enable the use of IO page faults outside the SVM/PASID use cases. Signed-off-by: Joel Granados <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Lu Baolu <[email protected]> Signed-off-by: Joerg Roedel <[email protected]>
1 parent f164567 commit 4d54409

File tree

5 files changed

+424
-419
lines changed

5 files changed

+424
-419
lines changed

drivers/iommu/intel/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# SPDX-License-Identifier: GPL-2.0
22
obj-$(CONFIG_DMAR_TABLE) += dmar.o
3-
obj-$(CONFIG_INTEL_IOMMU) += iommu.o pasid.o nested.o cache.o
3+
obj-$(CONFIG_INTEL_IOMMU) += iommu.o pasid.o nested.o cache.o prq.o
44
obj-$(CONFIG_DMAR_TABLE) += trace.o cap_audit.o
55
obj-$(CONFIG_DMAR_PERF) += perf.o
66
obj-$(CONFIG_INTEL_IOMMU_DEBUGFS) += debugfs.o

drivers/iommu/intel/iommu.c

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1329,12 +1329,10 @@ static void free_dmar_iommu(struct intel_iommu *iommu)
13291329
/* free context mapping */
13301330
free_context_table(iommu);
13311331

1332-
#ifdef CONFIG_INTEL_IOMMU_SVM
13331332
if (pasid_supported(iommu)) {
13341333
if (ecap_prs(iommu->ecap))
1335-
intel_svm_finish_prq(iommu);
1334+
intel_iommu_finish_prq(iommu);
13361335
}
1337-
#endif
13381336
}
13391337

13401338
/*
@@ -2194,19 +2192,18 @@ static int __init init_dmars(void)
21942192

21952193
iommu_flush_write_buffer(iommu);
21962194

2197-
#ifdef CONFIG_INTEL_IOMMU_SVM
21982195
if (pasid_supported(iommu) && ecap_prs(iommu->ecap)) {
21992196
/*
22002197
* Call dmar_alloc_hwirq() with dmar_global_lock held,
22012198
* could cause possible lock race condition.
22022199
*/
22032200
up_write(&dmar_global_lock);
2204-
ret = intel_svm_enable_prq(iommu);
2201+
ret = intel_iommu_enable_prq(iommu);
22052202
down_write(&dmar_global_lock);
22062203
if (ret)
22072204
goto free_iommu;
22082205
}
2209-
#endif
2206+
22102207
ret = dmar_set_interrupt(iommu);
22112208
if (ret)
22122209
goto free_iommu;
@@ -2619,13 +2616,12 @@ static int intel_iommu_add(struct dmar_drhd_unit *dmaru)
26192616
intel_iommu_init_qi(iommu);
26202617
iommu_flush_write_buffer(iommu);
26212618

2622-
#ifdef CONFIG_INTEL_IOMMU_SVM
26232619
if (pasid_supported(iommu) && ecap_prs(iommu->ecap)) {
2624-
ret = intel_svm_enable_prq(iommu);
2620+
ret = intel_iommu_enable_prq(iommu);
26252621
if (ret)
26262622
goto disable_iommu;
26272623
}
2628-
#endif
2624+
26292625
ret = dmar_set_interrupt(iommu);
26302626
if (ret)
26312627
goto disable_iommu;
@@ -4072,7 +4068,7 @@ static void intel_iommu_remove_dev_pasid(struct device *dev, ioasid_t pasid,
40724068
intel_iommu_debugfs_remove_dev_pasid(dev_pasid);
40734069
kfree(dev_pasid);
40744070
intel_pasid_tear_down_entry(iommu, dev, pasid, false);
4075-
intel_drain_pasid_prq(dev, pasid);
4071+
intel_iommu_drain_pasid_prq(dev, pasid);
40764072
}
40774073

40784074
static int intel_iommu_set_dev_pasid(struct iommu_domain *domain,
@@ -4415,9 +4411,7 @@ const struct iommu_ops intel_iommu_ops = {
44154411
.def_domain_type = device_def_domain_type,
44164412
.remove_dev_pasid = intel_iommu_remove_dev_pasid,
44174413
.pgsize_bitmap = SZ_4K,
4418-
#ifdef CONFIG_INTEL_IOMMU_SVM
4419-
.page_response = intel_svm_page_response,
4420-
#endif
4414+
.page_response = intel_iommu_page_response,
44214415
.default_domain_ops = &(const struct iommu_domain_ops) {
44224416
.attach_dev = intel_iommu_attach_device,
44234417
.set_dev_pasid = intel_iommu_set_dev_pasid,

drivers/iommu/intel/iommu.h

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -728,12 +728,10 @@ struct intel_iommu {
728728

729729
struct iommu_flush flush;
730730
#endif
731-
#ifdef CONFIG_INTEL_IOMMU_SVM
732731
struct page_req_dsc *prq;
733732
unsigned char prq_name[16]; /* Name for PRQ interrupt */
734733
unsigned long prq_seq_number;
735734
struct completion prq_complete;
736-
#endif
737735
struct iopf_queue *iopf_queue;
738736
unsigned char iopfq_name[16];
739737
/* Synchronization between fault report and iommu device release. */
@@ -1274,18 +1272,18 @@ void intel_context_flush_present(struct device_domain_info *info,
12741272
struct context_entry *context,
12751273
u16 did, bool affect_domains);
12761274

1275+
int intel_iommu_enable_prq(struct intel_iommu *iommu);
1276+
int intel_iommu_finish_prq(struct intel_iommu *iommu);
1277+
void intel_iommu_page_response(struct device *dev, struct iopf_fault *evt,
1278+
struct iommu_page_response *msg);
1279+
void intel_iommu_drain_pasid_prq(struct device *dev, u32 pasid);
1280+
12771281
#ifdef CONFIG_INTEL_IOMMU_SVM
12781282
void intel_svm_check(struct intel_iommu *iommu);
1279-
int intel_svm_enable_prq(struct intel_iommu *iommu);
1280-
int intel_svm_finish_prq(struct intel_iommu *iommu);
1281-
void intel_svm_page_response(struct device *dev, struct iopf_fault *evt,
1282-
struct iommu_page_response *msg);
12831283
struct iommu_domain *intel_svm_domain_alloc(struct device *dev,
12841284
struct mm_struct *mm);
1285-
void intel_drain_pasid_prq(struct device *dev, u32 pasid);
12861285
#else
12871286
static inline void intel_svm_check(struct intel_iommu *iommu) {}
1288-
static inline void intel_drain_pasid_prq(struct device *dev, u32 pasid) {}
12891287
static inline struct iommu_domain *intel_svm_domain_alloc(struct device *dev,
12901288
struct mm_struct *mm)
12911289
{

0 commit comments

Comments
 (0)