On 8/17/26 16:07, Taimuraz Kaitmazov wrote:
SYNC_BO clflushes an imported BO's scatterlist. An importer may not do that: the memory belongs to the exporter, and dma-buf gives the importer no interface to ask for maintenance on it. Refuse the request instead.
is_import_bo() is (obj)->attach, which covers more than foreign buffers. A userptr BO arrives through a ubuf, and on a carveout device every share BO and the device heap arrive through a cbuf, so SYNC_BO answers -EOPNOTSUPP for those too, including the AMDXDNA_BO_DEV path that flushes through its heap.
Only the ubuf case gives up maintenance it was getting: on a 64 MiB userptr BO a 4 KiB sync and a full sync both cost 659 us, this arm having ignored the range. amdxdna_cbuf_map() fills in only the DMA address and length, so drm_clflush_sg() already walks zero pages on carveout memory. Userspace maintains these through the mapping it already holds, as XRT's buffer::sync() does unless it is told to sync through the driver.
Suggested-by: Lizhi Hou lizhi.hou@amd.com Signed-off-by: Taimuraz Kaitmazov taimuraz@kaitmazov.com
drivers/accel/amdxdna/amdxdna_gem.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/accel/amdxdna/amdxdna_gem.c b/drivers/accel/amdxdna/amdxdna_gem.c index 4f38f985c74e..a713a9982d34 100644 --- a/drivers/accel/amdxdna/amdxdna_gem.c +++ b/drivers/accel/amdxdna/amdxdna_gem.c @@ -1224,6 +1224,9 @@ static int amdxdna_flush_bo(struct amdxdna_gem_obj *abo, u64 offset, u64 size) { u64 end;
- if (is_import_bo(abo))
return -EOPNOTSUPP;- if (offset >= abo->mem.size) return -EINVAL;
@@ -1234,9 +1237,7 @@ static int amdxdna_flush_bo(struct amdxdna_gem_obj *abo, u64 offset, u64 size) if (!size) return 0;
- if (is_import_bo(abo))
drm_clflush_sg(abo->base.sgt);- else if (amdxdna_gem_vmap(abo))
- if (amdxdna_gem_vmap(abo))
Reviewed-by: Lizhi Hou lizhi.hou@amd.com
drm_clflush_virt_range(amdxdna_gem_vmap(abo) + offset, size);else if (abo->base.pages) drm_clflush_pages(abo->base.pages, abo->mem.size >> PAGE_SHIFT);