Skip to contentSkip to conversation

thunderbolt: Expose router DROM through debugfs

PATCH Applied Mika Westerberg 1 participant 2 messages Dec 27, 2024 – Jan 5, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 thunderbolt: Expose router DROM through debugfs

Router DROM contains information that might be usable for development and debugging purposes. For example when new entries are added to the USB4 spec it is useful to be able to look for them without need to change the kernel.

For this reason expose the DROM through debugfs.

---
 drivers/thunderbolt/debugfs.c |  2 +
 drivers/thunderbolt/eeprom.c  | 78 ++++++++++++++++++++---------------
 drivers/thunderbolt/tb.h      |  5 +++
 3 files changed, 51 insertions(+), 34 deletions(-)
drivers/thunderbolt/debugfs.c +2 -0
index fa61127b2c47..f8328ca7e22e 100644
@@ -2413,6 +2413,8 @@ void tb_switch_debugfs_init(struct tb_switch *sw)
 	sw->debugfs_dir = debugfs_dir;
 	debugfs_create_file("regs", DEBUGFS_MODE, debugfs_dir, sw,
 			    &switch_regs_fops);
+	if (sw->drom)
+		debugfs_create_blob("drom", 0400, debugfs_dir, &sw->drom_blob);
 
 	tb_switch_for_each_port(sw, port) {
 		struct dentry *debugfs_dir;
drivers/thunderbolt/eeprom.c +44 -34

134 lines not on this page · raw message

drivers/thunderbolt/tb.h +5 -0
index ddbf0cd78377..b54147a1ba87 100644
@@ -9,6 +9,7 @@
 #ifndef TB_H_
 #define TB_H_
 
+#include <linux/debugfs.h>
 #include <linux/nvmem-provider.h>
 #include <linux/pci.h>
 #include <linux/thunderbolt.h>
@@ -160,6 +161,7 @@ struct tb_switch_tmu {
  * @max_pcie_credits: Router preferred number of buffers for PCIe
  * @max_dma_credits: Router preferred number of buffers for DMA/P2P
  * @clx: CLx states on the upstream link of the router
+ * @drom_blob: DROM debugfs blob wrapper
  *
  * When the switch is being added or removed to the domain (other
  * switches) you need to have domain lock held.
@@ -212,6 +214,9 @@ struct tb_switch {
 	unsigned int max_pcie_credits;
 	unsigned int max_dma_credits;
 	unsigned int clx;
+#ifdef CONFIG_DEBUG_FS
+	struct debugfs_blob_wrapper drom_blob;
+#endif
 };
 
 /**
Signature · 1 line
2.45.2
author Applied
#1 lore raw
Quoted 8 lines · Mika Westerberg

Router DROM contains information that might be usable for development and debugging purposes. For example when new entries are added to the USB4 spec it is useful to be able to look for them without need to change the kernel.

For this reason expose the DROM through debugfs.

Applied to thunderbolt.git/next.