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

Commit e1974c88 authored by Mahesh Sivasubramanian's avatar Mahesh Sivasubramanian Committed by Gerrit - the friendly Code Review server
Browse files

soc: qcom: rpm-smd: Account for NOACK messages with system sleep



When a system is entering RPM assisted sleep, the NOACK messages are
not accounted in preventing such sleep modes as no driver is waiting
on it. In such scenarios, some active messages could still be in the
Apps RX buffer which reduces the number of outstanding sleep messages.

Fix by accounting for NOACK messages while flushing sleep set requests
and ensuring that they are read before sending any Sleep set requests.

The original changes were reverted to address issues with SMD transport.
This change includes fixes from earlier squashed into a single commit.

Change-Id: I5570d7694424d0a602c446c0af098a64ffa681e4
Signed-off-by: default avatarMahesh Sivasubramanian <msivasub@codeaurora.org>
Signed-off-by: default avatarMaulik Shah <mkshah@codeaurora.org>
parent f82305b2
Loading
Loading
Loading
Loading
+29 −4
Original line number Diff line number Diff line
@@ -747,6 +747,7 @@ static int msm_rpm_read_sleep_ack(void)
{
	int ret;
	char buf[MAX_ERR_BUFFER_SIZE] = {0};
	uint32_t msg_id;

	if (glink_enabled)
		ret = msm_rpm_glink_rx_poll(glink_data->glink_handle);
@@ -777,18 +778,38 @@ static int msm_rpm_read_sleep_ack(void)
			return -EAGAIN;

		ret = msm_rpm_read_smd_data(buf);
		if (!ret)
		if (!ret) {
			/* Mimic Glink behavior to ensure that the
			 * data is read and the msg is removed from
			 * the wait list. We should have gotten here
			 * only when there are no drivers waiting on
			 * ACKs. msm_rpm_get_entry_from_msg_id()
			 * return non-NULL only then.
			 */
			msg_id = msm_rpm_get_msg_id_from_ack(buf);
			msm_rpm_process_ack(msg_id, 0);
			ret = smd_is_pkt_avail(msm_rpm_data.ch_info);
		}
	}
	return ret;
}

static void msm_rpm_flush_noack_messages(void)
{
	while (!list_empty(&msm_rpm_wait_list)) {
		if (!msm_rpm_read_sleep_ack())
			break;
	}
}

static int msm_rpm_flush_requests(bool print)
{
	struct rb_node *t;
	int ret;
	int count = 0;

	msm_rpm_flush_noack_messages();

	for (t = rb_first(&tr_root); t; t = rb_next(t)) {

		struct slp_buf *s = rb_entry(t, struct slp_buf, node);
@@ -1057,14 +1078,18 @@ static void msm_rpm_notify(void *data, unsigned int event)

bool msm_rpm_waiting_for_ack(void)
{
	bool ret;
	bool ret = false;
	unsigned long flags;
	struct msm_rpm_wait_data *elem = NULL;

	spin_lock_irqsave(&msm_rpm_list_lock, flags);
	ret = list_empty(&msm_rpm_wait_list);
	elem = list_first_entry_or_null(&msm_rpm_wait_list,
				struct msm_rpm_wait_data, list);
	if (elem)
		ret = !elem->delete_on_ack;
	spin_unlock_irqrestore(&msm_rpm_list_lock, flags);

	return !ret;
	return ret;
}

static struct msm_rpm_wait_data *msm_rpm_get_entry_from_msg_id(uint32_t msg_id)