Skip to contentSkip to conversation

iommu/msm: Add DT adaptation and generic bindings support

PATCH Superseded Sricharan R 4 participants 11 messages Aug 12, 2015 – Aug 14, 2015

Subsystems (4)

v1 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

cover iommu/msm: Add DT adaptation and generic bindings support

The msm_iommu.c driver currently works based on platform data. A single master device can be connected to more than one iommu and multiple contexts in each of the iommu. This association between master and iommus was represented from platform data using parent/child devices. The master drivers were responsible for attaching all of the iommus/context to a domain. Now the platform data support is removed and DT support is added. The master/iommus are added through generic iommu bindings.

This is essentially rework of the patch posted earlier by Rob Clark <[email protected]>. This series folds the changes in to the existing driver with the addition of generic bindings.

        http://www.spinics.net/lists/linux-arm-msm/msg10077.html

This series is based on the IOMMU probe deferral series from Laurent Pinchart <[email protected]>

        https://lkml.org/lkml/2015/5/14/786

Tested this series on ifc6410 board.

Sricharan R (5):
iommu/msm: Add DT adaptation
iommu/msm: Move the contents from msm_iommu_dev.c to msm_iommu.c iommu/msm: Add support for generic master bindings iommu/msm: Set cacheability attributes without tex remap iommu/msm: Remove driver BROKEN

 .../devicetree/bindings/iommu/msm,iommu-v0.txt     |  59 +++
 drivers/iommu/Kconfig                              |   1 -
 drivers/iommu/Makefile                             |   2 +-
 drivers/iommu/msm_iommu.c                          | 508 ++++++++++++++-------
 drivers/iommu/msm_iommu.h                          |  73 ++-
 drivers/iommu/msm_iommu_dev.c                      | 392 ----------------
 drivers/iommu/msm_iommu_hw-8xxx.h                  |  10 +-
 7 files changed, 432 insertions(+), 613 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/iommu/msm,iommu-v0.txt
 delete mode 100644 drivers/iommu/msm_iommu_dev.c
Signature · 1 line
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
#1 lore raw

PATCH 1/5 iommu/msm: Add DT adaptation

The driver currently works based on platform data. Remove this and add support for DT. A single master can have multiple ports connected to more than one iommu.

	  	      master
        	        |
	                |
	                |
	   ------------------------
           |  			  |
	IOMMU0			IOMMU1
           |			  |
      ctx0   ctx1	     ctx0   ctx1

This association of master and iommus/contexts were previously represented by platform data parent/child device details. The client drivers were responsible for programming all of the iommus/contexts for the device. Now while adapting to generic DT bindings we maintain the list of iommus, contexts that each master domain is connected to and program all of them on attach/detach.

---
 .../devicetree/bindings/iommu/msm,iommu-v0.txt     |  59 ++++
 drivers/iommu/msm_iommu.c                          | 252 ++++++++--------
 drivers/iommu/msm_iommu.h                          |  73 ++---
 drivers/iommu/msm_iommu_dev.c                      | 320 +++++----------------
 4 files changed, 289 insertions(+), 415 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/iommu/msm,iommu-v0.txt
