All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/5] iommu/arm-smmu: add support for non-pci devices
@ 2015-07-21  7:30 ` Zhen Lei
  0 siblings, 0 replies; 24+ messages in thread
From: Zhen Lei @ 2015-07-21  7:30 UTC (permalink / raw)
  To: Will Deacon, Joerg Roedel, linux-arm-kernel, iommu
  Cc: Xinwei Hu, Zhen Lei, Zefan Li, Tianhong Ding

Changelog:
v2 -> v3:
1. add support for pci device hotplug, which missed in patch v2.
2. only support #iommu-cells = <1>, add corresponding description in arm,smmu-v3.txt.
3. add function find_smmu_by_device which extracted from find_smmu_by_node, to resolve
   the problem mentioned by Robin Murphy in [PATCH v2 7/9].
   Additionally:
   +    platform_set_drvdata(pdev, smmu);       //Patch v2
   +	dev->archdata.iommu = smmu;             //Patch v3, dev = &pdev->dev

v1 -> v2:
update the implementation of patch 1/9 according to Will Deacon's suggestion.
update the comment of patch 3/9 and 4/9.
use arm_smmu_options to skip the execution of command CMD_PREFETCH_CONFIG, see patch 5/9.
patch 6/9 is base on Laurent's series, to support probe deferral.
patch 7/9 according to Robin Murphy's suggestion, remove global variable arm_smmu_devices, thanks.
patch 9/9 add support for a master with multiple stream IDs.

Zhen Lei (5):
  iommu/arm-smmu: to support probe deferral
  iommu/arm-smmu: remove arm_smmu_devices
  iommu/arm-smmu: rename __arm_smmu_get_pci_sid
  iommu/arm-smmu: add support for non-pci devices
  iommu/arm-smmu: describe the limitation of #iommu-cells

 .../devicetree/bindings/iommu/arm,smmu-v3.txt      |   6 +
 drivers/iommu/arm-smmu-v3.c                        | 209 ++++++++++++++++-----
 2 files changed, 163 insertions(+), 52 deletions(-)

--
1.8.0

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH v3 0/5] iommu/arm-smmu: add support for non-pci devices
@ 2015-07-21  7:30 ` Zhen Lei
  0 siblings, 0 replies; 24+ messages in thread
From: Zhen Lei @ 2015-07-21  7:30 UTC (permalink / raw)
  To: linux-arm-kernel

Changelog:
v2 -> v3:
1. add support for pci device hotplug, which missed in patch v2.
2. only support #iommu-cells = <1>, add corresponding description in arm,smmu-v3.txt.
3. add function find_smmu_by_device which extracted from find_smmu_by_node, to resolve
   the problem mentioned by Robin Murphy in [PATCH v2 7/9].
   Additionally:
   +    platform_set_drvdata(pdev, smmu);       //Patch v2
   +	dev->archdata.iommu = smmu;             //Patch v3, dev = &pdev->dev

v1 -> v2:
update the implementation of patch 1/9 according to Will Deacon's suggestion.
update the comment of patch 3/9 and 4/9.
use arm_smmu_options to skip the execution of command CMD_PREFETCH_CONFIG, see patch 5/9.
patch 6/9 is base on Laurent's series, to support probe deferral.
patch 7/9 according to Robin Murphy's suggestion, remove global variable arm_smmu_devices, thanks.
patch 9/9 add support for a master with multiple stream IDs.

Zhen Lei (5):
  iommu/arm-smmu: to support probe deferral
  iommu/arm-smmu: remove arm_smmu_devices
  iommu/arm-smmu: rename __arm_smmu_get_pci_sid
  iommu/arm-smmu: add support for non-pci devices
  iommu/arm-smmu: describe the limitation of #iommu-cells

 .../devicetree/bindings/iommu/arm,smmu-v3.txt      |   6 +
 drivers/iommu/arm-smmu-v3.c                        | 209 ++++++++++++++++-----
 2 files changed, 163 insertions(+), 52 deletions(-)

--
1.8.0

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH v3 1/5] iommu/arm-smmu: to support probe deferral
  2015-07-21  7:30 ` Zhen Lei
@ 2015-07-21  7:30     ` Zhen Lei
  -1 siblings, 0 replies; 24+ messages in thread
From: Zhen Lei @ 2015-07-21  7:30 UTC (permalink / raw)
  To: Will Deacon, Joerg Roedel, linux-arm-kernel, iommu
  Cc: Xinwei Hu, Zhen Lei, Zefan Li, Tianhong Ding

For pci devices, only the root nodes have "iommus" property. So we
should traverse all of its sub nodes in of_xlate.

There exists two cases:
Case 1: .add_device(sub node) happened before .of_xlate(root node)
Case 2: .add_device(sub node) happened after  .of_xlate(root node)

(1).add_device
	if (!root->archdata.iommu)
		return -ENODEV;

(2).of_xlate
	root->archdata.iommu = smmu;
	/*
	 * Probe the pci devices deferred in phase (1)
	 */

(3).add_device
	/*
	 * After phase (2), it's not NULL
	 */
	if (!root->archdata.iommu)
		return -ENODEV;

	__arm_smmu_add_pci_device(pdev, root->archdata.iommu);

Reviewed-by: Robin Murphy <robin.murphy-5wv7dgnIgG8@public.gmane.org>
Signed-off-by: Zhen Lei <thunder.leizhen-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
---
 drivers/iommu/arm-smmu-v3.c | 147 +++++++++++++++++++++++++++++++++++---------
 1 file changed, 117 insertions(+), 30 deletions(-)

diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c
index 4f09337..474eca4 100644
--- a/drivers/iommu/arm-smmu-v3.c
+++ b/drivers/iommu/arm-smmu-v3.c
@@ -30,6 +30,8 @@
 #include <linux/of_address.h>
 #include <linux/pci.h>
 #include <linux/platform_device.h>
+#include <linux/of_iommu.h>
+#include <linux/of_platform.h>

 #include "io-pgtable.h"

@@ -1741,32 +1743,37 @@ static void __arm_smmu_release_pci_iommudata(void *data)
 	kfree(data);
 }

-static struct arm_smmu_device *arm_smmu_get_for_pci_dev(struct pci_dev *pdev)
+static struct arm_smmu_device *find_smmu_by_device(struct device *dev)
+{
+	struct device_node *np = dev->of_node;
+
+	/* to ensure np is a smmu device node */
+	if (!of_iommu_get_ops(np))
+		return NULL;
+
+	return dev->archdata.iommu;
+}
+
+static struct arm_smmu_device *find_smmu_by_node(struct device_node *np)
+{
+	struct platform_device *pdev;
+
+	pdev = of_find_device_by_node(np);
+	if (!pdev)
+		return NULL;
+
+	return find_smmu_by_device(&pdev->dev);
+}
+
+static struct device *arm_smmu_get_pci_dev_root(struct pci_dev *pdev)
 {
-	struct device_node *of_node;
-	struct arm_smmu_device *curr, *smmu = NULL;
 	struct pci_bus *bus = pdev->bus;

 	/* Walk up to the root bus */
 	while (!pci_is_root_bus(bus))
 		bus = bus->parent;

-	/* Follow the "iommus" phandle from the host controller */
-	of_node = of_parse_phandle(bus->bridge->parent->of_node, "iommus", 0);
-	if (!of_node)
-		return NULL;
-
-	/* See if we can find an SMMU corresponding to the phandle */
-	spin_lock(&arm_smmu_devices_lock);
-	list_for_each_entry(curr, &arm_smmu_devices, list) {
-		if (curr->dev->of_node == of_node) {
-			smmu = curr;
-			break;
-		}
-	}
-	spin_unlock(&arm_smmu_devices_lock);
-	of_node_put(of_node);
-	return smmu;
+	return bus->bridge->parent;
 }

 static bool arm_smmu_sid_in_range(struct arm_smmu_device *smmu, u32 sid)
@@ -1779,27 +1786,21 @@ static bool arm_smmu_sid_in_range(struct arm_smmu_device *smmu, u32 sid)
 	return sid < limit;
 }

