All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ath10k: add configurable debugging.
@ 2017-05-10 21:19 ` Adrian Chadd
  0 siblings, 0 replies; 30+ messages in thread
From: Adrian Chadd @ 2017-05-10 21:19 UTC (permalink / raw)
  To: Kalle Valo, ath10k, linux-wireless; +Cc: Adrian Chadd, Adrian Chadd

This adds a few configurable debugging options:

* driver debugging and tracing is now configurable per device
* driver debugging and tracing is now configurable at runtime
* the debugging / tracing is not run at all (besides a mask check)
  unless the specific debugging bitmap field is configured.

Signed-off-by: Adrian Chadd <adrian@FreeBSD.org>
---
 drivers/net/wireless/ath/ath10k/core.c  |   2 +
 drivers/net/wireless/ath/ath10k/core.h  |   2 +
 drivers/net/wireless/ath/ath10k/debug.c | 101 ++++++++++++++++++++++++++++----
 drivers/net/wireless/ath/ath10k/debug.h |  44 +++++++++-----
 4 files changed, 125 insertions(+), 24 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/core.c b/drivers/net/wireless/ath/ath10k/core.c
index eea111d704c5..fcb068cb0248 100644
--- a/drivers/net/wireless/ath/ath10k/core.c
+++ b/drivers/net/wireless/ath/ath10k/core.c
@@ -2444,6 +2444,8 @@ struct ath10k *ath10k_core_create(size_t priv_size, struct device *dev,
 	ar->hw_rev = hw_rev;
 	ar->hif.ops = hif_ops;
 	ar->hif.bus = bus;
+	ar->debug_mask = ath10k_debug_mask;
+	ar->trace_debug_mask = ath10k_debug_mask;
 
 	switch (hw_rev) {
 	case ATH10K_HW_QCA988X:
diff --git a/drivers/net/wireless/ath/ath10k/core.h b/drivers/net/wireless/ath/ath10k/core.h
index 8fc08a5043db..07e392a377d0 100644
--- a/drivers/net/wireless/ath/ath10k/core.h
+++ b/drivers/net/wireless/ath/ath10k/core.h
@@ -762,6 +762,8 @@ struct ath10k {
 	struct device *dev;
 	u8 mac_addr[ETH_ALEN];
 
+	u32 debug_mask;
+	u32 trace_debug_mask;
 	enum ath10k_hw_rev hw_rev;
 	u16 dev_id;
 	u32 chip_id;
diff --git a/drivers/net/wireless/ath/ath10k/debug.c b/drivers/net/wireless/ath/ath10k/debug.c
index 389fcb7a9fd0..017360a26b40 100644
--- a/drivers/net/wireless/ath/ath10k/debug.c
+++ b/drivers/net/wireless/ath/ath10k/debug.c
@@ -2418,6 +2418,79 @@ int ath10k_debug_create(struct ath10k *ar)
 	return 0;
 }
 
+#ifdef	CONFIG_ATH10K_DEBUGFS
+static ssize_t ath10k_write_debug_mask(struct file *file,
+				       const char __user *ubuf,
+				       size_t count, loff_t *ppos)
+{
+	struct ath10k *ar = file->private_data;
+	int ret;
+	u32 val;
+
+        if (kstrtou32_from_user(ubuf, count, 0, &val))
+                return -EINVAL;
+
+	ar->debug_mask = val;
+	ret = count;
+
+	return ret;
+}
+
+static ssize_t ath10k_read_debug_mask(struct file *file, char __user *ubuf,
+				      size_t count, loff_t *ppos)
+{
+	char buf[32];
+	struct ath10k *ar = file->private_data;
+	int len = 0;
+
+	len = scnprintf(buf, sizeof(buf) - len, "0x%x\n", ar->debug_mask);
+	return simple_read_from_buffer(ubuf, count, ppos, buf, len);
+}
+
+static const struct file_operations fops_debug_mask = {
+	.read = ath10k_read_debug_mask,
+	.write = ath10k_write_debug_mask,
+	.open = simple_open
+};
+
+static ssize_t ath10k_write_trace_debug_mask(struct file *file,
+					     const char __user *ubuf,
+					     size_t count, loff_t *ppos)
+{
+	struct ath10k *ar = file->private_data;
+	int ret;
+	u32 val;
+
+        if (kstrtou32_from_user(ubuf, count, 0, &val))
+                return -EINVAL;
+
+	ar->trace_debug_mask = val;
+	ret = count;
+
+	return ret;
+}
+
+static ssize_t ath10k_read_trace_debug_mask(struct file *file,
+					    char __user *ubuf,
+					    size_t count, loff_t *ppos)
+{
+	char buf[32];
+	struct ath10k *ar = file->private_data;
+	int len = 0;
+
+	len = scnprintf(buf, sizeof(buf) - len, "0x%x\n",
+			ar->trace_debug_mask);
+	return simple_read_from_buffer(ubuf, count, ppos, buf, len);
+}
+
+static const struct file_operations fops_trace_debug_mask = {
+	.read = ath10k_read_trace_debug_mask,
+	.write = ath10k_write_trace_debug_mask,
+	.open = simple_open
+};
+#endif	/* CONFIG_ATH10K_DEBUGFS */
+
+
 void ath10k_debug_destroy(struct ath10k *ar)
 {
 	vfree(ar->debug.fw_crash_data);
@@ -2448,6 +2521,13 @@ int ath10k_debug_register(struct ath10k *ar)
 	init_completion(&ar->debug.tpc_complete);
 	init_completion(&ar->debug.fw_stats_complete);
 
+#ifdef	CONFIG_ATH10K_DEBUG
+	debugfs_create_file("debug", S_IRUSR, ar->debug.debugfs_phy, ar,
+			    &fops_debug_mask);
+	debugfs_create_file("trace_debug", S_IRUSR, ar->debug.debugfs_phy, ar,
+			    &fops_trace_debug_mask);
+#endif
+
 	debugfs_create_file("fw_stats", 0400, ar->debug.debugfs_phy, ar,
 			    &fops_fw_stats);
 
@@ -2536,7 +2616,7 @@ void ath10k_debug_unregister(struct ath10k *ar)
 #endif /* CONFIG_ATH10K_DEBUGFS */
 
 #ifdef CONFIG_ATH10K_DEBUG
-void ath10k_dbg(struct ath10k *ar, enum ath10k_debug_mask mask,
+void _ath10k_dbg(struct ath10k *ar, enum ath10k_debug_mask mask,
 		const char *fmt, ...)
 {
 	struct va_format vaf;
@@ -2547,16 +2627,16 @@ void ath10k_dbg(struct ath10k *ar, enum ath10k_debug_mask mask,
 	vaf.fmt = fmt;
 	vaf.va = &args;
 
-	if (ath10k_debug_mask & mask)
+	if (ar->debug_mask & mask)
 		dev_printk(KERN_DEBUG, ar->dev, "%pV", &vaf);
-
-	trace_ath10k_log_dbg(ar, mask, &vaf);
+	if (ar->trace_debug_mask & mask)
+		trace_ath10k_log_dbg(ar, mask, &vaf);
 
 	va_end(args);
 }
-EXPORT_SYMBOL(ath10k_dbg);
+EXPORT_SYMBOL(_ath10k_dbg);
 
-void ath10k_dbg_dump(struct ath10k *ar,
+void _ath10k_dbg_dump(struct ath10k *ar,
 		     enum ath10k_debug_mask mask,
 		     const char *msg, const char *prefix,
 		     const void *buf, size_t len)
@@ -2565,7 +2645,7 @@ void ath10k_dbg_dump(struct ath10k *ar,
 	size_t linebuflen;
 	const void *ptr;
 
-	if (ath10k_debug_mask & mask) {
+	if (ar->debug_mask & mask) {
 		if (msg)
 			ath10k_dbg(ar, mask, "%s\n", msg);
 
@@ -2584,9 +2664,10 @@ void ath10k_dbg_dump(struct ath10k *ar,
 	}
 
 	/* tracing code doesn't like null strings :/ */
-	trace_ath10k_log_dbg_dump(ar, msg ? msg : "", prefix ? prefix : "",
-				  buf, len);
+	if (ar->trace_debug_mask & mask)
+		trace_ath10k_log_dbg_dump(ar, msg ? msg : "", prefix ? prefix : "",
+					  buf, len);
 }
-EXPORT_SYMBOL(ath10k_dbg_dump);
+EXPORT_SYMBOL(_ath10k_dbg_dump);
 
 #endif /* CONFIG_ATH10K_DEBUG */
diff --git a/drivers/net/wireless/ath/ath10k/debug.h b/drivers/net/wireless/ath/ath10k/debug.h
index 257d10985c6e..ad6fcd37412f 100644
--- a/drivers/net/wireless/ath/ath10k/debug.h
+++ b/drivers/net/wireless/ath/ath10k/debug.h
@@ -200,27 +200,43 @@ void ath10k_sta_update_rx_duration(struct ath10k *ar,
 #endif /* CONFIG_MAC80211_DEBUGFS */
 
 #ifdef CONFIG_ATH10K_DEBUG
-__printf(3, 4) void ath10k_dbg(struct ath10k *ar,
+static inline int
+_ath10k_do_dbg(struct ath10k *ar, enum ath10k_debug_mask mask)
+{
+	if (ar->trace_debug_mask & mask)
+		return (1);
+	if (ar->debug_mask & mask)
+		return (1);
+	return (0);
+}
+
+__printf(3, 4) void _ath10k_dbg(struct ath10k *ar,
 			       enum ath10k_debug_mask mask,
 			       const char *fmt, ...);
-void ath10k_dbg_dump(struct ath10k *ar,
+
+void _ath10k_dbg_dump(struct ath10k *ar,
 		     enum ath10k_debug_mask mask,
 		     const char *msg, const char *prefix,
 		     const void *buf, size_t len);
+
+#define	ath10k_dbg(ar, mask, ...)					\
+	do {								\
+		if (_ath10k_do_dbg(ar, mask)) {				\
+			_ath10k_dbg((ar), (mask), __VA_ARGS__);		\
+		};							\
+	} while (0)
+
+#define	ath10k_dbg_dump(ar, mask, msg, pfx, buf, len)			\
+	do {								\
+		if (_ath10k_do_dbg(ar, mask)) {				\
+			_ath10k_dbg_dump((ar), (mask), (msg), (pfx), (buf), (len)); \
+		};							\
+	} while (0)
+
 #else /* CONFIG_ATH10K_DEBUG */
 
-static inline int ath10k_dbg(struct ath10k *ar,
-			     enum ath10k_debug_mask dbg_mask,
-			     const char *fmt, ...)
-{
-	return 0;
-}
+#define	ath10k_dbg(ar, mask, fmt, ...)
+#define	ath10k_dbg_dump(ar, mask, msg, pfx, buf, len)
 
-static inline void ath10k_dbg_dump(struct ath10k *ar,
-				   enum ath10k_debug_mask mask,
-				   const char *msg, const char *prefix,
-				   const void *buf, size_t len)
-{
-}
 #endif /* CONFIG_ATH10K_DEBUG */
 #endif /* _DEBUG_H_ */
-- 
2.12.1

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH] ath10k: add configurable debugging.
@ 2017-05-10 21:19 ` Adrian Chadd
  0 siblings, 0 replies; 30+ messages in thread
From: Adrian Chadd @ 2017-05-10 21:19 UTC (permalink / raw)
  To: Kalle Valo, ath10k, linux-wireless; +Cc: Adrian Chadd

This adds a few configurable debugging options:

* driver debugging and tracing is now configurable per device
* driver debugging and tracing is now configurable at runtime
* the debugging / tracing is not run at all (besides a mask check)
  unless the specific debugging bitmap field is configured.

Signed-off-by: Adrian Chadd <adrian@FreeBSD.org>
---
 drivers/net/wireless/ath/ath10k/core.c  |   2 +
 drivers/net/wireless/ath/ath10k/core.h  |   2 +
 drivers/net/wireless/ath/ath10k/debug.c | 101 ++++++++++++++++++++++++++++----
 drivers/net/wireless/ath/ath10k/debug.h |  44 +++++++++-----
 4 files changed, 125 insertions(+), 24 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/core.c b/drivers/net/wireless/ath/ath10k/core.c
