Commit Graph

476 Commits

Author SHA1 Message Date
Nicolas Pitre eee5b8e563 ring_buffer: make finish methods final
Make it possible to "finish" with fewer bytes than what was "claimed".

This was possible before on the get side, but the put side was
cummulative wrt finish. The revamp made it cummulative on both sides.
Turns out that existing users rely on the opposite behavior which is
more logical and useful. So make both sides that way.

Adjust documentation, test case and users accordingly.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2022-02-28 10:52:41 +01:00
Ederson de Souza 6babbd32e1 boards/riscv: Add qemu_riscv32_smp and qemu_riscv64_smp
Based on qemu_riscv32 and qemu_riscv64, add minimal SMP support
using the "virt" machine.

Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
2022-02-25 19:13:50 -05:00
Nicolas Pitre f4ac771f83 tests: ringbuffer: test 32-bit wrap-around conditions
The core ring buffer code presumes a 32-bit wrap-around behavior when its
head and tail indices cross the maximum value range. Make sure this is
covered by the test suite, for both 32- and 64-bit targets.

While at it, reduce stack requirement of the modified test.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2022-02-24 14:49:00 -08:00
Nicolas Pitre 099850e916 ring_buffer: the great simplification
This code is rather hairy. When I look at it I don't like the way it
stares back at me.

First, the rewind business looks fishy. It has to die.

And we don't have to rely on modulus either. Not even for non-power-of-2
buffers. Let's kill that distinction too and make all sizes always
"high performance".

The code is now entirely relying only on simple ALU operations (add,
sub and compare).

The key assumption: 32-bit values do wrap around after max range has
been reached. No saturation. All architectures supported by Zephyr
do that.

Some stats:

lib/os/ring_buffer.c: 62 insertions(+), 124 deletions(-)

ring_buffer.c.obj       before   after    diff
----------------------------------------------
frdm_k64f                 1224    1136     -88
m2gl025_miv               2485    2079    -406
mps2_an385                1228    1132     -96
mps2_an521                1228    1132     -96
native_posix              1546    1496     -50
native_posix_64           1598    1595      -3
nsim_hs_mpuv6             1252    1192     -60
nsim_hs_smp               1252    1192     -60
nsim_sem                  1252    1192     -60
qemu_arc_em               1324    1192    -132
qemu_arc_hs6x             1824    1620    -204
qemu_arc_hs               1252    1192     -60
qemu_cortex_a53_smp       2154    1888    -266
qemu_cortex_a53           2154    1888    -266
qemu_cortex_a9            1938    1792    -146

Before (qemu_cortex_a53):
START - test_ringbuffer_performance
1 byte put-get, avg cycles: 52
4 byte put-get, avg cycles: 47
1 byte put claim-finish, avg cycles: 39
5 byte put claim-finish, avg cycles: 41
5 byte get claim-finish, avg cycles: 52
 PASS - test_ringbuffer_performance in 0.8 seconds

After (qemu_cortex_a53):
START - test_ringbuffer_performance
1 byte put-get, avg cycles: 34
4 byte put-get, avg cycles: 41
1 byte put claim-finish, avg cycles: 27
5 byte put claim-finish, avg cycles: 29
5 byte get claim-finish, avg cycles: 29
 PASS - test_ringbuffer_performance in 0.4 seconds

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2022-02-24 14:49:00 -08:00
Nicolas Pitre c2543320d8 ring_buffer: rationalize the item-based put and get methods
Conceptually, ring_buf_item_put() and ring_buf_item_get() are specialized
versions of ring_buf_put() and ring_buf_get(). Make it so to rationalize
the code to open the way for more optimizations.