-static int arm_smmu_add_device(struct device *dev)
+static int __arm_smmu_add_device(struct device *dev, u32 sid)
 {
 	int i, ret;
-	u32 sid, *sids;
-	struct pci_dev *pdev;
+	u32 *sids;
 	struct iommu_group *group;
 	struct arm_smmu_group *smmu_group;
 	struct arm_smmu_device *smmu;

-	/* We only support PCI, for now */
-	if (!dev_is_pci(dev))
-		return -ENODEV;
-
-	pdev = to_pci_dev(dev);
 	group = iommu_group_get_for_dev(dev);
 	if (IS_ERR(group))
 		return PTR_ERR(group);

 	smmu_group = iommu_group_get_iommudata(group);
 	if (!smmu_group) {
-		smmu = arm_smmu_get_for_pci_dev(pdev);
+		smmu = dev->archdata.iommu;
 		if (!smmu) {
 			ret = -ENOENT;
 			goto out_put_group;
@@ -1819,8 +1820,6 @@ static int arm_smmu_add_device(struct device *dev)
 		smmu = smmu_group->smmu;
 	}

-	/* Assume SID == RID until firmware tells us otherwise */
-	pci_for_each_dma_alias(pdev, __arm_smmu_get_pci_sid, &sid);
 	for (i = 0; i < smmu_group->num_sids; ++i) {
 		/* If we already know about this SID, then we're done */
 		if (smmu_group->sids[i] == sid)
@@ -1857,11 +1856,43 @@ static int arm_smmu_add_device(struct device *dev)

 out_put_group:
 	iommu_group_put(group);
+	dev_err(dev, "failed to add into SMMU\n");
 	return ret;
 }

+static int __arm_smmu_add_pci_device(struct pci_dev *pdev, void *smmu)
+{
+	u32 sid;
+	struct device *dev = &pdev->dev;
+
+	/* Assume SID == RID until firmware tells us otherwise */
+	pci_for_each_dma_alias(pdev, __arm_smmu_get_pci_sid, &sid);
+
+	dev->archdata.iommu = smmu;
+
+	return __arm_smmu_add_device(dev, sid);
+}
+
+static int arm_smmu_add_device(struct device *dev)
+{
+	struct pci_dev *pdev;
+	struct device *root;
+
+	/* only support pci devices hotplug */
+	if (!dev_is_pci(dev))
+		return -ENODEV;
+
+	pdev = to_pci_dev(dev);
+	root = arm_smmu_get_pci_dev_root(pdev);
+	if (!root->archdata.iommu)
+		return -ENODEV;
+
+	return __arm_smmu_add_pci_device(pdev, root->archdata.iommu);
+}
+
 static void arm_smmu_remove_device(struct device *dev)
 {
+	dev->archdata.iommu = NULL;
 	iommu_group_remove_device(dev);
 }

@@ -1909,7 +1940,58 @@ out_unlock:
 	return ret;
 }

+static int arm_smmu_of_xlate(struct device *dev, struct of_phandle_args *args)
+{
+	int ret;
+	struct arm_smmu_device *smmu;
+
+	/*
+	 * We can sure that args->np is a smmu device node, because this
+	 * function was called by of_xlate hook.
+	 *
+	 * And in arm_smmu_device_dt_probe:
+	 *	dev->archdata.iommu = smmu;
+	 *	of_iommu_set_ops(smmu->dev->of_node, &arm_smmu_ops);
+	 *
+	 * It seems impossible return NULL in normal times.
+	 */
+	smmu = find_smmu_by_node(args->np);
+	if (!smmu) {
+		dev_err(dev, "unknown error caused smmu driver crashed\n");
+		return -ENODEV;
+	}
+
+	if (!dev->archdata.iommu)
+		dev->archdata.iommu = smmu;
+
+	if (dev->archdata.iommu != smmu) {
+		dev_err(dev, "behinds more than one smmu\n");
+		return -EINVAL;
+	}
+
+	/* We only support PCI, for now */
+	if (!dev_is_pci(dev)) {
+		return -ENODEV;
+	} else {
+		struct device *root;
+		struct pci_dev *pdev = NULL;
+
+		for_each_pci_dev(pdev) {
+			root = arm_smmu_get_pci_dev_root(pdev);
+			if (root->of_node != dev->of_node)
+				continue;
+
+			ret = __arm_smmu_add_pci_device(pdev, smmu);
+			if (ret)
+				return ret;
+		}
+	}
+
+	return 0;
+}
+
 static struct iommu_ops arm_smmu_ops = {
+	.of_xlate		= arm_smmu_of_xlate,
 	.capable		= arm_smmu_capable,
 	.domain_alloc		= arm_smmu_domain_alloc,
 	.domain_free		= arm_smmu_domain_free,
@@ -2635,6 +2717,9 @@ static int arm_smmu_device_dt_probe(struct platform_device *pdev)
 	spin_lock(&arm_smmu_devices_lock);
 	list_add(&smmu->list, &arm_smmu_devices);
 	spin_unlock(&arm_smmu_devices_lock);
+	dev->archdata.iommu = smmu;
+	of_iommu_set_ops(smmu->dev->of_node, &arm_smmu_ops);
+
 	return 0;

 out_free_structures:
@@ -2706,6 +2791,8 @@ static void __exit arm_smmu_exit(void)
 subsys_initcall(arm_smmu_init);
 module_exit(arm_smmu_exit);

+IOMMU_OF_DECLARE(arm_smmu_v3, "arm,smmu-v3", NULL);
+
 MODULE_DESCRIPTION("IOMMU API for ARM architected SMMUv3 implementations");
 MODULE_AUTHOR("Will Deacon <will.deacon-5wv7dgnIgG8@public.gmane.org>");
 MODULE_LICENSE("GPL v2");
--
1.8.0

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v3 1/5] iommu/arm-smmu: to support probe deferral
@ 2015-07-21  7:30     ` Zhen Lei
  0 siblings, 0 replies; 24+ messages in thread
From: Zhen Lei @ 2015-07-21  7:30 UTC (permalink / raw)
  To: linux-arm-kernel

For pci devices, only the root nodes have "iommus" property. So we
should traverse all of its sub nodes in of_xlate.

There exists two cases:
Case 1: .add_device(sub node) happened before .of_xlate(root node)
Case 2: .add_device(sub node) happened after  .of_xlate(root node)

(1).add_device
	if (!root->archdata.iommu)
		return -ENODEV;

(2).of_xlate
	root->archdata.iommu = smmu;
	/*
	 * Probe the pci devices deferred in phase (1)
	 */

(3).add_device
	/*
	 * After phase (2), it's not NULL
	 */
	if (!root->archdata.iommu)
		return -ENODEV;

	__arm_smmu_add_pci_device(pdev, root->archdata.iommu);

Reviewed-by: Robin Murphy <robin.murphy@arm.com>
Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
---
 drivers/iommu/arm-smmu-v3.c | 147 +++++++++++++++++++++++++++++++++++---------
 1 file changed, 117 insertions(+), 30 deletions(-)

diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c
index 4f09337..474eca4 100644
--- a/drivers/iommu/arm-smmu-v3.c
+++ b/drivers/iommu/arm-smmu-v3.c
@@ -30,6 +30,8 @@
 #include <linux/of_address.h>
 #include <linux/pci.h>
 #include <linux/platform_device.h>
+#include <linux/of_iommu.h>
+#include <linux/of_platform.h>

 #include "io-pgtable.h"

@@ -1741,32 +1743,37 @@ static void __arm_smmu_release_pci_iommudata(void *data)
 	kfree(data);
 }

-static struct arm_smmu_device *arm_smmu_get_for_pci_dev(struct pci_dev *pdev)
+static struct arm_smmu_device *find_smmu_by_device(struct device *dev)
+{
+	struct device_node *np = dev->of_node;
+
+	/* to ensure np is a smmu device node */
+	if (!of_iommu_get_ops(np))
+		return NULL;
+
+	return dev->archdata.iommu;
+}
+
+static struct arm_smmu_device *find_smmu_by_node(struct device_node *np)
+{
+	struct platform_device *pdev;
+
+	pdev = of_find_device_by_node(np);
+	if (!pdev)
+		return NULL;
+
+	return find_smmu_by_device(&pdev->dev);
+}
+
+static struct device *arm_smmu_get_pci_dev_root(struct pci_dev *pdev)
 {
-	struct device_node *of_node;
-	struct arm_smmu_device *curr, *smmu = NULL;
 	struct pci_bus *bus = pdev->bus;

 	/* Walk up to the root bus */
 	while (!pci_is_root_bus(bus))
 		bus = bus->parent;

-	/* Follow the "iommus" phandle from the host controller */
-	of_node = of_parse_phandle(bus->bridge->parent->of_node, "iommus", 0);
-	if (!of_node)
-		return NULL;
-
-	/* See if we can find an SMMU corresponding to the phandle */
-	spin_lock(&arm_smmu_devices_lock);
-	list_for_each_entry(curr, &arm_smmu_devices, list) {
-		if (curr->dev->of_node == of_node) {
-			smmu = curr;
-			break;
-		}
-	}
-	spin_unlock(&arm_smmu_devices_lock);
-	of_node_put(of_node);
-	return smmu;
+	return bus->bridge->parent;
 }

 static bool arm_smmu_sid_in_range(struct arm_smmu_device *smmu, u32 sid)
@@ -1779,27 +1786,21 @@ static bool arm_smmu_sid_in_range(struct arm_smmu_device *smmu, u32 sid)
 	return sid < limit;
 }

-static int arm_smmu_add_device(struct device *dev)
+static int __arm_smmu_add_device(struct device *dev, u32 sid)
 {
 	int i, ret;
-	u32 sid, *sids;
-	struct pci_dev *pdev;
+	u32 *sids;
 	struct iommu_group *group;
 	struct arm_smmu_group *smmu_group;
 	struct arm_smmu_device *smmu;

-	/* We only support PCI, for now */
-	if (!dev_is_pci(dev))
-		return -ENODEV;
-
-	pdev = to_pci_dev(dev);
 	group = iommu_group_get_for_dev(dev);
 	if (IS_ERR(group))
 		return PTR_ERR(group);

 	smmu_group = iommu_group_get_iommudata(group);
 	if (!smmu_group) {
-		smmu = arm_smmu_get_for_pci_dev(pdev);
+		smmu = dev->archdata.iommu;
 		if (!smmu) {
 			ret = -ENOENT;
 			goto out_put_group;
@@ -1819,8 +1820,6 @@ static int arm_smmu_add_device(struct device *dev)
 		smmu = smmu_group->smmu;
 	}

-	/* Assume SID == RID until firmware tells us otherwise */
-	pci_for_each_dma_alias(pdev, __arm_smmu_get_pci_sid, &sid);
 	for (i = 0; i < smmu_group->num_sids; ++i) {
 		/* If we already know about this SID, then we're done */
 		if (smmu_group->sids[i] == sid)
@@ -1857,11 +1856,43 @@ static int arm_smmu_add_device(struct device *dev)

 out_put_group:
 	iommu_group_put(group);
+	dev_err(dev, "failed to add into SMMU\n");
 	return ret;
 }

+static int __arm_smmu_add_pci_device(struct pci_dev *pdev, void *smmu)
+{
+	u32 sid;
+	struct device *dev = &pdev->dev;
+
+	/* Assume SID == RID until firmware tells us otherwise */
+	pci_for_each_dma_alias(pdev, __arm_smmu_get_pci_sid, &sid);
+
+	dev->archdata.iommu = smmu;
+
+	return __arm_smmu_add_device(dev, sid);
+}
+
+static int arm_smmu_add_device(struct device *dev)
+{
+	struct pci_dev *pdev;
+	struct device *root;
+
+	/* only support pci devices hotplug */
+	if (!dev_is_pci(dev))
+		return -ENODEV;
+
+	pdev = to_pci_dev(dev);
+	root = arm_smmu_get_pci_dev_root(pdev);
+	if (!root->archdata.iommu)
+		return -ENODEV;
+
+	return __arm_smmu_add_pci_device(pdev, root->archdata.iommu);
+}
+
 static void arm_smmu_remove_device(struct device *dev)
 {
+	dev->archdata.iommu = NULL;
 	iommu_group_remove_device(dev);
 }

@@ -1909,7 +1940,58 @@ out_unlock:
 	return ret;
 }

+static int arm_smmu_of_xlate(struct device *dev, struct of_phandle_args *args)
+{
+	int ret;
+	struct arm_smmu_device *smmu;
+
+	/*
+	 * We can sure that args->np is a smmu device node, because this
+	 * function was called by of_xlate hook.
+	 *
+	 * And in arm_smmu_device_dt_probe:
+	 *	dev->archdata.iommu = smmu;
+	 *	of_iommu_set_ops(smmu->dev->of_node, &arm_smmu_ops);
+	 *
+	 * It seems impossible return NULL in normal times.
+	 */
+	smmu = find_smmu_by_node(args->np);
+	if (!smmu) {
+		dev_err(dev, "unknown error caused smmu driver crashed\n");
+		return -ENODEV;
+	}
+
+	if (!dev->archdata.iommu)
+		dev->archdata.iommu = smmu;
+
+	if (dev->archdata.iommu != smmu) {
+		dev_err(dev, "behinds more than one smmu\n");
+		return -EINVAL;
+	}
+
+	/* We only support PCI, for now */
+	if (!dev_is_pci(dev)) {
+		return -ENODEV;
+	} else {
+		struct device *root;
+		struct pci_dev *pdev = NULL;
+
+		for_each_pci_dev(pdev) {
+			root = arm_smmu_get_pci_dev_root(pdev);
+			if (root->of_node != dev->of_node)
+				continue;
+
+			ret = __arm_smmu_add_pci_device(pdev, smmu);
+			if (ret)
+				return ret;
+		}
+	}
+
+	return 0;
+}
+
 static struct iommu_ops arm_smmu_ops = {
+	.of_xlate		= arm_smmu_of_xlate,
 	.capable		= arm_smmu_capable,
 	.domain_alloc		= arm_smmu_domain_alloc,
 	.domain_free		= arm_smmu_domain_free,
@@ -2635,6 +2717,9 @@ static int arm_smmu_device_dt_probe(struct platform_device *pdev)
 	spin_lock(&arm_smmu_devices_lock);
 	list_add(&smmu->list, &arm_smmu_devices);
 	spin_unlock(&arm_smmu_devices_lock);
+	dev->archdata.iommu = smmu;
+	of_iommu_set_ops(smmu->dev->of_node, &arm_smmu_ops);
+
 	return 0;

 out_free_structures:
@@ -2706,6 +2791,8 @@ static void __exit arm_smmu_exit(void)
 subsys_initcall(arm_smmu_init);
 module_exit(arm_smmu_exit);

+IOMMU_OF_DECLARE(arm_smmu_v3, "arm,smmu-v3", NULL);
+
 MODULE_DESCRIPTION("IOMMU API for ARM architected SMMUv3 implementations");
 MODULE_AUTHOR("Will Deacon <will.deacon@arm.com>");
 MODULE_LICENSE("GPL v2");
--
1.8.0

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v3 2/5] iommu/arm-smmu: remove arm_smmu_devices
  2015-07-21  7:30 ` Zhen Lei
@ 2015-07-21  7:30     ` Zhen Lei
  -1 siblings, 0 replies; 24+ messages in thread
From: Zhen Lei @ 2015-07-21  7:30 UTC (permalink / raw)
  To: Will Deacon, Joerg Roedel, linux-arm-kernel, iommu
  Cc: Xinwei Hu, Zhen Lei, Zefan Li, Tianhong Ding

It can be replaced by of_iommu_list(in of_iommu.c).

Reviewed-by: Robin Murphy <robin.murphy-5wv7dgnIgG8@public.gmane.org>
Signed-off-by: Zhen Lei <thunder.leizhen-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
---
 drivers/iommu/arm-smmu-v3.c | 22 ++--------------------
 1 file changed, 2 insertions(+), 20 deletions(-)

diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c
index 474eca4..9daf4cc 100644
--- a/drivers/iommu/arm-smmu-v3.c
+++ b/drivers/iommu/arm-smmu-v3.c
@@ -605,10 +605,6 @@ struct arm_smmu_domain {
 	struct iommu_domain		domain;
 };

-/* Our list of SMMU instances */
-static DEFINE_SPINLOCK(arm_smmu_devices_lock);
-static LIST_HEAD(arm_smmu_devices);
-
 struct arm_smmu_option_prop {
 	u32 opt;
 	const char *prop;
@@ -2712,11 +2708,6 @@ static int arm_smmu_device_dt_probe(struct platform_device *pdev)
 	if (ret)
 		goto out_free_structures;

-	/* Record our private device structure */
-	INIT_LIST_HEAD(&smmu->list);
-	spin_lock(&arm_smmu_devices_lock);
-	list_add(&smmu->list, &arm_smmu_devices);
-	spin_unlock(&arm_smmu_devices_lock);
 	dev->archdata.iommu = smmu;
 	of_iommu_set_ops(smmu->dev->of_node, &arm_smmu_ops);

@@ -2729,19 +2720,10 @@ out_free_structures:

 static int arm_smmu_device_remove(struct platform_device *pdev)
 {
-	struct arm_smmu_device *curr, *smmu = NULL;
+	struct arm_smmu_device *smmu;
 	struct device *dev = &pdev->dev;

-	spin_lock(&arm_smmu_devices_lock);
-	list_for_each_entry(curr, &arm_smmu_devices, list) {
-		if (curr->dev == dev) {
-			smmu = curr;
-			list_del(&smmu->list);
-			break;
-		}
-	}
-	spin_unlock(&arm_smmu_devices_lock);
-
+	smmu = find_smmu_by_device(dev);
 	if (!smmu)
 		return -ENODEV;

--
1.8.0

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v3 2/5] iommu/arm-smmu: remove arm_smmu_devices
@ 2015-07-21  7:30     ` Zhen Lei
  0 siblings, 0 replies; 24+ messages in thread
From: Zhen Lei @ 2015-07-21  7:30 UTC (permalink / raw)
  To: linux-arm-kernel

It can be replaced by of_iommu_list(in of_iommu.c).

Reviewed-by: Robin Murphy <robin.murphy@arm.com>
Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
---
 drivers/iommu/arm-smmu-v3.c | 22 ++--------------------
 1 file changed, 2 insertions(+), 20 deletions(-)

diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c
index 474eca4..9daf4cc 100644
--- a/drivers/iommu/arm-smmu-v3.c
+++ b/drivers/iommu/arm-smmu-v3.c
@@ -605,10 +605,6 @@ struct arm_smmu_domain {
 	struct iommu_domain		domain;
 };

-/* Our list of SMMU instances */
-static DEFINE_SPINLOCK(arm_smmu_devices_lock);
-static LIST_HEAD(arm_smmu_devices);
-
 struct arm_smmu_option_prop {
 	u32 opt;
 	const char *prop;
@@ -2712,11 +2708,6 @@ static int arm_smmu_device_dt_probe(struct platform_device *pdev)
 	if (ret)
 		goto out_free_structures;

-	/* Record our private device structure */
-	INIT_LIST_HEAD(&smmu->list);
-	spin_lock(&arm_smmu_devices_lock);
-	list_add(&smmu->list, &arm_smmu_devices);
-	spin_unlock(&arm_smmu_devices_lock);
 	dev->archdata.iommu = smmu;
 	of_iommu_set_ops(smmu->dev->of_node, &arm_smmu_ops);

@@ -2729,19 +2720,10 @@ out_free_structures:

 static int arm_smmu_device_remove(struct platform_device *pdev)
 {
-	struct arm_smmu_device *curr, *smmu = NULL;
+	struct arm_smmu_device *smmu;
 	struct device *dev = &pdev->dev;

-	spin_lock(&arm_smmu_devices_lock);
-	list_for_each_entry(curr, &arm_smmu_devices, list) {
-		if (curr->dev == dev) {
-			smmu = curr;
-			list_del(&smmu->list);
-			break;
-		}
-	}
-	spin_unlock(&arm_smmu_devices_lock);
-
+	smmu = find_smmu_by_device(dev);
 	if (!smmu)
 		return -ENODEV;

--
1.8.0

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v3 3/5] iommu/arm-smmu: rename __arm_smmu_get_pci_sid
  2015-07-21  7:30 ` Zhen Lei
@ 2015-07-21  7:30     ` Zhen Lei
  -1 siblings, 0 replies; 24+ messages in thread
From: Zhen Lei @ 2015-07-21  7:30 UTC (permalink / raw)
  To: Will Deacon, Joerg Roedel, linux-arm-kernel, iommu
  Cc: Xinwei Hu, Zhen Lei, Zefan Li, Tianhong Ding

Remove the words "pci", to make this function can also be used by
non-pci devices.

Signed-off-by: Zhen Lei <thunder.leizhen-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
---
 drivers/iommu/arm-smmu-v3.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c
index 9daf4cc..216c9d4 100644
--- a/drivers/iommu/arm-smmu-v3.c
+++ b/drivers/iommu/arm-smmu-v3.c
@@ -1734,7 +1734,7 @@ static int __arm_smmu_get_pci_sid(struct pci_dev *pdev, u16 alias, void *sidp)
 	return 0; /* Continue walking */
 }

-static void __arm_smmu_release_pci_iommudata(void *data)
+static void __arm_smmu_release_iommudata(void *data)
 {
 	kfree(data);
 }
@@ -1811,7 +1811,7 @@ static int __arm_smmu_add_device(struct device *dev, u32 sid)
 		smmu_group->ste.valid	= true;
 		smmu_group->smmu	= smmu;
 		iommu_group_set_iommudata(group, smmu_group,
-					  __arm_smmu_release_pci_iommudata);
+					  __arm_smmu_release_iommudata);
 	} else {
 		smmu = smmu_group->smmu;
 	}
