Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp1368350rdh; Mon, 25 Sep 2023 10:29:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGOshR8cDV9NwMfaNVYcrA5N7pR2YGu9oCq77tkPrRE0odAzB2/SigDJL+FMLywiwx5nwUN X-Received: by 2002:a17:902:e5d1:b0:1c1:fbec:bc3f with SMTP id u17-20020a170902e5d100b001c1fbecbc3fmr9147682plf.5.1695662996555; Mon, 25 Sep 2023 10:29:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695662996; cv=none; d=google.com; s=arc-20160816; b=OiidewJkexEcWon2wYtaaIgR4uffaD/y9gzW74MNx+gvUnk/cMJfQQhrdui6WBMHG2 /mlmYypoArbvVaou46GrqB01FvHcYm8olck8q6ufxOYCRr7yFn3qk0B7/okhpjtgyqLb FWIH1JYBDGOyO6tmBBqyoI2wTYc/SSXnKGRIBHUx2LobnsyBxkHWE1Z8x2IZNRK/e/dG gO1sYkzNBkqiuhiqsWqU0w5E3MyNphEicCVDx2Ggzk4FaruiF1pCQHkP9p1THu63bJbJ RGvZUt+9rKM28oxGRJBHJMtZ7PmaB4MAVOZ14ZTAOhVYVAjEMQpDwxzHzMWbd+bBUWs3 JtsA== 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=167tdHqooI6VpzhOKyy9DJn5EBlj5nE8zbkLsDZ7woM=; fh=0iKC8n1xKtkvw+5RDzSud32j7h9ilf6Mvh4d+L1hSv0=; b=I866EcI7J3C/VWaPJ5lBKaEGbP37bYGZ5J024iclupBAJlymi0HL82lWI6Fih+7IYh XbCQglVxy9DZBlHGZNUPYByOQb/hulaheVUg86AwJVvFLj73FtpT07wfVPr5UfvIO1M/ bSn4aDyS8sZbP6cnHkyV04EFaE4QF8gQ4wxWgOvrG/8uNw+nO2HOd25yoc1JsqiKJFVH 45gk4CWFjQ0sQd9xJvE3H0NlJvPufUVjtQJz6Sq4k1ZvrqSdrdwAONgo8V9pCuUyFapz 0HpJIVfAWi1CuQ0mDBZh60a4OGtc4VQNU2KZBVwSWP38Lv6AKVNjyD7uK0NCcEIseRbG 3MgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WBP4+Kkn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id n4-20020a170903110400b001c4621ac000si11140269plh.246.2023.09.25.10.29.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 10:29:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WBP4+Kkn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 677E281121FA; Mon, 25 Sep 2023 06:18:12 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231502AbjIYNSK (ORCPT + 99 others); Mon, 25 Sep 2023 09:18:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231706AbjIYNSF (ORCPT ); Mon, 25 Sep 2023 09:18:05 -0400 Received: from mail-lf1-x136.google.com (mail-lf1-x136.google.com [IPv6:2a00:1450:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB332FE for ; Mon, 25 Sep 2023 06:17:58 -0700 (PDT) Received: by mail-lf1-x136.google.com with SMTP id 2adb3069b0e04-50305abe5f0so9987684e87.2 for ; Mon, 25 Sep 2023 06:17:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1695647877; x=1696252677; darn=vger.kernel.org; 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=167tdHqooI6VpzhOKyy9DJn5EBlj5nE8zbkLsDZ7woM=; b=WBP4+Kknvb5kO7n8iUdyddmGhNYDy76agy14hEc9Lzsiq56UTzfZxCY+r8ln6rlItd scyX0Zdfo0L4pkQ4HFFpFBHhmu+jio7i3aHE7kdfcWu5WaubjK2T/KTDZzN2rjROsCr7 xyyt2iuivX2VXXvE6MuqGm9TSHvoq+4pSUAzbHXtrw/ivXtVMVaX7AQY4ErlsBjSiigc iP0UdG0nQxN49PjugAJe5kl2AdxA5pR/VDanP6bLT6Y6Rt527DDW49AAfPNZYbXFlDsM 169VaJzgHwt/qqncQgmcxn5L9En0/SBleLQovZZ/66eTsm9yqKNyrz/PqTrSZV/iYEEQ W0hA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695647877; x=1696252677; 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=167tdHqooI6VpzhOKyy9DJn5EBlj5nE8zbkLsDZ7woM=; b=BNiS+1unUY0jrNXPCkZtj34Xh3SiJzBLggA14M9fwyXJxPjJjRz2/DDENwgs4wy8f9 /Bid4AhTMZgiI7+k4aspYJoaWA9SsYhgWyT+BiWoK2BvHk7A4P4+qZIqO9exFgf3RD1a S4PU+K2dXuNyMRIPpLLgxThwa5W8Q2/nagUqjLcREOhY1o21oP/SMxn1uezhuzAEpi/J r2+ffzMinRHT/OdjfDdrfoDo+eM1zsWSl9UMVsaFnfXvSTcihKUZqnr2qy2O/OjdpnoC nriYISLTKX/XVMbYfYiofqvbEXbFe7Xpgpcl2LMfvor8+b48lk9LFggFcJ7/fPtOpxDF HzTQ== X-Gm-Message-State: AOJu0YzrSR+dYMHtZrMzih5h+sDRCZhEsic4mc5cQad23X7njviUmGE4 PWWgtOve7M5a9v3GL05uXPNFVw== X-Received: by 2002:a05:6512:328b:b0:4fb:8bab:48b6 with SMTP id p11-20020a056512328b00b004fb8bab48b6mr4881662lfe.52.1695647876928; Mon, 25 Sep 2023 06:17:56 -0700 (PDT) Received: from uffe-tuxpro14.. (h-94-254-63-18.NA.cust.bahnhof.se. [94.254.63.18]) by smtp.gmail.com with ESMTPSA id m29-20020a056512015d00b004fe10276bbfsm1823583lfo.296.2023.09.25.06.17.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 06:17:56 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Cristian Marussi , Viresh Kumar , "Rafael J . Wysocki" Cc: Nishanth Menon , Stephen Boyd , Nikunj Kela , Prasad Sodagudi , Alexandre Torgue , Ulf Hansson , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/9] PM: domains: Implement the ->set_performance_state() callback for genpd Date: Mon, 25 Sep 2023 15:17:08 +0200 Message-Id: <20230925131715.138411-3-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230925131715.138411-1-ulf.hansson@linaro.org> References: <20230925131715.138411-1-ulf.hansson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 25 Sep 2023 06:18:12 -0700 (PDT) To enable generic support for performance scaling for PM domains, let's implement the ->set_performance_state() callback for genpd. Beyond this change, users of the corresponding genpd specific API, dev_pm_genpd_set_performance_state() are encouraged to switch to the common dev_pm_domain_set_performance_state() API. Signed-off-by: Ulf Hansson --- drivers/base/power/domain.c | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index c74edf80417f..da1777e39eaa 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -420,6 +420,25 @@ static void genpd_restore_performance_state(struct device *dev, genpd_set_performance_state(dev, state); } +static int genpd_dev_pm_set_performance_state(struct device *dev, + unsigned int state) +{ + struct generic_pm_domain *genpd = dev_to_genpd(dev); + int ret = 0; + + genpd_lock(genpd); + if (pm_runtime_suspended(dev)) { + dev_gpd_data(dev)->rpm_pstate = state; + } else { + ret = genpd_set_performance_state(dev, state); + if (!ret) + dev_gpd_data(dev)->rpm_pstate = 0; + } + genpd_unlock(genpd); + + return ret; +} + /** * dev_pm_genpd_set_performance_state- Set performance state of device's power * domain. @@ -438,7 +457,6 @@ static void genpd_restore_performance_state(struct device *dev, int dev_pm_genpd_set_performance_state(struct device *dev, unsigned int state) { struct generic_pm_domain *genpd; - int ret = 0; genpd = dev_to_genpd_safe(dev); if (!genpd) @@ -448,17 +466,7 @@ int dev_pm_genpd_set_performance_state(struct device *dev, unsigned int state) !dev->power.subsys_data->domain_data)) return -EINVAL; - genpd_lock(genpd); - if (pm_runtime_suspended(dev)) { - dev_gpd_data(dev)->rpm_pstate = state; - } else { - ret = genpd_set_performance_state(dev, state); - if (!ret) - dev_gpd_data(dev)->rpm_pstate = 0; - } - genpd_unlock(genpd); - - return ret; + return genpd_dev_pm_set_performance_state(dev, state); } EXPORT_SYMBOL_GPL(dev_pm_genpd_set_performance_state); @@ -2080,6 +2088,7 @@ int pm_genpd_init(struct generic_pm_domain *genpd, genpd->domain.ops.restore_noirq = genpd_restore_noirq; genpd->domain.ops.complete = genpd_complete; genpd->domain.start = genpd_dev_pm_start; + genpd->domain.set_performance_state = genpd_dev_pm_set_performance_state; if (genpd->flags & GENPD_FLAG_PM_CLK) { genpd->dev_ops.stop = pm_clk_suspend; -- 2.34.1