@@ -5246,6 +5246,9 @@ int msm_vidc_flush_read_only_buffers(struct msm_vidc_inst *inst,
52465246 if (ro_buf -> attach && ro_buf -> dmabuf )
52475247 call_mem_op (core , dma_buf_detach , core ,
52485248 ro_buf -> dmabuf , ro_buf -> attach );
5249+ if (ro_buf -> kvaddr && ro_buf -> device_addr )
5250+ dma_free_attrs (& core -> pdev -> dev , ro_buf -> buffer_size ,
5251+ ro_buf -> kvaddr , ro_buf -> device_addr , ro_buf -> dma_attrs );
52495252 if (ro_buf -> dbuf_get )
52505253 call_mem_op (core , dma_buf_put , inst , ro_buf -> dmabuf );
52515254 ro_buf -> attach = NULL ;
@@ -5324,10 +5327,9 @@ void msm_vidc_destroy_buffers(struct msm_vidc_inst *inst)
53245327 buf -> attach , buf -> sg_table );
53255328 if (buf -> attach && buf -> dmabuf )
53265329 call_mem_op (core , dma_buf_detach , core , buf -> dmabuf , buf -> attach );
5327- if (buf -> kvaddr && buf -> device_addr && refcount_read (& buf -> refcount ) > 0 )
5328- i_vpr_e (inst ,
5329- "%s: destroy ro buffer with Non-Zero refcount %d, daddr 0x%llx\n" ,
5330- __func__ , refcount_read (& buf -> refcount ), buf -> device_addr );
5330+ if (buf -> kvaddr && buf -> device_addr )
5331+ dma_free_attrs (& core -> pdev -> dev , buf -> buffer_size ,
5332+ buf -> kvaddr , buf -> device_addr , buf -> dma_attrs );
53315333 if (buf -> dbuf_get )
53325334 call_mem_op (core , dma_buf_put , inst , buf -> dmabuf );
53335335 list_del_init (& buf -> list );
@@ -5345,10 +5347,10 @@ void msm_vidc_destroy_buffers(struct msm_vidc_inst *inst)
53455347 buf -> attach , buf -> sg_table );
53465348 if (buf -> attach && buf -> dmabuf )
53475349 call_mem_op (core , dma_buf_detach , core , buf -> dmabuf , buf -> attach );
5348- if (buf -> kvaddr && buf -> device_addr && refcount_read ( & buf -> refcount ) > 0 )
5349- i_vpr_e ( inst ,
5350- "%s: destroying ext buffer, refcount %d, daddr 0x%llx\n" ,
5351- __func__ , refcount_read ( & buf -> refcount ), buf -> device_addr );
5350+ if (buf -> kvaddr && buf -> device_addr )
5351+ dma_free_attrs ( & core -> pdev -> dev , buf -> buffer_size ,
5352+ buf -> kvaddr , buf -> device_addr , buf -> dma_attrs );
5353+
53525354 if (buf -> dbuf_get ) {
53535355 print_vidc_buffer (VIDC_ERR , "err " , "destroying: put dmabuf" ,
53545356 inst , buf );
0 commit comments