This means we need specialized wrappers on top of ring_buf_init()
accordingly, given that the core machinery is now common and byte based.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2022-02-24 14:49:00 -08:00
Nicolas Pitre f821a596f0 tests: ringbuffer: delete out-of-date comment
Commit 1e46bb3bb5 ("lib: os: ring_buffer: Allow using full buffer
capacity") changed the capacity test condition but left the comment
relating to the previous test condition in place.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2022-02-24 14:49:00 -08:00
Nicolas Pitre 4bf242725f tests: ringbuffer: remove bogus test
The removed test was bogus and pointless.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2022-02-24 14:49:00 -08:00
Bartosz Golaszewski 0f09360456 lvgl: change the prefix of Zephyr-specific LVGL config options
We're now using the Kconfig copied from the upstream lvgl repository. It
uses the LV_ prefix for all options while we're using LVGL_ for
Zephyr-specific ones. Make the latter consistent with upstream but also
make sure they're distinct from lvgl's by using LV_Z_ as the prefix.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@huawei.com>
2022-02-24 11:51:33 +01:00
Bartosz Golaszewski 6c190292c0 lvgl: move the lvgl glue out of the zephyr tree
Start using the upstream Kconfig from LVGL and move the glue code out
of the zephyr tree and put it under lvgl/zephyr/ in modules.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@huawei.com>
2022-02-24 11:51:33 +01:00
Bartosz Golaszewski 1244a89a21 lvgl: bump version to v8.1.0
This updates the lvgl in-tree glue code to work with version v8.1.0 and
bumps the west manifest accordingly.

The following are the most significant changes:
- The logging callback has changes in lvgl and no longer provides the
  caller with an integer log level code. We now need to parse the log
  string's prefix to determine the level.
- Several Kconfig options (mostly for default values of various settings)
  have been removed because these values are no longer configurable in
  lvgl.
- The library no longer performs a deep copy of the display and input
  device driver structs, so these must no longer be allocated on the
  stack in the init func.

Other than that it's mostly about renaming of various structures and
functions and adjusting the calls if function's signatures have changed.

This patch allows all in-tree users to work correctly but it's likely
it doesn't support all new widgets and layouts added in lvgl v8. These
however can be added gradually once this is upstream.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@huawei.com>
2022-02-24 11:51:33 +01:00
Bartosz Golaszewski 595131c2d0 lvgl: kill LVGL_MEM_POOL_HEAP_KERNEL and LVGL_MEM_POOL_KERNEL
Current lvgl code allows to use the kernel heap for dynamic memory
allocation. The k_heap API doesn't however provide k_realloc() which
will be needed in order to update lvgl to v8. Nico suggested there's
no good reason for lvgl to use k_heap and it should stick to either
the libc's allocator or depend on its own private sys_heap.

The alternative would be to extend the k_heap API to provide k_realloc()
but this may be tricky for several reasons and for now there would
be a single user anyway.

This removes the choice of using k_heap for lvgl and renames the user
pool to SYS_HEAP in Kconfig and makes it the default option.

The prj.conf for the lvgl sample is modifed to specify the number of
memory pool blocks instead of the total size as the default block
size is 2048 and it results in the same size of memory.

Suggested-by: Nicolas Pitre <npitre@baylibre.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@huawei.com>
2022-02-24 11:51:33 +01:00
Bartosz Golaszewski 98665755ea tests: lvgl: drop duplicate include
lvgl.h is already included in the img.h header. Drop the duplicate.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@huawei.com>
2022-02-24 11:51:33 +01:00
Bradley Bolen c0dd594d4d arch: arm: aarch32: Change CPU_CORTEX_R kconfig option
Change the CPU_CORTEX_R kconfig option to CPU_AARCH32_CORTEX_R to
distinguish the armv7 version from the armv8 version of Cortex-R.

Signed-off-by: Bradley Bolen <bbolen@lexmark.com>
2022-02-23 08:14:15 -06:00
Carles Cufi e83a13aabf kconfig: Rename the TEST_EXTRA stack size option to align with the rest
All stack sizes should end with STACK_SIZE.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-02-22 08:23:05 -05:00
Carles Cufi 4b8f1c04ab kconfig: Rename the ZTEST stack size option to align with the rest
All stack sizes should end with STACK_SIZE.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-02-22 08:23:05 -05:00
Ederson de Souza d1cdeab851 tests: Define mbox device
XCC (based on GCC 4.2) will emit undefined references to symbols that
are not used. Newer versions of GCC simply don't emit them, but for XCC,
linker will complain about those undefined references.

This patch adds a dummy definition of the mbox devices used on tests, so
that the linker is happy.

Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
2022-02-21 22:17:27 -05:00
Carlo Caione 18ffcdcf74 linker: Introduce zephyr,memory-region compatible
Introduce a new "zephyr,memory-region" compatible to be used when a new
memory region must be created in the linker script from the devicetree
nodes using the compatible.

Remove also the LINKER_DT_REGION_FROM_NODE macro and add a new
LINKER_DT_REGIONS macro to cycle through all the compatible regions.

In the same PR modify the DTS files and the linker scripts.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-02-21 22:02:04 -05:00
Krzysztof Chruscinski 9ea5c1e510 tests: lib: mpsc_pbuf: Add test for utilization api
Add test for mpsc_pbuf_get_utilization and
mpsc_pbuf_get_max_utilization.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-02-21 20:41:17 -05:00
Anas Nashif 73d8a8d8ef tests: ringbuffer: increase timeout
Increae timeout from 90 to 150 to make it pass on more slow boards.

Fixes #42756

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-02-15 13:26:08 -05:00
Erwan Gouriou 2f7b5ad8ea tests/lib: devicetree: Remove references to deprecated macros
These deprecated macros are now removed.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2022-02-05 06:26:25 -05:00
Maciej Perkowski 0c830822ae tests: lib: ring_buffer: Increase timeot
The tests from tests/lib/ringbuffer fails on all nrf platforms due
to a timeout. Increasing the timeout value solves the issue.

Signed-off-by: Maciej Perkowski <Maciej.Perkowski@nordicsemi.no>
2022-01-26 14:39:12 -05:00
Andy Ross 82bc7d0733 tests/lib/ringbuffer: Run with one CPU
The stress ('scuse me, "zstress") cases here are all written to
exercise reader/writer threads at different priority combinations.
That's defeated if the threads are allowed to run on different CPUs
(because being "low" priority doesn't matter if you have a spare CPU
to run on).

There is also extensive use of stack buffers to pass data through the
ring buffer zero copy implementation, which runs afoul of the
KERNEL_COHERENCE rules on intel_adsp platforms (where stack memory is
incoherent between CPUs and can't be shared like that).

Fix both issues by just setting CONFIG_MP_NUM_CPUS=1

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2022-01-24 12:23:46 -05:00
Gerard Marull-Paretas b768fb6f94 tests: lib: devicetree: drop get_dev_data/get_dev_config usage
Replace all get_dev_data()/get_dev_config() accessor utilities with
dev->data and dev->config.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-01-19 18:16:02 +01:00
Daniel Leung 8f7f62869a tests: remove @return doc for void functions
For functions returning nothing, there is no need to document
with @return, as Doxgen complains about "documented empty
return type of ...".

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-01-12 16:02:16 -05:00
Anas Nashif 5e05393afa tests: ztress: fix dependency on SMP
Use CONFIG_MP_NUM_CPUS=1 with ztress and do not disable SMP completely.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-01-12 14:13:21 -05:00
Krzysztof Chruscinski 902cff3d62 tests: lib: ringbuffer: Update test to use ztress
Updated test to use stress testing framework instead of implementing
own framework.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-01-11 18:19:44 -05:00
Daniel Leung 7d561a3ea5 tests: lib/mem_blocks: add test for heap listeners
This adds simple tests to make sure the heap listener interface
works with memory blocks allocator.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-01-11 16:10:53 -05:00
Daniel Leung 7f06fb4129 tests: lib/mem_blocks: add tests for multi mem_blocks allocator
This adds a few tests to make sure the multi memory blocks
allocator functions work correctly.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-01-11 16:10:53 -05:00
Daniel Leung 50f8f3caea tests: add new tests for the new memory blocks allocator
This adds some new tests to make sure the new memory blocks
allocator work correctly.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-01-11 16:10:53 -05:00
Daniel Leung be9779753f tests: lib/heap: add test for heap listeners
This adds test to make heap listeners are working correctly.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-01-10 10:28:04 -05:00
Daniel Leung ae415272c1 sys: heap_listener: extend to cover more events
This extends the heap_listener to cover more events,
specifically, allocation, free and realloc.

Note that typedef are used so the callback can be
documented.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-01-10 10:28:04 -05:00
Daniel Leung 39d17a180a sys: heap_listener: resize_cb to also take heap ID
Add a parameter to the resize callback to also take the heap ID.
This allows a single callback to be used for multiple heaps if
so desired.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-01-10 10:28:04 -05:00
Gerard Marull-Paretas 32bea9a7fb tests: lib: devicetree: use vnd,gpio-device
The vnd,gpio-device compatible is now used by the test GPIO driver
(CONFIG_GPIO_TEST) introduced in #41387. This means that we can't define
new devices with this compatible when CONFIG_GPIO=y.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2022-01-04 14:44:07 -05:00
Andrzej Głąbek 7fa4a33ea1 tests/lib/devicetree/devices: Exclude thingy52_nrf52832 platform
This test cannot be built for thingy52_nrf52832, as this board uses
regulator devices that need the SX1509B GPIO expander driver that
in turn depends on I2C which needs to be disabled in this test.
Commit b579c12714 addressed a similar
problem for hsdk platforms by excluding those. Use the same solution.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2021-12-23 12:51:01 +01:00
Damian Krolik 3aedda9852 lib: os: add heap event listener
* add generic heap event listener module that can be used
  for notifying an application of heap-related events
* use the listener module in newlib libc hooks
* add a unit test

Signed-off-by: Damian Krolik <damian.krolik@nordicsemi.no>
2021-12-18 07:49:15 -05:00
Gerard Marull-Paretas 0c0ad3d332 tests: lib: devicetree: api: test DT_INST_PARENT
Check that DT_INST_PARENT behavior is correct. Re-uses existing overlay
definitions (child of TEST_SPI_BUS_0) to test the behavior.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-12-16 11:10:01 -06:00
Carles Cufi 0b96dd419d tests: lib: mpsc_pbuf: Fix address-of-packed-mem warning
The warning below appears once -Waddress-of-packed-mem is enabled:

/__w/zephyr/zephyr/tests/lib/mpsc_pbuf/src/main.c: In function
'item_put_data_overwrite':
/__w/zephyr/zephyr/tests/lib/mpsc_pbuf/src/main.c:497:3: error:
converting a packed 'struct test_data_ext' pointer (alignment 1) to a
'uint32_t' {aka 'const unsigned int'} pointer (alignment 4) may result
in an unaligned pointer value [-Werror=address-of-packed-member]
  497 |   mpsc_pbuf_put_data(&buffer, (uint32_t *)&item, len);

To avoid the warning, as well as several others related to the same
problem, use an intermediate void * variable.

More info in #16587.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2021-12-10 14:08:59 +01:00
Johann Fischer 307c13b218 drivers: display: remove unused Kconfig options
remove unused options SDL_DISPLAY_* and DUMMY_DISPLAY_*.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2021-12-10 12:47:30 +01:00
Johann Fischer 2d175d14f3 drivers: display_dummy: rework to obtain configuration from devicetree
Add bindings for dummy display controller.
Rework dummy display controller driver to obtain
configuration from devicetree. Remove unnecessary casts,
add multi-instance support.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2021-12-10 12:47:30 +01:00
Jordan Yates 749b112fa8 tests: devicetree: test LINKER_DT_NODE_REGION_NAME
Add a new application for testing non-core devicetree functionality.
Add tests for the default and fallback case of
`LINKER_DT_NODE_REGION_NAME`.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2021-12-09 16:23:03 +01:00
Ramiro Merello 7dce757233 tests: lib: json: Added tests array decoding, encoding and int limits
Added tests for:
- json_arr_parse
- json_arr_encode_buf
- integer limit testings

Signed-off-by: Ramiro Merello <rmerello@itba.edu.ar>
2021-12-01 12:21:19 -05:00
Anas Nashif d4962db828 tests: m2gl025_miv: exclude slow platform from some tests
This platform is slow on some tests and times out on non-hardware
related tests, so exclude it or increase timeout for some of the tests
to avoid false negatives in the test results due to timeouts.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-11-29 19:39:38 -05:00
Krzysztof Chruscinski 8171417f77 tests: lib: cbprintf_package: Extend test
Extend test to validate CBPRINTF_MUST_RUNTIME_PACKAGE_CONST_CHAR flag.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2021-11-29 21:13:56 +01:00
Krzysztof Chruscinski 7831bfcce8 lib: os: cbprintf: Add flags to CBPRINTF_MUST_RUNTIME_PACKAGE
Add flags to macro which checks if string must be packaged
using runtime approach.

Added flag CBPRINTF_MUST_RUNTIME_PACKAGE_CONST_CHAR. When flag
is set then const char pointers are considered as pointers to
fixed strings and do not require runtime packaging.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2021-11-29 21:13:56 +01:00
Ryan McClelland a000acca5f tests: fix double promotion warning
With -Wdouble-promotion added to the warning base, fix warnings given
by the compiler.

Signed-off-by: Ryan McClelland <ryanmcclelland@fb.com>
2021-11-24 17:14:25 -05:00
Jordan Yates eec7c5389b tests: devicetree: test supported devices API
Add tests for the supported devices API.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2021-11-23 12:17:14 +01:00
Gerard Marull-Paretas 1832d68e01 tests: lib: devicetree: add tests for DT_INST_ENUM_IDX(_OR)
Add tests for the instance based enum macros DT_INST_ENUM_IDX and
DT_INST_ENUM_IDX_OR.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-11-18 19:12:07 -05:00
Chen Peng1 f4cf484ac6 tests: heap: validate sys_heap_runtime_stats_get API
Add CONFIG_SYS_HEAP_RUNTIME_STATS in existing heap tests
to enable validation for sys_heap_runtime_stats_get API.

Signed-off-by: Chen Peng1 <peng1.chen@intel.com>
2021-11-11 16:21:43 -05:00
Neil Armstrong 2825481747 devicetree: add tests for devicetree ranges API macros
Test cases for new APIs.

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
2021-11-10 08:23:00 -05:00
Christopher Friedt 60cc117c9c tests: libc: minimal: Add tests for qsort()
This change adds tests for qsort().

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
2021-11-10 07:00:36 -05:00