arm-trusted-firmware/plat
Boyan Karatotev 83ec7e452c perf(amu): greatly simplify AMU context management
The current code is incredibly resilient to updates to the spec and
has worked quite well so far. However, recent implementations expose a
weakness in that this is rather slow. A large part of it is written in
assembly, making it opaque to the compiler for optimisations. The
future proofness requires reading registers that are effectively
`volatile`, making it even harder for the compiler, as well as adding
lots of implicit barriers, making it hard for the microarchitecutre to
optimise as well.

We can make a few assumptions, checked by a few well placed asserts, and
remove a lot of this burden. For a start, at the moment there are 4
group 0 counters with static assignments. Contexting them is a trivial
affair that doesn't need a loop. Similarly, there can only be up to 16
group 1 counters. Contexting them is a bit harder, but we can do with a
single branch with a falling through switch. If/when both of these
change, we have a pair of asserts and the feature detection mechanism to
guard us against pretending that we support something we don't.

We can drop contexting of the offset registers. They are fully
accessible by EL2 and as such are its responsibility to preserve on
powerdown.

Another small thing we can do, is pass the core_pos into the hook.
The caller already knows which core we're running on, we don't need to
call this non-trivial function again.

Finally, knowing this, we don't really need the auxiliary AMUs to be
described by the device tree. Linux doesn't care at the moment, and any
information we need for EL3 can be neatly placed in a simple array.

All of this, combined with lifting the actual saving out of assembly,
reduces the instructions to save the context from 180 to 40, including a
lot fewer branches. The code is also much shorter and easier to read.

Also propagate to aarch32 so that the two don't diverge too much.

Change-Id: Ib62e6e9ba5be7fb9fb8965c8eee148d5598a5361
Signed-off-by: Boyan Karatotev <boyan.karatotev@arm.com>
2025-02-25 08:50:46 +00:00
..
allwinner refactor: panic after calling psci_power_down_wfi() 2025-02-03 14:29:47 +00:00
amd feat(versal2): extended SMCCC payload for EEMI 2025-02-21 07:31:47 +01:00
amlogic chore(docs): drop the "wfi" from pwr_domain_pwr_down_wfi 2025-02-03 14:29:47 +00:00
arm perf(amu): greatly simplify AMU context management 2025-02-25 08:50:46 +00:00
aspeed/ast2700 fix(ast2700): fix mpll calculate statement 2024-08-01 14:55:15 +08:00
brcm refactor(console): consolidate console runtime switch 2024-05-08 15:50:58 +02:00
common refactor(bl32): flush before console switch state 2025-01-21 12:22:57 +01:00
hisilicon fix(build): ensure $(ROT_KEY) depends on correct directory rules 2024-11-12 12:50:45 +00:00
imx Merge changes from topic "imx8mq_build_fix" into integration 2025-02-12 09:26:36 +01:00
intel/soc Merge "feat(intel): add FDT support for Altera products" into integration 2025-02-24 17:10:17 +01:00
marvell Merge changes I32bd0c71,I167e7398 into integration 2025-02-12 16:25:49 +01:00
mediatek fix(mt8196): remove EC_SUSPEND_PIN initial setting 2025-02-13 20:33:52 +08:00
nuvoton chore(docs): drop the "wfi" from pwr_domain_pwr_down_wfi 2025-02-03 14:29:47 +00:00
nvidia/tegra chore(docs): drop the "wfi" from pwr_domain_pwr_down_wfi 2025-02-03 14:29:47 +00:00
nxp chore(docs): drop the "wfi" from pwr_domain_pwr_down_wfi 2025-02-03 14:29:47 +00:00
qemu refactor(cpus): register DSU errata with the errata framework's wrappers 2025-02-20 17:28:17 +00:00
qti chore(docs): drop the "wfi" from pwr_domain_pwr_down_wfi 2025-02-03 14:29:47 +00:00
renesas chore(docs): drop the "wfi" from pwr_domain_pwr_down_wfi 2025-02-03 14:29:47 +00:00
rockchip Merge "feat(rockchip): increase FDT Buffer for Rockchip Devices" into integration 2025-02-24 09:18:52 +01:00
rpi chore(docs): drop the "wfi" from pwr_domain_pwr_down_wfi 2025-02-03 14:29:47 +00:00
socionext chore(docs): drop the "wfi" from pwr_domain_pwr_down_wfi 2025-02-03 14:29:47 +00:00
st chore(docs): drop the "wfi" from pwr_domain_pwr_down_wfi 2025-02-03 14:29:47 +00:00
ti/k3 feat(ti): implement DM_MANAGED suspend 2024-10-31 10:50:29 +01:00
xilinx feat(versal2): add support for platform management 2025-02-20 22:23:12 -08:00