diff options
author | Jack Diver <diverj@google.com> | 2023-01-09 14:29:17 +0000 |
---|---|---|
committer | Jack Diver <diverj@google.com> | 2023-03-23 12:11:40 +0000 |
commit | f2d35cdfa9820257f8b6655c79d30f2d0802a275 (patch) | |
tree | f4889afdb00174e788bbd53e3eae2249fead2710 /mali_kbase | |
parent | bbff2067d58e7b7b100c2319d7550250c594ac02 (diff) | |
download | gpu-f2d35cdfa9820257f8b6655c79d30f2d0802a275.tar.gz |
mali_kbase: platform: Make kctx platform_data extensible
Allocate a platform_data struct, which can be extended for more uses
than per-UID DVFS metrics.
Bug: 264990406
Test: Boot
Test: Check DVFS time_in_state reporting
Change-Id: Iae17f85e6ece87e5bd8aa6f13c75c6f5504e8436
Signed-off-by: Jack Diver <diverj@google.com>
Diffstat (limited to 'mali_kbase')
-rw-r--r-- | mali_kbase/platform/pixel/mali_kbase_config_platform.h | 9 | ||||
-rw-r--r-- | mali_kbase/platform/pixel/pixel_gpu.c | 48 | ||||
-rw-r--r-- | mali_kbase/platform/pixel/pixel_gpu_dvfs_metrics.c | 12 |
3 files changed, 63 insertions, 6 deletions
diff --git a/mali_kbase/platform/pixel/mali_kbase_config_platform.h b/mali_kbase/platform/pixel/mali_kbase_config_platform.h index a1e2e5d..3e18eed 100644 --- a/mali_kbase/platform/pixel/mali_kbase_config_platform.h +++ b/mali_kbase/platform/pixel/mali_kbase_config_platform.h @@ -404,4 +404,13 @@ struct pixel_context { #endif /* CONFIG_MALI_MIDGARD_DVFS */ }; +/** + * struct pixel_platform_data - Per kbase_context Pixel specific platform data + * + * @stats: Tracks the dvfs metrics for the UID associated with this context + */ +struct pixel_platform_data { + struct gpu_dvfs_metrics_uid_stats* stats; +}; + #endif /* _KBASE_CONFIG_PLATFORM_H_ */ diff --git a/mali_kbase/platform/pixel/pixel_gpu.c b/mali_kbase/platform/pixel/pixel_gpu.c index 7f8a4f2..c6800e2 100644 --- a/mali_kbase/platform/pixel/pixel_gpu.c +++ b/mali_kbase/platform/pixel/pixel_gpu.c @@ -171,6 +171,50 @@ static int gpu_fw_cfg_init(struct kbase_device *kbdev) { } /** + * gpu_pixel_kctx_init() - Called when a kernel context is created + * + * @kctx: The &struct kbase_context that is being initialized + * + * This function is called when the GPU driver is initializing a new kernel context. + * + * Return: Returns 0 on success, or an error code on failure. + */ +static int gpu_pixel_kctx_init(struct kbase_context *kctx) +{ + struct kbase_device* kbdev = kctx->kbdev; + int err; + + kctx->platform_data = kzalloc(sizeof(struct pixel_platform_data), GFP_KERNEL); + if (kctx->platform_data == NULL) { + dev_err(kbdev->dev, "pixel: failed to alloc platform_data for kctx"); + err = -ENOMEM; + goto done; + } + + err = gpu_dvfs_kctx_init(kctx); + if (err) { + dev_err(kbdev->dev, "pixel: DVFS kctx init failed\n"); + goto done; + } + +done: + return err; +} + +/** + * gpu_pixel_kctx_term() - Called when a kernel context is terminated + * + * @kctx: The &struct kbase_context that is being terminated + */ +static void gpu_pixel_kctx_term(struct kbase_context *kctx) +{ + gpu_dvfs_kctx_term(kctx); + + kfree(kctx->platform_data); + kctx->platform_data = NULL; +} + +/** * gpu_pixel_init() - Initializes the Pixel integration for the Mali GPU. * * @kbdev: The &struct kbase_device for the GPU. @@ -243,8 +287,8 @@ static void gpu_pixel_term(struct kbase_device *kbdev) struct kbase_platform_funcs_conf platform_funcs = { .platform_init_func = &gpu_pixel_init, .platform_term_func = &gpu_pixel_term, - .platform_handler_context_init_func = &gpu_dvfs_kctx_init, - .platform_handler_context_term_func = &gpu_dvfs_kctx_term, + .platform_handler_context_init_func = &gpu_pixel_kctx_init, + .platform_handler_context_term_func = &gpu_pixel_kctx_term, .platform_handler_work_begin_func = &gpu_dvfs_metrics_work_begin, .platform_handler_work_end_func = &gpu_dvfs_metrics_work_end, .platform_fw_cfg_init_func = &gpu_fw_cfg_init, diff --git a/mali_kbase/platform/pixel/pixel_gpu_dvfs_metrics.c b/mali_kbase/platform/pixel/pixel_gpu_dvfs_metrics.c index f024ff5..c7c2b81 100644 --- a/mali_kbase/platform/pixel/pixel_gpu_dvfs_metrics.c +++ b/mali_kbase/platform/pixel/pixel_gpu_dvfs_metrics.c @@ -209,7 +209,8 @@ void gpu_dvfs_metrics_work_begin(void* param) struct kbase_context* kctx = unit->kctx; struct kbase_device* kbdev = kctx->kbdev; struct pixel_context* pc = kbdev->platform_context; - struct gpu_dvfs_metrics_uid_stats* uid_stats = kctx->platform_data; + struct pixel_platform_data *pd = kctx->platform_data; + struct gpu_dvfs_metrics_uid_stats* uid_stats = pd->stats; struct gpu_dvfs_metrics_uid_stats** work_stats = &pc->dvfs.metrics.work_uid_stats[slot]; const u64 curr = ktime_get_ns(); unsigned long flags; @@ -264,7 +265,8 @@ void gpu_dvfs_metrics_work_end(void *param) struct kbase_context* kctx = unit->kctx; struct kbase_device* kbdev = kctx->kbdev; struct pixel_context* pc = kbdev->platform_context; - struct gpu_dvfs_metrics_uid_stats* uid_stats = kctx->platform_data; + struct pixel_platform_data *pd = kctx->platform_data; + struct gpu_dvfs_metrics_uid_stats* uid_stats = pd->stats; struct gpu_dvfs_metrics_uid_stats** work_stats = &pc->dvfs.metrics.work_uid_stats[slot]; const u64 curr = ktime_get_ns(); unsigned long flags; @@ -376,6 +378,7 @@ int gpu_dvfs_kctx_init(struct kbase_context *kctx) { struct kbase_device *kbdev = kctx->kbdev; struct pixel_context *pc = kbdev->platform_context; + struct pixel_platform_data *pd = kctx->platform_data; struct task_struct *task; kuid_t uid; @@ -428,7 +431,7 @@ int gpu_dvfs_kctx_init(struct kbase_context *kctx) stats->active_kctx_count++; /* Store a direct link in the kctx */ - kctx->platform_data = stats; + pd->stats = stats; done: mutex_unlock(&kbdev->kctx_list_lock); @@ -446,7 +449,8 @@ done: void gpu_dvfs_kctx_term(struct kbase_context *kctx) { struct kbase_device *kbdev = kctx->kbdev; - struct gpu_dvfs_metrics_uid_stats *stats = kctx->platform_data; + struct pixel_platform_data *pd = kctx->platform_data; + struct gpu_dvfs_metrics_uid_stats *stats = pd->stats; unsigned long flags; spin_lock_irqsave(&kbdev->hwaccess_lock, flags); |