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 From patchwork Mon Jan 2 10:48:28 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: 38070 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp4106204wrt; Mon, 2 Jan 2023 02:51:14 -0800 (PST) X-Google-Smtp-Source: AMrXdXsWZNOSXufto5YxCSaokCXxSTzaUkOVlJQWy2anYZOUGsxHfgl3XuGMpFqIwSy9OB7XY/Th X-Received: by 2002:a17:906:9f0a:b0:7c0:e302:b523 with SMTP id fy10-20020a1709069f0a00b007c0e302b523mr42874333ejc.59.1672656674429; Mon, 02 Jan 2023 02:51:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672656674; cv=none; d=google.com; s=arc-20160816; b=nTxLXxw0srSgd2+aWCCSw6HWmxP49ZoGtRHcv2vSYm8sx4CIZHLNyr9NHbL8DuZqjk JN+fJ22QVHpQw0DIhxde6o8sgcB+jXtaNrbWJI3PB2DvHsVmR9AYUtF82X44JKkokuRR XXwimulXKfWpfofmh9Vrw6h/Xn+uA+gYBSp2BENPj8hs6GwLHNRRa8Hg3XyLa8HXdaPU vbY6e4QacXYKFBA1b9A35QmexrUC6UVQjMKXMMGWtdCcYe1mN96EIeo/JdrBUvc7ooAR on25VkJ256mMacrLQGmlhV0UgATCDX96RVUJS9F1B2rhpaYmX7pnSwWejVwnfi1kjii0 4Y8w== 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=gJFZaBKm1J2oTYrnsJYWMaEEuU4OU/XOBGD0euxe2zc=; b=muWL0LR1oP2bsHWPC3CTlrGOug8+ZywwqWlNJtrnWAhEFqC1zysWbJlNmu1qW/KVqq XgvETrgpRGnIW/Q7k4CyfellAo0S3hhmCO1BSb8n/0mAP1kL92zZzuPWhalObdFkmqW8 /ykbFdhIF1++pMoFOrjtbsSdqfJyeINWTe/U9BCThtGRmeeO21KVqqDrjpZo6AoYEuHg xtrg2Z0XOxJnjQDVrwu4WJhgfrM/7iFdeRs3rb5nSaYIGetCLi55zWpAYBGzyOV9O5wQ xZcak+mmLa8+0TqEVbJMdIETcOjF4ConUfuVDQJj3P7HTI1PiS5SYoyDWFeMAlfARjBG C0Iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b="F7sUMv0/"; 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 hw20-20020a170907a0d400b007c1275dd934si20369607ejc.792.2023.01.02.02.50.50; Mon, 02 Jan 2023 02:51:14 -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="F7sUMv0/"; 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 S232371AbjABKtV (ORCPT + 99 others); Mon, 2 Jan 2023 05:49:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231633AbjABKtI (ORCPT ); Mon, 2 Jan 2023 05:49:08 -0500 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98015B25; Mon, 2 Jan 2023 02:49:07 -0800 (PST) Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3029f4CQ032142; Mon, 2 Jan 2023 10:49:01 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=gJFZaBKm1J2oTYrnsJYWMaEEuU4OU/XOBGD0euxe2zc=; b=F7sUMv0//AfzwdssG5weyD+4c9NDcuLhXHqhyW3JG7jgkV/f0yy/erxbBRtz+Pyj39CT jAaLpVHZnFAXC2FWzLIFGbpmgCfoIvcrfa6zxttkE15al7Ar8vHizPzRK4GKUEHANzgK 77XjtB9ET9IkWsKWkea32qCC5gpRG7ZjsNNCv5wXQf6p6ZQ8e+S5JGoYpc8WfQ/fyq3n 6S7dRcKsTgLgI5mg2WQVaUkWz34f8ViCtp4uYBxgygNncL7DYf77MV8VNws1ZUA9g1yk IQaJrhORHadd7tyQf+aqWJNT1U/fes2ofsBOEPfgLmio7jqe3ccbkHI2jFpthxTW3Urt 5Q== Received: from nalasppmta04.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3mtd61avtc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 02 Jan 2023 10:49:01 +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 302AmxF4007356 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 2 Jan 2023 10:49:00 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:55 -0800 From: Akhil P Oommen To: freedreno , , , Rob Clark , Ulf Hansson , Bjorn Andersson , Stephen Boyd , Philipp Zabel CC: Akhil P Oommen , Andy Gross , Konrad Dybcio , Michael Turquette , , Subject: [PATCH v5 2/5] clk: qcom: gdsc: Support 'synced_poweroff' genpd flag Date: Mon, 2 Jan 2023 16:18:28 +0530 Message-ID: <20230102161757.v5.2.Ic128c1df50b7fc9a6b919932a3b41a799b5ed5e8@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-GUID: VICx3pDz2fGaX6a4ZJRdP0V79wLzPK5W X-Proofpoint-ORIG-GUID: VICx3pDz2fGaX6a4ZJRdP0V79wLzPK5W 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 impostorscore=0 lowpriorityscore=0 malwarescore=0 priorityscore=1501 mlxlogscore=999 clxscore=1015 suspectscore=0 phishscore=0 spamscore=0 adultscore=0 mlxscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301020098 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?1753907644963670712?= X-GMAIL-MSGID: =?utf-8?q?1753907644963670712?= Add support for the newly added 'synced_poweroff' genpd flag. This allows some clients (like adreno gpu driver) to request gdsc driver to ensure a votable gdsc (like gpucc cx gdsc) has collapsed at hardware. Signed-off-by: Akhil P Oommen Reviewed-by: Ulf Hansson --- (no changes since v3) Changes in v3: - Rename the var 'force_sync' to 'wait (Stephen) drivers/clk/qcom/gdsc.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/clk/qcom/gdsc.c b/drivers/clk/qcom/gdsc.c index 9e4d6ce891aa..5358e28122ab 100644 --- a/drivers/clk/qcom/gdsc.c +++ b/drivers/clk/qcom/gdsc.c @@ -136,7 +136,8 @@ static int gdsc_update_collapse_bit(struct gdsc *sc, bool val) return 0; } -static int gdsc_toggle_logic(struct gdsc *sc, enum gdsc_status status) +static int gdsc_toggle_logic(struct gdsc *sc, enum gdsc_status status, + bool wait) { int ret; @@ -149,7 +150,7 @@ static int gdsc_toggle_logic(struct gdsc *sc, enum gdsc_status status) ret = gdsc_update_collapse_bit(sc, status == GDSC_OFF); /* If disabling votable gdscs, don't poll on status */ - if ((sc->flags & VOTABLE) && status == GDSC_OFF) { + if ((sc->flags & VOTABLE) && status == GDSC_OFF && !wait) { /* * Add a short delay here to ensure that an enable * right after it was disabled does not put it in an @@ -275,7 +276,7 @@ static int gdsc_enable(struct generic_pm_domain *domain) gdsc_deassert_clamp_io(sc); } - ret = gdsc_toggle_logic(sc, GDSC_ON); + ret = gdsc_toggle_logic(sc, GDSC_ON, false); if (ret) return ret; @@ -352,7 +353,7 @@ static int gdsc_disable(struct generic_pm_domain *domain) if (sc->pwrsts == PWRSTS_RET_ON) return 0; - ret = gdsc_toggle_logic(sc, GDSC_OFF); + ret = gdsc_toggle_logic(sc, GDSC_OFF, domain->synced_poweroff); if (ret) return ret; @@ -392,7 +393,7 @@ static int gdsc_init(struct gdsc *sc) /* Force gdsc ON if only ON state is supported */ if (sc->pwrsts == PWRSTS_ON) { - ret = gdsc_toggle_logic(sc, GDSC_ON); + ret = gdsc_toggle_logic(sc, GDSC_ON, false); if (ret) return ret; } From patchwork Mon Jan 2 10:48:29 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: 38074 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp4106343wrt; Mon, 2 Jan 2023 02:51:43 -0800 (PST) X-Google-Smtp-Source: AMrXdXvowzBrJDYPrN9Abv0O+LYtHPHDcrXteGFUjQUIPABvQCUpoP3soigBwj59fALulfSSTKh3 X-Received: by 2002:a05:6a20:7d9a:b0:af:9539:a2c0 with SMTP id v26-20020a056a207d9a00b000af9539a2c0mr61796498pzj.26.1672656703089; Mon, 02 Jan 2023 02:51:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672656703; cv=none; d=google.com; s=arc-20160816; b=RicsOV0sWY7I5F6LLNE4QNJIa37eQd4YKkU9q5o/KEmsbbWE5Fp0U4yVW96dHtAss2 2SsVdDS5n1Oo0OEytQFeyTnH/AqxmeLXSLyNIGMN7NhnXVotUMOyH+3hNOcYikc+xsSn DQDKRBqmj/yT7QalhFu6JVjciQqs6hR7wSqY8NV15FxMHGBr7KGV/29UVyal99fz5c5L CoAOlHtcHPdN/FCPTGbO5pfd9EsMMfQMVtC7ppI3xZBDWlWGcW7lieihdjqGNVGTSNwI Ucs79VucqGBjyhiXdTYql2lIty9VVftZT5SvMPkI2C5LFSq1DzrM56qj9xXNY1Jq2AEC oSnQ== 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=8lqJjL9jHslmMbRzyPjVaNyVeIhX99Na9q9L69myhZU=; b=sCAKjytKWgGei7La0/qJjyj7b+W7VC/JIKuftx2c3n6GErwKx0Avf+LpmhBUmG1Pr8 tIuUq+1soAG7beYrhM6KU+6GJrZYTKBaZ68VK9tXXsN1sqY8RAsgtrY0nwFYc9fu1UQU CmX+rGGhX+d8cO9NTxrMABpv/6dI0WiptfdHcq5cID3ovKv4+glIUsq4+4eTR6d+FZ2p j6chz5CSWOIyNVueswT3ksc6i3wFVQiYbzheswnjXU1KZoWIJPnfkeN2Ou3VXhVU6XvR eRf49E0tex2AVQHC7l81BYx2KQ6n4j2iLM8pTLJhbLHKkYF0mCvHq1lHCNzFPbiQo5rR 4l7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=cdiTahRd; 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 j36-20020a63fc24000000b0048e54a7f366si27838918pgi.587.2023.01.02.02.51.31; Mon, 02 Jan 2023 02:51:43 -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=cdiTahRd; 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 S232535AbjABKuE (ORCPT + 99 others); Mon, 2 Jan 2023 05:50:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232481AbjABKtf (ORCPT ); Mon, 2 Jan 2023 05:49:35 -0500 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0EA3EB25; Mon, 2 Jan 2023 02:49:34 -0800 (PST) Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 302AQxmD020756; Mon, 2 Jan 2023 10:49:07 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=8lqJjL9jHslmMbRzyPjVaNyVeIhX99Na9q9L69myhZU=; b=cdiTahRd3tYluyKKrVsfQhnW9N+KGQAaAsrZ7dgfNT5odizKrKCwQvhlmBD5CsHCZf1V ihdF54yPYNdLLgQozIScDNQZjfWTEf09CorGXnfbzBWpNdu0oIHCtSvVn/OcPyM1BF7m TulYs5xsARt0/TZXon/zLcFjxTBk01tdnjH44Y5OQ2QaTvN+mLW9gXFYQrBI6AmibtKP IuWKWCtVbFheEKjInpBunQ5uH4CetQN432LRQmuXf29TIUdQWI7tT2hZb7BYFYRW/k4H lUvpfWmXwS7U5fbz3b6eh//K9IExCUhXscdMYcJ2QmxmcLuJ8Kxe+AIBojxbmMy4PeUo YA== Received: from nalasppmta04.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3mtdabamej-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 02 Jan 2023 10:49:07 +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 302An6Rs007424 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 2 Jan 2023 10:49:06 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:49:00 -0800 From: Akhil P Oommen To: freedreno , , , Rob Clark , Ulf Hansson , Bjorn Andersson , Stephen Boyd , Philipp Zabel CC: Akhil P Oommen , Abhinav Kumar , Daniel Vetter , David Airlie , Dmitry Baryshkov , "Douglas Anderson" , Geert Uytterhoeven , Guenter Roeck , Konrad Dybcio , Sean Paul , Subject: [PATCH v5 3/5] drm/msm/a6xx: Vote for cx gdsc from gpu driver Date: Mon, 2 Jan 2023 16:18:29 +0530 Message-ID: <20230102161757.v5.3.I7f545d8494dcdbe6e96a15fbe8aaf5bb0c003d50@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-GUID: axuk3QOS2xzrB1blzC4lzWRmyNnkLIC6 X-Proofpoint-ORIG-GUID: axuk3QOS2xzrB1blzC4lzWRmyNnkLIC6 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 lowpriorityscore=0 malwarescore=0 adultscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 impostorscore=0 suspectscore=0 bulkscore=0 clxscore=1015 phishscore=0 priorityscore=1501 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?1753907675133587899?= X-GMAIL-MSGID: =?utf-8?q?1753907675133587899?= When a device has multiple power domains, dev->power_domain is left empty during probe. That didn't cause any issue so far because we are freeloading on smmu driver's vote on cx gdsc. Instead of that, create a device_link between cx genpd device and gmu device to keep a vote from gpu driver. Before this patch: localhost ~ # cat /sys/kernel/debug/pm_genpd/pm_genpd_summary gx_gdsc on 0 /devices/genpd:1:3d6a000.gmu active 0 cx_gdsc on 0 /devices/platform/soc@0/3da0000.iommu active 0 After this patch: localhost ~ # cat /sys/kernel/debug/pm_genpd/pm_genpd_summary gx_gdsc on 0 /devices/genpd:1:3d6a000.gmu active 0 cx_gdsc on 0 /devices/platform/soc@0/3da0000.iommu active 0 /devices/genpd:0:3d6a000.gmu active 0 Signed-off-by: Akhil P Oommen Reviewed-by: Ulf Hansson --- (no changes since v1) drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 31 +++++++++++++++++++++++++++---- drivers/gpu/drm/msm/adreno/a6xx_gmu.h | 1 + 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c index 6484b97c5344..1580d0090f35 100644 --- a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c +++ b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c @@ -1479,6 +1479,12 @@ void a6xx_gmu_remove(struct a6xx_gpu *a6xx_gpu) pm_runtime_force_suspend(gmu->dev); + /* + * Since cxpd is a virt device, the devlink with gmu-dev will be removed + * automatically when we do detach + */ + dev_pm_domain_detach(gmu->cxpd, false); + if (!IS_ERR_OR_NULL(gmu->gxpd)) { pm_runtime_disable(gmu->gxpd); dev_pm_domain_detach(gmu->gxpd, false); @@ -1605,8 +1611,10 @@ int a6xx_gmu_init(struct a6xx_gpu *a6xx_gpu, struct device_node *node) if (adreno_is_a650_family(adreno_gpu)) { gmu->rscc = a6xx_gmu_get_mmio(pdev, "rscc"); - if (IS_ERR(gmu->rscc)) + if (IS_ERR(gmu->rscc)) { + ret = -ENODEV; goto err_mmio; + } } else { gmu->rscc = gmu->mmio + 0x23000; } @@ -1615,8 +1623,22 @@ int a6xx_gmu_init(struct a6xx_gpu *a6xx_gpu, struct device_node *node) gmu->hfi_irq = a6xx_gmu_get_irq(gmu, pdev, "hfi", a6xx_hfi_irq); gmu->gmu_irq = a6xx_gmu_get_irq(gmu, pdev, "gmu", a6xx_gmu_irq); - if (gmu->hfi_irq < 0 || gmu->gmu_irq < 0) + if (gmu->hfi_irq < 0 || gmu->gmu_irq < 0) { + ret = -ENODEV; + goto err_mmio; + } + + gmu->cxpd = dev_pm_domain_attach_by_name(gmu->dev, "cx"); + if (IS_ERR(gmu->cxpd)) { + ret = PTR_ERR(gmu->cxpd); goto err_mmio; + } + + if (!device_link_add(gmu->dev, gmu->cxpd, + DL_FLAG_PM_RUNTIME)) { + ret = -ENODEV; + goto detach_cxpd; + } /* * Get a link to the GX power domain to reset the GPU in case of GMU @@ -1634,6 +1656,9 @@ int a6xx_gmu_init(struct a6xx_gpu *a6xx_gpu, struct device_node *node) return 0; +detach_cxpd: + dev_pm_domain_detach(gmu->cxpd, false); + err_mmio: iounmap(gmu->mmio); if (platform_get_resource_byname(pdev, IORESOURCE_MEM, "rscc")) @@ -1641,8 +1666,6 @@ int a6xx_gmu_init(struct a6xx_gpu *a6xx_gpu, struct device_node *node) free_irq(gmu->gmu_irq, gmu); free_irq(gmu->hfi_irq, gmu); - ret = -ENODEV; - err_memory: a6xx_gmu_memory_free(gmu); err_put_device: diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gmu.h b/drivers/gpu/drm/msm/adreno/a6xx_gmu.h index e034935b3986..5a42dd4dd31f 100644 --- a/drivers/gpu/drm/msm/adreno/a6xx_gmu.h +++ b/drivers/gpu/drm/msm/adreno/a6xx_gmu.h @@ -56,6 +56,7 @@ struct a6xx_gmu { int gmu_irq; struct device *gxpd; + struct device *cxpd; int idle_level; From patchwork Mon Jan 2 10:48:30 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: 38073 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp4106337wrt; Mon, 2 Jan 2023 02:51:42 -0800 (PST) X-Google-Smtp-Source: AMrXdXthY70umYGL2RdgSvS8l574O112SZFiJZnMHQQwYUr+3nKSKyYj8n7wjT9qFvzm2i7Tjwig X-Received: by 2002:a05:6a20:8341:b0:ad:a5fd:b659 with SMTP id z1-20020a056a20834100b000ada5fdb659mr36965894pzc.7.1672656701917; Mon, 02 Jan 2023 02:51:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672656701; cv=none; d=google.com; s=arc-20160816; b=tLHUQFZaOU8OFUWtBEq/HybaFbmBTj6gZBuQt0mWybqPwzGmmuydg6U96tmUZ+rQGw kUQIVkRPecsMQaCqVa5rCfnVF0l1ZV0gQ0zJvCQlxS4+QetDCf10ALmpwGHrVgZK9F9F gWboi8DUE8gsP9FXCfY2gsX6yeOBsKcKhc6vC9ygswQsuqSazeMtdRiq+bMepr/7Bq7b C1/59ZvuxqqIepjax9VmArHxyKQJydYZ9uBWsRc4yHNRoM2rRSBP9DIOGE1vNxnlw/0b 9uOSWGuihHi2nEg3gyf/Mr03kD8DUixtPIxJ1tnO+SCWNSDd5CrUPD9rRGUQ9s96X0bx 6VzA== 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=wfzCuv2Ut8akRnI/rige7c6Hypvi9XxXIunuUHzQ1N0=; b=Ix0ldH1vWSxkfjS0bZr6B5vOWCD4Qvz7TgmX5qKpIumyfnJnB1zPKOiHuEahkzrlHZ TXOHQZcuCYq+/7jawfS+kFU9LCZkrErsZ068xGLjgHk0+htwhTDniuNGJxXu1HlFUl9z SVVqVFc8NBRWP8IGnCw85iIseEjBME6NkroN0v/XiG5DN+uc8h/Ia/SiY9yNw8F3V9c4 Y3IWUAy5/7EIZglLYY63Yb04kAFemB3zzx8KpxEU3w6hqI4nq28/jFN//1kNC5XWz2BO yG4JvdAahkTmlAZgI8v2c2R7wiCcmU45s5rbiLYcQrgSfibpmOA1zHOz1bjPk2CnwB6H W6Iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=m9ou3jZ9; 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 v1-20020a170902b7c100b0017336c464ecsi28092701plz.407.2023.01.02.02.51.29; Mon, 02 Jan 2023 02:51:41 -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=m9ou3jZ9; 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 S232512AbjABKt7 (ORCPT + 99 others); Mon, 2 Jan 2023 05:49:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232471AbjABKtX (ORCPT ); Mon, 2 Jan 2023 05:49:23 -0500 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CFB69B25; Mon, 2 Jan 2023 02:49:22 -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 302AdVmk001973; Mon, 2 Jan 2023 10:49:13 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=wfzCuv2Ut8akRnI/rige7c6Hypvi9XxXIunuUHzQ1N0=; b=m9ou3jZ9oxmYtKQgoRhLk5U/13X8RoxerIXzW9R962zOIdFouTKlYD10uWu14HZ3m5vq TAYXrCDRM8sklW1i8Uxo7VMcOm0SSuOdwk7eKDVei+BF5bO+tbdnR18ecukIq7UhcAQb lZtmTxX/lxIJLOZH9Je+K9RAii7TP6zRRu5LI9Dwg4Sdoxz3qkB20tjhwBqK1pvu/87F r+2eDxg4Zav+Jz2kWyHPYqeofXo/xO8NjEYUMl7udIMqPBw16NEGVuTMNIXgyv0aXYAD NCszSqicCQVKjMM91BgFbDo+JFC5dDNyj2e2zHoVLsnrcJBMk0v68YEr3nt/WKV6D1qJ LA== Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3mtaewb31r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 02 Jan 2023 10:49:13 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 302AnC4N012728 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 2 Jan 2023 10:49:12 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:49:06 -0800 From: Akhil P Oommen To: freedreno , , , Rob Clark , Ulf Hansson , Bjorn Andersson , Stephen Boyd , Philipp Zabel CC: Akhil P Oommen , Abhinav Kumar , Chia-I Wu , Daniel Vetter , David Airlie , Dmitry Baryshkov , Douglas Anderson , Konrad Dybcio , Sean Paul , Subject: [PATCH v5 4/5] drm/msm/a6xx: Remove cx gdsc polling using 'reset' Date: Mon, 2 Jan 2023 16:18:30 +0530 Message-ID: <20230102161757.v5.4.I96e0bf9eaf96dd866111c1eec8a4c9b70fd7cbcb@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: fIwE4au6IqhOrhp_wSUYFIsVWKxsR_Ht X-Proofpoint-GUID: fIwE4au6IqhOrhp_wSUYFIsVWKxsR_Ht 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-2301020098 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?1753907673393840360?= X-GMAIL-MSGID: =?utf-8?q?1753907673393840360?= Remove the unused 'reset' interface which was supposed to help to ensure that cx gdsc has collapsed during gpu recovery. This is was not enabled so far due to missing gpucc driver support. Similar functionality using genpd framework will be implemented in the upcoming patch. This effectively reverts commit 1f6cca404918 ("drm/msm/a6xx: Ensure CX collapse during gpu recovery"). Signed-off-by: Akhil P Oommen Reviewed-by: Ulf Hansson Reviewed-by: Philipp Zabel --- (no changes since v3) Changes in v3: - Updated commit msg (Philipp) drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 4 ---- drivers/gpu/drm/msm/msm_gpu.c | 4 ---- drivers/gpu/drm/msm/msm_gpu.h | 4 ---- 3 files changed, 12 deletions(-) diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c index 36c8fb699b56..4b16e75dfa50 100644 --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c @@ -10,7 +10,6 @@ #include #include -#include #include #define GPU_PAS_ID 13 @@ -1298,9 +1297,6 @@ static void a6xx_recover(struct msm_gpu *gpu) /* And the final one from recover worker */ pm_runtime_put_sync(&gpu->pdev->dev); - /* Call into gpucc driver to poll for cx gdsc collapse */ - reset_control_reset(gpu->cx_collapse); - pm_runtime_use_autosuspend(&gpu->pdev->dev); if (active_submits) diff --git a/drivers/gpu/drm/msm/msm_gpu.c b/drivers/gpu/drm/msm/msm_gpu.c index 30ed45af76ad..97e1319d4577 100644 --- a/drivers/gpu/drm/msm/msm_gpu.c +++ b/drivers/gpu/drm/msm/msm_gpu.c @@ -16,7 +16,6 @@ #include #include #include -#include #include /* @@ -933,9 +932,6 @@ int msm_gpu_init(struct drm_device *drm, struct platform_device *pdev, if (IS_ERR(gpu->gpu_cx)) gpu->gpu_cx = NULL; - gpu->cx_collapse = devm_reset_control_get_optional_exclusive(&pdev->dev, - "cx_collapse"); - gpu->pdev = pdev; platform_set_drvdata(pdev, &gpu->adreno_smmu); diff --git a/drivers/gpu/drm/msm/msm_gpu.h b/drivers/gpu/drm/msm/msm_gpu.h index 651786bc55e5..fa9e34d02c91 100644 --- a/drivers/gpu/drm/msm/msm_gpu.h +++ b/drivers/gpu/drm/msm/msm_gpu.h @@ -13,7 +13,6 @@ #include #include #include -#include #include "msm_drv.h" #include "msm_fence.h" @@ -282,9 +281,6 @@ struct msm_gpu { bool hw_apriv; struct thermal_cooling_device *cooling; - - /* To poll for cx gdsc collapse during gpu recovery */ - struct reset_control *cx_collapse; }; static inline struct msm_gpu *dev_to_gpu(struct device *dev) From patchwork Mon Jan 2 10:48:31 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: 38075 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp4106410wrt; Mon, 2 Jan 2023 02:51:58 -0800 (PST) X-Google-Smtp-Source: AMrXdXsmJS0bBjTOazfi9QxWoiGfgFHeDMR+qwWg3npjhFy4tmOMswDk2576gueOuoM9C8skuo92 X-Received: by 2002:a17:907:c99d:b0:7c0:d88b:1695 with SMTP id uj29-20020a170907c99d00b007c0d88b1695mr29297088ejc.55.1672656718471; Mon, 02 Jan 2023 02:51:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672656718; cv=none; d=google.com; s=arc-20160816; b=WLqOTz6ZZBRaJi+oQiEhqouliKNh/oklWrRFgvBkLoWosR2MXGvATPk4SgsTfd8Daj E9LtE9F0SkTCzMbjPD7yDcBoCpGA4uyTuaVyUdzEW9IZLUJRvW6yOjqNZEwXy1Upd4y8 KCOPXcYQsshjMiQ7/2dqgFkSmvRJImatziB1GV6PL5dhMtqyUJOUKOzIrAQJLeADT5N9 rePyVuEtPHnckqsEaSeM6yrEW2dEI1uBZkjUBFTndsKPhdm8Mm+2DJIr/FaAk7akYLG0 tZIVd7kfT72NCW4cOLWFpKETCPWqE6e1oDhIlPAyaIQil6hx/FgNrXTQc/zOv+Gc9qWT Pj9w== 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=vP4cwRcWki3cMWzaww8+zSXXB5DIbu/Yv3Swnz6JckQ=; b=IzBek+d59P2gsod+1fFBqrEAaGMUSQJzEiMo9AESpGkHIzt0H0zdKc9dVobWZ7NlZc gEuNZeWVZm3eRAQoyOscq0aoPrs68kUNlTeToIvxBu5iIu0GeTcKBmA/4D7ogW6TitJI VZPTkoT1g4VJ9bM6LMqD512nEsEgygxyhePcAwTOlslRcllcacQ8Aw9jAMxb1PwMIsT/ EGZVuk1FcfdSDdcYrcZX9rtERzAqAgBefFZLK9OYOtPnRRKn9FjAJwdVS0J6gdUhL5s3 KFAq+OwDTyxHmUdWfWFKSwq97TDIQtEyLXMWRBP/o5YnpvZ5y9s0vWryxJitVHb3qEyk vtPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=icnaEWB+; 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 ji5-20020a170907980500b007addbdb9fbbsi25878203ejc.558.2023.01.02.02.51.34; Mon, 02 Jan 2023 02:51:58 -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=icnaEWB+; 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 S232481AbjABKuK (ORCPT + 99 others); Mon, 2 Jan 2023 05:50:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232490AbjABKtn (ORCPT ); Mon, 2 Jan 2023 05:49:43 -0500 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 963CFB87; Mon, 2 Jan 2023 02:49:42 -0800 (PST) Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 302AG7PT028684; Mon, 2 Jan 2023 10:49:19 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=vP4cwRcWki3cMWzaww8+zSXXB5DIbu/Yv3Swnz6JckQ=; b=icnaEWB+Eldb29GhObMhfkpRDc/saV9xSGYAOzOXr4PnChCf7/ARncsIrUMcNBGrmY9z BVQt8oDLGPcZ5m+MceDKFjg+u068DvwvD26O8l6B0WjtZluh66iQvIi7eO8+sGFJFlFj o7r500e04f7I94Z71/gsepHeR060tR7SDrswSrloJUCkxx1MlTSe0UrUL/Cqz1jlIYgW LS2C5JFE/fxrMTb9oBfuTI3wJiujrE8gOV32Nb6vLTXICqlcsLXg+An0mP3MnNulb9CI jBYt4GBGSWWNu8srcIr2F5qjQPHpyYuTkDGztF0eAkn4dbyFnZmTwv7W2YYbFeSxKo++ Jg== Received: from nalasppmta04.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3mtd61avtu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 02 Jan 2023 10:49:19 +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 302AnIBl007505 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 2 Jan 2023 10:49:18 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:49:12 -0800 From: Akhil P Oommen To: freedreno , , , Rob Clark , Ulf Hansson , Bjorn Andersson , Stephen Boyd , Philipp Zabel CC: Akhil P Oommen , Abhinav Kumar , Chia-I Wu , Daniel Vetter , David Airlie , Dmitry Baryshkov , Douglas Anderson , Geert Uytterhoeven , Guenter Roeck , Konrad Dybcio , Sean Paul , Subject: [PATCH v5 5/5] drm/msm/a6xx: Use genpd notifier to ensure cx-gdsc collapse Date: Mon, 2 Jan 2023 16:18:31 +0530 Message-ID: <20230102161757.v5.5.I9e10545c6a448d5eb1b734839b871d1b3146dac3@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-GUID: FnKxYPAyC9cKh-vTeEIjMl9zcOCYDZ3c X-Proofpoint-ORIG-GUID: FnKxYPAyC9cKh-vTeEIjMl9zcOCYDZ3c 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 impostorscore=0 lowpriorityscore=0 malwarescore=0 priorityscore=1501 mlxlogscore=999 clxscore=1015 suspectscore=0 phishscore=0 spamscore=0 adultscore=0 mlxscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301020098 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?1753907691620670038?= X-GMAIL-MSGID: =?utf-8?q?1753907691620670038?= As per the recommended recovery sequence of adreno gpu, cx gdsc should collapse at hardware before it is turned back ON. This helps to clear out the stale states in hardware before it is reinitialized. Use the genpd notifier along with the newly introduced dev_pm_genpd_synced_poweroff() api to ensure that cx gdsc has collapsed before we turn it back ON. Signed-off-by: Akhil P Oommen Reviewed-by: Ulf Hansson --- (no changes since v2) Changes in v2: - Select PM_GENERIC_DOMAINS from Kconfig drivers/gpu/drm/msm/Kconfig | 1 + drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 15 +++++++++++++++ drivers/gpu/drm/msm/adreno/a6xx_gmu.h | 6 ++++++ drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 11 +++++++++++ 4 files changed, 33 insertions(+) diff --git a/drivers/gpu/drm/msm/Kconfig b/drivers/gpu/drm/msm/Kconfig index 3c9dfdb0b328..74f5916f5ca5 100644 --- a/drivers/gpu/drm/msm/Kconfig +++ b/drivers/gpu/drm/msm/Kconfig @@ -28,6 +28,7 @@ config DRM_MSM select SYNC_FILE select PM_OPP select NVMEM + select PM_GENERIC_DOMAINS help DRM/KMS driver for MSM/snapdragon. diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c index 1580d0090f35..c03830957c26 100644 --- a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c +++ b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c @@ -1507,6 +1507,17 @@ void a6xx_gmu_remove(struct a6xx_gpu *a6xx_gpu) gmu->initialized = false; } +static int cxpd_notifier_cb(struct notifier_block *nb, + unsigned long action, void *data) +{ + struct a6xx_gmu *gmu = container_of(nb, struct a6xx_gmu, pd_nb); + + if (action == GENPD_NOTIFY_OFF) + complete_all(&gmu->pd_gate); + + return 0; +} + int a6xx_gmu_init(struct a6xx_gpu *a6xx_gpu, struct device_node *node) { struct adreno_gpu *adreno_gpu = &a6xx_gpu->base; @@ -1640,6 +1651,10 @@ int a6xx_gmu_init(struct a6xx_gpu *a6xx_gpu, struct device_node *node) goto detach_cxpd; } + init_completion(&gmu->pd_gate); + complete_all(&gmu->pd_gate); + gmu->pd_nb.notifier_call = cxpd_notifier_cb; + /* * Get a link to the GX power domain to reset the GPU in case of GMU * crash diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gmu.h b/drivers/gpu/drm/msm/adreno/a6xx_gmu.h index 5a42dd4dd31f..0bc3eb443fec 100644 --- a/drivers/gpu/drm/msm/adreno/a6xx_gmu.h +++ b/drivers/gpu/drm/msm/adreno/a6xx_gmu.h @@ -4,8 +4,10 @@ #ifndef _A6XX_GMU_H_ #define _A6XX_GMU_H_ +#include #include #include +#include #include "msm_drv.h" #include "a6xx_hfi.h" @@ -90,6 +92,10 @@ struct a6xx_gmu { bool initialized; bool hung; bool legacy; /* a618 or a630 */ + + /* For power domain callback */ + struct notifier_block pd_nb; + struct completion pd_gate; }; static inline u32 gmu_read(struct a6xx_gmu *gmu, u32 offset) diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c index 4b16e75dfa50..dd618b099110 100644 --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c @@ -10,6 +10,7 @@ #include #include +#include #include #define GPU_PAS_ID 13 @@ -1258,6 +1259,7 @@ static void a6xx_recover(struct msm_gpu *gpu) { struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu); struct a6xx_gpu *a6xx_gpu = to_a6xx_gpu(adreno_gpu); + struct a6xx_gmu *gmu = &a6xx_gpu->gmu; int i, active_submits; adreno_dump_info(gpu); @@ -1290,6 +1292,10 @@ static void a6xx_recover(struct msm_gpu *gpu) */ gpu->active_submits = 0; + reinit_completion(&gmu->pd_gate); + dev_pm_genpd_add_notifier(gmu->cxpd, &gmu->pd_nb); + dev_pm_genpd_synced_poweroff(gmu->cxpd); + /* Drop the rpm refcount from active submits */ if (active_submits) pm_runtime_put(&gpu->pdev->dev); @@ -1297,6 +1303,11 @@ static void a6xx_recover(struct msm_gpu *gpu) /* And the final one from recover worker */ pm_runtime_put_sync(&gpu->pdev->dev); + if (!wait_for_completion_timeout(&gmu->pd_gate, msecs_to_jiffies(1000))) + DRM_DEV_ERROR(&gpu->pdev->dev, "cx gdsc didn't collapse\n"); + + dev_pm_genpd_remove_notifier(gmu->cxpd); + pm_runtime_use_autosuspend(&gpu->pdev->dev); if (active_submits)