From aa06f84f03cba7ad1aae5cd527355bb3d8c152a6 Mon Sep 17 00:00:00 2001 From: Joshua Bakita Date: Thu, 5 Oct 2023 14:58:19 -0400 Subject: Only log interrupts if explictly enabled --- nvdebug_entry.c | 12 +++++++++--- 1 file 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 @@ #include "nvdebug.h" #include "stubs.h" +// Enable to intercept and log GPU interrupts +#define INTERRUPT_DEBUG 0 + // MIT is GPL-compatible. We need to be GPL-compatible for symbols like // platform_bus_type or bus_find_device_by_name... MODULE_LICENSE("Dual MIT/GPL"); @@ -50,11 +53,12 @@ const struct file_operations* compat_ops(const struct file_operations* ops) { } #endif -// TEMP +#if INTERRUPT_DEBUG irqreturn_t nvdebug_irq_tap(int irq_num, void * dev) { printk(KERN_INFO "[nvdebug] Interrupt tap triggered on IRQ %d.\n", irq_num); return IRQ_NONE; // We don't actually handle any interrupts. Pass them on. } +#endif // INTERRUPT_DEBUG // Find any and all NVIDIA GPUs in the system // Note: This function fails if any of them are in a bad state @@ -125,10 +129,11 @@ int probe_and_cache_device(void) { g_nvdebug_state[i].chip_id = ids.chip_id; printk(KERN_INFO "[nvdebug] Chip ID %x (architecture %s) detected on PCI bus and initialized.", ids.chip_id, ARCH2NAME(ids.architecture)); - // TEMP +#if INTERRUPT_DEBUG if (request_irq(pcid->irq, nvdebug_irq_tap, IRQF_SHARED, "nvdebug tap", pcid)) { printk(KERN_WARNING "[nvdebug] Unable to initialize IRQ tap\n"); } +#endif // INTERRUPT_DEBUG i++; } // Return the number of devices we found @@ -294,8 +299,9 @@ static void __exit nvdebug_exit(void) { pci_iounmap(g->pcid, g->regs); if (g && g->bar2) pci_iounmap(g->pcid, g->bar2); - // TEMP +#if INTERRUPT_DEBUG free_irq(g->pcid->irq, g->pcid); +#endif // INTERRUPT_DEBUG } printk(KERN_INFO "[nvdebug] Chip ID %x deinitialized.", g->chip_id); } -- cgit v1.2.2