index eea111d704c5..fcb068cb0248 100644
--- a/drivers/net/wireless/ath/ath10k/core.c
+++ b/drivers/net/wireless/ath/ath10k/core.c
@@ -2444,6 +2444,8 @@ struct ath10k *ath10k_core_create(size_t priv_size, struct device *dev,
 	ar->hw_rev = hw_rev;
 	ar->hif.ops = hif_ops;
 	ar->hif.bus = bus;
+	ar->debug_mask = ath10k_debug_mask;
+	ar->trace_debug_mask = ath10k_debug_mask;
 
 	switch (hw_rev) {
 	case ATH10K_HW_QCA988X:
diff --git a/drivers/net/wireless/ath/ath10k/core.h b/drivers/net/wireless/ath/ath10k/core.h
index 8fc08a5043db..07e392a377d0 100644
--- a/drivers/net/wireless/ath/ath10k/core.h
+++ b/drivers/net/wireless/ath/ath10k/core.h
@@ -762,6 +762,8 @@ struct ath10k {
 	struct device *dev;
 	u8 mac_addr[ETH_ALEN];
 
+	u32 debug_mask;
+	u32 trace_debug_mask;
 	enum ath10k_hw_rev hw_rev;
 	u16 dev_id;
 	u32 chip_id;
diff --git a/drivers/net/wireless/ath/ath10k/debug.c b/drivers/net/wireless/ath/ath10k/debug.c
index 389fcb7a9fd0..017360a26b40 100644
--- a/drivers/net/wireless/ath/ath10k/debug.c
+++ b/drivers/net/wireless/ath/ath10k/debug.c
@@ -2418,6 +2418,79 @@ int ath10k_debug_create(struct ath10k *ar)
 	return 0;
 }
 
+#ifdef	CONFIG_ATH10K_DEBUGFS
+static ssize_t ath10k_write_debug_mask(struct file *file,
+				       const char __user *ubuf,
+				       size_t count, loff_t *ppos)
+{
+	struct ath10k *ar = file->private_data;
+	int ret;
+	u32 val;
+
+        if (kstrtou32_from_user(ubuf, count, 0, &val))
+                return -EINVAL;
+
+	ar->debug_mask = val;
+	ret = count;
+
+	return ret;
+}
+
+static ssize_t ath10k_read_debug_mask(struct file *file, char __user *ubuf,
+				      size_t count, loff_t *ppos)
+{
+	char buf[32];
+	struct ath10k *ar = file->private_data;
+	int len = 0;
+
+	len = scnprintf(buf, sizeof(buf) - len, "0x%x\n", ar->debug_mask);
+	return simple_read_from_buffer(ubuf, count, ppos, buf, len);
+}
+
+static const struct file_operations fops_debug_mask = {
+	.read = ath10k_read_debug_mask,
+	.write = ath10k_write_debug_mask,
+	.open = simple_open
+};
+
+static ssize_t ath10k_write_trace_debug_mask(struct file *file,
+					     const char __user *ubuf,
+					     size_t count, loff_t *ppos)
+{
+	struct ath10k *ar = file->private_data;
+	int ret;
+	u32 val;
+
+        if (kstrtou32_from_user(ubuf, count, 0, &val))
+                return -EINVAL;
+
+	ar->trace_debug_mask = val;
+	ret = count;
+
+	return ret;
+}
+
+static ssize_t ath10k_read_trace_debug_mask(struct file *file,
+					    char __user *ubuf,
+					    size_t count, loff_t *ppos)
+{
+	char buf[32];
+	struct ath10k *ar = file->private_data;
+	int len = 0;
+
+	len = scnprintf(buf, sizeof(buf) - len, "0x%x\n",
+			ar->trace_debug_mask);
+	return simple_read_from_buffer(ubuf, count, ppos, buf, len);
+}
+
+static const struct file_operations fops_trace_debug_mask = {
+	.read = ath10k_read_trace_debug_mask,
+	.write = ath10k_write_trace_debug_mask,
+	.open = simple_open
+};
+#endif	/* CONFIG_ATH10K_DEBUGFS */
+
+
 void ath10k_debug_destroy(struct ath10k *ar)
 {
 	vfree(ar->debug.fw_crash_data);
@@ -2448,6 +2521,13 @@ int ath10k_debug_register(struct ath10k *ar)
 	init_completion(&ar->debug.tpc_complete);
 	init_completion(&ar->debug.fw_stats_complete);
 
+#ifdef	CONFIG_ATH10K_DEBUG
+	debugfs_create_file("debug", S_IRUSR, ar->debug.debugfs_phy, ar,
+			    &fops_debug_mask);
+	debugfs_create_file("trace_debug", S_IRUSR, ar->debug.debugfs_phy, ar,
+			    &fops_trace_debug_mask);
+#endif
+
 	debugfs_create_file("fw_stats", 0400, ar->debug.debugfs_phy, ar,
 			    &fops_fw_stats);
 
@@ -2536,7 +2616,7 @@ void ath10k_debug_unregister(struct ath10k *ar)
 #endif /* CONFIG_ATH10K_DEBUGFS */
 
 #ifdef CONFIG_ATH10K_DEBUG
-void ath10k_dbg(struct ath10k *ar, enum ath10k_debug_mask mask,
+void _ath10k_dbg(struct ath10k *ar, enum ath10k_debug_mask mask,
 		const char *fmt, ...)
 {
 	struct va_format vaf;
@@ -2547,16 +2627,16 @@ void ath10k_dbg(struct ath10k *ar, enum ath10k_debug_mask mask,
 	vaf.fmt = fmt;
 	vaf.va = &args;
 
-	if (ath10k_debug_mask & mask)
+	if (ar->debug_mask & mask)
 		dev_printk(KERN_DEBUG, ar->dev, "%pV", &vaf);
-
-	trace_ath10k_log_dbg(ar, mask, &vaf);
+	if (ar->trace_debug_mask & mask)
+		trace_ath10k_log_dbg(ar, mask, &vaf);
 
 	va_end(args);
 }
-EXPORT_SYMBOL(ath10k_dbg);
+EXPORT_SYMBOL(_ath10k_dbg);
 
-void ath10k_dbg_dump(struct ath10k *ar,
+void _ath10k_dbg_dump(struct ath10k *ar,
 		     enum ath10k_debug_mask mask,
 		     const char *msg, const char *prefix,
 		     const void *buf, size_t len)
@@ -2565,7 +2645,7 @@ void ath10k_dbg_dump(struct ath10k *ar,
 	size_t linebuflen;
 	const void *ptr;
 
-	if (ath10k_debug_mask & mask) {
+	if (ar->debug_mask & mask) {
 		if (msg)
 			ath10k_dbg(ar, mask, "%s\n", msg);
 
@@ -2584,9 +2664,10 @@ void ath10k_dbg_dump(struct ath10k *ar,
 	}
 
 	/* tracing code doesn't like null strings :/ */
-	trace_ath10k_log_dbg_dump(ar, msg ? msg : "", prefix ? prefix : "",
-				  buf, len);
+	if (ar->trace_debug_mask & mask)
+		trace_ath10k_log_dbg_dump(ar, msg ? msg : "", prefix ? prefix : "",
+					  buf, len);
 }
-EXPORT_SYMBOL(ath10k_dbg_dump);
+EXPORT_SYMBOL(_ath10k_dbg_dump);
 
 #endif /* CONFIG_ATH10K_DEBUG */
diff --git a/drivers/net/wireless/ath/ath10k/debug.h b/drivers/net/wireless/ath/ath10k/debug.h
index 257d10985c6e..ad6fcd37412f 100644
--- a/drivers/net/wireless/ath/ath10k/debug.h
+++ b/drivers/net/wireless/ath/ath10k/debug.h
@@ -200,27 +200,43 @@ void ath10k_sta_update_rx_duration(struct ath10k *ar,
 #endif /* CONFIG_MAC80211_DEBUGFS */
 
 #ifdef CONFIG_ATH10K_DEBUG
-__printf(3, 4) void ath10k_dbg(struct ath10k *ar,
+static inline int
+_ath10k_do_dbg(struct ath10k *ar, enum ath10k_debug_mask mask)
+{
+	if (ar->trace_debug_mask & mask)
+		return (1);
+	if (ar->debug_mask & mask)
+		return (1);
+	return (0);
+}
+
+__printf(3, 4) void _ath10k_dbg(struct ath10k *ar,
 			       enum ath10k_debug_mask mask,
 			       const char *fmt, ...);
-void ath10k_dbg_dump(struct ath10k *ar,
+
+void _ath10k_dbg_dump(struct ath10k *ar,
 		     enum ath10k_debug_mask mask,
 		     const char *msg, const char *prefix,
 		     const void *buf, size_t len);
+
+#define	ath10k_dbg(ar, mask, ...)					\
+	do {								\
+		if (_ath10k_do_dbg(ar, mask)) {				\
+			_ath10k_dbg((ar), (mask), __VA_ARGS__);		\
+		};							\
+	} while (0)
+
+#define	ath10k_dbg_dump(ar, mask, msg, pfx, buf, len)			\
+	do {								\
+		if (_ath10k_do_dbg(ar, mask)) {				\
+			_ath10k_dbg_dump((ar), (mask), (msg), (pfx), (buf), (len)); \
+		};							\
+	} while (0)
+
 #else /* CONFIG_ATH10K_DEBUG */
 
-static inline int ath10k_dbg(struct ath10k *ar,
-			     enum ath10k_debug_mask dbg_mask,
-			     const char *fmt, ...)
-{
-	return 0;
-}
+#define	ath10k_dbg(ar, mask, fmt, ...)
+#define	ath10k_dbg_dump(ar, mask, msg, pfx, buf, len)
 
-static inline void ath10k_dbg_dump(struct ath10k *ar,
-				   enum ath10k_debug_mask mask,
-				   const char *msg, const char *prefix,
-				   const void *buf, size_t len)
-{
-}
 #endif /* CONFIG_ATH10K_DEBUG */
 #endif /* _DEBUG_H_ */
-- 
2.12.1


_______________________________________________
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* Re: [PATCH] ath10k: add configurable debugging.
  2017-05-10 21:19 ` Adrian Chadd
@ 2017-05-19  9:51   ` Kalle Valo
  -1 siblings, 0 replies; 30+ messages in thread
From: Kalle Valo @ 2017-05-19  9:51 UTC (permalink / raw)
  To: Adrian Chadd; +Cc: ath10k, linux-wireless

Adrian Chadd <adrian@freebsd.org> writes:

> This adds a few configurable debugging options:
>
> * driver debugging and tracing is now configurable per device
> * driver debugging and tracing is now configurable at runtime
> * the debugging / tracing is not run at all (besides a mask check)
>   unless the specific debugging bitmap field is configured.
>
> Signed-off-by: Adrian Chadd <adrian@FreeBSD.org>

Oops, I accidentaly replied to the wrong version of the patch. This is a
perfect example why adding version to the subject is so important:

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatc=
hes#patch_version_missing

But anyway, this is what I wrote in v1:

ath10k-check found some trivial whitespace problems:

drivers/net/wireless/ath/ath10k/debug.h:207: return is not a function,
parentheses are not required
drivers/net/wireless/ath/ath10k/debug.h:209: return is not a function,
parentheses are not required
drivers/net/wireless/ath/ath10k/debug.h:210: return is not a function,
parentheses are not required
drivers/net/wireless/ath/ath10k/debug.h:214: Alignment should match open pa=
renthesis
drivers/net/wireless/ath/ath10k/debug.h:218: Alignment should match open pa=
renthesis
drivers/net/wireless/ath/ath10k/debug.c:2430: code indent should use
tabs where possible
drivers/net/wireless/ath/ath10k/debug.c:2430: please, no spaces at the star=
t of a line
drivers/net/wireless/ath/ath10k/debug.c:2431: code indent should use
tabs where possible
drivers/net/wireless/ath/ath10k/debug.c:2431: please, no spaces at the star=
t of a line
drivers/net/wireless/ath/ath10k/debug.c:2464: code indent should use
tabs where possible
drivers/net/wireless/ath/ath10k/debug.c:2464: please, no spaces at the star=
t of a line
drivers/net/wireless/ath/ath10k/debug.c:2465: code indent should use
tabs where possible
drivers/net/wireless/ath/ath10k/debug.c:2465: please, no spaces at the star=
t of a line
drivers/net/wireless/ath/ath10k/debug.c:2493: Please don't use multiple bla=
nk lines
drivers/net/wireless/ath/ath10k/debug.c:2525: Symbolic permissions
'S_IRUSR' are not preferred. Consider using octal permissions '0400'.
drivers/net/wireless/ath/ath10k/debug.c:2527: Symbolic permissions
'S_IRUSR' are not preferred. Consider using octal permissions '0400'.
drivers/net/wireless/ath/ath10k/debug.c:2620: Alignment should match open p=
arenthesis
drivers/net/wireless/ath/ath10k/debug.c:2640: Alignment should match open p=
arenthesis

I fixed those in the pending branch:

https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git/commit/?h=3Dp=
ending&id=3Dbd8c3bdce70adc201037b2eb7eda0a83911ef375

I'll look at this more closely later.

--=20
Kalle Valo=

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH] ath10k: add configurable debugging.
@ 2017-05-19  9:51   ` Kalle Valo
  0 siblings, 0 replies; 30+ messages in thread
From: Kalle Valo @ 2017-05-19  9:51 UTC (permalink / raw)
  To: Adrian Chadd; +Cc: linux-wireless, ath10k

Adrian Chadd <adrian@freebsd.org> writes:

> This adds a few configurable debugging options:
>
> * driver debugging and tracing is now configurable per device
> * driver debugging and tracing is now configurable at runtime
> * the debugging / tracing is not run at all (besides a mask check)
>   unless the specific debugging bitmap field is configured.
>
> Signed-off-by: Adrian Chadd <adrian@FreeBSD.org>

Oops, I accidentaly replied to the wrong version of the patch. This is a
perfect example why adding version to the subject is so important:

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches#patch_version_missing

But anyway, this is what I wrote in v1:

ath10k-check found some trivial whitespace problems:

drivers/net/wireless/ath/ath10k/debug.h:207: return is not a function,
parentheses are not required
drivers/net/wireless/ath/ath10k/debug.h:209: return is not a function,
parentheses are not required
drivers/net/wireless/ath/ath10k/debug.h:210: return is not a function,
parentheses are not required
drivers/net/wireless/ath/ath10k/debug.h:214: Alignment should match open parenthesis
drivers/net/wireless/ath/ath10k/debug.h:218: Alignment should match open parenthesis
drivers/net/wireless/ath/ath10k/debug.c:2430: code indent should use
tabs where possible
drivers/net/wireless/ath/ath10k/debug.c:2430: please, no spaces at the start of a line
drivers/net/wireless/ath/ath10k/debug.c:2431: code indent should use
tabs where possible
drivers/net/wireless/ath/ath10k/debug.c:2431: please, no spaces at the start of a line
drivers/net/wireless/ath/ath10k/debug.c:2464: code indent should use
tabs where possible
drivers/net/wireless/ath/ath10k/debug.c:2464: please, no spaces at the start of a line
drivers/net/wireless/ath/ath10k/debug.c:2465: code indent should use
tabs where possible
drivers/net/wireless/ath/ath10k/debug.c:2465: please, no spaces at the start of a line
drivers/net/wireless/ath/ath10k/debug.c:2493: Please don't use multiple blank lines
drivers/net/wireless/ath/ath10k/debug.c:2525: Symbolic permissions
'S_IRUSR' are not preferred. Consider using octal permissions '0400'.
drivers/net/wireless/ath/ath10k/debug.c:2527: Symbolic permissions
'S_IRUSR' are not preferred. Consider using octal permissions '0400'.
drivers/net/wireless/ath/ath10k/debug.c:2620: Alignment should match open parenthesis
drivers/net/wireless/ath/ath10k/debug.c:2640: Alignment should match open parenthesis

I fixed those in the pending branch:

https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git/commit/?h=pending&id=bd8c3bdce70adc201037b2eb7eda0a83911ef375

I'll look at this more closely later.

-- 
Kalle Valo
_______________________________________________
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH] ath10k: add configurable debugging.
  2017-05-10 21:19 ` Adrian Chadd
@ 2017-05-31 11:53   ` Kalle Valo
  -1 siblings, 0 replies; 30+ messages in thread
From: Kalle Valo @ 2017-05-31 11:53 UTC (permalink / raw)
  To: Adrian Chadd; +Cc: ath10k, linux-wireless

Adrian Chadd <adrian@freebsd.org> writes:

> This adds a few configurable debugging options:
>
> * driver debugging and tracing is now configurable per device

So this means that there's a debugfs file
/sys/kernel/debug/ieee80211/phy0/ath10k/debug for every ath10k device.
Sounds like a good idea. I just don't like the name of file, would
debug_mask be more descriptive?

> * driver debugging and tracing is now configurable at runtime

Correction, debug_mask has been always to possible change via
/sys/module/ath10k_core/parameters/debug_mask file. Now it doesn't work
anymore, which is ok, but I think we should make it clear for users as
well.

I wonder would that work if we change the mask to 0444:

module_param_named(debug_mask, ath10k_debug_mask, uint, 0644);

> * the debugging / tracing is not run at all (besides a mask check)
>   unless the specific debugging bitmap field is configured.

So I guess with this you mean that the function ath10k_dbg() is not
called if debug messages are disabled? This is something which is good
to do in another patch. And the original assumption was that if you care
about performance you won't even enable CONFIG_ATH10K_DEBUG, so that
path was not optimised in any way. How much benefit does this bring?

> --- a/drivers/net/wireless/ath/ath10k/debug.c
> +++ b/drivers/net/wireless/ath/ath10k/debug.c
> @@ -2418,6 +2418,79 @@ int ath10k_debug_create(struct ath10k *ar)
>  	return 0;
>  }
> =20
> +#ifdef	CONFIG_ATH10K_DEBUGFS
> +static ssize_t ath10k_write_debug_mask(struct file *file,
> +				       const char __user *ubuf,
> +				       size_t count, loff_t *ppos)
> +{

The ifdef looks wrong, it's already inside CONFIG_ATH10K_DEBUGFS. Was it
supposed to be CONFIG_ATH10K_DEBUG?

--=20
Kalle Valo=

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH] ath10k: add configurable debugging.
@ 2017-05-31 11:53   ` Kalle Valo
  0 siblings, 0 replies; 30+ messages in thread
From: Kalle Valo @ 2017-05-31 11:53 UTC (permalink / raw)
  To: Adrian Chadd; +Cc: linux-wireless, ath10k

Adrian Chadd <adrian@freebsd.org> writes:

> This adds a few configurable debugging options:
>
> * driver debugging and tracing is now configurable per device

So this means that there's a debugfs file
/sys/kernel/debug/ieee80211/phy0/ath10k/debug for every ath10k device.
Sounds like a good idea. I just don't like the name of file, would
debug_mask be more descriptive?

> * driver debugging and tracing is now configurable at runtime

Correction, debug_mask has been always to possible change via
/sys/module/ath10k_core/parameters/debug_mask file. Now it doesn't work
anymore, which is ok, but I think we should make it clear for users as
well.

I wonder would that work if we change the mask to 0444:

module_param_named(debug_mask, ath10k_debug_mask, uint, 0644);

> * the debugging / tracing is not run at all (besides a mask check)
>   unless the specific debugging bitmap field is configured.

So I guess with this you mean that the function ath10k_dbg() is not
called if debug messages are disabled? This is something which is good
to do in another patch. And the original assumption was that if you care
about performance you won't even enable CONFIG_ATH10K_DEBUG, so that
path was not optimised in any way. How much benefit does this bring?

> --- a/drivers/net/wireless/ath/ath10k/debug.c
> +++ b/drivers/net/wireless/ath/ath10k/debug.c
> @@ -2418,6 +2418,79 @@ int ath10k_debug_create(struct ath10k *ar)
>  	return 0;
>  }
>  
> +#ifdef	CONFIG_ATH10K_DEBUGFS
> +static ssize_t ath10k_write_debug_mask(struct file *file,
> +				       const char __user *ubuf,
> +				       size_t count, loff_t *ppos)
> +{

The ifdef looks wrong, it's already inside CONFIG_ATH10K_DEBUGFS. Was it
supposed to be CONFIG_ATH10K_DEBUG?

-- 
Kalle Valo
_______________________________________________
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH] ath10k: add configurable debugging.
  2017-05-10 21:19 ` Adrian Chadd
@ 2017-05-31 12:16   ` Kalle Valo
  -1 siblings, 0 replies; 30+ messages in thread
From: Kalle Valo @ 2017-05-31 12:16 UTC (permalink / raw)
  To: Adrian Chadd; +Cc: ath10k, linux-wireless

Adrian Chadd <adrian@freebsd.org> writes:

> This adds a few configurable debugging options:
>
> * driver debugging and tracing is now configurable per device
> * driver debugging and tracing is now configurable at runtime
> * the debugging / tracing is not run at all (besides a mask check)
>   unless the specific debugging bitmap field is configured.
>
> Signed-off-by: Adrian Chadd <adrian@FreeBSD.org>

[...]

> --- a/drivers/net/wireless/ath/ath10k/core.c
> +++ b/drivers/net/wireless/ath/ath10k/core.c
> @@ -2444,6 +2444,8 @@ struct ath10k *ath10k_core_create(size_t priv_size,=
 struct device *dev,
>  	ar->hw_rev =3D hw_rev;
>  	ar->hif.ops =3D hif_ops;
>  	ar->hif.bus =3D bus;
> +	ar->debug_mask =3D ath10k_debug_mask;
> +	ar->trace_debug_mask =3D ath10k_debug_mask;

Until now tracing has been always enabled, irrespective what debug_mask
has contained. Now you are changing that and by default log messages are
not delivered through tracing until user enables them. So I think to
keep the old behaviour trace_debug_mask should be ATH10K_DBG_ANY
(0xffffffff) by default and the user can modify the mask per device via
the debugfs file.

But is it really needed to be able to filter trace messages? debug_mask
I understand, but not sure about trace_debug_mask.

--=20
Kalle Valo=

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH] ath10k: add configurable debugging.
@ 2017-05-31 12:16   ` Kalle Valo
  0 siblings, 0 replies; 30+ messages in thread
From: Kalle Valo @ 2017-05-31 12:16 UTC (permalink / raw)
  To: Adrian Chadd; +Cc: linux-wireless, ath10k

Adrian Chadd <adrian@freebsd.org> writes:

> This adds a few configurable debugging options:
>
> * driver debugging and tracing is now configurable per device
> * driver debugging and tracing is now configurable at runtime
> * the debugging / tracing is not run at all (besides a mask check)
>   unless the specific debugging bitmap field is configured.
>
> Signed-off-by: Adrian Chadd <adrian@FreeBSD.org>

[...]

> --- a/drivers/net/wireless/ath/ath10k/core.c
> +++ b/drivers/net/wireless/ath/ath10k/core.c
> @@ -2444,6 +2444,8 @@ struct ath10k *ath10k_core_create(size_t priv_size, struct device *dev,
>  	ar->hw_rev = hw_rev;
>  	ar->hif.ops = hif_ops;
>  	ar->hif.bus = bus;
> +	ar->debug_mask = ath10k_debug_mask;
> +	ar->trace_debug_mask = ath10k_debug_mask;

Until now tracing has been always enabled, irrespective what debug_mask
has contained. Now you are changing that and by default log messages are
not delivered through tracing until user enables them. So I think to
keep the old behaviour trace_debug_mask should be ATH10K_DBG_ANY
(0xffffffff) by default and the user can modify the mask per device via
the debugfs file.

But is it really needed to be able to filter trace messages? debug_mask
I understand, but not sure about trace_debug_mask.

-- 
Kalle Valo
_______________________________________________
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH] ath10k: add configurable debugging.
  2017-05-31 12:16   ` Kalle Valo
@ 2017-05-31 20:20     ` Arend van Spriel
  -1 siblings, 0 replies; 30+ messages in thread
From: Arend van Spriel @ 2017-05-31 20:20 UTC (permalink / raw)
  To: Kalle Valo, Adrian Chadd; +Cc: ath10k, linux-wireless

On 31-05-17 14:16, Kalle Valo wrote:
> Adrian Chadd <adrian@freebsd.org> writes:
> 
>> This adds a few configurable debugging options:
>>
>> * driver debugging and tracing is now configurable per device
>> * driver debugging and tracing is now configurable at runtime
>> * the debugging / tracing is not run at all (besides a mask check)
>>   unless the specific debugging bitmap field is configured.
>>
>> Signed-off-by: Adrian Chadd <adrian@FreeBSD.org>
> 
> [...]
> 
>> --- a/drivers/net/wireless/ath/ath10k/core.c
>> +++ b/drivers/net/wireless/ath/ath10k/core.c
>> @@ -2444,6 +2444,8 @@ struct ath10k *ath10k_core_create(size_t priv_size, struct device *dev,
>>  	ar->hw_rev = hw_rev;
>>  	ar->hif.ops = hif_ops;
>>  	ar->hif.bus = bus;
>> +	ar->debug_mask = ath10k_debug_mask;
>> +	ar->trace_debug_mask = ath10k_debug_mask;
> 
> Until now tracing has been always enabled, irrespective what debug_mask
> has contained. Now you are changing that and by default log messages are
> not delivered through tracing until user enables them. So I think to
> keep the old behaviour trace_debug_mask should be ATH10K_DBG_ANY
> (0xffffffff) by default and the user can modify the mask per device via
> the debugfs file.
> 
> But is it really needed to be able to filter trace messages? debug_mask
> I understand, but not sure about trace_debug_mask.

FWIW, in brcmfmac I decided not to filter trace messages. The overhead
is relatively small and if needed you can pass filter expressions with
trace-cmd record.

Regards,
Arend

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH] ath10k: add configurable debugging.
@ 2017-05-31 20:20     ` Arend van Spriel
  0 siblings, 0 replies; 30+ messages in thread
From: Arend van Spriel @ 2017-05-31 20:20 UTC (permalink / raw)
  To: Kalle Valo, Adrian Chadd; +Cc: linux-wireless, ath10k

On 31-05-17 14:16, Kalle Valo wrote:
> Adrian Chadd <adrian@freebsd.org> writes:
> 
>> This adds a few configurable debugging options:
>>
>> * driver debugging and tracing is now configurable per device
>> * driver debugging and tracing is now configurable at runtime
>> * the debugging / tracing is not run at all (besides a mask check)
>>   unless the specific debugging bitmap field is configured.
>>
>> Signed-off-by: Adrian Chadd <adrian@FreeBSD.org>
> 
> [...]
> 
>> --- a/drivers/net/wireless/ath/ath10k/core.c
>> +++ b/drivers/net/wireless/ath/ath10k/core.c
>> @@ -2444,6 +2444,8 @@ struct ath10k *ath10k_core_create(size_t priv_size, struct device *dev,
>>  	ar->hw_rev = hw_rev;
>>  	ar->hif.ops = hif_ops;
>>  	ar->hif.bus = bus;
>> +	ar->debug_mask = ath10k_debug_mask;
>> +	ar->trace_debug_mask = ath10k_debug_mask;
> 
> Until now tracing has been always enabled, irrespective what debug_mask
> has contained. Now you are changing that and by default log messages are
> not delivered through tracing until user enables them. So I think to
> keep the old behaviour trace_debug_mask should be ATH10K_DBG_ANY
> (0xffffffff) by default and the user can modify the mask per device via
> the debugfs file.
> 
> But is it really needed to be able to filter trace messages? debug_mask
> I understand, but not sure about trace_debug_mask.

FWIW, in brcmfmac I decided not to filter trace messages. The overhead
is relatively small and if needed you can pass filter expressions with
trace-cmd record.

Regards,
Arend

_______________________________________________
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH] ath10k: add configurable debugging.
  2017-05-31 20:20     ` Arend van Spriel
@ 2017-05-31 20:23       ` Adrian Chadd
  -1 siblings, 0 replies; 30+ messages in thread
From: Adrian Chadd @ 2017-05-31 20:23 UTC (permalink / raw)
  To: Arend van Spriel; +Cc: Kalle Valo, ath10k, linux-wireless

On 31 May 2017 at 13:20, Arend van Spriel <arend.vanspriel@broadcom.com> wrote:
> On 31-05-17 14:16, Kalle Valo wrote:
>> Adrian Chadd <adrian@freebsd.org> writes:
>>
>>> This adds a few configurable debugging options:
>>>
>>> * driver debugging and tracing is now configurable per device
>>> * driver debugging and tracing is now configurable at runtime
>>> * the debugging / tracing is not run at all (besides a mask check)
>>>   unless the specific debugging bitmap field is configured.
>>>
>>> Signed-off-by: Adrian Chadd <adrian@FreeBSD.org>
>>
>> [...]
>>
>>> --- a/drivers/net/wireless/ath/ath10k/core.c
>>> +++ b/drivers/net/wireless/ath/ath10k/core.c
>>> @@ -2444,6 +2444,8 @@ struct ath10k *ath10k_core_create(size_t priv_size, struct device *dev,
>>>      ar->hw_rev = hw_rev;
>>>      ar->hif.ops = hif_ops;
>>>      ar->hif.bus = bus;
>>> +    ar->debug_mask = ath10k_debug_mask;
>>> +    ar->trace_debug_mask = ath10k_debug_mask;
>>
>> Until now tracing has been always enabled, irrespective what debug_mask
>> has contained. Now you are changing that and by default log messages are
>> not delivered through tracing until user enables them. So I think to
>> keep the old behaviour trace_debug_mask should be ATH10K_DBG_ANY
>> (0xffffffff) by default and the user can modify the mask per device via
>> the debugfs file.
>>
>> But is it really needed to be able to filter trace messages? debug_mask
>> I understand, but not sure about trace_debug_mask.
>
> FWIW, in brcmfmac I decided not to filter trace messages. The overhead
> is relatively small and if needed you can pass filter expressions with
> trace-cmd record.

The reason for configuring it via a mask is that:

* the previous behaviour is "always call debug(), conditionally print,
always pass to trace"

This meant that function arguments were evaluated even if things
weren't being printed.

So to avoid that in the default case, there are now two masks. If I
have one mask then I can only trace what is being printed, which is
not desired. I'd like to be able to have no overhead when doing no
debugging, a little overhead when doing tracing (and only the items
being traced), and then printing when I want to print.



-adrian

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH] ath10k: add configurable debugging.
@ 2017-05-31 20:23       ` Adrian Chadd
  0 siblings, 0 replies; 30+ messages in thread
From: Adrian Chadd @ 2017-05-31 20:23 UTC (permalink / raw)
  To: Arend van Spriel; +Cc: Kalle Valo, linux-wireless, ath10k

On 31 May 2017 at 13:20, Arend van Spriel <arend.vanspriel@broadcom.com> wrote:
> On 31-05-17 14:16, Kalle Valo wrote:
>> Adrian Chadd <adrian@freebsd.org> writes:
>>
>>> This adds a few configurable debugging options:
>>>
>>> * driver debugging and tracing is now configurable per device
>>> * driver debugging and tracing is now configurable at runtime
>>> * the debugging / tracing is not run at all (besides a mask check)
>>>   unless the specific debugging bitmap field is configured.
>>>
>>> Signed-off-by: Adrian Chadd <adrian@FreeBSD.org>
>>
>> [...]
>>
>>> --- a/drivers/net/wireless/ath/ath10k/core.c
>>> +++ b/drivers/net/wireless/ath/ath10k/core.c
>>> @@ -2444,6 +2444,8 @@ struct ath10k *ath10k_core_create(size_t priv_size, struct device *dev,
>>>      ar->hw_rev = hw_rev;
>>>      ar->hif.ops = hif_ops;
>>>      ar->hif.bus = bus;
>>> +    ar->debug_mask = ath10k_debug_mask;
>>> +    ar->trace_debug_mask = ath10k_debug_mask;
>>
>> Until now tracing has been always enabled, irrespective what debug_mask
>> has contained. Now you are changing that and by default log messages are
>> not delivered through tracing until user enables them. So I think to
>> keep the old behaviour trace_debug_mask should be ATH10K_DBG_ANY
>> (0xffffffff) by default and the user can modify the mask per device via
>> the debugfs file.
>>
>> But is it really needed to be able to filter trace messages? debug_mask
>> I understand, but not sure about trace_debug_mask.
>
> FWIW, in brcmfmac I decided not to filter trace messages. The overhead
> is relatively small and if needed you can pass filter expressions with
> trace-cmd record.

The reason for configuring it via a mask is that:

* the previous behaviour is "always call debug(), conditionally print,
always pass to trace"

This meant that function arguments were evaluated even if things
weren't being printed.

So to avoid that in the default case, there are now two masks. If I
have one mask then I can only trace what is being printed, which is
not desired. I'd like to be able to have no overhead when doing no
debugging, a little overhead when doing tracing (and only the items
being traced), and then printing when I want to print.



-adrian

_______________________________________________
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH] ath10k: add configurable debugging.
  2017-05-31 20:23       ` Adrian Chadd
@ 2017-05-31 21:28         ` Arend van Spriel
  -1 siblings, 0 replies; 30+ messages in thread
From: Arend van Spriel @ 2017-05-31 21:28 UTC (permalink / raw)
  To: Adrian Chadd; +Cc: Kalle Valo, ath10k, linux-wireless

On 31-05-17 22:23, Adrian Chadd wrote:
> On 31 May 2017 at 13:20, Arend van Spriel <arend.vanspriel@broadcom.com> wrote:
>> On 31-05-17 14:16, Kalle Valo wrote:
>>> Adrian Chadd <adrian@freebsd.org> writes:
>>>
>>>> This adds a few configurable debugging options:
>>>>
>>>> * driver debugging and tracing is now configurable per device
>>>> * driver debugging and tracing is now configurable at runtime
>>>> * the debugging / tracing is not run at all (besides a mask check)
>>>>   unless the specific debugging bitmap field is configured.
>>>>
>>>> Signed-off-by: Adrian Chadd <adrian@FreeBSD.org>
>>>
>>> [...]
>>>
>>>> --- a/drivers/net/wireless/ath/ath10k/core.c
>>>> +++ b/drivers/net/wireless/ath/ath10k/core.c
>>>> @@ -2444,6 +2444,8 @@ struct ath10k *ath10k_core_create(size_t priv_size, struct device *dev,
>>>>      ar->hw_rev = hw_rev;
>>>>      ar->hif.ops = hif_ops;
>>>>      ar->hif.bus = bus;
>>>> +    ar->debug_mask = ath10k_debug_mask;
>>>> +    ar->trace_debug_mask = ath10k_debug_mask;
>>>
>>> Until now tracing has been always enabled, irrespective what debug_mask
>>> has contained. Now you are changing that and by default log messages are
>>> not delivered through tracing until user enables them. So I think to
>>> keep the old behaviour trace_debug_mask should be ATH10K_DBG_ANY
>>> (0xffffffff) by default and the user can modify the mask per device via
>>> the debugfs file.
>>>
>>> But is it really needed to be able to filter trace messages? debug_mask
>>> I understand, but not sure about trace_debug_mask.
>>
>> FWIW, in brcmfmac I decided not to filter trace messages. The overhead
>> is relatively small and if needed you can pass filter expressions with
>> trace-cmd record.
> 
> The reason for configuring it via a mask is that:
> 
> * the previous behaviour is "always call debug(), conditionally print,
> always pass to trace"
> 
> This meant that function arguments were evaluated even if things
> weren't being printed.
> 
> So to avoid that in the default case, there are now two masks. If I
> have one mask then I can only trace what is being printed, which is
> not desired. I'd like to be able to have no overhead when doing no
> debugging, a little overhead when doing tracing (and only the items
> being traced), and then printing when I want to print.

Well, it is up to you. Have to clariy though that if you are not
actually recording a trace there is (almost) no overhead. We have
Kconfig to compile tracing code in and I see no performance impact with
tracing code. Only when doing tracing you will get little overhead.

Regards,
Arend

> -adrian
> 

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH] ath10k: add configurable debugging.
@ 2017-05-31 21:28         ` Arend van Spriel
  0 siblings, 0 replies; 30+ messages in thread
From: Arend van Spriel @ 2017-05-31 21:28 UTC (permalink / raw)
  To: Adrian Chadd; +Cc: Kalle Valo, linux-wireless, ath10k

On 31-05-17 22:23, Adrian Chadd wrote:
> On 31 May 2017 at 13:20, Arend van Spriel <arend.vanspriel@broadcom.com> wrote:
>> On 31-05-17 14:16, Kalle Valo wrote:
>>> Adrian Chadd <adrian@freebsd.org> writes:
>>>
>>>> This adds a few configurable debugging options:
>>>>
>>>> * driver debugging and tracing is now configurable per device
>>>> * driver debugging and tracing is now configurable at runtime
>>>> * the debugging / tracing is not run at all (besides a mask check)
>>>>   unless the specific debugging bitmap field is configured.
>>>>
>>>> Signed-off-by: Adrian Chadd <adrian@FreeBSD.org>
>>>
>>> [...]
>>>
>>>> --- a/drivers/net/wireless/ath/ath10k/core.c
>>>> +++ b/drivers/net/wireless/ath/ath10k/core.c
>>>> @@ -2444,6 +2444,8 @@ struct ath10k *ath10k_core_create(size_t priv_size, struct device *dev,
>>>>      ar->hw_rev = hw_rev;
>>>>      ar->hif.ops = hif_ops;
>>>>      ar->hif.bus = bus;
>>>> +    ar->debug_mask = ath10k_debug_mask;
>>>> +    ar->trace_debug_mask = ath10k_debug_mask;
>>>
>>> Until now tracing has been always enabled, irrespective what debug_mask
>>> has contained. Now you are changing that and by default log messages are
>>> not delivered through tracing until user enables them. So I think to
>>> keep the old behaviour trace_debug_mask should be ATH10K_DBG_ANY
>>> (0xffffffff) by default and the user can modify the mask per device via
>>> the debugfs file.
>>>
>>> But is it really needed to be able to filter trace messages? debug_mask
>>> I understand, but not sure about trace_debug_mask.
>>
>> FWIW, in brcmfmac I decided not to filter trace messages. The overhead
>> is relatively small and if needed you can pass filter expressions with
>> trace-cmd record.
> 
> The reason for configuring it via a mask is that:
> 
> * the previous behaviour is "always call debug(), conditionally print,
> always pass to trace"
> 
> This meant that function arguments were evaluated even if things
> weren't being printed.
> 
> So to avoid that in the default case, there are now two masks. If I
> have one mask then I can only trace what is being printed, which is
> not desired. I'd like to be able to have no overhead when doing no
> debugging, a little overhead when doing tracing (and only the items
> being traced), and then printing when I want to print.

Well, it is up to you. Have to clariy though that if you are not
actually recording a trace there is (almost) no overhead. We have
Kconfig to compile tracing code in and I see no performance impact with
tracing code. Only when doing tracing you will get little overhead.

Regards,
Arend

> -adrian
> 

_______________________________________________
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH] ath10k: add configurable debugging.
  2017-05-31 21:28         ` Arend van Spriel
@ 2017-05-31 21:32           ` Adrian Chadd
  -1 siblings, 0 replies; 30+ messages in thread
From: Adrian Chadd @ 2017-05-31 21:32 UTC (permalink / raw)
  To: Arend van Spriel; +Cc: Kalle Valo, ath10k, linux-wireless

On 31 May 2017 at 14:28, Arend van Spriel <arend.vanspriel@broadcom.com> wrote:
> On 31-05-17 22:23, Adrian Chadd wrote:
>> On 31 May 2017 at 13:20, Arend van Spriel <arend.vanspriel@broadcom.com> wrote:
>>> On 31-05-17 14:16, Kalle Valo wrote:
>>>> Adrian Chadd <adrian@freebsd.org> writes:
>>>>
>>>>> This adds a few configurable debugging options:
>>>>>
>>>>> * driver debugging and tracing is now configurable per device
>>>>> * driver debugging and tracing is now configurable at runtime
>>>>> * the debugging / tracing is not run at all (besides a mask check)
>>>>>   unless the specific debugging bitmap field is configured.
>>>>>
>>>>> Signed-off-by: Adrian Chadd <adrian@FreeBSD.org>
>>>>
>>>> [...]
>>>>
>>>>> --- a/drivers/net/wireless/ath/ath10k/core.c
>>>>> +++ b/drivers/net/wireless/ath/ath10k/core.c
>>>>> @@ -2444,6 +2444,8 @@ struct ath10k *ath10k_core_create(size_t priv_size, struct device *dev,
>>>>>      ar->hw_rev = hw_rev;
>>>>>      ar->hif.ops = hif_ops;
>>>>>      ar->hif.bus = bus;
>>>>> +    ar->debug_mask = ath10k_debug_mask;
>>>>> +    ar->trace_debug_mask = ath10k_debug_mask;
>>>>
>>>> Until now tracing has been always enabled, irrespective what debug_mask
>>>> has contained. Now you are changing that and by default log messages are
>>>> not delivered through tracing until user enables them. So I think to
>>>> keep the old behaviour trace_debug_mask should be ATH10K_DBG_ANY
>>>> (0xffffffff) by default and the user can modify the mask per device via
>>>> the debugfs file.
>>>>
>>>> But is it really needed to be able to filter trace messages? debug_mask
>>>> I understand, but not sure about trace_debug_mask.
>>>
>>> FWIW, in brcmfmac I decided not to filter trace messages. The overhead
>>> is relatively small and if needed you can pass filter expressions with
>>> trace-cmd record.
>>
>> The reason for configuring it via a mask is that:
>>
>> * the previous behaviour is "always call debug(), conditionally print,
>> always pass to trace"
>>
>> This meant that function arguments were evaluated even if things
>> weren't being printed.
>>
>> So to avoid that in the default case, there are now two masks. If I
>> have one mask then I can only trace what is being printed, which is
>> not desired. I'd like to be able to have no overhead when doing no
>> debugging, a little overhead when doing tracing (and only the items
>> being traced), and then printing when I want to print.
>
> Well, it is up to you. Have to clariy though that if you are not
> actually recording a trace there is (almost) no overhead. We have
> Kconfig to compile tracing code in and I see no performance impact with
> tracing code. Only when doing tracing you will get little overhead.

The tracing mask is only there to avoid calling debug() all the time
for events that aren't being debugged. That definitely has a cost.



-adrian

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH] ath10k: add configurable debugging.
@ 2017-05-31 21:32           ` Adrian Chadd
  0 siblings, 0 replies; 30+ messages in thread
From: Adrian Chadd @ 2017-05-31 21:32 UTC (permalink / raw)
  To: Arend van Spriel; +Cc: Kalle Valo, linux-wireless, ath10k

On 31 May 2017 at 14:28, Arend van Spriel <arend.vanspriel@broadcom.com> wrote:
> On 31-05-17 22:23, Adrian Chadd wrote:
>> On 31 May 2017 at 13:20, Arend van Spriel <arend.vanspriel@broadcom.com> wrote:
>>> On 31-05-17 14:16, Kalle Valo wrote:
>>>> Adrian Chadd <adrian@freebsd.org> writes:
>>>>
>>>>> This adds a few configurable debugging options:
>>>>>
>>>>> * driver debugging and tracing is now configurable per device
>>>>> * driver debugging and tracing is now configurable at runtime
>>>>> * the debugging / tracing is not run at all (besides a mask check)
>>>>>   unless the specific debugging bitmap field is configured.
>>>>>
>>>>> Signed-off-by: Adrian Chadd <adrian@FreeBSD.org>
>>>>
>>>> [...]
>>>>
>>>>> --- a/drivers/net/wireless/ath/ath10k/core.c
>>>>> +++ b/drivers/net/wireless/ath/ath10k/core.c
>>>>> @@ -2444,6 +2444,8 @@ struct ath10k *ath10k_core_create(size_t priv_size, struct device *dev,
>>>>>      ar->hw_rev = hw_rev;
>>>>>      ar->hif.ops = hif_ops;
>>>>>      ar->hif.bus = bus;
>>>>> +    ar->debug_mask = ath10k_debug_mask;
>>>>> +    ar->trace_debug_mask = ath10k_debug_mask;
>>>>
>>>> Until now tracing has been always enabled, irrespective what debug_mask
>>>> has contained. Now you are changing that and by default log messages are
>>>> not delivered through tracing until user enables them. So I think to
>>>> keep the old behaviour trace_debug_mask should be ATH10K_DBG_ANY
>>>> (0xffffffff) by default and the user can modify the mask per device via
>>>> the debugfs file.
>>>>
>>>> But is it really needed to be able to filter trace messages? debug_mask
>>>> I understand, but not sure about trace_debug_mask.
>>>
>>> FWIW, in brcmfmac I decided not to filter trace messages. The overhead
>>> is relatively small and if needed you can pass filter expressions with
>>> trace-cmd record.
>>
>> The reason for configuring it via a mask is that:
>>
>> * the previous behaviour is "always call debug(), conditionally print,
>> always pass to trace"
>>
>> This meant that function arguments were evaluated even if things
>> weren't being printed.
>>
>> So to avoid that in the default case, there are now two masks. If I
>> have one mask then I can only trace what is being printed, which is
>> not desired. I'd like to be able to have no overhead when doing no
>> debugging, a little overhead when doing tracing (and only the items
>> being traced), and then printing when I want to print.
>
> Well, it is up to you. Have to clariy though that if you are not
> actually recording a trace there is (almost) no overhead. We have
> Kconfig to compile tracing code in and I see no performance impact with
> tracing code. Only when doing tracing you will get little overhead.

The tracing mask is only there to avoid calling debug() all the time
for events that aren't being debugged. That definitely has a cost.



-adrian

_______________________________________________
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH] ath10k: add configurable debugging.
  2017-05-31 20:20     ` Arend van Spriel
@ 2017-06-01 13:24       ` Kalle Valo
  -1 siblings, 0 replies; 30+ messages in thread
From: Kalle Valo @ 2017-06-01 13:24 UTC (permalink / raw)
  To: Arend van Spriel; +Cc: Adrian Chadd, ath10k, linux-wireless

Arend van Spriel <arend.vanspriel@broadcom.com> writes:

> On 31-05-17 14:16, Kalle Valo wrote:
>> Adrian Chadd <adrian@freebsd.org> writes:
>>=20
>>> This adds a few configurable debugging options:
>>>
>>> * driver debugging and tracing is now configurable per device
>>> * driver debugging and tracing is now configurable at runtime
>>> * the debugging / tracing is not run at all (besides a mask check)
>>>   unless the specific debugging bitmap field is configured.
>>>
>>> Signed-off-by: Adrian Chadd <adrian@FreeBSD.org>
>>=20
>> [...]
>>=20
>>> --- a/drivers/net/wireless/ath/ath10k/core.c
>>> +++ b/drivers/net/wireless/ath/ath10k/core.c
>>> @@ -2444,6 +2444,8 @@ struct ath10k *ath10k_core_create(size_t
>>> priv_size, struct device *dev,
>>>  	ar->hw_rev =3D hw_rev;
>>>  	ar->hif.ops =3D hif_ops;
>>>  	ar->hif.bus =3D bus;
>>> +	ar->debug_mask =3D ath10k_debug_mask;
>>> +	ar->trace_debug_mask =3D ath10k_debug_mask;
>>=20
>> Until now tracing has been always enabled, irrespective what debug_mask
>> has contained. Now you are changing that and by default log messages are
>> not delivered through tracing until user enables them. So I think to
>> keep the old behaviour trace_debug_mask should be ATH10K_DBG_ANY
>> (0xffffffff) by default and the user can modify the mask per device via
>> the debugfs file.
>>=20
>> But is it really needed to be able to filter trace messages? debug_mask
>> I understand, but not sure about trace_debug_mask.
>
> FWIW, in brcmfmac I decided not to filter trace messages. The overhead
> is relatively small and if needed you can pass filter expressions with
> trace-cmd record.

I also think that this is how it should work. For example, if you have
tracing enabled in wpasupplicant/hostapd with the command below you can
get a lot of information in one file with relatively little overhead:

trace-cmd record -e mac80211 -e cfg80211 -e ath10k

But if user is forced to use debugfs to enable ath10k tracing that is
quite a step backwards.

--=20
Kalle Valo=

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH] ath10k: add configurable debugging.
@ 2017-06-01 13:24       ` Kalle Valo
  0 siblings, 0 replies; 30+ messages in thread
From: Kalle Valo @ 2017-06-01 13:24 UTC (permalink / raw)
  To: Arend van Spriel; +Cc: Adrian Chadd, linux-wireless, ath10k

Arend van Spriel <arend.vanspriel@broadcom.com> writes:

> On 31-05-17 14:16, Kalle Valo wrote:
>> Adrian Chadd <adrian@freebsd.org> writes:
>> 
>>> This adds a few configurable debugging options:
>>>
>>> * driver debugging and tracing is now configurable per device
>>> * driver debugging and tracing is now configurable at runtime
>>> * the debugging / tracing is not run at all (besides a mask check)
>>>   unless the specific debugging bitmap field is configured.
>>>
>>> Signed-off-by: Adrian Chadd <adrian@FreeBSD.org>
>> 
>> [...]
>> 
>>> --- a/drivers/net/wireless/ath/ath10k/core.c
>>> +++ b/drivers/net/wireless/ath/ath10k/core.c
>>> @@ -2444,6 +2444,8 @@ struct ath10k *ath10k_core_create(size_t
>>> priv_size, struct device *dev,
>>>  	ar->hw_rev = hw_rev;
>>>  	ar->hif.ops = hif_ops;
>>>  	ar->hif.bus = bus;
>>> +	ar->debug_mask = ath10k_debug_mask;
>>> +	ar->trace_debug_mask = ath10k_debug_mask;
>> 
>> Until now tracing has been always enabled, irrespective what debug_mask
>> has contained. Now you are changing that and by default log messages are
>> not delivered through tracing until user enables them. So I think to
>> keep the old behaviour trace_debug_mask should be ATH10K_DBG_ANY
>> (0xffffffff) by default and the user can modify the mask per device via
>> the debugfs file.
>> 
>> But is it really needed to be able to filter trace messages? debug_mask
>> I understand, but not sure about trace_debug_mask.
>
> FWIW, in brcmfmac I decided not to filter trace messages. The overhead
> is relatively small and if needed you can pass filter expressions with
> trace-cmd record.

I also think that this is how it should work. For example, if you have
tracing enabled in wpasupplicant/hostapd with the command below you can
get a lot of information in one file with relatively little overhead:

trace-cmd record -e mac80211 -e cfg80211 -e ath10k

But if user is forced to use debugfs to enable ath10k tracing that is
quite a step backwards.

-- 
Kalle Valo
_______________________________________________
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH] ath10k: add configurable debugging.
  2017-06-01 13:24       ` Kalle Valo
@ 2017-06-01 13:33         ` Adrian Chadd
  -1 siblings, 0 replies; 30+ messages in thread
From: Adrian Chadd @ 2017-06-01 13:33 UTC (permalink / raw)
  To: Kalle Valo; +Cc: Arend van Spriel, ath10k, linux-wireless

On 1 June 2017 at 06:24, Kalle Valo <kvalo@qca.qualcomm.com> wrote:
> Arend van Spriel <arend.vanspriel@broadcom.com> writes:
>
>> On 31-05-17 14:16, Kalle Valo wrote:
>>> Adrian Chadd <adrian@freebsd.org> writes:
>>>
>>>> This adds a few configurable debugging options:
>>>>
>>>> * driver debugging and tracing is now configurable per device
>>>> * driver debugging and tracing is now configurable at runtime
>>>> * the debugging / tracing is not run at all (besides a mask check)
>>>>   unless the specific debugging bitmap field is configured.
>>>>
>>>> Signed-off-by: Adrian Chadd <adrian@FreeBSD.org>
>>>
>>> [...]
>>>
>>>> --- a/drivers/net/wireless/ath/ath10k/core.c
>>>> +++ b/drivers/net/wireless/ath/ath10k/core.c
>>>> @@ -2444,6 +2444,8 @@ struct ath10k *ath10k_core_create(size_t
>>>> priv_size, struct device *dev,
>>>>     ar->hw_rev = hw_rev;
>>>>     ar->hif.ops = hif_ops;
>>>>     ar->hif.bus = bus;
>>>> +   ar->debug_mask = ath10k_debug_mask;
>>>> +   ar->trace_debug_mask = ath10k_debug_mask;
>>>
>>> Until now tracing has been always enabled, irrespective what debug_mask
>>> has contained. Now you are changing that and by default log messages are
>>> not delivered through tracing until user enables them. So I think to
>>> keep the old behaviour trace_debug_mask should be ATH10K_DBG_ANY
>>> (0xffffffff) by default and the user can modify the mask per device via
>>> the debugfs file.
>>>
>>> But is it really needed to be able to filter trace messages? debug_mask
>>> I understand, but not sure about trace_debug_mask.
>>
>> FWIW, in brcmfmac I decided not to filter trace messages. The overhead
>> is relatively small and if needed you can pass filter expressions with
>> trace-cmd record.
>
> I also think that this is how it should work. For example, if you have
> tracing enabled in wpasupplicant/hostapd with the command below you can
> get a lot of information in one file with relatively little overhead:
>
> trace-cmd record -e mac80211 -e cfg80211 -e ath10k
>
> But if user is forced to use debugfs to enable ath10k tracing that is
> quite a step backwards.
>

I agree that is how it should work, but i can't see how you do it on
ath10k without the debug overhead always being there.

If there's a way to know /a/ trace watch is going on from the kernel
then it could be flipped on for that, but i didn't see any obvious
"trace enable" / "trace disable" hooks.



-a

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH] ath10k: add configurable debugging.
@ 2017-06-01 13:33         ` Adrian Chadd
  0 siblings, 0 replies; 30+ messages in thread
From: Adrian Chadd @ 2017-06-01 13:33 UTC (permalink / raw)
  To: Kalle Valo; +Cc: Arend van Spriel, linux-wireless, ath10k

On 1 June 2017 at 06:24, Kalle Valo <kvalo@qca.qualcomm.com> wrote:
> Arend van Spriel <arend.vanspriel@broadcom.com> writes:
>
>> On 31-05-17 14:16, Kalle Valo wrote:
>>> Adrian Chadd <adrian@freebsd.org> writes:
>>>
>>>> This adds a few configurable debugging options:
>>>>
>>>> * driver debugging and tracing is now configurable per device
>>>> * driver debugging and tracing is now configurable at runtime
>>>> * the debugging / tracing is not run at all (besides a mask check)
>>>>   unless the specific debugging bitmap field is configured.
>>>>
>>>> Signed-off-by: Adrian Chadd <adrian@FreeBSD.org>
>>>
>>> [...]
>>>
>>>> --- a/drivers/net/wireless/ath/ath10k/core.c
>>>> +++ b/drivers/net/wireless/ath/ath10k/core.c
>>>> @@ -2444,6 +2444,8 @@ struct ath10k *ath10k_core_create(size_t
>>>> priv_size, struct device *dev,
>>>>     ar->hw_rev = hw_rev;
>>>>     ar->hif.ops = hif_ops;
>>>>     ar->hif.bus = bus;
>>>> +   ar->debug_mask = ath10k_debug_mask;
>>>> +   ar->trace_debug_mask = ath10k_debug_mask;
>>>
>>> Until now tracing has been always enabled, irrespective what debug_mask
>>> has contained. Now you are changing that and by default log messages are
>>> not delivered through tracing until user enables them. So I think to
>>> keep the old behaviour trace_debug_mask should be ATH10K_DBG_ANY
>>> (0xffffffff) by default and the user can modify the mask per device via
>>> the debugfs file.
>>>
>>> But is it really needed to be able to filter trace messages? debug_mask
>>> I understand, but not sure about trace_debug_mask.
>>
>> FWIW, in brcmfmac I decided not to filter trace messages. The overhead
>> is relatively small and if needed you can pass filter expressions with
>> trace-cmd record.
>
> I also think that this is how it should work. For example, if you have
> tracing enabled in wpasupplicant/hostapd with the command below you can
> get a lot of information in one file with relatively little overhead:
>
> trace-cmd record -e mac80211 -e cfg80211 -e ath10k
>
> But if user is forced to use debugfs to enable ath10k tracing that is
> quite a step backwards.
>

I agree that is how it should work, but i can't see how you do it on
ath10k without the debug overhead always being there.

If there's a way to know /a/ trace watch is going on from the kernel
then it could be flipped on for that, but i didn't see any obvious
"trace enable" / "trace disable" hooks.



-a

_______________________________________________
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH] ath10k: add configurable debugging.
  2017-05-31 20:23       ` Adrian Chadd
@ 2017-06-01 13:34         ` Kalle Valo
  -1 siblings, 0 replies; 30+ messages in thread
From: Kalle Valo @ 2017-06-01 13:34 UTC (permalink / raw)
  To: Adrian Chadd; +Cc: Arend van Spriel, ath10k, linux-wireless

Adrian Chadd <adrian@freebsd.org> writes:

>>>> --- a/drivers/net/wireless/ath/ath10k/core.c
>>>> +++ b/drivers/net/wireless/ath/ath10k/core.c
>>>> @@ -2444,6 +2444,8 @@ struct ath10k *ath10k_core_create(size_t
>>>> priv_size, struct device *dev,
>>>>      ar->hw_rev =3D hw_rev;
>>>>      ar->hif.ops =3D hif_ops;
>>>>      ar->hif.bus =3D bus;
>>>> +    ar->debug_mask =3D ath10k_debug_mask;
>>>> +    ar->trace_debug_mask =3D ath10k_debug_mask;
>>>
>>> Until now tracing has been always enabled, irrespective what debug_mask
>>> has contained. Now you are changing that and by default log messages ar=
e
>>> not delivered through tracing until user enables them. So I think to
>>> keep the old behaviour trace_debug_mask should be ATH10K_DBG_ANY
>>> (0xffffffff) by default and the user can modify the mask per device via
>>> the debugfs file.
>>>
>>> But is it really needed to be able to filter trace messages? debug_mask
>>> I understand, but not sure about trace_debug_mask.
>>
>> FWIW, in brcmfmac I decided not to filter trace messages. The overhead
>> is relatively small and if needed you can pass filter expressions with
>> trace-cmd record.
>
> The reason for configuring it via a mask is that:
>
> * the previous behaviour is "always call debug(), conditionally print,
> always pass to trace"
>
> This meant that function arguments were evaluated even if things
> weren't being printed.
>
> So to avoid that in the default case, there are now two masks. If I
> have one mask then I can only trace what is being printed, which is
> not desired. I'd like to be able to have no overhead when doing no
> debugging, a little overhead when doing tracing (and only the items
> being traced), and then printing when I want to print.

Ok, so you want also filter tracing messages. Any particular reason for
that, limited storage space or something else? Just curious.

So what's the most expensive part here, the actual function call to
ath10k_dbg() or va_start()/ve_end() within the function? And do you have
before and after throughput numbers for this? And maybe also with
CONFIG_ATH10K_DEBUG is disabled, which should be the most fastest. It
would be good to know how much this has affect on performance.

We could of course always change ath10k_dbg()/ath10k_dbg_dump() to
inline functions (or maybe even cpp macros) but if va_start()/va_end()
are the expensive part that won't help.

--=20
Kalle Valo=

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH] ath10k: add configurable debugging.
@ 2017-06-01 13:34         ` Kalle Valo
  0 siblings, 0 replies; 30+ messages in thread
From: Kalle Valo @ 2017-06-01 13:34 UTC (permalink / raw)
  To: Adrian Chadd; +Cc: Arend van Spriel, linux-wireless, ath10k

Adrian Chadd <adrian@freebsd.org> writes:

>>>> --- a/drivers/net/wireless/ath/ath10k/core.c
>>>> +++ b/drivers/net/wireless/ath/ath10k/core.c
>>>> @@ -2444,6 +2444,8 @@ struct ath10k *ath10k_core_create(size_t
>>>> priv_size, struct device *dev,
>>>>      ar->hw_rev = hw_rev;
>>>>      ar->hif.ops = hif_ops;
>>>>      ar->hif.bus = bus;
>>>> +    ar->debug_mask = ath10k_debug_mask;
>>>> +    ar->trace_debug_mask = ath10k_debug_mask;
>>>
>>> Until now tracing has been always enabled, irrespective what debug_mask
>>> has contained. Now you are changing that and by default log messages are
>>> not delivered through tracing until user enables them. So I think to
>>> keep the old behaviour trace_debug_mask should be ATH10K_DBG_ANY
>>> (0xffffffff) by default and the user can modify the mask per device via
>>> the debugfs file.
>>>
>>> But is it really needed to be able to filter trace messages? debug_mask
>>> I understand, but not sure about trace_debug_mask.
>>
>> FWIW, in brcmfmac I decided not to filter trace messages. The overhead
>> is relatively small and if needed you can pass filter expressions with
>> trace-cmd record.
>
> The reason for configuring it via a mask is that:
>
> * the previous behaviour is "always call debug(), conditionally print,
> always pass to trace"
>
> This meant that function arguments were evaluated even if things
> weren't being printed.
>
> So to avoid that in the default case, there are now two masks. If I
> have one mask then I can only trace what is being printed, which is
> not desired. I'd like to be able to have no overhead when doing no
> debugging, a little overhead when doing tracing (and only the items
> being traced), and then printing when I want to print.

Ok, so you want also filter tracing messages. Any particular reason for
that, limited storage space or something else? Just curious.

So what's the most expensive part here, the actual function call to
ath10k_dbg() or va_start()/ve_end() within the function? And do you have
before and after throughput numbers for this? And maybe also with
CONFIG_ATH10K_DEBUG is disabled, which should be the most fastest. It
would be good to know how much this has affect on performance.

We could of course always change ath10k_dbg()/ath10k_dbg_dump() to
inline functions (or maybe even cpp macros) but if va_start()/va_end()
are the expensive part that won't help.

-- 
Kalle Valo
_______________________________________________
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH] ath10k: add configurable debugging.
  2017-05-10 16:25 ` Adrian Chadd
@ 2017-05-19  9:47   ` Kalle Valo
  -1 siblings, 0 replies; 30+ messages in thread
From: Kalle Valo @ 2017-05-19  9:47 UTC (permalink / raw)
  To: Adrian Chadd; +Cc: ath10k, linux-wireless

Adrian Chadd <adrian@freebsd.org> writes:

> This adds a few configurable debugging options:
>
> * driver debugging and tracing is now configurable per device
> * driver debugging and tracing is now configurable at runtime
> * the debugging / tracing is not run at all (besides a mask check)
>   unless the specific debugging bitmap field is configured.
>
> Signed-off-by: Adrian Chadd <adrian@FreeBSD.org>

ath10k-check found some trivial whitespace problems:

drivers/net/wireless/ath/ath10k/debug.h:207: return is not a function, pare=
ntheses are not required
drivers/net/wireless/ath/ath10k/debug.h:209: return is not a function, pare=
ntheses are not required
drivers/net/wireless/ath/ath10k/debug.h:210: return is not a function, pare=
ntheses are not required
drivers/net/wireless/ath/ath10k/debug.h:214: Alignment should match open pa=
renthesis
drivers/net/wireless/ath/ath10k/debug.h:218: Alignment should match open pa=
renthesis
drivers/net/wireless/ath/ath10k/debug.c:2430: code indent should use tabs w=
here possible
drivers/net/wireless/ath/ath10k/debug.c:2430: please, no spaces at the star=
t of a line
drivers/net/wireless/ath/ath10k/debug.c:2431: code indent should use tabs w=
here possible
drivers/net/wireless/ath/ath10k/debug.c:2431: please, no spaces at the star=
t of a line
drivers/net/wireless/ath/ath10k/debug.c:2464: code indent should use tabs w=
here possible
drivers/net/wireless/ath/ath10k/debug.c:2464: please, no spaces at the star=
t of a line
drivers/net/wireless/ath/ath10k/debug.c:2465: code indent should use tabs w=
here possible
drivers/net/wireless/ath/ath10k/debug.c:2465: please, no spaces at the star=
t of a line
drivers/net/wireless/ath/ath10k/debug.c:2493: Please don't use multiple bla=
nk lines
drivers/net/wireless/ath/ath10k/debug.c:2525: Symbolic permissions 'S_IRUSR=
' are not preferred. Consider using octal permissions '0400'.
drivers/net/wireless/ath/ath10k/debug.c:2527: Symbolic permissions 'S_IRUSR=
' are not preferred. Consider using octal permissions '0400'.
drivers/net/wireless/ath/ath10k/debug.c:2620: Alignment should match open p=
arenthesis
drivers/net/wireless/ath/ath10k/debug.c:2640: Alignment should match open p=
arenthesis

I fixed those in the pending branch:

https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git/commit/?h=3Dp=
ending&id=3Dbd8c3bdce70adc201037b2eb7eda0a83911ef375

I'll look at this more closely later.

--=20
Kalle Valo=

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH] ath10k: add configurable debugging.
@ 2017-05-19  9:47   ` Kalle Valo
  0 siblings, 0 replies; 30+ messages in thread
From: Kalle Valo @ 2017-05-19  9:47 UTC (permalink / raw)
  To: Adrian Chadd; +Cc: linux-wireless, ath10k

Adrian Chadd <adrian@freebsd.org> writes:

> This adds a few configurable debugging options:
>
> * driver debugging and tracing is now configurable per device
> * driver debugging and tracing is now configurable at runtime
> * the debugging / tracing is not run at all (besides a mask check)
>   unless the specific debugging bitmap field is configured.
>
> Signed-off-by: Adrian Chadd <adrian@FreeBSD.org>

ath10k-check found some trivial whitespace problems:

drivers/net/wireless/ath/ath10k/debug.h:207: return is not a function, parentheses are not required
drivers/net/wireless/ath/ath10k/debug.h:209: return is not a function, parentheses are not required
drivers/net/wireless/ath/ath10k/debug.h:210: return is not a function, parentheses are not required
drivers/net/wireless/ath/ath10k/debug.h:214: Alignment should match open parenthesis
drivers/net/wireless/ath/ath10k/debug.h:218: Alignment should match open parenthesis
drivers/net/wireless/ath/ath10k/debug.c:2430: code indent should use tabs where possible
drivers/net/wireless/ath/ath10k/debug.c:2430: please, no spaces at the start of a line
drivers/net/wireless/ath/ath10k/debug.c:2431: code indent should use tabs where possible
drivers/net/wireless/ath/ath10k/debug.c:2431: please, no spaces at the start of a line
drivers/net/wireless/ath/ath10k/debug.c:2464: code indent should use tabs where possible
drivers/net/wireless/ath/ath10k/debug.c:2464: please, no spaces at the start of a line
drivers/net/wireless/ath/ath10k/debug.c:2465: code indent should use tabs where possible
drivers/net/wireless/ath/ath10k/debug.c:2465: please, no spaces at the start of a line
drivers/net/wireless/ath/ath10k/debug.c:2493: Please don't use multiple blank lines
drivers/net/wireless/ath/ath10k/debug.c:2525: Symbolic permissions 'S_IRUSR' are not preferred. Consider using octal permissions '0400'.
drivers/net/wireless/ath/ath10k/debug.c:2527: Symbolic permissions 'S_IRUSR' are not preferred. Consider using octal permissions '0400'.
drivers/net/wireless/ath/ath10k/debug.c:2620: Alignment should match open parenthesis
drivers/net/wireless/ath/ath10k/debug.c:2640: Alignment should match open parenthesis

I fixed those in the pending branch:

https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git/commit/?h=pending&id=bd8c3bdce70adc201037b2eb7eda0a83911ef375

I'll look at this more closely later.

-- 
Kalle Valo
_______________________________________________
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH] ath10k: add configurable debugging.
  2017-05-10 16:44   ` Steve deRosier
@ 2017-05-10 16:50     ` Adrian Chadd
  -1 siblings, 0 replies; 30+ messages in thread
From: Adrian Chadd @ 2017-05-10 16:50 UTC (permalink / raw)
  To: Steve deRosier; +Cc: Kalle Valo, ath10k, linux-wireless

grr, no. lemme go re-add that and resubmit.

thanks!


-a


On 10 May 2017 at 09:44, Steve deRosier <derosier@gmail.com> wrote:
> Hi Adrian,
>
> On Wed, May 10, 2017 at 9:25 AM, Adrian Chadd <adrian@freebsd.org> wrote:
>
>> diff --git a/drivers/net/wireless/ath/ath10k/debug.h b/drivers/net/wireless/ath/ath10k/debug.h
>> index 257d10985c6e..7bd461927029 100644
>> --- a/drivers/net/wireless/ath/ath10k/debug.h
>> +++ b/drivers/net/wireless/ath/ath10k/debug.h
>> @@ -200,27 +200,43 @@ void ath10k_sta_update_rx_duration(struct ath10k *ar,
>>  #endif /* CONFIG_MAC80211_DEBUGFS */
>>
>>  #ifdef CONFIG_ATH10K_DEBUG
>> -__printf(3, 4) void ath10k_dbg(struct ath10k *ar,
>> +static inline int
>> +_ath10k_do_dbg(struct ath10k *ar, enum ath10k_debug_mask mask)
>> +{
>> +       if (ar->trace_debug_mask & mask)
>> +               return (1);
>> +       if (ar->debug_mask & mask)
>> +               return (1);
>> +       return (0);
>> +}
>> +
>> +void _ath10k_dbg(struct ath10k *ar,
>>                                enum ath10k_debug_mask mask,
>>                                const char *fmt, ...);
>> -void ath10k_dbg_dump(struct ath10k *ar,
>> +
>> +void _ath10k_dbg_dump(struct ath10k *ar,
>>                      enum ath10k_debug_mask mask,
>>                      const char *msg, const char *prefix,
>>                      const void *buf, size_t len);
>> +
>> +#define        ath10k_dbg(ar, mask, ...)                                       \
>> +       do {                                                            \
>> +               if (_ath10k_do_dbg(ar, mask)) {                         \
>> +                       _ath10k_dbg((ar), (mask), __VA_ARGS__);         \
>> +               };                                                      \
>> +       } while (0)
>> +
>
> Looks to me you dropped the "__printf(3, 4)" safety check. Was that intentional?
>
> Thanks,
> - Steve

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH] ath10k: add configurable debugging.
@ 2017-05-10 16:50     ` Adrian Chadd
  0 siblings, 0 replies; 30+ messages in thread
From: Adrian Chadd @ 2017-05-10 16:50 UTC (permalink / raw)
  To: Steve deRosier; +Cc: Kalle Valo, linux-wireless, ath10k

grr, no. lemme go re-add that and resubmit.

thanks!


-a


On 10 May 2017 at 09:44, Steve deRosier <derosier@gmail.com> wrote:
> Hi Adrian,
>
> On Wed, May 10, 2017 at 9:25 AM, Adrian Chadd <adrian@freebsd.org> wrote:
>
>> diff --git a/drivers/net/wireless/ath/ath10k/debug.h b/drivers/net/wireless/ath/ath10k/debug.h
>> index 257d10985c6e..7bd461927029 100644
>> --- a/drivers/net/wireless/ath/ath10k/debug.h
>> +++ b/drivers/net/wireless/ath/ath10k/debug.h
>> @@ -200,27 +200,43 @@ void ath10k_sta_update_rx_duration(struct ath10k *ar,
>>  #endif /* CONFIG_MAC80211_DEBUGFS */
>>
>>  #ifdef CONFIG_ATH10K_DEBUG
>> -__printf(3, 4) void ath10k_dbg(struct ath10k *ar,
>> +static inline int
>> +_ath10k_do_dbg(struct ath10k *ar, enum ath10k_debug_mask mask)
>> +{
>> +       if (ar->trace_debug_mask & mask)
>> +               return (1);
>> +       if (ar->debug_mask & mask)
>> +               return (1);
>> +       return (0);
>> +}
>> +
>> +void _ath10k_dbg(struct ath10k *ar,
>>                                enum ath10k_debug_mask mask,
>>                                const char *fmt, ...);
>> -void ath10k_dbg_dump(struct ath10k *ar,
>> +
>> +void _ath10k_dbg_dump(struct ath10k *ar,
>>                      enum ath10k_debug_mask mask,
>>                      const char *msg, const char *prefix,
>>                      const void *buf, size_t len);
>> +
>> +#define        ath10k_dbg(ar, mask, ...)                                       \
>> +       do {                                                            \
>> +               if (_ath10k_do_dbg(ar, mask)) {                         \
>> +                       _ath10k_dbg((ar), (mask), __VA_ARGS__);         \
>> +               };                                                      \
>> +       } while (0)
>> +
>
> Looks to me you dropped the "__printf(3, 4)" safety check. Was that intentional?
>
> Thanks,
> - Steve

_______________________________________________
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH] ath10k: add configurable debugging.
  2017-05-10 16:25 ` Adrian Chadd
@ 2017-05-10 16:44   ` Steve deRosier
  -1 siblings, 0 replies; 30+ messages in thread
From: Steve deRosier @ 2017-05-10 16:44 UTC (permalink / raw)
  To: Adrian Chadd; +Cc: Kalle Valo, ath10k, linux-wireless

Hi Adrian,

On Wed, May 10, 2017 at 9:25 AM, Adrian Chadd <adrian@freebsd.org> wrote:

> diff --git a/drivers/net/wireless/ath/ath10k/debug.h b/drivers/net/wireless/ath/ath10k/debug.h
> index 257d10985c6e..7bd461927029 100644
> --- a/drivers/net/wireless/ath/ath10k/debug.h
> +++ b/drivers/net/wireless/ath/ath10k/debug.h
> @@ -200,27 +200,43 @@ void ath10k_sta_update_rx_duration(struct ath10k *ar,
>  #endif /* CONFIG_MAC80211_DEBUGFS */
>
>  #ifdef CONFIG_ATH10K_DEBUG
> -__printf(3, 4) void ath10k_dbg(struct ath10k *ar,
> +static inline int
> +_ath10k_do_dbg(struct ath10k *ar, enum ath10k_debug_mask mask)
> +{
> +       if (ar->trace_debug_mask & mask)
> +               return (1);
> +       if (ar->debug_mask & mask)
> +               return (1);
> +       return (0);
> +}
> +
> +void _ath10k_dbg(struct ath10k *ar,
>                                enum ath10k_debug_mask mask,
>                                const char *fmt, ...);
> -void ath10k_dbg_dump(struct ath10k *ar,
> +
> +void _ath10k_dbg_dump(struct ath10k *ar,
>                      enum ath10k_debug_mask mask,
>                      const char *msg, const char *prefix,
>                      const void *buf, size_t len);
> +
> +#define        ath10k_dbg(ar, mask, ...)                                       \
> +       do {                                                            \
> +               if (_ath10k_do_dbg(ar, mask)) {                         \
> +                       _ath10k_dbg((ar), (mask), __VA_ARGS__);         \
> +               };                                                      \
> +       } while (0)
> +

Looks to me you dropped the "__printf(3, 4)" safety check. Was that intentional?

Thanks,
- Steve

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH] ath10k: add configurable debugging.
@ 2017-05-10 16:44   ` Steve deRosier
  0 siblings, 0 replies; 30+ messages in thread
From: Steve deRosier @ 2017-05-10 16:44 UTC (permalink / raw)
  To: Adrian Chadd; +Cc: Kalle Valo, linux-wireless, ath10k

Hi Adrian,

On Wed, May 10, 2017 at 9:25 AM, Adrian Chadd <adrian@freebsd.org> wrote:

> diff --git a/drivers/net/wireless/ath/ath10k/debug.h b/drivers/net/wireless/ath/ath10k/debug.h
> index 257d10985c6e..7bd461927029 100644
> --- a/drivers/net/wireless/ath/ath10k/debug.h
> +++ b/drivers/net/wireless/ath/ath10k/debug.h
> @@ -200,27 +200,43 @@ void ath10k_sta_update_rx_duration(struct ath10k *ar,
>  #endif /* CONFIG_MAC80211_DEBUGFS */
>
>  #ifdef CONFIG_ATH10K_DEBUG
> -__printf(3, 4) void ath10k_dbg(struct ath10k *ar,
> +static inline int
> +_ath10k_do_dbg(struct ath10k *ar, enum ath10k_debug_mask mask)
> +{
> +       if (ar->trace_debug_mask & mask)
> +               return (1);
> +       if (ar->debug_mask & mask)
> +               return (1);
> +       return (0);
> +}
> +
> +void _ath10k_dbg(struct ath10k *ar,
>                                enum ath10k_debug_mask mask,
>                                const char *fmt, ...);
> -void ath10k_dbg_dump(struct ath10k *ar,
> +
> +void _ath10k_dbg_dump(struct ath10k *ar,
>                      enum ath10k_debug_mask mask,
>                      const char *msg, const char *prefix,
>                      const void *buf, size_t len);
> +
> +#define        ath10k_dbg(ar, mask, ...)                                       \
> +       do {                                                            \
> +               if (_ath10k_do_dbg(ar, mask)) {                         \
> +                       _ath10k_dbg((ar), (mask), __VA_ARGS__);         \
> +               };                                                      \
> +       } while (0)
> +

Looks to me you dropped the "__printf(3, 4)" safety check. Was that intentional?

Thanks,
- Steve

_______________________________________________
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [PATCH] ath10k: add configurable debugging.
@ 2017-05-10 16:25 ` Adrian Chadd
  0 siblings, 0 replies; 30+ messages in thread
From: Adrian Chadd @ 2017-05-10 16:25 UTC (permalink / raw)
  To: Kalle Valo, ath10k, linux-wireless; +Cc: Adrian Chadd, Adrian Chadd

This adds a few configurable debugging options:

* driver debugging and tracing is now configurable per device
* driver debugging and tracing is now configurable at runtime
* the debugging / tracing is not run at all (besides a mask check)
  unless the specific debugging bitmap field is configured.

Signed-off-by: Adrian Chadd <adrian@FreeBSD.org>
---
 drivers/net/wireless/ath/ath10k/core.c  |   2 +
 drivers/net/wireless/ath/ath10k/core.h  |   2 +
 drivers/net/wireless/ath/ath10k/debug.c | 101 ++++++++++++++++++++++++++++----
 drivers/net/wireless/ath/ath10k/debug.h |  44 +++++++++-----
 4 files changed, 125 insertions(+), 24 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/core.c b/drivers/net/wireless/ath/ath10k/core.c
index eea111d704c5..fcb068cb0248 100644
--- a/drivers/net/wireless/ath/ath10k/core.c
+++ b/drivers/net/wireless/ath/ath10k/core.c
@@ -2444,6 +2444,8 @@ struct ath10k *ath10k_core_create(size_t priv_size, struct device *dev,
 	ar->hw_rev = hw_rev;
 	ar->hif.ops = hif_ops;
 	ar->hif.bus = bus;
+	ar->debug_mask = ath10k_debug_mask;
+	ar->trace_debug_mask = ath10k_debug_mask;
 
 	switch (hw_rev) {
 	case ATH10K_HW_QCA988X:
diff --git a/drivers/net/wireless/ath/ath10k/core.h b/drivers/net/wireless/ath/ath10k/core.h
index 8fc08a5043db..07e392a377d0 100644
--- a/drivers/net/wireless/ath/ath10k/core.h
+++ b/drivers/net/wireless/ath/ath10k/core.h
@@ -762,6 +762,8 @@ struct ath10k {
 	struct device *dev;
 	u8 mac_addr[ETH_ALEN];
 
+	u32 debug_mask;
+	u32 trace_debug_mask;
 	enum ath10k_hw_rev hw_rev;
 	u16 dev_id;
 	u32 chip_id;
diff --git a/drivers/net/wireless/ath/ath10k/debug.c b/drivers/net/wireless/ath/ath10k/debug.c
index 389fcb7a9fd0..017360a26b40 100644
--- a/drivers/net/wireless/ath/ath10k/debug.c
+++ b/drivers/net/wireless/ath/ath10k/debug.c
@@ -2418,6 +2418,79 @@ int ath10k_debug_create(struct ath10k *ar)
 	return 0;
 }
 
+#ifdef	CONFIG_ATH10K_DEBUGFS
+static ssize_t ath10k_write_debug_mask(struct file *file,
+				       const char __user *ubuf,
+				       size_t count, loff_t *ppos)
+{
+	struct ath10k *ar = file->private_data;
+	int ret;
+	u32 val;
+
+        if (kstrtou32_from_user(ubuf, count, 0, &val))
+                return -EINVAL;
+
+	ar->debug_mask = val;
+	ret = count;
+
+	return ret;
+}
+
+static ssize_t ath10k_read_debug_mask(struct file *file, char __user *ubuf,
+				      size_t count, loff_t *ppos)
+{
+	char buf[32];
+	struct ath10k *ar = file->private_data;
+	int len = 0;
+
+	len = scnprintf(buf, sizeof(buf) - len, "0x%x\n", ar->debug_mask);
+	return simple_read_from_buffer(ubuf, count, ppos, buf, len);
+}
+
+static const struct file_operations fops_debug_mask = {
+	.read = ath10k_read_debug_mask,
+	.write = ath10k_write_debug_mask,
+	.open = simple_open
+};
+
+static ssize_t ath10k_write_trace_debug_mask(struct file *file,
+					     const char __user *ubuf,
+					     size_t count, loff_t *ppos)
+{
+	struct ath10k *ar = file->private_data;
+	int ret;
+	u32 val;
+
+        if (kstrtou32_from_user(ubuf, count, 0, &val))
+                return -EINVAL;
+
+	ar->trace_debug_mask = val;
+	ret = count;
+
+	return ret;
+}
+
+static ssize_t ath10k_read_trace_debug_mask(struct file *file,
+					    char __user *ubuf,
+					    size_t count, loff_t *ppos)
+{
+	char buf[32];
+	struct ath10k *ar = file->private_data;
+	int len = 0;
+
+	len = scnprintf(buf, sizeof(buf) - len, "0x%x\n",
+			ar->trace_debug_mask);
+	return simple_read_from_buffer(ubuf, count, ppos, buf, len);
+}
+
+static const struct file_operations fops_trace_debug_mask = {
+	.read = ath10k_read_trace_debug_mask,
+	.write = ath10k_write_trace_debug_mask,
+	.open = simple_open
+};
+#endif	/* CONFIG_ATH10K_DEBUGFS */
+
+
 void ath10k_debug_destroy(struct ath10k *ar)
 {
 	vfree(ar->debug.fw_crash_data);
@@ -2448,6 +2521,13 @@ int ath10k_debug_register(struct ath10k *ar)
 	init_completion(&ar->debug.tpc_complete);
 	init_completion(&ar->debug.fw_stats_complete);
 
+#ifdef	CONFIG_ATH10K_DEBUG
+	debugfs_create_file("debug", S_IRUSR, ar->debug.debugfs_phy, ar,
+			    &fops_debug_mask);
+	debugfs_create_file("trace_debug", S_IRUSR, ar->debug.debugfs_phy, ar,
+			    &fops_trace_debug_mask);
+#endif
+
 	debugfs_create_file("fw_stats", 0400, ar->debug.debugfs_phy, ar,
 			    &fops_fw_stats);
 
@@ -2536,7 +2616,7 @@ void ath10k_debug_unregister(struct ath10k *ar)
 #endif /* CONFIG_ATH10K_DEBUGFS */
 
 #ifdef CONFIG_ATH10K_DEBUG
-void ath10k_dbg(struct ath10k *ar, enum ath10k_debug_mask mask,
+void _ath10k_dbg(struct ath10k *ar, enum ath10k_debug_mask mask,
 		const char *fmt, ...)
 {
 	struct va_format vaf;
@@ -2547,16 +2627,16 @@ void ath10k_dbg(struct ath10k *ar, enum ath10k_debug_mask mask,
 	vaf.fmt = fmt;
 	vaf.va = &args;
 
-	if (ath10k_debug_mask & mask)
+	if (ar->debug_mask & mask)
 		dev_printk(KERN_DEBUG, ar->dev, "%pV", &vaf);
-
-	trace_ath10k_log_dbg(ar, mask, &vaf);
+	if (ar->trace_debug_mask & mask)
+		trace_ath10k_log_dbg(ar, mask, &vaf);
 
 	va_end(args);
 }
-EXPORT_SYMBOL(ath10k_dbg);
+EXPORT_SYMBOL(_ath10k_dbg);
 
-void ath10k_dbg_dump(struct ath10k *ar,
+void _ath10k_dbg_dump(struct ath10k *ar,
 		     enum ath10k_debug_mask mask,
 		     const char *msg, const char *prefix,
 		     const void *buf, size_t len)
@@ -2565,7 +2645,7 @@ void ath10k_dbg_dump(struct ath10k *ar,
 	size_t linebuflen;
 	const void *ptr;
 
-	if (ath10k_debug_mask & mask) {
+	if (ar->debug_mask & mask) {
 		if (msg)
 			ath10k_dbg(ar, mask, "%s\n", msg);
 
@@ -2584,9 +2664,10 @@ void ath10k_dbg_dump(struct ath10k *ar,
 	}
 
 	/* tracing code doesn't like null strings :/ */
-	trace_ath10k_log_dbg_dump(ar, msg ? msg : "", prefix ? prefix : "",
-				  buf, len);
+	if (ar->trace_debug_mask & mask)
+		trace_ath10k_log_dbg_dump(ar, msg ? msg : "", prefix ? prefix : "",
+					  buf, len);
 }
-EXPORT_SYMBOL(ath10k_dbg_dump);
+EXPORT_SYMBOL(_ath10k_dbg_dump);
 
 #endif /* CONFIG_ATH10K_DEBUG */
diff --git a/drivers/net/wireless/ath/ath10k/debug.h b/drivers/net/wireless/ath/ath10k/debug.h
index 257d10985c6e..7bd461927029 100644
--- a/drivers/net/wireless/ath/ath10k/debug.h
+++ b/drivers/net/wireless/ath/ath10k/debug.h
@@ -200,27 +200,43 @@ void ath10k_sta_update_rx_duration(struct ath10k *ar,
 #endif /* CONFIG_MAC80211_DEBUGFS */
 
 #ifdef CONFIG_ATH10K_DEBUG
-__printf(3, 4) void ath10k_dbg(struct ath10k *ar,
+static inline int
+_ath10k_do_dbg(struct ath10k *ar, enum ath10k_debug_mask mask)
+{
+	if (ar->trace_debug_mask & mask)
+		return (1);
+	if (ar->debug_mask & mask)
+		return (1);
+	return (0);
+}
+
+void _ath10k_dbg(struct ath10k *ar,
 			       enum ath10k_debug_mask mask,
 			       const char *fmt, ...);
-void ath10k_dbg_dump(struct ath10k *ar,
+
+void _ath10k_dbg_dump(struct ath10k *ar,
 		     enum ath10k_debug_mask mask,
 		     const char *msg, const char *prefix,
 		     const void *buf, size_t len);
+
+#define	ath10k_dbg(ar, mask, ...)					\
+	do {								\
+		if (_ath10k_do_dbg(ar, mask)) {				\
+			_ath10k_dbg((ar), (mask), __VA_ARGS__);		\
+		};							\
+	} while (0)
+
+#define	ath10k_dbg_dump(ar, mask, msg, pfx, buf, len)			\
+	do {								\
+		if (_ath10k_do_dbg(ar, mask)) {				\
+			_ath10k_dbg_dump((ar), (mask), (msg), (pfx), (buf), (len)); \
+		};							\
+	} while (0)
+
 #else /* CONFIG_ATH10K_DEBUG */
 
-static inline int ath10k_dbg(struct ath10k *ar,
-			     enum ath10k_debug_mask dbg_mask,
-			     const char *fmt, ...)
-{
-	return 0;
-}
+#define	ath10k_dbg(ar, mask, fmt, ...)
+#define	ath10k_dbg_dump(ar, mask, msg, pfx, buf, len)
 
-static inline void ath10k_dbg_dump(struct ath10k *ar,
-				   enum ath10k_debug_mask mask,
-				   const char *msg, const char *prefix,
-				   const void *buf, size_t len)
-{
-}
 #endif /* CONFIG_ATH10K_DEBUG */
 #endif /* _DEBUG_H_ */
-- 
2.12.1

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH] ath10k: add configurable debugging.
@ 2017-05-10 16:25 ` Adrian Chadd
  0 siblings, 0 replies; 30+ messages in thread
From: Adrian Chadd @ 2017-05-10 16:25 UTC (permalink / raw)
  To: Kalle Valo, ath10k, linux-wireless; +Cc: Adrian Chadd

This adds a few configurable debugging options:

* driver debugging and tracing is now configurable per device
* driver debugging and tracing is now configurable at runtime
* the debugging / tracing is not run at all (besides a mask check)
  unless the specific debugging bitmap field is configured.

Signed-off-by: Adrian Chadd <adrian@FreeBSD.org>
---
 drivers/net/wireless/ath/ath10k/core.c  |   2 +
 drivers/net/wireless/ath/ath10k/core.h  |   2 +
 drivers/net/wireless/ath/ath10k/debug.c | 101 ++++++++++++++++++++++++++++----
 drivers/net/wireless/ath/ath10k/debug.h |  44 +++++++++-----
 4 files changed, 125 insertions(+), 24 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/core.c b/drivers/net/wireless/ath/ath10k/core.c
index eea111d704c5..fcb068cb0248 100644
--- a/drivers/net/wireless/ath/ath10k/core.c
+++ b/drivers/net/wireless/ath/ath10k/core.c
@@ -2444,6 +2444,8 @@ struct ath10k *ath10k_core_create(size_t priv_size, struct device *dev,
 	ar->hw_rev = hw_rev;
 	ar->hif.ops = hif_ops;
 	ar->hif.bus = bus;
+	ar->debug_mask = ath10k_debug_mask;
+	ar->trace_debug_mask = ath10k_debug_mask;
 
 	switch (hw_rev) {
 	case ATH10K_HW_QCA988X:
diff --git a/drivers/net/wireless/ath/ath10k/core.h b/drivers/net/wireless/ath/ath10k/core.h
index 8fc08a5043db..07e392a377d0 100644
--- a/drivers/net/wireless/ath/ath10k/core.h
+++ b/drivers/net/wireless/ath/ath10k/core.h
@@ -762,6 +762,8 @@ struct ath10k {
 	struct device *dev;
 	u8 mac_addr[ETH_ALEN];
 
+	u32 debug_mask;
+	u32 trace_debug_mask;
 	enum ath10k_hw_rev hw_rev;
 	u16 dev_id;
 	u32 chip_id;
diff --git a/drivers/net/wireless/ath/ath10k/debug.c b/drivers/net/wireless/ath/ath10k/debug.c
index 389fcb7a9fd0..017360a26b40 100644
--- a/drivers/net/wireless/ath/ath10k/debug.c
+++ b/drivers/net/wireless/ath/ath10k/debug.c
@@ -2418,6 +2418,79 @@ int ath10k_debug_create(struct ath10k *ar)
 	return 0;
 }
 
+#ifdef	CONFIG_ATH10K_DEBUGFS
+static ssize_t ath10k_write_debug_mask(struct file *file,
+				       const char __user *ubuf,
+				       size_t count, loff_t *ppos)
+{
+	struct ath10k *ar = file->private_data;
+	int ret;
+	u32 val;
+
+        if (kstrtou32_from_user(ubuf, count, 0, &val))
+                return -EINVAL;
+
+	ar->debug_mask = val;
+	ret = count;
+
+	return ret;
+}
+
+static ssize_t ath10k_read_debug_mask(struct file *file, char __user *ubuf,
+				      size_t count, loff_t *ppos)
+{
+	char buf[32];
+	struct ath10k *ar = file->private_data;
+	int len = 0;
+
+	len = scnprintf(buf, sizeof(buf) - len, "0x%x\n", ar->debug_mask);
+	return simple_read_from_buffer(ubuf, count, ppos, buf, len);
+}
+
+static const struct file_operations fops_debug_mask = {
+	.read = ath10k_read_debug_mask,
+	.write = ath10k_write_debug_mask,
+	.open = simple_open
+};
+
+static ssize_t ath10k_write_trace_debug_mask(struct file *file,
+					     const char __user *ubuf,
+					     size_t count, loff_t *ppos)
+{
+	struct ath10k *ar = file->private_data;
+	int ret;
+	u32 val;
+
+        if (kstrtou32_from_user(ubuf, count, 0, &val))
+                return -EINVAL;
+
+	ar->trace_debug_mask = val;
+	ret = count;
+
+	return ret;
+}
+
+static ssize_t ath10k_read_trace_debug_mask(struct file *file,
+					    char __user *ubuf,
+					    size_t count, loff_t *ppos)
+{
+	char buf[32];
+	struct ath10k *ar = file->private_data;
+	int len = 0;
+
+	len = scnprintf(buf, sizeof(buf) - len, "0x%x\n",
+			ar->trace_debug_mask);
+	return simple_read_from_buffer(ubuf, count, ppos, buf, len);
+}
+
+static const struct file_operations fops_trace_debug_mask = {
+	.read = ath10k_read_trace_debug_mask,
+	.write = ath10k_write_trace_debug_mask,
+	.open = simple_open
+};
+#endif	/* CONFIG_ATH10K_DEBUGFS */
+
+
 void ath10k_debug_destroy(struct ath10k *ar)
 {
 	vfree(ar->debug.fw_crash_data);
@@ -2448,6 +2521,13 @@ int ath10k_debug_register(struct ath10k *ar)
 	init_completion(&ar->debug.tpc_complete);
 	init_completion(&ar->debug.fw_stats_complete);
 
+#ifdef	CONFIG_ATH10K_DEBUG
+	debugfs_create_file("debug", S_IRUSR, ar->debug.debugfs_phy, ar,
+			    &fops_debug_mask);
+	debugfs_create_file("trace_debug", S_IRUSR, ar->debug.debugfs_phy, ar,
+			    &fops_trace_debug_mask);
+#endif
+
 	debugfs_create_file("fw_stats", 0400, ar->debug.debugfs_phy, ar,
 			    &fops_fw_stats);
 
@@ -2536,7 +2616,7 @@ void ath10k_debug_unregister(struct ath10k *ar)
 #endif /* CONFIG_ATH10K_DEBUGFS */
 
 #ifdef CONFIG_ATH10K_DEBUG
-void ath10k_dbg(struct ath10k *ar, enum ath10k_debug_mask mask,
+void _ath10k_dbg(struct ath10k *ar, enum ath10k_debug_mask mask,
 		const char *fmt, ...)
 {
 	struct va_format vaf;
@@ -2547,16 +2627,16 @@ void ath10k_dbg(struct ath10k *ar, enum ath10k_debug_mask mask,
 	vaf.fmt = fmt;
 	vaf.va = &args;
 
-	if (ath10k_debug_mask & mask)
+	if (ar->debug_mask & mask)
 		dev_printk(KERN_DEBUG, ar->dev, "%pV", &vaf);
-
-	trace_ath10k_log_dbg(ar, mask, &vaf);
+	if (ar->trace_debug_mask & mask)
+		trace_ath10k_log_dbg(ar, mask, &vaf);
 
 	va_end(args);
 }
-EXPORT_SYMBOL(ath10k_dbg);
+EXPORT_SYMBOL(_ath10k_dbg);
 
-void ath10k_dbg_dump(struct ath10k *ar,
+void _ath10k_dbg_dump(struct ath10k *ar,
 		     enum ath10k_debug_mask mask,
 		     const char *msg, const char *prefix,
 		     const void *buf, size_t len)
@@ -2565,7 +2645,7 @@ void ath10k_dbg_dump(struct ath10k *ar,
 	size_t linebuflen;
 	const void *ptr;
 
-	if (ath10k_debug_mask & mask) {
+	if (ar->debug_mask & mask) {
 		if (msg)
 			ath10k_dbg(ar, mask, "%s\n", msg);
 
@@ -2584,9 +2664,10 @@ void ath10k_dbg_dump(struct ath10k *ar,
 	}
 
 	/* tracing code doesn't like null strings :/ */
-	trace_ath10k_log_dbg_dump(ar, msg ? msg : "", prefix ? prefix : "",
-				  buf, len);
+	if (ar->trace_debug_mask & mask)
+		trace_ath10k_log_dbg_dump(ar, msg ? msg : "", prefix ? prefix : "",
+					  buf, len);
 }
-EXPORT_SYMBOL(ath10k_dbg_dump);
+EXPORT_SYMBOL(_ath10k_dbg_dump);
 
 #endif /* CONFIG_ATH10K_DEBUG */
diff --git a/drivers/net/wireless/ath/ath10k/debug.h b/drivers/net/wireless/ath/ath10k/debug.h
index 257d10985c6e..7bd461927029 100644
--- a/drivers/net/wireless/ath/ath10k/debug.h
+++ b/drivers/net/wireless/ath/ath10k/debug.h
@@ -200,27 +200,43 @@ void ath10k_sta_update_rx_duration(struct ath10k *ar,
 #endif /* CONFIG_MAC80211_DEBUGFS */
 
 #ifdef CONFIG_ATH10K_DEBUG
-__printf(3, 4) void ath10k_dbg(struct ath10k *ar,
+static inline int
+_ath10k_do_dbg(struct ath10k *ar, enum ath10k_debug_mask mask)
+{
+	if (ar->trace_debug_mask & mask)
+		return (1);
+	if (ar->debug_mask & mask)
+		return (1);
+	return (0);
+}
+
+void _ath10k_dbg(struct ath10k *ar,
 			       enum ath10k_debug_mask mask,
 			       const char *fmt, ...);
-void ath10k_dbg_dump(struct ath10k *ar,
+
+void _ath10k_dbg_dump(struct ath10k *ar,
 		     enum ath10k_debug_mask mask,
 		     const char *msg, const char *prefix,
 		     const void *buf, size_t len);
+
+#define	ath10k_dbg(ar, mask, ...)					\
+	do {								\
+		if (_ath10k_do_dbg(ar, mask)) {				\
+			_ath10k_dbg((ar), (mask), __VA_ARGS__);		\
+		};							\
+	} while (0)
+
+#define	ath10k_dbg_dump(ar, mask, msg, pfx, buf, len)			\
+	do {								\
+		if (_ath10k_do_dbg(ar, mask)) {				\
+			_ath10k_dbg_dump((ar), (mask), (msg), (pfx), (buf), (len)); \
+		};							\
+	} while (0)
+
 #else /* CONFIG_ATH10K_DEBUG */
 
-static inline int ath10k_dbg(struct ath10k *ar,
-			     enum ath10k_debug_mask dbg_mask,
-			     const char *fmt, ...)
-{
-	return 0;
-}
+#define	ath10k_dbg(ar, mask, fmt, ...)
+#define	ath10k_dbg_dump(ar, mask, msg, pfx, buf, len)
 
-static inline void ath10k_dbg_dump(struct ath10k *ar,
-				   enum ath10k_debug_mask mask,
-				   const char *msg, const char *prefix,
-				   const void *buf, size_t len)
-{
-}
 #endif /* CONFIG_ATH10K_DEBUG */
 #endif /* _DEBUG_H_ */
-- 
2.12.1


_______________________________________________
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k

^ permalink raw reply related	[flat|nested] 30+ messages in thread

end of thread, other threads:[~2017-06-01 13:34 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-10 21:19 [PATCH] ath10k: add configurable debugging Adrian Chadd
2017-05-10 21:19 ` Adrian Chadd
2017-05-19  9:51 ` Kalle Valo
2017-05-19  9:51   ` Kalle Valo
2017-05-31 11:53 ` Kalle Valo
2017-05-31 11:53   ` Kalle Valo
2017-05-31 12:16 ` Kalle Valo
2017-05-31 12:16   ` Kalle Valo
2017-05-31 20:20   ` Arend van Spriel
2017-05-31 20:20     ` Arend van Spriel
2017-05-31 20:23     ` Adrian Chadd
2017-05-31 20:23       ` Adrian Chadd
2017-05-31 21:28       ` Arend van Spriel
2017-05-31 21:28         ` Arend van Spriel
2017-05-31 21:32         ` Adrian Chadd
2017-05-31 21:32           ` Adrian Chadd
2017-06-01 13:34       ` Kalle Valo
2017-06-01 13:34         ` Kalle Valo
2017-06-01 13:24     ` Kalle Valo
2017-06-01 13:24       ` Kalle Valo
2017-06-01 13:33       ` Adrian Chadd
2017-06-01 13:33         ` Adrian Chadd
  -- strict thread matches above, loose matches on Subject: below --
2017-05-10 16:25 Adrian Chadd
2017-05-10 16:25 ` Adrian Chadd
2017-05-10 16:44 ` Steve deRosier
2017-05-10 16:44   ` Steve deRosier
2017-05-10 16:50   ` Adrian Chadd
2017-05-10 16:50     ` Adrian Chadd
2017-05-19  9:47 ` Kalle Valo
2017-05-19  9:47   ` Kalle Valo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.