All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joerg Roedel <joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
To: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
Cc: Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org>,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: [PATCH 01/12] iommu: Introduce iommu_capable API function
Date: Fri,  5 Sep 2014 12:52:53 +0200	[thread overview]
Message-ID: <1409914384-21191-2-git-send-email-joro@8bytes.org> (raw)
In-Reply-To: <1409914384-21191-1-git-send-email-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>

From: Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org>

This function will replace the current iommu_domain_has_cap
function and clean up the interface while at it.

Signed-off-by: Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org>
---
 drivers/iommu/iommu.c | 18 +++++++++++++++---
 include/linux/iommu.h |  7 +++++++
 2 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index ac4adb3..1bc882e 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -815,6 +815,15 @@ bool iommu_present(struct bus_type *bus)
 }
 EXPORT_SYMBOL_GPL(iommu_present);
 
+bool iommu_capable(struct bus_type *bus, enum iommu_cap cap)
+{
+	if (!bus->iommu_ops || !bus->iommu_ops->capable)
+		return false;
+
+	return bus->iommu_ops->capable(cap);
+}
+EXPORT_SYMBOL_GPL(iommu_capable);
+
 /**
  * iommu_set_fault_handler() - set a fault handler for an iommu domain
  * @domain: iommu domain
@@ -948,10 +957,13 @@ EXPORT_SYMBOL_GPL(iommu_iova_to_phys);
 int iommu_domain_has_cap(struct iommu_domain *domain,
 			 unsigned long cap)
 {
-	if (unlikely(domain->ops->domain_has_cap == NULL))
-		return 0;
+	if (domain->ops->domain_has_cap != NULL)
+		return domain->ops->domain_has_cap(domain, cap);
+
+	if (domain->ops->capable != NULL)
+		return domain->ops->capable(cap);
 
-	return domain->ops->domain_has_cap(domain, cap);
+	return 0;
 }
 EXPORT_SYMBOL_GPL(iommu_domain_has_cap);
 
diff --git a/include/linux/iommu.h b/include/linux/iommu.h
index 20f9a52..d43146a 100644
--- a/include/linux/iommu.h
+++ b/include/linux/iommu.h
@@ -102,6 +102,7 @@ enum iommu_attr {
  * @pgsize_bitmap: bitmap of supported page sizes
  */
 struct iommu_ops {
+	bool (*capable)(enum iommu_cap);
 	int (*domain_init)(struct iommu_domain *domain);
 	void (*domain_destroy)(struct iommu_domain *domain);
 	int (*attach_dev)(struct iommu_domain *domain, struct device *dev);
@@ -142,6 +143,7 @@ struct iommu_ops {
 
 extern int bus_set_iommu(struct bus_type *bus, const struct iommu_ops *ops);
 extern bool iommu_present(struct bus_type *bus);
+extern bool iommu_capable(struct bus_type *bus, enum iommu_cap cap);
 extern struct iommu_domain *iommu_domain_alloc(struct bus_type *bus);
 extern struct iommu_group *iommu_group_get_by_id(int id);
 extern void iommu_domain_free(struct iommu_domain *domain);
@@ -250,6 +252,11 @@ static inline bool iommu_present(struct bus_type *bus)
 	return false;
 }
 
+static inline bool iommu_capable(struct bus_type *bus, enum iommu_cap cap)
+{
+	return false;
+}
+
 static inline struct iommu_domain *iommu_domain_alloc(struct bus_type *bus)
 {
 	return NULL;
-- 
1.9.1

WARNING: multiple messages have this Message-ID (diff)
From: Joerg Roedel <joro@8bytes.org>
To: iommu@lists.linux-foundation.org
Cc: linux-kernel@vger.kernel.org, Joerg Roedel <jroedel@suse.de>
Subject: [PATCH 01/12] iommu: Introduce iommu_capable API function
Date: Fri,  5 Sep 2014 12:52:53 +0200	[thread overview]
Message-ID: <1409914384-21191-2-git-send-email-joro@8bytes.org> (raw)
In-Reply-To: <1409914384-21191-1-git-send-email-joro@8bytes.org>

From: Joerg Roedel <jroedel@suse.de>

This function will replace the current iommu_domain_has_cap
function and clean up the interface while at it.

Signed-off-by: Joerg Roedel <jroedel@suse.de>
---
 drivers/iommu/iommu.c | 18 +++++++++++++++---
 include/linux/iommu.h |  7 +++++++
 2 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index ac4adb3..1bc882e 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -815,6 +815,15 @@ bool iommu_present(struct bus_type *bus)
 }
 EXPORT_SYMBOL_GPL(iommu_present);
 
+bool iommu_capable(struct bus_type *bus, enum iommu_cap cap)
+{
+	if (!bus->iommu_ops || !bus->iommu_ops->capable)
+		return false;
+
+	return bus->iommu_ops->capable(cap);
+}
+EXPORT_SYMBOL_GPL(iommu_capable);
+
 /**
  * iommu_set_fault_handler() - set a fault handler for an iommu domain
  * @domain: iommu domain
@@ -948,10 +957,13 @@ EXPORT_SYMBOL_GPL(iommu_iova_to_phys);
 int iommu_domain_has_cap(struct iommu_domain *domain,
 			 unsigned long cap)
 {
-	if (unlikely(domain->ops->domain_has_cap == NULL))
-		return 0;
+	if (domain->ops->domain_has_cap != NULL)
+		return domain->ops->domain_has_cap(domain, cap);
+
+	if (domain->ops->capable != NULL)
+		return domain->ops->capable(cap);
 
-	return domain->ops->domain_has_cap(domain, cap);
+	return 0;
 }
 EXPORT_SYMBOL_GPL(iommu_domain_has_cap);
 
diff --git a/include/linux/iommu.h b/include/linux/iommu.h
index 20f9a52..d43146a 100644
--- a/include/linux/iommu.h
+++ b/include/linux/iommu.h
@@ -102,6 +102,7 @@ enum iommu_attr {
  * @pgsize_bitmap: bitmap of supported page sizes
  */
 struct iommu_ops {
+	bool (*capable)(enum iommu_cap);
 	int (*domain_init)(struct iommu_domain *domain);
 	void (*domain_destroy)(struct iommu_domain *domain);
 	int (*attach_dev)(struct iommu_domain *domain, struct device *dev);
@@ -142,6 +143,7 @@ struct iommu_ops {
 
 extern int bus_set_iommu(struct bus_type *bus, const struct iommu_ops *ops);
 extern bool iommu_present(struct bus_type *bus);
+extern bool iommu_capable(struct bus_type *bus, enum iommu_cap cap);
 extern struct iommu_domain *iommu_domain_alloc(struct bus_type *bus);
 extern struct iommu_group *iommu_group_get_by_id(int id);
 extern void iommu_domain_free(struct iommu_domain *domain);
@@ -250,6 +252,11 @@ static inline bool iommu_present(struct bus_type *bus)
 	return false;
 }
 
+static inline bool iommu_capable(struct bus_type *bus, enum iommu_cap cap)
+{
+	return false;
+}
+
 static inline struct iommu_domain *iommu_domain_alloc(struct bus_type *bus)
 {
 	return NULL;
-- 
1.9.1


  parent reply	other threads:[~2014-09-05 10:52 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-05 10:52 [PATCH 00/12] iommu: Convert iommu_domain_has_cap() to iommu_capable() Joerg Roedel
2014-09-05 10:52 ` Joerg Roedel
     [not found] ` <1409914384-21191-1-git-send-email-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
2014-09-05 10:52   ` Joerg Roedel [this message]
2014-09-05 10:52     ` [PATCH 01/12] iommu: Introduce iommu_capable API function Joerg Roedel
2014-09-05 10:52   ` [PATCH 02/12] iommu: Convert iommu-caps from define to enum Joerg Roedel
2014-09-05 10:52     ` Joerg Roedel
2014-09-05 10:52   ` [PATCH 03/12] iommu/amd: Convert to iommu_capable() API function Joerg Roedel
2014-09-05 10:52     ` Joerg Roedel
2014-09-05 10:52   ` [PATCH 04/12] iommu/arm-smmu: " Joerg Roedel
2014-09-05 10:52     ` Joerg Roedel
     [not found]     ` <1409914384-21191-5-git-send-email-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
2014-09-08 16:51       ` Will Deacon
2014-09-08 16:51         ` Will Deacon
     [not found]         ` <20140908165136.GW26030-5wv7dgnIgG8@public.gmane.org>
2014-09-09 13:57           ` Joerg Roedel
2014-09-09 13:57             ` Joerg Roedel
2014-09-17  8:53           ` [PATCH 04/13 v2] iommu/arm-smmu: Convert to iommu_capable() API function function Joerg Roedel
2014-09-17  8:53             ` Joerg Roedel
     [not found]             ` <20140917085312.GE2533-l3A5Bk7waGM@public.gmane.org>
2014-09-19 16:42               ` Will Deacon
2014-09-19 16:42                 ` Will Deacon
     [not found]                 ` <20140919164220.GI20773-5wv7dgnIgG8@public.gmane.org>
2014-09-22 15:36                   ` Joerg Roedel
2014-09-22 15:36                     ` Joerg Roedel
2014-09-05 10:52   ` [PATCH 05/12] iommu/fsl: Convert to iommu_capable() API function Joerg Roedel
2014-09-05 10:52     ` Joerg Roedel
2014-09-09 18:38     ` Varun Sethi
2014-09-05 10:52   ` [PATCH 06/12] iommu/vt-d: " Joerg Roedel
2014-09-05 10:52     ` Joerg Roedel
2014-09-05 10:52   ` [PATCH 07/12] iommu/msm: " Joerg Roedel
2014-09-05 10:52     ` Joerg Roedel
2014-09-05 10:53   ` [PATCH 08/12] iommu/tegra: " Joerg Roedel
2014-09-05 10:53     ` Joerg Roedel
2014-09-05 10:53   ` [PATCH 09/12] kvm: iommu: Convert to use new " Joerg Roedel
2014-09-05 10:53     ` Joerg Roedel
     [not found]     ` <1409914384-21191-10-git-send-email-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
2014-09-17  8:29       ` Joerg Roedel
2014-09-17  8:29         ` Joerg Roedel
2014-09-05 10:53   ` [PATCH 10/12] vfio: " Joerg Roedel
2014-09-05 10:53     ` Joerg Roedel
     [not found]     ` <1409914384-21191-11-git-send-email-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
2014-09-08 23:14       ` Alex Williamson
2014-09-08 23:14         ` Alex Williamson
2014-09-05 10:53   ` [PATCH 11/12] IB/usnic: " Joerg Roedel
2014-09-05 10:53     ` Joerg Roedel
     [not found]     ` <1409914384-21191-12-git-send-email-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
2014-09-17  8:30       ` Joerg Roedel
2014-09-17  8:30         ` Joerg Roedel
2014-09-05 10:53   ` [PATCH 12/12] iommu: Remove iommu_domain_has_cap() " Joerg Roedel
2014-09-05 10:53     ` Joerg Roedel

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=1409914384-21191-2-git-send-email-joro@8bytes.org \
    --to=joro-zlv9swrftaidnm+yrofe0a@public.gmane.org \
    --cc=iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
    --cc=jroedel-l3A5Bk7waGM@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.