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: 13175853 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 52A68C6FD1D for ; Wed, 15 Mar 2023 13:23:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232103AbjCONXl (ORCPT ); Wed, 15 Mar 2023 09:23:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232032AbjCONXk (ORCPT ); Wed, 15 Mar 2023 09:23:40 -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 77E9BC15B for ; Wed, 15 Mar 2023 06:23:37 -0700 (PDT) Received: by mail-ed1-x535.google.com with SMTP id eh3so19569355edb.11 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=doz9jgzjhJMPnp0xUQM4vXkMeo3UuJeXBoRO5HJOKRl4QVtWsKaze1geuaI/P18XBA Y+l7XlsHcpro7fSXLI5ldcHgymlsS0LivxzzcVCSrXn/cEKDW47yfLvRvDIXwNmuBbn7 MT0F3qlK4wT5n2B/VMQu7GFfjJykLnsqVh0Y784Ai+hpfW6Wi0aIHPJs5JLA3UGEI8iA +Nersd0lxxS7z+rdQ63GzEkX7tz32bEuHNWkrx8VRDLdgK0otnchrTfZ+yV3svPxdhEk n8Mjhm/hS6yvOZvEorCP3W0MPUKH4AKLIZG+amrjOB7eO0VifUBWucg7jDaQjrn1dzII 9pZw== X-Gm-Message-State: AO0yUKUOIrAVav9b5dA00cTsFL6AWl3vecn9A/zfJmp4VFwVtgVU+8ha DSMI+klsM7vPkiZ0GOSX7sPM7w== 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-clk@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: 13175854 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 F2EA0C7618A for ; Wed, 15 Mar 2023 13:23:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232108AbjCONXm (ORCPT ); Wed, 15 Mar 2023 09:23:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232049AbjCONXl (ORCPT ); Wed, 15 Mar 2023 09:23:41 -0400 Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C4791BD1 for ; Wed, 15 Mar 2023 06:23:39 -0700 (PDT) Received: by mail-ed1-x532.google.com with SMTP id fd5so41604487edb.7 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=OfnrL6vMion//7WPw+plSzNdEZNXDUDOWXXeiDhb2ogNhhvCCssgTtn7M2tpxLmUgA nIol5EREY9tgZog/g51urHiuWn6917lXOsvFWO5Jr5hgJGmuUINJFF+LfykcSJ+RUzh/ u00seEqGMppUA1RA/lCnsOd9OeGvJLFppe1mtXkd7GV7bbKvxCVFBwJXeTOOZLSMwlbM e2MMwOYDG3S+0j1Ke6RjFqPVm+xsmt0lDRZB8aGC6S2TGDUyfo1AKoYELTEJ0xi4nCfB v54LK1yfDNhZGpcDV0jpLZMbow4+5B4yAIAZ/8V6qan62b6evcttNezk7PClxyUNSFH/ oEQw== X-Gm-Message-State: AO0yUKU8TWOzrER7JwvLjoC0L/vFLvP6/gmSg8eZQ01LSIEaoQ0UCZik kiheJBCBDoe9IW5qU97/cXCvsQ== 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-clk@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: 13175855 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 49F44C76195 for ; Wed, 15 Mar 2023 13:23:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232116AbjCONXn (ORCPT ); Wed, 15 Mar 2023 09:23:43 -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 S231859AbjCONXm (ORCPT ); Wed, 15 Mar 2023 09:23:42 -0400 Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EEDB47C9C8 for ; Wed, 15 Mar 2023 06:23:40 -0700 (PDT) Received: by mail-ed1-x533.google.com with SMTP id eh3so19570031edb.11 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=dx62Z5iPjvnRVpMat7H1gTqDICM7foUCHrMNOb2UShdLOM4yCd0gvxWFjseq73gBU6 RdZQHtdp5ywEhYshvYJbYLtQaAEFlVHjlgftXxyA0ipOpMlUHjhiVXVKYnXyRJid5/pf odN52EvRKkc3GUyuIGbKEjjDcAxi5r1YHDg9duafPgk/5iRuadOeodHS4GfXednCW2sp yUS1WhEmLpEuZmwsN16mz9Xcp358AJE/26FgNEGE+xq0S4g7OYS7qpMfbPdAwywpPuIG WO00uDIESU+D3F/VYAhVTaHke205Ozu5zc8934c5E529w34aVqNn2jDQm5aZB/BQ9mPM cRUg== X-Gm-Message-State: AO0yUKXMhDd9mz3OZ12HrG+3tQr/6G2rvpJ55qODCoLsMl+OiMOWV9HC XPEV8IofGjS0ujc3sIa9BPSafg== 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-clk@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: 13175856 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 0CF8FC61DA4 for ; Wed, 15 Mar 2023 13:24:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232186AbjCONX6 (ORCPT ); Wed, 15 Mar 2023 09:23:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232123AbjCONXp (ORCPT ); Wed, 15 Mar 2023 09:23:45 -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 8EC74A3B64 for ; Wed, 15 Mar 2023 06:23:42 -0700 (PDT) Received: by mail-ed1-x52b.google.com with SMTP id r11so23837694edd.5 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=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=2gU9fiT8yqZz7kob6Ddh11mdTbh2WK+4dNWSVyI3GlsouEZzbRZSzCvgzsNfx0VsaK vNT3/KrjWsG9oKP/01d29FQLy0sTE7V8Cl2Xv6WWwGAUkqzguVbxiA1zvd1HbJJIKJ/+ wxKEqY3R2zCdUv3gDYCvCAwpuDu435qiN93YPolTaPOE/rtuekZpt+6qgRsYNsJUFVve tw+ZdjpSkESSApKWtOevgNAlO5Hgg4t4b/2H0hAcwPeIqy2KMr0Eq8kypoxWK/qWYU5I cwi0IzfaxEM+prIplkDty6doCOkcJQq+DdIJTWIkcGnx/l15+ff3JznnsFPwpubGHFMq dqxg== X-Gm-Message-State: AO0yUKUy4gvL8Fhp9rCFZaj5KDiS2wCWSLFZ2p4mdwwESWUw8y8GkAnC rkj8bvFraH4AmpVqnvHitwD3aA== 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-clk@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: 13175857 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 2807BC6FD1D for ; Wed, 15 Mar 2023 13:24:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232139AbjCONX7 (ORCPT ); Wed, 15 Mar 2023 09:23:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232126AbjCONXp (ORCPT ); Wed, 15 Mar 2023 09:23:45 -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 08B76A3B7C for ; Wed, 15 Mar 2023 06:23:43 -0700 (PDT) Received: by mail-ed1-x535.google.com with SMTP id eh3so19570661edb.11 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=1/uGjC/2708je2XKDSA7TLYgOKy03rKrwcBIp1/8B6gKdIY6SnCZoUz348xd/KjeYU nKYLSVLqh7Lm1i4PHH2Q2eokv73db7iXyCtSVRV7+fsDWz9QkRX+GREtlOJZOgq5fgDr jMHZriCGGif94DHHoaYXV1moESADVkwCMJMijDf0mg8Y4LTM6gO0B6Mkya54Y5dZRg28 oTvhVPOwBBgR/ci1x2I3Fr9UblJNhwOtXa6nC7YsuwQmHP2gZvVgx1f4JJs+6gDJ3dH+ OkOCLxSD56T6vpm8A2mQgRMXigHrn7sojZ9jNhVJ0s6xU5YsV6OA2p40nNJ53UL8rAvS Vf6A== X-Gm-Message-State: AO0yUKWcz4edpPrkenpzT8t9jDK6LM6iWPXyOC+JEn7V/XPdsjpI/bKz a6gBJ++pFTdzFYriN4dxWU6gaw== 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-clk@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, }, };