]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blobdiff - drivers/iommu/iommu.c
iommu/core: let drivers know if an iommu fault handler isn't installed
[mirror_ubuntu-artful-kernel.git] / drivers / iommu / iommu.c
index 6e6b6a11b3ced64d1c90e3c9d35d25823f6b5ccf..bd2d4d2764ddf2cf54491d43a3c49f109ba638db 100644 (file)
@@ -39,6 +39,26 @@ bool iommu_found(void)
 }
 EXPORT_SYMBOL_GPL(iommu_found);
 
+/**
+ * iommu_set_fault_handler() - set a fault handler for an iommu domain
+ * @domain: iommu domain
+ * @handler: fault handler
+ *
+ * This function should be used by IOMMU users which want to be notified
+ * whenever an IOMMU fault happens.
+ *
+ * The fault handler itself should return 0 on success, and an appropriate
+ * error code otherwise.
+ */
+void iommu_set_fault_handler(struct iommu_domain *domain,
+                                       iommu_fault_handler_t handler)
+{
+       BUG_ON(!domain);
+
+       domain->handler = handler;
+}
+EXPORT_SYMBOL_GPL(iommu_set_fault_handler);
+
 struct iommu_domain *iommu_domain_alloc(void)
 {
        struct iommu_domain *domain;