This is an automated email from the ASF dual-hosted git repository.
xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 52a46c6737b drivers/rpmsg/rpmsg_ping: log the start and end of each
ping run
52a46c6737b is described below
commit 52a46c6737b469783fd8240d98b80c3f6c9f2d08
Author: Bowen Wang <[email protected]>
AuthorDate: Tue Nov 10 22:39:28 2026 +0800
drivers/rpmsg/rpmsg_ping: log the start and end of each ping run
A ping run printed statistics only at the end, and a failed send
returned without a message, so a stalled link left no trace of where it
stopped. Log the start and the end of every run with a sequence number,
a timestamp, the two cpu names and the parameters, and log the end also
when a send fails.
Signed-off-by: Bowen Wang <[email protected]>
---
drivers/rpmsg/rpmsg_ping.c | 21 +++++++++++++++++++--
drivers/rpmsg/rpmsg_ping.h | 2 ++
2 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/drivers/rpmsg/rpmsg_ping.c b/drivers/rpmsg/rpmsg_ping.c
index 4c447667aa1..5d5a13080bf 100644
--- a/drivers/rpmsg/rpmsg_ping.c
+++ b/drivers/rpmsg/rpmsg_ping.c
@@ -26,6 +26,7 @@
#include <nuttx/config.h>
#include <nuttx/arch.h>
+#include <nuttx/clock.h>
#include <nuttx/lib/lib.h>
#include <nuttx/signal.h>
@@ -222,8 +223,10 @@ int rpmsg_ping(FAR struct rpmsg_ping_dev_s *dev,
clock_t min = CLOCK_MAX;
clock_t max = 0;
uint64_t total = 0;
+ struct timespec ts;
uint32_t buf_len = 0;
int send_len = 0;
+ int seq;
int i;
if (!dev || !ping || ping->times <= 0)
@@ -240,6 +243,14 @@ int rpmsg_ping(FAR struct rpmsg_ping_dev_s *dev,
ept = &dev->ept;
}
+ seq = atomic_add(&dev->seq, 1) + 1;
+ clock_systime_timespec(&ts);
+ syslog(LOG_EMERG, "ping #%d start at %" PRIu64 ".%09ld: %s <-> %s, "
+ "times %d, len %d, cmd 0x%x, sleep %d ms\n", seq,
+ (uint64_t)ts.tv_sec, ts.tv_nsec,
+ rpmsg_get_local_cpuname(ept->rdev), rpmsg_get_cpuname(ept->rdev),
+ ping->times, ping->len, ping->cmd, ping->sleep);
+
for (i = 0; i < ping->times; i++)
{
clock_t tm = perf_gettime();
@@ -247,7 +258,7 @@ int rpmsg_ping(FAR struct rpmsg_ping_dev_s *dev,
send_len = rpmsg_ping_once(ept, ping->len, ping->cmd, &buf_len, i);
if (send_len < 0)
{
- return send_len;
+ goto out;
}
tm = perf_gettime() - tm;
@@ -270,7 +281,12 @@ int rpmsg_ping(FAR struct rpmsg_ping_dev_s *dev,
rpmsg_ping_logout("max", max);
rpmsg_ping_logout_rate(send_len, total / ping->times);
- return 0;
+out:
+ clock_systime_timespec(&ts);
+ syslog(LOG_EMERG, "ping #%d end at %" PRIu64 ".%09ld: %d of %d done, "
+ "ret %d\n", seq, (uint64_t)ts.tv_sec, ts.tv_nsec, i, ping->times,
+ MIN(send_len, 0));
+ return MIN(send_len, 0);
}
int rpmsg_ping_init(FAR struct rpmsg_device *rdev,
@@ -278,6 +294,7 @@ int rpmsg_ping_init(FAR struct rpmsg_device *rdev,
{
int ret;
+ atomic_set(&dev->seq, 0);
ret = rpmsg_create_ept(&dev->ept, rdev, RPMSG_PING_EPT_NAME,
RPMSG_ADDR_ANY, RPMSG_ADDR_ANY,
rpmsg_ping_ept_cb, NULL);
diff --git a/drivers/rpmsg/rpmsg_ping.h b/drivers/rpmsg/rpmsg_ping.h
index 9e31ddadb5a..ec597f2161c 100644
--- a/drivers/rpmsg/rpmsg_ping.h
+++ b/drivers/rpmsg/rpmsg_ping.h
@@ -27,6 +27,7 @@
* Included Files
****************************************************************************/
+#include <nuttx/atomic.h>
#include <nuttx/rpmsg/rpmsg.h>
#ifdef CONFIG_RPMSG_PING
@@ -39,6 +40,7 @@ struct rpmsg_ping_dev_s
{
struct rpmsg_endpoint ept;
struct rpmsg_endpoint ept_rt;
+ atomic_t seq;
};
/****************************************************************************