This is an automated email from the ASF dual-hosted git repository. GUIDINGLI pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 2003a1cbfa6ef92994eab9266e6818422829a186 Author: Bowen Wang <[email protected]> AuthorDate: Tue Nov 24 13:07:00 2026 +0800 openamp: take the ns endpoint reference just once Add a patch that takes the reference to the matched endpoint once in rpmsg_ns_handle_msg() instead of separately in each of its branches. Signed-off-by: Bowen Wang <[email protected]> --- ...-take-the-ns-endpoint-reference-just-once.patch | 93 ++++++++++++++++++++++ openamp/open-amp.cmake | 2 + openamp/open-amp.defs | 1 + 3 files changed, 96 insertions(+) diff --git a/openamp/0028-rpmsg-take-the-ns-endpoint-reference-just-once.patch b/openamp/0028-rpmsg-take-the-ns-endpoint-reference-just-once.patch new file mode 100644 index 00000000000..50bce6d9557 --- /dev/null +++ b/openamp/0028-rpmsg-take-the-ns-endpoint-reference-just-once.patch @@ -0,0 +1,93 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Bowen Wang <[email protected]> +Date: Thu, 27 Aug 2026 12:00:00 +0800 +Subject: [PATCH] rpmsg: take the ns endpoint reference just once + +rpmsg_ns_handle_msg() takes and drops a reference to the matched +endpoint separately in each of its three branches. Take it once right +after the lookup and drop it once at the end, so that a new branch +cannot forget it. + +Signed-off-by: Bowen Wang <[email protected]> +--- + lib/rpmsg/rpmsg_ns.c | 29 ++++++++--------------------- + 1 file changed, 8 insertions(+), 21 deletions(-) + +diff --git a/lib/rpmsg/rpmsg_ns.c open-amp/lib/rpmsg/rpmsg_ns.c +index 2102c7c..7e6831b 100644 +--- a/lib/rpmsg/rpmsg_ns.c ++++ open-amp/lib/rpmsg/rpmsg_ns.c +@@ -28,22 +28,17 @@ void rpmsg_ns_handle_msg(struct rpmsg_device *rdev, + * Test ept->release_cb before calling ns_unbind_cb() callbacks. + */ + ept_to_release = ept && ept->release_cb; ++ if (ept_to_release) ++ rpmsg_ept_incref(ept); + + if (ns_msg->flags == RPMSG_NS_DESTROY) { + if (ept) + ept->dest_addr = RPMSG_ADDR_ANY; +- if (ept_to_release) +- rpmsg_ept_incref(ept); + metal_mutex_release(&rdev->lock); + if (ept && ept->ns_unbind_cb) + ept->ns_unbind_cb(ept); + if (rdev->ns_unbind_cb) + rdev->ns_unbind_cb(rdev, ns_msg->name, dest); +- if (ept_to_release) { +- metal_mutex_acquire(&rdev->lock); +- rpmsg_ept_decref(ept); +- metal_mutex_release(&rdev->lock); +- } + } else if (ns_msg->flags == RPMSG_NS_CREATE) { + if (!ept) { + /* +@@ -57,19 +52,12 @@ void rpmsg_ns_handle_msg(struct rpmsg_device *rdev, + rdev->ns_bind_cb(rdev, ns_msg->name, dest); + } else if (ept->dest_addr == RPMSG_ADDR_ANY) { + ept->dest_addr = dest; +- if (ept_to_release) +- rpmsg_ept_incref(ept); + metal_mutex_release(&rdev->lock); + if (ept->name[0] && rdev->support_ack) + rpmsg_send_ns_message(ept, RPMSG_NS_CREATE_ACK); + /* notify application that the endpoint has been bound */ + if (ept->ns_bound_cb) + ept->ns_bound_cb(ept); +- if (ept_to_release) { +- metal_mutex_acquire(&rdev->lock); +- rpmsg_ept_decref(ept); +- metal_mutex_release(&rdev->lock); +- } + } + else + metal_mutex_release(&rdev->lock); +@@ -77,19 +65,18 @@ void rpmsg_ns_handle_msg(struct rpmsg_device *rdev, + /* save the received destination address */ + if (ept && ept->dest_addr == RPMSG_ADDR_ANY) { + ept->dest_addr = dest; +- if (ept_to_release) +- rpmsg_ept_incref(ept); + metal_mutex_release(&rdev->lock); + /* notify application that the endpoint has been bound */ + if (ept->ns_bound_cb) + ept->ns_bound_cb(ept); +- if (ept_to_release) { +- metal_mutex_acquire(&rdev->lock); +- rpmsg_ept_decref(ept); +- metal_mutex_release(&rdev->lock); +- } + } + else + metal_mutex_release(&rdev->lock); + } ++ ++ if (ept_to_release) { ++ metal_mutex_acquire(&rdev->lock); ++ rpmsg_ept_decref(ept); ++ metal_mutex_release(&rdev->lock); ++ } + } +-- +2.34.1 + diff --git a/openamp/open-amp.cmake b/openamp/open-amp.cmake index ae98ab33aab..f543b4c117b 100644 --- a/openamp/open-amp.cmake +++ b/openamp/open-amp.cmake @@ -92,6 +92,8 @@ if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/open-amp) ${CMAKE_CURRENT_LIST_DIR}/0026-rpmsg_virtio-hold-the-endpoint-across-the-ns-bound-c.patch && patch -p0 -d ${CMAKE_CURRENT_LIST_DIR} < ${CMAKE_CURRENT_LIST_DIR}/0027-rpmsg-extract-the-name-service-handling-into-a-commo.patch + && patch -p0 -d ${CMAKE_CURRENT_LIST_DIR} < + ${CMAKE_CURRENT_LIST_DIR}/0028-rpmsg-take-the-ns-endpoint-reference-just-once.patch DOWNLOAD_NO_PROGRESS true TIMEOUT 30) diff --git a/openamp/open-amp.defs b/openamp/open-amp.defs index f908b19b90f..a6cb16f2c58 100644 --- a/openamp/open-amp.defs +++ b/openamp/open-amp.defs @@ -94,6 +94,7 @@ open-amp.zip: $(Q) patch -p0 < 0025-rpmsg_virtio-add-priority-in-the-rpmsg-virtio-config.patch $(Q) patch -p0 < 0026-rpmsg_virtio-hold-the-endpoint-across-the-ns-bound-c.patch $(Q) patch -p0 < 0027-rpmsg-extract-the-name-service-handling-into-a-commo.patch + $(Q) patch -p0 < 0028-rpmsg-take-the-ns-endpoint-reference-just-once.patch .openamp_headers: open-amp.zip else
