From patchwork Mon Jan 9 12:03:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 9504533 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3628A60710 for ; Mon, 9 Jan 2017 12:05:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 13E912848D for ; Mon, 9 Jan 2017 12:05:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 08662284BB; Mon, 9 Jan 2017 12:05:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9B33D284C0 for ; Mon, 9 Jan 2017 12:05:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752275AbdAIMF1 (ORCPT ); Mon, 9 Jan 2017 07:05:27 -0500 Received: from mailout3.w1.samsung.com ([210.118.77.13]:16310 "EHLO mailout3.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751517AbdAIMEP (ORCPT ); Mon, 9 Jan 2017 07:04:15 -0500 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout3.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OJI00LO5HJ2LM30@mailout3.w1.samsung.com> for linux-samsung-soc@vger.kernel.org; Mon, 09 Jan 2017 12:04:14 +0000 (GMT) Received: from eusmges4.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20170109120413eucas1p1cba6ec55b9208078fae1e8f50fff4567~YGOYIZ8Ao1250012500eucas1p1H; Mon, 9 Jan 2017 12:04:13 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges4.samsung.com (EUCPMTA) with SMTP id 8E.8C.28517.D3C73785; Mon, 9 Jan 2017 12:04:13 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20170109120412eucas1p27f3aab2d42712a9783d79bb4e06d01d5~YGOXc6I712696226962eucas1p2s; Mon, 9 Jan 2017 12:04:12 +0000 (GMT) X-AuditID: cbfec7f4-f79716d000006f65-74-58737c3dcbbb Received: from eusync3.samsung.com ( [203.254.199.213]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id FB.FC.10233.43C73785; Mon, 9 Jan 2017 12:04:04 +0000 (GMT) Received: from AMDC2765.digital.local ([106.116.147.25]) by eusync3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OJI00KQMHIPLS60@eusync3.samsung.com>; Mon, 09 Jan 2017 12:04:12 +0000 (GMT) From: Marek Szyprowski To: iommu@lists.linux-foundation.org, linux-samsung-soc@vger.kernel.org Cc: Marek Szyprowski , Joerg Roedel , Krzysztof Kozlowski , Bartlomiej Zolnierkiewicz Subject: [PATCH v2 3/4] iommu/exynos: Ensure that SYSMMU is added only once to its master device Date: Mon, 09 Jan 2017 13:03:55 +0100 Message-id: <1483963436-29803-4-git-send-email-m.szyprowski@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1483963436-29803-1-git-send-email-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrCIsWRmVeSWpSXmKPExsWy7djP87q2NcURBtdu8lpsnLGe1WLBfmuL ztkb2C3OnwcSM87vY7JYe+QuuwObx5OD85g8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v8sCUsUmYCjR9baLDcQWEXCXuP7nOQtIEbPABkaJdTMmgI0SFkiSaFn3iQnEZhFQlVj6 phesmVfAQ2LCojtMEOvkJE4em8wKYnMKeErc//kDLC4EVHN0xU/2CYy8CxgZVjGKpJYW56bn FhvpFSfmFpfmpesl5+duYgSG8LZjP7fsYOx6F3yIUYCDUYmHd4JXUYQQa2JZcWXuIUYJDmYl Ed6FFcURQrwpiZVVqUX58UWlOanFhxhNgY6ayCwlmpwPjK+8knhDE0NzS0MjYwsLcyMjJXHe qR+uhAsJpCeWpGanphakFsH0MXFwSjUwnth0PMHs0+6krcq9/S83lm2zl2c4e9vk1euDiq8O 8sjOzvHvXPKddbuITZrKpfIHwRk8OtxZ7/5kTA38Ux46P9H9/CvTLB62uBjvKUbZh1MeyWSk JcZ9CT0x8ZxT8Azrh1PX1G9gv33WyDj29ve2vXcdWvbvOtBXsKw6oe3grZZVzMVCUbG/lViK MxINtZiLihMBDfuzUXcCAAA= X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20170109120412eucas1p27f3aab2d42712a9783d79bb4e06d01d5 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: 20170109120412eucas1p27f3aab2d42712a9783d79bb4e06d01d5 X-RootMTR: 20170109120412eucas1p27f3aab2d42712a9783d79bb4e06d01d5 References: <1483963436-29803-1-git-send-email-m.szyprowski@samsung.com> Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch prepares Exynos IOMMU driver for deferred probing support. Once it gets added, of_xlate() callback might be called more than once for the same SYSMMU controller and master device (for example it happens when masters device driver fails with EPROBE_DEFER). This patch adds a check, which ensures 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(-) diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c index b0d537e6a445..8bf5a06a6c01 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; @@ -1272,6 +1272,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); data->master = dev;