* [PATCH 01/12] iommu: Introduce iommu_capable API function
[not found] ` <1409914384-21191-1-git-send-email-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
@ 2014-09-05 10:52 ` Joerg Roedel
2014-09-05 10:52 ` [PATCH 02/12] iommu: Convert iommu-caps from define to enum Joerg Roedel
` (10 subsequent siblings)
11 siblings, 0 replies; 22+ messages in thread
From: Joerg Roedel @ 2014-09-05 10:52 UTC (permalink / raw)
To: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA
Cc: Joerg Roedel, linux-kernel-u79uwXL29TY76Z2rM5mHXA
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
^ permalink raw reply related [flat|nested] 22+ messages in thread* [PATCH 02/12] iommu: Convert iommu-caps from define to enum
[not found] ` <1409914384-21191-1-git-send-email-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
2014-09-05 10:52 ` [PATCH 01/12] iommu: Introduce iommu_capable API function 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
` (9 subsequent siblings)
11 siblings, 0 replies; 22+ messages in thread
From: Joerg Roedel @ 2014-09-05 10:52 UTC (permalink / raw)
To: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA
Cc: Joerg Roedel, linux-kernel-u79uwXL29TY76Z2rM5mHXA
From: Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org>
Allow compile-time type-checking.
Signed-off-by: Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org>
---
drivers/iommu/iommu.c | 2 +-
include/linux/iommu.h | 11 +++++++----
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index 1bc882e..319d40e 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -955,7 +955,7 @@ phys_addr_t iommu_iova_to_phys(struct iommu_domain *domain, dma_addr_t iova)
EXPORT_SYMBOL_GPL(iommu_iova_to_phys);
int iommu_domain_has_cap(struct iommu_domain *domain,
- unsigned long cap)
+ enum iommu_cap cap)
{
if (domain->ops->domain_has_cap != NULL)
return domain->ops->domain_has_cap(domain, cap);
diff --git a/include/linux/iommu.h b/include/linux/iommu.h
index d43146a..d5534d5 100644
--- a/include/linux/iommu.h
+++ b/include/linux/iommu.h
@@ -57,8 +57,11 @@ struct iommu_domain {
struct iommu_domain_geometry geometry;
};
-#define IOMMU_CAP_CACHE_COHERENCY 0x1
-#define IOMMU_CAP_INTR_REMAP 0x2 /* isolates device intrs */
+enum iommu_cap {
+ IOMMU_CAP_CACHE_COHERENCY, /* IOMMU can enforce cache coherent DMA
+ transactions */
+ IOMMU_CAP_INTR_REMAP, /* IOMMU supports interrupt isolation */
+};
/*
* Following constraints are specifc to FSL_PAMUV1:
@@ -157,7 +160,7 @@ extern size_t iommu_unmap(struct iommu_domain *domain, unsigned long iova,
size_t size);
extern phys_addr_t iommu_iova_to_phys(struct iommu_domain *domain, dma_addr_t iova);
extern int iommu_domain_has_cap(struct iommu_domain *domain,
- unsigned long cap);
+ enum iommu_cap cap);
extern void iommu_set_fault_handler(struct iommu_domain *domain,
iommu_fault_handler_t handler, void *token);
@@ -312,7 +315,7 @@ static inline phys_addr_t iommu_iova_to_phys(struct iommu_domain *domain, dma_ad
}
static inline int iommu_domain_has_cap(struct iommu_domain *domain,
- unsigned long cap)
+ enum iommu_cap cap)
{
return 0;
}
--
1.9.1
^ permalink raw reply related [flat|nested] 22+ messages in thread* [PATCH 03/12] iommu/amd: Convert to iommu_capable() API function
[not found] ` <1409914384-21191-1-git-send-email-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
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 04/12] iommu/arm-smmu: " Joerg Roedel
` (8 subsequent siblings)
11 siblings, 0 replies; 22+ messages in thread
From: Joerg Roedel @ 2014-09-05 10:52 UTC (permalink / raw)
To: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA
Cc: Joerg Roedel, linux-kernel-u79uwXL29TY76Z2rM5mHXA
From: Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org>
Signed-off-by: Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org>
---
drivers/iommu/amd_iommu.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
index ecb0109..7de9276 100644
--- a/drivers/iommu/amd_iommu.c
+++ b/drivers/iommu/amd_iommu.c
@@ -3384,20 +3384,20 @@ static phys_addr_t amd_iommu_iova_to_phys(struct iommu_domain *dom,
return paddr;
}
-static int amd_iommu_domain_has_cap(struct iommu_domain *domain,
- unsigned long cap)
+static bool amd_iommu_capable(enum iommu_cap cap)
{
switch (cap) {
case IOMMU_CAP_CACHE_COHERENCY:
- return 1;
+ return true;
case IOMMU_CAP_INTR_REMAP:
- return irq_remapping_enabled;
+ return (irq_remapping_enabled == 1);
}
- return 0;
+ return false;
}
static const struct iommu_ops amd_iommu_ops = {
+ .capable = amd_iommu_capable,
.domain_init = amd_iommu_domain_init,
.domain_destroy = amd_iommu_domain_destroy,
.attach_dev = amd_iommu_attach_device,
@@ -3405,7 +3405,6 @@ static const struct iommu_ops amd_iommu_ops = {
.map = amd_iommu_map,
.unmap = amd_iommu_unmap,
.iova_to_phys = amd_iommu_iova_to_phys,
- .domain_has_cap = amd_iommu_domain_has_cap,
.pgsize_bitmap = AMD_IOMMU_PGSIZES,
};
--
1.9.1
^ permalink raw reply related [flat|nested] 22+ messages in thread* [PATCH 04/12] iommu/arm-smmu: Convert to iommu_capable() API function
[not found] ` <1409914384-21191-1-git-send-email-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
` (2 preceding siblings ...)
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
[not found] ` <1409914384-21191-5-git-send-email-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
2014-09-05 10:52 ` [PATCH 05/12] iommu/fsl: Convert to iommu_capable() API function Joerg Roedel
` (7 subsequent siblings)
11 siblings, 1 reply; 22+ messages in thread
From: Joerg Roedel @ 2014-09-05 10:52 UTC (permalink / raw)
To: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA
Cc: Joerg Roedel, Will Deacon, linux-kernel-u79uwXL29TY76Z2rM5mHXA
From: Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org>
Cc: Will Deacon <will.deacon-5wv7dgnIgG8@public.gmane.org>
Signed-off-by: Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org>
---
drivers/iommu/arm-smmu.c | 35 ++++++++++++++++++++++++++---------
1 file changed, 26 insertions(+), 9 deletions(-)
diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c
index ca18d6d..47c2cb6 100644
--- a/drivers/iommu/arm-smmu.c
+++ b/drivers/iommu/arm-smmu.c
@@ -1515,20 +1515,37 @@ static phys_addr_t arm_smmu_iova_to_phys(struct iommu_domain *domain,
return __pfn_to_phys(pte_pfn(pte)) | (iova & ~PAGE_MASK);
}
-static int arm_smmu_domain_has_cap(struct iommu_domain *domain,
- unsigned long cap)
+static bool arm_smmu_capable(enum iommu_cap cap)
{
- struct arm_smmu_domain *smmu_domain = domain->priv;
- struct arm_smmu_device *smmu = smmu_domain->smmu;
- u32 features = smmu ? smmu->features : 0;
+ struct arm_smmu_device *smmu;
+ bool ret = false;
switch (cap) {
case IOMMU_CAP_CACHE_COHERENCY:
- return features & ARM_SMMU_FEAT_COHERENT_WALK;
+ /*
+ * Use ARM_SMMU_FEAT_COHERENT_WALK as an indicator on whether
+ * the SMMU can force coherency on the DMA transaction. If it
+ * supports COHERENT_WALK it must be behind a coherent
+ * interconnect.
+ * A domain can be attached to any SMMU, so to reliably support
+ * IOMMU_CAP_CACHE_COHERENCY all SMMUs in the system need to be
+ * behind a coherent interconnect.
+ */
+ spin_lock(&arm_smmu_devices_lock);
+ list_for_each_entry(smmu, &arm_smmu_devices, list) {
+ if (smmu->features & ARM_SMMU_FEAT_COHERENT_WALK) {
+ ret = true;
+ } else {
+ ret = false;
+ break;
+ }
+ }
+ spin_unlock(&arm_smmu_devices_lock);
+ return ret;
case IOMMU_CAP_INTR_REMAP:
- return 1; /* MSIs are just memory writes */
+ return true; /* MSIs are just memory writes */
default:
- return 0;
+ return false;
}
}
@@ -1598,6 +1615,7 @@ static void arm_smmu_remove_device(struct device *dev)
}
static const struct iommu_ops arm_smmu_ops = {
+ .capable = arm_smmu_capable,
.domain_init = arm_smmu_domain_init,
.domain_destroy = arm_smmu_domain_destroy,
.attach_dev = arm_smmu_attach_dev,
@@ -1605,7 +1623,6 @@ static const struct iommu_ops arm_smmu_ops = {
.map = arm_smmu_map,
.unmap = arm_smmu_unmap,
.iova_to_phys = arm_smmu_iova_to_phys,
- .domain_has_cap = arm_smmu_domain_has_cap,
.add_device = arm_smmu_add_device,
.remove_device = arm_smmu_remove_device,
.pgsize_bitmap = (SECTION_SIZE |
--
1.9.1
^ permalink raw reply related [flat|nested] 22+ messages in thread* [PATCH 05/12] iommu/fsl: Convert to iommu_capable() API function
[not found] ` <1409914384-21191-1-git-send-email-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
` (3 preceding siblings ...)
2014-09-05 10:52 ` [PATCH 04/12] iommu/arm-smmu: " 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
` (6 subsequent siblings)
11 siblings, 1 reply; 22+ messages in thread
From: Joerg Roedel @ 2014-09-05 10:52 UTC (permalink / raw)
To: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA
Cc: Varun Sethi, Joerg Roedel, linux-kernel-u79uwXL29TY76Z2rM5mHXA
From: Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org>
Cc: Varun Sethi <Varun.Sethi-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
Signed-off-by: Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org>
---
drivers/iommu/fsl_pamu_domain.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/iommu/fsl_pamu_domain.c b/drivers/iommu/fsl_pamu_domain.c
index 61d1daf..f43a80d 100644
--- a/drivers/iommu/fsl_pamu_domain.c
+++ b/drivers/iommu/fsl_pamu_domain.c
@@ -411,8 +411,7 @@ static phys_addr_t fsl_pamu_iova_to_phys(struct iommu_domain *domain,
return get_phys_addr(dma_domain, iova);
}
-static int fsl_pamu_domain_has_cap(struct iommu_domain *domain,
- unsigned long cap)
+static bool fsl_pamu_capable(enum iommu_cap cap)
{
return cap == IOMMU_CAP_CACHE_COHERENCY;
}
@@ -1074,6 +1073,7 @@ static u32 fsl_pamu_get_windows(struct iommu_domain *domain)
}
static const struct iommu_ops fsl_pamu_ops = {
+ .capable = fsl_pamu_capable,
.domain_init = fsl_pamu_domain_init,
.domain_destroy = fsl_pamu_domain_destroy,
.attach_dev = fsl_pamu_attach_device,
@@ -1083,7 +1083,6 @@ static const struct iommu_ops fsl_pamu_ops = {
.domain_get_windows = fsl_pamu_get_windows,
.domain_set_windows = fsl_pamu_set_windows,
.iova_to_phys = fsl_pamu_iova_to_phys,
- .domain_has_cap = fsl_pamu_domain_has_cap,
.domain_set_attr = fsl_pamu_set_domain_attr,
.domain_get_attr = fsl_pamu_get_domain_attr,
.add_device = fsl_pamu_add_device,
--
1.9.1
^ permalink raw reply related [flat|nested] 22+ messages in thread* RE: [PATCH 05/12] iommu/fsl: Convert to iommu_capable() API function
2014-09-05 10:52 ` [PATCH 05/12] iommu/fsl: Convert to iommu_capable() API function Joerg Roedel
@ 2014-09-09 18:38 ` Varun Sethi
0 siblings, 0 replies; 22+ messages in thread
From: Varun Sethi @ 2014-09-09 18:38 UTC (permalink / raw)
To: Joerg Roedel, iommu@lists.linux-foundation.org
Cc: linux-kernel@vger.kernel.org, Joerg Roedel
> -----Original Message-----
> From: Joerg Roedel [mailto:joro@8bytes.org]
> Sent: Friday, September 05, 2014 4:23 PM
> To: iommu@lists.linux-foundation.org
> Cc: linux-kernel@vger.kernel.org; Joerg Roedel; Sethi Varun-B16395
> Subject: [PATCH 05/12] iommu/fsl: Convert to iommu_capable() API function
>
> From: Joerg Roedel <jroedel@suse.de>
>
> Cc: Varun Sethi <Varun.Sethi@freescale.com>
> Signed-off-by: Joerg Roedel <jroedel@suse.de>
> ---
> drivers/iommu/fsl_pamu_domain.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/iommu/fsl_pamu_domain.c
> b/drivers/iommu/fsl_pamu_domain.c index 61d1daf..f43a80d 100644
> --- a/drivers/iommu/fsl_pamu_domain.c
> +++ b/drivers/iommu/fsl_pamu_domain.c
> @@ -411,8 +411,7 @@ static phys_addr_t fsl_pamu_iova_to_phys(struct
> iommu_domain *domain,
> return get_phys_addr(dma_domain, iova); }
>
> -static int fsl_pamu_domain_has_cap(struct iommu_domain *domain,
> - unsigned long cap)
> +static bool fsl_pamu_capable(enum iommu_cap cap)
> {
> return cap == IOMMU_CAP_CACHE_COHERENCY; } @@ -1074,6
> +1073,7 @@ static u32 fsl_pamu_get_windows(struct iommu_domain
> *domain) }
>
> static const struct iommu_ops fsl_pamu_ops = {
> + .capable = fsl_pamu_capable,
> .domain_init = fsl_pamu_domain_init,
> .domain_destroy = fsl_pamu_domain_destroy,
> .attach_dev = fsl_pamu_attach_device,
> @@ -1083,7 +1083,6 @@ static const struct iommu_ops fsl_pamu_ops = {
> .domain_get_windows = fsl_pamu_get_windows,
> .domain_set_windows = fsl_pamu_set_windows,
> .iova_to_phys = fsl_pamu_iova_to_phys,
> - .domain_has_cap = fsl_pamu_domain_has_cap,
> .domain_set_attr = fsl_pamu_set_domain_attr,
> .domain_get_attr = fsl_pamu_get_domain_attr,
> .add_device = fsl_pamu_add_device,
Acked-by: Varun Sethi <varun.sethi@freescale.com>
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH 06/12] iommu/vt-d: Convert to iommu_capable() API function
[not found] ` <1409914384-21191-1-git-send-email-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
` (4 preceding siblings ...)
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-05 10:52 ` [PATCH 07/12] iommu/msm: " Joerg Roedel
` (5 subsequent siblings)
11 siblings, 0 replies; 22+ messages in thread
From: Joerg Roedel @ 2014-09-05 10:52 UTC (permalink / raw)
To: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA
Cc: Joerg Roedel, David Woodhouse,
linux-kernel-u79uwXL29TY76Z2rM5mHXA, Jiang Liu
From: Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org>
Cc: Jiang Liu <jiang.liu-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
Cc: David Woodhouse <dwmw2-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
Signed-off-by: Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org>
---
drivers/iommu/intel-iommu.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index 5619f26..bc1a203 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -4415,17 +4415,14 @@ static phys_addr_t intel_iommu_iova_to_phys(struct iommu_domain *domain,
return phys;
}
-static int intel_iommu_domain_has_cap(struct iommu_domain *domain,
- unsigned long cap)
+static bool intel_iommu_capable(enum iommu_cap cap)
{
- struct dmar_domain *dmar_domain = domain->priv;
-
if (cap == IOMMU_CAP_CACHE_COHERENCY)
- return dmar_domain->iommu_snooping;
+ return domain_update_iommu_snooping(NULL) == 1;
if (cap == IOMMU_CAP_INTR_REMAP)
- return irq_remapping_enabled;
+ return irq_remapping_enabled == 1;
- return 0;
+ return false;
}
static int intel_iommu_add_device(struct device *dev)
@@ -4464,6 +4461,7 @@ static void intel_iommu_remove_device(struct device *dev)
}
static const struct iommu_ops intel_iommu_ops = {
+ .capable = intel_iommu_capable,
.domain_init = intel_iommu_domain_init,
.domain_destroy = intel_iommu_domain_destroy,
.attach_dev = intel_iommu_attach_device,
@@ -4471,7 +4469,6 @@ static const struct iommu_ops intel_iommu_ops = {
.map = intel_iommu_map,
.unmap = intel_iommu_unmap,
.iova_to_phys = intel_iommu_iova_to_phys,
- .domain_has_cap = intel_iommu_domain_has_cap,
.add_device = intel_iommu_add_device,
.remove_device = intel_iommu_remove_device,
.pgsize_bitmap = INTEL_IOMMU_PGSIZES,
--
1.9.1
^ permalink raw reply related [flat|nested] 22+ messages in thread* [PATCH 07/12] iommu/msm: Convert to iommu_capable() API function
[not found] ` <1409914384-21191-1-git-send-email-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
` (5 preceding siblings ...)
2014-09-05 10:52 ` [PATCH 06/12] iommu/vt-d: " Joerg Roedel
@ 2014-09-05 10:52 ` Joerg Roedel
2014-09-05 10:53 ` [PATCH 08/12] iommu/tegra: " Joerg Roedel
` (4 subsequent siblings)
11 siblings, 0 replies; 22+ messages in thread
From: Joerg Roedel @ 2014-09-05 10:52 UTC (permalink / raw)
To: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA
Cc: Joerg Roedel, linux-kernel-u79uwXL29TY76Z2rM5mHXA
From: Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org>
Signed-off-by: Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org>
---
drivers/iommu/msm_iommu.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/iommu/msm_iommu.c b/drivers/iommu/msm_iommu.c
index 49f41d6..6e3dcc28 100644
--- a/drivers/iommu/msm_iommu.c
+++ b/drivers/iommu/msm_iommu.c
@@ -603,10 +603,9 @@ fail:
return ret;
}
-static int msm_iommu_domain_has_cap(struct iommu_domain *domain,
- unsigned long cap)
+static bool msm_iommu_capable(enum iommu_cap cap)
{
- return 0;
+ return false;
}
static void print_ctx_regs(void __iomem *base, int ctx)
@@ -675,6 +674,7 @@ fail:
}
static const struct iommu_ops msm_iommu_ops = {
+ .capable = msm_iommu_capable,
.domain_init = msm_iommu_domain_init,
.domain_destroy = msm_iommu_domain_destroy,
.attach_dev = msm_iommu_attach_dev,
@@ -682,7 +682,6 @@ static const struct iommu_ops msm_iommu_ops = {
.map = msm_iommu_map,
.unmap = msm_iommu_unmap,
.iova_to_phys = msm_iommu_iova_to_phys,
- .domain_has_cap = msm_iommu_domain_has_cap,
.pgsize_bitmap = MSM_IOMMU_PGSIZES,
};
--
1.9.1
^ permalink raw reply related [flat|nested] 22+ messages in thread* [PATCH 08/12] iommu/tegra: Convert to iommu_capable() API function
[not found] ` <1409914384-21191-1-git-send-email-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
` (6 preceding siblings ...)
2014-09-05 10:52 ` [PATCH 07/12] iommu/msm: " 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
` (3 subsequent siblings)
11 siblings, 0 replies; 22+ messages in thread
From: Joerg Roedel @ 2014-09-05 10:53 UTC (permalink / raw)
To: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA
Cc: Joerg Roedel, linux-kernel-u79uwXL29TY76Z2rM5mHXA
From: Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org>
Cc: Hiroshi Doyu <hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
Signed-off-by: Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org>
---
drivers/iommu/tegra-gart.c | 7 +++----
drivers/iommu/tegra-smmu.c | 7 +++----
2 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/drivers/iommu/tegra-gart.c b/drivers/iommu/tegra-gart.c
index b10a8ec..6f44ebb 100644
--- a/drivers/iommu/tegra-gart.c
+++ b/drivers/iommu/tegra-gart.c
@@ -303,13 +303,13 @@ static phys_addr_t gart_iommu_iova_to_phys(struct iommu_domain *domain,
return pa;
}
-static int gart_iommu_domain_has_cap(struct iommu_domain *domain,
- unsigned long cap)
+static bool gart_iommu_capable(enum iommu_cap cap)
{
- return 0;
+ return false;
}
static const struct iommu_ops gart_iommu_ops = {
+ .capable = gart_iommu_capable,
.domain_init = gart_iommu_domain_init,
.domain_destroy = gart_iommu_domain_destroy,
.attach_dev = gart_iommu_attach_dev,
@@ -317,7 +317,6 @@ static const struct iommu_ops gart_iommu_ops = {
.map = gart_iommu_map,
.unmap = gart_iommu_unmap,
.iova_to_phys = gart_iommu_iova_to_phys,
- .domain_has_cap = gart_iommu_domain_has_cap,
.pgsize_bitmap = GART_IOMMU_PGSIZES,
};
diff --git a/drivers/iommu/tegra-smmu.c b/drivers/iommu/tegra-smmu.c
index 3ded389..05d14e1 100644
--- a/drivers/iommu/tegra-smmu.c
+++ b/drivers/iommu/tegra-smmu.c
@@ -780,10 +780,9 @@ static phys_addr_t smmu_iommu_iova_to_phys(struct iommu_domain *domain,
return PFN_PHYS(pfn);
}
-static int smmu_iommu_domain_has_cap(struct iommu_domain *domain,
- unsigned long cap)
+static bool smmu_iommu_capable(enum iommu_cap cap)
{
- return 0;
+ return false;
}
static int smmu_iommu_attach_dev(struct iommu_domain *domain,
@@ -949,6 +948,7 @@ static void smmu_iommu_domain_destroy(struct iommu_domain *domain)
}
static const struct iommu_ops smmu_iommu_ops = {
+ .capable = smmu_iommu_capable,
.domain_init = smmu_iommu_domain_init,
.domain_destroy = smmu_iommu_domain_destroy,
.attach_dev = smmu_iommu_attach_dev,
@@ -956,7 +956,6 @@ static const struct iommu_ops smmu_iommu_ops = {
.map = smmu_iommu_map,
.unmap = smmu_iommu_unmap,
.iova_to_phys = smmu_iommu_iova_to_phys,
- .domain_has_cap = smmu_iommu_domain_has_cap,
.pgsize_bitmap = SMMU_IOMMU_PGSIZES,
};
--
1.9.1
^ permalink raw reply related [flat|nested] 22+ messages in thread* [PATCH 09/12] kvm: iommu: Convert to use new iommu_capable() API function
[not found] ` <1409914384-21191-1-git-send-email-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
` (7 preceding siblings ...)
2014-09-05 10:53 ` [PATCH 08/12] iommu/tegra: " 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-05 10:53 ` [PATCH 10/12] vfio: " Joerg Roedel
` (2 subsequent siblings)
11 siblings, 1 reply; 22+ messages in thread
From: Joerg Roedel @ 2014-09-05 10:53 UTC (permalink / raw)
To: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA
Cc: Gleb Natapov, Paolo Bonzini, Joerg Roedel,
linux-kernel-u79uwXL29TY76Z2rM5mHXA
From: Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org>
Cc: Gleb Natapov <gleb-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: Paolo Bonzini <pbonzini-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Signed-off-by: Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org>
---
virt/kvm/iommu.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/virt/kvm/iommu.c b/virt/kvm/iommu.c
index 714b949..45ee080 100644
--- a/virt/kvm/iommu.c
+++ b/virt/kvm/iommu.c
@@ -191,8 +191,7 @@ int kvm_assign_device(struct kvm *kvm,
return r;
}
- noncoherent = !iommu_domain_has_cap(kvm->arch.iommu_domain,
- IOMMU_CAP_CACHE_COHERENCY);
+ noncoherent = !iommu_capable(&pci_bus_type, IOMMU_CAP_CACHE_COHERENCY);
/* Check if need to update IOMMU page table for guest memory */
if (noncoherent != kvm->arch.iommu_noncoherent) {
@@ -254,8 +253,7 @@ int kvm_iommu_map_guest(struct kvm *kvm)
}
if (!allow_unsafe_assigned_interrupts &&
- !iommu_domain_has_cap(kvm->arch.iommu_domain,
- IOMMU_CAP_INTR_REMAP)) {
+ !iommu_capable(&pci_bus_type, IOMMU_CAP_INTR_REMAP)) {
printk(KERN_WARNING "%s: No interrupt remapping support,"
" disallowing device assignment."
" Re-enble with \"allow_unsafe_assigned_interrupts=1\""
--
1.9.1
^ permalink raw reply related [flat|nested] 22+ messages in thread* [PATCH 10/12] vfio: Convert to use new iommu_capable() API function
[not found] ` <1409914384-21191-1-git-send-email-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
` (8 preceding siblings ...)
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-11-git-send-email-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
2014-09-05 10:53 ` [PATCH 11/12] IB/usnic: " Joerg Roedel
2014-09-05 10:53 ` [PATCH 12/12] iommu: Remove iommu_domain_has_cap() " Joerg Roedel
11 siblings, 1 reply; 22+ messages in thread
From: Joerg Roedel @ 2014-09-05 10:53 UTC (permalink / raw)
To: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA
Cc: Joerg Roedel, linux-kernel-u79uwXL29TY76Z2rM5mHXA
From: Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org>
Cc: Alex Williamson <alex.williamson-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Signed-off-by: Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org>
---
drivers/vfio/vfio_iommu_type1.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c
index 0734fbe..562f686 100644
--- a/drivers/vfio/vfio_iommu_type1.c
+++ b/drivers/vfio/vfio_iommu_type1.c
@@ -713,14 +713,14 @@ static int vfio_iommu_type1_attach_group(void *iommu_data,
list_add(&group->next, &domain->group_list);
if (!allow_unsafe_interrupts &&
- !iommu_domain_has_cap(domain->domain, IOMMU_CAP_INTR_REMAP)) {
+ !iommu_capable(bus, IOMMU_CAP_INTR_REMAP)) {
pr_warn("%s: No interrupt remapping support. Use the module param \"allow_unsafe_interrupts\" to enable VFIO IOMMU support on this platform\n",
__func__);
ret = -EPERM;
goto out_detach;
}
- if (iommu_domain_has_cap(domain->domain, IOMMU_CAP_CACHE_COHERENCY))
+ if (iommu_capable(bus, IOMMU_CAP_CACHE_COHERENCY))
domain->prot |= IOMMU_CACHE;
/*
--
1.9.1
^ permalink raw reply related [flat|nested] 22+ messages in thread* [PATCH 11/12] IB/usnic: Convert to use new iommu_capable() API function
[not found] ` <1409914384-21191-1-git-send-email-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
` (9 preceding siblings ...)
2014-09-05 10:53 ` [PATCH 10/12] vfio: " 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-05 10:53 ` [PATCH 12/12] iommu: Remove iommu_domain_has_cap() " Joerg Roedel
11 siblings, 1 reply; 22+ messages in thread
From: Joerg Roedel @ 2014-09-05 10:53 UTC (permalink / raw)
To: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA
Cc: Joerg Roedel, linux-kernel-u79uwXL29TY76Z2rM5mHXA
From: Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org>
Cc: Upinder Malhi <umalhi-FYB4Gu1CFyUAvxtiuMwx3w@public.gmane.org>
Signed-off-by: Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org>
---
drivers/infiniband/hw/usnic/usnic_uiom.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/infiniband/hw/usnic/usnic_uiom.c b/drivers/infiniband/hw/usnic/usnic_uiom.c
index 801a1d6..417de1f 100644
--- a/drivers/infiniband/hw/usnic/usnic_uiom.c
+++ b/drivers/infiniband/hw/usnic/usnic_uiom.c
@@ -507,7 +507,7 @@ int usnic_uiom_attach_dev_to_pd(struct usnic_uiom_pd *pd, struct device *dev)
if (err)
goto out_free_dev;
- if (!iommu_domain_has_cap(pd->domain, IOMMU_CAP_CACHE_COHERENCY)) {
+ if (!iommu_capable(dev->bus, IOMMU_CAP_CACHE_COHERENCY)) {
usnic_err("IOMMU of %s does not support cache coherency\n",
dev_name(dev));
err = -EINVAL;
--
1.9.1
^ permalink raw reply related [flat|nested] 22+ messages in thread* [PATCH 12/12] iommu: Remove iommu_domain_has_cap() API function
[not found] ` <1409914384-21191-1-git-send-email-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
` (10 preceding siblings ...)
2014-09-05 10:53 ` [PATCH 11/12] IB/usnic: " Joerg Roedel
@ 2014-09-05 10:53 ` Joerg Roedel
11 siblings, 0 replies; 22+ messages in thread
From: Joerg Roedel @ 2014-09-05 10:53 UTC (permalink / raw)
To: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA
Cc: Joerg Roedel, linux-kernel-u79uwXL29TY76Z2rM5mHXA
From: Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org>
Signed-off-by: Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org>
---
drivers/iommu/iommu.c | 13 -------------
include/linux/iommu.h | 11 -----------
2 files changed, 24 deletions(-)
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index 319d40e..41c6a7d 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -954,19 +954,6 @@ phys_addr_t iommu_iova_to_phys(struct iommu_domain *domain, dma_addr_t iova)
}
EXPORT_SYMBOL_GPL(iommu_iova_to_phys);
-int iommu_domain_has_cap(struct iommu_domain *domain,
- enum iommu_cap cap)
-{
- 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 0;
-}
-EXPORT_SYMBOL_GPL(iommu_domain_has_cap);
-
static size_t iommu_pgsize(struct iommu_domain *domain,
unsigned long addr_merge, size_t size)
{
diff --git a/include/linux/iommu.h b/include/linux/iommu.h
index d5534d5..379a617 100644
--- a/include/linux/iommu.h
+++ b/include/linux/iommu.h
@@ -97,7 +97,6 @@ enum iommu_attr {
* @map: map a physically contiguous memory region to an iommu domain
* @unmap: unmap a physically contiguous memory region from an iommu domain
* @iova_to_phys: translate iova to physical address
- * @domain_has_cap: domain capabilities query
* @add_device: add device to iommu grouping
* @remove_device: remove device from iommu grouping
* @domain_get_attr: Query domain attributes
@@ -115,8 +114,6 @@ struct iommu_ops {
size_t (*unmap)(struct iommu_domain *domain, unsigned long iova,
size_t size);
phys_addr_t (*iova_to_phys)(struct iommu_domain *domain, dma_addr_t iova);
- int (*domain_has_cap)(struct iommu_domain *domain,
- unsigned long cap);
int (*add_device)(struct device *dev);
void (*remove_device)(struct device *dev);
int (*device_group)(struct device *dev, unsigned int *groupid);
@@ -159,8 +156,6 @@ extern int iommu_map(struct iommu_domain *domain, unsigned long iova,
extern size_t iommu_unmap(struct iommu_domain *domain, unsigned long iova,
size_t size);
extern phys_addr_t iommu_iova_to_phys(struct iommu_domain *domain, dma_addr_t iova);
-extern int iommu_domain_has_cap(struct iommu_domain *domain,
- enum iommu_cap cap);
extern void iommu_set_fault_handler(struct iommu_domain *domain,
iommu_fault_handler_t handler, void *token);
@@ -314,12 +309,6 @@ static inline phys_addr_t iommu_iova_to_phys(struct iommu_domain *domain, dma_ad
return 0;
}
-static inline int iommu_domain_has_cap(struct iommu_domain *domain,
- enum iommu_cap cap)
-{
- return 0;
-}
-
static inline void iommu_set_fault_handler(struct iommu_domain *domain,
iommu_fault_handler_t handler, void *token)
{
--
1.9.1
^ permalink raw reply related [flat|nested] 22+ messages in thread