amdgpu: fix race issue between two bo functions(v2)
authorMonk Liu <monk.liu@amd.com>
Tue, 8 Aug 2017 07:34:20 +0000 (15:34 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 8 Aug 2017 16:00:11 +0000 (12:00 -0400)
commit2a89ae5d7a7d5845226ed85146140ff4c8788d59
treed8a7d5caec863950ba1c1a2c4a91b407fcc18ced
parent4d244155945f5531b4d9735bbe73c887aac81070
amdgpu: fix race issue between two bo functions(v2)

there is race issue between two threads on amdgpu_bo_reference and
amdgpu_bo_import, this patch tends to fix it by moving the
pthread_mutex_lock out of bo_free_internal and move to bo_reference
to cover the update_reference part.

The mutex_unlock in bo_import should also cover bo refcount
increasement.

Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Monk Liu <monk.liu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
amdgpu/amdgpu_bo.c
amdgpu/amdgpu_internal.h