|
@@ -1980,7 +1980,7 @@ int msm_vidc_process_readonly_buffers(struct msm_vidc_inst *inst,
|
|
|
buf->attr |= MSM_VIDC_ATTR_READ_ONLY;
|
|
|
print_vidc_buffer(VIDC_LOW, "low ", "ro buf removed", inst, ro_buf);
|
|
|
list_del(&ro_buf->list);
|
|
|
- msm_vidc_put_vidc_buffer(inst, ro_buf);
|
|
|
+ msm_memory_free(inst, MSM_MEM_POOL_BUFFER, ro_buf);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
@@ -2007,7 +2007,7 @@ int msm_vidc_memory_unmap_completely(struct msm_vidc_inst *inst,
|
|
|
if (!map->refcount) {
|
|
|
msm_vidc_memory_put_dmabuf(map->dmabuf);
|
|
|
list_del(&map->list);
|
|
|
- msm_vidc_put_map_buffer(inst, map);
|
|
|
+ msm_memory_free(inst, MSM_MEM_POOL_MAP, map);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
@@ -2112,7 +2112,7 @@ int msm_vidc_flush_ts(struct msm_vidc_inst *inst)
|
|
|
i_vpr_l(inst, "%s: flushing ts: val %lld, rank %%lld\n",
|
|
|
__func__, ts->sort.val, ts->rank);
|
|
|
list_del(&ts->sort.list);
|
|
|
- msm_vidc_put_ts(inst, ts);
|
|
|
+ msm_memory_free(inst, MSM_MEM_POOL_TIMESTAMP, ts);
|
|
|
}
|
|
|
inst->timestamps.count = 0;
|
|
|
inst->timestamps.rank = 0;
|
|
@@ -2130,7 +2130,7 @@ int msm_vidc_update_timestamp(struct msm_vidc_inst *inst, u64 timestamp)
|
|
|
return -EINVAL;
|
|
|
}
|
|
|
|
|
|
- ts = msm_vidc_get_ts(inst);
|
|
|
+ ts = msm_memory_alloc(inst, MSM_MEM_POOL_TIMESTAMP);
|
|
|
if (!ts) {
|
|
|
i_vpr_e(inst, "%s: ts alloc failed\n", __func__);
|
|
|
return -ENOMEM;
|
|
@@ -2153,229 +2153,12 @@ int msm_vidc_update_timestamp(struct msm_vidc_inst *inst, u64 timestamp)
|
|
|
}
|
|
|
inst->timestamps.count--;
|
|
|
list_del(&ts->sort.list);
|
|
|
- msm_vidc_put_ts(inst, ts);
|
|
|
+ msm_memory_free(inst, MSM_MEM_POOL_TIMESTAMP, ts);
|
|
|
}
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-struct msm_vidc_timestamp *msm_vidc_get_ts(struct msm_vidc_inst *inst)
|
|
|
-{
|
|
|
- struct msm_vidc_timestamp *ts = NULL;
|
|
|
-
|
|
|
- if (!inst) {
|
|
|
- d_vpr_e("%s: Invalid params\n", __func__);
|
|
|
- return NULL;
|
|
|
- }
|
|
|
-
|
|
|
- if (!list_empty(&inst->pool.timestamps.list)) {
|
|
|
- ts = list_first_entry(&inst->pool.timestamps.list,
|
|
|
- struct msm_vidc_timestamp, sort.list);
|
|
|
- inst->pool.timestamps.count--;
|
|
|
- list_del(&ts->sort.list);
|
|
|
- memset(ts, 0, sizeof(struct msm_vidc_timestamp));
|
|
|
- return ts;
|
|
|
- }
|
|
|
-
|
|
|
- ts = kzalloc(sizeof(struct msm_vidc_timestamp), GFP_KERNEL);
|
|
|
- if (!ts) {
|
|
|
- i_vpr_e(inst, "%s: ts failed\n", __func__);
|
|
|
- return NULL;
|
|
|
- }
|
|
|
-
|
|
|
- return ts;
|
|
|
-}
|
|
|
-
|
|
|
-int msm_vidc_put_ts(struct msm_vidc_inst *inst, struct msm_vidc_timestamp *ts)
|
|
|
-{
|
|
|
- if (!inst || !ts) {
|
|
|
- d_vpr_e("%s: Invalid params\n", __func__);
|
|
|
- return -EINVAL;
|
|
|
- }
|
|
|
-
|
|
|
- inst->pool.timestamps.count++;
|
|
|
- list_add_tail(&ts->sort.list, &inst->pool.timestamps.list);
|
|
|
-
|
|
|
- return 0;
|
|
|
-}
|
|
|
-
|
|
|
-int msm_vidc_destroy_ts(struct msm_vidc_inst *inst)
|
|
|
-{
|
|
|
- struct msm_vidc_timestamp *ts, *temp;
|
|
|
-
|
|
|
- if (!inst) {
|
|
|
- d_vpr_e("%s: Invalid params\n", __func__);
|
|
|
- return -EINVAL;
|
|
|
- }
|
|
|
-
|
|
|
- i_vpr_h(inst, "%s: pool: ts count %u\n", __func__, inst->pool.timestamps.count);
|
|
|
-
|
|
|
- /* free all timestamps from pool */
|
|
|
- list_for_each_entry_safe(ts, temp, &inst->pool.timestamps.list, sort.list) {
|
|
|
- list_del(&ts->sort.list);
|
|
|
- kfree(ts);
|
|
|
- }
|
|
|
-
|
|
|
- return 0;
|
|
|
-}
|
|
|
-
|
|
|
-struct msm_vidc_buffer *msm_vidc_get_vidc_buffer(struct msm_vidc_inst *inst)
|
|
|
-{
|
|
|
- struct msm_vidc_buffer *buf = NULL;
|
|
|
-
|
|
|
- if (!inst) {
|
|
|
- d_vpr_e("%s: Invalid params\n", __func__);
|
|
|
- return NULL;
|
|
|
- }
|
|
|
-
|
|
|
- if (!list_empty(&inst->pool.buffers.list)) {
|
|
|
- buf = list_first_entry(&inst->pool.buffers.list, struct msm_vidc_buffer, list);
|
|
|
- inst->pool.buffers.count--;
|
|
|
- list_del(&buf->list);
|
|
|
- memset(buf, 0, sizeof(struct msm_vidc_buffer));
|
|
|
- return buf;
|
|
|
- }
|
|
|
-
|
|
|
- buf = kzalloc(sizeof(struct msm_vidc_buffer), GFP_KERNEL);
|
|
|
- if (!buf) {
|
|
|
- i_vpr_e(inst, "%s: buf failed\n", __func__);
|
|
|
- return NULL;
|
|
|
- }
|
|
|
-
|
|
|
- return buf;
|
|
|
-}
|
|
|
-
|
|
|
-int msm_vidc_put_vidc_buffer(struct msm_vidc_inst *inst, struct msm_vidc_buffer *buf)
|
|
|
-{
|
|
|
- if (!inst || !buf) {
|
|
|
- d_vpr_e("%s: Invalid params\n", __func__);
|
|
|
- return -EINVAL;
|
|
|
- }
|
|
|
-
|
|
|
- inst->pool.buffers.count++;
|
|
|
- list_add_tail(&buf->list, &inst->pool.buffers.list);
|
|
|
-
|
|
|
- return 0;
|
|
|
-}
|
|
|
-
|
|
|
-int msm_vidc_destroy_vidc_buffer(struct msm_vidc_inst *inst)
|
|
|
-{
|
|
|
- struct msm_vidc_buffer *buf, *dummy;
|
|
|
-
|
|
|
- if (!inst) {
|
|
|
- d_vpr_e("%s: Invalid params\n", __func__);
|
|
|
- return -EINVAL;
|
|
|
- }
|
|
|
-
|
|
|
- i_vpr_h(inst, "%s: pool: buffer count %u\n", __func__, inst->pool.buffers.count);
|
|
|
-
|
|
|
- /* free all buffers from pool */
|
|
|
- list_for_each_entry_safe(buf, dummy, &inst->pool.buffers.list, list) {
|
|
|
- list_del(&buf->list);
|
|
|
- kfree(buf);
|
|
|
- }
|
|
|
-
|
|
|
- return 0;
|
|
|
-}
|
|
|
-
|
|
|
-struct msm_vidc_alloc *msm_vidc_get_alloc_buffer(struct msm_vidc_inst *inst)
|
|
|
-{
|
|
|
- struct msm_vidc_alloc *alloc = NULL;
|
|
|
-
|
|
|
- if (!inst) {
|
|
|
- d_vpr_e("%s: Invalid params\n", __func__);
|
|
|
- return NULL;
|
|
|
- }
|
|
|
-
|
|
|
- if (!list_empty(&inst->pool.allocations.list)) {
|
|
|
- alloc = list_first_entry(&inst->pool.allocations.list, struct msm_vidc_alloc, list);
|
|
|
- inst->pool.allocations.count--;
|
|
|
- list_del(&alloc->list);
|
|
|
- memset(alloc, 0, sizeof(struct msm_vidc_alloc));
|
|
|
- return alloc;
|
|
|
- }
|
|
|
-
|
|
|
- alloc = kzalloc(sizeof(struct msm_vidc_alloc), GFP_KERNEL);
|
|
|
- if (!alloc) {
|
|
|
- i_vpr_e(inst, "%s: alloc failed\n", __func__);
|
|
|
- return NULL;
|
|
|
- }
|
|
|
-
|
|
|
- return alloc;
|
|
|
-}
|
|
|
-
|
|
|
-int msm_vidc_put_alloc_buffer(struct msm_vidc_inst *inst, struct msm_vidc_alloc *alloc)
|
|
|
-{
|
|
|
- if (!inst || !alloc) {
|
|
|
- d_vpr_e("%s: Invalid params\n", __func__);
|
|
|
- return -EINVAL;
|
|
|
- }
|
|
|
-
|
|
|
- list_add_tail(&alloc->list, &inst->pool.allocations.list);
|
|
|
- inst->pool.allocations.count++;
|
|
|
-
|
|
|
- return 0;
|
|
|
-}
|
|
|
-
|
|
|
-int msm_vidc_destroy_alloc_buffer(struct msm_vidc_inst *inst)
|
|
|
-{
|
|
|
- struct msm_vidc_alloc *alloc, *dummy;
|
|
|
-
|
|
|
- if (!inst) {
|
|
|
- d_vpr_e("%s: Invalid params\n", __func__);
|
|
|
- return -EINVAL;
|
|
|
- }
|
|
|
-
|
|
|
- i_vpr_h(inst, "%s: pool: allocations count %u\n", __func__, inst->pool.allocations.count);
|
|
|
-
|
|
|
- /* free all allocations from pool */
|
|
|
- list_for_each_entry_safe(alloc, dummy, &inst->pool.allocations.list, list) {
|
|
|
- list_del(&alloc->list);
|
|
|
- kfree(alloc);
|
|
|
- }
|
|
|
-
|
|
|
- return 0;
|
|
|
-}
|
|
|
-
|
|
|
-struct msm_vidc_map *msm_vidc_get_map_buffer(struct msm_vidc_inst *inst)
|
|
|
-{
|
|
|
- struct msm_vidc_map *map = NULL;
|
|
|
-
|
|
|
- if (!inst) {
|
|
|
- d_vpr_e("%s: Invalid params\n", __func__);
|
|
|
- return NULL;
|
|
|
- }
|
|
|
-
|
|
|
- if (!list_empty(&inst->pool.mappings.list)) {
|
|
|
- map = list_first_entry(&inst->pool.mappings.list, struct msm_vidc_map, list);
|
|
|
- inst->pool.mappings.count--;
|
|
|
- list_del(&map->list);
|
|
|
- memset(map, 0, sizeof(struct msm_vidc_map));
|
|
|
- return map;
|
|
|
- }
|
|
|
-
|
|
|
- map = kzalloc(sizeof(struct msm_vidc_map), GFP_KERNEL);
|
|
|
- if (!map) {
|
|
|
- i_vpr_e(inst, "%s: map failed\n", __func__);
|
|
|
- return NULL;
|
|
|
- }
|
|
|
-
|
|
|
- return map;
|
|
|
-}
|
|
|
-
|
|
|
-int msm_vidc_put_map_buffer(struct msm_vidc_inst *inst, struct msm_vidc_map *map)
|
|
|
-{
|
|
|
- if (!inst || !map) {
|
|
|
- d_vpr_e("%s: Invalid params\n", __func__);
|
|
|
- return -EINVAL;
|
|
|
- }
|
|
|
-
|
|
|
- list_add_tail(&map->list, &inst->pool.mappings.list);
|
|
|
- inst->pool.mappings.count++;
|
|
|
-
|
|
|
- return 0;
|
|
|
-}
|
|
|
-
|
|
|
int msm_vidc_get_delayed_unmap(struct msm_vidc_inst *inst, struct msm_vidc_map *map)
|
|
|
{
|
|
|
int rc = 0;
|
|
@@ -2416,32 +2199,12 @@ int msm_vidc_put_delayed_unmap(struct msm_vidc_inst *inst, struct msm_vidc_map *
|
|
|
if (!map->refcount) {
|
|
|
msm_vidc_memory_put_dmabuf(map->dmabuf);
|
|
|
list_del(&map->list);
|
|
|
- msm_vidc_put_map_buffer(inst, map);
|
|
|
+ msm_memory_free(inst, MSM_MEM_POOL_MAP, map);
|
|
|
}
|
|
|
|
|
|
return rc;
|
|
|
}
|
|
|
|
|
|
-int msm_vidc_destroy_map_buffer(struct msm_vidc_inst *inst)
|
|
|
-{
|
|
|
- struct msm_vidc_map *map, *dummy;
|
|
|
-
|
|
|
- if (!inst) {
|
|
|
- d_vpr_e("%s: Invalid params\n", __func__);
|
|
|
- return -EINVAL;
|
|
|
- }
|
|
|
-
|
|
|
- i_vpr_h(inst, "%s: pool: mappings count %u\n", __func__, inst->pool.mappings.count);
|
|
|
-
|
|
|
- /* free all mappings from pool */
|
|
|
- list_for_each_entry_safe(map, dummy, &inst->pool.mappings.list, list) {
|
|
|
- list_del(&map->list);
|
|
|
- kfree(map);
|
|
|
- }
|
|
|
-
|
|
|
- return 0;
|
|
|
-}
|
|
|
-
|
|
|
int msm_vidc_unmap_buffers(struct msm_vidc_inst *inst,
|
|
|
enum msm_vidc_buffer_type type)
|
|
|
{
|
|
@@ -2504,7 +2267,7 @@ int msm_vidc_unmap_driver_buf(struct msm_vidc_inst *inst,
|
|
|
if (!map->refcount) {
|
|
|
msm_vidc_memory_put_dmabuf(map->dmabuf);
|
|
|
list_del(&map->list);
|
|
|
- msm_vidc_put_map_buffer(inst, map);
|
|
|
+ msm_memory_free(inst, MSM_MEM_POOL_MAP, map);
|
|
|
}
|
|
|
|
|
|
return rc;
|
|
@@ -2539,7 +2302,7 @@ int msm_vidc_map_driver_buf(struct msm_vidc_inst *inst,
|
|
|
}
|
|
|
if (!found) {
|
|
|
/* new buffer case */
|
|
|
- map = msm_vidc_get_map_buffer(inst);
|
|
|
+ map = msm_memory_alloc(inst, MSM_MEM_POOL_MAP);
|
|
|
if (!map) {
|
|
|
i_vpr_e(inst, "%s: alloc failed\n", __func__);
|
|
|
return -ENOMEM;
|
|
@@ -2555,7 +2318,7 @@ int msm_vidc_map_driver_buf(struct msm_vidc_inst *inst,
|
|
|
rc = msm_vidc_get_delayed_unmap(inst, map);
|
|
|
if (rc) {
|
|
|
msm_vidc_memory_put_dmabuf(map->dmabuf);
|
|
|
- msm_vidc_put_map_buffer(inst, map);
|
|
|
+ msm_memory_free(inst, MSM_MEM_POOL_MAP, map);
|
|
|
return rc;
|
|
|
}
|
|
|
}
|
|
@@ -2586,7 +2349,7 @@ int msm_vidc_put_driver_buf(struct msm_vidc_inst *inst,
|
|
|
|
|
|
/* delete the buffer from buffers->list */
|
|
|
list_del(&buf->list);
|
|
|
- msm_vidc_put_vidc_buffer(inst, buf);
|
|
|
+ msm_memory_free(inst, MSM_MEM_POOL_BUFFER, buf);
|
|
|
|
|
|
return rc;
|
|
|
}
|
|
@@ -2612,7 +2375,7 @@ struct msm_vidc_buffer *msm_vidc_get_driver_buf(struct msm_vidc_inst *inst,
|
|
|
if (!buffers)
|
|
|
return NULL;
|
|
|
|
|
|
- buf = msm_vidc_get_vidc_buffer(inst);
|
|
|
+ buf = msm_memory_alloc(inst, MSM_MEM_POOL_BUFFER);
|
|
|
if (!buf) {
|
|
|
i_vpr_e(inst, "%s: alloc failed\n", __func__);
|
|
|
return NULL;
|
|
@@ -2640,7 +2403,7 @@ struct msm_vidc_buffer *msm_vidc_get_driver_buf(struct msm_vidc_inst *inst,
|
|
|
error:
|
|
|
msm_vidc_memory_put_dmabuf(buf->dmabuf);
|
|
|
list_del(&buf->list);
|
|
|
- msm_vidc_put_vidc_buffer(inst, buf);
|
|
|
+ msm_memory_free(inst, MSM_MEM_POOL_BUFFER, buf);
|
|
|
return NULL;
|
|
|
}
|
|
|
|
|
@@ -3083,7 +2846,7 @@ int msm_vidc_destroy_internal_buffer(struct msm_vidc_inst *inst,
|
|
|
if (map->dmabuf == buffer->dmabuf) {
|
|
|
msm_vidc_memory_unmap(inst->core, map);
|
|
|
list_del(&map->list);
|
|
|
- msm_vidc_put_map_buffer(inst, map);
|
|
|
+ msm_memory_free(inst, MSM_MEM_POOL_MAP, map);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
@@ -3092,7 +2855,7 @@ int msm_vidc_destroy_internal_buffer(struct msm_vidc_inst *inst,
|
|
|
if (alloc->dmabuf == buffer->dmabuf) {
|
|
|
msm_vidc_memory_free(inst->core, alloc);
|
|
|
list_del(&alloc->list);
|
|
|
- msm_vidc_put_alloc_buffer(inst, alloc);
|
|
|
+ msm_memory_free(inst, MSM_MEM_POOL_ALLOC, alloc);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
@@ -3100,7 +2863,7 @@ int msm_vidc_destroy_internal_buffer(struct msm_vidc_inst *inst,
|
|
|
list_for_each_entry_safe(buf, dummy, &buffers->list, list) {
|
|
|
if (buf->dmabuf == buffer->dmabuf) {
|
|
|
list_del(&buf->list);
|
|
|
- msm_vidc_put_vidc_buffer(inst, buf);
|
|
|
+ msm_memory_free(inst, MSM_MEM_POOL_BUFFER, buf);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
@@ -3180,7 +2943,7 @@ int msm_vidc_create_internal_buffer(struct msm_vidc_inst *inst,
|
|
|
if (!buffers->size)
|
|
|
return 0;
|
|
|
|
|
|
- buffer = msm_vidc_get_vidc_buffer(inst);
|
|
|
+ buffer = msm_memory_alloc(inst, MSM_MEM_POOL_BUFFER);
|
|
|
if (!buffer) {
|
|
|
i_vpr_e(inst, "%s: buf alloc failed\n", __func__);
|
|
|
return -ENOMEM;
|
|
@@ -3191,7 +2954,7 @@ int msm_vidc_create_internal_buffer(struct msm_vidc_inst *inst,
|
|
|
buffer->buffer_size = buffers->size;
|
|
|
list_add_tail(&buffer->list, &buffers->list);
|
|
|
|
|
|
- alloc = msm_vidc_get_alloc_buffer(inst);
|
|
|
+ alloc = msm_memory_alloc(inst, MSM_MEM_POOL_ALLOC);
|
|
|
if (!alloc) {
|
|
|
i_vpr_e(inst, "%s: alloc failed\n", __func__);
|
|
|
return -ENOMEM;
|
|
@@ -3207,7 +2970,7 @@ int msm_vidc_create_internal_buffer(struct msm_vidc_inst *inst,
|
|
|
return -ENOMEM;
|
|
|
list_add_tail(&alloc->list, &allocations->list);
|
|
|
|
|
|
- map = msm_vidc_get_map_buffer(inst);
|
|
|
+ map = msm_memory_alloc(inst, MSM_MEM_POOL_MAP);
|
|
|
if (!map) {
|
|
|
i_vpr_e(inst, "%s: map alloc failed\n", __func__);
|
|
|
return -ENOMEM;
|
|
@@ -4735,20 +4498,20 @@ void msm_vidc_destroy_buffers(struct msm_vidc_inst *inst)
|
|
|
list_for_each_entry_safe(buf, dummy, &inst->buffers.read_only.list, list) {
|
|
|
print_vidc_buffer(VIDC_ERR, "err ", "destroying ro buffer", inst, buf);
|
|
|
list_del(&buf->list);
|
|
|
- msm_vidc_put_vidc_buffer(inst, buf);
|
|
|
+ msm_memory_free(inst, MSM_MEM_POOL_BUFFER, buf);
|
|
|
}
|
|
|
|
|
|
list_for_each_entry_safe(buf, dummy, &inst->buffers.release.list, list) {
|
|
|
print_vidc_buffer(VIDC_ERR, "err ", "destroying release buffer", inst, buf);
|
|
|
list_del(&buf->list);
|
|
|
- msm_vidc_put_vidc_buffer(inst, buf);
|
|
|
+ msm_memory_free(inst, MSM_MEM_POOL_BUFFER, buf);
|
|
|
}
|
|
|
|
|
|
list_for_each_entry_safe(ts, dummy_ts, &inst->timestamps.list, sort.list) {
|
|
|
i_vpr_e(inst, "%s: removing ts: val %lld, rank %lld\n",
|
|
|
__func__, ts->sort.val, ts->rank);
|
|
|
list_del(&ts->sort.list);
|
|
|
- msm_vidc_put_ts(inst, ts);
|
|
|
+ msm_memory_free(inst, MSM_MEM_POOL_TIMESTAMP, ts);
|
|
|
}
|
|
|
|
|
|
list_for_each_entry_safe(work, dummy_work, &inst->response_works, list) {
|
|
@@ -4758,10 +4521,7 @@ void msm_vidc_destroy_buffers(struct msm_vidc_inst *inst)
|
|
|
}
|
|
|
|
|
|
/* destroy buffers from pool */
|
|
|
- msm_vidc_destroy_vidc_buffer(inst);
|
|
|
- msm_vidc_destroy_alloc_buffer(inst);
|
|
|
- msm_vidc_destroy_map_buffer(inst);
|
|
|
- msm_vidc_destroy_ts(inst);
|
|
|
+ msm_memory_pools_deinit(inst);
|
|
|
}
|
|
|
|
|
|
static void msm_vidc_close_helper(struct kref *kref)
|