Remove the following CMake options and associated definitions that have
been deprecated for over two years:
- WITH_DCACHE_VRINGS
- WITH_DCACHE_BUFFERS
- WITH_DCACHE_RSC_TABLE
- VIRTIO_CACHED_RSC_TABLE
- VIRTIO_CACHED_BUFFERS
- VIRTIO_CACHED_VRINGS
Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
The function rproc_virtio_wait_remote_ready does not return a value.
Remove the related @return field from the documentation.
Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
- removes CACHE_FLUSH macro clashing with internal QNX definition
- also removes CACHE_INVALIDATE macro for consistency
Signed-off-by: Deep Chordia <dchordia@blackberry.com>
review requested to use a table rather than a code snippet to define
the memory layout, so convert proposed struct to a table with
definition, size and description and explanation of padding between
available and used structures.
Signed-off-by: Sipke Vriend <sipke@direktembedded.com>
In virtio device side, we always need to get the next avaiable
buffer based on current buffer index. So add these two APIs for
convinience use.
For example, virtio blk driver origanize the buffer:
+----------+
| Reqeust | (Flags: Read | Next)
+----------+
| Buffer | (Flags: Read/Write | Next)
+----------+
| Response | (Flags: Write)
+----------+
For the virtio blk device size, we need get the Buffer and Response buffer
based on the Request buffer index.
So add api virtqueue_get_next_avail_buffer() to get the next available
buffer based on the first buffer index.
And rename the virtqueue_get_available_buffer() to
virtqueue_get_first_avail_buffer()
Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
Signed-off-by: Yongrong Wang <wangyongrong@xiaomi.com>
virtio_has_feature() can be easily used to check if the virtio device
support a specific feature.
And assgin feature to vdev->feature for virtio device role when get
features, so the virtio device side can use virtio_has_featrue() to
check weather the virtio device support a feature.
Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
Follow the virtio spec, this feature bit indicates that the device
accepts arbitrary descriptor layouts.
Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
Add parentheses around the "vdev" parameter to avoid side effects.
This fixes a build error when using the macro in the following way:
if (VIRTIO_ROLE_IS_DEVICE(&my_context->vdev))
The error encountered:
openamp/open-amp/lib/include/openamp/virtio.h:89:49: error: invalid type argument of ‘->’ (have ‘struct virtio_device’)
89 | (VIRTIO_ENABLED(VIRTIO_DRIVER_SUPPORT) && (vdev->role) == VIRTIO_DEV_DRIVER)
Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
Buffer management is different for different transport layer:
For MMIO transport layer, the buffer can directly allocated from
the geust OS heap beacase the hypervisor can access all the memory own
by guest OS.
For remoteproc transport layer, the buffer should be allocated from
the share memory region to make sure the remote core can access this
buffer too.
So add memory ops in virtio device to make different transport/device can
implement their own share memory management.
Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
Fix the size of the source string passed in argument of safe_strcpy().
In rpmsg_register_endpoint we can not trust the size of the name
string provided, so we limit the max size to RPROC_MAX_NAME_LEN.
Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
Fix the size of the source string passed in argument of safe_strcpy().
In rpmsg_create_ept we can not trust the size of the name
string provided, so we limit the max size to RPMSG_NAME_SIZE.
Update the rpmsg_create_ept documentation to clarify the limit
Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
The strlcpy() function has only recently become available in glibc.
While this function prevents destination buffer overflow, it seems
that it cannot guarantee read access only within the source buffer.
this is for instance the case if the source string is not terminated by
a'\0' character.
Implement a safe_strcpy to ensure that no access is done out of the
source and destination buffer ranges.
Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
Make the metal_io_region for cfg_io and shm_io into full member structs
instead of just pointers. This means they will be allocated along with
the parent virtio_mmio_device struct and not need dynamically allocated
later.
Signed-off-by: Andrew Davis <afd@ti.com>
A virtual metal_device is created, then the needed IO regions are created
and added to this device. Immediately we extract these same regions back
out and make use of them. There is no reason to do this, instead simply
use the created IO regions.
This also removes the need to have struct metal_device defined to have
more than one IO region (METAL_MAX_DEVICE_REGIONS), which is not the
default and can change per-platform. If the libmetal library was built
with the default value for METAL_MAX_DEVICE_REGIONS, then this would
have led to runtime failures.
Signed-off-by: Andrew Davis <afd@ti.com>
The virtio.h header can be included by applications. In such cases,
VIRTIO_DRIVER_SUPPORT and VIRTIO_DEVICE_SUPPORT, which are used to
optimize the library, may not be defined in the application.
Define default VIRTIO_ROLE_IS_DEVICE and VIRTIO_ROLE_IS_DRIVER macros
that do not check for VIRTIO_DEVICE_SUPPORT or VIRTIO_DRIVER_SUPPORT if
they are not defined.
Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
Building the samples/subsys/ipc/openamp_rsc_table/ sample generates the
following warning:
[24/182] Building C object zephyr/CMakeFiles/zephyr.dir/lib/open-amp/resource_table.c.obj
In file included from /zephyrproject/zephyr/lib/open-amp/./resource_table.h:11,
from /zephyrproject/zephyr/lib/open-amp/resource_table.c:30:
/zephyrproject/modules/lib/open-amp/open-amp/lib/include/openamp/virtio.h:83:2:
warning: #warning "VIRTIO_DRIVER_SUPPORT and/or VIRTIO_DEVICE_SUPPORT should be defined" [-Wcpp]
83 | #warning "VIRTIO_DRIVER_SUPPORT and/or VIRTIO_DEVICE_SUPPORT should be defined"
| ^~~~~~~
The issue occurs because the project includes the virtio API while
VIRTIO_DRIVER_SUPPORT and VIRTIO_DEVICE_SUPPORT is only defined for
the open-amp library build.
Fix the warning by testing deprecated usage of VIRTIO_DRIVER_ONLY and
VIRTIO_DEVICE_ONLY but not under
#if !defined(VIRTIO_DRIVER_SUPPORT) && !defined(VIRTIO_DEVICE_SUPPORT)
condition.
Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
As part of the deprecation process for VIRTIO_DEVICE_ONLY and
VIRTIO_DRIVER_ONLY, we should still support builds without errors when
possible.
For legacy support, define VIRTIO_DRIVER_SUPPORT and VIRTIO_DEVICE_SUPPORT
default values based on VIRTIO_DEVICE_ONLY and VIRTIO_DRIVER_ONLY.
Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
The `role` member of `struct virtio_device` stores either the value
VIRTIO_DEV_DRIVER or VIRTIO_DEV_DEVICE. This means the function
rpmsg_virtio_get_role() will also return one of these values.
The values RPMSG_HOST and RPMSG_REMOTE are defined to be the same,
but there is no need for this redefinition. Update the return
values in the comment docs.
While here, remove the same from rpmsg_virtio_set_wait_cb() which
does not return anything, this looks to be a copy/paste error.
Signed-off-by: Andrew Davis <afd@ti.com>
The doxygen build report issue for function descriptions that provide
reference to some function parameters using @:
...
lib/include/openamp/rpmsg.h:160: warning: Found unknown command '\data'
lib/include/openamp/rpmsg.h:160: warning: Found unknown command '\len'
...
Fix the warning by replacing with back-ticks that will be interpreted as
code by Markdown(Markdown support is enabled in the Doxygen configuration).
Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
Fix following warning by updating bad rpc_id parameter type in
the rpmsg_rpc_client_send() API.
Align the rpc_id type to the one used in rpmsg_rpc_server_send().
/github/workspace/lib/service/rpmsg/rpc/rpmsg_rpc_client.c:60:9:
error: ‘memcpy’ reading 8 bytes from a region of size 4
[-Werror=stringop-overread]
1286
60 | memcpy(tmpbuf, &rpc_id, MAX_FUNC_ID_LEN);
1287
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1288
/github/workspace/lib/service/rpmsg/rpc/rpmsg_rpc_client.c:51:40:
note: source object ‘rpc_id’ of size 4
1289
51 | unsigned int rpc_id, void *request_param,
1290
| ~~~~~~~~~~~~~^~~~~~
Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
The use of the master and slave terminologies in configs and API are now
deprecated since 2 years, we can remove the associated code.
Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
There is a common pattern of checking the virtio role while also checking
that this role is supported in this build, which can help optimize away
unusable code. Add a couple macros for this. This has two main benefits,
first being shorter and easier to read if statements, and also makes it
easier to not forget to always do both checks.
Use these everywhere except rpmsg_virtio.c which needs one more refactor
before we can switch it over.
Signed-off-by: Andrew Davis <afd@ti.com>
Checks if this symbol is defined and set to equal 1. Used to make it
more clear that a preprocessor level check is intended.
Signed-off-by: Andrew Davis <afd@ti.com>
Currently compiler defines are defined when support for driver or device
is the only support being built. This is a negative define, it surrounds
the code to not be built and we use ifndef. This is confusing. It also
leaves ifndefs all throughout the code-base. Instead, define a macro that
is set to 1 if support is enabled. Use this inline in if statements where
possible. Any sane compiler will optimize away the code in the branch
when support is not enabled just the same as when using the preprocessor
so we keep the same binary size.
Signed-off-by: Andrew Davis <afd@ti.com>
The rvdev->notify_wait_cb is not initialized to NULL if
not set by the user.
Initialize it to NULL and provide an API for the application to set it.
Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
This should hold a pointer to a metal_io_region, make that the type.
Also fix the comment above this variable. This region holds the address
of the message buffers, not the vring descriptor table nor available/used
ring data. It is only used for virt-to-phys/phys-to-vert translation on
the buffers pointed to by these descriptors.
Signed-off-by: Andrew Davis <afd@ti.com>
Having these functions as inline header functions forces the contents of
struct remoteproc_mem to remain externally exposed. It also does not save
space in most cases as every call-site gets the full contents of the
function instead of just a call instruction. Make these normal functions
like all others in remoteproc.h.
Signed-off-by: Andrew Davis <afd@ti.com>
Add an RPMsg API to get the buffer sizes supported by the backing
transport layer. Add hooks so that transport layers can register
functions to provide this data.
Signed-off-by: Andrew Davis <afd@ti.com>
Do not expose new functions that reach into structs not belonging to
rpmsg_virtio, that breaks layering. Functions to access these members of
struct virtio are already provided by virtio, use those instead. Deprecate
the unneeded and layer breaking rpmsg_virtio functions for the same.
Signed-off-by: Andrew Davis <afd@ti.com>
These are only used internally by rpmsg_virtio. They also already exist
as part of the virtio API. Do not create an extra wrapper API out of
these functions. Deprecate these functions.
Signed-off-by: Andrew Davis <afd@ti.com>
The files in include/openamp are deployed on install and can be used
by applications using the OpenAMP API. The functions in rsc_table_parser
are all internal use only. Move this header out of that location.
Signed-off-by: Andrew Davis <afd@ti.com>
These functions are only used within rsc_table_parser. These should be
only available there and made static. This prevents them from becoming
part of the API.
Signed-off-by: Andrew Davis <afd@ti.com>
Give users a chance to handle the no tx buffer situation when get tx
buffer, with this patch, user can set the notify_wait_cb in driver
and this callback function will be called to handle the wait when no
tx buffer in tx virtqueue.
Signed-off-by: Yongrong Wang <wangyongrong@xiaomi.com>
1. Implement the rproc_virtio_create_virtqueues() and
rproc_virtio_delete_virtqueues().
2. Because 1, also modified the rpmsg init.
Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
Give users a chance to handle the no tx buffer situation when get tx
buffer, with this patch, user can call rproc_virtio_set_wait_notified()
to set the wait_notified() callback and this callback function will be
called to handle the wait when no tx buffer in tx virtqueue.
Signed-off-by: Guiding Li <liguiding1@xiaomi.com>
Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
if rpmsg service free the ept when has got the ept from the ept
list in rpmsg_virtio_rx_callback, there is a used after free about
the ept, so add refcnt to end point and call the rpmsg service
release callback when ept callback fininshed.
Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
This API can be used by the endpoint callback to limit the rx
buffer usage range.
Signed-off-by: Guiding Li <liguiding1@xiaomi.com>
Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
CPU0 CPU1
create_ept1:addr1 create_ept1
OK <====== msg1
OK <====== msg2
OK <====== msg3
msg4
<====== msg4 on the virtioqueue
close_ept1 close_ept1
create_ept2:addr1 create_ept1
(same addr with ept1)
msg4
ept2 recv ept1 msg ERROR <======
The msg4 which belong to ep1, error received by ept2.
For this issue, I give a resolve method:
Let the rpmsg_get_address() always return a new increased num.
Signed-off-by: Guiding Li <liguiding1@xiaomi.com>
The function should return void. the reason is that
vdev->func->delete_virtqueues() is optional and return void.
To be generic we should call virtio_delete_virtqueues in all cases.
Then depending on the dispatcher we do nothing or call delete_virtqueues()
Fixes: 7f90610 ("virtio: add create_virtqueues and delete_virtqueues in virtio_dispatch")
Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
The virtio_describe() function does not seem usable.
Therefore, it should be marked as deprecated to initiate
the removal process.
Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
Add descriptions for following structures:
- virtio_device_id
- virtio_feature_desc
- virtio_dispatch
- virtqueue_buf
- virtqueue
- vring_alloc_info
Move some comments related to the vring structure in its description.
Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
Add WITH_DCACHE operation used for all cache operations:
vrings, buffers and resource table.
The other options will be deprecated - add warning
message for this.
Add info for WITH_DCACHE option in README.
Signed-off-by: Iuliana Prodan <iuliana.prodan@nxp.com>