All of 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, media-ci@linuxtv.org
Subject: Re: [PATCH 2/8] drm/msm/adreno: migrate zap shader loading to qcom_mdt_pas_load() and qcom_pas_prepare_and_auth_reset()
Date: Sat, 26 Sep 2026 15:59:36 +0000	[thread overview]
Message-ID: <20260926155936.8DE5D1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260925155737.4161358-3-mukesh.ojha@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] drm/msm/adreno: memory leak of PAS metadata buffer
- [High] drm/msm/adreno: shmbridge preparation step silently skipped
- [Medium] drm/msm/adreno: struct qcom_pas_context leaked via devres on post-probe retries
--

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

drm/msm/adreno: migrate zap shader loading to qcom_mdt_pas_load() and qcom_pas_prepare_and_auth_reset()

This commit replaces the open-coded memremap/mdt_load sequence for zap shader
loading with devm_qcom_pas_context_alloc and qcom_mdt_pas_load. It then passes
the context to qcom_pas_prepare_and_auth_reset to ensure the shmbridge
preparation step is executed before TrustZone authentication.

> diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
> --- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c
> +++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c

[ ... ]

> @@ -122,9 +122,9 @@ static int zap_shader_load_mdt(struct msm_gpu *gpu, const char *fwname,
>  	}
>  
>  	/* Allocate memory for the firmware image */
> -	mem_region = memremap(mem_phys, mem_size,  MEMREMAP_WC);
> -	if (!mem_region) {
> -		ret = -ENOMEM;
> +	ctx = devm_qcom_pas_context_alloc(dev, pasid, mem_phys, resource_size(&r));
> +	if (IS_ERR(ctx)) {
> +		ret = PTR_ERR(ctx);

[Severity: High]
Is the shmbridge preparation step actually skipped here?

The commit message mentions fixing the omission of the shmbridge prepare step.
However, devm_qcom_pas_context_alloc() uses devm_kzalloc() which zeroes the
context, and ctx->use_tzmem is never explicitly set to true in
zap_shader_load_mdt().

Because of this, it looks like qcom_pas_prepare_and_auth_reset() will hit
the early return (if (!ctx->use_tzmem)) downstream and bypass the shmbridge
creation entirely, leaving the behaviour unchanged.

[Severity: Medium]
Can this devm allocation cause an accumulating memory leak during post-probe 
retries?

Since devm_qcom_pas_context_alloc() ties the allocation to the device
lifetime, if zap_shader_load_mdt() fails and is called multiple times during
runtime PM resume or GPU recovery sequences, the context allocations might
accumulate without being freed since the device remains bound.

>  		goto out;
>  	}
>  

[ ... ]

> @@ -165,9 +163,6 @@ static int zap_shader_load_mdt(struct msm_gpu *gpu, const char *fwname,
>  		DRM_DEV_ERROR(dev, "Unable to authorize the image\n");
>  
>  out:
> -	if (mem_region)
> -		memunmap(mem_region);
> -
>  	release_firmware(fw);
>  
>  	return ret;

[Severity: High]
Does this exit path leak the PAS metadata buffer?

When qcom_mdt_pas_load() executes, it internally calls qcom_pas_init_image(),
which allocates a metadata buffer and stores it in ctx->ptr. Unlike the
previous flow with a NULL context where the buffer was immediately freed
internally, a valid context tracks it so the caller can free it.

Should there be a call to qcom_pas_metadata_release(ctx) in this exit path
to prevent leaking this physical memory on every execution?

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

  reply	other threads:[~2026-09-26 15:59 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-25 15:57 [PATCH 0/8] Migrate PAS clients to qcom_mdt_pas_load() and qcom_pas_prepare_and_auth_reset() Mukesh Ojha
2026-09-25 15:57 ` [PATCH 1/8] remoteproc: qcom_wcnss: migrate " Mukesh Ojha
2026-09-26 15:59   ` sashiko-bot
2026-09-25 15:57 ` [PATCH 2/8] drm/msm/adreno: migrate zap shader loading " Mukesh Ojha
2026-09-26 15:59   ` sashiko-bot [this message]
2026-09-25 15:57 ` [PATCH 3/8] media: iris: migrate firmware " Mukesh Ojha
2026-09-26 15:59   ` sashiko-bot
2026-09-25 15:57 ` [PATCH 4/8] media: venus: " Mukesh Ojha
2026-09-26 15:59   ` sashiko-bot
2026-09-25 15:57 ` [PATCH 5/8] net: ipa: " Mukesh Ojha
2026-09-26 15:59   ` sashiko-bot
2026-09-25 15:57 ` [PATCH 6/8] wifi: ath12k: " Mukesh Ojha
2026-09-26 15:59   ` sashiko-bot
2026-09-25 15:57 ` [PATCH 7/8] soc: qcom: mdt_loader: remove qcom_mdt_load() Mukesh Ojha
2026-09-26 15:59   ` sashiko-bot
2026-09-25 15:57 ` [PATCH 8/8] firmware: qcom: pas: remove qcom_pas_auth_and_reset() 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=20260926155936.8DE5D1F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=media-ci@linuxtv.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.