From patchwork Fri Jul 9 17:31:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 471885 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp517369jao; Fri, 9 Jul 2021 10:32:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyACoCPiXq2yt8UHvOdcVK+9Nod5xH2mKlztWdaQsjErr1FfDGucvjBib81tb3U1mF2t3gk X-Received: by 2002:a92:6e07:: with SMTP id j7mr12812860ilc.71.1625851938606; Fri, 09 Jul 2021 10:32:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625851938; cv=none; d=google.com; s=arc-20160816; b=fBDbjvn5gXWSwL/DOIgfYRS0ZiejNKLrnTilPqAI62Unv8CgD6uZAvYir4/feOMFBO 1FgmLol0UDp4C2nnNYzVhcKng6HKzaTdgH4XlBjUKpqyUvhtvkqLwNEpFMKbghM+FkF3 FQ2sITbQifGuvURMbrR/CPYoIjjKVGCtPzKEk1q8EoAZoGjccHghkPtYsEQ37mAkRkiD e0CTkOjXdnOetzf9odbae+Pr8/V38iu+9lFFoQAKr1h6RxZ932Gyd8HH+ihpLbGlWE7p anMVMP2eXZxSjgnEogafyyvwZfo025xVNubDFL0LIwVLwTCdnMmz8GET2nn/dXmau5nJ AEjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=SjFzSjONYuEpNPrn8vILKcXv8t+6phQCfA+Cce2Zw8Y=; b=QCQVAhKdiQ/0jGCWfNJWbzhfMLcV2Kvgo4DmODR1Vq/TIXUa7Y0j+b/ZGrIuMYrs6Q QlDTlGBJK3NsfEtgYF3a93dsOPBmT05RHyJ+f06u+XaV+IH2fljy1IXhAbTUfV7lqMhI 68gv3+QDRSOnkh2mqJfFPSNKAbO7rU1jTGnynCMs3wM8L2TXqKgxGrcbkKz4y9rC0cbf aD+m10Zblh8BFAik1sbJJYy6jpg74TRSreAkJzOPLbrCAvUvzIumx3UkXhpshk0k2843 mmuqXJiHs73B8ZGY3JA6fTZIELT3lKLdq9A6DuknRivzT4HBisKcyVXwYGbqMmxvqiKp befg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=p1R064hg; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g12si6886612jas.65.2021.07.09.10.32.18; Fri, 09 Jul 2021 10:32:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=p1R064hg; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230189AbhGIRe7 (ORCPT + 17 others); Fri, 9 Jul 2021 13:34:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230130AbhGIRey (ORCPT ); Fri, 9 Jul 2021 13:34:54 -0400 Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 042DEC0613E8 for ; Fri, 9 Jul 2021 10:32:09 -0700 (PDT) Received: by mail-lf1-x130.google.com with SMTP id p16so24794000lfc.5 for ; Fri, 09 Jul 2021 10:32:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SjFzSjONYuEpNPrn8vILKcXv8t+6phQCfA+Cce2Zw8Y=; b=p1R064hgfUHwIESmq5LWdQ94d96i6QYw/zDC96aRgFZNeECDduxwX5DPaypaqL8KvL qq9vz4ZgnML2KJfPa6ObS6NeNfG2TIX1xOGXMZRdjMtDU3+ZwhWDlWgwL2Y2t6QBllsZ xJCH8mDwzSbeJ+L7X8saMxxPRidmmJ8fMQNF0ifXOaa/ZyOjmVQYOuh2zhGUKEgBQTL7 a7BLDovTgb7UTa8F9oH64kxrVpk8PMltfj7qNrUZVtpFKwraRRPtpGiY5pVOuk/DK8iu esK8He96Cw4cAEP84HrkKLYrb1Qh0kfK7hCyuGXXa4bakHyxLUsT4f8tpPxe+AHKTtpt 0IMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SjFzSjONYuEpNPrn8vILKcXv8t+6phQCfA+Cce2Zw8Y=; b=WJB7Ol5GOicVDOHviTenqQPU3ZlBUIFyeFoH2CzOSKSyTayMTwQIup3f2WcM0YZsUM ZEvlZ7oQUmwMZC2W/4xmjwAl1XkrrrNLb00iV9srlxT2S9w2cJ4nf/KWIkWSri5fOFH3 OYiembtKG/t0SKrpX38H/Oz8ZpOoIRDFf06fkwH/oYLn+fpOtXldmG6V3+rGW+3s8Q5Z oXVCicdijaIg1lLsMCmroG5faVeZ0HyOTB3F6uVq9b1eT2sOEiw2cFwQSUHSZU3S0r6C awcvovouE5dJfi0FEXlf/6fcElsfYxNsvyLYdDyMOz8cgdErMHlrTV/CADDhZV3R4GvY D5yA== X-Gm-Message-State: AOAM5331h75TMVdhXjx76/DyWyU1C1IuJ6cTaq2+EmAVh/Zvi7Lw0pBc U4cAEPr8iRrR5phga8c5IVnaKg== X-Received: by 2002:a19:6a09:: with SMTP id u9mr1385279lfu.119.1625851927371; Fri, 09 Jul 2021 10:32:07 -0700 (PDT) Received: from eriador.lan ([37.153.55.125]) by smtp.gmail.com with ESMTPSA id b14sm511129lfb.132.2021.07.09.10.32.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jul 2021 10:32:07 -0700 (PDT) From: Dmitry Baryshkov To: Andy Gross , Bjorn Andersson , Rob Herring , Stephen Boyd , Taniya Das , Jonathan Marek , Michael Turquette Cc: linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-clk@vger.kernel.org, Bryan O'Donoghue , Mark Brown , Ulf Hansson , linux-kernel@vger.kernel.org Subject: [PATCH v3 4/7] clk: qcom: gdsc: call runtime PM functions for the provider device Date: Fri, 9 Jul 2021 20:31:59 +0300 Message-Id: <20210709173202.667820-5-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210709173202.667820-1-dmitry.baryshkov@linaro.org> References: <20210709173202.667820-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org In order to properly handle runtime PM status of the provider device, call pm_runtime_get/pm_runtime_put on the clock controller device. Signed-off-by: Dmitry Baryshkov --- drivers/clk/qcom/gdsc.c | 66 ++++++++++++++++++++++++++++++++++++++--- drivers/clk/qcom/gdsc.h | 2 ++ 2 files changed, 64 insertions(+), 4 deletions(-) -- 2.30.2 diff --git a/drivers/clk/qcom/gdsc.c b/drivers/clk/qcom/gdsc.c index ccd36617d067..6bec31fccb09 100644 --- a/drivers/clk/qcom/gdsc.c +++ b/drivers/clk/qcom/gdsc.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -50,6 +51,30 @@ enum gdsc_status { GDSC_ON }; +static int gdsc_pm_runtime_get(struct gdsc *sc) +{ + int ret; + + if (!sc->rpm_dev) + return 0; + + ret = pm_runtime_get_sync(sc->rpm_dev); + if (ret < 0) { + pm_runtime_put_noidle(sc->rpm_dev); + return ret; + } + + return 0; +} + +static int gdsc_pm_runtime_put(struct gdsc *sc) +{ + if (!sc->rpm_dev) + return 0; + + return pm_runtime_put_sync(sc->rpm_dev); +} + /* Returns 1 if GDSC status is status, 0 if not, and < 0 on error */ static int gdsc_check_status(struct gdsc *sc, enum gdsc_status status) { @@ -232,9 +257,8 @@ static void gdsc_retain_ff_on(struct gdsc *sc) regmap_update_bits(sc->regmap, sc->gdscr, mask, mask); } -static int gdsc_enable(struct generic_pm_domain *domain) +static int _gdsc_enable(struct gdsc *sc) { - struct gdsc *sc = domain_to_gdsc(domain); int ret; if (sc->pwrsts == PWRSTS_ON) @@ -290,11 +314,28 @@ static int gdsc_enable(struct generic_pm_domain *domain) return 0; } -static int gdsc_disable(struct generic_pm_domain *domain) +static int gdsc_enable(struct generic_pm_domain *domain) { struct gdsc *sc = domain_to_gdsc(domain); int ret; + ret = gdsc_pm_runtime_get(sc); + if (ret) + return ret; + + ret = _gdsc_enable(sc); + if (ret) { + gdsc_pm_runtime_put(sc); + return ret; + } + + return 0; +} + +static int _gdsc_disable(struct gdsc *sc) +{ + int ret; + if (sc->pwrsts == PWRSTS_ON) return gdsc_assert_reset(sc); @@ -329,6 +370,18 @@ static int gdsc_disable(struct generic_pm_domain *domain) return 0; } +static int gdsc_disable(struct generic_pm_domain *domain) +{ + struct gdsc *sc = domain_to_gdsc(domain); + int ret; + + ret = _gdsc_disable(sc); + if (ret) + return ret; + + return gdsc_pm_runtime_put(sc); +} + static int gdsc_init(struct gdsc *sc) { u32 mask, val; @@ -425,6 +478,8 @@ int gdsc_register(struct gdsc_desc *desc, for (i = 0; i < num; i++) { if (!scs[i]) continue; + if (pm_runtime_enabled(dev)) + scs[i]->rpm_dev = dev; scs[i]->regmap = regmap; scs[i]->rcdev = rcdev; ret = gdsc_init(scs[i]); @@ -486,7 +541,10 @@ void gdsc_unregister(struct gdsc_desc *desc) */ int gdsc_gx_do_nothing_enable(struct generic_pm_domain *domain) { + struct gdsc *sc = domain_to_gdsc(domain); + /* Do nothing but give genpd the impression that we were successful */ - return 0; + /* Get the runtime PM device only */ + return gdsc_pm_runtime_get(sc); } EXPORT_SYMBOL_GPL(gdsc_gx_do_nothing_enable); diff --git a/drivers/clk/qcom/gdsc.h b/drivers/clk/qcom/gdsc.h index 5bb396b344d1..a82982df0a55 100644 --- a/drivers/clk/qcom/gdsc.h +++ b/drivers/clk/qcom/gdsc.h @@ -25,6 +25,7 @@ struct reset_controller_dev; * @resets: ids of resets associated with this gdsc * @reset_count: number of @resets * @rcdev: reset controller + * @rpm_dev: runtime PM device */ struct gdsc { struct generic_pm_domain pd; @@ -58,6 +59,7 @@ struct gdsc { const char *supply; struct regulator *rsupply; + struct device *rpm_dev; }; struct gdsc_desc {