From d5304c2fbb0c4fbc9c4ded32d032d00cbc1cd39c Mon Sep 17 00:00:00 2001 From: Jack Diver Date: Mon, 10 Jul 2023 14:37:38 +0000 Subject: mali_pixel: mgm: Compensate for group migration Pages in the SLC group were often 'migrated' there from the reserved group. This leads to unbalanced accounting as at alloc time the reserved group counter is incremented, but at free time the SLC group counter is decremented. Add custom logic to detect this, but plan to remove it soon when memory groups are decoupled from SLC partitions (b/290354607). Bug: 289501175 Signed-off-by: Jack Diver (cherry picked from https://partner-android-review.googlesource.com/q/commit:7bb27d3d29f850315d0b7ee103fbdfe75e9403da) Merged-In: Ia878a05c4d8dd7db7969f7089c6b93bf90c17f8e Change-Id: Ia878a05c4d8dd7db7969f7089c6b93bf90c17f8e --- mali_pixel/memory_group_manager.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'mali_pixel') diff --git a/mali_pixel/memory_group_manager.c b/mali_pixel/memory_group_manager.c index ed5f04f..0618994 100644 --- a/mali_pixel/memory_group_manager.c +++ b/mali_pixel/memory_group_manager.c @@ -434,7 +434,26 @@ static void update_size(struct memory_group_manager_device *mgm_dev, int atomic_inc(size); atomic64_add(1 << order, &total_gpu_pages); } else { - WARN_ON(atomic_dec_return(size) < 0); + if (atomic_dec_return(size) < 0) { + /* b/289501175 + * Pages are often 'migrated' to the SLC group, which needs special + * accounting. + * + * TODO: Remove after SLC MGM decoupling b/290354607 + */ + if (!WARN_ON(group_id != MGM_SLC_GROUP_ID)) { + /* Undo the dec, and instead decrement the reserved group counter. + * This is still making the assumption that the migration came from + * the reserved group. Currently this is always true, however it + * might not be in future. It would be invasive and costly to track + * where every page came from, so instead this will be fixed as part + * of the b/290354607 effort. + */ + atomic_inc(size); + update_size(mgm_dev, MGM_RESERVED_GROUP_ID, order, alloc); + return; + } + } atomic64_sub(1 << order, &total_gpu_pages); } -- cgit v1.2.3