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

Commit a4b4f042 authored by Karthik Parsha's avatar Karthik Parsha
Browse files

qcom: rpm-smd: Force smd channel update in interrupt lock context



In the power collapse path, when checking for availability of an ack from
rpm, use smd_is_pkt_avail. This api is designed to be used with
interrupts disabled, and will be able to poll for acks from rpm.

Wait for upto 500us to receive this ack. If in 500us, an ack is not
received generate a kernel panic.

The rpm-smd receive buffer is able to hold a limited number of packets.
Reduce the threshold of sent packets, such that apps will process received
packets in the receive buffer after 10 sent packets. This will ensure that
the receive buffer does not overflow even if the rpm sends bigger nack
packets along with ack packets.

Change-Id: Ie99d0bb9ae17445872e0c37f0797cac3a221daa4
Signed-off-by: default avatarKarthik Parsha <kparsha@codeaurora.org>
parent 512fe370
Loading
Loading
Loading
Loading
+20 −5
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 24
#define MAX_WAIT_ON_ACK 10
#define INIT_ERROR 1

static ATOMIC_NOTIFIER_HEAD(msm_rpm_sleep_notifier);
@@ -413,7 +413,7 @@ static int msm_rpm_flush_requests(bool print)

		/*
		 * RPM acks need to be handled here if we have sent over
		 * 24 messages such that we do not overrun SMD buffer. Since
		 * 10 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.
@@ -421,10 +421,25 @@ static int msm_rpm_flush_requests(bool print)
		count++;
		if (count > MAX_WAIT_ON_ACK) {
			int len;
			int timeout = 10;

			while (timeout) {
				if (smd_is_pkt_avail(msm_rpm_data.ch_info))
					break;
				/*
				 * 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.
				 */
				udelay(50);
				timeout--;
			}

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