Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1689023
| Path | csiph.com!news.mixmin.net!aioe.org!bofh.it!news.nic.it!robomod |
|---|---|
| From | Magnus Damm <magnus.damm@gmail.com> |
| Newsgroups | linux.kernel |
| Subject | [PATCH v2 02/05] iommu/ipmmu-vmsa: Consistent ->of_xlate() handling |
| Date | Mon, 17 Jul 2017 15:10:03 +0200 |
| Message-ID | <u4dWH-5qj-47@gated-at.bofh.it> (permalink) |
| References | <u4dWF-5qj-17@gated-at.bofh.it> |
| Dkim-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:date:message-id:in-reply-to:references:subject; bh=JG2DWv/VaPEViA51go7uyb6kIHhM26qAacJqqQ1bdBk=; b=i6wR86OxlsdiDgWyyZ5nBsPw8k+1fPtW5omnrN0vvl6oNHzB2xWU0Bi+oGKdf65YMs XUoR6Pwug4PR0DZCdAbrnlFC81Myk/FFVq72GoluJSvYAfvXwEYt0q/tYRJqx4Tx93zB PN3MSl4V4gZErntY5ND1rm0JdUeQLgPue+EvTe97+JRRsYB3450oy7R6+huBIsVhrs80 J6GCqiWTMu7I6yeSFBWBcE4f0FyUdjslPZ6NAAoyloedvct9tNDrG4m10ena5ydXbi5U 0xu7oJOPSJqY8BU5kiT2+RDyxWhqxDOzOnchQN2SsyXYrl4Qo6lIfsXQ6k8iFjGmjfy7 L4jA== |
| X-Google-Dkim-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:date:message-id:in-reply-to :references:subject; bh=JG2DWv/VaPEViA51go7uyb6kIHhM26qAacJqqQ1bdBk=; b=kdmDrPzugSxbxbWxJTYEc65hia6nUmCJJm+LdMxbtOd/0W5Xs16KVHQMJ5URwkfdi5 5wREGxa0NSso5w60LfYWTNg379uynPH2Y4RLGcPtPRBut9vIe5SthxsAIGW6GBoV1gqH OU5dUaDgOSLRiGSn+2f34K2Vtbb5Y5q+YHP3uoKZQFkEYkINxRZtbB3cf9jWP0A9lbjk jXnm6tFBVO/Il4zXLYHhr6cU6hPk3EeUMpfhBp6j6CSHZAuvcH6nORYzTJlG1P24VQay ncbWRpTnwvzg0CaX95uVDzKZCLZq/8WWp32B+xCDySKtKwUjQTslNHPK8gE8zxRvzx5I NLlA== |
| X-Gm-Message-State | AIVw110k+ubBd45TLyMVL+pDyvq7g1QzKUxIT2HNGjhofXSBpgFSQwFQ IPHT9ctdpRQyHg== |
| X-Received | by 10.99.121.204 with SMTP id u195mr28266361pgc.16.1500296922670; Mon, 17 Jul 2017 06:08:42 -0700 (PDT) |
| Sender | robomod@news.nic.it |
| List-ID | <linux-kernel.vger.kernel.org> |
| X-Mailing-List | linux-kernel@vger.kernel.org |
| Approved | robomod@news.nic.it |
| Lines | 125 |
| Organization | linux.* mail to news gateway |
| X-Original-Cc | laurent.pinchart+renesas@ideasonboard.com, geert+renesas@glider.be, sricharan@codeaurora.org, will.deacon@arm.com, 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 |
| X-Original-Date | Mon, 17 Jul 2017 22:05:20 +0900 |
| X-Original-Message-ID | <150029672099.22030.9705035062184016120.sendpatchset@little-apple> |
| X-Original-References | <150029669967.22030.8059216113725566341.sendpatchset@little-apple> |
| X-Original-Sender | linux-kernel-owner@vger.kernel.org |
| Xref | csiph.com linux.kernel:1689023 |
Show key headers only | View raw
From: Magnus Damm <damm+renesas@opensource.se>
The 32-bit ARM code gets updated to make use of ->of_xlate() and the
code is shared between 64-bit and 32-bit ARM. The of_device_is_available()
check gets dropped since it is included in of_iommu_xlate().
Suggested-by: Robin Murphy <robin.murphy@arm.com>
Signed-off-by: Magnus Damm <damm+renesas@opensource.se>
---
Changes since V1:
- Moved "Initialize once" check to ipmmu_of_xlate() - thanks Geert!
drivers/iommu/ipmmu-vmsa.c | 51 ++++++++++++++------------------------------
1 file changed, 17 insertions(+), 34 deletions(-)
--- 0002/drivers/iommu/ipmmu-vmsa.c
+++ work/drivers/iommu/ipmmu-vmsa.c 2017-07-17 21:03:38.340607110 +0900
@@ -734,6 +734,16 @@ error:
return ret;
}
+static int ipmmu_of_xlate(struct device *dev,
+ struct of_phandle_args *spec)
+{
+ /* Initialize once - xlate() will call multiple times */
+ if (to_priv(dev))
+ return 0;
+
+ return ipmmu_init_platform_device(dev);
+}
+
#if defined(CONFIG_ARM) && !defined(CONFIG_IOMMU_DMA)
static struct iommu_domain *ipmmu_domain_alloc(unsigned type)
@@ -750,11 +760,11 @@ static int ipmmu_add_device(struct devic
struct iommu_group *group;
int ret;
- if (to_priv(dev)) {
- dev_warn(dev, "IOMMU driver already assigned to device %s\n",
- dev_name(dev));
- return -EINVAL;
- }
+ /*
+ * Only let through devices that have been verified in xlate()
+ */
+ if (!to_priv(dev))
+ return -ENODEV;
/* Create a device group and add the device to it. */
group = iommu_group_alloc();
@@ -773,10 +783,6 @@ static int ipmmu_add_device(struct devic
goto error;
}
- ret = ipmmu_init_platform_device(dev);
- if (ret < 0)
- goto error;
-
/*
* Create the ARM mapping, used by the ARM DMA mapping core to allocate
* VAs. This will allocate a corresponding IOMMU domain.
@@ -817,24 +823,13 @@ error:
if (!IS_ERR_OR_NULL(group))
iommu_group_remove_device(dev);
- kfree(to_priv(dev)->utlbs);
- kfree(to_priv(dev));
- set_priv(dev, NULL);
-
return ret;
}
static void ipmmu_remove_device(struct device *dev)
{
- struct ipmmu_vmsa_iommu_priv *priv = to_priv(dev);
-
arm_iommu_detach_device(dev);
iommu_group_remove_device(dev);
-
- kfree(priv->utlbs);
- kfree(priv);
-
- set_priv(dev, NULL);
}
static const struct iommu_ops ipmmu_ops = {
@@ -849,6 +844,7 @@ static const struct iommu_ops ipmmu_ops
.add_device = ipmmu_add_device,
.remove_device = ipmmu_remove_device,
.pgsize_bitmap = SZ_1G | SZ_2M | SZ_4K,
+ .of_xlate = ipmmu_of_xlate,
};
#endif /* !CONFIG_ARM && CONFIG_IOMMU_DMA */
@@ -958,19 +954,6 @@ static struct iommu_group *ipmmu_find_gr
return group;
}
-static int ipmmu_of_xlate_dma(struct device *dev,
- struct of_phandle_args *spec)
-{
- /* If the IPMMU device is disabled in DT then return error
- * to make sure the of_iommu code does not install ops
- * even though the iommu device is disabled
- */
- if (!of_device_is_available(spec->np))
- return -ENODEV;
-
- return ipmmu_init_platform_device(dev);
-}
-
static const struct iommu_ops ipmmu_ops = {
.domain_alloc = ipmmu_domain_alloc_dma,
.domain_free = ipmmu_domain_free_dma,
@@ -984,7 +967,7 @@ static const struct iommu_ops ipmmu_ops
.remove_device = ipmmu_remove_device_dma,
.device_group = ipmmu_find_group_dma,
.pgsize_bitmap = SZ_1G | SZ_2M | SZ_4K,
- .of_xlate = ipmmu_of_xlate_dma,
+ .of_xlate = ipmmu_of_xlate,
};
#endif /* CONFIG_IOMMU_DMA */
Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread
[PATCH v2 00/05] iommu/ipmmu-vmsa: 32-bit ARM update V2 Magnus Damm <magnus.damm@gmail.com> - 2017-07-17 15:10 +0200 [PATCH v2 02/05] iommu/ipmmu-vmsa: Consistent ->of_xlate() handling Magnus Damm <magnus.damm@gmail.com> - 2017-07-17 15:10 +0200
csiph-web