From patchwork Mon Nov 14 10:08:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 82037 Delivered-To: patch@linaro.org Received: by 10.140.97.165 with SMTP id m34csp932605qge; Mon, 14 Nov 2016 02:10:49 -0800 (PST) X-Received: by 10.99.100.132 with SMTP id y126mr67150044pgb.177.1479118249496; Mon, 14 Nov 2016 02:10:49 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o20si21634477pgn.236.2016.11.14.02.10.49; Mon, 14 Nov 2016 02:10:49 -0800 (PST) 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 S933258AbcKNKKg (ORCPT + 26 others); Mon, 14 Nov 2016 05:10:36 -0500 Received: from mailout2.w1.samsung.com ([210.118.77.12]:31554 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753671AbcKNKJQ (ORCPT ); Mon, 14 Nov 2016 05:09:16 -0500 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OGM008Z3MVCYK00@mailout2.w1.samsung.com>; Mon, 14 Nov 2016 10:09:12 +0000 (GMT) Received: from eusmges2.samsung.com (unknown [203.254.199.241]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20161114100912eucas1p1abaad5c2f51673a2fd3636ada3046f2a~G4h9sdlVT3209332093eucas1p1W; Mon, 14 Nov 2016 10:09:12 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2.samsung.com (EUCPMTA) with SMTP id 5A.10.02283.74D89285; Mon, 14 Nov 2016 10:09:11 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20161114100911eucas1p15b495af346ea89af2f10bb3267b2cdc5~G4h8-wgkX3209332093eucas1p1Q; Mon, 14 Nov 2016 10:09:11 +0000 (GMT) X-AuditID: cbfec7f1-f79f46d0000008eb-46-58298d47b2d8 Received: from eusync4.samsung.com ( [203.254.199.214]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id C4.B3.07726.B4D89285; Mon, 14 Nov 2016 10:09:15 +0000 (GMT) Received: from AMDC2765.digital.local ([106.116.147.25]) by eusync4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OGM00IDHMV2LBA0@eusync4.samsung.com>; Mon, 14 Nov 2016 10:09:11 +0000 (GMT) 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, Joerg Roedel Cc: Marek Szyprowski , 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 v7 4/7] iommu/exynos: Set master device once on boot Date: Mon, 14 Nov 2016 11:08:09 +0100 Message-id: <1479118092-1365-5-git-send-email-m.szyprowski@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1479118092-1365-1-git-send-email-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAAzWSfUhTUQDFu3tvb8/V4rENu/gRtIiyyDQSL1qWIfUogv5ripAjHyo5lT2V 9B/NSrfl1BzmUldWprCK1VpiUfnR3KyF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t7gx4SmjxZnTl1gt2lZ/YLVYtesPo0Xf2ktsDsIeTw7OY/LYcXcJo8fOWXfZPTat 6mTz2D93DbvH5BvLGT3+HWP32HK1ncWjb8sqRo/Pm+Q8ZrRvYw3gjnKzyUhNTEktUkjNS85P ycxLt1UKDXHTtVBSyEvMTbVVitD1DQlSUihLzCkF8owM0ICDc4B7sJK+XYJbxpJ/k9kL2kQq 7n//xNLAeEygi5GTQ0LAROLP/Z3MELaYxIV769lAbCGBJYwS7S8Nuhi5gOwmJomud21gRWwC hhJdb7vYQBIiAosZJRoOTWEEcZgFjrFILO45CFYlLOAi8XnyJTCbRUBV4vK3PkYQm1fAXWLZ 4x5WiHVyEiePTQazOQU8JOZ+/sQCsdpd4url/cwTGHkXMDKsYhRJLS3OTc8tNtQrTswtLs1L 10vOz93ECIy+bcd+bt7BeGlj8CFGAQ5GJR7ejnyNCCHWxLLiytxDjBIczEoivMo9mhFCvCmJ lVWpRfnxRaU5qcWHGE2BjprILCWanA9MDHkl8YYmhuaWhkbGFhbmRkZK4rwlH66ECwmkJ5ak ZqemFqQWwfQxcXBKNTBm90++FuX22CSa87D091kfpxTva4s+2//QvT37bWLz7Z7NrXejDy3/ OPmt4YJNRpJNhYcX72syXbHhyb6d7AKRs/VCjX/H3d60uMInf9mGyNn7HvrM8jt0J4b9VM2j 37G8Ro9+BpVM2/3YWrPMMWNO0PzUWfs8tHbe2v9C09XM+lOi3vTLpyI0lFiKMxINtZiLihMB /IfZa9QCAAA= X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20161114100911eucas1p15b495af346ea89af2f10bb3267b2cdc5 X-Msg-Generator: CA X-Sender-IP: 182.198.249.179 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: 20161114100911eucas1p15b495af346ea89af2f10bb3267b2cdc5 X-RootMTR: 20161114100911eucas1p15b495af346ea89af2f10bb3267b2cdc5 References: <1479118092-1365-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 f45b274..28e570b 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; }