From 1dcfd26f70998f2b9ea6b3b73508dc91d9be203f Mon Sep 17 00:00:00 2001 From: Johnny Liu Date: Tue, 22 Aug 2023 03:35:45 +0000 Subject: [PATCH] drm/tegra: Set nvjpg actmon count weight once Change the implementation to set count weight values for both actmon and the engine once in runtime resume cycle to align the implementation as nvdec for kernel upstream. Bug 4251915 Signed-off-by: Johnny Liu Change-Id: I6df0f13d1c58402cb78e4e05ff6cd6cd21ef2c4b Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2965505 Reviewed-by: svcacv Reviewed-by: Mikko Perttunen GVS: Gerrit_Virtual_Submit --- drivers/gpu/drm/tegra/nvjpg.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/tegra/nvjpg.c b/drivers/gpu/drm/tegra/nvjpg.c index 8d40db35..8daa55c3 100644 --- a/drivers/gpu/drm/tegra/nvjpg.c +++ b/drivers/gpu/drm/tegra/nvjpg.c @@ -73,9 +73,8 @@ static inline void nvjpg_writel(struct nvjpg *nvjpg, u32 value, unsigned int off static int nvjpg_set_rate(struct nvjpg *nvjpg, unsigned long rate) { - struct host1x_client *client = &nvjpg->client.base; unsigned long dev_rate; - u32 weight, emc_kbps; + u32 emc_kbps; int err; err = clk_set_rate(nvjpg->clk, rate); @@ -87,11 +86,6 @@ static int nvjpg_set_rate(struct nvjpg *nvjpg, unsigned long rate) dev_rate = clk_get_rate(nvjpg->clk); - host1x_actmon_update_client_rate(client, dev_rate, &weight); - - if (weight) - nvjpg_writel(nvjpg, weight, NVJPG_TFBIF_ACTMON_ACTIVE_WEIGHT); - if (nvjpg->icc_write) { emc_kbps = dev_rate * NVJPG_AXI_RW_BANDWIDTH / 1024; err = icc_set_bw(nvjpg->icc_write, kbps_to_icc(emc_kbps), 0); @@ -447,6 +441,17 @@ static void nvjpg_actmon_reg_init(struct nvjpg *nvjpg) NVJPG_TFBIF_ACTMON_ACTIVE_BORPS); } +static void nvjpg_count_weight_init(struct nvjpg *nvjpg, unsigned long rate) +{ + struct host1x_client *client = &nvjpg->client.base; + u32 weight = 0; + + host1x_actmon_update_client_rate(client, rate, &weight); + + if (weight) + nvjpg_writel(nvjpg, weight, NVJPG_TFBIF_ACTMON_ACTIVE_WEIGHT); +} + static __maybe_unused int nvjpg_runtime_resume(struct device *dev) { struct nvjpg *nvjpg = dev_get_drvdata(dev); @@ -472,6 +477,8 @@ static __maybe_unused int nvjpg_runtime_resume(struct device *dev) nvjpg_actmon_reg_init(nvjpg); + nvjpg_count_weight_init(nvjpg, nvjpg->devfreq->resume_freq); + host1x_actmon_enable(&nvjpg->client.base); return 0;