Re: [PATCH v3 12/17] media: venus: core: Add support for opp tables/perf voting

From: Rajendra Nayak
Date: Wed Apr 29 2020 - 10:19:42 EST



On 4/29/2020 6:09 AM, Matthias Kaehlcke wrote:
On Tue, Apr 28, 2020 at 07:03:00PM +0530, Rajendra Nayak wrote:
Add support to add OPP tables and perf voting on the OPP powerdomain.
This is needed so venus votes on the corresponding performance state
for the OPP powerdomain along with setting the core clock rate.

Signed-off-by: Rajendra Nayak <rnayak@xxxxxxxxxxxxxx>
Cc: Stanimir Varbanov <stanimir.varbanov@xxxxxxxxxx>
Cc: linux-media@xxxxxxxxxxxxxxx
---
drivers/media/platform/qcom/venus/core.c | 28 +++++++++++++++++++
drivers/media/platform/qcom/venus/core.h | 5 ++++
drivers/media/platform/qcom/venus/pm_helpers.c | 37 +++++++++++++++++++++++---
3 files changed, 66 insertions(+), 4 deletions(-)

diff --git a/drivers/media/platform/qcom/venus/core.c b/drivers/media/platform/qcom/venus/core.c
index 194b10b9..e98fea92 100644
--- a/drivers/media/platform/qcom/venus/core.c
+++ b/drivers/media/platform/qcom/venus/core.c
@@ -12,6 +12,7 @@
#include <linux/platform_device.h>
#include <linux/slab.h>
#include <linux/types.h>
+#include <linux/pm_opp.h>
#include <linux/pm_runtime.h>
#include <media/videobuf2-v4l2.h>
#include <media/v4l2-mem2mem.h>
@@ -214,6 +215,20 @@ static int venus_probe(struct platform_device *pdev)
if (!core->pm_ops)
return -ENODEV;
+ core->opp_table = dev_pm_opp_set_clkname(dev, "core");
+ if (IS_ERR(core->opp_table))
+ return PTR_ERR(core->opp_table);
+
+ if (core->res->opp_pmdomain) {
+ ret = dev_pm_opp_of_add_table(dev);
+ if (!ret) {
+ core->has_opp_table = true;
+ } else if (ret != -ENODEV) {
+ dev_err(dev, "Invalid OPP table in Device tree\n");
+ return ret;
+ }
+ }
+
if (core->pm_ops->core_get) {
ret = core->pm_ops->core_get(dev);
if (ret)
@@ -301,6 +316,9 @@ static int venus_probe(struct platform_device *pdev)
err_venus_shutdown:
venus_shutdown(core);
err_runtime_disable:
+ if (core->res->opp_pmdomain && core->has_opp_table)

the check for 'core->res->opp_pmdomain' is not needed, 'core->has_opp_table'
can only be true when 'core->res->opp_pmdomain' is not NULL.

ah, that's right, will fix. Thanks.


+ dev_pm_opp_of_remove_table(dev);
+ dev_pm_opp_put_clkname(core->opp_table);
pm_runtime_set_suspended(dev);
pm_runtime_disable(dev);
hfi_destroy(core);
@@ -326,6 +344,10 @@ static int venus_remove(struct platform_device *pdev)
venus_firmware_deinit(core);
+ if (core->res->opp_pmdomain && core->has_opp_table)

ditto


--
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation