dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Mukesh Ojha" <mukesh.ojha@oss.qualcomm.com>
Cc: dri-devel@lists.freedesktop.org, linux-sunxi@lists.linux.dev
Subject: Re: [PATCH v2 5/11] drm: malidp: Use devm_of_reserved_mem_device_init()
Date: Wed, 02 Sep 2026 20:35:49 +0000	[thread overview]
Message-ID: <20260902203550.304C21F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260902201640.2024648-6-mukesh.ojha@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Permanent CMA capacity leak due to clearing dev->cma_area before GEM objects are freed during device unbind.
--

commit a1f947cbe50ede0e9b650dcb9e31cc36cb85952d
Author: Mukesh Ojha <mukesh.ojha@oss.qualcomm.com>

drm: malidp: Use devm_of_reserved_mem_device_init()

This commit simplifies the driver by transitioning to the devres-managed
devm_of_reserved_mem_device_init(), removing manual cleanup calls during
bind failures and unbind.

> diff --git a/drivers/gpu/drm/arm/malidp_drv.c b/drivers/gpu/drm/arm/malidp_drv.c
> index 23fa942ae4bbe..3e17513c31147 100644
> --- a/drivers/gpu/drm/arm/malidp_drv.c
> +++ b/drivers/gpu/drm/arm/malidp_drv.c
> @@ -758,7 +758,7 @@ static int malidp_bind(struct device *dev)
>  		return PTR_ERR(hwdev->pxlclk);
>  
>  	/* Get the optional framebuffer memory resource */
> -	ret = of_reserved_mem_device_init(dev);
> +	ret = devm_of_reserved_mem_device_init(dev);

[Severity: High]
This isn't a bug introduced by this patch, but does this devres conversion
preserve a pre-existing CMA memory capacity leak during device unbind?

In malidp_bind(), devm_drm_dev_alloc() is called before this initialization
function. Because devres actions execute in reverse order of allocation, the
cleanup action registered here will execute before the drm_dev_put() action.

When malidp_unbind() returns, the component framework immediately releases
the component's devres group, clearing dev->cma_area. Later, when the DRM
device is freed (either immediately or when userspace eventually closes its
file descriptors), drm_gem_object_free() calls dma_free_contiguous().

Because dev->cma_area is already NULL at that point, it bypasses
cma_release() and falls back to the buddy allocator, permanently leaking
the CMA region's bitmap capacity.

The previous code suffered from this exact same ordering issue since the
manual of_reserved_mem_device_release() call happened before drm_dev_put()
ran. Is there a way to adjust the cleanup order so the CMA area outlives
the GEM objects?

>  	if (ret && ret != -ENODEV)
>  		return ret;
>  

[ ... ]
> @@ -913,7 +912,6 @@ static void malidp_unbind(struct device *dev)
>  	else
>  		malidp_runtime_pm_suspend(dev);
>  	dev_set_drvdata(dev, NULL);
> -	of_reserved_mem_device_release(dev);
>  }
>  
>  static const struct component_master_ops malidp_master_ops = {

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260902201640.2024648-1-mukesh.ojha@oss.qualcomm.com?part=5

  reply	other threads:[~2026-09-02 20:35 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-02 20:16 [PATCH v2 0/11] drm: Use devm_of_reserved_mem_device_init() Mukesh Ojha
2026-09-02 20:16 ` [PATCH v2 1/11] drm: logicvc: " Mukesh Ojha
2026-09-02 20:30   ` sashiko-bot
2026-09-02 20:16 ` [PATCH v2 2/11] drm: hdlcd: " Mukesh Ojha
2026-09-02 20:16 ` [PATCH v2 3/11] drm: pl111: " Mukesh Ojha
2026-09-02 20:33   ` sashiko-bot
2026-09-02 20:16 ` [PATCH v2 4/11] drm: komeda: " Mukesh Ojha
2026-09-02 20:16 ` [PATCH v2 5/11] drm: malidp: " Mukesh Ojha
2026-09-02 20:35   ` sashiko-bot [this message]
2026-09-02 20:16 ` [PATCH v2 6/11] drm: ingenic: " Mukesh Ojha
2026-09-02 20:27   ` sashiko-bot
2026-09-02 20:16 ` [PATCH v2 7/11] drm: kmb: " Mukesh Ojha
2026-09-02 20:31   ` sashiko-bot
2026-09-02 20:16 ` [PATCH v2 8/11] drm: sun4i: " Mukesh Ojha
2026-09-02 20:16 ` [PATCH v2 9/11] drm: xlnx: zynqmp_dpsub: " Mukesh Ojha
2026-09-02 20:31   ` sashiko-bot
2026-09-02 20:55   ` Laurent Pinchart
2026-09-02 20:16 ` [PATCH v2 10/11] drm: aspeed: " Mukesh Ojha
2026-09-02 20:35   ` sashiko-bot
2026-09-02 20:16 ` [PATCH v2 11/11] drm: arcpgu: " Mukesh Ojha

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=20260902203550.304C21F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-sunxi@lists.linux.dev \
    --cc=mukesh.ojha@oss.qualcomm.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /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