aboutsummaryrefslogtreecommitdiffstats
path: root/nvdebug.h
diff options
context:
space:
mode:
authorJoshua Bakita <jbakita@cs.unc.edu>2023-06-29 17:09:54 -0400
committerJoshua Bakita <jbakita@cs.unc.edu>2023-06-29 17:14:49 -0400
commita3fe3788535dd099d15e0ddca455be58e1d63156 (patch)
tree414b93951935d9e434c78c68326af1f59fa54d5a /nvdebug.h
parent7e8fc4f9ae9fb4424aab73622cd9d7b89390dcb3 (diff)
Hacky support for Linux 5.6+ and the Jetson AGX Orin
Works around change in parameters to proc initialization functions via a hacky function which rewrites the layout. This also required making all the struct file_operations writable. Also start reducing dependency on nvgpu headers. Known issues: - Incorrect message printed in log after module is loaded. Unclear if this is because the register detection logic is broken, or if the layout of the data at NV_MC_BOOT_0 has changed. - Not tested
Diffstat (limited to 'nvdebug.h')
-rw-r--r--nvdebug.h14
1 files changed, 13 insertions, 1 deletions
diff --git a/nvdebug.h b/nvdebug.h
index 1882756..968a60b 100644
--- a/nvdebug.h
+++ b/nvdebug.h
@@ -4,8 +4,10 @@
4 4
5// TODO(jbakita): Don't depend on these. 5// TODO(jbakita): Don't depend on these.
6#include <nvgpu/gk20a.h> // For struct gk20a 6#include <nvgpu/gk20a.h> // For struct gk20a
7#include <os/linux/os_linux.h> // For struct nvgpu_os_linux
8#include <linux/proc_fs.h> // For PDE_DATA() macro 7#include <linux/proc_fs.h> // For PDE_DATA() macro
8#include <linux/device.h> // For dev_get_drvdata()
9#include <linux/version.h> // For KERNEL_VERSION and LINUX_VERSION_CODE
10#include <asm/io.h>
9 11
10/* Runlist Channel 12/* Runlist Channel
11 A timeslice group (TSG) is composed of channels. Each channel is a FIFO queue 13 A timeslice group (TSG) is composed of channels. Each channel is a FIFO queue
@@ -943,7 +945,17 @@ static inline int file2parentgpuidx(const struct file *f) {
943 return (uintptr_t)PDE_DATA(file_dentry(f)->d_parent->d_inode); 945 return (uintptr_t)PDE_DATA(file_dentry(f)->d_parent->d_inode);
944} 946}
945 947
948#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,6,0)
949// Commit 643eb158a3 in nvgpu moved the mapped registers to the second entry
950// of the gk20a struct (after a function pointer). This change was made as L4T
951// was upgraded from Linux 4.9 to 5.10 (r32 -> r34+)
952// Note that this is wrong if nvgpu was built without CONFIG_NVGPU_NON_FUSA
953// i.e. if FUSA was enabled, this is wrong.
954#define gk20a_regs(gk20a) ((void*)gk20a + sizeof(void(*)(void)))
955#else
956#include <os/linux/os_linux.h> // For struct nvgpu_os_linux, which holds regs
946#define gk20a_regs(gk20a) (container_of(gk20a, struct nvgpu_os_linux, g)->regs) 957#define gk20a_regs(gk20a) (container_of(gk20a, struct nvgpu_os_linux, g)->regs)
958#endif
947 959
948// Similar to nvgpu_readl() 960// Similar to nvgpu_readl()
949// (except we don't try to resolve situations where regs is NULL) 961// (except we don't try to resolve situations where regs is NULL)