From patchwork Mon Nov 14 10:08:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 82035 Delivered-To: patch@linaro.org Received: by 10.140.97.165 with SMTP id m34csp932601qge; Mon, 14 Nov 2016 02:10:48 -0800 (PST) X-Received: by 10.99.42.80 with SMTP id q77mr27935123pgq.170.1479118248723; Mon, 14 Nov 2016 02:10:48 -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.48; Mon, 14 Nov 2016 02:10:48 -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 S932698AbcKNKK0 (ORCPT + 26 others); Mon, 14 Nov 2016 05:10:26 -0500 Received: from mailout1.w1.samsung.com ([210.118.77.11]:24828 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753005AbcKNKJS (ORCPT ); Mon, 14 Nov 2016 05:09:18 -0500 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OGM0070CMVFMP10@mailout1.w1.samsung.com>; Mon, 14 Nov 2016 10:09:15 +0000 (GMT) Received: from eusmges1.samsung.com (unknown [203.254.199.239]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20161114100914eucas1p2269035261eea0c6ec34f82ce5fce3e78~G4iAAIDVJ2464424644eucas1p20; Mon, 14 Nov 2016 10:09:14 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1.samsung.com (EUCPMTA) with SMTP id 0C.DE.23383.B4D89285; Mon, 14 Nov 2016 10:09:15 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20161114100913eucas1p13d380f351985e8401a054c48bd13e299~G4h-UFfqy2318423184eucas1p1R; Mon, 14 Nov 2016 10:09:13 +0000 (GMT) X-AuditID: cbfec7ef-f79e76d000005b57-ee-58298d4b1831 Received: from eusync4.samsung.com ( [203.254.199.214]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id DD.22.10494.E2D89285; Mon, 14 Nov 2016 10:08:46 +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:13 +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 7/7] iommu/exynos: Use device dependency links to control runtime pm Date: Mon, 14 Nov 2016 11:08:12 +0100 Message-id: <1479118092-1365-8-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: H4sIAAAAAAAAAz2Se0hTURzHO7t3d3fWrcscdfD1x6RILUv0j0PKyJC6UWJFkFqgIy8q+dxV UUkaiq/5zGGK5gNmBVMxdekS34ommistNU3FV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ZnTl1gt2lZ/YLVYtesPo0Xf2ktsDsIeTw7OY/LYcXcJo8fOWXfZPTat 6mTz2D93DbvH5BvLGT3+HWP32HK1ncWjb8sqRo/Pm+Q8ZrRvYw3gjnKzyUhNTEktUkjNS85P ycxLt1UKDXHTtVBSyEvMTbVVitD1DQlSUihLzCkF8owM0ICDc4B7sJK+XYJbxpO9j5kKHklU 7Ph2nK2B8ZZIFyMHh4SAicT+hsIuRk4gU0ziwr31bF2MXBxCAksYJY5NP8sMkhASaGKSeLvA CMRmEzCU6HrbBVYkIrCYUaLh0BRGEIdZ4BiLxOKeg2AdwgKREte272EEsVkEVCV6PvxgA7F5 Bdwl9i15yQixTk7i5LHJrCA2p4CHxNzPn1ggtrlLXL28n3kCI+8CRoZVjCKppcW56bnFRnrF ibnFpXnpesn5uZsYgbG37djPLTsYu94FH2IU4GBU4uHtyNeIEGJNLCuuzD3EKMHBrCTCq9yj GSHEm5JYWZValB9fVJqTWnyI0RToqInMUqLJ+cC0kFcSb2hiaG5paGRsYWFuZKQkzjv1w5Vw IYH0xJLU7NTUgtQimD4mDk6pBsZDhqXFC5TdTs3VmJDU9291uOvi441n30kp70k0ePdcQe1d 3s4T8QHcDArR6k2ilf4lRXvPsBa31e/2ebDtoObGF6utbvTp29RInlgvv6A8YXJ3Wbx+u2Wk VC0f339/+xkmU+MZVou/nvN9K+9lrz9zJihP3FzlZ3A/1/9UxfEZvL47N6vMKlZiKc5INNRi LipOBABBF0ku0wIAAA== X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20161114100913eucas1p13d380f351985e8401a054c48bd13e299 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: 20161114100913eucas1p13d380f351985e8401a054c48bd13e299 X-RootMTR: 20161114100913eucas1p13d380f351985e8401a054c48bd13e299 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 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. This patch reduces total power consumption of idle system, because most power domains can be finally turned off. For example, on Exynos 4412 based Odroid U3 this patch reduces power consuption from 136mA to 130mA at 5V (by 4.4%). The dependency links also enforce 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; }