From: sashiko-bot@kernel.org
To: "James Zhu" <James.Zhu@amd.com>, amd-gfx@lists.freedesktop.org
Subject: Re: [RFC PATCH 3/3] drm/amdgpu: scope AMDGPU_VM_OP_RESERVE_VMID to the caller's partition
Date: Tue, 17 Nov 2026 17:18:21 +0000 [thread overview]
Message-ID: <sashiko-outbox-219223@kernel.org> (raw)
In-Reply-To: <20261117165952.3558762-4-James.Zhu@amd.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] drm/amdgpu: skipped wait in amdgpu_vm_fini() for partition SPM
VMID
- [Medium] drm/amdgpu: unchecked amdgpu_xcp_get_inst_details() in
amdgpu_vm_ioctl()
--
commit a5f43653ba23f302ebd963bef5053a4d46508cd1
Author: James Zhu <James.Zhu@amd.com>
drm/amdgpu: scope AMDGPU_VM_OP_RESERVE_VMID to the caller's partition
This commit scopes AMDGPU_VM_OP_RESERVE_VMID to the GFXHUB instances of
the caller's compute partition when fpriv->xcp_id is set.
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> index e1691145da903..8098fbb542c82 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> @@ -3021,11 +3021,21 @@ int amdgpu_vm_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
>
> switch (args->in.op) {
> case AMDGPU_VM_OP_RESERVE_VMID: {
> + uint32_t xcc_mask = adev->gfx.xcc_mask;
> int r;
>
> + /*
> + * Scope the reservation to the hardware partition behind the
> + * caller's render node, so other partitions can hold the
> + * reserved VMID on their own XCCs independently.
> + */
> + if (adev->xcp_mgr && fpriv->xcp_id != AMDGPU_XCP_NO_PARTITION)
> + amdgpu_xcp_get_inst_details(
> + &adev->xcp_mgr->xcp[fpriv->xcp_id],
> + AMDGPU_XCP_GFX, &xcc_mask);
[Severity: Medium]
Should the return value of amdgpu_xcp_get_inst_details() be checked here?
If a runtime compute partition switch reduces the number of partitions
while a DRM file opened on a higher-numbered partition remains open,
xcp[fpriv->xcp_id].valid becomes false and amdgpu_xcp_get_inst_details()
returns -EINVAL without updating xcc_mask. The reservation then silently
falls back to adev->gfx.xcc_mask and reserves the SPM VMID across every
GFXHUB on the device.
> +
> /* We only have requirement to reserve vmid from gfxhub */
> - r = amdgpu_vmid_alloc_spm_gfxhubs(adev, vm,
> - adev->gfx.xcc_mask);
> + r = amdgpu_vmid_alloc_spm_gfxhubs(adev, vm, xcc_mask);
[Severity: High]
When a process on a non-zero partition (fpriv->xcp_id > 0) closes its DRM
file without calling AMDGPU_VM_OP_UNRESERVE_VMID, does amdgpu_vm_fini()
skip waiting for in-flight jobs before unbinding and freeing the reserved
SPM VMID?
For fpriv->xcp_id > 0, xcc_mask only includes that partition's XCCs, so
vm->reserved_vmid[AMDGPU_GFXHUB(0)] stays NULL. Unlike
AMDGPU_VM_OP_UNRESERVE_VMID, amdgpu_vm_fini() only checks GFXHUB(0) before
waiting and then frees the SPM VMID on all hubs:
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:amdgpu_vm_fini() {
...
/* Wait for the jobs which might still use the reserved VMID */
if (vm->reserved_vmid[AMDGPU_GFXHUB(0)])
dma_resv_wait_timeout(root->tbo.base.resv, DMA_RESV_USAGE_READ,
false, MAX_SCHEDULE_TIMEOUT);
...
for (i = 0; i < AMDGPU_MAX_VMHUBS; i++) {
amdgpu_vmid_free_spm(adev, vm, i);
}
...
}
amdgpu_vmid_free_spm() then unbinds spm_vmid to address 0 and clears
id_mgr->reserved_vmid while GPU jobs on that partition are still running
under spm_vmid, causing in-flight work to page-fault and letting another
process rebind the VMID concurrently. Checking all GFXHUBs in
adev->gfx.xcc_mask in amdgpu_vm_fini(), matching
AMDGPU_VM_OP_UNRESERVE_VMID, would avoid this regression.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261117165952.3558762-1-James.Zhu@amd.com?part=3
next prev parent reply other threads:[~2026-11-17 17:18 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-17 16:59 [RFC PATCH 0/3] drm/amdgpu: make the reserved SPM VMID per-partition James Zhu
2026-11-17 16:59 ` [RFC PATCH 1/3] drm/amdgpu: expose the XCC-masked setup_vm_pt_regs as a gfxhub callback James Zhu
2026-11-18 9:36 ` Christian König
2026-11-17 16:59 ` [RFC PATCH 2/3] drm/amdgpu: reserve and bind the SPM VMID on every GFXHUB instance James Zhu
2026-11-17 17:21 ` sashiko-bot
2026-11-18 9:38 ` Christian König
2026-11-17 16:59 ` [RFC PATCH 3/3] drm/amdgpu: scope AMDGPU_VM_OP_RESERVE_VMID to the caller's partition James Zhu
2026-11-17 17:18 ` sashiko-bot [this message]
2026-11-17 18:19 ` [RFC PATCH v2 0/3] drm/amdgpu: make the reserved SPM VMID per-partition James Zhu
2026-11-17 18:19 ` [RFC PATCH v2 1/3] drm/amdgpu: expose the XCC-masked setup_vm_pt_regs as a gfxhub callback James Zhu
2026-11-17 18:19 ` [RFC PATCH v2 2/3] drm/amdgpu: reserve and bind the SPM VMID on every GFXHUB instance James Zhu
2026-11-17 18:47 ` sashiko-bot
2026-11-17 18:19 ` [RFC PATCH v2 3/3] drm/amdgpu: scope AMDGPU_VM_OP_RESERVE_VMID to the caller's partition James Zhu
2026-11-18 16:24 ` [RFC PATCH v3 0/3] drm/amdgpu: make the reserved SPM VMID per-partition James Zhu
2026-11-18 16:24 ` [RFC PATCH v3 1/3] drm/amdgpu: pass an XCC mask to the setup_vm_pt_regs gfxhub callback James Zhu
2026-11-18 16:24 ` [RFC PATCH v3 2/3] drm/amdgpu: reserve and bind the SPM VMID on every GFXHUB instance James Zhu
2026-11-18 16:24 ` [RFC PATCH v3 3/3] drm/amdgpu: scope AMDGPU_VM_OP_RESERVE_VMID to the caller's partition James Zhu
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-219223@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=James.Zhu@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