iommu/vt-d: Make SVA and IOPF irrelevant
Subsystems (2)
Lu Baolu
maintainerPATCH 1/1 iommu/vt-d: Make SVA and IOPF irrelevant
The existing IOPF handling code relies on the per-PASID SVA data structures. It does not apply to scenarios other than SVA. This decouples the I/O page fault reporting and responding code from SVA related data structures so that the PRQ handling code could become generic.
--- drivers/iommu/intel/iommu.h | 1 - drivers/iommu/intel/svm.c | 65 +++++-------------------------------- 2 files changed, 8 insertions(+), 58 deletions(-)
drivers/iommu/intel/iommu.h +0 -1
@@ -757,7 +757,6 @@ struct intel_svm_dev {struct device *dev;struct intel_iommu *iommu;struct iommu_sva sva; -unsigned long prq_seq_number;u32 pasid;int users;u16 did;
drivers/iommu/intel/svm.c +8 -57
125 lines not on this page · raw message
Signature · 1 line
2.25.1
Quoted 8 lines
From: Lu Baolu <[email protected]>
Sent: Thursday, September 8, 2022 10:36 AMThe existing IOPF handling code relies on the per-PASID SVA data structures. It does not apply to scenarios other than SVA. This decouples the I/O page fault reporting and responding code from SVA related data structures so that the PRQ handling code could become generic.
I think the point is that it's unnecessary to access those SVA data in the fault path. otherwise 'decouple' reads like an alternative implementation is added instead of just removing the code.
Overall this is a nice cleanup, but a few nits here:
drivers/iommu/intel/svm.c static irqreturn_t prq_event_thread(int irq, void *d) · line 765
Quoted 4 lines
drivers/iommu/intel/svm.c +0
-4-/* -* If prq is to be handled outside iommu driver via receiver of -* the fault notifiers, we skip the page response here. -*/
I didn't understand what this comment is trying to say. But just want to confirm removing it is the desired thing given the original code below it is still kept below...
Quoted 11 lines
drivers/iommu/intel/svm.c +4
-1-if (intel_svm_prq_report (iommu, sdev->dev, req)) + pdev =pci_get_domain_bus_and_slot (iommu->segment, +PCI_BUS_NUM (req->rid), + req->rid &0xff ); +if (!pdev ||intel_svm_prq_report (iommu, &pdev->dev, req)) handle_bad_prq_event(iommu, req,
QI_RESP_INVALID);(quoted diff) +1
-1- trace_prq_report(iommu, sdev->dev, req->qw_0, req->qw_1, + trace_prq_report(iommu, &pdev->dev, req->qw_0, req-Quoted 1 line
qw_1,
drivers/iommu/intel/svm.c static irqreturn_t prq_event_thread(int irq, void *d) · line 733
Quoted 3 lines
drivers/iommu/intel/svm.c +1
-1req->priv_data[0 ], req->priv_data[1 ], - sdev->prq_seq_number); + prq_seq_number++);
Previously this is counted per device but now becomes global. Could it be stored elsewhere in a per-device structure?
Baolu Lu
maintainerQuoted 9 lines · Kevin
Quoted 8 lines
From: Lu Baolu <[email protected]>
Sent: Thursday, September 8, 2022 10:36 AMThe existing IOPF handling code relies on the per-PASID SVA data structures. It does not apply to scenarios other than SVA. This decouples the I/O page fault reporting and responding code from SVA related data structures so that the PRQ handling code could become generic.
Quoted 3 lines
I think the point is that it's unnecessary to access those SVA data in the fault path. otherwise 'decouple' reads like an alternative implementation is added instead of just removing the code.
Makes sense. I will rephrase the commit message like this:
iommu/vt-d: Remove unnecessary SVA data accesses in page fault path
The existing I/O page fault handling code accesses the per-PASID SVA data structures. This is unnecessary and makes the fault handling code only suitable for SVA scenarios. This removes the SVA data accesses from the I/O page fault reporting and responding code, so that the fault handling code could be generic.
Quoted 11 lines
Overall this is a nice cleanup, but a few nits here:
drivers/iommu/intel/svm.c static irqreturn_t prq_event_thread(int irq, void *d) · line 765
Quoted 4 lines
drivers/iommu/intel/svm.c +0
-4-/* -* If prq is to be handled outside iommu driver via receiver of -* the fault notifiers, we skip the page response here. -*/ I didn't understand what this comment is trying to say. But just want to confirm removing it is the desired thing given the original code below it is still kept below...
I carelessly removed this comment. Yes. It still makes sense. I will add it back.
Quoted 11 lines
Quoted 11 lines
drivers/iommu/intel/svm.c +4
-1-if (intel_svm_prq_report (iommu, sdev->dev, req)) + pdev =pci_get_domain_bus_and_slot (iommu->segment, +PCI_BUS_NUM (req->rid), + req->rid &0xff ); +if (!pdev ||intel_svm_prq_report (iommu, &pdev->dev, req)) handle_bad_prq_event(iommu, req,
QI_RESP_INVALID);(quoted diff) +1
-1- trace_prq_report(iommu, sdev->dev, req->qw_0, req->qw_1, + trace_prq_report(iommu, &pdev->dev, req->qw_0, req-
Quoted 7 lines
drivers/iommu/intel/svm.c static irqreturn_t prq_event_thread(int irq, void *d) · line 733
Quoted 4 lines
Quoted 1 line
qw_1,req->priv_data[0], req->priv_data[1],
drivers/iommu/intel/svm.c +1
-1- sdev->prq_seq_number); + prq_seq_number++);Previously this is counted per device but now becomes global. Could it be stored elsewhere in a per-device structure?
I think the per-IOMMU structure might be the right place to store it. Those faults share a page fault queue.
Best regards,
baolu