Commit Graph
1044 Commits
Author SHA1 Message Date
Guiding Li 7a11ad1e68 rpmsg: add cache flash when return rx buffer
Assume we have 2 cpus, and use cached shram buffer

CPU0                    CPU1

1. send tx bufferX
                        2. recv rx bufferX
                        3. set idx to hdr->reserved
                        4. handled rx bufferX
                        5. return bufferX
6. reuse tx bufferX
                        7. dirty cache auto flushed, hdr changed
8. buffer X meet error

Signed-off-by: Guiding Li <liguiding1@xiaomi.com>
2023-04-20 11:56:54 +02:00
Sergei Korneichuk 11d13f900a zynq7, microblaze resource table: virtio notifyid
Port commit 46d0418088 ("zynqmp_r5 resource table: Change notifyid
for the virtio device.") to zynq7 and microblaze.

Signed-off-by: Sergei Korneichuk <sergei.korneichuk@amd.com>
2023-03-23 09:35:11 +01: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
Yunfei Li d4145ecd75 apps: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
Guiding Li 246540f3d6 rpmsg: do cache_invalidate() when real data returned
This is a bugfix when open VIRTIO_CACHED_BUFFERS

Signed-off-by: Guiding Li <liguiding1@xiaomi.com>
2023-03-07 11:05:40 +01:00
Ben Levinsky 7513776e35 openamp: fix remoteproc_load_noblock hasn't update rsc_io
This addressess issue https://github.com/OpenAMP/open-amp/issues/427

Signed-off-by: Ben Levinsky <ben.levinsky@amd.com>
2023-02-27 11:15:38 +01:00
Hiago De Franco c5fa9ff0b2 readme: Fix broken openamp-rp mailing list link
Fix broken link that gives "page not found".

Signed-off-by: Hiago De Franco <hiagofranco@gmail.com>
2022-12-19 10:33:49 +01:00
Tammy Leino c1f93a1b5d Added build for Doxygen docs
Build workflow will generate html files from source if Doxygen is present.
Signed-off-by: Tammy Leino <tammy_leino@mentor.com>
2022-12-14 09:43:10 +01:00
Arnaud Pouliquen 081172c53c CI: add more build warning checks and force them to error.
Add CMAKE_C_FLAGS warnings to highlight potential issue:
"-Wall -Wextra -Wshadow -Wunused-but-set-variable"
And force warning as error with "-Werror"

Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
2022-11-28 18:36:41 +01:00
Arnaud Pouliquen 3586171a46 apps: Fix warnings about declaration of shadows variables
fix warnings reported by gcc with compilation flag '-Wshadow'

Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
2022-11-28 18:36:41 +01:00
Arnaud Pouliquen 452510d946 CI: fix Zephyr build issue resulting from the introduction of sysbuild
"Sysbuild is a higher-level build system that can be used to combine
multiple other build systems together"

Add the option by default for all platform as it is compatible with
a single image.

Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
2022-11-23 08:59:51 +01:00
Xiang Xiao 3a9119d655 Fix warn: declaration of 'vring_rsc' shadows a previous local
regressed by commit 03c80a1341
Author: Tammy Leino <tammy_leino@mentor.com>
Date:   Mon Sep 26 08:14:35 2022 -0700

    handle_vdev_rsc must return error if notifyid cannot be assigned

    Updated handle_vdev_rsc to return error if a unique id cannot be assigned
    Signed-off-by: Tammy Leino <tammy_leino@mentor.com>

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-11-14 10:59:27 +01:00
Arnaud Pouliquen 568d507be8 release: open-amp 2022.10.0
Set library version to 1.3.0

Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
Signed-off-by: Ed Mooring <ed.mooring@gmail.com>
v2022.10.0
2022-11-04 09:22:41 +01:00
Ed Mooring 46d0418088 zynqmp_r5 resource table: Change notifyid for the virtio device.
1. At firmware build time, the resource table for the Xilinx zynqmp_r5
is set up with notifyid==0 for the rpmsg virtio device. The vrings are
set up with notifyid==1 for vring0 and notifyid==2 for vring1.

2. When the firmware is loaded onto the R5 via the Linux remoteproc sysfs
interface, the kernel remoteproc implementation ignores the notifyid
values for the vrings, and reallocates them, changing the resource
table. On the Xilinx configuration I tested on, this results in vring0
being allocated notifyid 0, and vring1 being allocated notifyid 1.

3. When the remote processor is started, it parses the resource table. When
it gets to the virtio device, it calls handle_vdev_rsc(), which
in turn calls remoteproc_allocate_id() with the vdev's notifyid of
0. This successfully returns 0.  Then handle_vdev_rsc() goes through the
vrings. On vring0, it calls remoteproc_allocate_id(), with notifyid set to
0, because Linux changed vring0.notifyid from 1 to 0 in (2) above. This
results in remoteproc_allocate_id() returning RSC_NOTIFY_ID_ANY. This
causes handle_vdev_rsc() to return -RPROC_ERR_RSC_TAB_NP after commit
03c80a1, which causes the firmware startup to fail.

This appeared to work in previous versions, because
remoteproc_allocate_id() returning RSC_NOTIFY_ID_ANY was effectively
ignored, leaving the notifyid unchanged and allowing execution to
continue.

Set the value of notifyid for the virtio device (rvdev) to 31 to
avoid possible conflicts with the Linux imposed values.

Signed-off-by: Ed Mooring <ed.mooring@gmail.com>
2022-11-04 09:22:41 +01:00
Arnaud Pouliquen cd7f331045 remoteproc: Fix build warning in rproc_virtio_create_vdev function
The arm-none-eabi-gcc complains when VIRTIO_DEVICE_ONLY is enable

remoteproc_virtio.c:222:29: warning: variable 'vring_rsc'
set but not used [-Wunused-but-set-variable]
  222 |   struct fw_rsc_vdev_vring *vring_rsc;
      |                             ^~~~~~~~~

The vring_rsc variable should be declared and set only if
VIRTIO_DEVICE_ONLY is not enable.

Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
2022-10-20 15:25:16 +02:00
Arnaud Pouliquen 80555a314e test: Add test for the no-copy validation.
Add test to validate the no copy and the associated Tx buffer
recycler.

Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
2022-10-18 10:31:19 +02: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 753a20368b docs: add no-copy user API description
Add short description of the no-copy user interface.
Add some sub-chapters to increase the readability.

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
Tanmay Shah 988da0074d examples: apps: Update rpc_demo description
rpc_demo.c file creates firmware that runs on remote processor.
The current description implies that proxy service is implemented
on remote side which is not true. Fix description and explicitly
mention that proxy service is implemented on host side

Signed-off-by: Tanmay Shah <tanmay.shah@amd.com>
2022-10-18 10:08:53 +02:00
Arnaud Pouliquen 4f2d0c2106 README: Remove deprecated method to build open-amp lib for zephyr
The instructions to build open-amp for zephyr do not work.
Instead of trying to maintain a cross dependency between the zephyr
and the open-amp, just reference the zephyr project and documentation

Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
2022-10-18 10:06:47 +02:00
Ben Levinsky 4ab1ce6f95 app: rpc_demod: replace copy_from_shbuf with metal_io_block_read
After a toolchain upgrade, the OpenAMP rpc_demod application would
fail with a bus error on AArch64 Linux. This was because the call to
copy_from_shbuf() was now inlined by the optimizer and the compiler
generated code that used 8-byte copies ("ldp x10, x11 [x4, #16]" followed
by the corresponding store instruction). The bus error happened when
the address in x4 (the index) was 4-byte aligned, but not 8-byte aligned.

This would not be a problem with normal user-space memory, but the memory
used for the shared buffer between the remote processor and Linux is
mapped as device memory. On AArch64, device memory is strictly ordered
and the alignment and width of accesses must match.

Replace copy_from_shbuf() with a call to metal_io_block_read(), which
is intended to do this sort of thing, and also makes this a better
example of how to use OpenAMP.

Return error only on a negative return value from copy_from_shbuf in
rpmsg_endpoint_cb.

Signed-off-by: Ben Levinsky <ben.levinsky@xilinx.com>
2022-10-18 10:03:47 +02:00
Manikanta Sreeram 2e9f3a31cc Update LICENSE.md to cover CI test scripts
Add Apache and GPL licensing to cover CI test scripts in case they
are converted to SPDX:
  Apache-2.0
	scripts/ci/check_compliance.py
	scripts/do_checkpatch.sh
	scripts/gitlint/commit_rules.py
  GPL-2.0
	scripts/checkpatch.pl
	scripts/spelling.txt

Note: Neither Apache nor GPL are used by the libmetal library itself.

Signed-off-by: Manikanta Sreeram <manikanta.sreeram@xilinx.com>
2022-10-18 10:03:47 +02:00
Manikanta Sreeram 29fbf24ef9 apps: update linker scripts to SPDX license
Update linker scripts to SPDX based licensing.

Signed-off-by: Manikanta Sreeram <manikanta.sreeram@xilinx.com>
2022-10-18 10:03:47 +02:00
Ben Levinsky bb6d16837b apps: examples: load_fw: fix up for -werror
with werror flag compilation fails. update to build

Signed-off-by: Ben Levinsky <ben.levinsky@xilinx.com>
2022-10-18 10:03:47 +02:00
Sergei Korneichuk 17b2594ab6 app: rpc_demod: fix buffer overflow in handle_read
Fix the following error:
	Remote>Opened file 'remote.file' with fd = 8
	*** buffer overflow detected ***: rpc_demod-shared
1. Change RPC_BUFF_SIZE to accomodate the remote
2. Set size to the minimum of the request or the buffer size

Signed-off-by: Sergei Korneichuk <sergei.korneichuk@amd.com>
2022-10-18 10:03:47 +02:00
Guiding Li 2b6a38a9c6 openamp: should kick remote when use release_rx_buffer
There is missing virtqueue_kick when use hold_rx/release_rx

Signed-off-by: Guiding Li <liguiding1@xiaomi.com>
2022-10-14 10:44:36 +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 03c80a1341 handle_vdev_rsc must return error if notifyid cannot be assigned
Updated handle_vdev_rsc to return error if a unique id cannot be assigned
Signed-off-by: Tammy Leino <tammy_leino@mentor.com>
2022-10-04 10:17:54 +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
Sergei Korneichuk 54595de006 linux_rpc_demo: do not include rsc_table.h
No symbols from rsc_table.h are used in linux_rpc_demo.c and
the demo fails to build for Zynq, ZynqMP, and Versal systems.
Remove include rsc_table.h.

Signed-off-by: Sergei Korneichuk <sergei.korneichuk@amd.com>
2022-10-03 17:48:49 +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 a1c64fbc77 CI: Fix Zephyr build by updating Zephyr SDK version to 0.15.0
Update zephyr SDK to 0.15.0 to fix CI build issue.

Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
2022-09-09 18:21:27 +02:00
Guiding Li 1460543153 openamp: add available_idx to dump
Just update debug logs

Signed-off-by: Guiding Li <liguiding1@xiaomi.com>
2022-08-17 15:09:26 +02:00
Tammy Leino 8590171dc1 virtqueue_add_consumed_buffer input parameter fix
head_idx must be restricted to 0 ... vq_nentries - 1
Signed-off-by: Tammy Leino <tammy_leino@mentor.com>
2022-08-17 15:07:25 +02:00
Tammy Leino 6d9df8fbac Add missing macros for driver/device-only compilation
Added macros to omit code when compiling for device-only.
Signed-off-by: Tammy Leino <tammy_leino@mentor.com>
2022-08-17 15:05: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
Arnaud Pouliquen ef7a9d014d app: fix comment style and trailing whitespace
Fix some checkpatch complains

Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
2022-05-31 10:15:47 +02:00
Arnaud Pouliquen 923e060045 README: fix broken link
The link to meta-openamp is not valid, fix it.

Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
2022-05-24 17:36:57 -07:00
Arnaud Pouliquen 1671b6f80c README: Fix links with renamed branches
Some "master" branches have be renamed "main".

Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
2022-05-24 17:36:57 -07:00
Arnaud Pouliquen 9e30ada7e9 doc: clean-up data structures
Realign data structure description with the code.
The Description of the libmetal API is removed.

Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
2022-05-24 09:57:15 +02:00
Arnaud Pouliquen 4687a0ca53 apps: machines: clean-up the virtio device features definition
Provide a more explicit name and value for the virtio device
features.

Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
2022-05-24 09:56:25 +02:00
Ed Mooring 0107a28539 lib: Remove warnings from -Wcast-align
There were several places in the library where a char* was used to point
to a wider type (uint32_t or a struct). Casting the char* to the wider
type resulted in a compiler warning.

This commit changes some simple casts to (void *) to silence compiler
warnings. In rsc_table_parser.c, replace casts and pointer arithmetic
with explicit uses of fw_rsc_hdr.

Signed-off-by: Ed Mooring <ed.mooring@gmail.com>
2022-05-24 09:53:51 +02:00
Ed Mooring e5988ab1c0 CMake: Drop deprecated CMAKE_FORCE_*_COMPILER directives.
Building OpenAMP for standalone ARM R5, the following warning occurs:

CMake Deprecation Warning at
/usr/share/cmake-3.16/Modules/CMakeForceCompiler.cmake:75 (message):
  The CMAKE_FORCE_C_COMPILER macro is deprecated.  Instead just set
  CMAKE_C_COMPILER and allow CMake to identify the compiler.
Call Stack (most recent call first):
  cmake/platforms/cross_generic_gcc.cmake:5 (CMAKE_FORCE_C_COMPILER)
  /home/mooring/build-oa/toolchain.r5-oa.sa:18 (include)
  /usr/share/cmake-3.16/Modules/CMakeDetermineSystem.cmake:93 (include)
  CMakeLists.txt:19 (project)

Follow the suggestions in the above error message, and add
CMAKE_TRY_COMPILE_TARGET_TYPE = STATIC LIBRARY, which makes try_compile()
not try to link the cross-compiled binary. This is necessary because the
arm-none-eabi toolchain libgcc doesn't have an implementation of _exit(),
leaving that to the BSP. This results in a CMake error because it can't
build the test executable.

Signed-off-by: Ed Mooring <ed.mooring@gmail.com>
2022-05-16 09:55:19 +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
Ed Mooring 8c93bffd9f apps: Remove leading space in CMake linker directive variables.
While building the Xilinx R5 demo apps, the following error message
occurs:

CMake Error at apps/examples/echo/CMakeLists.txt:38 (add_executable):
Target "rpmsg-echo.out" links to item " -Wl,--defsym,_rsc_table=0x3ed20000
-T"/OpenAMP-Project/gh3/open-amp/apps/system/generic/machine/zynqmp_r5/
linker_remote.ld""
which has leading or trailing whitespace.  This is now an error according
to policy CMP0004.

Remove the leading space.

Signed-off-by: Ed Mooring <ed.mooring@gmail.com>
2022-05-06 11:14:51 +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
Arnaud Pouliquen 10dcceca63 release: open-amp 2022.04.0
Set library version to 1.2.0

Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
v2022.04.0
2022-04-29 10:14:15 +02:00