// SPDX-License-Identifier: GPL-2.0+
/*
- * Copyright (c) 2018 Linaro Limited
+ * Copyright (c) 2018-2020 Linaro Limited
*/
#include <common.h>
+#include <cpu_func.h>
#include <dm.h>
#include <dm/device_compat.h>
#include <log.h>
}
}
+static void flush_shm_dcache(struct udevice *dev, struct optee_msg_arg *arg)
+{
+ size_t sz = OPTEE_MSG_GET_ARG_SIZE(arg->num_params);
+
+ flush_dcache_range(rounddown((ulong)arg, CONFIG_SYS_CACHELINE_SIZE),
+ roundup((ulong)arg + sz, CONFIG_SYS_CACHELINE_SIZE));
+
+ tee_flush_all_shm_dcache(dev);
+}
+
static u32 do_call_with_arg(struct udevice *dev, struct optee_msg_arg *arg)
{
struct optee_pdata *pdata = dev_get_plat(dev);
while (true) {
struct arm_smccc_res res;
+ /* If cache are off from U-Boot, sync the cache shared with OP-TEE */
+ if (!dcache_status())
+ flush_shm_dcache(dev, arg);
+
pdata->invoke_fn(param.a0, param.a1, param.a2, param.a3,
param.a4, param.a5, param.a6, param.a7, &res);
+ /* If cache are off from U-Boot, sync the cache shared with OP-TEE */
+ if (!dcache_status())
+ flush_shm_dcache(dev, arg);
+
free(page_list);
page_list = NULL;
// SPDX-License-Identifier: GPL-2.0+
/*
- * Copyright (c) 2018 Linaro Limited
+ * Copyright (c) 2018-2020 Linaro Limited
*/
#define LOG_CATEGORY UCLASS_TEE
#include <common.h>
+#include <cpu_func.h>
#include <dm.h>
#include <log.h>
#include <malloc.h>
#include <tee.h>
+#include <asm/cache.h>
#include <dm/device-internal.h>
#include <dm/uclass-internal.h>
d[7] = s->time_hi_and_version;
memcpy(d + 8, s->clock_seq_and_node, sizeof(s->clock_seq_and_node));
}
+
+void tee_flush_all_shm_dcache(struct udevice *dev)
+{
+ struct tee_uclass_priv *priv = dev_get_uclass_priv(dev);
+ struct tee_shm *s;
+
+ list_for_each_entry(s, &priv->list_shm, link) {
+ ulong start = rounddown((ulong)s->addr,
+ CONFIG_SYS_CACHELINE_SIZE);
+ ulong end = roundup((ulong)s->addr + s->size,
+ CONFIG_SYS_CACHELINE_SIZE);
+
+ flush_dcache_range(start, end);
+ }
+}
void tee_optee_ta_uuid_to_octets(u8 d[TEE_UUID_LEN],
const struct tee_optee_ta_uuid *s);
+/**
+ * tee_flush_all_shm_dcache() - Flush data cache for all shared memories
+ * @dev: The TEE device
+ */
+void tee_flush_all_shm_dcache(struct udevice *dev);
+
#endif /* __TEE_H */