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=-8.2 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham 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 B23EBC432C2 for ; Thu, 26 Sep 2019 09:05:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 763BF206B7 for ; Thu, 26 Sep 2019 09:05:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20150623.gappssmtp.com header.i=@baylibre-com.20150623.gappssmtp.com header.b="gnwJafIB" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729396AbfIZJF5 (ORCPT ); Thu, 26 Sep 2019 05:05:57 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:55099 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729018AbfIZJF4 (ORCPT ); Thu, 26 Sep 2019 05:05:56 -0400 Received: by mail-wm1-f65.google.com with SMTP id p7so1769362wmp.4 for ; Thu, 26 Sep 2019 02:05:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:openpgp:autocrypt:organization :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=y3UAKILIqpgM19VWO+ghuctuhVWrhxkcd8iKP1VJBP8=; b=gnwJafIBrwq0EIp4RDn08UIZ08l7IIRf7mtmT4dxDOOcZBfSvct5ndYseSAMZs0E71 HaRj0jbiu90eRoW0Q6Rv6xTZAbv2AMkDCgLEARbTMX25ZrJ4cMLrRIOwECYLan0eCI0j ZSVC1X4DPNDHa9HQFu7c+Mp8V2upBqkjfS29BRTEhdoUIp6K1AHToUOGntfe/Fsvfcow Ob4R+b8QZ0NBXB34MQCyshnktp3kghJwYXfGsJcXdWTuFdcixKLixBx4zc8D9dc4hbyo pTbFBmHPsR6aESZ2W4/ZUuVMC7OUaUfd20AC+axsdZOudddWcuK7Mr6T7sgqlEvlLaiH QnyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:openpgp:autocrypt :organization:message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=y3UAKILIqpgM19VWO+ghuctuhVWrhxkcd8iKP1VJBP8=; b=A/JOjpT7HUu2y3GwdUrzbZ58yHxuWAz4JGPahJobdVC0wLqsY5sVqMoa5VyPb0Eo0L EbCUCkRZ1tD2ND94N3d1bUiho/kDLkvAr0yvNXepktUb2adkSCQU1lZgVKcVgW5PC4ka iHvRIIzM6MDgQ1vmGYZXHRfGhAsG9qyuSHrqJx8yTwsC85vdKJKvJb9gKFWkPmIR7elG 4egbXf8XkGSM7GXIeOeAY0hcLMrgZBdI2IxCwblrCUcMyOp3d1cVfT6SnwH2Dsvc1OTF 7EQl5zyZtyvkdLcGbslTMRu2Y4nhKcB+satkZcFONS/5n10RSTD7xGNW6MoYxVCGCUJd zu7A== X-Gm-Message-State: APjAAAUUlUGpWZSa9r5LdCi/fANl8qKhu+98PIuJYhvTQiMNdSnqGJKk 8AyV8wgvUiOQ0l3AwrtMlzTYYfTAWEbpoA== X-Google-Smtp-Source: APXvYqxOXCCanM1wt6rtzf5BBxuK3PzOwqkWJ4j6vkm4GpILZMxzBY5FVLhNNCeOGNKGVw0rgft4/Q== X-Received: by 2002:a1c:a404:: with SMTP id n4mr2032775wme.41.1569488754154; Thu, 26 Sep 2019 02:05:54 -0700 (PDT) Received: from [10.1.2.12] (lmontsouris-657-1-212-31.w90-63.abo.wanadoo.fr. [90.63.244.31]) by smtp.gmail.com with ESMTPSA id x129sm2412840wmg.8.2019.09.26.02.05.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Sep 2019 02:05:53 -0700 (PDT) Subject: Re: [PATCH v2 2/2] soc: amlogic: ee-pwrc: ensure driver state maches HW state To: Kevin Hilman , linux-amlogic@lists.infradead.org Cc: linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org References: <20190925213528.21515-1-khilman@kernel.org> <20190925213528.21515-3-khilman@kernel.org> From: Neil Armstrong Openpgp: preference=signencrypt Autocrypt: addr=narmstrong@baylibre.com; prefer-encrypt=mutual; keydata= mQENBE1ZBs8BCAD78xVLsXPwV/2qQx2FaO/7mhWL0Qodw8UcQJnkrWmgTFRobtTWxuRx8WWP GTjuhvbleoQ5Cxjr+v+1ARGCH46MxFP5DwauzPekwJUD5QKZlaw/bURTLmS2id5wWi3lqVH4 BVF2WzvGyyeV1o4RTCYDnZ9VLLylJ9bneEaIs/7cjCEbipGGFlfIML3sfqnIvMAxIMZrvcl9 qPV2k+KQ7q+aXavU5W+yLNn7QtXUB530Zlk/d2ETgzQ5FLYYnUDAaRl+8JUTjc0CNOTpCeik 80TZcE6f8M76Xa6yU8VcNko94Ck7iB4vj70q76P/J7kt98hklrr85/3NU3oti3nrIHmHABEB AAG0KE5laWwgQXJtc3Ryb25nIDxuYXJtc3Ryb25nQGJheWxpYnJlLmNvbT6JATsEEwEKACUC GyMGCwkIBwMCBhUIAgkKCwQWAgMBAh4BAheABQJXDO2CAhkBAAoJEBaat7Gkz/iubGIH/iyk RqvgB62oKOFlgOTYCMkYpm2aAOZZLf6VKHKc7DoVwuUkjHfIRXdslbrxi4pk5VKU6ZP9AKsN NtMZntB8Wr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/THomkH24Fum9K3iM /4Wh4V2eqGEgpdeSp5K+LdaNyNgaqzMOtt4HYk86LYLSHfFXywdlbGrY9+TqiJ+ZVW4trmui NIJCOku8SYansq34QzYM0x3UFRwff+45zNBEVzctSnremg1mVgrzOfXU8rt+4N1b2MxorPF8 619aCwVP7U16qNSBaqiAJr4e5SNEnoAq18+1Gp8QsFG0ARY8xp+qaKBByWES7lRi3QbqAKZf yOHS6gmYo9gBmuAhc65/VtHMJtxwjpUeN4Bcs9HUpDMDVHdfeRa73wM+wY5potfQ5zkSp0Jp bxnv/cRBH6+c43stTffprd//4Hgz+nJcCgZKtCYIAPkUxABC85ID2CidzbraErVACmRoizhT KR2OiqSLW2x4xdmSiFNcIWkWJB6Qdri0Fzs2dHe8etD1HYaht1ZhZ810s7QOL7JwypO8dscN KTEkyoTGn6cWj0CX+PeP4xp8AR8ot4d0BhtUY34UPzjE1/xyrQFAdnLd0PP4wXxdIUuRs0+n WLY9Aou/vC1LAdlaGsoTVzJ2gX4fkKQIWhX0WVk41BSFeDKQ3RQ2pnuzwedLO94Bf6X0G48O VsbXrP9BZ6snXyHfebPnno/te5XRqZTL9aJOytB/1iUna+1MAwBxGFPvqeEUUyT+gx1l3Acl ZaTUOEkgIor5losDrePdPgE= Organization: Baylibre Message-ID: <8936e777-8996-5c7b-ea9d-8e17c8d6c4b1@baylibre.com> Date: Thu, 26 Sep 2019 11:05:52 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20190925213528.21515-3-khilman@kernel.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org On 25/09/2019 23:35, Kevin Hilman wrote: > From: Kevin Hilman > > During init, ensure that the driver on/off state as well as clock and > reset state matches the hardware state. Do this by always calling the > drivers 'on' function, and then callling the 'off' function if the > HW state was initially detected as off. > > Signed-off-by: Kevin Hilman > --- > drivers/soc/amlogic/meson-ee-pwrc.c | 29 ++++++++--------------------- > 1 file changed, 8 insertions(+), 21 deletions(-) > > diff --git a/drivers/soc/amlogic/meson-ee-pwrc.c b/drivers/soc/amlogic/meson-ee-pwrc.c > index dcce8e694a07..2e8eee0dc166 100644 > --- a/drivers/soc/amlogic/meson-ee-pwrc.c > +++ b/drivers/soc/amlogic/meson-ee-pwrc.c > @@ -323,6 +323,8 @@ static int meson_ee_pwrc_init_domain(struct platform_device *pdev, > struct meson_ee_pwrc *pwrc, > struct meson_ee_pwrc_domain *dom) > { > + bool is_off; > + > dom->pwrc = pwrc; > dom->num_rstc = dom->desc.reset_names_count; > dom->num_clks = dom->desc.clk_names_count; > @@ -356,27 +358,12 @@ static int meson_ee_pwrc_init_domain(struct platform_device *pdev, > dom->base.power_on = meson_ee_pwrc_on; > dom->base.power_off = meson_ee_pwrc_off; > > - /* > - * TOFIX: This is a special case for the VPU power domain, which can > - * be enabled previously by the bootloader. In this case the VPU > - * pipeline may be functional but no driver maybe never attach > - * to this power domain, and if the domain is disabled it could > - * cause system errors. This is why the pm_domain_always_on_gov > - * is used here. > - * For the same reason, the clocks should be enabled in case > - * we need to power the domain off, otherwise the internal clocks > - * prepare/enable counters won't be in sync. > - */ > - if (dom->num_clks && dom->desc.is_off && !dom->desc.is_off(dom)) { > - int ret = clk_bulk_prepare_enable(dom->num_clks, dom->clks); > - if (ret) > - return ret; > - > - pm_genpd_init(&dom->base, &pm_domain_always_on_gov, false); > - } else > - pm_genpd_init(&dom->base, NULL, > - (dom->desc.is_off ? > - dom->desc.is_off(dom) : true)); > + /* Ensure that driver state matches HW state */ > + is_off = dom->desc.is_off ? dom->desc.is_off(dom) : true; > + meson_ee_pwrc_on(&dom->base); > + if (is_off) > + meson_ee_pwrc_off(&dom->base); > + pm_genpd_init(&dom->base, NULL, is_off); > > return 0; > } > I don't see what you are trying to solve except simplifying the code. And the case is more that "matching the clock state" here, the pm_domain_always_on_gov was is a real case when booting from the Amlogic U-boot. The display power domain is complex and as been half solved by using "simple-framebuffer" on gx and is missing on g12a/g12b/sm1. For example, Debian installer runs without the modules, but will use the EFIfb set by U-Boot, but in this precise case : - the DRM driver isn't loaded - we can't hook this power domain with EFIfb When *not* in EFIfb, we use simple-framebuffer on GX, using this power domain, but it hasn't been copied to G12A. Personally I'll leave this code until we really tested and checked all uses cases, not only on the sei510/sei610 using mainline u-boot. Neil