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:
Sujeev Dias 2016-05-16 16:05:52 -07:00
parent 78f1bef7e5
commit fc63288a51
5 changed files with 92 additions and 49 deletions

View file

@ -520,8 +520,8 @@ static inline int mhi_queue_tre(struct mhi_device_ctxt
} }
} else { } else {
mhi_log(MHI_MSG_VERBOSE, mhi_log(MHI_MSG_VERBOSE,
"Wakeup, pending data state %d chan state %d\n", "Wakeup, pending data state %s chan state %d\n",
mhi_dev_ctxt->mhi_state, TO_MHI_STATE_STR(mhi_dev_ctxt->mhi_state),
chan_ctxt->mhi_chan_state); chan_ctxt->mhi_chan_state);
ret_val = 0; ret_val = 0;
} }
@ -766,10 +766,9 @@ int mhi_send_cmd(struct mhi_device_ctxt *mhi_dev_ctxt,
} }
mhi_log(MHI_MSG_INFO, mhi_log(MHI_MSG_INFO,
"Entered, MHI state %d dev_exec_env %d chan %d cmd %d\n", "Entered, MHI state %s dev_exec_env %d chan %d cmd %d\n",
mhi_dev_ctxt->mhi_state, TO_MHI_STATE_STR(mhi_dev_ctxt->mhi_state),
mhi_dev_ctxt->dev_exec_env, mhi_dev_ctxt->dev_exec_env, chan, cmd);
chan, cmd);
mhi_log(MHI_MSG_INFO, "Getting Reference %d", chan); mhi_log(MHI_MSG_INFO, "Getting Reference %d", chan);
pm_runtime_get(&mhi_dev_ctxt->dev_info->pcie_device->dev); pm_runtime_get(&mhi_dev_ctxt->dev_info->pcie_device->dev);
/* /*

View file

@ -46,8 +46,8 @@ int mhi_pci_suspend(struct device *dev)
if (NULL == mhi_dev_ctxt) if (NULL == mhi_dev_ctxt)
return -EINVAL; return -EINVAL;
mhi_log(MHI_MSG_INFO, "Entered, MHI state %d\n", mhi_log(MHI_MSG_INFO, "Entered, MHI state %s\n",
mhi_dev_ctxt->mhi_state); TO_MHI_STATE_STR(mhi_dev_ctxt->mhi_state));
atomic_set(&mhi_dev_ctxt->flags.pending_resume, 1); atomic_set(&mhi_dev_ctxt->flags.pending_resume, 1);
r = mhi_initiate_m3(mhi_dev_ctxt); r = mhi_initiate_m3(mhi_dev_ctxt);
@ -115,7 +115,8 @@ int mhi_pci_resume(struct device *dev)
break; break;
default: default:
mhi_log(MHI_MSG_INFO, 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; r = 0;
} }
exit: exit:
@ -181,8 +182,8 @@ ssize_t sysfs_init_m0(struct device *dev, struct device_attribute *attr,
} }
mhi_initiate_m0(mhi_dev_ctxt); mhi_initiate_m0(mhi_dev_ctxt);
mhi_log(MHI_MSG_CRITICAL, mhi_log(MHI_MSG_CRITICAL,
"Current mhi_state = 0x%x\n", "Current mhi_state = %s\n",
mhi_dev_ctxt->mhi_state); TO_MHI_STATE_STR(mhi_dev_ctxt->mhi_state));
return count; return count;
} }

View file

@ -17,6 +17,29 @@
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/pm_runtime.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, static inline void mhi_set_m_state(struct mhi_device_ctxt *mhi_dev_ctxt,
enum MHI_STATE new_state) enum MHI_STATE new_state)
{ {
@ -150,8 +173,9 @@ static int process_m0_transition(
"Transitioning from M1.\n"); "Transitioning from M1.\n");
} else { } else {
mhi_log(MHI_MSG_INFO, mhi_log(MHI_MSG_INFO,
"MHI State %d link state %d. Quitting\n", "MHI State %s link state %d. Quitting\n",
mhi_dev_ctxt->mhi_state, mhi_dev_ctxt->flags.link_up); TO_MHI_STATE_STR(mhi_dev_ctxt->mhi_state),
mhi_dev_ctxt->flags.link_up);
} }
read_lock_irqsave(&mhi_dev_ctxt->xfer_lock, flags); read_lock_irqsave(&mhi_dev_ctxt->xfer_lock, flags);
@ -196,8 +220,8 @@ static int process_m1_transition(
int r = 0; int r = 0;
mhi_log(MHI_MSG_INFO, mhi_log(MHI_MSG_INFO,
"Processing M1 state transition from state %d\n", "Processing M1 state transition from state %s\n",
mhi_dev_ctxt->mhi_state); TO_MHI_STATE_STR(mhi_dev_ctxt->mhi_state));
write_lock_irqsave(&mhi_dev_ctxt->xfer_lock, flags); write_lock_irqsave(&mhi_dev_ctxt->xfer_lock, flags);
if (!mhi_dev_ctxt->flags.pending_M3) { if (!mhi_dev_ctxt->flags.pending_M3) {
@ -444,8 +468,8 @@ static int process_reset_transition(
STATE_TRANSITION_RESET); STATE_TRANSITION_RESET);
if (0 != r) if (0 != r)
mhi_log(MHI_MSG_CRITICAL, mhi_log(MHI_MSG_CRITICAL,
"Failed to initiate 0x%x state trans\n", "Failed to initiate %s state trans\n",
STATE_TRANSITION_RESET); state_transition_str(STATE_TRANSITION_RESET));
break; break;
default: default:
mhi_log(MHI_MSG_CRITICAL, mhi_log(MHI_MSG_CRITICAL,
@ -475,8 +499,8 @@ static int process_reset_transition(
STATE_TRANSITION_READY); STATE_TRANSITION_READY);
if (0 != r) if (0 != r)
mhi_log(MHI_MSG_CRITICAL, mhi_log(MHI_MSG_CRITICAL,
"Failed to initiate 0x%x state trans\n", "Failed to initiate %s state trans\n",
STATE_TRANSITION_READY); state_transition_str(STATE_TRANSITION_READY));
return r; return r;
} }
@ -636,8 +660,8 @@ int mhi_trigger_reset(struct mhi_device_ctxt *mhi_dev_ctxt)
STATE_TRANSITION_RESET); STATE_TRANSITION_RESET);
if (0 != r) if (0 != r)
mhi_log(MHI_MSG_CRITICAL, mhi_log(MHI_MSG_CRITICAL,
"Failed to initiate 0x%x state trans ret %d\n", "Failed to initiate %s state trans ret %d\n",
STATE_TRANSITION_RESET, r); state_transition_str(STATE_TRANSITION_RESET), r);
mhi_log(MHI_MSG_INFO, "Exiting\n"); mhi_log(MHI_MSG_INFO, "Exiting\n");
return r; return r;
} }
@ -648,8 +672,8 @@ static int process_stt_work_item(
{ {
int r = 0; int r = 0;
mhi_log(MHI_MSG_INFO, "Transitioning to %d\n", mhi_log(MHI_MSG_INFO, "Transitioning to %s\n",
(int)cur_work_item); state_transition_str(cur_work_item));
trace_mhi_state(cur_work_item); trace_mhi_state(cur_work_item);
switch (cur_work_item) { switch (cur_work_item) {
case STATE_TRANSITION_BHI: case STATE_TRANSITION_BHI:
@ -689,7 +713,8 @@ static int process_stt_work_item(
break; break;
default: default:
mhi_log(MHI_MSG_ERROR, mhi_log(MHI_MSG_ERROR,
"Unrecongized state: %d\n", cur_work_item); "Unrecongized state: %s\n",
state_transition_str(cur_work_item));
break; break;
} }
return r; 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); BUG_ON(nr_avail_work_items <= 0);
mhi_log(MHI_MSG_VERBOSE, mhi_log(MHI_MSG_VERBOSE,
"Processing state transition %x\n", "Processing state transition %s\n",
new_state); state_transition_str(new_state));
*(enum STATE_TRANSITION *)stt_ring->wp = new_state; *(enum STATE_TRANSITION *)stt_ring->wp = new_state;
r = ctxt_add_element(stt_ring, (void **)&cur_work_item); r = ctxt_add_element(stt_ring, (void **)&cur_work_item);
BUG_ON(r); BUG_ON(r);
@ -778,13 +803,14 @@ int mhi_initiate_m0(struct mhi_device_ctxt *mhi_dev_ctxt)
unsigned long flags; unsigned long flags;
mhi_log(MHI_MSG_INFO, mhi_log(MHI_MSG_INFO,
"Entered MHI state %d, Pending M0 %d Pending M3 %d\n", "Entered MHI state %s, Pending M0 %d Pending M3 %d\n",
mhi_dev_ctxt->mhi_state, mhi_dev_ctxt->flags.pending_M0, TO_MHI_STATE_STR(mhi_dev_ctxt->mhi_state),
mhi_dev_ctxt->flags.pending_M0,
mhi_dev_ctxt->flags.pending_M3); mhi_dev_ctxt->flags.pending_M3);
mutex_lock(&mhi_dev_ctxt->pm_lock); mutex_lock(&mhi_dev_ctxt->pm_lock);
mhi_log(MHI_MSG_INFO, mhi_log(MHI_MSG_INFO,
"Waiting for M0 M1 or M3. Currently %d...\n", "Waiting for M0 M1 or M3. Currently %s...\n",
mhi_dev_ctxt->mhi_state); TO_MHI_STATE_STR(mhi_dev_ctxt->mhi_state));
r = wait_event_interruptible_timeout(*mhi_dev_ctxt->mhi_ev_wq.m3_event, r = wait_event_interruptible_timeout(*mhi_dev_ctxt->mhi_ev_wq.m3_event,
mhi_dev_ctxt->mhi_state == MHI_STATE_M3 || 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) { switch (r) {
case 0: case 0:
mhi_log(MHI_MSG_CRITICAL, mhi_log(MHI_MSG_CRITICAL,
"Timeout: State %d after %d ms\n", "Timeout: State %s after %d ms\n",
mhi_dev_ctxt->mhi_state, TO_MHI_STATE_STR(mhi_dev_ctxt->mhi_state),
MHI_MAX_SUSPEND_TIMEOUT); MHI_MAX_SUSPEND_TIMEOUT);
mhi_dev_ctxt->counters.m0_event_timeouts++; mhi_dev_ctxt->counters.m0_event_timeouts++;
r = -ETIME; r = -ETIME;
@ -806,7 +832,8 @@ int mhi_initiate_m0(struct mhi_device_ctxt *mhi_dev_ctxt)
goto exit; goto exit;
default: default:
mhi_log(MHI_MSG_INFO, 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; r = 0;
break; 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_dev_ctxt->mhi_state == MHI_STATE_M1) {
mhi_assert_device_wake(mhi_dev_ctxt); mhi_assert_device_wake(mhi_dev_ctxt);
mhi_log(MHI_MSG_INFO, mhi_log(MHI_MSG_INFO,
"MHI state %d, done\n", "MHI state %s, done\n",
mhi_dev_ctxt->mhi_state); TO_MHI_STATE_STR(mhi_dev_ctxt->mhi_state));
goto exit; goto exit;
} else { } else {
if (0 != mhi_turn_on_pcie_link(mhi_dev_ctxt)) { 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; int r = 0, abort_m3 = 0;
mhi_log(MHI_MSG_INFO, mhi_log(MHI_MSG_INFO,
"Entered MHI state %d, Pending M0 %d Pending M3 %d\n", "Entered MHI state %s, Pending M0 %d Pending M3 %d\n",
mhi_dev_ctxt->mhi_state, mhi_dev_ctxt->flags.pending_M0, TO_MHI_STATE_STR(mhi_dev_ctxt->mhi_state),
mhi_dev_ctxt->flags.pending_M0,
mhi_dev_ctxt->flags.pending_M3); mhi_dev_ctxt->flags.pending_M3);
mutex_lock(&mhi_dev_ctxt->pm_lock); mutex_lock(&mhi_dev_ctxt->pm_lock);
switch (mhi_dev_ctxt->mhi_state) { switch (mhi_dev_ctxt->mhi_state) {
@ -906,8 +934,8 @@ int mhi_initiate_m3(struct mhi_device_ctxt *mhi_dev_ctxt)
break; break;
case MHI_STATE_M3: case MHI_STATE_M3:
mhi_log(MHI_MSG_INFO, mhi_log(MHI_MSG_INFO,
"MHI state %d, link state %d.\n", "MHI state %s, link state %d.\n",
mhi_dev_ctxt->mhi_state, TO_MHI_STATE_STR(mhi_dev_ctxt->mhi_state),
mhi_dev_ctxt->flags.link_up); mhi_dev_ctxt->flags.link_up);
if (mhi_dev_ctxt->flags.link_up) if (mhi_dev_ctxt->flags.link_up)
r = -EAGAIN; r = -EAGAIN;
@ -916,8 +944,8 @@ int mhi_initiate_m3(struct mhi_device_ctxt *mhi_dev_ctxt)
goto exit; goto exit;
default: default:
mhi_log(MHI_MSG_INFO, mhi_log(MHI_MSG_INFO,
"MHI state %d, link state %d.\n", "MHI state %s, link state %d.\n",
mhi_dev_ctxt->mhi_state, TO_MHI_STATE_STR(mhi_dev_ctxt->mhi_state),
mhi_dev_ctxt->flags.link_up); mhi_dev_ctxt->flags.link_up);
break; break;
} }

View file

@ -34,6 +34,17 @@ MODULE_PARM_DESC(mhi_msg_lvl, "dbg lvl");
module_param(mhi_ipc_log_lvl, uint, S_IRUGO | S_IWUSR); module_param(mhi_ipc_log_lvl, uint, S_IRUGO | S_IWUSR);
MODULE_PARM_DESC(mhi_ipc_log_lvl, "dbg lvl"); 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, static ssize_t mhi_dbgfs_chan_read(struct file *fp, char __user *buf,
size_t count, loff_t *offp) 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 = amnt_copied =
scnprintf(mhi_dev_ctxt->chan_info, scnprintf(mhi_dev_ctxt->chan_info,
MHI_LOG_SIZE, 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:", "Our State:",
mhi_dev_ctxt->mhi_state, TO_MHI_STATE_STR(mhi_dev_ctxt->mhi_state),
"M0->M1:", "M0->M1:",
mhi_dev_ctxt->counters.m0_m1, mhi_dev_ctxt->counters.m0_m1,
"M0<-M1:", "M0<-M1:",

View file

@ -46,6 +46,10 @@ extern void *mhi_ipc_log;
"[%s] " _msg, __func__, ##__VA_ARGS__); \ "[%s] " _msg, __func__, ##__VA_ARGS__); \
} while (0) } 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); irqreturn_t mhi_msi_handlr(int msi_number, void *dev_id);
struct mhi_meminfo { struct mhi_meminfo {