diff --git a/drivers/gpu/nvgpu/common/init/nvgpu_init.c b/drivers/gpu/nvgpu/common/init/nvgpu_init.c index 4f23fbe8b..cf30b2c38 100644 --- a/drivers/gpu/nvgpu/common/init/nvgpu_init.c +++ b/drivers/gpu/nvgpu/common/init/nvgpu_init.c @@ -74,11 +74,6 @@ void nvgpu_check_gpu_state(struct gk20a *g) } } -void nvgpu_warn_on_no_regs(void) -{ - WARN_ONCE(true, "Attempted access to GPU regs after unmapping!"); -} - static void gk20a_mask_interrupts(struct gk20a *g) { if (g->ops.mc.intr_mask != NULL) { @@ -583,35 +578,6 @@ int nvgpu_can_busy(struct gk20a *g) } } -int nvgpu_wait_for_idle(struct gk20a *g) -{ - int wait_length = 150; /* 3 second overall max wait. */ - int target_usage_count = 0; - bool done = false; - - if (g == NULL) { - return -ENODEV; - } - - do { - if (nvgpu_atomic_read(&g->usage_count) == target_usage_count) { - done = true; - } else if (wait_length-- < 0) { - done = true; - } else { - nvgpu_msleep(20); - } - } while (!done); - - if (wait_length < 0) { - nvgpu_warn(g, "Timed out waiting for idle (%d)!\n", - nvgpu_atomic_read(&g->usage_count)); - return -ETIMEDOUT; - } - - return 0; -} - void nvgpu_init_gpu_characteristics(struct gk20a *g) { #ifdef NV_BUILD_CONFIGURATION_IS_SAFETY diff --git a/drivers/gpu/nvgpu/include/nvgpu/nvgpu_init.h b/drivers/gpu/nvgpu/include/nvgpu/nvgpu_init.h index a966a5f80..7a21f0c8f 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/nvgpu_init.h +++ b/drivers/gpu/nvgpu/include/nvgpu/nvgpu_init.h @@ -27,14 +27,12 @@ int nvgpu_finalize_poweron(struct gk20a *g); int nvgpu_prepare_poweroff(struct gk20a *g); int nvgpu_can_busy(struct gk20a *g); -int nvgpu_wait_for_idle(struct gk20a *g); struct gk20a * __must_check nvgpu_get(struct gk20a *g); void nvgpu_put(struct gk20a *g); /* register accessors */ void nvgpu_check_gpu_state(struct gk20a *g); -void nvgpu_warn_on_no_regs(void); void nvgpu_init_gpu_characteristics(struct gk20a *g); diff --git a/drivers/gpu/nvgpu/os/linux/linux-io.c b/drivers/gpu/nvgpu/os/linux/linux-io.c index 1076c351e..efe4af28a 100644 --- a/drivers/gpu/nvgpu/os/linux/linux-io.c +++ b/drivers/gpu/nvgpu/os/linux/linux-io.c @@ -18,6 +18,11 @@ #include "os_linux.h" +static void nvgpu_warn_on_no_regs(void) +{ + WARN_ONCE(true, "Attempted access to GPU regs after unmapping!"); +} + void nvgpu_writel(struct gk20a *g, u32 r, u32 v) { struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g); diff --git a/drivers/gpu/nvgpu/os/linux/module.c b/drivers/gpu/nvgpu/os/linux/module.c index 03b898128..5b84e71e1 100644 --- a/drivers/gpu/nvgpu/os/linux/module.c +++ b/drivers/gpu/nvgpu/os/linux/module.c @@ -90,6 +90,35 @@ #include #endif +static int nvgpu_wait_for_idle(struct gk20a *g) +{ + int wait_length = 150; /* 3 second overall max wait. */ + int target_usage_count = 0; + bool done = false; + + if (g == NULL) { + return -ENODEV; + } + + do { + if (nvgpu_atomic_read(&g->usage_count) == target_usage_count) { + done = true; + } else if (wait_length-- < 0) { + done = true; + } else { + nvgpu_msleep(20); + } + } while (!done); + + if (wait_length < 0) { + nvgpu_warn(g, "Timed out waiting for idle (%d)!\n", + nvgpu_atomic_read(&g->usage_count)); + return -ETIMEDOUT; + } + + return 0; +} + static int nvgpu_kernel_shutdown_notification(struct notifier_block *nb, unsigned long event, void *unused) {