From patchwork Wed Mar 15 13:23:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abel Vesa X-Patchwork-Id: 664438 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 0123EC7618B for ; Wed, 15 Mar 2023 13:23:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230421AbjCONXk (ORCPT ); Wed, 15 Mar 2023 09:23:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231871AbjCONXj (ORCPT ); Wed, 15 Mar 2023 09:23:39 -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 7631F59E8 for ; Wed, 15 Mar 2023 06:23:37 -0700 (PDT) Received: by mail-ed1-x530.google.com with SMTP id cn21so45311888edb.0 for ; Wed, 15 Mar 2023 06:23:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678886616; 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=HLRj53L/DjbMBhi79PBbCLq4uHXoSyceNvFogThLTB0=; b=O83NQyj//J7bmfedXnmbIqeW8+JZ+xkH6PdT0B1LHXQwigwDA4kKO9qois1oqflooO 2qN3SbCw7sMLxHiCBH7UUzaSlQI4tGkIPl7tWzRhqwe4cPeQHepWNoSWdv1JkeiUSAqn 6SzVrAsKaY8+/+6upW+K0/kX1dagOxqA+52IjhgReVcifbfVHPco3q1/sknGmtHVlrny zCmslTLInyjOgsClAVV/udywSh2Gcem+dLJEEkkoouFM6o1cNve15fCMg3e293FtrHTG hgnBZQ8zlkCCYlgZaw+6j17I9qlldEHXyzFQlTMNuVVtaAODnnJm+KQvCRdBVtEzX7Il 8rzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678886616; 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=HLRj53L/DjbMBhi79PBbCLq4uHXoSyceNvFogThLTB0=; b=YQOdaMh1uoQ3UjI7CpHC0mjaUymCOwTrylMGhVbKVSGna0GYlD4WVD0qdiTyEY1jXS LY+0tZUOcRyfYnqEquBAjIbRHpIb9eqpZdnyFojfCI9Dzp/ipvCAV1rgG1PVEsV7Kqe1 V96c8iaYpWRpzewdGnK6kkn36L9S23BigxR9K+CQ3VFFDblicbuQm0SipZw7tjDTUWHU LPjrK4gWaju4HiwKQtJV5TmzUnAb5ZYFttkv7CzJDKcpRlVteTDJ6oOefxH/Egt90TZx 14V6py4AbrgDUinzxa/rGbctaVzTVw1qj2BgWwJXXgz6Ogae6tjXXEKgYgaGJHufb6dl KxbA== X-Gm-Message-State: AO0yUKUwS4NDRe6TOItXy20He0GxsjjzyCjNtlHfGV6ZbQ81rH0yue9i RqUea+WXmbQLuHToihZMrVpulw== X-Google-Smtp-Source: AK7set9pBrz1LS8rrkjEkjlBWW/QTLUzc6ajPIuUyelYl6UYlSSo60YiGfHokLYhvw8Y59YDahM3DQ== X-Received: by 2002:a17:906:c2c3:b0:870:b950:18d4 with SMTP id ch3-20020a170906c2c300b00870b95018d4mr5975836ejb.5.1678886615800; Wed, 15 Mar 2023 06:23:35 -0700 (PDT) Received: from localhost.localdomain ([94.52.112.99]) by smtp.gmail.com with ESMTPSA id pj18-20020a170906d79200b008b133f9b33dsm2497365ejb.169.2023.03.15.06.23.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Mar 2023 06:23:35 -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 1/5] PM: domains: Allow power off queuing from providers Date: Wed, 15 Mar 2023 15:23:26 +0200 Message-Id: <20230315132330.450877-2-abel.vesa@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230315132330.450877-1-abel.vesa@linaro.org> References: <20230315132330.450877-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..c9c0b4916e25 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 Wed Mar 15 13:23:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abel Vesa X-Patchwork-Id: 663902 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 AB967C76196 for ; Wed, 15 Mar 2023 13:23:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232019AbjCONXn (ORCPT ); Wed, 15 Mar 2023 09:23:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231871AbjCONXl (ORCPT ); Wed, 15 Mar 2023 09:23:41 -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 5C6472690 for ; Wed, 15 Mar 2023 06:23:39 -0700 (PDT) Received: by mail-ed1-x536.google.com with SMTP id x13so28145842edd.1 for ; Wed, 15 Mar 2023 06:23:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678886617; 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=kcCmlMd948KTeFaT82iddBgwWZPmI85qhyHyJAJKzspk0SsOyGqNByNvBE+bAMsClo fiFyE57RAgHFWGTtx0x6MMBEZbVVWGTbmc5kIMsBNu60iCBvcRghGHAaJ7BFtc87EdA4 gQIsAiC51MpVQSrv61X7jG93H+kGWQ3fc9BenKW5Kzi2S870BrFMviIX0b1INPVah++M 3WTlJCeJcP5wH/B62iolL3NhCGoDdPmtecKFbZ5qkFujaQJxgLzaNpCR+mLxefhwaoy0 m8E24qya4KdhgUG3MeW999hZMIAzUmzBGnlWzix4N893xlvhnGBj61IcTG8H96l9XN+v C7lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678886617; 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=beXloMlhHTt0kCLeffyzFJC/3nM9Ulnx2Y7edzm8ddsv9orb8cbPtZ1N9xa7eB/N9U LnYF1jCEFOp+vPinMm5mhG0aRXDXUMnUzgxldrjSELX1A9ghiOSIWWlkDb/WDhLseVAD 3xdy6dS5Tvqst3SJl1JarFS7Eikye3TTsi2pgh+4+DR4kyNWbLvad9ylYI4TAzZxSTJ3 mZq61gCozF06MuFY8hh4gslHjvZltuPzYsfp35GOcL3MMiJz8RNXyAUHYJoyJGnbIkgk bD0PDNmPPQXOdxZOsOTVDrnpxhkLgqo8+ZhUyUxpvK+6J3zD7VKidXU+RC5A/r1Fb8+n tKGQ== X-Gm-Message-State: AO0yUKV95S4mvH6TA7zxkQiw/HbqFd75UyDSofSAAcWwDPomqxKG6IdD 9K7B2Qt3jiS7mVJpARUZs4j+qw== X-Google-Smtp-Source: AK7set+aEpLN7DIU+ICSDUHqoC29NPehGqibZ+dEU/3SKCMWs0P9gQyG0fxkTGoZVcpIiVf9y8OyVQ== X-Received: by 2002:a17:907:9708:b0:878:711d:9310 with SMTP id jg8-20020a170907970800b00878711d9310mr7626418ejc.1.1678886617534; Wed, 15 Mar 2023 06:23:37 -0700 (PDT) Received: from localhost.localdomain ([94.52.112.99]) by smtp.gmail.com with ESMTPSA id pj18-20020a170906d79200b008b133f9b33dsm2497365ejb.169.2023.03.15.06.23.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Mar 2023 06:23:36 -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 2/5] soc: qcom: rpmhpd: Do proper power off when state synced Date: Wed, 15 Mar 2023 15:23:27 +0200 Message-Id: <20230315132330.450877-3-abel.vesa@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230315132330.450877-1-abel.vesa@linaro.org> References: <20230315132330.450877-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 Wed Mar 15 13:23:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abel Vesa X-Patchwork-Id: 664437 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 D61C9C7618A for ; Wed, 15 Mar 2023 13:23:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232138AbjCONXr (ORCPT ); Wed, 15 Mar 2023 09:23:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232111AbjCONXm (ORCPT ); Wed, 15 Mar 2023 09:23:42 -0400 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F015A7D55E for ; Wed, 15 Mar 2023 06:23:40 -0700 (PDT) Received: by mail-ed1-x52b.google.com with SMTP id x13so28146218edd.1 for ; Wed, 15 Mar 2023 06:23:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678886619; 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=aqhvuVHwpVGYPj1wx2nfChRpVpIaSQgTHV9PFa+xcU4=; b=UsAAKnqynOf+CGYjQ+eAfuXtM4OZkXDj+dNmcyHjBiZ8gH+LUv1IEFkcR1KNv3mAbg 2vCP3Lmn95yeoXEWlzjV8f3RbAtJ0hE0P4SmjtspJKfhJO2Upi+bMtyefb/QFelag0C3 1/5q7H92YbC4PM8Fgkfm1dGQGWBNVK40elIPH56ubtH1nkf++N5EHIfAV+jdnMdeT0hO WvdKXsW9aDx/5gXtJi4Oady7nf04mxv1cdhBW9xg2+2AtfyKbPzf+crEkufH6GMSE9yV Eu7J24eEAGSOr1DC0yZw4BV9lRDDGZH26NPaAtJ5MTzDXH3Yr8uUTBL7XoQ7f2myaYUW zOGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678886619; 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=aqhvuVHwpVGYPj1wx2nfChRpVpIaSQgTHV9PFa+xcU4=; b=DQfdbCvAflTYZkG2T41ekD3Qct3xtAX19gpIksGOyQl4l+D+GUbJGwY2wuPC/Uk0E6 /WfN/IL1f6aonfQPwS1PJKTmim7NIBVw7a5CvuKWLUNp7bO+gyfbAxd9CnFGb9ZMm86q W7NmYxuSBaq9UiRyvrIcFHAw+in+ujdcL4PKiUNubePy6tqHAkSRtHfBbxlLzM8e6xNl 1maq36hPgqFFwOsWl04td0Pa5+USRfpuBpPxPP/DoLA7Wodzlb2vptOrxfi7KLm4dNqB t5+sZFhP0MXjdmHVtbMevWgeeTmPhMLZ5ScYD66lv+10Cl8fV9CUGdVVxRwSJo+BRAGl JQMw== X-Gm-Message-State: AO0yUKWJ037u7x6Ukm8ZNFsPTkYyiF6U7qmJzRqRtmfBre5cnb83okiB d6gvXpI5RMcxMJMoylNtPvLGOg== X-Google-Smtp-Source: AK7set8pwlmsIm8odlhiimk6qn4jYvTXoMnOIO03pAqLGGAYfkZ6JfwzBQxc201BT+jvzeQ9s6qLVA== X-Received: by 2002:a17:907:2076:b0:878:625c:c8ff with SMTP id qp22-20020a170907207600b00878625cc8ffmr6136496ejb.54.1678886619280; Wed, 15 Mar 2023 06:23:39 -0700 (PDT) Received: from localhost.localdomain ([94.52.112.99]) by smtp.gmail.com with ESMTPSA id pj18-20020a170906d79200b008b133f9b33dsm2497365ejb.169.2023.03.15.06.23.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Mar 2023 06:23:38 -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 3/5] clk: qcom: gdsc: Avoid actual power off until sync state Date: Wed, 15 Mar 2023 15:23:28 +0200 Message-Id: <20230315132330.450877-4-abel.vesa@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230315132330.450877-1-abel.vesa@linaro.org> References: <20230315132330.450877-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 | 13 +++++++++++++ drivers/clk/qcom/common.h | 1 + drivers/clk/qcom/gdsc.c | 26 ++++++++++++++++++++++++++ drivers/clk/qcom/gdsc.h | 6 ++++++ 4 files changed, 46 insertions(+) diff --git a/drivers/clk/qcom/common.c b/drivers/clk/qcom/common.c index 75f09e6e057e..9bcda6952c20 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; diff --git a/drivers/clk/qcom/common.h b/drivers/clk/qcom/common.h index 9c8f7b798d9f..170266b4e9e8 100644 --- a/drivers/clk/qcom/common.h +++ b/drivers/clk/qcom/common.h @@ -61,6 +61,7 @@ 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, 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 Wed Mar 15 13:23:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abel Vesa X-Patchwork-Id: 663901 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 8881FC61DA4 for ; Wed, 15 Mar 2023 13:23:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232161AbjCONXs (ORCPT ); Wed, 15 Mar 2023 09:23:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232093AbjCONXn (ORCPT ); Wed, 15 Mar 2023 09:23:43 -0400 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A078C26BD for ; Wed, 15 Mar 2023 06:23:41 -0700 (PDT) Received: by mail-ed1-x52a.google.com with SMTP id z21so10158069edb.4 for ; Wed, 15 Mar 2023 06:23:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678886621; 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=z6Q5mnwZerUqt0rPDmFb5WgXIlQQvBuhlqFXmv7x/E8=; b=v8CeUBfci+2vyzQEs4Rv2vSs3xgOflEwBGX290bxPufp8u8LNIOMlkwcnVzAd/JHTS fKtlg1yp861KIf8/L1MJwZILV+rQXo66j3Yxt9GK2ezkucnxv+S+0i/EnOuoYDUhJOV3 B6JpC0fqm3lrN2erdD+046lrlomd/a16+nW2JchX0Jb24U9w1cd/ZJNtpLSUYRhQsIlu j0VP1QxVb20iygWUI9vh2kc1KeznBSrLdSCryvv3cS+hgbtWk5/gbaQj/AD3vNkuqYPU A/IWUl2UBUfC+Ob8tJcCN4OaDEuUsJbZqVAv+jnL6QKj1HEuwp2mjGfX7wCJLSZMrfzW EfjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678886621; 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=z6Q5mnwZerUqt0rPDmFb5WgXIlQQvBuhlqFXmv7x/E8=; b=OZ5JbaswpC1vToTMRiH64M0xwknfzYWr3+8mAR3EeKZIJXQ6wgwKgzd61EXkUlR+lu bXmvfLwrdS5n8eZZ8RbdjW2ScjRWwT/gZGbweNL/plGgOp0+2AgoPd6+pdLY1g4jFXzw dK0FxAhf8eFQ5Kv3ypSzxrPi9CZlCNdHfcwj/92DzwnE8kfnc+DBxytdqXGoGQDlbxpD Y+a8mYO4zN8DAzpPJ3ELhWszzMQiyD+uHcVDamMW4ybEkwLGviYv5gJ897qd8bQqwCny 2xX7l72q7m/FTTJvFunQ4TJgePAalP415ziSEGPQyN8l2OS9cvWm2qrdQR3ukJJJPxEk YQWQ== X-Gm-Message-State: AO0yUKVufqgxc3Ibk4C6Xg0DzXeBWjS+YEp9u2qoBAoedktQb3Fx1wQ6 KpEioco3bq4ySJ2d+bp2LW+84w== X-Google-Smtp-Source: AK7set80lwILGeMEjE90/hXf2KxCex24k3hIxwK6a87YWNsiAs3RYf8jzg8Y/7RnlkbsWjydDWh7+g== X-Received: by 2002:a17:907:7f8e:b0:92f:1418:27f0 with SMTP id qk14-20020a1709077f8e00b0092f141827f0mr2127459ejc.34.1678886620990; Wed, 15 Mar 2023 06:23:40 -0700 (PDT) Received: from localhost.localdomain ([94.52.112.99]) by smtp.gmail.com with ESMTPSA id pj18-20020a170906d79200b008b133f9b33dsm2497365ejb.169.2023.03.15.06.23.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Mar 2023 06:23:40 -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 4/5] clk: qcom: Add sync state callback to all SC8280XP providers Date: Wed, 15 Mar 2023 15:23:29 +0200 Message-Id: <20230315132330.450877-5-abel.vesa@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230315132330.450877-1-abel.vesa@linaro.org> References: <20230315132330.450877-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..f97bda6c7e3a 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 = gdsc_sync_state, }, }; diff --git a/drivers/clk/qcom/gcc-sc8280xp.c b/drivers/clk/qcom/gcc-sc8280xp.c index b3198784e1c3..222bca0f8093 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 = gdsc_sync_state, }, }; diff --git a/drivers/clk/qcom/gpucc-sc8280xp.c b/drivers/clk/qcom/gpucc-sc8280xp.c index ea1e9505c335..a9f0e7bbacce 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 = gdsc_sync_state, }, }; module_platform_driver(gpu_cc_sc8280xp_driver); From patchwork Wed Mar 15 13:23:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abel Vesa X-Patchwork-Id: 664436 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 E615CC7618A for ; Wed, 15 Mar 2023 13:24:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232221AbjCONX7 (ORCPT ); Wed, 15 Mar 2023 09:23:59 -0400 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 S232130AbjCONXp (ORCPT ); Wed, 15 Mar 2023 09:23:45 -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 0A1B3A4029 for ; Wed, 15 Mar 2023 06:23:43 -0700 (PDT) Received: by mail-ed1-x536.google.com with SMTP id x13so28146860edd.1 for ; Wed, 15 Mar 2023 06:23:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678886622; 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=UnW0CMrrRD3o9YvTtj/2PZfd1w3APSitkBSkSzkAq3A=; b=cIoenhYmTDDKZ0euB2ODKr3LotX4ppL2RTmY7rx4LHYybPdccQrPSTr+zjPffclIwD k+6Q4fDW3EAwNRRuFsbyhhImD8R3omHYItX05zQqnwsqlABoIOICjL/Cf/X9pC4J8Wjv HZj1lO/Nsh2knHgaHr7f2V67UlTJVZWVAoynksoC9l8EeKEowzrk0pY+o+vQHm3IeQnm PvdZtWTxW3F3JCNkpG+rgvq0x8m1XaGQ7HaEivuI/+dOvcEeU3nYVP0i9mtPnqsRSVM6 X1N4cWtUjSaXy2FJCd1/duAtLA7rV8DmP43e1rCd0jFSF52WSdUK/eikCZgXZ0TRFum3 eCdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678886622; 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=UnW0CMrrRD3o9YvTtj/2PZfd1w3APSitkBSkSzkAq3A=; b=DOIZE54gHQWRw4cRUXvDygcEQEbjxr0dyQkUnDM60w5H6qVEqZ9YFn5xWGYLRaZJ+a a09AQbbfqS1cf9IYodfaEohRdg6PqDIe5ZodF2Hh0yxXa5P2F7WZXYvW44gVftsMhBN8 xzn0eyKWymsgDtZhftu8JTknHH9IJQiY4aMheW3A/zcR+wpzVahPWVkQWjnxOyNdHy90 zalnWJ77ydT/3bF8HECTEpQe+Nw2XsQWGn4E8oLYHERWzpXVstHHJo0cmwrcaoRz8HNk YEzKC6Ia3tA+IMMjch5B+bF9tUML7asmkyzwVaN1N352wCPNgvShJVR+5cTiMyYtng2T 2Cfg== X-Gm-Message-State: AO0yUKXZCIqE/WwhTpPObfIX8S0DvAy8NrTUgd8bPsml8+xZSK3Ofmol JmxkgJGKAcEBvzSQsVd/d/h0Eg== X-Google-Smtp-Source: AK7set+W+V2K+JVgObXv7PEO2bdA92Y2AmBplxjf8AwC8skNcxMQIt1ZNpm4fZzwq+uDEYAYCDcLJQ== X-Received: by 2002:a17:906:dff5:b0:8b1:3193:4874 with SMTP id lc21-20020a170906dff500b008b131934874mr5703584ejc.46.1678886622632; Wed, 15 Mar 2023 06:23:42 -0700 (PDT) Received: from localhost.localdomain ([94.52.112.99]) by smtp.gmail.com with ESMTPSA id pj18-20020a170906d79200b008b133f9b33dsm2497365ejb.169.2023.03.15.06.23.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Mar 2023 06:23:42 -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 5/5] clk: qcom: Add sync state callback to all SM8450 providers Date: Wed, 15 Mar 2023 15:23:30 +0200 Message-Id: <20230315132330.450877-6-abel.vesa@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230315132330.450877-1-abel.vesa@linaro.org> References: <20230315132330.450877-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..6ae360898aee 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 = gdsc_sync_state, }, }; diff --git a/drivers/clk/qcom/dispcc-sm8450.c b/drivers/clk/qcom/dispcc-sm8450.c index adbfd30bfc96..45f4ea3d26bc 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 = gdsc_sync_state, }, }; diff --git a/drivers/clk/qcom/gcc-sm8450.c b/drivers/clk/qcom/gcc-sm8450.c index 84764cc3db4f..f2b542753553 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 = gdsc_sync_state, }, };