From patchwork Thu Dec 15 15:10:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akhil P Oommen X-Patchwork-Id: 33670 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp420439wrn; Thu, 15 Dec 2022 07:18:30 -0800 (PST) X-Google-Smtp-Source: AA0mqf5AL9LoegnqQOC/SD5g19jN2b7nbpnD7VjEpRDE++4HhUFrLVrjAkWp0D5x1xXE2GlfbCb5 X-Received: by 2002:a05:6a21:9181:b0:a4:150f:8ddc with SMTP id tp1-20020a056a21918100b000a4150f8ddcmr34354920pzb.52.1671117509932; Thu, 15 Dec 2022 07:18:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671117509; cv=none; d=google.com; s=arc-20160816; b=NEi3OOrptpcrqjrLEzrOJp9FEcUHq01my+EH3tjnIRb84d6l7YcIdQ+A6tFrfv7H6S 9mNhwP6lZ211Kndf5LNhAL/zM3upeFgsIcyk4ZW+PS0wy3Kpd2S5yuwqnpi6PRLo948X xQ9eaOzY3ksrsCGDEKnlcJiYWZC8/mhAiyBYK6zrL7vsw6XNYD2syFBmhpw5M3SwM9XY n9vdnrABrwwTSOm+VV3qihzLO86LI2LC6YXDX2L9f6b2Hy/J//QG0f7uCnTWymHvACUC gIOM+1FfGTRWIywLnAwufJYO2eCA03V9b5VIoXxAw6UcePN4A3m2D9nKBN0KK6gAuopc zTDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=NQjuWdRJhlzvQflQiWmSjH+nZpjlOK16M6kbc7ZMIv4=; b=YsqNk+4Snl0wgfL3/wz7s+Q1gBGba5CPGinhJ+deDtuG4IuqmVhKJnw+YFRTDu7Vij sacHrety+/mMINGIhTVnZL5ybN9ta00JDq5E44+ci3wm+gCqsMWtD2sWKcl0sfty7oPd cw+Hc30XsYGemFFHrfPtOlPuEryaE7YDlbJaXosPETQ/XxOZp9t6irmp9yQ38CgFcUbR 4pkeLAyUorlmaTUa8BVp8FRFQCew1l1Kr5ratoIJ1X8GlJj8DOOiVvF0L4NZnMd+Q0yt X/gfQQDVzekeJX67GDDnMFP00TqaLVnbFfhZePVGMyRD3Lfu5KSYGyutlM0p2tpV3ocp Ylcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=MjYlOQcC; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 80-20020a630453000000b0046f75b665b8si3144893pge.757.2022.12.15.07.18.15; Thu, 15 Dec 2022 07:18:29 -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=MjYlOQcC; 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 S230071AbiLOPMH (ORCPT + 99 others); Thu, 15 Dec 2022 10:12:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230082AbiLOPLv (ORCPT ); Thu, 15 Dec 2022 10:11:51 -0500 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A9F430575; Thu, 15 Dec 2022 07:11:46 -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 2BFAjkI2018902; Thu, 15 Dec 2022 15:11:30 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=qcppdkim1; bh=NQjuWdRJhlzvQflQiWmSjH+nZpjlOK16M6kbc7ZMIv4=; b=MjYlOQcCGoJhiESaeavfM6gxfW7Xn+jK53Jip20RGxsTMbT2NB6HQJ7rZ/YSWWVW3ymW 0tOj1sRiZIs/gBWRB2H8bow0imZ3sNiCN7s0zMosGe9LO26sIog4JRoDESqNvYc4Mzap Z9SfllnVXZxM5IVCLQ6kE/azQFIX2VU+DfmU6CSMRPkdpy4sA4qLpgOTorfQQ6jMotWy yDfjtFmaE5afTbGwNgDbJgVK7wemFS4+d7+n6YSvyphYjxazxb9lx+KeRWvYqysd0GO9 R2pTak/MfSb1ba0qN0Jn99NcGq3VXwfiyZDLjnfFcVcohJatE0kydL6KrrKxl7aOVz18 tw== Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3mfukhstj5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 15 Dec 2022 15:11:29 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 2BFFBSss012483 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 15 Dec 2022 15:11:28 GMT Received: from hyd-lnxbld559.qualcomm.com (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; Thu, 15 Dec 2022 07:11:24 -0800 From: Akhil P Oommen To: freedreno , , , Rob Clark , Ulf Hansson , Bjorn Andersson CC: Akhil P Oommen , Greg Kroah-Hartman , Kevin Hilman , Len Brown , Pavel Machek , "Rafael J. Wysocki" , , Subject: [PATCH 1/5] PM: domains: Allow a genpd consumer to require a synced power off Date: Thu, 15 Dec 2022 20:40:57 +0530 Message-ID: <20221215203751.1.I3e6b1f078ad0f1ca9358c573daa7b70ec132cdbe@changeid> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1671117062-26276-1-git-send-email-quic_akhilpo@quicinc.com> References: <1671117062-26276-1-git-send-email-quic_akhilpo@quicinc.com> MIME-Version: 1.0 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-GUID: 3ozT3s2LygexvKrtlfkWG3Is6S-kalNQ X-Proofpoint-ORIG-GUID: 3ozT3s2LygexvKrtlfkWG3Is6S-kalNQ 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-15_08,2022-12-15_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 clxscore=1015 mlxscore=0 malwarescore=0 impostorscore=0 lowpriorityscore=0 bulkscore=0 mlxlogscore=602 spamscore=0 priorityscore=1501 adultscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2212150123 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752293714298174944?= X-GMAIL-MSGID: =?utf-8?q?1752293714298174944?= 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 --- @Ulf, I took the liberty to cleanup and post your patch. 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..4fa624218967 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. + */ +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