Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp6022514rwj; Wed, 21 Dec 2022 09:45:38 -0800 (PST) X-Google-Smtp-Source: AMrXdXvUI3pJZ5McA9lFdZMHGXCD+WTo3jHNu9nf7npSLmR+9c4ALn+ocgitmLjA+wl1gSLr2+aT X-Received: by 2002:a17:90a:8a08:b0:223:3642:f74f with SMTP id w8-20020a17090a8a0800b002233642f74fmr2568657pjn.0.1671644738482; Wed, 21 Dec 2022 09:45:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671644738; cv=none; d=google.com; s=arc-20160816; b=CLBULUFSf0sqFq9JOv8RkskYIMaTmfJRmj6RDyAQFY+bgHfb6kAoE9tXeXkOt9nSvI Nm5E7TI4xipUmkdSkMQLu0zrDSz6lwBJOIx3SIzrei33clx6N2iW1Kndrjm6ND87QqQo EcxSEHYSuv5jeUMRnOsw1yOvKYK+wQ7LEJT4WP1IHAwUSQzxbcG1YbLvgflncf1jp0d+ vg2od1rpPihBcX0E1++P3Rfhqlx3mTcHdH7Uuz/0Rwm7SPdgstA9rYr/WDcYxqakpEXn zeUKRDnMPPHEg3sh/nWmaReTD1Ki5B93zZIgem2B7+B9pyUsXoZ4TOJaBPQKx4m4ngtP NC4w== 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=1oxQmQwiIenoFfxBXVP/PxDgwVG72FR62Q+9mRgzxps=; b=efHQDyxUjTLiVjAGCYBQDFgydgioGw5k7EK14+uqMF6bVG3bXSScjmT9s2KLHvZTKI mVZufvXzvRe9h6NbUcHeHplLQixJeGrno+lT3HRBgJ6YxEJLPYpETYs8l+XhjmEqTAMo 0KdJ6yRJmTaXpkExxO99mxYL96UnwcED7kfgyj/xE58Wv5Uc5lPBh+0bVc1EK7qov9Ka elkkQLuB1QtwQnqJNAcgMfqIGrYVybj9qXgMw6QG5d7Y0BNjWoqj+EffgSuZKj7liFr0 sNiNesRwW2ujbRQ05rotHKI5E0178fMTOtSR0RlqRQ8sg8Ey/bx8Vr19k003b85STwOB BcDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=Z8ObkR+w; 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 kb13-20020a17090ae7cd00b00223c0bc663dsi2395742pjb.146.2022.12.21.09.45.29; Wed, 21 Dec 2022 09:45:38 -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=Z8ObkR+w; 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 S234793AbiLURQs (ORCPT + 67 others); Wed, 21 Dec 2022 12:16:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234842AbiLURQD (ORCPT ); Wed, 21 Dec 2022 12:16:03 -0500 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D02213F5E; Wed, 21 Dec 2022 09:15:53 -0800 (PST) Received: from pps.filterd (m0279872.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2BLFsCh4010831; Wed, 21 Dec 2022 17:15:40 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=1oxQmQwiIenoFfxBXVP/PxDgwVG72FR62Q+9mRgzxps=; b=Z8ObkR+wJaOsGV3+N4M4pUt3zlAz45cFfkX0nlySOZ4nuYIMYbfW4duGCgUHF/S8aRzZ uO+MGXDBwxDxGsn6PrwogMsXSr9KAYDzfnk/xms/MRUmx2qD9Uxx+qqUBH4kTvdGoq1j SKe18fgfFhPaOETT9RiR4CfyffVD3QhUjZj+KQVPZPqUVzuPmCODr5CQoQvDyPQOsOOy +ELK1dowxJurCFuVI8/YxZEplRNwR/CE8WSk6A+EhCd98u9vjsnSLQtRd7sNEIAKHAkw L9+nB/zJ6AVrcTbK5alBMXtb6Me1sCEMGkOoMXzeX43h9/lLd5q3REOjGn514ljZD7rr uQ== Received: from nalasppmta04.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3mm3cjrdwm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 21 Dec 2022 17:15:40 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 2BLHFcnw003686 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 21 Dec 2022 17:15:38 GMT Received: from [10.216.38.32] (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; Wed, 21 Dec 2022 09:15:33 -0800 Message-ID: <84ab14d8-8177-a921-7ae2-7d05248a190b@quicinc.com> Date: Wed, 21 Dec 2022 22:45:29 +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 v3 1/5] PM: domains: Allow a genpd consumer to require a synced power off Content-Language: en-US To: Ulf Hansson CC: freedreno , , , Rob Clark , Bjorn Andersson , Stephen Boyd , Philipp Zabel , Greg Kroah-Hartman , Kevin Hilman , Len Brown , Pavel Machek , "Rafael J. Wysocki" , , References: <1671522257-38778-1-git-send-email-quic_akhilpo@quicinc.com> <20221220131255.v3.1.I3e6b1f078ad0f1ca9358c573daa7b70ec132cdbe@changeid> From: Akhil P Oommen In-Reply-To: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) 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-GUID: okB0CZmVtG-v0eCEsgLc9zJvsRiBbtBG X-Proofpoint-ORIG-GUID: okB0CZmVtG-v0eCEsgLc9zJvsRiBbtBG 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=2022-12-21_10,2022-12-21_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 mlxlogscore=999 impostorscore=0 spamscore=0 phishscore=0 clxscore=1015 priorityscore=1501 suspectscore=0 malwarescore=0 lowpriorityscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2212210144 X-Spam-Status: No, score=-3.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/21/2022 8:13 PM, Ulf Hansson wrote: > On Tue, 20 Dec 2022 at 08:44, 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 >> --- >> >> (no changes since v2) >> >> Changes in v2: >> - Minor formatting fix >> >> drivers/base/power/domain.c | 23 +++++++++++++++++++++++ >> include/linux/pm_domain.h | 5 +++++ >> 2 files changed, 28 insertions(+) >> >> diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c >> index 967bcf9d415e..53524a102321 100644 >> --- a/drivers/base/power/domain.c >> +++ b/drivers/base/power/domain.c >> @@ -519,6 +519,28 @@ 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. > Nitpick; similar to other dev_pm_genpd_* function-descriptions, I > think it's important to add the below information. > > "It is assumed that the users guarantee that the genpd wouldn't be > detached while this routine is getting called." > > Can you please add that? Thanks. Fixed in revision 4. -Akhil. > >> + */ >> +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 +584,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 >> > Kind regards > Uffe