Re: [PATCH v5 5/5] accel/amdxdna: do not fail a sync for a BO with no debug context
From: Lizhi Hou
Date: Thu Sep 17 2026 - 16:25:50 EST
Applied to drm-misc-next
On 9/17/26 09:11, Lizhi Hou wrote:
On 8/19/26 15:44, Taimuraz Kaitmazov wrote:
amdxdna_drm_sync_bo_ioctl() calls amdxdna_hwctx_sync_debug_bo() for everyReviewed-by: Lizhi Hou <lizhi.hou@xxxxxxx>
FROM_DEVICE sync, which answers -EINVAL when the BO's assigned_hwctx names
no context. Only a BO attached with ATTACH_DEBUG_BO is ever given one, so
an ordinary read-back sync reports failure after its flush has already run.
Ask for the debug sync only when the BO has a context. An unattached BO
carries AMDXDNA_INVALID_CTX_HANDLE and hwctx ids are allocated above it, so
the test is exact, -EINVAL keeps meaning that the named context is gone,
and the handle is not resolved twice. The field is written under dev_lock
and read here without it; the context is still resolved under that lock, so
a racing attach only decides whether this sync sees the buffer.
Suggested-by: Lizhi Hou <lizhi.hou@xxxxxxx>
Signed-off-by: Taimuraz Kaitmazov <taimuraz@xxxxxxxxxxxxx>
---
drivers/accel/amdxdna/amdxdna_gem.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/accel/amdxdna/amdxdna_gem.c b/drivers/accel/amdxdna/amdxdna_gem.c
index 4be5298d1062..2613c94dd842 100644
--- a/drivers/accel/amdxdna/amdxdna_gem.c
+++ b/drivers/accel/amdxdna/amdxdna_gem.c
@@ -1319,7 +1319,8 @@ int amdxdna_drm_sync_bo_ioctl(struct drm_device *dev,
XDNA_DBG(xdna, "Sync bo %d offset 0x%llx, size 0x%llx\n",
args->handle, args->offset, args->size);
- if (args->direction == SYNC_DIRECT_FROM_DEVICE)
+ if (abo->assigned_hwctx != AMDXDNA_INVALID_CTX_HANDLE &&
+ args->direction == SYNC_DIRECT_FROM_DEVICE)
ret = amdxdna_hwctx_sync_debug_bo(client, args->handle);
put_obj: