From patchwork Mon Oct 10 12:36:41 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 77434 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp1177268qge; Mon, 10 Oct 2016 05:38:21 -0700 (PDT) X-Received: by 10.157.7.200 with SMTP id 66mr18273357oto.85.1476103101835; Mon, 10 Oct 2016 05:38:21 -0700 (PDT) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id e26si21205559otc.111.2016.10.10.05.38.21 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Oct 2016 05:38:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1btZpT-0003ha-Gj; Mon, 10 Oct 2016 12:37:15 +0000 Received: from mailout4.w1.samsung.com ([210.118.77.14]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1btZpN-0003aA-1x for linux-arm-kernel@lists.infradead.org; Mon, 10 Oct 2016 12:37:10 +0000 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout4.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OEU007350D8C310@mailout4.w1.samsung.com> for linux-arm-kernel@lists.infradead.org; Mon, 10 Oct 2016 13:36:45 +0100 (BST) Received: from eusmges4.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20161010123644eucas1p1bdb0e047c075b38f1d460fd86604d528~8K9ySbZF21190811908eucas1p1M; Mon, 10 Oct 2016 12:36:44 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges4.samsung.com (EUCPMTA) with SMTP id DF.C1.28332.B5B8BF75; Mon, 10 Oct 2016 13:36:43 +0100 (BST) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20161010123643eucas1p21238ec0164722fdf112be47bfb4933c2~8K9xosznh2959529595eucas1p2T; Mon, 10 Oct 2016 12:36:43 +0000 (GMT) X-AuditID: cbfec7f4-f791c6d000006eac-d3-57fb8b5ba058 Received: from eusync1.samsung.com ( [203.254.199.211]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id F2.48.10494.43B8BF75; Mon, 10 Oct 2016 13:36:04 +0100 (BST) Received: from [106.120.52.91] by eusync1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OEU005N20D6FD90@eusync1.samsung.com>; Mon, 10 Oct 2016 13:36:43 +0100 (BST) Subject: Re: [PATCH V3 0/8] IOMMU probe deferral support To: Sricharan R , will.deacon@arm.com, robin.murphy@arm.com, joro@8bytes.org, iommu@lists.linux-foundation.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, laurent.pinchart@ideasonboard.com, tfiga@chromium.org, srinivas.kandagatla@linaro.org From: Marek Szyprowski Message-id: <12cfb59f-f7ca-d4df-eb7f-42348e357979@samsung.com> Date: Mon, 10 Oct 2016 14:36:41 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-version: 1.0 In-reply-to: <1475600632-21289-1-git-send-email-sricharan@codeaurora.org> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFl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afJnYwWLRduwYq8Xn1n9sFi8/nmBx4PJ4cnAek8eaeWsY PWY3XGTxuNzXy+Qxu2Mmq8eda3vYPDYvqfeYfGM5o8fnTXIBnFFuNhmpiSmpRQqpecn5KZl5 6bZKoSFuuhZKCnmJuam2ShG6viFBSgpliTmlQJ6RARpwcA5wD1bSt0twy2jrOcNccM+gYvfN eawNjKtVuxg5OCQETCRe3GTvYuQEMsUkLtxbz9bFyMUhJLCEUWLdxq2sIAkhgWeMEseXeYHY wgIWEg/m/AaLiwisYZLY9TwBomEeo8TGyYvAJrEJGEp0ve1iA7F5BewkGtqnMYHYLAKqEvOn vACrERWIkbj+7BFUjaDEj8n3WEBsTgFPif8vToDZzAJmEl9eHmaFsOUlNq95yzyBkX8WkpZZ SMpmISlbwMi8ilEktbQ4Nz232EivODG3uDQvXS85P3cTIzAKtx37uWUHY9e74EOMAhyMSjy8 Lyt/hQuxJpYVV+YeYpTgYFYS4Z3Y8TtciDclsbIqtSg/vqg0J7X4EKMp0BMTmaVEk/OBCSKv JN7QxNDc0tDI2MLC3MhISZx36ocr4UIC6YklqdmpqQWpRTB9TBycUg2MS7fX+jAJrLnbtJpb f/kFJ47UqfoWtxmuJkmZP1+x1Pf6IS/7u5v9NwhbTuYwfr1q0RpP+fAzcb/31x+SeJTR8ED1 csj9znPnZjz7vOuX3emWXqkzSwOqxDoX182TCJtdcfDrpRemuk8Nqn+6vShYG+f541zo6Uk/ RDYs77zn/WSSyculf+beva/EUpyRaKjFXFScCAAyHGz92AIAAA== X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20161010123643eucas1p21238ec0164722fdf112be47bfb4933c2 X-Msg-Generator: CA X-Sender-IP: 182.198.249.180 X-Local-Sender: =?UTF-8?B?TWFyZWsgU3p5cHJvd3NraRtTUlBPTC1LZXJuZWwgKFRQKRs=?= =?UTF-8?B?7IK87ISx7KCE7J6QG1NlbmlvciBTb2Z0d2FyZSBFbmdpbmVlcg==?= X-Global-Sender: =?UTF-8?B?TWFyZWsgU3p5cHJvd3NraRtTUlBPTC1LZXJuZWwgKFRQKRtT?= =?UTF-8?B?YW1zdW5nIEVsZWN0cm9uaWNzG1NlbmlvciBTb2Z0d2FyZSBFbmdpbmVlcg==?= X-Sender-Code: =?UTF-8?B?QzEwG0VIURtDMTBDRDAyQ0QwMjczOTI=?= CMS-TYPE: 201P X-HopCount: 7 X-CMS-RootMailID: 20161004170414eucas1p141bebe16e1bf241862833e7ad0270c72 X-RootMTR: 20161004170414eucas1p141bebe16e1bf241862833e7ad0270c72 References: <1475600632-21289-1-git-send-email-sricharan@codeaurora.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161010_053709_291914_E9285AF7 X-CRM114-Status: GOOD ( 30.54 ) X-Spam-Score: -8.3 (--------) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-8.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [210.118.77.14 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [210.118.77.14 listed in wl.mailspike.net] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -1.4 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org Hi Sricharan, On 2016-10-04 19:03, Sricharan R wrote: > Initial post from Laurent Pinchart[1]. This is > series calls the dma ops configuration for the devices > at a generic place so that it works for all busses. > The dma_configure_ops for a device is now called during > the device_attach callback just before the probe of the > bus/driver is called. Similarly dma_deconfigure is called during > device/driver_detach path. > > > pci_bus_add_devices (platform/amba)(_device_create/driver_register) > | | > pci_bus_add_device (device_add/driver_register) > | | > device_attach device_initial_probe > | | > __device_attach_driver __device_attach_driver > | > driver_probe_device > | > really_probe > | > dma_configure > > Similarly on the device/driver_unregister path __device_release_driver is > called which inturn calls dma_deconfigure. > > If the ACPI bus code follows the same, we can add acpi_dma_configure > at the same place as of_dma_configure. > > This series is based on the recently merged Generic DT bindings for > PCI IOMMUs and ARM SMMU from Robin Murphy robin.murphy@arm.com [2] > > This time tested this with platform and pci device for probe deferral > and reprobe on arm64 based platform. There is an issue on the cleanup > path for arm64 though, where there is WARN_ON if the dma_ops is reset while > device is attached to an domain in arch_teardown_dma_ops. > But with iommu_groups created from the iommu driver, the device is always > attached to a domain/default_domain. So so the WARN has to be removed/handled > probably. Thanks for continuing work on this feature! Your can add my: Tested-by: Marek Szyprowski It works fine with Exynos SYSMMU driver, although a patch is needed to fix infinite loop due to list corruption (same element is added twice if master device fails with deferred probe): From: Marek Szyprowski Date: Mon, 10 Oct 2016 14:22:42 +0200 Subject: [PATCH] iommu/exynos: ensure that sysmmu is added only once to its master Since adding IOMMU deferred probing support, of_xlate() callback might be called more than once for given master device (for example it happens when masters device driver fails with EPROBE_DEFER), so ensure that SYSMMU controller is added to its master device (owner) only once. Signed-off-by: Marek Szyprowski --- drivers/iommu/exynos-iommu.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) -- 1.9.1 > > Previous post of this series [3]. > > [V3] > * Removed the patch to split dma_masks/dma_ops configuration separately > based on review comments that both masks and ops are required only > during the device probe time. > > * Reworked the series based on Generic DT bindings series [2]. > > * Added call to iommu's remove_device in the cleanup path for arm and arm64. > > * Removed the notifier trick in arm64 to handle early device registration. > > * Added reset of dma_ops in cleanup path for arm based on comments. > > * Fixed the pci_iommu_configure path and tested with PCI device as well. > > * Fixed a bug to return the correct iommu_ops from patch 7 [4] in last post. > > * Fixed few other cosmetic comments. > > [V2] > * Updated the Initial post to call dma_configure/deconfigure from generic code > > * Added iommu add_device callback from of_iommu_configure path > > [V1] > * Initial post > > [1] http://lists.linuxfoundation.org/pipermail/iommu/2015-May/013016.html > [2] http://www.spinics.net/lists/devicetree/msg142943.html > [3] https://www.mail-archive.com/iommu@lists.linux-foundation.org/msg13941.html > [4] https://www.mail-archive.com/iommu@lists.linux-foundation.org/msg13940.html > > > > Laurent Pinchart (4): > arm: dma-mapping: Don't override dma_ops in arch_setup_dma_ops() > of: dma: Move range size workaround to of_dma_get_range() > of: dma: Make of_dma_deconfigure() public > iommu: of: Handle IOMMU lookup failure with deferred probing or error > > Sricharan R (4): > drivers: platform: Configure dma operations at probe time > arm: dma-mapping: Reset the device's dma_ops > arm/arm64: dma-mapping: Call iommu's remove_device callback during > device detach > arm64: dma-mapping: Remove the notifier trick to handle early setting > of dma_ops > > arch/arm/mm/dma-mapping.c | 18 ++++++++ > arch/arm64/mm/dma-mapping.c | 107 +++++--------------------------------------- > drivers/base/dd.c | 10 +++++ > drivers/base/dma-mapping.c | 11 +++++ > drivers/iommu/of_iommu.c | 47 +++++++++++++++++-- > drivers/of/address.c | 20 ++++++++- > drivers/of/device.c | 34 +++++++------- > drivers/of/platform.c | 9 ---- > drivers/pci/probe.c | 5 +-- > include/linux/dma-mapping.h | 3 ++ > include/linux/of_device.h | 7 ++- > 11 files changed, 138 insertions(+), 133 deletions(-) > Best regards -- Marek Szyprowski, PhD Samsung R&D Institute Poland _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c index 30808e91b775..1525a86eb829 100644 --- a/drivers/iommu/exynos-iommu.c +++ b/drivers/iommu/exynos-iommu.c @@ -1253,7 +1253,7 @@ static int exynos_iommu_of_xlate(struct device *dev, { struct exynos_iommu_owner *owner = dev->archdata.iommu; struct platform_device *sysmmu = of_find_device_by_node(spec->np); - struct sysmmu_drvdata *data; + struct sysmmu_drvdata *data, *entry; if (!sysmmu) return -ENODEV; @@ -1271,6 +1271,10 @@ static int exynos_iommu_of_xlate(struct device *dev, dev->archdata.iommu = owner; } + list_for_each_entry(entry, &owner->controllers, owner_node) + if (entry == data) + return 0; + list_add_tail(&data->owner_node, &owner->controllers); return 0; }