From a2b48ce8c36e4dc47c3c6d68a338a42e9a675590 Mon Sep 17 00:00:00 2001 From: Iuliana Prodan Date: Wed, 12 Jul 2023 14:40:31 +0300 Subject: [PATCH] remoteproc: do cache invalidation before reading rsc_table status 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 --- cmake/options.cmake | 6 ++++++ lib/remoteproc/remoteproc_virtio.c | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/cmake/options.cmake b/cmake/options.cmake index f36ea1b5f..4f895893f 100644 --- a/cmake/options.cmake +++ b/cmake/options.cmake @@ -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") diff --git a/lib/remoteproc/remoteproc_virtio.c b/lib/remoteproc/remoteproc_virtio.c index 169e5b5fa..47301167c 100644 --- a/lib/remoteproc/remoteproc_virtio.c +++ b/lib/remoteproc/remoteproc_virtio.c @@ -15,6 +15,7 @@ #include #include #include +#include static void rproc_virtio_virtqueue_notify(struct virtqueue *vq) { @@ -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;