Documentation/devicetree/bindings/iommu/msm,iommu-v0.txt new file +59 -0
new file mode 100644
index 0000000..21bfbfc
@@ -0,0 +1,59 @@
+* QCOM IOMMU
+
+The QCOM IOMMU is an implementation compatible with the ARM VMSA short
+descriptor page tables. It provides address translation for bus masters outside
+of the CPU, each connected to the IOMMU through a port called micro-TLB.
+
+Required Properties:
+
+  - compatible: Must contain "qcom,iommu-v0".
+  - reg: Base address and size of the IOMMU registers.
+  - interrupts: Specifiers for the MMU fault interrupts. For instances that
+    support secure mode two interrupts must be specified, for non-secure and
+    secure mode, in that order. For instances that don't support secure mode a
+    single interrupt must be specified.
+  - #iommu-cells: This is the total number of stream ids that a master would
+		  use during transactions which will be specified as a list
+		  as a part of iommus property below.
+  - ncb: The total number of context banks in the IOMMU.
+  - clocks	: List of clocks to be used during SMMU register access. See
+		  Documentation/devicetree/bindings/clock/clock-bindings.txt
+		  for information about the format. For each clock specified
+		  here, there must be a corresponding entry in clock-names
+		  (see below).
+
+  - clock-names	: List of clock names corresponding to the clocks specified in
+		  the "clocks" property (above). See
+		  Documentation/devicetree/bindings/clock/clock-bindings.txt
+		  for more info.
+
+Each bus master connected to an IOMMU must reference the IOMMU in its device
+node with the following property:
+
+  - iommus: A reference to the IOMMU in multiple cells. The first cell is a
+	    phandle to the IOMMU and the second cell is the list of the
+	    stream ids used by the device.
+
+Example: mdp iommu and its bus master
+
+                mdp_port0: qcom,iommu at 7500000 {
+			compatible = "qcom,iommu-v0";
+			#iommu-cells = <2>;
+			clock-names =
+			    "smmu_pclk",
+			    "iommu_clk";
+			clocks =
+			    <&mmcc SMMU_AHB_CLK>,
+			    <&mmcc MDP_AXI_CLK>;
+			reg = <0x07500000 0x100000>;
+			interrupts =
+			    <GIC_SPI 63 0>,
+			    <GIC_SPI 64 0>;
+			ncb = <2>;
+		};
+
+		mdp: qcom,mdp at 5100000 {
+			compatible = "qcom,mdp";
+			...
+			iommus = <&mdp_port0 0 2>;
+		};
drivers/iommu/msm_iommu.c +138 -114

381 lines not on this page · raw message

drivers/iommu/msm_iommu.h +26 -47

100 lines not on this page · raw message

drivers/iommu/msm_iommu_dev.c +66 -254

386 lines not on this page · raw message

Signature · 1 line
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
#2 lore raw

PATCH 2/5 iommu/msm: Move the contents from msm_iommu_dev.c to msm_iommu.c

In reply to Sricharan R

There are only two functions left in msm_iommu_dev.c. Move it to msm_iommu.c and delete the file.

---
 drivers/iommu/Makefile        |   2 +-
 drivers/iommu/msm_iommu.c     | 163 +++++++++++++++++++++++++++++++++
 drivers/iommu/msm_iommu_dev.c | 204 ------------------------------------------
 3 files changed, 164 insertions(+), 205 deletions(-)
 delete mode 100644 drivers/iommu/msm_iommu_dev.c
drivers/iommu/Makefile +1 -1
index c6dcc51..83ee0bf 100644
@@ -5,7 +5,7 @@ obj-$(CONFIG_IOMMU_IO_PGTABLE) += io-pgtable.o
 obj-$(CONFIG_IOMMU_IO_PGTABLE_LPAE) += io-pgtable-arm.o
 obj-$(CONFIG_IOMMU_IOVA) += iova.o
 obj-$(CONFIG_OF_IOMMU)	+= of_iommu.o
-obj-$(CONFIG_MSM_IOMMU) += msm_iommu.o msm_iommu_dev.o
+obj-$(CONFIG_MSM_IOMMU) += msm_iommu.o
 obj-$(CONFIG_AMD_IOMMU) += amd_iommu.o amd_iommu_init.o
 obj-$(CONFIG_AMD_IOMMU_V2) += amd_iommu_v2.o
 obj-$(CONFIG_ARM_SMMU) += arm-smmu.o
drivers/iommu/msm_iommu.c +163 -0

181 lines not on this page · raw message

drivers/iommu/msm_iommu_dev.c deleted +0 -204

204 lines not on this page · raw message

Signature · 1 line
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
#3 lore raw

PATCH 3/5 iommu/msm: Add support for generic master bindings

In reply to Sricharan R

This adds the xlate callback which gets invoked during device registration from DT. The master devices gets added through this. Also adding the iommu_of_setup callback here.

