From af2ced332265c4ff6cd2bbd702e723de1ca28c4e Mon Sep 17 00:00:00 2001 From: Johnny Liu Date: Thu, 6 Jul 2023 05:04:12 +0000 Subject: [PATCH] gpu: host1x: Disable actmon by default Disable actmon by default and export the controllability of enabling and disabling the actmon. DRM clients should enable the actmon in the runtime resume cycle, and disable the actmon in the runtime suspend cycle. Bug 4168788 Signed-off-by: Johnny Liu Change-Id: I72bcd6d92383595a41c2de5cad708610a205ba25 Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2931874 Reviewed-by: Santosh BS Reviewed-by: Bibek Basu GVS: Gerrit_Virtual_Submit --- drivers/gpu/host1x/actmon.c | 40 ++++++++++++++++++- .../gpu/host1x/include/linux/host1x-next.h | 2 + 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/host1x/actmon.c b/drivers/gpu/host1x/actmon.c index 8ead0f65..8cd354ee 100644 --- a/drivers/gpu/host1x/actmon.c +++ b/drivers/gpu/host1x/actmon.c @@ -251,7 +251,7 @@ static void host1x_actmon_module_init(struct host1x_actmon_module *module) { /* Local control register */ actmon_module_writel(module, - HOST1X_ACTMON_MODULE_CTRL_ACTMON_ENB(1) | + HOST1X_ACTMON_MODULE_CTRL_ACTMON_ENB(0) | HOST1X_ACTMON_MODULE_CTRL_ENB_PERIODIC(1) | HOST1X_ACTMON_MODULE_CTRL_K_VAL(module->k) | HOST1X_ACTMON_MODULE_CTRL_CONSEC_UPPER_NUM(module->consec_upper_num) | @@ -420,6 +420,44 @@ int host1x_actmon_unregister(struct host1x_client *client) } EXPORT_SYMBOL(host1x_actmon_unregister); +void host1x_actmon_enable(struct host1x_client *client) +{ + struct host1x_actmon *actmon = client->actmon; + struct host1x_actmon_module *module; + int i; + + if (!actmon) + return; + + for (i = 0; i < actmon->num_modules; i++) { + module = &actmon->modules[i]; + actmon_module_writel(module, + actmon_module_readl(module, HOST1X_ACTMON_MODULE_CTRL_REG) | + HOST1X_ACTMON_MODULE_CTRL_ACTMON_ENB(1), + HOST1X_ACTMON_MODULE_CTRL_REG); + } +} +EXPORT_SYMBOL(host1x_actmon_enable); + +void host1x_actmon_disable(struct host1x_client *client) +{ + struct host1x_actmon *actmon = client->actmon; + struct host1x_actmon_module *module; + int i; + + if (!actmon) + return; + + for (i = 0; i < actmon->num_modules; i++) { + module = &actmon->modules[i]; + actmon_module_writel(module, + actmon_module_readl(module, HOST1X_ACTMON_MODULE_CTRL_REG) & + ~HOST1X_ACTMON_MODULE_CTRL_ACTMON_ENB(1), + HOST1X_ACTMON_MODULE_CTRL_REG); + } +} +EXPORT_SYMBOL(host1x_actmon_disable); + void host1x_actmon_update_client_rate(struct host1x_client *client, unsigned long rate, u32 *weight) diff --git a/drivers/gpu/host1x/include/linux/host1x-next.h b/drivers/gpu/host1x/include/linux/host1x-next.h index ddf5a214..25e1d693 100644 --- a/drivers/gpu/host1x/include/linux/host1x-next.h +++ b/drivers/gpu/host1x/include/linux/host1x-next.h @@ -527,6 +527,8 @@ static inline void host1x_memory_context_put(struct host1x_memory_context *cd) int host1x_actmon_read_avg_count(struct host1x_client *client); int host1x_actmon_register(struct host1x_client *client); int host1x_actmon_unregister(struct host1x_client *client); +void host1x_actmon_enable(struct host1x_client *client); +void host1x_actmon_disable(struct host1x_client *client); void host1x_actmon_update_client_rate(struct host1x_client *client, unsigned long rate, u32 *weight);