From 552f119915df9f7367f03349077128acc2de9615 Mon Sep 17 00:00:00 2001 From: Kamal Agrawal Date: Sat, 12 Jun 2021 04:07:14 +0530 Subject: [PATCH] msm: kgsl: Use non-atomic snapshot memory if it is unused Over time, memory gets fragmented, and eventually, a system that is up for a long time may have only a few physically contiguous pages. Hence, there is a chance of atomic snapshot memory allocation failure. Use non-atomic snapshot memory if it is unused as it is allocated during probe time. Change-Id: I725adeb80614a775f92213ebe9768f4f2f1c70a2 Signed-off-by: Kamal Agrawal Signed-off-by: Rohan Sethi --- drivers/gpu/msm/kgsl_snapshot.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/msm/kgsl_snapshot.c b/drivers/gpu/msm/kgsl_snapshot.c index d3aa3de2bc7c..f75fa57fa30f 100644 --- a/drivers/gpu/msm/kgsl_snapshot.c +++ b/drivers/gpu/msm/kgsl_snapshot.c @@ -687,13 +687,18 @@ static void kgsl_device_snapshot_atomic(struct kgsl_device *device) } device->snapshot_memory_atomic.size = device->snapshot_memory.size; - device->snapshot_memory_atomic.ptr = devm_kzalloc(&device->pdev->dev, - device->snapshot_memory_atomic.size, GFP_ATOMIC); + if (!device->snapshot_faultcount) { + /* Use non-atomic snapshot memory if it is unused */ + device->snapshot_memory_atomic.ptr = device->snapshot_memory.ptr; + } else { + device->snapshot_memory_atomic.ptr = devm_kzalloc(&device->pdev->dev, + device->snapshot_memory_atomic.size, GFP_ATOMIC); - if (!device->snapshot_memory_atomic.ptr) { - dev_err(device->dev, - "KGSL failed to allocate memory for atomic snapshot\n"); - return; + if (!device->snapshot_memory_atomic.ptr) { + dev_err(device->dev, + "KGSL failed to allocate memory for atomic snapshot\n"); + return; + } } /* Allocate memory for the snapshot instance */