From 69be500c0b6fab324a34fc0b0f6b80f21a128c7e Mon Sep 17 00:00:00 2001 From: seshendra Gadagottu Date: Mon, 9 Jul 2018 16:25:40 -0700 Subject: gpu: nvgpu: debugfs node to enable/disable ltc_illegal_compstat intr Added debugfs node under ltc directory with name: intr_illegal_compstat_enable Enabling/disabling of ltc_illegal_compstat intr is possible through debugfs node. Since ltc state is lost with rail gate, this setting is cached and will be populated during ltc initialization. Bug 2099406 Change-Id: I4bf62228dfd2bbb94f87f923f9f4f6e5ad0b07f0 Signed-off-by: seshendra Gadagottu Reviewed-on: https://git-master.nvidia.com/r/1774683 Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/Makefile | 1 + drivers/gpu/nvgpu/gk20a/gk20a.h | 3 ++ drivers/gpu/nvgpu/gv100/hal_gv100.c | 1 + drivers/gpu/nvgpu/gv11b/hal_gv11b.c | 1 + drivers/gpu/nvgpu/gv11b/ltc_gv11b.c | 23 ++++++++- drivers/gpu/nvgpu/gv11b/ltc_gv11b.h | 3 +- drivers/gpu/nvgpu/os/linux/debug.c | 2 + drivers/gpu/nvgpu/os/linux/debug_ltc.c | 93 ++++++++++++++++++++++++++++++++++ drivers/gpu/nvgpu/os/linux/debug_ltc.h | 21 ++++++++ drivers/gpu/nvgpu/os/linux/os_linux.h | 1 + 10 files changed, 147 insertions(+), 2 deletions(-) create mode 100644 drivers/gpu/nvgpu/os/linux/debug_ltc.c create mode 100644 drivers/gpu/nvgpu/os/linux/debug_ltc.h (limited to 'drivers/gpu') diff --git a/drivers/gpu/nvgpu/Makefile b/drivers/gpu/nvgpu/Makefile index 90858e55..aa780f55 100644 --- a/drivers/gpu/nvgpu/Makefile +++ b/drivers/gpu/nvgpu/Makefile @@ -86,6 +86,7 @@ nvgpu-$(CONFIG_DEBUG_FS) += \ os/linux/debug_hal.o \ os/linux/debug_clk.o \ os/linux/debug_bios.o \ + os/linux/debug_ltc.o \ os/linux/debug_xve.o ifeq ($(CONFIG_NVGPU_TRACK_MEM_USAGE),y) diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.h b/drivers/gpu/nvgpu/gk20a/gk20a.h index 4934958c..afd18658 100644 --- a/drivers/gpu/nvgpu/gk20a/gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/gk20a.h @@ -189,6 +189,7 @@ struct gpu_ops { void (*isr)(struct gk20a *g); u32 (*cbc_fix_config)(struct gk20a *g, int base); void (*flush)(struct gk20a *g); + void (*intr_en_illegal_compstat)(struct gk20a *g, bool enable); } ltc; struct { void (*isr_stall)(struct gk20a *g, u32 inst_id, u32 pri_base); @@ -1547,6 +1548,8 @@ struct gk20a { struct gk20a_ce_app ce_app; + bool ltc_intr_en_illegal_compstat; + /* PCI device identifier */ u16 pci_vendor_id, pci_device_id; u16 pci_subsystem_vendor_id, pci_subsystem_device_id; diff --git a/drivers/gpu/nvgpu/gv100/hal_gv100.c b/drivers/gpu/nvgpu/gv100/hal_gv100.c index 09a96d40..6ebf1675 100644 --- a/drivers/gpu/nvgpu/gv100/hal_gv100.c +++ b/drivers/gpu/nvgpu/gv100/hal_gv100.c @@ -283,6 +283,7 @@ static const struct gpu_ops gv100_ops = { .cbc_fix_config = NULL, .flush = gm20b_flush_ltc, .set_enabled = gp10b_ltc_set_enabled, + .intr_en_illegal_compstat = gv11b_ltc_intr_en_illegal_compstat, }, .ce2 = { .isr_stall = gv11b_ce_isr, diff --git a/drivers/gpu/nvgpu/gv11b/hal_gv11b.c b/drivers/gpu/nvgpu/gv11b/hal_gv11b.c index 08c3097e..0508452c 100644 --- a/drivers/gpu/nvgpu/gv11b/hal_gv11b.c +++ b/drivers/gpu/nvgpu/gv11b/hal_gv11b.c @@ -241,6 +241,7 @@ static const struct gpu_ops gv11b_ops = { .isr = gv11b_ltc_isr, .flush = gm20b_flush_ltc, .set_enabled = gp10b_ltc_set_enabled, + .intr_en_illegal_compstat = gv11b_ltc_intr_en_illegal_compstat, }, .ce2 = { .isr_stall = gv11b_ce_isr, diff --git a/drivers/gpu/nvgpu/gv11b/ltc_gv11b.c b/drivers/gpu/nvgpu/gv11b/ltc_gv11b.c index 3cea4cd4..a040de23 100644 --- a/drivers/gpu/nvgpu/gv11b/ltc_gv11b.c +++ b/drivers/gpu/nvgpu/gv11b/ltc_gv11b.c @@ -70,10 +70,13 @@ void gv11b_ltc_init_fs_state(struct gk20a *g) /* Disable LTC interrupts */ reg = gk20a_readl(g, ltc_ltcs_ltss_intr_r()); reg &= ~ltc_ltcs_ltss_intr_en_evicted_cb_m(); - reg &= ~ltc_ltcs_ltss_intr_en_illegal_compstat_m(); reg &= ~ltc_ltcs_ltss_intr_en_illegal_compstat_access_m(); nvgpu_writel_check(g, ltc_ltcs_ltss_intr_r(), reg); + if (g->ops.ltc.intr_en_illegal_compstat) + g->ops.ltc.intr_en_illegal_compstat(g, + g->ltc_intr_en_illegal_compstat); + /* Enable ECC interrupts */ ltc_intr = gk20a_readl(g, ltc_ltcs_ltss_intr_r()); ltc_intr |= ltc_ltcs_ltss_intr_en_ecc_sec_error_enabled_f() | @@ -82,6 +85,24 @@ void gv11b_ltc_init_fs_state(struct gk20a *g) ltc_intr); } +void gv11b_ltc_intr_en_illegal_compstat(struct gk20a *g, bool enable) +{ + u32 val; + + /* disble/enble illegal_compstat interrupt */ + val = gk20a_readl(g, ltc_ltcs_ltss_intr_r()); + if (enable) + val = set_field(val, + ltc_ltcs_ltss_intr_en_illegal_compstat_m(), + ltc_ltcs_ltss_intr_en_illegal_compstat_enabled_f()); + else + val = set_field(val, + ltc_ltcs_ltss_intr_en_illegal_compstat_m(), + ltc_ltcs_ltss_intr_en_illegal_compstat_disabled_f()); + gk20a_writel(g, ltc_ltcs_ltss_intr_r(), val); +} + + void gv11b_ltc_isr(struct gk20a *g) { u32 mc_intr, ltc_intr3; diff --git a/drivers/gpu/nvgpu/gv11b/ltc_gv11b.h b/drivers/gpu/nvgpu/gv11b/ltc_gv11b.h index 8309e662..9d33b9fb 100644 --- a/drivers/gpu/nvgpu/gv11b/ltc_gv11b.h +++ b/drivers/gpu/nvgpu/gv11b/ltc_gv11b.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2016-2018, 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"), @@ -28,6 +28,7 @@ void gv11b_ltc_set_zbc_stencil_entry(struct gk20a *g, struct zbc_entry *stencil_val, u32 index); void gv11b_ltc_init_fs_state(struct gk20a *g); +void gv11b_ltc_intr_en_illegal_compstat(struct gk20a *g, bool enable); void gv11b_ltc_isr(struct gk20a *g); #endif diff --git a/drivers/gpu/nvgpu/os/linux/debug.c b/drivers/gpu/nvgpu/os/linux/debug.c index c4dae9e6..9403e72e 100644 --- a/drivers/gpu/nvgpu/os/linux/debug.c +++ b/drivers/gpu/nvgpu/os/linux/debug.c @@ -22,6 +22,7 @@ #include "debug_sched.h" #include "debug_hal.h" #include "debug_xve.h" +#include "debug_ltc.h" #include "debug_bios.h" #include "os_linux.h" #include "platform_gk20a.h" @@ -435,6 +436,7 @@ void gk20a_debug_init(struct gk20a *g, const char *debugfs_symlink) #ifdef CONFIG_NVGPU_TRACK_MEM_USAGE nvgpu_kmem_debugfs_init(g); #endif + nvgpu_ltc_debugfs_init(g); if (g->pci_vendor_id) { nvgpu_xve_debugfs_init(g); nvgpu_bios_debugfs_init(g); diff --git a/drivers/gpu/nvgpu/os/linux/debug_ltc.c b/drivers/gpu/nvgpu/os/linux/debug_ltc.c new file mode 100644 index 00000000..88fb45f4 --- /dev/null +++ b/drivers/gpu/nvgpu/os/linux/debug_ltc.c @@ -0,0 +1,93 @@ +/* + * Copyright (C) 2018 NVIDIA Corporation. All rights reserved. + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include "debug_ltc.h" +#include "os_linux.h" +#include "gk20a/gk20a.h" + +#include +#include + +static ssize_t ltc_intr_illegal_compstat_read(struct file *file, + char __user *user_buf, size_t count, loff_t *ppos) +{ + char buf[3]; + struct gk20a *g = file->private_data; + + if (g->ltc_intr_en_illegal_compstat) + buf[0] = 'Y'; + else + buf[0] = 'N'; + buf[1] = '\n'; + buf[2] = 0x00; + + return simple_read_from_buffer(user_buf, count, ppos, buf, 2); +} + +static ssize_t ltc_intr_illegal_compstat_write(struct file *file, + const char __user *user_buf, size_t count, loff_t *ppos) +{ + char buf[3]; + int buf_size; + bool intr_illegal_compstat_enabled; + struct gk20a *g = file->private_data; + int err; + + if (!g->ops.ltc.intr_en_illegal_compstat) + return -EINVAL; + + buf_size = min(count, (sizeof(buf)-1)); + if (copy_from_user(buf, user_buf, buf_size)) + return -EFAULT; + + err = gk20a_busy(g); + if (err) + return err; + + if (strtobool(buf, &intr_illegal_compstat_enabled) == 0) { + g->ops.ltc.intr_en_illegal_compstat(g, + intr_illegal_compstat_enabled); + g->ltc_intr_en_illegal_compstat = intr_illegal_compstat_enabled; + } + + gk20a_idle(g); + + return buf_size; +} + +static const struct file_operations ltc_intr_illegal_compstat_fops = { + .open = simple_open, + .read = ltc_intr_illegal_compstat_read, + .write = ltc_intr_illegal_compstat_write, +}; + +int nvgpu_ltc_debugfs_init(struct gk20a *g) +{ + struct dentry *d; + struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g); + struct dentry *gpu_root = l->debugfs; + + l->debugfs_ltc = debugfs_create_dir("ltc", gpu_root); + if (IS_ERR_OR_NULL(l->debugfs_ltc)) + return -ENODEV; + + /* Debug fs node to enable/disable illegal_compstat */ + d = debugfs_create_file("intr_illegal_compstat_enable", 0600, + l->debugfs_ltc, g, + <c_intr_illegal_compstat_fops); + if (!d) + return -ENOMEM; + + return 0; +} diff --git a/drivers/gpu/nvgpu/os/linux/debug_ltc.h b/drivers/gpu/nvgpu/os/linux/debug_ltc.h new file mode 100644 index 00000000..3ad734ce --- /dev/null +++ b/drivers/gpu/nvgpu/os/linux/debug_ltc.h @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2018 NVIDIA Corporation. All rights reserved. + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#ifndef __NVGPU_DEBUG_LTC_H__ +#define __NVGPU_DEBUG_LTC_H__ + +struct gk20a; +int nvgpu_ltc_debugfs_init(struct gk20a *g); + +#endif /* __NVGPU_DEBUG_LTC_H__ */ diff --git a/drivers/gpu/nvgpu/os/linux/os_linux.h b/drivers/gpu/nvgpu/os/linux/os_linux.h index 85d697bd..13c20a81 100644 --- a/drivers/gpu/nvgpu/os/linux/os_linux.h +++ b/drivers/gpu/nvgpu/os/linux/os_linux.h @@ -135,6 +135,7 @@ struct nvgpu_os_linux { struct dentry *debugfs_xve; struct dentry *debugfs_kmem; struct dentry *debugfs_hal; + struct dentry *debugfs_ltc; struct dentry *debugfs_force_preemption_cilp; struct dentry *debugfs_force_preemption_gfxp; -- cgit v1.2.2