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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
Updated test to use stress testing framework instead of implementing
own framework.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
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>
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>
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>
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>
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>
* 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>
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>
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>
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>
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>
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>
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>