Skip to contentSkip to conversation

ath9k: create a common debugfs_root for all device instances

PATCH New Gabor Juhos 2 participants 3 messages Mar 5, 2009 Networking drivers (wireless)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ath9k: create a common debugfs_root for all device instances

The driver are trying to create an 'ath9k' directory in debugfs for each device currently. If there are more than one device in the system, the second try will always fail.

Changes-licensed-under: ISC

---
 drivers/net/wireless/ath9k/debug.c |   24 ++++++++++++++++++------
 drivers/net/wireless/ath9k/debug.h |   12 +++++++++++-
 drivers/net/wireless/ath9k/main.c  |   13 ++++++++++++-
 3 files changed, 41 insertions(+), 8 deletions(-)
drivers/net/wireless/ath9k/debug.c +18 -6
index 0c422c5..3b645ee 100644
@@ -19,6 +19,8 @@
 static unsigned int ath9k_debug = DBG_DEFAULT;
 module_param_named(debug, ath9k_debug, uint, 0);
 
+static struct dentry *ath9k_debugfs_root;
+
 void DPRINTF(struct ath_softc *sc, int dbg_mask, const char *fmt, ...)
 {
 	if (!sc)
@@ -334,12 +336,8 @@ int ath9k_init_debug(struct ath_softc *sc)
 {
 	sc->debug.debug_mask = ath9k_debug;
 
-	sc->debug.debugfs_root = debugfs_create_dir(KBUILD_MODNAME, NULL);
-	if (!sc->debug.debugfs_root)
-		goto err;
-
 	sc->debug.debugfs_phy = debugfs_create_dir(wiphy_name(sc->hw->wiphy),
-						      sc->debug.debugfs_root);
+						      ath9k_debugfs_root);
 	if (!sc->debug.debugfs_phy)
 		goto err;
 
@@ -374,5 +372,19 @@ void ath9k_exit_debug(struct ath_softc *sc)
 	debugfs_remove(sc->debug.debugfs_interrupt);
 	debugfs_remove(sc->debug.debugfs_dma);
 	debugfs_remove(sc->debug.debugfs_phy);
-	debugfs_remove(sc->debug.debugfs_root);
+}
+
+int ath9k_debug_create_root(void)
+{
+	ath9k_debugfs_root = debugfs_create_dir(KBUILD_MODNAME, NULL);
+	if (!ath9k_debugfs_root)
+		return -ENOENT;
+
+	return 0;
+}
+
+void ath9k_debug_remove_root(void)
+{
+	debugfs_remove(ath9k_debugfs_root);
+	ath9k_debugfs_root = NULL;
 }
