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

drm/syncobj: extend syncobj query ability v3

user space needs a flexiable query ability.
So that umd can get last signaled or submitted point.
v2:
add sanitizer checking.
v3:
rebase

Change-Id: I6512b430524ebabe715e602a2bf5abb0a7e780ea
Signed-off-by: Chunming Zhou <david1.zhou@amd.com>
Cc: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Cc: Christian König <Christian.Koenig@amd.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Signed-off-by: Christian König <christian.koenig@amd.com>
Link: https://patchwork.freedesktop.org/series/64044/

authored by

Chunming Zhou and committed by
Christian König
2093dea3 be428f24

+23 -15
+21 -14
drivers/gpu/drm/drm_syncobj.c
··· 1280 1280 if (!drm_core_check_feature(dev, DRIVER_SYNCOBJ_TIMELINE)) 1281 1281 return -EOPNOTSUPP; 1282 1282 1283 - if (args->pad != 0) 1283 + if (args->flags != 0) 1284 1284 return -EINVAL; 1285 1285 1286 1286 if (args->count_handles == 0) ··· 1351 1351 if (!drm_core_check_feature(dev, DRIVER_SYNCOBJ_TIMELINE)) 1352 1352 return -EOPNOTSUPP; 1353 1353 1354 - if (args->pad != 0) 1354 + if (args->flags & ~DRM_SYNCOBJ_QUERY_FLAGS_LAST_SUBMITTED) 1355 1355 return -EINVAL; 1356 1356 1357 1357 if (args->count_handles == 0) ··· 1372 1372 fence = drm_syncobj_fence_get(syncobjs[i]); 1373 1373 chain = to_dma_fence_chain(fence); 1374 1374 if (chain) { 1375 - struct dma_fence *iter, *last_signaled = NULL; 1375 + struct dma_fence *iter, *last_signaled = 1376 + dma_fence_get(fence); 1376 1377 1377 - dma_fence_chain_for_each(iter, fence) { 1378 - if (iter->context != fence->context) { 1379 - dma_fence_put(iter); 1380 - /* It is most likely that timeline has 1381 - * unorder points. */ 1382 - break; 1378 + if (args->flags & 1379 + DRM_SYNCOBJ_QUERY_FLAGS_LAST_SUBMITTED) { 1380 + point = fence->seqno; 1381 + } else { 1382 + dma_fence_chain_for_each(iter, fence) { 1383 + if (iter->context != fence->context) { 1384 + dma_fence_put(iter); 1385 + /* It is most likely that timeline has 1386 + * unorder points. */ 1387 + break; 1388 + } 1389 + dma_fence_put(last_signaled); 1390 + last_signaled = dma_fence_get(iter); 1383 1391 } 1384 - dma_fence_put(last_signaled); 1385 - last_signaled = dma_fence_get(iter); 1392 + point = dma_fence_is_signaled(last_signaled) ? 1393 + last_signaled->seqno : 1394 + to_dma_fence_chain(last_signaled)->prev_seqno; 1386 1395 } 1387 - point = dma_fence_is_signaled(last_signaled) ? 1388 - last_signaled->seqno : 1389 - to_dma_fence_chain(last_signaled)->prev_seqno; 1390 1396 dma_fence_put(last_signaled); 1391 1397 } else { 1392 1398 point = 0; 1393 1399 } 1400 + dma_fence_put(fence); 1394 1401 ret = copy_to_user(&points[i], &point, sizeof(uint64_t)); 1395 1402 ret = ret ? -EFAULT : 0; 1396 1403 if (ret)
+2 -1
include/uapi/drm/drm.h
··· 778 778 __u32 pad; 779 779 }; 780 780 781 + #define DRM_SYNCOBJ_QUERY_FLAGS_LAST_SUBMITTED (1 << 0) /* last available point on timeline syncobj */ 781 782 struct drm_syncobj_timeline_array { 782 783 __u64 handles; 783 784 __u64 points; 784 785 __u32 count_handles; 785 - __u32 pad; 786 + __u32 flags; 786 787 }; 787 788 788 789