From b7c0a63b431ee3d10bd8de2b7d87015518c988d1 Mon Sep 17 00:00:00 2001 From: Chris Lew Date: Mon, 29 Nov 2021 14:34:31 -0800 Subject: [PATCH] rpmsg: glink: Add wakeup information Add a function to query the glink core layer on whether a packet has caused a wakeup. This function also takes a parameter to specify if the wakeup state should be reset after reading the variable. Add print to log the wakeup packet for glink interrupts. Some channels such as IPCRTR will already reset the wakeup info state and print their own messages. This print is meant to be a default print for all other channels. Change-Id: Iff7ff4e08d595c63f1c6924b77436b8edf261485 Signed-off-by: Chris Lew --- drivers/rpmsg/qcom_glink_native.c | 20 ++++++++++++++++++++ include/linux/rpmsg/qcom_glink.h | 6 ++++++ 2 files changed, 26 insertions(+) diff --git a/drivers/rpmsg/qcom_glink_native.c b/drivers/rpmsg/qcom_glink_native.c index fb123c324b1c..7a0fb37a4750 100644 --- a/drivers/rpmsg/qcom_glink_native.c +++ b/drivers/rpmsg/qcom_glink_native.c @@ -31,6 +31,7 @@ #define RPM_GLINK_CID_MAX 65536 static int should_wake; +static int glink_resume_pkt; struct glink_msg { __le16 cmd; @@ -897,6 +898,18 @@ static int qcom_glink_rx_defer(struct qcom_glink *glink, size_t extra) return 0; } +bool qcom_glink_is_wakeup(bool reset) +{ + if (!glink_resume_pkt) + return false; + + if (reset) + glink_resume_pkt = false; + + return true; +} +EXPORT_SYMBOL(qcom_glink_is_wakeup); + static int qcom_glink_rx_data(struct qcom_glink *glink, size_t avail) { struct glink_core_rx_intent *intent; @@ -999,6 +1012,12 @@ static int qcom_glink_rx_data(struct qcom_glink *glink, size_t avail) } spin_unlock(&channel->recv_lock); + if (qcom_glink_is_wakeup(true)) { + pr_info("%s[%d:%d] %s: wakeup packet size:%d\n", + channel->name, channel->lcid, channel->rcid, + __func__, intent->offset); + } + intent->offset = 0; channel->buf = NULL; @@ -1105,6 +1124,7 @@ static irqreturn_t qcom_glink_native_intr(int irq, void *data) if (should_wake) { pr_info("%s: wakeup %s\n", __func__, glink->irqname); + glink_resume_pkt = true; should_wake = false; pm_system_wakeup(); } diff --git a/include/linux/rpmsg/qcom_glink.h b/include/linux/rpmsg/qcom_glink.h index 9657059e53b0..2e86994a3ebe 100644 --- a/include/linux/rpmsg/qcom_glink.h +++ b/include/linux/rpmsg/qcom_glink.h @@ -19,6 +19,7 @@ struct qcom_glink *qcom_glink_smem_register(struct device *parent, struct device_node *node); void qcom_glink_smem_unregister(struct qcom_glink *glink); int qcom_glink_smem_start(struct qcom_glink *glink); +bool qcom_glink_is_wakeup(bool reset); void qcom_glink_early_ssr_notify(void *data); #else @@ -38,6 +39,11 @@ int qcom_glink_smem_start(struct qcom_glink *glink) { return -ENXIO; } + +static inline bool qcom_glink_is_wakeup(bool reset) +{ + return false; +} #endif #endif