summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoshua Bakita <bakitajoshua@gmail.com>2023-10-05 14:58:19 -0400
committerJoshua Bakita <bakitajoshua@gmail.com>2023-10-05 14:58:19 -0400
commitaa06f84f03cba7ad1aae5cd527355bb3d8c152a6 (patch)
tree7e894c28e5f0e5311b8738cd195da8313733f095
parentef96c6b7ebc32b0f839fd5339f11d8f25b8e6d62 (diff)
Only log interrupts if explictly enabled
-rw-r--r--nvdebug_entry.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/nvdebug_entry.c b/nvdebug_entry.c
index 8e8266c..4eb44a2 100644
--- a/nvdebug_entry.c
+++ b/nvdebug_entry.c
@@ -12,6 +12,9 @@
12#include "nvdebug.h" 12#include "nvdebug.h"
13#include "stubs.h" 13#include "stubs.h"
14 14
15// Enable to intercept and log GPU interrupts
16#define INTERRUPT_DEBUG 0
17
15// MIT is GPL-compatible. We need to be GPL-compatible for symbols like 18// MIT is GPL-compatible. We need to be GPL-compatible for symbols like
16// platform_bus_type or bus_find_device_by_name... 19// platform_bus_type or bus_find_device_by_name...
17MODULE_LICENSE("Dual MIT/GPL"); 20MODULE_LICENSE("Dual MIT/GPL");
@@ -50,11 +53,12 @@ const struct file_operations* compat_ops(const struct file_operations* ops) {
50} 53}
51#endif 54#endif
52 55
53// TEMP 56#if INTERRUPT_DEBUG
54irqreturn_t nvdebug_irq_tap(int irq_num, void * dev) { 57irqreturn_t nvdebug_irq_tap(int irq_num, void * dev) {
55 printk(KERN_INFO "[nvdebug] Interrupt tap triggered on IRQ %d.\n", irq_num); 58 printk(KERN_INFO "[nvdebug] Interrupt tap triggered on IRQ %d.\n", irq_num);
56 return IRQ_NONE; // We don't actually handle any interrupts. Pass them on. 59 return IRQ_NONE; // We don't actually handle any interrupts. Pass them on.
57} 60}
61#endif // INTERRUPT_DEBUG
58 62
59// Find any and all NVIDIA GPUs in the system 63// Find any and all NVIDIA GPUs in the system
60// Note: This function fails if any of them are in a bad state 64// Note: This function fails if any of them are in a bad state
@@ -125,10 +129,11 @@ int probe_and_cache_device(void) {
125 g_nvdebug_state[i].chip_id = ids.chip_id; 129 g_nvdebug_state[i].chip_id = ids.chip_id;
126 printk(KERN_INFO "[nvdebug] Chip ID %x (architecture %s) detected on PCI bus and initialized.", 130 printk(KERN_INFO "[nvdebug] Chip ID %x (architecture %s) detected on PCI bus and initialized.",
127 ids.chip_id, ARCH2NAME(ids.architecture)); 131 ids.chip_id, ARCH2NAME(ids.architecture));
128 // TEMP 132#if INTERRUPT_DEBUG
129 if (request_irq(pcid->irq, nvdebug_irq_tap, IRQF_SHARED, "nvdebug tap", pcid)) { 133 if (request_irq(pcid->irq, nvdebug_irq_tap, IRQF_SHARED, "nvdebug tap", pcid)) {
130 printk(KERN_WARNING "[nvdebug] Unable to initialize IRQ tap\n"); 134 printk(KERN_WARNING "[nvdebug] Unable to initialize IRQ tap\n");
131 } 135 }
136#endif // INTERRUPT_DEBUG
132 i++; 137 i++;
133 } 138 }
134 // Return the number of devices we found 139 // Return the number of devices we found
@@ -294,8 +299,9 @@ static void __exit nvdebug_exit(void) {
294 pci_iounmap(g->pcid, g->regs); 299 pci_iounmap(g->pcid, g->regs);
295 if (g && g->bar2) 300 if (g && g->bar2)
296 pci_iounmap(g->pcid, g->bar2); 301 pci_iounmap(g->pcid, g->bar2);
297 // TEMP 302#if INTERRUPT_DEBUG
298 free_irq(g->pcid->irq, g->pcid); 303 free_irq(g->pcid->irq, g->pcid);
304#endif // INTERRUPT_DEBUG
299 } 305 }
300 printk(KERN_INFO "[nvdebug] Chip ID %x deinitialized.", g->chip_id); 306 printk(KERN_INFO "[nvdebug] Chip ID %x deinitialized.", g->chip_id);
301 } 307 }