b23d7e06b9dce5dd01223f45fcded2fc3cd8baed
[openwrt/staging/wigyori.git] /
1 From 8612169a05c5e979af033868b7a9b177e0f9fcdf Mon Sep 17 00:00:00 2001
2 From: Dragan Simic <dsimic@manjaro.org>
3 Date: Sat, 9 Mar 2024 05:25:06 +0100
4 Subject: [PATCH] arm64: dts: rockchip: Add cache information to the SoC dtsi
5 for RK356x
6
7 Add missing cache information to the Rockchip RK356x SoC dtsi, to allow
8 the userspace, which includes lscpu(1) that uses the virtual files provided
9 by the kernel under the /sys/devices/system/cpu directory, to display the
10 proper RK3566 and RK3568 cache information.
11
12 Adding the cache information to the RK356x SoC dtsi also makes the following
13 warning message in the kernel log go away:
14
15 cacheinfo: Unable to detect cache hierarchy for CPU 0
16
17 The cache parameters for the RK356x dtsi were obtained and partially derived
18 by hand from the cache size and layout specifications found in the following
19 datasheets and technical reference manuals:
20
21 - Rockchip RK3566 datasheet, version 1.1
22 - Rockchip RK3568 datasheet, version 1.3
23 - ARM Cortex-A55 revision r1p0 TRM, version 0100-00
24 - ARM DynamIQ Shared Unit revision r4p0 TRM, version 0400-02
25
26 For future reference, here's a rather detailed summary of the documentation,
27 which applies to both Rockchip RK3566 and RK3568 SoCs:
28
29 - All caches employ the 64-byte cache line length
30 - Each Cortex-A55 core has 32 KB of L1 4-way, set-associative instruction
31 cache and 32 KB of L1 4-way, set-associative data cache
32 - There are no L2 caches, which are per-core and private in Cortex-A55,
33 because it belongs to the ARM DynamIQ IP core lineup
34 - The entire SoC has 512 KB of unified L3 16-way, set-associative cache,
35 which is shared among all four Cortex-A55 CPU cores
36 - Cortex-A55 cores can be configured without private per-core L2 caches,
37 in which case the shared L3 cache appears to them as an L2 cache; this
38 is the case for the RK356x SoCs, so let's use "cache-level = <2>" to
39 prevent the "huh, no L2 caches, but an L3 cache?" confusion among the
40 users viewing the data presented to the userspace; another option could
41 be to have additional 0 KB L2 caches defined, which may be technically
42 correct, but would probably be even more confusing
43
44 Helped-by: Anand Moon <linux.amoon@gmail.com>
45 Tested-By: Diederik de Haas <didi.debian@cknow.org>
46 Reviewed-by: Anand Moon <linux.amoon@gmail.com>
47 Signed-off-by: Dragan Simic <dsimic@manjaro.org>
48 Link: https://lore.kernel.org/r/2dee6dad8460b0c5f3b5da53cf55f735840efef1.1709957777.git.dsimic@manjaro.org
49 Signed-off-by: Heiko Stuebner <heiko@sntech.de>
50 ---
51 arch/arm64/boot/dts/rockchip/rk356x.dtsi | 41 ++++++++++++++++++++++++
52 1 file changed, 41 insertions(+)
53
54 --- a/arch/arm64/boot/dts/rockchip/rk356x.dtsi
55 +++ b/arch/arm64/boot/dts/rockchip/rk356x.dtsi
56 @@ -57,6 +57,13 @@
57 #cooling-cells = <2>;
58 enable-method = "psci";
59 operating-points-v2 = <&cpu0_opp_table>;
60 + i-cache-size = <0x8000>;
61 + i-cache-line-size = <64>;
62 + i-cache-sets = <128>;
63 + d-cache-size = <0x8000>;
64 + d-cache-line-size = <64>;
65 + d-cache-sets = <128>;
66 + next-level-cache = <&l3_cache>;
67 };
68
69 cpu1: cpu@100 {
70 @@ -66,6 +73,13 @@
71 #cooling-cells = <2>;
72 enable-method = "psci";
73 operating-points-v2 = <&cpu0_opp_table>;
74 + i-cache-size = <0x8000>;
75 + i-cache-line-size = <64>;
76 + i-cache-sets = <128>;
77 + d-cache-size = <0x8000>;
78 + d-cache-line-size = <64>;
79 + d-cache-sets = <128>;
80 + next-level-cache = <&l3_cache>;
81 };
82
83 cpu2: cpu@200 {
84 @@ -75,6 +89,13 @@
85 #cooling-cells = <2>;
86 enable-method = "psci";
87 operating-points-v2 = <&cpu0_opp_table>;
88 + i-cache-size = <0x8000>;
89 + i-cache-line-size = <64>;
90 + i-cache-sets = <128>;
91 + d-cache-size = <0x8000>;
92 + d-cache-line-size = <64>;
93 + d-cache-sets = <128>;
94 + next-level-cache = <&l3_cache>;
95 };
96
97 cpu3: cpu@300 {
98 @@ -84,9 +105,29 @@
99 #cooling-cells = <2>;
100 enable-method = "psci";
101 operating-points-v2 = <&cpu0_opp_table>;
102 + i-cache-size = <0x8000>;
103 + i-cache-line-size = <64>;
104 + i-cache-sets = <128>;
105 + d-cache-size = <0x8000>;
106 + d-cache-line-size = <64>;
107 + d-cache-sets = <128>;
108 + next-level-cache = <&l3_cache>;
109 };
110 };
111
112 + /*
113 + * There are no private per-core L2 caches, but only the
114 + * L3 cache that appears to the CPU cores as L2 caches
115 + */
116 + l3_cache: l3-cache {
117 + compatible = "cache";
118 + cache-level = <2>;
119 + cache-unified;
120 + cache-size = <0x80000>;
121 + cache-line-size = <64>;
122 + cache-sets = <512>;
123 + };
124 +
125 cpu0_opp_table: opp-table-0 {
126 compatible = "operating-points-v2";
127 opp-shared;