--
1.8.0

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v3 3/5] iommu/arm-smmu: rename __arm_smmu_get_pci_sid
@ 2015-07-21  7:30     ` Zhen Lei
  0 siblings, 0 replies; 24+ messages in thread
From: Zhen Lei @ 2015-07-21  7:30 UTC (permalink / raw)
  To: linux-arm-kernel

Remove the words "pci", to make this function can also be used by
non-pci devices.

Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
---
 drivers/iommu/arm-smmu-v3.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c
index 9daf4cc..216c9d4 100644
--- a/drivers/iommu/arm-smmu-v3.c
+++ b/drivers/iommu/arm-smmu-v3.c
@@ -1734,7 +1734,7 @@ static int __arm_smmu_get_pci_sid(struct pci_dev *pdev, u16 alias, void *sidp)
 	return 0; /* Continue walking */
 }

-static void __arm_smmu_release_pci_iommudata(void *data)
+static void __arm_smmu_release_iommudata(void *data)
 {
 	kfree(data);
 }
@@ -1811,7 +1811,7 @@ static int __arm_smmu_add_device(struct device *dev, u32 sid)
 		smmu_group->ste.valid	= true;
 		smmu_group->smmu	= smmu;
 		iommu_group_set_iommudata(group, smmu_group,
-					  __arm_smmu_release_pci_iommudata);
+					  __arm_smmu_release_iommudata);
 	} else {
 		smmu = smmu_group->smmu;
 	}
--
1.8.0

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v3 4/5] iommu/arm-smmu: add support for non-pci devices
  2015-07-21  7:30 ` Zhen Lei
