From d412dc39e1dfc072a3726bb79de2d964bc1ee9b3 Mon Sep 17 00:00:00 2001 From: Johnny Liu Date: Tue, 8 Aug 2023 13:50:33 +0000 Subject: [PATCH] drm/tegra: Set actmon count weight for nvdec once Method invocation for updating count weight for nvdec may conflict with a job being submitted through host1x. Change the implementation to set count weight values for both actmon and the engine once in runtime resume cycle to prevent possible conflicts. Bug 3962196 Signed-off-by: Johnny Liu Change-Id: I19d160abd90373721df78cdb107ca396a206a6e8 Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2952692 Tested-by: mobile promotions Reviewed-by: mobile promotions --- drivers/gpu/drm/tegra/nvdec.c | 41 ++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/drivers/gpu/drm/tegra/nvdec.c b/drivers/gpu/drm/tegra/nvdec.c index 6a99d43e..40f12aac 100644 --- a/drivers/gpu/drm/tegra/nvdec.c +++ b/drivers/gpu/drm/tegra/nvdec.c @@ -91,10 +91,8 @@ static inline void nvdec_writel(struct nvdec *nvdec, u32 value, static int nvdec_set_rate(struct nvdec *nvdec, unsigned long rate) { - const struct nvdec_config *config = nvdec->config; - struct host1x_client *client = &nvdec->client.base; unsigned long dev_rate; - u32 weight, emc_kbps; + u32 emc_kbps; int err; err = clk_set_rate(nvdec->clks[0].clk, rate); @@ -113,20 +111,6 @@ static int nvdec_set_rate(struct nvdec *nvdec, unsigned long rate) dev_warn(nvdec->dev, "failed to set icc bw: %d\n", err); } - 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 { - nvdec_writel(nvdec, - NVDEC_FW_MTHD_ADDR_ACTMON_ACTIVE_WEIGHT, - NVDEC_FALCON_UCLASS_METHOD_OFFSET); - nvdec_writel(nvdec, weight, NVDEC_FALCON_UCLASS_METHOD_DATA); - } - return 0; } @@ -552,6 +536,27 @@ static void nvdec_actmon_reg_init(struct nvdec *nvdec) } } +static void nvdec_count_weight_init(struct nvdec *nvdec, unsigned long rate) +{ + const struct nvdec_config *config = nvdec->config; + struct host1x_client *client = &nvdec->client.base; + u32 weight; + + host1x_actmon_update_client_rate(client, rate, &weight); + + if (!weight) + return; + + if (!config->has_riscv) { + nvdec_writel(nvdec, weight, NVDEC_TFBIF_ACTMON_ACTIVE_WEIGHT); + } else { + nvdec_writel(nvdec, + NVDEC_FW_MTHD_ADDR_ACTMON_ACTIVE_WEIGHT, + NVDEC_FALCON_UCLASS_METHOD_OFFSET); + nvdec_writel(nvdec, weight, NVDEC_FALCON_UCLASS_METHOD_DATA); + } +} + static __maybe_unused int nvdec_runtime_resume(struct device *dev) { struct nvdec *nvdec = dev_get_drvdata(dev); @@ -583,6 +588,8 @@ static __maybe_unused int nvdec_runtime_resume(struct device *dev) nvdec_actmon_reg_init(nvdec); + nvdec_count_weight_init(nvdec, nvdec->devfreq->resume_freq); + host1x_actmon_enable(&nvdec->client.base); return 0;