* [PATCHv2 0/2] OMAP IOMMU Fixes for DT-clients
@ 2014-09-04 22:27 Suman Anna
[not found] ` <1409869650-26115-1-git-send-email-s-anna-l0cyMroinI0@public.gmane.org>
2014-09-04 22:27 ` [PATCHv2 2/2] iommu/omap: Fix iommu archdata name for DT-based devices Suman Anna
0 siblings, 2 replies; 6+ messages in thread
From: Suman Anna @ 2014-09-04 22:27 UTC (permalink / raw)
To: Joerg Roedel
Cc: Laurent Pinchart, Florian Vaussard, iommu, linux-omap, Suman Anna
Hi,
This is an updated series addressing Laurent's review comments on
Patch1. Patch2 is unchanged from the previous series.
Patches are based on 3.17-rc3.
v1:
http://marc.info/?l=linux-omap&m=140978874026176&w=2
Suman Anna (2):
iommu/omap: Check for valid archdata in attach_dev
iommu/omap: Fix iommu archdata name for DT-based devices
drivers/iommu/omap-iommu.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
--
2.0.4
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCHv2 1/2] iommu/omap: Check for valid archdata in attach_dev
[not found] ` <1409869650-26115-1-git-send-email-s-anna-l0cyMroinI0@public.gmane.org>
@ 2014-09-04 22:27 ` Suman Anna
[not found] ` <1409869650-26115-2-git-send-email-s-anna-l0cyMroinI0@public.gmane.org>
2014-09-05 13:31 ` [PATCHv2 0/2] OMAP IOMMU Fixes for DT-clients Joerg Roedel
1 sibling, 1 reply; 6+ messages in thread
From: Suman Anna @ 2014-09-04 22:27 UTC (permalink / raw)
To: Joerg Roedel
Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
linux-omap-u79uwXL29TY76Z2rM5mHXA, Laurent Pinchart,
Florian Vaussard
Any device requiring to be attached to an iommu_domain must have
valid archdata containing the necessary iommu information, which
is SoC-specific. Add a check in the omap_iommu_attach_dev to make
sure that the device has valid archdata before accessing
different SoC-specific fields of the archdata. This prevents a
NULL pointer dereference on any misconfigured devices.
Signed-off-by: Suman Anna <s-anna-l0cyMroinI0@public.gmane.org>
---
drivers/iommu/omap-iommu.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/iommu/omap-iommu.c b/drivers/iommu/omap-iommu.c
index 02ef0ac..ea6e59d 100644
--- a/drivers/iommu/omap-iommu.c
+++ b/drivers/iommu/omap-iommu.c
@@ -1090,6 +1090,11 @@ omap_iommu_attach_dev(struct iommu_domain *domain, struct device *dev)
struct omap_iommu_arch_data *arch_data = dev->archdata.iommu;
int ret = 0;
+ if (!arch_data || !arch_data->name) {
+ dev_err(dev, "device doesn't have an associated iommu\n");
+ return -EINVAL;
+ }
+
spin_lock(&omap_domain->lock);
/* only a single device is supported per domain for now */
--
2.0.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCHv2 2/2] iommu/omap: Fix iommu archdata name for DT-based devices
2014-09-04 22:27 [PATCHv2 0/2] OMAP IOMMU Fixes for DT-clients Suman Anna
[not found] ` <1409869650-26115-1-git-send-email-s-anna-l0cyMroinI0@public.gmane.org>
@ 2014-09-04 22:27 ` Suman Anna
[not found] ` <1409869650-26115-3-git-send-email-s-anna-l0cyMroinI0@public.gmane.org>
1 sibling, 1 reply; 6+ messages in thread
From: Suman Anna @ 2014-09-04 22:27 UTC (permalink / raw)
To: Joerg Roedel
Cc: Laurent Pinchart, Florian Vaussard, iommu, linux-omap, Suman Anna
A device is tied to an iommu through its archdata field. The archdata
is allocated on the fly for DT-based devices automatically through the
.add_device iommu ops. The current logic incorrectly assigned the name
of the IOMMU user device, instead of the name of the IOMMU device as
required by the attach logic. Fix this issue so that DT-based devices
can attach successfully to an IOMMU domain.
Signed-off-by: Suman Anna <s-anna@ti.com>
---
drivers/iommu/omap-iommu.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/iommu/omap-iommu.c b/drivers/iommu/omap-iommu.c
index ea6e59d..8cf8bf1 100644
--- a/drivers/iommu/omap-iommu.c
+++ b/drivers/iommu/omap-iommu.c
@@ -26,6 +26,7 @@
#include <linux/of.h>
#include <linux/of_iommu.h>
#include <linux/of_irq.h>
+#include <linux/of_platform.h>
#include <asm/cacheflush.h>
@@ -1243,6 +1244,7 @@ static int omap_iommu_add_device(struct device *dev)
{
struct omap_iommu_arch_data *arch_data;
struct device_node *np;
+ struct platform_device *pdev;
/*
* Allocate the archdata iommu structure for DT-based devices.
@@ -1257,13 +1259,19 @@ static int omap_iommu_add_device(struct device *dev)
if (!np)
return 0;
+ pdev = of_find_device_by_node(np);
+ if (WARN_ON(!pdev)) {
+ of_node_put(np);
+ return -EINVAL;
+ }
+
arch_data = kzalloc(sizeof(*arch_data), GFP_KERNEL);
if (!arch_data) {
of_node_put(np);
return -ENOMEM;
}
- arch_data->name = kstrdup(dev_name(dev), GFP_KERNEL);
+ arch_data->name = kstrdup(dev_name(&pdev->dev), GFP_KERNEL);
dev->archdata.iommu = arch_data;
of_node_put(np);
--
2.0.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCHv2 1/2] iommu/omap: Check for valid archdata in attach_dev
[not found] ` <1409869650-26115-2-git-send-email-s-anna-l0cyMroinI0@public.gmane.org>
@ 2014-09-05 11:12 ` Laurent Pinchart
0 siblings, 0 replies; 6+ messages in thread
From: Laurent Pinchart @ 2014-09-05 11:12 UTC (permalink / raw)
To: Suman Anna
Cc: linux-omap-u79uwXL29TY76Z2rM5mHXA,
iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
Florian Vaussard
Hi Suman,
Thank you for the patch.
On Thursday 04 September 2014 17:27:29 Suman Anna wrote:
> Any device requiring to be attached to an iommu_domain must have
> valid archdata containing the necessary iommu information, which
> is SoC-specific. Add a check in the omap_iommu_attach_dev to make
> sure that the device has valid archdata before accessing
> different SoC-specific fields of the archdata. This prevents a
> NULL pointer dereference on any misconfigured devices.
>
> Signed-off-by: Suman Anna <s-anna-l0cyMroinI0@public.gmane.org>
Acked-by: Laurent Pinchart <laurent.pinchart-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org>
> ---
> drivers/iommu/omap-iommu.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/iommu/omap-iommu.c b/drivers/iommu/omap-iommu.c
> index 02ef0ac..ea6e59d 100644
> --- a/drivers/iommu/omap-iommu.c
> +++ b/drivers/iommu/omap-iommu.c
> @@ -1090,6 +1090,11 @@ omap_iommu_attach_dev(struct iommu_domain *domain,
> struct device *dev) struct omap_iommu_arch_data *arch_data =
> dev->archdata.iommu;
> int ret = 0;
>
> + if (!arch_data || !arch_data->name) {
> + dev_err(dev, "device doesn't have an associated iommu\n");
> + return -EINVAL;
> + }
> +
> spin_lock(&omap_domain->lock);
>
> /* only a single device is supported per domain for now */
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCHv2 2/2] iommu/omap: Fix iommu archdata name for DT-based devices
[not found] ` <1409869650-26115-3-git-send-email-s-anna-l0cyMroinI0@public.gmane.org>
@ 2014-09-05 11:13 ` Laurent Pinchart
0 siblings, 0 replies; 6+ messages in thread
From: Laurent Pinchart @ 2014-09-05 11:13 UTC (permalink / raw)
To: Suman Anna
Cc: linux-omap-u79uwXL29TY76Z2rM5mHXA,
iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
Florian Vaussard
Hi Suman,
Thank you for the patch.
On Thursday 04 September 2014 17:27:30 Suman Anna wrote:
> A device is tied to an iommu through its archdata field. The archdata
> is allocated on the fly for DT-based devices automatically through the
> .add_device iommu ops. The current logic incorrectly assigned the name
> of the IOMMU user device, instead of the name of the IOMMU device as
> required by the attach logic. Fix this issue so that DT-based devices
> can attach successfully to an IOMMU domain.
>
> Signed-off-by: Suman Anna <s-anna-l0cyMroinI0@public.gmane.org>
Acked-by: Laurent Pinchart <laurent.pinchart-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org>
> ---
> drivers/iommu/omap-iommu.c | 10 +++++++++-
> 1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/iommu/omap-iommu.c b/drivers/iommu/omap-iommu.c
> index ea6e59d..8cf8bf1 100644
> --- a/drivers/iommu/omap-iommu.c
> +++ b/drivers/iommu/omap-iommu.c
> @@ -26,6 +26,7 @@
> #include <linux/of.h>
> #include <linux/of_iommu.h>
> #include <linux/of_irq.h>
> +#include <linux/of_platform.h>
>
> #include <asm/cacheflush.h>
>
> @@ -1243,6 +1244,7 @@ static int omap_iommu_add_device(struct device *dev)
> {
> struct omap_iommu_arch_data *arch_data;
> struct device_node *np;
> + struct platform_device *pdev;
>
> /*
> * Allocate the archdata iommu structure for DT-based devices.
> @@ -1257,13 +1259,19 @@ static int omap_iommu_add_device(struct device *dev)
> if (!np)
> return 0;
>
> + pdev = of_find_device_by_node(np);
> + if (WARN_ON(!pdev)) {
> + of_node_put(np);
> + return -EINVAL;
> + }
> +
> arch_data = kzalloc(sizeof(*arch_data), GFP_KERNEL);
> if (!arch_data) {
> of_node_put(np);
> return -ENOMEM;
> }
>
> - arch_data->name = kstrdup(dev_name(dev), GFP_KERNEL);
> + arch_data->name = kstrdup(dev_name(&pdev->dev), GFP_KERNEL);
> dev->archdata.iommu = arch_data;
>
> of_node_put(np);
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCHv2 0/2] OMAP IOMMU Fixes for DT-clients
[not found] ` <1409869650-26115-1-git-send-email-s-anna-l0cyMroinI0@public.gmane.org>
2014-09-04 22:27 ` [PATCHv2 1/2] iommu/omap: Check for valid archdata in attach_dev Suman Anna
@ 2014-09-05 13:31 ` Joerg Roedel
1 sibling, 0 replies; 6+ messages in thread
From: Joerg Roedel @ 2014-09-05 13:31 UTC (permalink / raw)
To: Suman Anna
Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
linux-omap-u79uwXL29TY76Z2rM5mHXA, Laurent Pinchart,
Florian Vaussard
On Thu, Sep 04, 2014 at 05:27:28PM -0500, Suman Anna wrote:
> Suman Anna (2):
> iommu/omap: Check for valid archdata in attach_dev
> iommu/omap: Fix iommu archdata name for DT-based devices
>
> drivers/iommu/omap-iommu.c | 15 ++++++++++++++-
> 1 file changed, 14 insertions(+), 1 deletion(-)
Applied, thanks.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-09-05 13:31 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-04 22:27 [PATCHv2 0/2] OMAP IOMMU Fixes for DT-clients Suman Anna
[not found] ` <1409869650-26115-1-git-send-email-s-anna-l0cyMroinI0@public.gmane.org>
2014-09-04 22:27 ` [PATCHv2 1/2] iommu/omap: Check for valid archdata in attach_dev Suman Anna
[not found] ` <1409869650-26115-2-git-send-email-s-anna-l0cyMroinI0@public.gmane.org>
2014-09-05 11:12 ` Laurent Pinchart
2014-09-05 13:31 ` [PATCHv2 0/2] OMAP IOMMU Fixes for DT-clients Joerg Roedel
2014-09-04 22:27 ` [PATCHv2 2/2] iommu/omap: Fix iommu archdata name for DT-based devices Suman Anna
[not found] ` <1409869650-26115-3-git-send-email-s-anna-l0cyMroinI0@public.gmane.org>
2014-09-05 11:13 ` Laurent Pinchart
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).