hc
2023-12-11 6778948f9de86c3cfaf36725a7c87dcff9ba247f
kernel/drivers/rpmsg/rockchip_rpmsg_test.c
....@@ -6,17 +6,22 @@
66 * Author: Hongming Zou <hongming.zou@rock-chips.com>
77 */
88
9
+#include <linux/delay.h>
910 #include <linux/kernel.h>
1011 #include <linux/module.h>
1112 #include <linux/rpmsg.h>
1213 #include <linux/rpmsg/rockchip_rpmsg.h>
14
+#include <linux/time.h>
1315 #include <linux/virtio.h>
1416
1517 #define LINUX_TEST_MSG_1 "Announce master ept id!"
1618 #define LINUX_TEST_MSG_2 "Rockchip rpmsg linux test pingpong!"
17
-#define MSG_LIMIT 100
19
+#define MSG_LIMIT 10000
1820
19
-struct instance_data {
21
+/* different processor cores may need to adjust the value of this definition */
22
+#define LINUX_RPMSG_COMPENSATION (1) //ms
23
+
24
+struct rpmsg_info_t {
2025 int rx_count;
2126 };
2227
....@@ -25,18 +30,19 @@
2530 {
2631 int ret;
2732 uint32_t remote_ept_id;
28
- struct instance_data *idata = dev_get_drvdata(&rp->dev);
33
+ struct rpmsg_info_t *info = dev_get_drvdata(&rp->dev);
2934
3035 remote_ept_id = src;
3136 dev_info(&rp->dev, "rx msg %s rx_count %d(remote_ept_id: 0x%x)\n",
32
- (char *)payload, ++idata->rx_count, remote_ept_id);
37
+ (char *)payload, ++info->rx_count, remote_ept_id);
3338
3439 /* test should not live forever */
35
- if (idata->rx_count >= MSG_LIMIT) {
40
+ if (info->rx_count >= MSG_LIMIT) {
3641 dev_info(&rp->dev, "Rockchip rpmsg test exit!\n");
3742 return 0;
3843 }
3944
45
+ mdelay(LINUX_RPMSG_COMPENSATION);
4046 /* send a new message now */
4147 ret = rpmsg_sendto(rp->ept, LINUX_TEST_MSG_2, strlen(LINUX_TEST_MSG_2), remote_ept_id);
4248 if (ret)
....@@ -48,17 +54,17 @@
4854 {
4955 int ret;
5056 uint32_t master_ept_id, remote_ept_id;
51
- struct instance_data *idata;
57
+ struct rpmsg_info_t *info;
5258
5359 master_ept_id = rp->src;
5460 remote_ept_id = rp->dst;
5561 dev_info(&rp->dev, "new channel: 0x%x -> 0x%x!\n", master_ept_id, remote_ept_id);
5662
57
- idata = devm_kzalloc(&rp->dev, sizeof(*idata), GFP_KERNEL);
58
- if (!idata)
63
+ info = devm_kzalloc(&rp->dev, sizeof(*info), GFP_KERNEL);
64
+ if (!info)
5965 return -ENOMEM;
6066
61
- dev_set_drvdata(&rp->dev, idata);
67
+ dev_set_drvdata(&rp->dev, info);
6268
6369 /*
6470 * send a message to our remote processor, and tell remote
....@@ -69,7 +75,7 @@
6975 dev_err(&rp->dev, "rpmsg_send failed: %d\n", ret);
7076 return ret;
7177 }
72
-
78
+ mdelay(LINUX_RPMSG_COMPENSATION);
7379 ret = rpmsg_sendto(rp->ept, LINUX_TEST_MSG_2, strlen(LINUX_TEST_MSG_2), remote_ept_id);
7480 if (ret) {
7581 dev_err(&rp->dev, "rpmsg_send failed: %d\n", ret);
....@@ -86,6 +92,7 @@
8692
8793 static struct rpmsg_device_id rockchip_rpmsg_test_id_table[] = {
8894 { .name = "rpmsg-ap3-ch0" },
95
+ { .name = "rpmsg-mcu0-test" },
8996 { /* sentinel */ },
9097 };
9198