Commit Graph
241 Commits
Author SHA1 Message Date
Arnaud Pouliquen de33a8d675 virtio: Fix delete_virtqueues function
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>
2023-10-19 16:00:21 -07:00
Arnaud Pouliquen cd8823876f virtio: make unused function virtio_describe() deprecated
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>
2023-10-16 16:53:32 +02:00
Arnaud Pouliquen 0360890c32 virtio: Add virtio_dev_name function description
Add function description in Doxygen format for documentation.

Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
2023-10-13 10:29:36 +02:00
Arnaud Pouliquen adc68ec055 virtio: Complete virtio and virtqueue structures Doxygen description
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>
2023-10-13 10:29:36 +02:00
Dan Milea bdf5f910c0 Refactor VRING macros for AMP VIRTIO
Renamed AMP VIRTIO macros to avoid conflicts.

Signed-off-by: Dan Milea <dan.milea@windriver.com>
2023-10-10 16:22:53 +02:00
Tammy Leino 937ba1d700 Doxygen updates for data structures
Improved doxygen formatting and consistency for data structures.
Signed-off-by: Tammy Leino <tammy.leino@siemens.com>
2023-10-06 16:44:53 +02:00
Iuliana Prodan f2162a69ac options: add option for all cache operations
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>
2023-09-18 09:12:36 +02:00
Iuliana Prodan b4f10fbb69 virtqueue: define a common cache flush/invalidate
Since all cache operations, for vrings, buffer and
resource table are using metal_cache_flush and
metal_cache_invalidate, define a common function for all.

Signed-off-by: Iuliana Prodan <iuliana.prodan@nxp.com>
2023-09-18 09:12:36 +02:00
Iuliana Prodan 95a9038ca6 rpmsg: buffers flush/invalidate
Do buffers flush and invalidate the same as with vrings
and resource table:
- add defines in header file;
- call BUFFER_FLUSH/BUFFER_INVALIDATE where necessary.

Signed-off-by: Iuliana Prodan <iuliana.prodan@nxp.com>
2023-09-18 09:12:36 +02:00
Iuliana Prodan ca0747ebec virtqueue: move VRING_FLUSH and VRING_INVALIDATE to header
Move VRING_FLUSH and VRING_INVALIDATE defines to header file.

Signed-off-by: Iuliana Prodan <iuliana.prodan@nxp.com>
2023-09-18 09:12:36 +02:00
Dan Milea e63d07d105 virtio: virtio-mmio framework
VIRTIO MMIO transport for OpenAMP.

Signed-off-by: Dan Milea <dan.milea@windriver.com>
2023-08-17 09:14:38 +02:00
Iuliana Prodan a2456e61ee remoteproc: do cache invalidation before reading rsc_table info
Do a cache invalidation before reading the resource table's info
since this ca be in a cacheable region.

Make this optional, based on VIRTIO_CACHED_RSC_TABLE.

Signed-off-by: Iuliana Prodan <iuliana.prodan@nxp.com>
2023-07-17 17:16:05 +02:00
Bowen Wang 7f906105a9 virtio: add create_virtqueues and delete_virtqueues in virtio_dispatch
This is the first step to decoupling the virtio device and transport
layer.

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2023-07-12 10:56:55 +02:00
Bowen Wang b177618da4 virtio: follow virtio v1.2 spec, add more virtio status and device id
Follow the virtio v1.2 spec, add more virtio status and device id
definition in virtio.h

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2023-06-22 09:50:50 +02:00
Tammy Leino 873039d24e Function header description consistency
Updated function header descriptions formatting to be consistent.
Signed-off-by: Tammy Leino <tammy.leino@siemens.com>
2023-04-26 10:29:49 +02:00
Yunfei Li 1b9754867b lib:Fix atomic_flag error for clang compilation
Change atomic_int to atomic_flag to solve the error
reported when compiling with clang.