---
 drivers/iommu/msm_iommu.c | 51 +++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 49 insertions(+), 2 deletions(-)
drivers/iommu/msm_iommu.c +49 -2
index 1210152..1d95d7c 100644
@@ -28,6 +28,7 @@
 #include <linux/iommu.h>
 #include <linux/clk.h>
 #include <linux/err.h>
+#include <linux/of_iommu.h>
 
 #include <asm/cacheflush.h>
 #include <asm/sizes.h>
@@ -702,6 +703,44 @@ static void print_ctx_regs(void __iomem *base, int ctx)
 	       GET_PRRR(base, ctx), GET_NMRR(base, ctx));
 }
 
+static void insert_iommu_master(struct device *dev,
+				struct msm_iommu_dev *iommu,
+				struct of_phandle_args *spec)
+{
+	struct msm_iommu_ctx_dev *master;
+	int sid;
+
+	master = kzalloc(sizeof(*master), GFP_KERNEL);
+	master->of_node = dev->of_node;
+	list_add(&master->list, &iommu->ctx_list);
+
+	for (sid = 0; sid < spec->args_count; sid++)
+		master->mids[sid] = spec->args[sid];
+
+	master->num_mids = spec->args_count;
+}
+
+static int qcom_iommu_of_xlate(struct device *dev,
+			       struct of_phandle_args *spec)
+{
+	struct msm_iommu_dev *iommu;
+	unsigned long flags;
+
+	spin_lock_irqsave(&msm_iommu_lock, flags);
+	list_for_each_entry(iommu, &qcom_iommu_devices, dev_node) {
+		if (iommu->dev->of_node == spec->np)
+			break;
+	}
+
+	if (!iommu || (iommu->dev->of_node != spec->np))
+		return -ENODEV;
+
+	insert_iommu_master(dev, iommu, spec);
+	spin_unlock_irqrestore(&msm_iommu_lock, flags);
+
+	return 0;
+}
+
 irqreturn_t msm_iommu_fault_handler(int irq, void *dev_id)
 {
 	struct msm_iommu_dev *iommu = dev_id;
@@ -737,7 +776,7 @@ fail:
 	return 0;
 }
 
-static const struct iommu_ops msm_iommu_ops = {
+static struct iommu_ops msm_iommu_ops = {
 	.capable = msm_iommu_capable,
 	.domain_alloc = msm_iommu_domain_alloc,
 	.domain_free = msm_iommu_domain_free,
@@ -748,6 +787,7 @@ static const struct iommu_ops msm_iommu_ops = {
 	.map_sg = default_iommu_map_sg,
 	.iova_to_phys = msm_iommu_iova_to_phys,
 	.pgsize_bitmap = MSM_IOMMU_PGSIZES,
+	.of_xlate = qcom_iommu_of_xlate,
 };
 
 static int msm_iommu_probe(struct platform_device *pdev)
@@ -832,6 +872,7 @@ static int msm_iommu_probe(struct platform_device *pdev)
 	}
 
 	list_add(&iommu->dev_node, &qcom_iommu_devices);
+	of_iommu_set_ops(pdev->dev.of_node, &msm_iommu_ops);
 
 	pr_info("device mapped at %p, irq %d with %d ctx banks\n",
 		iommu->base, iommu->irq, iommu->ncb);
@@ -916,7 +957,13 @@ static int __init msm_iommu_init(void)
 	return 0;
 }
 
-subsys_initcall(msm_iommu_init);
+static int __init msm_iommu_of_setup(struct device_node *np)
+{
+	msm_iommu_init();
+	return 0;
+}
+
+IOMMU_OF_DECLARE(msm_iommu_of, "qcom,iommu-v0", msm_iommu_of_setup);
 
 MODULE_LICENSE("GPL v2");
 MODULE_AUTHOR("Stepan Moskovchenko <[email protected]>");
Signature · 1 line
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
#4 lore raw

PATCH 3/5 iommu/msm: Add support for generic master bindings

