[PATCH v6,12/24] media: mediatek: vcodec: add interface to allocate/free secure memory

Yong Wu (吴勇) Yong.Wu at mediatek.com
Sun Jun 16 23:53:07 PDT 2024


On Wed, 2024-06-12 at 14:22 +0900, Tomasz Figa wrote:
>  	 
> External email : Please do not click links or open attachments until
> you have verified the sender or the content.
>  On Thu, May 16, 2024 at 08:20:50PM +0800, Yunfei Dong wrote:
> > Need to call dma heap interface to allocate/free secure memory when
> playing
> > secure video.
> > 
> > Signed-off-by: Yunfei Dong <yunfei.dong at mediatek.com>
> > ---
> >  .../media/platform/mediatek/vcodec/Kconfig    |   1 +
> >  .../mediatek/vcodec/common/mtk_vcodec_util.c  | 122
> +++++++++++++++++-
> >  .../mediatek/vcodec/common/mtk_vcodec_util.h  |   3 +
> >  3 files changed, 123 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/media/platform/mediatek/vcodec/Kconfig
> b/drivers/media/platform/mediatek/vcodec/Kconfig
> > index bc8292232530..707865703e61 100644
> > --- a/drivers/media/platform/mediatek/vcodec/Kconfig
> > +++ b/drivers/media/platform/mediatek/vcodec/Kconfig
> > @@ -17,6 +17,7 @@ config VIDEO_MEDIATEK_VCODEC

[snip]
  
> > -void mtk_vcodec_mem_free(void *priv, struct mtk_vcodec_mem *mem)
> > +static int mtk_vcodec_mem_alloc_sec(struct mtk_vcodec_dec_ctx
> *ctx, struct mtk_vcodec_mem *mem)
> > +{
> > +struct device *dev = &ctx->dev->plat_dev->dev;
> > +struct dma_buf *dma_buffer;
> > +struct dma_heap *vdec_heap;
> > +struct dma_buf_attachment *attach;
> > +struct sg_table *sgt;
> > +unsigned long size = mem->size;
> > +int ret = 0;
> > +
> > +if (!size)
> > +return -EINVAL;
> > +
> > +vdec_heap = dma_heap_find("restricted_mtk_cma");
> > +if (!vdec_heap) {
> > +mtk_v4l2_vdec_err(ctx, "dma heap find failed!");
> > +return -EPERM;
> > +}
> 
> How is the heap name determined here? My recollection is that the
> heap
> name comes from the heap node in the DT, so it may vary depending on
> the
> board.
> 
> Is the heap name documented anywhere in the DT bindings?
> 
> Shouldn't we rather query DT for a phandle to the right heap?
> 

Hi Tomasz,

This heap name does not come from dt-binding. It is hard-coded in the
driver[1]. Because the heap driver is a pure SW driver, there is no
corresponding HW unit, and there is no way to add a dtsi node.

[1] 
https://lore.kernel.org/linux-mediatek/20240515112308.10171-10-yong.wu@mediatek.com/

Thanks.


More information about the linux-arm-kernel mailing list