From 3b42f92d4d82ecd50bdc452b35f57519f36b70db Mon Sep 17 00:00:00 2001 From: Johnny Liu Date: Mon, 24 Apr 2023 06:44:43 +0000 Subject: [PATCH] gpu: host1x: Export normalized actmon active time The exported interface will be used by devfreq framework to get the load information of the monitored device. Bug 3788919 Signed-off-by: Johnny Liu Change-Id: Id95c8398f44e2c94bd83c1f83d7a7d93d1f2609d Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2892879 Tested-by: mobile promotions Reviewed-by: mobile promotions --- drivers/gpu/host1x/actmon.c | 18 ++++++++++++++++++ drivers/gpu/host1x/include/linux/host1x-next.h | 1 + 2 files changed, 19 insertions(+) diff --git a/drivers/gpu/host1x/actmon.c b/drivers/gpu/host1x/actmon.c index c2f0b75c..cef6d67c 100644 --- a/drivers/gpu/host1x/actmon.c +++ b/drivers/gpu/host1x/actmon.c @@ -446,6 +446,24 @@ void host1x_actmon_update_client_rate(struct host1x_client *client, } EXPORT_SYMBOL(host1x_actmon_update_client_rate); +void host1x_actmon_read_active_norm(struct host1x_client *client, unsigned long *usage) +{ + struct host1x_actmon *actmon = client->actmon; + struct host1x_actmon_module *module; + u64 val; + + if (!actmon || !actmon->num_modules) { + *usage = 0; + return; + } + + module = &actmon->modules[HOST1X_ACTMON_MODULE_ACTIVE]; + host1x_actmon_module_avg_norm_get(module, &val); + + *usage = (unsigned long)val; +} +EXPORT_SYMBOL(host1x_actmon_read_active_norm); + int host1x_actmon_read_avg_count(struct host1x_client *client) { struct host1x *host = dev_get_drvdata(client->host->parent); diff --git a/drivers/gpu/host1x/include/linux/host1x-next.h b/drivers/gpu/host1x/include/linux/host1x-next.h index e65f26f6..360a8cc2 100644 --- a/drivers/gpu/host1x/include/linux/host1x-next.h +++ b/drivers/gpu/host1x/include/linux/host1x-next.h @@ -530,5 +530,6 @@ int host1x_actmon_unregister(struct host1x_client *client); void host1x_actmon_update_client_rate(struct host1x_client *client, unsigned long rate, u32 *weight); +void host1x_actmon_read_active_norm(struct host1x_client *client, unsigned long *usage); #endif