drivers/iommu/msm_iommu.c static void print_ctx_regs(void __iomem *base, int ctx) · line 713

Quoted 12 lines · Sricharan R
drivers/iommu/msm_iommu.c +8 -0
@@ -702,6 +703,44 @@ static void print_ctx_regs(void __iomem *base, int ctx)
  	       GET_PRRR(base, ctx), GET_NMRR(base, ctx));
  }
 
+static void insert_iommu_master(struct device *dev,
+				struct msm_iommu_dev *iommu,
+				struct of_phandle_args *spec)
+{
+	struct msm_iommu_ctx_dev *master;
+	int sid;
+
+	master = kzalloc(sizeof(*master), GFP_KERNEL);

This is called with irqs disabled, but it's not GFP_ATOMIC. Please test with DEBUG_ATOMIC_SLEEP=y.

Quoted 10 lines
drivers/iommu/msm_iommu.c +10 -0
+	master->of_node = dev->of_node;
+	list_add(&master->list, &iommu->ctx_list);
+
+	for (sid = 0; sid < spec->args_count; sid++)
+		master->mids[sid] = spec->args[sid];
+
+	master->num_mids = spec->args_count;
+}
+
+static int qcom_iommu_of_xlate(struct device *dev,

drivers/iommu/msm_iommu.c static void print_ctx_regs(void __iomem *base, int ctx) · line 733

Quoted 10 lines
drivers/iommu/msm_iommu.c +10 -0
+			       struct of_phandle_args *spec)
+{
+	struct msm_iommu_dev *iommu;
+	unsigned long flags;
+
+	spin_lock_irqsave(&msm_iommu_lock, flags);
+	list_for_each_entry(iommu, &qcom_iommu_devices, dev_node) {
+		if (iommu->dev->of_node == spec->np)
+			break;
+	}

The braces are unnecessary here.

Review static void print_ctx_regs(void __iomem *base, int ctx) · line 735

Quoted 2 lines
(quoted diff) +2 -0
+
+	if (!iommu || (iommu->dev->of_node != spec->np))

Please remove extraneous parentheses.

Quoted 12 lines
drivers/iommu/msm_iommu.c +8 -0
+		return -ENODEV;
+
+	insert_iommu_master(dev, iommu, spec);
+	spin_unlock_irqrestore(&msm_iommu_lock, flags);
+
+	return 0;
+}
+
  irqreturn_t msm_iommu_fault_handler(int irq, void *dev_id)
  {
  	struct msm_iommu_dev *iommu = dev_id;

drivers/iommu/msm_iommu.c fail: · line 779

Quoted 5 lines
drivers/iommu/msm_iommu.c +1 -1
@@ -737,7 +776,7 @@ fail:
  	return 0;
  }
 
