From patchwork Mon Mar 20 13:42:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abel Vesa X-Patchwork-Id: 665769 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 3C87EC7619A for ; Mon, 20 Mar 2023 13:42:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231660AbjCTNmk (ORCPT ); Mon, 20 Mar 2023 09:42:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231347AbjCTNma (ORCPT ); Mon, 20 Mar 2023 09:42:30 -0400 Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C224EDBDB for ; Mon, 20 Mar 2023 06:42:27 -0700 (PDT) Received: by mail-ed1-x530.google.com with SMTP id b20so13955514edd.1 for ; Mon, 20 Mar 2023 06:42:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1679319745; 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=wjKiN0F5wVydodH1DdUegjCL8bujRKxDngFdNV9Cs2c=; b=CDVGNXBPBN3zdUl7FjlFIv2E0h2geCNhMI1PP8HGrSgTs+BJuRsvUQ8kKvW/9nHD6N ow11RnoeG6AyipGzzUF/lO2TgVbEawbgTLBNGTuFejZWb9xACrAOTxT0Pc+DyojUHoQj z6XSF+lwJMKFBd7D22ZkGy7V0IY7K+0c1K3HQzE2X+WVa7wCm1IXg4yUc2lPx8QODOc3 mS04vNuhq8CkG3cvPfStcuTLNmf7zvbJHoA98VNoLA4Ehm4wvwJ9NS5qSTVeudyu4MSB 3XpH2Aq0TssgKopj8KOSAqljUq6V79aGyWyrfVrfP4Q0Gl5ncE9tOmeL9rZtZSNVqcba ZPrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679319745; 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=wjKiN0F5wVydodH1DdUegjCL8bujRKxDngFdNV9Cs2c=; b=KzfXMlOepLgughdXzFRQ/td5ykUPptCGloo7YPshAQppnFwzqQwzIcN7Cax3+QL+j2 FfDMeEK+Wh4XuXmNnWXC8bZc6tXUG/4nejqqKJDalG4et6fG3i+xqmiEoTj8ZmghWcrq YOf6m+fUJS58NbpblDLikIIQZ97QjVv2+FUy37bf7EBl34AYWpW0sKtVrZSUMlYi7EbI SPY61zVl+grfb3RhkUlV9SnQCbRTsKfnij/2nXFh2fgYypITkZKH4sqf0GWXeCogQ3yQ S4X0UMtgRxvoUuLkkTMdLpSrF2GCFirUdrG+e+UMvUcNA9qiImW8HvDRAV8qzyU4F9yk TAFg== X-Gm-Message-State: AO0yUKXrj0J4EpVKbMiKgFwPJEkicTpHQJvhKN3lLBnmBiO+bfjycE0v kZTClP+TSLmD5zFT61xqL1iE+A== X-Google-Smtp-Source: AK7set8fdXj5wZW+bwPsLGCClZ5wHbtWt3lGG6NeFx2qa6Ytz64EWWAV2hS1cYoBxEYSKOOASiOrVw== X-Received: by 2002:a17:906:1e85:b0:931:1567:f84f with SMTP id e5-20020a1709061e8500b009311567f84fmr8266966ejj.4.1679319745664; Mon, 20 Mar 2023 06:42:25 -0700 (PDT) Received: from localhost.localdomain ([94.52.112.99]) by smtp.gmail.com with ESMTPSA id u23-20020a170906409700b009334a6ef3e8sm2368602ejj.141.2023.03.20.06.42.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Mar 2023 06:42:25 -0700 (PDT) From: Abel Vesa To: "Rafael J. Wysocki" , Kevin Hilman , Ulf Hansson , Pavel Machek , Len Brown , Greg Kroah-Hartman , Bjorn Andersson , Andy Gross , Konrad Dybcio , Mike Turquette , Stephen Boyd , Saravana Kannan Cc: linux-pm@vger.kernel.org, Linux Kernel Mailing List , linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, Doug Anderson , Matthias Kaehlcke Subject: [RFC PATCH v2 1/5] PM: domains: Allow power off queuing from providers Date: Mon, 20 Mar 2023 15:42:13 +0200 Message-Id: <20230320134217.1685781-2-abel.vesa@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230320134217.1685781-1-abel.vesa@linaro.org> References: <20230320134217.1685781-1-abel.vesa@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org In some cases, the providers might choose to refuse powering off some domains until all of the consumer have had a chance to probe, that is, until sync state callback has been called. Such providers might choose to disable such domains on their on, from the sync state callback. So, in order to do that, they need a way to queue up a power off request. Since the generic genpd already has such API, make that available to those providers. Signed-off-by: Abel Vesa --- drivers/base/power/domain.c | 3 ++- include/linux/pm_domain.h | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 32084e38b73d..97d4e2f2da91 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -649,10 +649,11 @@ static int _genpd_power_off(struct generic_pm_domain *genpd, bool timed) * Queue up the execution of genpd_power_off() unless it's already been done * before. */ -static void genpd_queue_power_off_work(struct generic_pm_domain *genpd) +void genpd_queue_power_off_work(struct generic_pm_domain *genpd) { queue_work(pm_wq, &genpd->power_off_work); } +EXPORT_SYMBOL_GPL(genpd_queue_power_off_work); /** * genpd_power_off - Remove power from a given PM domain. diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index f776fb93eaa0..f9729640f87e 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -231,6 +231,7 @@ int pm_genpd_remove_subdomain(struct generic_pm_domain *genpd, int pm_genpd_init(struct generic_pm_domain *genpd, struct dev_power_governor *gov, bool is_off); int pm_genpd_remove(struct generic_pm_domain *genpd); +void genpd_queue_power_off_work(struct generic_pm_domain *genpd); int dev_pm_genpd_set_performance_state(struct device *dev, unsigned int state); int dev_pm_genpd_add_notifier(struct device *dev, struct notifier_block *nb); int dev_pm_genpd_remove_notifier(struct device *dev); @@ -278,6 +279,11 @@ static inline int pm_genpd_remove(struct generic_pm_domain *genpd) return -EOPNOTSUPP; } +void genpd_queue_power_off_work(struct generic_pm_domain *genpd) +{ + return -EOPNOTSUPP; +} + static inline int dev_pm_genpd_set_performance_state(struct device *dev, unsigned int state) { From patchwork Mon Mar 20 13:42:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abel Vesa X-Patchwork-Id: 665475 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 AE882C77B60 for ; Mon, 20 Mar 2023 13:42:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231320AbjCTNml (ORCPT ); Mon, 20 Mar 2023 09:42:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231434AbjCTNma (ORCPT ); Mon, 20 Mar 2023 09:42:30 -0400 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C31B4F941 for ; Mon, 20 Mar 2023 06:42:28 -0700 (PDT) Received: by mail-ed1-x529.google.com with SMTP id eh3so46846460edb.11 for ; Mon, 20 Mar 2023 06:42:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1679319747; 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=xQtrWDCM+22cQpzRRbVDJZjtR/eFtKTL53q6CUnjVrA=; b=m6WWdvyhtAOPk/0OuJjnEg21hoMIbAVidJpiNn+dmHa6hrOTmwvVTWgmYoobYKk7bk YuXgKLPbT+avt/j0eZvscu00k3J1cPtSfbLKJ7kbnyCcGSGgVOh+yECsfSnJKybt4up8 kV/48kbVKfW8V7xGb9E0sW5ce44PrIUJVXiejhK4aTy/HZ/Bv8Vc+76SgxAEuYTqV5bq a8hciAQRZBC58PAUCewbgn8YnhSZwW1ZSq6P5VeUjicnDDbRkUs4NMKhXIxfqJUtXPL7 oSiNulSiYQll2eiuOheOcK904JTbsGuREE5VJTu16BWfiggbU5HS5zw9cQFyz41bo+me pPpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679319747; 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=xQtrWDCM+22cQpzRRbVDJZjtR/eFtKTL53q6CUnjVrA=; b=o/TEeEwscgLeHmN1OfYNaUW9xj83nt9VYSSOSSjP701ycezRerSERBaE9R507wGMWa GWiBju5JdZ8SAIkjaMxx2YJtV498weti+jl2KW040psH8jc5BnCGm8juQYtK5HDIdcOs XDSiAXw2I8sI9/moCR4cv+G74WxwSpKrB024eEOWIztws4uXNTAdUeCRaiP8PEcB5SMJ mJmbURcM95uvZak3aHj53ly0912Uw3STT1lc+t0McOFOrJngtaLWFc+JEF8Odi+PURn6 rWlICb97dEPXfhsuvVoXjQ1B6O0xCkpQ9+tDOX4FhuCka4g6UydAKrW+bjkZ/BcrQVFT r7hg== X-Gm-Message-State: AO0yUKX3evNPCdxCDWM5eCy3ZwQyoHKU1tkQdapvBC2R5UE5u9IBFLGq arj6TUC1OIg1OJSQjQseRYEuOI+5hcE/YB7xIV0= X-Google-Smtp-Source: AK7set8STWg1Rns3/0smj0Q44nbZB3/IvQ/ygDqex3RKHPaT6fygb8UA/9acK6hL7QexFWuXYa/MTQ== X-Received: by 2002:aa7:db83:0:b0:4fd:7f6f:3179 with SMTP id u3-20020aa7db83000000b004fd7f6f3179mr11830162edt.3.1679319747250; Mon, 20 Mar 2023 06:42:27 -0700 (PDT) Received: from localhost.localdomain ([94.52.112.99]) by smtp.gmail.com with ESMTPSA id u23-20020a170906409700b009334a6ef3e8sm2368602ejj.141.2023.03.20.06.42.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Mar 2023 06:42:26 -0700 (PDT) From: Abel Vesa To: "Rafael J. Wysocki" , Kevin Hilman , Ulf Hansson , Pavel Machek , Len Brown , Greg Kroah-Hartman , Bjorn Andersson , Andy Gross , Konrad Dybcio , Mike Turquette , Stephen Boyd , Saravana Kannan Cc: linux-pm@vger.kernel.org, Linux Kernel Mailing List , linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, Doug Anderson , Matthias Kaehlcke Subject: [RFC PATCH v2 2/5] soc: qcom: rpmhpd: Do proper power off when state synced Date: Mon, 20 Mar 2023 15:42:14 +0200 Message-Id: <20230320134217.1685781-3-abel.vesa@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230320134217.1685781-1-abel.vesa@linaro.org> References: <20230320134217.1685781-1-abel.vesa@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Instead of aggregating different corner values on sync state callback, call the genpd API for queuing up the power off. This will also mark the domain as powered off in the debugfs genpd summary. Also, until sync state has been reached, return busy on power off request, in order to allow genpd core to know that the actual domain hasn't been powered of from the "disable unused" late initcall. Signed-off-by: Abel Vesa --- drivers/soc/qcom/rpmhpd.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/drivers/soc/qcom/rpmhpd.c b/drivers/soc/qcom/rpmhpd.c index f20e2a49a669..abd999c74783 100644 --- a/drivers/soc/qcom/rpmhpd.c +++ b/drivers/soc/qcom/rpmhpd.c @@ -649,8 +649,12 @@ static int rpmhpd_power_off(struct generic_pm_domain *domain) mutex_lock(&rpmhpd_lock); ret = rpmhpd_aggregate_corner(pd, 0); - if (!ret) - pd->enabled = false; + if (!ret) { + if (!pd->state_synced) + ret = -EBUSY; + else + pd->enabled = false; + } mutex_unlock(&rpmhpd_lock); @@ -810,10 +814,8 @@ static void rpmhpd_sync_state(struct device *dev) { const struct rpmhpd_desc *desc = of_device_get_match_data(dev); struct rpmhpd **rpmhpds = desc->rpmhpds; - unsigned int corner; struct rpmhpd *pd; unsigned int i; - int ret; mutex_lock(&rpmhpd_lock); for (i = 0; i < desc->num_pds; i++) { @@ -822,14 +824,7 @@ static void rpmhpd_sync_state(struct device *dev) continue; pd->state_synced = true; - if (pd->enabled) - corner = max(pd->corner, pd->enable_corner); - else - corner = 0; - - ret = rpmhpd_aggregate_corner(pd, corner); - if (ret) - dev_err(dev, "failed to sync %s\n", pd->res_name); + genpd_queue_power_off_work(&pd->pd); } mutex_unlock(&rpmhpd_lock); } From patchwork Mon Mar 20 13:42:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abel Vesa X-Patchwork-Id: 665768 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 EC942C76195 for ; Mon, 20 Mar 2023 13:42:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231358AbjCTNmn (ORCPT ); Mon, 20 Mar 2023 09:42:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231479AbjCTNmb (ORCPT ); Mon, 20 Mar 2023 09:42:31 -0400 Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [IPv6:2a00:1450:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3296F951 for ; Mon, 20 Mar 2023 06:42:29 -0700 (PDT) Received: by mail-ed1-x536.google.com with SMTP id cy23so46807207edb.12 for ; Mon, 20 Mar 2023 06:42:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1679319749; 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=HPUxYFnkGMoE5avSL4JFzjtLyBuUkiovE45vzPm5gIE=; b=qDgGGZj4rTh9vnjkTHytvQnecNq3U/8RsnWgvn0sR57EYqL/Tk27hjcIYNMQMAfHcj Ly/dojV9xXN6PUxnU0zzDS4hqZ6OBxig+eFKGKlhvM9EJA92rLXvzCMFYbwAl1ZAwjZH BJ0JSiMmvmhHjUzIM6uiHD1xrCflH+W/dtwOlQSXt7+qMYN31DPIIlzuv7okpLvIrskM ioUKKh5/KOJhfNKWsQUeCvxtsp0VyOiJUBj6qgUzyeVuZhbLRgbGEYyiREU0ZERUHhn5 xBOiBXl1fkDQsFj9ggEELJ/W6bNs09FZcaJ3juwjNS2RGiEW/6KdfN2nOrSVkGJRZg1X Bj1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679319749; 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=HPUxYFnkGMoE5avSL4JFzjtLyBuUkiovE45vzPm5gIE=; b=nUR7UCUClrSMiLaMoK6PI5o6q1AOCZIH6La+ddBVv5XsUm/bNxh9GcyxwOZy21q1Qa RMFrvrn77L19KhOXMOT4xzxGiva+5t0Wq/EwRKMu3rDs/KMs7Nyw/aU01YZJVQMoZWRi d8kVGruiTG0PGK2QMeXPuDwEAslrMOwKnQZBVZ7yHjQhQYq/vN+piq0ohvHlBF7JVjWt B7o/HIHeBRn7lZsp1Si00RwF/cJS2SlteL+hNPWrzQCL8QtRTeP3jmu0VOlYx8cRI7KD br0/GtMJw7qphbd8edQs+DJWpL0CpeMapNr3fguloZbVUYnU9yKNoLQnBPF2DOiw6+Og tK6w== X-Gm-Message-State: AO0yUKXOYHVrcs7fm6a3XP3KeZA/tG2lAS09vs4vywe+6AWQa1LRJWq8 G6Izuh4wKoXZt1+xxwR1/RVPaw== X-Google-Smtp-Source: AK7set9MXHEJtUYrxRfCKi0r5p0hqHTOQrRzxZchU9k4CB8noF1liekyd/seH/UA43C9v9iMsMnztw== X-Received: by 2002:a17:906:1906:b0:925:1d1d:6825 with SMTP id a6-20020a170906190600b009251d1d6825mr9770894eje.42.1679319748816; Mon, 20 Mar 2023 06:42:28 -0700 (PDT) Received: from localhost.localdomain ([94.52.112.99]) by smtp.gmail.com with ESMTPSA id u23-20020a170906409700b009334a6ef3e8sm2368602ejj.141.2023.03.20.06.42.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Mar 2023 06:42:28 -0700 (PDT) From: Abel Vesa To: "Rafael J. Wysocki" , Kevin Hilman , Ulf Hansson , Pavel Machek , Len Brown , Greg Kroah-Hartman , Bjorn Andersson , Andy Gross , Konrad Dybcio , Mike Turquette , Stephen Boyd , Saravana Kannan Cc: linux-pm@vger.kernel.org, Linux Kernel Mailing List , linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, Doug Anderson , Matthias Kaehlcke Subject: [RFC PATCH v2 3/5] clk: qcom: gdsc: Avoid actual power off until sync state Date: Mon, 20 Mar 2023 15:42:15 +0200 Message-Id: <20230320134217.1685781-4-abel.vesa@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230320134217.1685781-1-abel.vesa@linaro.org> References: <20230320134217.1685781-1-abel.vesa@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org In case there is a sync state callback registered for a provider, do not actually power off any gdsc for that provider until sync state has been reached and return busy instead. Since the qcom_cc is private, add a helper that returns the gdsc_desc based on the device of the provider. Finally, add the generic gdsc sync state callback to be used by the platform specific providers. Signed-off-by: Abel Vesa --- drivers/clk/qcom/common.c | 19 +++++++++++++++++++ drivers/clk/qcom/common.h | 2 ++ drivers/clk/qcom/gdsc.c | 26 ++++++++++++++++++++++++++ drivers/clk/qcom/gdsc.h | 6 ++++++ 4 files changed, 53 insertions(+) diff --git a/drivers/clk/qcom/common.c b/drivers/clk/qcom/common.c index 75f09e6e057e..d7fd1b170c1c 100644 --- a/drivers/clk/qcom/common.c +++ b/drivers/clk/qcom/common.c @@ -20,6 +20,7 @@ struct qcom_cc { struct qcom_reset_controller reset; struct clk_regmap **rclks; + struct gdsc_desc *scd; size_t num_rclks; }; @@ -234,6 +235,13 @@ static struct clk_hw *qcom_cc_clk_hw_get(struct of_phandle_args *clkspec, return cc->rclks[idx] ? &cc->rclks[idx]->hw : NULL; } +struct gdsc_desc *qcom_cc_get_gdsc_desc(struct device *dev) +{ + struct qcom_cc *cc = dev_get_drvdata(dev); + + return cc->scd; +} + int qcom_cc_really_probe(struct platform_device *pdev, const struct qcom_cc_desc *desc, struct regmap *regmap) { @@ -251,6 +259,8 @@ int qcom_cc_really_probe(struct platform_device *pdev, if (!cc) return -ENOMEM; + dev_set_drvdata(dev, cc); + reset = &cc->reset; reset->rcdev.of_node = dev->of_node; reset->rcdev.ops = &qcom_reset_ops; @@ -267,6 +277,9 @@ int qcom_cc_really_probe(struct platform_device *pdev, scd = devm_kzalloc(dev, sizeof(*scd), GFP_KERNEL); if (!scd) return -ENOMEM; + + cc->scd = scd; + scd->dev = dev; scd->scs = desc->gdscs; scd->num = desc->num_gdscs; @@ -319,6 +332,12 @@ int qcom_cc_probe(struct platform_device *pdev, const struct qcom_cc_desc *desc) } EXPORT_SYMBOL_GPL(qcom_cc_probe); +void qcom_cc_sync_state(struct device *dev) +{ + gdsc_sync_state(dev); +} +EXPORT_SYMBOL_GPL(qcom_cc_sync_state); + int qcom_cc_probe_by_index(struct platform_device *pdev, int index, const struct qcom_cc_desc *desc) { diff --git a/drivers/clk/qcom/common.h b/drivers/clk/qcom/common.h index 9c8f7b798d9f..1bea04da0a00 100644 --- a/drivers/clk/qcom/common.h +++ b/drivers/clk/qcom/common.h @@ -61,9 +61,11 @@ extern struct regmap *qcom_cc_map(struct platform_device *pdev, extern int qcom_cc_really_probe(struct platform_device *pdev, const struct qcom_cc_desc *desc, struct regmap *regmap); +extern struct gdsc_desc *qcom_cc_get_gdsc_desc(struct device *dev); extern int qcom_cc_probe(struct platform_device *pdev, const struct qcom_cc_desc *desc); extern int qcom_cc_probe_by_index(struct platform_device *pdev, int index, const struct qcom_cc_desc *desc); +extern void qcom_cc_sync_state(struct device *dev); #endif diff --git a/drivers/clk/qcom/gdsc.c b/drivers/clk/qcom/gdsc.c index 5358e28122ab..af745907dc49 100644 --- a/drivers/clk/qcom/gdsc.c +++ b/drivers/clk/qcom/gdsc.c @@ -15,6 +15,8 @@ #include #include #include + +#include "common.h" #include "gdsc.h" #define PWR_ON_MASK BIT(31) @@ -319,6 +321,9 @@ static int gdsc_disable(struct generic_pm_domain *domain) struct gdsc *sc = domain_to_gdsc(domain); int ret; + if (!sc->state_synced) + return -EBUSY; + if (sc->pwrsts == PWRSTS_ON) return gdsc_assert_reset(sc); @@ -365,6 +370,7 @@ static int gdsc_disable(struct generic_pm_domain *domain) static int gdsc_init(struct gdsc *sc) { + struct device *dev = sc->dev; u32 mask, val; int on, ret; @@ -452,6 +458,9 @@ static int gdsc_init(struct gdsc *sc) if (!sc->pd.power_on) sc->pd.power_on = gdsc_enable; + if (!dev_has_sync_state(dev)) + sc->state_synced = true; + ret = pm_genpd_init(&sc->pd, NULL, !on); if (ret) goto err_disable_supply; @@ -496,6 +505,7 @@ int gdsc_register(struct gdsc_desc *desc, for (i = 0; i < num; i++) { if (!scs[i]) continue; + scs[i]->dev = dev; scs[i]->regmap = regmap; scs[i]->rcdev = rcdev; ret = gdsc_init(scs[i]); @@ -536,6 +546,22 @@ void gdsc_unregister(struct gdsc_desc *desc) of_genpd_del_provider(dev->of_node); } +void gdsc_sync_state(struct device *dev) +{ + struct gdsc_desc *scd = qcom_cc_get_gdsc_desc(dev); + struct gdsc **scs = scd->scs; + size_t num = scd->num; + int i; + + for (i = 0; i < num; i++) { + if (!scs[i]) + continue; + + scs[i]->state_synced = true; + genpd_queue_power_off_work(&scs[i]->pd); + } +} + /* * On SDM845+ the GPU GX domain is *almost* entirely controlled by the GMU * running in the CX domain so the CPU doesn't need to know anything about the diff --git a/drivers/clk/qcom/gdsc.h b/drivers/clk/qcom/gdsc.h index 803512688336..e1c902caecde 100644 --- a/drivers/clk/qcom/gdsc.h +++ b/drivers/clk/qcom/gdsc.h @@ -35,6 +35,7 @@ struct gdsc { struct generic_pm_domain pd; struct generic_pm_domain *parent; struct regmap *regmap; + struct device *dev; unsigned int gdscr; unsigned int collapse_ctrl; unsigned int collapse_mask; @@ -73,6 +74,8 @@ struct gdsc { const char *supply; struct regulator *rsupply; + + bool state_synced; }; struct gdsc_desc { @@ -86,6 +89,7 @@ int gdsc_register(struct gdsc_desc *desc, struct reset_controller_dev *, struct regmap *); void gdsc_unregister(struct gdsc_desc *desc); int gdsc_gx_do_nothing_enable(struct generic_pm_domain *domain); +void gdsc_sync_state(struct device *dev); #else static inline int gdsc_register(struct gdsc_desc *desc, struct reset_controller_dev *rcdev, @@ -94,6 +98,8 @@ static inline int gdsc_register(struct gdsc_desc *desc, return -ENOSYS; } +static inline void gdsc_sync_state(struct device *dev) { } + static inline void gdsc_unregister(struct gdsc_desc *desc) {}; #endif /* CONFIG_QCOM_GDSC */ #endif /* __QCOM_GDSC_H__ */ From patchwork Mon Mar 20 13:42:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abel Vesa X-Patchwork-Id: 665767 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 5E9F1C76195 for ; Mon, 20 Mar 2023 13:42:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231396AbjCTNmu (ORCPT ); Mon, 20 Mar 2023 09:42:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231544AbjCTNmd (ORCPT ); Mon, 20 Mar 2023 09:42:33 -0400 Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DBFFEF747 for ; Mon, 20 Mar 2023 06:42:31 -0700 (PDT) Received: by mail-ed1-x535.google.com with SMTP id w9so46947353edc.3 for ; Mon, 20 Mar 2023 06:42:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1679319750; 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=Htzjm9MSCo4/scEOmWkP20tbOGwc7n5xhdN8GyJQ6GQ=; b=bg8QBqEMCU2HBbMjnyK7G8pFNFhcaxlWlgPUkC1vmuTd98atUix3MIbBpG3lJAys+0 2OxXvRg04f1/Y4Zw8e3Vi2GHv7C9QlOn47ZCDI6ypkC2t9j4c/68f5X7HfJigdkdE4rU i6r/7Cch0fOo1xTP21OktKc1Onawn+Hn4+yuBsrBwgR0h8M9V2FtKPI82e3hKXiBAOs3 0pkDKbVru0PvsTBhhRiwHkOpn+cVCzsC1PdmFNoudWUAkN/Vby253U2/xMXn+Gzbg8yk ZxWg6fRkJz01IddW7B7uWGI0TLzKV5ppQJdre2FTgTZw29WSq37fGZgEi2MlHSxuctke Iqng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679319750; 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=Htzjm9MSCo4/scEOmWkP20tbOGwc7n5xhdN8GyJQ6GQ=; b=5Ny2CHjUCosB96wK5KsUCiEGuVlXc5jcz7NGCg9u5pC8Sfw2r7jAhjCNty9CSgzuTV N1krSqXOV2FVxc5ek1PdL+OCUqCJEl32XIMA0zw7Z26XcJRGPYR6bgkNXtWb2ecEZeel OMjROwu2GJJ0lO5qXBiYAqUBUYuU0qBArb2f8moTNbpjJyEwuHnA+A7CEs1LIfxF2q1f BsRW+C53J5kXmlVedaPvVT6g/1Dv0Xl+IZEHxuzqaQ1XGnHAi/BsR9W/grzK/knF7Bm/ qAKNHmbnBuJ9N9t7SbZT6vzR//X2F05knT5t3I6Wq9xzkomVaoi+pFur2QYPxEv321Ra yNQg== X-Gm-Message-State: AO0yUKUtadw+v1UcRNBwI+473FEdbVQ11JSRMpilIRqX3Daf015izwx3 f+60KWQ5WOL5h9jROFpBlC998w== X-Google-Smtp-Source: AK7set8r62lDWNAku2VSCK32k/4YB9QoETXYmzVcob5j4AQs+mzZFX1MpD0qRD8dnoNReX8JRMdX/Q== X-Received: by 2002:a17:906:13cb:b0:925:f542:1a3d with SMTP id g11-20020a17090613cb00b00925f5421a3dmr8999852ejc.25.1679319750345; Mon, 20 Mar 2023 06:42:30 -0700 (PDT) Received: from localhost.localdomain ([94.52.112.99]) by smtp.gmail.com with ESMTPSA id u23-20020a170906409700b009334a6ef3e8sm2368602ejj.141.2023.03.20.06.42.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Mar 2023 06:42:29 -0700 (PDT) From: Abel Vesa To: "Rafael J. Wysocki" , Kevin Hilman , Ulf Hansson , Pavel Machek , Len Brown , Greg Kroah-Hartman , Bjorn Andersson , Andy Gross , Konrad Dybcio , Mike Turquette , Stephen Boyd , Saravana Kannan Cc: linux-pm@vger.kernel.org, Linux Kernel Mailing List , linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, Doug Anderson , Matthias Kaehlcke Subject: [RFC PATCH v2 4/5] clk: qcom: Add sync state callback to all SC8280XP providers Date: Mon, 20 Mar 2023 15:42:16 +0200 Message-Id: <20230320134217.1685781-5-abel.vesa@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230320134217.1685781-1-abel.vesa@linaro.org> References: <20230320134217.1685781-1-abel.vesa@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Now that we have support for sync state delayed disabling of unused power domains and a provided generic gdsc sync state callback, add it to all the providers related to the SC8280XP platform. Signed-off-by: Abel Vesa --- drivers/clk/qcom/dispcc-sc8280xp.c | 1 + drivers/clk/qcom/gcc-sc8280xp.c | 1 + drivers/clk/qcom/gpucc-sc8280xp.c | 1 + 3 files changed, 3 insertions(+) diff --git a/drivers/clk/qcom/dispcc-sc8280xp.c b/drivers/clk/qcom/dispcc-sc8280xp.c index 167470beb369..a64c396b9cc4 100644 --- a/drivers/clk/qcom/dispcc-sc8280xp.c +++ b/drivers/clk/qcom/dispcc-sc8280xp.c @@ -3199,6 +3199,7 @@ static struct platform_driver disp_cc_sc8280xp_driver = { .driver = { .name = "disp_cc-sc8280xp", .of_match_table = disp_cc_sc8280xp_match_table, + .sync_state = qcom_cc_sync_state, }, }; diff --git a/drivers/clk/qcom/gcc-sc8280xp.c b/drivers/clk/qcom/gcc-sc8280xp.c index b3198784e1c3..64d828ba07da 100644 --- a/drivers/clk/qcom/gcc-sc8280xp.c +++ b/drivers/clk/qcom/gcc-sc8280xp.c @@ -7441,6 +7441,7 @@ static struct platform_driver gcc_sc8280xp_driver = { .driver = { .name = "gcc-sc8280xp", .of_match_table = gcc_sc8280xp_match_table, + .sync_state = qcom_cc_sync_state, }, }; diff --git a/drivers/clk/qcom/gpucc-sc8280xp.c b/drivers/clk/qcom/gpucc-sc8280xp.c index ea1e9505c335..46ca242ba427 100644 --- a/drivers/clk/qcom/gpucc-sc8280xp.c +++ b/drivers/clk/qcom/gpucc-sc8280xp.c @@ -453,6 +453,7 @@ static struct platform_driver gpu_cc_sc8280xp_driver = { .driver = { .name = "gpu_cc-sc8280xp", .of_match_table = gpu_cc_sc8280xp_match_table, + .sync_state = qcom_cc_sync_state, }, }; module_platform_driver(gpu_cc_sc8280xp_driver); From patchwork Mon Mar 20 13:42:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abel Vesa X-Patchwork-Id: 665474 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 EC9E7C7619A for ; Mon, 20 Mar 2023 13:42:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231425AbjCTNmq (ORCPT ); Mon, 20 Mar 2023 09:42:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231580AbjCTNmf (ORCPT ); Mon, 20 Mar 2023 09:42:35 -0400 Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96164C667 for ; Mon, 20 Mar 2023 06:42:33 -0700 (PDT) Received: by mail-ed1-x534.google.com with SMTP id o12so46877252edb.9 for ; Mon, 20 Mar 2023 06:42:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1679319752; 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=5bAvIgcdwvK6qGlX9/tkRQ+PgCIHsC6PUxID2XxtmJs=; b=uQJkr15djkVmBgXdKKgYT+9o9C75QiioeKW8Q5/wJYPZfxnhvse2/8a0DDverHAWLS V4MRks7KPnmb3/58MMbQeBZJCd+WBChFQ/qlPGj271EniIbqjMTbcFNtivNU+bjVjPo3 VJ8RMTBwR3qb8UntS5t8Mbw6a7v6pOYhS7hWQ322eXdq3ae0xeb281kDss612++wBbkl dFNiQ9tS/f7YmtYvC8fQTGYMgak7u2A8A0NWXOYfPEzqdzOVdoEsbBM1FOBolkv0PEJG 8F5nYdKwqjF2UqeqKa5HdYWamA+Adnph+EsOxTr0nRpV6i04HhKU+5xExxxro1quh0yR j/Pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679319752; 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=5bAvIgcdwvK6qGlX9/tkRQ+PgCIHsC6PUxID2XxtmJs=; b=gxMQcDoZ7b3YdFeE+Bqdv3Ttzq2dW1xfQl6OZ0nT+YPeNGcWNkVa3u6+9QPTaLtiYl 4jwGc/cu8lI7dQQ6LNIs46ZLSYPnytvwEC8x91grSoBOaopdLbN0cMdgZ3xF0iBrVmrl HaYk7+poGBxbmHruOpqqm1GKpWxa9hZznygEWLp7Ee6t+r34DaW0BYiuRQ/84V0ATGNk w8/BqaqpFDviLz+mnMVASSq9sdQaYzAp/1rDDjfyZOcdFvsw0elwF1PcEiYFdeIYedxy vP+ypPjmAax1xLWt0pJQFX2hIcxv3+AR+gXW+i9gaSS0mZfEroa8kx0AHl0p4cfwZ7Og /wyA== X-Gm-Message-State: AO0yUKVIMHtXEAPN+K7FPVXg08GJ5LlVjrdjA+JyaBN/U5nLcRKGj67E J4gaE5XeJWpCoLGJxuW92BQTXQ== X-Google-Smtp-Source: AK7set+MK8KcRE7MiT2j4MzvskiRjviqc1Ln0yYh7b/PAFNB5eSsRSEpWjDZaOM3sZzgMOex9ThcPg== X-Received: by 2002:a17:906:5015:b0:922:ae30:3c23 with SMTP id s21-20020a170906501500b00922ae303c23mr9566199ejj.18.1679319751913; Mon, 20 Mar 2023 06:42:31 -0700 (PDT) Received: from localhost.localdomain ([94.52.112.99]) by smtp.gmail.com with ESMTPSA id u23-20020a170906409700b009334a6ef3e8sm2368602ejj.141.2023.03.20.06.42.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Mar 2023 06:42:31 -0700 (PDT) From: Abel Vesa To: "Rafael J. Wysocki" , Kevin Hilman , Ulf Hansson , Pavel Machek , Len Brown , Greg Kroah-Hartman , Bjorn Andersson , Andy Gross , Konrad Dybcio , Mike Turquette , Stephen Boyd , Saravana Kannan Cc: linux-pm@vger.kernel.org, Linux Kernel Mailing List , linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, Doug Anderson , Matthias Kaehlcke Subject: [RFC PATCH v2 5/5] clk: qcom: Add sync state callback to all SM8450 providers Date: Mon, 20 Mar 2023 15:42:17 +0200 Message-Id: <20230320134217.1685781-6-abel.vesa@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230320134217.1685781-1-abel.vesa@linaro.org> References: <20230320134217.1685781-1-abel.vesa@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Now that we have support for sync state delayed disabling of unused power domains and a provided generic gdsc sync state callback, add it to all the providers related to the SM8450 platform. Signed-off-by: Abel Vesa --- drivers/clk/qcom/camcc-sm8450.c | 1 + drivers/clk/qcom/dispcc-sm8450.c | 1 + drivers/clk/qcom/gcc-sm8450.c | 1 + 3 files changed, 3 insertions(+) diff --git a/drivers/clk/qcom/camcc-sm8450.c b/drivers/clk/qcom/camcc-sm8450.c index 51338a2884d2..b2c6109c7eba 100644 --- a/drivers/clk/qcom/camcc-sm8450.c +++ b/drivers/clk/qcom/camcc-sm8450.c @@ -2847,6 +2847,7 @@ static struct platform_driver cam_cc_sm8450_driver = { .driver = { .name = "camcc-sm8450", .of_match_table = cam_cc_sm8450_match_table, + .sync_state = qcom_cc_sync_state, }, }; diff --git a/drivers/clk/qcom/dispcc-sm8450.c b/drivers/clk/qcom/dispcc-sm8450.c index adbfd30bfc96..0ea719940a8e 100644 --- a/drivers/clk/qcom/dispcc-sm8450.c +++ b/drivers/clk/qcom/dispcc-sm8450.c @@ -1803,6 +1803,7 @@ static struct platform_driver disp_cc_sm8450_driver = { .driver = { .name = "disp_cc-sm8450", .of_match_table = disp_cc_sm8450_match_table, + .sync_state = qcom_cc_sync_state, }, }; diff --git a/drivers/clk/qcom/gcc-sm8450.c b/drivers/clk/qcom/gcc-sm8450.c index 84764cc3db4f..248709fb975e 100644 --- a/drivers/clk/qcom/gcc-sm8450.c +++ b/drivers/clk/qcom/gcc-sm8450.c @@ -3262,6 +3262,7 @@ static struct platform_driver gcc_sm8450_driver = { .driver = { .name = "gcc-sm8450", .of_match_table = gcc_sm8450_match_table, + .sync_state = qcom_cc_sync_state, }, };