mirror of
https://github.com/apache/nuttx.git
synced 2025-01-13 09:49:21 +08:00
rpmsg_port.c:add rpmsg_port_dump function
[01/01 00:02:48] [187] [ EMERG] [ap] Remote: wit [01/01 00:02:48] [187] [ EMERG] [ap] ept NS [01/01 00:02:48] [187] [ EMERG] [ap] ept rpmsg-sensor [01/01 00:02:48] [187] [ EMERG] [ap] ept rpmsg-ping [01/01 00:02:48] [187] [ EMERG] [ap] rpmsg_port queue RX: {used: 0, avail: 5} [01/01 00:02:48] [187] [ EMERG] [ap] rpmsg buffer list: [01/01 00:02:48] [187] [ EMERG] [ap] rpmsg_port queue TX: {used: 4, avail: 0} [01/01 00:02:48] [187] [ EMERG] [ap] rpmsg buffer list: [01/01 00:02:48] [187] [ EMERG] [ap] TX buffer 0x619b84a8 hold by rpmsg-ping [01/01 00:02:48] [187] [ EMERG] [ap] TX buffer 0x619b86a8 hold by rpmsg-ping [01/01 00:02:48] [187] [ EMERG] [ap] TX buffer 0x619b88a8 hold by rpmsg-ping [01/01 00:02:48] [187] [ EMERG] [ap] TX buffer 0x619b8aa8 hold by rpmsg-ping Signed-off-by: wangshaoxin <wangshaoxin@xiaomi.com>
This commit is contained in:
parent
f93688cbd5
commit
6feec8e4c5
1 changed files with 74 additions and 1 deletions
|
@ -28,6 +28,7 @@
|
|||
#include <nuttx/kmalloc.h>
|
||||
|
||||
#include <metal/mutex.h>
|
||||
#include <metal/sys.h>
|
||||
|
||||
#include <rpmsg/rpmsg_internal.h>
|
||||
|
||||
|
@ -49,6 +50,7 @@ rpmsg_port_get_local_cpuname(FAR struct rpmsg_s *rpmsg);
|
|||
static FAR const char *rpmsg_port_get_cpuname(FAR struct rpmsg_s *rpmsg);
|
||||
static int rpmsg_port_get_tx_buffer_size(FAR struct rpmsg_s *rpmsg);
|
||||
static int rpmsg_port_get_rx_buffer_size(FAR struct rpmsg_s *rpmsg);
|
||||
static void rpmsg_port_dump(FAR struct rpmsg_s *rpmsg);
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
|
@ -60,7 +62,7 @@ static const struct rpmsg_ops_s g_rpmsg_port_ops =
|
|||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
rpmsg_port_dump,
|
||||
rpmsg_port_get_local_cpuname,
|
||||
rpmsg_port_get_cpuname,
|
||||
rpmsg_port_get_tx_buffer_size,
|
||||
|
@ -759,3 +761,74 @@ void rpmsg_port_unregister(FAR struct rpmsg_port_s *port)
|
|||
|
||||
rpmsg_device_destory(&port->rpmsg);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: rpmsg_port_dump_buffer
|
||||
****************************************************************************/
|
||||
|
||||
static void rpmsg_port_dump_buffer(FAR struct rpmsg_device *rdev,
|
||||
FAR struct rpmsg_port_queue_s *queue,
|
||||
bool rx)
|
||||
{
|
||||
FAR struct list_node *node;
|
||||
irqstate_t flags = spin_lock_irqsave(&queue->ready.lock);
|
||||
|
||||
metal_log(METAL_LOG_EMERGENCY,
|
||||
"rpmsg_port queue %s: {used: %u, avail: %u}\n",
|
||||
rx ? "RX" : "TX",
|
||||
rpmsg_port_queue_nused(queue),
|
||||
rpmsg_port_queue_navail(queue));
|
||||
metal_log(METAL_LOG_EMERGENCY, "rpmsg buffer list:\n");
|
||||
list_for_every(&queue->ready.head, node)
|
||||
{
|
||||
FAR struct rpmsg_port_header_s *hdr =
|
||||
RPMSG_PORT_NODE_TO_BUF(queue, node);
|
||||
FAR struct rpmsg_hdr *rphdr = (FAR struct rpmsg_hdr *)hdr->buf;
|
||||
FAR struct rpmsg_endpoint *ept;
|
||||
|
||||
ept = rpmsg_get_ept_from_addr(rdev, rx ? rphdr->dst : rphdr->src);
|
||||
if (ept)
|
||||
{
|
||||
metal_log(METAL_LOG_EMERGENCY, " %s buffer %p hold by %s\n",
|
||||
rx ? "RX" : "TX", rphdr, ept->name);
|
||||
}
|
||||
}
|
||||
|
||||
spin_unlock_irqrestore(&queue->ready.lock, flags);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: rpmsg_port_dump
|
||||
****************************************************************************/
|
||||
|
||||
static void rpmsg_port_dump(FAR struct rpmsg_s *rpmsg)
|
||||
{
|
||||
FAR struct rpmsg_port_s *port = (FAR struct rpmsg_port_s *)rpmsg;
|
||||
FAR struct rpmsg_device *rdev = rpmsg->rdev;
|
||||
FAR struct rpmsg_endpoint *ept;
|
||||
FAR struct metal_list *node;
|
||||
bool needunlock = false;
|
||||
|
||||
if (!up_interrupt_context() && !sched_idletask() &&
|
||||
!nxmutex_is_hold(&rdev->lock))
|
||||
{
|
||||
metal_mutex_acquire(&rdev->lock);
|
||||
needunlock = true;
|
||||
}
|
||||
|
||||
metal_log(METAL_LOG_EMERGENCY, "Remote: %s\n", port->cpuname);
|
||||
|
||||
metal_list_for_each(&rdev->endpoints, node)
|
||||
{
|
||||
ept = metal_container_of(node, struct rpmsg_endpoint, node);
|
||||
metal_log(METAL_LOG_EMERGENCY, "ept %s\n", ept->name);
|
||||
}
|
||||
|
||||
rpmsg_port_dump_buffer(rdev, &port->rxq, true);
|
||||
rpmsg_port_dump_buffer(rdev, &port->txq, false);
|
||||
|
||||
if (needunlock)
|
||||
{
|
||||
metal_mutex_release(&rdev->lock);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue