mirror of
git://nv-tegra.nvidia.com/linux-nv-oot.git
synced 2025-12-22 17:25:35 +03:00
drm/tegra: Register actmon for the nvdec client
Register nvdec actmon to export the engine utilization information in the debugfs. Bug 200493763 Bug 3923137 Signed-off-by: Johnny Liu <johnliu@nvidia.com> Change-Id: I6e445a4e4ce729f2a1af63ed95f4110916b1adb0 Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2892036 Reviewed-by: svcacv <svcacv@nvidia.com> Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com> Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com> Reviewed-by: Mikko Perttunen <mperttunen@nvidia.com> GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
This commit is contained in:
committed by
mobile promotions
parent
9db84e035b
commit
d5eff2f344
@@ -1,6 +1,6 @@
|
|||||||
// SPDX-License-Identifier: GPL-2.0-only
|
// SPDX-License-Identifier: GPL-2.0-only
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2015-2022, NVIDIA Corporation.
|
* Copyright (c) 2015-2023, NVIDIA CORPORATION & AFFILIATES. All Rights Reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <linux/clk.h>
|
#include <linux/clk.h>
|
||||||
@@ -23,10 +23,13 @@
|
|||||||
#include "falcon.h"
|
#include "falcon.h"
|
||||||
#include "riscv.h"
|
#include "riscv.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "vic.h"
|
|
||||||
|
|
||||||
|
#define NVDEC_FW_MTHD_ADDR_ACTMON_WEIGHT 0xC9U
|
||||||
|
#define NVDEC_FALCON_UCLASS_METHOD_OFFSET 0x40
|
||||||
|
#define NVDEC_FALCON_UCLASS_METHOD_DATA 0x44
|
||||||
#define NVDEC_FALCON_DEBUGINFO 0x1094
|
#define NVDEC_FALCON_DEBUGINFO 0x1094
|
||||||
#define NVDEC_TFBIF_TRANSCFG 0x2c44
|
#define NVDEC_TFBIF_TRANSCFG 0x2c44
|
||||||
|
#define NVDEC_TFBIF_ACTMON_ACTIVE_WEIGHT 0x2c54
|
||||||
|
|
||||||
struct nvdec_config {
|
struct nvdec_config {
|
||||||
const char *firmware;
|
const char *firmware;
|
||||||
@@ -67,6 +70,37 @@ static inline void nvdec_writel(struct nvdec *nvdec, u32 value,
|
|||||||
writel(value, nvdec->regs + offset);
|
writel(value, nvdec->regs + offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int nvdec_set_rate(struct nvdec *nvdec, unsigned long rate)
|
||||||
|
{
|
||||||
|
struct nvdec_config *config = nvdec->config;
|
||||||
|
struct host1x_client *client = &nvdec->client.base;
|
||||||
|
unsigned long dev_rate;
|
||||||
|
u32 weight;
|
||||||
|
int err;
|
||||||
|
|
||||||
|
err = clk_set_rate(nvdec->clks[0].clk, rate);
|
||||||
|
if (err < 0)
|
||||||
|
return err;
|
||||||
|
|
||||||
|
dev_rate = clk_get_rate(nvdec->clks[0].clk);
|
||||||
|
|
||||||
|
host1x_actmon_update_client_rate(client, dev_rate, &weight);
|
||||||
|
|
||||||
|
if (!weight)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (!config->has_riscv) {
|
||||||
|
nvdec_writel(nvdec, weight, NVDEC_TFBIF_ACTMON_ACTIVE_WEIGHT);
|
||||||
|
} else if (config->has_riscv) {
|
||||||
|
nvdec_writel(nvdec,
|
||||||
|
NVDEC_FW_MTHD_ADDR_ACTMON_WEIGHT,
|
||||||
|
NVDEC_FALCON_UCLASS_METHOD_OFFSET);
|
||||||
|
nvdec_writel(nvdec, weight, NVDEC_FALCON_UCLASS_METHOD_DATA);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int nvdec_boot_falcon(struct nvdec *nvdec)
|
static int nvdec_boot_falcon(struct nvdec *nvdec)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
@@ -232,9 +266,18 @@ static int nvdec_exit(struct host1x_client *client)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static unsigned long nvdec_get_rate(struct host1x_client *client)
|
||||||
|
{
|
||||||
|
struct platform_device *pdev = to_platform_device(client->dev);
|
||||||
|
struct nvdec *nvdec = platform_get_drvdata(pdev);
|
||||||
|
|
||||||
|
return clk_get_rate(nvdec->clks[0].clk);
|
||||||
|
}
|
||||||
|
|
||||||
static const struct host1x_client_ops nvdec_client_ops = {
|
static const struct host1x_client_ops nvdec_client_ops = {
|
||||||
.init = nvdec_init,
|
.init = nvdec_init,
|
||||||
.exit = nvdec_exit,
|
.exit = nvdec_exit,
|
||||||
|
.get_rate = nvdec_get_rate,
|
||||||
};
|
};
|
||||||
|
|
||||||
static int nvdec_load_falcon_firmware(struct nvdec *nvdec)
|
static int nvdec_load_falcon_firmware(struct nvdec *nvdec)
|
||||||
@@ -325,6 +368,9 @@ static __maybe_unused int nvdec_runtime_resume(struct device *dev)
|
|||||||
goto disable;
|
goto disable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Configure proper count weight */
|
||||||
|
nvdec_set_rate(nvdec, clk_get_rate(nvdec->clks[0].clk));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
disable:
|
disable:
|
||||||
@@ -471,12 +517,6 @@ static int nvdec_probe(struct platform_device *pdev)
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = clk_set_rate(nvdec->clks[0].clk, ULONG_MAX);
|
|
||||||
if (err < 0) {
|
|
||||||
dev_err(&pdev->dev, "failed to set clock rate\n");
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
err = of_property_read_u32(dev->of_node, "nvidia,host1x-class", &host_class);
|
err = of_property_read_u32(dev->of_node, "nvidia,host1x-class", &host_class);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
host_class = HOST1X_CLASS_NVDEC;
|
host_class = HOST1X_CLASS_NVDEC;
|
||||||
@@ -541,6 +581,17 @@ static int nvdec_probe(struct platform_device *pdev)
|
|||||||
goto exit_falcon;
|
goto exit_falcon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = host1x_actmon_register(&nvdec->client.base);
|
||||||
|
if (err < 0)
|
||||||
|
dev_info(&pdev->dev, "failed to register host1x actmon: %d\n", err);
|
||||||
|
|
||||||
|
/* Set default clock rate for nvdec */
|
||||||
|
err = clk_set_rate(nvdec->clks[0].clk, ULONG_MAX);
|
||||||
|
if (err < 0) {
|
||||||
|
dev_err(&pdev->dev, "failed to set clock rate: %d\n", err);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
pm_runtime_enable(dev);
|
pm_runtime_enable(dev);
|
||||||
pm_runtime_use_autosuspend(dev);
|
pm_runtime_use_autosuspend(dev);
|
||||||
pm_runtime_set_autosuspend_delay(dev, 500);
|
pm_runtime_set_autosuspend_delay(dev, 500);
|
||||||
@@ -560,6 +611,11 @@ static int nvdec_remove(struct platform_device *pdev)
|
|||||||
|
|
||||||
pm_runtime_disable(&pdev->dev);
|
pm_runtime_disable(&pdev->dev);
|
||||||
|
|
||||||
|
err = host1x_actmon_unregister(&nvdec->client.base);
|
||||||
|
if (err < 0)
|
||||||
|
dev_info(&pdev->dev, "failed to unregister host1x actmon: %d\n",
|
||||||
|
err);
|
||||||
|
|
||||||
err = host1x_client_unregister(&nvdec->client.base);
|
err = host1x_client_unregister(&nvdec->client.base);
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
dev_err(&pdev->dev, "failed to unregister host1x client: %d\n",
|
dev_err(&pdev->dev, "failed to unregister host1x client: %d\n",
|
||||||
|
|||||||
Reference in New Issue
Block a user