From 29dc4e509a767deb93d91fb0d2fe473048c5a0d8 Mon Sep 17 00:00:00 2001 From: ajeshkv Date: Tue, 24 Nov 2020 11:49:19 +0530 Subject: [PATCH] gpu: nvgpu: fix for posix cond unit test Fix a possible synchronization issue between the threads in posix condition variable unit test. Bug 3183891 Change-Id: I315b55dc0225319f393e9e410c95245ed3d19683 Signed-off-by: ajeshkv Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2450060 Reviewed-by: automaticguardword Reviewed-by: svc-mobile-coverity Reviewed-by: svc-mobile-misra Reviewed-by: Philip Elcan Reviewed-by: Shashank Singh Reviewed-by: mobile promotions GVS: Gerrit_Virtual_Submit Tested-by: mobile promotions --- userspace/units/posix/cond/posix-cond.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/userspace/units/posix/cond/posix-cond.c b/userspace/units/posix/cond/posix-cond.c index d34e49343..11f3a6079 100644 --- a/userspace/units/posix/cond/posix-cond.c +++ b/userspace/units/posix/cond/posix-cond.c @@ -186,6 +186,8 @@ static int test_cond_write_thread(void *args) test_code[i] = 0x55; } + usleep(50); + read_wait = false; if (data->use_broadcast) { @@ -228,8 +230,6 @@ static int test_cond_read_thread(void *args) data = (struct unit_test_cond_data *)args; - read_wait = true; - if (data->use_timedwait) { timeout = 50; } else { @@ -237,6 +237,7 @@ static int test_cond_read_thread(void *args) } if (data->use_condition) { + read_wait = true; if (data->use_wait_int) { ret = NVGPU_COND_WAIT_INTERRUPTIBLE(&test_cond, test_code[3] == 0x55, 0); @@ -256,6 +257,7 @@ static int test_cond_read_thread(void *args) } else { nvgpu_cond_lock(&test_cond); + read_wait = true; ret = nvgpu_cond_timedwait(&test_cond, &timeout); if (ret != 0) { read_status = ret; @@ -285,8 +287,6 @@ static int test_cond_bcst_read_thread(void *args) data = (struct unit_test_cond_data *)args; - bcst_read_wait = true; - if (data->use_timedwait) { timeout = 50; } else { @@ -295,6 +295,7 @@ static int test_cond_bcst_read_thread(void *args) nvgpu_cond_lock(&test_cond); + bcst_read_wait = true; ret = nvgpu_cond_timedwait(&test_cond, &timeout); if (ret != 0) { bcst_read_status = ret;