diff --git a/drivers/gpu/nvgpu/common/fifo/channel_wdt.c b/drivers/gpu/nvgpu/common/fifo/channel_wdt.c index 4cb06ec04..2d6382dde 100644 --- a/drivers/gpu/nvgpu/common/fifo/channel_wdt.c +++ b/drivers/gpu/nvgpu/common/fifo/channel_wdt.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2021, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2015-2022, NVIDIA CORPORATION. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -142,7 +142,7 @@ void nvgpu_channel_worker_poll_init(struct nvgpu_worker *worker) ch_worker->watchdog_interval = 100U; - nvgpu_timeout_init_cpu_timer(worker->g, &ch_worker->timeout, + nvgpu_timeout_init_cpu_timer_sw(worker->g, &ch_worker->timeout, ch_worker->watchdog_interval); } @@ -175,7 +175,7 @@ void nvgpu_channel_worker_poll_wakeup_post_process_item( if (nvgpu_timeout_peek_expired(&ch_worker->timeout)) { nvgpu_channel_poll_wdt(g); - nvgpu_timeout_init_cpu_timer(g, &ch_worker->timeout, + nvgpu_timeout_init_cpu_timer_sw(g, &ch_worker->timeout, ch_worker->watchdog_interval); } } diff --git a/drivers/gpu/nvgpu/common/fifo/watchdog.c b/drivers/gpu/nvgpu/common/fifo/watchdog.c index e637fe5c2..65657d733 100644 --- a/drivers/gpu/nvgpu/common/fifo/watchdog.c +++ b/drivers/gpu/nvgpu/common/fifo/watchdog.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2021, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2011-2022, NVIDIA CORPORATION. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -92,6 +92,10 @@ static void nvgpu_channel_wdt_init(struct nvgpu_channel_wdt *wdt, { struct gk20a *g = wdt->g; + /* + * Note: this is intentionally not the sw kind of timer to avoid false + * triggers in pre-si environments that tend to run slow. + */ nvgpu_timeout_init_cpu_timer(g, &wdt->timer, wdt->limit_ms); wdt->ch_state = *state; diff --git a/drivers/gpu/nvgpu/common/nvs/nvs_sched.c b/drivers/gpu/nvgpu/common/nvs/nvs_sched.c index b456b73a8..5515ce6e1 100644 --- a/drivers/gpu/nvgpu/common/nvs/nvs_sched.c +++ b/drivers/gpu/nvgpu/common/nvs/nvs_sched.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2021-2022, NVIDIA CORPORATION. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -67,7 +67,7 @@ static void nvgpu_nvs_worker_poll_init(struct nvgpu_worker *worker) /* 100 ms is a nice arbitrary timeout for default status */ nvs_worker->current_timeout = 100; - nvgpu_timeout_init_cpu_timer(worker->g, &nvs_worker->timeout, + nvgpu_timeout_init_cpu_timer_sw(worker->g, &nvs_worker->timeout, nvs_worker->current_timeout); } @@ -135,7 +135,7 @@ static void nvgpu_nvs_worker_wakeup_post_process(struct nvgpu_worker *worker) (next_timeout_ns + NSEC_PER_MSEC - 1) / NSEC_PER_MSEC; } - nvgpu_timeout_init_cpu_timer(g, &nvs_worker->timeout, + nvgpu_timeout_init_cpu_timer_sw(g, &nvs_worker->timeout, nvs_worker->current_timeout); } } diff --git a/drivers/gpu/nvgpu/include/nvgpu/timers.h b/drivers/gpu/nvgpu/include/nvgpu/timers.h index c739935f3..437db0397 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/timers.h +++ b/drivers/gpu/nvgpu/include/nvgpu/timers.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2021, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2016-2022, NVIDIA CORPORATION. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -166,6 +166,24 @@ int nvgpu_timeout_init_flags(struct gk20a *g, struct nvgpu_timeout *timeout, void nvgpu_timeout_init_cpu_timer(struct gk20a *g, struct nvgpu_timeout *timeout, u32 duration_ms); +/** + * @brief Initialize a pure software timeout. + * + * Init a cpu clock based timeout with no pre-si override. See + * nvgpu_timeout_init_flags() and NVGPU_TIMER_CPU_TIMER for full explanation. + * + * This builds a timer that has the NVGPU_TIMER_NO_PRE_SI flag. Most often, + * hardware polling related loops are preferred to be infinite in presilicon + * simulation mode. That's not the case in some timers for only software logic, + * which this function is for. + * + * @param g [in] GPU driver structure. + * @param timeout [in] Timeout object to initialize. + * @param duration [in] Timeout duration in milliseconds. + */ +void nvgpu_timeout_init_cpu_timer_sw(struct gk20a *g, struct nvgpu_timeout *timeout, + u32 duration_ms); + /** * @brief Initialize a timeout. * diff --git a/drivers/gpu/nvgpu/os/linux/cde.c b/drivers/gpu/nvgpu/os/linux/cde.c index bb9eb3cb8..2217cce5a 100644 --- a/drivers/gpu/nvgpu/os/linux/cde.c +++ b/drivers/gpu/nvgpu/os/linux/cde.c @@ -1,7 +1,7 @@ /* * Color decompression engine support * - * Copyright (c) 2014-2021, NVIDIA Corporation. All rights reserved. + * Copyright (c) 2014-2022, NVIDIA Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -936,7 +936,7 @@ __acquires(&cde_app->mutex) struct gk20a_cde_ctx *cde_ctx = NULL; struct nvgpu_timeout timeout; - nvgpu_timeout_init_cpu_timer(g, &timeout, MAX_CTX_RETRY_TIME); + nvgpu_timeout_init_cpu_timer_sw(g, &timeout, MAX_CTX_RETRY_TIME); do { cde_ctx = gk20a_cde_do_get_context(l); diff --git a/drivers/gpu/nvgpu/os/linux/timers.c b/drivers/gpu/nvgpu/os/linux/timers.c index 16240b617..45c8eabb8 100644 --- a/drivers/gpu/nvgpu/os/linux/timers.c +++ b/drivers/gpu/nvgpu/os/linux/timers.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2021, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2016-2022, NVIDIA CORPORATION. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -45,6 +45,16 @@ void nvgpu_timeout_init_cpu_timer(struct gk20a *g, struct nvgpu_timeout *timeout nvgpu_assert(err == 0); } +void nvgpu_timeout_init_cpu_timer_sw(struct gk20a *g, struct nvgpu_timeout *timeout, + u32 duration_ms) +{ + int err = nvgpu_timeout_init_flags(g, timeout, duration_ms, + NVGPU_TIMER_CPU_TIMER | + NVGPU_TIMER_NO_PRE_SI); + + nvgpu_assert(err == 0); +} + void nvgpu_timeout_init_retry(struct gk20a *g, struct nvgpu_timeout *timeout, u32 duration_count) { diff --git a/drivers/gpu/nvgpu/os/posix/timers.c b/drivers/gpu/nvgpu/os/posix/timers.c index 59323ccd9..e08bdeccb 100644 --- a/drivers/gpu/nvgpu/os/posix/timers.c +++ b/drivers/gpu/nvgpu/os/posix/timers.c @@ -132,6 +132,16 @@ void nvgpu_timeout_init_cpu_timer(struct gk20a *g, struct nvgpu_timeout *timeout nvgpu_assert(err == 0); } +void nvgpu_timeout_init_cpu_timer_sw(struct gk20a *g, struct nvgpu_timeout *timeout, + u32 duration_ms) +{ + int err = nvgpu_timeout_init_flags(g, timeout, duration_ms, + NVGPU_TIMER_CPU_TIMER | + NVGPU_TIMER_NO_PRE_SI); + + nvgpu_assert(err == 0); +} + void nvgpu_timeout_init_retry(struct gk20a *g, struct nvgpu_timeout *timeout, u32 duration_count) {