From patchwork Mon Sep 25 13:17:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13397787 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 04051CE7A81 for ; Mon, 25 Sep 2023 13:18:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=1ZmWcikpovdV3qL8lUCWhTi13KQF62Bw0vAFzjBjoBM=; b=ifEABx/ludtbdP U025l5fjM9oOoH4LlRWD3kgJa1Bqzlt4NRxLM2JMYzxDGApYNZ+7htFTBQAvb+EUle4nlVEDPdMbR VlsUXZfxhub4v6k1AEuwahU81a3MN4YgfPMO7rYcDNO7DEgNC47Fga9pWVSLv0wilFogkSqTyBe0E jqscE2rXSCJmANRTeP6c7gB2/vc18jLlUGgrP0Dov2EPXEJcQpUUxi1V6X3Hg7p651ZOOgnrIMx+P MGscEO2VnWerG5GAPD86rCXaH1VCmkvgv2JcgEXACqFLKHn3GWBVVP77Qa/y4zzp+mWtgKIgn07OX wGU57KWtbKbMbMbdoEUQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qklTN-00EJPH-2S; Mon, 25 Sep 2023 13:18:01 +0000 Received: from mail-lf1-x129.google.com ([2a00:1450:4864:20::129]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qklTK-00EJNr-2t for linux-arm-kernel@lists.infradead.org; Mon, 25 Sep 2023 13:18:00 +0000 Received: by mail-lf1-x129.google.com with SMTP id 2adb3069b0e04-5042f391153so7478974e87.1 for ; Mon, 25 Sep 2023 06:17:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1695647875; x=1696252675; darn=lists.infradead.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=8U5TCt8PhKvPqkMPolS3qJOc5aJpgLowONzlvaY1uCA=; b=HW0ED0bmC2Sqr/MSLupEPsNkUW4MdmXAkKYZgGDrJdKu8ktA3YGBcxcKMWWIQY9pns wIrGF41X1xzbJw59Yp5FeZEjy+yIWTVzzmgO4YKHkZLwjwzs2aLbm8DdkKivoNBRgIu4 qBZew9KFklaaU9jtGX0OlCQG3IDmxn+C++QCjM1/UFdLnJx2u6TX+TdMiZe2jo1TD+uM 0CXd7nIpJmlBzNfOi6ceI56Eput7CYZgt43s6y2JVNDYikReuVWqfW0Pip84ZutMoQkj Wl2TjoTyWHm3GeB3jxkxLhDXCN3EegWwD3Gu8gz3vx3dB4dWPeTvQQTH3/Yv416iNac3 W7dQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695647875; x=1696252675; 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=8U5TCt8PhKvPqkMPolS3qJOc5aJpgLowONzlvaY1uCA=; b=bUsvwW5rmlwgnHTg0BBMTdW8W5ZclDG/ihydBw0B538QE2i7U73UU0LJDZpS6Mh5JD SJwWySqpYXLFy97FWwPNa1Y/aMKtZFQVdBulZZw4n0ah6hk/quR26bGOvWri9wU2Ia4a vVe7le7jkUbCdJ2zh730Azf1fyLcahIvN5u7i/B3HOOYFnfOyY8zk03RWqJZsUewokvt m2NwSo3F/rH0mV33ywLvL5m0NcUfRAFtrO+kH/1Qhil1JxUhK+tha4bY03ZhCU2i4UyO ++snXZq4spLpoBvae85fBFMxdkNGFGWI3yVxK+/vehmDC2E9SeTqiBavfgm/pU6+lFkd 60NQ== X-Gm-Message-State: AOJu0YxsIgbxw4I5bsYGALbXjlpy1a7VXGt/BQDyfiPTiBrovPA0dNIY TsEdqaSYq7oZiqXDxMOj09Xs9O7GqP/NE8kc9Fo= X-Google-Smtp-Source: AGHT+IHKbJtqXxLpoL/3TxVjGxZPgSGBoxzRkGP+PUJOzo30gCEuhg29mQ3rnnoMG3KuUNvxb6UVyg== X-Received: by 2002:a05:6512:acd:b0:4f9:dac6:2f3d with SMTP id n13-20020a0565120acd00b004f9dac62f3dmr3152406lfu.13.1695647875663; Mon, 25 Sep 2023 06:17:55 -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.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 06:17:55 -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 1/9] PM: domains: Introduce dev_pm_domain_set_performance_state() Date: Mon, 25 Sep 2023 15:17:07 +0200 Message-Id: <20230925131715.138411-2-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230925_061758_933460_7C1D0A9C X-CRM114-Status: GOOD ( 19.25 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The generic PM domain is currently the only PM domain variant that supports performance scaling. To allow performance scaling to be supported through a common interface, let's add an optional callback ->set_performance_state(), in the struct dev_pm_domain. Moreover, let's add a function, dev_pm_domain_set_performance_state(), that may be called by consumers to request a new performance state for a device through its PM domain. Note that, in most cases it's preferred that a consumer use the OPP library to request a new performance state for its device. Although, this requires some additional changes to be supported, which are being implemented from subsequent changes. Signed-off-by: Ulf Hansson --- drivers/base/power/common.c | 21 +++++++++++++++++++++ include/linux/pm.h | 2 ++ include/linux/pm_domain.h | 6 ++++++ 3 files changed, 29 insertions(+) diff --git a/drivers/base/power/common.c b/drivers/base/power/common.c index 72115917e0bd..44ec20918a4d 100644 --- a/drivers/base/power/common.c +++ b/drivers/base/power/common.c @@ -228,3 +228,24 @@ void dev_pm_domain_set(struct device *dev, struct dev_pm_domain *pd) device_pm_check_callbacks(dev); } EXPORT_SYMBOL_GPL(dev_pm_domain_set); + +/** + * dev_pm_domain_set_performance_state - Request a new performance state. + * @dev: The device to make the request for. + * @state: Target performance state for the device. + * + * This function should be called when a new performance state needs to be + * requested for a device that is attached to a PM domain. Note that, the + * support for performance scaling for PM domains is optional. + * + * Returns 0 on success and when performance scaling isn't supported, negative + * error code on failure. + */ +int dev_pm_domain_set_performance_state(struct device *dev, unsigned int state) +{ + if (dev->pm_domain && dev->pm_domain->set_performance_state) + return dev->pm_domain->set_performance_state(dev, state); + + return 0; +} +EXPORT_SYMBOL_GPL(dev_pm_domain_set_performance_state); diff --git a/include/linux/pm.h b/include/linux/pm.h index 1400c37b29c7..4c9f571609c8 100644 --- a/include/linux/pm.h +++ b/include/linux/pm.h @@ -719,6 +719,7 @@ extern void dev_pm_put_subsys_data(struct device *dev); * @activate: Called before executing probe routines for bus types and drivers. * @sync: Called after successful driver probe. * @dismiss: Called after unsuccessful driver probe and after driver removal. + * @set_performance_state: Called to request a new performance state. * * Power domains provide callbacks that are executed during system suspend, * hibernation, system resume and during runtime PM transitions instead of @@ -731,6 +732,7 @@ struct dev_pm_domain { int (*activate)(struct device *dev); void (*sync)(struct device *dev); void (*dismiss)(struct device *dev); + int (*set_performance_state)(struct device *dev, unsigned int state); }; /* diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index 05ad8cefdff1..34663d0d5c55 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -435,6 +435,7 @@ struct device *dev_pm_domain_attach_by_name(struct device *dev, void dev_pm_domain_detach(struct device *dev, bool power_off); int dev_pm_domain_start(struct device *dev); void dev_pm_domain_set(struct device *dev, struct dev_pm_domain *pd); +int dev_pm_domain_set_performance_state(struct device *dev, unsigned int state); #else static inline int dev_pm_domain_attach(struct device *dev, bool power_on) { @@ -457,6 +458,11 @@ static inline int dev_pm_domain_start(struct device *dev) } static inline void dev_pm_domain_set(struct device *dev, struct dev_pm_domain *pd) {} +static inline int dev_pm_domain_set_performance_state(struct device *dev, + unsigned int state) +{ + return 0; +} #endif #endif /* _LINUX_PM_DOMAIN_H */