mhi: core: change logs to print MHI_STATEs in text
Instead of printing enum index convert MHI_STATE enum to text representation for easier interpretation of debug logs. CRs-Fixed: 1012249 Change-Id: I97a9a7ff293c739531d8197334a0f0a35bf20419 Signed-off-by: Sujeev Dias <sdias@codeaurora.org>
This commit is contained in:
parent
78f1bef7e5
commit
fc63288a51
5 changed files with 92 additions and 49 deletions
|
@ -520,8 +520,8 @@ static inline int mhi_queue_tre(struct mhi_device_ctxt
|
|||
}
|
||||
} else {
|
||||
mhi_log(MHI_MSG_VERBOSE,
|
||||
"Wakeup, pending data state %d chan state %d\n",
|
||||
mhi_dev_ctxt->mhi_state,
|
||||
"Wakeup, pending data state %s chan state %d\n",
|
||||
TO_MHI_STATE_STR(mhi_dev_ctxt->mhi_state),
|
||||
chan_ctxt->mhi_chan_state);
|
||||
ret_val = 0;
|
||||
}
|
||||
|
@ -766,10 +766,9 @@ int mhi_send_cmd(struct mhi_device_ctxt *mhi_dev_ctxt,
|
|||
}
|
||||
|
||||
mhi_log(MHI_MSG_INFO,
|
||||
"Entered, MHI state %d dev_exec_env %d chan %d cmd %d\n",
|
||||
mhi_dev_ctxt->mhi_state,
|
||||
mhi_dev_ctxt->dev_exec_env,
|
||||
chan, cmd);
|
||||
"Entered, MHI state %s dev_exec_env %d chan %d cmd %d\n",
|
||||
TO_MHI_STATE_STR(mhi_dev_ctxt->mhi_state),
|
||||
mhi_dev_ctxt->dev_exec_env, chan, cmd);
|
||||
mhi_log(MHI_MSG_INFO, "Getting Reference %d", chan);
|
||||
pm_runtime_get(&mhi_dev_ctxt->dev_info->pcie_device->dev);
|
||||
/*
|
||||
|
|
|
@ -46,8 +46,8 @@ int mhi_pci_suspend(struct device *dev)
|
|||
|
||||
if (NULL == mhi_dev_ctxt)
|
||||
return -EINVAL;
|
||||
mhi_log(MHI_MSG_INFO, "Entered, MHI state %d\n",
|
||||
mhi_dev_ctxt->mhi_state);
|
||||
mhi_log(MHI_MSG_INFO, "Entered, MHI state %s\n",
|
||||
TO_MHI_STATE_STR(mhi_dev_ctxt->mhi_state));
|
||||
atomic_set(&mhi_dev_ctxt->flags.pending_resume, 1);
|
||||
|
||||
r = mhi_initiate_m3(mhi_dev_ctxt);
|
||||
|
@ -115,7 +115,8 @@ int mhi_pci_resume(struct device *dev)
|
|||
break;
|
||||
default:
|
||||
mhi_log(MHI_MSG_INFO,
|
||||
"Wait complete state: %d\n", mhi_dev_ctxt->mhi_state);
|
||||
"Wait complete state: %s\n",
|
||||
TO_MHI_STATE_STR(mhi_dev_ctxt->mhi_state));
|
||||
r = 0;
|
||||
}
|
||||
exit:
|
||||
|
@ -181,8 +182,8 @@ ssize_t sysfs_init_m0(struct device *dev, struct device_attribute *attr,
|
|||
}
|
||||
mhi_initiate_m0(mhi_dev_ctxt);
|
||||
mhi_log(MHI_MSG_CRITICAL,
|
||||
"Current mhi_state = 0x%x\n",
|
||||
mhi_dev_ctxt->mhi_state);
|
||||
"Current mhi_state = %s\n",
|
||||
TO_MHI_STATE_STR(mhi_dev_ctxt->mhi_state));
|
||||
|
||||
return count;
|
||||
}
|
||||
|
|
|
@ -17,6 +17,29 @@
|
|||
#include <linux/platform_device.h>
|
||||
#include <linux/pm_runtime.h>
|
||||
|
||||
static const char *state_transition_str(enum STATE_TRANSITION state)
|
||||
{
|
||||
static const char * const mhi_states_transition_str[] = {
|
||||
"RESET",
|
||||
"READY",
|
||||
"M0",
|
||||
"M1",
|
||||
"M2",
|
||||
"M3",
|
||||
"BHI",
|
||||
"SBL",
|
||||
"AMSS",
|
||||
"LINK_DOWN",
|
||||
"WAKE"
|
||||
};
|
||||
|
||||
if (state == STATE_TRANSITION_SYS_ERR)
|
||||
return "SYS_ERR";
|
||||
|
||||
return (state <= STATE_TRANSITION_WAKE) ?
|
||||
mhi_states_transition_str[state] : "Invalid";
|
||||
}
|
||||
|
||||
static inline void mhi_set_m_state(struct mhi_device_ctxt *mhi_dev_ctxt,
|
||||
enum MHI_STATE new_state)
|
||||
{
|
||||
|
@ -150,8 +173,9 @@ static int process_m0_transition(
|
|||
"Transitioning from M1.\n");
|
||||
} else {
|
||||
mhi_log(MHI_MSG_INFO,
|
||||
"MHI State %d link state %d. Quitting\n",
|
||||
mhi_dev_ctxt->mhi_state, mhi_dev_ctxt->flags.link_up);
|
||||
"MHI State %s link state %d. Quitting\n",
|
||||
TO_MHI_STATE_STR(mhi_dev_ctxt->mhi_state),
|
||||
mhi_dev_ctxt->flags.link_up);
|
||||
}
|
||||
|
||||
read_lock_irqsave(&mhi_dev_ctxt->xfer_lock, flags);
|
||||
|
@ -196,8 +220,8 @@ static int process_m1_transition(
|
|||
int r = 0;
|
||||
|
||||
mhi_log(MHI_MSG_INFO,
|
||||
"Processing M1 state transition from state %d\n",
|
||||
mhi_dev_ctxt->mhi_state);
|
||||
"Processing M1 state transition from state %s\n",
|
||||
TO_MHI_STATE_STR(mhi_dev_ctxt->mhi_state));
|
||||
|
||||
write_lock_irqsave(&mhi_dev_ctxt->xfer_lock, flags);
|
||||
if (!mhi_dev_ctxt->flags.pending_M3) {
|
||||
|
@ -444,8 +468,8 @@ static int process_reset_transition(
|
|||
STATE_TRANSITION_RESET);
|
||||
if (0 != r)
|
||||
mhi_log(MHI_MSG_CRITICAL,
|
||||
"Failed to initiate 0x%x state trans\n",
|
||||
STATE_TRANSITION_RESET);
|
||||
"Failed to initiate %s state trans\n",
|
||||
state_transition_str(STATE_TRANSITION_RESET));
|
||||
break;
|
||||
default:
|
||||
mhi_log(MHI_MSG_CRITICAL,
|
||||
|
@ -475,8 +499,8 @@ static int process_reset_transition(
|
|||
STATE_TRANSITION_READY);
|
||||
if (0 != r)
|
||||
mhi_log(MHI_MSG_CRITICAL,
|
||||
"Failed to initiate 0x%x state trans\n",
|
||||
STATE_TRANSITION_READY);
|
||||
"Failed to initiate %s state trans\n",
|
||||
state_transition_str(STATE_TRANSITION_READY));
|
||||
return r;
|
||||
}
|
||||
|
||||
|
@ -636,8 +660,8 @@ int mhi_trigger_reset(struct mhi_device_ctxt *mhi_dev_ctxt)
|
|||
STATE_TRANSITION_RESET);
|
||||
if (0 != r)
|
||||
mhi_log(MHI_MSG_CRITICAL,
|
||||
"Failed to initiate 0x%x state trans ret %d\n",
|
||||
STATE_TRANSITION_RESET, r);
|
||||
"Failed to initiate %s state trans ret %d\n",
|
||||
state_transition_str(STATE_TRANSITION_RESET), r);
|
||||
mhi_log(MHI_MSG_INFO, "Exiting\n");
|
||||
return r;
|
||||
}
|
||||
|
@ -648,8 +672,8 @@ static int process_stt_work_item(
|
|||
{
|
||||
int r = 0;
|
||||
|
||||
mhi_log(MHI_MSG_INFO, "Transitioning to %d\n",
|
||||
(int)cur_work_item);
|
||||
mhi_log(MHI_MSG_INFO, "Transitioning to %s\n",
|
||||
state_transition_str(cur_work_item));
|
||||
trace_mhi_state(cur_work_item);
|
||||
switch (cur_work_item) {
|
||||
case STATE_TRANSITION_BHI:
|
||||
|
@ -689,7 +713,8 @@ static int process_stt_work_item(
|
|||
break;
|
||||
default:
|
||||
mhi_log(MHI_MSG_ERROR,
|
||||
"Unrecongized state: %d\n", cur_work_item);
|
||||
"Unrecongized state: %s\n",
|
||||
state_transition_str(cur_work_item));
|
||||
break;
|
||||
}
|
||||
return r;
|
||||
|
@ -762,8 +787,8 @@ int mhi_init_state_transition(struct mhi_device_ctxt *mhi_dev_ctxt,
|
|||
|
||||
BUG_ON(nr_avail_work_items <= 0);
|
||||
mhi_log(MHI_MSG_VERBOSE,
|
||||
"Processing state transition %x\n",
|
||||
new_state);
|
||||
"Processing state transition %s\n",
|
||||
state_transition_str(new_state));
|
||||
*(enum STATE_TRANSITION *)stt_ring->wp = new_state;
|
||||
r = ctxt_add_element(stt_ring, (void **)&cur_work_item);
|
||||
BUG_ON(r);
|
||||
|
@ -778,13 +803,14 @@ int mhi_initiate_m0(struct mhi_device_ctxt *mhi_dev_ctxt)
|
|||
unsigned long flags;
|
||||
|
||||
mhi_log(MHI_MSG_INFO,
|
||||
"Entered MHI state %d, Pending M0 %d Pending M3 %d\n",
|
||||
mhi_dev_ctxt->mhi_state, mhi_dev_ctxt->flags.pending_M0,
|
||||
"Entered MHI state %s, Pending M0 %d Pending M3 %d\n",
|
||||
TO_MHI_STATE_STR(mhi_dev_ctxt->mhi_state),
|
||||
mhi_dev_ctxt->flags.pending_M0,
|
||||
mhi_dev_ctxt->flags.pending_M3);
|
||||
mutex_lock(&mhi_dev_ctxt->pm_lock);
|
||||
mhi_log(MHI_MSG_INFO,
|
||||
"Waiting for M0 M1 or M3. Currently %d...\n",
|
||||
mhi_dev_ctxt->mhi_state);
|
||||
"Waiting for M0 M1 or M3. Currently %s...\n",
|
||||
TO_MHI_STATE_STR(mhi_dev_ctxt->mhi_state));
|
||||
|
||||
r = wait_event_interruptible_timeout(*mhi_dev_ctxt->mhi_ev_wq.m3_event,
|
||||
mhi_dev_ctxt->mhi_state == MHI_STATE_M3 ||
|
||||
|
@ -794,8 +820,8 @@ int mhi_initiate_m0(struct mhi_device_ctxt *mhi_dev_ctxt)
|
|||
switch (r) {
|
||||
case 0:
|
||||
mhi_log(MHI_MSG_CRITICAL,
|
||||
"Timeout: State %d after %d ms\n",
|
||||
mhi_dev_ctxt->mhi_state,
|
||||
"Timeout: State %s after %d ms\n",
|
||||
TO_MHI_STATE_STR(mhi_dev_ctxt->mhi_state),
|
||||
MHI_MAX_SUSPEND_TIMEOUT);
|
||||
mhi_dev_ctxt->counters.m0_event_timeouts++;
|
||||
r = -ETIME;
|
||||
|
@ -806,7 +832,8 @@ int mhi_initiate_m0(struct mhi_device_ctxt *mhi_dev_ctxt)
|
|||
goto exit;
|
||||
default:
|
||||
mhi_log(MHI_MSG_INFO,
|
||||
"Wait complete state: %d\n", mhi_dev_ctxt->mhi_state);
|
||||
"Wait complete state: %s\n",
|
||||
TO_MHI_STATE_STR(mhi_dev_ctxt->mhi_state));
|
||||
r = 0;
|
||||
break;
|
||||
}
|
||||
|
@ -814,8 +841,8 @@ int mhi_initiate_m0(struct mhi_device_ctxt *mhi_dev_ctxt)
|
|||
mhi_dev_ctxt->mhi_state == MHI_STATE_M1) {
|
||||
mhi_assert_device_wake(mhi_dev_ctxt);
|
||||
mhi_log(MHI_MSG_INFO,
|
||||
"MHI state %d, done\n",
|
||||
mhi_dev_ctxt->mhi_state);
|
||||
"MHI state %s, done\n",
|
||||
TO_MHI_STATE_STR(mhi_dev_ctxt->mhi_state));
|
||||
goto exit;
|
||||
} else {
|
||||
if (0 != mhi_turn_on_pcie_link(mhi_dev_ctxt)) {
|
||||
|
@ -864,8 +891,9 @@ int mhi_initiate_m3(struct mhi_device_ctxt *mhi_dev_ctxt)
|
|||
int r = 0, abort_m3 = 0;
|
||||
|
||||
mhi_log(MHI_MSG_INFO,
|
||||
"Entered MHI state %d, Pending M0 %d Pending M3 %d\n",
|
||||
mhi_dev_ctxt->mhi_state, mhi_dev_ctxt->flags.pending_M0,
|
||||
"Entered MHI state %s, Pending M0 %d Pending M3 %d\n",
|
||||
TO_MHI_STATE_STR(mhi_dev_ctxt->mhi_state),
|
||||
mhi_dev_ctxt->flags.pending_M0,
|
||||
mhi_dev_ctxt->flags.pending_M3);
|
||||
mutex_lock(&mhi_dev_ctxt->pm_lock);
|
||||
switch (mhi_dev_ctxt->mhi_state) {
|
||||
|
@ -906,8 +934,8 @@ int mhi_initiate_m3(struct mhi_device_ctxt *mhi_dev_ctxt)
|
|||
break;
|
||||
case MHI_STATE_M3:
|
||||
mhi_log(MHI_MSG_INFO,
|
||||
"MHI state %d, link state %d.\n",
|
||||
mhi_dev_ctxt->mhi_state,
|
||||
"MHI state %s, link state %d.\n",
|
||||
TO_MHI_STATE_STR(mhi_dev_ctxt->mhi_state),
|
||||
mhi_dev_ctxt->flags.link_up);
|
||||
if (mhi_dev_ctxt->flags.link_up)
|
||||
r = -EAGAIN;
|
||||
|
@ -916,8 +944,8 @@ int mhi_initiate_m3(struct mhi_device_ctxt *mhi_dev_ctxt)
|
|||
goto exit;
|
||||
default:
|
||||
mhi_log(MHI_MSG_INFO,
|
||||
"MHI state %d, link state %d.\n",
|
||||
mhi_dev_ctxt->mhi_state,
|
||||
"MHI state %s, link state %d.\n",
|
||||
TO_MHI_STATE_STR(mhi_dev_ctxt->mhi_state),
|
||||
mhi_dev_ctxt->flags.link_up);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -34,6 +34,17 @@ MODULE_PARM_DESC(mhi_msg_lvl, "dbg lvl");
|
|||
module_param(mhi_ipc_log_lvl, uint, S_IRUGO | S_IWUSR);
|
||||
MODULE_PARM_DESC(mhi_ipc_log_lvl, "dbg lvl");
|
||||
|
||||
const char * const mhi_states_str[MHI_STATE_LIMIT] = {
|
||||
"RESET",
|
||||
"READY",
|
||||
"M0",
|
||||
"M1",
|
||||
"M2",
|
||||
"M3",
|
||||
"BHI",
|
||||
"SYS_ERR",
|
||||
};
|
||||
|
||||
static ssize_t mhi_dbgfs_chan_read(struct file *fp, char __user *buf,
|
||||
size_t count, loff_t *offp)
|
||||
{
|
||||
|
@ -225,9 +236,9 @@ static ssize_t mhi_dbgfs_state_read(struct file *fp, char __user *buf,
|
|||
amnt_copied =
|
||||
scnprintf(mhi_dev_ctxt->chan_info,
|
||||
MHI_LOG_SIZE,
|
||||
"%s %u %s %d %s %d %s %d %s %d %s %d %s %d %s %d %s %d %s %d %s %d, %s, %d, %s %d\n",
|
||||
"%s %s %s %d %s %d %s %d %s %d %s %d %s %d %s %d %s %d %s %d %s %d, %s, %d, %s %d\n",
|
||||
"Our State:",
|
||||
mhi_dev_ctxt->mhi_state,
|
||||
TO_MHI_STATE_STR(mhi_dev_ctxt->mhi_state),
|
||||
"M0->M1:",
|
||||
mhi_dev_ctxt->counters.m0_m1,
|
||||
"M0<-M1:",
|
||||
|
|
|
@ -46,6 +46,10 @@ extern void *mhi_ipc_log;
|
|||
"[%s] " _msg, __func__, ##__VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
extern const char * const mhi_states_str[MHI_STATE_LIMIT];
|
||||
#define TO_MHI_STATE_STR(state) (((state) >= MHI_STATE_LIMIT) ? \
|
||||
"INVALID_STATE" : mhi_states_str[state])
|
||||
|
||||
irqreturn_t mhi_msi_handlr(int msi_number, void *dev_id);
|
||||
|
||||
struct mhi_meminfo {
|
||||
|
|
Loading…
Add table
Reference in a new issue