Skip to content

arm64: dts: rockchip: rk3576: add cache hierarchy information to CPU nodes - #18

Merged
alchark merged 1 commit into
flipperdevices:flipper-develfrom
munzzyy:rk3576-cacheinfo-dts
Jul 28, 2026
Merged

arm64: dts: rockchip: rk3576: add cache hierarchy information to CPU nodes#18
alchark merged 1 commit into
flipperdevices:flipper-develfrom
munzzyy:rk3576-cacheinfo-dts

Conversation

@munzzyy

@munzzyy munzzyy commented Jul 28, 2026

Copy link
Copy Markdown

Fixes #13.

Every boot logs cacheinfo: Unable to detect cache hierarchy for CPU 0. The cause is in the generic cacheinfo core, not arm64: of_check_cache_nodes() finds no cache properties on the RK3576 CPU nodes, so cache_setup_of_node() returns -ENOENT and cache_shared_cpu_map_setup() throws away the topology that CLIDR-based detection had already computed correctly.

This adds L1 i/d size, line-size and sets to all eight CPU nodes, plus the two per-cluster unified L2 nodes with next-level-cache phandles. It's the same shape as the rk3399 fix that went into mainline rk3399-base.dtsi.

Where the numbers come from:

  • L1/L2 sizes: RK3576 datasheet (A72 cluster: 48KB I / 32KB D per core, 1MB L2; A53 cluster: 32KB/32KB, 512KB L2)
  • Line size and associativity are fixed by the architecture per the A53 and A72 TRMs, so the *-sets values are derived as size / (line-size x ways). The A53 numbers come out identical to rk3399's, which is a decent cross-check.

Verified by building dtc from the tree and compiling the full rk3576-flipper-one-rev-f0b1c2.dts include chain: no warnings, and decompiling the dtb shows all eight next-level-cache phandles resolving to the right L2 node. I don't have a board, so this isn't boot-tested. On hardware the cacheinfo line should disappear from dmesg and /sys/devices/system/cpu/cpu0/cache/index*/size should read 32K/32K/512K on the A53 side.

Mainline rk3576.dtsi has the identical gap, so this is probably worth sending upstream too. Happy to do that, or leave it to you since you're closer to the mainline RK3576 work.

@munzzyy
munzzyy requested a review from a team July 28, 2026 05:00

@alchark alchark left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @munzzyy, this looks good to me but please reference the RK3576 datasheet, not RK3576S, as they are technically different products.

Cache sizes stated in the RK3576 datasheet are the same as those you used here, so it’s purely about wording in the commit description.

I’ll be able to test and confirm on actual hardware later today, and then it would be great if you submitted it directly to the upstream mailing list using b4.

alchark pushed a commit that referenced this pull request Jul 28, 2026
…fset

