From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E3531C433E0 for ; Wed, 23 Dec 2020 08:33:38 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8710F22248 for ; Wed, 23 Dec 2020 08:33:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8710F22248 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=0LN5JIHFbOFoIq8jl7mWQREyMdNrZb+DaoHdq+QIjvU=; b=gnr+32Z+4gVIND1Nr1NvEQRPI PuifeEmGAJX+SbMv4onZ0EykKgmqosfPKCkOukWlH4gAcfpXhiNL7fvmDROmKIISH1n/tEkwv4OVd CoxBBzOLY93PiBGa5sm6prSb/pVfabzAoGHfQRTLjw6rS7HzYEaQBp4N1E4WHMD+DCnbNQFaSfjVB GMLtV20rRz/aK8QFKSPozh1NDcQJP26Tz4JBZ/RHeTWM0P5/h5wH+ENQbGPWUrL7u1/QVS0j+dj7j gyihp9hkGXQdxvhJcI39R+Wkla+Uqvah1dcatt6cZ8moA4P0iUxCt3DZMoiXCFQBSVsSyghlk3jZr uCDK15mSA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1krzZF-0004yq-0P; Wed, 23 Dec 2020 08:32:21 +0000 Received: from mail-pg1-x533.google.com ([2607:f8b0:4864:20::533]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1krzZA-0004x6-N6 for linux-arm-kernel@lists.infradead.org; Wed, 23 Dec 2020 08:32:18 +0000 Received: by mail-pg1-x533.google.com with SMTP id n10so10163118pgl.10 for ; Wed, 23 Dec 2020 00:32:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=f6z2jHWOUsdwvkW1sMAfQ+uPvAPsBSWtcQYM5UeGKOQ=; b=R1Dtuprupk5qqiUMugbruG8tuTkprsynKgHI6FENUZDJPwteKI/RPbhP1u7CXwuf4u L2eZUc5xoe1egZtRKXhxLNCysC2nfWPgQ798UT68SUdKJM28lGqsh3znYrwyyn9m3a/x 4vpCIEXdsq/TxF/e/vNFR3MLDzRxVnPS19Kls= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=f6z2jHWOUsdwvkW1sMAfQ+uPvAPsBSWtcQYM5UeGKOQ=; b=h5NVTiZJwI/5EnYPxq1kmtgHauKLljk53ufuM4zqm0mt+deoskvbEg0o27KDt7mL+v mYn+3LOsMUWU0oHIOMmLPP/3A4omvM4FIQw3Kd3l3CAeQzfnTg5uH82J/8OigtQg1vKc 3B5SLoKK0yB1f0PaKR8eFWbfYc+gCj+Tab8Yrl+zeN72M+CbVa/SIWH7e2OAfkUAPVKa KS2ImrizHpAuu7zFCr6mfut2SylHjxFkd5DpxE3YCdvo0r115EB0HzGA3S98/LwHNkiX K0nvHwGg+33VHkIKeQaOsI2cIRre4NyFhmCDhZ1cSAE0msJqiHAlGKbKS3cf1N4y5NWz dsaQ== X-Gm-Message-State: AOAM531wnaVN7WUhFJPboFh4OpCOS5U/cPeiagM5j/h1JE08GfUt+Kz3 ADARAVOnmjZOGzZe7H+5fUV7jQ== X-Google-Smtp-Source: ABdhPJxRY0t2ecrt0qdbX6wNZyK5FMit7yNVCixLg3SFVanvhZuz5z5iGFCyfF9mG3ZV++F089pKQw== X-Received: by 2002:a62:9208:0:b029:19e:a15f:169e with SMTP id o8-20020a6292080000b029019ea15f169emr23179186pfd.71.1608712334434; Wed, 23 Dec 2020 00:32:14 -0800 (PST) Received: from chromium.org ([2401:fa00:8f:2:a28c:fdff:fef0:43bf]) by smtp.gmail.com with ESMTPSA id p187sm21556047pfp.60.2020.12.23.00.32.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Dec 2020 00:32:13 -0800 (PST) Date: Wed, 23 Dec 2020 17:32:07 +0900 From: Tomasz Figa To: Yong Wu Subject: Re: [PATCH v5 17/27] iommu/mediatek: Add pm runtime callback Message-ID: References: <20201209080102.26626-1-yong.wu@mediatek.com> <20201209080102.26626-18-yong.wu@mediatek.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20201209080102.26626-18-yong.wu@mediatek.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201223_033216_801806_88EDFB95 X-CRM114-Status: GOOD ( 27.95 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: youlin.pei@mediatek.com, devicetree@vger.kernel.org, Nicolas Boichat , srv_heupstream@mediatek.com, Tomasz Figa , Will Deacon , Joerg Roedel , linux-kernel@vger.kernel.org, Evan Green , chao.hao@mediatek.com, iommu@lists.linux-foundation.org, Rob Herring , linux-mediatek@lists.infradead.org, Krzysztof Kozlowski , Matthias Brugger , anan.sun@mediatek.com, Robin Murphy , linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Dec 09, 2020 at 04:00:52PM +0800, Yong Wu wrote: > 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, This sounds wrong and could lead to hard to debug errors when the driver is changed in the future. Would it be possible to make the behavior consistent across the SoCs instead, so that runtime PM status is ACTIVE when needed, even on SoCs without an IOMMU PM domain? > 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); > +} Wouldn't it be enough to just use pm_runtime_force_suspend() and pm_runtime_force_resume() as system sleep ops? > + > 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 > > _______________________________________________ > iommu mailing list > iommu@lists.linux-foundation.org > https://lists.linuxfoundation.org/mailman/listinfo/iommu _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel