From 2519fbb39711e5e6696685f29fe049af93c5987c Mon Sep 17 00:00:00 2001 From: Suman Anna Date: Fri, 9 Aug 2019 11:27:09 -0500 Subject: [PATCH 1/7] samples/rpmsg: Replace print_hex_dump() with print_hex_dump_debug() Replace the raw print_hex_dump() call in the rpmsg_sample_cb() function with the equivalent print_hex_dump_debug() better suited for dynamic debug. This switch allows flexibility of controlling this trace through dynamic debug when enabled. Signed-off-by: Suman Anna Signed-off-by: Bjorn Andersson --- samples/rpmsg/rpmsg_client_sample.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/rpmsg/rpmsg_client_sample.c b/samples/rpmsg/rpmsg_client_sample.c index 2a0695573b47..b9a99e621a5c 100644 --- a/samples/rpmsg/rpmsg_client_sample.c +++ b/samples/rpmsg/rpmsg_client_sample.c @@ -29,8 +29,8 @@ static int rpmsg_sample_cb(struct rpmsg_device *rpdev, void *data, int len, dev_info(&rpdev->dev, "incoming msg %d (src: 0x%x)\n", ++idata->rx_count, src); - print_hex_dump(KERN_DEBUG, __func__, DUMP_PREFIX_NONE, 16, 1, - data, len, true); + print_hex_dump_debug(__func__, DUMP_PREFIX_NONE, 16, 1, data, len, + true); /* samples should not live forever */ if (idata->rx_count >= MSG_LIMIT) { From 9a703eb72059530941ad32e2f99eccb70071f3f4 Mon Sep 17 00:00:00 2001 From: Suman Anna Date: Fri, 9 Aug 2019 11:27:10 -0500 Subject: [PATCH 2/7] samples/rpmsg: Introduce a module parameter for message count The current rpmsg_client_sample uses a fixed number of messages to be sent to each instance. This is currently set at 100. Introduce an optional module parameter 'count' so that the number of messages to be exchanged can be made flexible. Signed-off-by: Suman Anna Signed-off-by: Bjorn Andersson --- samples/rpmsg/rpmsg_client_sample.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/samples/rpmsg/rpmsg_client_sample.c b/samples/rpmsg/rpmsg_client_sample.c index b9a99e621a5c..ae5081662283 100644 --- a/samples/rpmsg/rpmsg_client_sample.c +++ b/samples/rpmsg/rpmsg_client_sample.c @@ -14,7 +14,9 @@ #include #define MSG "hello world!" -#define MSG_LIMIT 100 + +static int count = 100; +module_param(count, int, 0644); struct instance_data { int rx_count; @@ -33,7 +35,7 @@ static int rpmsg_sample_cb(struct rpmsg_device *rpdev, void *data, int len, true); /* samples should not live forever */ - if (idata->rx_count >= MSG_LIMIT) { + if (idata->rx_count >= count) { dev_info(&rpdev->dev, "goodbye!\n"); return 0; } From 9ff166def8c1f5759555c2c94ddd0fef11a18c2b Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Fri, 22 Feb 2019 22:20:17 -0600 Subject: [PATCH 3/7] rpmsg: core: fix comments Minor typos, grammar and copy/paste issues. Fix for consistency. No functional or semantic change. Signed-off-by: Pierre-Louis Bossart Signed-off-by: Bjorn Andersson --- drivers/rpmsg/rpmsg_core.c | 8 ++++---- drivers/rpmsg/rpmsg_internal.h | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/rpmsg/rpmsg_core.c b/drivers/rpmsg/rpmsg_core.c index ea88fd4e2a6e..e330ec4dfc33 100644 --- a/drivers/rpmsg/rpmsg_core.c +++ b/drivers/rpmsg/rpmsg_core.c @@ -46,7 +46,7 @@ * equals to the src address of their rpmsg channel), the driver's handler * is invoked to process it. * - * That said, more complicated drivers might do need to allocate + * That said, more complicated drivers might need to allocate * additional rpmsg addresses, and bind them to different rx callbacks. * To accomplish that, those drivers need to call this function. * @@ -177,7 +177,7 @@ int rpmsg_send_offchannel(struct rpmsg_endpoint *ept, u32 src, u32 dst, EXPORT_SYMBOL(rpmsg_send_offchannel); /** - * rpmsg_send() - send a message across to the remote processor + * rpmsg_trysend() - send a message across to the remote processor * @ept: the rpmsg endpoint * @data: payload of message * @len: length of payload @@ -205,7 +205,7 @@ int rpmsg_trysend(struct rpmsg_endpoint *ept, void *data, int len) EXPORT_SYMBOL(rpmsg_trysend); /** - * rpmsg_sendto() - send a message across to the remote processor, specify dst + * rpmsg_trysendto() - send a message across to the remote processor, specify dst * @ept: the rpmsg endpoint * @data: payload of message * @len: length of payload @@ -253,7 +253,7 @@ __poll_t rpmsg_poll(struct rpmsg_endpoint *ept, struct file *filp, EXPORT_SYMBOL(rpmsg_poll); /** - * rpmsg_send_offchannel() - send a message using explicit src/dst addresses + * rpmsg_trysend_offchannel() - send a message using explicit src/dst addresses * @ept: the rpmsg endpoint * @src: source address * @dst: destination address diff --git a/drivers/rpmsg/rpmsg_internal.h b/drivers/rpmsg/rpmsg_internal.h index 0d791c30b7ea..3fc83cd50e98 100644 --- a/drivers/rpmsg/rpmsg_internal.h +++ b/drivers/rpmsg/rpmsg_internal.h @@ -20,7 +20,7 @@ /** * struct rpmsg_device_ops - indirection table for the rpmsg_device operations - * @create_ept: create backend-specific endpoint, requried + * @create_ept: create backend-specific endpoint, required * @announce_create: announce presence of new channel, optional * @announce_destroy: announce destruction of channel, optional * @@ -39,13 +39,14 @@ struct rpmsg_device_ops { /** * struct rpmsg_endpoint_ops - indirection table for rpmsg_endpoint operations - * @destroy_ept: destroy the given endpoint, required + * @destroy_ept: see @rpmsg_destroy_ept(), required * @send: see @rpmsg_send(), required * @sendto: see @rpmsg_sendto(), optional * @send_offchannel: see @rpmsg_send_offchannel(), optional * @trysend: see @rpmsg_trysend(), required * @trysendto: see @rpmsg_trysendto(), optional * @trysend_offchannel: see @rpmsg_trysend_offchannel(), optional + * @poll: see @rpmsg_poll(), optional * * Indirection table for the operations that a rpmsg backend should implement. * In addition to @destroy_ept, the backend must at least implement @send and From 13ef71f074837b53a25822e0a6912c2aefe55019 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Fri, 22 Feb 2019 22:20:16 -0600 Subject: [PATCH 4/7] MAINTAINERS: rpmsg: fix git tree location The current information isn't up-to-date, use Bjorn Andersson's kernel.org repo instead. Signed-off-by: Pierre-Louis Bossart [bjorn: Replaced github URL] Signed-off-by: Bjorn Andersson --- MAINTAINERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MAINTAINERS b/MAINTAINERS index 783569e3c4b4..f045b89bbc6f 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -13608,7 +13608,7 @@ REMOTE PROCESSOR MESSAGING (RPMSG) SUBSYSTEM M: Ohad Ben-Cohen M: Bjorn Andersson L: linux-remoteproc@vger.kernel.org -T: git git://git.kernel.org/pub/scm/linux/kernel/git/ohad/rpmsg.git +T: git git://git.kernel.org/pub/scm/linux/kernel/git/andersson/remoteproc.git rpmsg-next S: Maintained F: drivers/rpmsg/ F: Documentation/rpmsg.txt From de4064af76537f13d74a814a962f4524e81436ac Mon Sep 17 00:00:00 2001 From: Suman Anna Date: Tue, 23 Oct 2018 20:19:09 -0500 Subject: [PATCH 5/7] rpmsg: virtio_rpmsg_bus: replace "%p" with "%pK" The virtio_rpmsg_bus driver uses the "%p" format-specifier for printing the vring buffer address. This prints only a hashed pointer even for previliged users. Use "%pK" instead so that the address can be printed during debug using kptr_restrict sysctl. Signed-off-by: Suman Anna Signed-off-by: Bjorn Andersson --- drivers/rpmsg/virtio_rpmsg_bus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/rpmsg/virtio_rpmsg_bus.c b/drivers/rpmsg/virtio_rpmsg_bus.c index 5d3685bd76a2..376ebbf880d6 100644 --- a/drivers/rpmsg/virtio_rpmsg_bus.c +++ b/drivers/rpmsg/virtio_rpmsg_bus.c @@ -920,7 +920,7 @@ static int rpmsg_probe(struct virtio_device *vdev) goto vqs_del; } - dev_dbg(&vdev->dev, "buffers: va %p, dma %pad\n", + dev_dbg(&vdev->dev, "buffers: va %pK, dma %pad\n", bufs_va, &vrp->bufs_dma); /* half of the buffers is dedicated for RX */ From 61c65f47f30a1f32e0a84fe8335cd0360a028b48 Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Thu, 29 Aug 2019 13:17:21 -0500 Subject: [PATCH 6/7] rpmsg: glink: Use struct_size() helper One of the more common cases of allocation size calculations is finding the size of a structure that has a zero-sized array at the end, along with memory for some number of elements for that array. For example: struct { ... struct intent_pair intents[]; } __packed * msg; Make use of the struct_size() helper instead of an open-coded version in order to avoid any potential type mistakes. So, replace the following form: sizeof(*msg) + sizeof(struct intent_pair) * count with: struct_size(msg, intents, count) This code was detected with the help of Coccinelle. Signed-off-by: Gustavo A. R. Silva Signed-off-by: Bjorn Andersson --- drivers/rpmsg/qcom_glink_native.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/rpmsg/qcom_glink_native.c b/drivers/rpmsg/qcom_glink_native.c index f46c787733e8..621f1afd4d6b 100644 --- a/drivers/rpmsg/qcom_glink_native.c +++ b/drivers/rpmsg/qcom_glink_native.c @@ -892,7 +892,7 @@ static void qcom_glink_handle_intent(struct qcom_glink *glink, struct intent_pair intents[]; } __packed * msg; - const size_t msglen = sizeof(*msg) + sizeof(struct intent_pair) * count; + const size_t msglen = struct_size(msg, intents, count); int ret; int i; unsigned long flags; From 9fe69a725e238ac279027f0132e50617a63b847d Mon Sep 17 00:00:00 2001 From: Bjorn Andersson Date: Mon, 19 Aug 2019 21:16:56 -0700 Subject: [PATCH 7/7] rpmsg: glink-smem: Name the edge based on parent remoteproc Naming the glink edge device on the parent of_node short name causes collisions when multiple remoteproc instances with only different unit address are described on the platform_bus in DeviceTree. Base the edge's name on the parent remoteproc's name instead, to ensure that it's unique. Reviewed-by: Niklas Cassel Signed-off-by: Bjorn Andersson --- drivers/rpmsg/qcom_glink_smem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/rpmsg/qcom_glink_smem.c b/drivers/rpmsg/qcom_glink_smem.c index 64a5ce324c7f..4238383d8685 100644 --- a/drivers/rpmsg/qcom_glink_smem.c +++ b/drivers/rpmsg/qcom_glink_smem.c @@ -201,7 +201,7 @@ struct qcom_glink *qcom_glink_smem_register(struct device *parent, dev->parent = parent; dev->of_node = node; dev->release = qcom_glink_smem_release; - dev_set_name(dev, "%pOFn:%pOFn", node->parent, node); + dev_set_name(dev, "%s:%pOFn", dev_name(parent->parent), node); ret = device_register(dev); if (ret) { pr_err("failed to register glink edge\n");