History

iommu: Add recoverable fault reporting

Some IOMMU hardware features, for example PCI PRI and Arm SMMU Stall, enable recoverable I/O page faults. Allow IOMMU drivers to report PRI Page Requests and Stall events through the new fault reporting API. The consumer of the fault can be either an I/O page fault handler in the host, or a guest OS. Once handled, the fault must be completed by sending a page response back to the IOMMU. Add an iommu_page_response() function to complete a page fault. There are two ways to extend the userspace API: * Add a field to iommu_page_response and a flag to iommu_page_response::flags describing the validity of this field. * Introduce a new iommu_page_response_X structure with a different version number. The kernel must then support both versions.

Jean-Philippe Brucker committed 7 years ago

Commit bf3255b1 parent 0c830e63 files · +146 −2Browse files

Showing the changes to include/linux (1 of 3 files). Show all

Unified · Split

include/linux/iommu.h+19−0
@@ -227,6 +227,7 @@ struct iommu_sva_ops { · 226 unmodified lines
227227 * @sva_bind: Bind process address space to device
228228 * @sva_unbind: Unbind process address space from device
229229 * @sva_get_pasid: Get PASID associated to a SVA handle
230+ * @page_response: handle page request response
230231 * @pgsize_bitmap: bitmap of all possible supported page sizes
231232 */
232233 struct iommu_ops {
@@ -287,6 +288,10 @@ struct iommu_ops { · 54 unmodified lines
287288 void (*sva_unbind)(struct iommu_sva *handle);
288289 int (*sva_get_pasid)(struct iommu_sva *handle);
289290
291+ int (*page_response)(struct device *dev,
292+ struct iommu_fault_event *evt,
293+ struct iommu_page_response *msg);
294+
290295 unsigned long pgsize_bitmap;
291296 };
292297
@@ -311,19 +316,25 @@ struct iommu_device { · 18 unmodified lines
311316 * unrecoverable faults such as DMA or IRQ remapping faults.
312317 *
313318 * @fault: fault descriptor
319+ * @list: pending fault event list, used for tracking responses
314320 */
315321 struct iommu_fault_event {
316322 struct iommu_fault fault;
323+ struct list_head list;
317324 };
318325
319326 /**
320327 * struct iommu_fault_param - per-device IOMMU fault data
321328 * @handler: Callback function to handle IOMMU faults at device level
322329 * @data: handler private data
330+ * @faults: holds the pending faults which needs response
331+ * @lock: protect pending faults list
323332 */
324333 struct iommu_fault_param {
325334 iommu_dev_fault_handler_t handler;
326335 void *data;
336+ struct list_head faults;
337+ struct mutex lock;
327338 };
328339
329340 /**
@@ -437,6 +448,8 @@ extern int iommu_unregister_device_fault_handler(struct device *dev); · 107 unmodified lines
437448
438449 extern int iommu_report_device_fault(struct device *dev,
439450 struct iommu_fault_event *evt);
451+extern int iommu_page_response(struct device *dev,
452+ struct iommu_page_response *msg);
440453
441454 extern int iommu_group_id(struct iommu_group *group);
442455 extern struct iommu_group *iommu_group_get_for_dev(struct device *dev);
@@ -765,6 +778,12 @@ int iommu_report_device_fault(struct device *dev, struct iommu_fault_event *evt) · 322 unmodified lines
765778 return -ENODEV;
766779 }
767780
781+static inline int iommu_page_response(struct device *dev,
782+ struct iommu_page_response *msg)
783+{
784+ return -ENODEV;
785+}
786+
768787 static inline int iommu_group_id(struct iommu_group *group)
769788 {
770789 return -ENODEV;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t