From 9a6c788f309f09f5cb6f3acbe900213c570e9692 Mon Sep 17 00:00:00 2001 From: Bowen Wang Date: Thu, 18 Dec 2025 16:25:27 +0800 Subject: [PATCH 1/8] openamp: update openamp and libmetal to last release version and remove somes libmetal and openamp patches that already merged in the OpenAMP and Libmetal community. Signed-off-by: Bowen Wang --- .../0001-lib-errno.h-fix-compile-error.patch | 28 ---- ...et-HAVE_STDATOMIC_H-default-true-in-.patch | 33 ++++ ...wledge-the-received-creation-message.patch | 32 ++-- ...e-individual-buffer-size-dynamically.patch | 24 +-- .../0003-atomic.h-fix-compiler-error.patch | 51 ------ ...-user-when-the-remote-address-is-rec.patch | 10 +- ...x-fix-unused-parameter-compile-error.patch | 155 ------------------ ...-negotiate_features-also-can-be-call.patch | 36 ---- ...-rpmsg-wait-ept-ready-in-rpmsg_send.patch} | 22 +-- ...et-HAVE_STDATOMIC_H-default-true-in-.patch | 40 ----- ...add-VIRTIO_RING_F_MUST_NOTIFY-event.patch} | 16 +- ..._virtio-change-sched_yeild-to-usleep.patch | 48 ------ ...-io.c-include-stddef.h-in-nuttx-io.c.patch | 27 --- ...t-need-check-status-when-get_tx_pay.patch} | 10 +- ...tx-Update-function-prototype-changes.patch | 58 ------- ...irtqueue_nused-and-virtqueue_navail-.patch | 149 +++++++++++++++++ ...virtio-add-last-buffer-check-to-fix-.patch | 67 ++++++++ ..._rx_buffer-return_rx_buffer-to-resol.patch | 57 ------- ...ture-to-64-bit-in-all-virtio_dispat.patch} | 87 +++++----- ...dd-assert-when-get-tx-buffer-failed.patch} | 8 +- ...irtqueue_kick-after-all-rx-buffer-re.patch | 70 -------- ...io.c-fix-get_tx_payload_buffer-error.patch | 32 ---- ...d-memory-operation-for-virtio-device.patch | 97 ----------- openamp/CMakeLists.txt | 4 +- openamp/Makefile | 4 +- openamp/libmetal.cmake | 16 +- openamp/libmetal.defs | 11 +- openamp/open-amp.cmake | 24 +-- openamp/open-amp.defs | 33 ++-- 29 files changed, 382 insertions(+), 867 deletions(-) delete mode 100644 openamp/0001-lib-errno.h-fix-compile-error.patch create mode 100644 openamp/0001-libmetal-cmake-set-HAVE_STDATOMIC_H-default-true-in-.patch delete mode 100644 openamp/0003-atomic.h-fix-compiler-error.patch delete mode 100644 openamp/0004-lib-system-nuttx-fix-unused-parameter-compile-error.patch delete mode 100644 openamp/0004-openamp-virtio.h-negotiate_features-also-can-be-call.patch rename openamp/{0006-rpmsg-wait-ept-ready-in-rpmsg_send.patch => 0004-rpmsg-wait-ept-ready-in-rpmsg_send.patch} (89%) delete mode 100644 openamp/0005-libmetal-cmake-set-HAVE_STDATOMIC_H-default-true-in-.patch rename openamp/{0007-openamp-add-VIRTIO_RING_F_MUST_NOTIFY-event.patch => 0005-openamp-add-VIRTIO_RING_F_MUST_NOTIFY-event.patch} (72%) delete mode 100644 openamp/0005-remoteproc-rpmsg_virtio-change-sched_yeild-to-usleep.patch delete mode 100644 openamp/0006-lib-system-nuttx-io.c-include-stddef.h-in-nuttx-io.c.patch rename openamp/{0008-rpmsg_virtio-don-t-need-check-status-when-get_tx_pay.patch => 0006-rpmsg_virtio-don-t-need-check-status-when-get_tx_pay.patch} (76%) delete mode 100644 openamp/0007-libmetal-nuttx-Update-function-prototype-changes.patch create mode 100644 openamp/0007-virtqueue-move-virtqueue_nused-and-virtqueue_navail-.patch create mode 100644 openamp/0008-lib-rpmsg-rpmsg_virtio-add-last-buffer-check-to-fix-.patch delete mode 100644 openamp/0009-openamp-swap-get_rx_buffer-return_rx_buffer-to-resol.patch rename openamp/{0011-virtio-change-feature-to-64-bit-in-all-virtio_dispat.patch => 0009-virtio-change-feature-to-64-bit-in-all-virtio_dispat.patch} (80%) rename openamp/{0013-openamp-add-assert-when-get-tx-buffer-failed.patch => 0010-openamp-add-assert-when-get-tx-buffer-failed.patch} (69%) delete mode 100644 openamp/0010-rpmsg_virtio.c-virtqueue_kick-after-all-rx-buffer-re.patch delete mode 100644 openamp/0012-rpmsg_virtio.c-fix-get_tx_payload_buffer-error.patch delete mode 100644 openamp/0014-virtio.h-add-memory-operation-for-virtio-device.patch diff --git a/openamp/0001-lib-errno.h-fix-compile-error.patch b/openamp/0001-lib-errno.h-fix-compile-error.patch deleted file mode 100644 index 48444e474d9ce..0000000000000 --- a/openamp/0001-lib-errno.h-fix-compile-error.patch +++ /dev/null @@ -1,28 +0,0 @@ -From b7eaa824f0f660825a7c2d601940d59141fb4f83 Mon Sep 17 00:00:00 2001 -From: wangyongrong -Date: Tue, 2 Jul 2024 10:27:44 +0800 -Subject: [PATCH 1/5] lib/errno.h: fix compile error - -lib/errno.h: delete defined(__arm__) for use GCC compile - -Signed-off-by: wangyongrong ---- - lib/errno.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/lib/errno.h libmetal/lib/errno.h -index 2fc4f77..e84a2bc 100644 ---- a/lib/errno.h -+++ libmetal/lib/errno.h -@@ -14,7 +14,7 @@ - - #if defined(__ICCARM__) - # include --#elif defined(__CC_ARM) || defined(__arm__) -+#elif defined(__CC_ARM) - # include - #else - # include --- -2.34.1 - diff --git a/openamp/0001-libmetal-cmake-set-HAVE_STDATOMIC_H-default-true-in-.patch b/openamp/0001-libmetal-cmake-set-HAVE_STDATOMIC_H-default-true-in-.patch new file mode 100644 index 0000000000000..2ca6017b08935 --- /dev/null +++ b/openamp/0001-libmetal-cmake-set-HAVE_STDATOMIC_H-default-true-in-.patch @@ -0,0 +1,33 @@ +From fad5ddc80345f97a0c7b20c545502ac1f8e321a5 Mon Sep 17 00:00:00 2001 +From: Bowen Wang +Date: Thu, 18 Dec 2025 17:26:13 +0800 +Subject: [PATCH] libmetal(cmake):set HAVE_STDATOMIC_H default true in NuttX + platform + +Signed-off-by: Bowen Wang +--- + cmake/depends.cmake | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +diff --git a/cmake/depends.cmake libmetal/cmake/depends.cmake +index cb53903..15683f8 100644 +--- a/cmake/depends.cmake ++++ libmetal/cmake/depends.cmake +@@ -24,7 +24,13 @@ if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") + find_package(LibRt REQUIRED) + collect (PROJECT_LIB_DEPS "${LIBRT_LIBRARIES}") + +-elseif (NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "NuttX") ++elseif ("${CMAKE_SYSTEM_NAME}" STREQUAL "NuttX") ++ ++ # there is no need to use cmake include detection ++ # under NuttX platform ++ set(HAVE_STDATOMIC_H true) ++ ++else () + + # TODO: fix for find_path() to detect stdatomic.h + # find_path (HAVE_STDATOMIC_H stdatomic.h) +-- +2.34.1 + diff --git a/openamp/0001-ns-acknowledge-the-received-creation-message.patch b/openamp/0001-ns-acknowledge-the-received-creation-message.patch index 0fa6d3f39c99e..e62f3f20390d3 100644 --- a/openamp/0001-ns-acknowledge-the-received-creation-message.patch +++ b/openamp/0001-ns-acknowledge-the-received-creation-message.patch @@ -1,7 +1,7 @@ -From 5f90973cb572ec8df29ea03550eef29afa48015b Mon Sep 17 00:00:00 2001 +From a4f6ac1cb1545fdadf7f80cf34f1d31b15d543f7 Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Mon, 7 Jan 2019 02:15:42 +0800 -Subject: [PATCH 01/14] ns: acknowledge the received creation message +Subject: [PATCH 01/10] ns: acknowledge the received creation message the two phase handshake make the client could initiate the transfer immediately without the server side send any dummy message first. @@ -17,7 +17,7 @@ Signed-off-by: wangyongrong 5 files changed, 21 insertions(+), 4 deletions(-) diff --git a/lib/include/openamp/rpmsg.h open-amp/lib/include/openamp/rpmsg.h -index f994e1d..b2a9b17 100644 +index 8871cfef88..0a4b47bae9 100644 --- a/lib/include/openamp/rpmsg.h +++ open-amp/lib/include/openamp/rpmsg.h @@ -155,6 +155,9 @@ struct rpmsg_device { @@ -31,7 +31,7 @@ index f994e1d..b2a9b17 100644 /** diff --git a/lib/include/openamp/rpmsg_virtio.h open-amp/lib/include/openamp/rpmsg_virtio.h -index 44ac4c0..6d6925f 100644 +index dbbbbfd245..b738e618cf 100644 --- a/lib/include/openamp/rpmsg_virtio.h +++ open-amp/lib/include/openamp/rpmsg_virtio.h @@ -29,6 +29,7 @@ extern "C" { @@ -40,13 +40,13 @@ index 44ac4c0..6d6925f 100644 #define VIRTIO_RPMSG_F_NS 0 /* RP supports name service notifications */ +#define VIRTIO_RPMSG_F_ACK 1 /* RP supports name service acknowledge */ - #ifdef VIRTIO_CACHED_BUFFERS - #warning "VIRTIO_CACHED_BUFFERS is deprecated, please use VIRTIO_USE_DCACHE" + #if defined(VIRTIO_USE_DCACHE) + #define BUFFER_FLUSH(x, s) metal_cache_flush(x, s) diff --git a/lib/rpmsg/rpmsg.c open-amp/lib/rpmsg/rpmsg.c -index 39774bc..8ab59e1 100644 +index b13e25fd23..28a8de61b3 100644 --- a/lib/rpmsg/rpmsg.c +++ open-amp/lib/rpmsg/rpmsg.c -@@ -357,10 +357,13 @@ int rpmsg_create_ept(struct rpmsg_endpoint *ept, struct rpmsg_device *rdev, +@@ -362,10 +362,13 @@ int rpmsg_create_ept(struct rpmsg_endpoint *ept, struct rpmsg_device *rdev, rpmsg_register_endpoint(rdev, ept, name, addr, dest, cb, unbind_cb, ept->priv); metal_mutex_release(&rdev->lock); @@ -62,7 +62,7 @@ index 39774bc..8ab59e1 100644 if (status) rpmsg_unregister_endpoint(ept); diff --git a/lib/rpmsg/rpmsg_internal.h open-amp/lib/rpmsg/rpmsg_internal.h -index 27b0f0d..1011b42 100644 +index 27b0f0d1b0..3e9ff02cb3 100644 --- a/lib/rpmsg/rpmsg_internal.h +++ open-amp/lib/rpmsg/rpmsg_internal.h @@ -44,6 +44,8 @@ enum rpmsg_ns_flags { @@ -75,10 +75,10 @@ index 27b0f0d..1011b42 100644 /** diff --git a/lib/rpmsg/rpmsg_virtio.c open-amp/lib/rpmsg/rpmsg_virtio.c -index 7baaedd..820227e 100644 +index ed3f4920c9..d59bad5d79 100644 --- a/lib/rpmsg/rpmsg_virtio.c +++ open-amp/lib/rpmsg/rpmsg_virtio.c -@@ -656,7 +656,7 @@ static int rpmsg_virtio_ns_callback(struct rpmsg_endpoint *ept, void *data, +@@ -668,7 +668,7 @@ static int rpmsg_virtio_ns_callback(struct rpmsg_endpoint *ept, void *data, */ ept_to_release = _ept && _ept->release_cb; @@ -87,7 +87,7 @@ index 7baaedd..820227e 100644 if (_ept) _ept->dest_addr = RPMSG_ADDR_ANY; if (ept_to_release) -@@ -671,7 +671,7 @@ static int rpmsg_virtio_ns_callback(struct rpmsg_endpoint *ept, void *data, +@@ -683,7 +683,7 @@ static int rpmsg_virtio_ns_callback(struct rpmsg_endpoint *ept, void *data, rpmsg_ept_decref(_ept); metal_mutex_release(&rdev->lock); } @@ -96,7 +96,7 @@ index 7baaedd..820227e 100644 if (!_ept) { /* * send callback to application, that can -@@ -685,7 +685,14 @@ static int rpmsg_virtio_ns_callback(struct rpmsg_endpoint *ept, void *data, +@@ -697,7 +697,14 @@ static int rpmsg_virtio_ns_callback(struct rpmsg_endpoint *ept, void *data, } else { _ept->dest_addr = dest; metal_mutex_release(&rdev->lock); @@ -111,15 +111,15 @@ index 7baaedd..820227e 100644 } return RPMSG_SUCCESS; -@@ -828,6 +835,7 @@ int rpmsg_init_vdev_with_config(struct rpmsg_virtio_device *rvdev, +@@ -840,6 +847,7 @@ int rpmsg_init_vdev_with_config(struct rpmsg_virtio_device *rvdev, if (status) return status; rdev->support_ns = !!(features & (1 << VIRTIO_RPMSG_F_NS)); + rdev->support_ack = !!(features & (1 << VIRTIO_RPMSG_F_ACK)); - if (VIRTIO_ROLE_IS_DRIVER(rvdev->vdev)) { + if (VIRTIO_ROLE_IS_DRIVER(vdev)) { /* -@@ -926,7 +934,7 @@ int rpmsg_init_vdev_with_config(struct rpmsg_virtio_device *rvdev, +@@ -938,7 +946,7 @@ int rpmsg_init_vdev_with_config(struct rpmsg_virtio_device *rvdev, * Create name service announcement endpoint if device supports name * service announcement feature. */ diff --git a/openamp/0002-Negotiate-individual-buffer-size-dynamically.patch b/openamp/0002-Negotiate-individual-buffer-size-dynamically.patch index 4e2e531b91295..dbf0b518bf6a0 100644 --- a/openamp/0002-Negotiate-individual-buffer-size-dynamically.patch +++ b/openamp/0002-Negotiate-individual-buffer-size-dynamically.patch @@ -1,7 +1,7 @@ -From a12f4359e3d4382e31a0f6f6983184b635fd0611 Mon Sep 17 00:00:00 2001 +From 4f552ae6fa88eec2a42c3933ea201ab71555838c Mon Sep 17 00:00:00 2001 From: anchao Date: Mon, 10 Dec 2018 16:26:39 +0800 -Subject: [PATCH 02/14] Negotiate individual buffer size dynamically +Subject: [PATCH 02/10] Negotiate individual buffer size dynamically Change config type from fw_rsc_config to rpmsg_virtio_config to avoid rpmsg_vitio.h couple with remoteproc.h. @@ -19,7 +19,7 @@ Signed-off-by: wangyongrong 3 files changed, 23 insertions(+) diff --git a/lib/include/openamp/remoteproc.h open-amp/lib/include/openamp/remoteproc.h -index 84bf233..abc5481 100644 +index 29b28ed0ad..aadc7a798f 100644 --- a/lib/include/openamp/remoteproc.h +++ open-amp/lib/include/openamp/remoteproc.h @@ -361,6 +361,21 @@ struct fw_rsc_vendor { @@ -45,7 +45,7 @@ index 84bf233..abc5481 100644 struct image_store_ops; struct remoteproc_ops; diff --git a/lib/include/openamp/rpmsg_virtio.h open-amp/lib/include/openamp/rpmsg_virtio.h -index 6d6925f..d9cfa9b 100644 +index b738e618cf..a757166082 100644 --- a/lib/include/openamp/rpmsg_virtio.h +++ open-amp/lib/include/openamp/rpmsg_virtio.h @@ -30,6 +30,7 @@ extern "C" { @@ -54,21 +54,21 @@ index 6d6925f..d9cfa9b 100644 #define VIRTIO_RPMSG_F_ACK 1 /* RP supports name service acknowledge */ +#define VIRTIO_RPMSG_F_BUFSZ 2 /* RP supports get buffer size from config space */ - #ifdef VIRTIO_CACHED_BUFFERS - #warning "VIRTIO_CACHED_BUFFERS is deprecated, please use VIRTIO_USE_DCACHE" + #if defined(VIRTIO_USE_DCACHE) + #define BUFFER_FLUSH(x, s) metal_cache_flush(x, s) diff --git a/lib/rpmsg/rpmsg_virtio.c open-amp/lib/rpmsg/rpmsg_virtio.c -index 820227e..94c4b95 100644 +index d59bad5d79..8654e7d8b8 100644 --- a/lib/rpmsg/rpmsg_virtio.c +++ open-amp/lib/rpmsg/rpmsg_virtio.c -@@ -12,6 +12,7 @@ - #include +@@ -13,6 +13,7 @@ + #include #include #include +#include #include #include "rpmsg_internal.h" -@@ -790,6 +791,7 @@ int rpmsg_init_vdev_with_config(struct rpmsg_virtio_device *rvdev, +@@ -802,6 +803,7 @@ int rpmsg_init_vdev_with_config(struct rpmsg_virtio_device *rvdev, struct rpmsg_device *rdev; const char *vq_names[RPMSG_NUM_VRINGS]; vq_callback callback[RPMSG_NUM_VRINGS]; @@ -76,7 +76,7 @@ index 820227e..94c4b95 100644 uint32_t features; int status; unsigned int i; -@@ -836,6 +838,11 @@ int rpmsg_init_vdev_with_config(struct rpmsg_virtio_device *rvdev, +@@ -848,6 +850,11 @@ int rpmsg_init_vdev_with_config(struct rpmsg_virtio_device *rvdev, return status; rdev->support_ns = !!(features & (1 << VIRTIO_RPMSG_F_NS)); rdev->support_ack = !!(features & (1 << VIRTIO_RPMSG_F_ACK)); @@ -86,7 +86,7 @@ index 820227e..94c4b95 100644 + rvdev->config.r2h_buf_size = fw_config.r2h_buf_size; + } - if (VIRTIO_ROLE_IS_DRIVER(rvdev->vdev)) { + if (VIRTIO_ROLE_IS_DRIVER(vdev)) { /* -- 2.34.1 diff --git a/openamp/0003-atomic.h-fix-compiler-error.patch b/openamp/0003-atomic.h-fix-compiler-error.patch deleted file mode 100644 index 4056a3260d14d..0000000000000 --- a/openamp/0003-atomic.h-fix-compiler-error.patch +++ /dev/null @@ -1,51 +0,0 @@ -From 6842947d3cd08748b8d44fd771a53a86ddfc8dac Mon Sep 17 00:00:00 2001 -From: Yongrong Wang -Date: Fri, 19 Jul 2024 17:40:51 +0800 -Subject: [PATCH 3/5] atomic.h: fix compiler error - -/home/wyr/work/code/velasim/upgrade/nuttx/include/metal/compiler/gcc/atomic.h:19:13: error: conflicting type qualifiers for 'atomic_flag' - 19 | typedef int atomic_flag; - | ^~~~~~~~~~~ -In file included from /home/wyr/work/code/velasim/upgrade/nuttx/include/nuttx/net/netdev_lowerhalf.h:38, - from virtio/virtio-net.c:33: -/home/wyr/work/code/velasim/upgrade/prebuilts/gcc/linux/arm/lib/gcc/arm-none-eabi/13.2.1/include/stdatomic.h:233:3: note: previous declaration of 'atomic_flag' with type 'atomic_flag' - 233 | } atomic_flag; - | ^~~~~~~~~~~ -/home/wyr/work/code/velasim/upgrade/nuttx/include/metal/compiler/gcc/atomic.h:20:14: error: conflicting type qualifiers for 'atomic_char' - 20 | typedef char atomic_char; - | ^~~~~~~~~~~ -/home/wyr/work/code/velasim/upgrade/prebuilts/gcc/linux/arm/lib/gcc/arm-none-eabi/13.2.1/include/stdatomic.h:41:22: note: previous declaration of 'atomic_char' with type 'atomic_char' {aka '_Atomic char'} - 41 | typedef _Atomic char atomic_char; - | ^~~~~~~~~~~ -/home/wyr/work/code/velasim/upgrade/nuttx/include/metal/compiler/gcc/atomic.h:21:23: error: conflicting type qualifiers for 'atomic_uchar' - 21 | typedef unsigned char atomic_uchar; - | ^~~~~~~~~~~~ -/home/wyr/work/code/velasim/upgrade/prebuilts/gcc/linux/arm/lib/gcc/arm-none-eabi/13.2.1/include/stdatomic.h:43:31: note: previous declaration of 'atomic_uchar' with type 'atomic_uchar' {aka '_Atomic unsigned char'} - 43 | typedef _Atomic unsigned char atomic_uchar; - | ^~~~~~~~~~~~ -/home/wyr/work/code/velasim/upgrade/nuttx/include/metal/compiler/gcc/atomic.h:22:15: error: conflicting type qualifiers for 'atomic_short' - 22 | typedef short atomic_short; - -Signed-off-by: Yongrong Wang ---- - lib/atomic.h | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/lib/atomic.h libmetal/lib/atomic.h -index 2f4ab04..fe2c1e0 100644 ---- a/lib/atomic.h -+++ libmetal/lib/atomic.h -@@ -100,8 +100,8 @@ using std::atomic_fetch_and_explicit; - using std::atomic_thread_fence; - using std::atomic_signal_fence; - --#elif defined(HAVE_STDATOMIC_H) && !defined(__CC_ARM) && !defined(__arm__) && \ -- !defined(__STDC_NO_ATOMICS__) -+#elif defined(HAVE_STDATOMIC_H) && !defined(__STDC_NO_ATOMICS__) && \ -+ ((!defined(__CC_ARM) && !defined(__arm__)) || defined(__GNUC__)) - # include - # include - #elif defined(__GNUC__) --- -2.34.1 - diff --git a/openamp/0003-rpmsg-notify-the-user-when-the-remote-address-is-rec.patch b/openamp/0003-rpmsg-notify-the-user-when-the-remote-address-is-rec.patch index 7db9086e559b3..e84f21216d01b 100644 --- a/openamp/0003-rpmsg-notify-the-user-when-the-remote-address-is-rec.patch +++ b/openamp/0003-rpmsg-notify-the-user-when-the-remote-address-is-rec.patch @@ -1,7 +1,7 @@ -From ccedce5807709d184a9fe89529e611a556f0bf23 Mon Sep 17 00:00:00 2001 +From 0fd409ef494b47464f57667b24fce91a4f1a5753 Mon Sep 17 00:00:00 2001 From: ligd Date: Tue, 19 Oct 2021 19:45:14 +0800 -Subject: [PATCH 03/14] rpmsg: notify the user when the remote address is +Subject: [PATCH 03/10] rpmsg: notify the user when the remote address is received Signed-off-by: ligd @@ -12,7 +12,7 @@ Signed-off-by: wangyongrong 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/lib/include/openamp/rpmsg.h open-amp/lib/include/openamp/rpmsg.h -index b2a9b17..bb1c160 100644 +index 0a4b47bae9..a0e351af68 100644 --- a/lib/include/openamp/rpmsg.h +++ open-amp/lib/include/openamp/rpmsg.h @@ -52,6 +52,7 @@ struct rpmsg_device; @@ -34,10 +34,10 @@ index b2a9b17..bb1c160 100644 rpmsg_ns_unbind_cb ns_unbind_cb; diff --git a/lib/rpmsg/rpmsg_virtio.c open-amp/lib/rpmsg/rpmsg_virtio.c -index 94c4b95..ad9a730 100644 +index 8654e7d8b8..cc6c2fd52f 100644 --- a/lib/rpmsg/rpmsg_virtio.c +++ open-amp/lib/rpmsg/rpmsg_virtio.c -@@ -683,17 +683,28 @@ static int rpmsg_virtio_ns_callback(struct rpmsg_endpoint *ept, void *data, +@@ -695,17 +695,28 @@ static int rpmsg_virtio_ns_callback(struct rpmsg_endpoint *ept, void *data, metal_mutex_release(&rdev->lock); if (rdev->ns_bind_cb) rdev->ns_bind_cb(rdev, name, dest); diff --git a/openamp/0004-lib-system-nuttx-fix-unused-parameter-compile-error.patch b/openamp/0004-lib-system-nuttx-fix-unused-parameter-compile-error.patch deleted file mode 100644 index fe31a3665a26e..0000000000000 --- a/openamp/0004-lib-system-nuttx-fix-unused-parameter-compile-error.patch +++ /dev/null @@ -1,155 +0,0 @@ -From f003d671f816b319ad0f8d017022c93b438b78b3 Mon Sep 17 00:00:00 2001 -From: Yongrong Wang -Date: Mon, 9 Sep 2024 19:46:37 +0800 -Subject: [PATCH 4/5] lib/system/nuttx: fix unused parameter compile error -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -/home/wyr/work/code/project/cardev/nuttx/openamp/libmetal/lib/system/nuttx/device.c:16:22: error: 'io' undeclared (first use in this function) - 16 | metal_unused(io); -/home/wyr/work/code/project/cardev/nuttx/openamp/libmetal/lib/system/nuttx/device.c:14:53: error: unused parameter 'dev' [-Werror=unused-parameter] - 14 | int metal_generic_dev_sys_open(struct metal_device *dev) - -error: unused parameter ‘addr’ [-Werror=unused-parameter] - 25 | static inline void __metal_cache_flush(void *addr, unsigned int len) - | ~~~~~~^~~~ -error: unused parameter ‘len’ [-Werror=unused-parameter] - 25 | static inline void __metal_cache_flush(void *addr, unsigned int len) - | ~~~~~~~~~~~~~^~~ - -Signed-off-by: Yongrong Wang ---- - lib/system/nuttx/cache.h | 5 +++++ - lib/system/nuttx/device.c | 1 + - lib/system/nuttx/init.c | 1 + - lib/system/nuttx/io.c | 6 ++++++ - lib/system/nuttx/io.h | 3 +++ - 5 files changed, 16 insertions(+) - -diff --git a/lib/system/nuttx/cache.h libmetal/lib/system/nuttx/cache.h -index e3b6052..22b94b4 100644 ---- a/lib/system/nuttx/cache.h -+++ libmetal/lib/system/nuttx/cache.h -@@ -16,6 +16,7 @@ - #ifndef __METAL_NUTTX_CACHE__H__ - #define __METAL_NUTTX_CACHE__H__ - -+#include - #include - - #ifdef __cplusplus -@@ -24,11 +25,15 @@ extern "C" { - - static inline void __metal_cache_flush(void *addr, unsigned int len) - { -+ metal_unused(addr); -+ metal_unused(len); - up_clean_dcache((uintptr_t)addr, (uintptr_t)addr + len); - } - - static inline void __metal_cache_invalidate(void *addr, unsigned int len) - { -+ metal_unused(addr); -+ metal_unused(len); - up_invalidate_dcache((uintptr_t)addr, (uintptr_t)addr + len); - } - -diff --git a/lib/system/nuttx/device.c libmetal/lib/system/nuttx/device.c -index 7e66ab3..2c828ab 100644 ---- a/lib/system/nuttx/device.c -+++ libmetal/lib/system/nuttx/device.c -@@ -13,5 +13,6 @@ - - int metal_generic_dev_sys_open(struct metal_device *dev) - { -+ metal_unused(dev); - return 0; - } -diff --git a/lib/system/nuttx/init.c libmetal/lib/system/nuttx/init.c -index 8d59784..2519dc6 100644 ---- a/lib/system/nuttx/init.c -+++ libmetal/lib/system/nuttx/init.c -@@ -19,6 +19,7 @@ int metal_sys_init(const struct metal_init_params *params) - { - int ret = metal_cntr_irq_init(); - -+ metal_unused(params); - if (ret >= 0) - ret = metal_bus_register(&metal_generic_bus); - return ret; -diff --git a/lib/system/nuttx/io.c libmetal/lib/system/nuttx/io.c -index ab9bc6a..41697a7 100644 ---- a/lib/system/nuttx/io.c -+++ libmetal/lib/system/nuttx/io.c -@@ -15,6 +15,7 @@ static uint64_t metal_io_read_(struct metal_io_region *io, - { - uint64_t value = 0; - -+ metal_unused(order); - metal_io_block_read(io, offset, &value, width); - return value; - } -@@ -25,6 +26,7 @@ static void metal_io_write_(struct metal_io_region *io, - memory_order order, - int width) - { -+ metal_unused(order); - metal_io_block_write(io, offset, &value, width); - } - -@@ -36,6 +38,7 @@ static int metal_io_block_read_(struct metal_io_region *io, - { - void *va = metal_io_virt(io, offset); - -+ metal_unused(order); - metal_cache_invalidate(va, len); - if (len == 1) - *(uint8_t *)dst = *(uint8_t *)va; -@@ -60,6 +63,7 @@ static int metal_io_block_write_(struct metal_io_region *io, - { - void *va = metal_io_virt(io, offset); - -+ metal_unused(order); - if (len == 1) - *(uint8_t *)va = *(uint8_t *)src; - else if (len == 2) -@@ -85,12 +89,14 @@ static void metal_io_block_set_(struct metal_io_region *io, - { - void *va = metal_io_virt(io, offset); - -+ metal_unused(order); - memset(va, value, len); - metal_cache_flush(va, len); - } - - static void metal_io_close_(struct metal_io_region *io) - { -+ metal_unused(io); - } - - static metal_phys_addr_t metal_io_offset_to_phys_(struct metal_io_region *io, -diff --git a/lib/system/nuttx/io.h libmetal/lib/system/nuttx/io.h -index 7f6508d..743b7b1 100644 ---- a/lib/system/nuttx/io.h -+++ libmetal/lib/system/nuttx/io.h -@@ -16,6 +16,8 @@ - #ifndef __METAL_NUTTX_IO__H__ - #define __METAL_NUTTX_IO__H__ - -+#include -+ - #ifdef __cplusplus - extern "C" { - #endif -@@ -39,6 +41,7 @@ struct metal_io_region *metal_io_get_region(void); - */ - static inline void metal_sys_io_mem_map(struct metal_io_region *io) - { -+ metal_unused(io); - } - #endif - --- -2.34.1 - diff --git a/openamp/0004-openamp-virtio.h-negotiate_features-also-can-be-call.patch b/openamp/0004-openamp-virtio.h-negotiate_features-also-can-be-call.patch deleted file mode 100644 index 36b6027ddefa4..0000000000000 --- a/openamp/0004-openamp-virtio.h-negotiate_features-also-can-be-call.patch +++ /dev/null @@ -1,36 +0,0 @@ -From 17ca934563b3d62f950f5d1693d89556495d150f Mon Sep 17 00:00:00 2001 -From: wangyongrong -Date: Tue, 2 Jul 2024 16:33:32 +0800 -Subject: [PATCH 04/14] openamp/virtio.h: negotiate_features also can be call - when final_features is NULL - -Signed-off-by: wangyongrong ---- - lib/include/openamp/virtio.h | 6 ++++-- - 1 file changed, 4 insertions(+), 2 deletions(-) - -diff --git a/lib/include/openamp/virtio.h open-amp/lib/include/openamp/virtio.h -index c4d4927..278d2da 100644 ---- a/lib/include/openamp/virtio.h -+++ open-amp/lib/include/openamp/virtio.h -@@ -468,13 +468,15 @@ static inline int virtio_negotiate_features(struct virtio_device *vdev, - uint32_t features, - uint32_t *final_features) - { -- if (!vdev || !final_features) -+ if (!vdev) - return -EINVAL; - - if (!vdev->func || !vdev->func->negotiate_features) - return -ENXIO; - -- *final_features = vdev->func->negotiate_features(vdev, features); -+ vdev->features = vdev->func->negotiate_features(vdev, features); -+ if (final_features) -+ *final_features = vdev->features; - return 0; - } - --- -2.34.1 - diff --git a/openamp/0006-rpmsg-wait-ept-ready-in-rpmsg_send.patch b/openamp/0004-rpmsg-wait-ept-ready-in-rpmsg_send.patch similarity index 89% rename from openamp/0006-rpmsg-wait-ept-ready-in-rpmsg_send.patch rename to openamp/0004-rpmsg-wait-ept-ready-in-rpmsg_send.patch index a7252a24628ae..0ed785ba35b01 100644 --- a/openamp/0006-rpmsg-wait-ept-ready-in-rpmsg_send.patch +++ b/openamp/0004-rpmsg-wait-ept-ready-in-rpmsg_send.patch @@ -1,7 +1,7 @@ -From 9ed3332f08c9877deb4dcabb7447b634abe8845e Mon Sep 17 00:00:00 2001 +From a2c5e7e101392eb8b72acd608b81b525c643cf4a Mon Sep 17 00:00:00 2001 From: ligd Date: Wed, 20 Feb 2019 11:36:57 +0800 -Subject: [PATCH 06/14] rpmsg: wait ept ready in rpmsg_send +Subject: [PATCH 04/10] rpmsg: wait ept ready in rpmsg_send since the destination address need time to return from peer @@ -9,11 +9,11 @@ Signed-off-by: ligd Signed-off-by: wangyongrong --- lib/include/openamp/rpmsg.h | 59 ++++++++++++++++++++++++++----------- - lib/rpmsg/rpmsg_virtio.c | 7 ----- - 2 files changed, 42 insertions(+), 24 deletions(-) + lib/rpmsg/rpmsg_virtio.c | 6 ---- + 2 files changed, 42 insertions(+), 23 deletions(-) diff --git a/lib/include/openamp/rpmsg.h open-amp/lib/include/openamp/rpmsg.h -index bb1c160..cb1a648 100644 +index a0e351af68..3f4c6c7fc6 100644 --- a/lib/include/openamp/rpmsg.h +++ open-amp/lib/include/openamp/rpmsg.h @@ -15,6 +15,7 @@ @@ -124,18 +124,10 @@ index bb1c160..cb1a648 100644 } #endif diff --git a/lib/rpmsg/rpmsg_virtio.c open-amp/lib/rpmsg/rpmsg_virtio.c -index db3392e..e6a4969 100644 +index cc6c2fd52f..0e2885c732 100644 --- a/lib/rpmsg/rpmsg_virtio.c +++ open-amp/lib/rpmsg/rpmsg_virtio.c -@@ -9,7 +9,6 @@ - */ - - #include --#include - #include - #include - #include -@@ -19,12 +18,6 @@ +@@ -20,12 +20,6 @@ #define RPMSG_NUM_VRINGS 2 diff --git a/openamp/0005-libmetal-cmake-set-HAVE_STDATOMIC_H-default-true-in-.patch b/openamp/0005-libmetal-cmake-set-HAVE_STDATOMIC_H-default-true-in-.patch deleted file mode 100644 index d4ecbd8a3aff0..0000000000000 --- a/openamp/0005-libmetal-cmake-set-HAVE_STDATOMIC_H-default-true-in-.patch +++ /dev/null @@ -1,40 +0,0 @@ -From 2b9bd97db33d95c4d6d40e6f0ec1fa388fac3ab0 Mon Sep 17 00:00:00 2001 -From: xuxin19 -Date: Fri, 6 Sep 2024 10:56:49 +0800 -Subject: [PATCH 5/5] libmetal(cmake):set HAVE_STDATOMIC_H default true in - NuttX platform - -Signed-off-by: xuxin19 ---- - cmake/depends.cmake | 10 ++++++++-- - 1 file changed, 8 insertions(+), 2 deletions(-) - -diff --git a/cmake/depends.cmake libmetal/cmake/depends.cmake -index 60b9739..15683f8 100644 ---- a/cmake/depends.cmake -+++ libmetal/cmake/depends.cmake -@@ -24,7 +24,13 @@ if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") - find_package(LibRt REQUIRED) - collect (PROJECT_LIB_DEPS "${LIBRT_LIBRARIES}") - --else ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") -+elseif ("${CMAKE_SYSTEM_NAME}" STREQUAL "NuttX") -+ -+ # there is no need to use cmake include detection -+ # under NuttX platform -+ set(HAVE_STDATOMIC_H true) -+ -+else () - - # TODO: fix for find_path() to detect stdatomic.h - # find_path (HAVE_STDATOMIC_H stdatomic.h) -@@ -33,5 +39,5 @@ else ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") - check_include_files (stdatomic.h HAVE_STDATOMIC_H) - set (CMAKE_REQUIRED_FLAGS ${_saved_cmake_required_flags}) - --endif ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") -+endif () - --- -2.34.1 - diff --git a/openamp/0007-openamp-add-VIRTIO_RING_F_MUST_NOTIFY-event.patch b/openamp/0005-openamp-add-VIRTIO_RING_F_MUST_NOTIFY-event.patch similarity index 72% rename from openamp/0007-openamp-add-VIRTIO_RING_F_MUST_NOTIFY-event.patch rename to openamp/0005-openamp-add-VIRTIO_RING_F_MUST_NOTIFY-event.patch index 23a4a6a484384..9fe851cdcb312 100644 --- a/openamp/0007-openamp-add-VIRTIO_RING_F_MUST_NOTIFY-event.patch +++ b/openamp/0005-openamp-add-VIRTIO_RING_F_MUST_NOTIFY-event.patch @@ -1,7 +1,7 @@ -From 9a8e63285c30026a8fabaf0ed8af323eafd07539 Mon Sep 17 00:00:00 2001 +From 7c6597d46da6d1c3c085dda33262c89b633707ae Mon Sep 17 00:00:00 2001 From: ligd Date: Thu, 23 Jun 2022 00:41:13 +0800 -Subject: [PATCH 07/14] openamp: add VIRTIO_RING_F_MUST_NOTIFY event +Subject: [PATCH 05/10] openamp: add VIRTIO_RING_F_MUST_NOTIFY event Signed-off-by: ligd --- @@ -10,7 +10,7 @@ Signed-off-by: ligd 2 files changed, 6 insertions(+) diff --git a/lib/include/openamp/virtqueue.h open-amp/lib/include/openamp/virtqueue.h -index 8194398..dd42c3a 100644 +index 7921948c8e..92a4a87f10 100644 --- a/lib/include/openamp/virtqueue.h +++ open-amp/lib/include/openamp/virtqueue.h @@ -48,6 +48,9 @@ extern "C" { @@ -20,14 +20,14 @@ index 8194398..dd42c3a 100644 +/* Support to can't suppress interrupt. */ +#define VIRTIO_RING_F_MUST_NOTIFY (1 << 30) + - /* cache invalidation helpers */ - #define CACHE_FLUSH(x, s) metal_cache_flush(x, s) - #define CACHE_INVALIDATE(x, s) metal_cache_invalidate(x, s) + #if defined(VIRTIO_USE_DCACHE) + #define VRING_FLUSH(x, s) metal_cache_flush(x, s) + #define VRING_INVALIDATE(x, s) metal_cache_invalidate(x, s) diff --git a/lib/virtio/virtqueue.c open-amp/lib/virtio/virtqueue.c -index 363fda8..7ffe569 100644 +index ed7af3fccd..d2738faaba 100644 --- a/lib/virtio/virtqueue.c +++ open-amp/lib/virtio/virtqueue.c -@@ -609,6 +609,9 @@ static int vq_ring_must_notify(struct virtqueue *vq) +@@ -633,6 +633,9 @@ static int vq_ring_must_notify(struct virtqueue *vq) { uint16_t new_idx, prev_idx, event_idx; diff --git a/openamp/0005-remoteproc-rpmsg_virtio-change-sched_yeild-to-usleep.patch b/openamp/0005-remoteproc-rpmsg_virtio-change-sched_yeild-to-usleep.patch deleted file mode 100644 index 53ac619f0a6d7..0000000000000 --- a/openamp/0005-remoteproc-rpmsg_virtio-change-sched_yeild-to-usleep.patch +++ /dev/null @@ -1,48 +0,0 @@ -From 8892766fc72db6d607e2057be0cf7386ee7fea14 Mon Sep 17 00:00:00 2001 -From: wangyongrong -Date: Wed, 3 Jul 2024 10:00:34 +0800 -Subject: [PATCH 05/14] remoteproc/rpmsg_virtio: change sched_yeild to usleep - -Signed-off-by: wangyongrong ---- - lib/remoteproc/remoteproc_virtio.c | 3 ++- - lib/rpmsg/rpmsg_virtio.c | 3 +-- - 2 files changed, 3 insertions(+), 3 deletions(-) - -diff --git a/lib/remoteproc/remoteproc_virtio.c open-amp/lib/remoteproc/remoteproc_virtio.c -index ef39c49..aae026c 100644 ---- a/lib/remoteproc/remoteproc_virtio.c -+++ open-amp/lib/remoteproc/remoteproc_virtio.c -@@ -15,6 +15,7 @@ - #include - #include - #include -+#include - - static void rproc_virtio_delete_virtqueues(struct virtio_device *vdev) - { -@@ -412,6 +413,6 @@ void rproc_virtio_wait_remote_ready(struct virtio_device *vdev) - status = rproc_virtio_get_status(vdev); - if (status & VIRTIO_CONFIG_STATUS_DRIVER_OK) - return; -- metal_cpu_yield(); -+ metal_sleep_usec(1000); - } - } -diff --git a/lib/rpmsg/rpmsg_virtio.c open-amp/lib/rpmsg/rpmsg_virtio.c -index ad9a730..db3392e 100644 ---- a/lib/rpmsg/rpmsg_virtio.c -+++ open-amp/lib/rpmsg/rpmsg_virtio.c -@@ -272,8 +272,7 @@ static int rpmsg_virtio_wait_remote_ready(struct rpmsg_virtio_device *rvdev) - } else if (status & VIRTIO_CONFIG_STATUS_DRIVER_OK) { - return 0; - } -- /* TODO: clarify metal_cpu_yield usage*/ -- metal_cpu_yield(); -+ metal_sleep_usec(1000); - } - } - --- -2.34.1 - diff --git a/openamp/0006-lib-system-nuttx-io.c-include-stddef.h-in-nuttx-io.c.patch b/openamp/0006-lib-system-nuttx-io.c-include-stddef.h-in-nuttx-io.c.patch deleted file mode 100644 index 3cfcb0beb9b14..0000000000000 --- a/openamp/0006-lib-system-nuttx-io.c-include-stddef.h-in-nuttx-io.c.patch +++ /dev/null @@ -1,27 +0,0 @@ -From b9181b30e8fc1c7ee058b34e6cfe2f54c43af665 Mon Sep 17 00:00:00 2001 -From: Bowen Wang -Date: Wed, 9 Oct 2024 20:54:56 +0800 -Subject: [PATCH 6/6] lib/system/nuttx/io.c: include in nuttx/io.c - -Because nuttx/io.c use NULL and NULL is defined in - -Signed-off-by: Bowen Wang ---- - lib/system/nuttx/io.c | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/lib/system/nuttx/io.c libmetal/lib/system/nuttx/io.c -index 41697a7..cc5e0a7 100644 ---- a/lib/system/nuttx/io.c -+++ libmetal/lib/system/nuttx/io.c -@@ -4,6 +4,7 @@ - * SPDX-License-Identifier: BSD-3-Clause - */ - -+#include - #include - #include - #include --- -2.34.1 - diff --git a/openamp/0008-rpmsg_virtio-don-t-need-check-status-when-get_tx_pay.patch b/openamp/0006-rpmsg_virtio-don-t-need-check-status-when-get_tx_pay.patch similarity index 76% rename from openamp/0008-rpmsg_virtio-don-t-need-check-status-when-get_tx_pay.patch rename to openamp/0006-rpmsg_virtio-don-t-need-check-status-when-get_tx_pay.patch index 3923d4c525337..3a060e763f467 100644 --- a/openamp/0008-rpmsg_virtio-don-t-need-check-status-when-get_tx_pay.patch +++ b/openamp/0006-rpmsg_virtio-don-t-need-check-status-when-get_tx_pay.patch @@ -1,7 +1,7 @@ -From b092024f77f34c679b0537f6481947d297bca281 Mon Sep 17 00:00:00 2001 +From 8dcd7daec66939841c10872a0ca310ac16f10be2 Mon Sep 17 00:00:00 2001 From: wangyongrong Date: Wed, 3 Jul 2024 10:28:31 +0800 -Subject: [PATCH 08/14] rpmsg_virtio: don't need check status when +Subject: [PATCH 06/10] rpmsg_virtio: don't need check status when get_tx_payload Signed-off-by: ligd @@ -10,10 +10,10 @@ Signed-off-by: ligd 1 file changed, 6 deletions(-) diff --git a/lib/rpmsg/rpmsg_virtio.c open-amp/lib/rpmsg/rpmsg_virtio.c -index e6a4969..9dd14b6 100644 +index 0e2885c732..6df5a52a48 100644 --- a/lib/rpmsg/rpmsg_virtio.c +++ open-amp/lib/rpmsg/rpmsg_virtio.c -@@ -352,7 +352,6 @@ static void *rpmsg_virtio_get_tx_payload_buffer(struct rpmsg_device *rdev, +@@ -355,7 +355,6 @@ static void *rpmsg_virtio_get_tx_payload_buffer(struct rpmsg_device *rdev, { struct rpmsg_virtio_device *rvdev; struct rpmsg_hdr *rp_hdr; @@ -21,7 +21,7 @@ index e6a4969..9dd14b6 100644 uint16_t idx; int tick_count; int status; -@@ -360,11 +359,6 @@ static void *rpmsg_virtio_get_tx_payload_buffer(struct rpmsg_device *rdev, +@@ -363,11 +362,6 @@ static void *rpmsg_virtio_get_tx_payload_buffer(struct rpmsg_device *rdev, /* Get the associated remote device for channel. */ rvdev = metal_container_of(rdev, struct rpmsg_virtio_device, rdev); diff --git a/openamp/0007-libmetal-nuttx-Update-function-prototype-changes.patch b/openamp/0007-libmetal-nuttx-Update-function-prototype-changes.patch deleted file mode 100644 index 3ccf707ed8e5b..0000000000000 --- a/openamp/0007-libmetal-nuttx-Update-function-prototype-changes.patch +++ /dev/null @@ -1,58 +0,0 @@ -From a120e0e698ff3f7af8bfee34a47051f13b74aac0 Mon Sep 17 00:00:00 2001 -From: chao an -Date: Thu, 9 Oct 2025 19:39:01 +0800 -Subject: [PATCH] libmetal/nuttx: Update function prototype changes -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -clock_systime_timespec() always returns 0, so there is no need to -check the return value in the caller code, let us remove the return -value directly. - -From: - int clock_systime_timespec(FAR struct timespec *ts) -To: - void clock_systime_timespec(FAR struct timespec *ts) - -Fix build break: - -libmetal/lib/system/nuttx/time.c: In function ‘metal_get_timestamp’: -libmetal/lib/system/nuttx/time.c:21:11: error: void value not ignored as it ought to be - 21 | r = clock_systime_timespec(&tp); - | ^ -make[1]: *** [Makefile:46: libmetal/lib/system/nuttx/time.o] Error 1 - -Change-Id: I88443c4a5725bd269a05c8a503bd5095b082bfbe ---- - lib/system/nuttx/time.c | 13 ++++++------- - 1 file changed, 6 insertions(+), 7 deletions(-) - -diff --git a/lib/system/nuttx/time.c libmetal/lib/system/nuttx/time.c -index 986f1ba..f06725d 100644 ---- a/lib/system/nuttx/time.c -+++ libmetal/lib/system/nuttx/time.c -@@ -14,14 +14,13 @@ - - unsigned long long metal_get_timestamp(void) - { -- unsigned long long t = 0; -+ unsigned long long t; - struct timespec tp; -- int r; - -- r = clock_systime_timespec(&tp); -- if (!r) { -- t = (unsigned long long)tp.tv_sec * NSEC_PER_SEC; -- t += tp.tv_nsec; -- } -+ clock_systime_timespec(&tp); -+ -+ t = (unsigned long long)tp.tv_sec * NSEC_PER_SEC; -+ t += tp.tv_nsec; -+ - return t; - } --- -2.43.0 - diff --git a/openamp/0007-virtqueue-move-virtqueue_nused-and-virtqueue_navail-.patch b/openamp/0007-virtqueue-move-virtqueue_nused-and-virtqueue_navail-.patch new file mode 100644 index 0000000000000..a665a4121bfef --- /dev/null +++ b/openamp/0007-virtqueue-move-virtqueue_nused-and-virtqueue_navail-.patch @@ -0,0 +1,149 @@ +From bbaf772058b44a383b4ef81676eccd7a1b503c09 Mon Sep 17 00:00:00 2001 +From: Bowen Wang +Date: Wed, 20 Nov 2024 10:43:16 +0800 +Subject: [PATCH 07/10] virtqueue: move virtqueue_nused and virtqueue_navail to + public + +Use these two apis to judge whether there is buffers in the virtqueues +to be processed. + +Signed-off-by: Bowen Wang +--- + lib/include/openamp/virtqueue.h | 18 ++++++++ + lib/virtio/virtqueue.c | 80 ++++++++++++++++----------------- + 2 files changed, 57 insertions(+), 41 deletions(-) + +diff --git a/lib/include/openamp/virtqueue.h open-amp/lib/include/openamp/virtqueue.h +index 92a4a87f10..2d42219be5 100644 +--- a/lib/include/openamp/virtqueue.h ++++ open-amp/lib/include/openamp/virtqueue.h +@@ -428,6 +428,24 @@ static inline int virtqueue_full(struct virtqueue *vq) + return (vq->vq_free_cnt == 0); + } + ++/** ++ * @brief Get number of used buffers in virtqueue ++ * ++ * @param vq Pointer to VirtIO queue control block ++ * ++ * @return Number of used buffers ++ */ ++int virtqueue_nused(struct virtqueue *vq); ++ ++/** ++ * @brief Get number of available buffers in virtqueue ++ * ++ * @param vq Pointer to VirtIO queue control block ++ * ++ * @return Number of available buffers ++ */ ++int virtqueue_navail(struct virtqueue *vq); ++ + #if defined __cplusplus + } + #endif +diff --git a/lib/virtio/virtqueue.c open-amp/lib/virtio/virtqueue.c +index d2738faaba..69e3572cd1 100644 +--- a/lib/virtio/virtqueue.c ++++ open-amp/lib/virtio/virtqueue.c +@@ -21,8 +21,6 @@ static int vq_ring_enable_interrupt(struct virtqueue *, uint16_t); + static void vq_ring_free_chain(struct virtqueue *, uint16_t); + static int vq_ring_must_notify(struct virtqueue *vq); + static void vq_ring_notify(struct virtqueue *vq); +-static int virtqueue_nused(struct virtqueue *vq); +-static int virtqueue_navail(struct virtqueue *vq); + + /* Default implementation of P2V based on libmetal */ + static inline void *virtqueue_phys_to_virt(struct virtqueue *vq, +@@ -397,6 +395,45 @@ uint32_t virtqueue_get_desc_size(struct virtqueue *vq) + return len; + } + ++/* ++ * ++ * virtqueue_nused ++ * ++ */ ++int virtqueue_nused(struct virtqueue *vq) ++{ ++ uint16_t used_idx, nused; ++ ++ /* Used is written by remote */ ++ VRING_INVALIDATE(&vq->vq_ring.used->idx, sizeof(vq->vq_ring.used->idx)); ++ used_idx = vq->vq_ring.used->idx; ++ ++ nused = (uint16_t)(used_idx - vq->vq_used_cons_idx); ++ VQASSERT(vq, nused <= vq->vq_nentries, "used more than available"); ++ ++ return nused; ++} ++ ++/* ++ * ++ * virtqueue_navail ++ * ++ */ ++int virtqueue_navail(struct virtqueue *vq) ++{ ++ uint16_t avail_idx, navail; ++ ++ /* Avail is written by driver */ ++ VRING_INVALIDATE(&vq->vq_ring.avail->idx, sizeof(vq->vq_ring.avail->idx)); ++ ++ avail_idx = vq->vq_ring.avail->idx; ++ ++ navail = (uint16_t)(avail_idx - vq->vq_available_idx); ++ VQASSERT(vq, navail <= vq->vq_nentries, "avail more than available"); ++ ++ return navail; ++} ++ + /************************************************************************** + * Helper Functions * + **************************************************************************/ +@@ -685,42 +722,3 @@ static void vq_ring_notify(struct virtqueue *vq) + if (vq->notify) + vq->notify(vq); + } +- +-/* +- * +- * virtqueue_nused +- * +- */ +-static int virtqueue_nused(struct virtqueue *vq) +-{ +- uint16_t used_idx, nused; +- +- /* Used is written by remote */ +- VRING_INVALIDATE(&vq->vq_ring.used->idx, sizeof(vq->vq_ring.used->idx)); +- used_idx = vq->vq_ring.used->idx; +- +- nused = (uint16_t)(used_idx - vq->vq_used_cons_idx); +- VQASSERT(vq, nused <= vq->vq_nentries, "used more than available"); +- +- return nused; +-} +- +-/* +- * +- * virtqueue_navail +- * +- */ +-static int virtqueue_navail(struct virtqueue *vq) +-{ +- uint16_t avail_idx, navail; +- +- /* Avail is written by driver */ +- VRING_INVALIDATE(&vq->vq_ring.avail->idx, sizeof(vq->vq_ring.avail->idx)); +- +- avail_idx = vq->vq_ring.avail->idx; +- +- navail = (uint16_t)(avail_idx - vq->vq_available_idx); +- VQASSERT(vq, navail <= vq->vq_nentries, "avail more than available"); +- +- return navail; +-} +-- +2.34.1 + diff --git a/openamp/0008-lib-rpmsg-rpmsg_virtio-add-last-buffer-check-to-fix-.patch b/openamp/0008-lib-rpmsg-rpmsg_virtio-add-last-buffer-check-to-fix-.patch new file mode 100644 index 0000000000000..408dc8f6efa56 --- /dev/null +++ b/openamp/0008-lib-rpmsg-rpmsg_virtio-add-last-buffer-check-to-fix-.patch @@ -0,0 +1,67 @@ +From fc9d645243c585731832ba42aa960a4ebb6656ab Mon Sep 17 00:00:00 2001 +From: Bowen Wang +Date: Mon, 26 May 2025 21:38:28 +0800 +Subject: [PATCH 08/10] lib/rpmsg/rpmsg_virtio: add last buffer check to fix + low power issue + +add `last` argument to rpmsg_virtio_get_rx_buffer() to know whether +current got rx buffer is the last buffer. +When this is the last buffer, do not try to access the vring to avoid +the low power issue. + +Signed-off-by: Bowen Wang +--- + lib/rpmsg/rpmsg_virtio.c | 10 +++++++--- + 1 file changed, 7 insertions(+), 3 deletions(-) + +diff --git a/lib/rpmsg/rpmsg_virtio.c open-amp/lib/rpmsg/rpmsg_virtio.c +index 6df5a52a48..4aba94e973 100644 +--- a/lib/rpmsg/rpmsg_virtio.c ++++ open-amp/lib/rpmsg/rpmsg_virtio.c +@@ -216,21 +216,24 @@ static void *rpmsg_virtio_get_tx_buffer(struct rpmsg_virtio_device *rvdev, + * @param rvdev Pointer to rpmsg device + * @param len Size of received buffer + * @param idx Index of buffer ++ * @param last Indicates whether this is the last buffer + * + * @return Pointer to received buffer + */ + static void *rpmsg_virtio_get_rx_buffer(struct rpmsg_virtio_device *rvdev, +- uint32_t *len, uint16_t *idx) ++ uint32_t *len, uint16_t *idx, bool *last) + { + void *data = NULL; + + if (VIRTIO_ROLE_IS_DRIVER(rvdev->vdev)) { + data = virtqueue_get_buffer(rvdev->rvq, len, idx); ++ *last = virtqueue_nused(rvdev->rvq) == 0; + } + + if (VIRTIO_ROLE_IS_DEVICE(rvdev->vdev)) { + data = + virtqueue_get_first_avail_buffer(rvdev->rvq, idx, len); ++ *last = virtqueue_navail(rvdev->rvq) == 0; + } + + /* Invalidate the buffer before returning it */ +@@ -551,14 +554,15 @@ static void rpmsg_virtio_rx_callback(struct virtqueue *vq) + struct rpmsg_endpoint *ept; + struct rpmsg_hdr *rp_hdr; + bool release = false; ++ bool last = false; + uint32_t len; + uint16_t idx; + int status; + +- while (1) { ++ while (!last) { + /* Process the received data from remote node */ + metal_mutex_acquire(&rdev->lock); +- rp_hdr = rpmsg_virtio_get_rx_buffer(rvdev, &len, &idx); ++ rp_hdr = rpmsg_virtio_get_rx_buffer(rvdev, &len, &idx, &last); + + /* No more filled rx buffers */ + if (!rp_hdr) { +-- +2.34.1 + diff --git a/openamp/0009-openamp-swap-get_rx_buffer-return_rx_buffer-to-resol.patch b/openamp/0009-openamp-swap-get_rx_buffer-return_rx_buffer-to-resol.patch deleted file mode 100644 index 5259d62a3f3c1..0000000000000 --- a/openamp/0009-openamp-swap-get_rx_buffer-return_rx_buffer-to-resol.patch +++ /dev/null @@ -1,57 +0,0 @@ -From fc935c6e5abcd0a96e5c3ca3bd5ec272543abc1a Mon Sep 17 00:00:00 2001 -From: ligd -Date: Fri, 7 Apr 2023 12:42:09 +0800 -Subject: [PATCH 09/14] openamp: swap get_rx_buffer & return_rx_buffer to - resolve remote low power. - -Signed-off-by: ligd -Signed-off-by: wangyongrong ---- - lib/rpmsg/rpmsg_virtio.c | 16 +++++++++++++--- - 1 file changed, 13 insertions(+), 3 deletions(-) - -diff --git a/lib/rpmsg/rpmsg_virtio.c open-amp/lib/rpmsg/rpmsg_virtio.c -index 9dd14b6..dfd36e3 100644 ---- a/lib/rpmsg/rpmsg_virtio.c -+++ open-amp/lib/rpmsg/rpmsg_virtio.c -@@ -545,17 +545,26 @@ static void rpmsg_virtio_rx_callback(struct virtqueue *vq) - struct virtio_device *vdev = vq->vq_dev; - struct rpmsg_virtio_device *rvdev = vdev->priv; - struct rpmsg_device *rdev = &rvdev->rdev; -+ struct rpmsg_hdr *next_hdr = NULL; - struct rpmsg_endpoint *ept; - struct rpmsg_hdr *rp_hdr; -+ uint32_t next_len; -+ uint16_t next_idx; - uint32_t len; - uint16_t idx; - int status; - - while (1) { - /* Process the received data from remote node */ -- metal_mutex_acquire(&rdev->lock); -- rp_hdr = rpmsg_virtio_get_rx_buffer(rvdev, &len, &idx); -- metal_mutex_release(&rdev->lock); -+ if (!next_hdr) { -+ metal_mutex_acquire(&rdev->lock); -+ rp_hdr = rpmsg_virtio_get_rx_buffer(rvdev, &len, &idx); -+ metal_mutex_release(&rdev->lock); -+ } else { -+ rp_hdr = next_hdr; -+ len = next_len; -+ idx = next_idx; -+ } - - /* No more filled rx buffers */ - if (!rp_hdr) -@@ -587,6 +596,7 @@ static void rpmsg_virtio_rx_callback(struct virtqueue *vq) - - metal_mutex_acquire(&rdev->lock); - rpmsg_ept_decref(ept); -+ next_hdr = rpmsg_virtio_get_rx_buffer(rvdev, &next_len, &next_idx); - if (rpmsg_virtio_buf_held_dec_test(rp_hdr)) - rpmsg_virtio_release_rx_buffer_nolock(rvdev, rp_hdr); - metal_mutex_release(&rdev->lock); --- -2.34.1 - diff --git a/openamp/0011-virtio-change-feature-to-64-bit-in-all-virtio_dispat.patch b/openamp/0009-virtio-change-feature-to-64-bit-in-all-virtio_dispat.patch similarity index 80% rename from openamp/0011-virtio-change-feature-to-64-bit-in-all-virtio_dispat.patch rename to openamp/0009-virtio-change-feature-to-64-bit-in-all-virtio_dispat.patch index 03649ff071a0a..cf0270557832a 100644 --- a/openamp/0011-virtio-change-feature-to-64-bit-in-all-virtio_dispat.patch +++ b/openamp/0009-virtio-change-feature-to-64-bit-in-all-virtio_dispat.patch @@ -1,26 +1,26 @@ -From 6d2bf800f07a9584ea2445b4046c2d82cddf0c6f Mon Sep 17 00:00:00 2001 +From 33fca04b5d33b7b501775f2384a6374eef302729 Mon Sep 17 00:00:00 2001 From: Yongrong Wang Date: Wed, 10 Jul 2024 18:47:33 +0800 -Subject: [PATCH 11/14] virtio: change feature to 64 bit in all virtio_dispatch +Subject: [PATCH 09/10] virtio: change feature to 64 bit in all virtio_dispatch The virtio device feature bit has exceeded 32 bits, so change feature to 64 bit like linux does to support more features Signed-off-by: Yongrong Wang +Signed-off-by: Bowen Wang --- lib/include/openamp/rpmsg_virtio.h | 2 +- - lib/include/openamp/virtio.h | 20 ++++++------- - lib/remoteproc/remoteproc_virtio.c | 14 +++++----- + lib/include/openamp/virtio.h | 22 +++++++-------- + lib/remoteproc/remoteproc_virtio.c | 12 ++++---- lib/rpmsg/rpmsg_virtio.c | 2 +- - lib/virtio/virtio.c | 2 +- lib/virtio_mmio/virtio_mmio_drv.c | 45 +++++++++++++++--------------- - 6 files changed, 42 insertions(+), 43 deletions(-) + 5 files changed, 41 insertions(+), 42 deletions(-) diff --git a/lib/include/openamp/rpmsg_virtio.h open-amp/lib/include/openamp/rpmsg_virtio.h -index d9cfa9b..866e9eb 100644 +index a757166082..a069bb02b0 100644 --- a/lib/include/openamp/rpmsg_virtio.h +++ open-amp/lib/include/openamp/rpmsg_virtio.h -@@ -179,7 +179,7 @@ static inline uint8_t rpmsg_virtio_get_status(struct rpmsg_virtio_device *rvdev) +@@ -176,7 +176,7 @@ static inline uint8_t rpmsg_virtio_get_status(struct rpmsg_virtio_device *rvdev) * @return The features supported by both the rpmsg driver and rpmsg device. */ __deprecated @@ -30,10 +30,10 @@ index d9cfa9b..866e9eb 100644 { return rvdev->vdev->func->get_features(rvdev->vdev); diff --git a/lib/include/openamp/virtio.h open-amp/lib/include/openamp/virtio.h -index 278d2da..dd285ac 100644 +index 5e244f6a01..0c35c45ccf 100644 --- a/lib/include/openamp/virtio.h +++ open-amp/lib/include/openamp/virtio.h -@@ -156,7 +156,7 @@ struct virtio_dispatch; +@@ -163,7 +163,7 @@ struct virtio_memory_ops; /** @brief Device features. */ struct virtio_feature_desc { /** Unique feature ID, defined in the virtio specification. */ @@ -42,16 +42,7 @@ index 278d2da..dd285ac 100644 /** Name of the feature (for debug). */ const char *vfd_str; -@@ -221,7 +221,7 @@ struct virtio_device { - const char *virtio_dev_name(uint16_t devid); - - __deprecated void virtio_describe(struct virtio_device *dev, const char *msg, -- uint32_t features, -+ uint64_t features, - struct virtio_feature_desc *feature_desc); - - /** -@@ -249,17 +249,17 @@ struct virtio_dispatch { +@@ -246,17 +246,17 @@ struct virtio_dispatch { void (*set_status)(struct virtio_device *dev, uint8_t status); /** Get the feature exposed by the virtio device. */ @@ -73,7 +64,7 @@ index 278d2da..dd285ac 100644 /** * Read a variable amount from the device specific (ie, network) -@@ -422,7 +422,7 @@ static inline int virtio_write_config(struct virtio_device *vdev, +@@ -427,7 +427,7 @@ static inline int virtio_write_config(struct virtio_device *vdev, * @return 0 on success, otherwise error code. */ static inline int virtio_get_features(struct virtio_device *vdev, @@ -82,7 +73,7 @@ index 278d2da..dd285ac 100644 { if (!vdev || !features) return -EINVAL; -@@ -443,7 +443,7 @@ static inline int virtio_get_features(struct virtio_device *vdev, +@@ -451,7 +451,7 @@ static inline int virtio_get_features(struct virtio_device *vdev, * @return 0 on success, otherwise error code. */ static inline int virtio_set_features(struct virtio_device *vdev, @@ -91,7 +82,7 @@ index 278d2da..dd285ac 100644 { if (!vdev) return -EINVAL; -@@ -465,8 +465,8 @@ static inline int virtio_set_features(struct virtio_device *vdev, +@@ -473,8 +473,8 @@ static inline int virtio_set_features(struct virtio_device *vdev, * @return 0 on success, otherwise error code. */ static inline int virtio_negotiate_features(struct virtio_device *vdev, @@ -102,8 +93,26 @@ index 278d2da..dd285ac 100644 { if (!vdev) return -EINVAL; +@@ -566,7 +566,7 @@ static inline int virtio_free_buf(struct virtio_device *vdev, void *buf) + static inline bool virtio_has_feature(struct virtio_device *vdev, + unsigned int feature_bit) + { +- uint32_t features; ++ uint64_t features; + + if (!vdev && feature_bit >= sizeof(features) * 8) + return false; +@@ -574,7 +574,7 @@ static inline bool virtio_has_feature(struct virtio_device *vdev, + if (!vdev->features) + virtio_get_features(vdev, &features); + +- return (vdev->features & (1UL << feature_bit)) != 0; ++ return (vdev->features & (1ULL << feature_bit)) != 0; + } + + #if defined __cplusplus diff --git a/lib/remoteproc/remoteproc_virtio.c open-amp/lib/remoteproc/remoteproc_virtio.c -index aae026c..902fc41 100644 +index 4eb40768d6..b07c0b3e45 100644 --- a/lib/remoteproc/remoteproc_virtio.c +++ open-amp/lib/remoteproc/remoteproc_virtio.c @@ -165,7 +165,7 @@ static uint32_t rproc_virtio_get_dfeatures(struct virtio_device *vdev) @@ -130,7 +139,7 @@ index aae026c..902fc41 100644 { struct remoteproc_virtio *rpvdev; struct fw_rsc_vdev *vdev_rsc; -@@ -197,17 +197,17 @@ static void rproc_virtio_set_features(struct virtio_device *vdev, +@@ -197,13 +197,13 @@ static void rproc_virtio_set_features(struct virtio_device *vdev, io = rpvdev->vdev_rsc_io; metal_io_write32(io, metal_io_virt_to_offset(io, &vdev_rsc->gfeatures), @@ -145,18 +154,13 @@ index aae026c..902fc41 100644 +static uint64_t rproc_virtio_negotiate_features(struct virtio_device *vdev, + uint64_t features) { - uint32_t dfeatures = rproc_virtio_get_dfeatures(vdev); - -- rproc_virtio_set_features(vdev, dfeatures & features); -+ rproc_virtio_set_features(vdev, dfeatures & (uint32_t)features); - - return 0; - } + features = features & rproc_virtio_get_dfeatures(vdev); + rproc_virtio_set_features(vdev, features); diff --git a/lib/rpmsg/rpmsg_virtio.c open-amp/lib/rpmsg/rpmsg_virtio.c -index bdf9046..e54155f 100644 +index 4aba94e973..4bc6fb21cb 100644 --- a/lib/rpmsg/rpmsg_virtio.c +++ open-amp/lib/rpmsg/rpmsg_virtio.c -@@ -805,7 +805,7 @@ int rpmsg_init_vdev_with_config(struct rpmsg_virtio_device *rvdev, +@@ -807,7 +807,7 @@ int rpmsg_init_vdev_with_config(struct rpmsg_virtio_device *rvdev, const char *vq_names[RPMSG_NUM_VRINGS]; vq_callback callback[RPMSG_NUM_VRINGS]; struct fw_rsc_config fw_config; @@ -165,21 +169,8 @@ index bdf9046..e54155f 100644 int status; unsigned int i; -diff --git a/lib/virtio/virtio.c open-amp/lib/virtio/virtio.c -index a442e52..e2ab3d8 100644 ---- a/lib/virtio/virtio.c -+++ open-amp/lib/virtio/virtio.c -@@ -51,7 +51,7 @@ const char *virtio_dev_name(unsigned short devid) - } - - __deprecated void virtio_describe(struct virtio_device *dev, const char *msg, -- uint32_t features, struct virtio_feature_desc *desc) -+ uint64_t features, struct virtio_feature_desc *desc) - { - (void)dev; - (void)msg; diff --git a/lib/virtio_mmio/virtio_mmio_drv.c open-amp/lib/virtio_mmio/virtio_mmio_drv.c -index 5700471..34f2b67 100644 +index 9f72f0fe04..45dab76c02 100644 --- a/lib/virtio_mmio/virtio_mmio_drv.c +++ open-amp/lib/virtio_mmio/virtio_mmio_drv.c @@ -75,44 +75,43 @@ static void virtio_mmio_read_config(struct virtio_device *vdev, diff --git a/openamp/0013-openamp-add-assert-when-get-tx-buffer-failed.patch b/openamp/0010-openamp-add-assert-when-get-tx-buffer-failed.patch similarity index 69% rename from openamp/0013-openamp-add-assert-when-get-tx-buffer-failed.patch rename to openamp/0010-openamp-add-assert-when-get-tx-buffer-failed.patch index 9633c14c2b0af..ffc3a42466358 100644 --- a/openamp/0013-openamp-add-assert-when-get-tx-buffer-failed.patch +++ b/openamp/0010-openamp-add-assert-when-get-tx-buffer-failed.patch @@ -1,7 +1,7 @@ -From a2f4672050433811aabfcd8abef206c28397276d Mon Sep 17 00:00:00 2001 +From e201b5ba1fd11bb486a844afb2362d699f915f7f Mon Sep 17 00:00:00 2001 From: dongjiuzhu1 Date: Mon, 27 May 2024 20:32:46 +0800 -Subject: [PATCH 13/14] openamp: add assert when get tx buffer failed +Subject: [PATCH 10/10] openamp: add assert when get tx buffer failed So we can found the error more eaily @@ -11,10 +11,10 @@ Signed-off-by: dongjiuzhu1 1 file changed, 2 insertions(+) diff --git a/lib/rpmsg/rpmsg_virtio.c open-amp/lib/rpmsg/rpmsg_virtio.c -index 7aeec5b..33c6c33 100644 +index 4bc6fb21cb..0293d17d24 100644 --- a/lib/rpmsg/rpmsg_virtio.c +++ open-amp/lib/rpmsg/rpmsg_virtio.c -@@ -384,6 +384,8 @@ static void *rpmsg_virtio_get_tx_payload_buffer(struct rpmsg_device *rdev, +@@ -391,6 +391,8 @@ static void *rpmsg_virtio_get_tx_payload_buffer(struct rpmsg_device *rdev, } } diff --git a/openamp/0010-rpmsg_virtio.c-virtqueue_kick-after-all-rx-buffer-re.patch b/openamp/0010-rpmsg_virtio.c-virtqueue_kick-after-all-rx-buffer-re.patch deleted file mode 100644 index f8bf9e6c95735..0000000000000 --- a/openamp/0010-rpmsg_virtio.c-virtqueue_kick-after-all-rx-buffer-re.patch +++ /dev/null @@ -1,70 +0,0 @@ -From 76fd1e2c7e967ec979a24a49ce1c9626a4279f21 Mon Sep 17 00:00:00 2001 -From: Yongrong Wang -Date: Wed, 10 Jul 2024 15:02:01 +0800 -Subject: [PATCH 10/14] rpmsg_virtio.c: virtqueue_kick after all rx buffer - release - -Only kick once when all the rx buffers has been returned to decrease -the interrupt times to improve the performance - -Signed-off-by: Yongrong Wang -Signed-off-by: Bowen Wang ---- - lib/rpmsg/rpmsg_virtio.c | 20 +++++++++++++------- - 1 file changed, 13 insertions(+), 7 deletions(-) - -diff --git a/lib/rpmsg/rpmsg_virtio.c open-amp/lib/rpmsg/rpmsg_virtio.c -index dfd36e3..bdf9046 100644 ---- a/lib/rpmsg/rpmsg_virtio.c -+++ open-amp/lib/rpmsg/rpmsg_virtio.c -@@ -314,8 +314,6 @@ static bool rpmsg_virtio_release_rx_buffer_nolock(struct rpmsg_virtio_device *rv - /* Return buffer on virtqueue. */ - len = virtqueue_get_buffer_length(rvdev->rvq, idx); - rpmsg_virtio_return_buffer(rvdev, rp_hdr, len, idx); -- /* Tell peer we returned an rx buffer */ -- virtqueue_kick(rvdev->rvq); - - return true; - } -@@ -330,8 +328,11 @@ static void rpmsg_virtio_release_rx_buffer(struct rpmsg_device *rdev, - rp_hdr = RPMSG_LOCATE_HDR(rxbuf); - - metal_mutex_acquire(&rdev->lock); -- if (rpmsg_virtio_buf_held_dec_test(rp_hdr)) -+ if (rpmsg_virtio_buf_held_dec_test(rp_hdr)) { - rpmsg_virtio_release_rx_buffer_nolock(rvdev, rp_hdr); -+ /* Tell peer we returned an rx buffer */ -+ virtqueue_kick(rvdev->rvq); -+ } - metal_mutex_release(&rdev->lock); - } - -@@ -560,16 +561,21 @@ static void rpmsg_virtio_rx_callback(struct virtqueue *vq) - metal_mutex_acquire(&rdev->lock); - rp_hdr = rpmsg_virtio_get_rx_buffer(rvdev, &len, &idx); - metal_mutex_release(&rdev->lock); -+ if (!rp_hdr) -+ break; - } else { -+ /* No more filled rx buffers */ -+ if (!next_hdr) { -+ /* Tell peer we returned some rx buffer */ -+ virtqueue_kick(rvdev->rvq); -+ break; -+ } -+ - rp_hdr = next_hdr; - len = next_len; - idx = next_idx; - } - -- /* No more filled rx buffers */ -- if (!rp_hdr) -- break; -- - rp_hdr->reserved = idx; - - /* Get the channel node from the remote device channels list. */ --- -2.34.1 - diff --git a/openamp/0012-rpmsg_virtio.c-fix-get_tx_payload_buffer-error.patch b/openamp/0012-rpmsg_virtio.c-fix-get_tx_payload_buffer-error.patch deleted file mode 100644 index 2aa6c36130034..0000000000000 --- a/openamp/0012-rpmsg_virtio.c-fix-get_tx_payload_buffer-error.patch +++ /dev/null @@ -1,32 +0,0 @@ -From 3146340e66f9dae5817c0a9592f8e375c2cf9e77 Mon Sep 17 00:00:00 2001 -From: Yongrong Wang -Date: Wed, 31 Jul 2024 15:36:43 +0800 -Subject: [PATCH 12/14] rpmsg_virtio.c: fix get_tx_payload_buffer error - -Always sleep when notify wait return not RPMSG_SUCCESS - -Signed-off-by: Yongrong Wang ---- - lib/rpmsg/rpmsg_virtio.c | 4 +--- - 1 file changed, 1 insertion(+), 3 deletions(-) - -diff --git a/lib/rpmsg/rpmsg_virtio.c open-amp/lib/rpmsg/rpmsg_virtio.c -index e54155f..7aeec5b 100644 ---- a/lib/rpmsg/rpmsg_virtio.c -+++ open-amp/lib/rpmsg/rpmsg_virtio.c -@@ -378,11 +378,9 @@ static void *rpmsg_virtio_get_tx_payload_buffer(struct rpmsg_device *rdev, - * use metal_sleep_usec() method by default. - */ - status = rpmsg_virtio_notify_wait(rvdev, rvdev->rvq); -- if (status == RPMSG_EOPNOTSUPP) { -+ if (status != RPMSG_SUCCESS) { - metal_sleep_usec(RPMSG_TICKS_PER_INTERVAL); - tick_count--; -- } else if (status == RPMSG_SUCCESS) { -- break; - } - } - --- -2.34.1 - diff --git a/openamp/0014-virtio.h-add-memory-operation-for-virtio-device.patch b/openamp/0014-virtio.h-add-memory-operation-for-virtio-device.patch deleted file mode 100644 index 7c09c34011d9e..0000000000000 --- a/openamp/0014-virtio.h-add-memory-operation-for-virtio-device.patch +++ /dev/null @@ -1,97 +0,0 @@ -From 1091cadd99315959303ab3a8227e054884c28770 Mon Sep 17 00:00:00 2001 -From: Bowen Wang -Date: Mon, 12 Aug 2024 10:15:24 +0800 -Subject: [PATCH 14/14] virtio.h: add memory operation for virtio device - -To make different virtio device/transport can use it's own memory -region. - -Signed-off-by: Bowen Wang ---- - lib/include/openamp/virtio.h | 42 ++++++++++++++++++++++++++++++++++++ - 1 file changed, 42 insertions(+) - -diff --git a/lib/include/openamp/virtio.h open-amp/lib/include/openamp/virtio.h -index dd285ac..1099a26 100644 ---- a/lib/include/openamp/virtio.h -+++ open-amp/lib/include/openamp/virtio.h -@@ -152,6 +152,7 @@ struct virtio_device_id { - typedef void (*virtio_dev_reset_cb)(struct virtio_device *vdev); - - struct virtio_dispatch; -+struct virtio_memory_ops; - - /** @brief Device features. */ - struct virtio_feature_desc { -@@ -197,6 +198,9 @@ struct virtio_device { - /** Virtio dispatch table */ - const struct virtio_dispatch *func; - -+ /** Virtio device memory operations */ -+ const struct virtio_memory_ops *mmops; -+ - /** Private data */ - void *priv; - -@@ -204,6 +208,7 @@ struct virtio_device { - unsigned int vrings_num; - - /** Pointer to the virtio vring structure */ -+ - struct virtio_vring_info *vrings_info; - }; - -@@ -282,6 +287,11 @@ struct virtio_dispatch { - void (*notify)(struct virtqueue *vq); - }; - -+struct virtio_memory_ops { -+ void *(*alloc)(struct virtio_device *dev, size_t size, size_t align); -+ void (*free)(struct virtio_device *dev, void *buf); -+}; -+ - /** - * @brief Create the virtio device virtqueue. - * -@@ -499,6 +509,38 @@ static inline int virtio_reset_device(struct virtio_device *vdev) - return 0; - } - -+/** -+ * @brief Allocate buffer from the virtio device -+ * -+ * @param vdev Pointer to virtio device structure. -+ * @param size Allocated buffer size. -+ * @param align Allocated buffer alignment. -+ * -+ * @return The allocated buffer address. -+ */ -+static inline void *virtio_alloc_buf(struct virtio_device *vdev, -+ size_t size, size_t align) -+{ -+ if (!vdev->mmops->alloc) -+ return NULL; -+ -+ return vdev->mmops->alloc(vdev, size, align); -+} -+ -+/** -+ * @brief Free buffer to the virtio device -+ * -+ * @param vdev Pointer to virtio device structure. -+ * @param buf Buffer need to be freed. -+ */ -+static inline void virtio_free_buf(struct virtio_device *vdev, void *buf) -+{ -+ if (!vdev->mmops->free) -+ return; -+ -+ vdev->mmops->free(vdev, buf); -+} -+ - #if defined __cplusplus - } - #endif --- -2.34.1 - diff --git a/openamp/CMakeLists.txt b/openamp/CMakeLists.txt index ceff5d839efea..156cfef417643 100644 --- a/openamp/CMakeLists.txt +++ b/openamp/CMakeLists.txt @@ -21,8 +21,8 @@ # ############################################################################## if(CONFIG_OPENAMP) - set(OPENAMP_COMMIT c468328487a1e0596307a5ef7172756819e15745) - set(LIBMETAL_COMMIT a4bce3507502a7eb9e29bafe0eb174ed5c4316e9) + set(OPENAMP_VERSION 2025.10.0) + set(LIBMETAL_VERSION 2025.10.0) include(libmetal.cmake) include(open-amp.cmake) diff --git a/openamp/Makefile b/openamp/Makefile index b71febcbc5f19..9d298a4dadb2f 100644 --- a/openamp/Makefile +++ b/openamp/Makefile @@ -22,8 +22,8 @@ include $(TOPDIR)/Make.defs -OPENAMP_COMMIT ?= c468328487a1e0596307a5ef7172756819e15745 -LIBMETAL_COMMIT ?= a4bce3507502a7eb9e29bafe0eb174ed5c4316e9 +OPENAMP_VERSION ?= 2025.10.0 +LIBMETAL_VERSION ?= 2025.10.0 include libmetal.defs include open-amp.defs diff --git a/openamp/libmetal.cmake b/openamp/libmetal.cmake index d4b996c1ac877..8717be7c4c37c 100644 --- a/openamp/libmetal.cmake +++ b/openamp/libmetal.cmake @@ -24,7 +24,7 @@ if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/libmetal) libmetal DOWNLOAD_NAME "libmetal-main.zip" DOWNLOAD_DIR ${CMAKE_CURRENT_LIST_DIR} - URL "https://github.com/OpenAMP/libmetal/archive/${LIBMETAL_COMMIT}.zip" + URL "https://github.com/OpenAMP/libmetal/archive/v${LIBMETAL_VERSION}.zip" SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/libmetal BINARY_DIR @@ -37,19 +37,9 @@ if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/libmetal) "" PATCH_COMMAND patch -p0 -d ${CMAKE_CURRENT_LIST_DIR} < - ${CMAKE_CURRENT_LIST_DIR}/0001-lib-errno.h-fix-compile-error.patch && - patch -p0 -d ${CMAKE_CURRENT_LIST_DIR} < - ${CMAKE_CURRENT_LIST_DIR}/0002-libmetal-atomic-enable-64-bit-atomic-by-toolchain-bu.patch - && patch -p0 -d ${CMAKE_CURRENT_LIST_DIR} < - ${CMAKE_CURRENT_LIST_DIR}/0003-atomic.h-fix-compiler-error.patch && patch - -p0 -d ${CMAKE_CURRENT_LIST_DIR} < - ${CMAKE_CURRENT_LIST_DIR}/0004-lib-system-nuttx-fix-unused-parameter-compile-error.patch + ${CMAKE_CURRENT_LIST_DIR}/0001-libmetal-cmake-set-HAVE_STDATOMIC_H-default-true-in-.patch && patch -p0 -d ${CMAKE_CURRENT_LIST_DIR} < - ${CMAKE_CURRENT_LIST_DIR}/0005-libmetal-cmake-set-HAVE_STDATOMIC_H-default-true-in-.patch - && patch -p0 -d ${CMAKE_CURRENT_LIST_DIR} < - ${CMAKE_CURRENT_LIST_DIR}/0006-lib-system-nuttx-io.c-include-stddef.h-in-nuttx-io.c.patch - && patch -p0 -d ${CMAKE_CURRENT_LIST_DIR} < - ${CMAKE_CURRENT_LIST_DIR}/0007-libmetal-nuttx-Update-function-prototype-changes.patch + ${CMAKE_CURRENT_LIST_DIR}/0002-libmetal-atomic-enable-64-bit-atomic-by-toolchain-bu.patch DOWNLOAD_NO_PROGRESS true TIMEOUT 30) diff --git a/openamp/libmetal.defs b/openamp/libmetal.defs index fc5443dde734f..7d4734fa58c9a 100644 --- a/openamp/libmetal.defs +++ b/openamp/libmetal.defs @@ -79,16 +79,11 @@ LIBMETAL_HDRS_SEDEXP := \ ifeq ($(wildcard libmetal/.git),) libmetal.zip: # Download and unpack tarball if no git repo found - $(call DOWNLOAD,https://github.com/OpenAMP/libmetal/archive,$(LIBMETAL_COMMIT).zip,libmetal.zip) + $(call DOWNLOAD,https://github.com/OpenAMP/libmetal/archive,v$(LIBMETAL_VERSION).zip,libmetal.zip) $(Q) unzip -o libmetal.zip - mv libmetal-$(LIBMETAL_COMMIT) libmetal - $(Q) patch -p0 < 0001-lib-errno.h-fix-compile-error.patch + mv libmetal-$(LIBMETAL_VERSION) libmetal + $(Q) patch -p0 < 0001-libmetal-cmake-set-HAVE_STDATOMIC_H-default-true-in-.patch $(Q) patch -p0 < 0002-libmetal-atomic-enable-64-bit-atomic-by-toolchain-bu.patch - $(Q) patch -p0 < 0003-atomic.h-fix-compiler-error.patch - $(Q) patch -p0 < 0004-lib-system-nuttx-fix-unused-parameter-compile-error.patch - $(Q) patch -p0 < 0005-libmetal-cmake-set-HAVE_STDATOMIC_H-default-true-in-.patch - $(Q) patch -p0 < 0006-lib-system-nuttx-io.c-include-stddef.h-in-nuttx-io.c.patch - $(Q) patch -p0 < 0007-libmetal-nuttx-Update-function-prototype-changes.patch .libmetal_headers: libmetal.zip else diff --git a/openamp/open-amp.cmake b/openamp/open-amp.cmake index 677e54ae60d64..825c0128627e0 100644 --- a/openamp/open-amp.cmake +++ b/openamp/open-amp.cmake @@ -24,7 +24,7 @@ if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/open-amp) open-amp DOWNLOAD_NAME "libopen-amp-main.zip" DOWNLOAD_DIR ${CMAKE_CURRENT_LIST_DIR} - URL "https://github.com/OpenAMP/open-amp/archive/${OPENAMP_COMMIT}.zip" + URL "https://github.com/OpenAMP/open-amp/archive/v${OPENAMP_VERSION}.zip" SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/open-amp BINARY_DIR @@ -45,27 +45,19 @@ if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/open-amp) && patch -p0 -d ${CMAKE_CURRENT_LIST_DIR} < ${CMAKE_CURRENT_LIST_DIR}/0003-rpmsg-notify-the-user-when-the-remote-address-is-rec.patch && patch -p0 -d ${CMAKE_CURRENT_LIST_DIR} < - ${CMAKE_CURRENT_LIST_DIR}/0004-openamp-virtio.h-negotiate_features-also-can-be-call.patch - && patch -p0 -d ${CMAKE_CURRENT_LIST_DIR} < - ${CMAKE_CURRENT_LIST_DIR}/0005-remoteproc-rpmsg_virtio-change-sched_yeild-to-usleep.patch - && patch -p0 -d ${CMAKE_CURRENT_LIST_DIR} < - ${CMAKE_CURRENT_LIST_DIR}/0006-rpmsg-wait-ept-ready-in-rpmsg_send.patch && + ${CMAKE_CURRENT_LIST_DIR}/0004-rpmsg-wait-ept-ready-in-rpmsg_send.patch && patch -p0 -d ${CMAKE_CURRENT_LIST_DIR} < - ${CMAKE_CURRENT_LIST_DIR}/0007-openamp-add-VIRTIO_RING_F_MUST_NOTIFY-event.patch - && patch -p0 -d ${CMAKE_CURRENT_LIST_DIR} < - ${CMAKE_CURRENT_LIST_DIR}/0008-rpmsg_virtio-don-t-need-check-status-when-get_tx_pay.patch - && patch -p0 -d ${CMAKE_CURRENT_LIST_DIR} < - ${CMAKE_CURRENT_LIST_DIR}/0009-openamp-swap-get_rx_buffer-return_rx_buffer-to-resol.patch + ${CMAKE_CURRENT_LIST_DIR}/0005-openamp-add-VIRTIO_RING_F_MUST_NOTIFY-event.patch && patch -p0 -d ${CMAKE_CURRENT_LIST_DIR} < - ${CMAKE_CURRENT_LIST_DIR}/0010-rpmsg_virtio.c-virtqueue_kick-after-all-rx-buffer-re.patch + ${CMAKE_CURRENT_LIST_DIR}/0006-rpmsg_virtio-don-t-need-check-status-when-get_tx_pay.patch && patch -p0 -d ${CMAKE_CURRENT_LIST_DIR} < - ${CMAKE_CURRENT_LIST_DIR}/0011-virtio-change-feature-to-64-bit-in-all-virtio_dispat.patch + ${CMAKE_CURRENT_LIST_DIR}/0007-virtqueue-move-virtqueue_nused-and-virtqueue_navail-.patch && patch -p0 -d ${CMAKE_CURRENT_LIST_DIR} < - ${CMAKE_CURRENT_LIST_DIR}/0012-rpmsg_virtio.c-fix-get_tx_payload_buffer-error.patch + ${CMAKE_CURRENT_LIST_DIR}/0008-lib-rpmsg-rpmsg_virtio-add-last-buffer-check-to-fix-.patch && patch -p0 -d ${CMAKE_CURRENT_LIST_DIR} < - ${CMAKE_CURRENT_LIST_DIR}/0013-openamp-add-assert-when-get-tx-buffer-failed.patch + ${CMAKE_CURRENT_LIST_DIR}/0009-virtio-change-feature-to-64-bit-in-all-virtio_dispat.patch && patch -p0 -d ${CMAKE_CURRENT_LIST_DIR} < - ${CMAKE_CURRENT_LIST_DIR}/0014-virtio.h-add-memory-operation-for-virtio-device.patch + ${CMAKE_CURRENT_LIST_DIR}/0010-openamp-add-assert-when-get-tx-buffer-failed.patch DOWNLOAD_NO_PROGRESS true TIMEOUT 30) diff --git a/openamp/open-amp.defs b/openamp/open-amp.defs index 8ca50ff58c1bb..30f7fde7d11bf 100644 --- a/openamp/open-amp.defs +++ b/openamp/open-amp.defs @@ -23,7 +23,7 @@ ifeq ($(CONFIG_OPENAMP),y) ifeq ($(CONFIG_OPENAMP_CACHE),y) - CFLAGS += -DVIRTIO_CACHED_BUFFERS -DVIRTIO_CACHED_VRINGS + CFLAGS += -DVIRTIO_USE_DCACHE endif ifeq ($(CONFIG_OPENAMP_DEBUG),y) @@ -44,41 +44,46 @@ else CFLAGS += -DVIRTIO_DRIVER_SUPPORT=0 endif +CFLAGS += -DVQ_RX_EMPTY_NOTIFY=1 +CFLAGS += -Iopen-amp/lib/include + +# avoid multiple definitions in other file +CFLAGS += -Dsafe_strcpy=openamp_safe_strcpy + CSRCS += open-amp/lib/remoteproc/elf_loader.c CSRCS += open-amp/lib/remoteproc/remoteproc.c CSRCS += open-amp/lib/remoteproc/remoteproc_virtio.c CSRCS += open-amp/lib/remoteproc/rsc_table_parser.c CSRCS += open-amp/lib/rpmsg/rpmsg.c CSRCS += open-amp/lib/rpmsg/rpmsg_virtio.c +CSRCS += open-amp/lib/utils/utilities.c CSRCS += open-amp/lib/virtio/virtio.c CSRCS += open-amp/lib/virtio/virtqueue.c # Download and unpack tarball if no git repo found ifeq ($(wildcard open-amp/.git),) open-amp.zip: - $(call DOWNLOAD,https://github.com/OpenAMP/open-amp/archive,$(OPENAMP_COMMIT).zip,open-amp.zip) + $(call DOWNLOAD,https://github.com/OpenAMP/open-amp/archive,v$(OPENAMP_VERSION).zip,open-amp.zip) $(Q) unzip -o open-amp.zip - mv open-amp-$(OPENAMP_COMMIT) open-amp + mv open-amp-$(OPENAMP_VERSION) open-amp $(Q) patch -p0 < 0001-ns-acknowledge-the-received-creation-message.patch $(Q) patch -p0 < 0002-Negotiate-individual-buffer-size-dynamically.patch $(Q) patch -p0 < 0003-rpmsg-notify-the-user-when-the-remote-address-is-rec.patch - $(Q) patch -p0 < 0004-openamp-virtio.h-negotiate_features-also-can-be-call.patch - $(Q) patch -p0 < 0005-remoteproc-rpmsg_virtio-change-sched_yeild-to-usleep.patch - $(Q) patch -p0 < 0006-rpmsg-wait-ept-ready-in-rpmsg_send.patch - $(Q) patch -p0 < 0007-openamp-add-VIRTIO_RING_F_MUST_NOTIFY-event.patch - $(Q) patch -p0 < 0008-rpmsg_virtio-don-t-need-check-status-when-get_tx_pay.patch - $(Q) patch -p0 < 0009-openamp-swap-get_rx_buffer-return_rx_buffer-to-resol.patch - $(Q) patch -p0 < 0010-rpmsg_virtio.c-virtqueue_kick-after-all-rx-buffer-re.patch - $(Q) patch -p0 < 0011-virtio-change-feature-to-64-bit-in-all-virtio_dispat.patch - $(Q) patch -p0 < 0012-rpmsg_virtio.c-fix-get_tx_payload_buffer-error.patch - $(Q) patch -p0 < 0013-openamp-add-assert-when-get-tx-buffer-failed.patch - $(Q) patch -p0 < 0014-virtio.h-add-memory-operation-for-virtio-device.patch + $(Q) patch -p0 < 0004-rpmsg-wait-ept-ready-in-rpmsg_send.patch + $(Q) patch -p0 < 0005-openamp-add-VIRTIO_RING_F_MUST_NOTIFY-event.patch + $(Q) patch -p0 < 0006-rpmsg_virtio-don-t-need-check-status-when-get_tx_pay.patch + $(Q) patch -p0 < 0007-virtqueue-move-virtqueue_nused-and-virtqueue_navail-.patch + $(Q) patch -p0 < 0008-lib-rpmsg-rpmsg_virtio-add-last-buffer-check-to-fix-.patch + $(Q) patch -p0 < 0009-virtio-change-feature-to-64-bit-in-all-virtio_dispat.patch + $(Q) patch -p0 < 0010-openamp-add-assert-when-get-tx-buffer-failed.patch .openamp_headers: open-amp.zip else .openamp_headers: endif $(eval headers := $(wildcard open-amp/lib/include/openamp/*.h)) + $(eval headers += open-amp/lib/remoteproc/rsc_table_parser.h) + $(eval headers += open-amp/lib/rpmsg/rpmsg_internal.h) $(shell mkdir -p $(TOPDIR)$(DELIM)include$(DELIM)openamp$(DELIM)) $(foreach header,$(headers),$(shell cp -rf $(header) $(TOPDIR)$(DELIM)include$(DELIM)openamp$(DELIM))) touch $@ From 09498c29863044eca2bb192f2fff9c77217b70a1 Mon Sep 17 00:00:00 2001 From: Bowen Wang Date: Mon, 29 Dec 2025 16:19:45 +0800 Subject: [PATCH 2/8] virtio: remove virtio_has_feture() in nuttx because openamp already implement virtio_has_feture() change alreay merged into the OpenAMP community Signed-off-by: Bowen Wang --- include/nuttx/virtio/virtio.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/include/nuttx/virtio/virtio.h b/include/nuttx/virtio/virtio.h index bef7383d802d5..a0d122714f708 100644 --- a/include/nuttx/virtio/virtio.h +++ b/include/nuttx/virtio/virtio.h @@ -47,9 +47,6 @@ /* Virtio helper functions */ -#define virtio_has_feature(vdev, fbit) \ - (((vdev)->features & (1ULL << (fbit))) != 0) - #define virtio_read_config_member(vdev, structname, member, ptr) \ virtio_read_config((vdev), offsetof(structname, member), \ (ptr), sizeof(*(ptr))); From b231d8c1d14015565951568a4dabcd1fa31be3a9 Mon Sep 17 00:00:00 2001 From: Bowen Wang Date: Thu, 18 Dec 2025 17:21:18 +0800 Subject: [PATCH 3/8] drivers/sensors/sersor_rpmsg: fix compile error about workqueue need include Signed-off-by: Bowen Wang --- drivers/sensors/sensor_rpmsg.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/sensors/sensor_rpmsg.c b/drivers/sensors/sensor_rpmsg.c index 6ed7577121029..d5f798c2e1193 100644 --- a/drivers/sensors/sensor_rpmsg.c +++ b/drivers/sensors/sensor_rpmsg.c @@ -35,6 +35,7 @@ #include #include #include +#include /**************************************************************************** * Pre-processor Definitions From a16c9ad7c3f1a3eeb8c5260e15f9afba17e5237f Mon Sep 17 00:00:00 2001 From: Bowen Wang Date: Thu, 18 Dec 2025 17:21:49 +0800 Subject: [PATCH 4/8] net/rpmsg/rpmsg_sockif: fix compile error about nxsched_getpid need include Signed-off-by: Bowen Wang --- net/rpmsg/rpmsg_sockif.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/rpmsg/rpmsg_sockif.c b/net/rpmsg/rpmsg_sockif.c index d03cbb290c97a..502053921be00 100644 --- a/net/rpmsg/rpmsg_sockif.c +++ b/net/rpmsg/rpmsg_sockif.c @@ -39,6 +39,7 @@ #include #include #include +#include #include #include From d07c683cfd01fe7cac6fc997e9255adfd6a84089 Mon Sep 17 00:00:00 2001 From: Bowen Wang Date: Fri, 23 Aug 2024 00:17:09 +0800 Subject: [PATCH 5/8] virtio-config.h: move common virtio apis to virtio-config.h So the config releated api can be used by both the virtio and vhost Signed-off-by: Bowen Wang --- include/nuttx/virtio/virtio-config.h | 53 ++++++++++++++++++++++++++++ include/nuttx/virtio/virtio.h | 20 +---------- 2 files changed, 54 insertions(+), 19 deletions(-) create mode 100644 include/nuttx/virtio/virtio-config.h diff --git a/include/nuttx/virtio/virtio-config.h b/include/nuttx/virtio/virtio-config.h new file mode 100644 index 0000000000000..8e80427f71619 --- /dev/null +++ b/include/nuttx/virtio/virtio-config.h @@ -0,0 +1,53 @@ +/**************************************************************************** + * include/nuttx/virtio/virtio-config.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __INCLUDE_NUTTX_VIRTIO_VIRTIO_CONFIG_H +#define __INCLUDE_NUTTX_VIRTIO_VIRTIO_CONFIG_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#ifdef CONFIG_OPENAMP + +#include +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* Virtio common feature bits */ + +#define VIRTIO_F_ANY_LAYOUT 27 + +/* Virtio helper functions */ + +#define virtio_read_config_member(vdev, structname, member, ptr) \ + virtio_read_config((vdev), offsetof(structname, member), \ + (ptr), sizeof(*(ptr))); + +#define virtio_write_config_member(vdev, structname, member, ptr) \ + virtio_write_config((vdev), offsetof(structname, member), \ + (ptr), sizeof(*(ptr))); + +#endif /* CONFIG_OPENAMP */ + +#endif /* __INCLUDE_NUTTX_VIRTIO_VIRTIO_CONFIG_H */ diff --git a/include/nuttx/virtio/virtio.h b/include/nuttx/virtio/virtio.h index a0d122714f708..7f288d8867d77 100644 --- a/include/nuttx/virtio/virtio.h +++ b/include/nuttx/virtio/virtio.h @@ -29,32 +29,14 @@ #include -#include #include #include +#include #ifdef CONFIG_DRIVERS_VIRTIO #include -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/* Virtio common feature bits */ - -#define VIRTIO_F_ANY_LAYOUT 27 - -/* Virtio helper functions */ - -#define virtio_read_config_member(vdev, structname, member, ptr) \ - virtio_read_config((vdev), offsetof(structname, member), \ - (ptr), sizeof(*(ptr))); - -#define virtio_write_config_member(vdev, structname, member, ptr) \ - virtio_write_config((vdev), offsetof(structname, member), \ - (ptr), sizeof(*(ptr))); - /**************************************************************************** * Public Type Definitions ****************************************************************************/ From c7720ee450d7f001ad6f335d23432f2b806a15cf Mon Sep 17 00:00:00 2001 From: Bowen Wang Date: Tue, 29 Oct 2024 23:13:03 +0800 Subject: [PATCH 6/8] virtio: update virtio_alloc_buf() releated APIs usage new virtio_alloc_buf() return int type, so add virtio_malloc_buf() for the convenience of use. And replace all virtio_alloc_buf() to virtio_malloc_buf() in NuttX. Signed-off-by: Bowen Wang --- drivers/virtio/virtio-snd.c | 16 ++++++++-------- include/nuttx/virtio/virtio.h | 21 ++++++++++++++++++--- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/drivers/virtio/virtio-snd.c b/drivers/virtio/virtio-snd.c index ea861aba936c2..7952fb7fc9d2a 100644 --- a/drivers/virtio/virtio-snd.c +++ b/drivers/virtio/virtio-snd.c @@ -478,7 +478,7 @@ static int virtio_snd_query_info(FAR struct virtio_snd_s *priv, req->count = count; req->size = size; - resp = virtio_alloc_buf(priv->vdev, sizeof(*resp), 16); + resp = virtio_malloc_buf(priv->vdev, sizeof(*resp), 16); if (resp == NULL) { vrterr("virtio audio driver cmd response alloc failed\n"); @@ -562,7 +562,7 @@ static int virtio_snd_set_params(FAR struct virtio_snd_dev_s *sdev, req->buffer_bytes = req->period_bytes * CONFIG_DRIVERS_VIRTIO_SND_BUFFER_COUNT; - resp = virtio_alloc_buf(priv->vdev, sizeof(*resp), 16); + resp = virtio_malloc_buf(priv->vdev, sizeof(*resp), 16); if (resp == NULL) { vrterr("zalloc for request error\n"); @@ -609,7 +609,7 @@ static int virtio_snd_send_cmd(FAR struct virtio_snd_dev_s *sdev, struct virtqueue_buf vb[2]; int ret; - req = virtio_alloc_buf(vdev, sizeof(*req), 16); + req = virtio_malloc_buf(vdev, sizeof(*req), 16); if (req == NULL) { vrterr("zalloc for request error\n"); @@ -619,7 +619,7 @@ static int virtio_snd_send_cmd(FAR struct virtio_snd_dev_s *sdev, req->hdr.code = cmd; req->stream_id = sdev->index; - resp = virtio_alloc_buf(vdev, sizeof(*resp), 16); + resp = virtio_malloc_buf(vdev, sizeof(*resp), 16); if (resp == NULL) { vrterr("zalloc for request error\n"); @@ -1112,10 +1112,10 @@ static int virtio_snd_init(FAR struct virtio_snd_s *priv) vrtinfo("jacks:%"PRIu32" streams:%"PRIu32" chmap:%"PRIu32"\n", priv->config.jacks, priv->config.streams, priv->config.chmaps); - priv->info = virtio_alloc_buf(priv->vdev, - priv->config.streams * - sizeof(struct virtio_snd_pcm_info), - 16); + priv->info = virtio_malloc_buf(priv->vdev, + priv->config.streams * + sizeof(struct virtio_snd_pcm_info), + 16); if (priv->info == NULL) { vrterr("virtio audio driver query pcm info alloc failed\n"); diff --git a/include/nuttx/virtio/virtio.h b/include/nuttx/virtio/virtio.h index 7f288d8867d77..c6130bf75e507 100644 --- a/include/nuttx/virtio/virtio.h +++ b/include/nuttx/virtio/virtio.h @@ -187,15 +187,30 @@ extern "C" #define EXTERN extern #endif +static inline_function FAR void * +virtio_malloc_buf(FAR struct virtio_device *vdev, size_t size, size_t align) +{ + FAR void *buf; + + if (virtio_alloc_buf(vdev, &buf, size, align) < 0) + { + return NULL; + } + + return buf; +} + static inline_function FAR void * virtio_zalloc_buf(FAR struct virtio_device *vdev, size_t size, size_t align) { - FAR void *buf = virtio_alloc_buf(vdev, size, align); - if (buf != NULL) + FAR void *buf; + + if (virtio_alloc_buf(vdev, &buf, size, align) < 0) { - memset(buf, 0, size); + return NULL; } + memset(buf, 0, size); return buf; } From a68550c47f1efd36adc4a6d5f0ab341d4386fcbe Mon Sep 17 00:00:00 2001 From: Bowen Wang Date: Tue, 30 Dec 2025 17:18:35 +0800 Subject: [PATCH 7/8] virtio/vhost: update virtqueue_get_available_buffer() api OpenAMP already change virtqueue_get_available_buffer() to virtqueue_get_first_avail_buffer(), so update them Signed-off-by: Bowen Wang --- drivers/vhost/vhost-rng.c | 2 +- include/nuttx/virtio/virtio.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/vhost/vhost-rng.c b/drivers/vhost/vhost-rng.c index 5730ee50c9dab..0ed1477167e00 100644 --- a/drivers/vhost/vhost-rng.c +++ b/drivers/vhost/vhost-rng.c @@ -95,7 +95,7 @@ static void vhost_rng_work(FAR void *arg) flags = spin_lock_irqsave(&priv->lock); for (; ; ) { - buf = virtqueue_get_available_buffer(vq, &idx, &len); + buf = virtqueue_get_first_avail_buffer(vq, &idx, &len); if (buf == NULL) { break; diff --git a/include/nuttx/virtio/virtio.h b/include/nuttx/virtio/virtio.h index c6130bf75e507..98dafb4573dcc 100644 --- a/include/nuttx/virtio/virtio.h +++ b/include/nuttx/virtio/virtio.h @@ -105,7 +105,7 @@ virtqueue_get_available_buffer_lock(FAR struct virtqueue *vq, FAR void *ret; flags = spin_lock_irqsave(lock); - ret = virtqueue_get_available_buffer(vq, avail_idx, len); + ret = virtqueue_get_first_avail_buffer(vq, avail_idx, len); spin_unlock_irqrestore(lock, flags); return ret; From 58034a98b2e122816f7d48570057eccfa991bea2 Mon Sep 17 00:00:00 2001 From: Bowen Wang Date: Tue, 30 Dec 2025 19:47:07 +0800 Subject: [PATCH 8/8] nuttx/cache.h: fix the compile warning in sim when enable OpenAMP MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit /data/project/code/apache/nuttx/cmake_out/sim_server/openamp/libmetal/lib/include/metal/system/nuttx/cache.h: In function ‘__metal_cache_flush’: /data/project/code/apache/nuttx/cmake_out/sim_server/openamp/libmetal/lib/include/metal/system/nuttx/cache.h:25:46: warning: unused parameter ‘addr’ [-Wunused-parameter] 25 | static inline void __metal_cache_flush(void *addr, unsigned int len) | ~~~~~~^~~~ /data/project/code/apache/nuttx/cmake_out/sim_server/openamp/libmetal/lib/include/metal/system/nuttx/cache.h:25:65: warning: unused parameter ‘len’ [-Wunused-parameter] 25 | static inline void __metal_cache_flush(void *addr, unsigned int len) | ~~~~~~~~~~~~~^~~ /data/project/code/apache/nuttx/cmake_out/sim_server/openamp/libmetal/lib/include/metal/system/nuttx/cache.h: In function ‘__metal_cache_invalidate’: /data/project/code/apache/nuttx/cmake_out/sim_server/openamp/libmetal/lib/include/metal/system/nuttx/cache.h:30:51: warning: unused parameter ‘addr’ [-Wunused-parameter] 30 | static inline void __metal_cache_invalidate(void *addr, unsigned int len) | ~~~~~~^~~~ /data/project/code/apache/nuttx/cmake_out/sim_server/openamp/libmetal/lib/include/metal/system/nuttx/cache.h:30:70: warning: unused parameter ‘len’ [-Wunused-parameter] 30 | static inline void __metal_cache_invalidate(void *addr, unsigned int len) | ~~~~~~~~~~~~~^~~ Signed-off-by: Bowen Wang --- include/nuttx/cache.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/nuttx/cache.h b/include/nuttx/cache.h index 030b6d7e3f791..ef5e477b6e095 100644 --- a/include/nuttx/cache.h +++ b/include/nuttx/cache.h @@ -342,7 +342,7 @@ void up_disable_dcache(void); #ifdef CONFIG_ARCH_DCACHE void up_invalidate_dcache(uintptr_t start, uintptr_t end); #else -# define up_invalidate_dcache(start, end) +# define up_invalidate_dcache(start, end) ((void)(start), (void)(end)) #endif /**************************************************************************** @@ -384,7 +384,7 @@ void up_invalidate_dcache_all(void); #ifdef CONFIG_ARCH_DCACHE void up_clean_dcache(uintptr_t start, uintptr_t end); #else -# define up_clean_dcache(start, end) +# define up_clean_dcache(start, end) ((void)(start), (void)(end)) #endif /****************************************************************************