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

drm/amdgpu:fix race condition

sequence is protected by spinlock so don't access sequence
in paramter seq when invoking this function.

~0 means to get the latest sequence number and 0 means none to
get.

Change-Id: Ib7a03f3cf5594deeb4ad333cc59b47a6bddfd1ad
Signed-off-by: Monk Liu <Monk.Liu@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Monk Liu and committed by
Alex Deucher
d7b1eeb2 5e78835a

+7 -1
+3
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
··· 273 273 274 274 spin_lock(&ctx->ring_lock); 275 275 276 + if (seq == ~0ull) 277 + seq = ctx->rings[ring->idx].sequence - 1; 278 + 276 279 if (seq >= cring->sequence) { 277 280 spin_unlock(&ctx->ring_lock); 278 281 return ERR_PTR(-EINVAL);
+4 -1
include/uapi/drm/amdgpu_drm.h
··· 295 295 }; 296 296 297 297 struct drm_amdgpu_wait_cs_in { 298 - /** Command submission handle */ 298 + /* Command submission handle 299 + * handle equals 0 means none to wait for 300 + * handle equal ~0ull meanas wait for the latest sequence number 301 + */ 299 302 __u64 handle; 300 303 /** Absolute timeout to wait */ 301 304 __u64 timeout;