From 784c9c82121c67da9c88dbcb7cb05065ddc812e5 Mon Sep 17 00:00:00 2001 From: Deepak Kumar Date: Tue, 19 Jan 2021 09:53:27 +0530 Subject: [PATCH] msm: kgsl: Fix nr_removed calculation while reducing pools Current code is reducing total_pages by pcount for each loop iteration which results in decrementing total_pages incorrectly as pcount is total number of pages reduced in all previous iterations. Incorrect total_pages results in incorrect nr_removed. Fix this by not decrementing total_pages and directly accounting for already reduced pages in nr_removed calculation. Change-Id: I69485c26f1f98974eecc30caa1a888ddeafe7c73 Signed-off-by: Deepak Kumar --- drivers/gpu/msm/kgsl_pool.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/msm/kgsl_pool.c b/drivers/gpu/msm/kgsl_pool.c index d3f5313d8fc2..dbff8e91bfe4 100644 --- a/drivers/gpu/msm/kgsl_pool.c +++ b/drivers/gpu/msm/kgsl_pool.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2016-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2016-2021, The Linux Foundation. All rights reserved. */ #include @@ -208,9 +208,7 @@ kgsl_pool_reduce(unsigned int target_pages, bool exit) if (!pool->allocation_allowed && !exit) continue; - total_pages -= pcount; - - nr_removed = total_pages - target_pages; + nr_removed = total_pages - target_pages - pcount; if (nr_removed <= 0) return pcount;