Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7f39ce6d authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "msm: mhi: fix error handling"

parents bf5be4a1 4aa301f0
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -259,8 +259,6 @@ static int rmnet_mhi_poll(struct napi_struct *napi, int budget)

		/* Nothing more to read, or out of buffers in MHI layer */
		if (unlikely(!result->buf_addr || !result->bytes_xferd)) {
			rmnet_log(MSG_CRITICAL,
				  "Not valid buff not rescheduling\n");
			should_reschedule = false;
			break;
		}
@@ -625,6 +623,9 @@ static int rmnet_mhi_xmit(struct sk_buff *skb, struct net_device *dev)
				tx_ring_full_count[rmnet_mhi_ptr->dev_index]++;
				netif_stop_queue(dev);
				rmnet_log(MSG_VERBOSE, "Stopping Queue\n");
				write_unlock_irqrestore(
					    &rmnet_mhi_ptr->out_chan_full_lock,
					    flags);
				goto rmnet_mhi_xmit_error_cleanup;
			} else {
				retry = 1;
@@ -652,7 +653,6 @@ static int rmnet_mhi_xmit(struct sk_buff *skb, struct net_device *dev)

rmnet_mhi_xmit_error_cleanup:
	rmnet_log(MSG_VERBOSE, "Ring full\n");
	write_unlock_irqrestore(&rmnet_mhi_ptr->out_chan_full_lock, flags);
	return NETDEV_TX_BUSY;
}

+16 −10
Original line number Diff line number Diff line
@@ -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);
	/*
@@ -1166,6 +1165,7 @@ int parse_xfer_event(struct mhi_device_ctxt *ctxt,
	{
		struct mhi_ring *chan_ctxt = NULL;
		u64 db_value = 0;
		unsigned long flags;

		mhi_dev_ctxt->flags.uldl_enabled = 1;
		chan = MHI_EV_READ_CHID(EV_CHID, event);
@@ -1173,6 +1173,8 @@ int parse_xfer_event(struct mhi_device_ctxt *ctxt,
		chan_ctxt =
			&mhi_dev_ctxt->mhi_local_chan_ctxt[chan];
		mhi_log(MHI_MSG_INFO, "DB_MODE/OOB Detected chan %d.\n", chan);
		spin_lock_irqsave(&mhi_dev_ctxt->db_write_lock[chan],
				  flags);
		if (chan_ctxt->wp != chan_ctxt->rp) {
			db_value = mhi_v2p_addr(mhi_dev_ctxt,
						MHI_RING_TYPE_XFER_RING, chan,
@@ -1184,6 +1186,8 @@ int parse_xfer_event(struct mhi_device_ctxt *ctxt,
		client_handle = mhi_dev_ctxt->client_handle_list[chan];
		if (NULL != client_handle)
			result->transaction_status = -ENOTCONN;
		spin_unlock_irqrestore(&mhi_dev_ctxt->db_write_lock[chan],
				       flags);
		break;
	}
	case MHI_EVENT_CC_BAD_TRE:
@@ -1393,8 +1397,10 @@ static int start_chan_cmd(struct mhi_device_ctxt *mhi_dev_ctxt,
	u32 chan;

	MHI_TRB_GET_INFO(CMD_TRB_CHID, cmd_pkt, chan);
	if (!VALID_CHAN_NR(chan))
	if (!VALID_CHAN_NR(chan)) {
		mhi_log(MHI_MSG_ERROR, "Bad chan: 0x%x\n", chan);
		return -EINVAL;
	}
	mhi_dev_ctxt->mhi_chan_pend_cmd_ack[chan] =
					MHI_CMD_NOT_PENDING;
	mhi_log(MHI_MSG_INFO, "Processed START CMD chan %d\n", chan);
+6 −5
Original line number Diff line number Diff line
@@ -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;
}
+63 −35
Original line number Diff line number Diff line
@@ -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;
	}
+13 −2
Original line number Diff line number Diff line
@@ -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:",
Loading