AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Alex Deucher" <alexander.deucher@amd.com>,
	amd-gfx@lists.freedesktop.org
Subject: Re: [PATCH 6/9] drm/amdgpu/userq/mes: implement set gang submit
Date: Tue, 17 Nov 2026 19:35:22 +0000	[thread overview]
Message-ID: <sashiko-outbox-219493@kernel.org> (raw)
In-Reply-To: <20261117192415.810117-6-alexander.deucher@amd.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] drm/amdgpu: out-of-bounds gang context address in
  mes_set_gang()
--

commit faefcb7998343e4f4e1ec3ab6ccf3f3feccc05e7
Author: Alex Deucher <alexander.deucher@amd.com>

drm/amdgpu/userq/mes: implement set gang submit

This commit adds the mes_set_gang() callback to userq_mes_funcs to
configure MES gang submission between a primary and secondary usermode
queue.

> diff --git a/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c b/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
> index 7abb9d95ef59a..e186ebd08b8d2 100644
> --- a/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
> +++ b/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
> @@ -649,6 +649,31 @@ static int mes_userq_restore(struct amdgpu_usermode_queue *queue)
>  	return r;
>  }
>  
> +static int mes_set_gang(struct amdgpu_usermode_queue *primary_queue,
> +			struct amdgpu_usermode_queue *secondary_queue)
> +{
> +	struct amdgpu_userq_obj *primary_ctx = &primary_queue->fw_obj;
> +	struct amdgpu_userq_obj *secondary_ctx = &secondary_queue->fw_obj;
> +	struct amdgpu_userq_mgr *uq_mgr = primary_queue->userq_mgr;
> +	struct amdgpu_device *adev = uq_mgr->adev;
> +	struct mes_set_gang_submit_input input;
> +	int r;
> +
> +	memset(&input, 0x0, sizeof(struct mes_set_gang_submit_input));
> +
> +	input.primary_gang_context_addr =
> +		primary_ctx->gpu_addr + AMDGPU_USERQ_PROC_CTX_SZ;
> +	input.secondary_gang_context_addr =
> +		secondary_ctx->gpu_addr + AMDGPU_USERQ_PROC_CTX_SZ;

[Severity: High]
Should primary_gang_context_addr and secondary_gang_context_addr be set
to primary_ctx->gpu_addr and secondary_ctx->gpu_addr without adding
AMDGPU_USERQ_PROC_CTX_SZ?

Since 97bcaf15ad25 ("drm/amdgpu: implement per-process MES context"),
the process context is allocated separately in uq_mgr->proc_ctx_obj, and
mes_userq_create_ctx_space() allocates queue->fw_obj with size
AMDGPU_USERQ_GANG_CTX_SZ (one page) for the gang context alone:

drivers/gpu/drm/amd/amdgpu/mes_userqueue.c:mes_userq_create_ctx_space() {
	...
	/* The FW expects at least one page space allocated for gang ctx. */
	size = AMDGPU_USERQ_GANG_CTX_SZ;
	r = amdgpu_bo_create_kernel(uq_mgr->adev, size, 0,
				    AMDGPU_GEM_DOMAIN_GTT,
				    &ctx->obj, &ctx->gpu_addr,
				    &ctx->cpu_ptr);
	...
}

Adding AMDGPU_USERQ_PROC_CTX_SZ points one page past the end of each
queue's fw_obj BO and does not match the gang_context_addr (ctx->gpu_addr)
passed to MES in mes_userq_map().

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261117192415.810117-1-alexander.deucher@amd.com?part=6

  reply	other threads:[~2026-11-17 19:35 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17 19:24 [PATCH 1/9] drm/amdgpu/mes11: add API for gang submit Alex Deucher
2026-11-17 19:24 ` [PATCH 2/9] drm/amdgpu/mes: add callback " Alex Deucher
2026-11-17 19:24 ` [PATCH 3/9] drm/amdgpu/mes11: add support for setting " Alex Deucher
2026-11-17 19:37   ` sashiko-bot
2026-11-17 19:24 ` [PATCH 4/9] drm/amdgpu/mes12: " Alex Deucher
2026-11-17 19:24 ` [PATCH 5/9] drm/amdgpu/userq: add callback for gang setup Alex Deucher
2026-11-17 19:24 ` [PATCH 6/9] drm/amdgpu/userq/mes: implement set gang submit Alex Deucher
2026-11-17 19:35   ` sashiko-bot [this message]
2026-11-17 19:24 ` [PATCH 7/9] drm/amdgpu/userq: add handling for set_gang Alex Deucher
2026-11-17 19:46   ` sashiko-bot
2026-11-17 19:24 ` [PATCH 8/9] drm/amdgpu: add UAPI to create user queue gangs Alex Deucher
2026-11-17 19:24 ` [PATCH 9/9] drm/amdgpu/userq: enable support for creating gangs Alex Deucher
2026-11-17 19:44   ` sashiko-bot

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=sashiko-outbox-219493@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --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