mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-23 01:50:07 +03:00
For safety build, nvgpu driver should enter SW quiesce state in case an uncorrectable error has occurred. In this state, any activity on the GPU should be prevented, without powering off the GPU. Also, a minimal set of operations should be used to enter SW quiesce state. Entering SW quiesce state does the following: - set sw_quiesce_pending: when this flag is set, interrupt handlers exit after masking interrupts. This should help mitigate an interrupt storm. - wake up thread to complete quiescing. The thread performs the following: - set NVGPU_DRIVER_IS_DYING to prevent allocation of new resources - disable interrupts - disable fifo scheduling - preempt all runlists - set error notifier for all active channels Note: for channels with usermode submit enabled, userspace can still ring doorbell, but this will not trigger any work on engines since fifo scheduling is disabled. Jira NVGPU-3493 Change-Id: I639a32da754d8833f54dcec1fa23135721d8d89a Signed-off-by: Thomas Fleury <tfleury@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/2172391 Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
132 lines
3.0 KiB
C
132 lines
3.0 KiB
C
/*
|
|
* Copyright (c) 2018-2019, 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"),
|
|
* to deal in the Software without restriction, including without limitation
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in
|
|
* all copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
* DEALINGS IN THE SOFTWARE.
|
|
*/
|
|
|
|
#include <unistd.h>
|
|
#include <stdlib.h>
|
|
#include <pthread.h>
|
|
|
|
#include <nvgpu/bug.h>
|
|
#include <nvgpu/types.h>
|
|
#include <nvgpu/atomic.h>
|
|
#include <nvgpu/nvgpu_common.h>
|
|
#include <nvgpu/nvgpu_init.h>
|
|
#include <nvgpu/os_sched.h>
|
|
#include <nvgpu/gk20a.h>
|
|
#include <nvgpu/enabled.h>
|
|
|
|
#include <nvgpu/posix/probe.h>
|
|
|
|
#include "os_posix.h"
|
|
|
|
/*
|
|
* Somewhat meaningless in userspace...
|
|
*/
|
|
void nvgpu_kernel_restart(void *cmd)
|
|
{
|
|
BUG();
|
|
}
|
|
|
|
void nvgpu_start_gpu_idle(struct gk20a *g)
|
|
{
|
|
nvgpu_set_enabled(g, NVGPU_DRIVER_IS_DYING, true);
|
|
}
|
|
|
|
void nvgpu_disable_irqs(struct gk20a *g)
|
|
{
|
|
}
|
|
|
|
/*
|
|
* We have no runtime PM stuff in userspace so these are really just noops.
|
|
*/
|
|
void gk20a_busy_noresume(struct gk20a *g)
|
|
{
|
|
}
|
|
|
|
void gk20a_idle_nosuspend(struct gk20a *g)
|
|
{
|
|
}
|
|
|
|
int gk20a_busy(struct gk20a *g)
|
|
{
|
|
nvgpu_atomic_inc(&g->usage_count);
|
|
|
|
return 0;
|
|
}
|
|
|
|
void gk20a_idle(struct gk20a *g)
|
|
{
|
|
nvgpu_atomic_dec(&g->usage_count);
|
|
}
|
|
|
|
/*
|
|
* This function aims to initialize enough stuff to make unit testing worth
|
|
* while. There are several interfaces and APIs that rely on the struct gk20a's
|
|
* state in order to function: logging, for example, but there are many other
|
|
* things, too.
|
|
*
|
|
* Initialize as much of that as possible here. This is meant to be equivalent
|
|
* to the kernel space driver's probe function.
|
|
*/
|
|
struct gk20a *nvgpu_posix_probe(void)
|
|
{
|
|
struct gk20a *g;
|
|
struct nvgpu_os_posix *p;
|
|
|
|
p = malloc(sizeof(*p));
|
|
|
|
if (p == NULL) {
|
|
return NULL;
|
|
}
|
|
|
|
(void) memset(p, 0, sizeof(*p));
|
|
|
|
g = &p->g;
|
|
g->log_mask = 0;
|
|
g->mm.g = g;
|
|
|
|
if (nvgpu_kmem_init(g) != 0) {
|
|
goto fail_kmem;
|
|
}
|
|
|
|
if (nvgpu_init_enabled_flags(g) != 0) {
|
|
goto fail_enabled_flags;
|
|
}
|
|
|
|
return g;
|
|
|
|
fail_enabled_flags:
|
|
nvgpu_kmem_fini(g, 0);
|
|
fail_kmem:
|
|
free(p);
|
|
|
|
return NULL;
|
|
}
|
|
|
|
void nvgpu_posix_cleanup(struct gk20a *g)
|
|
{
|
|
struct nvgpu_os_posix *p = nvgpu_os_posix_from_gk20a(g);
|
|
|
|
nvgpu_kmem_fini(g, 0);
|
|
nvgpu_free_enabled_flags(g);
|
|
free(p);
|
|
}
|