From: David Rosca <david.rosca@amd.com>
To: <amd-gfx@lists.freedesktop.org>
Cc: David Rosca <david.rosca@amd.com>
Subject: [PATCH 2/4] drm/amdgpu: Allow multiple VCE create commands with same handle
Date: Fri, 9 Oct 2026 17:02:33 +0200 [thread overview]
Message-ID: <20261009150233.90598-4-david.rosca@amd.com> (raw)
In-Reply-To: <20261009150233.90598-2-david.rosca@amd.com>
As long as it is done by the process that owns the session, additional
create commands should be allowed.
This is needed for Vulkan to reset existing session.
The image size is now staged locally and only committed when the IB
parses successfully, so a failed create can't change the size of
a live session.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: David Rosca <david.rosca@amd.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c | 28 ++++++++++++++-----------
1 file changed, 16 insertions(+), 12 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c
index 39d87f3df9e0..07c4434c4948 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c
@@ -788,6 +788,7 @@ int amdgpu_vce_ring_parse_cs(struct amdgpu_cs_parser *p,
{
unsigned int fb_idx = 0, bs_idx = 0;
int session_idx = -1;
+ uint32_t img_size[AMDGPU_MAX_VCE_HANDLES];
uint32_t destroyed = 0;
uint32_t created = 0;
uint32_t allocated = 0;
@@ -878,7 +879,15 @@ int amdgpu_vce_ring_parse_cs(struct amdgpu_cs_parser *p,
r = session_idx;
goto out;
}
- size = &p->adev->vce.img_size[session_idx];
+ /*
+ * Stage the image size locally and only commit it once
+ * the whole IB is valid, otherwise a failed create
+ * could change the size of a live session.
+ */
+ if (!(created & (1 << session_idx)))
+ img_size[session_idx] =
+ p->adev->vce.img_size[session_idx];
+ size = &img_size[session_idx];
break;
case 0x00000002: /* task info */
@@ -891,11 +900,6 @@ int amdgpu_vce_ring_parse_cs(struct amdgpu_cs_parser *p,
if (destroyed & (1 << session_idx)) {
destroyed &= ~(1 << session_idx);
allocated |= 1 << session_idx;
-
- } else if (!(allocated & (1 << session_idx))) {
- DRM_ERROR("Handle already in use!\n");
- r = -EINVAL;
- goto out;
}
uint32_t width, height;
@@ -1010,7 +1014,12 @@ int amdgpu_vce_ring_parse_cs(struct amdgpu_cs_parser *p,
out:
if (!r) {
- /* No error, free all destroyed handle slots */
+ /* No error, commit the image size of created sessions */
+ for (i = 0; i < AMDGPU_MAX_VCE_HANDLES; ++i)
+ if (created & (1 << i))
+ p->adev->vce.img_size[i] = img_size[i];
+
+ /* and free all destroyed handle slots */
tmp = destroyed;
} else {
/* Error during parsing, free all allocated handle slots */
@@ -1068,11 +1077,6 @@ int amdgpu_vce_ring_parse_cs_vm(struct amdgpu_cs_parser *p,
if (destroyed & (1 << session_idx)) {
destroyed &= ~(1 << session_idx);
allocated |= 1 << session_idx;
-
- } else if (!(allocated & (1 << session_idx))) {
- DRM_ERROR("Handle already in use!\n");
- r = -EINVAL;
- goto out;
}
break;
--
2.43.0
next prev parent reply other threads:[~2026-10-09 15:05 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-09 15:02 [PATCH 1/4] drm/amdgpu: Use feedback buffer for VCE destroy message David Rosca
2026-10-09 15:02 ` David Rosca [this message]
2026-10-09 15:02 ` [PATCH 3/4] drm/amdgpu: Fix VCE buffer size check for DPB and input surface David Rosca
2026-10-09 15:02 ` [PATCH 4/4] drm/amdgpu: Allow VCE SEI command in IB David Rosca
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=20261009150233.90598-4-david.rosca@amd.com \
--to=david.rosca@amd.com \
--cc=amd-gfx@lists.freedesktop.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 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.