<html><body><p>
<pre>
Hi Maxime,

On Fri, 2024-06-21 at 11:00 +0200, mripard@kernel.org wrote:
> Hi,
>
> On Tue, Jun 11, 2024 at 09:13:03AM GMT, Jason-JH Lin (林睿祥) wrote:
> > Hi Maxime,
> >

[snip]

> > I have changed user space to use DMA_HEAP_IOCTL_ALLOC to allocate
> > secure buffer, but I still encounter the problem of determining
> > whether
> > the buffer is secure in mediatek-drm driver to add some secure
> > configure for hardware.
> >
> >
> > As the comment in [1], dma driver won't provide API for use.
> > [1]:
> >
https://patchwork.kernel.org/project/linux-mediatek/patch/20240515112308.10171-3-yong.wu@mediatek.com/#25857255
> >
> >
> > So I use name checking at [PATCH v6 3/7] like this currently:
> >
> > struct drm_gem_object *mtk_gem_prime_import_sg_table(struct
> > drm_device
> > *dev,
> > struct dma_buf_attachment *attach, struct sg_table *sg)
> > {
> > struct mtk_gem_obj *mtk_gem;
> >
> > /* check if the entries in the sg_table are contiguous */
> > if (drm_prime_get_contiguous_size(sg) < attach->dmabuf->size) {
> > DRM_ERROR("sg_table is not contiguous");
> > return ERR_PTR(-EINVAL);
> > }
> >
> > mtk_gem = mtk_gem_init(dev, attach->dmabuf->size);
> > if (IS_ERR(mtk_gem))
> > return ERR_CAST(mtk_gem);
> >
> > + mtk_gem->secure = (!strncmp(attach->dmabuf->exp_name,
> > "restricted",
> > 10));
> > mtk_gem->dma_addr = sg_dma_address(sg->sgl);
> > + mtk_gem->size = attach->dmabuf->size;
> > mtk_gem->sg = sg;
> >
> > return &mtk_gem->base;
> > }
> >
> > But I want to change this name checking to the information brought
> > from
> > user space.
> > I tried to use arg->flags to append the secure flag in user space
> > and
> > call drmPrimeHandleToFD() to pass it to DRM driver, but it will be
> > blocked by at the beginning of the drm_prime_handle_to_fd_ioctl().
>
> I agree with you, it's something to discuss mostly with the dma-buf
> maintainers but it would be better to just set a flag on the dma-buf,
> and use that flag whenever necessary.
>
> It might be related to the recent work I did to introduce allocation
> flags too:
>
https://lore.kernel.org/linux-media/20240515-dma-buf-ecc-heap-v1-0-54cbbd049511@kernel.org/
>

Thanks for your information!
I'll discuss with dma-buf maintainer in series [1].

Regards,
Jason-JH Lin

> Maxime

</pre>
</p></body></html><!--type:text--><!--{--><pre>************* MEDIATEK Confidentiality Notice ********************
The information contained in this e-mail message (including any 
attachments) may be confidential, proprietary, privileged, or otherwise
exempt from disclosure under applicable laws. It is intended to be 
conveyed only to the designated recipient(s). Any use, dissemination, 
distribution, printing, retaining or copying of this e-mail (including its 
attachments) by unintended recipient(s) is strictly prohibited and may 
be unlawful. If you are not an intended recipient of this e-mail, or believe 
that you have received this e-mail in error, please notify the sender 
immediately (by replying to this e-mail), delete any and all copies of 
this e-mail (including any attachments) from your system, and do not
disclose the content of this e-mail to any other person. Thank you!
</pre><!--}-->