-static const struct iommu_ops msm_iommu_ops = {
+static struct iommu_ops msm_iommu_ops = {

Is there a reason why we can't make of_iommu_set_ops() take a const ops pointer?

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
author
#5 lore raw

PATCH 3/5 iommu/msm: Add support for generic master bindings

Hi Stephen,

Quoted 5 lines

-----Original Message-----
From: Stephen Boyd [mailto:sboyd at codeaurora.org]
Sent: Thursday, August 13, 2015 12:42 AM
To: Sricharan R
Cc: linux-arm-kernel at lists.infradead.org;

iommu at lists.linux-foundation.org;

Quoted 13 lines

devicetree at vger.kernel.org; linux-arm-msm at vger.kernel.org; robin.murphy at arm.com; robdclark at gmail.com; joro at 8bytes.org; srinivas.kandagatla at linaro.org; laurent.pinchart at ideasonboard.com; Will.Deacon at arm.com; stepanm at codeaurora.org; treding at nvidia.com
Subject: Re: [PATCH 3/5] iommu/msm: Add support for generic master bindings

Review static void print_ctx_regs(void __iomem *base,

Quoted 1 line · Sricharan R
(quoted diff) +0 -0
@@ -702,6 +703,44 @@ static void print_ctx_regs(void __iomem *base,

int ctx)

Quoted 3 lines
drivers/iommu/msm_iommu.c +0 -0
  	       GET_PRRR(base, ctx), GET_NMRR(base, ctx));
  }
 
Quoted 10 lines

drivers/iommu/msm_iommu.c static void print_ctx_regs(void __iomem *base, int ctx) · line 713

Quoted 8 lines
drivers/iommu/msm_iommu.c +8 -0
+static void insert_iommu_master(struct device *dev,
+				struct msm_iommu_dev *iommu,
+				struct of_phandle_args *spec)
+{
+	struct msm_iommu_ctx_dev *master;
+	int sid;
+
+	master = kzalloc(sizeof(*master), GFP_KERNEL);

This is called with irqs disabled, but it's not GFP_ATOMIC. Please test

with

Quoted 1 line

DEBUG_ATOMIC_SLEEP=y.

Ok. I will have to adjust the locking here. It should be granular only
for the list manipulation.

Quoted 13 lines
Quoted 13 lines
drivers/iommu/msm_iommu.c +12 -0
+	master->of_node = dev->of_node;
+	list_add(&master->list, &iommu->ctx_list);
+
+	for (sid = 0; sid < spec->args_count; sid++)
+		master->mids[sid] = spec->args[sid];
+
+	master->num_mids = spec->args_count; }
+
+static int qcom_iommu_of_xlate(struct device *dev,
+			       struct of_phandle_args *spec) {
+	struct msm_iommu_dev *iommu;
+	unsigned long flags;
Quoted 8 lines

drivers/iommu/msm_iommu.c static void print_ctx_regs(void __iomem *base, int ctx) · line 733

Quoted 6 lines
drivers/iommu/msm_iommu.c +6 -0
+
+	spin_lock_irqsave(&msm_iommu_lock, flags);
+	list_for_each_entry(iommu, &qcom_iommu_devices, dev_node) {
+		if (iommu->dev->of_node == spec->np)
+			break;
+	}

The braces are unnecessary here.

Ok, will remove this.

Quoted 6 lines

Review static void print_ctx_regs(void __iomem *base, · line 733

Quoted 3 lines
(quoted diff) +2 -0
+
+	if (!iommu || (iommu->dev->of_node != spec->np))

Please remove extraneous parentheses.

Ok.

Quoted 12 lines

drivers/iommu/msm_iommu.c static void print_ctx_regs(void __iomem *base, int ctx)

Quoted 11 lines
drivers/iommu/msm_iommu.c +8 -0
+		return -ENODEV;
+
+	insert_iommu_master(dev, iommu, spec);
+	spin_unlock_irqrestore(&msm_iommu_lock, flags);
+
+	return 0;
+}
+
  irqreturn_t msm_iommu_fault_handler(int irq, void *dev_id)
  {
  	struct msm_iommu_dev *iommu = dev_id; @@ -737,7 +776,7 @@

fail:

Quoted 9 lines

drivers/iommu/msm_iommu.c fail: · line 779

Quoted 5 lines
drivers/iommu/msm_iommu.c +1 -1
  	return 0;
  }
 
-static const struct iommu_ops msm_iommu_ops = {
+static struct iommu_ops msm_iommu_ops = {

Is there a reason why we can't make of_iommu_set_ops() take a const ops pointer?

Hmm right. of_iommu_set_ops is the one that needs change. I will add a
separate
patch to correct that.

Regards,
Sricharan

#6 lore raw

PATCH 4/5 iommu/msm: Set cacheability attributes without tex remap

In reply to Sricharan R

The cacheablity attributes are set when IOMMU_CACHE property is true. So cachebility is set as either noncached (normal) or cached (normal WBWA) directly and avoid setting using tex remap.

---
 drivers/iommu/msm_iommu.c         | 66 +++------------------------------------
 drivers/iommu/msm_iommu_hw-8xxx.h | 10 ++----
 2 files changed, 8 insertions(+), 68 deletions(-)
drivers/iommu/msm_iommu.c +5 -61
index 1d95d7c..d554ffa 100644
@@ -41,14 +41,9 @@ __asm__ __volatile__ (							\
 "   mrc   "   #processor "," #op1 ", %0,"  #crn "," #crm "," #op2 "\n"  \
 : "=r" (reg))
 
-#define RCP15_PRRR(reg)		MRC(reg, p15, 0, c10, c2, 0)
-#define RCP15_NMRR(reg)		MRC(reg, p15, 0, c10, c2, 1)
-
 /* bitmap of the page sizes currently supported */
 #define MSM_IOMMU_PGSIZES	(SZ_4K | SZ_64K | SZ_1M | SZ_16M)
 
-static int msm_iommu_tex_class[4];
-
 DEFINE_SPINLOCK(msm_iommu_lock);
 static LIST_HEAD(qcom_iommu_devices);
 
@@ -122,8 +117,6 @@ static void msm_iommu_reset(void __iomem *base, int ncb)
 		SET_TLBFLPTER(base, ctx, 0);
 		SET_TLBSLPTER(base, ctx, 0);
 		SET_TLBLKCR(base, ctx, 0);
-		SET_PRRR(base, ctx, 0);
-		SET_NMRR(base, ctx, 0);
 		SET_CONTEXTIDR(base, ctx, 0);
 	}
 }
@@ -232,13 +225,10 @@ static void __reset_context(void __iomem *base, int ctx)
 	SET_TLBFLPTER(base, ctx, 0);
 	SET_TLBSLPTER(base, ctx, 0);
 	SET_TLBLKCR(base, ctx, 0);
-	SET_PRRR(base, ctx, 0);
-	SET_NMRR(base, ctx, 0);
 }
 
 static void __program_context(void __iomem *base, int ctx, phys_addr_t pgtable)
 {
-	unsigned int prrr, nmrr;
 	__reset_context(base, ctx);
 
 	/* Set up HTW mode */
@@ -268,15 +258,6 @@ static void __program_context(void __iomem *base, int ctx, phys_addr_t pgtable)
 	SET_RCOSH(base, ctx, 1);
 	SET_RCNSH(base, ctx, 1);
 
-	/* Turn on TEX Remap */
-	SET_TRE(base, ctx, 1);
-
-	/* Set TEX remap attributes */
-	RCP15_PRRR(prrr);
-	RCP15_NMRR(nmrr);
-	SET_PRRR(base, ctx, prrr);
-	SET_NMRR(base, ctx, nmrr);
-
 	/* Turn on BFB prefetch */
 	SET_BFBDFE(base, ctx, 1);
 
@@ -452,7 +433,11 @@ static int msm_iommu_map(struct iommu_domain *domain, unsigned long va,
 	spin_lock_irqsave(&msm_iommu_lock, flags);
 
 	sh = (prot & MSM_IOMMU_ATTR_SH) ? 1 : 0;
-	tex = msm_iommu_tex_class[prot & MSM_IOMMU_CP_MASK];
+
+	tex = TEX_0;
+
+	if (prot & IOMMU_CACHE)
+		tex |= BUFFERABLE | CACHEABLE;
 
 	if (tex < 0 || tex > NUM_TEX_CLASS - 1) {
 		ret = -EINVAL;
@@ -699,8 +684,6 @@ static void print_ctx_regs(void __iomem *base, int ctx)
 	       GET_TTBR0(base, ctx), GET_TTBR1(base, ctx));
 	pr_err("SCTLR  = %08x    ACTLR  = %08x\n",
 	       GET_SCTLR(base, ctx), GET_ACTLR(base, ctx));
-	pr_err("PRRR   = %08x    NMRR   = %08x\n",
-	       GET_PRRR(base, ctx), GET_NMRR(base, ctx));
 }
 
 static void insert_iommu_master(struct device *dev,
@@ -912,47 +895,8 @@ static void __exit msm_iommu_driver_exit(void)
 subsys_initcall(msm_iommu_driver_init);
 module_exit(msm_iommu_driver_exit);
 
-static int __init get_tex_class(int icp, int ocp, int mt, int nos)
-{
-	int i = 0;
-	unsigned int prrr = 0;
-	unsigned int nmrr = 0;
-	int c_icp, c_ocp, c_mt, c_nos;
-
-	RCP15_PRRR(prrr);
-	RCP15_NMRR(nmrr);
-
-	for (i = 0; i < NUM_TEX_CLASS; i++) {
-		c_nos = PRRR_NOS(prrr, i);
-		c_mt = PRRR_MT(prrr, i);
-		c_icp = NMRR_ICP(nmrr, i);
-		c_ocp = NMRR_OCP(nmrr, i);
-
-		if (icp == c_icp && ocp == c_ocp && c_mt == mt && c_nos == nos)
-			return i;
-	}
-
-	return -ENODEV;
-}
-
-static void __init setup_iommu_tex_classes(void)
-{
-	msm_iommu_tex_class[MSM_IOMMU_ATTR_NONCACHED] =
-			get_tex_class(CP_NONCACHED, CP_NONCACHED, MT_NORMAL, 1);
-
-	msm_iommu_tex_class[MSM_IOMMU_ATTR_CACHED_WB_WA] =
-			get_tex_class(CP_WB_WA, CP_WB_WA, MT_NORMAL, 1);
-
-	msm_iommu_tex_class[MSM_IOMMU_ATTR_CACHED_WB_NWA] =
-			get_tex_class(CP_WB_NWA, CP_WB_NWA, MT_NORMAL, 1);
-
-	msm_iommu_tex_class[MSM_IOMMU_ATTR_CACHED_WT] =
-			get_tex_class(CP_WT, CP_WT, MT_NORMAL, 1);
-}
-
 static int __init msm_iommu_init(void)
 {
-	setup_iommu_tex_classes();
 	bus_set_iommu(&platform_bus_type, &msm_iommu_ops);
 	return 0;
 }
drivers/iommu/msm_iommu_hw-8xxx.h +3 -7
index fc16010..5be99cb 100644
@@ -85,13 +85,9 @@ do { \
 #define SL_NG			(1 << 11)
 
 /* Memory type and cache policy attributes */
-#define MT_SO			0
-#define MT_DEV			1
-#define MT_NORMAL		2
-#define CP_NONCACHED		0
-#define CP_WB_WA		1
-#define CP_WT			2
-#define CP_WB_NWA		3
+#define BUFFERABLE		(1 << 0)
+#define CACHEABLE		(1 << 1)
+#define TEX_0			(1 << 2)
 
 /* Global register setters / getters */
 #define SET_M2VCBR_N(b, N, v)	 SET_GLOBAL_REG_N(M2VCBR_N, N, (b), (v))
Signature · 1 line
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
#7 lore raw

PATCH 4/5 iommu/msm: Set cacheability attributes without tex remap

Quoted 4 lines · Sricharan R

The cacheablity attributes are set when IOMMU_CACHE property is true. So cachebility is set as either noncached (normal) or cached (normal WBWA) directly and avoid setting using tex remap.

Does this IOMMU support the ARMv7 short descriptor format? If so, would it work with Yong's patch here:

http://lists.infradead.org/pipermail/linux-arm-kernel/2015-August/361615.html

I've not gotten around to reviewing the latest version yet, but having other IOMMUs consolidate on one set of page table code would be a good thing.

Will

author
#8 lore raw

PATCH 4/5 iommu/msm: Set cacheability attributes without tex remap

Hi Will,

Quoted 11 lines

-----Original Message-----
From: linux-arm-kernel [mailto:linux-arm-kernel-
bounces at lists.infradead.org] On Behalf Of Will Deacon
Sent: Wednesday, August 12, 2015 8:24 PM
To: Sricharan R
Cc: devicetree at vger.kernel.org; linux-arm-msm at vger.kernel.org; joro at 8bytes.org; robdclark at gmail.com; iommu at lists.linux-foundation.org; srinivas.kandagatla at linaro.org; laurent.pinchart at ideasonboard.com; treding at nvidia.com; Robin Murphy; linux-arm-kernel at lists.infradead.org; stepanm at codeaurora.org
Subject: Re: [PATCH 4/5] iommu/msm: Set cacheability attributes without

tex

Quoted 7 lines

remap

Quoted 3 lines · Sricharan R

The cacheablity attributes are set when IOMMU_CACHE property is true. So cachebility is set as either noncached (normal) or cached (normal WBWA) directly and avoid setting using tex remap.

Quoted 7 lines

Does this IOMMU support the ARMv7 short descriptor format? If so, would it work with Yong's patch here:

http://lists.infradead.org/pipermail/linux-arm-kernel/2015-
August/361615.html

I've not gotten around to reviewing the latest version yet, but having

other

Quoted 1 line

IOMMUs consolidate on one set of page table code would be a good thing.

Yes, this is ARMv7 short descriptor complaint. I will rebase the next
one the
above. That should reduce more code in this driver. Thanks.

Regards,
Sricharan

#9 lore raw

PATCH 5/5 iommu/msm: Remove driver BROKEN

In reply to Sricharan R

Now that the driver is DT adapted, bus_set_iommu gets called only when on compatible matching. So the driver should not break multiplatform builds now. So remove the BROKEN config.

---
 drivers/iommu/Kconfig | 1 -
 1 file changed, 1 deletion(-)
drivers/iommu/Kconfig +0 -1
index f1fb1d3..147de52 100644
@@ -64,7 +64,6 @@ config MSM_IOMMU
 	bool "MSM IOMMU Support"
 	depends on ARM
 	depends on ARCH_MSM8X60 || ARCH_MSM8960 || COMPILE_TEST
-	depends on BROKEN
 	select IOMMU_API
 	help
 	  Support for the IOMMUs found on certain Qualcomm SOCs.
Signature · 1 line
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
#10 lore raw

cover iommu/msm: Add DT adaptation and generic bindings support

In reply to Sricharan R

Hi Sricharan,

thanks for the patches,

Quoted 12 lines · Sricharan R

The msm_iommu.c driver currently works based on platform data. A single master device can be connected to more than one iommu and multiple contexts in each of the iommu. This association between master and iommus was represented from platform data using parent/child devices. The master drivers were responsible for attaching all of the iommus/context to a domain. Now the platform data support is removed and DT support is added. The master/iommus are added through generic iommu bindings.

This is essentially rework of the patch posted earlier by Rob Clark <[email protected]>. This series folds the changes in to the existing driver with the addition of generic bindings.

Quoted 9 lines
         http://www.spinics.net/lists/linux-arm-msm/msg10077.html

This series is based on the IOMMU probe deferral series from Laurent Pinchart <[email protected]>

         https://lkml.org/lkml/2015/5/14/786

Tested this series on ifc6410 board.

I tested this series on IFC6410 with both HDMI and LVDS Panel with openbox desktop. It works.. :-)

--srini

Quoted 18 lines

Sricharan R (5):
iommu/msm: Add DT adaptation
iommu/msm: Move the contents from msm_iommu_dev.c to msm_iommu.c iommu/msm: Add support for generic master bindings iommu/msm: Set cacheability attributes without tex remap iommu/msm: Remove driver BROKEN

  .../devicetree/bindings/iommu/msm,iommu-v0.txt     |  59 +++
  drivers/iommu/Kconfig                              |   1 -
  drivers/iommu/Makefile                             |   2 +-
  drivers/iommu/msm_iommu.c                          | 508 ++++++++++++++-------
  drivers/iommu/msm_iommu.h                          |  73 ++-
  drivers/iommu/msm_iommu_dev.c                      | 392 ----------------
  drivers/iommu/msm_iommu_hw-8xxx.h                  |  10 +-
  7 files changed, 432 insertions(+), 613 deletions(-)

create mode 100644 Documentation/devicetree/bindings/iommu/msm,iommu-v0.txt delete mode 100644 drivers/iommu/msm_iommu_dev.c