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 12, 2023
1 parent 7f90610 commit 125b19d
Show file tree
Hide file tree
Showing 2 changed files with 12 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
6 changes: 6 additions & 0 deletions lib/remoteproc/remoteproc_virtio.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <metal/cpu.h>
#include <metal/utilities.h>
#include <metal/alloc.h>
#include <metal/cache.h>

static void rproc_virtio_virtqueue_notify(struct virtqueue *vq)
{
Expand All @@ -40,6 +41,11 @@ 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;

#ifdef VIRTIO_CACHED_RSC_TABLE
metal_cache_invalidate(vdev_rsc, sizeof(vdev_rsc));
#endif /* VIRTIO_CACHED_RSC_TABLE */

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

0 comments on commit 125b19d

Please sign in to comment.