arm-trusted-firmware/lib/psci
Boyan Karatotev 5d89341002 refactor(gic): promote most of the GIC driver to common code
More often than not, Arm based systems include some revision of a GIC.
There are two ways of adding support for them in platform code - calling
the top-level helpers from plat/arm/common/arm_gicvX.c or by using the
driver directly. Both of these methods allow for a high degree of
customisation - most functions are defined to be weak and there are no
calls to any of them in generic code.

As it turns out, requirements around those GICs are largely the same.
Platforms that use arm_gicvX.c use the helpers identically among each
other. Platforms that use the driver directly tend to end up with calls
that look a lot like the arm_gicvX.c helpers and the weakness of the
functions are never exercised.

All of this results in a lot of code duplication to do what is
essentially the same thing. Even though it's not a lot of code, when
multiplied among many platforms it becomes significant and makes
refactoring it quite difficult. It's also bug prone since the steps are
a little convoluted and things are likely to work even with subtle
errors (see 50009f6117).

So promote as much of the GIC to be called from common code. Do the
setup in bl31_main() and have every PSCI method do the state management
directly instead of delegating it to the platform hooks. We can base
this implementation on arm_gicvX.c since they already offer logical
names and have worked quite well so far with minimal changes.

The main benefit of doing this is reduced code duplication. If we assume
that, outside of some platform setup, GIC management is identical, then
a platform can add support by telling the build system, regardless of
GIC revision. The other benefit is performance - BL31 and PSCI already
know the core_pos and they can pass it as an argument instead of having
to call plat_my_core_pos(). Now, the only platform specific GIC actions
necessary are the saving and restoring of context on entering and
exiting a power domain. The PSCI library does not keep track of this so
it is unable perform it itself. The routines themselves are also
provided.

For compatibility all of this is hidden behind a build flag. Platforms
are encouraged to adopt this driver, but it would not be practical to
convert and validate every GIC based platform.

This patch renames the functions in question to follow the
gic_<function>() convention. This allows the names to be version
agnostic.

Finally, drop the weak definitions - they are unused, likely to remain
so, and can be added back if the need arises.

Change-Id: I5b5267f4b72f633fb1096400ec8e4b208694135f
Signed-off-by: Boyan Karatotev <boyan.karatotev@arm.com>
2025-04-17 07:05:26 +01:00
..
aarch32 chore: update to use Arm word across TF-A 2023-08-08 15:12:30 +01:00
aarch64 feat(psci): allow cores to wake up from powerdown 2025-02-03 14:29:47 +00:00
psci_common.c feat(psci): remove cpu context init by index 2025-04-11 07:27:23 +01:00
psci_lib.mk chore(cpus): optimise runtime errata applications 2024-10-16 13:59:57 +01:00
psci_main.c Merge "feat(psci): remove cpu context init by index" into integration 2025-04-14 14:21:24 +02:00
psci_mem_protect.c chore: update to use Arm word across TF-A 2023-08-08 15:12:30 +01:00
psci_off.c refactor(gic): promote most of the GIC driver to common code 2025-04-17 07:05:26 +01:00
psci_on.c refactor(gic): promote most of the GIC driver to common code 2025-04-17 07:05:26 +01:00
psci_private.h feat(psci): remove cpu context init by index 2025-04-11 07:27:23 +01:00
psci_setup.c Merge changes Id942c20c,Idd286bea,I8917a26e,Iec8c3477,If3c25dcd, ... into integration 2025-04-16 17:42:26 +02:00
psci_stat.c perf(psci): pass my_core_pos around instead of calling it repeatedly 2025-01-14 10:02:00 +00:00
psci_suspend.c refactor(gic): promote most of the GIC driver to common code 2025-04-17 07:05:26 +01:00
psci_system_off.c refactor(gic): promote most of the GIC driver to common code 2025-04-17 07:05:26 +01:00