Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp3994497pxu; Wed, 9 Dec 2020 06:00:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJxyE2isDFA3gNIomyNzakgrckuKEpgMMUPF7iiUpDcgGHsESk5fnYbRUSAt4FVzkycaM/8S X-Received: by 2002:a17:907:4243:: with SMTP id np3mr2148778ejb.212.1607522445437; Wed, 09 Dec 2020 06:00:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607522445; cv=none; d=google.com; s=arc-20160816; b=FegFlvGBuPA/j2tAx9VvXA/AzfQee2guGKNl4aK7ILco83J5IpgM2VHlfZk7xwzU52 KuG/9EvCX6eHg6yjie/sDXGbetqvbG0JaD1GQwLW4dtc4sL0pkgA6a6rmm8niv0k53Xe K6rggAyhRSM3rJAX0z8Ikf85MaP2ltls3SkXu2C1de5dn9eoutHaU1yKCpr6ZoQL3GnM tNenC/iqX02S6bdB9sahlR9yTVpWOcaHhZMLFkY/GlZXnywrAK4B6CtmjLIx+7FelLqB g+jY1bE2mpOYaYvkPJmmNQt3hrMWYTM+aGJdcnI1fqCnE6LGD5mpiwplpTXITy74GCX2 1jvQ== 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=pxuUkaGKLZJV9Ox3KJ19PtgEkKd9B8SEm1yZawp5YxY=; b=q+AU+Qofibm86HS+yuHPe6nAMmBB/OHHjctPcRy6VDlgal4RQJEAYYpD4KYxONpF/h 6tNZwBFyD4M4Nd/5Kp1Z6ZfkLfRVYCy26CFWC0bBserrJ92EJQ7RU8rPZimoYnhhdx2L GqQzfREAV76oWa+iz1A6gj/XNasljjy/mDovQ1njYZNueJr9HYJk1WcVQOewytuY0av5 9Y+aho1SW5MP6JAYAHfcPPVO1xGBufmf2NZDjD3uBE3p0vw9H2A22l/CL7Gc2aHHnjJT nwpl3Y/hFwjeeWXtbdrGUweuCO40/MCEmbX9WKVyEevhM4yy+tbxVtPt6WFnLvsNnn7i 2eTw== 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 j22si784907ejm.64.2020.12.09.06.00.19; Wed, 09 Dec 2020 06:00:45 -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 S1728678AbgLIIEy (ORCPT + 99 others); Wed, 9 Dec 2020 03:04:54 -0500 Received: from mailgw01.mediatek.com ([210.61.82.183]:50360 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1728644AbgLIIEp (ORCPT ); Wed, 9 Dec 2020 03:04:45 -0500 X-UUID: 126cedf986c94846b5ea264774694395-20201209 X-UUID: 126cedf986c94846b5ea264774694395-20201209 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 2036823754; Wed, 09 Dec 2020 16:03:57 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs07n1.mediatek.inc (172.21.101.16) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 9 Dec 2020 16:03:52 +0800 Received: from localhost.localdomain (10.17.3.153) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 9 Dec 2020 16:03:55 +0800 From: Yong Wu To: Joerg Roedel , Matthias Brugger , Rob Herring , Will Deacon , Robin Murphy CC: Krzysztof Kozlowski , Evan Green , Tomasz Figa , , , , , , , , , Nicolas Boichat , , Subject: [PATCH v5 17/27] iommu/mediatek: Add pm runtime callback Date: Wed, 9 Dec 2020 16:00:52 +0800 Message-ID: <20201209080102.26626-18-yong.wu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20201209080102.26626-1-yong.wu@mediatek.com> References: <20201209080102.26626-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 5614015e5b96..6fe3ee2b2bf5 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/iommu/mtk_iommu.c @@ -808,7 +808,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; @@ -826,7 +826,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; @@ -853,7 +853,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