msm: camera: mem_mgr: Add dma_buf_vmap to cam_compat
dma_buf_vmap function signature changed between kernel version 5.10 and 5.15. CRs-Fixed: 3048249 Change-Id: I4c8dc951cc383c3dc888fca1d0b1becf92f4662c Signed-off-by: Karthik Jayakumar <kjayakum@codeaurora.org>
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
#include "cam_trace.h"
|
||||
#include "cam_common_util.h"
|
||||
#include "cam_presil_hw_access.h"
|
||||
#include "cam_compat.h"
|
||||
|
||||
#define CAM_MEM_SHARED_BUFFER_PAD_4K (4 * 1024)
|
||||
|
||||
@@ -109,12 +110,9 @@ static int cam_mem_util_get_dma_dir(uint32_t flags)
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int cam_mem_util_map_cpu_va(struct dma_buf *dmabuf,
|
||||
uintptr_t *vaddr,
|
||||
size_t *len)
|
||||
static int cam_mem_util_map_cpu_va(struct dma_buf *dmabuf, uintptr_t *vaddr, size_t *len)
|
||||
{
|
||||
int rc = 0;
|
||||
void *addr;
|
||||
|
||||
/*
|
||||
* dma_buf_begin_cpu_access() and dma_buf_end_cpu_access()
|
||||
@@ -126,24 +124,20 @@ static int cam_mem_util_map_cpu_va(struct dma_buf *dmabuf,
|
||||
return rc;
|
||||
}
|
||||
|
||||
addr = dma_buf_vmap(dmabuf);
|
||||
if (!addr) {
|
||||
CAM_ERR(CAM_MEM, "kernel map fail");
|
||||
*vaddr = 0;
|
||||
rc = cam_compat_util_get_dmabuf_va(dmabuf, vaddr);
|
||||
if (rc) {
|
||||
CAM_ERR(CAM_MEM, "kernel vmap failed: rc = %d", rc);
|
||||
*len = 0;
|
||||
rc = -ENOSPC;
|
||||
goto fail;
|
||||
dma_buf_end_cpu_access(dmabuf, DMA_BIDIRECTIONAL);
|
||||
}
|
||||
else {
|
||||
*len = dmabuf->size;
|
||||
CAM_DBG(CAM_MEM, "vaddr = %llu, len = %zu", *vaddr, *len);
|
||||
}
|
||||
|
||||
*vaddr = (uint64_t)addr;
|
||||
*len = dmabuf->size;
|
||||
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
dma_buf_end_cpu_access(dmabuf, DMA_BIDIRECTIONAL);
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int cam_mem_util_unmap_cpu_va(struct dma_buf *dmabuf,
|
||||
uint64_t vaddr)
|
||||
{
|
||||
|
@@ -301,6 +301,20 @@ int cam_req_mgr_ordered_list_cmp(void *priv,
|
||||
list_entry(head_2, struct cam_subdev, list));
|
||||
}
|
||||
|
||||
int cam_compat_util_get_dmabuf_va(struct dma_buf *dmabuf, uintptr_t *vaddr)
|
||||
{
|
||||
struct dma_buf_map mapping;
|
||||
int error_code = dma_buf_vmap(dmabuf, &mapping);
|
||||
|
||||
if (error_code)
|
||||
*vaddr = 0;
|
||||
else
|
||||
*vaddr = (mapping.is_iomem) ?
|
||||
(uintptr_t)mapping.vaddr_iomem : (uintptr_t)mapping.vaddr;
|
||||
|
||||
return error_code;
|
||||
}
|
||||
|
||||
int cam_get_ddr_type(void)
|
||||
{
|
||||
/* We assume all chipsets running kernel version 5.15+
|
||||
@@ -316,6 +330,21 @@ int cam_req_mgr_ordered_list_cmp(void *priv,
|
||||
list_entry(head_2, struct cam_subdev, list));
|
||||
}
|
||||
|
||||
int cam_compat_util_get_dmabuf_va(struct dma_buf *dmabuf, uintptr_t *vaddr)
|
||||
{
|
||||
int error_code = 0;
|
||||
void *addr = dma_buf_vmap(dmabuf);
|
||||
|
||||
if (!addr) {
|
||||
*vaddr = 0;
|
||||
error_code = -ENOSPC;
|
||||
} else {
|
||||
*vaddr = (uintptr_t)addr;
|
||||
}
|
||||
|
||||
return error_code;
|
||||
}
|
||||
|
||||
int cam_get_ddr_type(void)
|
||||
{
|
||||
return of_fdt_get_ddrtype();
|
||||
|
@@ -47,6 +47,7 @@ void cam_free_clear(const void *);
|
||||
void cam_check_iommu_faults(struct iommu_domain *domain,
|
||||
struct cam_smmu_pf_info *pf_info);
|
||||
int cam_get_ddr_type(void);
|
||||
int cam_compat_util_get_dmabuf_va(struct dma_buf *dmabuf, uintptr_t *vaddr);
|
||||
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0)
|
||||
int cam_req_mgr_ordered_list_cmp(void *priv,
|
||||
|
Reference in New Issue
Block a user