Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp321341pxb; Wed, 11 Nov 2020 04:43:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJzzIOW4hcOWyz+/u0hJAxf89uXRGtWVjot82g8lPO2FojZMHCrGzj71l13tZu/CVhPi8O1n X-Received: by 2002:a17:906:d7b7:: with SMTP id pk23mr26091543ejb.214.1605098620842; Wed, 11 Nov 2020 04:43:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605098620; cv=none; d=google.com; s=arc-20160816; b=liyPpfjbEQoy1EP3/sl2jHZpIvHK8Cmviuvugll6vuDeGtbZDWFaad5SO9GMC6v7mD AMXSxdbVdSwlEQ+uCnGTF0OWNQjhJZZEM/8H9aYBSYgD/qQODydA/0RwoGrEpxqq+nRb GS6Qqp5J+jwTh5JegBeky62ZBWqDy1wzoxyT5CknD629sGxAOTXsRyclKPJKGPnkf8OP teo27yhmTqqMpnPuqR75NPA1nIDKjtA11kKNz2yhsDA4f7nvJfpWuaj7LAp2VoAAUTub v8eyfXrn43cMpn0ZJkXSL7Bjuj/aRSZi6vfCXErhgHwAPA6SHADMeH8bB8juLASoQFxG +cuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=aSaqAKWgY47b6j1IkavA1Mcr9HJm8/ekH5XKzvD5OJM=; b=Jl1ApdBqEAsZztgUiDiOGY/oAyc9DJJVb4LO4SnSPYWwgL1l1sC/3WTQMCF5/VSi4R KR5WP+f5P9D+E5JefKcXu6pWDb6W2xiRVmHg5XsS8y5ln5ikz7Xs7JHqwJie5odYi3ah Xj3fsNlLnddAyAj1NEQi6ZHo1TPiFlSRh4Bj2SIJnN8xxUHgWr/gV5Qjta5jBoc8Iw4W R0uDOUGGL4OMWaZ+XqWLappjHvnLD7UfVh0x+OeZT1WlSGSCJlhBBRTQXds8rI+xcm3b /RNfMRTVaSleD7pYPKPd2lv+SgkGuVXDMRRj2Vq08kcZEOzeUcDeJ8/+qjF1MCaA+TZ0 ZUPA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x19si1400932edi.214.2020.11.11.04.43.15; Wed, 11 Nov 2020 04:43:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726902AbgKKMlQ (ORCPT + 99 others); Wed, 11 Nov 2020 07:41:16 -0500 Received: from mailgw01.mediatek.com ([210.61.82.183]:34550 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726136AbgKKMlH (ORCPT ); Wed, 11 Nov 2020 07:41:07 -0500 X-UUID: dd13a01c76a14c638eacd6e28d075caa-20201111 X-UUID: dd13a01c76a14c638eacd6e28d075caa-20201111 Received: from mtkcas06.mediatek.inc [(172.21.101.30)] by mailgw01.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.14 Build 0819 with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 54121942; Wed, 11 Nov 2020 20:41:01 +0800 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs07n1.mediatek.inc (172.21.101.16) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 11 Nov 2020 20:41:00 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 11 Nov 2020 20:40:59 +0800 From: Yong Wu To: Joerg Roedel , Matthias Brugger , Rob Herring , Will Deacon , Robin Murphy CC: Krzysztof Kozlowski , Evan Green , Tomasz Figa , , , , , , , , , Nicolas Boichat , , , Greg Kroah-Hartman , Subject: [PATCH v4 14/24] iommu/mediatek: Add pm runtime callback Date: Wed, 11 Nov 2020 20:38:28 +0800 Message-ID: <20201111123838.15682-15-yong.wu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20201111123838.15682-1-yong.wu@mediatek.com> References: <20201111123838.15682-1-yong.wu@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch adds pm runtime callback. In pm runtime case, all the registers backup/restore and bclk are controlled in the pm_runtime callback, then pm_suspend is not needed in this case. runtime PM is disabled when suspend, thus we call pm_runtime_status_suspended instead of pm_runtime_suspended. And, m4u doesn't have its special pm runtime domain in previous SoC, in this case dev->power.runtime_status is RPM_SUSPENDED defaultly, thus add a "dev->pm_domain" checking for the SoC that has pm runtime domain. Signed-off-by: Yong Wu --- drivers/iommu/mtk_iommu.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index 4ce7e0883e4d..fe16053eda48 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/iommu/mtk_iommu.c @@ -802,7 +802,7 @@ static int mtk_iommu_remove(struct platform_device *pdev) return 0; } -static int __maybe_unused mtk_iommu_suspend(struct device *dev) +static int __maybe_unused mtk_iommu_runtime_suspend(struct device *dev) { struct mtk_iommu_data *data = dev_get_drvdata(dev); struct mtk_iommu_suspend_reg *reg = &data->reg; @@ -820,7 +820,7 @@ static int __maybe_unused mtk_iommu_suspend(struct device *dev) return 0; } -static int __maybe_unused mtk_iommu_resume(struct device *dev) +static int __maybe_unused mtk_iommu_runtime_resume(struct device *dev) { struct mtk_iommu_data *data = dev_get_drvdata(dev); struct mtk_iommu_suspend_reg *reg = &data->reg; @@ -847,7 +847,25 @@ static int __maybe_unused mtk_iommu_resume(struct device *dev) return 0; } +static int __maybe_unused mtk_iommu_suspend(struct device *dev) +{ + /* runtime PM is disabled when suspend in pm_runtime case. */ + if (dev->pm_domain && pm_runtime_status_suspended(dev)) + return 0; + + return mtk_iommu_runtime_suspend(dev); +} + +static int __maybe_unused mtk_iommu_resume(struct device *dev) +{ + if (dev->pm_domain && pm_runtime_status_suspended(dev)) + return 0; + + return mtk_iommu_runtime_resume(dev); +} + static const struct dev_pm_ops mtk_iommu_pm_ops = { + SET_RUNTIME_PM_OPS(mtk_iommu_runtime_suspend, mtk_iommu_runtime_resume, NULL) SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(mtk_iommu_suspend, mtk_iommu_resume) }; -- 2.18.0