drivers/net/wireless/ath9k/debug.h +11 -1
index 01681f2..89ba818 100644
@@ -102,7 +102,6 @@ struct ath_stats {
 
 struct ath9k_debug {
 	int debug_mask;
-	struct dentry *debugfs_root;
 	struct dentry *debugfs_phy;
 	struct dentry *debugfs_dma;
 	struct dentry *debugfs_interrupt;
@@ -113,6 +112,8 @@ struct ath9k_debug {
 void DPRINTF(struct ath_softc *sc, int dbg_mask, const char *fmt, ...);
 int ath9k_init_debug(struct ath_softc *sc);
 void ath9k_exit_debug(struct ath_softc *sc);
+int ath9k_debug_create_root(void);
+void ath9k_debug_remove_root(void);
 void ath_debug_stat_interrupt(struct ath_softc *sc, enum ath9k_int status);
 void ath_debug_stat_rc(struct ath_softc *sc, struct sk_buff *skb);
 void ath_debug_stat_retries(struct ath_softc *sc, int rix,
@@ -134,6 +135,15 @@ static inline void ath9k_exit_debug(struct ath_softc *sc)
 {
 }
 
+static inline int ath9k_debug_create_root(void)
+{
+	return 0;
+}
+
+static inline void ath9k_debug_remove_root(void)
+{
+}
+
 static inline void ath_debug_stat_interrupt(struct ath_softc *sc,
 					    enum ath9k_int status)
 {
drivers/net/wireless/ath9k/main.c +12 -1
index 28200ce..d37924a 100644
@@ -2712,12 +2712,20 @@ static int __init ath9k_init(void)
 		goto err_out;
 	}
 
+	error = ath9k_debug_create_root();
+	if (error) {
+		printk(KERN_ERR
+			"ath9k: Unable to create debugfs root: %d\n",
+			error);
+		goto err_rate_unregister;
+	}
+
 	error = ath_pci_init();
 	if (error < 0) {
 		printk(KERN_ERR
 			"ath9k: No PCI devices found, driver not installed.\n");
 		error = -ENODEV;
-		goto err_rate_unregister;
+		goto err_remove_root;
 	}
 
 	error = ath_ahb_init();
@@ -2731,6 +2739,8 @@ static int __init ath9k_init(void)
  err_pci_exit:
 	ath_pci_exit();
 
+ err_remove_root:
+	ath9k_debug_remove_root();
  err_rate_unregister:
 	ath_rate_control_unregister();
  err_out:
@@ -2742,6 +2752,7 @@ static void __exit ath9k_exit(void)
 {
 	ath_ahb_exit();
 	ath_pci_exit();
+	ath9k_debug_remove_root();
 	ath_rate_control_unregister();
 	printk(KERN_INFO "%s: Driver unloaded\n", dev_info);
 }
Signature · 1 line
1.5.3.2
#1 lore raw

PATCH 1/1 ath9k: create a common debugfs_root for all device instances

Quoted 3 lines · Gabor Juhos

The driver are trying to create an 'ath9k' directory in debugfs for each device currently. If there are more than one device in the system, the second try will always fail.

Looks good. Thanks.

Also, reading 'rcstat' when the interface is down would cause a NULL pointer dereference. Will send out a patch fixing this.

Sujith

#2 lore raw

PATCH 1/1 ath9k: create a common debugfs_root for all device instances

Sujith ?rta:

Quoted 6 lines
Quoted 3 lines · Gabor Juhos

The driver are trying to create an 'ath9k' directory in debugfs for each device currently. If there are more than one device in the system, the second try will always fail.

Looks good. Thanks.

Thank you for the review.

Quoted 3 lines

Also, reading 'rcstat' when the interface is down would cause a NULL pointer dereference.

Indeed. :)

root at OpenWrt:/# cat /tmp/debug/ath9k/phy0/rcstat
CPU 0 Unable to handle kernel paging request at virtual address 00000000, epc == c02886c8, ra == c0288674
Oops[#1]:
Cpu 0

$ 0   : 00000000 fffffff8 00000000 00000000
$ 4   : ffffffff 00000200 c02a0000 00000005
$ 8   : 00000000 80000008 ffffffff 00000000
$12   : 82d8d080 00000000 2ab935ac 00404995
$16   : 00000017 82f30ae0 82f30ae0 00000000
$20   : 00000000 7fc3d130 00001000 82d9bf18
$24   : 00000166 c028853c
$28   : 82d9a000 82d9bab0 00000003 c0288674
Hi    : 0000025b
Lo    : 000001df
epc   : c02886c8 0xc02886c8
    Not tainted
ra    : c0288674 0xc0288674
Status: 1000f403    KERNEL EXL IE
Cause : 00800008
BadVA : 00000000
PrId  : 00019374 (MIPS 24Kc)
Modules linked in: leds_gpio nf_nat_tftp nf_conntrack_tftp nf_nat_irc
nf_conntrack_irc nf_nat_ftp nf_conntrack_ftp ipt_MASQUi
Process cat (pid: 852, threadinfo=82d9a000, task=82ddba18, tls=00000000)
Stack : 8027809c 00000000 c029b96c c029b974 83889f48 00000001 80278098 00000200
        00000000 2aaed0d8 20202052 61746520 20202020 20205375 63636573 730a0a00
        00000001 00000044 00000000 2aaed0d8 00000000 001200d2 81065c60 8284b2a8
        82897528 82897528 00000001 00000200 81065c60 00000000 800bee0c 800bee0c
        82897528 82897528 82e904b4 00000000 00000001 00000005 2aaed000 81065c60
        ...
Quoted 1 line

Will send out a patch fixing this.

Superb.

Gabor