Skip to content

Commit 0ed6d2d

Browse files
ohadbcjoergroedel
authored andcommitted
iommu/core: let drivers know if an iommu fault handler isn't installed
Make report_iommu_fault() return -ENOSYS whenever an iommu fault handler isn't installed, so IOMMU drivers can then do their own platform-specific default behavior if they wanted. Fault handlers can still return -ENOSYS in case they want to elicit the default behavior of the IOMMU drivers. Signed-off-by: Ohad Ben-Cohen <[email protected]> Signed-off-by: Joerg Roedel <[email protected]>
1 parent 30bd918 commit 0ed6d2d

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

drivers/iommu/iommu.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ EXPORT_SYMBOL_GPL(iommu_found);
4343
* iommu_set_fault_handler() - set a fault handler for an iommu domain
4444
* @domain: iommu domain
4545
* @handler: fault handler
46+
*
47+
* This function should be used by IOMMU users which want to be notified
48+
* whenever an IOMMU fault happens.
49+
*
50+
* The fault handler itself should return 0 on success, and an appropriate
51+
* error code otherwise.
4652
*/
4753
void iommu_set_fault_handler(struct iommu_domain *domain,
4854
iommu_fault_handler_t handler)

include/linux/iommu.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,15 @@ extern void iommu_set_fault_handler(struct iommu_domain *domain,
9898
* Returns 0 on success and an appropriate error code otherwise (if dynamic
9999
* PTE/TLB loading will one day be supported, implementations will be able
100100
* to tell whether it succeeded or not according to this return value).
101+
*
102+
* Specifically, -ENOSYS is returned if a fault handler isn't installed
103+
* (though fault handlers can also return -ENOSYS, in case they want to
104+
* elicit the default behavior of the IOMMU drivers).
101105
*/
102106
static inline int report_iommu_fault(struct iommu_domain *domain,
103107
struct device *dev, unsigned long iova, int flags)
104108
{
105-
int ret = 0;
109+
int ret = -ENOSYS;
106110

107111
/*
108112
* if upper layers showed interest and installed a fault handler,

0 commit comments

Comments
 (0)