From patchwork Thu Oct 20 07:22:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 78422 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp639116qge; Thu, 20 Oct 2016 00:24:02 -0700 (PDT) X-Received: by 10.98.156.7 with SMTP id f7mr18959825pfe.134.1476948242556; Thu, 20 Oct 2016 00:24:02 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q9si10931731pfg.57.2016.10.20.00.24.02; Thu, 20 Oct 2016 00:24:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933253AbcJTHXw (ORCPT + 27 others); Thu, 20 Oct 2016 03:23:52 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:23930 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753439AbcJTHXk (ORCPT ); Thu, 20 Oct 2016 03:23:40 -0400 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OFC004EE4JB3T60@mailout2.w1.samsung.com>; Thu, 20 Oct 2016 08:23:35 +0100 (BST) Received: from eusmges3.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20161020072334eucas1p239a7442a93bb4fb4f0786c8e88da8106~-LJN1DJoz0144201442eucas1p2O; Thu, 20 Oct 2016 07:23:34 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3.samsung.com (EUCPMTA) with SMTP id 5C.53.11330.6F078085; Thu, 20 Oct 2016 08:23:34 +0100 (BST) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20161020072333eucas1p25b638379091939f10b3c9eb5d89a031e~-LJNKHEQN0144101441eucas1p2Q; Thu, 20 Oct 2016 07:23:33 +0000 (GMT) X-AuditID: cbfec7f2-f79556d000002c42-b1-580870f6822e Received: from eusync2.samsung.com ( [203.254.199.212]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id E2.BD.10494.2D078085; Thu, 20 Oct 2016 08:22:58 +0100 (BST) Received: from AMDC2765.digital.local ([106.116.147.25]) by eusync2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OFC0074C4J1JF30@eusync2.samsung.com>; Thu, 20 Oct 2016 08:23:33 +0100 (BST) From: Marek Szyprowski To: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, linux-samsung-soc@vger.kernel.org Cc: Marek Szyprowski , Joerg Roedel , Inki Dae , Kukjin Kim , Krzysztof Kozlowski , Bartlomiej Zolnierkiewicz , "Rafael J. Wysocki" , Mark Brown , "Luis R. Rodriguez" , Greg Kroah-Hartman , Tomeu Vizoso , Lukas Wunner , Kevin Hilman , Tobias Jakobi , Tomasz Figa Subject: [PATCH v5 4/7] iommu/exynos: Set master device once on boot Date: Thu, 20 Oct 2016 09:22:50 +0200 Message-id: <1476948173-21093-5-git-send-email-m.szyprowski@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1476948173-21093-1-git-send-email-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAAzWSf0gTYRzGe+9ud7fVxTGXvWkJDSIw+x30lhUFZRcIWRSt/ihXHdNy03ZN ZhRp1qpFc7kiMS3TlbG5Vmsssx8zG1tZOFP7QaFRM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pS3WHrnLbnFjwlNGizOnL7FatK3+wGqxatcfRou+tZfYHIQ9nhycx+Sx4+4SRo+ds+6ye2xa 1cnmsX/uGnaPyTeWM3r8O8buseVqO4tH35ZVjB6fN8l5zGjfxhrAHeVmk5GamJJapJCal5yf kpmXbqsUGuKma6GkkJeYm2qrFKHrGxKkpFCWmFMK5BkZoAEH5wD3YCV9uwS3jMuP/zIWTBCp 6Po0n72B8YJAFyMnh4SAicTi1/cYIWwxiQv31rN1MXJxCAksYZQ4vHI7lNPEJDHn4S12kCo2 AUOJrrddYAkRgUZGiW1bJ7KDOMwCz1gkFvzYxgZSJSzgIvFk3gdmEJtFQFVi7bttYN28Ah4S k1esY4PYJydx8thkVhCbU8BTYveaXrB6IaCa9xvXMU5g5F3AyLCKUSS1tDg3PbfYSK84Mbe4 NC9dLzk/dxMjMP62Hfu5ZQdj17vgQ4wCHIxKPLwZ59gjhFgTy4orcw8xSnAwK4nwHsvhiBDi TUmsrEotyo8vKs1JLT7EaAp01ERmKdHkfGBqyCuJNzQxNLc0NDK2sDA3MlIS55364Uq4kEB6 YklqdmpqQWoRTB8TB6dUA2Pq0q8i1odDzmXLqPYl37w1RzFIrUqodp67MlPZ5ytbS1/2dZ9V ceRd76gWM7W/Xcdvn324gPgmOemudJvdrioJwWv3nHBdF/78G/e/5h+a1y8ddctattFG2nCb pn5bpc+NAs0NJp7xRvL8v/dsELf6/FTh+ungDSuastY0r9dRi94ft8JZVYmlOCPRUIu5qDgR AIIcw2DVAgAA X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20161020072333eucas1p25b638379091939f10b3c9eb5d89a031e 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: 20161020072333eucas1p25b638379091939f10b3c9eb5d89a031e X-RootMTR: 20161020072333eucas1p25b638379091939f10b3c9eb5d89a031e References: <1476948173-21093-1-git-send-email-m.szyprowski@samsung.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org To avoid possible races, set master device pointer in each SYSMMU controller once on boot. Suspend/resume callbacks now properly relies on the configured iommu domain to enable or disable SYSMMU controller. While changing the code, also update the sleep debug messages and make them conditional. Signed-off-by: Marek Szyprowski --- drivers/iommu/exynos-iommu.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) -- 1.9.1 diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c index f45b274513cc..28e570b53672 100644 --- a/drivers/iommu/exynos-iommu.c +++ b/drivers/iommu/exynos-iommu.c @@ -600,10 +600,12 @@ static int exynos_sysmmu_suspend(struct device *dev) struct sysmmu_drvdata *data = dev_get_drvdata(dev); struct device *master = data->master; - dev_dbg(dev, "suspend\n"); if (master) { - __sysmmu_disable(data); pm_runtime_put(dev); + if (data->domain) { + dev_dbg(data->sysmmu, "saving state\n"); + __sysmmu_disable(data); + } } return 0; } @@ -613,10 +615,12 @@ static int exynos_sysmmu_resume(struct device *dev) struct sysmmu_drvdata *data = dev_get_drvdata(dev); struct device *master = data->master; - dev_dbg(dev, "resume\n"); if (master) { pm_runtime_get_sync(dev); - __sysmmu_enable(data); + if (data->domain) { + dev_dbg(data->sysmmu, "restoring state\n"); + __sysmmu_enable(data); + } } return 0; } @@ -730,7 +734,6 @@ static void exynos_iommu_domain_free(struct iommu_domain *iommu_domain) __sysmmu_disable(data); data->pgtable = 0; data->domain = NULL; - data->master = NULL; list_del_init(&data->domain_node); } @@ -772,7 +775,6 @@ static void exynos_iommu_detach_device(struct iommu_domain *iommu_domain, spin_lock_irqsave(&domain->lock, flags); list_for_each_entry_safe(data, next, &domain->clients, domain_node) { __sysmmu_disable(data); - data->master = NULL; data->pgtable = 0; data->domain = NULL; list_del_init(&data->domain_node); @@ -806,7 +808,6 @@ static int exynos_iommu_attach_device(struct iommu_domain *iommu_domain, data->domain = domain; pm_runtime_get_sync(data->sysmmu); __sysmmu_enable(data); - data->master = dev; spin_lock_irqsave(&domain->lock, flags); list_add_tail(&data->domain_node, &domain->clients); @@ -1192,6 +1193,7 @@ static int exynos_iommu_of_xlate(struct device *dev, } list_add_tail(&data->owner_node, &owner->controllers); + data->master = dev; return 0; }