Skip to contentSkip to conversation

[PATCH v2 0/3]

PATCH In review Rakesh Pillai 4 participants 10 messages Jul 31, 2020 – Aug 1, 2020

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

v2 cover [PATCH v2 0/3]

The history recording will be compiled only if ATH10K_DEBUG is enabled, and also enabled via the module parameter. Once the history recording is enabled via module parameter, it can be enabled or disabled runtime via debugfs.

---
Changes from v1:
- Add module param and debugfs to enable/disable history recording.

Rakesh Pillai (3):
ath10k: Add history for tracking certain events
ath10k: Add module param to enable history
ath10k: Add debugfs support to enable event history

 drivers/net/wireless/ath/ath10k/ce.c      |   1 +
 drivers/net/wireless/ath/ath10k/core.c    |   3 +
 drivers/net/wireless/ath/ath10k/core.h    |  82 ++++++++++++
 drivers/net/wireless/ath/ath10k/debug.c   | 207 ++++++++++++++++++++++++++++++
 drivers/net/wireless/ath/ath10k/debug.h   |  75 +++++++++++
 drivers/net/wireless/ath/ath10k/snoc.c    |  15 ++-
 drivers/net/wireless/ath/ath10k/wmi-tlv.c |   1 +
 drivers/net/wireless/ath/ath10k/wmi.c     |  10 ++
 8 files changed, 393 insertions(+), 1 deletion(-)
Signature · 1 line
2.7.4
#1 lore raw

PATCH v2 1/3 ath10k: Add history for tracking certain events

Add history for tracking the below events
- register read
- register write
- IRQ trigger
- NAPI poll
- CE service
- WMI cmd
- WMI event
- WMI tx completion

This will help in debugging any crash or any
improper behaviour.

Tested-on: WCN3990 hw1.0 SNOC WLAN.HL.3.1-01040-QCAHLSWMTPLZ-1

---
 drivers/net/wireless/ath/ath10k/ce.c      |   1 +
 drivers/net/wireless/ath/ath10k/core.h    |  74 +++++++++++++++++
 drivers/net/wireless/ath/ath10k/debug.c   | 133 ++++++++++++++++++++++++++++++
 drivers/net/wireless/ath/ath10k/debug.h   |  74 +++++++++++++++++
 drivers/net/wireless/ath/ath10k/snoc.c    |  15 +++-
 drivers/net/wireless/ath/ath10k/wmi-tlv.c |   1 +
 drivers/net/wireless/ath/ath10k/wmi.c     |  10 +++
 7 files changed, 307 insertions(+), 1 deletion(-)
drivers/net/wireless/ath/ath10k/ce.c +1 -0
index 84ec80c..0f541de 100644
@@ -1299,6 +1299,7 @@ void ath10k_ce_per_engine_service(struct ath10k *ar, unsigned int ce_id)
 	struct ath10k_hw_ce_host_wm_regs *wm_regs = ar->hw_ce_regs->wm_regs;
 	u32 ctrl_addr = ce_state->ctrl_addr;
 