@ 2015-07-21  7:30     ` Zhen Lei
  -1 siblings, 0 replies; 24+ messages in thread
From: Zhen Lei @ 2015-07-21  7:30 UTC (permalink / raw)
  To: Will Deacon, Joerg Roedel, linux-arm-kernel, iommu
  Cc: Xinwei Hu, Zhen Lei, Zefan Li, Tianhong Ding

This patch support a master with multiple stream IDs, but doesn't support a
master behinds more than one SMMUs.

Reviewed-by: Robin Murphy <robin.murphy-5wv7dgnIgG8@public.gmane.org>
Signed-off-by: Zhen Lei <thunder.leizhen-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
---
 drivers/iommu/arm-smmu-v3.c | 40 ++++++++++++++++++++++++++++++++++++++--
 1 file changed, 38 insertions(+), 2 deletions(-)

diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c
index 216c9d4..129ff36 100644
--- a/drivers/iommu/arm-smmu-v3.c
+++ b/drivers/iommu/arm-smmu-v3.c
@@ -30,6 +30,7 @@
 #include <linux/of_address.h>
 #include <linux/pci.h>
 #include <linux/platform_device.h>
+#include <linux/amba/bus.h>
 #include <linux/of_iommu.h>
 #include <linux/of_platform.h>

@@ -1965,9 +1966,36 @@ static int arm_smmu_of_xlate(struct device *dev, struct of_phandle_args *args)
 		return -EINVAL;
 	}

-	/* We only support PCI, for now */
 	if (!dev_is_pci(dev)) {
-		return -ENODEV;
+		struct iommu_group *group;
+
+		if (args->args_count != 1) {
+			dev_err(dev,
+				"only support #iommu-cells = <1>, please check node: %s\n",
+				dev_name(smmu->dev));
+			return -ENODEV;
+		}
+
+		group = iommu_group_get(dev);
+		if (!group) {
+			group = iommu_group_alloc();
+			if (IS_ERR(group)) {
+				dev_err(dev, "failed to allocate IOMMU group\n");
+				return PTR_ERR(group);
+			}
+
+			ret = iommu_group_add_device(group, dev);
+			if (ret) {
+				iommu_group_put(group);
+				dev_err(dev, "failed to add device into IOMMU group\n");
+				return ret;
+			}
+		}
+		iommu_group_put(group);
+
+		ret = __arm_smmu_add_device(dev, args->args[0]);
+		if (ret)
+			return ret;
 	} else {
 		struct device *root;
 		struct pci_dev *pdev = NULL;
@@ -2762,6 +2790,14 @@ static int __init arm_smmu_init(void)
 	if (ret)
 		return ret;

+	if (!iommu_present(&platform_bus_type))
+		bus_set_iommu(&platform_bus_type, &arm_smmu_ops);
+
+#ifdef CONFIG_ARM_AMBA
+	if (!iommu_present(&amba_bustype))
+		bus_set_iommu(&amba_bustype, &arm_smmu_ops);
+#endif
+
 	return bus_set_iommu(&pci_bus_type, &arm_smmu_ops);
 }

--
1.8.0

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v3 4/5] iommu/arm-smmu: add support for non-pci devices
@ 2015-07-21  7:30     ` Zhen Lei
  0 siblings, 0 replies; 24+ messages in thread
From: Zhen Lei @ 2015-07-21  7:30 UTC (permalink / raw)
  To: linux-arm-kernel

This patch support a master with multiple stream IDs, but doesn't support a
master behinds more than one SMMUs.