Commit 390ac56 ("ocfs2: add boundary check to
ocfs2_check_dir_entry()") added an out-of-bounds guard using the
caller-supplied 'offset' argument:

	if (offset > size - OCFS2_DIR_REC_LEN(1))
		return 0;

However, 'offset' and 'size' are not measured against the same base for
all callers.  In the block-based lookup path, ocfs2_find_entry_el() passes
'offset' as an absolute offset into the whole directory:

	i = ocfs2_search_dirblock(bh, dir, name, namelen,
				  block << sb->s_blocksize_bits,
				  bh->b_data, sb->s_blocksize, res_dir);

while 'size' is a single block size (sb->s_blocksize).  For any directory
entry located in the second or later block, 'offset' is >=
sb->s_blocksize, so the guard rejects every such entry even though it is
perfectly valid and lies entirely within its block buffer.

This makes mounting fail for filesystems whose system directory spans more
than one block, e.g.  a volume formatted with a small block size:

  mkfs.ocfs2 -b 512 -C 4096 -N 2 -T datafiles --fs-features=usrquota,grpquota

  ocfs2_check_dir_entry:314 ERROR: directory entry (#18: offset=512) too close to end or out-of-bounds
  ocfs2_init_local_system_inodes:496 ERROR: status=-22, sysfile=12, slot=0
  ocfs2_mount_volume:1757 ERROR: status = -22

The dirent's position within the buffer being validated is ((char *)de -
buf), which is what the rest of the function already uses (via
next_offset) and what must be bounds-checked against 'size'.  Compute that
buffer-relative offset and use it for the guard.  The subtraction is
reordered to size - buf_offset < OCFS2_DIR_REC_LEN(1) to avoid an unsigned
underflow when size is smaller than the minimal record length.

Link: https://lore.kernel.org/20260710040512.3310736-1-joseph.qi@linux.alibaba.com
Fixes: 390ac56 ("ocfs2: add boundary check to ocfs2_check_dir_entry()")
Signed-off-by: Joseph Qi <joseph.qi@linux.alibaba.com>
Reviewed-by: Dmitry Antipov <dmantipov@yandex.ru>
Tested-by: Dmitry Antipov <dmantipov@yandex.ru>
Cc: Mark Fasheh <mark@fasheh.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Junxiao Bi <junxiao.bi@oracle.com>
Cc: Changwei Ge <gechangwei@live.cn>
Cc: Jun Piao <piaojun@huawei.com>
Cc: Heming Zhao <heming.zhao@suse.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
@alchark

alchark commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

@munzzyy I've tested it on my Flipper One prototype board. The warning line is gone from dmesg, and /sys/devices/system/cpu/cpu*/cache/index* now contains meaningful cache information instead of just level, type and shared_cpu_list. Same for lscpu:

user@flipperone-36c831-764:~$ lscpu --caches
NAME ONE-SIZE ALL-SIZE WAYS TYPE        LEVEL SETS PHY-LINE COHERENCY-SIZE
L1d       32K     256K    4 Data            1  128                      64
L1i       32K     320K    2 Instruction     1  256                      64
L2       512K     1.5M   16 Unified         2  512                      64

So please feel free to include upon mainline submission:
Tested-by: Alexey Charkov <alchark@flipper.net>

@munzzyy
munzzyy force-pushed the rk3576-cacheinfo-dts branch from 5fbc287 to 118825a Compare July 28, 2026 16:12
@munzzyy

munzzyy commented Jul 28, 2026

Copy link
Copy Markdown
Author

That lscpu output is great to see — thanks for putting it on real hardware so quickly.

Datasheet reference fixed: the commit message now cites the RK3576 datasheet (same cache numbers, as you said, but the S is a different product — my mistake). Force-pushed with just the wording change; the diff itself is untouched.

I'll prepare the mainline submission next and include your Tested-by there. Will follow up once it's on the list.

…nodes

The RK3576 CPU nodes carry no cache properties, so cache_setup_of_node()
in the generic cacheinfo core fails with -ENOENT on the first CPU. That
error propagates out of cache_shared_cpu_map_setup(), which discards the
topology arm64 had already derived from CLIDR and prints
"cacheinfo: Unable to detect cache hierarchy for CPU 0" on every boot.

Add L1 i/d cache size, line-size and sets to all eight CPU nodes, plus
per-cluster unified L2 nodes wired up through next-level-cache. Sizes
come from the RK3576 datasheet (A72 cluster: 48KB/32KB L1 I/D, 1MB L2;
A53 cluster: 32KB/32KB L1 I/D, 512KB L2). Line size and associativity
are architecturally fixed per the Cortex-A53 and Cortex-A72 TRMs, and
the *-sets values follow as size / (line-size * ways).

Same shape as the rk3399 fix that landed upstream in rk3399-base.dtsi.
Mainline rk3576.dtsi has the identical gap.

Signed-off-by: Cole Munz <Munzzyy1@proton.me>
@munzzyy
munzzyy force-pushed the rk3576-cacheinfo-dts branch from 118825a to c2fe199 Compare July 28, 2026 16:17

@alchark alchark left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for your contribution! Eager to see the mainline submission next :)

@alchark
alchark merged commit ffbee6b into flipperdevices:flipper-devel Jul 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cacheinfo: "Unable to detect cache hierarchy for CPU 0" at early boot

2 participants