]> git.baikalelectronics.ru Git - arm-tf.git/commitdiff
arm_fpga: Remove SPE PMU DT node if SPE is not available
authorAndre Przywara <andre.przywara@arm.com>
Mon, 3 Aug 2020 11:55:28 +0000 (12:55 +0100)
committerAndre Przywara <andre.przywara@arm.com>
Tue, 29 Sep 2020 12:28:25 +0000 (13:28 +0100)
The Statistical Profiling Extension (SPE) is an architectural feature we
can safely detect at runtime. However it still relies on one piece of
platform-specific information: the interrupt line it is connected
to. This requires SPE to be described in a devicetree node.

Since SPE support varies with the CPU cores found on an FPGA image, we
should detect the presence of SPE at runtime, and remove a potentially
existing SPE PMU node from the DT.

This allows to always have the SPE node in a generic devicetree file,
without risking exposing it on a CPU without this feature.

Change-Id: I73d83ea8509b03fe7bba20b9cce8d1335035fa31
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
plat/arm/board/arm_fpga/fpga_bl31_setup.c

index d5478d2d63e8475eb8dccafca46dfa9020313359..a5f5ea0f3a5aba803e4679818a947d8a5d89f835 100644 (file)
@@ -12,6 +12,7 @@
 #include <drivers/arm/gicv3.h>
 #include <drivers/delay_timer.h>
 #include <drivers/generic_delay_timer.h>
+#include <lib/extensions/spe.h>
 #include <libfdt.h>
 
 #include "fpga_private.h"
@@ -224,6 +225,16 @@ static void fpga_prepare_dtb(void)
                }
        }
 
+       /* Check whether we support the SPE PMU. Remove the DT node if not. */
+       if (!spe_supported()) {
+               int node = fdt_node_offset_by_compatible(fdt, 0,
+                                    "arm,statistical-profiling-extension-v1");
+
+               if (node >= 0) {
+                       fdt_del_node(fdt, node);
+               }
+       }
+
        err = fdt_pack(fdt);
        if (err < 0) {
                ERROR("Failed to pack Device Tree at %p: error %d\n", fdt, err);