From patchwork Fri Jan 27 10:40:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abel Vesa X-Patchwork-Id: 13118355 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 19E95C38142 for ; Fri, 27 Jan 2023 10:41:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232555AbjA0Klm (ORCPT ); Fri, 27 Jan 2023 05:41:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232433AbjA0Kla (ORCPT ); Fri, 27 Jan 2023 05:41:30 -0500 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3FAC879214 for ; Fri, 27 Jan 2023 02:40:59 -0800 (PST) Received: by mail-wr1-x431.google.com with SMTP id h16so4533949wrz.12 for ; Fri, 27 Jan 2023 02:40:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=VsoS+HLMRIQitJW5cLuMou8qpfRBnFIRf9XZouh1e9Q=; b=LO+sAoyMEwdNEnHWYaJlKEDGIbwLsEP/ebM803ORYTt0D1wWGXQWE1WBxnR1wz694Q 6I2JzsmrVmtFbXDXHT/9+E3jUbMfVHCF0EsD7aKRHo/s1JKRfrmqHwgD6BYPbdy+VBLf 4ej96pIguY293PjvbWcAHtpb8e3PjD3ITHtbx7HQZabQvv7zV+eIhtRsKIX2mxsynJzh 906Itbpo2L3Y3oCZ5mfqUKDSc9dghK3F+bGvejJ6i/XllOhHLnTAuyVkCfFxEgwG5CoU XrOiUs02/Q6TEEWVXkFB/e4UgtBOuQD0lKZL4O8gpVQqoO57RoXpGL21ESOyw3UJ5TNQ YxbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=VsoS+HLMRIQitJW5cLuMou8qpfRBnFIRf9XZouh1e9Q=; b=F1JGKZjFxrpTxZv5EDoZHaeP7ogVIEKq9c3yyMwF3zmpwWZKUxxyDPYmVwIkhvZcaZ J2a94BnWuHK1/KiTWD9GaHzJSTJSDw+fQc6nOD2qZx6EUQ+pW35abAuEzaFjKoH6jelS CXQm/8VPzfmPO4YfK1AAHPJwfHYeuuKbDHQnCEIW9AhKuWgFj0tSSNFEehZB0x1xXVHw Syy053Lvag7KGx0RUPbBlUsL4ZsQ6wMc5dP7NfJJY9cnmneqXYbJfXxaZ2L/oRysSR10 vYLD+JDO5KDBlgh+GlowgME5eJ4qpWqSEpTL97pi//cCMTHFs6yfGGHTz2YiL7Ri1rs9 vx7Q== X-Gm-Message-State: AFqh2krfBlQOrI92z7/GkkQgtcb8T66w8wiTiDMQhWUvqbTRMQh6leVZ kZ1xuERsjBKiBHpkordvf9SA1Q== X-Google-Smtp-Source: AMrXdXs0EK70vgBGw/Uczwfmggrv143kEnn1iNXDjOTsUS+fwt3Hl+f67U/4xB5huJ2TL8fz+9txig== X-Received: by 2002:a05:6000:5c2:b0:2bb:eb3d:8d20 with SMTP id bh2-20020a05600005c200b002bbeb3d8d20mr32723282wrb.43.1674816057617; Fri, 27 Jan 2023 02:40:57 -0800 (PST) Received: from hackbox.lan ([94.52.112.99]) by smtp.gmail.com with ESMTPSA id e21-20020a5d5955000000b002b57bae7174sm3613089wri.5.2023.01.27.02.40.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Jan 2023 02:40:57 -0800 (PST) From: Abel Vesa To: "Rafael J . Wysocki" , Kevin Hilman , Ulf Hansson , Len Brown , Pavel Machek , Greg Kroah-Hartman Cc: Bjorn Andersson , Andy Gross , Konrad Dybcio , linux-pm@vger.kernel.org, Linux Kernel Mailing List , linux-arm-msm@vger.kernel.org, Dmitry Baryshkov , Stephen Boyd Subject: [RFC PATCH v2 1/2] PM: domains: Skip disabling unused domains if provider has sync_state Date: Fri, 27 Jan 2023 12:40:53 +0200 Message-Id: <20230127104054.895129-1-abel.vesa@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Currently, there are cases when a domain needs to remain enabled until the consumer driver probes. Sometimes such consumer drivers may be built as modules. Since the genpd_power_off_unused is called too early for such consumer driver modules to get a chance to probe, the domain, since it is unused, will get disabled. On the other hand, the best time for an unused domain to be disabled is on the provider's sync_state callback. So, if the provider has registered a sync_state callback, assume the unused domains for that provider will be disabled on its sync_state callback. Also provide a generic sync_state callback which disables all the domains unused for the provider that registers it. Signed-off-by: Abel Vesa --- This approach has been applied for unused clocks as well. With this patch merged in, all the providers that have sync_state callback registered will leave the domains enabled unless the provider's sync_state callback explicitly disables them. So those providers will need to add the disabling part to their sync_state callback. On the other hand, the platforms that have cases where domains need to remain enabled (even if unused) until the consumer driver probes, will be able, with this patch in, to run without the pd_ignore_unused kernel argument, which seems to be the case for most Qualcomm platforms, at this moment. The v1 is here: https://lore.kernel.org/all/20230126234013.3638425-1-abel.vesa@linaro.org/ Changes since v1: * added a generic sync state callback to be registered by providers in order to disable the unused domains on their sync state. Also mentioned this in the commit message. drivers/base/power/domain.c | 17 ++++++++++++++++- include/linux/pm_domain.h | 3 +++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 84662d338188..c2a5f77c01f3 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -1099,7 +1099,8 @@ static int __init genpd_power_off_unused(void) mutex_lock(&gpd_list_lock); list_for_each_entry(genpd, &gpd_list, gpd_list_node) - genpd_queue_power_off_work(genpd); + if (!dev_has_sync_state(genpd->provider->dev)) + genpd_queue_power_off_work(genpd); mutex_unlock(&gpd_list_lock); @@ -1107,6 +1108,20 @@ static int __init genpd_power_off_unused(void) } late_initcall(genpd_power_off_unused); +void genpd_power_off_unused_sync_state(struct device *dev) +{ + struct generic_pm_domain *genpd; + + mutex_lock(&gpd_list_lock); + + list_for_each_entry(genpd, &gpd_list, gpd_list_node) + if (genpd->provider->dev == dev) + genpd_queue_power_off_work(genpd); + + mutex_unlock(&gpd_list_lock); +} +EXPORT_SYMBOL_GPL(genpd_power_off_unused_sync_state); + #ifdef CONFIG_PM_SLEEP /** diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index f776fb93eaa0..1fd5aa500c81 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -351,6 +351,7 @@ struct device *genpd_dev_pm_attach_by_id(struct device *dev, unsigned int index); struct device *genpd_dev_pm_attach_by_name(struct device *dev, const char *name); +void genpd_power_off_unused_sync_state(struct device *dev); #else /* !CONFIG_PM_GENERIC_DOMAINS_OF */ static inline int of_genpd_add_provider_simple(struct device_node *np, struct generic_pm_domain *genpd) @@ -419,6 +420,8 @@ struct generic_pm_domain *of_genpd_remove_last(struct device_node *np) { return ERR_PTR(-EOPNOTSUPP); } + +static inline genpd_power_off_unused_sync_state(struct device *dev) {} #endif /* CONFIG_PM_GENERIC_DOMAINS_OF */ #ifdef CONFIG_PM From patchwork Fri Jan 27 10:40:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abel Vesa X-Patchwork-Id: 13118356 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C6DC3C54EAA for ; Fri, 27 Jan 2023 10:41:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232321AbjA0Klr (ORCPT ); Fri, 27 Jan 2023 05:41:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230035AbjA0Kle (ORCPT ); Fri, 27 Jan 2023 05:41:34 -0500 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0501287368 for ; Fri, 27 Jan 2023 02:41:02 -0800 (PST) Received: by mail-wr1-x42a.google.com with SMTP id m14so4107243wrg.13 for ; Fri, 27 Jan 2023 02:41:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8ndsWZlMYJtLnCMyPNKqHVtE/EpqIzhsLhwbLZ4yPv4=; b=pcaxpn5GMKc3hkUSiYbL+KXIkk1Q1jNEiF+bU+AlkY+STYO3YlRvQm4CL21G4uTads F/E/cizCK4pB4IQlFZKWr8aSp4CCedzSP2kphFS6FM/wvN0Luquv6iGCXd/tWJXY8GX0 9bsSectbf3oqAaCTzIoEYNOIW56UR0X/8PYQARIfXV3J6PsZGKoS4sdm8p/QY1N1D3ql ANEzBvnGxND2hKbLMo4bOSELPxRaJfYjp0wgi2if4zc7TbN9VBlnFQRJG7ZLNUG1v3Ry 3ySwzcl03uohRgHU0KFYDSwcLQMlZVBi3c5g87Yg1c3Pa1hIZAmjGNgfwY+HwgaM/H+0 +TMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8ndsWZlMYJtLnCMyPNKqHVtE/EpqIzhsLhwbLZ4yPv4=; b=i0LKFBChlamY/F3b/iAYCcziyLrq8olMUwbKMEr9rXIuskUg2iPf3/JpCaYQSPVQoQ 6dIsPv28+2PX8cAQKeSGhJQ+NuH5JmzsBx13phG0X6o3bgjKZJY2ZA8M1BB4sgTQpYKN 7ZIwpAu/d0r444vARGJBKmhmOVLtufBXiR3C0O1HWcYjsWpR8ujWypjMt17k5D7RYTrb UkGByZ1ugJA6mBqFbCrF6CP0j+CiexQ8gPllJhqCSP+qFCCZxIk6rMeEMrW6JzmwG1i9 XeJiQURIMbunQr/8NM8owa36C1BCEoa4XyWmofEQWXgBsZau13c73eZBa+hFpTgCIAgH 5aZw== X-Gm-Message-State: AFqh2ko5ZG467ykqA9+UsSYKTM15gikhk5GYMlifPzKU3PHXJqMUbg2C 6bVxSleC7TDEQEJEHTsRGpaxNg== X-Google-Smtp-Source: AMrXdXtjBKnqIUXFzK6rBR+HmbIbBe/29qiO4dzM4gQIAWtKV0EMLASAJZaz9DTkAQvvlkGJd/5SnQ== X-Received: by 2002:a05:6000:8d:b0:2be:3a6a:f565 with SMTP id m13-20020a056000008d00b002be3a6af565mr25744279wrx.38.1674816058948; Fri, 27 Jan 2023 02:40:58 -0800 (PST) Received: from hackbox.lan ([94.52.112.99]) by smtp.gmail.com with ESMTPSA id e21-20020a5d5955000000b002b57bae7174sm3613089wri.5.2023.01.27.02.40.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Jan 2023 02:40:58 -0800 (PST) From: Abel Vesa To: "Rafael J . Wysocki" , Kevin Hilman , Ulf Hansson , Len Brown , Pavel Machek , Greg Kroah-Hartman Cc: Bjorn Andersson , Andy Gross , Konrad Dybcio , linux-pm@vger.kernel.org, Linux Kernel Mailing List , linux-arm-msm@vger.kernel.org, Dmitry Baryshkov , Stephen Boyd Subject: [RFC PATCH v2 2/2] soc: qcom: rmphpd: Call the genpd unused power off sync state callback Date: Fri, 27 Jan 2023 12:40:54 +0200 Message-Id: <20230127104054.895129-2-abel.vesa@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230127104054.895129-1-abel.vesa@linaro.org> References: <20230127104054.895129-1-abel.vesa@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Genpd provides a generic sync state callback for disabling unused domains for a specific provider identified by its device. Call that generic callback from the existing sync state callback in order to disable all RPMh PD unused domains when all the consumers have probed. Signed-off-by: Abel Vesa --- This patch was not part of v1. Added to this patchset for context. drivers/soc/qcom/rpmhpd.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/soc/qcom/rpmhpd.c b/drivers/soc/qcom/rpmhpd.c index f20e2a49a669..8b341cb97546 100644 --- a/drivers/soc/qcom/rpmhpd.c +++ b/drivers/soc/qcom/rpmhpd.c @@ -832,6 +832,8 @@ static void rpmhpd_sync_state(struct device *dev) dev_err(dev, "failed to sync %s\n", pd->res_name); } mutex_unlock(&rpmhpd_lock); + + genpd_power_off_unused_sync_state(dev); } static struct platform_driver rpmhpd_driver = {