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

Commit 29282e89 authored by Karthik Parsha's avatar Karthik Parsha
Browse files

msm: rpm-smd: Increase the max outstanding sleep set messages to 24



When sending sleep-set requests send up 24 requests before reading any
acks.  The RX FIFO can hold 24 acks. Increase the threshold to the
max number of acks the FIFO can hold, so as to delay the process of
emptying the FIFO.

Also check and return an err on timeout and propagate that error up the
call chain.

Change-Id: Ic774fad65fbaa1906fcc7c51ab0d8b3766b8a987
Signed-off-by: default avatarKarthik Parsha <kparsha@codeaurora.org>
parent 548e7c28
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -496,11 +496,12 @@ static int cluster_configure(struct lpm_cluster *cluster, int idx,

failed_set_mode:
	for (i = 0; i < cluster->ndevices; i++) {
		int rc = 0;
		level = &cluster->levels[cluster->default_level];
		ret = cluster->lpm_dev[i].set_mode(&cluster->lpm_dev[i],
		rc = cluster->lpm_dev[i].set_mode(&cluster->lpm_dev[i],
				level->mode[i],
				level->notify_rpm);
		BUG_ON(ret);
		BUG_ON(rc);
	}
	spin_unlock(&cluster->sync_lock);
	return ret;
+33 −22
Original line number Diff line number Diff line
@@ -68,7 +68,7 @@ struct msm_rpm_driver_data {
#define INV_RSC "resource does not exist"
#define ERR "err\0"
#define MAX_ERR_BUFFER_SIZE 128
#define MAX_WAIT_ON_ACK 10
#define MAX_WAIT_ON_ACK 24
#define INIT_ERROR 1

static ATOMIC_NOTIFIER_HEAD(msm_rpm_sleep_notifier);
@@ -411,15 +411,24 @@ static int msm_rpm_flush_requests(bool print)
		ret = msm_rpm_send_smd_buffer(s->buf,
				get_buf_len(s->buf), true);

		WARN_ON(ret != get_buf_len(s->buf));

		s->valid = false;
		count++;

		trace_rpm_send_message(true, MSM_RPM_CTX_SLEEP_SET,
				get_rsc_type(s->buf),
				get_rsc_id(s->buf),
				get_msg_id(s->buf));

		/*
		 * RPM acks need to be handled here if we have sent over
		 * 10 messages such that we do not overrun SMD buffer. Since
		 * RPM acks need to be handled here if we have sent 24
		 * messages such that we do not overrun SMD buffer. Since
		 * we expect only sleep sets at this point (RPM PC would be
		 * disallowed if we had pending active requests), we need not
		 * process these sleep set acks.
		 */
		count++;
		if (count > MAX_WAIT_ON_ACK) {
		if (count >= MAX_WAIT_ON_ACK) {
			int len;
			int timeout = 10;

@@ -429,33 +438,32 @@ static int msm_rpm_flush_requests(bool print)
				/*
				 * Sleep for 50us at a time before checking
				 * for packet availability. The 50us is based
				 * on the the max time rpm could take to
				 * process and send an ack for sleep set
				 * request.
				 * on the the time rpm could take to process
				 * and send an ack for the sleep set request.
				 */
				udelay(50);
				timeout--;
			}
			/*
			 * On timeout return an error and exit the spinlock
			 * control on this cpu. This will allow any other
			 * core that has wokenup and trying to acquire the
			 * spinlock from being locked out.
			 */
			if (!timeout) {
				pr_err("%s: Timed out waiting for RPM ACK\n",
					__func__);
				return -EAGAIN;
			}

			pkt_sz = smd_cur_packet_size(msm_rpm_data.ch_info);
			BUG_ON(!pkt_sz);
			len = smd_read(msm_rpm_data.ch_info, buf, pkt_sz);
			count--;
		}

		WARN_ON(ret != get_buf_len(s->buf));

		trace_rpm_send_message(true, MSM_RPM_CTX_SLEEP_SET,
				get_rsc_type(s->buf),
				get_rsc_id(s->buf),
				get_msg_id(s->buf));

		s->valid = false;
	}
	return 0;
}


static atomic_t msm_rpm_msg_id = ATOMIC_INIT(0);

struct msm_rpm_request {
@@ -1347,9 +1355,12 @@ int msm_rpm_enter_sleep(bool print, const struct cpumask *cpumask)
		return 0;

	ret = smd_mask_receive_interrupt(msm_rpm_data.ch_info, true, cpumask);
	if (!ret)
		msm_rpm_flush_requests(print);

	if (!ret) {
		ret = msm_rpm_flush_requests(print);
		if (ret)
			smd_mask_receive_interrupt(msm_rpm_data.ch_info,
							false, NULL);
	}
	return ret;
}
EXPORT_SYMBOL(msm_rpm_enter_sleep);