Reviewed-by: Robin Murphy <robin.murphy@arm.com>
Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
---
 drivers/iommu/arm-smmu-v3.c | 40 ++++++++++++++++++++++++++++++++++++++--
 1 file changed, 38 insertions(+), 2 deletions(-)

diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c
index 216c9d4..129ff36 100644
--- a/drivers/iommu/arm-smmu-v3.c
+++ b/drivers/iommu/arm-smmu-v3.c
@@ -30,6 +30,7 @@
 #include <linux/of_address.h>
 #include <linux/pci.h>
 #include <linux/platform_device.h>
+#include <linux/amba/bus.h>
 #include <linux/of_iommu.h>
 #include <linux/of_platform.h>

@@ -1965,9 +1966,36 @@ static int arm_smmu_of_xlate(struct device *dev, struct of_phandle_args *args)
 		return -EINVAL;
 	}

-	/* We only support PCI, for now */
 	if (!dev_is_pci(dev)) {
-		return -ENODEV;
+		struct iommu_group *group;
+
+		if (args->args_count != 1) {
+			dev_err(dev,
+				"only support #iommu-cells = <1>, please check node: %s\n",
+				dev_name(smmu->dev));
+			return -ENODEV;
+		}
+
+		group = iommu_group_get(dev);
+		if (!group) {
+			group = iommu_group_alloc();
+			if (IS_ERR(group)) {
+				dev_err(dev, "failed to allocate IOMMU group\n");
+				return PTR_ERR(group);
+			}
+
+			ret = iommu_group_add_device(group, dev);
+			if (ret) {
+				iommu_group_put(group);
+				dev_err(dev, "failed to add device into IOMMU group\n");
+				return ret;
+			}
+		}
+		iommu_group_put(group);
+
+		ret = __arm_smmu_add_device(dev, args->args[0]);
+		if (ret)
+			return ret;
 	} else {
 		struct device *root;
 		struct pci_dev *pdev = NULL;
@@ -2762,6 +2790,14 @@ static int __init arm_smmu_init(void)
 	if (ret)
 		return ret;

+	if (!iommu_present(&platform_bus_type))
+		bus_set_iommu(&platform_bus_type, &arm_smmu_ops);
+
+#ifdef CONFIG_ARM_AMBA
+	if (!iommu_present(&amba_bustype))
+		bus_set_iommu(&amba_bustype, &arm_smmu_ops);
+#endif
+
 	return bus_set_iommu(&pci_bus_type, &arm_smmu_ops);
 }

--
1.8.0

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v3 5/5] iommu/arm-smmu: describe the limitation of #iommu-cells
  2015-07-21  7:30 ` Zhen Lei
@ 2015-07-21  7:30     ` Zhen Lei
  -1 siblings, 0 replies; 24+ messages in thread
From: Zhen Lei @ 2015-07-21  7:30 UTC (permalink / raw)
  To: Will Deacon, Joerg Roedel, linux-arm-kernel, iommu
  Cc: Xinwei Hu, Zhen Lei, Zefan Li, Tianhong Ding

Only support #iommu-cells = <1>.

Signed-off-by: Zhen Lei <thunder.leizhen-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
---
 Documentation/devicetree/bindings/iommu/arm,smmu-v3.txt | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/Documentation/devicetree/bindings/iommu/arm,smmu-v3.txt b/Documentation/devicetree/bindings/iommu/arm,smmu-v3.txt
index 3443e0f..7d110a1 100644
--- a/Documentation/devicetree/bindings/iommu/arm,smmu-v3.txt
+++ b/Documentation/devicetree/bindings/iommu/arm,smmu-v3.txt
@@ -5,6 +5,12 @@ revisions, replacing the MMIO register interface with in-memory command
 and event queues and adding support for the ATS and PRI components of
 the PCIe specification.

+Please read ./iommu.txt first, here list something special as below:
+
+** SMMUv3 limited properties:
+- #iommu-cells      : fixed to <1>. The pci root device is a special case,
+                      its IDs can be omitted in dts, seems #iommu-cells = <0>.
+
 ** SMMUv3 required properties:

 - compatible        : Should include:
--
1.8.0

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v3 5/5] iommu/arm-smmu: describe the limitation of #iommu-cells
@ 2015-07-21  7:30     ` Zhen Lei
  0 siblings, 0 replies; 24+ messages in thread
From: Zhen Lei @ 2015-07-21  7:30 UTC (permalink / raw)
  To: linux-arm-kernel

Only support #iommu-cells = <1>.

Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
---
 Documentation/devicetree/bindings/iommu/arm,smmu-v3.txt | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/Documentation/devicetree/bindings/iommu/arm,smmu-v3.txt b/Documentation/devicetree/bindings/iommu/arm,smmu-v3.txt
index 3443e0f..7d110a1 100644
--- a/Documentation/devicetree/bindings/iommu/arm,smmu-v3.txt
+++ b/Documentation/devicetree/bindings/iommu/arm,smmu-v3.txt
@@ -5,6 +5,12 @@ revisions, replacing the MMIO register interface with in-memory command
 and event queues and adding support for the ATS and PRI components of
 the PCIe specification.

+Please read ./iommu.txt first, here list something special as below:
+
+** SMMUv3 limited properties:
+- #iommu-cells      : fixed to <1>. The pci root device is a special case,
+                      its IDs can be omitted in dts, seems #iommu-cells = <0>.
+
 ** SMMUv3 required properties:

 - compatible        : Should include:
--
1.8.0

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* Re: [PATCH v3 0/5] iommu/arm-smmu: add support for non-pci devices
  2015-07-21  7:30 ` Zhen Lei
@ 2015-07-21 10:30     ` Robin Murphy
  -1 siblings, 0 replies; 24+ messages in thread
From: Robin Murphy @ 2015-07-21 10:30 UTC (permalink / raw)
  To: Zhen Lei, Will Deacon, Joerg Roedel, linux-arm-kernel, iommu
  Cc: huxinwei-hv44wF8Li93QT0dZR+AlfA, Zefan Li, Tianhong Ding

On 21/07/15 08:30, Zhen Lei wrote:
> Changelog:
> v2 -> v3:
> 1. add support for pci device hotplug, which missed in patch v2.
> 2. only support #iommu-cells = <1>, add corresponding description in arm,smmu-v3.txt.
> 3. add function find_smmu_by_device which extracted from find_smmu_by_node, to resolve
>     the problem mentioned by Robin Murphy in [PATCH v2 7/9].
>     Additionally:
>     +    platform_set_drvdata(pdev, smmu);       //Patch v2
>     +	dev->archdata.iommu = smmu;             //Patch v3, dev = &pdev->dev


I didn't give any Reviewed-by tags, much less to revised patches that 
I've not even looked at yet; please see section 13 of 
Documentation/SubmittingPatches for what the Reviewed-by tag means.

Robin.

>
> v1 -> v2:
> update the implementation of patch 1/9 according to Will Deacon's suggestion.
> update the comment of patch 3/9 and 4/9.
> use arm_smmu_options to skip the execution of command CMD_PREFETCH_CONFIG, see patch 5/9.
> patch 6/9 is base on Laurent's series, to support probe deferral.
> patch 7/9 according to Robin Murphy's suggestion, remove global variable arm_smmu_devices, thanks.
> patch 9/9 add support for a master with multiple stream IDs.
>
> Zhen Lei (5):
>    iommu/arm-smmu: to support probe deferral
>    iommu/arm-smmu: remove arm_smmu_devices
>    iommu/arm-smmu: rename __arm_smmu_get_pci_sid
>    iommu/arm-smmu: add support for non-pci devices
>    iommu/arm-smmu: describe the limitation of #iommu-cells
>
>   .../devicetree/bindings/iommu/arm,smmu-v3.txt      |   6 +
>   drivers/iommu/arm-smmu-v3.c                        | 209 ++++++++++++++++-----
>   2 files changed, 163 insertions(+), 52 deletions(-)
>
> --
> 1.8.0
>
>

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH v3 0/5] iommu/arm-smmu: add support for non-pci devices
@ 2015-07-21 10:30     ` Robin Murphy
  0 siblings, 0 replies; 24+ messages in thread
From: Robin Murphy @ 2015-07-21 10:30 UTC (permalink / raw)
  To: linux-arm-kernel

On 21/07/15 08:30, Zhen Lei wrote:
> Changelog:
> v2 -> v3:
> 1. add support for pci device hotplug, which missed in patch v2.
> 2. only support #iommu-cells = <1>, add corresponding description in arm,smmu-v3.txt.
> 3. add function find_smmu_by_device which extracted from find_smmu_by_node, to resolve
>     the problem mentioned by Robin Murphy in [PATCH v2 7/9].
>     Additionally:
>     +    platform_set_drvdata(pdev, smmu);       //Patch v2
>     +	dev->archdata.iommu = smmu;             //Patch v3, dev = &pdev->dev