Signed-off-by: Yunfei Li <liyunfei33@huawei.com>
2023-03-14 19:00:49 +01:00
Arnaud Pouliquen 6dad72724f rpmsg virtio: Implement the Tx buffer reclaimer
With the no-copy feature a tx buffer can be get, filled and then
sent to the remote side.
In Some error cases the application can need to release it instead
of sending it to the remote side.
As the virtqueue is updated when the buffer it get, it is not
possible to manage this use case at virtqueue level.

This patchset implements the release based on a buffer recycler.
The principle is to store the released buffer in a 'reclaimer' list.
On next get pmsg_virtio_get_tx_buffer call the buffer is reused.

Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
2022-10-18 10:31:19 +02:00
Arnaud Pouliquen 2e0015af74 virtqueue: Add helper to get the buffer address from descriptor index
As it possible to get the buffer length we need also to retrieve
the address associated to the descriptor index.
This is need by rpmsg virtio to implement the buffer recycler.

Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
2022-10-18 10:31:19 +02:00
Arnaud Pouliquen 4e1fa03814 rpmsg: Add rpmsg_release_tx_buffer API
Add an API to be able to release unused TX buffer that will not be
sent.
For instance this API can be called in case of error between the
buffer reservation and the send to the remote side.

Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
2022-10-18 10:31:19 +02:00
Jiuzhu Dong e62c824489 openamp: divide shram to TX shram & RX shram by config:split_shpool
In the multi core of lower power device, when one of core enters sleep,
it needs to put its corresponding share memory into retention mode to
save power consumption. Based on the limitations of the chip design,
when the CPU to which share memory belongs goes to sleep, the share
memory enters the retention mode, and other cores will not be able
to access it. When the share memory divides tx shm and rx shm
and the core of tx shm and rx shm are different, so that when one
CPU sleeps, the other CPU can still access its own tx shm.

Signed-off-by: Guiding Li <liguiding1@xiaomi.com>
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2022-10-14 10:26:35 +02:00
Tammy Leino 88f38c9020 Potential overflow of notifyid on 64-bit architectures
handle_vdev_rsc sets end to RSC_NOTIFY_ID_ANY in case of wildcard notifyid
Signed-off-by: Tammy Leino <tammy_leino@mentor.com>
2022-10-14 09:54:03 +02:00
Tammy Leino e40eea8ff1 Vring descriptor count must be limited to 65k per device
Code must ensure we don't overflow the 16-bit count in vring_alloc_info
Signed-off-by: Tammy Leino <tammy_leino@mentor.com>
2022-10-04 10:08:36 +02:00
Tammy Leino 2016ff1e49 Additional input parameter checks for APIs
Added additional input parameter checks to APIs
Signed-off-by: Tammy Leino <tammy_leino@mentor.com>
2022-10-03 17:30:14 +02:00
Arnaud Pouliquen afed3bd117 Terminology: Replace potentially offensive terms in documentation
In line with the terminology changes proposed by the OpenAMP
Technical Steering committee. Suppress "master and "slave" terms
in comments and documentations.

Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
2022-05-31 10:15:47 +02:00
Guiding Li 9fdadd0a4a openamp: add ns_unbind_cb to rpmsg_device
it's useful to notify the port layer and
also symmetry with ns_bind_cb callback

Signed-off-by: Guiding Li <liguiding1@xiaomi.com>
2022-05-16 09:51:12 +02:00
Xiang Xiao 3ff669b993 rpmsg: remove rpmsg_init_ept
since it is deprecated for while

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-05-04 15:01:29 -07:00
Ed Mooring 71c85d6b66 Terminology: Replace potentially offensive terms in the code.
In line with the terminology changes proposed by the OpenAMP
Technical Steering committe. Change VIRTIO_SLAVE_ONLY to
VIRTIO_DEVICE_ONLY. On linux, the two ends of the virtio communication
path are referred to as the "driver" (Linux), and the "device", in this
case running on the remote processor.

Terminology: Replace VIRTIO_MASTER_ONLY with VIRTIO_DRIVER_ONLY.

Terminology: Replace VIRTIO_DEV_SLAVE with VIRTIO_DEV_DEVICE

Terminology: Replace VIRTIO_DEV_MASTER with VIRTIO_DEV_DRIVER.

Apps: Fix variable names

