Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp1679394ybf; Sun, 1 Mar 2020 15:37:02 -0800 (PST) X-Google-Smtp-Source: APXvYqzCEKMleNwcvnOCf8kIm7XIuMuSepm9bgFq9husnfnlxAS0TiPRwHBUlOzzvv0/3CfL1T3N X-Received: by 2002:a05:6830:140f:: with SMTP id v15mr11359915otp.218.1583105822586; Sun, 01 Mar 2020 15:37:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583105822; cv=none; d=google.com; s=arc-20160816; b=bEpMeLnnFUZWlM2NvxgWJmT/Juo5yvm4cyP/961+awDm4zv9QTUpQAD1K1z2rGCw2X sU0nzcf2DLvPSzge/TBM34nN7TAB9z+9gq+e+s/lRdiXZZS/63Spuo9//sC3C5iBNIQA 1cOLkHbjbFhziV1Qwpjo0d+SvjH1F3+IPl7r02wfvay6Qo3InbYAHZCWIOJsZfInt6i3 W/lwHcBZZ8gdVrjDlxnSVZvEHL/oP/CfNeT0htkJ1RD6Y49Ur6cAedY/TET5UCmQ/AQf 17JwyYMEoO26mVwmYdmvmBqAVCNsPfWD8gPHPDFS6STfU4eNd10AefaNQMfIX+PSqTh1 3/wA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=/GiNJ2/rlUqhbIJraZkyEPs9JjHC6+JCTtQcTcJawY0=; b=teY1oCgy+jdCqElHy2L8fM1J4wlGtCJHA0IEG6zrXvDstlNpaSiZVEzFQm9fanEvXZ VhUoLvq09AEEczCRxjpsjuQEwNOvCEAMilNt0Ira0NqVLAP73OTMZywoR6HrAxSXjbB1 hN4ML8D9/j2cjgnKmNmxnrk6HZTQzaRwfD6HTUQ81haBDSfbjJ5Ain2dBXmthmNj5stD uZRWla4sxvbbUv4kQ5sft12c2P8i4I+hWVNQ1+nFqPaxSQjRnun8u5u3g6eR1MyHKnKB iEt9dtgZe/YqUcBsBSblTdirHO4Ur1vgPdkHs7FCDF9o0yJTqhR18PRRGfyXN7XcH6P0 cYkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CujpEhgd; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 5si3655573otr.108.2020.03.01.15.36.49; Sun, 01 Mar 2020 15:37:02 -0800 (PST) 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=@linaro.org header.s=google header.b=CujpEhgd; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726673AbgCAXgG (ORCPT + 99 others); Sun, 1 Mar 2020 18:36:06 -0500 Received: from mail-qv1-f66.google.com ([209.85.219.66]:44417 "EHLO mail-qv1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726592AbgCAXgG (ORCPT ); Sun, 1 Mar 2020 18:36:06 -0500 Received: by mail-qv1-f66.google.com with SMTP id b13so1600558qvt.11 for ; Sun, 01 Mar 2020 15:36:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=/GiNJ2/rlUqhbIJraZkyEPs9JjHC6+JCTtQcTcJawY0=; b=CujpEhgd9L0R3Jf2z/rdQGP/G7t3hzTjm/Uql+k6sF6s4QYY0IvvZ2JBmdwcwKfq+M wc+m6pJQ1FWv5vdBfNO0i8wOUw56eq1hrg1V1uqL0IA4JNCHO5i3dQRSu3IiJAJFtuYJ ji9MafTThebIT+6EIX2KkTOZHL6EGN7Amhwdef1TWVXr4z/N53hbQj+yVvhXp6W4F+hV LPAABheXoy/KO5sJMwWFOXnSR1F/Vjz+JVBb318toxoj+bpCjIKBpFKeHpaLQhOg5HHd OhyF0esTMQH+aypeq7CVlxpe7Qo7+C+ArLOEVtuXn6SvSd6s/ZHeawjRXWishHI2M5RW Qztg== 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:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=/GiNJ2/rlUqhbIJraZkyEPs9JjHC6+JCTtQcTcJawY0=; b=p6gxIMVzEZMJTUH4sgTQLXH+IfLwTsBtBDshJMwYU7aUUtsKDuK5ftsaqIlkVuylrK s12QmFWq/A8dbDZ7++JmZzN0A8osVnK8Gqr+rklZtuXVQbsM1uGdFU3Qz1QgcmW1l7gt 4llcMl4G4GOXgMWxFThRC3F4XZVKlj8Q8e646bChANHm/bcRCeWtgrVNYzZ1GKbxmY70 D+87HuYc7hbQPKR3OMeqyOZeoTBfDJzLUo0fmsUZzXe6oQ1+OX1wyoaStWbA3enOtWrO lBddZHj1IL8/jNo3oXaQPAga7bKFwS7sWEKLrK11mNFfZ2prU4ES/HTOFBRIFn8l0AYc ui1Q== X-Gm-Message-State: APjAAAV8tTCh1Dk6Edtp+GpxiJVy1YkVTaYY2oCkyGWFOfRY5rdrzKxj IIUDw76QsPN/dFzVXq0Gxk6hPaS7F2E= X-Received: by 2002:ad4:40c7:: with SMTP id x7mr13166097qvp.176.1583105764533; Sun, 01 Mar 2020 15:36:04 -0800 (PST) Received: from [192.168.1.92] (pool-71-255-246-27.washdc.fios.verizon.net. [71.255.246.27]) by smtp.gmail.com with ESMTPSA id n138sm9100868qkn.33.2020.03.01.15.36.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 01 Mar 2020 15:36:03 -0800 (PST) Subject: Re: [Patch v4 5/7] soc: qcom: Extend RPMh power controller driver to register warming devices. To: Ulf Hansson Cc: Zhang Rui , Daniel Lezcano , Bjorn Andersson , Andy Gross , Amit Kucheria , Mark Rutland , "Rafael J. Wysocki" , Linux PM , DTML , linux-arm-msm , Linux Kernel Mailing List References: <1574254593-16078-1-git-send-email-thara.gopinath@linaro.org> <1574254593-16078-6-git-send-email-thara.gopinath@linaro.org> From: Thara Gopinath Message-ID: <6292d698-38f4-6a75-551c-629bbfa3c896@linaro.org> Date: Sun, 1 Mar 2020 18:36:02 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2/4/20 12:40 PM, Ulf Hansson wrote: > On Wed, 20 Nov 2019 at 13:56, Thara Gopinath wrote: >> >> RPMh power control hosts power domains that can be used as >> thermal warming devices. Register these power domains >> with the generic power domain warming device thermal framework. >> >> Signed-off-by: Thara Gopinath >> --- >> v3->v4: >> - Introduce a boolean value is_warming_dev in rpmhpd structure to >> indicate if a generic power domain can be used as a warming >> device or not.With this change, device tree no longer has to >> specify which power domain inside the rpmh power domain provider >> is a warming device. >> - Move registering of warming devices into a late initcall to >> ensure that warming devices are registerd after thermal >> framework is initialized. >> >> drivers/soc/qcom/rpmhpd.c | 38 +++++++++++++++++++++++++++++++++++++- >> 1 file changed, 37 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/soc/qcom/rpmhpd.c b/drivers/soc/qcom/rpmhpd.c >> index 9d37534..5666d1f 100644 >> --- a/drivers/soc/qcom/rpmhpd.c >> +++ b/drivers/soc/qcom/rpmhpd.c >> @@ -11,6 +11,7 @@ >> #include >> #include >> #include >> +#include >> #include >> #include >> #include >> @@ -48,6 +49,7 @@ struct rpmhpd { >> bool enabled; >> const char *res_name; >> u32 addr; >> + bool is_warming_dev; >> }; >> >> struct rpmhpd_desc { >> @@ -55,6 +57,8 @@ struct rpmhpd_desc { >> size_t num_pds; >> }; >> >> +const struct rpmhpd_desc *global_desc; >> + >> static DEFINE_MUTEX(rpmhpd_lock); >> >> /* SDM845 RPMH powerdomains */ >> @@ -89,6 +93,7 @@ static struct rpmhpd sdm845_mx = { >> .pd = { .name = "mx", }, >> .peer = &sdm845_mx_ao, >> .res_name = "mx.lvl", >> + .is_warming_dev = true, >> }; >> >> static struct rpmhpd sdm845_mx_ao = { >> @@ -396,7 +401,14 @@ static int rpmhpd_probe(struct platform_device *pdev) >> &rpmhpds[i]->pd); >> } >> >> - return of_genpd_add_provider_onecell(pdev->dev.of_node, data); >> + ret = of_genpd_add_provider_onecell(pdev->dev.of_node, data); >> + >> + if (ret) >> + return ret; >> + >> + global_desc = desc; > > I assume this works fine, for now. > > Although, nothing prevents this driver from being probed for two > different compatibles for the same platform. Thus the global_desc > could be overwritten with the last one being probed, so then how do > you know which one to use? Yes. It works fine for now. There are multiple ways to fix this in future. One is to make global_desc an array. Other would be to move the code in rpmhpd_init_warming_device to this init and make this a post_core init considering thermal subsytem uses core init. Like you said I will leave this at this for now and we can fix this if a need arises. I don't think there is a need for multiple compatibles for the same platform now. Thanks for the reviewed by! I will add it in the next version. > >> + >> + return 0; >> } >> >> static struct platform_driver rpmhpd_driver = { >> @@ -413,3 +425,27 @@ static int __init rpmhpd_init(void) >> return platform_driver_register(&rpmhpd_driver); >> } >> core_initcall(rpmhpd_init); >> + >> +static int __init rpmhpd_init_warming_device(void) >> +{ >> + size_t num_pds; >> + struct rpmhpd **rpmhpds; >> + int i; >> + >> + if (!global_desc) >> + return -EINVAL; >> + >> + rpmhpds = global_desc->rpmhpds; >> + num_pds = global_desc->num_pds; >> + >> + if (!of_find_property(rpmhpds[0]->dev->of_node, "#cooling-cells", NULL)) >> + return 0; >> + >> + for (i = 0; i < num_pds; i++) >> + if (rpmhpds[i]->is_warming_dev) >> + pwr_domain_warming_register(rpmhpds[i]->dev, >> + rpmhpds[i]->res_name, i); >> + >> + return 0; >> +} >> +late_initcall(rpmhpd_init_warming_device); > > For the record, there are limitations with this approach, for example > you can't deal with -EPROBE_DEFER. > > On the other hand, I don't have anything better to suggest, from the > top of my head. So, feel free to add: > > Reviewed-by: Ulf Hansson > > Kind regards > Uffe > -- Warm Regards Thara