Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp3982598ybz; Mon, 4 May 2020 13:26:45 -0700 (PDT) X-Google-Smtp-Source: APiQypImmqc3ErtoBe30lui610dLZAABA/+3TzqpKJI5q5RFnIZ8a3qw5tyGi9xtL2qTwb0NPeJD X-Received: by 2002:a50:99c4:: with SMTP id n4mr16843667edb.187.1588624005300; Mon, 04 May 2020 13:26:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588624005; cv=none; d=google.com; s=arc-20160816; b=vAoDitUn/9Tnp+eyUyN+UkDYbckg3AYBHwo4NkoEipFGQNwMzpsbCWxg0tjm980NGu vi96VSCL/wYU0IDr7qgHWdtXzXb+G2S/5/qoIITrgcWF92V/GNYjAEEU8J98RcO1c1u3 zrJQhqRCOrbqQHEm0Wgu9ZSMk28J3z8wJmtvxQf4a5XCakTdBB4LxnG4JG3BhpTNTJHq tdWJ3rI65oaCqJwhKY/wBx81y087rBlIRAZs7kNXQ7A/25BzcYqWacauGVkBM2bRoNup dj8DLdfE1Hyfj71n+lP6f/xPOMJhqaWfOCOOCdNtJ9mJTyl29Kg9wo7osGfTCNrPM3Vz 3NYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dmarc-filter:dkim-signature; bh=8MFAQptwlMzZ213cs5BM39F034pibT5h/5vqQT13lbY=; b=SV5EQsdeqooR934C6zFt06deD+w31R0XxAHhQ4jyydIvNwOZBXbxWv36H19e84TxIJ H8BcGQkMIopxiMoQ8kFnLK2rQ9X0OTSuhrWRi4QmO2TdHXUwH8va9nEHaAoJg3MNkDa2 YvKDa1Tts6fti6vkLHiKR8wvcYWFq4szzZl1MGOMxO1/frdYAqp8YlBP0UacYFNT3a9z 9uLmNh7K0Z9x3C67BH08Sv6Q75ZPlcsdfhuqwNWRSIYfaF8Ww+4QHfKrPQCtJpqkKk8U hHml7PXtN1jkoWe0xaeMagaNlkE/aLV/qEBKZpRBvCX7+pQndFsAWcAUptH+TBwChbvJ 7D5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=r1xw0osq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n26si6861878ejy.188.2020.05.04.13.26.21; Mon, 04 May 2020 13:26:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=r1xw0osq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728070AbgEDUYm (ORCPT + 99 others); Mon, 4 May 2020 16:24:42 -0400 Received: from mail27.static.mailgun.info ([104.130.122.27]:39407 "EHLO mail27.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728021AbgEDUYk (ORCPT ); Mon, 4 May 2020 16:24:40 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1588623880; h=Content-Transfer-Encoding: MIME-Version: References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=8MFAQptwlMzZ213cs5BM39F034pibT5h/5vqQT13lbY=; b=r1xw0osqBlH9i0XrQaex1ok/9i3Sc4rWDBQjg5p7tS4v8DcW3zN/HOf42Om0V4OeGj1N3XM1 lpcCQsX63tD2wtHVh638fWDiKGI1pESaw4Yn58OmPRwPUIbKJ9aFjDwjLO0T5I2iN3pyx2y4 DkGPHNWALR2Q3wYFNy0gvuAdciU= X-Mailgun-Sending-Ip: 104.130.122.27 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by mxa.mailgun.org with ESMTP id 5eb079f9.7fef583320d8-smtp-out-n04; Mon, 04 May 2020 20:24:25 -0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 8597CC433F2; Mon, 4 May 2020 20:24:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=ALL_TRUSTED,SPF_NONE autolearn=ham autolearn_force=no version=3.4.0 Received: from blr-ubuntu-87.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.18.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: sibis) by smtp.codeaurora.org (Postfix) with ESMTPSA id 19BA8C43637; Mon, 4 May 2020 20:24:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 19BA8C43637 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=none smtp.mailfrom=sibis@codeaurora.org From: Sibi Sankar To: viresh.kumar@linaro.org, sboyd@kernel.org, georgi.djakov@linaro.org, bjorn.andersson@linaro.org, saravanak@google.com, mka@chromium.org Cc: nm@ti.com, agross@kernel.org, david.brown@linaro.org, robh+dt@kernel.org, mark.rutland@arm.com, rjw@rjwysocki.net, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, dianders@chromium.org, vincent.guittot@linaro.org, amit.kucheria@linaro.org, ulf.hansson@linaro.org, lukasz.luba@arm.com, sudeep.holla@arm.com, Sibi Sankar Subject: [PATCH v4 05/12] OPP: Add and export helper to set bandwidth Date: Tue, 5 May 2020 01:52:36 +0530 Message-Id: <20200504202243.5476-6-sibis@codeaurora.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200504202243.5476-1-sibis@codeaurora.org> References: <20200504202243.5476-1-sibis@codeaurora.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add and export 'dev_pm_opp_set_bw' to set the bandwidth levels associated with an OPP for a given frequency. Signed-off-by: Sibi Sankar --- v4: https://patchwork.kernel.org/patch/11019737/ * Pass device opp to set bw levels [Bjorn] drivers/opp/core.c | 43 ++++++++++++++++++++++++++++++++++++++++++ include/linux/pm_opp.h | 6 ++++++ 2 files changed, 49 insertions(+) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 7f7060079bb28..f157e2d768d76 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -791,6 +791,49 @@ static int _set_required_opps(struct device *dev, return ret; } +/** + * dev_pm_opp_set_bw() - sets bandwidth levels corresponding to an available opp + * @dev: device for which we do this operation + * @opp: opp based on which the bandwidth levels are to be configured + * + * This configures the bandwidth to the levels specified + * by the OPP. + * + * Return: 0 on success or a negative error value. + */ +int dev_pm_opp_set_bw(struct device *dev, struct dev_pm_opp *opp) +{ + struct opp_table *opp_table; + int ret = -EINVAL; + int i; + + if (IS_ERR_OR_NULL(opp) || !opp->available) { + dev_err(dev, "%s: Invalid parameters\n", __func__); + return -EINVAL; + } + + opp_table = _find_opp_table(dev); + if (IS_ERR(opp_table)) { + dev_err(dev, "%s: device opp table doesn't exist\n", __func__); + return PTR_ERR(opp_table); + } + + if (opp_table->paths) { + for (i = 0; i < opp_table->path_count; i++) { + ret = icc_set_bw(opp_table->paths[i], + opp->bandwidth[i].avg, + opp->bandwidth[i].peak); + if (ret) + dev_err(dev, "Failed to set bandwidth[%d]: %d\n", + i, ret); + } + } + + dev_pm_opp_put_opp_table(opp_table); + return ret; +} +EXPORT_SYMBOL_GPL(dev_pm_opp_set_bw); + /** * dev_pm_opp_set_rate() - Configure new OPP based on frequency * @dev: device for which we do this operation diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index 639bc0382ee02..87ba295080a2b 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -154,6 +154,7 @@ struct opp_table *dev_pm_opp_attach_genpd(struct device *dev, const char **names void dev_pm_opp_detach_genpd(struct opp_table *opp_table); 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_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); @@ -352,6 +353,11 @@ static inline int dev_pm_opp_set_rate(struct device *dev, unsigned long target_f return -ENOTSUPP; } +static inline int dev_pm_opp_set_bw(struct device *dev, struct dev_pm_opp *opp) +{ + return -ENOTSUPP; +} + static inline int dev_pm_opp_set_sharing_cpus(struct device *cpu_dev, const struct cpumask *cpumask) { return -ENOTSUPP; -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project