Per guidance from the Technical Steering Committee, replace "master" and
"slave" with more appropriate terms.

lib: Replace RPMSG_MASTER with RPMSG_HOST

cmake: Change option names from "master", "slave" to "driver", "device".

Apps: Cleanup terminology

README: Update variable names to match the code.

Terminology: Add deprecation warnings to configuration variables.

Warn the user if they use the older, possibly offensively
named configuration variables.

Terminology: Clean up deprecation warnings.

CMake: Default deprecated configuration variables to off.

Make the deprecated WITH_VIRTIO_MASTER and WITH_VIRTIO_SLAVE
configuration variables default to OFF. This means that only deliberate
use of those variables will trigger the deprecation warning.

Terminology: Replace compiler-specific warnings with #warning.

In warning about deprecated constant names, change from
compiler-specific compile time warnings to the standard #warning.

fixup! Terminology: Replace potentially offensive terms in the code.

Fix the compilation error in zephyr by declaring a deprecated function

Deprecated message generated:
zephyr/samples/subsys/ipc/openamp_rsc_table/src/main_remote.c: In function 'rpmsg_mng_task':
zephyr/samples/subsys/ipc/openamp_rsc_table/src/main_remote.c:351:2: warning: 'deprecated_virtio_dev_slave' is deprecated [-Wdeprecated-declarations]
  351 |  rpdev = platform_create_rpmsg_vdev(0, VIRTIO_DEV_SLAVE, NULL,
      |  ^~~~~
In file included from modules/lib/open-amp/open-amp/lib/include/openamp/rpmsg_virtio.h:18,
                 from modules/lib/open-amp/open-amp/lib/include/openamp/open_amp.h:12,
                 from zephyr/samples/subsys/ipc/openamp_rsc_table/src/main_remote.c:15:
modules/lib/open-amp/open-amp/lib/include/openamp/virtio.h:49:32: note: declared here
   49 | __deprecated static inline int deprecated_virtio_dev_slave(void)
      |                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~

fixup! Terminology: Replace potentially offensive terms in the code.

miscellaneous update

Signed-off-by: Ed Mooring <ed.mooring@gmail.com>
Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
2022-04-29 10:12:09 +02:00
Xiang Xiao 6f03c1e952 lib: add const for remoteproc_ops, image_store_ops and laoder_ops
to avoid load the constant data to ram in XIP mode

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-04-28 09:40:05 +02:00
Tammy Leino e4307e142e Document buf argument in get_mem for remoteproc_ops structure
Added a description of the buf parameter to get_mem.
Signed-off-by: Tammy Leino <tammy_leino@mentor.com>
2022-04-15 09:20:36 +02:00
Arnaud Pouliquen 4728d56c85 Fix various typo with codespell
Found via `codespell -q 3 -S ./scripts/spelling.txt`

Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
2022-04-14 09:13:39 +02:00
Xiang Xiao 353122136d rpmsg_virtio: move RPMSG_VIRTIO_DEFAULT_CONFIG to private location
and define it to NULL when VIRTIO_SLAVE_ONLY is defined to save space

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-01-24 09:37:31 +01:00
Hubert Miś a12d03ccc1 rpmsg_virtio: docs fixes for the rpmsg_init_vdev function
Replacing potentially objectionable terms from the function description.
Language fixes.

Signed-off-by: Hubert Miś <hubert.mis@nordicsemi.no>
2022-01-04 10:20:47 +01:00
Hubert Miś 6cb75b8e58 rpmsg_virtio: configuration option to set buffer sizes per instance
Enable user of rpmsg_virtio to set sizes of TX and RX buffers per
created rpmsg_virtio instance. Each instance can use other buffer sizes.

Signed-off-by: Hubert Miś <hubert.mis@nordicsemi.no>
2022-01-04 10:20:47 +01:00
ViswaHarsha C 413ff36118 lib: added generic rpmsg services
defined generic services for rpmsg based calls between master and
slave

Signed-off-by: ViswaHarsha C <cviswa.harsha_ext@ltts.com>
2021-10-11 18:44:48 +02:00
Arnaud Pouliquen 2833ca2aaa lib: add new API to get the library version
Add similar API that the libmetal to allow application to get information
about the version of the openamp library.

Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
2021-04-26 16:06:20 +02:00
GFWisshit 278bcd2d10 Fix compilation error.Add missing semicolon. 2021-04-16 09:13:18 +02:00
Xiang Xiao e03656d53e remoteproc: add get_mem callback to remoteproc_ops
Since the mapping info is normally managed inside the porting
layer, the new callback could avoid the mapping duplication.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-04-16 09:13:18 +02:00
Chao An 47549566ea rpmsg: bring back zero copy transfer
Commit-id: b16ca55
Adding RPMsg Extension layer implementing zero-copy send and receive.

Signed-off-by: Chao An <anchao@pinecone.net>
2020-12-03 15:31:20 +01:00
Arnaud Pouliquen 39cbd87454 lib: add missing license information for rpmsg_retarget
Add BSD license and mentor copyright.

Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
2020-12-01 10:14:00 +01:00
Xiang Xiao 8e6fb73843 rename size parameter to len for rpmsg_send_offchannel_raw
to align with other rpmsg_send_xxx function naming convention

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-11-05 13:05:24 -08:00
Arnaud Pouliquen 885a263451 rpmsg: set rpmsg_init_ept API as deprecated
The rpmsg_init_ept does not seem to be usable by application
but is used internally. This patch mark this API deprecated
and in at least two full release, to remove this API as the
standard API to use is rpmsg_create_ept.
In addition, move the rpmsg_init_ept to rpmsg_internal and rename it.

Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
2020-10-12 14:16:12 +02:00
Simon Leiner 6a83524009 Cast allocated memory to target type
Although omitting the cast to the target type is idiomatic C, the
omission is actually forbidden in ISO C++. This patch enables the header
to be used in C++ code.

Signed-off-by: Simon Leiner <simon@leiner.me>
2020-07-27 11:29:06 +02:00
Xiang Xiao 94ca6c206a rpmsg: zero out rdev field in rpmsg_unregister_endpoint
so is_rpmsg_ept_ready can check the validity more easier

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-05-29 15:39:18 +02:00
Xiang Xiao a3a46ab518 rpmsg: reserve 0-1023 for predefined services in rpmsg_create_ept
and allocate the dynamic address from 1024 like Linux kernel

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-05-29 15:37:45 +02:00
Xiang Xiao 20292c5dca implement rproc_virtio_read_config/rproc_virtio_write_config
so the rpmsg could access the configuration space as needed

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-05-13 11:03:59 +02:00
Xiang Xiao ff798a9103 rpmsg: remove the address check in rpmsg_send/rpmsg_trysend
since rpmsg_send_offchannel_raw already do the same validation

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-05-13 09:52:55 +02:00
Arnaud Pouliquen ef7cf424a8 virtio: fix virtqueue callback typedef
Fix declaration of the the function pointer type reported
by checkpatch tool.

Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
2020-04-08 17:06:50 +02:00
Arnaud Pouliquen b8bc3b7122 lib: fix minor coding style.
Fix coding style reported by do_checkpatch.sh

Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
2020-04-08 17:06:50 +02:00
Gaute Nilsson bc8b2c5e8f rpmsg: pack the vring_desc and vring_avail structs
This is done in order to avoid a compiler warning from
the -Wcast-align flag.

Signed-off-by: Gaute Nilsson <gaute.nilsson@siemens.com>
2020-02-20 08:53:10 +01:00
Arnaud Pouliquen a1701c474e remoteproc: fix IAR C-STAT tool reports
Fix errors returned by fix IAR C-STAT tool:
elf_loader.c:
 - L374	Variable `phdr' may be uninitialized
 - L469 (and some others) Expression may overflow
remoteproc.c:
 - L43: Overrun in strncmp with string `mem->name'. Length passed
   to strncmp is 32, but string is of length <unknown size>
 - L185: Variable `ret' may be uninitialized
 - L498 & L696: Value assigned to variable `ret' is never used

Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
2020-01-16 15:00:31 +01:00