Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp588700ybl; Fri, 9 Aug 2019 10:29:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqyZ81pcGycD8SML4OkRgULPlrVnTUVjfSdWbglB8KR6UO5Du7ZPlVo9gmP2D5D/X1Vc+xmG X-Received: by 2002:a63:8a49:: with SMTP id y70mr19250710pgd.271.1565371790229; Fri, 09 Aug 2019 10:29:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565371790; cv=none; d=google.com; s=arc-20160816; b=CmyMZcmUUQlJU9szOQSheesAyZzHyGKPJ0tq/uAvsKO0Q4gWiGDbcSqG0po05DGfYS 8ifq1pwnd1WiqfY0ZYULDAagQFXsQKZqOwQqvLfYv3bmGxwuw5/+W0A6y6w9Jng+o2BC l30PBOjedFSrOw69LXDharDGZwNe4sFHMtBTXl8YzqKvsaA42NAeOBMfXNgRELTEYtcY 3zs2lPb/BsXtVBcpC4E5pOifdFzw8vLh/XzvYa5FJojc558lrWMB0Gdh9Tbon2GQabzd tyr7+3LIJuzhQCTdNS/pwyXGXon7qjlW+kNTESadDbpokUn+b6TI2OgRHbV3hduDD0vu ueXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:dkim-signature:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=9K+xIDK15KtnHzPSfE7vIgbQ51SDxHeJAKLybJBjPKQ=; b=rIoVXumrI/xZkgggQKdP2+sQnePtGd1ddSBaocTkFqixM3J/dwWwF00U7QmxXDFMBP z73DhHEZ8mRtthJhgOh66wmF+rWwUr6OSpKA5y3Ea/sHZX2zSEfFH5mBAtyJPWR/BGku HjUh9crTy0i/b/bOuGXNzNkGJjzDQm19DucKyg5Q/ODzqW1kKLuzHFAttff+Q4jt1/p5 SyEzzJklx9MWn6EvoHkQ8oTdtc17rGFe6td/hLLfX6dHENDK/W5j/ZHgU5z1qPfRRL57 /5EjO91xGSn/Fvli1xVR6sEz2jE5+ujevrFkIj7p6JQfEQpcm0NWC3hPxAjZuJwAUxWh 9Xhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=o41zlVC8; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 143si56280022pgc.479.2019.08.09.10.29.35; Fri, 09 Aug 2019 10:29:50 -0700 (PDT) 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; dkim=pass header.i=@nvidia.com header.s=n1 header.b=o41zlVC8; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2437263AbfHIQjh (ORCPT + 99 others); Fri, 9 Aug 2019 12:39:37 -0400 Received: from hqemgate15.nvidia.com ([216.228.121.64]:4075 "EHLO hqemgate15.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2437094AbfHIQjg (ORCPT ); Fri, 9 Aug 2019 12:39:36 -0400 Received: from hqpgpgate102.nvidia.com (Not Verified[216.228.121.13]) by hqemgate15.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Fri, 09 Aug 2019 09:39:44 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate102.nvidia.com (PGP Universal service); Fri, 09 Aug 2019 09:39:33 -0700 X-PGP-Universal: processed; by hqpgpgate102.nvidia.com on Fri, 09 Aug 2019 09:39:33 -0700 Received: from [10.2.167.88] (10.124.1.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Fri, 9 Aug 2019 16:39:31 +0000 Subject: Re: [PATCH v8 11/21] clk: tegra: clk-dfll: Add suspend and resume support To: Dmitry Osipenko , , , , , , , , CC: , , , , , , , , , , , , , , , , References: <1565308020-31952-1-git-send-email-skomatineni@nvidia.com> <1565308020-31952-12-git-send-email-skomatineni@nvidia.com> From: Sowjanya Komatineni Message-ID: <29a85a35-10ff-2d43-d148-9dba1ee25869@nvidia.com> Date: Fri, 9 Aug 2019 09:39:30 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: X-Originating-IP: [10.124.1.5] X-ClientProxiedBy: HQMAIL101.nvidia.com (172.20.187.10) To HQMAIL107.nvidia.com (172.20.187.13) Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: quoted-printable Content-Language: en-US DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1565368784; bh=9K+xIDK15KtnHzPSfE7vIgbQ51SDxHeJAKLybJBjPKQ=; h=X-PGP-Universal:Subject:To:CC:References:From:Message-ID:Date: User-Agent:MIME-Version:In-Reply-To:X-Originating-IP: X-ClientProxiedBy:Content-Type:Content-Transfer-Encoding: Content-Language; b=o41zlVC8fAIKHUMNwo88I810EK8Np1WhCq7WhUlSL5mmY2fpXLKsKNwPwGQ/ycgc2 SCF9CXU6z1Hqc7D8unfJT292Ya4VMaxvTnEg6jN+fyrIB7OZAwbL1M//Y57z67NmiH ZCCQkeq5b3W2QgRQdlNUIVAVBT9yAp1gL6c9S+a6wdXASdNzP9IX5wdOowafV5EECY BjZFCPotMY+/dM8p4GCgCUM2vlbe9mYawsPgww0OuD4URE1VVosQ9G0D+jNWrAvElE inCug8oTmQ/lAsLM8M25b7hdqMd5n8KqdnEDbWSahu6oV0AO7ziDdd0IFWzXrdl2HA B+nHixOl9nsmQ== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 8/9/19 5:23 AM, Dmitry Osipenko wrote: > 09.08.2019 2:46, Sowjanya Komatineni =D0=BF=D0=B8=D1=88=D0=B5=D1=82: >> This patch implements DFLL suspend and resume operation. >> >> During system suspend entry, CPU clock will switch CPU to safe >> clock source of PLLP and disables DFLL clock output. >> >> DFLL driver suspend confirms DFLL disable state and errors out on >> being active. >> >> DFLL is re-initialized during the DFLL driver resume as it goes >> through complete reset during suspend entry. >> >> Signed-off-by: Sowjanya Komatineni >> --- >> drivers/clk/tegra/clk-dfll.c | 56 ++++++++++++++++++++++= ++++++++ >> drivers/clk/tegra/clk-dfll.h | 2 ++ >> drivers/clk/tegra/clk-tegra124-dfll-fcpu.c | 1 + >> 3 files changed, 59 insertions(+) >> >> diff --git a/drivers/clk/tegra/clk-dfll.c b/drivers/clk/tegra/clk-dfll.c >> index f8688c2ddf1a..eb298a5d7be9 100644 >> --- a/drivers/clk/tegra/clk-dfll.c >> +++ b/drivers/clk/tegra/clk-dfll.c >> @@ -1487,6 +1487,7 @@ static int dfll_init(struct tegra_dfll *td) >> td->last_unrounded_rate =3D 0; >> =20 >> pm_runtime_enable(td->dev); >> + pm_runtime_irq_safe(td->dev); >> pm_runtime_get_sync(td->dev); >> =20 >> dfll_set_mode(td, DFLL_DISABLED); >> @@ -1513,6 +1514,61 @@ static int dfll_init(struct tegra_dfll *td) >> return ret; >> } >> =20 >> +/** >> + * tegra_dfll_suspend - check DFLL is disabled >> + * @dev: DFLL device * >> + * >> + * DFLL clock should be disabled by the CPUFreq driver. So, make >> + * sure it is disabled and disable all clocks needed by the DFLL. >> + */ >> +int tegra_dfll_suspend(struct device *dev) >> +{ >> + struct tegra_dfll *td =3D dev_get_drvdata(dev); >> + >> + if (dfll_is_running(td)) { >> + dev_err(td->dev, "dfll is enabled while shouldn't be\n"); >> + return -EBUSY; >> + } >> + >> + reset_control_assert(td->dvco_rst); >> + >> + return 0; >> +} >> +EXPORT_SYMBOL(tegra_dfll_suspend); >> + >> +/** >> + * tegra_dfll_resume - reinitialize DFLL on resume >> + * @dev: DFLL instance >> + * >> + * DFLL is disabled and reset during suspend and resume. >> + * So, reinitialize the DFLL IP block back for use. >> + * DFLL clock is enabled later in closed loop mode by CPUFreq >> + * driver before switching its clock source to DFLL output. >> + */ >> +int tegra_dfll_resume(struct device *dev) >> +{ >> + struct tegra_dfll *td =3D dev_get_drvdata(dev); >> + >> + reset_control_deassert(td->dvco_rst); > This doesn't look right because I assume that DFLL resetting is > synchronous and thus clk should be enabled in order for reset to > propagate inside hardware. > >> + pm_runtime_get_sync(td->dev); > Hence it will be better to remove the above reset_control_deassert() and > add here: > > reset_control_reset(td->dvco_rst); By the time dfll resume happens, dfll controller clock will already be=20 enabled. so doing reset de-assert before pm_runtime seems ok. >> + dfll_set_mode(td, DFLL_DISABLED); >> + dfll_set_default_params(td); >> + >> + if (td->soc->init_clock_trimmers) >> + td->soc->init_clock_trimmers(); >> + >> + dfll_set_open_loop_config(td); >> + >> + dfll_init_out_if(td); >> + >> + pm_runtime_put_sync(td->dev); >> + >> + return 0; >> +} >> +EXPORT_SYMBOL(tegra_dfll_resume); >> + >> /* >> * DT data fetch >> */ >> diff --git a/drivers/clk/tegra/clk-dfll.h b/drivers/clk/tegra/clk-dfll.h >> index 1b14ebe7268b..fb209eb5f365 100644 >> --- a/drivers/clk/tegra/clk-dfll.h >> +++ b/drivers/clk/tegra/clk-dfll.h >> @@ -42,5 +42,7 @@ int tegra_dfll_register(struct platform_device *pdev, >> struct tegra_dfll_soc_data *tegra_dfll_unregister(struct platform_devi= ce *pdev); >> int tegra_dfll_runtime_suspend(struct device *dev); >> int tegra_dfll_runtime_resume(struct device *dev); >> +int tegra_dfll_suspend(struct device *dev); >> +int tegra_dfll_resume(struct device *dev); >> =20 >> #endif /* __DRIVERS_CLK_TEGRA_CLK_DFLL_H */ >> diff --git a/drivers/clk/tegra/clk-tegra124-dfll-fcpu.c b/drivers/clk/te= gra/clk-tegra124-dfll-fcpu.c >> index e84b6d52cbbd..2ac2679d696d 100644 >> --- a/drivers/clk/tegra/clk-tegra124-dfll-fcpu.c >> +++ b/drivers/clk/tegra/clk-tegra124-dfll-fcpu.c >> @@ -631,6 +631,7 @@ static int tegra124_dfll_fcpu_remove(struct platform= _device *pdev) >> static const struct dev_pm_ops tegra124_dfll_pm_ops =3D { >> SET_RUNTIME_PM_OPS(tegra_dfll_runtime_suspend, >> tegra_dfll_runtime_resume, NULL) >> + SET_SYSTEM_SLEEP_PM_OPS(tegra_dfll_suspend, tegra_dfll_resume) >> }; >> =20 >> static struct platform_driver tegra124_dfll_fcpu_driver =3D { >>