I didn't give any Reviewed-by tags, much less to revised patches that 
I've not even looked at yet; please see section 13 of 
Documentation/SubmittingPatches for what the Reviewed-by tag means.

Robin.

>
> v1 -> v2:
> update the implementation of patch 1/9 according to Will Deacon's suggestion.
> update the comment of patch 3/9 and 4/9.
> use arm_smmu_options to skip the execution of command CMD_PREFETCH_CONFIG, see patch 5/9.
> patch 6/9 is base on Laurent's series, to support probe deferral.
> patch 7/9 according to Robin Murphy's suggestion, remove global variable arm_smmu_devices, thanks.
> patch 9/9 add support for a master with multiple stream IDs.
>
> Zhen Lei (5):
>    iommu/arm-smmu: to support probe deferral
>    iommu/arm-smmu: remove arm_smmu_devices
>    iommu/arm-smmu: rename __arm_smmu_get_pci_sid
>    iommu/arm-smmu: add support for non-pci devices
>    iommu/arm-smmu: describe the limitation of #iommu-cells
>
>   .../devicetree/bindings/iommu/arm,smmu-v3.txt      |   6 +
>   drivers/iommu/arm-smmu-v3.c                        | 209 ++++++++++++++++-----
>   2 files changed, 163 insertions(+), 52 deletions(-)
>
> --
> 1.8.0
>
>

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v3 0/5] iommu/arm-smmu: add support for non-pci devices
  2015-07-21 10:30     ` Robin Murphy
@ 2015-07-22  3:00         ` Leizhen (ThunderTown)
  -1 siblings, 0 replies; 24+ messages in thread
From: Leizhen (ThunderTown) @ 2015-07-22  3:00 UTC (permalink / raw)
  To: Robin Murphy, Will Deacon, Joerg Roedel, linux-arm-kernel, iommu
  Cc: huxinwei-hv44wF8Li93QT0dZR+AlfA, Zefan Li, Tianhong Ding



On 2015/7/21 18:30, Robin Murphy wrote:
> On 21/07/15 08:30, Zhen Lei wrote:
>> Changelog:
>> v2 -> v3:
>> 1. add support for pci device hotplug, which missed in patch v2.
>> 2. only support #iommu-cells = <1>, add corresponding description in arm,smmu-v3.txt.
>> 3. add function find_smmu_by_device which extracted from find_smmu_by_node, to resolve
>>     the problem mentioned by Robin Murphy in [PATCH v2 7/9].
>>     Additionally:
>>     +    platform_set_drvdata(pdev, smmu);       //Patch v2
>>     +    dev->archdata.iommu = smmu;             //Patch v3, dev = &pdev->dev
> 
> 
> I didn't give any Reviewed-by tags, much less to revised patches that I've not even looked at yet; please see section 13 of Documentation/SubmittingPatches for what the Reviewed-by tag means.

OK. I see that now. So that Reviewed-by tags should always be given by the reviewer.

I initially thought that "Reviewed-by" should be added for who had reviewed the patch.

> 
> Robin.
> 
>>
>> v1 -> v2:
>> update the implementation of patch 1/9 according to Will Deacon's suggestion.
>> update the comment of patch 3/9 and 4/9.
>> use arm_smmu_options to skip the execution of command CMD_PREFETCH_CONFIG, see patch 5/9.
>> patch 6/9 is base on Laurent's series, to support probe deferral.
>> patch 7/9 according to Robin Murphy's suggestion, remove global variable arm_smmu_devices, thanks.
>> patch 9/9 add support for a master with multiple stream IDs.
>>
>> Zhen Lei (5):
>>    iommu/arm-smmu: to support probe deferral
>>    iommu/arm-smmu: remove arm_smmu_devices
>>    iommu/arm-smmu: rename __arm_smmu_get_pci_sid
>>    iommu/arm-smmu: add support for non-pci devices
>>    iommu/arm-smmu: describe the limitation of #iommu-cells
>>
>>   .../devicetree/bindings/iommu/arm,smmu-v3.txt      |   6 +
>>   drivers/iommu/arm-smmu-v3.c                        | 209 ++++++++++++++++-----
>>   2 files changed, 163 insertions(+), 52 deletions(-)
>>
>> -- 
>> 1.8.0
>>
>>
> 
> 
> .
> 

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH v3 0/5] iommu/arm-smmu: add support for non-pci devices
@ 2015-07-22  3:00         ` Leizhen (ThunderTown)
  0 siblings, 0 replies; 24+ messages in thread
From: Leizhen (ThunderTown) @ 2015-07-22  3:00 UTC (permalink / raw)
  To: linux-arm-kernel



On 2015/7/21 18:30, Robin Murphy wrote:
> On 21/07/15 08:30, Zhen Lei wrote:
>> Changelog:
>> v2 -> v3:
>> 1. add support for pci device hotplug, which missed in patch v2.
>> 2. only support #iommu-cells = <1>, add corresponding description in arm,smmu-v3.txt.
>> 3. add function find_smmu_by_device which extracted from find_smmu_by_node, to resolve
>>     the problem mentioned by Robin Murphy in [PATCH v2 7/9].
>>     Additionally:
>>     +    platform_set_drvdata(pdev, smmu);       //Patch v2
>>     +    dev->archdata.iommu = smmu;             //Patch v3, dev = &pdev->dev
> 
> 
> I didn't give any Reviewed-by tags, much less to revised patches that I've not even looked at yet; please see section 13 of Documentation/SubmittingPatches for what the Reviewed-by tag means.

OK. I see that now. So that Reviewed-by tags should always be given by the reviewer.

I initially thought that "Reviewed-by" should be added for who had reviewed the patch.

> 
> Robin.
> 
>>
>> v1 -> v2:
>> update the implementation of patch 1/9 according to Will Deacon's suggestion.
>> update the comment of patch 3/9 and 4/9.
>> use arm_smmu_options to skip the execution of command CMD_PREFETCH_CONFIG, see patch 5/9.
>> patch 6/9 is base on Laurent's series, to support probe deferral.
>> patch 7/9 according to Robin Murphy's suggestion, remove global variable arm_smmu_devices, thanks.
>> patch 9/9 add support for a master with multiple stream IDs.
>>
>> Zhen Lei (5):
>>    iommu/arm-smmu: to support probe deferral
>>    iommu/arm-smmu: remove arm_smmu_devices
>>    iommu/arm-smmu: rename __arm_smmu_get_pci_sid
>>    iommu/arm-smmu: add support for non-pci devices
>>    iommu/arm-smmu: describe the limitation of #iommu-cells
>>
>>   .../devicetree/bindings/iommu/arm,smmu-v3.txt      |   6 +
>>   drivers/iommu/arm-smmu-v3.c                        | 209 ++++++++++++++++-----
>>   2 files changed, 163 insertions(+), 52 deletions(-)
>>
>> -- 
>> 1.8.0
>>
>>
> 
> 
> .
> 

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v3 0/5] iommu/arm-smmu: add support for non-pci devices
  2015-07-21 10:30     ` Robin Murphy
@ 2015-07-28 12:48         ` Will Deacon
  -1 siblings, 0 replies; 24+ messages in thread
From: Will Deacon @ 2015-07-28 12:48 UTC (permalink / raw)
  To: Robin Murphy
  Cc: Tianhong Ding, huxinwei-hv44wF8Li93QT0dZR+AlfA, iommu, Zefan Li,
	laurent.pinchart-ryLnwIuWjnjg/C1BVhZhaw, Zhen Lei,
	linux-arm-kernel

On Tue, Jul 21, 2015 at 11:30:07AM +0100, Robin Murphy wrote:
> On 21/07/15 08:30, Zhen Lei wrote:
> > Changelog:
> > v2 -> v3:
> > 1. add support for pci device hotplug, which missed in patch v2.
> > 2. only support #iommu-cells = <1>, add corresponding description in arm,smmu-v3.txt.
> > 3. add function find_smmu_by_device which extracted from find_smmu_by_node, to resolve
> >     the problem mentioned by Robin Murphy in [PATCH v2 7/9].
> >     Additionally:
> >     +    platform_set_drvdata(pdev, smmu);       //Patch v2
> >     +	dev->archdata.iommu = smmu;             //Patch v3, dev = &pdev->dev
> 
> 
> I didn't give any Reviewed-by tags, much less to revised patches that 
> I've not even looked at yet; please see section 13 of 
> Documentation/SubmittingPatches for what the Reviewed-by tag means.

That said, it would be great if you could review the patches anyway ;)

Also, it looks like this is all based on Laurent's IOMMU probe deferral
series which hasn't seen any movement for a while.

Laurent: are you planning to repost that, or is it worth us picking up
the original version and bashing it into shape ourselves?

Will

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH v3 0/5] iommu/arm-smmu: add support for non-pci devices
@ 2015-07-28 12:48         ` Will Deacon
  0 siblings, 0 replies; 24+ messages in thread
