Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp3167934rwb; Sat, 6 Aug 2022 14:28:43 -0700 (PDT) X-Google-Smtp-Source: AA6agR7k2ZjcembEv3Ayz5C4gLwiM9OQfhCOoArwz1lNDu1dev4SsJDsfB+Yarbfv8i1zbEC4JCu X-Received: by 2002:a17:90b:4b46:b0:1f7:2430:2286 with SMTP id mi6-20020a17090b4b4600b001f724302286mr4743067pjb.138.1659821323616; Sat, 06 Aug 2022 14:28:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659821323; cv=none; d=google.com; s=arc-20160816; b=RYx7IdIsYK/f79kE7+6FREOoh7yg7z/zCUz+u9uyPqbAM0ZImFXYDZOMATAGDdg3fG yFIDJh09GAD1y+1Kg+PyX3UM9Fq4eRAi4IrugATG85pakYEa4ALKC+YB2J5S4k7R5Ed5 XZQ3DP5gdiRS5vAs6KASdJNIicCLqw0Zd6BnAYS4WNYd/V3lj98seORwhRTNSkYorgWe jLMfEW3ZDWnVmCfKd70fSvBBFcXbO679fjpsbpSlBBbCHTECC3mMY6PI4dIbwdmGiMfg nDGs+xNmz/JQlqFALGp3YI4DDIZo7oNTv1h29ZqeESShm/ur09L2ukGyex924BMeuWVQ Nupw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=91odOXT9Cgfb8foMwz8vIOBpFbq0+hI7q9gwTHXuYhI=; b=zIReg9Bb3HAUAI9qsp2qp3pACyrU836I6AWXq5p2Tl9O22vfdtCZ7AVsLQKZ3iR30X kl4fOrH7on7+Y/8ozPgRMq4vwgIK6VM9WDgeOfr4vppAEDfCtwEochrUs6vQE5RaOK6i ucDmugJIuqyIXXqxR+iahMzSZz1GxxQqrFGB1bQtKGTDbrliKhnC60hYcJeYn7gfVyCD 5Jsce8RRjD3bv3I5wt7nGUetfdsUcYl4BnRBSRlMJkfqYT4Wz7QUcn5g9M/BIt54wxmJ wTe1Jjl872OScasIeTzZ+W7i1IzUXOvaUsCOHkI7ntjpqtF2215zl+b7BXTX7PpjAjBD aXsA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l186-20020a6388c3000000b0041cb4f8c278si3680197pgd.555.2022.08.06.14.28.30; Sat, 06 Aug 2022 14:28:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232702AbiHFUnj (ORCPT + 99 others); Sat, 6 Aug 2022 16:43:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229740AbiHFUnf (ORCPT ); Sat, 6 Aug 2022 16:43:35 -0400 Received: from relay06.th.seeweb.it (relay06.th.seeweb.it [IPv6:2001:4b7a:2000:18::167]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F1209FD1; Sat, 6 Aug 2022 13:43:33 -0700 (PDT) Received: from [192.168.1.101] (abxh187.neoplus.adsl.tpnet.pl [83.9.1.187]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by m-r2.th.seeweb.it (Postfix) with ESMTPSA id C4A453F713; Sat, 6 Aug 2022 22:43:28 +0200 (CEST) Message-ID: <55e88968-69f6-30f1-048b-6fa6a0c26909@somainline.org> Date: Sat, 6 Aug 2022 22:43:27 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.12.0 Subject: Re: [PATCH] soc: qcom: rpmhpd: Use highest corner until sync_state Content-Language: en-US To: Bjorn Andersson , Andy Gross Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Abel Vesa , Rajendra Nayak References: <20220806155035.968340-1-bjorn.andersson@linaro.org> From: Konrad Dybcio In-Reply-To: <20220806155035.968340-1-bjorn.andersson@linaro.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 6.08.2022 17:50, Bjorn Andersson wrote: > In some cases the hardware that the bootloader has left configured > depends on RPMH power domains for their operation up until the point > where the related Linux device driver probes and can inherit that > configuration, or power down the hardware gracefully. > > Unfortunately as Linux probes the releavant drivers in sequence there > are periods during the Linux boot flow where either the genpd refcount > will reach 0, or worse where the active performance_state votes does not > meet the requirements of the state that the hardware was left in. > > One specific example of this is during boot of e.g. SM8150/SC8180X, > where the display clock controller probes, without any particular > performance state needs (to access its registers). This will drop the > MMCX rail to MIN_SVS, which isn't sufficient to sustain the clock rates > that the later probing MDP is configured to. This results in an > unrecoverable system state. > > Handle both these cases by keeping the RPMH power-domais that are > referenced voted for highest state, until sync_state indicates that all > devices referencing the RPMH power-domain driver has been probed. > > Signed-off-by: Bjorn Andersson > --- Must have been fun to debug.. Reviewed-by: Konrad Dybcio Konrad > drivers/soc/qcom/rpmhpd.c | 35 ++++++++++++++++++++++++++++++++++- > 1 file changed, 34 insertions(+), 1 deletion(-) > > diff --git a/drivers/soc/qcom/rpmhpd.c b/drivers/soc/qcom/rpmhpd.c > index 092f6ab09acf..494bb6c75ed7 100644 > --- a/drivers/soc/qcom/rpmhpd.c > +++ b/drivers/soc/qcom/rpmhpd.c > @@ -39,6 +39,7 @@ > * @res_name: Resource name used for cmd-db lookup > * @addr: Resource address as looped up using resource name from > * cmd-db > + * @state_synced: Indicator that sync_state has been invoked for the rpmhpd resource > */ > struct rpmhpd { > struct device *dev; > @@ -54,6 +55,7 @@ struct rpmhpd { > bool enabled; > const char *res_name; > u32 addr; > + bool state_synced; > }; > > struct rpmhpd_desc { > @@ -493,7 +495,13 @@ static int rpmhpd_aggregate_corner(struct rpmhpd *pd, unsigned int corner) > unsigned int this_active_corner = 0, this_sleep_corner = 0; > unsigned int peer_active_corner = 0, peer_sleep_corner = 0; > > - to_active_sleep(pd, corner, &this_active_corner, &this_sleep_corner); > + if (pd->state_synced) { > + to_active_sleep(pd, corner, &this_active_corner, &this_sleep_corner); > + } else { > + /* Clamp to highest corner if sync_state hasn't happened */ > + this_active_corner = pd->level_count - 1; > + this_sleep_corner = pd->level_count - 1; > + } > > if (peer && peer->enabled) > to_active_sleep(peer, peer->corner, &peer_active_corner, > @@ -708,11 +716,36 @@ static int rpmhpd_probe(struct platform_device *pdev) > return of_genpd_add_provider_onecell(pdev->dev.of_node, data); > } > > +static void rpmhpd_sync_state(struct device *dev) > +{ > + const struct rpmhpd_desc *desc = of_device_get_match_data(dev); > + struct rpmhpd **rpmhpds = desc->rpmhpds; > + unsigned int corner; > + struct rpmhpd *pd; > + unsigned int i; > + > + mutex_lock(&rpmhpd_lock); > + for (i = 0; i < desc->num_pds; i++) { > + pd = rpmhpds[i]; > + if (!pd) > + continue; > + > + pd->state_synced = true; > + if (pd->enabled) > + corner = max(pd->corner, pd->enable_corner); > + else > + corner = 0; > + rpmhpd_aggregate_corner(pd, corner); > + } > + mutex_unlock(&rpmhpd_lock); > +} > + > static struct platform_driver rpmhpd_driver = { > .driver = { > .name = "qcom-rpmhpd", > .of_match_table = rpmhpd_match_table, > .suppress_bind_attrs = true, > + .sync_state = rpmhpd_sync_state, > }, > .probe = rpmhpd_probe, > };