linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Emmanuel Grumbach <egrumbach@gmail.com>
To: linux-wireless@vger.kernel.org
Cc: Liad Kaufman <liad.kaufman@intel.com>,
	Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Subject: [PATCH 25/26] iwlwifi: pcie: support more monitor types dumping
Date: Tue,  2 Dec 2014 20:11:16 +0200	[thread overview]
Message-ID: <1417543877-24193-25-git-send-email-egrumbach@gmail.com> (raw)
In-Reply-To: <0BA3FCBA62E2DC44AF3030971E174FB31B5A7D27@hasmsx107.ger.corp.intel.com>

From: Liad Kaufman <liad.kaufman@intel.com>

Until this patch, dumping the monitor data could be done only
for PCIe external (DRAM) mode in 7000 HW family. This patch
allows to pull the monitor data also on other families, and
also to pull the monitor data if an internal buffer is used.

Signed-off-by: Liad Kaufman <liad.kaufman@intel.com>
Reviewed-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
---
 drivers/net/wireless/iwlwifi/pcie/trans.c | 102 +++++++++++++++++++++++-------
 1 file changed, 79 insertions(+), 23 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
index 71d466c..5d79a1f 100644
--- a/drivers/net/wireless/iwlwifi/pcie/trans.c
+++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
@@ -2065,6 +2065,7 @@ struct iwl_trans_dump_data *iwl_trans_pcie_dump_data(struct iwl_trans *trans)
 	struct iwl_fw_error_dump_txcmd *txcmd;
 	struct iwl_trans_dump_data *dump_data;
 	u32 len;
+	u32 monitor_len;
 	int i, ptr;
 
 	/* transport dump header */
@@ -2091,9 +2092,30 @@ struct iwl_trans_dump_data *iwl_trans_pcie_dump_data(struct iwl_trans *trans)
 	len += sizeof(*data) + (FH_MEM_UPPER_BOUND - FH_MEM_LOWER_BOUND);
 
 	/* FW monitor */
-	if (trans_pcie->fw_mon_page)
+	if (trans_pcie->fw_mon_page) {
 		len += sizeof(*data) + sizeof(struct iwl_fw_error_dump_fw_mon) +
-			trans_pcie->fw_mon_size;
+		       trans_pcie->fw_mon_size;
+		monitor_len = trans_pcie->fw_mon_size;
+	} else if (trans->dbg_dest_tlv) {
+		u32 base, end;
+
+		base = le32_to_cpu(trans->dbg_dest_tlv->base_reg);
+		end = le32_to_cpu(trans->dbg_dest_tlv->end_reg);
+
+		base = iwl_read_prph(trans, base) <<
+		       trans->dbg_dest_tlv->base_shift;
+		end = iwl_read_prph(trans, end) <<
+		      trans->dbg_dest_tlv->end_shift;
+
+		/* Make "end" point to the actual end */
+		if (trans->cfg->device_family == IWL_DEVICE_FAMILY_8000)
+			end += (1 << trans->dbg_dest_tlv->end_shift);
+		monitor_len = end - base;
+		len += sizeof(*data) + sizeof(struct iwl_fw_error_dump_fw_mon) +
+		       monitor_len;
+	} else {
+		monitor_len = 0;
+	}
 
 	dump_data = vzalloc(len);
 	if (!dump_data)
@@ -2133,34 +2155,68 @@ struct iwl_trans_dump_data *iwl_trans_pcie_dump_data(struct iwl_trans *trans)
 	len += iwl_trans_pcie_fh_regs_dump(trans, &data);
 	/* data is already pointing to the next section */
 
