diff --git a/drivers/rpmsg/rockchip_rpmsg_test.c b/drivers/rpmsg/rockchip_rpmsg_test.c index 08677d6975b0..08e882112e53 100644 --- a/drivers/rpmsg/rockchip_rpmsg_test.c +++ b/drivers/rpmsg/rockchip_rpmsg_test.c @@ -6,17 +6,22 @@ * Author: Hongming Zou */ +#include #include #include #include #include +#include #include #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);