From 0bb25d2e17536a8dfb5cf75fd9a4e75aaa53360a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Chru=C5=9Bci=C5=84ski?= Date: Thu, 27 Jun 2024 06:20:07 +0200 Subject: [PATCH] lib: os: spsc_pbuf: Clarify using cache management in the module MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Packet buffer can be used for sharing data between cores. In that case when any core has data cache then data cache handling must be enabled in the module. However, it shall never be enabled when the packet buffer is used on a single core. Adding that information to the documentation. Signed-off-by: Krzysztof Chruściński --- include/zephyr/sys/spsc_pbuf.h | 6 +++++- lib/os/Kconfig | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/include/zephyr/sys/spsc_pbuf.h b/include/zephyr/sys/spsc_pbuf.h index 0e7f018fa63..a65d15cc5c4 100644 --- a/include/zephyr/sys/spsc_pbuf.h +++ b/include/zephyr/sys/spsc_pbuf.h @@ -25,7 +25,11 @@ extern "C" { * @{ */ -/** @brief Flag indicating that cache shall be handled. */ +/** @brief Flag indicating that cache shall be handled. + * + * It shall be used only when packet buffer is shared between two cores as on a single + * core cache shall not be handled manually because it results in data corruption. + */ #define SPSC_PBUF_CACHE BIT(0) /** @brief Size of the field which stores maximum utilization. */ diff --git a/lib/os/Kconfig b/lib/os/Kconfig index fa52338e525..9ce3be2a66e 100644 --- a/lib/os/Kconfig +++ b/lib/os/Kconfig @@ -60,7 +60,9 @@ config SPSC_PBUF_CACHE_ALWAYS bool "Always handle cache" help Handle cache writeback and invalidation for all instances. Option used - to avoid runtime check and thus reduce memory footprint. + to avoid runtime check and thus reduce memory footprint. Beware! It shall + be used only if all packet buffer instances are used for data sharing + between cores. config SPSC_PBUF_CACHE_NEVER bool "Never handle cache"