From: Will Deacon @ 2015-07-28 12:48 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Jul 21, 2015 at 11:30:07AM +0100, Robin Murphy wrote:
> On 21/07/15 08:30, Zhen Lei wrote:
> > Changelog:
> > v2 -> v3:
> > 1. add support for pci device hotplug, which missed in patch v2.
> > 2. only support #iommu-cells = <1>, add corresponding description in arm,smmu-v3.txt.
> > 3. add function find_smmu_by_device which extracted from find_smmu_by_node, to resolve
> >     the problem mentioned by Robin Murphy in [PATCH v2 7/9].
> >     Additionally:
> >     +    platform_set_drvdata(pdev, smmu);       //Patch v2
> >     +	dev->archdata.iommu = smmu;             //Patch v3, dev = &pdev->dev
> 
> 
> I didn't give any Reviewed-by tags, much less to revised patches that 
> I've not even looked at yet; please see section 13 of 
> Documentation/SubmittingPatches for what the Reviewed-by tag means.

That said, it would be great if you could review the patches anyway ;)

Also, it looks like this is all based on Laurent's IOMMU probe deferral
series which hasn't seen any movement for a while.

Laurent: are you planning to repost that, or is it worth us picking up
the original version and bashing it into shape ourselves?

Will

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v3 0/5] iommu/arm-smmu: add support for non-pci devices
  2015-07-28 12:48         ` Will Deacon
@ 2015-08-04 22:50             ` Laurent Pinchart
  -1 siblings, 0 replies; 24+ messages in thread
From: Laurent Pinchart @ 2015-08-04 22:50 UTC (permalink / raw)
  To: Will Deacon
  Cc: Tianhong Ding, huxinwei-hv44wF8Li93QT0dZR+AlfA, iommu, Zefan Li,
	Zhen Lei, linux-arm-kernel

Hi Will,

On Tuesday 28 July 2015 13:48:47 Will Deacon wrote:
> On Tue, Jul 21, 2015 at 11:30:07AM +0100, Robin Murphy wrote:
> > On 21/07/15 08:30, Zhen Lei wrote:
> > > Changelog:
> > > v2 -> v3:
> > > 1. add support for pci device hotplug, which missed in patch v2.
> > > 2. only support #iommu-cells = <1>, add corresponding description in
> > > arm,smmu-v3.txt. 3. add function find_smmu_by_device which extracted
> > > from find_smmu_by_node, to resolve> > 
> > >     the problem mentioned by Robin Murphy in [PATCH v2 7/9].
> > >     Additionally:
> > >     +    platform_set_drvdata(pdev, smmu);       //Patch v2
> > >     +	dev->archdata.iommu = smmu;             //Patch v3, dev =
> > >     &pdev->dev
> > 
> > I didn't give any Reviewed-by tags, much less to revised patches that
> > I've not even looked at yet; please see section 13 of
> > Documentation/SubmittingPatches for what the Reviewed-by tag means.
> 
> That said, it would be great if you could review the patches anyway ;)
> 
> Also, it looks like this is all based on Laurent's IOMMU probe deferral
> series which hasn't seen any movement for a while.
> 
> Laurent: are you planning to repost that, or is it worth us picking up
> the original version and bashing it into shape ourselves?

I'd really appreciate if you could take it where I left it and get into shape 
for upstream. I have no time to work on IOMMU at the moment I'm afraid :-( 
I'll try to review patches though.

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH v3 0/5] iommu/arm-smmu: add support for non-pci devices
@ 2015-08-04 22:50             ` Laurent Pinchart
  0 siblings, 0 replies; 24+ messages in thread
From: Laurent Pinchart @ 2015-08-04 22:50 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Will,

On Tuesday 28 July 2015 13:48:47 Will Deacon wrote:
> On Tue, Jul 21, 2015 at 11:30:07AM +0100, Robin Murphy wrote:
> > On 21/07/15 08:30, Zhen Lei wrote:
> > > Changelog:
> > > v2 -> v3:
> > > 1. add support for pci device hotplug, which missed in patch v2.
> > > 2. only support #iommu-cells = <1>, add corresponding description in
> > > arm,smmu-v3.txt. 3. add function find_smmu_by_device which extracted
> > > from find_smmu_by_node, to resolve> > 
> > >     the problem mentioned by Robin Murphy in [PATCH v2 7/9].
> > >     Additionally:
> > >     +    platform_set_drvdata(pdev, smmu);       //Patch v2
> > >     +	dev->archdata.iommu = smmu;             //Patch v3, dev =
> > >     &pdev->dev
> > 
> > I didn't give any Reviewed-by tags, much less to revised patches that
> > I've not even looked at yet; please see section 13 of
> > Documentation/SubmittingPatches for what the Reviewed-by tag means.
> 
> That said, it would be great if you could review the patches anyway ;)
> 
> Also, it looks like this is all based on Laurent's IOMMU probe deferral
> series which hasn't seen any movement for a while.
> 
> Laurent: are you planning to repost that, or is it worth us picking up
> the original version and bashing it into shape ourselves?

I'd really appreciate if you could take it where I left it and get into shape 
for upstream. I have no time to work on IOMMU at the moment I'm afraid :-( 
I'll try to review patches though.

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v3 0/5] iommu/arm-smmu: add support for non-pci devices
  2015-08-04 22:50             ` Laurent Pinchart
@ 2015-08-05 10:45               ` Will Deacon
  -1 siblings, 0 replies; 24+ messages in thread
From: Will Deacon @ 2015-08-05 10:45 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: Tianhong Ding, huxinwei-hv44wF8Li93QT0dZR+AlfA, iommu, Zefan Li,
	Zhen Lei, linux-arm-kernel

On Tue, Aug 04, 2015 at 11:50:45PM +0100, Laurent Pinchart wrote:
> Hi Will,

Hi Laurent,

> On Tuesday 28 July 2015 13:48:47 Will Deacon wrote:
> > On Tue, Jul 21, 2015 at 11:30:07AM +0100, Robin Murphy wrote:
> > > On 21/07/15 08:30, Zhen Lei wrote:
> > > > Changelog:
> > > > v2 -> v3:
> > > > 1. add support for pci device hotplug, which missed in patch v2.
> > > > 2. only support #iommu-cells = <1>, add corresponding description in
> > > > arm,smmu-v3.txt. 3. add function find_smmu_by_device which extracted
> > > > from find_smmu_by_node, to resolve> > 
> > > >     the problem mentioned by Robin Murphy in [PATCH v2 7/9].
> > > >     Additionally:
> > > >     +    platform_set_drvdata(pdev, smmu);       //Patch v2
> > > >     +	dev->archdata.iommu = smmu;             //Patch v3, dev =
> > > >     &pdev->dev
> > > 
> > > I didn't give any Reviewed-by tags, much less to revised patches that
> > > I've not even looked at yet; please see section 13 of
> > > Documentation/SubmittingPatches for what the Reviewed-by tag means.
> > 
> > That said, it would be great if you could review the patches anyway ;)
> > 
> > Also, it looks like this is all based on Laurent's IOMMU probe deferral
> > series which hasn't seen any movement for a while.
> > 
> > Laurent: are you planning to repost that, or is it worth us picking up
> > the original version and bashing it into shape ourselves?
> 
> I'd really appreciate if you could take it where I left it and get into shape 
> for upstream. I have no time to work on IOMMU at the moment I'm afraid :-( 

No problem at all. It will probably be Robin doing most of the hacking,
since he's the platform_device guy and I'm the PCI guy in the office at
the moment :)

I think he's also currently got a rebased version of your series with
some changes on top, so stay tuned.

> I'll try to review patches though.

That would certainly be appreciated, cheers!

Will

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH v3 0/5] iommu/arm-smmu: add support for non-pci devices
@ 2015-08-05 10:45               ` Will Deacon
  0 siblings, 0 replies; 24+ messages in thread
From: Will Deacon @ 2015-08-05 10:45 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Aug 04, 2015 at 11:50:45PM +0100, Laurent Pinchart wrote:
> Hi Will,

Hi Laurent,

> On Tuesday 28 July 2015 13:48:47 Will Deacon wrote:
> > On Tue, Jul 21, 2015 at 11:30:07AM +0100, Robin Murphy wrote:
> > > On 21/07/15 08:30, Zhen Lei wrote:
> > > > Changelog:
> > > > v2 -> v3:
> > > > 1. add support for pci device hotplug, which missed in patch v2.
> > > > 2. only support #iommu-cells = <1>, add corresponding description in
> > > > arm,smmu-v3.txt. 3. add function find_smmu_by_device which extracted
> > > > from find_smmu_by_node, to resolve> > 
> > > >     the problem mentioned by Robin Murphy in [PATCH v2 7/9].
> > > >     Additionally:
> > > >     +    platform_set_drvdata(pdev, smmu);       //Patch v2
> > > >     +	dev->archdata.iommu = smmu;             //Patch v3, dev =
> > > >     &pdev->dev
> > > 
> > > I didn't give any Reviewed-by tags, much less to revised patches that
> > > I've not even looked at yet; please see section 13 of
> > > Documentation/SubmittingPatches for what the Reviewed-by tag means.
> > 
> > That said, it would be great if you could review the patches anyway ;)
> > 
> > Also, it looks like this is all based on Laurent's IOMMU probe deferral
> > series which hasn't seen any movement for a while.
> > 
> > Laurent: are you planning to repost that, or is it worth us picking up
> > the original version and bashing it into shape ourselves?
> 
> I'd really appreciate if you could take it where I left it and get into shape 
> for upstream. I have no time to work on IOMMU at the moment I'm afraid :-( 

