linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: ohad@wizery.com (Ohad Ben-Cohen)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] iommu/core: let drivers know if an iommu fault
Date: Tue, 27 Sep 2011 11:14:22 +0300	[thread overview]
Message-ID: <mailman.155.1317113313.20020.linux-arm-kernel@lists.infradead.org> (raw)

handler isn't installed

Let 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 want.

Clarify that -ENOSYS is reserved for this purpose, and that fault
handlers are prohibited from using it.

Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com>
---
 drivers/iommu/iommu.c |    7 +++++++
 include/linux/iommu.h |    3 ++-
 2 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index 3a07259..c41a6a1 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -43,6 +43,13 @@ 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. It should never return -ENOSYS though, as this is
+ * reserved for the IOMMU core to return when no handler is installed.
  */
 void iommu_set_fault_handler(struct iommu_domain *domain,
 					iommu_fault_handler_t handler)
diff --git a/include/linux/iommu.h b/include/linux/iommu.h
index d084e87..2987199 100644
--- a/include/linux/iommu.h
+++ b/include/linux/iommu.h
@@ -98,11 +98,12 @@ extern void iommu_set_fault_handler(struct
iommu_domain *domain,
  * Returns 0 on success and an appropriate error code otherwise (if dynamic
  * PTE/TLB loading will one day be supported, implementations will be able
  * to tell whether it succeeded or not according to this return value).
+ * If a fault handler isn't installed, -ENOSYS is returned.
  */
 static inline int report_iommu_fault(struct iommu_domain *domain,
 		struct device *dev, unsigned long iova, int flags)
 {
-	int ret = 0;
+	int ret = -ENOSYS;

 	/*
 	 * if upper layers showed interest and installed a fault handler,
-- 
1.7.4.1

                 reply	other threads:[~2011-09-27  8:14 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=mailman.155.1317113313.20020.linux-arm-kernel@lists.infradead.org \
    --to=ohad@wizery.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).