Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp10418060rwl; Mon, 2 Jan 2023 02:11:01 -0800 (PST) X-Google-Smtp-Source: AMrXdXtcm76W7OZyIJHFiKx5eUK8A6M8CI+VJGg9BZ9MerzBtvfo1D43IDpNCa3C+Ado8p0h+b/n X-Received: by 2002:a17:907:2061:b0:7c0:dfbd:5a1a with SMTP id qp1-20020a170907206100b007c0dfbd5a1amr35599221ejb.33.1672654260692; Mon, 02 Jan 2023 02:11:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672654260; cv=none; d=google.com; s=arc-20160816; b=LcnJaGZj/aBH5g15Ij+vVc0ZHqWUp+EwYDcUKwIsOa0ZyVzXi+pXlGZp7vLoew89P0 9xTnO7UA8Wudf/YhGCtzUv9SbjplhB10U6gKP63hunFd2E4xPavTjMEDC3oABFxIIYnX EUPnzlSo0yWdXKYm4TSoQ5i6UK1fL6Ujdev7gK8BoC1LKofmhkZMoW46TUEI2RxU0Hql dbnlYCS5IUpEZAW8aW+1/mhjaw62D86+GFpVByqHH4+n692JJQICinzGCJmL7ZzHQB3z sU+CBCng71+EtZgXGMjWUXmUTXRTwQqROeG8WuxRdbdMt+XjmmjBBej7eZ1dHkoO1KdS 7z3w== 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:dkim-signature; bh=pN14Ku/R5oS6jwPsJMmldiWfAUHtnStZiqYP0Pe5dk0=; b=mINkjN13v8E2Em/d2WglBCeC+GMuMoucf1Qcsw6wZV3IHDNpO9qMwY5fJVSHeYd5bX uOdEK0TUnq+yKIuKzv3VbOUvT71WOtSmBc9OflzL+3291unfvOqMJdLFyRz37lVbwvnh XNpHelqkStuQb3rSdTmHdL6mqVBRaEh9yt0nsMKvbS5hMa7BSj60yiuFT1L/clFtqLOT LCVEFdLJpVcEF2J1C3+WAoVVVzybWPQ5tOFbguablsZklrn8MycZPRnCu+3XRWDEG7yP mkMiaFnphENEQYDebG1y95PeDsTQIVE8dlNGqRjbLvj8eyTC8N22nddo9DR8/qAEEUmy ZWLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=h4J2x2xy; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s2-20020a17090699c200b0084c4399a502si19823769ejn.893.2023.01.02.02.10.46; Mon, 02 Jan 2023 02:11:00 -0800 (PST) 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; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=h4J2x2xy; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230196AbjABJ5P (ORCPT + 60 others); Mon, 2 Jan 2023 04:57:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232651AbjABJ5L (ORCPT ); Mon, 2 Jan 2023 04:57:11 -0500 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69294DCB; Mon, 2 Jan 2023 01:57:10 -0800 (PST) Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3029i4Xt024889; Mon, 2 Jan 2023 09:56:49 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=message-id : date : mime-version : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding; s=qcppdkim1; bh=pN14Ku/R5oS6jwPsJMmldiWfAUHtnStZiqYP0Pe5dk0=; b=h4J2x2xyqmO3RVWDP06VfIqJ5R11gPQCYxzDnY7Qn9xKnr+k7rt1rrYXQY6+oVzCDCoZ cKXighasqSrlJS4UDuwy9aweVCi2smdESh7F4FIeUXuVfcYRRFTn3L0l9utXWVn63zmd G+LkovkxAzkdh9b30j/btU214fCxZCvoZKpEUdecC0xFJB6MlqF1afoTvJ0doAYOmDQG nvnOkkrlAUmj7GrQry4LMebDfJtmoO83M3zWlZcq8WdSvL9srqsf7YSpT8NCh6YZf/uE RfEIa5m21dOn9MQK6veew9GgpHsnIvND4qAVcAu+pSTeuGzDOuVC+9ONrctv+S+Wersl MQ== Received: from nalasppmta01.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3mtaewb18t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 02 Jan 2023 09:56:49 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 3029umSu004946 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 2 Jan 2023 09:56:48 GMT Received: from [10.216.21.21] (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Mon, 2 Jan 2023 01:56:43 -0800 Message-ID: <8140a64b-3f3e-b8c7-7edc-03f5cc7d14e7@quicinc.com> Date: Mon, 2 Jan 2023 15:26:39 +0530 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.3.2 Subject: Re: [PATCH v4 1/5] PM: domains: Allow a genpd consumer to require a synced power off Content-Language: en-US To: Bjorn Andersson , "Rafael J. Wysocki" CC: freedreno , , , Rob Clark , Ulf Hansson , Stephen Boyd , Philipp Zabel , Greg Kroah-Hartman , Kevin Hilman , Len Brown , Pavel Machek , , References: <1671642843-5244-1-git-send-email-quic_akhilpo@quicinc.com> <20221221224338.v4.1.I3e6b1f078ad0f1ca9358c573daa7b70ec132cdbe@changeid> <20221228184304.4lldh7dxp2pnplzc@builder.lan> From: Akhil P Oommen In-Reply-To: <20221228184304.4lldh7dxp2pnplzc@builder.lan> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: 8mlf8f69kRu3DTGol2s9lk1KbUy_9zpc X-Proofpoint-GUID: 8mlf8f69kRu3DTGol2s9lk1KbUy_9zpc X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2023-01-02_06,2022-12-30_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 suspectscore=0 phishscore=0 priorityscore=1501 malwarescore=0 mlxscore=0 bulkscore=0 impostorscore=0 mlxlogscore=999 lowpriorityscore=0 adultscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301020090 X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS 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 12/29/2022 12:13 AM, Bjorn Andersson wrote: > On Wed, Dec 21, 2022 at 10:43:59PM +0530, Akhil P Oommen wrote: >> From: Ulf Hansson >> >> Some genpd providers doesn't ensure that it has turned off at hardware. >> This is fine until the consumer really requires during some special >> scenarios that the power domain collapse at hardware before it is >> turned ON again. >> >> An example is the reset sequence of Adreno GPU which requires that the >> 'gpucc cx gdsc' power domain should move to OFF state in hardware at >> least once before turning in ON again to clear the internal state. >> >> Signed-off-by: Ulf Hansson >> Signed-off-by: Akhil P Oommen > Reviewed-by: Bjorn Andersson > > @Rafael, would you be willing to share an immutable branch with this > change? Or would you be okay with me doing so from the qcom clock tree? > > Regards, > Bjorn Rafael, gentle ping. Could you please check Bjorn's question here? -Akhil. > >> --- >> >> Changes in v4: >> - Update genpd function documentation (Ulf) >> >> Changes in v2: >> - Minor formatting fix >> >> drivers/base/power/domain.c | 26 ++++++++++++++++++++++++++ >> include/linux/pm_domain.h | 5 +++++ >> 2 files changed, 31 insertions(+) >> >> diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c >> index 967bcf9d415e..84662d338188 100644 >> --- a/drivers/base/power/domain.c >> +++ b/drivers/base/power/domain.c >> @@ -519,6 +519,31 @@ ktime_t dev_pm_genpd_get_next_hrtimer(struct device *dev) >> } >> EXPORT_SYMBOL_GPL(dev_pm_genpd_get_next_hrtimer); >> >> +/* >> + * dev_pm_genpd_synced_poweroff - Next power off should be synchronous >> + * >> + * @dev: A device that is attached to the genpd. >> + * >> + * Allows a consumer of the genpd to notify the provider that the next power off >> + * should be synchronous. >> + * >> + * It is assumed that the users guarantee that the genpd wouldn't be detached >> + * while this routine is getting called. >> + */ >> +void dev_pm_genpd_synced_poweroff(struct device *dev) >> +{ >> + struct generic_pm_domain *genpd; >> + >> + genpd = dev_to_genpd_safe(dev); >> + if (!genpd) >> + return; >> + >> + genpd_lock(genpd); >> + genpd->synced_poweroff = true; >> + genpd_unlock(genpd); >> +} >> +EXPORT_SYMBOL_GPL(dev_pm_genpd_synced_poweroff); >> + >> static int _genpd_power_on(struct generic_pm_domain *genpd, bool timed) >> { >> unsigned int state_idx = genpd->state_idx; >> @@ -562,6 +587,7 @@ static int _genpd_power_on(struct generic_pm_domain *genpd, bool timed) >> >> out: >> raw_notifier_call_chain(&genpd->power_notifiers, GENPD_NOTIFY_ON, NULL); >> + genpd->synced_poweroff = false; >> return 0; >> err: >> raw_notifier_call_chain(&genpd->power_notifiers, GENPD_NOTIFY_OFF, >> diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h >> index 1cd41bdf73cf..f776fb93eaa0 100644 >> --- a/include/linux/pm_domain.h >> +++ b/include/linux/pm_domain.h >> @@ -136,6 +136,7 @@ struct generic_pm_domain { >> unsigned int prepared_count; /* Suspend counter of prepared devices */ >> unsigned int performance_state; /* Aggregated max performance state */ >> cpumask_var_t cpus; /* A cpumask of the attached CPUs */ >> + bool synced_poweroff; /* A consumer needs a synced poweroff */ >> int (*power_off)(struct generic_pm_domain *domain); >> int (*power_on)(struct generic_pm_domain *domain); >> struct raw_notifier_head power_notifiers; /* Power on/off notifiers */ >> @@ -235,6 +236,7 @@ int dev_pm_genpd_add_notifier(struct device *dev, struct notifier_block *nb); >> int dev_pm_genpd_remove_notifier(struct device *dev); >> void dev_pm_genpd_set_next_wakeup(struct device *dev, ktime_t next); >> ktime_t dev_pm_genpd_get_next_hrtimer(struct device *dev); >> +void dev_pm_genpd_synced_poweroff(struct device *dev); >> >> extern struct dev_power_governor simple_qos_governor; >> extern struct dev_power_governor pm_domain_always_on_gov; >> @@ -300,6 +302,9 @@ static inline ktime_t dev_pm_genpd_get_next_hrtimer(struct device *dev) >> { >> return KTIME_MAX; >> } >> +static inline void dev_pm_genpd_synced_poweroff(struct device *dev) >> +{ } >> + >> #define simple_qos_governor (*(struct dev_power_governor *)(NULL)) >> #define pm_domain_always_on_gov (*(struct dev_power_governor *)(NULL)) >> #endif >> -- >> 2.7.4 >>