From 0f4eeb6380db5734fd234e44dfa2e4d9e8419c8c Mon Sep 17 00:00:00 2001 From: Andy Ross Date: Sat, 8 Feb 2025 10:13:37 -0800 Subject: [PATCH] soc/mediatek/mtk_adsp: Use smaller accesses when find()ing in device memory Recent Python interpreters have started tossing bus errors from this 12-byte string search (the loader is looking for the winstream descriptor in the live firmware image). My guess is that there's a SIMD optimization that's been added that's trying to do e.g. a 16 byte load, and something in the fabric is kicking that out. Note that this is 100% a software change: the same hardware with one version of the host environment works, and an update breaks it. But really I have no idea what's happening here, the memory region in question is documented as system DRAM, the same bus regular process memory is on (it's just not kernel-utilized memory). All I know is that the bus error is introduced with a Python upgrade from 3.8.20 to 3.11.10. Regardless, it's no great hardship to do the search on 64 bit chunks. Signed-off-by: Andy Ross --- soc/mediatek/mt8xxx/mtk_adsp_load.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/soc/mediatek/mt8xxx/mtk_adsp_load.py b/soc/mediatek/mt8xxx/mtk_adsp_load.py index 03efcd2f1cc..42127b75ec5 100755 --- a/soc/mediatek/mt8xxx/mtk_adsp_load.py +++ b/soc/mediatek/mt8xxx/mtk_adsp_load.py @@ -277,7 +277,13 @@ def find_winstream(maps): magic = b'\x74\x5f\x6a\xd0\x79\xe2\x4f\x00\xcd\xb8\xbd\xf9' for m in maps: if "dram" in m: - magoff = maps[m].find(magic) + # Some python versions produce bus errors (!) on the + # hardware when finding a 12 byte substring (maybe a SIMD + # load that the hardware doesn't like?). Do it in two + # chunks. + magoff = maps[m].find(magic[0:8]) + if magoff >= 0: + magoff = maps[m].find(magic[8:], magoff) - 8 if magoff >= 0: addr = le4(maps[m][magoff + 12 : magoff + 16]) return addr