Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752855AbaDWBP3 (ORCPT ); Tue, 22 Apr 2014 21:15:29 -0400 Received: from mailout1.samsung.com ([203.254.224.24]:64908 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751314AbaDWBP0 (ORCPT ); Tue, 22 Apr 2014 21:15:26 -0400 X-AuditID: cbfee691-b7f3e6d000002ce8-5c-5357142cb307 Date: Wed, 23 Apr 2014 10:15:24 +0900 From: Cho KyongHo To: Shaik Ameer Basha Cc: Linux ARM Kernel , Linux DeviceTree , Linux IOMMU , Linux Kernel , Linux Samsung SOC , Antonios Motakis , Grant Grundler , Joerg Roedel , Kukjin Kim , Prathyush , Rahul Sharma , Sachin Kamat , Sylwester Nawrocki , Tomasz Figa , Varun Sethi Subject: Re: [PATCH v11 20/27] iommu/exynos: allow having multiple System MMUs for a master H/W Message-id: <20140423101524.4145e9f88300293e0cea92c4@samsung.com> In-reply-to: References: <20140314141050.c8bedcb66532d277c496796d@samsung.com> X-Mailer: Sylpheed 3.3.0 (GTK+ 2.10.14; i686-pc-mingw32) MIME-version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpileLIzCtJLcpLzFFi42I5/e+Zvq6OSHiwwYtpNhZ37p5jtZh/BEi8 OvKDyWLBfmuLztkb2C16F1xls9j0+BqrxeVdc9gsZpzfx2RxYcVGdospiw6zWhx+085qcfJP L6PFup2T2C3Wz3jNYjHz1hoWBwGPJwfnMXnMbrjI4vHvcD+Tx85Zd9k97lzbw+axeUm9x+Qb yxk9+rasYvT4vEnO48rRM0wBXFFcNimpOZllqUX6dglcGfvnxBfM0a642f2csYHxuGQXIyeH hICJRPvaK0wQtpjEhXvr2boYuTiEBJYxSvzp38rYxcgBVrRmOgdEfBGjxKrjC5khnMlMEjPm XWAB6WYRUJV49rWBEcRmE9CSWD33OJgtIqA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JGiAUdjBLT2rcwQ5xhIXGhqYMdokFQ4sfkeywQQ7Uk Nm9rYoWw5SU2r3nLPIFRYBaSsllIymYhKVvAyLyKUTS1ILmgOCk910ivODG3uDQvXS85P3cT Izi5PJPewbiqweIQowAHoxIPr8TysGAh1sSy4srcQ4wSHMxKIrwzPwKFeFMSK6tSi/Lji0pz UosPMSYDg2Mis5Rocj4w8eWVxBsam5gZWRqZWRiZmJuTJqwkznuw1TpQSCA9sSQ1OzW1ILUI ZgsTB6dUA6MrU45b/Gq2kOTAH0nPT37Yz/7UxGKhhqDq6c8fzUI2M390LSpMXx5TUxr8oyf6 t+67BSlenL2CzRLVJ3o2eQmE3zo/7+ryV2LC/32eKRa0X1I9bGSxWEzgnoRgN6P5h5vtdaYF j8zuSVdlMP97unCR9LKynSwtLNLH6+IW1mavUM7Xf8VUo8RSnJFoqMVcVJwIALae5fpyAwAA DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 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 > > --- > > 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@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/