Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/xe: Add sa/guc_buf_cache sync interface

In upcoming changes the cached buffers are going to be used to read data
produced by the GuC. Add a counterpart to flush, which synchronizes the
CPU-side of suballocation with the GPU data and propagate the interface
to GuC Buffer Cache.

Reviewed-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Link: https://patch.msgid.link/20251112132220.516975-11-michal.winiarski@intel.com
Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>

+36
+13
drivers/gpu/drm/xe/xe_guc_buf.c
··· 116 116 } 117 117 118 118 /** 119 + * xe_guc_buf_sync_read() - Copy the data from the GPU memory to the sub-allocation. 120 + * @buf: the &xe_guc_buf to sync 121 + * 122 + * Return: a CPU pointer of the sub-allocation. 123 + */ 124 + void *xe_guc_buf_sync_read(const struct xe_guc_buf buf) 125 + { 126 + xe_sa_bo_sync_read(buf.sa); 127 + 128 + return xe_sa_bo_cpu_addr(buf.sa); 129 + } 130 + 131 + /** 119 132 * xe_guc_buf_flush() - Copy the data from the sub-allocation to the GPU memory. 120 133 * @buf: the &xe_guc_buf to flush 121 134 *
+1
drivers/gpu/drm/xe/xe_guc_buf.h
··· 30 30 } 31 31 32 32 void *xe_guc_buf_cpu_ptr(const struct xe_guc_buf buf); 33 + void *xe_guc_buf_sync_read(const struct xe_guc_buf buf); 33 34 u64 xe_guc_buf_flush(const struct xe_guc_buf buf); 34 35 u64 xe_guc_buf_gpu_addr(const struct xe_guc_buf buf); 35 36 u64 xe_guc_cache_gpu_addr_from_ptr(struct xe_guc_buf_cache *cache, const void *ptr, u32 size);
+21
drivers/gpu/drm/xe/xe_sa.c
··· 110 110 return drm_suballoc_new(&sa_manager->base, size, gfp, true, 0); 111 111 } 112 112 113 + /** 114 + * xe_sa_bo_flush_write() - Copy the data from the sub-allocation to the GPU memory. 115 + * @sa_bo: the &drm_suballoc to flush 116 + */ 113 117 void xe_sa_bo_flush_write(struct drm_suballoc *sa_bo) 114 118 { 115 119 struct xe_sa_manager *sa_manager = to_xe_sa_manager(sa_bo->manager); ··· 125 121 xe_map_memcpy_to(xe, &sa_manager->bo->vmap, drm_suballoc_soffset(sa_bo), 126 122 xe_sa_bo_cpu_addr(sa_bo), 127 123 drm_suballoc_size(sa_bo)); 124 + } 125 + 126 + /** 127 + * xe_sa_bo_sync_read() - Copy the data from GPU memory to the sub-allocation. 128 + * @sa_bo: the &drm_suballoc to sync 129 + */ 130 + void xe_sa_bo_sync_read(struct drm_suballoc *sa_bo) 131 + { 132 + struct xe_sa_manager *sa_manager = to_xe_sa_manager(sa_bo->manager); 133 + struct xe_device *xe = tile_to_xe(sa_manager->bo->tile); 134 + 135 + if (!sa_manager->bo->vmap.is_iomem) 136 + return; 137 + 138 + xe_map_memcpy_from(xe, xe_sa_bo_cpu_addr(sa_bo), &sa_manager->bo->vmap, 139 + drm_suballoc_soffset(sa_bo), 140 + drm_suballoc_size(sa_bo)); 128 141 } 129 142 130 143 void xe_sa_bo_free(struct drm_suballoc *sa_bo,
+1
drivers/gpu/drm/xe/xe_sa.h
··· 37 37 } 38 38 39 39 void xe_sa_bo_flush_write(struct drm_suballoc *sa_bo); 40 + void xe_sa_bo_sync_read(struct drm_suballoc *sa_bo); 40 41 void xe_sa_bo_free(struct drm_suballoc *sa_bo, struct dma_fence *fence); 41 42 42 43 static inline struct xe_sa_manager *