video: driver: optimize buffer pool implementation

- Maintain free & busy pool to track buffers separately
- track double-free cases during msm_memory_free()
- track memory leak, by checking busy pool buffer count.
  it is expected to be zero at the end of a session.
- maintain common api's to init, alloc, free, destroy
  for all below buffer types.
    - struct msm_vidc_buffer
    - struct msm_vidc_alloc
    - struct msm_vidc_map
    - struct msm_vidc_timestamp.

Change-Id: Ib8655047c3883ea6601344661058d7a629ffd5bd
Signed-off-by: Govindaraj Rajagopal <grajagop@codeaurora.org>
This commit is contained in:
Govindaraj Rajagopal
2021-06-07 14:37:02 +05:30
parent b113af07cb
commit 3e4248dfb0
9 changed files with 232 additions and 296 deletions

View File

@@ -7,7 +7,30 @@
#define _MSM_VIDC_MEMORY_H_
#include "msm_vidc_internal.h"
#include "msm_vidc_core.h"
struct msm_vidc_core;
struct msm_vidc_inst;
enum msm_memory_pool_type {
MSM_MEM_POOL_BUFFER = 0,
MSM_MEM_POOL_MAP,
MSM_MEM_POOL_ALLOC,
MSM_MEM_POOL_TIMESTAMP,
MSM_MEM_POOL_MAX,
};
struct msm_memory_alloc_header {
struct list_head list;
void *buf;
};
struct msm_memory_pool {
u32 type;
u32 size;
char *name;
struct list_head free_pool; /* list of struct msm_memory_alloc_header */
struct list_head busy_pool; /* list of struct msm_memory_alloc_header */
};
int msm_vidc_memory_alloc(struct msm_vidc_core *core,
struct msm_vidc_alloc *alloc);
@@ -19,5 +42,11 @@ int msm_vidc_memory_unmap(struct msm_vidc_core *core,
struct msm_vidc_map *map);
struct dma_buf *msm_vidc_memory_get_dmabuf(int fd);
void msm_vidc_memory_put_dmabuf(void *dmabuf);
int msm_memory_pools_init(struct msm_vidc_inst *inst);
void msm_memory_pools_deinit(struct msm_vidc_inst *inst);
void *msm_memory_alloc(struct msm_vidc_inst *inst,
enum msm_memory_pool_type type);
void msm_memory_free(struct msm_vidc_inst *inst,
enum msm_memory_pool_type type, void *vidc_buf);
#endif // _MSM_VIDC_MEMORY_H_