+	ath10k_record_ce_event(ar, ATH10K_CE_SERVICE, ce_id);
 	/*
 	 * Clear before handling
 	 *
drivers/net/wireless/ath/ath10k/core.h +74 -0

86 lines not on this page · raw message

drivers/net/wireless/ath/ath10k/debug.c +133 -0

137 lines not on this page · raw message

drivers/net/wireless/ath/ath10k/debug.h +74 -0

86 lines not on this page · raw message

drivers/net/wireless/ath/ath10k/snoc.c +14 -1
index 1ef5fdb..aa7ee32 100644
@@ -473,6 +473,7 @@ static void ath10k_snoc_write32(struct ath10k *ar, u32 offset, u32 value)
 {
 	struct ath10k_snoc *ar_snoc = ath10k_snoc_priv(ar);
 
+	ath10k_record_reg_access(ar, offset, value, true);
 	iowrite32(value, ar_snoc->mem + offset);
 }
 
@@ -482,6 +483,7 @@ static u32 ath10k_snoc_read32(struct ath10k *ar, u32 offset)
 	u32 val;
 
 	val = ioread32(ar_snoc->mem + offset);
+	ath10k_record_reg_access(ar, offset, val, false);
 
 	return val;
 }
@@ -1159,6 +1161,7 @@ static irqreturn_t ath10k_snoc_per_engine_handler(int irq, void *arg)
 			    ce_id);
 		return IRQ_HANDLED;
 	}
+	ath10k_record_ce_event(ar, ATH10K_IRQ_TRIGGER, ce_id);
 
 	ath10k_ce_disable_interrupt(ar, ce_id);
 	set_bit(ce_id, ar_snoc->pending_ce_irqs);
@@ -1175,6 +1178,7 @@ static int ath10k_snoc_napi_poll(struct napi_struct *ctx, int budget)
 	int done = 0;
 	int ce_id;
 
+	ath10k_record_ce_event(ar, ATH10K_NAPI_POLL, 0);
 	if (test_bit(ATH10K_FLAG_CRASH_FLUSH, &ar->dev_flags)) {
 		napi_complete(ctx);
 		return done;
@@ -1188,8 +1192,12 @@ static int ath10k_snoc_napi_poll(struct napi_struct *ctx, int budget)
 
 	done = ath10k_htt_txrx_compl_task(ar, budget);
 
-	if (done < budget)
+	if (done < budget) {
 		napi_complete(ctx);
+		ath10k_record_ce_event(ar, ATH10K_NAPI_COMPLETE, 0);
+	} else {
+		ath10k_record_ce_event(ar, ATH10K_NAPI_RESCHED, 0);
+	}
 
 	return done;
 }
@@ -1660,6 +1668,11 @@ static int ath10k_snoc_probe(struct platform_device *pdev)
 	ar->ce_priv = &ar_snoc->ce;
 	msa_size = drv_data->msa_size;
 
+	ath10k_core_reg_access_history_init(ar, ATH10K_REG_ACCESS_HISTORY_MAX);
+	ath10k_core_wmi_event_history_init(ar, ATH10K_WMI_EVENT_HISTORY_MAX);
+	ath10k_core_wmi_cmd_history_init(ar, ATH10K_WMI_CMD_HISTORY_MAX);
+	ath10k_core_ce_event_history_init(ar, ATH10K_CE_EVENT_HISTORY_MAX);
+
 	ath10k_snoc_quirks_init(ar);
 
 	ret = ath10k_snoc_resource_init(ar);
drivers/net/wireless/ath/ath10k/wmi-tlv.c +1 -0
index 932266d..9df5748 100644
@@ -627,6 +627,7 @@ static void ath10k_wmi_tlv_op_rx(struct ath10k *ar, struct sk_buff *skb)
 	if (skb_pull(skb, sizeof(struct wmi_cmd_hdr)) == NULL)
 		goto out;
 
+	ath10k_record_wmi_event(ar, ATH10K_WMI_EVENT, id, skb->data);
 	trace_ath10k_wmi_event(ar, id, skb->data, skb->len);
 
 	consumed = ath10k_tm_event_wmi(ar, id, skb);
drivers/net/wireless/ath/ath10k/wmi.c +10 -0
index a81a1ab..8ebd05c 100644
@@ -1802,6 +1802,15 @@ struct sk_buff *ath10k_wmi_alloc_skb(struct ath10k *ar, u32 len)
 
 static void ath10k_wmi_htc_tx_complete(struct ath10k *ar, struct sk_buff *skb)
 {
+	struct wmi_cmd_hdr *cmd_hdr;
+	enum wmi_tlv_event_id id;
+
+	cmd_hdr = (struct wmi_cmd_hdr *)skb->data;
+	id = MS(__le32_to_cpu(cmd_hdr->cmd_id), WMI_CMD_HDR_CMD_ID);
+
+	ath10k_record_wmi_event(ar, ATH10K_WMI_TX_COMPL, id,
+				skb->data + sizeof(struct wmi_cmd_hdr));
+
 	dev_kfree_skb(skb);
 }
 
@@ -1912,6 +1921,7 @@ int ath10k_wmi_cmd_send(struct ath10k *ar, struct sk_buff *skb, u32 cmd_id)
 
 	might_sleep();
 
+	ath10k_record_wmi_event(ar, ATH10K_WMI_CMD, cmd_id, skb->data);
 	if (cmd_id == WMI_CMD_UNSUPPORTED) {
 		ath10k_warn(ar, "wmi command %d is not supported by firmware\n",
 			    cmd_id);
Signature · 1 line
2.7.4
#2 lore raw

Re: [PATCH v2 1/3] ath10k: Add history for tracking certain events

Quoted 27 lines · Rakesh Pillai

Add history for tracking the below events
- register read
- register write
- IRQ trigger
- NAPI poll
- CE service
- WMI cmd
- WMI event
- WMI tx completion

This will help in debugging any crash or any
improper behaviour.

Tested-on: WCN3990 hw1.0 SNOC WLAN.HL.3.1-01040-QCAHLSWMTPLZ-1

---
  drivers/net/wireless/ath/ath10k/ce.c      |   1 +
  drivers/net/wireless/ath/ath10k/core.h    |  74 +++++++++++++++++
  drivers/net/wireless/ath/ath10k/debug.c   | 133 ++++++++++++++++++++++++++++++
  drivers/net/wireless/ath/ath10k/debug.h   |  74 +++++++++++++++++
  drivers/net/wireless/ath/ath10k/snoc.c    |  15 +++-
  drivers/net/wireless/ath/ath10k/wmi-tlv.c |   1 +
  drivers/net/wireless/ath/ath10k/wmi.c     |  10 +++
  7 files changed, 307 insertions(+), 1 deletion(-)

drivers/net/wireless/ath/ath10k/debug.c void ath10k_dbg_dump(struct ath10k *ar, · line 2812

Quoted 9 lines
drivers/net/wireless/ath/ath10k/debug.c +9 -0
+void ath10k_record_wmi_event(struct ath10k *ar, enum ath10k_wmi_type type,
+			     u32 id, unsigned char *data)
+{
+	struct ath10k_wmi_event_entry *entry;
+	u32 idx;
+
+	if (type == ATH10K_WMI_EVENT) {
+		if (!ar->wmi_event_history.record)
+			return;

This check above is duplicated below, add it once at top of the method instead.

Quoted 26 lines
drivers/net/wireless/ath/ath10k/debug.c +24 -0
+
+		spin_lock_bh(&ar->wmi_event_history.hist_lock);
+		idx = ath10k_core_get_next_idx(&ar->reg_access_history.index,
+					       ar->wmi_event_history.max_entries);
+		spin_unlock_bh(&ar->wmi_event_history.hist_lock);
+		entry = &ar->wmi_event_history.record[idx];
+	} else {
+		if (!ar->wmi_cmd_history.record)
+			return;
+
+		spin_lock_bh(&ar->wmi_cmd_history.hist_lock);
+		idx = ath10k_core_get_next_idx(&ar->reg_access_history.index,
+					       ar->wmi_cmd_history.max_entries);
+		spin_unlock_bh(&ar->wmi_cmd_history.hist_lock);
+		entry = &ar->wmi_cmd_history.record[idx];
+	}
+
+	entry->timestamp = ath10k_core_get_timestamp();
+	entry->cpu_id = smp_processor_id();
+	entry->type = type;
+	entry->id = id;
+	memcpy(&entry->data, data + 4, ATH10K_WMI_DATA_LEN);
+}
+EXPORT_SYMBOL(ath10k_record_wmi_event);

drivers/net/wireless/ath/ath10k/debug.c static int ath10k_snoc_probe(struct platform_device *pdev) · line 1674

Quoted 7 lines
drivers/net/wireless/ath/ath10k/debug.c +4 -0
@@ -1660,6 +1668,11 @@ static int ath10k_snoc_probe(struct platform_device *pdev)
  	ar->ce_priv = &ar_snoc->ce;
  	msa_size = drv_data->msa_size;
 
+	ath10k_core_reg_access_history_init(ar, ATH10K_REG_ACCESS_HISTORY_MAX);
+	ath10k_core_wmi_event_history_init(ar, ATH10K_WMI_EVENT_HISTORY_MAX);
+	ath10k_core_wmi_cmd_history_init(ar, ATH10K_WMI_CMD_HISTORY_MAX);
+	ath10k_core_ce_event_history_init(ar, ATH10K_CE_EVENT_HISTORY_MAX);

Maybe only enable this once user turns it on? It sucks up a bit of memory?

Quoted 25 lines
drivers/net/wireless/ath/ath10k/snoc.c +1 -0
+
  	ath10k_snoc_quirks_init(ar);
 
  	ret = ath10k_snoc_resource_init(ar);
drivers/net/wireless/ath/ath10k/wmi-tlv.c +1 -0
index 932266d..9df5748 100644
@@ -627,6 +627,7 @@ static void ath10k_wmi_tlv_op_rx(struct ath10k *ar, struct sk_buff *skb)
  	if (skb_pull(skb, sizeof(struct wmi_cmd_hdr)) == NULL)
  		goto out;
 
+	ath10k_record_wmi_event(ar, ATH10K_WMI_EVENT, id, skb->data);
  	trace_ath10k_wmi_event(ar, id, skb->data, skb->len);
 
  	consumed = ath10k_tm_event_wmi(ar, id, skb);
drivers/net/wireless/ath/ath10k/wmi.c +1 -0
index a81a1ab..8ebd05c 100644
@@ -1802,6 +1802,15 @@ struct sk_buff *ath10k_wmi_alloc_skb(struct ath10k *ar, u32 len)
 
  static void ath10k_wmi_htc_tx_complete(struct ath10k *ar, struct sk_buff *skb)
  {
+	struct wmi_cmd_hdr *cmd_hdr;

drivers/net/wireless/ath/ath10k/wmi.c struct sk_buff *ath10k_wmi_alloc_skb(struct ath10k *ar, u32 len) · line 1815

Quoted 10 lines
drivers/net/wireless/ath/ath10k/wmi.c +8 -0
+	enum wmi_tlv_event_id id;
+
+	cmd_hdr = (struct wmi_cmd_hdr *)skb->data;
+	id = MS(__le32_to_cpu(cmd_hdr->cmd_id), WMI_CMD_HDR_CMD_ID);
+
+	ath10k_record_wmi_event(ar, ATH10K_WMI_TX_COMPL, id,
+				skb->data + sizeof(struct wmi_cmd_hdr));
+
  	dev_kfree_skb(skb);
  }

I think guard the above new code with if (unlikely(ar->ce_event_history.record)) { ... }

All in all, I think I'd want to compile this out (while leaving other debug compiled in) since it seems this stuff would be rarely used and it adds method calls to hot paths.

That is a decision for Kalle though, so see what he says...

Thanks,
Ben

Signature · 2 lines
Ben Greear <[email protected]>
Candela Technologies Inc  http://www.candelatech.com
#3 lore raw

RE: [PATCH v2 1/3] ath10k: Add history for tracking certain events

Quoted 42 lines

-----Original Message-----
From: Ben Greear <[email protected]>
Sent: Saturday, August 1, 2020 12:08 AM
To: Rakesh Pillai <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v2 1/3] ath10k: Add history for tracking certain events

Quoted 13 lines · Rakesh Pillai

Add history for tracking the below events
- register read
- register write
- IRQ trigger
- NAPI poll
- CE service
- WMI cmd
- WMI event
- WMI tx completion

This will help in debugging any crash or any
improper behaviour.

Quoted 7 lines

Tested-on: WCN3990 hw1.0 SNOC WLAN.HL.3.1-01040-QCAHLSWMTPLZ-1

---
  drivers/net/wireless/ath/ath10k/ce.c      |   1 +
  drivers/net/wireless/ath/ath10k/core.h    |  74 +++++++++++++++++
  drivers/net/wireless/ath/ath10k/debug.c   | 133

++++++++++++++++++++++++++++++

Quoted 8 lines
  drivers/net/wireless/ath/ath10k/debug.h   |  74 +++++++++++++++++
  drivers/net/wireless/ath/ath10k/snoc.c    |  15 +++-
  drivers/net/wireless/ath/ath10k/wmi-tlv.c |   1 +
  drivers/net/wireless/ath/ath10k/wmi.c     |  10 +++
  7 files changed, 307 insertions(+), 1 deletion(-)

+void ath10k_record_wmi_event(struct ath10k *ar, enum

ath10k_wmi_type type,

Quoted 11 lines

drivers/net/wireless/ath/ath10k/debug.c void ath10k_dbg_dump(struct ath10k *ar, · line 2812

Quoted 8 lines
drivers/net/wireless/ath/ath10k/debug.c +8 -0
+			     u32 id, unsigned char *data)
+{
+	struct ath10k_wmi_event_entry *entry;
+	u32 idx;
+
+	if (type == ATH10K_WMI_EVENT) {
+		if (!ar->wmi_event_history.record)
+			return;

This check above is duplicated below, add it once at top of the method instead.

The same function is used to record WMI events and CMD, which are stored in different memory locations. Hence the check " if (type == ATH10K_WMI_EVENT) {" is necessary.

Quoted 37 lines

drivers/net/wireless/ath/ath10k/debug.c static int ath10k_snoc_probe(struct

Quoted 31 lines
drivers/net/wireless/ath/ath10k/debug.c +3 -0
+
+		spin_lock_bh(&ar->wmi_event_history.hist_lock);
+		idx = ath10k_core_get_next_idx(&ar-

reg_access_history.index,

(quoted diff) +1 -0
+					       ar-

wmi_event_history.max_entries);

drivers/net/wireless/ath/ath10k/debug.c +8 -0
+		spin_unlock_bh(&ar->wmi_event_history.hist_lock);
+		entry = &ar->wmi_event_history.record[idx];
+	} else {
+		if (!ar->wmi_cmd_history.record)
+			return;
+
+		spin_lock_bh(&ar->wmi_cmd_history.hist_lock);
+		idx = ath10k_core_get_next_idx(&ar-

reg_access_history.index,

(quoted diff) +1 -0
+					       ar-

wmi_cmd_history.max_entries);

drivers/net/wireless/ath/ath10k/debug.c +11 -0
+		spin_unlock_bh(&ar->wmi_cmd_history.hist_lock);
+		entry = &ar->wmi_cmd_history.record[idx];
+	}
+
+	entry->timestamp = ath10k_core_get_timestamp();
+	entry->cpu_id = smp_processor_id();
+	entry->type = type;
+	entry->id = id;
+	memcpy(&entry->data, data + 4, ATH10K_WMI_DATA_LEN);
+}
+EXPORT_SYMBOL(ath10k_record_wmi_event);
@@ -1660,6 +1668,11 @@ static int ath10k_snoc_probe(struct

platform_device *pdev)

drivers/net/wireless/ath/ath10k/snoc.c static int ath10k_snoc_probe(struct platform_device *pdev)

Quoted 4 lines
drivers/net/wireless/ath/ath10k/snoc.c +1 -0
  	ar->ce_priv = &ar_snoc->ce;
  	msa_size = drv_data->msa_size;
 
+	ath10k_core_reg_access_history_init(ar,

ATH10K_REG_ACCESS_HISTORY_MAX);

Quoted 8 lines

Review static int ath10k_snoc_probe(struct · line 1672

Quoted 1 line
(quoted diff) +1 -0
+	ath10k_core_wmi_event_history_init(ar,

ATH10K_WMI_EVENT_HISTORY_MAX);

Review static int ath10k_snoc_probe(struct · line 1673

Quoted 1 line
(quoted diff) +1 -0
+	ath10k_core_wmi_cmd_history_init(ar,

ATH10K_WMI_CMD_HISTORY_MAX);

Review static int ath10k_snoc_probe(struct · line 1674

Quoted 1 line
(quoted diff) +1 -0
+	ath10k_core_ce_event_history_init(ar,

ATH10K_CE_EVENT_HISTORY_MAX);

Maybe only enable this once user turns it on? It sucks up a bit of memory?

This memory will be allocated only if the history is enabled via module param, else the function just returns 0.

Quoted 46 lines

Review

Quoted 6 lines
drivers/net/wireless/ath/ath10k/snoc.c +1 -0
+
  	ath10k_snoc_quirks_init(ar);
 
  	ret = ath10k_snoc_resource_init(ar);
(quoted diff) +0 -0

b/drivers/net/wireless/ath/ath10k/wmi-tlv.c

drivers/net/wireless/ath/ath10k/wmi-tlv.c static void ath10k_wmi_tlv_op_rx(struct ath10k *ar,

Quoted 4 lines

index 932266d..9df5748 100644

drivers/net/wireless/ath/ath10k/wmi-tlv.c +0 -0
@@ -627,6 +627,7 @@ static void ath10k_wmi_tlv_op_rx(struct ath10k *ar,

struct sk_buff *skb)

Review

Quoted 8 lines
drivers/net/wireless/ath/ath10k/wmi-tlv.c +1 -0
  	if (skb_pull(skb, sizeof(struct wmi_cmd_hdr)) == NULL)
  		goto out;
 
+	ath10k_record_wmi_event(ar, ATH10K_WMI_EVENT, id, skb->data);
  	trace_ath10k_wmi_event(ar, id, skb->data, skb->len);
 
  	consumed = ath10k_tm_event_wmi(ar, id, skb);
(quoted diff) +0 -0

b/drivers/net/wireless/ath/ath10k/wmi.c

drivers/net/wireless/ath/ath10k/wmi.c struct sk_buff *ath10k_wmi_alloc_skb(struct

Quoted 4 lines

index a81a1ab..8ebd05c 100644

drivers/net/wireless/ath/ath10k/wmi.c +0 -0
@@ -1802,6 +1802,15 @@ struct sk_buff *ath10k_wmi_alloc_skb(struct

ath10k *ar, u32 len)

drivers/net/wireless/ath/ath10k/wmi.c struct sk_buff *ath10k_wmi_alloc_skb(struct · line 1802

Quoted 2 lines
drivers/net/wireless/ath/ath10k/wmi.c +0 -0
  static void ath10k_wmi_htc_tx_complete(struct ath10k *ar, struct sk_buff

*skb)

drivers/net/wireless/ath/ath10k/wmi.c struct sk_buff *ath10k_wmi_alloc_skb(struct ath10k *ar, u32 len)

Quoted 6 lines
drivers/net/wireless/ath/ath10k/wmi.c +5 -0
  {
+	struct wmi_cmd_hdr *cmd_hdr;
+	enum wmi_tlv_event_id id;
+
+	cmd_hdr = (struct wmi_cmd_hdr *)skb->data;
+	id = MS(__le32_to_cpu(cmd_hdr->cmd_id),

WMI_CMD_HDR_CMD_ID);

drivers/net/wireless/ath/ath10k/wmi.c struct sk_buff *ath10k_wmi_alloc_skb(struct ath10k *ar, u32 len) · line 1815

Quoted 6 lines
drivers/net/wireless/ath/ath10k/wmi.c +4 -0
+
+	ath10k_record_wmi_event(ar, ATH10K_WMI_TX_COMPL, id,
+				skb->data + sizeof(struct wmi_cmd_hdr));
+
  	dev_kfree_skb(skb);
  }

I think guard the above new code with if (unlikely(ar-

drivers/net/wireless/ath/ath10k/wmi.c struct sk_buff *ath10k_wmi_alloc_skb(struct · line 1815

Quoted 1 line
drivers/net/wireless/ath/ath10k/wmi.c +0 -0
 ce_event_history.record)) { ... }
Quoted 7 lines

All in all, I think I'd want to compile this out (while leaving other debug compiled
in) since it seems this stuff would be rarely used and it adds method calls to hot
paths.

That is a decision for Kalle though, so see what he says...

Sure let me add this check.

Quoted 8 lines

Thanks,
Ben

--
Ben Greear <[email protected]>
Candela Technologies Inc http://www.candelatech.com

_______________________________________________
ath10k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath10k

#4 lore raw

PATCH v2 2/3 ath10k: Add module param to enable history

In reply to Rakesh Pillai

Add a module param to enable recording history of certain debug events. This module parameter is a mask of the different history recording to be enabled.

The memory for recording the history will not be allocated if its not enabled via module parameter. This is to avoid unnecessary memory allocation when recording the history is not needed.

To enable all the history recording, the driver should be loaded as below
"insmod ath10k_core.ko history_enable_mask=0xf"

Tested-on: WCN3990 hw1.0 SNOC WLAN.HL.3.1-01040-QCAHLSWMTPLZ-1

---
 drivers/net/wireless/ath/ath10k/core.c  |  3 +++
 drivers/net/wireless/ath/ath10k/core.h  |  8 ++++++++
 drivers/net/wireless/ath/ath10k/debug.c | 26 ++++++++++++++++++++++----
 drivers/net/wireless/ath/ath10k/debug.h |  1 +
 4 files changed, 34 insertions(+), 4 deletions(-)
drivers/net/wireless/ath/ath10k/core.c +3 -0
index 9104496..f91a9d0 100644
@@ -29,6 +29,7 @@
 unsigned int ath10k_debug_mask;
 EXPORT_SYMBOL(ath10k_debug_mask);
 
+unsigned long ath10k_history_enable_mask;
 static unsigned int ath10k_cryptmode_param;
 static bool uart_print;
 static bool skip_otp;
@@ -46,6 +47,7 @@ module_param(skip_otp, bool, 0644);
 module_param(rawmode, bool, 0644);
 module_param(fw_diag_log, bool, 0644);
 module_param_named(coredump_mask, ath10k_coredump_mask, ulong, 0444);
+module_param_named(history_enable_mask, ath10k_history_enable_mask, ulong, 0444);
 
 MODULE_PARM_DESC(debug_mask, "Debugging mask");
 MODULE_PARM_DESC(uart_print, "Uart target debugging");
@@ -54,6 +56,7 @@ MODULE_PARM_DESC(cryptmode, "Crypto mode: 0-hardware, 1-software");
 MODULE_PARM_DESC(rawmode, "Use raw 802.11 frame datapath");
 MODULE_PARM_DESC(coredump_mask, "Bitfield of what to include in firmware crash file");
 MODULE_PARM_DESC(fw_diag_log, "Diag based fw log debugging");
+MODULE_PARM_DESC(history_enable_mask, "Enable events history recording");
 
 static const struct ath10k_hw_params ath10k_hw_params_list[] = {
 	{
drivers/net/wireless/ath/ath10k/core.h +8 -0
index 46bd5aa..ce429df 100644
@@ -977,6 +977,14 @@ struct ath10k_bus_params {
 
 #define ATH10K_WMI_DATA_LEN	16
 
+enum ath10k_history {
+	ATH10K_REG_ACCESS_HISTORY,
+	ATH10K_CE_EVENTS_HISTORY,
+	ATH10K_WMI_CMD_HISTORY,
+	ATH10K_WMI_EVENTS_HISTORY,
+	ATH10K_HISTORY_MAX,
+};
+
 enum ath10k_ce_event {
 	ATH10K_IRQ_TRIGGER,
 	ATH10K_NAPI_POLL,
drivers/net/wireless/ath/ath10k/debug.c +22 -4
index 9105b0b..5d08652 100644
@@ -2724,6 +2724,9 @@ EXPORT_SYMBOL(ath10k_dbg_dump);
 
 int ath10k_core_reg_access_history_init(struct ath10k *ar, u32 max_entries)
 {
+	if (!test_bit(ATH10K_REG_ACCESS_HISTORY, &ath10k_history_enable_mask))
+		return 0;
+
 	ar->reg_access_history.record = vzalloc(max_entries *
 						sizeof(struct ath10k_reg_access_entry));
 	if (!ar->reg_access_history.record)
@@ -2739,6 +2742,9 @@ EXPORT_SYMBOL(ath10k_core_reg_access_history_init);
 
 int ath10k_core_wmi_cmd_history_init(struct ath10k *ar, u32 max_entries)
 {
+	if (!test_bit(ATH10K_WMI_CMD_HISTORY, &ath10k_history_enable_mask))
+		return 0;
+
 	ar->wmi_cmd_history.record = vzalloc(max_entries *
 					     sizeof(struct ath10k_wmi_event_entry));
 	if (!ar->wmi_cmd_history.record)
@@ -2754,6 +2760,9 @@ EXPORT_SYMBOL(ath10k_core_wmi_cmd_history_init);
 
 int ath10k_core_wmi_event_history_init(struct ath10k *ar, u32 max_entries)
 {
+	if (!test_bit(ATH10K_WMI_EVENTS_HISTORY, &ath10k_history_enable_mask))
+		return 0;
+
 	ar->wmi_event_history.record = vzalloc(max_entries *
 					       sizeof(struct ath10k_wmi_event_entry));
 	if (!ar->wmi_event_history.record)
@@ -2769,6 +2778,9 @@ EXPORT_SYMBOL(ath10k_core_wmi_event_history_init);
 
 int ath10k_core_ce_event_history_init(struct ath10k *ar, u32 max_entries)
 {
+	if (!test_bit(ATH10K_CE_EVENTS_HISTORY, &ath10k_history_enable_mask))
+		return 0;
+
 	ar->ce_event_history.record = vzalloc(max_entries *
 					      sizeof(struct ath10k_ce_event_entry));
 	if (!ar->ce_event_history.record)
@@ -2787,7 +2799,8 @@ void ath10k_record_reg_access(struct ath10k *ar, u32 offset, u32 val, bool write
 	struct ath10k_reg_access_entry *entry;
 	u32 idx;
 
-	if (!ar->reg_access_history.record)
+	if (!test_bit(ATH10K_REG_ACCESS_HISTORY, &ath10k_history_enable_mask) ||
+	    !ar->reg_access_history.record)
 		return;
 
 	idx = ath10k_core_get_next_idx(&ar->reg_access_history.index,
@@ -2808,7 +2821,9 @@ void ath10k_record_wmi_event(struct ath10k *ar, enum ath10k_wmi_type type,
 	u32 idx;
 
 	if (type == ATH10K_WMI_EVENT) {
-		if (!ar->wmi_event_history.record)
+		if (!test_bit(ATH10K_WMI_EVENTS_HISTORY,
+			      &ath10k_history_enable_mask) ||
+		    !ar->wmi_event_history.record)
 			return;
 
 		spin_lock_bh(&ar->wmi_event_history.hist_lock);
@@ -2817,7 +2832,9 @@ void ath10k_record_wmi_event(struct ath10k *ar, enum ath10k_wmi_type type,
 		spin_unlock_bh(&ar->wmi_event_history.hist_lock);
 		entry = &ar->wmi_event_history.record[idx];
 	} else {
-		if (!ar->wmi_cmd_history.record)
+		if (!test_bit(ATH10K_WMI_CMD_HISTORY,
+			      &ath10k_history_enable_mask) ||
+		    !ar->wmi_event_history.record)
 			return;
 
 		spin_lock_bh(&ar->wmi_cmd_history.hist_lock);
@@ -2841,7 +2858,8 @@ void ath10k_record_ce_event(struct ath10k *ar, enum ath10k_ce_event event_type,
 	struct ath10k_ce_event_entry *entry;
 	u32 idx;
 
-	if (!ar->ce_event_history.record)
+	if (!test_bit(ATH10K_CE_EVENTS_HISTORY, &ath10k_history_enable_mask) ||
+	    !ar->ce_event_history.record)
 		return;
 
 	idx = ath10k_core_get_next_idx(&ar->ce_event_history.index,
drivers/net/wireless/ath/ath10k/debug.h +1 -0
index c28aeb1..7799b89 100644
@@ -75,6 +75,7 @@ struct ath10k_pktlog_hdr {
 #define ATH10K_TX_POWER_MIN_VAL 0
 
 extern unsigned int ath10k_debug_mask;
+extern unsigned long ath10k_history_enable_mask;
 
 __printf(2, 3) void ath10k_info(struct ath10k *ar, const char *fmt, ...);
 __printf(2, 3) void ath10k_err(struct ath10k *ar, const char *fmt, ...);
Signature · 1 line
2.7.4
#5 lore raw

PATCH v2 3/3 ath10k: Add debugfs support to enable event history

In reply to Rakesh Pillai

Add the support to enable/disable the recording of debug events history.

The enable/disable of the history from debugfs will not make any affect if its not enabled via module parameter.

Tested-on: WCN3990 hw1.0 SNOC WLAN.HL.3.1-01040-QCAHLSWMTPLZ-1

---
 drivers/net/wireless/ath/ath10k/debug.c | 56 +++++++++++++++++++++++++++++++++
 1 file changed, 56 insertions(+)
drivers/net/wireless/ath/ath10k/debug.c +56 -0
index 5d08652..6785fae 100644
@@ -610,6 +610,59 @@ static const struct file_operations fops_simulate_fw_crash = {
 	.llseek = default_llseek,
 };
 
+static ssize_t ath10k_read_history_enable(struct file *file,
+					  char __user *user_buf,
+					  size_t count, loff_t *ppos)
+{
+	const char buf[] =
+		"To enable recording of certain event history, write to this file with the enable mask\n"
+		"BIT(0): Enable Reg Access history\n"
+		"	- Register write events\n"
+		"	- Register read events\n"
+		"BIT(1): Enable CE events history\n"
+		"	- ATH10K_IRQ_TRIGGER event\n"
+		"	- ATH10K_NAPI_POLL event\n"
+		"	- ATH10K_CE_SERVICE event\n"
+		"	- ATH10K_NAPI_COMPLETE event\n"
+		"	- ATH10K_NAPI_RESCHED event\n"
+		"	- ATH10K_IRQ_SUMMARY event\n"
+		"BIT(2): Enable WMI CMD history\n"
+		"	- WMI CMD event\n"
+		"	- WMI CMD TX completion event\n"
+		"BIT(3): Enable WMI events history\n"
+		"	- WMI Events event\n";
+
+	return simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf));
+}
+
+static ssize_t ath10k_write_history_enable(struct file *file,
+					   const char __user *user_buf,
+					   size_t count, loff_t *ppos)
+{
+	u32 history_enable_mask;
+	int i, ret;
+
+	ret = kstrtou32_from_user(user_buf, count, 0, &history_enable_mask);
+	if (ret)
+		return ret;
+
+	for (i = 0; i < ATH10K_HISTORY_MAX; i++)
+		if (history_enable_mask & BIT(i))
+			set_bit(i, &ath10k_history_enable_mask);
+		else
+			clear_bit(i, &ath10k_history_enable_mask);
+
+	return count;
+}
+
+static const struct file_operations fops_history_enable = {
+	.read = ath10k_read_history_enable,
+	.write = ath10k_write_history_enable,
+	.open = simple_open,
+	.owner = THIS_MODULE,
+	.llseek = default_llseek,
+};
+
 static ssize_t ath10k_read_chip_id(struct file *file, char __user *user_buf,
 				   size_t count, loff_t *ppos)
 {
@@ -2658,6 +2711,9 @@ int ath10k_debug_register(struct ath10k *ar)
 	debugfs_create_file("reset_htt_stats", 0200, ar->debug.debugfs_phy, ar,
 			    &fops_reset_htt_stats);
 
+	debugfs_create_file("history_enable", 0644, ar->debug.debugfs_phy, ar,
+			    &fops_history_enable);
+
 	return 0;
 }
 
Signature · 7 lines
2.7.4


_______________________________________________
ath10k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath10k
#6 lore raw
In reply to Rakesh Pillai
Quoted 5 lines · Rakesh Pillai

The history recording will be compiled only if ATH10K_DEBUG is enabled, and also enabled via the module parameter. Once the history recording is enabled via module parameter, it can be enabled or disabled runtime via debugfs.

Why not use trace prints and retrieving them via the function tracer? This seems very ad-hoc.

Quoted 20 lines

---
Changes from v1:
- Add module param and debugfs to enable/disable history recording.

Rakesh Pillai (3):
ath10k: Add history for tracking certain events
ath10k: Add module param to enable history
ath10k: Add debugfs support to enable event history

 drivers/net/wireless/ath/ath10k/ce.c      |   1 +
 drivers/net/wireless/ath/ath10k/core.c    |   3 +
 drivers/net/wireless/ath/ath10k/core.h    |  82 ++++++++++++
 drivers/net/wireless/ath/ath10k/debug.c   | 207 ++++++++++++++++++++++++++++++
 drivers/net/wireless/ath/ath10k/debug.h   |  75 +++++++++++
 drivers/net/wireless/ath/ath10k/snoc.c    |  15 ++-
 drivers/net/wireless/ath/ath10k/wmi-tlv.c |   1 +
 drivers/net/wireless/ath/ath10k/wmi.c     |  10 ++
 8 files changed, 393 insertions(+), 1 deletion(-)
Signature · 6 lines
Florian

_______________________________________________
ath10k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath10k
#7 lore raw
Quoted 12 lines

-----Original Message-----
From: Florian Fainelli <[email protected]>
Sent: Saturday, August 1, 2020 12:17 AM
To: Rakesh Pillai <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v2 0/3]

On 7/31/20 11:27 AM, Rakesh Pillai wrote:

Quoted 8 lines
Quoted 5 lines

The history recording will be compiled only if ATH10K_DEBUG is enabled, and also enabled via the module parameter. Once the history recording is enabled via module parameter, it can be enabled or disabled runtime via debugfs.

Why not use trace prints and retrieving them via the function tracer? This seems very ad-hoc.

Tracing needs to be enabled to capture the events.
But these events can be turned on in some kind of a debug build and capture the history to help us debug in case there is a crash. It wont even allocate memory if not enabled via module parameter.

Quoted 26 lines
Quoted 11 lines

---
Changes from v1:
- Add module param and debugfs to enable/disable history recording.

Rakesh Pillai (3):
ath10k: Add history for tracking certain events
ath10k: Add module param to enable history
ath10k: Add debugfs support to enable event history

Quoted 4 lines
 drivers/net/wireless/ath/ath10k/ce.c      |   1 +
 drivers/net/wireless/ath/ath10k/core.c    |   3 +
 drivers/net/wireless/ath/ath10k/core.h    |  82 ++++++++++++
 drivers/net/wireless/ath/ath10k/debug.c   | 207

++++++++++++++++++++++++++++++

Quoted 6 lines
 drivers/net/wireless/ath/ath10k/debug.h   |  75 +++++++++++
 drivers/net/wireless/ath/ath10k/snoc.c    |  15 ++-
 drivers/net/wireless/ath/ath10k/wmi-tlv.c |   1 +
 drivers/net/wireless/ath/ath10k/wmi.c     |  10 ++
 8 files changed, 393 insertions(+), 1 deletion(-)

--
Florian

#8 lore raw
Quoted 18 lines · Rakesh Pillai
Quoted 18 lines

-----Original Message-----
From: Florian Fainelli <[email protected]>
Sent: Saturday, August 1, 2020 12:17 AM
To: Rakesh Pillai <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v2 0/3]

Quoted 5 lines · Rakesh Pillai

The history recording will be compiled only if ATH10K_DEBUG is enabled, and also enabled via the module parameter. Once the history recording is enabled via module parameter, it can be enabled or disabled runtime via debugfs.

Quoted 6 lines
Quoted 2 lines

Why not use trace prints and retrieving them via the function tracer? This seems very ad-hoc.

Tracing needs to be enabled to capture the events.
But these events can be turned on in some kind of a debug build and capture the history to help us debug in case there is a crash. It wont even allocate memory if not enabled via module parameter.

I would suggest researching what other drivers do and also considering the benefits, for someone doing system analysis of plugging into the kernel's general tracing mechanism to have all information in the same place and just do filtering on the record/report side.

Signature · 6 lines
Florian

_______________________________________________
ath10k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath10k
maintainer
#9 lore raw
In reply to Rakesh Pillai
Quoted 5 lines · On Fri, 31 Jul 2020 23:57:19 +0530 Rakesh Pillai wrote:

The history recording will be compiled only if ATH10K_DEBUG is enabled, and also enabled via the module parameter. Once the history recording is enabled via module parameter, it can be enabled or disabled runtime via debugfs.

Have you seen the trace_devlink_hwmsg() interface? Could it be used here?

_______________________________________________
ath10k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath10k