2015-10-28 00:17:14 +07:00
|
|
|
/******************************************************************************
|
|
|
|
*
|
|
|
|
* This file is provided under a dual BSD/GPLv2 license. When using or
|
|
|
|
* redistributing this file, you may do so under either license.
|
|
|
|
*
|
|
|
|
* GPL LICENSE SUMMARY
|
|
|
|
*
|
|
|
|
* Copyright(c) 2008 - 2014 Intel Corporation. All rights reserved.
|
|
|
|
* Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
|
2017-01-26 17:40:25 +07:00
|
|
|
* Copyright(c) 2015 - 2017 Intel Deutschland GmbH
|
2018-01-11 21:18:46 +07:00
|
|
|
* Copyright(c) 2018 Intel Corporation
|
2015-10-28 00:17:14 +07:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of version 2 of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* The full GNU General Public License is included in this distribution
|
|
|
|
* in the file called COPYING.
|
|
|
|
*
|
|
|
|
* Contact Information:
|
2015-11-17 20:39:56 +07:00
|
|
|
* Intel Linux Wireless <linuxwifi@intel.com>
|
2015-10-28 00:17:14 +07:00
|
|
|
* Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
|
|
|
|
*
|
|
|
|
* BSD LICENSE
|
|
|
|
*
|
|
|
|
* Copyright(c) 2005 - 2014 Intel Corporation. All rights reserved.
|
|
|
|
* Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
|
2017-01-26 17:40:25 +07:00
|
|
|
* Copyright(c) 2015 - 2017 Intel Deutschland GmbH
|
2018-01-11 21:18:46 +07:00
|
|
|
* Copyright(c) 2018 Intel Corporation
|
2015-10-28 00:17:14 +07:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
*
|
|
|
|
* * Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* * Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in
|
|
|
|
* the documentation and/or other materials provided with the
|
|
|
|
* distribution.
|
|
|
|
* * Neither the name Intel Corporation nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
#include <linux/devcoredump.h>
|
2017-06-01 21:03:19 +07:00
|
|
|
#include "iwl-drv.h"
|
|
|
|
#include "runtime.h"
|
|
|
|
#include "dbg.h"
|
2017-12-19 17:24:44 +07:00
|
|
|
#include "debugfs.h"
|
2015-10-28 00:17:14 +07:00
|
|
|
#include "iwl-io.h"
|
|
|
|
#include "iwl-prph.h"
|
|
|
|
#include "iwl-csr.h"
|
|
|
|
|
2017-06-01 21:03:19 +07:00
|
|
|
/**
|
|
|
|
* struct iwl_fw_dump_ptrs - set of pointers needed for the fw-error-dump
|
|
|
|
*
|
|
|
|
* @fwrt_ptr: pointer to the buffer coming from fwrt
|
|
|
|
* @trans_ptr: pointer to struct %iwl_trans_dump_data which contains the
|
|
|
|
* transport's data.
|
|
|
|
* @trans_len: length of the valid data in trans_ptr
|
|
|
|
* @fwrt_len: length of the valid data in fwrt_ptr
|
|
|
|
*/
|
|
|
|
struct iwl_fw_dump_ptrs {
|
|
|
|
struct iwl_trans_dump_data *trans_ptr;
|
|
|
|
void *fwrt_ptr;
|
|
|
|
u32 fwrt_len;
|
|
|
|
};
|
|
|
|
|
2015-12-28 20:22:28 +07:00
|
|
|
#define RADIO_REG_MAX_READ 0x2ad
|
2017-06-01 21:03:19 +07:00
|
|
|
static void iwl_read_radio_regs(struct iwl_fw_runtime *fwrt,
|
|
|
|
struct iwl_fw_error_dump_data **dump_data)
|
2015-12-28 20:22:28 +07:00
|
|
|
{
|
|
|
|
u8 *pos = (void *)(*dump_data)->data;
|
|
|
|
unsigned long flags;
|
|
|
|
int i;
|
|
|
|
|
2017-09-04 18:39:22 +07:00
|
|
|
IWL_DEBUG_INFO(fwrt, "WRT radio registers dump\n");
|
|
|
|
|
2017-06-01 21:03:19 +07:00
|
|
|
if (!iwl_trans_grab_nic_access(fwrt->trans, &flags))
|
2015-12-28 20:22:28 +07:00
|
|
|
return;
|
|
|
|
|
|
|
|
(*dump_data)->type = cpu_to_le32(IWL_FW_ERROR_DUMP_RADIO_REG);
|
|
|
|
(*dump_data)->len = cpu_to_le32(RADIO_REG_MAX_READ);
|
|
|
|
|
|
|
|
for (i = 0; i < RADIO_REG_MAX_READ; i++) {
|
|
|
|
u32 rd_cmd = RADIO_RSP_RD_CMD;
|
|
|
|
|
|
|
|
rd_cmd |= i << RADIO_RSP_ADDR_POS;
|
2017-06-01 21:03:19 +07:00
|
|
|
iwl_write_prph_no_grab(fwrt->trans, RSP_RADIO_CMD, rd_cmd);
|
|
|
|
*pos = (u8)iwl_read_prph_no_grab(fwrt->trans, RSP_RADIO_RDDAT);
|
2015-12-28 20:22:28 +07:00
|
|
|
|
|
|
|
pos++;
|
|
|
|
}
|
|
|
|
|
|
|
|
*dump_data = iwl_fw_error_next_data(*dump_data);
|
|
|
|
|
2017-06-01 21:03:19 +07:00
|
|
|
iwl_trans_release_nic_access(fwrt->trans, &flags);
|
2015-12-28 20:22:28 +07:00
|
|
|
}
|
|
|
|
|
2017-06-01 21:03:19 +07:00
|
|
|
static void iwl_fwrt_dump_rxf(struct iwl_fw_runtime *fwrt,
|
|
|
|
struct iwl_fw_error_dump_data **dump_data,
|
|
|
|
int size, u32 offset, int fifo_num)
|
2017-01-26 17:40:25 +07:00
|
|
|
{
|
|
|
|
struct iwl_fw_error_dump_fifo *fifo_hdr;
|
|
|
|
u32 *fifo_data;
|
|
|
|
u32 fifo_len;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
fifo_hdr = (void *)(*dump_data)->data;
|
|
|
|
fifo_data = (void *)fifo_hdr->data;
|
|
|
|
fifo_len = size;
|
|
|
|
|
|
|
|
/* No need to try to read the data if the length is 0 */
|
|
|
|
if (fifo_len == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Add a TLV for the RXF */
|
|
|
|
(*dump_data)->type = cpu_to_le32(IWL_FW_ERROR_DUMP_RXF);
|
|
|
|
(*dump_data)->len = cpu_to_le32(fifo_len + sizeof(*fifo_hdr));
|
|
|
|
|
|
|
|
fifo_hdr->fifo_num = cpu_to_le32(fifo_num);
|
|
|
|
fifo_hdr->available_bytes =
|
2017-06-01 21:03:19 +07:00
|
|
|
cpu_to_le32(iwl_trans_read_prph(fwrt->trans,
|
2017-01-26 17:40:25 +07:00
|
|
|
RXF_RD_D_SPACE + offset));
|
|
|
|
fifo_hdr->wr_ptr =
|
2017-06-01 21:03:19 +07:00
|
|
|
cpu_to_le32(iwl_trans_read_prph(fwrt->trans,
|
2017-01-26 17:40:25 +07:00
|
|
|
RXF_RD_WR_PTR + offset));
|
|
|
|
fifo_hdr->rd_ptr =
|
2017-06-01 21:03:19 +07:00
|
|
|
cpu_to_le32(iwl_trans_read_prph(fwrt->trans,
|
2017-01-26 17:40:25 +07:00
|
|
|
RXF_RD_RD_PTR + offset));
|
|
|
|
fifo_hdr->fence_ptr =
|
2017-06-01 21:03:19 +07:00
|
|
|
cpu_to_le32(iwl_trans_read_prph(fwrt->trans,
|
2017-01-26 17:40:25 +07:00
|
|
|
RXF_RD_FENCE_PTR + offset));
|
|
|
|
fifo_hdr->fence_mode =
|
2017-06-01 21:03:19 +07:00
|
|
|
cpu_to_le32(iwl_trans_read_prph(fwrt->trans,
|
2017-01-26 17:40:25 +07:00
|
|
|
RXF_SET_FENCE_MODE + offset));
|
|
|
|
|
|
|
|
/* Lock fence */
|
2017-06-01 21:03:19 +07:00
|
|
|
iwl_trans_write_prph(fwrt->trans, RXF_SET_FENCE_MODE + offset, 0x1);
|
2017-01-26 17:40:25 +07:00
|
|
|
/* Set fence pointer to the same place like WR pointer */
|
2017-06-01 21:03:19 +07:00
|
|
|
iwl_trans_write_prph(fwrt->trans, RXF_LD_WR2FENCE + offset, 0x1);
|
2017-01-26 17:40:25 +07:00
|
|
|
/* Set fence offset */
|
2017-06-01 21:03:19 +07:00
|
|
|
iwl_trans_write_prph(fwrt->trans,
|
2017-01-26 17:40:25 +07:00
|
|
|
RXF_LD_FENCE_OFFSET_ADDR + offset, 0x0);
|
|
|
|
|
|
|
|
/* Read FIFO */
|
|
|
|
fifo_len /= sizeof(u32); /* Size in DWORDS */
|
|
|
|
for (i = 0; i < fifo_len; i++)
|
2017-06-01 21:03:19 +07:00
|
|
|
fifo_data[i] = iwl_trans_read_prph(fwrt->trans,
|
2017-01-26 17:40:25 +07:00
|
|
|
RXF_FIFO_RD_FENCE_INC +
|
|
|
|
offset);
|
|
|
|
*dump_data = iwl_fw_error_next_data(*dump_data);
|
|
|
|
}
|
|
|
|
|
2017-06-01 21:03:19 +07:00
|
|
|
static void iwl_fwrt_dump_txf(struct iwl_fw_runtime *fwrt,
|
|
|
|
struct iwl_fw_error_dump_data **dump_data,
|
|
|
|
int size, u32 offset, int fifo_num)
|
2017-01-26 17:40:25 +07:00
|
|
|
{
|
|
|
|
struct iwl_fw_error_dump_fifo *fifo_hdr;
|
|
|
|
u32 *fifo_data;
|
|
|
|
u32 fifo_len;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
fifo_hdr = (void *)(*dump_data)->data;
|
|
|
|
fifo_data = (void *)fifo_hdr->data;
|
|
|
|
fifo_len = size;
|
|
|
|
|
|
|
|
/* No need to try to read the data if the length is 0 */
|
|
|
|
if (fifo_len == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Add a TLV for the FIFO */
|
|
|
|
(*dump_data)->type = cpu_to_le32(IWL_FW_ERROR_DUMP_TXF);
|
|
|
|
(*dump_data)->len = cpu_to_le32(fifo_len + sizeof(*fifo_hdr));
|
|
|
|
|
|
|
|
fifo_hdr->fifo_num = cpu_to_le32(fifo_num);
|
|
|
|
fifo_hdr->available_bytes =
|
2017-06-01 21:03:19 +07:00
|
|
|
cpu_to_le32(iwl_trans_read_prph(fwrt->trans,
|
2017-01-26 17:40:25 +07:00
|
|
|
TXF_FIFO_ITEM_CNT + offset));
|
|
|
|
fifo_hdr->wr_ptr =
|
2017-06-01 21:03:19 +07:00
|
|
|
cpu_to_le32(iwl_trans_read_prph(fwrt->trans,
|
2017-01-26 17:40:25 +07:00
|
|
|
TXF_WR_PTR + offset));
|
|
|
|
fifo_hdr->rd_ptr =
|
2017-06-01 21:03:19 +07:00
|
|
|
cpu_to_le32(iwl_trans_read_prph(fwrt->trans,
|
2017-01-26 17:40:25 +07:00
|
|
|
TXF_RD_PTR + offset));
|
|
|
|
fifo_hdr->fence_ptr =
|
2017-06-01 21:03:19 +07:00
|
|
|
cpu_to_le32(iwl_trans_read_prph(fwrt->trans,
|
2017-01-26 17:40:25 +07:00
|
|
|
TXF_FENCE_PTR + offset));
|
|
|
|
fifo_hdr->fence_mode =
|
2017-06-01 21:03:19 +07:00
|
|
|
cpu_to_le32(iwl_trans_read_prph(fwrt->trans,
|
2017-01-26 17:40:25 +07:00
|
|
|
TXF_LOCK_FENCE + offset));
|
|
|
|
|
|
|
|
/* Set the TXF_READ_MODIFY_ADDR to TXF_WR_PTR */
|
2017-06-01 21:03:19 +07:00
|
|
|
iwl_trans_write_prph(fwrt->trans, TXF_READ_MODIFY_ADDR + offset,
|
2017-01-26 17:40:25 +07:00
|
|
|
TXF_WR_PTR + offset);
|
|
|
|
|
|
|
|
/* Dummy-read to advance the read pointer to the head */
|
2017-06-01 21:03:19 +07:00
|
|
|
iwl_trans_read_prph(fwrt->trans, TXF_READ_MODIFY_DATA + offset);
|
2017-01-26 17:40:25 +07:00
|
|
|
|
|
|
|
/* Read FIFO */
|
|
|
|
fifo_len /= sizeof(u32); /* Size in DWORDS */
|
|
|
|
for (i = 0; i < fifo_len; i++)
|
2017-06-01 21:03:19 +07:00
|
|
|
fifo_data[i] = iwl_trans_read_prph(fwrt->trans,
|
2017-01-26 17:40:25 +07:00
|
|
|
TXF_READ_MODIFY_DATA +
|
|
|
|
offset);
|
|
|
|
*dump_data = iwl_fw_error_next_data(*dump_data);
|
|
|
|
}
|
|
|
|
|
2018-07-31 13:54:26 +07:00
|
|
|
static void iwl_fw_dump_rxf(struct iwl_fw_runtime *fwrt,
|
|
|
|
struct iwl_fw_error_dump_data **dump_data)
|
2015-10-28 00:17:14 +07:00
|
|
|
{
|
2017-06-01 21:03:19 +07:00
|
|
|
struct iwl_fwrt_shared_mem_cfg *cfg = &fwrt->smem_cfg;
|
2015-10-28 00:17:14 +07:00
|
|
|
unsigned long flags;
|
|
|
|
|
2018-07-31 13:54:26 +07:00
|
|
|
IWL_DEBUG_INFO(fwrt, "WRT RX FIFO dump\n");
|
2017-09-04 18:39:22 +07:00
|
|
|
|
2017-06-01 21:03:19 +07:00
|
|
|
if (!iwl_trans_grab_nic_access(fwrt->trans, &flags))
|
2015-10-28 00:17:14 +07:00
|
|
|
return;
|
|
|
|
|
2018-07-30 13:43:24 +07:00
|
|
|
if (iwl_fw_dbg_type_on(fwrt, IWL_FW_ERROR_DUMP_RXF)) {
|
2018-02-20 22:20:32 +07:00
|
|
|
/* Pull RXF1 */
|
|
|
|
iwl_fwrt_dump_rxf(fwrt, dump_data,
|
|
|
|
cfg->lmac[0].rxfifo1_size, 0, 0);
|
|
|
|
/* Pull RXF2 */
|
|
|
|
iwl_fwrt_dump_rxf(fwrt, dump_data, cfg->rxfifo2_size,
|
|
|
|
RXF_DIFF_FROM_PREV, 1);
|
|
|
|
/* Pull LMAC2 RXF1 */
|
|
|
|
if (fwrt->smem_cfg.num_lmacs > 1)
|
|
|
|
iwl_fwrt_dump_rxf(fwrt, dump_data,
|
|
|
|
cfg->lmac[1].rxfifo1_size,
|
|
|
|
LMAC2_PRPH_OFFSET, 2);
|
2017-01-26 17:40:25 +07:00
|
|
|
}
|
2015-10-28 00:17:14 +07:00
|
|
|
|
2018-07-31 13:54:26 +07:00
|
|
|
iwl_trans_release_nic_access(fwrt->trans, &flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void iwl_fw_dump_txf(struct iwl_fw_runtime *fwrt,
|
|
|
|
struct iwl_fw_error_dump_data **dump_data)
|
|
|
|
{
|
|
|
|
struct iwl_fw_error_dump_fifo *fifo_hdr;
|
|
|
|
struct iwl_fwrt_shared_mem_cfg *cfg = &fwrt->smem_cfg;
|
|
|
|
u32 *fifo_data;
|
|
|
|
u32 fifo_len;
|
|
|
|
unsigned long flags;
|
|
|
|
int i, j;
|
|
|
|
|
|
|
|
IWL_DEBUG_INFO(fwrt, "WRT TX FIFO dump\n");
|
|
|
|
|
|
|
|
if (!iwl_trans_grab_nic_access(fwrt->trans, &flags))
|
|
|
|
return;
|
|
|
|
|
2018-07-30 13:43:24 +07:00
|
|
|
if (iwl_fw_dbg_type_on(fwrt, IWL_FW_ERROR_DUMP_TXF)) {
|
2018-02-20 22:20:32 +07:00
|
|
|
/* Pull TXF data from LMAC1 */
|
2017-06-01 21:03:19 +07:00
|
|
|
for (i = 0; i < fwrt->smem_cfg.num_txfifo_entries; i++) {
|
2017-01-26 17:40:25 +07:00
|
|
|
/* Mark the number of TXF we're pulling now */
|
2018-02-20 22:20:32 +07:00
|
|
|
iwl_trans_write_prph(fwrt->trans, TXF_LARC_NUM, i);
|
2017-06-01 21:03:19 +07:00
|
|
|
iwl_fwrt_dump_txf(fwrt, dump_data,
|
2018-02-20 22:20:32 +07:00
|
|
|
cfg->lmac[0].txfifo_size[i], 0, i);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Pull TXF data from LMAC2 */
|
|
|
|
if (fwrt->smem_cfg.num_lmacs > 1) {
|
|
|
|
for (i = 0; i < fwrt->smem_cfg.num_txfifo_entries;
|
|
|
|
i++) {
|
|
|
|
/* Mark the number of TXF we're pulling now */
|
|
|
|
iwl_trans_write_prph(fwrt->trans,
|
|
|
|
TXF_LARC_NUM +
|
|
|
|
LMAC2_PRPH_OFFSET, i);
|
|
|
|
iwl_fwrt_dump_txf(fwrt, dump_data,
|
|
|
|
cfg->lmac[1].txfifo_size[i],
|
|
|
|
LMAC2_PRPH_OFFSET,
|
|
|
|
i + cfg->num_txfifo_entries);
|
|
|
|
}
|
2017-01-26 17:40:25 +07:00
|
|
|
}
|
2015-10-28 00:17:14 +07:00
|
|
|
}
|
|
|
|
|
2018-07-30 13:43:24 +07:00
|
|
|
if (iwl_fw_dbg_type_on(fwrt, IWL_FW_ERROR_DUMP_INTERNAL_TXF) &&
|
2018-02-20 22:20:32 +07:00
|
|
|
fw_has_capa(&fwrt->fw->ucode_capa,
|
2016-02-09 17:57:16 +07:00
|
|
|
IWL_UCODE_TLV_CAPA_EXTEND_SHARED_MEM_CFG)) {
|
|
|
|
/* Pull UMAC internal TXF data from all TXFs */
|
|
|
|
for (i = 0;
|
2017-06-01 21:03:19 +07:00
|
|
|
i < ARRAY_SIZE(fwrt->smem_cfg.internal_txfifo_size);
|
2016-02-09 17:57:16 +07:00
|
|
|
i++) {
|
|
|
|
fifo_hdr = (void *)(*dump_data)->data;
|
|
|
|
fifo_data = (void *)fifo_hdr->data;
|
2017-06-01 21:03:19 +07:00
|
|
|
fifo_len = fwrt->smem_cfg.internal_txfifo_size[i];
|
2016-02-09 17:57:16 +07:00
|
|
|
|
|
|
|
/* No need to try to read the data if the length is 0 */
|
|
|
|
if (fifo_len == 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* Add a TLV for the internal FIFOs */
|
|
|
|
(*dump_data)->type =
|
|
|
|
cpu_to_le32(IWL_FW_ERROR_DUMP_INTERNAL_TXF);
|
|
|
|
(*dump_data)->len =
|
|
|
|
cpu_to_le32(fifo_len + sizeof(*fifo_hdr));
|
|
|
|
|
|
|
|
fifo_hdr->fifo_num = cpu_to_le32(i);
|
2016-04-12 17:07:52 +07:00
|
|
|
|
|
|
|
/* Mark the number of TXF we're pulling now */
|
2017-06-01 21:03:19 +07:00
|
|
|
iwl_trans_write_prph(fwrt->trans, TXF_CPU2_NUM, i +
|
|
|
|
fwrt->smem_cfg.num_txfifo_entries);
|
2016-04-12 17:07:52 +07:00
|
|
|
|
2016-02-09 17:57:16 +07:00
|
|
|
fifo_hdr->available_bytes =
|
2017-06-01 21:03:19 +07:00
|
|
|
cpu_to_le32(iwl_trans_read_prph(fwrt->trans,
|
2016-02-09 17:57:16 +07:00
|
|
|
TXF_CPU2_FIFO_ITEM_CNT));
|
|
|
|
fifo_hdr->wr_ptr =
|
2017-06-01 21:03:19 +07:00
|
|
|
cpu_to_le32(iwl_trans_read_prph(fwrt->trans,
|
2016-02-09 17:57:16 +07:00
|
|
|
TXF_CPU2_WR_PTR));
|
|
|
|
fifo_hdr->rd_ptr =
|
2017-06-01 21:03:19 +07:00
|
|
|
cpu_to_le32(iwl_trans_read_prph(fwrt->trans,
|
2016-02-09 17:57:16 +07:00
|
|
|
TXF_CPU2_RD_PTR));
|
|
|
|
fifo_hdr->fence_ptr =
|
2017-06-01 21:03:19 +07:00
|
|
|
cpu_to_le32(iwl_trans_read_prph(fwrt->trans,
|
2016-02-09 17:57:16 +07:00
|
|
|
TXF_CPU2_FENCE_PTR));
|
|
|
|
fifo_hdr->fence_mode =
|
2017-06-01 21:03:19 +07:00
|
|
|
cpu_to_le32(iwl_trans_read_prph(fwrt->trans,
|
2016-02-09 17:57:16 +07:00
|
|
|
TXF_CPU2_LOCK_FENCE));
|
|
|
|
|
|
|
|
/* Set TXF_CPU2_READ_MODIFY_ADDR to TXF_CPU2_WR_PTR */
|
2017-06-01 21:03:19 +07:00
|
|
|
iwl_trans_write_prph(fwrt->trans,
|
2016-02-09 17:57:16 +07:00
|
|
|
TXF_CPU2_READ_MODIFY_ADDR,
|
|
|
|
TXF_CPU2_WR_PTR);
|
|
|
|
|
|
|
|
/* Dummy-read to advance the read pointer to head */
|
2017-06-01 21:03:19 +07:00
|
|
|
iwl_trans_read_prph(fwrt->trans,
|
2016-02-09 17:57:16 +07:00
|
|
|
TXF_CPU2_READ_MODIFY_DATA);
|
|
|
|
|
|
|
|
/* Read FIFO */
|
|
|
|
fifo_len /= sizeof(u32); /* Size in DWORDS */
|
|
|
|
for (j = 0; j < fifo_len; j++)
|
|
|
|
fifo_data[j] =
|
2017-06-01 21:03:19 +07:00
|
|
|
iwl_trans_read_prph(fwrt->trans,
|
2016-02-09 17:57:16 +07:00
|
|
|
TXF_CPU2_READ_MODIFY_DATA);
|
|
|
|
*dump_data = iwl_fw_error_next_data(*dump_data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-01 21:03:19 +07:00
|
|
|
iwl_trans_release_nic_access(fwrt->trans, &flags);
|
2015-10-28 00:17:14 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
#define IWL8260_ICCM_OFFSET 0x44000 /* Only for B-step */
|
|
|
|
#define IWL8260_ICCM_LEN 0xC000 /* Only for B-step */
|
|
|
|
|
2016-04-06 15:59:50 +07:00
|
|
|
struct iwl_prph_range {
|
2015-10-28 00:17:14 +07:00
|
|
|
u32 start, end;
|
2016-04-06 15:59:50 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
static const struct iwl_prph_range iwl_prph_dump_addr_comm[] = {
|
2015-10-28 00:17:14 +07:00
|
|
|
{ .start = 0x00a00000, .end = 0x00a00000 },
|
|
|
|
{ .start = 0x00a0000c, .end = 0x00a00024 },
|
|
|
|
{ .start = 0x00a0002c, .end = 0x00a0003c },
|
|
|
|
{ .start = 0x00a00410, .end = 0x00a00418 },
|
|
|
|
{ .start = 0x00a00420, .end = 0x00a00420 },
|
|
|
|
{ .start = 0x00a00428, .end = 0x00a00428 },
|
|
|
|
{ .start = 0x00a00430, .end = 0x00a0043c },
|
|
|
|
{ .start = 0x00a00444, .end = 0x00a00444 },
|
|
|
|
{ .start = 0x00a004c0, .end = 0x00a004cc },
|
|
|
|
{ .start = 0x00a004d8, .end = 0x00a004d8 },
|
|
|
|
{ .start = 0x00a004e0, .end = 0x00a004f0 },
|
|
|
|
{ .start = 0x00a00840, .end = 0x00a00840 },
|
|
|
|
{ .start = 0x00a00850, .end = 0x00a00858 },
|
|
|
|
{ .start = 0x00a01004, .end = 0x00a01008 },
|
|
|
|
{ .start = 0x00a01010, .end = 0x00a01010 },
|
|
|
|
{ .start = 0x00a01018, .end = 0x00a01018 },
|
|
|
|
{ .start = 0x00a01024, .end = 0x00a01024 },
|
|
|
|
{ .start = 0x00a0102c, .end = 0x00a01034 },
|
|
|
|
{ .start = 0x00a0103c, .end = 0x00a01040 },
|
|
|
|
{ .start = 0x00a01048, .end = 0x00a01094 },
|
|
|
|
{ .start = 0x00a01c00, .end = 0x00a01c20 },
|
|
|
|
{ .start = 0x00a01c58, .end = 0x00a01c58 },
|
|
|
|
{ .start = 0x00a01c7c, .end = 0x00a01c7c },
|
|
|
|
{ .start = 0x00a01c28, .end = 0x00a01c54 },
|
|
|
|
{ .start = 0x00a01c5c, .end = 0x00a01c5c },
|
|
|
|
{ .start = 0x00a01c60, .end = 0x00a01cdc },
|
|
|
|
{ .start = 0x00a01ce0, .end = 0x00a01d0c },
|
|
|
|
{ .start = 0x00a01d18, .end = 0x00a01d20 },
|
|
|
|
{ .start = 0x00a01d2c, .end = 0x00a01d30 },
|
|
|
|
{ .start = 0x00a01d40, .end = 0x00a01d5c },
|
|
|
|
{ .start = 0x00a01d80, .end = 0x00a01d80 },
|
|
|
|
{ .start = 0x00a01d98, .end = 0x00a01d9c },
|
|
|
|
{ .start = 0x00a01da8, .end = 0x00a01da8 },
|
|
|
|
{ .start = 0x00a01db8, .end = 0x00a01df4 },
|
|
|
|
{ .start = 0x00a01dc0, .end = 0x00a01dfc },
|
|
|
|
{ .start = 0x00a01e00, .end = 0x00a01e2c },
|
|
|
|
{ .start = 0x00a01e40, .end = 0x00a01e60 },
|
|
|
|
{ .start = 0x00a01e68, .end = 0x00a01e6c },
|
|
|
|
{ .start = 0x00a01e74, .end = 0x00a01e74 },
|
|
|
|
{ .start = 0x00a01e84, .end = 0x00a01e90 },
|
|
|
|
{ .start = 0x00a01e9c, .end = 0x00a01ec4 },
|
|
|
|
{ .start = 0x00a01ed0, .end = 0x00a01ee0 },
|
|
|
|
{ .start = 0x00a01f00, .end = 0x00a01f1c },
|
|
|
|
{ .start = 0x00a01f44, .end = 0x00a01ffc },
|
|
|
|
{ .start = 0x00a02000, .end = 0x00a02048 },
|
|
|
|
{ .start = 0x00a02068, .end = 0x00a020f0 },
|
|
|
|
{ .start = 0x00a02100, .end = 0x00a02118 },
|
|
|
|
{ .start = 0x00a02140, .end = 0x00a0214c },
|
|
|
|
{ .start = 0x00a02168, .end = 0x00a0218c },
|
|
|
|
{ .start = 0x00a021c0, .end = 0x00a021c0 },
|
|
|
|
{ .start = 0x00a02400, .end = 0x00a02410 },
|
|
|
|
{ .start = 0x00a02418, .end = 0x00a02420 },
|
|
|
|
{ .start = 0x00a02428, .end = 0x00a0242c },
|
|
|
|
{ .start = 0x00a02434, .end = 0x00a02434 },
|
|
|
|
{ .start = 0x00a02440, .end = 0x00a02460 },
|
|
|
|
{ .start = 0x00a02468, .end = 0x00a024b0 },
|
|
|
|
{ .start = 0x00a024c8, .end = 0x00a024cc },
|
|
|
|
{ .start = 0x00a02500, .end = 0x00a02504 },
|
|
|
|
{ .start = 0x00a0250c, .end = 0x00a02510 },
|
|
|
|
{ .start = 0x00a02540, .end = 0x00a02554 },
|
|
|
|
{ .start = 0x00a02580, .end = 0x00a025f4 },
|
|
|
|
{ .start = 0x00a02600, .end = 0x00a0260c },
|
|
|
|
{ .start = 0x00a02648, .end = 0x00a02650 },
|
|
|
|
{ .start = 0x00a02680, .end = 0x00a02680 },
|
|
|
|
{ .start = 0x00a026c0, .end = 0x00a026d0 },
|
|
|
|
{ .start = 0x00a02700, .end = 0x00a0270c },
|
|
|
|
{ .start = 0x00a02804, .end = 0x00a02804 },
|
|
|
|
{ .start = 0x00a02818, .end = 0x00a0281c },
|
|
|
|
{ .start = 0x00a02c00, .end = 0x00a02db4 },
|
|
|
|
{ .start = 0x00a02df4, .end = 0x00a02fb0 },
|
|
|
|
{ .start = 0x00a03000, .end = 0x00a03014 },
|
|
|
|
{ .start = 0x00a0301c, .end = 0x00a0302c },
|
|
|
|
{ .start = 0x00a03034, .end = 0x00a03038 },
|
|
|
|
{ .start = 0x00a03040, .end = 0x00a03048 },
|
|
|
|
{ .start = 0x00a03060, .end = 0x00a03068 },
|
|
|
|
{ .start = 0x00a03070, .end = 0x00a03074 },
|
|
|
|
{ .start = 0x00a0307c, .end = 0x00a0307c },
|
|
|
|
{ .start = 0x00a03080, .end = 0x00a03084 },
|
|
|
|
{ .start = 0x00a0308c, .end = 0x00a03090 },
|
|
|
|
{ .start = 0x00a03098, .end = 0x00a03098 },
|
|
|
|
{ .start = 0x00a030a0, .end = 0x00a030a0 },
|
|
|
|
{ .start = 0x00a030a8, .end = 0x00a030b4 },
|
|
|
|
{ .start = 0x00a030bc, .end = 0x00a030bc },
|
|
|
|
{ .start = 0x00a030c0, .end = 0x00a0312c },
|
|
|
|
{ .start = 0x00a03c00, .end = 0x00a03c5c },
|
|
|
|
{ .start = 0x00a04400, .end = 0x00a04454 },
|
|
|
|
{ .start = 0x00a04460, .end = 0x00a04474 },
|
|
|
|
{ .start = 0x00a044c0, .end = 0x00a044ec },
|
|
|
|
{ .start = 0x00a04500, .end = 0x00a04504 },
|
|
|
|
{ .start = 0x00a04510, .end = 0x00a04538 },
|
|
|
|
{ .start = 0x00a04540, .end = 0x00a04548 },
|
|
|
|
{ .start = 0x00a04560, .end = 0x00a0457c },
|
|
|
|
{ .start = 0x00a04590, .end = 0x00a04598 },
|
|
|
|
{ .start = 0x00a045c0, .end = 0x00a045f4 },
|
|
|
|
};
|
|
|
|
|
2016-04-06 15:59:50 +07:00
|
|
|
static const struct iwl_prph_range iwl_prph_dump_addr_9000[] = {
|
|
|
|
{ .start = 0x00a05c00, .end = 0x00a05c18 },
|
|
|
|
{ .start = 0x00a05400, .end = 0x00a056e8 },
|
|
|
|
{ .start = 0x00a08000, .end = 0x00a098bc },
|
|
|
|
{ .start = 0x00a02400, .end = 0x00a02758 },
|
|
|
|
};
|
|
|
|
|
2018-10-02 18:13:48 +07:00
|
|
|
static const struct iwl_prph_range iwl_prph_dump_addr_22000[] = {
|
|
|
|
{ .start = 0x00a00000, .end = 0x00a00000 },
|
|
|
|
{ .start = 0x00a0000c, .end = 0x00a00024 },
|
|
|
|
{ .start = 0x00a0002c, .end = 0x00a00034 },
|
|
|
|
{ .start = 0x00a0003c, .end = 0x00a0003c },
|
|
|
|
{ .start = 0x00a00410, .end = 0x00a00418 },
|
|
|
|
{ .start = 0x00a00420, .end = 0x00a00420 },
|
|
|
|
{ .start = 0x00a00428, .end = 0x00a00428 },
|
|
|
|
{ .start = 0x00a00430, .end = 0x00a0043c },
|
|
|
|
{ .start = 0x00a00444, .end = 0x00a00444 },
|
|
|
|
{ .start = 0x00a00840, .end = 0x00a00840 },
|
|
|
|
{ .start = 0x00a00850, .end = 0x00a00858 },
|
|
|
|
{ .start = 0x00a01004, .end = 0x00a01008 },
|
|
|
|
{ .start = 0x00a01010, .end = 0x00a01010 },
|
|
|
|
{ .start = 0x00a01018, .end = 0x00a01018 },
|
|
|
|
{ .start = 0x00a01024, .end = 0x00a01024 },
|
|
|
|
{ .start = 0x00a0102c, .end = 0x00a01034 },
|
|
|
|
{ .start = 0x00a0103c, .end = 0x00a01040 },
|
|
|
|
{ .start = 0x00a01048, .end = 0x00a01050 },
|
|
|
|
{ .start = 0x00a01058, .end = 0x00a01058 },
|
|
|
|
{ .start = 0x00a01060, .end = 0x00a01070 },
|
|
|
|
{ .start = 0x00a0108c, .end = 0x00a0108c },
|
|
|
|
{ .start = 0x00a01c20, .end = 0x00a01c28 },
|
|
|
|
{ .start = 0x00a01d10, .end = 0x00a01d10 },
|
|
|
|
{ .start = 0x00a01e28, .end = 0x00a01e2c },
|
|
|
|
{ .start = 0x00a01e60, .end = 0x00a01e60 },
|
|
|
|
{ .start = 0x00a01e80, .end = 0x00a01e80 },
|
|
|
|
{ .start = 0x00a01ea0, .end = 0x00a01ea0 },
|
|
|
|
{ .start = 0x00a02000, .end = 0x00a0201c },
|
|
|
|
{ .start = 0x00a02024, .end = 0x00a02024 },
|
|
|
|
{ .start = 0x00a02040, .end = 0x00a02048 },
|
|
|
|
{ .start = 0x00a020c0, .end = 0x00a020e0 },
|
|
|
|
{ .start = 0x00a02400, .end = 0x00a02404 },
|
|
|
|
{ .start = 0x00a0240c, .end = 0x00a02414 },
|
|
|
|
{ .start = 0x00a0241c, .end = 0x00a0243c },
|
|
|
|
{ .start = 0x00a02448, .end = 0x00a024bc },
|
|
|
|
{ .start = 0x00a024c4, .end = 0x00a024cc },
|
|
|
|
{ .start = 0x00a02508, .end = 0x00a02508 },
|
|
|
|
{ .start = 0x00a02510, .end = 0x00a02514 },
|
|
|
|
{ .start = 0x00a0251c, .end = 0x00a0251c },
|
|
|
|
{ .start = 0x00a0252c, .end = 0x00a0255c },
|
|
|
|
{ .start = 0x00a02564, .end = 0x00a025a0 },
|
|
|
|
{ .start = 0x00a025a8, .end = 0x00a025b4 },
|
|
|
|
{ .start = 0x00a025c0, .end = 0x00a025c0 },
|
|
|
|
{ .start = 0x00a025e8, .end = 0x00a025f4 },
|
|
|
|
{ .start = 0x00a02c08, .end = 0x00a02c18 },
|
|
|
|
{ .start = 0x00a02c2c, .end = 0x00a02c38 },
|
|
|
|
{ .start = 0x00a02c68, .end = 0x00a02c78 },
|
|
|
|
{ .start = 0x00a03000, .end = 0x00a03000 },
|
|
|
|
{ .start = 0x00a03010, .end = 0x00a03014 },
|
|
|
|
{ .start = 0x00a0301c, .end = 0x00a0302c },
|
|
|
|
{ .start = 0x00a03034, .end = 0x00a03038 },
|
|
|
|
{ .start = 0x00a03040, .end = 0x00a03044 },
|
|
|
|
{ .start = 0x00a03060, .end = 0x00a03068 },
|
|
|
|
{ .start = 0x00a03070, .end = 0x00a03070 },
|
|
|
|
{ .start = 0x00a0307c, .end = 0x00a03084 },
|
|
|
|
{ .start = 0x00a0308c, .end = 0x00a03090 },
|
|
|
|
{ .start = 0x00a03098, .end = 0x00a03098 },
|
|
|
|
{ .start = 0x00a030a0, .end = 0x00a030a0 },
|
|
|
|
{ .start = 0x00a030a8, .end = 0x00a030b4 },
|
|
|
|
{ .start = 0x00a030bc, .end = 0x00a030c0 },
|
|
|
|
{ .start = 0x00a030c8, .end = 0x00a030f4 },
|
|
|
|
{ .start = 0x00a03100, .end = 0x00a0312c },
|
|
|
|
{ .start = 0x00a03c00, .end = 0x00a03c5c },
|
|
|
|
{ .start = 0x00a04400, .end = 0x00a04454 },
|
|
|
|
{ .start = 0x00a04460, .end = 0x00a04474 },
|
|
|
|
{ .start = 0x00a044c0, .end = 0x00a044ec },
|
|
|
|
{ .start = 0x00a04500, .end = 0x00a04504 },
|
|
|
|
{ .start = 0x00a04510, .end = 0x00a04538 },
|
|
|
|
{ .start = 0x00a04540, .end = 0x00a04548 },
|
|
|
|
{ .start = 0x00a04560, .end = 0x00a04560 },
|
|
|
|
{ .start = 0x00a04570, .end = 0x00a0457c },
|
|
|
|
{ .start = 0x00a04590, .end = 0x00a04590 },
|
|
|
|
{ .start = 0x00a04598, .end = 0x00a04598 },
|
|
|
|
{ .start = 0x00a045c0, .end = 0x00a045f4 },
|
|
|
|
{ .start = 0x00a0c000, .end = 0x00a0c018 },
|
|
|
|
{ .start = 0x00a0c020, .end = 0x00a0c028 },
|
|
|
|
{ .start = 0x00a0c038, .end = 0x00a0c094 },
|
|
|
|
{ .start = 0x00a0c0c0, .end = 0x00a0c104 },
|
|
|
|
{ .start = 0x00a0c10c, .end = 0x00a0c118 },
|
|
|
|
{ .start = 0x00a0c150, .end = 0x00a0c174 },
|
|
|
|
{ .start = 0x00a0c17c, .end = 0x00a0c188 },
|
|
|
|
{ .start = 0x00a0c190, .end = 0x00a0c198 },
|
|
|
|
{ .start = 0x00a0c1a0, .end = 0x00a0c1a8 },
|
|
|
|
{ .start = 0x00a0c1b0, .end = 0x00a0c1b8 },
|
|
|
|
};
|
|
|
|
|
2018-05-17 21:02:36 +07:00
|
|
|
static void iwl_read_prph_block(struct iwl_trans *trans, u32 start,
|
|
|
|
u32 len_bytes, __le32 *data)
|
2016-10-20 15:01:43 +07:00
|
|
|
{
|
|
|
|
u32 i;
|
|
|
|
|
|
|
|
for (i = 0; i < len_bytes; i += 4)
|
|
|
|
*data++ = cpu_to_le32(iwl_read_prph_no_grab(trans, start + i));
|
|
|
|
}
|
|
|
|
|
2018-10-02 18:13:48 +07:00
|
|
|
static void iwl_dump_prph(struct iwl_fw_runtime *fwrt,
|
2016-10-20 14:44:05 +07:00
|
|
|
const struct iwl_prph_range *iwl_prph_dump_addr,
|
2018-10-02 18:13:48 +07:00
|
|
|
u32 range_len, void *ptr)
|
2015-10-28 00:17:14 +07:00
|
|
|
{
|
|
|
|
struct iwl_fw_error_dump_prph *prph;
|
2018-10-02 18:13:48 +07:00
|
|
|
struct iwl_trans *trans = fwrt->trans;
|
|
|
|
struct iwl_fw_error_dump_data **data =
|
|
|
|
(struct iwl_fw_error_dump_data **)ptr;
|
2015-10-28 00:17:14 +07:00
|
|
|
unsigned long flags;
|
2016-10-20 14:44:05 +07:00
|
|
|
u32 i;
|
2015-10-28 00:17:14 +07:00
|
|
|
|
2018-10-02 18:13:48 +07:00
|
|
|
if (!data)
|
|
|
|
return;
|
|
|
|
|
2017-09-04 18:39:22 +07:00
|
|
|
IWL_DEBUG_INFO(trans, "WRT PRPH dump\n");
|
|
|
|
|
2015-12-17 16:55:13 +07:00
|
|
|
if (!iwl_trans_grab_nic_access(trans, &flags))
|
2016-10-20 14:44:05 +07:00
|
|
|
return;
|
2015-10-28 00:17:14 +07:00
|
|
|
|
2016-04-06 15:59:50 +07:00
|
|
|
for (i = 0; i < range_len; i++) {
|
2015-10-28 00:17:14 +07:00
|
|
|
/* The range includes both boundaries */
|
|
|
|
int num_bytes_in_chunk = iwl_prph_dump_addr[i].end -
|
|
|
|
iwl_prph_dump_addr[i].start + 4;
|
|
|
|
|
|
|
|
(*data)->type = cpu_to_le32(IWL_FW_ERROR_DUMP_PRPH);
|
|
|
|
(*data)->len = cpu_to_le32(sizeof(*prph) +
|
|
|
|
num_bytes_in_chunk);
|
|
|
|
prph = (void *)(*data)->data;
|
|
|
|
prph->prph_start = cpu_to_le32(iwl_prph_dump_addr[i].start);
|
|
|
|
|
2018-05-17 21:02:36 +07:00
|
|
|
iwl_read_prph_block(trans, iwl_prph_dump_addr[i].start,
|
|
|
|
/* our range is inclusive, hence + 4 */
|
|
|
|
iwl_prph_dump_addr[i].end -
|
|
|
|
iwl_prph_dump_addr[i].start + 4,
|
|
|
|
(void *)prph->data);
|
2015-10-28 00:17:14 +07:00
|
|
|
|
2015-12-09 17:26:08 +07:00
|
|
|
*data = iwl_fw_error_next_data(*data);
|
2015-10-28 00:17:14 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
iwl_trans_release_nic_access(trans, &flags);
|
|
|
|
}
|
|
|
|
|
2016-09-20 22:07:44 +07:00
|
|
|
/*
|
|
|
|
* alloc_sgtable - allocates scallerlist table in the given size,
|
|
|
|
* fills it with pages and returns it
|
|
|
|
* @size: the size (in bytes) of the table
|
|
|
|
*/
|
|
|
|
static struct scatterlist *alloc_sgtable(int size)
|
|
|
|
{
|
|
|
|
int alloc_size, nents, i;
|
|
|
|
struct page *new_page;
|
|
|
|
struct scatterlist *iter;
|
|
|
|
struct scatterlist *table;
|
|
|
|
|
|
|
|
nents = DIV_ROUND_UP(size, PAGE_SIZE);
|
|
|
|
table = kcalloc(nents, sizeof(*table), GFP_KERNEL);
|
|
|
|
if (!table)
|
|
|
|
return NULL;
|
|
|
|
sg_init_table(table, nents);
|
|
|
|
iter = table;
|
|
|
|
for_each_sg(table, iter, sg_nents(table), i) {
|
|
|
|
new_page = alloc_page(GFP_KERNEL);
|
|
|
|
if (!new_page) {
|
|
|
|
/* release all previous allocated pages in the table */
|
|
|
|
iter = table;
|
|
|
|
for_each_sg(table, iter, sg_nents(table), i) {
|
|
|
|
new_page = sg_page(iter);
|
|
|
|
if (new_page)
|
|
|
|
__free_page(new_page);
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
alloc_size = min_t(int, size, PAGE_SIZE);
|
|
|
|
size -= PAGE_SIZE;
|
|
|
|
sg_set_page(iter, new_page, alloc_size, 0);
|
|
|
|
}
|
|
|
|
return table;
|
|
|
|
}
|
|
|
|
|
2018-10-02 18:13:48 +07:00
|
|
|
static void iwl_fw_get_prph_len(struct iwl_fw_runtime *fwrt,
|
|
|
|
const struct iwl_prph_range *iwl_prph_dump_addr,
|
|
|
|
u32 range_len, void *ptr)
|
2018-04-10 16:29:49 +07:00
|
|
|
{
|
2018-10-02 18:13:48 +07:00
|
|
|
u32 *prph_len = (u32 *)ptr;
|
|
|
|
int i, num_bytes_in_chunk;
|
|
|
|
|
|
|
|
if (!prph_len)
|
|
|
|
return;
|
2018-04-10 16:29:49 +07:00
|
|
|
|
2018-10-02 18:13:48 +07:00
|
|
|
for (i = 0; i < range_len; i++) {
|
2018-04-10 16:29:49 +07:00
|
|
|
/* The range includes both boundaries */
|
2018-10-02 18:13:48 +07:00
|
|
|
num_bytes_in_chunk =
|
|
|
|
iwl_prph_dump_addr[i].end -
|
|
|
|
iwl_prph_dump_addr[i].start + 4;
|
2018-04-10 16:29:49 +07:00
|
|
|
|
2018-10-02 18:13:48 +07:00
|
|
|
*prph_len += sizeof(struct iwl_fw_error_dump_data) +
|
2018-04-10 16:29:49 +07:00
|
|
|
sizeof(struct iwl_fw_error_dump_prph) +
|
|
|
|
num_bytes_in_chunk;
|
|
|
|
}
|
2018-10-02 18:13:48 +07:00
|
|
|
}
|
2018-04-10 16:29:49 +07:00
|
|
|
|
2018-10-02 18:13:48 +07:00
|
|
|
static void iwl_fw_prph_handler(struct iwl_fw_runtime *fwrt, void *ptr,
|
|
|
|
void (*handler)(struct iwl_fw_runtime *,
|
|
|
|
const struct iwl_prph_range *,
|
|
|
|
u32, void *))
|
|
|
|
{
|
|
|
|
u32 range_len;
|
|
|
|
|
|
|
|
if (fwrt->trans->cfg->device_family >= IWL_DEVICE_FAMILY_22000) {
|
|
|
|
range_len = ARRAY_SIZE(iwl_prph_dump_addr_22000);
|
|
|
|
handler(fwrt, iwl_prph_dump_addr_22000, range_len, ptr);
|
|
|
|
} else {
|
|
|
|
range_len = ARRAY_SIZE(iwl_prph_dump_addr_comm);
|
|
|
|
handler(fwrt, iwl_prph_dump_addr_comm, range_len, ptr);
|
|
|
|
|
|
|
|
if (fwrt->trans->cfg->mq_rx_supported) {
|
|
|
|
range_len = ARRAY_SIZE(iwl_prph_dump_addr_9000);
|
|
|
|
handler(fwrt, iwl_prph_dump_addr_9000, range_len, ptr);
|
2018-04-10 16:29:49 +07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void iwl_fw_dump_mem(struct iwl_fw_runtime *fwrt,
|
|
|
|
struct iwl_fw_error_dump_data **dump_data,
|
2018-06-12 18:34:32 +07:00
|
|
|
u32 len, u32 ofs, u32 type)
|
2018-04-10 16:29:49 +07:00
|
|
|
{
|
|
|
|
struct iwl_fw_error_dump_mem *dump_mem;
|
|
|
|
|
2018-06-12 18:34:32 +07:00
|
|
|
if (!len)
|
|
|
|
return;
|
2018-04-10 16:29:49 +07:00
|
|
|
|
2018-06-12 18:34:32 +07:00
|
|
|
(*dump_data)->type = cpu_to_le32(IWL_FW_ERROR_DUMP_MEM);
|
|
|
|
(*dump_data)->len = cpu_to_le32(len + sizeof(*dump_mem));
|
|
|
|
dump_mem = (void *)(*dump_data)->data;
|
|
|
|
dump_mem->type = cpu_to_le32(type);
|
|
|
|
dump_mem->offset = cpu_to_le32(ofs);
|
|
|
|
iwl_trans_read_mem_bytes(fwrt->trans, ofs, dump_mem->data, len);
|
|
|
|
*dump_data = iwl_fw_error_next_data(*dump_data);
|
2018-04-10 16:29:49 +07:00
|
|
|
|
2018-06-12 18:34:32 +07:00
|
|
|
IWL_DEBUG_INFO(fwrt, "WRT memory dump. Type=%u\n", dump_mem->type);
|
2018-04-10 16:29:49 +07:00
|
|
|
}
|
|
|
|
|
2018-06-11 16:43:26 +07:00
|
|
|
#define ADD_LEN(len, item_len, const_len) \
|
|
|
|
do {size_t item = item_len; len += (!!item) * const_len + item; } \
|
|
|
|
while (0)
|
|
|
|
|
2018-07-31 13:54:26 +07:00
|
|
|
static int iwl_fw_rxf_len(struct iwl_fw_runtime *fwrt,
|
|
|
|
struct iwl_fwrt_shared_mem_cfg *mem_cfg)
|
2018-06-11 16:43:26 +07:00
|
|
|
{
|
|
|
|
size_t hdr_len = sizeof(struct iwl_fw_error_dump_data) +
|
|
|
|
sizeof(struct iwl_fw_error_dump_fifo);
|
|
|
|
u32 fifo_len = 0;
|
|
|
|
int i;
|
|
|
|
|
2018-07-30 13:43:24 +07:00
|
|
|
if (!iwl_fw_dbg_type_on(fwrt, IWL_FW_ERROR_DUMP_RXF))
|
2018-07-31 13:54:26 +07:00
|
|
|
return 0;
|
2018-06-11 16:43:26 +07:00
|
|
|
|
|
|
|
/* Count RXF2 size */
|
|
|
|
ADD_LEN(fifo_len, mem_cfg->rxfifo2_size, hdr_len);
|
|
|
|
|
|
|
|
/* Count RXF1 sizes */
|
2018-10-21 22:48:13 +07:00
|
|
|
if (WARN_ON(mem_cfg->num_lmacs > MAX_NUM_LMAC))
|
|
|
|
mem_cfg->num_lmacs = MAX_NUM_LMAC;
|
|
|
|
|
2018-06-11 16:43:26 +07:00
|
|
|
for (i = 0; i < mem_cfg->num_lmacs; i++)
|
|
|
|
ADD_LEN(fifo_len, mem_cfg->lmac[i].rxfifo1_size, hdr_len);
|
|
|
|
|
2018-07-31 13:54:26 +07:00
|
|
|
return fifo_len;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int iwl_fw_txf_len(struct iwl_fw_runtime *fwrt,
|
|
|
|
struct iwl_fwrt_shared_mem_cfg *mem_cfg)
|
|
|
|
{
|
|
|
|
size_t hdr_len = sizeof(struct iwl_fw_error_dump_data) +
|
|
|
|
sizeof(struct iwl_fw_error_dump_fifo);
|
|
|
|
u32 fifo_len = 0;
|
|
|
|
int i;
|
|
|
|
|
2018-07-30 13:43:24 +07:00
|
|
|
if (!iwl_fw_dbg_type_on(fwrt, IWL_FW_ERROR_DUMP_TXF))
|
2018-06-11 16:43:26 +07:00
|
|
|
goto dump_internal_txf;
|
|
|
|
|
|
|
|
/* Count TXF sizes */
|
2018-10-21 22:48:13 +07:00
|
|
|
if (WARN_ON(mem_cfg->num_lmacs > MAX_NUM_LMAC))
|
|
|
|
mem_cfg->num_lmacs = MAX_NUM_LMAC;
|
|
|
|
|
2018-06-11 16:43:26 +07:00
|
|
|
for (i = 0; i < mem_cfg->num_lmacs; i++) {
|
|
|
|
int j;
|
|
|
|
|
|
|
|
for (j = 0; j < mem_cfg->num_txfifo_entries; j++)
|
|
|
|
ADD_LEN(fifo_len, mem_cfg->lmac[i].txfifo_size[j],
|
|
|
|
hdr_len);
|
|
|
|
}
|
|
|
|
|
|
|
|
dump_internal_txf:
|
2018-07-30 13:43:24 +07:00
|
|
|
if (!(iwl_fw_dbg_type_on(fwrt, IWL_FW_ERROR_DUMP_INTERNAL_TXF) &&
|
2018-06-11 16:43:26 +07:00
|
|
|
fw_has_capa(&fwrt->fw->ucode_capa,
|
|
|
|
IWL_UCODE_TLV_CAPA_EXTEND_SHARED_MEM_CFG)))
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(mem_cfg->internal_txfifo_size); i++)
|
|
|
|
ADD_LEN(fifo_len, mem_cfg->internal_txfifo_size[i], hdr_len);
|
|
|
|
|
|
|
|
out:
|
|
|
|
return fifo_len;
|
|
|
|
}
|
|
|
|
|
2018-07-30 15:06:09 +07:00
|
|
|
static void iwl_dump_paging(struct iwl_fw_runtime *fwrt,
|
|
|
|
struct iwl_fw_error_dump_data **data)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
IWL_DEBUG_INFO(fwrt, "WRT paging dump\n");
|
|
|
|
for (i = 1; i < fwrt->num_of_paging_blk + 1; i++) {
|
|
|
|
struct iwl_fw_error_dump_paging *paging;
|
|
|
|
struct page *pages =
|
|
|
|
fwrt->fw_paging_db[i].fw_paging_block;
|
|
|
|
dma_addr_t addr = fwrt->fw_paging_db[i].fw_paging_phys;
|
|
|
|
|
|
|
|
(*data)->type = cpu_to_le32(IWL_FW_ERROR_DUMP_PAGING);
|
|
|
|
(*data)->len = cpu_to_le32(sizeof(*paging) +
|
|
|
|
PAGING_BLOCK_SIZE);
|
|
|
|
paging = (void *)(*data)->data;
|
|
|
|
paging->index = cpu_to_le32(i);
|
|
|
|
dma_sync_single_for_cpu(fwrt->trans->dev, addr,
|
|
|
|
PAGING_BLOCK_SIZE,
|
|
|
|
DMA_BIDIRECTIONAL);
|
|
|
|
memcpy(paging->data, page_address(pages),
|
|
|
|
PAGING_BLOCK_SIZE);
|
2018-11-20 14:46:33 +07:00
|
|
|
dma_sync_single_for_device(fwrt->trans->dev, addr,
|
|
|
|
PAGING_BLOCK_SIZE,
|
|
|
|
DMA_BIDIRECTIONAL);
|
2018-07-30 15:06:09 +07:00
|
|
|
(*data) = iwl_fw_error_next_data(*data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-11 19:30:07 +07:00
|
|
|
static struct iwl_fw_error_dump_file *
|
|
|
|
_iwl_fw_error_dump(struct iwl_fw_runtime *fwrt,
|
|
|
|
struct iwl_fw_dump_ptrs *fw_error_dump)
|
2015-10-28 00:17:14 +07:00
|
|
|
{
|
|
|
|
struct iwl_fw_error_dump_file *dump_file;
|
|
|
|
struct iwl_fw_error_dump_data *dump_data;
|
|
|
|
struct iwl_fw_error_dump_info *dump_info;
|
2017-06-25 21:23:23 +07:00
|
|
|
struct iwl_fw_error_dump_smem_cfg *dump_smem_cfg;
|
2015-10-28 00:17:14 +07:00
|
|
|
struct iwl_fw_error_dump_trigger_desc *dump_trig;
|
|
|
|
u32 sram_len, sram_ofs;
|
2018-06-11 16:43:26 +07:00
|
|
|
const struct iwl_fw_dbg_mem_seg_tlv *fw_mem = fwrt->fw->dbg.mem_tlv;
|
2017-06-25 21:23:23 +07:00
|
|
|
struct iwl_fwrt_shared_mem_cfg *mem_cfg = &fwrt->smem_cfg;
|
2018-06-11 16:43:26 +07:00
|
|
|
u32 file_len, fifo_len = 0, prph_len = 0, radio_len = 0;
|
2018-06-11 15:43:09 +07:00
|
|
|
u32 smem_len = fwrt->fw->dbg.n_mem_tlv ? 0 : fwrt->trans->cfg->smem_len;
|
|
|
|
u32 sram2_len = fwrt->fw->dbg.n_mem_tlv ?
|
2017-06-01 21:03:19 +07:00
|
|
|
0 : fwrt->trans->cfg->dccm2_len;
|
2015-10-28 00:17:14 +07:00
|
|
|
int i;
|
|
|
|
|
|
|
|
/* SRAM - include stack CCM if driver knows the values for it */
|
2017-06-01 21:03:19 +07:00
|
|
|
if (!fwrt->trans->cfg->dccm_offset || !fwrt->trans->cfg->dccm_len) {
|
2015-10-28 00:17:14 +07:00
|
|
|
const struct fw_img *img;
|
|
|
|
|
2018-10-21 18:39:05 +07:00
|
|
|
if (fwrt->cur_fw_img >= IWL_UCODE_TYPE_MAX)
|
|
|
|
return NULL;
|
2017-06-01 21:03:19 +07:00
|
|
|
img = &fwrt->fw->img[fwrt->cur_fw_img];
|
2015-10-28 00:17:14 +07:00
|
|
|
sram_ofs = img->sec[IWL_UCODE_SECTION_DATA].offset;
|
|
|
|
sram_len = img->sec[IWL_UCODE_SECTION_DATA].len;
|
|
|
|
} else {
|
2017-06-01 21:03:19 +07:00
|
|
|
sram_ofs = fwrt->trans->cfg->dccm_offset;
|
|
|
|
sram_len = fwrt->trans->cfg->dccm_len;
|
2015-10-28 00:17:14 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* reading RXF/TXF sizes */
|
2017-06-01 21:03:19 +07:00
|
|
|
if (test_bit(STATUS_FW_ERROR, &fwrt->trans->status)) {
|
2018-07-31 13:54:26 +07:00
|
|
|
fifo_len = iwl_fw_rxf_len(fwrt, mem_cfg);
|
|
|
|
fifo_len += iwl_fw_txf_len(fwrt, mem_cfg);
|
2016-02-09 17:57:16 +07:00
|
|
|
|
2015-12-16 18:42:17 +07:00
|
|
|
/* Make room for PRPH registers */
|
2018-10-02 18:13:48 +07:00
|
|
|
if (iwl_fw_dbg_type_on(fwrt, IWL_FW_ERROR_DUMP_PRPH))
|
|
|
|
iwl_fw_prph_handler(fwrt, &prph_len,
|
|
|
|
iwl_fw_get_prph_len);
|
2016-04-06 15:59:50 +07:00
|
|
|
|
2018-02-20 22:20:32 +07:00
|
|
|
if (fwrt->trans->cfg->device_family == IWL_DEVICE_FAMILY_7000 &&
|
2018-07-30 13:43:24 +07:00
|
|
|
iwl_fw_dbg_type_on(fwrt, IWL_FW_ERROR_DUMP_RADIO_REG))
|
2015-12-28 20:22:28 +07:00
|
|
|
radio_len = sizeof(*dump_data) + RADIO_REG_MAX_READ;
|
2015-10-28 00:17:14 +07:00
|
|
|
}
|
|
|
|
|
2018-06-11 16:43:26 +07:00
|
|
|
file_len = sizeof(*dump_file) + fifo_len + prph_len + radio_len;
|
2018-02-20 22:20:32 +07:00
|
|
|
|
2018-07-30 13:43:24 +07:00
|
|
|
if (iwl_fw_dbg_type_on(fwrt, IWL_FW_ERROR_DUMP_DEV_FW_INFO))
|
2018-02-20 22:20:32 +07:00
|
|
|
file_len += sizeof(*dump_data) + sizeof(*dump_info);
|
2018-07-30 13:43:24 +07:00
|
|
|
if (iwl_fw_dbg_type_on(fwrt, IWL_FW_ERROR_DUMP_MEM_CFG))
|
2018-02-20 22:20:32 +07:00
|
|
|
file_len += sizeof(*dump_data) + sizeof(*dump_smem_cfg);
|
|
|
|
|
2018-07-30 13:43:24 +07:00
|
|
|
if (iwl_fw_dbg_type_on(fwrt, IWL_FW_ERROR_DUMP_MEM)) {
|
2018-06-11 16:43:26 +07:00
|
|
|
size_t hdr_len = sizeof(*dump_data) +
|
|
|
|
sizeof(struct iwl_fw_error_dump_mem);
|
|
|
|
|
|
|
|
/* Dump SRAM only if no mem_tlvs */
|
|
|
|
if (!fwrt->fw->dbg.n_mem_tlv)
|
|
|
|
ADD_LEN(file_len, sram_len, hdr_len);
|
|
|
|
|
|
|
|
/* Make room for all mem types that exist */
|
|
|
|
ADD_LEN(file_len, smem_len, hdr_len);
|
|
|
|
ADD_LEN(file_len, sram2_len, hdr_len);
|
|
|
|
|
|
|
|
for (i = 0; i < fwrt->fw->dbg.n_mem_tlv; i++)
|
|
|
|
ADD_LEN(file_len, le32_to_cpu(fw_mem[i].len), hdr_len);
|
2016-03-14 17:24:20 +07:00
|
|
|
}
|
|
|
|
|
2015-10-28 00:17:14 +07:00
|
|
|
/* Make room for fw's virtual image pages, if it exists */
|
2018-07-30 15:06:09 +07:00
|
|
|
if (iwl_fw_dbg_is_paging_enabled(fwrt))
|
2017-06-01 21:03:19 +07:00
|
|
|
file_len += fwrt->num_of_paging_blk *
|
2015-10-28 00:17:14 +07:00
|
|
|
(sizeof(*dump_data) +
|
|
|
|
sizeof(struct iwl_fw_error_dump_paging) +
|
|
|
|
PAGING_BLOCK_SIZE);
|
|
|
|
|
2018-01-29 16:05:37 +07:00
|
|
|
if (iwl_fw_dbg_is_d3_debug_enabled(fwrt) && fwrt->dump.d3_debug_data) {
|
|
|
|
file_len += sizeof(*dump_data) +
|
|
|
|
fwrt->trans->cfg->d3_debug_data_length * 2;
|
|
|
|
}
|
|
|
|
|
2015-10-28 00:17:14 +07:00
|
|
|
/* If we only want a monitor dump, reset the file length */
|
2018-07-23 17:50:02 +07:00
|
|
|
if (fwrt->dump.monitor_only) {
|
2017-06-25 21:23:23 +07:00
|
|
|
file_len = sizeof(*dump_file) + sizeof(*dump_data) * 2 +
|
|
|
|
sizeof(*dump_info) + sizeof(*dump_smem_cfg);
|
2015-10-28 00:17:14 +07:00
|
|
|
}
|
|
|
|
|
2018-07-30 13:43:24 +07:00
|
|
|
if (iwl_fw_dbg_type_on(fwrt, IWL_FW_ERROR_DUMP_ERROR_INFO) &&
|
2018-02-20 22:20:32 +07:00
|
|
|
fwrt->dump.desc)
|
2015-10-28 00:17:14 +07:00
|
|
|
file_len += sizeof(*dump_data) + sizeof(*dump_trig) +
|
2017-06-01 21:03:19 +07:00
|
|
|
fwrt->dump.desc->len;
|
2015-10-28 00:17:14 +07:00
|
|
|
|
|
|
|
dump_file = vzalloc(file_len);
|
2018-06-11 19:30:07 +07:00
|
|
|
if (!dump_file)
|
|
|
|
return NULL;
|
2015-10-28 00:17:14 +07:00
|
|
|
|
2017-06-01 21:03:19 +07:00
|
|
|
fw_error_dump->fwrt_ptr = dump_file;
|
2015-10-28 00:17:14 +07:00
|
|
|
|
|
|
|
dump_file->barker = cpu_to_le32(IWL_FW_ERROR_DUMP_BARKER);
|
|
|
|
dump_data = (void *)dump_file->data;
|
|
|
|
|
2018-07-30 13:43:24 +07:00
|
|
|
if (iwl_fw_dbg_type_on(fwrt, IWL_FW_ERROR_DUMP_DEV_FW_INFO)) {
|
2018-02-20 22:20:32 +07:00
|
|
|
dump_data->type = cpu_to_le32(IWL_FW_ERROR_DUMP_DEV_FW_INFO);
|
|
|
|
dump_data->len = cpu_to_le32(sizeof(*dump_info));
|
|
|
|
dump_info = (void *)dump_data->data;
|
|
|
|
dump_info->device_family =
|
|
|
|
fwrt->trans->cfg->device_family ==
|
|
|
|
IWL_DEVICE_FAMILY_7000 ?
|
|
|
|
cpu_to_le32(IWL_FW_ERROR_DUMP_FAMILY_7) :
|
|
|
|
cpu_to_le32(IWL_FW_ERROR_DUMP_FAMILY_8);
|
|
|
|
dump_info->hw_step =
|
|
|
|
cpu_to_le32(CSR_HW_REV_STEP(fwrt->trans->hw_rev));
|
|
|
|
memcpy(dump_info->fw_human_readable, fwrt->fw->human_readable,
|
|
|
|
sizeof(dump_info->fw_human_readable));
|
|
|
|
strncpy(dump_info->dev_human_readable, fwrt->trans->cfg->name,
|
|
|
|
sizeof(dump_info->dev_human_readable) - 1);
|
|
|
|
strncpy(dump_info->bus_human_readable, fwrt->dev->bus->name,
|
|
|
|
sizeof(dump_info->bus_human_readable) - 1);
|
2018-09-13 18:52:59 +07:00
|
|
|
dump_info->num_of_lmacs = fwrt->smem_cfg.num_lmacs;
|
|
|
|
dump_info->lmac_err_id[0] =
|
|
|
|
cpu_to_le32(fwrt->dump.lmac_err_id[0]);
|
|
|
|
if (fwrt->smem_cfg.num_lmacs > 1)
|
|
|
|
dump_info->lmac_err_id[1] =
|
|
|
|
cpu_to_le32(fwrt->dump.lmac_err_id[1]);
|
|
|
|
dump_info->umac_err_id = cpu_to_le32(fwrt->dump.umac_err_id);
|
2018-02-20 22:20:32 +07:00
|
|
|
|
|
|
|
dump_data = iwl_fw_error_next_data(dump_data);
|
2017-06-25 21:23:23 +07:00
|
|
|
}
|
|
|
|
|
2018-07-30 13:43:24 +07:00
|
|
|
if (iwl_fw_dbg_type_on(fwrt, IWL_FW_ERROR_DUMP_MEM_CFG)) {
|
2018-02-20 22:20:32 +07:00
|
|
|
/* Dump shared memory configuration */
|
|
|
|
dump_data->type = cpu_to_le32(IWL_FW_ERROR_DUMP_MEM_CFG);
|
|
|
|
dump_data->len = cpu_to_le32(sizeof(*dump_smem_cfg));
|
|
|
|
dump_smem_cfg = (void *)dump_data->data;
|
|
|
|
dump_smem_cfg->num_lmacs = cpu_to_le32(mem_cfg->num_lmacs);
|
|
|
|
dump_smem_cfg->num_txfifo_entries =
|
|
|
|
cpu_to_le32(mem_cfg->num_txfifo_entries);
|
|
|
|
for (i = 0; i < MAX_NUM_LMAC; i++) {
|
|
|
|
int j;
|
|
|
|
u32 *txf_size = mem_cfg->lmac[i].txfifo_size;
|
|
|
|
|
|
|
|
for (j = 0; j < TX_FIFO_MAX_NUM; j++)
|
|
|
|
dump_smem_cfg->lmac[i].txfifo_size[j] =
|
|
|
|
cpu_to_le32(txf_size[j]);
|
|
|
|
dump_smem_cfg->lmac[i].rxfifo1_size =
|
|
|
|
cpu_to_le32(mem_cfg->lmac[i].rxfifo1_size);
|
|
|
|
}
|
|
|
|
dump_smem_cfg->rxfifo2_size =
|
|
|
|
cpu_to_le32(mem_cfg->rxfifo2_size);
|
|
|
|
dump_smem_cfg->internal_txfifo_addr =
|
|
|
|
cpu_to_le32(mem_cfg->internal_txfifo_addr);
|
|
|
|
for (i = 0; i < TX_FIFO_INTERNAL_MAX_NUM; i++) {
|
|
|
|
dump_smem_cfg->internal_txfifo_size[i] =
|
|
|
|
cpu_to_le32(mem_cfg->internal_txfifo_size[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
dump_data = iwl_fw_error_next_data(dump_data);
|
|
|
|
}
|
2017-06-25 21:23:23 +07:00
|
|
|
|
2015-10-28 00:17:14 +07:00
|
|
|
/* We only dump the FIFOs if the FW is in error state */
|
2018-06-11 16:43:26 +07:00
|
|
|
if (fifo_len) {
|
2018-07-31 13:54:26 +07:00
|
|
|
iwl_fw_dump_rxf(fwrt, &dump_data);
|
|
|
|
iwl_fw_dump_txf(fwrt, &dump_data);
|
2015-12-28 20:22:28 +07:00
|
|
|
if (radio_len)
|
2017-06-01 21:03:19 +07:00
|
|
|
iwl_read_radio_regs(fwrt, &dump_data);
|
2015-12-28 20:22:28 +07:00
|
|
|
}
|
2015-10-28 00:17:14 +07:00
|
|
|
|
2018-07-30 13:43:24 +07:00
|
|
|
if (iwl_fw_dbg_type_on(fwrt, IWL_FW_ERROR_DUMP_ERROR_INFO) &&
|
2018-02-20 22:20:32 +07:00
|
|
|
fwrt->dump.desc) {
|
2015-10-28 00:17:14 +07:00
|
|
|
dump_data->type = cpu_to_le32(IWL_FW_ERROR_DUMP_ERROR_INFO);
|
|
|
|
dump_data->len = cpu_to_le32(sizeof(*dump_trig) +
|
2017-06-01 21:03:19 +07:00
|
|
|
fwrt->dump.desc->len);
|
2015-10-28 00:17:14 +07:00
|
|
|
dump_trig = (void *)dump_data->data;
|
2017-06-01 21:03:19 +07:00
|
|
|
memcpy(dump_trig, &fwrt->dump.desc->trig_desc,
|
|
|
|
sizeof(*dump_trig) + fwrt->dump.desc->len);
|
2015-10-28 00:17:14 +07:00
|
|
|
|
|
|
|
dump_data = iwl_fw_error_next_data(dump_data);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* In case we only want monitor dump, skip to dump trasport data */
|
2018-07-23 17:50:02 +07:00
|
|
|
if (fwrt->dump.monitor_only)
|
2018-06-11 19:30:07 +07:00
|
|
|
goto out;
|
2015-10-28 00:17:14 +07:00
|
|
|
|
2018-07-30 13:43:24 +07:00
|
|
|
if (iwl_fw_dbg_type_on(fwrt, IWL_FW_ERROR_DUMP_MEM)) {
|
2018-06-12 18:34:32 +07:00
|
|
|
const struct iwl_fw_dbg_mem_seg_tlv *fw_dbg_mem =
|
|
|
|
fwrt->fw->dbg.mem_tlv;
|
|
|
|
|
|
|
|
if (!fwrt->fw->dbg.n_mem_tlv)
|
|
|
|
iwl_fw_dump_mem(fwrt, &dump_data, sram_len, sram_ofs,
|
|
|
|
IWL_FW_ERROR_DUMP_MEM_SRAM);
|
|
|
|
|
|
|
|
for (i = 0; i < fwrt->fw->dbg.n_mem_tlv; i++) {
|
|
|
|
u32 len = le32_to_cpu(fw_dbg_mem[i].len);
|
|
|
|
u32 ofs = le32_to_cpu(fw_dbg_mem[i].ofs);
|
2018-04-10 16:29:49 +07:00
|
|
|
|
2018-06-12 18:34:32 +07:00
|
|
|
iwl_fw_dump_mem(fwrt, &dump_data, len, ofs,
|
|
|
|
le32_to_cpu(fw_dbg_mem[i].data_type));
|
|
|
|
}
|
|
|
|
|
|
|
|
iwl_fw_dump_mem(fwrt, &dump_data, smem_len,
|
|
|
|
fwrt->trans->cfg->smem_offset,
|
|
|
|
IWL_FW_ERROR_DUMP_MEM_SMEM);
|
|
|
|
|
|
|
|
iwl_fw_dump_mem(fwrt, &dump_data, sram2_len,
|
|
|
|
fwrt->trans->cfg->dccm2_offset,
|
|
|
|
IWL_FW_ERROR_DUMP_MEM_SRAM);
|
|
|
|
}
|
2016-03-14 17:24:20 +07:00
|
|
|
|
2018-01-29 16:05:37 +07:00
|
|
|
if (iwl_fw_dbg_is_d3_debug_enabled(fwrt) && fwrt->dump.d3_debug_data) {
|
|
|
|
u32 addr = fwrt->trans->cfg->d3_debug_data_base_addr;
|
|
|
|
size_t data_size = fwrt->trans->cfg->d3_debug_data_length;
|
|
|
|
|
|
|
|
dump_data->type = cpu_to_le32(IWL_FW_ERROR_DUMP_D3_DEBUG_DATA);
|
|
|
|
dump_data->len = cpu_to_le32(data_size * 2);
|
|
|
|
|
2018-04-10 16:29:49 +07:00
|
|
|
memcpy(dump_data->data, fwrt->dump.d3_debug_data, data_size);
|
2018-01-29 16:05:37 +07:00
|
|
|
|
|
|
|
kfree(fwrt->dump.d3_debug_data);
|
|
|
|
fwrt->dump.d3_debug_data = NULL;
|
|
|
|
|
|
|
|
iwl_trans_read_mem_bytes(fwrt->trans, addr,
|
|
|
|
dump_data->data + data_size,
|
|
|
|
data_size);
|
|
|
|
|
|
|
|
dump_data = iwl_fw_error_next_data(dump_data);
|
|
|
|
}
|
|
|
|
|
2015-10-28 00:17:14 +07:00
|
|
|
/* Dump fw's virtual image */
|
2018-07-30 15:06:09 +07:00
|
|
|
if (iwl_fw_dbg_is_paging_enabled(fwrt))
|
|
|
|
iwl_dump_paging(fwrt, &dump_data);
|
2015-10-28 00:17:14 +07:00
|
|
|
|
2018-10-02 18:13:48 +07:00
|
|
|
if (prph_len)
|
|
|
|
iwl_fw_prph_handler(fwrt, &dump_data, iwl_dump_prph);
|
2015-10-28 00:17:14 +07:00
|
|
|
|
2018-06-11 19:30:07 +07:00
|
|
|
out:
|
|
|
|
dump_file->file_len = cpu_to_le32(file_len);
|
|
|
|
return dump_file;
|
|
|
|
}
|
|
|
|
|
2018-12-03 14:19:25 +07:00
|
|
|
static int iwl_dump_ini_prph_iter(struct iwl_fw_runtime *fwrt,
|
|
|
|
struct iwl_fw_ini_error_dump_range *range,
|
|
|
|
struct iwl_fw_ini_region_cfg *reg,
|
|
|
|
int idx)
|
|
|
|
{
|
|
|
|
__le32 *val = range->data;
|
|
|
|
u32 addr, prph_val, offset = le32_to_cpu(reg->offset);
|
|
|
|
int i;
|
|
|
|
|
|
|
|
range->start_addr = reg->start_addr[idx];
|
|
|
|
range->range_data_size = reg->internal.range_data_size;
|
|
|
|
for (i = 0; i < le32_to_cpu(reg->internal.range_data_size); i += 4) {
|
|
|
|
addr = le32_to_cpu(range->start_addr) + i;
|
|
|
|
prph_val = iwl_read_prph(fwrt->trans, addr + offset);
|
|
|
|
if (prph_val == 0x5a5a5a5a)
|
|
|
|
return -1;
|
|
|
|
*val++ = cpu_to_le32(prph_val);
|
|
|
|
}
|
|
|
|
return le32_to_cpu(range->range_data_size);
|
|
|
|
}
|
|
|
|
|
2018-12-03 17:13:31 +07:00
|
|
|
static int iwl_dump_ini_csr_iter(struct iwl_fw_runtime *fwrt,
|
|
|
|
struct iwl_fw_ini_error_dump_range *range,
|
|
|
|
struct iwl_fw_ini_region_cfg *reg,
|
|
|
|
int idx)
|
|
|
|
{
|
|
|
|
__le32 *val = range->data;
|
|
|
|
u32 addr, offset = le32_to_cpu(reg->offset);
|
|
|
|
int i;
|
|
|
|
|
|
|
|
range->start_addr = reg->start_addr[idx];
|
|
|
|
range->range_data_size = reg->internal.range_data_size;
|
|
|
|
for (i = 0; i < le32_to_cpu(reg->internal.range_data_size); i += 4) {
|
|
|
|
addr = le32_to_cpu(range->start_addr) + i;
|
|
|
|
*val++ = cpu_to_le32(iwl_trans_read32(fwrt->trans,
|
|
|
|
addr + offset));
|
|
|
|
}
|
|
|
|
return le32_to_cpu(range->range_data_size);
|
|
|
|
}
|
|
|
|
|
2018-12-03 18:40:24 +07:00
|
|
|
static int iwl_dump_ini_dev_mem_iter(struct iwl_fw_runtime *fwrt,
|
|
|
|
struct iwl_fw_ini_error_dump_range *range,
|
|
|
|
struct iwl_fw_ini_region_cfg *reg,
|
|
|
|
int idx)
|
|
|
|
{
|
|
|
|
u32 addr = le32_to_cpu(range->start_addr);
|
|
|
|
u32 offset = le32_to_cpu(reg->offset);
|
|
|
|
|
|
|
|
range->start_addr = reg->start_addr[idx];
|
|
|
|
range->range_data_size = reg->internal.range_data_size;
|
|
|
|
iwl_trans_read_mem_bytes(fwrt->trans, addr + offset, range->data,
|
|
|
|
le32_to_cpu(reg->internal.range_data_size));
|
|
|
|
return le32_to_cpu(range->range_data_size);
|
|
|
|
}
|
|
|
|
|
2018-12-05 15:08:19 +07:00
|
|
|
static int
|
|
|
|
iwl_dump_ini_paging_gen2_iter(struct iwl_fw_runtime *fwrt,
|
|
|
|
struct iwl_fw_ini_error_dump_range *range,
|
|
|
|
struct iwl_fw_ini_region_cfg *reg,
|
|
|
|
int idx)
|
|
|
|
{
|
|
|
|
u32 page_size = fwrt->trans->init_dram.paging[idx].size;
|
|
|
|
|
|
|
|
range->start_addr = cpu_to_le32(idx);
|
|
|
|
range->range_data_size = cpu_to_le32(page_size);
|
|
|
|
memcpy(range->data, fwrt->trans->init_dram.paging[idx].block,
|
|
|
|
page_size);
|
|
|
|
return le32_to_cpu(range->range_data_size);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int iwl_dump_ini_paging_iter(struct iwl_fw_runtime *fwrt,
|
|
|
|
struct iwl_fw_ini_error_dump_range *range,
|
|
|
|
struct iwl_fw_ini_region_cfg *reg,
|
|
|
|
int idx)
|
|
|
|
{
|
|
|
|
/* increase idx by 1 since the pages are from 1 to
|
|
|
|
* fwrt->num_of_paging_blk + 1
|
|
|
|
*/
|
|
|
|
struct page *page = fwrt->fw_paging_db[++idx].fw_paging_block;
|
|
|
|
dma_addr_t addr = fwrt->fw_paging_db[idx].fw_paging_phys;
|
|
|
|
u32 page_size = fwrt->fw_paging_db[idx].fw_paging_size;
|
|
|
|
|
|
|
|
range->start_addr = cpu_to_le32(idx);
|
|
|
|
range->range_data_size = cpu_to_le32(page_size);
|
|
|
|
dma_sync_single_for_cpu(fwrt->trans->dev, addr, page_size,
|
|
|
|
DMA_BIDIRECTIONAL);
|
|
|
|
memcpy(range->data, page_address(page), page_size);
|
|
|
|
dma_sync_single_for_device(fwrt->trans->dev, addr, page_size,
|
|
|
|
DMA_BIDIRECTIONAL);
|
|
|
|
return le32_to_cpu(range->range_data_size);
|
|
|
|
}
|
|
|
|
|
2018-12-03 14:19:25 +07:00
|
|
|
static struct iwl_fw_ini_error_dump_range
|
|
|
|
*iwl_dump_ini_mem_fill_header(struct iwl_fw_runtime *fwrt, void *data)
|
|
|
|
{
|
|
|
|
struct iwl_fw_ini_error_dump *dump = data;
|
|
|
|
|
|
|
|
return dump->ranges;
|
|
|
|
}
|
|
|
|
|
|
|
|
static u32 iwl_dump_ini_mem_get_size(struct iwl_fw_runtime *fwrt,
|
|
|
|
struct iwl_fw_ini_region_cfg *reg)
|
|
|
|
{
|
|
|
|
return le32_to_cpu(reg->internal.num_of_ranges) *
|
|
|
|
le32_to_cpu(reg->internal.range_data_size);
|
|
|
|
}
|
|
|
|
|
2018-12-05 15:08:19 +07:00
|
|
|
static u32 iwl_dump_ini_paging_gen2_get_size(struct iwl_fw_runtime *fwrt,
|
|
|
|
struct iwl_fw_ini_region_cfg *reg)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
u32 size = 0;
|
|
|
|
|
|
|
|
for (i = 0; i < fwrt->trans->init_dram.paging_cnt; i++)
|
|
|
|
size += fwrt->trans->init_dram.paging[i].size;
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
|
|
|
static u32 iwl_dump_ini_paging_get_size(struct iwl_fw_runtime *fwrt,
|
|
|
|
struct iwl_fw_ini_region_cfg *reg)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
u32 size = 0;
|
|
|
|
|
|
|
|
for (i = 1; i <= fwrt->num_of_paging_blk; i++)
|
|
|
|
size += fwrt->fw_paging_db[i].fw_paging_size;
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
2018-12-03 14:19:25 +07:00
|
|
|
static u32 iwl_dump_ini_mem_ranges(struct iwl_fw_runtime *fwrt,
|
|
|
|
struct iwl_fw_ini_region_cfg *reg)
|
|
|
|
{
|
|
|
|
return le32_to_cpu(reg->internal.num_of_ranges);
|
|
|
|
}
|
|
|
|
|
2018-12-05 15:08:19 +07:00
|
|
|
static u32 iwl_dump_ini_paging_gen2_ranges(struct iwl_fw_runtime *fwrt,
|
|
|
|
struct iwl_fw_ini_region_cfg *reg)
|
|
|
|
{
|
|
|
|
return fwrt->trans->init_dram.paging_cnt;
|
|
|
|
}
|
|
|
|
|
|
|
|
static u32 iwl_dump_ini_paging_ranges(struct iwl_fw_runtime *fwrt,
|
|
|
|
struct iwl_fw_ini_region_cfg *reg)
|
|
|
|
{
|
|
|
|
return fwrt->num_of_paging_blk;
|
|
|
|
}
|
|
|
|
|
2018-12-03 14:19:25 +07:00
|
|
|
/**
|
|
|
|
* struct iwl_dump_ini_mem_ops - ini memory dump operations
|
|
|
|
* @get_num_of_ranges: returns the number of memory ranges in the region.
|
|
|
|
* @get_size: returns the size of the region data without headers.
|
|
|
|
* @fill_mem_hdr: fills region type specific headers and returns the first
|
|
|
|
* range or NULL if failed to fill headers.
|
|
|
|
* @fill_range: copies a given memory range into the dump.
|
|
|
|
* Returns the size of the range or -1 otherwise.
|
|
|
|
*/
|
|
|
|
struct iwl_dump_ini_mem_ops {
|
|
|
|
u32 (*get_num_of_ranges)(struct iwl_fw_runtime *fwrt,
|
|
|
|
struct iwl_fw_ini_region_cfg *reg);
|
|
|
|
u32 (*get_size)(struct iwl_fw_runtime *fwrt,
|
|
|
|
struct iwl_fw_ini_region_cfg *reg);
|
|
|
|
struct iwl_fw_ini_error_dump_range *
|
|
|
|
(*fill_mem_hdr)(struct iwl_fw_runtime *fwrt, void *data);
|
|
|
|
int (*fill_range)(struct iwl_fw_runtime *fwrt,
|
|
|
|
struct iwl_fw_ini_error_dump_range *range,
|
|
|
|
struct iwl_fw_ini_region_cfg *reg, int idx);
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* iwl_dump_ini_mem - copy a memory region into the dump
|
|
|
|
* @fwrt: fw runtime struct.
|
|
|
|
* @data: dump memory data.
|
|
|
|
* @reg: region to copy to the dump.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
iwl_dump_ini_mem(struct iwl_fw_runtime *fwrt,
|
|
|
|
enum iwl_fw_ini_region_type type,
|
|
|
|
struct iwl_fw_error_dump_data **data,
|
|
|
|
struct iwl_fw_ini_region_cfg *reg,
|
|
|
|
struct iwl_dump_ini_mem_ops *ops)
|
|
|
|
{
|
|
|
|
struct iwl_fw_ini_error_dump_header *header = (void *)(*data)->data;
|
|
|
|
struct iwl_fw_ini_error_dump_range *range;
|
|
|
|
u32 num_of_ranges, i;
|
|
|
|
|
|
|
|
if (WARN_ON(!ops || !ops->get_num_of_ranges || !ops->get_size ||
|
|
|
|
!ops->fill_mem_hdr || !ops->fill_range))
|
|
|
|
return;
|
|
|
|
|
|
|
|
num_of_ranges = ops->get_num_of_ranges(fwrt, reg);
|
|
|
|
|
|
|
|
(*data)->type = cpu_to_le32(type | INI_DUMP_BIT);
|
|
|
|
(*data)->len = cpu_to_le32(sizeof(*header) + num_of_ranges *
|
|
|
|
sizeof(*range) + ops->get_size(fwrt, reg));
|
|
|
|
|
|
|
|
header->num_of_ranges = cpu_to_le32(num_of_ranges);
|
|
|
|
header->name_len = cpu_to_le32(min_t(int, IWL_FW_INI_MAX_NAME,
|
|
|
|
le32_to_cpu(reg->name_len)));
|
|
|
|
memcpy(header->name, reg->name, le32_to_cpu(header->name_len));
|
|
|
|
|
|
|
|
range = ops->fill_mem_hdr(fwrt, header);
|
|
|
|
if (!range)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (i = 0; i < num_of_ranges; i++) {
|
|
|
|
int range_data_size = ops->fill_range(fwrt, range, reg, i);
|
|
|
|
|
|
|
|
if (range_data_size < 0) {
|
|
|
|
IWL_ERR(fwrt, "Failed to dump region type %d\n", type);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
range = ((void *)range) + sizeof(*range) + range_data_size;
|
|
|
|
}
|
|
|
|
*data = iwl_fw_error_next_data(*data);
|
|
|
|
}
|
|
|
|
|
2018-06-13 19:24:13 +07:00
|
|
|
static int iwl_fw_ini_get_trigger_len(struct iwl_fw_runtime *fwrt,
|
|
|
|
struct iwl_fw_ini_trigger *trigger)
|
|
|
|
{
|
2018-12-03 14:19:25 +07:00
|
|
|
int i, size = 0, hdr_len = sizeof(struct iwl_fw_error_dump_data);
|
|
|
|
u32 dump_header_len = sizeof(struct iwl_fw_ini_error_dump);
|
|
|
|
u32 range_header_len = sizeof(struct iwl_fw_ini_error_dump_range);
|
2018-06-13 19:24:13 +07:00
|
|
|
|
|
|
|
if (!trigger || !trigger->num_regions)
|
|
|
|
return 0;
|
|
|
|
|
2018-12-03 14:19:25 +07:00
|
|
|
for (i = 0; i < le32_to_cpu(trigger->num_regions); i++) {
|
2018-06-13 19:24:13 +07:00
|
|
|
u32 reg_id = le32_to_cpu(trigger->data[i]);
|
|
|
|
struct iwl_fw_ini_region_cfg *reg;
|
|
|
|
enum iwl_fw_ini_region_type type;
|
|
|
|
|
|
|
|
if (WARN_ON(reg_id >= ARRAY_SIZE(fwrt->dump.active_regs)))
|
|
|
|
continue;
|
|
|
|
|
2018-11-20 18:29:29 +07:00
|
|
|
reg = fwrt->dump.active_regs[reg_id];
|
2018-06-13 19:24:13 +07:00
|
|
|
if (WARN(!reg, "Unassigned region %d\n", reg_id))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
type = le32_to_cpu(reg->region_type);
|
|
|
|
switch (type) {
|
|
|
|
case IWL_FW_INI_REGION_DEVICE_MEMORY:
|
|
|
|
case IWL_FW_INI_REGION_PERIPHERY_MAC:
|
|
|
|
case IWL_FW_INI_REGION_PERIPHERY_PHY:
|
|
|
|
case IWL_FW_INI_REGION_PERIPHERY_AUX:
|
2018-12-03 17:13:31 +07:00
|
|
|
case IWL_FW_INI_REGION_CSR:
|
2018-12-03 14:19:25 +07:00
|
|
|
size += hdr_len + dump_header_len + range_header_len *
|
|
|
|
iwl_dump_ini_mem_ranges(fwrt, reg) +
|
|
|
|
iwl_dump_ini_mem_get_size(fwrt, reg);
|
2018-06-13 19:24:13 +07:00
|
|
|
break;
|
|
|
|
case IWL_FW_INI_REGION_TXF:
|
|
|
|
size += iwl_fw_txf_len(fwrt, &fwrt->smem_cfg);
|
|
|
|
break;
|
|
|
|
case IWL_FW_INI_REGION_RXF:
|
|
|
|
size += iwl_fw_rxf_len(fwrt, &fwrt->smem_cfg);
|
|
|
|
break;
|
2018-12-05 15:08:19 +07:00
|
|
|
case IWL_FW_INI_REGION_PAGING: {
|
|
|
|
size += hdr_len + dump_header_len;
|
|
|
|
if (iwl_fw_dbg_is_paging_enabled(fwrt)) {
|
|
|
|
size += range_header_len *
|
|
|
|
iwl_dump_ini_paging_ranges(fwrt, reg) +
|
|
|
|
iwl_dump_ini_paging_get_size(fwrt, reg);
|
|
|
|
} else {
|
|
|
|
size += range_header_len *
|
|
|
|
iwl_dump_ini_paging_gen2_ranges(fwrt,
|
|
|
|
reg) +
|
|
|
|
iwl_dump_ini_paging_gen2_get_size(fwrt,
|
|
|
|
reg);
|
|
|
|
}
|
2018-06-13 19:24:13 +07:00
|
|
|
break;
|
2018-12-05 15:08:19 +07:00
|
|
|
}
|
2018-06-13 19:24:13 +07:00
|
|
|
case IWL_FW_INI_REGION_DRAM_BUFFER:
|
|
|
|
/* Transport takes care of DRAM dumping */
|
|
|
|
case IWL_FW_INI_REGION_INTERNAL_BUFFER:
|
|
|
|
case IWL_FW_INI_REGION_DRAM_IMR:
|
|
|
|
/* Undefined yet */
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void iwl_fw_ini_dump_trigger(struct iwl_fw_runtime *fwrt,
|
|
|
|
struct iwl_fw_ini_trigger *trigger,
|
|
|
|
struct iwl_fw_error_dump_data **data,
|
|
|
|
u32 *dump_mask)
|
|
|
|
{
|
|
|
|
int i, num = le32_to_cpu(trigger->num_regions);
|
|
|
|
|
|
|
|
for (i = 0; i < num; i++) {
|
|
|
|
u32 reg_id = le32_to_cpu(trigger->data[i]);
|
|
|
|
enum iwl_fw_ini_region_type type;
|
|
|
|
struct iwl_fw_ini_region_cfg *reg;
|
2018-12-03 14:19:25 +07:00
|
|
|
struct iwl_dump_ini_mem_ops ops;
|
2018-06-13 19:24:13 +07:00
|
|
|
|
|
|
|
if (reg_id >= ARRAY_SIZE(fwrt->dump.active_regs))
|
|
|
|
continue;
|
|
|
|
|
2018-11-20 18:29:29 +07:00
|
|
|
reg = fwrt->dump.active_regs[reg_id];
|
2018-06-13 19:24:13 +07:00
|
|
|
/* Don't warn, get_trigger_len already warned */
|
|
|
|
if (!reg)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
type = le32_to_cpu(reg->region_type);
|
|
|
|
switch (type) {
|
2018-12-03 18:40:24 +07:00
|
|
|
case IWL_FW_INI_REGION_DEVICE_MEMORY:
|
|
|
|
ops.get_num_of_ranges = iwl_dump_ini_mem_ranges;
|
|
|
|
ops.get_size = iwl_dump_ini_mem_get_size;
|
|
|
|
ops.fill_mem_hdr = iwl_dump_ini_mem_fill_header;
|
|
|
|
ops.fill_range = iwl_dump_ini_dev_mem_iter;
|
|
|
|
iwl_dump_ini_mem(fwrt, type, data, reg, &ops);
|
2018-06-13 19:24:13 +07:00
|
|
|
break;
|
|
|
|
case IWL_FW_INI_REGION_PERIPHERY_MAC:
|
|
|
|
case IWL_FW_INI_REGION_PERIPHERY_PHY:
|
|
|
|
case IWL_FW_INI_REGION_PERIPHERY_AUX:
|
2018-12-03 14:19:25 +07:00
|
|
|
ops.get_num_of_ranges = iwl_dump_ini_mem_ranges;
|
|
|
|
ops.get_size = iwl_dump_ini_mem_get_size;
|
|
|
|
ops.fill_mem_hdr = iwl_dump_ini_mem_fill_header;
|
|
|
|
ops.fill_range = iwl_dump_ini_prph_iter;
|
|
|
|
iwl_dump_ini_mem(fwrt, type, data, reg, &ops);
|
2018-06-13 19:24:13 +07:00
|
|
|
break;
|
|
|
|
case IWL_FW_INI_REGION_DRAM_BUFFER:
|
2018-11-26 15:29:15 +07:00
|
|
|
*dump_mask |= BIT(IWL_FW_ERROR_DUMP_FW_MONITOR);
|
2018-06-13 19:24:13 +07:00
|
|
|
break;
|
2018-12-05 15:08:19 +07:00
|
|
|
case IWL_FW_INI_REGION_PAGING: {
|
|
|
|
ops.fill_mem_hdr = iwl_dump_ini_mem_fill_header;
|
|
|
|
if (iwl_fw_dbg_is_paging_enabled(fwrt)) {
|
|
|
|
ops.get_num_of_ranges =
|
|
|
|
iwl_dump_ini_paging_ranges;
|
|
|
|
ops.get_size = iwl_dump_ini_paging_get_size;
|
|
|
|
ops.fill_range = iwl_dump_ini_paging_iter;
|
|
|
|
} else {
|
|
|
|
ops.get_num_of_ranges =
|
|
|
|
iwl_dump_ini_paging_gen2_ranges;
|
|
|
|
ops.get_size =
|
|
|
|
iwl_dump_ini_paging_gen2_get_size;
|
|
|
|
ops.fill_range = iwl_dump_ini_paging_gen2_iter;
|
|
|
|
}
|
|
|
|
|
|
|
|
iwl_dump_ini_mem(fwrt, type, data, reg, &ops);
|
2018-06-13 19:24:13 +07:00
|
|
|
break;
|
2018-12-05 15:08:19 +07:00
|
|
|
}
|
2018-06-13 19:24:13 +07:00
|
|
|
case IWL_FW_INI_REGION_TXF:
|
|
|
|
iwl_fw_dump_txf(fwrt, data);
|
|
|
|
break;
|
|
|
|
case IWL_FW_INI_REGION_RXF:
|
|
|
|
iwl_fw_dump_rxf(fwrt, data);
|
|
|
|
break;
|
|
|
|
case IWL_FW_INI_REGION_CSR:
|
2018-12-03 17:13:31 +07:00
|
|
|
ops.get_num_of_ranges = iwl_dump_ini_mem_ranges;
|
|
|
|
ops.get_size = iwl_dump_ini_mem_get_size;
|
|
|
|
ops.fill_mem_hdr = iwl_dump_ini_mem_fill_header;
|
|
|
|
ops.fill_range = iwl_dump_ini_csr_iter;
|
|
|
|
iwl_dump_ini_mem(fwrt, type, data, reg, &ops);
|
2018-06-13 19:24:13 +07:00
|
|
|
break;
|
|
|
|
case IWL_FW_INI_REGION_DRAM_IMR:
|
|
|
|
case IWL_FW_INI_REGION_INTERNAL_BUFFER:
|
|
|
|
/* This is undefined yet */
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct iwl_fw_error_dump_file *
|
|
|
|
_iwl_fw_error_ini_dump(struct iwl_fw_runtime *fwrt,
|
|
|
|
struct iwl_fw_dump_ptrs *fw_error_dump,
|
|
|
|
u32 *dump_mask)
|
|
|
|
{
|
|
|
|
int size, id = le32_to_cpu(fwrt->dump.desc->trig_desc.type);
|
|
|
|
struct iwl_fw_error_dump_data *dump_data;
|
|
|
|
struct iwl_fw_error_dump_file *dump_file;
|
|
|
|
struct iwl_fw_ini_trigger *trigger, *ext;
|
|
|
|
|
|
|
|
if (id == FW_DBG_TRIGGER_FW_ASSERT)
|
|
|
|
id = IWL_FW_TRIGGER_ID_FW_ASSERT;
|
|
|
|
|
|
|
|
if (WARN_ON(id >= ARRAY_SIZE(fwrt->dump.active_trigs)))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
trigger = fwrt->dump.active_trigs[id].conf;
|
|
|
|
ext = fwrt->dump.active_trigs[id].conf_ext;
|
|
|
|
|
|
|
|
size = sizeof(*dump_file);
|
|
|
|
size += iwl_fw_ini_get_trigger_len(fwrt, trigger);
|
|
|
|
size += iwl_fw_ini_get_trigger_len(fwrt, ext);
|
|
|
|
|
|
|
|
if (!size)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
dump_file = vzalloc(size);
|
|
|
|
if (!dump_file)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
fw_error_dump->fwrt_ptr = dump_file;
|
|
|
|
|
|
|
|
dump_file->barker = cpu_to_le32(IWL_FW_ERROR_DUMP_BARKER);
|
|
|
|
dump_data = (void *)dump_file->data;
|
|
|
|
dump_file->file_len = cpu_to_le32(size);
|
|
|
|
|
|
|
|
*dump_mask = 0;
|
|
|
|
if (trigger)
|
|
|
|
iwl_fw_ini_dump_trigger(fwrt, trigger, &dump_data, dump_mask);
|
|
|
|
if (ext)
|
|
|
|
iwl_fw_ini_dump_trigger(fwrt, ext, &dump_data, dump_mask);
|
|
|
|
|
|
|
|
return dump_file;
|
|
|
|
}
|
|
|
|
|
2018-06-11 19:30:07 +07:00
|
|
|
void iwl_fw_error_dump(struct iwl_fw_runtime *fwrt)
|
|
|
|
{
|
|
|
|
struct iwl_fw_dump_ptrs *fw_error_dump;
|
|
|
|
struct iwl_fw_error_dump_file *dump_file;
|
|
|
|
struct scatterlist *sg_dump_data;
|
|
|
|
u32 file_len;
|
2018-07-30 15:59:16 +07:00
|
|
|
u32 dump_mask = fwrt->fw->dbg.dump_mask;
|
2018-06-11 19:30:07 +07:00
|
|
|
|
|
|
|
IWL_DEBUG_INFO(fwrt, "WRT dump start\n");
|
|
|
|
|
|
|
|
/* there's no point in fw dump if the bus is dead */
|
|
|
|
if (test_bit(STATUS_TRANS_DEAD, &fwrt->trans->status)) {
|
|
|
|
IWL_ERR(fwrt, "Skip fw error dump since bus is dead\n");
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
fw_error_dump = kzalloc(sizeof(*fw_error_dump), GFP_KERNEL);
|
|
|
|
if (!fw_error_dump)
|
|
|
|
goto out;
|
|
|
|
|
2018-06-13 19:24:13 +07:00
|
|
|
if (fwrt->trans->ini_valid)
|
|
|
|
dump_file = _iwl_fw_error_ini_dump(fwrt, fw_error_dump,
|
|
|
|
&dump_mask);
|
|
|
|
else
|
|
|
|
dump_file = _iwl_fw_error_dump(fwrt, fw_error_dump);
|
|
|
|
|
2018-06-11 19:30:07 +07:00
|
|
|
if (!dump_file) {
|
|
|
|
kfree(fw_error_dump);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2018-06-13 19:24:13 +07:00
|
|
|
if (!fwrt->trans->ini_valid && fwrt->dump.monitor_only)
|
2018-07-30 15:59:16 +07:00
|
|
|
dump_mask &= IWL_FW_ERROR_DUMP_FW_MONITOR;
|
|
|
|
|
|
|
|
fw_error_dump->trans_ptr = iwl_trans_dump_data(fwrt->trans, dump_mask);
|
2018-06-11 19:30:07 +07:00
|
|
|
file_len = le32_to_cpu(dump_file->file_len);
|
2017-06-01 21:03:19 +07:00
|
|
|
fw_error_dump->fwrt_len = file_len;
|
2018-06-11 19:30:07 +07:00
|
|
|
if (fw_error_dump->trans_ptr) {
|
2015-10-28 00:17:14 +07:00
|
|
|
file_len += fw_error_dump->trans_ptr->len;
|
2018-06-11 19:30:07 +07:00
|
|
|
dump_file->file_len = cpu_to_le32(file_len);
|
|
|
|
}
|
2015-10-28 00:17:14 +07:00
|
|
|
|
2016-09-20 22:07:44 +07:00
|
|
|
sg_dump_data = alloc_sgtable(file_len);
|
|
|
|
if (sg_dump_data) {
|
|
|
|
sg_pcopy_from_buffer(sg_dump_data,
|
|
|
|
sg_nents(sg_dump_data),
|
2017-06-01 21:03:19 +07:00
|
|
|
fw_error_dump->fwrt_ptr,
|
|
|
|
fw_error_dump->fwrt_len, 0);
|
2016-10-20 20:25:00 +07:00
|
|
|
if (fw_error_dump->trans_ptr)
|
|
|
|
sg_pcopy_from_buffer(sg_dump_data,
|
|
|
|
sg_nents(sg_dump_data),
|
|
|
|
fw_error_dump->trans_ptr->data,
|
|
|
|
fw_error_dump->trans_ptr->len,
|
2017-06-01 21:03:19 +07:00
|
|
|
fw_error_dump->fwrt_len);
|
|
|
|
dev_coredumpsg(fwrt->trans->dev, sg_dump_data, file_len,
|
2016-09-20 22:07:44 +07:00
|
|
|
GFP_KERNEL);
|
|
|
|
}
|
2017-06-01 21:03:19 +07:00
|
|
|
vfree(fw_error_dump->fwrt_ptr);
|
2016-09-20 22:07:44 +07:00
|
|
|
vfree(fw_error_dump->trans_ptr);
|
|
|
|
kfree(fw_error_dump);
|
2015-10-28 00:17:14 +07:00
|
|
|
|
2016-01-05 14:35:21 +07:00
|
|
|
out:
|
2017-06-01 21:03:19 +07:00
|
|
|
iwl_fw_free_dump_desc(fwrt);
|
|
|
|
clear_bit(IWL_FWRT_STATUS_DUMPING, &fwrt->status);
|
2017-09-04 18:39:22 +07:00
|
|
|
IWL_DEBUG_INFO(fwrt, "WRT dump done\n");
|
2015-10-28 00:17:14 +07:00
|
|
|
}
|
2017-06-01 21:03:19 +07:00
|
|
|
IWL_EXPORT_SYMBOL(iwl_fw_error_dump);
|
2015-10-28 00:17:14 +07:00
|
|
|
|
2017-06-01 21:03:19 +07:00
|
|
|
const struct iwl_fw_dump_desc iwl_dump_desc_assert = {
|
2015-10-28 00:17:14 +07:00
|
|
|
.trig_desc = {
|
|
|
|
.type = cpu_to_le32(FW_DBG_TRIGGER_FW_ASSERT),
|
|
|
|
},
|
|
|
|
};
|
2017-06-01 21:03:19 +07:00
|
|
|
IWL_EXPORT_SYMBOL(iwl_dump_desc_assert);
|
2015-10-28 00:17:14 +07:00
|
|
|
|
2017-06-01 21:03:19 +07:00
|
|
|
int iwl_fw_dbg_collect_desc(struct iwl_fw_runtime *fwrt,
|
2018-07-23 17:50:02 +07:00
|
|
|
const struct iwl_fw_dump_desc *desc,
|
|
|
|
bool monitor_only,
|
2018-06-21 18:44:28 +07:00
|
|
|
unsigned int delay)
|
2015-10-28 00:17:14 +07:00
|
|
|
{
|
2017-10-31 20:54:50 +07:00
|
|
|
/*
|
|
|
|
* If the loading of the FW completed successfully, the next step is to
|
|
|
|
* get the SMEM config data. Thus, if fwrt->smem_cfg.num_lmacs is non
|
|
|
|
* zero, the FW was already loaded successully. If the state is "NO_FW"
|
2018-04-19 15:57:08 +07:00
|
|
|
* in such a case - exit, since FW may be dead. Otherwise, we
|
2017-10-31 20:54:50 +07:00
|
|
|
* can try to collect the data, since FW might just not be fully
|
|
|
|
* loaded (no "ALIVE" yet), and the debug data is accessible.
|
|
|
|
*
|
|
|
|
* Corner case: got the FW alive but crashed before getting the SMEM
|
|
|
|
* config. In such a case, due to HW access problems, we might
|
|
|
|
* collect garbage.
|
|
|
|
*/
|
2018-04-19 15:57:08 +07:00
|
|
|
if (fwrt->trans->state == IWL_TRANS_NO_FW &&
|
|
|
|
fwrt->smem_cfg.num_lmacs)
|
2017-03-23 16:08:59 +07:00
|
|
|
return -EIO;
|
|
|
|
|
2018-11-22 14:12:08 +07:00
|
|
|
if (test_and_set_bit(IWL_FWRT_STATUS_DUMPING, &fwrt->status))
|
2015-10-28 00:17:14 +07:00
|
|
|
return -EBUSY;
|
|
|
|
|
2017-06-01 21:03:19 +07:00
|
|
|
if (WARN_ON(fwrt->dump.desc))
|
|
|
|
iwl_fw_free_dump_desc(fwrt);
|
2015-10-28 00:17:14 +07:00
|
|
|
|
2017-06-01 21:03:19 +07:00
|
|
|
IWL_WARN(fwrt, "Collecting data: trigger %d fired.\n",
|
2015-10-28 00:17:14 +07:00
|
|
|
le32_to_cpu(desc->trig_desc.type));
|
|
|
|
|
2017-06-01 21:03:19 +07:00
|
|
|
fwrt->dump.desc = desc;
|
2018-07-23 17:50:02 +07:00
|
|
|
fwrt->dump.monitor_only = monitor_only;
|
2015-10-28 00:17:14 +07:00
|
|
|
|
2017-06-01 21:03:19 +07:00
|
|
|
schedule_delayed_work(&fwrt->dump.wk, delay);
|
2015-10-28 00:17:14 +07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2017-06-01 21:03:19 +07:00
|
|
|
IWL_EXPORT_SYMBOL(iwl_fw_dbg_collect_desc);
|
2015-10-28 00:17:14 +07:00
|
|
|
|
2018-11-12 18:27:51 +07:00
|
|
|
int iwl_fw_dbg_error_collect(struct iwl_fw_runtime *fwrt,
|
|
|
|
enum iwl_fw_dbg_trigger trig_type)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
struct iwl_fw_dump_desc *iwl_dump_error_desc =
|
|
|
|
kmalloc(sizeof(*iwl_dump_error_desc), GFP_KERNEL);
|
|
|
|
|
|
|
|
if (!iwl_dump_error_desc)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
iwl_dump_error_desc->trig_desc.type = cpu_to_le32(trig_type);
|
|
|
|
iwl_dump_error_desc->len = 0;
|
|
|
|
|
|
|
|
ret = iwl_fw_dbg_collect_desc(fwrt, iwl_dump_error_desc, false, 0);
|
|
|
|
if (ret) {
|
|
|
|
kfree(iwl_dump_error_desc);
|
|
|
|
} else {
|
|
|
|
set_bit(STATUS_FW_WAIT_DUMP, &fwrt->trans->status);
|
|
|
|
|
|
|
|
/* trigger nmi to halt the fw */
|
|
|
|
iwl_force_nmi(fwrt->trans);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
IWL_EXPORT_SYMBOL(iwl_fw_dbg_error_collect);
|
|
|
|
|
2018-06-21 13:42:12 +07:00
|
|
|
int _iwl_fw_dbg_collect(struct iwl_fw_runtime *fwrt,
|
|
|
|
enum iwl_fw_dbg_trigger trig,
|
|
|
|
const char *str, size_t len,
|
|
|
|
struct iwl_fw_dbg_trigger_tlv *trigger)
|
2015-10-28 00:17:14 +07:00
|
|
|
{
|
2017-06-01 21:03:19 +07:00
|
|
|
struct iwl_fw_dump_desc *desc;
|
2018-06-21 18:44:28 +07:00
|
|
|
unsigned int delay = 0;
|
2018-07-23 17:50:02 +07:00
|
|
|
bool monitor_only = false;
|
2015-10-28 00:17:14 +07:00
|
|
|
|
2018-06-21 18:44:28 +07:00
|
|
|
if (trigger) {
|
|
|
|
u16 occurrences = le16_to_cpu(trigger->occurrences) - 1;
|
2018-06-21 18:24:45 +07:00
|
|
|
|
2018-06-21 18:44:28 +07:00
|
|
|
if (!le16_to_cpu(trigger->occurrences))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (trigger->flags & IWL_FW_DBG_FORCE_RESTART) {
|
|
|
|
IWL_WARN(fwrt, "Force restart: trigger %d fired.\n",
|
|
|
|
trig);
|
|
|
|
iwl_force_nmi(fwrt->trans);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
trigger->occurrences = cpu_to_le16(occurrences);
|
|
|
|
delay = le16_to_cpu(trigger->trig_dis_ms);
|
2018-07-23 17:50:02 +07:00
|
|
|
monitor_only = trigger->mode & IWL_FW_DBG_TRIGGER_MONITOR_ONLY;
|
2017-12-28 15:19:43 +07:00
|
|
|
}
|
|
|
|
|
2015-10-28 00:17:14 +07:00
|
|
|
desc = kzalloc(sizeof(*desc) + len, GFP_ATOMIC);
|
|
|
|
if (!desc)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
2018-06-21 18:24:45 +07:00
|
|
|
|
2015-10-28 00:17:14 +07:00
|
|
|
desc->len = len;
|
|
|
|
desc->trig_desc.type = cpu_to_le32(trig);
|
|
|
|
memcpy(desc->trig_desc.data, str, len);
|
|
|
|
|
2018-07-23 17:50:02 +07:00
|
|
|
return iwl_fw_dbg_collect_desc(fwrt, desc, monitor_only, delay);
|
2015-10-28 00:17:14 +07:00
|
|
|
}
|
2018-06-21 13:42:12 +07:00
|
|
|
IWL_EXPORT_SYMBOL(_iwl_fw_dbg_collect);
|
|
|
|
|
|
|
|
int iwl_fw_dbg_collect(struct iwl_fw_runtime *fwrt,
|
|
|
|
u32 id, const char *str, size_t len)
|
|
|
|
{
|
|
|
|
struct iwl_fw_dump_desc *desc;
|
|
|
|
u32 occur, delay;
|
|
|
|
|
|
|
|
if (!fwrt->trans->ini_valid)
|
|
|
|
return _iwl_fw_dbg_collect(fwrt, id, str, len, NULL);
|
|
|
|
|
|
|
|
if (id == FW_DBG_TRIGGER_USER)
|
|
|
|
id = IWL_FW_TRIGGER_ID_USER_TRIGGER;
|
|
|
|
|
|
|
|
if (WARN_ON(!fwrt->dump.active_trigs[id].active))
|
|
|
|
return -EINVAL;
|
|
|
|
|
2018-11-26 15:34:37 +07:00
|
|
|
delay = le32_to_cpu(fwrt->dump.active_trigs[id].conf->dump_delay);
|
2018-06-21 13:42:12 +07:00
|
|
|
occur = le32_to_cpu(fwrt->dump.active_trigs[id].conf->occurrences);
|
|
|
|
if (!occur)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (le32_to_cpu(fwrt->dump.active_trigs[id].conf->force_restart)) {
|
|
|
|
IWL_WARN(fwrt, "Force restart: trigger %d fired.\n", id);
|
|
|
|
iwl_force_nmi(fwrt->trans);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
desc = kzalloc(sizeof(*desc) + len, GFP_ATOMIC);
|
|
|
|
if (!desc)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
occur--;
|
|
|
|
fwrt->dump.active_trigs[id].conf->occurrences = cpu_to_le32(occur);
|
|
|
|
|
|
|
|
desc->len = len;
|
|
|
|
desc->trig_desc.type = cpu_to_le32(id);
|
|
|
|
memcpy(desc->trig_desc.data, str, len);
|
|
|
|
|
|
|
|
return iwl_fw_dbg_collect_desc(fwrt, desc, true, delay);
|
|
|
|
}
|
2017-06-01 21:03:19 +07:00
|
|
|
IWL_EXPORT_SYMBOL(iwl_fw_dbg_collect);
|
2015-10-28 00:17:14 +07:00
|
|
|
|
2017-06-01 21:03:19 +07:00
|
|
|
int iwl_fw_dbg_collect_trig(struct iwl_fw_runtime *fwrt,
|
|
|
|
struct iwl_fw_dbg_trigger_tlv *trigger,
|
|
|
|
const char *fmt, ...)
|
2015-10-28 00:17:14 +07:00
|
|
|
{
|
|
|
|
int ret, len = 0;
|
|
|
|
char buf[64];
|
|
|
|
|
2018-06-13 18:41:35 +07:00
|
|
|
if (fwrt->trans->ini_valid)
|
|
|
|
return 0;
|
|
|
|
|
2015-10-28 00:17:14 +07:00
|
|
|
if (fmt) {
|
|
|
|
va_list ap;
|
|
|
|
|
|
|
|
buf[sizeof(buf) - 1] = '\0';
|
|
|
|
|
|
|
|
va_start(ap, fmt);
|
|
|
|
vsnprintf(buf, sizeof(buf), fmt, ap);
|
|
|
|
va_end(ap);
|
|
|
|
|
|
|
|
/* check for truncation */
|
|
|
|
if (WARN_ON_ONCE(buf[sizeof(buf) - 1]))
|
|
|
|
buf[sizeof(buf) - 1] = '\0';
|
|
|
|
|
|
|
|
len = strlen(buf) + 1;
|
|
|
|
}
|
|
|
|
|
2018-06-21 13:42:12 +07:00
|
|
|
ret = _iwl_fw_dbg_collect(fwrt, le32_to_cpu(trigger->id), buf, len,
|
|
|
|
trigger);
|
2015-10-28 00:17:14 +07:00
|
|
|
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2017-06-01 21:03:19 +07:00
|
|
|
IWL_EXPORT_SYMBOL(iwl_fw_dbg_collect_trig);
|
2015-10-28 00:17:14 +07:00
|
|
|
|
2017-06-01 21:03:19 +07:00
|
|
|
int iwl_fw_start_dbg_conf(struct iwl_fw_runtime *fwrt, u8 conf_id)
|
2015-10-28 00:17:14 +07:00
|
|
|
{
|
|
|
|
u8 *ptr;
|
|
|
|
int ret;
|
|
|
|
int i;
|
|
|
|
|
2018-06-11 15:43:09 +07:00
|
|
|
if (WARN_ONCE(conf_id >= ARRAY_SIZE(fwrt->fw->dbg.conf_tlv),
|
2015-10-28 00:17:14 +07:00
|
|
|
"Invalid configuration %d\n", conf_id))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
/* EARLY START - firmware's configuration is hard coded */
|
2018-06-11 15:43:09 +07:00
|
|
|
if ((!fwrt->fw->dbg.conf_tlv[conf_id] ||
|
|
|
|
!fwrt->fw->dbg.conf_tlv[conf_id]->num_of_hcmds) &&
|
2017-03-29 14:21:09 +07:00
|
|
|
conf_id == FW_DBG_START_FROM_ALIVE)
|
2015-10-28 00:17:14 +07:00
|
|
|
return 0;
|
|
|
|
|
2018-06-11 15:43:09 +07:00
|
|
|
if (!fwrt->fw->dbg.conf_tlv[conf_id])
|
2015-10-28 00:17:14 +07:00
|
|
|
return -EINVAL;
|
|
|
|
|
2017-06-01 21:03:19 +07:00
|
|
|
if (fwrt->dump.conf != FW_DBG_INVALID)
|
|
|
|
IWL_WARN(fwrt, "FW already configured (%d) - re-configuring\n",
|
|
|
|
fwrt->dump.conf);
|
2015-10-28 00:17:14 +07:00
|
|
|
|
|
|
|
/* Send all HCMDs for configuring the FW debug */
|
2018-06-11 15:43:09 +07:00
|
|
|
ptr = (void *)&fwrt->fw->dbg.conf_tlv[conf_id]->hcmd;
|
|
|
|
for (i = 0; i < fwrt->fw->dbg.conf_tlv[conf_id]->num_of_hcmds; i++) {
|
2015-10-28 00:17:14 +07:00
|
|
|
struct iwl_fw_dbg_conf_hcmd *cmd = (void *)ptr;
|
2017-06-01 21:03:19 +07:00
|
|
|
struct iwl_host_cmd hcmd = {
|
|
|
|
.id = cmd->id,
|
|
|
|
.len = { le16_to_cpu(cmd->len), },
|
|
|
|
.data = { cmd->data, },
|
|
|
|
};
|
2015-10-28 00:17:14 +07:00
|
|
|
|
2017-06-01 21:03:19 +07:00
|
|
|
ret = iwl_trans_send_cmd(fwrt->trans, &hcmd);
|
2015-10-28 00:17:14 +07:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
ptr += sizeof(*cmd);
|
|
|
|
ptr += le16_to_cpu(cmd->len);
|
|
|
|
}
|
|
|
|
|
2017-06-01 21:03:19 +07:00
|
|
|
fwrt->dump.conf = conf_id;
|
2016-08-04 02:06:43 +07:00
|
|
|
|
|
|
|
return 0;
|
2015-10-28 00:17:14 +07:00
|
|
|
}
|
2017-06-01 21:03:19 +07:00
|
|
|
IWL_EXPORT_SYMBOL(iwl_fw_start_dbg_conf);
|
|
|
|
|
2018-06-11 14:46:58 +07:00
|
|
|
/* this function assumes dump_start was called beforehand and dump_end will be
|
|
|
|
* called afterwards
|
|
|
|
*/
|
|
|
|
void iwl_fw_dbg_collect_sync(struct iwl_fw_runtime *fwrt)
|
2017-06-01 21:03:19 +07:00
|
|
|
{
|
2018-05-17 18:04:19 +07:00
|
|
|
struct iwl_fw_dbg_params params = {0};
|
2017-06-01 21:03:19 +07:00
|
|
|
|
2018-06-11 14:46:58 +07:00
|
|
|
if (!test_bit(IWL_FWRT_STATUS_DUMPING, &fwrt->status))
|
2017-06-01 21:03:19 +07:00
|
|
|
return;
|
|
|
|
|
2018-01-11 21:18:46 +07:00
|
|
|
if (fwrt->ops && fwrt->ops->fw_running &&
|
|
|
|
!fwrt->ops->fw_running(fwrt->ops_ctx)) {
|
|
|
|
IWL_ERR(fwrt, "Firmware not running - cannot dump error\n");
|
|
|
|
iwl_fw_free_dump_desc(fwrt);
|
|
|
|
clear_bit(IWL_FWRT_STATUS_DUMPING, &fwrt->status);
|
2018-06-11 14:46:58 +07:00
|
|
|
return;
|
2018-01-11 21:18:46 +07:00
|
|
|
}
|
|
|
|
|
2018-05-17 18:41:10 +07:00
|
|
|
iwl_fw_dbg_stop_recording(fwrt, ¶ms);
|
2018-05-17 18:04:19 +07:00
|
|
|
|
|
|
|
iwl_fw_error_dump(fwrt);
|
2017-06-01 21:03:19 +07:00
|
|
|
|
2018-05-17 18:04:19 +07:00
|
|
|
/* start recording again if the firmware is not crashed */
|
|
|
|
if (!test_bit(STATUS_FW_ERROR, &fwrt->trans->status) &&
|
2018-06-11 15:43:09 +07:00
|
|
|
fwrt->fw->dbg.dest_tlv) {
|
2017-06-01 21:03:19 +07:00
|
|
|
/* wait before we collect the data till the DBGC stop */
|
|
|
|
udelay(500);
|
2018-05-17 18:41:10 +07:00
|
|
|
iwl_fw_dbg_restart_recording(fwrt, ¶ms);
|
2017-06-01 21:03:19 +07:00
|
|
|
}
|
2018-06-11 14:46:58 +07:00
|
|
|
}
|
|
|
|
IWL_EXPORT_SYMBOL(iwl_fw_dbg_collect_sync);
|
|
|
|
|
|
|
|
void iwl_fw_error_dump_wk(struct work_struct *work)
|
|
|
|
{
|
|
|
|
struct iwl_fw_runtime *fwrt =
|
|
|
|
container_of(work, struct iwl_fw_runtime, dump.wk.work);
|
|
|
|
|
|
|
|
if (fwrt->ops && fwrt->ops->dump_start &&
|
|
|
|
fwrt->ops->dump_start(fwrt->ops_ctx))
|
|
|
|
return;
|
|
|
|
|
|
|
|
iwl_fw_dbg_collect_sync(fwrt);
|
|
|
|
|
2017-06-01 21:03:19 +07:00
|
|
|
if (fwrt->ops && fwrt->ops->dump_end)
|
|
|
|
fwrt->ops->dump_end(fwrt->ops_ctx);
|
|
|
|
}
|
|
|
|
|
2018-01-29 16:05:37 +07:00
|
|
|
void iwl_fw_dbg_read_d3_debug_data(struct iwl_fw_runtime *fwrt)
|
|
|
|
{
|
|
|
|
const struct iwl_cfg *cfg = fwrt->trans->cfg;
|
|
|
|
|
|
|
|
if (!iwl_fw_dbg_is_d3_debug_enabled(fwrt))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!fwrt->dump.d3_debug_data) {
|
|
|
|
fwrt->dump.d3_debug_data = kmalloc(cfg->d3_debug_data_length,
|
|
|
|
GFP_KERNEL);
|
|
|
|
if (!fwrt->dump.d3_debug_data) {
|
|
|
|
IWL_ERR(fwrt,
|
|
|
|
"failed to allocate memory for D3 debug data\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* if the buffer holds previous debug data it is overwritten */
|
|
|
|
iwl_trans_read_mem_bytes(fwrt->trans, cfg->d3_debug_data_base_addr,
|
|
|
|
fwrt->dump.d3_debug_data,
|
|
|
|
cfg->d3_debug_data_length);
|
|
|
|
}
|
|
|
|
IWL_EXPORT_SYMBOL(iwl_fw_dbg_read_d3_debug_data);
|
2018-06-13 19:19:47 +07:00
|
|
|
|
|
|
|
static void
|
2018-11-20 18:29:29 +07:00
|
|
|
iwl_fw_dbg_buffer_allocation(struct iwl_fw_runtime *fwrt, u32 size)
|
2018-06-13 19:19:47 +07:00
|
|
|
{
|
|
|
|
struct iwl_trans *trans = fwrt->trans;
|
|
|
|
void *virtual_addr = NULL;
|
|
|
|
dma_addr_t phys_addr;
|
|
|
|
|
2018-11-20 18:29:29 +07:00
|
|
|
if (WARN_ON_ONCE(trans->num_blocks == ARRAY_SIZE(trans->fw_mon)))
|
2018-06-13 19:19:47 +07:00
|
|
|
return;
|
|
|
|
|
2018-11-26 16:19:00 +07:00
|
|
|
virtual_addr =
|
|
|
|
dma_alloc_coherent(fwrt->trans->dev, size, &phys_addr,
|
|
|
|
GFP_KERNEL | __GFP_NOWARN | __GFP_ZERO |
|
|
|
|
__GFP_COMP);
|
2018-06-13 19:19:47 +07:00
|
|
|
|
|
|
|
/* TODO: alloc fragments if needed */
|
|
|
|
if (!virtual_addr)
|
|
|
|
IWL_ERR(fwrt, "Failed to allocate debug memory\n");
|
|
|
|
|
|
|
|
trans->fw_mon[trans->num_blocks].block = virtual_addr;
|
|
|
|
trans->fw_mon[trans->num_blocks].physical = phys_addr;
|
|
|
|
trans->fw_mon[trans->num_blocks].size = size;
|
|
|
|
trans->num_blocks++;
|
|
|
|
|
|
|
|
IWL_DEBUG_FW(trans, "Allocated debug block of size %d\n", size);
|
2018-11-20 18:29:29 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void iwl_fw_dbg_buffer_apply(struct iwl_fw_runtime *fwrt,
|
|
|
|
struct iwl_fw_ini_allocation_data *alloc)
|
|
|
|
{
|
|
|
|
struct iwl_trans *trans = fwrt->trans;
|
|
|
|
struct iwl_ldbg_config_cmd ldbg_cmd = {
|
|
|
|
.type = cpu_to_le32(BUFFER_ALLOCATION),
|
|
|
|
};
|
|
|
|
struct iwl_buffer_allocation_cmd *cmd = &ldbg_cmd.buffer_allocation;
|
|
|
|
struct iwl_host_cmd hcmd = {
|
|
|
|
.id = LDBG_CONFIG_CMD,
|
|
|
|
.flags = CMD_ASYNC,
|
|
|
|
.data[0] = &ldbg_cmd,
|
|
|
|
.len[0] = sizeof(ldbg_cmd),
|
|
|
|
};
|
|
|
|
int block_idx = trans->num_blocks;
|
|
|
|
|
|
|
|
if (le32_to_cpu(alloc->tlv.buffer_location) !=
|
|
|
|
IWL_FW_INI_LOCATION_DRAM_PATH)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!alloc->is_alloc) {
|
|
|
|
iwl_fw_dbg_buffer_allocation(fwrt,
|
|
|
|
le32_to_cpu(alloc->tlv.size));
|
|
|
|
if (block_idx == trans->num_blocks)
|
|
|
|
return;
|
|
|
|
alloc->is_alloc = 1;
|
|
|
|
}
|
2018-06-13 19:19:47 +07:00
|
|
|
|
|
|
|
/* First block is assigned via registers / context info */
|
|
|
|
if (trans->num_blocks == 1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
cmd->num_frags = cpu_to_le32(1);
|
2018-11-20 18:29:29 +07:00
|
|
|
cmd->fragments[0].address =
|
|
|
|
cpu_to_le64(trans->fw_mon[block_idx].physical);
|
|
|
|
cmd->fragments[0].size = alloc->tlv.size;
|
|
|
|
cmd->allocation_id = alloc->tlv.allocation_id;
|
|
|
|
cmd->buffer_location = alloc->tlv.buffer_location;
|
2018-06-13 19:19:47 +07:00
|
|
|
|
|
|
|
iwl_trans_send_cmd(trans, &hcmd);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void iwl_fw_dbg_send_hcmd(struct iwl_fw_runtime *fwrt,
|
|
|
|
struct iwl_ucode_tlv *tlv)
|
|
|
|
{
|
|
|
|
struct iwl_fw_ini_hcmd_tlv *hcmd_tlv = (void *)&tlv->data[0];
|
|
|
|
struct iwl_fw_ini_hcmd *data = &hcmd_tlv->hcmd;
|
|
|
|
u16 len = le32_to_cpu(tlv->length) - sizeof(*hcmd_tlv);
|
|
|
|
|
|
|
|
struct iwl_host_cmd hcmd = {
|
|
|
|
.id = WIDE_ID(data->group, data->id),
|
|
|
|
.len = { len, },
|
|
|
|
.data = { data->data, },
|
|
|
|
};
|
|
|
|
|
|
|
|
iwl_trans_send_cmd(fwrt->trans, &hcmd);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void iwl_fw_dbg_update_regions(struct iwl_fw_runtime *fwrt,
|
|
|
|
struct iwl_fw_ini_region_tlv *tlv,
|
|
|
|
bool ext, enum iwl_fw_ini_apply_point pnt)
|
|
|
|
{
|
|
|
|
void *iter = (void *)tlv->region_config;
|
|
|
|
int i, size = le32_to_cpu(tlv->num_regions);
|
|
|
|
|
|
|
|
for (i = 0; i < size; i++) {
|
2018-11-20 18:29:29 +07:00
|
|
|
struct iwl_fw_ini_region_cfg *reg = iter, **active;
|
2018-06-13 19:19:47 +07:00
|
|
|
int id = le32_to_cpu(reg->region_id);
|
2018-12-05 19:02:53 +07:00
|
|
|
u32 type = le32_to_cpu(reg->region_type);
|
2018-06-13 19:19:47 +07:00
|
|
|
|
2018-09-06 14:03:22 +07:00
|
|
|
if (WARN(id >= ARRAY_SIZE(fwrt->dump.active_regs),
|
|
|
|
"Invalid region id %d for apply point %d\n", id, pnt))
|
2018-06-13 19:19:47 +07:00
|
|
|
break;
|
|
|
|
|
|
|
|
active = &fwrt->dump.active_regs[id];
|
|
|
|
|
2018-11-20 18:29:29 +07:00
|
|
|
if (*active)
|
|
|
|
IWL_WARN(fwrt->trans, "region TLV %d override\n", id);
|
2018-06-13 19:19:47 +07:00
|
|
|
|
|
|
|
IWL_DEBUG_FW(fwrt,
|
|
|
|
"%s: apply point %d, activating region ID %d\n",
|
|
|
|
__func__, pnt, id);
|
|
|
|
|
2018-11-20 18:29:29 +07:00
|
|
|
*active = reg;
|
2018-06-13 19:19:47 +07:00
|
|
|
|
2018-12-05 19:02:53 +07:00
|
|
|
if (type == IWL_FW_INI_REGION_TXF ||
|
|
|
|
type == IWL_FW_INI_REGION_RXF)
|
|
|
|
iter += le32_to_cpu(reg->fifos.num_of_registers) *
|
|
|
|
sizeof(__le32);
|
|
|
|
else if (type != IWL_FW_INI_REGION_DRAM_BUFFER)
|
|
|
|
iter += le32_to_cpu(reg->internal.num_of_ranges) *
|
2018-11-26 15:15:35 +07:00
|
|
|
sizeof(__le32);
|
2018-06-13 19:19:47 +07:00
|
|
|
|
|
|
|
iter += sizeof(*reg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void iwl_fw_dbg_update_triggers(struct iwl_fw_runtime *fwrt,
|
|
|
|
struct iwl_fw_ini_trigger_tlv *tlv,
|
|
|
|
bool ext,
|
|
|
|
enum iwl_fw_ini_apply_point apply_point)
|
|
|
|
{
|
|
|
|
int i, size = le32_to_cpu(tlv->num_triggers);
|
|
|
|
void *iter = (void *)tlv->trigger_config;
|
|
|
|
|
|
|
|
for (i = 0; i < size; i++) {
|
|
|
|
struct iwl_fw_ini_trigger *trig = iter;
|
|
|
|
struct iwl_fw_ini_active_triggers *active;
|
|
|
|
int id = le32_to_cpu(trig->trigger_id);
|
|
|
|
u32 num;
|
|
|
|
|
|
|
|
if (WARN_ON(id >= ARRAY_SIZE(fwrt->dump.active_trigs)))
|
|
|
|
break;
|
|
|
|
|
|
|
|
active = &fwrt->dump.active_trigs[id];
|
|
|
|
|
|
|
|
if (active->apply_point != apply_point) {
|
|
|
|
active->conf = NULL;
|
|
|
|
active->conf_ext = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
num = le32_to_cpu(trig->num_regions);
|
|
|
|
|
|
|
|
if (ext && active->apply_point == apply_point) {
|
|
|
|
num += le32_to_cpu(active->conf->num_regions);
|
|
|
|
if (trig->ignore_default) {
|
|
|
|
active->conf_ext = active->conf;
|
|
|
|
active->conf = trig;
|
|
|
|
} else {
|
|
|
|
active->conf_ext = trig;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
active->conf = trig;
|
|
|
|
}
|
|
|
|
|
2018-06-21 13:42:12 +07:00
|
|
|
/* Since zero means infinity - just set to -1 */
|
|
|
|
if (!le32_to_cpu(trig->occurrences))
|
|
|
|
trig->occurrences = cpu_to_le32(-1);
|
|
|
|
if (!le32_to_cpu(trig->ignore_consec))
|
|
|
|
trig->ignore_consec = cpu_to_le32(-1);
|
|
|
|
|
2018-06-13 19:19:47 +07:00
|
|
|
iter += sizeof(*trig) +
|
|
|
|
le32_to_cpu(trig->num_regions) * sizeof(__le32);
|
|
|
|
|
|
|
|
active->active = num;
|
|
|
|
active->apply_point = apply_point;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void _iwl_fw_dbg_apply_point(struct iwl_fw_runtime *fwrt,
|
|
|
|
struct iwl_apply_point_data *data,
|
|
|
|
enum iwl_fw_ini_apply_point pnt,
|
|
|
|
bool ext)
|
|
|
|
{
|
|
|
|
void *iter = data->data;
|
|
|
|
|
|
|
|
while (iter && iter < data->data + data->size) {
|
|
|
|
struct iwl_ucode_tlv *tlv = iter;
|
|
|
|
void *ini_tlv = (void *)tlv->data;
|
|
|
|
u32 type = le32_to_cpu(tlv->type);
|
|
|
|
|
|
|
|
switch (type) {
|
2018-11-20 18:29:29 +07:00
|
|
|
case IWL_UCODE_TLV_TYPE_BUFFER_ALLOCATION: {
|
|
|
|
struct iwl_fw_ini_allocation_data *buf_alloc = ini_tlv;
|
|
|
|
|
|
|
|
iwl_fw_dbg_buffer_apply(fwrt, ini_tlv);
|
|
|
|
iter += sizeof(buf_alloc->is_alloc);
|
2018-06-13 19:19:47 +07:00
|
|
|
break;
|
2018-11-20 18:29:29 +07:00
|
|
|
}
|
2018-06-13 19:19:47 +07:00
|
|
|
case IWL_UCODE_TLV_TYPE_HCMD:
|
|
|
|
if (pnt < IWL_FW_INI_APPLY_AFTER_ALIVE) {
|
|
|
|
IWL_ERR(fwrt,
|
|
|
|
"Invalid apply point %x for host command\n",
|
|
|
|
pnt);
|
|
|
|
goto next;
|
|
|
|
}
|
|
|
|
iwl_fw_dbg_send_hcmd(fwrt, tlv);
|
|
|
|
break;
|
|
|
|
case IWL_UCODE_TLV_TYPE_REGIONS:
|
|
|
|
iwl_fw_dbg_update_regions(fwrt, ini_tlv, ext, pnt);
|
|
|
|
break;
|
|
|
|
case IWL_UCODE_TLV_TYPE_TRIGGERS:
|
|
|
|
iwl_fw_dbg_update_triggers(fwrt, ini_tlv, ext, pnt);
|
|
|
|
break;
|
|
|
|
case IWL_UCODE_TLV_TYPE_DEBUG_FLOW:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
WARN_ONCE(1, "Invalid TLV %x for apply point\n", type);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
next:
|
|
|
|
iter += sizeof(*tlv) + le32_to_cpu(tlv->length);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void iwl_fw_dbg_apply_point(struct iwl_fw_runtime *fwrt,
|
|
|
|
enum iwl_fw_ini_apply_point apply_point)
|
|
|
|
{
|
|
|
|
void *data = &fwrt->trans->apply_points[apply_point];
|
2018-11-20 18:29:29 +07:00
|
|
|
int i;
|
|
|
|
|
|
|
|
if (apply_point == IWL_FW_INI_APPLY_EARLY) {
|
|
|
|
for (i = 0; i < IWL_FW_INI_MAX_REGION_ID; i++)
|
|
|
|
fwrt->dump.active_regs[i] = NULL;
|
|
|
|
}
|
2018-06-13 19:19:47 +07:00
|
|
|
|
|
|
|
_iwl_fw_dbg_apply_point(fwrt, data, apply_point, false);
|
|
|
|
|
|
|
|
data = &fwrt->trans->apply_points_ext[apply_point];
|
|
|
|
_iwl_fw_dbg_apply_point(fwrt, data, apply_point, true);
|
|
|
|
}
|
|
|
|
IWL_EXPORT_SYMBOL(iwl_fw_dbg_apply_point);
|
2018-11-12 18:27:51 +07:00
|
|
|
|
|
|
|
void iwl_fwrt_stop_device(struct iwl_fw_runtime *fwrt)
|
|
|
|
{
|
|
|
|
/* if the wait event timeout elapses instead of wake up then
|
|
|
|
* the driver did not receive NMI interrupt and can not assume the FW
|
|
|
|
* is halted
|
|
|
|
*/
|
|
|
|
int ret = wait_event_timeout(fwrt->trans->fw_halt_waitq,
|
|
|
|
!test_bit(STATUS_FW_WAIT_DUMP,
|
|
|
|
&fwrt->trans->status),
|
|
|
|
msecs_to_jiffies(2000));
|
|
|
|
if (!ret) {
|
|
|
|
/* failed to receive NMI interrupt, assuming the FW is stuck */
|
|
|
|
set_bit(STATUS_FW_ERROR, &fwrt->trans->status);
|
|
|
|
|
|
|
|
clear_bit(STATUS_FW_WAIT_DUMP, &fwrt->trans->status);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Assuming the op mode mutex is held at this point */
|
|
|
|
iwl_fw_dbg_collect_sync(fwrt);
|
|
|
|
|
|
|
|
iwl_trans_stop_device(fwrt->trans);
|
|
|
|
}
|
|
|
|
IWL_EXPORT_SYMBOL(iwl_fwrt_stop_device);
|