Message ID | 20230102161757.v5.5.I9e10545c6a448d5eb1b734839b871d1b3146dac3@changeid |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> 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 <rfc822;wlfightup@gmail.com> + 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 <rfc822;linux-kernel@vger.kernel.org>); 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 <quic_akhilpo@quicinc.com> To: freedreno <freedreno@lists.freedesktop.org>, <dri-devel@lists.freedesktop.org>, <linux-arm-msm@vger.kernel.org>, Rob Clark <robdclark@gmail.com>, Ulf Hansson <ulf.hansson@linaro.org>, Bjorn Andersson <andersson@kernel.org>, Stephen Boyd <sboyd@kernel.org>, Philipp Zabel <p.zabel@pengutronix.de> CC: Akhil P Oommen <quic_akhilpo@quicinc.com>, Abhinav Kumar <quic_abhinavk@quicinc.com>, Chia-I Wu <olvaffe@gmail.com>, Daniel Vetter <daniel@ffwll.ch>, David Airlie <airlied@gmail.com>, Dmitry Baryshkov <dmitry.baryshkov@linaro.org>, Douglas Anderson <dianders@chromium.org>, Geert Uytterhoeven <geert@linux-m68k.org>, Guenter Roeck <linux@roeck-us.net>, Konrad Dybcio <konrad.dybcio@somainline.org>, Sean Paul <sean@poorly.run>, <linux-kernel@vger.kernel.org> 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 Content-Type: text/plain 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: <linux-kernel.vger.kernel.org> 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?= |
Series |
Improve GPU reset sequence for Adreno GPU
|
|
Commit Message
Akhil P Oommen
Jan. 2, 2023, 10:48 a.m. UTC
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 <quic_akhilpo@quicinc.com> Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org> --- (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(+)
Comments
Hi Akhil, Thank you for the patch! Yet something to improve: [auto build test ERROR on rafael-pm/linux-next] [also build test ERROR on drm/drm-next drm-intel/for-linux-next drm-intel/for-linux-next-fixes drm-tip/drm-tip linus/master v6.2-rc2 next-20221226] [cannot apply to drm-misc/drm-misc-next clk/clk-next drm-exynos/exynos-drm-next] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Akhil-P-Oommen/PM-domains-Allow-a-genpd-consumer-to-require-a-synced-power-off/20230102-185027 base: https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next patch link: https://lore.kernel.org/r/20230102161757.v5.5.I9e10545c6a448d5eb1b734839b871d1b3146dac3%40changeid patch subject: [PATCH v5 5/5] drm/msm/a6xx: Use genpd notifier to ensure cx-gdsc collapse config: ia64-randconfig-r004-20230102 compiler: ia64-linux-gcc (GCC) 12.1.0 reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # https://github.com/intel-lab-lkp/linux/commit/c9b6ea9d206842b4117757b53c1bf66363090e1d git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Akhil-P-Oommen/PM-domains-Allow-a-genpd-consumer-to-require-a-synced-power-off/20230102-185027 git checkout c9b6ea9d206842b4117757b53c1bf66363090e1d # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=ia64 olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=ia64 SHELL=/bin/bash drivers/base/power/ If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot <lkp@intel.com> All errors (new ones prefixed by >>): drivers/base/power/domain.c: In function 'genpd_queue_power_off_work': >> drivers/base/power/domain.c:657:20: error: 'pm_wq' undeclared (first use in this function) 657 | queue_work(pm_wq, &genpd->power_off_work); | ^~~~~ drivers/base/power/domain.c:657:20: note: each undeclared identifier is reported only once for each function it appears in drivers/base/power/domain.c: In function 'genpd_dev_pm_qos_notifier': >> drivers/base/power/domain.c:856:39: error: 'struct dev_pm_info' has no member named 'ignore_children' 856 | if (!dev || dev->power.ignore_children) | ^ drivers/base/power/domain.c: In function 'rtpm_status_str': >> drivers/base/power/domain.c:3093:23: error: 'struct dev_pm_info' has no member named 'runtime_error' 3093 | if (dev->power.runtime_error) | ^ >> drivers/base/power/domain.c:3095:28: error: 'struct dev_pm_info' has no member named 'disable_depth' 3095 | else if (dev->power.disable_depth) | ^ >> drivers/base/power/domain.c:3097:28: error: 'struct dev_pm_info' has no member named 'runtime_status' 3097 | else if (dev->power.runtime_status < ARRAY_SIZE(status_lookup)) | ^ drivers/base/power/domain.c:3098:45: error: 'struct dev_pm_info' has no member named 'runtime_status' 3098 | p = status_lookup[dev->power.runtime_status]; | ^ -- drivers/base/power/domain_governor.c: In function 'default_suspend_ok': >> drivers/base/power/domain_governor.c:85:24: error: 'struct dev_pm_info' has no member named 'ignore_children' 85 | if (!dev->power.ignore_children) | ^ Kconfig warnings: (for reference only) WARNING: unmet direct dependencies detected for PM_GENERIC_DOMAINS Depends on [n]: PM [=n] Selected by [y]: - DRM_MSM [=y] && HAS_IOMEM [=y] && DRM [=y] && (ARCH_QCOM || SOC_IMX5 || COMPILE_TEST [=y]) && COMMON_CLK [=y] && IOMMU_SUPPORT [=y] && (QCOM_OCMEM [=n] || QCOM_OCMEM [=n]=n) && (QCOM_LLCC [=y] || QCOM_LLCC [=y]=n) && (QCOM_COMMAND_DB [=n] || QCOM_COMMAND_DB [=n]=n) vim +/pm_wq +657 drivers/base/power/domain.c c8f0ea45169c57 Geert Uytterhoeven 2014-11-10 647 29e47e2173349e Ulf Hansson 2015-09-02 648 /** 86e12eac1f7f84 Ulf Hansson 2016-12-08 649 * genpd_queue_power_off_work - Queue up the execution of genpd_power_off(). a3d09c73492e57 Moritz Fischer 2016-01-27 650 * @genpd: PM domain to power off. 29e47e2173349e Ulf Hansson 2015-09-02 651 * 86e12eac1f7f84 Ulf Hansson 2016-12-08 652 * Queue up the execution of genpd_power_off() unless it's already been done 29e47e2173349e Ulf Hansson 2015-09-02 653 * before. 29e47e2173349e Ulf Hansson 2015-09-02 654 */ 29e47e2173349e Ulf Hansson 2015-09-02 655 static void genpd_queue_power_off_work(struct generic_pm_domain *genpd) 29e47e2173349e Ulf Hansson 2015-09-02 656 { 29e47e2173349e Ulf Hansson 2015-09-02 @657 queue_work(pm_wq, &genpd->power_off_work); 29e47e2173349e Ulf Hansson 2015-09-02 658 } 29e47e2173349e Ulf Hansson 2015-09-02 659 1f8728b7adc4c2 Ulf Hansson 2017-02-17 660 /** 1f8728b7adc4c2 Ulf Hansson 2017-02-17 661 * genpd_power_off - Remove power from a given PM domain. 1f8728b7adc4c2 Ulf Hansson 2017-02-17 662 * @genpd: PM domain to power down. 3c64649d1cf9f3 Ulf Hansson 2017-02-17 663 * @one_dev_on: If invoked from genpd's ->runtime_suspend|resume() callback, the 3c64649d1cf9f3 Ulf Hansson 2017-02-17 664 * RPM status of the releated device is in an intermediate state, not yet turned 3c64649d1cf9f3 Ulf Hansson 2017-02-17 665 * into RPM_SUSPENDED. This means genpd_power_off() must allow one device to not 3c64649d1cf9f3 Ulf Hansson 2017-02-17 666 * be RPM_SUSPENDED, while it tries to power off the PM domain. 763663c9715f5f Yang Yingliang 2021-05-12 667 * @depth: nesting count for lockdep. 1f8728b7adc4c2 Ulf Hansson 2017-02-17 668 * 1f8728b7adc4c2 Ulf Hansson 2017-02-17 669 * If all of the @genpd's devices have been suspended and all of its subdomains 1f8728b7adc4c2 Ulf Hansson 2017-02-17 670 * have been powered down, remove power from @genpd. 1f8728b7adc4c2 Ulf Hansson 2017-02-17 671 */ 2da835452a0875 Ulf Hansson 2017-02-17 672 static int genpd_power_off(struct generic_pm_domain *genpd, bool one_dev_on, 2da835452a0875 Ulf Hansson 2017-02-17 673 unsigned int depth) 1f8728b7adc4c2 Ulf Hansson 2017-02-17 674 { 1f8728b7adc4c2 Ulf Hansson 2017-02-17 675 struct pm_domain_data *pdd; 1f8728b7adc4c2 Ulf Hansson 2017-02-17 676 struct gpd_link *link; 1f8728b7adc4c2 Ulf Hansson 2017-02-17 677 unsigned int not_suspended = 0; f63816e43d9044 Ulf Hansson 2020-09-24 678 int ret; 1f8728b7adc4c2 Ulf Hansson 2017-02-17 679 1f8728b7adc4c2 Ulf Hansson 2017-02-17 680 /* 1f8728b7adc4c2 Ulf Hansson 2017-02-17 681 * Do not try to power off the domain in the following situations: 1f8728b7adc4c2 Ulf Hansson 2017-02-17 682 * (1) The domain is already in the "power off" state. 1f8728b7adc4c2 Ulf Hansson 2017-02-17 683 * (2) System suspend is in progress. 1f8728b7adc4c2 Ulf Hansson 2017-02-17 684 */ 41e2c8e0060db2 Ulf Hansson 2017-03-20 685 if (!genpd_status_on(genpd) || genpd->prepared_count > 0) 1f8728b7adc4c2 Ulf Hansson 2017-02-17 686 return 0; 1f8728b7adc4c2 Ulf Hansson 2017-02-17 687 ffaa42e8a40b7f Ulf Hansson 2017-03-20 688 /* ffaa42e8a40b7f Ulf Hansson 2017-03-20 689 * Abort power off for the PM domain in the following situations: ffaa42e8a40b7f Ulf Hansson 2017-03-20 690 * (1) The domain is configured as always on. ffaa42e8a40b7f Ulf Hansson 2017-03-20 691 * (2) When the domain has a subdomain being powered on. ffaa42e8a40b7f Ulf Hansson 2017-03-20 692 */ ed61e18a4b4e44 Leonard Crestez 2019-04-30 693 if (genpd_is_always_on(genpd) || ed61e18a4b4e44 Leonard Crestez 2019-04-30 694 genpd_is_rpm_always_on(genpd) || ed61e18a4b4e44 Leonard Crestez 2019-04-30 695 atomic_read(&genpd->sd_count) > 0) 1f8728b7adc4c2 Ulf Hansson 2017-02-17 696 return -EBUSY; 1f8728b7adc4c2 Ulf Hansson 2017-02-17 697 e7d90cfac5510f Ulf Hansson 2022-02-17 698 /* e7d90cfac5510f Ulf Hansson 2022-02-17 699 * The children must be in their deepest (powered-off) states to allow e7d90cfac5510f Ulf Hansson 2022-02-17 700 * the parent to be powered off. Note that, there's no need for e7d90cfac5510f Ulf Hansson 2022-02-17 701 * additional locking, as powering on a child, requires the parent's e7d90cfac5510f Ulf Hansson 2022-02-17 702 * lock to be acquired first. e7d90cfac5510f Ulf Hansson 2022-02-17 703 */ e7d90cfac5510f Ulf Hansson 2022-02-17 704 list_for_each_entry(link, &genpd->parent_links, parent_node) { e7d90cfac5510f Ulf Hansson 2022-02-17 705 struct generic_pm_domain *child = link->child; e7d90cfac5510f Ulf Hansson 2022-02-17 706 if (child->state_idx < child->state_count - 1) e7d90cfac5510f Ulf Hansson 2022-02-17 707 return -EBUSY; e7d90cfac5510f Ulf Hansson 2022-02-17 708 } e7d90cfac5510f Ulf Hansson 2022-02-17 709 1f8728b7adc4c2 Ulf Hansson 2017-02-17 710 list_for_each_entry(pdd, &genpd->dev_list, list_node) { 1f8728b7adc4c2 Ulf Hansson 2017-02-17 711 /* 1f8728b7adc4c2 Ulf Hansson 2017-02-17 712 * Do not allow PM domain to be powered off, when an IRQ safe 1f8728b7adc4c2 Ulf Hansson 2017-02-17 713 * device is part of a non-IRQ safe domain. 1f8728b7adc4c2 Ulf Hansson 2017-02-17 714 */ 1f8728b7adc4c2 Ulf Hansson 2017-02-17 715 if (!pm_runtime_suspended(pdd->dev) || 7a02444b8fc25a Ulf Hansson 2022-05-11 716 irq_safe_dev_in_sleep_domain(pdd->dev, genpd)) 1f8728b7adc4c2 Ulf Hansson 2017-02-17 717 not_suspended++; 1f8728b7adc4c2 Ulf Hansson 2017-02-17 718 } 1f8728b7adc4c2 Ulf Hansson 2017-02-17 719 3c64649d1cf9f3 Ulf Hansson 2017-02-17 720 if (not_suspended > 1 || (not_suspended == 1 && !one_dev_on)) 1f8728b7adc4c2 Ulf Hansson 2017-02-17 721 return -EBUSY; 1f8728b7adc4c2 Ulf Hansson 2017-02-17 722 1f8728b7adc4c2 Ulf Hansson 2017-02-17 723 if (genpd->gov && genpd->gov->power_down_ok) { 1f8728b7adc4c2 Ulf Hansson 2017-02-17 724 if (!genpd->gov->power_down_ok(&genpd->domain)) 1f8728b7adc4c2 Ulf Hansson 2017-02-17 725 return -EAGAIN; 1f8728b7adc4c2 Ulf Hansson 2017-02-17 726 } 1f8728b7adc4c2 Ulf Hansson 2017-02-17 727 2c9b7f8772033c Ulf Hansson 2018-10-03 728 /* Default to shallowest state. */ 2c9b7f8772033c Ulf Hansson 2018-10-03 729 if (!genpd->gov) 2c9b7f8772033c Ulf Hansson 2018-10-03 730 genpd->state_idx = 0; 2c9b7f8772033c Ulf Hansson 2018-10-03 731 f63816e43d9044 Ulf Hansson 2020-09-24 732 /* Don't power off, if a child domain is waiting to power on. */ 1f8728b7adc4c2 Ulf Hansson 2017-02-17 733 if (atomic_read(&genpd->sd_count) > 0) 1f8728b7adc4c2 Ulf Hansson 2017-02-17 734 return -EBUSY; 1f8728b7adc4c2 Ulf Hansson 2017-02-17 735 1f8728b7adc4c2 Ulf Hansson 2017-02-17 736 ret = _genpd_power_off(genpd, true); c6a113b52302ad Lina Iyer 2020-10-15 737 if (ret) { c6a113b52302ad Lina Iyer 2020-10-15 738 genpd->states[genpd->state_idx].rejected++; 1f8728b7adc4c2 Ulf Hansson 2017-02-17 739 return ret; c6a113b52302ad Lina Iyer 2020-10-15 740 } 1f8728b7adc4c2 Ulf Hansson 2017-02-17 741 49f618e1b669ef Ulf Hansson 2020-09-24 742 genpd->status = GENPD_STATE_OFF; afece3ab9a3640 Thara Gopinath 2017-07-14 743 genpd_update_accounting(genpd); c6a113b52302ad Lina Iyer 2020-10-15 744 genpd->states[genpd->state_idx].usage++; 1f8728b7adc4c2 Ulf Hansson 2017-02-17 745 8d87ae48ced2df Kees Cook 2020-07-08 746 list_for_each_entry(link, &genpd->child_links, child_node) { 8d87ae48ced2df Kees Cook 2020-07-08 747 genpd_sd_counter_dec(link->parent); 8d87ae48ced2df Kees Cook 2020-07-08 748 genpd_lock_nested(link->parent, depth + 1); 8d87ae48ced2df Kees Cook 2020-07-08 749 genpd_power_off(link->parent, false, depth + 1); 8d87ae48ced2df Kees Cook 2020-07-08 750 genpd_unlock(link->parent); 1f8728b7adc4c2 Ulf Hansson 2017-02-17 751 } 1f8728b7adc4c2 Ulf Hansson 2017-02-17 752 1f8728b7adc4c2 Ulf Hansson 2017-02-17 753 return 0; 1f8728b7adc4c2 Ulf Hansson 2017-02-17 754 } 1f8728b7adc4c2 Ulf Hansson 2017-02-17 755 5248051b9afb66 Rafael J. Wysocki 2011-07-01 756 /** 8d87ae48ced2df Kees Cook 2020-07-08 757 * genpd_power_on - Restore power to a given PM domain and its parents. 5248051b9afb66 Rafael J. Wysocki 2011-07-01 758 * @genpd: PM domain to power up. 0106ef5146f9e8 Marek Szyprowski 2016-01-20 759 * @depth: nesting count for lockdep. 5248051b9afb66 Rafael J. Wysocki 2011-07-01 760 * 8d87ae48ced2df Kees Cook 2020-07-08 761 * Restore power to @genpd and all of its parents so that it is possible to 5248051b9afb66 Rafael J. Wysocki 2011-07-01 762 * resume a device belonging to it. 5248051b9afb66 Rafael J. Wysocki 2011-07-01 763 */ 86e12eac1f7f84 Ulf Hansson 2016-12-08 764 static int genpd_power_on(struct generic_pm_domain *genpd, unsigned int depth) 5248051b9afb66 Rafael J. Wysocki 2011-07-01 765 { 5063ce1571b738 Rafael J. Wysocki 2011-08-08 766 struct gpd_link *link; 5248051b9afb66 Rafael J. Wysocki 2011-07-01 767 int ret = 0; 5248051b9afb66 Rafael J. Wysocki 2011-07-01 768 41e2c8e0060db2 Ulf Hansson 2017-03-20 769 if (genpd_status_on(genpd)) 3f241775c30365 Rafael J. Wysocki 2011-08-08 770 return 0; 5248051b9afb66 Rafael J. Wysocki 2011-07-01 771 5063ce1571b738 Rafael J. Wysocki 2011-08-08 772 /* 5063ce1571b738 Rafael J. Wysocki 2011-08-08 773 * The list is guaranteed not to change while the loop below is being 8d87ae48ced2df Kees Cook 2020-07-08 774 * executed, unless one of the parents' .power_on() callbacks fiddles 5063ce1571b738 Rafael J. Wysocki 2011-08-08 775 * with it. 5063ce1571b738 Rafael J. Wysocki 2011-08-08 776 */ 8d87ae48ced2df Kees Cook 2020-07-08 777 list_for_each_entry(link, &genpd->child_links, child_node) { 8d87ae48ced2df Kees Cook 2020-07-08 778 struct generic_pm_domain *parent = link->parent; 0106ef5146f9e8 Marek Szyprowski 2016-01-20 779 8d87ae48ced2df Kees Cook 2020-07-08 780 genpd_sd_counter_inc(parent); 0106ef5146f9e8 Marek Szyprowski 2016-01-20 781 8d87ae48ced2df Kees Cook 2020-07-08 782 genpd_lock_nested(parent, depth + 1); 8d87ae48ced2df Kees Cook 2020-07-08 783 ret = genpd_power_on(parent, depth + 1); 8d87ae48ced2df Kees Cook 2020-07-08 784 genpd_unlock(parent); 5248051b9afb66 Rafael J. Wysocki 2011-07-01 785 5063ce1571b738 Rafael J. Wysocki 2011-08-08 786 if (ret) { 8d87ae48ced2df Kees Cook 2020-07-08 787 genpd_sd_counter_dec(parent); 9e08cf42969709 Rafael J. Wysocki 2011-08-08 788 goto err; 5248051b9afb66 Rafael J. Wysocki 2011-07-01 789 } 5063ce1571b738 Rafael J. Wysocki 2011-08-08 790 } 5248051b9afb66 Rafael J. Wysocki 2011-07-01 791 86e12eac1f7f84 Ulf Hansson 2016-12-08 792 ret = _genpd_power_on(genpd, true); 9e08cf42969709 Rafael J. Wysocki 2011-08-08 793 if (ret) 9e08cf42969709 Rafael J. Wysocki 2011-08-08 794 goto err; 0140d8bd47f798 Rafael J. Wysocki 2011-12-01 795 49f618e1b669ef Ulf Hansson 2020-09-24 796 genpd->status = GENPD_STATE_ON; afece3ab9a3640 Thara Gopinath 2017-07-14 797 genpd_update_accounting(genpd); afece3ab9a3640 Thara Gopinath 2017-07-14 798 3f241775c30365 Rafael J. Wysocki 2011-08-08 799 return 0; 9e08cf42969709 Rafael J. Wysocki 2011-08-08 800 9e08cf42969709 Rafael J. Wysocki 2011-08-08 801 err: 29e47e2173349e Ulf Hansson 2015-09-02 802 list_for_each_entry_continue_reverse(link, 8d87ae48ced2df Kees Cook 2020-07-08 803 &genpd->child_links, 8d87ae48ced2df Kees Cook 2020-07-08 804 child_node) { 8d87ae48ced2df Kees Cook 2020-07-08 805 genpd_sd_counter_dec(link->parent); 8d87ae48ced2df Kees Cook 2020-07-08 806 genpd_lock_nested(link->parent, depth + 1); 8d87ae48ced2df Kees Cook 2020-07-08 807 genpd_power_off(link->parent, false, depth + 1); 8d87ae48ced2df Kees Cook 2020-07-08 808 genpd_unlock(link->parent); 29e47e2173349e Ulf Hansson 2015-09-02 809 } 9e08cf42969709 Rafael J. Wysocki 2011-08-08 810 3f241775c30365 Rafael J. Wysocki 2011-08-08 811 return ret; 3f241775c30365 Rafael J. Wysocki 2011-08-08 812 } 3f241775c30365 Rafael J. Wysocki 2011-08-08 813 ea71c59669f17d Ulf Hansson 2019-10-16 814 static int genpd_dev_pm_start(struct device *dev) ea71c59669f17d Ulf Hansson 2019-10-16 815 { ea71c59669f17d Ulf Hansson 2019-10-16 816 struct generic_pm_domain *genpd = dev_to_genpd(dev); ea71c59669f17d Ulf Hansson 2019-10-16 817 ea71c59669f17d Ulf Hansson 2019-10-16 818 return genpd_start_dev(genpd, dev); ea71c59669f17d Ulf Hansson 2019-10-16 819 } ea71c59669f17d Ulf Hansson 2019-10-16 820 6ff7bb0d02f829 Rafael J. Wysocki 2012-05-01 821 static int genpd_dev_pm_qos_notifier(struct notifier_block *nb, 6ff7bb0d02f829 Rafael J. Wysocki 2012-05-01 822 unsigned long val, void *ptr) 6ff7bb0d02f829 Rafael J. Wysocki 2012-05-01 823 { 6ff7bb0d02f829 Rafael J. Wysocki 2012-05-01 824 struct generic_pm_domain_data *gpd_data; 6ff7bb0d02f829 Rafael J. Wysocki 2012-05-01 825 struct device *dev; 6ff7bb0d02f829 Rafael J. Wysocki 2012-05-01 826 6ff7bb0d02f829 Rafael J. Wysocki 2012-05-01 827 gpd_data = container_of(nb, struct generic_pm_domain_data, nb); 6ff7bb0d02f829 Rafael J. Wysocki 2012-05-01 828 dev = gpd_data->base.dev; 6ff7bb0d02f829 Rafael J. Wysocki 2012-05-01 829 6ff7bb0d02f829 Rafael J. Wysocki 2012-05-01 830 for (;;) { f38d1a6d002526 Ulf Hansson 2022-05-11 831 struct generic_pm_domain *genpd = ERR_PTR(-ENODATA); 6ff7bb0d02f829 Rafael J. Wysocki 2012-05-01 832 struct pm_domain_data *pdd; 66d29d802ef3bf Ulf Hansson 2022-05-11 833 struct gpd_timing_data *td; 6ff7bb0d02f829 Rafael J. Wysocki 2012-05-01 834 6ff7bb0d02f829 Rafael J. Wysocki 2012-05-01 835 spin_lock_irq(&dev->power.lock); 6ff7bb0d02f829 Rafael J. Wysocki 2012-05-01 836 6ff7bb0d02f829 Rafael J. Wysocki 2012-05-01 837 pdd = dev->power.subsys_data ? 6ff7bb0d02f829 Rafael J. Wysocki 2012-05-01 838 dev->power.subsys_data->domain_data : NULL; b4883ca449473e Viresh Kumar 2017-05-16 839 if (pdd) { 66d29d802ef3bf Ulf Hansson 2022-05-11 840 td = to_gpd_data(pdd)->td; f38d1a6d002526 Ulf Hansson 2022-05-11 841 if (td) { 66d29d802ef3bf Ulf Hansson 2022-05-11 842 td->constraint_changed = true; 6ff7bb0d02f829 Rafael J. Wysocki 2012-05-01 843 genpd = dev_to_genpd(dev); f38d1a6d002526 Ulf Hansson 2022-05-11 844 } 6ff7bb0d02f829 Rafael J. Wysocki 2012-05-01 845 } 6ff7bb0d02f829 Rafael J. Wysocki 2012-05-01 846 6ff7bb0d02f829 Rafael J. Wysocki 2012-05-01 847 spin_unlock_irq(&dev->power.lock); 6ff7bb0d02f829 Rafael J. Wysocki 2012-05-01 848 6ff7bb0d02f829 Rafael J. Wysocki 2012-05-01 849 if (!IS_ERR(genpd)) { 35241d12f750d2 Lina Iyer 2016-10-14 850 genpd_lock(genpd); f38d1a6d002526 Ulf Hansson 2022-05-11 851 genpd->gd->max_off_time_changed = true; 35241d12f750d2 Lina Iyer 2016-10-14 852 genpd_unlock(genpd); 6ff7bb0d02f829 Rafael J. Wysocki 2012-05-01 853 } 6ff7bb0d02f829 Rafael J. Wysocki 2012-05-01 854 6ff7bb0d02f829 Rafael J. Wysocki 2012-05-01 855 dev = dev->parent; 6ff7bb0d02f829 Rafael J. Wysocki 2012-05-01 @856 if (!dev || dev->power.ignore_children) 6ff7bb0d02f829 Rafael J. Wysocki 2012-05-01 857 break; 6ff7bb0d02f829 Rafael J. Wysocki 2012-05-01 858 } 6ff7bb0d02f829 Rafael J. Wysocki 2012-05-01 859 6ff7bb0d02f829 Rafael J. Wysocki 2012-05-01 860 return NOTIFY_DONE; 6ff7bb0d02f829 Rafael J. Wysocki 2012-05-01 861 } 6ff7bb0d02f829 Rafael J. Wysocki 2012-05-01 862
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 <linux/completion.h> #include <linux/iopoll.h> #include <linux/interrupt.h> +#include <linux/notifier.h> #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 <linux/bitfield.h> #include <linux/devfreq.h> +#include <linux/pm_domain.h> #include <linux/soc/qcom/llcc-qcom.h> #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)