mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-22 17:36:20 +03:00
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 <akv@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2450060 Reviewed-by: automaticguardword <automaticguardword@nvidia.com> Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com> Reviewed-by: svc-mobile-misra <svc-mobile-misra@nvidia.com> Reviewed-by: Philip Elcan <pelcan@nvidia.com> Reviewed-by: Shashank Singh <shashsingh@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> GVS: Gerrit_Virtual_Submit Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
@@ -186,6 +186,8 @@ static int test_cond_write_thread(void *args)
|
|||||||
test_code[i] = 0x55;
|
test_code[i] = 0x55;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
usleep(50);
|
||||||
|
|
||||||
read_wait = false;
|
read_wait = false;
|
||||||
|
|
||||||
if (data->use_broadcast) {
|
if (data->use_broadcast) {
|
||||||
@@ -228,8 +230,6 @@ static int test_cond_read_thread(void *args)
|
|||||||
|
|
||||||
data = (struct unit_test_cond_data *)args;
|
data = (struct unit_test_cond_data *)args;
|
||||||
|
|
||||||
read_wait = true;
|
|
||||||
|
|
||||||
if (data->use_timedwait) {
|
if (data->use_timedwait) {
|
||||||
timeout = 50;
|
timeout = 50;
|
||||||
} else {
|
} else {
|
||||||
@@ -237,6 +237,7 @@ static int test_cond_read_thread(void *args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (data->use_condition) {
|
if (data->use_condition) {
|
||||||
|
read_wait = true;
|
||||||
if (data->use_wait_int) {
|
if (data->use_wait_int) {
|
||||||
ret = NVGPU_COND_WAIT_INTERRUPTIBLE(&test_cond,
|
ret = NVGPU_COND_WAIT_INTERRUPTIBLE(&test_cond,
|
||||||
test_code[3] == 0x55, 0);
|
test_code[3] == 0x55, 0);
|
||||||
@@ -256,6 +257,7 @@ static int test_cond_read_thread(void *args)
|
|||||||
} else {
|
} else {
|
||||||
nvgpu_cond_lock(&test_cond);
|
nvgpu_cond_lock(&test_cond);
|
||||||
|
|
||||||
|
read_wait = true;
|
||||||
ret = nvgpu_cond_timedwait(&test_cond, &timeout);
|
ret = nvgpu_cond_timedwait(&test_cond, &timeout);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
read_status = ret;
|
read_status = ret;
|
||||||
@@ -285,8 +287,6 @@ static int test_cond_bcst_read_thread(void *args)
|
|||||||
|
|
||||||
data = (struct unit_test_cond_data *)args;
|
data = (struct unit_test_cond_data *)args;
|
||||||
|
|
||||||
bcst_read_wait = true;
|
|
||||||
|
|
||||||
if (data->use_timedwait) {
|
if (data->use_timedwait) {
|
||||||
timeout = 50;
|
timeout = 50;
|
||||||
} else {
|
} else {
|
||||||
@@ -295,6 +295,7 @@ static int test_cond_bcst_read_thread(void *args)
|
|||||||
|
|
||||||
nvgpu_cond_lock(&test_cond);
|
nvgpu_cond_lock(&test_cond);
|
||||||
|
|
||||||
|
bcst_read_wait = true;
|
||||||
ret = nvgpu_cond_timedwait(&test_cond, &timeout);
|
ret = nvgpu_cond_timedwait(&test_cond, &timeout);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
bcst_read_status = ret;
|
bcst_read_status = ret;
|
||||||
|
|||||||
Reference in New Issue
Block a user