From d6a45460a5b5e709bf9db608b1f4cc51c5eebc5b Mon Sep 17 00:00:00 2001 From: Johnny Liu Date: Tue, 22 Aug 2023 03:30:30 +0000 Subject: [PATCH] drm/tegra: Set nvenc 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: Ie2df685e990a4ebcd5a83db23db3c3bc8ab2af37 Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2965502 Reviewed-by: svcacv Reviewed-by: Mikko Perttunen GVS: Gerrit_Virtual_Submit --- drivers/gpu/drm/tegra/nvenc.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/tegra/nvenc.c b/drivers/gpu/drm/tegra/nvenc.c index c666e74d..a9b8f4ce 100644 --- a/drivers/gpu/drm/tegra/nvenc.c +++ b/drivers/gpu/drm/tegra/nvenc.c @@ -74,9 +74,8 @@ static inline void nvenc_writel(struct nvenc *nvenc, u32 value, unsigned int off static int nvenc_set_rate(struct nvenc *nvenc, unsigned long rate) { - struct host1x_client *client = &nvenc->client.base; unsigned long dev_rate; - u32 weight, emc_kbps; + u32 emc_kbps; int err; err = clk_set_rate(nvenc->clk, rate); @@ -88,11 +87,6 @@ static int nvenc_set_rate(struct nvenc *nvenc, unsigned long rate) dev_rate = clk_get_rate(nvenc->clk); - host1x_actmon_update_client_rate(client, dev_rate, &weight); - - if (weight) - nvenc_writel(nvenc, weight, NVENC_TFBIF_ACTMON_ACTIVE_WEIGHT); - if (nvenc->icc_write) { emc_kbps = dev_rate * NVENC_AXI_RW_BANDWIDTH / 1024; err = icc_set_bw(nvenc->icc_write, kbps_to_icc(emc_kbps), 0); @@ -448,6 +442,17 @@ static void nvenc_actmon_reg_init(struct nvenc *nvenc) NVENC_TFBIF_ACTMON_ACTIVE_BORPS); } +static void nvenc_count_weight_init(struct nvenc *nvenc, unsigned long rate) +{ + struct host1x_client *client = &nvenc->client.base; + u32 weight = 0; + + host1x_actmon_update_client_rate(client, rate, &weight); + + if (weight) + nvenc_writel(nvenc, weight, NVENC_TFBIF_ACTMON_ACTIVE_WEIGHT); +} + static __maybe_unused int nvenc_runtime_resume(struct device *dev) { struct nvenc *nvenc = dev_get_drvdata(dev); @@ -473,6 +478,8 @@ static __maybe_unused int nvenc_runtime_resume(struct device *dev) nvenc_actmon_reg_init(nvenc); + nvenc_count_weight_init(nvenc, nvenc->devfreq->resume_freq); + host1x_actmon_enable(&nvenc->client.base); return 0;