msm: camera: memmgr: Add refcount to track umd in use buffers

Currently krefcount is using by umd and kmd. Due to sometimes
there is issue in umd, such as release twice. That maybe causes
buffer release before kmd access the buffer. This commit add
a new refcount to track umd in use buffers and use current krefcount
to track kmd in use buffers. For the same buffer use in kmd and umd
only when all refcount become zero, the buffer start to release.

CRs-Fixed: 3692103
Change-Id: I5a58d9bab4c82bdb192d6a6a3d2b3d254dc04c9e
Signed-off-by: zhuo <quic_zhuo@quicinc.com>
This commit is contained in:
zhuo
2024-03-27 16:00:50 +08:00
parent 4408d24dab
commit 77cdd783b0
2 changed files with 116 additions and 23 deletions

View File

@@ -1,7 +1,7 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright (c) 2016-2021, The Linux Foundation. All rights reserved.
* Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
* Copyright (c) 2022-2024 Qualcomm Innovation Center, Inc. All rights reserved.
*/
#ifndef _CAM_MEM_MGR_H_
@@ -82,10 +82,13 @@ struct cam_mem_buf_hw_hdl_info {
* @is_internal: Flag indicating kernel allocated buffer
* @timestamp: Timestamp at which this entry in tbl was made
* @krefcount: Reference counter to track whether the buffer is
* mapped and in use
* mapped and in use by kmd
* @smmu_mapping_client: Client buffer (User or kernel)
* @buf_name: Name associated with buffer.
* @presil_params: Parameters specific to presil environment
* @urefcount: Reference counter to track whether the buffer is
* mapped and in use by umd
* @ref_lock: Mutex lock for refcount
*/
struct cam_mem_buf_queue {
struct dma_buf *dma_buf;
@@ -111,6 +114,8 @@ struct cam_mem_buf_queue {
#ifdef CONFIG_CAM_PRESIL
struct cam_presil_dmabuf_params presil_params;
#endif
struct kref urefcount;
struct mutex ref_lock;
};
/**