From 66e18fb51eb97b20530f54bc9118525d21426ad5 Mon Sep 17 00:00:00 2001 From: Govindaraj Rajagopal Date: Sat, 24 Oct 2020 02:58:31 +0530 Subject: [PATCH] msm: vidc: print inode and refcount for all dma_buffers Print dma_buffer inode and file refcount details for all dma buffers including dpb and driver internal buffers. Change-Id: I3c22ccc1aaba555a3748d4607617737bd24adb12 Signed-off-by: Govindaraj Rajagopal --- msm/vidc/msm_smem.c | 23 +++++++++++------- msm/vidc/msm_vidc_common.c | 49 ++++++++++++++++++++++++++------------ 2 files changed, 48 insertions(+), 24 deletions(-) diff --git a/msm/vidc/msm_smem.c b/msm/vidc/msm_smem.c index 4d3454ebc46b..5dfa1e70a089 100644 --- a/msm/vidc/msm_smem.c +++ b/msm/vidc/msm_smem.c @@ -440,8 +440,9 @@ static int alloc_dma_mem(size_t size, u32 align, u32 flags, } s_vpr_h(sid, - "%s: dma_buf = %pK, device_addr = %x, size = %d, kvaddr = %pK, buffer_type = %#x, flags = %#lx\n", - __func__, mem->dma_buf, mem->device_addr, mem->size, + "%s: dma_buf = %pK, inode = %lu, ref = %ld, device_addr = %x, size = %d, kvaddr = %pK, buffer_type = %#x, flags = %#lx\n", + __func__, mem->dma_buf, (dbuf ? file_inode(dbuf->file)->i_ino : -1), + (dbuf ? file_count(dbuf->file) : -1), mem->device_addr, mem->size, mem->kvaddr, mem->buffer_type, mem->flags); return rc; @@ -456,10 +457,14 @@ fail_shared_mem_alloc: static int free_dma_mem(struct msm_smem *mem, u32 sid) { + struct dma_buf *dbuf = NULL; + + dbuf = (struct dma_buf *)mem->dma_buf; s_vpr_h(sid, - "%s: dma_buf = %pK, device_addr = %x, size = %d, kvaddr = %pK, buffer_type = %#x\n", - __func__, mem->dma_buf, mem->device_addr, mem->size, - mem->kvaddr, mem->buffer_type); + "%s: dma_buf = %pK, inode = %lu, ref = %ld, device_addr = %x, size = %d, kvaddr = %pK, buffer_type = %#x\n", + __func__, dbuf, (dbuf ? file_inode(dbuf->file)->i_ino : -1), + (dbuf ? file_count(dbuf->file) : -1), mem->device_addr, + mem->size, mem->kvaddr, mem->buffer_type); if (mem->device_addr) { msm_dma_put_device_address(mem->flags, @@ -468,16 +473,16 @@ static int free_dma_mem(struct msm_smem *mem, u32 sid) } if (mem->kvaddr) { - dma_buf_vunmap(mem->dma_buf, mem->kvaddr); + dma_buf_vunmap(dbuf, mem->kvaddr); mem->kvaddr = NULL; - dma_buf_end_cpu_access(mem->dma_buf, DMA_BIDIRECTIONAL); + dma_buf_end_cpu_access(dbuf, DMA_BIDIRECTIONAL); } - if (mem->dma_buf) { + if (dbuf) { trace_msm_smem_buffer_dma_op_start("FREE", (u32)mem->buffer_type, -1, mem->size, -1, mem->flags, -1); - dma_buf_put(mem->dma_buf); + dma_buf_put(dbuf); mem->dma_buf = NULL; trace_msm_smem_buffer_dma_op_end("FREE", (u32)mem->buffer_type, -1, mem->size, -1, mem->flags, -1); diff --git a/msm/vidc/msm_vidc_common.c b/msm/vidc/msm_vidc_common.c index cfeeb7dfe0de..8104f60fd5de 100644 --- a/msm/vidc/msm_vidc_common.c +++ b/msm/vidc/msm_vidc_common.c @@ -6372,6 +6372,7 @@ int msm_comm_set_color_format(struct msm_vidc_inst *inst, void msm_comm_print_inst_info(struct msm_vidc_inst *inst) { struct msm_vidc_buffer *mbuf; + struct dma_buf *dbuf; struct internal_buf *buf; bool is_decode = false; enum vidc_ports port; @@ -6405,26 +6406,35 @@ void msm_comm_print_inst_info(struct msm_vidc_inst *inst) mutex_lock(&inst->scratchbufs.lock); s_vpr_e(inst->sid, "scratch buffer list:\n"); - list_for_each_entry(buf, &inst->scratchbufs.list, list) - s_vpr_e(inst->sid, "type: %d addr: %x size: %u\n", - buf->buffer_type, buf->smem.device_addr, - buf->smem.size); + list_for_each_entry(buf, &inst->scratchbufs.list, list) { + dbuf = (struct dma_buf *)buf->smem.dma_buf; + s_vpr_e(inst->sid, "type: %d addr: %x size: %u inode: %lu ref: %ld\n", + buf->buffer_type, buf->smem.device_addr, buf->smem.size, + (dbuf ? file_inode(dbuf->file)->i_ino : -1), + (dbuf ? file_count(dbuf->file) : -1)); + } mutex_unlock(&inst->scratchbufs.lock); mutex_lock(&inst->persistbufs.lock); s_vpr_e(inst->sid, "persist buffer list:\n"); - list_for_each_entry(buf, &inst->persistbufs.list, list) - s_vpr_e(inst->sid, "type: %d addr: %x size: %u\n", - buf->buffer_type, buf->smem.device_addr, - buf->smem.size); + list_for_each_entry(buf, &inst->persistbufs.list, list) { + dbuf = (struct dma_buf *)buf->smem.dma_buf; + s_vpr_e(inst->sid, "type: %d addr: %x size: %u inode: %lu ref: %ld\n", + buf->buffer_type, buf->smem.device_addr, buf->smem.size, + (dbuf ? file_inode(dbuf->file)->i_ino : -1), + (dbuf ? file_count(dbuf->file) : -1)); + } mutex_unlock(&inst->persistbufs.lock); mutex_lock(&inst->outputbufs.lock); s_vpr_e(inst->sid, "dpb buffer list:\n"); - list_for_each_entry(buf, &inst->outputbufs.list, list) - s_vpr_e(inst->sid, "type: %d addr: %x size: %u\n", - buf->buffer_type, buf->smem.device_addr, - buf->smem.size); + list_for_each_entry(buf, &inst->outputbufs.list, list) { + dbuf = (struct dma_buf *)buf->smem.dma_buf; + s_vpr_e(inst->sid, "type: %d addr: %x size: %u inode: %lu ref: %ld\n", + buf->buffer_type, buf->smem.device_addr, buf->smem.size, + (dbuf ? file_inode(dbuf->file)->i_ino : -1), + (dbuf ? file_count(dbuf->file) : -1)); + } mutex_unlock(&inst->outputbufs.lock); } @@ -6499,34 +6509,43 @@ void print_vidc_buffer(u32 tag, const char *str, struct msm_vidc_inst *inst, struct msm_vidc_buffer *mbuf) { struct vb2_buffer *vb2 = NULL; + struct dma_buf *dbuf[2]; if (!(tag & msm_vidc_debug) || !inst || !mbuf) return; vb2 = &mbuf->vvb.vb2_buf; + dbuf[0] = (struct dma_buf *)mbuf->smem[0].dma_buf; + dbuf[1] = (struct dma_buf *)mbuf->smem[1].dma_buf; if (vb2->num_planes == 1) dprintk(tag, inst->sid, - "%s: %s: idx %2d fd %d off %d daddr %x size %d filled %d flags 0x%x ts %lld refcnt %d mflags 0x%x\n", + "%s: %s: idx %2d fd %d off %d daddr %x inode %lu ref %ld size %d filled %d flags 0x%x ts %lld refcnt %d mflags 0x%x\n", str, vb2->type == INPUT_MPLANE ? "OUTPUT" : "CAPTURE", vb2->index, vb2->planes[0].m.fd, vb2->planes[0].data_offset, mbuf->smem[0].device_addr, + (dbuf[0] ? file_inode(dbuf[0]->file)->i_ino : -1), + (dbuf[0] ? file_count(dbuf[0]->file) : -1), vb2->planes[0].length, vb2->planes[0].bytesused, mbuf->vvb.flags, mbuf->vvb.vb2_buf.timestamp, mbuf->smem[0].refcount, mbuf->flags); else dprintk(tag, inst->sid, - "%s: %s: idx %2d fd %d off %d daddr %x size %d filled %d flags 0x%x ts %lld refcnt %d mflags 0x%x, extradata: fd %d off %d daddr %x size %d filled %d refcnt %d\n", + "%s: %s: idx %2d fd %d off %d daddr %x inode %lu ref %ld size %d filled %d flags 0x%x ts %lld refcnt %d mflags 0x%x, extradata: fd %d off %d daddr %x inode %lu ref %ld size %d filled %d refcnt %d\n", str, vb2->type == INPUT_MPLANE ? "OUTPUT" : "CAPTURE", vb2->index, vb2->planes[0].m.fd, vb2->planes[0].data_offset, mbuf->smem[0].device_addr, + (dbuf[0] ? file_inode(dbuf[0]->file)->i_ino : -1), + (dbuf[0] ? file_count(dbuf[0]->file) : -1), vb2->planes[0].length, vb2->planes[0].bytesused, mbuf->vvb.flags, mbuf->vvb.vb2_buf.timestamp, mbuf->smem[0].refcount, mbuf->flags, vb2->planes[1].m.fd, vb2->planes[1].data_offset, - mbuf->smem[1].device_addr, vb2->planes[1].length, + mbuf->smem[1].device_addr, + (dbuf[1] ? file_inode(dbuf[1]->file)->i_ino : -1), + (dbuf[1] ? file_count(dbuf[1]->file) : -1), vb2->planes[1].length, vb2->planes[1].bytesused, mbuf->smem[1].refcount); }