mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-23 01:50:07 +03:00
All graphics code is under CONFIG_NVGPU_GRAPHICS and all the HALs are in non-fusa files. In order to support graphics in safety, CONFIG_NVGPU_GRAPHICS needs to be enabled. But since most of the HALs are in non-fusa files, this causes huge compilation problem. Fix this by moving all graphics specific HALs used on gv11b to fusa files. Graphics specific HALs not used on gv11b remain in non-fusa files and need not be protected with GRAPHICS config. Protect call to nvgpu_pmu_save_zbc() also with config CONFIG_NVGPU_POWER_PG, since it is implemented under that config. Delete hal/ltc/ltc_gv11b.c since sole function in this file is moved to fusa file. Enable nvgpu_writel_loop() in safety build since it is needed for now. This will be revisited later once requirements are clearer. Move below CTXSW methods under CONFIG_NVGPU_NON_FUSA for now. Safety CTXSW ucode does not support these methods. These too will be revisited later once requirements are clearer. NVGPU_GR_FALCON_METHOD_PREEMPT_IMAGE_SIZE NVGPU_GR_FALCON_METHOD_CTXSW_DISCOVER_ZCULL_IMAGE_SIZE Jira NVGPU-6460 Change-Id: Ia095a04a9ba67126068aa7193f491ea27477f882 Signed-off-by: Deepak Nibade <dnibade@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2513675 Tested-by: mobile promotions <svcmobile_promotions@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
164 lines
4.0 KiB
C
164 lines
4.0 KiB
C
/*
|
|
* Copyright (c) 2018-2021, 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 <nvgpu/io.h>
|
|
#include <nvgpu/types.h>
|
|
#include <nvgpu/bug.h>
|
|
#include <nvgpu/gk20a.h>
|
|
#include <nvgpu/nvgpu_init.h>
|
|
|
|
static void nvgpu_warn_on_no_regs(struct gk20a *g)
|
|
{
|
|
nvgpu_warn(g, "Attempted access to GPU regs after unmapping!");
|
|
}
|
|
|
|
void nvgpu_writel(struct gk20a *g, u32 r, u32 v)
|
|
{
|
|
if (unlikely(!g->regs)) {
|
|
nvgpu_warn_on_no_regs(g);
|
|
nvgpu_log(g, gpu_dbg_reg, "r=0x%x v=0x%x (failed)", r, v);
|
|
} else {
|
|
nvgpu_os_writel(v, g->regs + r);
|
|
nvgpu_wmb();
|
|
nvgpu_log(g, gpu_dbg_reg, "r=0x%x v=0x%x", r, v);
|
|
}
|
|
}
|
|
|
|
#ifdef CONFIG_NVGPU_DGPU
|
|
void nvgpu_writel_relaxed(struct gk20a *g, u32 r, u32 v)
|
|
{
|
|
if (unlikely(!g->regs)) {
|
|
nvgpu_warn_on_no_regs(g);
|
|
nvgpu_log(g, gpu_dbg_reg, "r=0x%x v=0x%x (failed)", r, v);
|
|
} else {
|
|
nvgpu_os_writel_relaxed(v, g->regs + r);
|
|
}
|
|
}
|
|
#endif
|
|
|
|
u32 nvgpu_readl(struct gk20a *g, u32 r)
|
|
{
|
|
u32 v = nvgpu_readl_impl(g, r);
|
|
|
|
if (v == 0xffffffff)
|
|
nvgpu_check_gpu_state(g);
|
|
|
|
return v;
|
|
}
|
|
|
|
u32 nvgpu_readl_impl(struct gk20a *g, u32 r)
|
|
{
|
|
u32 v = 0xffffffff;
|
|
|
|
if (unlikely(!g->regs)) {
|
|
nvgpu_warn_on_no_regs(g);
|
|
nvgpu_log(g, gpu_dbg_reg, "r=0x%x v=0x%x (failed)", r, v);
|
|
} else {
|
|
v = nvgpu_os_readl(g->regs + r);
|
|
nvgpu_log(g, gpu_dbg_reg, "r=0x%x v=0x%x", r, v);
|
|
}
|
|
|
|
return v;
|
|
}
|
|
|
|
void nvgpu_writel_loop(struct gk20a *g, u32 r, u32 v)
|
|
{
|
|
if (unlikely(!g->regs)) {
|
|
nvgpu_warn_on_no_regs(g);
|
|
nvgpu_log(g, gpu_dbg_reg, "r=0x%x v=0x%x (failed)", r, v);
|
|
} else {
|
|
nvgpu_wmb();
|
|
do {
|
|
nvgpu_os_writel(v, g->regs + r);
|
|
} while (nvgpu_os_readl(g->regs + r) != v);
|
|
nvgpu_log(g, gpu_dbg_reg, "r=0x%x v=0x%x", r, v);
|
|
}
|
|
}
|
|
|
|
void nvgpu_bar1_writel(struct gk20a *g, u32 b, u32 v)
|
|
{
|
|
if (unlikely(!g->bar1)) {
|
|
nvgpu_warn_on_no_regs(g);
|
|
nvgpu_log(g, gpu_dbg_reg, "b=0x%x v=0x%x (failed)", b, v);
|
|
} else {
|
|
nvgpu_wmb();
|
|
nvgpu_os_writel(v, g->bar1 + b);
|
|
nvgpu_log(g, gpu_dbg_reg, "b=0x%x v=0x%x", b, v);
|
|
}
|
|
}
|
|
|
|
u32 nvgpu_bar1_readl(struct gk20a *g, u32 b)
|
|
{
|
|
u32 v = 0xffffffff;
|
|
|
|
if (unlikely(!g->bar1)) {
|
|
nvgpu_warn_on_no_regs(g);
|
|
nvgpu_log(g, gpu_dbg_reg, "b=0x%x v=0x%x (failed)", b, v);
|
|
} else {
|
|
v = nvgpu_os_readl(g->bar1 + b);
|
|
nvgpu_log(g, gpu_dbg_reg, "b=0x%x v=0x%x", b, v);
|
|
}
|
|
|
|
return v;
|
|
}
|
|
|
|
bool nvgpu_io_exists(struct gk20a *g)
|
|
{
|
|
return g->regs != 0U;
|
|
}
|
|
|
|
bool nvgpu_io_valid_reg(struct gk20a *g, u32 r)
|
|
{
|
|
return r < g->regs_size;
|
|
}
|
|
|
|
void nvgpu_writel_check(struct gk20a *g, u32 r, u32 v)
|
|
{
|
|
u32 read_val = 0U;
|
|
|
|
nvgpu_writel(g, r, v);
|
|
read_val = nvgpu_readl(g, r);
|
|
if (v != read_val) {
|
|
nvgpu_err(g, "r=0x%x rd=0x%x wr=0x%x (mismatch)",
|
|
r, read_val, v);
|
|
BUG_ON(1);
|
|
}
|
|
}
|
|
|
|
void nvgpu_func_writel(struct gk20a *g, u32 r, u32 v)
|
|
{
|
|
if (g->ops.func.get_full_phys_offset == NULL) {
|
|
BUG_ON(1);
|
|
}
|
|
nvgpu_writel(g,
|
|
nvgpu_safe_add_u32(r, g->ops.func.get_full_phys_offset(g)), v);
|
|
}
|
|
|
|
u32 nvgpu_func_readl(struct gk20a *g, u32 r)
|
|
{
|
|
if (g->ops.func.get_full_phys_offset == NULL) {
|
|
BUG_ON(1);
|
|
}
|
|
return nvgpu_readl(g,
|
|
nvgpu_safe_add_u32(r, g->ops.func.get_full_phys_offset(g)));
|
|
}
|