Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1707386 > unrolled thread
| Started by | Joerg Roedel <joro@8bytes.org> |
|---|---|
| First post | 2017-08-09 16:50 +0200 |
| Last post | 2017-08-09 16:50 +0200 |
| Articles | 3 — 1 participant |
Back to article view | Back to linux.kernel
[PATCH 0/4] iommu/pamu: Support generic iommu-device handles Joerg Roedel <joro@8bytes.org> - 2017-08-09 16:50 +0200
[PATCH 4/4] iommu/pamu: Add support for generic iommu-device Joerg Roedel <joro@8bytes.org> - 2017-08-09 16:50 +0200
[PATCH 3/4] iommu/pamu: WARN when fsl_pamu_probe() is called more than once Joerg Roedel <joro@8bytes.org> - 2017-08-09 16:50 +0200
| From | Joerg Roedel <joro@8bytes.org> |
|---|---|
| Date | 2017-08-09 16:50 +0200 |
| Subject | [PATCH 0/4] iommu/pamu: Support generic iommu-device handles |
| Message-ID | <ucAt4-fu-11@gated-at.bofh.it> |
Hi, Here is a patch-set to support the iommu_device_register() interface in the fsl-pamu iommu driver. To make it work a few fixes (Patch 1 and 2), an additional check (Patch 3) were necessary. Please review. Regards, Joerg Joerg Roedel (4): iommu/pamu: Let PAMU depend on PCI iommu/pamu: Make driver depend on CONFIG_PHYS_64BIT iommu/pamu: WARN when fsl_pamu_probe() is called more than once iommu/pamu: Add support for generic iommu-device drivers/iommu/Kconfig | 2 ++ drivers/iommu/fsl_pamu.c | 24 ++++++++++++++++++++++++ drivers/iommu/fsl_pamu.h | 3 +++ drivers/iommu/fsl_pamu_domain.c | 5 ++++- drivers/iommu/fsl_pamu_domain.h | 2 ++ 5 files changed, 35 insertions(+), 1 deletion(-) -- 2.7.4
[toc] | [next] | [standalone]
| From | Joerg Roedel <joro@8bytes.org> |
|---|---|
| Date | 2017-08-09 16:50 +0200 |
| Subject | [PATCH 4/4] iommu/pamu: Add support for generic iommu-device |
| Message-ID | <ucAt5-fu-25@gated-at.bofh.it> |
| In reply to | #1707386 |
From: Joerg Roedel <jroedel@suse.de>
This patch adds a global iommu-handle to the pamu driver and
initializes it at probe time. Also link devices added to the
iommu to this handle.
Signed-off-by: Joerg Roedel <jroedel@suse.de>
---
drivers/iommu/fsl_pamu.c | 17 +++++++++++++++++
drivers/iommu/fsl_pamu.h | 3 +++
drivers/iommu/fsl_pamu_domain.c | 5 ++++-
drivers/iommu/fsl_pamu_domain.h | 2 ++
4 files changed, 26 insertions(+), 1 deletion(-)
diff --git a/drivers/iommu/fsl_pamu.c b/drivers/iommu/fsl_pamu.c
index 9ee8e9e..9238a85 100644
--- a/drivers/iommu/fsl_pamu.c
+++ b/drivers/iommu/fsl_pamu.c
@@ -44,6 +44,8 @@ static struct paace *spaact;
static bool probed; /* Has PAMU been probed? */
+struct iommu_device pamu_iommu; /* IOMMU core code handle */
+
/*
* Table for matching compatible strings, for device tree
* guts node, for QorIQ SOCs.
@@ -1154,6 +1156,18 @@ static int fsl_pamu_probe(struct platform_device *pdev)
if (ret)
goto error_genpool;
+ ret = iommu_device_sysfs_add(&pamu_iommu, dev, NULL, "iommu0");
+ if (ret)
+ goto error_genpool;
+
+ iommu_device_set_ops(&pamu_iommu, &fsl_pamu_ops);
+
+ ret = iommu_device_register(&pamu_iommu);
+ if (ret) {
+ dev_err(dev, "Can't register iommu device\n");
+ goto error_sysfs;
+ }
+
pamubypenr = in_be32(&guts_regs->pamubypenr);
for (pamu_reg_off = 0, pamu_counter = 0x80000000; pamu_reg_off < size;
@@ -1181,6 +1195,9 @@ static int fsl_pamu_probe(struct platform_device *pdev)
return 0;
+error_sysfs:
+ iommu_device_sysfs_remove(&pamu_iommu);
+
error_genpool:
gen_pool_destroy(spaace_pool);
diff --git a/drivers/iommu/fsl_pamu.h b/drivers/iommu/fsl_pamu.h
index c3434f2..fa48222 100644
--- a/drivers/iommu/fsl_pamu.h
+++ b/drivers/iommu/fsl_pamu.h
@@ -391,6 +391,9 @@ struct ome {
#define EOE_WWSAOL 0x1e /* Write with stash allocate only and lock */
#define EOE_VALID 0x80
+extern const struct iommu_ops fsl_pamu_ops;
+extern struct iommu_device pamu_iommu; /* IOMMU core code handle */
+
/* Function prototypes */
int pamu_domain_init(void);
int pamu_enable_liodn(int liodn);
diff --git a/drivers/iommu/fsl_pamu_domain.c b/drivers/iommu/fsl_pamu_domain.c
index da0e1e3..914953b 100644
--- a/drivers/iommu/fsl_pamu_domain.c
+++ b/drivers/iommu/fsl_pamu_domain.c
@@ -983,11 +983,14 @@ static int fsl_pamu_add_device(struct device *dev)
iommu_group_put(group);
+ iommu_device_link(&pamu_iommu, dev);
+
return 0;
}
static void fsl_pamu_remove_device(struct device *dev)
{
+ iommu_device_unlink(&pamu_iommu, dev);
iommu_group_remove_device(dev);
}
@@ -1047,7 +1050,7 @@ static u32 fsl_pamu_get_windows(struct iommu_domain *domain)
return dma_domain->win_cnt;
}
-static const struct iommu_ops fsl_pamu_ops = {
+const struct iommu_ops fsl_pamu_ops = {
.capable = fsl_pamu_capable,
.domain_alloc = fsl_pamu_domain_alloc,
.domain_free = fsl_pamu_domain_free,
diff --git a/drivers/iommu/fsl_pamu_domain.h b/drivers/iommu/fsl_pamu_domain.h
index f2b0f74..6d8661e 100644
--- a/drivers/iommu/fsl_pamu_domain.h
+++ b/drivers/iommu/fsl_pamu_domain.h
@@ -21,6 +21,8 @@
#include "fsl_pamu.h"
+const struct iommu_ops fsl_pamu_ops;
+
struct dma_window {
phys_addr_t paddr;
u64 size;
--
2.7.4
[toc] | [prev] | [next] | [standalone]
| From | Joerg Roedel <joro@8bytes.org> |
|---|---|
| Date | 2017-08-09 16:50 +0200 |
| Subject | [PATCH 3/4] iommu/pamu: WARN when fsl_pamu_probe() is called more than once |
| Message-ID | <ucAt5-fu-31@gated-at.bofh.it> |
| In reply to | #1707386 |
From: Joerg Roedel <jroedel@suse.de>
The function probes the PAMU hardware from device-tree
specifications. It initializes global variables and can thus
be only safely called once.
Add a check that that prints a warning when its called more
than once.
Signed-off-by: Joerg Roedel <jroedel@suse.de>
---
drivers/iommu/fsl_pamu.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/iommu/fsl_pamu.c b/drivers/iommu/fsl_pamu.c
index a34355f..9ee8e9e 100644
--- a/drivers/iommu/fsl_pamu.c
+++ b/drivers/iommu/fsl_pamu.c
@@ -42,6 +42,8 @@ struct pamu_isr_data {
static struct paace *ppaact;
static struct paace *spaact;
+static bool probed; /* Has PAMU been probed? */
+
/*
* Table for matching compatible strings, for device tree
* guts node, for QorIQ SOCs.
@@ -1033,6 +1035,9 @@ static int fsl_pamu_probe(struct platform_device *pdev)
* NOTE : All PAMUs share the same LIODN tables.
*/
+ if (WARN_ON(probed))
+ return -EBUSY;
+
pamu_regs = of_iomap(dev->of_node, 0);
if (!pamu_regs) {
dev_err(dev, "ioremap of PAMU node failed\n");
@@ -1172,6 +1177,8 @@ static int fsl_pamu_probe(struct platform_device *pdev)
setup_liodns();
+ probed = true;
+
return 0;
error_genpool:
--
2.7.4
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web