mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Magnus Damm <magnus.damm@gmail.com>
To: joro@8bytes.org
Cc: laurent.pinchart+renesas@ideasonboard.com,
	geert+renesas@glider.be, linux-kernel@vger.kernel.org,
	linux-renesas-soc@vger.kernel.org,
	iommu@lists.linux-foundation.org, horms+renesas@verge.net.au,
	Magnus Damm <magnus.damm@gmail.com>,
	robin.murphy@arm.com, m.szyprowski@samsung.com
Subject: [PATCH v7 06/07] iommu/ipmmu-vmsa: ARM and ARM64 archdata access
Date: Tue, 07 Mar 2017 12:17:43 +0900	[thread overview]
Message-ID: <148885666392.28553.6653211200015255398.sendpatchset@little-apple> (raw)
In-Reply-To: <148885660307.28553.995847796823338863.sendpatchset@little-apple>

From: Magnus Damm <damm+renesas@opensource.se>

Not all architectures have an iommu member in their archdata, so
use #ifdefs support build with COMPILE_TEST on any architecture.

Signed-off-by: Magnus Damm <damm+renesas@opensource.se>
Reviewed-by: Joerg Roedel <jroedel@suse.de>
---

Changes since V6:
 - Updated patch to handle newly introduced functions in:
   [PATCH v7 05/07] iommu/ipmmu-vmsa: Add new IOMMU_DOMAIN_DMA ops

 drivers/iommu/ipmmu-vmsa.c |   43 ++++++++++++++++++++++++++++++-------------
 1 file changed, 30 insertions(+), 13 deletions(-)

--- 0010/drivers/iommu/ipmmu-vmsa.c
+++ work/drivers/iommu/ipmmu-vmsa.c	2017-03-06 19:26:26.070607110 +0900
@@ -72,6 +72,25 @@ static struct ipmmu_vmsa_domain *to_vmsa
 	return container_of(dom, struct ipmmu_vmsa_domain, io_domain);
 }
 
+#if defined(CONFIG_ARM) || defined(CONFIG_ARM64)
+static struct ipmmu_vmsa_archdata *to_archdata(struct device *dev)
+{
+	return dev->archdata.iommu;
+}
+static void set_archdata(struct device *dev, struct ipmmu_vmsa_archdata *p)
+{
+	dev->archdata.iommu = p;
+}
+#else
+static struct ipmmu_vmsa_archdata *to_archdata(struct device *dev)
+{
+	return NULL;
+}
+static void set_archdata(struct device *dev, struct ipmmu_vmsa_archdata *p)
+{
+}
+#endif
+
 #define TLB_LOOP_TIMEOUT		100	/* 100us */
 
 /* -----------------------------------------------------------------------------
@@ -543,7 +562,7 @@ static void ipmmu_domain_free(struct iom
 static int ipmmu_attach_device(struct iommu_domain *io_domain,
 			       struct device *dev)
 {
-	struct ipmmu_vmsa_archdata *archdata = dev->archdata.iommu;
+	struct ipmmu_vmsa_archdata *archdata = to_archdata(dev);
 	struct ipmmu_vmsa_device *mmu = archdata->mmu;
 	struct ipmmu_vmsa_domain *domain = to_vmsa_domain(io_domain);
 	unsigned long flags;
@@ -588,7 +607,7 @@ static int ipmmu_attach_device(struct io
 static void ipmmu_detach_device(struct iommu_domain *io_domain,
 				struct device *dev)
 {
-	struct ipmmu_vmsa_archdata *archdata = dev->archdata.iommu;
+	struct ipmmu_vmsa_archdata *archdata = to_archdata(dev);
 	struct ipmmu_vmsa_domain *domain = to_vmsa_domain(io_domain);
 	unsigned int i;
 
@@ -709,7 +728,7 @@ static int ipmmu_init_platform_device(st
 	archdata->utlbs = utlbs;
 	archdata->num_utlbs = num_utlbs;
 	archdata->dev = dev;
-	dev->archdata.iommu = archdata;
+	set_archdata(dev, archdata);
 	return 0;
 
 error:
@@ -729,12 +748,11 @@ static struct iommu_domain *ipmmu_domain
 
 static int ipmmu_add_device(struct device *dev)
 {
-	struct ipmmu_vmsa_archdata *archdata;
 	struct ipmmu_vmsa_device *mmu = NULL;
 	struct iommu_group *group;
 	int ret;
 
-	if (dev->archdata.iommu) {
+	if (to_archdata(dev)) {
 		dev_warn(dev, "IOMMU driver already assigned to device %s\n",
 			 dev_name(dev));
 		return -EINVAL;
@@ -770,8 +788,7 @@ static int ipmmu_add_device(struct devic
 	 * - Make the mapping size configurable ? We currently use a 2GB mapping
 	 *   at a 1GB offset to ensure that NULL VAs will fault.
 	 */
