gpu: nvgpu: init: move out linux-specific APIs

The functions nvgpu_warn_on_no_regs() and nvgpu_wait_for_idle() are only
used by linux, so move them out of nvgpu.common.init into linux-specific
driver code.

JIRA NVGPU-2385

Change-Id: Iea38cdb16f9e513d8242c1b07b80171b8b68db5b
Signed-off-by: Philip Elcan <pelcan@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2156459
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-misra <svc-mobile-misra@nvidia.com>
Reviewed-by: Sagar Kamble <skamble@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Alex Waterman <alexw@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Philip Elcan
2019-07-18 14:02:11 -04:00
committed by mobile promotions
parent 91187b6db2
commit b0ad7c0ad2
4 changed files with 34 additions and 36 deletions

View File

@@ -90,6 +90,35 @@
#include <trace/events/gk20a.h>
#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)
{