drivers: rpmsg: fix to avoid dump stack in rpm-smd driver

While rpm driver flushing messages in lpm mode, use
rpmsg_trysend instead of rpmsg_send to avoid the dump stack.
qcom_smd driver is going to sleep when tx ring buffer is full
if rpmsg_send is used while flushing. rpm-smd is using spinlock
while flushing the messages. Under spinlock it should not go to sleep.
dump stack is shown because of this. Use rpmsg_trysend to avoid
showing dump stack.

Change-Id: I3c9bf895d5ec70a9cb1f607eb227df65a2402be2
Signed-off-by: Prasadarao Durvasula <pdurvasu@codeaurora.org>
Signed-off-by: Sivasri Kumar Vanka <sivasri@codeaurora.org>
This commit is contained in:
Prasadarao Durvasula
2019-12-04 17:32:03 +05:30
committed by Sivasri Kumar Vanka
parent 4c5fed65f1
commit 808861b856

View File

@@ -215,6 +215,7 @@ enum rpm_msg_fmts {
static struct rb_root tr_root = RB_ROOT;
static int msm_rpm_send_smd_buffer(char *buf, uint32_t size);
static int msm_rpm_trysend_smd_buffer(char *buf, uint32_t size);
static uint32_t msm_rpm_get_next_msg_id(void);
static inline uint32_t get_offset_value(uint32_t val, uint32_t offset,
@@ -727,7 +728,7 @@ static int msm_rpm_flush_requests(bool print)
set_msg_id(s->buf, msm_rpm_get_next_msg_id());
ret = msm_rpm_send_smd_buffer(s->buf,
ret = msm_rpm_trysend_smd_buffer(s->buf,
get_buf_len(s->buf));
WARN_ON(ret != 0);
trace_rpm_smd_send_sleep_set(get_msg_id(s->buf), type, id);
@@ -1201,6 +1202,30 @@ static int msm_rpm_send_smd_buffer(char *buf, uint32_t size)
return ret;
}
static int trysend_count = 12;
module_param(trysend_count, int, 0664);
static int msm_rpm_trysend_smd_buffer(char *buf, uint32_t size)
{
unsigned long flags;
int ret;
int count = 0;
do {
spin_lock_irqsave(&msm_rpm_data.smd_lock_write, flags);
ret = rpmsg_trysend(rpm->rpm_channel, buf, size);
spin_unlock_irqrestore(&msm_rpm_data.smd_lock_write, flags);
if (!ret)
break;
udelay(10);
count++;
} while (count < trysend_count);
return ret;
}
static int msm_rpm_send_data(struct msm_rpm_request *cdata,
int msg_type, bool noack)
{