mirror of
https://github.com/OpenAMP/open-amp.git
synced 2026-09-26 12:28:32 +08:00
remoteproc: do cache invalidation before reading rsc_table info
Do a cache invalidation before reading the resource table's info 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>
This commit is contained in:
committed by
Arnaud Pouliquen
parent
7f906105a9
commit
a2456e61ee
@@ -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")
|
||||
|
||||
|
||||
@@ -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" {
|
||||
@@ -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, s) metal_cache_flush(x, s)
|
||||
#define RSC_TABLE_INVALIDATE(x, s) metal_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 */
|
||||
|
||||
/* define vdev notification function user should implement */
|
||||
typedef int (*rpvdev_notify_func)(void *priv, uint32_t id);
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@ 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, sizeof(struct fw_rsc_vdev));
|
||||
status = metal_io_read8(io,
|
||||
metal_io_virt_to_offset(io, &vdev_rsc->status));
|
||||
return status;
|
||||
@@ -59,6 +60,7 @@ static void rproc_virtio_set_status(struct virtio_device *vdev,
|
||||
metal_io_write8(io,
|
||||
metal_io_virt_to_offset(io, &vdev_rsc->status),
|
||||
status);
|
||||
RSC_TABLE_FLUSH(vdev_rsc, sizeof(struct fw_rsc_vdev));
|
||||
rpvdev->notify(rpvdev->priv, vdev->notifyid);
|
||||
}
|
||||
#endif
|
||||
@@ -73,6 +75,7 @@ static uint32_t rproc_virtio_get_dfeatures(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, sizeof(struct fw_rsc_vdev));
|
||||
features = metal_io_read32(io,
|
||||
metal_io_virt_to_offset(io, &vdev_rsc->dfeatures));
|
||||
|
||||
@@ -90,6 +93,7 @@ static uint32_t rproc_virtio_get_features(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, sizeof(struct fw_rsc_vdev));
|
||||
gfeatures = metal_io_read32(io,
|
||||
metal_io_virt_to_offset(io, &vdev_rsc->gfeatures));
|
||||
dfeatures = rproc_virtio_get_dfeatures(vdev);
|
||||
@@ -111,6 +115,7 @@ static void rproc_virtio_set_features(struct virtio_device *vdev,
|
||||
metal_io_write32(io,
|
||||
metal_io_virt_to_offset(io, &vdev_rsc->gfeatures),
|
||||
features);
|
||||
RSC_TABLE_FLUSH(vdev_rsc, sizeof(struct fw_rsc_vdev));
|
||||
rpvdev->notify(rpvdev->priv, vdev->notifyid);
|
||||
}
|
||||
|
||||
@@ -138,10 +143,12 @@ static void rproc_virtio_read_config(struct virtio_device *vdev,
|
||||
config = (char *)(&vdev_rsc->vring[vdev->vrings_num]);
|
||||
io = rpvdev->vdev_rsc_io;
|
||||
|
||||
if (offset + length <= vdev_rsc->config_len)
|
||||
if (offset + length <= vdev_rsc->config_len) {
|
||||
RSC_TABLE_INVALIDATE(config + offset, length);
|
||||
metal_io_block_read(io,
|
||||
metal_io_virt_to_offset(io, config + offset),
|
||||
dst, length);
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef VIRTIO_DEVICE_ONLY
|
||||
@@ -162,6 +169,7 @@ static void rproc_virtio_write_config(struct virtio_device *vdev,
|
||||
metal_io_block_write(io,
|
||||
metal_io_virt_to_offset(io, config + offset),
|
||||
src, length);
|
||||
RSC_TABLE_FLUSH(config + offset, length);
|
||||
rpvdev->notify(rpvdev->priv, vdev->notifyid);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user