mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-23 09:57:08 +03:00
gpu: nvgpu: add should stop condition to workers
As the docs of nvgpu_thread say, each thread (which the worker loop is) should wake up and check also nvgpu_thread_should_stop() to manage graceful and quick exit as requested. The loop does have that check already, but the workqueue condition does not, so the cond wait might end up waiting until its timeout hits. It's not robust to trust the worker users to have a swift timeout for exiting the thread, so read the should-stop flag in the wakeup condition too. Simplify the clk arb worker ops now that calling nvgpu_worker_should_stop from there is no longer necessary. (Other worker users did not have those, so they were technically buggy.) Change-Id: I5409b8037564d4b6445a15cdbd4f1f3d616c4083 Signed-off-by: Konsta Hölttä <kholtta@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2635808 Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com> Reviewed-by: svc-mobile-misra <svc-mobile-misra@nvidia.com> Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com> Reviewed-by: svcacv <svcacv@nvidia.com> Reviewed-by: Alex Waterman <alexw@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com> GVS: Gerrit_Virtual_Submit
This commit is contained in:
committed by
mobile promotions
parent
bf5f789805
commit
23f6da4fe5
@@ -404,13 +404,8 @@ static void nvgpu_clk_arb_worker_poll_init(struct nvgpu_worker *worker)
|
||||
|
||||
const struct nvgpu_worker_ops clk_arb_worker_ops = {
|
||||
.pre_process = nvgpu_clk_arb_worker_poll_init,
|
||||
.wakeup_early_exit = nvgpu_worker_should_stop,
|
||||
.wakeup_post_process = NULL,
|
||||
.wakeup_process_item =
|
||||
nvgpu_clk_arb_worker_poll_wakeup_process_item,
|
||||
.wakeup_condition =
|
||||
nvgpu_worker_should_stop,
|
||||
.wakeup_timeout = NULL,
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -153,13 +153,14 @@ static int nvgpu_worker_poll_work(void *arg)
|
||||
|
||||
nvgpu_worker_pre_process(worker);
|
||||
|
||||
while (!nvgpu_thread_should_stop(&worker->poll_task)) {
|
||||
while (!nvgpu_worker_should_stop(worker)) {
|
||||
int ret;
|
||||
|
||||
ret = NVGPU_COND_WAIT_INTERRUPTIBLE(
|
||||
&worker->wq,
|
||||
nvgpu_worker_pending(worker, get) ||
|
||||
nvgpu_worker_wakeup_condition(worker),
|
||||
nvgpu_worker_wakeup_condition(worker) ||
|
||||
nvgpu_worker_should_stop(worker),
|
||||
nvgpu_worker_wakeup_timeout(worker));
|
||||
|
||||
if (nvgpu_worker_wakeup_early_exit(worker)) {
|
||||
|
||||
Reference in New Issue
Block a user