mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "CK Hu (胡俊光)" <ck.hu@mediatek.com>
To: AngeloGioacchino Del Regno
	<angelogioacchino.delregno@collabora.com>,
	"chunkuang.hu@kernel.org" <chunkuang.hu@kernel.org>
Cc: "tzimmermann@suse.de" <tzimmermann@suse.de>,
	"simona@ffwll.ch" <simona@ffwll.ch>,
	"javierm@redhat.com" <javierm@redhat.com>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	"airlied@gmail.com" <airlied@gmail.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"p.zabel@pengutronix.de" <p.zabel@pengutronix.de>,
	"matthias.bgg@gmail.com" <matthias.bgg@gmail.com>,
	"linux-mediatek@lists.infradead.org"
	<linux-mediatek@lists.infradead.org>,
	"kernel@collabora.com" <kernel@collabora.com>
Subject: Re: [PATCH] drm/mediatek: mtk_gem: Partial refactor and use drm_gem_dma_object
Date: Fri, 16 Jan 2026 07:19:17 +0000	[thread overview]
Message-ID: <46eccd39845cd516f243912981610d78f9b2d7a2.camel@mediatek.com> (raw)
In-Reply-To: <20251111085114.9752-1-angelogioacchino.delregno@collabora.com>

Hi, Angelo:

On Tue, 2025-11-11 at 09:51 +0100, AngeloGioacchino Del Regno wrote:
> External email : Please do not click links or open attachments until you have verified the sender or the content.
> 
> 
> Partially refactor mtk_gem to stop using (and remove) the unneeded
> custom mtk_gem_obj structure and migrate drivers to use the API
> defined drm_gem_dma_object structure instead, and to align all of
> the functions to be similar to the logic from drm_gem_dma_helper.
> 
> Unfortunately, for this driver it wasn't possible to directly use
> the drm_gem_dma_helper callbacks (apart from .print_info), as the
> DMA mapping here is done on specific dma devices instead of the
> main DRM device.
> 
> Also, since the mtk_gem_obj structure is no more, also migrate the
> mtk_plane.c code to grab the DMA address from a drm_gem_dma_object
> and replace the inclusion of the custom mtk_gem.h header (as it is
> now unneeded) with the DRM API provided drm_gem_dma_helper.
> 
> While at it, also set DRM_GEM_DMA_HELPER as an unconditional
> dependency (remove the `if DRM_FBDEV_EMULATION` from the select
> DRM_GEM_DMA_HELPER statement in Kconfig).
> 
> This resolves an issue pointed by UBSAN, as when using drm_fbdev_dma
> the drm_gem_object is supposed to be child of a drm_gem_dma_object
> instead of a custom mtk_gem_obj (or the mtk_gem_obj should have been
> reordered to have the same fields as drm_gem_dma_object, but that
> would have been too fragile and generally a bad idea anyway).
> 
> Fixes: 0992284b4fe4 ("drm/mediatek: Use fbdev-dma")
> Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> ---

[snip]

> -
>  int mtk_gem_dumb_create(struct drm_file *file_priv, struct drm_device *dev,
>                         struct drm_mode_create_dumb *args)
>  {
> -       struct mtk_gem_obj *mtk_gem;
> +       struct drm_gem_dma_object *dma_obj;
>         int ret;
> 
>         args->pitch = DIV_ROUND_UP(args->width * args->bpp, 8);
> @@ -134,25 +155,24 @@ int mtk_gem_dumb_create(struct drm_file *file_priv, struct drm_device *dev,
>         args->size = args->pitch;
>         args->size *= args->height;
> 
> -       mtk_gem = mtk_gem_create(dev, args->size, false);
> -       if (IS_ERR(mtk_gem))
> -               return PTR_ERR(mtk_gem);
> +       dma_obj = mtk_gem_create(dev, args->size);
> +       if (IS_ERR(dma_obj))
> +               return PTR_ERR(dma_obj);
> 
>         /*
>          * 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);
> +       ret = drm_gem_handle_create(file_priv, &dma_obj->base, &args->handle);
> +       /* drop reference from allocate - handle holds it now. */
> +       drm_gem_object_put(&dma_obj->base);

I've trce drm_gem_handle_create() and find it would call drm_gem_object_put() when error.
Please confirm this.
If so, I would modify this when I applied.

Regards,
CK

>         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_gem_free_object(&mtk_gem->base);
> +       mtk_gem_free_object(&dma_obj->base);
>         return ret;
>  }
> 


  reply	other threads:[~2026-01-16  7:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-11  8:51 AngeloGioacchino Del Regno
2026-01-16  7:19 ` CK Hu (胡俊光) [this message]
2026-01-18 23:51 ` Chun-Kuang Hu

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=46eccd39845cd516f243912981610d78f9b2d7a2.camel@mediatek.com \
    --to=ck.hu@mediatek.com \
    --cc=airlied@gmail.com \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=chunkuang.hu@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=javierm@redhat.com \
    --cc=kernel@collabora.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=matthias.bgg@gmail.com \
    --cc=p.zabel@pengutronix.de \
    --cc=simona@ffwll.ch \
    --cc=tzimmermann@suse.de \
    /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

all inboxes | Powered by JetHome®