Skip to content

Commit

Permalink
remoteproc: do cache invalidation before reading rsc_table status
Browse files Browse the repository at this point in the history
Do a cache invalidation before reading the resource table's status
since this ca be in a cacheable region.

Make this optional, based on VIRTIO_CACHED_RSC_TABLE.

Signed-off-by: Iuliana Prodan <iuliana.prodan@nxp.com>
  • Loading branch information
iuliana-prodan committed Jul 13, 2023
1 parent 7f90610 commit 364ebc5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cmake/options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ if (WITH_DCACHE_BUFFERS)
add_definitions(-DVIRTIO_CACHED_BUFFERS)
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)
endif (WITH_DCACHE_RSC_TABLE)

# Set the complication flags
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra")

Expand Down
10 changes: 10 additions & 0 deletions lib/include/openamp/remoteproc_virtio.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <metal/io.h>
#include <metal/list.h>
#include <openamp/virtio.h>
#include <metal/cache.h>

#if defined __cplusplus
extern "C" {
Expand All @@ -23,6 +24,15 @@ extern "C" {
/* maximum number of vring descriptors for a vdev limited by 16-bit data type */
#define RPROC_MAX_VRING_DESC USHRT_MAX

/* cache invalidation helpers for resource table */
#ifdef VIRTIO_CACHED_RSC_TABLE
#define RSC_TABLE_FLUSH(x) metal_cache_flush(&x, sizeof(x))
#define RSC_TABLE_INVALIDATE(x) metal_cache_invalidate(&x, sizeof(x))
#else
#define RSC_TABLE_FLUSH(x) do { } while (0)
#define RSC_TABLE_INVALIDATE(x) do { } while (0)
#endif /* VIRTIO_CACHED_RSC_TABLE */

/* define vdev notification function user should implement */
typedef int (*rpvdev_notify_func)(void *priv, uint32_t id);

Expand Down
3 changes: 3 additions & 0 deletions lib/remoteproc/remoteproc_virtio.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ static unsigned char rproc_virtio_get_status(struct virtio_device *vdev)
rpvdev = metal_container_of(vdev, struct remoteproc_virtio, vdev);
vdev_rsc = rpvdev->vdev_rsc;
io = rpvdev->vdev_rsc_io;

RSC_TABLE_INVALIDATE(vdev_rsc);

status = metal_io_read8(io,
metal_io_virt_to_offset(io, &vdev_rsc->status));
return status;
Expand Down

0 comments on commit 364ebc5

Please sign in to comment.