-	archdata = dev->archdata.iommu;
-	mmu = archdata->mmu;
+	mmu = to_archdata(dev)->mmu;
 	if (!mmu->mapping) {
 		struct dma_iommu_mapping *mapping;
 
@@ -799,7 +816,7 @@ error:
 	if (mmu)
 		arm_iommu_release_mapping(mmu->mapping);
 
-	dev->archdata.iommu = NULL;
+	set_archdata(dev, NULL);
 
 	if (!IS_ERR_OR_NULL(group))
 		iommu_group_remove_device(dev);
@@ -809,7 +826,7 @@ error:
 
 static void ipmmu_remove_device(struct device *dev)
 {
-	struct ipmmu_vmsa_archdata *archdata = dev->archdata.iommu;
+	struct ipmmu_vmsa_archdata *archdata = to_archdata(dev);
 
 	arm_iommu_detach_device(dev);
 	iommu_group_remove_device(dev);
@@ -817,7 +834,7 @@ static void ipmmu_remove_device(struct d
 	kfree(archdata->utlbs);
 	kfree(archdata);
 
-	dev->archdata.iommu = NULL;
+	set_archdata(dev, NULL);
 }
 
 static const struct iommu_ops ipmmu_ops = {
@@ -874,7 +891,7 @@ static void ipmmu_domain_free_dma(struct
 
 static int ipmmu_add_device_dma(struct device *dev)
 {
-	struct ipmmu_vmsa_archdata *archdata = dev->archdata.iommu;
+	struct ipmmu_vmsa_archdata *archdata = to_archdata(dev);
 	struct iommu_group *group;
 
 	/* The device has been verified in xlate() */
@@ -893,7 +910,7 @@ static int ipmmu_add_device_dma(struct d
 
 static void ipmmu_remove_device_dma(struct device *dev)
 {
-	struct ipmmu_vmsa_archdata *archdata = dev->archdata.iommu;
+	struct ipmmu_vmsa_archdata *archdata = to_archdata(dev);
 
 	spin_lock(&ipmmu_slave_devices_lock);
 	list_del(&archdata->list);
@@ -904,7 +921,7 @@ static void ipmmu_remove_device_dma(stru
 
 static struct device *ipmmu_find_sibling_device(struct device *dev)
 {
-	struct ipmmu_vmsa_archdata *archdata = dev->archdata.iommu;
+	struct ipmmu_vmsa_archdata *archdata = to_archdata(dev);
 	struct ipmmu_vmsa_archdata *sibling_archdata = NULL;
 	bool found = false;
 

  parent reply	other threads:[~2017-03-07  3:33 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-07  3:16 [PATCH v7 00/07] iommu/ipmmu-vmsa: IPMMU multi-arch update V7 Magnus Damm
2017-03-07  3:16 ` [PATCH v7 01/07] iommu/ipmmu-vmsa: Remove platform data handling Magnus Damm
2017-03-08  9:49   ` Geert Uytterhoeven
2017-03-07  3:17 ` [PATCH v7 02/07] iommu/ipmmu-vmsa: Rework interrupt code and use bitmap for context Magnus Damm
2017-03-07  3:17 ` [PATCH v7 03/07] iommu/ipmmu-vmsa: Break out utlb parsing code Magnus Damm
2017-03-07  3:17 ` [PATCH v7 04/07] iommu/ipmmu-vmsa: Break out domain allocation code Magnus Damm
2017-03-08  9:51   ` Geert Uytterhoeven
2017-03-07  3:17 ` [PATCH v7 05/07] iommu/ipmmu-vmsa: Add new IOMMU_DOMAIN_DMA ops Magnus Damm
2017-03-08 13:38   ` Robin Murphy
2017-03-22 14:25   ` Joerg Roedel
2017-03-07  3:17 ` Magnus Damm [this message]
2017-03-08  9:55   ` [PATCH v7 06/07] iommu/ipmmu-vmsa: ARM and ARM64 archdata access Geert Uytterhoeven
2017-03-08 12:48   ` Robin Murphy
2017-03-09  3:44     ` Magnus Damm
2017-03-09 11:40       ` Robin Murphy
2017-03-07  3:17 ` [PATCH v7 07/07] iommu/ipmmu-vmsa: Drop LPAE Kconfig dependency Magnus Damm

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=148885666392.28553.6653211200015255398.sendpatchset@little-apple \
    --to=magnus.damm@gmail.com \
    --cc=geert+renesas@glider.be \
    --cc=horms+renesas@verge.net.au \
    --cc=iommu@lists.linux-foundation.org \
    --cc=joro@8bytes.org \
    --cc=laurent.pinchart+renesas@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=robin.murphy@arm.com \
    /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

all inboxes | Powered by JetHome®