mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-22 17:36:20 +03:00
gpu: nvgpu: fix for worker thread unit test
Fix a possible issue which could arise due to invoking the function nvgpu_worker_init twice on same worker thread. A worker poll task thread could be already using the mutex/condition variable when the second init invocation is done, leading to an undefined behaviour. Second invocation is done for branch coverage, which can be done using a different worker with thread running status set. Bug 3180383 Change-Id: Ife2917e349aa039a4e0baa399c696a7c9ab3015e Signed-off-by: ajeshkv <akv@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2453218 Reviewed-by: automaticguardword <automaticguardword@nvidia.com> Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com> Reviewed-by: Alex Waterman <alexw@nvidia.com> Reviewed-by: Sagar Kamble <skamble@nvidia.com> Reviewed-by: Philip Elcan <pelcan@nvidia.com> Reviewed-by: Vaibhav Kachore <vkachore@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:
@@ -95,6 +95,7 @@ static u32 wakeup_timeout(struct nvgpu_worker *worker)
|
|||||||
}
|
}
|
||||||
|
|
||||||
_Thread_local struct nvgpu_worker worker;
|
_Thread_local struct nvgpu_worker worker;
|
||||||
|
_Thread_local struct nvgpu_worker worker_branch;
|
||||||
_Thread_local struct nvgpu_worker_ops worker_ops = {
|
_Thread_local struct nvgpu_worker_ops worker_ops = {
|
||||||
/* pre_process is NULL for branch testing for NULL when thread starts. */
|
/* pre_process is NULL for branch testing for NULL when thread starts. */
|
||||||
.pre_process = NULL,
|
.pre_process = NULL,
|
||||||
@@ -136,7 +137,9 @@ int test_init(struct unit_module *m, struct gk20a *g, void *args)
|
|||||||
while (!nvgpu_thread_is_running(&worker.poll_task)) {
|
while (!nvgpu_thread_is_running(&worker.poll_task)) {
|
||||||
nvgpu_udelay(5);
|
nvgpu_udelay(5);
|
||||||
}
|
}
|
||||||
err = nvgpu_worker_init(g, &worker, &worker_ops);
|
|
||||||
|
nvgpu_atomic_set(&worker_branch.poll_task.running, 1);
|
||||||
|
err = nvgpu_worker_init(g, &worker_branch, &worker_ops);
|
||||||
unit_assert(err == 0, return UNIT_FAIL);
|
unit_assert(err == 0, return UNIT_FAIL);
|
||||||
|
|
||||||
return UNIT_SUCCESS;
|
return UNIT_SUCCESS;
|
||||||
|
|||||||
Reference in New Issue
Block a user