No problem at all. It will probably be Robin doing most of the hacking,
since he's the platform_device guy and I'm the PCI guy in the office at
the moment :)

I think he's also currently got a rebased version of your series with
some changes on top, so stay tuned.

> I'll try to review patches though.

That would certainly be appreciated, cheers!

Will

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v3 0/5] iommu/arm-smmu: add support for non-pci devices
  2015-08-05 10:45               ` Will Deacon
@ 2015-08-05 10:53                   ` Laurent Pinchart
  -1 siblings, 0 replies; 24+ messages in thread
From: Laurent Pinchart @ 2015-08-05 10:53 UTC (permalink / raw)
  To: Will Deacon
  Cc: Tianhong Ding, huxinwei-hv44wF8Li93QT0dZR+AlfA, iommu, Zefan Li,
	Zhen Lei, linux-arm-kernel

Hi Will,

On Wednesday 05 August 2015 11:45:24 Will Deacon wrote:
> On Tue, Aug 04, 2015 at 11:50:45PM +0100, Laurent Pinchart wrote:
> > On Tuesday 28 July 2015 13:48:47 Will Deacon wrote:
> >> On Tue, Jul 21, 2015 at 11:30:07AM +0100, Robin Murphy wrote:
> >>> On 21/07/15 08:30, Zhen Lei wrote:
> >>>> Changelog:
> >>>> v2 -> v3:
> >>>> 1. add support for pci device hotplug, which missed in patch v2.
> >>>> 2. only support #iommu-cells = <1>, add corresponding description in
> >>>> arm,smmu-v3.txt. 3. add function find_smmu_by_device which extracted
> >>>> from find_smmu_by_node, to resolve> >
> >>>> 
> >>>>     the problem mentioned by Robin Murphy in [PATCH v2 7/9].
> >>>>     Additionally:
> >>>>     +    platform_set_drvdata(pdev, smmu);       //Patch v2
> >>>>     +	dev->archdata.iommu = smmu;             //Patch v3, dev =
> >>>>     &pdev->dev
> >>> 
> >>> I didn't give any Reviewed-by tags, much less to revised patches that
> >>> I've not even looked at yet; please see section 13 of
> >>> Documentation/SubmittingPatches for what the Reviewed-by tag means.
> >> 
> >> That said, it would be great if you could review the patches anyway ;)
> >> 
> >> Also, it looks like this is all based on Laurent's IOMMU probe deferral
> >> series which hasn't seen any movement for a while.
> >> 
> >> Laurent: are you planning to repost that, or is it worth us picking up
> >> the original version and bashing it into shape ourselves?
> > 
> > I'd really appreciate if you could take it where I left it and get into
> > shape for upstream. I have no time to work on IOMMU at the moment I'm
> > afraid :-(
>
> No problem at all. It will probably be Robin doing most of the hacking,
> since he's the platform_device guy and I'm the PCI guy in the office at
> the moment :)
> 
> I think he's also currently got a rebased version of your series with
> some changes on top, so stay tuned.

Great ! As they say here, paljon kiitoksia (yes, Finnish can be used on 
mailing lists for other purposes than cursing ;-)).

> > I'll try to review patches though.
> 
> That would certainly be appreciated, cheers!

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH v3 0/5] iommu/arm-smmu: add support for non-pci devices
@ 2015-08-05 10:53                   ` Laurent Pinchart
  0 siblings, 0 replies; 24+ messages in thread
From: Laurent Pinchart @ 2015-08-05 10:53 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Will,

On Wednesday 05 August 2015 11:45:24 Will Deacon wrote:
> On Tue, Aug 04, 2015 at 11:50:45PM +0100, Laurent Pinchart wrote:
> > On Tuesday 28 July 2015 13:48:47 Will Deacon wrote:
> >> On Tue, Jul 21, 2015 at 11:30:07AM +0100, Robin Murphy wrote:
> >>> On 21/07/15 08:30, Zhen Lei wrote:
> >>>> Changelog:
> >>>> v2 -> v3:
> >>>> 1. add support for pci device hotplug, which missed in patch v2.
> >>>> 2. only support #iommu-cells = <1>, add corresponding description in
> >>>> arm,smmu-v3.txt. 3. add function find_smmu_by_device which extracted
> >>>> from find_smmu_by_node, to resolve> >
> >>>> 
> >>>>     the problem mentioned by Robin Murphy in [PATCH v2 7/9].
> >>>>     Additionally:
> >>>>     +    platform_set_drvdata(pdev, smmu);       //Patch v2
> >>>>     +	dev->archdata.iommu = smmu;             //Patch v3, dev =
> >>>>     &pdev->dev
> >>> 
> >>> I didn't give any Reviewed-by tags, much less to revised patches that
> >>> I've not even looked at yet; please see section 13 of
> >>> Documentation/SubmittingPatches for what the Reviewed-by tag means.
> >> 
> >> That said, it would be great if you could review the patches anyway ;)
> >> 
> >> Also, it looks like this is all based on Laurent's IOMMU probe deferral
> >> series which hasn't seen any movement for a while.
> >> 
> >> Laurent: are you planning to repost that, or is it worth us picking up
> >> the original version and bashing it into shape ourselves?
> > 
> > I'd really appreciate if you could take it where I left it and get into
> > shape for upstream. I have no time to work on IOMMU at the moment I'm
> > afraid :-(
>
> No problem at all. It will probably be Robin doing most of the hacking,
> since he's the platform_device guy and I'm the PCI guy in the office at
> the moment :)
> 
> I think he's also currently got a rebased version of your series with
> some changes on top, so stay tuned.

Great ! As they say here, paljon kiitoksia (yes, Finnish can be used on 
mailing lists for other purposes than cursing ;-)).

> > I'll try to review patches though.
> 
> That would certainly be appreciated, cheers!

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2015-08-05 10:53 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-21  7:30 [PATCH v3 0/5] iommu/arm-smmu: add support for non-pci devices Zhen Lei
2015-07-21  7:30 ` Zhen Lei
     [not found] ` <1437463833-16112-1-git-send-email-thunder.leizhen-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2015-07-21  7:30   ` [PATCH v3 1/5] iommu/arm-smmu: to support probe deferral Zhen Lei
2015-07-21  7:30     ` Zhen Lei
2015-07-21  7:30   ` [PATCH v3 2/5] iommu/arm-smmu: remove arm_smmu_devices Zhen Lei
2015-07-21  7:30     ` Zhen Lei
2015-07-21  7:30   ` [PATCH v3 3/5] iommu/arm-smmu: rename __arm_smmu_get_pci_sid Zhen Lei
2015-07-21  7:30     ` Zhen Lei
2015-07-21  7:30   ` [PATCH v3 4/5] iommu/arm-smmu: add support for non-pci devices Zhen Lei
2015-07-21  7:30     ` Zhen Lei
2015-07-21  7:30   ` [PATCH v3 5/5] iommu/arm-smmu: describe the limitation of #iommu-cells Zhen Lei
2015-07-21  7:30     ` Zhen Lei
2015-07-21 10:30   ` [PATCH v3 0/5] iommu/arm-smmu: add support for non-pci devices Robin Murphy
2015-07-21 10:30     ` Robin Murphy
     [not found]     ` <55AE1F2F.3090106-5wv7dgnIgG8@public.gmane.org>
2015-07-22  3:00       ` Leizhen (ThunderTown)
2015-07-22  3:00         ` Leizhen (ThunderTown)
2015-07-28 12:48       ` Will Deacon
2015-07-28 12:48         ` Will Deacon
     [not found]         ` <20150728124847.GL29209-5wv7dgnIgG8@public.gmane.org>
2015-08-04 22:50           ` Laurent Pinchart
2015-08-04 22:50             ` Laurent Pinchart
2015-08-05 10:45             ` Will Deacon
2015-08-05 10:45               ` Will Deacon
     [not found]               ` <20150805104524.GD6092-5wv7dgnIgG8@public.gmane.org>
2015-08-05 10:53                 ` Laurent Pinchart
2015-08-05 10:53                   ` Laurent Pinchart

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.