-	if (trans_pcie->fw_mon_page) {
+	if ((trans_pcie->fw_mon_page &&
+	     trans->cfg->device_family == IWL_DEVICE_FAMILY_7000) ||
+	    trans->dbg_dest_tlv) {
 		struct iwl_fw_error_dump_fw_mon *fw_mon_data;
+		u32 base, write_ptr, wrap_cnt;
+
+		/* If there was a dest TLV - use the values from there */
+		if (trans->dbg_dest_tlv) {
+			write_ptr =
+				le32_to_cpu(trans->dbg_dest_tlv->write_ptr_reg);
+			wrap_cnt = le32_to_cpu(trans->dbg_dest_tlv->wrap_count);
+			base = le32_to_cpu(trans->dbg_dest_tlv->base_reg);
+		} else {
+			base = MON_BUFF_BASE_ADDR;
+			write_ptr = MON_BUFF_WRPTR;
+			wrap_cnt = MON_BUFF_CYCLE_CNT;
+		}
 
 		data->type = cpu_to_le32(IWL_FW_ERROR_DUMP_FW_MONITOR);
-		data->len = cpu_to_le32(trans_pcie->fw_mon_size +
-					sizeof(*fw_mon_data));
 		fw_mon_data = (void *)data->data;
 		fw_mon_data->fw_mon_wr_ptr =
-			cpu_to_le32(iwl_read_prph(trans, MON_BUFF_WRPTR));
+			cpu_to_le32(iwl_read_prph(trans, write_ptr));
 		fw_mon_data->fw_mon_cycle_cnt =
-			cpu_to_le32(iwl_read_prph(trans, MON_BUFF_CYCLE_CNT));
+			cpu_to_le32(iwl_read_prph(trans, wrap_cnt));
 		fw_mon_data->fw_mon_base_ptr =
-			cpu_to_le32(iwl_read_prph(trans, MON_BUFF_BASE_ADDR));
-
-		/*
-		 * The firmware is now asserted, it won't write anything to
-		 * the buffer. CPU can take ownership to fetch the data.
-		 * The buffer will be handed back to the device before the
-		 * firmware will be restarted.
-		 */
-		dma_sync_single_for_cpu(trans->dev, trans_pcie->fw_mon_phys,
-					trans_pcie->fw_mon_size,
-					DMA_FROM_DEVICE);
-		memcpy(fw_mon_data->data, page_address(trans_pcie->fw_mon_page),
-		       trans_pcie->fw_mon_size);
-
-		len += sizeof(*data) + sizeof(*fw_mon_data) +
-			trans_pcie->fw_mon_size;
+			cpu_to_le32(iwl_read_prph(trans, base));
+
+		len += sizeof(*data) + sizeof(*fw_mon_data);
+		if (trans_pcie->fw_mon_page) {
+			data->len = cpu_to_le32(trans_pcie->fw_mon_size +
+						sizeof(*fw_mon_data));
+
+			/*
+			 * The firmware is now asserted, it won't write anything
+			 * to the buffer. CPU can take ownership to fetch the
+			 * data. The buffer will be handed back to the device
+			 * before the firmware will be restarted.
+			 */
+			dma_sync_single_for_cpu(trans->dev,
+						trans_pcie->fw_mon_phys,
+						trans_pcie->fw_mon_size,
+						DMA_FROM_DEVICE);
+			memcpy(fw_mon_data->data,
+			       page_address(trans_pcie->fw_mon_page),
+			       trans_pcie->fw_mon_size);
+
+			len += trans_pcie->fw_mon_size;
+		} else {
+			/* If we are here then the buffer is internal */
+
+			/*
+			 * Update pointers to reflect actual values after
+			 * shifting
+			 */
+			base = iwl_read_prph(trans, base) <<
+			       trans->dbg_dest_tlv->base_shift;
+			iwl_trans_read_mem(trans, base, fw_mon_data->data,
+					   monitor_len / sizeof(u32));
+			data->len = cpu_to_le32(sizeof(*fw_mon_data) +
+						monitor_len);
+			len += monitor_len;
+		}
 	}
 
 	dump_data->len = len;
-- 
1.9.1


  parent reply	other threads:[~2014-12-02 18:18 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-02 18:05 pull request: iwlwifi-next 2014-12-02 Grumbach, Emmanuel
2014-12-02 18:10 ` [PATCH 01/26] iwlwifi: move firmware file format definitions to correct header Emmanuel Grumbach
2014-12-02 18:10 ` [PATCH 02/26] iwlwifi: mvm: check and report if wake up was due to net detect Emmanuel Grumbach
2014-12-02 18:10 ` [PATCH 03/26] iwlwifi: deprecate -8.ucode for 3160 / 7260 / 7265 Emmanuel Grumbach
2014-12-02 18:10 ` [PATCH 04/26] iwlwifi: mvm: remove IWL_UCODE_TLV_CAPA_EXTENDED_BEACON Emmanuel Grumbach
2014-12-02 18:10 ` [PATCH 05/26] iwlwifi: mvm: remove IWL_UCODE_TLV_API_WOWLAN_CONFIG_TID Emmanuel Grumbach
2014-12-02 18:10 ` [PATCH 06/26] iwlwifi: mvm: remove IWL_UCODE_TLV_API_CSA_FLOW Emmanuel Grumbach
2014-12-02 18:10 ` [PATCH 07/26] iwlwifi: mvm: BT Coex - change the MPLUT registers' value Emmanuel Grumbach
2014-12-02 18:10 ` [PATCH 08/26] iwlwifi: mvm: add missing mvm ref debug print Emmanuel Grumbach
2014-12-02 18:11 ` [PATCH 09/26] iwlwifi: pcie: refactor cmd_in_flight set/clear code Emmanuel Grumbach
2014-12-02 18:11 ` [PATCH 10/26] iwlwifi: mvm: add SSID match information for net-detect Emmanuel Grumbach
2014-12-02 18:11 ` [PATCH 11/26] iwlwifi: mvm: add channel information to the netdetect notifications Emmanuel Grumbach
2014-12-02 18:11 ` [PATCH 12/26] iwlwifi: mvm: support NVM file with header Emmanuel Grumbach
2014-12-02 18:11 ` [PATCH 13/26] iwlwifi: don't load on 7265D with old NVM Emmanuel Grumbach
2014-12-02 18:11 ` [PATCH 14/26] iwlwifi: pcie: claim ownership on the device after stop_device() Emmanuel Grumbach
2014-12-02 18:11 ` [PATCH 15/26] iwlwifi: mvm: remove a dangling line of documentation Emmanuel Grumbach
2014-12-02 18:11 ` [PATCH 16/26] iwlwifi: mvm: support ucode load for family_8000 B0 only Emmanuel Grumbach
2014-12-02 18:11 ` [PATCH 17/26] iwlwifi: pcie: add fh registers to dump data Emmanuel Grumbach
2014-12-02 18:11 ` [PATCH 18/26] iwlwifi: fix 4165 series name Emmanuel Grumbach
2014-12-02 18:11 ` [PATCH 19/26] iwlwifi: use correct fw file in 8000 b-step Emmanuel Grumbach
2014-12-02 18:11 ` [PATCH 20/26] iwlwifi: dvm: fix flush support for old firmware Emmanuel Grumbach
2014-12-02 18:11 ` [PATCH 21/26] iwlwifi: mvm: update values for Smart Fifo Emmanuel Grumbach
2014-12-02 18:11 ` [PATCH 22/26] iwlwifi: define the .ucode file format for debug Emmanuel Grumbach
2014-12-02 18:11 ` [PATCH 23/26] iwlwifi: mvm: send dbg config hcmds to fw if set in tlv Emmanuel Grumbach
2014-12-02 18:11 ` [PATCH 24/26] iwlwifi: pcie: config regs according to fw tlv Emmanuel Grumbach
2014-12-02 18:11 ` Emmanuel Grumbach [this message]
2014-12-02 18:11 ` [PATCH 26/26] iwlwifi: mvm: Ability to work with packed usniffer image Emmanuel Grumbach
2014-12-02 21:56 ` pull request: iwlwifi-next 2014-12-02 John W. Linville

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1417543877-24193-25-git-send-email-egrumbach@gmail.com \
    --to=egrumbach@gmail.com \
    --cc=emmanuel.grumbach@intel.com \
    --cc=liad.kaufman@intel.com \
    --cc=linux-wireless@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).