Messages in this thread Patch in this message | | | From | Konrad Dybcio <> | Date | Fri, 26 May 2023 11:17:57 +0200 | Subject | [PATCH] opp: Provide a function for just setting bandwidth |
| |
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 <konrad.dybcio@linaro.org> --- drivers/opp/core.c | 28 ++++++++++++++++++++++++++++ include/linux/pm_opp.h | 6 ++++++ 2 files changed, 34 insertions(+)
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; --- base-commit: 6a3d37b4d885129561e1cef361216f00472f7d2e change-id: 20230526-topic-opp_bw-8d04a85a93a8 Best regards, -- Konrad Dybcio <konrad.dybcio@linaro.org>
| |