|
@@ -39,6 +39,10 @@ static int _wncc_unmap_metadata_bufs(struct eva_kmd_hfi_packet* in_pkt,
|
|
|
int print_smem(u32 tag, const char *str, struct msm_cvp_inst *inst,
|
|
|
struct msm_cvp_smem *smem)
|
|
|
{
|
|
|
+ int i;
|
|
|
+ char name[PKT_NAME_LEN] = "Unknown";
|
|
|
+
|
|
|
+
|
|
|
if (!(tag & msm_cvp_debug))
|
|
|
return 0;
|
|
|
|
|
@@ -49,11 +53,21 @@ int print_smem(u32 tag, const char *str, struct msm_cvp_inst *inst,
|
|
|
}
|
|
|
|
|
|
if (smem->dma_buf) {
|
|
|
+ if (!atomic_read(&smem->refcount))
|
|
|
+ return 0;
|
|
|
+
|
|
|
+ for (i = 0; i < get_pkt_array_size(); i++)
|
|
|
+ if (cvp_hfi_defs[i].type == smem->pkt_type) {
|
|
|
+ strlcpy(name, cvp_hfi_defs[i].name, PKT_NAME_LEN);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
dprintk(tag,
|
|
|
- "%s: %x : %s size %d flags %#x iova %#x idx %d ref %d",
|
|
|
+ "%s: %x : %s size %d flags %#x iova %#x idx %d ref %d pkt_type %s buf_idx %#x",
|
|
|
str, hash32_ptr(inst->session), smem->dma_buf->name,
|
|
|
smem->size, smem->flags, smem->device_addr,
|
|
|
- smem->bitmap_index, smem->refcount);
|
|
|
+ smem->bitmap_index, atomic_read(&smem->refcount),
|
|
|
+ name, smem->buf_idx);
|
|
|
}
|
|
|
return 0;
|
|
|
}
|
|
@@ -81,8 +95,11 @@ static void print_internal_buffer(u32 tag, const char *str,
|
|
|
void print_cvp_buffer(u32 tag, const char *str, struct msm_cvp_inst *inst,
|
|
|
struct cvp_internal_buf *cbuf)
|
|
|
{
|
|
|
- dprintk(tag, "%s addr: %x size %u\n", str,
|
|
|
- cbuf->smem->device_addr, cbuf->size);
|
|
|
+ if (!inst || !cbuf)
|
|
|
+ dprintk(CVP_ERR,
|
|
|
+ "%s Invalid params inst %pK, cbuf %pK\n", inst, cbuf);
|
|
|
+
|
|
|
+ print_smem(tag, str, inst, cbuf->smem);
|
|
|
}
|
|
|
|
|
|
static void _log_smem(struct inst_snapshot *snapshot, struct msm_cvp_inst *inst,
|
|
@@ -102,6 +119,8 @@ static void _log_smem(struct inst_snapshot *snapshot, struct msm_cvp_inst *inst,
|
|
|
s->device_addr = smem->device_addr;
|
|
|
s->bitmap_index = smem->bitmap_index;
|
|
|
s->refcount = atomic_read(&smem->refcount);
|
|
|
+ s->pkt_type = smem->pkt_type;
|
|
|
+ s->buf_idx = smem->buf_idx;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -282,6 +301,8 @@ int msm_cvp_map_buf_dsp(struct msm_cvp_inst *inst, struct eva_kmd_buffer *buf)
|
|
|
|
|
|
smem->dma_buf = dma_buf;
|
|
|
smem->bitmap_index = MAX_DMABUF_NUMS;
|
|
|
+ smem->pkt_type = 0;
|
|
|
+ smem->buf_idx = 0;
|
|
|
dprintk(CVP_MEM, "%s: dma_buf = %llx\n", __func__, dma_buf);
|
|
|
rc = msm_cvp_map_smem(inst, smem, "map dsp");
|
|
|
if (rc) {
|
|
@@ -439,6 +460,8 @@ int msm_cvp_map_buf_wncc(struct msm_cvp_inst *inst,
|
|
|
|
|
|
smem->dma_buf = dma_buf;
|
|
|
smem->bitmap_index = MAX_DMABUF_NUMS;
|
|
|
+ smem->pkt_type = 0;
|
|
|
+ smem->buf_idx = 0;
|
|
|
dprintk(CVP_MEM, "%s: dma_buf = %llx", __func__, dma_buf);
|
|
|
rc = msm_cvp_map_smem(inst, smem, "map wncc");
|
|
|
if (rc) {
|
|
@@ -1183,7 +1206,8 @@ exit:
|
|
|
}
|
|
|
|
|
|
static u32 msm_cvp_map_user_persist_buf(struct msm_cvp_inst *inst,
|
|
|
- struct cvp_buf_type *buf)
|
|
|
+ struct cvp_buf_type *buf,
|
|
|
+ u32 pkt_type, u32 buf_idx)
|
|
|
{
|
|
|
u32 iova = 0;
|
|
|
struct msm_cvp_smem *smem = NULL;
|
|
@@ -1203,6 +1227,8 @@ static u32 msm_cvp_map_user_persist_buf(struct msm_cvp_inst *inst,
|
|
|
goto exit;
|
|
|
|
|
|
smem->flags |= SMEM_PERSIST;
|
|
|
+ smem->pkt_type = pkt_type;
|
|
|
+ smem->buf_idx = buf_idx;
|
|
|
pbuf->smem = smem;
|
|
|
pbuf->fd = buf->fd;
|
|
|
pbuf->size = buf->size;
|
|
@@ -1226,7 +1252,8 @@ exit:
|
|
|
|
|
|
u32 msm_cvp_map_frame_buf(struct msm_cvp_inst *inst,
|
|
|
struct cvp_buf_type *buf,
|
|
|
- struct msm_cvp_frame *frame)
|
|
|
+ struct msm_cvp_frame *frame,
|
|
|
+ u32 pkt_type, u32 buf_idx)
|
|
|
{
|
|
|
u32 iova = 0;
|
|
|
struct msm_cvp_smem *smem = NULL;
|
|
@@ -1248,6 +1275,9 @@ u32 msm_cvp_map_frame_buf(struct msm_cvp_inst *inst,
|
|
|
if (!smem)
|
|
|
return 0;
|
|
|
|
|
|
+ smem->pkt_type = pkt_type;
|
|
|
+ smem->buf_idx = buf_idx;
|
|
|
+
|
|
|
frame->bufs[nr].fd = buf->fd;
|
|
|
frame->bufs[nr].smem = smem;
|
|
|
frame->bufs[nr].size = buf->size;
|
|
@@ -1284,6 +1314,7 @@ static void msm_cvp_unmap_frame_buf(struct msm_cvp_inst *inst,
|
|
|
/* smem not in dmamap cache */
|
|
|
msm_cvp_unmap_smem(inst, smem, "unmap cpu");
|
|
|
dma_heap_buffer_free(smem->dma_buf);
|
|
|
+ smem->pkt_type = smem->buf_idx = 0;
|
|
|
kmem_cache_free(cvp_driver->smem_cache, smem);
|
|
|
buf->smem = NULL;
|
|
|
} else {
|
|
@@ -1292,6 +1323,7 @@ static void msm_cvp_unmap_frame_buf(struct msm_cvp_inst *inst,
|
|
|
CLEAR_USE_BITMAP(smem->bitmap_index, inst);
|
|
|
print_smem(CVP_MEM, "Map dereference",
|
|
|
inst, smem);
|
|
|
+ smem->pkt_type = smem->buf_idx = 0;
|
|
|
}
|
|
|
mutex_unlock(&inst->dma_cache.lock);
|
|
|
}
|
|
@@ -1362,16 +1394,19 @@ int msm_cvp_unmap_user_persist(struct msm_cvp_inst *inst,
|
|
|
msm_cvp_unmap_smem(inst, smem,
|
|
|
"unmap cpu");
|
|
|
dma_heap_buffer_free(smem->dma_buf);
|
|
|
+ smem->pkt_type = smem->buf_idx = 0;
|
|
|
kmem_cache_free(
|
|
|
cvp_driver->smem_cache,
|
|
|
smem);
|
|
|
pbuf->smem = NULL;
|
|
|
} else {
|
|
|
mutex_lock(&inst->dma_cache.lock);
|
|
|
- if (atomic_dec_and_test(&smem->refcount))
|
|
|
+ if (atomic_dec_and_test(&smem->refcount)) {
|
|
|
CLEAR_USE_BITMAP(
|
|
|
smem->bitmap_index,
|
|
|
inst);
|
|
|
+ smem->pkt_type = smem->buf_idx = 0;
|
|
|
+ }
|
|
|
mutex_unlock(&inst->dma_cache.lock);
|
|
|
}
|
|
|
|
|
@@ -1436,12 +1471,14 @@ int msm_cvp_map_user_persist(struct msm_cvp_inst *inst,
|
|
|
unsigned int offset, unsigned int buf_num)
|
|
|
{
|
|
|
struct cvp_buf_type *buf;
|
|
|
+ struct cvp_hfi_cmd_session_hdr *cmd_hdr;
|
|
|
int i;
|
|
|
u32 iova;
|
|
|
|
|
|
if (!offset || !buf_num)
|
|
|
return 0;
|
|
|
|
|
|
+ cmd_hdr = (struct cvp_hfi_cmd_session_hdr *)in_pkt;
|
|
|
for (i = 0; i < buf_num; i++) {
|
|
|
buf = (struct cvp_buf_type *)&in_pkt->pkt_data[offset];
|
|
|
offset += sizeof(*buf) >> 2;
|
|
@@ -1449,7 +1486,7 @@ int msm_cvp_map_user_persist(struct msm_cvp_inst *inst,
|
|
|
if (buf->fd < 0 || !buf->size)
|
|
|
continue;
|
|
|
|
|
|
- iova = msm_cvp_map_user_persist_buf(inst, buf);
|
|
|
+ iova = msm_cvp_map_user_persist_buf(inst, buf, cmd_hdr->packet_type, i);
|
|
|
if (!iova) {
|
|
|
dprintk(CVP_ERR,
|
|
|
"%s: buf %d register failed.\n",
|
|
@@ -1496,7 +1533,7 @@ int msm_cvp_map_frame(struct msm_cvp_inst *inst,
|
|
|
if (buf->fd < 0 || !buf->size)
|
|
|
continue;
|
|
|
|
|
|
- iova = msm_cvp_map_frame_buf(inst, buf, frame);
|
|
|
+ iova = msm_cvp_map_frame_buf(inst, buf, frame, cmd_hdr->packet_type, i);
|
|
|
if (!iova) {
|
|
|
dprintk(CVP_ERR,
|
|
|
"%s: buf %d register failed.\n",
|
|
@@ -1690,7 +1727,9 @@ struct cvp_internal_buf *cvp_allocate_arp_bufs(struct msm_cvp_inst *inst,
|
|
|
dprintk(CVP_ERR, "Failed to allocate ARP memory\n");
|
|
|
goto err_no_mem;
|
|
|
}
|
|
|
+ buf->smem->pkt_type = buf->smem->buf_idx = 0;
|
|
|
|
|
|
+ buf->smem->pkt_type = buf->smem->buf_idx = 0;
|
|
|
buf->size = buf->smem->size;
|
|
|
buf->type = HFI_BUFFER_INTERNAL_PERSIST_1;
|
|
|
buf->ownership = DRIVER;
|
|
@@ -1826,6 +1865,7 @@ int cvp_allocate_dsp_bufs(struct msm_cvp_inst *inst,
|
|
|
dprintk(CVP_ERR, "Failed to allocate ARP memory\n");
|
|
|
goto err_no_mem;
|
|
|
}
|
|
|
+ buf->smem->pkt_type = buf->smem->buf_idx = 0;
|
|
|
|
|
|
dprintk(CVP_MEM, "%s dma_buf %pK\n", __func__, buf->smem->dma_buf);
|
|
|
|