From patchwork Tue Nov 8 13:29:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 81315 Delivered-To: patch@linaro.org Received: by 10.140.97.165 with SMTP id m34csp1548956qge; Tue, 8 Nov 2016 05:31:55 -0800 (PST) X-Received: by 10.99.6.134 with SMTP id 128mr18671116pgg.53.1478611915867; Tue, 08 Nov 2016 05:31:55 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r12si37012404pfg.7.2016.11.08.05.31.55; Tue, 08 Nov 2016 05:31:55 -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 S1752365AbcKHNbv (ORCPT + 27 others); Tue, 8 Nov 2016 08:31:51 -0500 Received: from mailout4.w1.samsung.com ([210.118.77.14]:22271 "EHLO mailout4.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752006AbcKHNaX (ORCPT ); Tue, 8 Nov 2016 08:30:23 -0500 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout4.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OGB00FPKS6KYI30@mailout4.w1.samsung.com>; Tue, 08 Nov 2016 13:30:20 +0000 (GMT) Received: from eusmges3.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20161108133020eucas1p191a81b01c71264d1feada5bb69757bb2~FFZ3UriBW0406704067eucas1p1x; Tue, 8 Nov 2016 13:30:20 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3.samsung.com (EUCPMTA) with SMTP id F5.6C.11330.B63D1285; Tue, 8 Nov 2016 13:30:20 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20161108133019eucas1p1be275492ba670030324a164320866008~FFZ2qFK-N2471724717eucas1p1M; Tue, 8 Nov 2016 13:30:19 +0000 (GMT) X-AuditID: cbfec7f2-f79556d000002c42-24-5821d36b03ae Received: from eusync1.samsung.com ( [203.254.199.211]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 78.76.10494.E43D1285; Tue, 8 Nov 2016 13:29:50 +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:19 +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 7/7] iommu/exynos: Use device dependency links to control runtime pm Date: Tue, 08 Nov 2016 14:29:24 +0100 Message-id: <1478611764-6473-8-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: H4sIAAAAAAAAAzWSXUhTYRjHe3fOtuNqcdiGPZlWLurC0JK6eMmKPoQO0kU30eqmVh5Uckt3 VFJLRqHWRKdz6XBqS9NkGpaKmmXzY22W4cpl6sU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jwlNGizOnL7FatK3+wGqxatcfRou+tZfYHIQ9nhycx+Sx4+4SRo+ds+6ye2xa 1cnmsX/uGnaPyTeWM3r8O8buseVqO4tH35ZVjB6fN8l5zGjfxhrAHeVmk5GamJJapJCal5yf kpmXbqsUGuKma6GkkJeYm2qrFKHrGxKkpFCWmFMK5BkZoAEH5wD3YCV9uwS3jHkNegXfxSoe L5zN3sA4R7iLkZNDQsBE4vjpHUwQtpjEhXvr2boYuTiEBJYwSvy+8ZsZwmlikvg5YwobSBWb gKFE19susCoRgcWMEg2HpjCCOMwCx1gkFvccZAapEhaIlFg9fT1YB4uAqsTutqNANgcHr4C7 xLHn1RDr5CROHpvMCmJzCnhInFjxEOwMIaCSXxuesU9g5F3AyLCKUSS1tDg3PbfYSK84Mbe4 NC9dLzk/dxMjMPa2Hfu5ZQdj17vgQ4wCHIxKPLwv+hUihFgTy4orcw8xSnAwK4nwXj6nGCHE m5JYWZValB9fVJqTWnyI0RToponMUqLJ+cC0kFcSb2hiaG5paGRsYWFuZKQkzjv1w5VwIYH0 xJLU7NTUgtQimD4mDk6pBsbQ1CsSa869e/RMbWV4sa6QxgL7phqBJRsTfA0+J8lskrq3/c6/ mUzzSto9Jj4qd5uWr7TzLvcF/9rHKxglDzfps+x0LumY7H3F2fnbpHO1S4XZPc8lnYl7dnWi aGN408p4y+WzJa8Eizv4BifYHdNz+zsvr4S90rOM6ezfqeblbRqrY15GLlJiKc5INNRiLipO BADef/cU0wIAAA== X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20161108133019eucas1p1be275492ba670030324a164320866008 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: 20161108133019eucas1p1be275492ba670030324a164320866008 X-RootMTR: 20161108133019eucas1p1be275492ba670030324a164320866008 References: <1478611764-6473-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 This patch uses recently introduced device dependency links to track the runtime pm state of the master's device. The goal is to let SYSMMU controller device's runtime PM to follow the runtime PM state of the respective master's device. This way each SYSMMU controller is active only when its master's device is active and can properly restore or save its state instead on runtime PM transition of master's device. This approach replaces old behavior, when SYSMMU controller was set to runtime active once after attaching to the master device. In the new approach SYSMMU controllers no longer prevents respective power domains to be turned off when master's device is not being used. The dependency links also enforces proper order of suspending/restoring devices during system sleep transition, so there is no more need to use LATE_SYSTEM_SLEEP_PM_OPS-based workaround for ensuring that SYSMMUs are suspended after their master devices. Signed-off-by: Marek Szyprowski --- drivers/iommu/exynos-iommu.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) -- 1.9.1 diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c index 5e6d7bb..4b05a15 100644 --- a/drivers/iommu/exynos-iommu.c +++ b/drivers/iommu/exynos-iommu.c @@ -633,8 +633,8 @@ static int __maybe_unused exynos_sysmmu_resume(struct device *dev) static const struct dev_pm_ops sysmmu_pm_ops = { SET_RUNTIME_PM_OPS(exynos_sysmmu_suspend, exynos_sysmmu_resume, NULL) - SET_LATE_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, - pm_runtime_force_resume) + SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, + pm_runtime_force_resume) }; static const struct of_device_id sysmmu_of_match[] __initconst = { @@ -781,10 +781,6 @@ static void exynos_iommu_detach_device(struct iommu_domain *iommu_domain, if (!has_sysmmu(dev) || owner->domain != iommu_domain) return; - list_for_each_entry(data, &owner->controllers, owner_node) { - pm_runtime_put_sync(data->sysmmu); - } - mutex_lock(&owner->rpm_lock); list_for_each_entry(data, &owner->controllers, owner_node) { @@ -848,10 +844,6 @@ static int exynos_iommu_attach_device(struct iommu_domain *iommu_domain, mutex_unlock(&owner->rpm_lock); - list_for_each_entry(data, &owner->controllers, owner_node) { - pm_runtime_get_sync(data->sysmmu); - } - dev_dbg(dev, "%s: Attached IOMMU with pgtable %pa\n", __func__, &pagetable); @@ -1232,6 +1224,14 @@ static int exynos_iommu_of_xlate(struct device *dev, list_add_tail(&data->owner_node, &owner->controllers); data->master = dev; + + /* + * SYSMMU will be runtime activated via device link (dependency) to its + * master device, so there are no direct calls to pm_runtime_get/put + * in this driver. + */ + device_link_add(dev, data->sysmmu, DL_FLAG_PM_RUNTIME); + return 0; }