From 122570d6747f1e628d4d44e47aa859a5699e96d7 Mon Sep 17 00:00:00 2001 From: Iuliana Prodan Date: Tue, 18 Jul 2023 15:19:06 +0300 Subject: [PATCH] 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 --- README.md | 3 +++ cmake/options.cmake | 9 +++++++++ lib/include/openamp/remoteproc_virtio.h | 5 ++++- lib/include/openamp/rpmsg_virtio.h | 5 ++++- lib/include/openamp/virtqueue.h | 5 ++++- 5 files changed, 24 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 35ce24308..74b9b7157 100644 --- a/README.md +++ b/README.md @@ -96,6 +96,9 @@ library for it project: enabled on buffers. * **WITH_DCACHE_RSC_TABLE** (default OFF): Build with data cache operations enabled on resource table. +* **WITH_DCACHE** (default OFF): Build with all cache operations + enabled. When set to ON, cache operations for vrings, buffers and resource + table are enabled. * **RPMSG_BUFFER_SIZE** (default 512): adjust the size of the RPMsg buffers. The default value of the RPMsg size is compatible with the Linux Kernel hard coded value. If you AMP configuration is Linux kernel host/ OpenAMP remote, diff --git a/cmake/options.cmake b/cmake/options.cmake index 25e5c8401..723391ee7 100644 --- a/cmake/options.cmake +++ b/cmake/options.cmake @@ -78,22 +78,31 @@ if (NOT WITH_VIRTIO_DEVICE AND NOT WITH_VIRTIO_SLAVE) add_definitions(-DVIRTIO_DRIVER_ONLY) endif (NOT WITH_VIRTIO_DEVICE AND NOT WITH_VIRTIO_SLAVE) +option (WITH_DCACHE "Build with all cache operations enabled" OFF) + +if (WITH_DCACHE) + add_definitions(-DVIRTIO_USE_DCACHE) +endif (WITH_DCACHE) + option (WITH_DCACHE_VRINGS "Build with vrings cache operations enabled" OFF) if (WITH_DCACHE_VRINGS) add_definitions(-DVIRTIO_CACHED_VRINGS) + message(DEPRECATION "deprecated cmake option replaced by WITH_DCACHE" ...) endif (WITH_DCACHE_VRINGS) option (WITH_DCACHE_BUFFERS "Build with buffers cache operations enabled" OFF) if (WITH_DCACHE_BUFFERS) add_definitions(-DVIRTIO_CACHED_BUFFERS) + message(DEPRECATION "deprecated cmake option replaced by WITH_DCACHE" ...) endif (WITH_DCACHE_BUFFERS) option (WITH_DCACHE_RSC_TABLE "Build with resource table cache operations enabled" OFF) if (WITH_DCACHE_RSC_TABLE) add_definitions(-DVIRTIO_CACHED_RSC_TABLE) + message(DEPRECATION "deprecated cmake option replaced by WITH_DCACHE" ...) endif (WITH_DCACHE_RSC_TABLE) # Set the complication flags diff --git a/lib/include/openamp/remoteproc_virtio.h b/lib/include/openamp/remoteproc_virtio.h index 770b428cc..7cef8fc1d 100644 --- a/lib/include/openamp/remoteproc_virtio.h +++ b/lib/include/openamp/remoteproc_virtio.h @@ -26,12 +26,15 @@ extern "C" { /* cache invalidation helpers for resource table */ #ifdef VIRTIO_CACHED_RSC_TABLE +#warning "VIRTIO_CACHED_RSC_TABLE is deprecated, please use VIRTIO_USE_CACHE" +#endif +#if defined(VIRTIO_CACHED_RSC_TABLE) || defined(VIRTIO_USE_CACHE) #define RSC_TABLE_FLUSH(x, s) CACHE_FLUSH(x, s) #define RSC_TABLE_INVALIDATE(x, s) CACHE_INVALIDATE(x, s) #else #define RSC_TABLE_FLUSH(x, s) do { } while (0) #define RSC_TABLE_INVALIDATE(x, s) do { } while (0) -#endif /* VIRTIO_CACHED_RSC_TABLE */ +#endif /* VIRTIO_CACHED_RSC_TABLE || VIRTIO_USE_CACHE */ /* define vdev notification function user should implement */ typedef int (*rpvdev_notify_func)(void *priv, uint32_t id); diff --git a/lib/include/openamp/rpmsg_virtio.h b/lib/include/openamp/rpmsg_virtio.h index 1a6095c53..9ad0eb1d3 100644 --- a/lib/include/openamp/rpmsg_virtio.h +++ b/lib/include/openamp/rpmsg_virtio.h @@ -31,12 +31,15 @@ extern "C" { #define VIRTIO_RPMSG_F_NS 0 /* RP supports name service notifications */ #ifdef VIRTIO_CACHED_BUFFERS +#warning "VIRTIO_CACHED_BUFFERS is deprecated, please use VIRTIO_USE_CACHE" +#endif +#if defined(VIRTIO_CACHED_BUFFERS) || defined(VIRTIO_USE_CACHE) #define BUFFER_FLUSH(x, s) CACHE_FLUSH(x, s) #define BUFFER_INVALIDATE(x, s) CACHE_INVALIDATE(x, s) #else #define BUFFER_FLUSH(x, s) do { } while (0) #define BUFFER_INVALIDATE(x, s) do { } while (0) -#endif /* VIRTIO_CACHED_BUFFERS */ +#endif /* VIRTIO_CACHED_BUFFERS || VIRTIO_USE_CACHE */ /** * struct rpmsg_virtio_shm_pool - shared memory pool used for rpmsg buffers diff --git a/lib/include/openamp/virtqueue.h b/lib/include/openamp/virtqueue.h index 219b909de..ca3ac9545 100644 --- a/lib/include/openamp/virtqueue.h +++ b/lib/include/openamp/virtqueue.h @@ -53,12 +53,15 @@ extern "C" { #define CACHE_INVALIDATE(x, s) metal_cache_invalidate(x, s) #ifdef VIRTIO_CACHED_VRINGS +#warning "VIRTIO_CACHED_VRINGS is deprecated, please use VIRTIO_USE_CACHE" +#endif +#if defined(VIRTIO_CACHED_VRINGS) || defined(VIRTIO_USE_CACHE) #define VRING_FLUSH(x, s) CACHE_FLUSH(x, s) #define VRING_INVALIDATE(x, s) CACHE_INVALIDATE(x, s) #else #define VRING_FLUSH(x, s) do { } while (0) #define VRING_INVALIDATE(x, s) do { } while (0) -#endif /* VIRTIO_CACHED_VRINGS */ +#endif /* VIRTIO_CACHED_VRINGS || VIRTIO_USE_CACHE */ struct virtqueue_buf { void *buf;