From patchwork Mon Jan 2 10:48:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akhil P Oommen X-Patchwork-Id: 38071 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp4106220wrt; Mon, 2 Jan 2023 02:51:17 -0800 (PST) X-Google-Smtp-Source: AMrXdXsQjkZ6FnO8cjvChBsIrHGg8C+LpNob8bm9+d9BdAsHpm90pZ0J5WlxNqgqT9ZyNClxNc+e X-Received: by 2002:a05:6402:241b:b0:461:2288:6808 with SMTP id t27-20020a056402241b00b0046122886808mr38041360eda.21.1672656676987; Mon, 02 Jan 2023 02:51:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672656676; cv=none; d=google.com; s=arc-20160816; b=ORPV8XqBaisUhYW++MfoORGEd6wGjYYZ6Qj6bKaqMt6Q9pK4stS4vnBBwhMuF7Rsd7 ggCzwyucwxs02wCphEVaOKmgiajiAMYF3NBAWAMGWpFsP0bsKGojADG2lM3lLovon7zF 36+GSi8IcgAJ6OBLA9Oi5AZjC0grzv9ynamtsoBSxVH6Df+cMhPSmKIPUfpb/436uoEa SN4jl/kPZAaF57/mPPX1eqAgDgvjBi9DaVfebGODJl8Xl3+y4GhBeqD9gpbw+TimS5Sl rmGZa/AK/j+n2uebn1sF/dOO1a+JLhK51agXaJYZBb45w2Q9DWaVYIf9301bHWHXPZRv tC3g== 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=1ZvNNLs9YHL5F6tWfigNRJClcoTRZ+GFT3G9ZlMqXro=; b=dW4r3c25liqNSrxLyOM9bJU2PEifzNnaDaqcDuPUUEwIdWxbLNjdDAdgx1t0ZJWpLs Ok5I2IpNfwaDMkNY7AaDZry3/31fvQOiKBjO3126i9RgylAaN54GB0CUT2kku7M/9p+X 5vqBGT4dNKwRuR4OR6pyX+SOLNTzAqgtjkMX9T6VucquLlkLKtNeaPPpvabmTgk6yDpJ d32fDV1kaBm27VxmKfoT2doUpxOn5CoVU0W220mJCHOBQRnKPclbkGcG+RQAM3IqrWO5 xhWO6TRRZlWRa0KQJDkHWzCBNAnRlz+r3g1kiSnNuWPXLHES+3h1sRadrQ3AKMV2bMAe Dc4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=MVvKEL4e; 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 r14-20020a05640251ce00b0047cf2d292b8si26082116edd.559.2023.01.02.02.50.53; Mon, 02 Jan 2023 02:51:16 -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=MVvKEL4e; 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 S232427AbjABKtX (ORCPT + 99 others); Mon, 2 Jan 2023 05:49:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231972AbjABKtJ (ORCPT ); Mon, 2 Jan 2023 05:49:09 -0500 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD315B79; Mon, 2 Jan 2023 02:49:08 -0800 (PST) Received: from pps.filterd (m0279865.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3029fNQJ030336; Mon, 2 Jan 2023 10:48:56 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=1ZvNNLs9YHL5F6tWfigNRJClcoTRZ+GFT3G9ZlMqXro=; b=MVvKEL4eMSvojwFEC+79BZJrsV9L0eekkAFhx53Nl19RpVkiJzj1JtD4Svvd39YfeiMt pH3BB2IJKjZXfy+l5DyNXXshQ/Vy07PLKxco/Or9nDnkt/6cZySHg6CZJb9ohsopDJbs BRTGRgXnuysOgvmgCOWP9t0RwxqpN091QiY9NO5OuuoABJJ+2cNLa9YhJQfKS9c0uSg5 nmTRJCzXEChcckqnUQc4qKy04sLl239ViHl5LIDrzZe3K6rnIozbpAF6q2ChOlW+fXT+ XO8dyCK/lOLvDUggjMTvjXbQDiddgUwh2s/D/61i3GxqEU7yPIU2JQvLpXAzCjUrhr6i 5A== Received: from nalasppmta01.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3mtc202nfg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 02 Jan 2023 10:48:55 +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 302Amttv000341 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 2 Jan 2023 10:48:55 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; Mon, 2 Jan 2023 02:48:49 -0800 From: Akhil P Oommen To: freedreno , , , Rob Clark , Ulf Hansson , Bjorn Andersson , Stephen Boyd , Philipp Zabel CC: Akhil P Oommen , Greg Kroah-Hartman , Kevin Hilman , Len Brown , Pavel Machek , "Rafael J. Wysocki" , , Subject: [PATCH v5 1/5] PM: domains: Allow a genpd consumer to require a synced power off Date: Mon, 2 Jan 2023 16:18:27 +0530 Message-ID: <20230102161757.v5.1.I3e6b1f078ad0f1ca9358c573daa7b70ec132cdbe@changeid> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1672656511-1931-1-git-send-email-quic_akhilpo@quicinc.com> References: <1672656511-1931-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-ORIG-GUID: ShIwPCzvseLWnEawiuL7o3TIhORqugrQ X-Proofpoint-GUID: ShIwPCzvseLWnEawiuL7o3TIhORqugrQ 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 suspectscore=0 lowpriorityscore=0 bulkscore=0 mlxlogscore=999 phishscore=0 malwarescore=0 priorityscore=1501 spamscore=0 impostorscore=0 mlxscore=0 clxscore=1015 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301020098 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,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?1753907647758643166?= X-GMAIL-MSGID: =?utf-8?q?1753907647758643166?= 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 --- (no changes since v4) 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