summaryrefslogtreecommitdiff
path: root/mali_kbase
diff options
context:
space:
mode:
authorJack Diver <diverj@google.com>2023-11-08 17:09:20 +0000
committerJack Diver <diverj@google.com>2024-02-28 18:24:08 +0000
commitee7d8af92a5ddd8645dc4ec689e3eab8a461bf53 (patch)
treec2629e349473118d15b8eabdb1c071c9fb274181 /mali_kbase
parent2dd21a70c75d09b6e73838f8882e19dd734a66f0 (diff)
downloadgpu-ee7d8af92a5ddd8645dc4ec689e3eab8a461bf53.tar.gz
mali_pixel: Implement SLC partition ref counting
Bug: 313458962 Test: gfxbench Signed-off-by: Jack Diver <diverj@google.com> (cherry picked from https://partner-android-review.googlesource.com/q/commit:ef62a44e1e80286433fae8918996eb57647ba84c) Merged-In: Id2ab03db4b8b3122bc1f87ecb97715fa3a5d80e4 Change-Id: Id2ab03db4b8b3122bc1f87ecb97715fa3a5d80e4
Diffstat (limited to 'mali_kbase')
-rw-r--r--mali_kbase/platform/pixel/mali_kbase_config_platform.h6
-rw-r--r--mali_kbase/platform/pixel/pixel_gpu_slc.c51
2 files changed, 52 insertions, 5 deletions
diff --git a/mali_kbase/platform/pixel/mali_kbase_config_platform.h b/mali_kbase/platform/pixel/mali_kbase_config_platform.h
index 06b76ea..47b1318 100644
--- a/mali_kbase/platform/pixel/mali_kbase_config_platform.h
+++ b/mali_kbase/platform/pixel/mali_kbase_config_platform.h
@@ -428,12 +428,14 @@ struct pixel_context {
/**
* struct pixel_platform_data - Per kbase_context Pixel specific platform data
*
- * @kctx: Handle to the parent kctx
- * @stats: Tracks the dvfs metrics for the UID associated with this context
+ * @kctx: Handle to the parent kctx
+ * @stats: Tracks the dvfs metrics for the UID associated with this context
+ * @slc_vote: Tracks whether this context is voting for slc
*/
struct pixel_platform_data {
struct kbase_context *kctx;
struct gpu_dvfs_metrics_uid_stats* stats;
+ int slc_vote;
};
#endif /* _KBASE_CONFIG_PLATFORM_H_ */
diff --git a/mali_kbase/platform/pixel/pixel_gpu_slc.c b/mali_kbase/platform/pixel/pixel_gpu_slc.c
index 8e46be1..e8aae75 100644
--- a/mali_kbase/platform/pixel/pixel_gpu_slc.c
+++ b/mali_kbase/platform/pixel/pixel_gpu_slc.c
@@ -17,6 +17,37 @@
#include "mali_kbase_config_platform.h"
#include "pixel_gpu_slc.h"
+#include <uapi/gpu/arm/midgard/platform/pixel/pixel_memory_group_manager.h>
+
+/**
+ * enum slc_vote_state - Whether a context is voting for SLC
+ */
+enum slc_vote_state {
+ /** @IDLE: Idle, not voting for SLC */
+ IDLE = 0,
+ /** @VOTING: Active, voting for SLC */
+ VOTING = 1,
+};
+
+/**
+ * transition() - Try to transition from one value to another
+ *
+ * @v: Value to transition
+ * @old: Starting state to transition from
+ * @new: Destination state to transition to
+ *
+ * Return: Whether the transition was successful
+ */
+static bool transition(int *v, int old, int new)
+{
+ bool const cond = *v == old;
+
+ if (cond)
+ *v = new;
+
+ return cond;
+}
+
/**
* gpu_pixel_handle_buffer_liveness_update_ioctl() - See gpu_slc_liveness_update
*
@@ -57,7 +88,11 @@ int gpu_slc_kctx_init(struct kbase_context *kctx)
*/
void gpu_slc_kctx_term(struct kbase_context *kctx)
{
- (void)kctx;
+ struct pixel_platform_data *pd = kctx->platform_data;
+
+ /* Contexts can be terminated without being idled first */
+ if (transition(&pd->slc_vote, VOTING, IDLE))
+ pixel_mgm_slc_dec_refcount(kctx->kbdev->mgm_dev);
}
/**
@@ -67,7 +102,12 @@ void gpu_slc_kctx_term(struct kbase_context *kctx)
*/
void gpu_slc_kctx_active(struct kbase_context *kctx)
{
- (void)kctx;
+ struct pixel_platform_data *pd = kctx->platform_data;
+
+ lockdep_assert_held(&kctx->kbdev->hwaccess_lock);
+
+ if (transition(&pd->slc_vote, IDLE, VOTING))
+ pixel_mgm_slc_inc_refcount(kctx->kbdev->mgm_dev);
}
/**
@@ -77,7 +117,12 @@ void gpu_slc_kctx_active(struct kbase_context *kctx)
*/
void gpu_slc_kctx_idle(struct kbase_context *kctx)
{
- (void)kctx;
+ struct pixel_platform_data *pd = kctx->platform_data;
+
+ lockdep_assert_held(&kctx->kbdev->hwaccess_lock);
+
+ if (transition(&pd->slc_vote, VOTING, IDLE))
+ pixel_mgm_slc_dec_refcount(kctx->kbdev->mgm_dev);
}
/**