video: driver: amend delayed unmap feature

Due to delayed unmap feature on decoder output buffers,
refcount will become one when no one uses the buffer
in driver. In release done functonality, remove the
buffer from maps list only if refcount equal to one.
If refcount is more than one indicates the buffer is
being used, so do not remove from maps list. There are
chances that same decoder output buffer might be queued
by the client in which case we are not supposed to
unmap it from maps list in release done.

Change-Id: I69250c3efa89d77055e89770fd441af1fb50b755
Signed-off-by: Maheshwar Ajja <majja@codeaurora.org>
This commit is contained in:
Maheshwar Ajja
2021-04-19 18:03:32 -07:00
committed by Gerrit - the friendly Code Review server
parent da6943c26a
commit 09356ed279
6 changed files with 83 additions and 12 deletions

View File

@@ -2067,6 +2067,52 @@ int msm_vidc_put_map_buffer(struct msm_vidc_inst *inst, struct msm_vidc_map *map
return 0;
}
int msm_vidc_get_delayed_unmap(struct msm_vidc_inst *inst, struct msm_vidc_map *map)
{
int rc = 0;
if (!inst || !map) {
d_vpr_e("%s: invalid params\n", __func__);
return -EINVAL;
}
map->skip_delayed_unmap = 1;
rc = msm_vidc_memory_map(inst->core, map);
if (rc)
return rc;
return 0;
}
int msm_vidc_put_delayed_unmap(struct msm_vidc_inst *inst, struct msm_vidc_map *map)
{
int rc = 0;
if (!inst || !map) {
d_vpr_e("%s: invalid params\n", __func__);
return -EINVAL;
}
if (!map->skip_delayed_unmap) {
i_vpr_e(inst, "%s: no delayed unmap, addr %#x\n",
__func__, map->device_addr);
return -EINVAL;
}
map->skip_delayed_unmap = 0;
rc = msm_vidc_memory_unmap(inst->core, map);
if (rc)
i_vpr_e(inst, "%s: unmap failed\n", __func__);
if (!map->refcount) {
msm_vidc_memory_put_dmabuf(map->dmabuf);
list_del(&map->list);
msm_vidc_put_map_buffer(inst, map);
}
return rc;
}
int msm_vidc_destroy_map_buffer(struct msm_vidc_inst *inst)
{
struct msm_vidc_map *map, *dummy;
@@ -2173,7 +2219,7 @@ int msm_vidc_map_driver_buf(struct msm_vidc_inst *inst,
return -EINVAL;
/*
* new buffer: map twice for lazy unmap feature sake
* new buffer: map twice for delayed unmap feature sake
* existing buffer: map once
*/
list_for_each_entry(map, &mappings->list, list) {
@@ -2195,10 +2241,9 @@ int msm_vidc_map_driver_buf(struct msm_vidc_inst *inst,
if (!map->dmabuf)
return -EINVAL;
map->region = msm_vidc_get_buffer_region(inst, buf->type, __func__);
/* lazy unmap feature not needed for decoder output buffers */
/* delayed unmap feature needed for decoder output buffers */
if (is_decode_session(inst) && is_output_buffer(buf->type)) {
map->skip_delayed_unmap = 1;
rc = msm_vidc_memory_map(inst->core, map);
rc = msm_vidc_get_delayed_unmap(inst, map);
if (rc) {
msm_vidc_memory_put_dmabuf(map->dmabuf);
msm_vidc_put_map_buffer(inst, map);