mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-06 02:50:49 +09:00
rpmsg: rockchip_test: add delay compensation
1. add delay compensation to the test demo 2. update the names of some structures Change-Id: I12026f13395ad691628fd6a2c3cb1b15185b156e Signed-off-by: Hongming Zou <hongming.zou@rock-chips.com>
This commit is contained in:
@@ -6,17 +6,22 @@
|
||||
* Author: Hongming Zou <hongming.zou@rock-chips.com>
|
||||
*/
|
||||
|
||||
#include <linux/delay.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/rpmsg.h>
|
||||
#include <linux/rpmsg/rockchip_rpmsg.h>
|
||||
#include <linux/time.h>
|
||||
#include <linux/virtio.h>
|
||||
|
||||
#define LINUX_TEST_MSG_1 "Announce master ept id!"
|
||||
#define LINUX_TEST_MSG_2 "Rockchip rpmsg linux test pingpong!"
|
||||
#define MSG_LIMIT 100
|
||||
#define MSG_LIMIT 10000
|
||||
|
||||
struct instance_data {
|
||||
/* different processor cores may need to adjust the value of this definition */
|
||||
#define LINUX_RPMSG_COMPENSATION (1) //ms
|
||||
|
||||
struct rpmsg_info_t {
|
||||
int rx_count;
|
||||
};
|
||||
|
||||
@@ -25,18 +30,19 @@ static int rockchip_rpmsg_test_cb(struct rpmsg_device *rp, void *payload,
|
||||
{
|
||||
int ret;
|
||||
uint32_t remote_ept_id;
|
||||
struct instance_data *idata = dev_get_drvdata(&rp->dev);
|
||||
struct rpmsg_info_t *info = dev_get_drvdata(&rp->dev);
|
||||
|
||||
remote_ept_id = src;
|
||||
dev_info(&rp->dev, "rx msg %s rx_count %d(remote_ept_id: 0x%x)\n",
|
||||
(char *)payload, ++idata->rx_count, remote_ept_id);
|
||||
(char *)payload, ++info->rx_count, remote_ept_id);
|
||||
|
||||
/* test should not live forever */
|
||||
if (idata->rx_count >= MSG_LIMIT) {
|
||||
if (info->rx_count >= MSG_LIMIT) {
|
||||
dev_info(&rp->dev, "Rockchip rpmsg test exit!\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
mdelay(LINUX_RPMSG_COMPENSATION);
|
||||
/* send a new message now */
|
||||
ret = rpmsg_sendto(rp->ept, LINUX_TEST_MSG_2, strlen(LINUX_TEST_MSG_2), remote_ept_id);
|
||||
if (ret)
|
||||
@@ -48,17 +54,17 @@ static int rockchip_rpmsg_test_probe(struct rpmsg_device *rp)
|
||||
{
|
||||
int ret;
|
||||
uint32_t master_ept_id, remote_ept_id;
|
||||
struct instance_data *idata;
|
||||
struct rpmsg_info_t *info;
|
||||
|
||||
master_ept_id = rp->src;
|
||||
remote_ept_id = rp->dst;
|
||||
dev_info(&rp->dev, "new channel: 0x%x -> 0x%x!\n", master_ept_id, remote_ept_id);
|
||||
|
||||
idata = devm_kzalloc(&rp->dev, sizeof(*idata), GFP_KERNEL);
|
||||
if (!idata)
|
||||
info = devm_kzalloc(&rp->dev, sizeof(*info), GFP_KERNEL);
|
||||
if (!info)
|
||||
return -ENOMEM;
|
||||
|
||||
dev_set_drvdata(&rp->dev, idata);
|
||||
dev_set_drvdata(&rp->dev, info);
|
||||
|
||||
/*
|
||||
* send a message to our remote processor, and tell remote
|
||||
@@ -69,7 +75,7 @@ static int rockchip_rpmsg_test_probe(struct rpmsg_device *rp)
|
||||
dev_err(&rp->dev, "rpmsg_send failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
mdelay(LINUX_RPMSG_COMPENSATION);
|
||||
ret = rpmsg_sendto(rp->ept, LINUX_TEST_MSG_2, strlen(LINUX_TEST_MSG_2), remote_ept_id);
|
||||
if (ret) {
|
||||
dev_err(&rp->dev, "rpmsg_send failed: %d\n", ret);
|
||||
|
||||
Reference in New Issue
Block a user