From b1da2a6cc13d66c03c364f7b72d5a343b3ccdb3c Mon Sep 17 00:00:00 2001 From: Taimuraz Kaitmazov Date: Thu, 20 Aug 2026 01:44:58 +0300 Subject: [PATCH] accel/amdxdna: do not fail a sync for a BO with no debug context amdxdna_drm_sync_bo_ioctl() calls amdxdna_hwctx_sync_debug_bo() for every 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. Fixes: 7ea046838021 ("accel/amdxdna: Support firmware debug buffer") Suggested-by: Lizhi Hou Signed-off-by: Taimuraz Kaitmazov Reviewed-by: Lizhi Hou Signed-off-by: Lizhi Hou Link: https://patch.msgid.link/20260819224458.257346-6-taimuraz@kaitmazov.com --- 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 96f8bd46f079..f4832337ec31 100644 --- a/drivers/accel/amdxdna/amdxdna_gem.c +++ b/drivers/accel/amdxdna/amdxdna_gem.c @@ -1511,7 +1511,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: