From: "CK Hu (胡俊光)" <ck.hu@mediatek.com>
To: "matthias.bgg@gmail.com" <matthias.bgg@gmail.com>,
"Jason-JH Lin (林睿祥)" <Jason-JH.Lin@mediatek.com>,
"chunkuang.hu@kernel.org" <chunkuang.hu@kernel.org>,
"conor+dt@kernel.org" <conor+dt@kernel.org>,
"robh+dt@kernel.org" <robh+dt@kernel.org>,
"krzysztof.kozlowski+dt@linaro.org"
<krzysztof.kozlowski+dt@linaro.org>,
"angelogioacchino.delregno@collabora.com"
<angelogioacchino.delregno@collabora.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-mediatek@lists.infradead.org"
<linux-mediatek@lists.infradead.org>,
"Singo Chang (張興國)" <Singo.Chang@mediatek.com>,
"Johnson Wang (王聖鑫)" <Johnson.Wang@mediatek.com>,
"linaro-mm-sig@lists.linaro.org" <linaro-mm-sig@lists.linaro.org>,
"linux-media@vger.kernel.org" <linux-media@vger.kernel.org>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
"Jason-ch Chen (陳建豪)" <Jason-ch.Chen@mediatek.com>,
"drinkcat@chromium.org" <drinkcat@chromium.org>,
"Shawn Sung (宋孝謙)" <Shawn.Sung@mediatek.com>,
"Nancy Lin (林欣螢)" <Nancy.Lin@mediatek.com>,
"p.zabel@pengutronix.de" <p.zabel@pengutronix.de>,
"jkardatzke@google.com" <jkardatzke@google.com>,
"dri-devel@lists.freedesktop.org"
<dri-devel@lists.freedesktop.org>,
Project_Global_Chrome_Upstream_Group
<Project_Global_Chrome_Upstream_Group@mediatek.com>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH v3 01/11] drm/mediatek: Add interface to allocate MediaTek GEM buffer.
Date: Mon, 25 Dec 2023 09:05:33 +0000 [thread overview]
Message-ID: <4169f943f6e82da50243d91614ab73d6b5f57c8a.camel@mediatek.com> (raw)
In-Reply-To: <20231223182932.27683-2-jason-jh.lin@mediatek.com>
Hi, Jason:
On Sun, 2023-12-24 at 02:29 +0800, Jason-JH.Lin wrote:
> From: CK Hu <ck.hu@mediatek.com>
>
> Add an interface to allocate MediaTek GEM buffers, allow the IOCTLs
> to be used by render nodes.
> This patch also sets the RENDER driver feature.
>
> Signed-off-by: CK Hu <ck.hu@mediatek.com>
> Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
> Signed-off-by: Jason-JH.Lin <jason-jh.lin@mediatek.com>
> Reviewed-by: Daniel Kurtz <djkurtz@chromium.org>
> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
> Tested-by: Daniel Kurtz <djkurtz@chromium.org>
> Tested-by: Pi-Hsun Shih <pihsun@chromium.org>
> ---
> drivers/gpu/drm/mediatek/mtk_drm_drv.c | 13 ++++++
> drivers/gpu/drm/mediatek/mtk_drm_gem.c | 39 +++++++++++++++++
> drivers/gpu/drm/mediatek/mtk_drm_gem.h | 12 ++++++
> include/uapi/drm/mediatek_drm.h | 58
> ++++++++++++++++++++++++++
> 4 files changed, 122 insertions(+)
> create mode 100644 include/uapi/drm/mediatek_drm.h
>
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> index 2b0c35cacbc6..5d2a39e491aa 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> @@ -24,6 +24,7 @@
> #include <drm/drm_of.h>
> #include <drm/drm_probe_helper.h>
> #include <drm/drm_vblank.h>
> +#include <drm/mediatek_drm.h>
>
> #include "mtk_drm_crtc.h"
> #include "mtk_drm_ddp_comp.h"
> @@ -569,6 +570,14 @@ static void mtk_drm_kms_deinit(struct drm_device
> *drm)
> component_unbind_all(drm->dev, drm);
> }
>
> +static const struct drm_ioctl_desc mtk_ioctls[] = {
> + DRM_IOCTL_DEF_DRV(MTK_GEM_CREATE, mtk_gem_create_ioctl,
> + DRM_UNLOCKED | DRM_AUTH | DRM_RENDER_ALLOW),
> + DRM_IOCTL_DEF_DRV(MTK_GEM_MAP_OFFSET,
> + mtk_gem_map_offset_ioctl,
> + DRM_UNLOCKED | DRM_AUTH | DRM_RENDER_ALLOW),
For secure buffer, we don't need map offset function. If you really
need this function, separate this to another patch and describe why
need this.
Regards,
CK
> +};
> +
> DEFINE_DRM_GEM_FOPS(mtk_drm_fops);
>
> /*
> @@ -590,6 +599,10 @@ static const struct drm_driver mtk_drm_driver =
> {
>
> .gem_prime_import = mtk_drm_gem_prime_import,
> .gem_prime_import_sg_table = mtk_gem_prime_import_sg_table,
> +
> + .ioctls = mtk_ioctls,
> + .num_ioctls = ARRAY_SIZE(mtk_ioctls),
> +
> .fops = &mtk_drm_fops,
>
> .name = DRIVER_NAME,
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_gem.c
> b/drivers/gpu/drm/mediatek/mtk_drm_gem.c
> index 4f2e3feabc0f..30e347adcbe9 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_gem.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_gem.c
> @@ -4,6 +4,7 @@
> */
>
> #include <linux/dma-buf.h>
> +#include <drm/mediatek_drm.h>
>
> #include <drm/drm.h>
> #include <drm/drm_device.h>
> @@ -283,3 +284,41 @@ void mtk_drm_gem_prime_vunmap(struct
> drm_gem_object *obj,
> mtk_gem->kvaddr = NULL;
> kfree(mtk_gem->pages);
> }
> +
> +int mtk_gem_map_offset_ioctl(struct drm_device *drm, void *data,
> + struct drm_file *file_priv)
> +{
> + struct drm_mtk_gem_map_off *args = data;
> +
> + return drm_gem_dumb_map_offset(file_priv, drm, args->handle,
> + &args->offset);
> +}
> +
> +int mtk_gem_create_ioctl(struct drm_device *dev, void *data,
> + struct drm_file *file_priv)
> +{
> + struct mtk_drm_gem_obj *mtk_gem;
> + struct drm_mtk_gem_create *args = data;
> + int ret;
> +
> + mtk_gem = mtk_drm_gem_create(dev, args->size, false);
> + if (IS_ERR(mtk_gem))
> + return PTR_ERR(mtk_gem);
> +
> + /*
> + * allocate a id of idr table where the obj is registered
> + * and handle has the id what user can see.
> + */
> + ret = drm_gem_handle_create(file_priv, &mtk_gem->base, &args-
> >handle);
> + if (ret)
> + goto err_handle_create;
> +
> + /* drop reference from allocate - handle holds it now. */
> + drm_gem_object_put(&mtk_gem->base);
> +
> + return 0;
> +
> +err_handle_create:
> + mtk_drm_gem_free_object(&mtk_gem->base);
> + return ret;
> +}
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_gem.h
> b/drivers/gpu/drm/mediatek/mtk_drm_gem.h
> index 78f23b07a02e..90f3d2916ec5 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_gem.h
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_gem.h
> @@ -46,4 +46,16 @@ int mtk_drm_gem_prime_vmap(struct drm_gem_object
> *obj, struct iosys_map *map);
> void mtk_drm_gem_prime_vunmap(struct drm_gem_object *obj,
> struct iosys_map *map);
>
> +/*
> + * request gem object creation and buffer allocation as the size
> + * that it is calculated with framebuffer information such as width,
> + * height and bpp.
> + */
> +int mtk_gem_create_ioctl(struct drm_device *dev, void *data,
> + struct drm_file *file_priv);
> +
> +/* get buffer offset to map to user space. */
> +int mtk_gem_map_offset_ioctl(struct drm_device *dev, void *data,
> + struct drm_file *file_priv);
> +
> #endif
> diff --git a/include/uapi/drm/mediatek_drm.h
> b/include/uapi/drm/mediatek_drm.h
> new file mode 100644
> index 000000000000..f4d47577c94e
> --- /dev/null
> +++ b/include/uapi/drm/mediatek_drm.h
> @@ -0,0 +1,58 @@
> +/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
> +/*
> + * Copyright (c) 2015 MediaTek Inc.
> + *
> + * This program is free software; you can redistribute it and/or
> modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + */
> +
> +#ifndef _UAPI_MEDIATEK_DRM_H
> +#define _UAPI_MEDIATEK_DRM_H
> +
> +#include <drm/drm.h>
> +
> +/**
> + * struct drm_mtk_gem_create - User-desired buffer creation
> information structure.
> + *
> + * @size: user-desired memory allocation size.
> + * - this size value would be page-aligned internally.
> + * @flags: user request for setting memory type or cache attributes.
> + * @handle: returned a handle to created gem object.
> + * - this handle will be set by gem module of kernel side.
> + */
> +struct drm_mtk_gem_create {
> + uint64_t size;
> + uint32_t flags;
> + uint32_t handle;
> +};
> +
> +/**
> + * struct drm_mtk_gem_map_off - A structure for getting buffer
> offset.
> + *
> + * @handle: a pointer to gem object created.
> + * @pad: just padding to be 64-bit aligned.
> + * @offset: relatived offset value of the memory region allocated.
> + * - this value should be set by user.
> + */
> +struct drm_mtk_gem_map_off {
> + uint32_t handle;
> + uint32_t pad;
> + uint64_t offset;
> +};
> +
> +#define DRM_MTK_GEM_CREATE 0x00
> +#define DRM_MTK_GEM_MAP_OFFSET 0x01
> +
> +#define DRM_IOCTL_MTK_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + \
> + DRM_MTK_GEM_CREATE, struct drm_mtk_gem_create)
> +
> +#define DRM_IOCTL_MTK_GEM_MAP_OFFSET DRM_IOWR(DRM_COMMAND_BASE + \
> + DRM_MTK_GEM_MAP_OFFSET, struct drm_mtk_gem_map_off)
> +
> +#endif /* _UAPI_MEDIATEK_DRM_H */
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2023-12-25 9:07 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-23 18:29 [PATCH v3 00/11] Add mediate-drm secure flow for SVP Jason-JH.Lin
2023-12-23 18:29 ` [PATCH v3 01/11] drm/mediatek: Add interface to allocate MediaTek GEM buffer Jason-JH.Lin
2023-12-25 9:05 ` CK Hu (胡俊光) [this message]
2023-12-27 3:18 ` Jason-JH Lin (林睿祥)
2023-12-23 18:29 ` [PATCH v3 02/11] drm/mediatek/uapi: Add DRM_MTK_GEM_CREATE_ENCRYPTED flag Jason-JH.Lin
2023-12-23 18:29 ` [PATCH v3 03/11] drm/mediatek: Add secure buffer control flow to mtk_drm_gem Jason-JH.Lin
2024-01-12 13:13 ` Daniel Vetter
2024-02-05 20:21 ` Jeffrey Kardatzke
2023-12-23 18:29 ` [PATCH v3 04/11] drm/mediatek: Add secure identify flag and funcution to mtk_drm_plane Jason-JH.Lin
2023-12-23 18:29 ` [PATCH v3 05/11] drm/mediatek: Add mtk_ddp_sec_write to config secure buffer info Jason-JH.Lin
2023-12-23 18:29 ` [PATCH v3 06/11] drm/mediatek: Add get_sec_port interface to mtk_ddp_comp Jason-JH.Lin
2023-12-26 5:24 ` CK Hu (胡俊光)
2023-12-27 3:19 ` Jason-JH Lin (林睿祥)
2023-12-23 18:29 ` [PATCH v3 07/11] drm/mediatek: Add secure layer config support for ovl Jason-JH.Lin
2023-12-26 5:14 ` CK Hu (胡俊光)
2023-12-27 7:16 ` Jason-JH Lin (林睿祥)
2024-01-12 3:41 ` Jason-JH Lin (林睿祥)
2023-12-23 18:29 ` [PATCH v3 08/11] drm/mediatek: Add secure layer config support for ovl_adaptor Jason-JH.Lin
2023-12-26 3:20 ` CK Hu (胡俊光)
2023-12-27 3:35 ` Jason-JH Lin (林睿祥)
2023-12-23 18:29 ` [PATCH v3 09/11] drm/mediatek: Add secure flow support to mediatek-drm Jason-JH.Lin
2023-12-26 5:43 ` CK Hu (胡俊光)
2023-12-27 7:05 ` Jason-JH Lin (林睿祥)
2023-12-23 18:29 ` [PATCH v3 10/11] drm/mediatek: Add cmdq_insert_backup_cookie before secure pkt finalize Jason-JH.Lin
2023-12-23 18:29 ` [PATCH v3 11/11] arm64: dts: mt8195: Add secure mbox settings for vdosys Jason-JH.Lin
2023-12-28 6:27 ` [PATCH v3 00/11] Add mediate-drm secure flow for SVP CK Hu (胡俊光)
2024-01-03 6:41 ` Jason-JH Lin (林睿祥)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4169f943f6e82da50243d91614ab73d6b5f57c8a.camel@mediatek.com \
--to=ck.hu@mediatek.com \
--cc=Jason-JH.Lin@mediatek.com \
--cc=Jason-ch.Chen@mediatek.com \
--cc=Johnson.Wang@mediatek.com \
--cc=Nancy.Lin@mediatek.com \
--cc=Project_Global_Chrome_Upstream_Group@mediatek.com \
--cc=Shawn.Sung@mediatek.com \
--cc=Singo.Chang@mediatek.com \
--cc=angelogioacchino.delregno@collabora.com \
--cc=chunkuang.hu@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=drinkcat@chromium.org \
--cc=jkardatzke@google.com \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=p.zabel@pengutronix.de \
--cc=robh+dt@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).