From patchwork Fri May 26 09:17:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Dybcio X-Patchwork-Id: 686331 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 AB032C77B7C for ; Fri, 26 May 2023 09:18:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236878AbjEZJSL (ORCPT ); Fri, 26 May 2023 05:18:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242192AbjEZJSK (ORCPT ); Fri, 26 May 2023 05:18:10 -0400 Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [IPv6:2a00:1450:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02193194 for ; Fri, 26 May 2023 02:18:08 -0700 (PDT) Received: by mail-lf1-x129.google.com with SMTP id 2adb3069b0e04-4f4b384c09fso527522e87.3 for ; Fri, 26 May 2023 02:18:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1685092687; x=1687684687; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:from:to:cc:subject:date:message-id:reply-to; bh=91tk7JnZvoP+ZW5JLDTfXwmLebfjuJ7VnX3iXfJ77W0=; b=QS8bKhKDThq0rAuN2+fsxR00emtYae6i+vLDdt4gCEZeMJSjGK0lyiRKpfBAucZFjL lXJ86c8/7cbuyQ5mxw10zfrrrgdNHL4s18Om9KqnxUeNN39T8uKXQALXoPnH8XKAA3sn /LGJU7IBGUfV4Hr8xwnEh3v7z22V9Dx8gSEJlxTezrdk4lkklWL7BJKLnDMuluIyDqXR konuJc7n1imdaQGuAXdF0uP4lIcmX1KSy5LY1mGLzesbQ3reYvVf3Pr0lEC791Solvlv nQrLtbFqIXkIAB/gyvCn2r8RREtOCrZWdlgPVpw9r8fs/MKCup1T4NdI4cEVOTlFIN23 t7GA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685092687; x=1687684687; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=91tk7JnZvoP+ZW5JLDTfXwmLebfjuJ7VnX3iXfJ77W0=; b=DJJxPBmj20yulfT7aFu1R13CkDa3f76R+q2xA2W28GgHyXG0Sx5CFytE4pBDBilwSw xKSfVWumm6obozIPfseMkntCaggxePykelMJrT3xLcAZDMXcUGLeiWPCyaKMiATpmjb7 c0ZnK9qCEyf5wxoIWPP/qBAxbRUooP0z5ENYnjdlGqLOZIXewLGuB0DxW9rJvHI59DNW gn59yYp0NVqMnTUUwef/Mzkk83BTd/uK8XBHK+5cwJ+Bt6lUlUvIgwgKYXb6++p9PhfK cAYPHkAXVxrwZCE2JKRGXfVOGZ+Ek1f35/hGevCqXY6NKU74AOOEB07OrS7iI7Q2qq19 EWKQ== X-Gm-Message-State: AC+VfDwfKyxSMn0ZwA+NY5XXzk5pMuKh+sCXauJZ51xTvt0PGf7PRrJR 9T700ZyKIX1PHBI9EsmzbRIu4Q== X-Google-Smtp-Source: ACHHUZ5pVXxnq41qSI3DUD3q3lMcT395RxsySupwpCpNXWyJC1IBqJiIE9xgJ5ip/vOMblL+KfTBVw== X-Received: by 2002:ac2:5297:0:b0:4f0:1076:2682 with SMTP id q23-20020ac25297000000b004f010762682mr299189lfm.42.1685092687181; Fri, 26 May 2023 02:18:07 -0700 (PDT) Received: from [192.168.1.101] (abyj77.neoplus.adsl.tpnet.pl. [83.9.29.77]) by smtp.gmail.com with ESMTPSA id y16-20020ac255b0000000b004eed8de597csm541544lfg.32.2023.05.26.02.18.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 May 2023 02:18:06 -0700 (PDT) From: Konrad Dybcio Date: Fri, 26 May 2023 11:17:57 +0200 Subject: [PATCH] opp: Provide a function for just setting bandwidth MIME-Version: 1.0 Message-Id: <20230526-topic-opp_bw-v1-1-e881091363af@linaro.org> X-B4-Tracking: v=1; b=H4sIAER5cGQC/x2N0QqDMAwAf0XyvEBX56j7lTEkrZkGpC3tNgfiv xt8vIPjNqhchCs8mg0K/6RKigrXSwNhpjgxyqgM1tjWdPaOn5QlYMp58Cu60dzIddS35EATT5X RF4ph1ih+l0VlLvyW//l4vvb9AEqQCpxzAAAA To: Viresh Kumar , Nishanth Menon , Stephen Boyd , "Rafael J. Wysocki" Cc: Marijn Suijten , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Konrad Dybcio X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1685092686; l=2963; i=konrad.dybcio@linaro.org; s=20230215; h=from:subject:message-id; bh=jmkpzRF+36y/udydjUbD4CkymkzSnR6tIx+s488Udkg=; b=pooO+7/d+QQWxeUu11CD/xGFtkMuBp2jmmtr446tuhCyL/PQzTmHgqcGjl3Xb+UcTy4HKDfUW FNJPdUPUBTuBqnhHj0s6oWCT/Fs2sTpaBviLJz2Y1iduC2IxlYw/RsR X-Developer-Key: i=konrad.dybcio@linaro.org; a=ed25519; pk=iclgkYvtl2w05SSXO5EjjSYlhFKsJ+5OSZBjOkQuEms= Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Currently it's not possible to set just the bandwidth if the OPP describes other properties (required-opps, opp-hz etc.). Introduce dev_pm_opp_set_bw() to solve this problem. Signed-off-by: Konrad Dybcio --- drivers/opp/core.c | 28 ++++++++++++++++++++++++++++ include/linux/pm_opp.h | 6 ++++++ 2 files changed, 34 insertions(+) --- base-commit: 6a3d37b4d885129561e1cef361216f00472f7d2e change-id: 20230526-topic-opp_bw-8d04a85a93a8 Best regards, diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 85cbc8de407c..00d7f7c20189 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -1278,6 +1278,34 @@ int dev_pm_opp_set_opp(struct device *dev, struct dev_pm_opp *opp) } EXPORT_SYMBOL_GPL(dev_pm_opp_set_opp); +/** + * dev_pm_opp_set_bw() - Configure device's interconnect bandwidth from OPP + * @dev: device for which we do this operation + * @opp: OPP to get the bandwidth data from + * + * This configures the interconnect bandwidth based on the properties of the + * OPP passed to this routine. + * + * Return: 0 on success, a negative error number otherwise. + */ +int dev_pm_opp_set_bw(struct device *dev, struct dev_pm_opp *opp) +{ + struct opp_table *opp_table; + int ret; + + opp_table = _find_opp_table(dev); + if (IS_ERR(opp_table)) { + dev_err(dev, "%s: device opp doesn't exist\n", __func__); + return PTR_ERR(opp_table); + } + + ret = _set_opp_bw(opp_table, opp, dev); + dev_pm_opp_put_opp_table(opp_table); + + return ret; +} +EXPORT_SYMBOL_GPL(dev_pm_opp_set_bw); + /* OPP-dev Helpers */ static void _remove_opp_dev(struct opp_device *opp_dev, struct opp_table *opp_table) diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index dc1fb5890792..5e074ac7a68e 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -167,6 +167,7 @@ struct dev_pm_opp *dev_pm_opp_xlate_required_opp(struct opp_table *src_table, st int dev_pm_opp_xlate_performance_state(struct opp_table *src_table, struct opp_table *dst_table, unsigned int pstate); int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq); int dev_pm_opp_set_opp(struct device *dev, struct dev_pm_opp *opp); +int dev_pm_opp_set_bw(struct device *dev, struct dev_pm_opp *opp); int dev_pm_opp_set_sharing_cpus(struct device *cpu_dev, const struct cpumask *cpumask); int dev_pm_opp_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpumask); void dev_pm_opp_remove_table(struct device *dev); @@ -373,6 +374,11 @@ static inline int dev_pm_opp_set_opp(struct device *dev, struct dev_pm_opp *opp) return -EOPNOTSUPP; } +static inline int dev_pm_opp_set_bw(struct device *dev, struct dev_pm_opp *opp) +{ + return -EOPNOTSUPP; +} + static inline int dev_pm_opp_set_sharing_cpus(struct device *cpu_dev, const struct cpumask *cpumask) { return -EOPNOTSUPP;