Commit eeef0168 authored by Miri Korenblit's avatar Miri Korenblit Committed by Johannes Berg

wifi: iwlwifi: fw: send marker cmd before suspend cmd

This is needed to sync the times in the FW and driver logs
Signed-off-by: default avatarMiri Korenblit <miriam.rachel.korenblit@intel.com>
Signed-off-by: default avatarGregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20230620125813.9c84322c41b5.Id13816b3ece103f88514a7523b22bb2b9dcc8ab7@changeidSigned-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent 26aa35e2
// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
/*
* Copyright (C) 2005-2014, 2018-2021 Intel Corporation
* Copyright (C) 2005-2014, 2018-2023 Intel Corporation
* Copyright (C) 2013-2015 Intel Mobile Communications GmbH
* Copyright (C) 2015-2017 Intel Deutschland GmbH
*/
......@@ -3154,6 +3154,51 @@ static int iwl_fw_dbg_restart_recording(struct iwl_trans *trans,
return 0;
}
int iwl_fw_send_timestamp_marker_cmd(struct iwl_fw_runtime *fwrt)
{
struct iwl_mvm_marker marker = {
.dw_len = sizeof(struct iwl_mvm_marker) / 4,
.marker_id = MARKER_ID_SYNC_CLOCK,
};
struct iwl_host_cmd hcmd = {
.flags = CMD_ASYNC,
.id = WIDE_ID(LONG_GROUP, MARKER_CMD),
.dataflags = {},
};
struct iwl_mvm_marker_rsp *resp;
int cmd_ver = iwl_fw_lookup_cmd_ver(fwrt->fw,
WIDE_ID(LONG_GROUP, MARKER_CMD),
IWL_FW_CMD_VER_UNKNOWN);
int ret;
if (cmd_ver == 1) {
/* the real timestamp is taken from the ftrace clock
* this is for finding the match between fw and kernel logs
*/
marker.timestamp = cpu_to_le64(fwrt->timestamp.seq++);
} else if (cmd_ver == 2) {
marker.timestamp = cpu_to_le64(ktime_get_boottime_ns());
} else {
IWL_DEBUG_INFO(fwrt,
"Invalid version of Marker CMD. Ver = %d\n",
cmd_ver);
return -EINVAL;
}
hcmd.data[0] = &marker;
hcmd.len[0] = sizeof(marker);
ret = iwl_trans_send_cmd(fwrt->trans, &hcmd);
if (cmd_ver > 1 && hcmd.resp_pkt) {
resp = (void *)hcmd.resp_pkt->data;
IWL_DEBUG_INFO(fwrt, "FW GP2 time: %u\n",
le32_to_cpu(resp->gp2));
}
return ret;
}
void iwl_fw_dbg_stop_restart_recording(struct iwl_fw_runtime *fwrt,
struct iwl_fw_dbg_params *params,
bool stop)
......@@ -3164,12 +3209,15 @@ void iwl_fw_dbg_stop_restart_recording(struct iwl_fw_runtime *fwrt,
return;
if (fw_has_capa(&fwrt->fw->ucode_capa,
IWL_UCODE_TLV_CAPA_DBG_SUSPEND_RESUME_CMD_SUPP))
IWL_UCODE_TLV_CAPA_DBG_SUSPEND_RESUME_CMD_SUPP)) {
if (stop)
iwl_fw_send_timestamp_marker_cmd(fwrt);
ret = iwl_fw_dbg_suspend_resume_hcmd(fwrt->trans, stop);
else if (stop)
} else if (stop) {
iwl_fw_dbg_stop_recording(fwrt->trans, params);
else
} else {
ret = iwl_fw_dbg_restart_recording(fwrt->trans, params);
}
#ifdef CONFIG_IWLWIFI_DEBUGFS
if (!ret) {
if (stop)
......
......@@ -227,6 +227,8 @@ static inline void iwl_fw_flush_dumps(struct iwl_fw_runtime *fwrt)
flush_delayed_work(&fwrt->dump.wks[i].wk);
}
int iwl_fw_send_timestamp_marker_cmd(struct iwl_fw_runtime *fwrt);
#ifdef CONFIG_IWLWIFI_DEBUGFS
static inline void iwl_fw_cancel_timestamp(struct iwl_fw_runtime *fwrt)
{
......
......@@ -123,28 +123,6 @@ static const struct file_operations iwl_dbgfs_##name##_ops = { \
#define FWRT_DEBUGFS_ADD_FILE(name, parent, mode) \
FWRT_DEBUGFS_ADD_FILE_ALIAS(#name, name, parent, mode)
static int iwl_fw_send_timestamp_marker_cmd(struct iwl_fw_runtime *fwrt)
{
struct iwl_mvm_marker marker = {
.dw_len = sizeof(struct iwl_mvm_marker) / 4,
.marker_id = MARKER_ID_SYNC_CLOCK,
/* the real timestamp is taken from the ftrace clock
* this is for finding the match between fw and kernel logs
*/
.timestamp = cpu_to_le64(fwrt->timestamp.seq++),
};
struct iwl_host_cmd hcmd = {
.id = MARKER_CMD,
.flags = CMD_ASYNC,
.data[0] = &marker,
.len[0] = sizeof(marker),
};
return iwl_trans_send_cmd(fwrt->trans, &hcmd);
}
static int iwl_dbgfs_enabled_severities_write(struct iwl_fw_runtime *fwrt,
char *buf, size_t count)
{
......
/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
/*
* Copyright (C) 2017 Intel Deutschland GmbH
* Copyright (C) 2018-2022 Intel Corporation
* Copyright (C) 2018-2023 Intel Corporation
*/
#ifndef __iwl_fw_runtime_h__
#define __iwl_fw_runtime_h__
......@@ -146,12 +146,14 @@ struct iwl_fw_runtime {
u32 umac_minor;
} fw_ver;
} dump;
#ifdef CONFIG_IWLWIFI_DEBUGFS
struct {
#ifdef CONFIG_IWLWIFI_DEBUGFS
struct delayed_work wk;
u32 delay;
#endif
u64 seq;
} timestamp;
#ifdef CONFIG_IWLWIFI_DEBUGFS
bool tpc_enabled;
#endif /* CONFIG_IWLWIFI_DEBUGFS */
#ifdef CONFIG_ACPI
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment