From c2eae40b63aabc52bf346cca55ba81d7be4fcf79 Mon Sep 17 00:00:00 2001 From: Lynus Vaz Date: Fri, 19 Jan 2024 08:38:17 -0800 Subject: [PATCH] msm: kgsl: Keep the timeline fence valid for logging The timeline fence needs to remain valid for logging purposes. Take an extra refcount on the timeline dma_fence to make sure it doesn't go away till we're done with it. Change-Id: I6670ef7add099a72684c1fe20ed009dff85d1f27 Signed-off-by: Lynus Vaz Signed-off-by: Deepak Kumar --- drivers/gpu/msm/kgsl_drawobj.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/msm/kgsl_drawobj.c b/drivers/gpu/msm/kgsl_drawobj.c index 9e00d2c08234..7ecae4f7cebd 100644 --- a/drivers/gpu/msm/kgsl_drawobj.c +++ b/drivers/gpu/msm/kgsl_drawobj.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2016-2021, The Linux Foundation. All rights reserved. - * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. + * Copyright (c) 2023-2024 Qualcomm Innovation Center, Inc. All rights reserved. */ /* @@ -510,6 +510,8 @@ static int drawobj_add_sync_timeline(struct kgsl_device *device, /* Set pending flag before adding callback to avoid race */ set_bit(event->id, &syncobj->pending); + /* Get a dma_fence refcount to hand over to the callback */ + dma_fence_get(event->fence); ret = dma_fence_add_callback(event->fence, &event->cb, drawobj_sync_timeline_fence_callback); @@ -522,11 +524,16 @@ static int drawobj_add_sync_timeline(struct kgsl_device *device, ret = 0; } + /* Put the refcount from fence creation */ + dma_fence_put(event->fence); kgsl_drawobj_put(drawobj); return ret; } trace_syncpoint_timeline_fence(event->syncobj, event->fence, false); + + /* Put the refcount from fence creation */ + dma_fence_put(event->fence); return 0; }