Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions drivers/sensors/sensor_rpmsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <nuttx/mutex.h>
#include <nuttx/sensors/sensor.h>
#include <nuttx/rpmsg/rpmsg.h>
#include <nuttx/wqueue.h>

/****************************************************************************
* Pre-processor Definitions
Expand Down
2 changes: 1 addition & 1 deletion drivers/vhost/vhost-rng.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
16 changes: 8 additions & 8 deletions drivers/virtio/virtio-snd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand All @@ -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");
Expand Down Expand Up @@ -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");
Expand Down
4 changes: 2 additions & 2 deletions include/nuttx/cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

/****************************************************************************
Expand Down Expand Up @@ -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

/****************************************************************************
Expand Down
53 changes: 53 additions & 0 deletions include/nuttx/virtio/virtio-config.h
Original file line number Diff line number Diff line change
@@ -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 <nuttx/compiler.h>
#include <openamp/open_amp.h>

/****************************************************************************
* 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 */
46 changes: 20 additions & 26 deletions include/nuttx/virtio/virtio.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,35 +29,14 @@

#include <stdint.h>

#include <nuttx/compiler.h>
#include <nuttx/list.h>
#include <nuttx/spinlock.h>
#include <nuttx/virtio/virtio-config.h>

#ifdef CONFIG_DRIVERS_VIRTIO

#include <openamp/open_amp.h>

/****************************************************************************
* Pre-processor Definitions
****************************************************************************/

/* Virtio common feature bits */

#define VIRTIO_F_ANY_LAYOUT 27

/* 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)));

#define virtio_write_config_member(vdev, structname, member, ptr) \
virtio_write_config((vdev), offsetof(structname, member), \
(ptr), sizeof(*(ptr)));

/****************************************************************************
* Public Type Definitions
****************************************************************************/
Expand Down Expand Up @@ -126,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;
Expand Down Expand Up @@ -208,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;
}

Expand Down
1 change: 1 addition & 0 deletions net/rpmsg/rpmsg_sockif.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include <nuttx/crc32.h>
#include <nuttx/rpmsg/rpmsg.h>
#include <nuttx/mutex.h>
#include <nuttx/sched.h>
#include <nuttx/semaphore.h>
#include <nuttx/fs/ioctl.h>

Expand Down
28 changes: 0 additions & 28 deletions openamp/0001-lib-errno.h-fix-compile-error.patch

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
From fad5ddc80345f97a0c7b20c545502ac1f8e321a5 Mon Sep 17 00:00:00 2001
From: Bowen Wang <wangbowen6@xiaomi.com>
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 <wangbowen6@xiaomi.com>
---
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

32 changes: 16 additions & 16 deletions openamp/0001-ns-acknowledge-the-received-creation-message.patch
Original file line number Diff line number Diff line change
@@ -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 <xiaoxiang@xiaomi.com>
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.
Expand All @@ -17,7 +17,7 @@ Signed-off-by: wangyongrong <wangyongrong@xiaomi.com>
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 {
Expand All @@ -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" {
Expand All @@ -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);

Expand All @@ -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 {
Expand All @@ -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;

Expand All @@ -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);
}
Expand All @@ -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);
Expand All @@ -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.
*/
Expand Down
Loading
Loading