Re: [PATCH v11 20/27] iommu/exynos: allow having multiple System MMUs for a master H/W
From: Cho KyongHo
Date: Tue Apr 22 2014 - 21:15:40 EST
On Tue, 22 Apr 2014 18:53:51 +0530, Shaik Ameer Basha wrote:
> Hi KyongHo Cho,
>
>
>
> On Fri, Mar 14, 2014 at 10:40 AM, Cho KyongHo <pullip.cho@xxxxxxxxxxx> wrote:
> > Some master device descriptor like fimc-is which is an abstraction
> > of very complex H/W may have multiple System MMUs. For those devices,
> > the design of the link between System MMU and its master H/W is needed
> > to be reconsidered.
> >
> > A link structure, sysmmu_list_data is introduced that provides a link
> > to master H/W and that has a pointer to the device descriptor of a
> > System MMU. Given a device descriptor of a master H/W, it is possible
> > to traverse all System MMUs that must be controlled along with the
> > master H/W.
> >
> > Signed-off-by: Cho KyongHo <pullip.cho@xxxxxxxxxxx>
> > ---
> > drivers/iommu/exynos-iommu.c | 534 ++++++++++++++++++++++++++----------------
> > 1 file changed, 333 insertions(+), 201 deletions(-)
> >
> > diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c
> > index 84ba29a..7489343 100644
> > --- a/drivers/iommu/exynos-iommu.c
> > +++ b/drivers/iommu/exynos-iommu.c
> > @@ -128,6 +128,10 @@
> > #define __master_clk_disable(data) __clk_gate_ctrl(data, clk_master, dis)
> >
>
> [snip]
>
> > +static int __init __sysmmu_init_master(struct device *dev)
> > +{
> > + int ret;
> > + int i = 0;
> > + struct device_node *node;
> > +
> > + while ((node = of_parse_phandle(dev->of_node, "mmu-masters", i++))) {
> > struct platform_device *master = of_find_device_by_node(node);
> > + struct exynos_iommu_owner *owner;
> > + struct sysmmu_list_data *list_data;
> >
> > if (!master) {
> > dev_err(dev, "%s: mmu-master '%s' not found\n",
> > __func__, node->name);
> > - return -EINVAL;
> > + ret = -EINVAL;
> > + goto err;
> > }
> >
> > - if (master->dev.archdata.iommu != NULL) {
> > - dev_err(dev, "%s: '%s' is master of other MMU\n",
> > - __func__, node->name);
> > - return -EINVAL;
> > + owner = master->dev.archdata.iommu;
> > + if (!owner) {
> > + owner = devm_kzalloc(dev, sizeof(*owner), GFP_KERNEL);
> > + if (!owner) {
> > + dev_err(dev,
> > + "%s: Failed to allocate owner structure\n",
> > + __func__);
> > + ret = -ENOMEM;
> > + goto err;
> > + }
> > +
> > + INIT_LIST_HEAD(&owner->mmu_list);
> > + INIT_LIST_HEAD(&owner->client);
> > + owner->dev = &master->dev;
> > + spin_lock_init(&owner->lock);
> > +
> > + master->dev.archdata.iommu = owner;
> > }
> >
> > + list_data = devm_kzalloc(dev, sizeof(*list_data), GFP_KERNEL);
> > + if (!list_data) {
> > + dev_err(dev,
> > + "%s: Failed to allocate sysmmu_list_data\n",
> > + __func__);
> > + ret = -ENOMEM;
> > + goto err;
> > + }
> > +
> > + INIT_LIST_HEAD(&list_data->entry);
> > + list_data->sysmmu = dev;
> > +
> > /*
> > - * archdata.iommu will be initialized with exynos_iommu_client
> > - * in sysmmu_hook_driver_register().
> > + * System MMUs are attached in the order of the presence
> > + * in device tree
> > */
> > - master->dev.archdata.iommu = dev;
> > + list_add_tail(&list_data->entry, &owner->mmu_list);
> > }
> >
> > - data->sysmmu = dev;
> > - rwlock_init(&data->lock);
> > + return 0;
> > +err:
> > + while ((node = of_parse_phandle(dev->of_node, "mmu-masters", i++))) {
>
> Don't we need to reinitialize variable 'i' here before using?
> i = 0;
>
Oh. You are right.
Thanks.
>
>
>
> > + struct platform_device *master = of_find_device_by_node(node);
> > + struct exynos_iommu_owner *owner;
> > + struct sysmmu_list_data *list_data;
> >
> > - platform_set_drvdata(pdev, data);
> > + if (!master)
> > + continue;
> >
> > - pm_runtime_enable(dev);
> > - data->runtime_active = !pm_runtime_enabled(dev);
> > + owner = master->dev.archdata.iommu;
> > + if (!owner)
> > + continue;
> >
> > - dev_dbg(dev, "Probed and initialized\n");
> > - return 0;
> > + for_each_sysmmu_list(owner->dev, list_data) {
> > + if (list_data->sysmmu == dev) {
> > + list_del(&list_data->entry);
> > + kfree(list_data);
> > + break;
> > + }
> > + }
> > + }
> > +
> > + return ret;
> > }
> >
>
> [snip]
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/