Skip to content

Commit 0e6aee3

Browse files
edersondisouzanashif
authored andcommitted
tests/boards/intel_adsp: Add cache related tests
Tests that exercise z_xtensa_cache_[flush|inv|flush_inv]_all() functions. These tests are at board level because what is mapped into memory is SoC/board dependent - no one wants side effects due writing to some inappropriate address. Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
1 parent c28d382 commit 0e6aee3

File tree

4 files changed

+77
-0
lines changed

4 files changed

+77
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
cmake_minimum_required(VERSION 3.20.0)
4+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
5+
project(adsp_cache)
6+
7+
target_sources(app PRIVATE src/main.c)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CONFIG_ZTEST=y
2+
CONFIG_ZTEST_NEW_API=y
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
* Copyright (c) 2022 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <zephyr/ztest.h>
8+
#include <adsp_memory.h>
9+
10+
ZTEST(adsp_cache, test_adsp_cache_flush_inv_all)
11+
{
12+
uint32_t *cached, *uncached;
13+
14+
cached = (uint32_t *)LP_SRAM_BASE;
15+
uncached = arch_xtensa_uncached_ptr(cached);
16+
17+
*cached = 42;
18+
*uncached = 40;
19+
20+
/* Just some sanity checks */
21+
zassert_equal(*cached, 42, NULL);
22+
zassert_equal(*uncached, 40, NULL);
23+
24+
z_xtensa_cache_flush_inv_all();
25+
26+
/* After z_xtensa_cache_flush_inv_all(), uncached should be updated */
27+
zassert_equal(*cached, 42, NULL);
28+
zassert_equal(*uncached, 42, NULL);
29+
30+
/* Flush and invalidate again, this time to check the invalidate part */
31+
z_xtensa_cache_flush_inv_all();
32+
*uncached = 80;
33+
34+
/* As cache is invalid, cached should be updated with uncached new value */
35+
zassert_equal(*cached, 80, NULL);
36+
zassert_equal(*uncached, 80, NULL);
37+
38+
*cached = 82;
39+
40+
/* Only cached should have changed */
41+
zassert_equal(*cached, 82, NULL);
42+
zassert_equal(*uncached, 80, NULL);
43+
44+
z_xtensa_cache_flush_all();
45+
46+
/* After z_xtensa_cache_flush_all(), uncached should be updated */
47+
zassert_equal(*cached, 82, NULL);
48+
zassert_equal(*uncached, 82, NULL);
49+
50+
*uncached = 100;
51+
52+
/* As cache is not invalid, only uncached should be updated */
53+
zassert_equal(*cached, 82, NULL);
54+
zassert_equal(*uncached, 100, NULL);
55+
56+
z_xtensa_cache_inv_all();
57+
58+
/* Now, cached should be updated */
59+
zassert_equal(*cached, 100, NULL);
60+
zassert_equal(*uncached, 100, NULL);
61+
}
62+
63+
ZTEST_SUITE(adsp_cache, NULL, NULL, NULL, NULL, NULL);
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
common:
2+
tags: boards
3+
tests:
4+
boards.intel_adsp.cache:
5+
platform_allow: intel_adsp_cavs15 intel_adsp_cavs18 intel_adsp_cavs25

0 commit comments

Comments
 (0)