From patchwork Tue Nov 8 13:29:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 81316 Delivered-To: patch@linaro.org Received: by 10.140.97.165 with SMTP id m34csp1549088qge; Tue, 8 Nov 2016 05:32:10 -0800 (PST) X-Received: by 10.98.201.196 with SMTP id l65mr23424085pfk.116.1478611930425; Tue, 08 Nov 2016 05:32:10 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s66si36946507pfg.201.2016.11.08.05.32.10; Tue, 08 Nov 2016 05:32:10 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-pm-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-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752429AbcKHNb4 (ORCPT + 13 others); Tue, 8 Nov 2016 08:31:56 -0500 Received: from mailout2.w1.samsung.com ([210.118.77.12]:18841 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752001AbcKHNaX (ORCPT ); Tue, 8 Nov 2016 08:30:23 -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 <0OGB003X8S6IU130@mailout2.w1.samsung.com>; Tue, 08 Nov 2016 13:30:18 +0000 (GMT) Received: from eusmges2.samsung.com (unknown [203.254.199.241]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20161108133018eucas1p12e1c05045668ee81a724261f05434353~FFZ1OQbaY2471724717eucas1p1E; Tue, 8 Nov 2016 13:30:18 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2.samsung.com (EUCPMTA) with SMTP id 93.18.02283.963D1285; Tue, 8 Nov 2016 13:30:17 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20161108133017eucas1p29e9dc833d57d4f7951d053dab8ba6bef~FFZ0VihF60098300983eucas1p2k; Tue, 8 Nov 2016 13:30:17 +0000 (GMT) X-AuditID: cbfec7f1-f79f46d0000008eb-b1-5821d3691b16 Received: from eusync1.samsung.com ( [203.254.199.211]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 3C.97.07726.863D1285; Tue, 8 Nov 2016 13:30:16 +0000 (GMT) Received: from AMDC2765.digital.local ([106.116.147.25]) by eusync1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OGB005BFS5J9G30@eusync1.samsung.com>; Tue, 08 Nov 2016 13:30:16 +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 v6 4/7] iommu/exynos: Set master device once on boot Date: Tue, 08 Nov 2016 14:29:21 +0100 Message-id: <1478611764-6473-5-git-send-email-m.szyprowski@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1478611764-6473-1-git-send-email-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAAzWSWUwTURSGvZ3pzIBWx7biDSBK0Ug0ohAerqBEI8Z5MMblwUJMpMpYUCik Q4mgD7ixNGERaGwACatLBcEWCRACFLAFMUVZDDGyBRqLQF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GizOnL7FatK3+wGqxatcfRou+tZfYHIQ9nhycx+Sx4+4SRo+ds+6ye2xa 1cnmsX/uGnaPyTeWM3r8O8buseVqO4tH35ZVjB6fN8l5zGjfxhrAHeVmk5GamJJapJCal5yf kpmXbqsUGuKma6GkkJeYm2qrFKHrGxKkpFCWmFMK5BkZoAEH5wD3YCV9uwS3jCX/JrMXtIlU 3P/+iaWB8ZhAFyMnh4SAicSSc09YIGwxiQv31rN1MXJxCAksYZTovvuIGSQhJNDEJPGyqQbE ZhMwlOh62wVWJCKwmFGi4dAURhCHWeAYi8TinoNgHcICLhJ9E46wg9gsAqoSd4/+BYvzCrhL 3Lu1iA1inZzEyWOTWUFsTgEPiRMrHjJBbHOX+LXhGfsERt4FjAyrGEVSS4tz03OLDfWKE3OL S/PS9ZLzczcxAqNv27Gfm3cwXtoYfIhRgINRiYf3Rb9ChBBrYllxZe4hRgkOZiUR3svnFCOE eFMSK6tSi/Lji0pzUosPMZoCHTWRWUo0OR+YGPJK4g1NDM0tDY2MLSzMjYyUxHlLPlwJFxJI TyxJzU5NLUgtgulj4uCUamDkfFXnzjF3yrTMTwuF+i8c6Ts8jecMx+ddTjvMH0mtrQjWu3z6 EnM9p5+NSGgpgwFHS2YKW/bB1+tznboyL7nZrej4/0KuNdR3uvoGq7VmX174F0ybyhidwfSt PSNZ5sfxc4s+OE4SfhvwqDDWNma++PdtU932umisUZ0r8M5X79X+2H0ld9WVWIozEg21mIuK EwEinpfz1AIAAA== X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20161108133017eucas1p29e9dc833d57d4f7951d053dab8ba6bef 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: 20161108133017eucas1p29e9dc833d57d4f7951d053dab8ba6bef X-RootMTR: 20161108133017eucas1p29e9dc833d57d4f7951d053dab8ba6bef References: <1478611764-6473-1-git-send-email-m.szyprowski@samsung.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@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 -- To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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; }