From patchwork Thu Nov 24 11:20:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 9445247 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 E161E6071C for ; Thu, 24 Nov 2016 11:20:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CD09127D76 for ; Thu, 24 Nov 2016 11:20:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C1D0927D8D; Thu, 24 Nov 2016 11:20:47 +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 7C79427D7F for ; Thu, 24 Nov 2016 11:20:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964867AbcKXLUr (ORCPT ); Thu, 24 Nov 2016 06:20:47 -0500 Received: from mailout1.samsung.com ([203.254.224.24]:54307 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964851AbcKXLUq (ORCPT ); Thu, 24 Nov 2016 06:20:46 -0500 Received: from epcpsbgm2new.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OH502FMU8TW1J20@mailout1.samsung.com> for linux-samsung-soc@vger.kernel.org; Thu, 24 Nov 2016 20:20:40 +0900 (KST) X-AuditID: cbfee61b-f796f6d000004092-06-5836cd075f86 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2new.samsung.com (EPCPMTA) with SMTP id D1.0E.16530.70DC6385; Thu, 24 Nov 2016 20:20:40 +0900 (KST) Received: from AMDC2765.digital.local ([106.116.147.25]) by mmp1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OH500D6Y8U00G70@mmp1.samsung.com>; Thu, 24 Nov 2016 20:20:39 +0900 (KST) 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 3/5] iommu/exynos: Ensure that SYSMMU is added only once to its master device Date: Thu, 24 Nov 2016 12:20:18 +0100 Message-id: <1479986420-30859-4-git-send-email-m.szyprowski@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1479986420-30859-1-git-send-email-m.szyprowski@samsung.com> References: <1479986420-30859-1-git-send-email-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrBLMWRmVeSWpSXmKPExsVy+t9jAV2Os2YRBntWMllsnLGe1WLBfmuL ztkb2C3OnwcSM87vY7JYe+QuuwObx5OD85g8Nq3qZPOYfGM5o0ffllWMHp83yQWwRrnZZKQm pqQWKaTmJeenZOal2yqFhrjpWigp5CXmptoqRej6hgQpKZQl5pQCeUYGaMDBOcA9WEnfLsEt Y8vP/YwFt7kq2ndtYmlg/MnRxcjJISFgIvFi+gp2CFtM4sK99WxdjFwcQgJLGSUu989mgnB+ MUo8PniCGaSKTcBQouttFxuILSLgLnH9z3MWkCJmgQ2MEutmTAArEhaIl+hZ9oQVxGYRUJU4 cfkKE4jNK+AhsXnbZKh1chInj00Gq+EU8JSYvrGfBcQWAqq5sOot4wRG3gWMDKsYJVILkguK k9JzjfJSy/WKE3OLS/PS9ZLzczcxgkP5mfQOxsO73A8xCnAwKvHwdpiYRQixJpYVV+YeYpTg YFYS4TU4BRTiTUmsrEotyo8vKs1JLT7EaAp02ERmKdHkfGCc5ZXEG5qYm5gbG1iYW1qaGCmJ 8zbOfhYuJJCeWJKanZpakFoE08fEwSnVwChYIpJ/TfiOKYeZSmnfxi2/n50NyNpVHZTxhKnr Xc7svWour84vtWWcksopNq855rVx0Dep/DWPe+/UcR2Zn+rnlndEqk1VXs6y813E+mWLWFp2 ctjLfNvzJqJkUVvMhjeZnxLVBRZf1eU7PMdVUKJJTtVU2issb/aGQ/OlTgsWLd+Y++LWBiWW 4oxEQy3mouJEAN6o+p97AgAA X-MTR: 20000000000000000@CPGS 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 e7851cffbbee..426b1534d4d3 100644 --- a/drivers/iommu/exynos-iommu.c +++ b/drivers/iommu/exynos-iommu.c @@ -1247,7 +1247,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; @@ -1266,6 +1266,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;