Path: blob/main/sys/contrib/device-tree/Bindings/cpu/cpu-topology.txt
48375 views
===========================================1CPU topology binding description2===========================================34===========================================51 - Introduction6===========================================78In a SMP system, the hierarchy of CPUs is defined through three entities that9are used to describe the layout of physical CPUs in the system:1011- socket12- cluster13- core14- thread1516The bottom hierarchy level sits at core or thread level depending on whether17symmetric multi-threading (SMT) is supported or not.1819For instance in a system where CPUs support SMT, "cpu" nodes represent all20threads existing in the system and map to the hierarchy level "thread" above.21In systems where SMT is not supported "cpu" nodes represent all cores present22in the system and map to the hierarchy level "core" above.2324CPU topology bindings allow one to associate cpu nodes with hierarchical groups25corresponding to the system hierarchy; syntactically they are defined as device26tree nodes.2728Currently, only ARM/RISC-V intend to use this cpu topology binding but it may be29used for any other architecture as well.3031The cpu nodes, as per bindings defined in [4], represent the devices that32correspond to physical CPUs and are to be mapped to the hierarchy levels.3334A topology description containing phandles to cpu nodes that are not compliant35with bindings standardized in [4] is therefore considered invalid.3637===========================================382 - cpu-map node39===========================================4041The ARM/RISC-V CPU topology is defined within the cpu-map node, which is a direct42child of the cpus node and provides a container where the actual topology43nodes are listed.4445- cpu-map node4647Usage: Optional - On SMP systems provide CPUs topology to the OS.48Uniprocessor systems do not require a topology49description and therefore should not define a50cpu-map node.5152Description: The cpu-map node is just a container node where its53subnodes describe the CPU topology.5455Node name must be "cpu-map".5657The cpu-map node's parent node must be the cpus node.5859The cpu-map node's child nodes can be:6061- one or more cluster nodes or62- one or more socket nodes in a multi-socket system6364Any other configuration is considered invalid.6566The cpu-map node can only contain 4 types of child nodes:6768- socket node69- cluster node70- core node71- thread node7273whose bindings are described in paragraph 3.7475The nodes describing the CPU topology (socket/cluster/core/thread) can76only be defined within the cpu-map node and every core/thread in the77system must be defined within the topology. Any other configuration is78invalid and therefore must be ignored.7980===========================================812.1 - cpu-map child nodes naming convention82===========================================8384cpu-map child nodes must follow a naming convention where the node name85must be "socketN", "clusterN", "coreN", "threadN" depending on the node type86(ie socket/cluster/core/thread) (where N = {0, 1, ...} is the node number; nodes87which are siblings within a single common parent node must be given a unique and88sequential N value, starting from 0).89cpu-map child nodes which do not share a common parent node can have the same90name (ie same number N as other cpu-map child nodes at different device tree91levels) since name uniqueness will be guaranteed by the device tree hierarchy.9293===========================================943 - socket/cluster/core/thread node bindings95===========================================9697Bindings for socket/cluster/cpu/thread nodes are defined as follows:9899- socket node100101Description: must be declared within a cpu-map node, one node102per physical socket in the system. A system can103contain single or multiple physical socket.104The association of sockets and NUMA nodes is beyond105the scope of this bindings, please refer [2] for106NUMA bindings.107108This node is optional for a single socket system.109110The socket node name must be "socketN" as described in 2.1 above.111A socket node can not be a leaf node.112113A socket node's child nodes must be one or more cluster nodes.114115Any other configuration is considered invalid.116117- cluster node118119Description: must be declared within a cpu-map node, one node120per cluster. A system can contain several layers of121clustering within a single physical socket and cluster122nodes can be contained in parent cluster nodes.123124The cluster node name must be "clusterN" as described in 2.1 above.125A cluster node can not be a leaf node.126127A cluster node's child nodes must be:128129- one or more cluster nodes; or130- one or more core nodes131132Any other configuration is considered invalid.133134- core node135136Description: must be declared in a cluster node, one node per core in137the cluster. If the system does not support SMT, core138nodes are leaf nodes, otherwise they become containers of139thread nodes.140141The core node name must be "coreN" as described in 2.1 above.142143A core node must be a leaf node if SMT is not supported.144145Properties for core nodes that are leaf nodes:146147- cpu148Usage: required149Value type: <phandle>150Definition: a phandle to the cpu node that corresponds to the151core node.152153If a core node is not a leaf node (CPUs supporting SMT) a core node's154child nodes can be:155156- one or more thread nodes157158Any other configuration is considered invalid.159160- thread node161162Description: must be declared in a core node, one node per thread163in the core if the system supports SMT. Thread nodes are164always leaf nodes in the device tree.165166The thread node name must be "threadN" as described in 2.1 above.167168A thread node must be a leaf node.169170A thread node must contain the following property:171172- cpu173Usage: required174Value type: <phandle>175Definition: a phandle to the cpu node that corresponds to176the thread node.177178===========================================1794 - Example dts180===========================================181182Example 1 (ARM 64-bit, 16-cpu system, two clusters of clusters in a single183physical socket):184185cpus {186#size-cells = <0>;187#address-cells = <2>;188189cpu-map {190socket0 {191cluster0 {192cluster0 {193core0 {194thread0 {195cpu = <&CPU0>;196};197thread1 {198cpu = <&CPU1>;199};200};201202core1 {203thread0 {204cpu = <&CPU2>;205};206thread1 {207cpu = <&CPU3>;208};209};210};211212cluster1 {213core0 {214thread0 {215cpu = <&CPU4>;216};217thread1 {218cpu = <&CPU5>;219};220};221222core1 {223thread0 {224cpu = <&CPU6>;225};226thread1 {227cpu = <&CPU7>;228};229};230};231};232233cluster1 {234cluster0 {235core0 {236thread0 {237cpu = <&CPU8>;238};239thread1 {240cpu = <&CPU9>;241};242};243core1 {244thread0 {245cpu = <&CPU10>;246};247thread1 {248cpu = <&CPU11>;249};250};251};252253cluster1 {254core0 {255thread0 {256cpu = <&CPU12>;257};258thread1 {259cpu = <&CPU13>;260};261};262core1 {263thread0 {264cpu = <&CPU14>;265};266thread1 {267cpu = <&CPU15>;268};269};270};271};272};273};274275CPU0: cpu@0 {276device_type = "cpu";277compatible = "arm,cortex-a57";278reg = <0x0 0x0>;279enable-method = "spin-table";280cpu-release-addr = <0 0x20000000>;281};282283CPU1: cpu@1 {284device_type = "cpu";285compatible = "arm,cortex-a57";286reg = <0x0 0x1>;287enable-method = "spin-table";288cpu-release-addr = <0 0x20000000>;289};290291CPU2: cpu@100 {292device_type = "cpu";293compatible = "arm,cortex-a57";294reg = <0x0 0x100>;295enable-method = "spin-table";296cpu-release-addr = <0 0x20000000>;297};298299CPU3: cpu@101 {300device_type = "cpu";301compatible = "arm,cortex-a57";302reg = <0x0 0x101>;303enable-method = "spin-table";304cpu-release-addr = <0 0x20000000>;305};306307CPU4: cpu@10000 {308device_type = "cpu";309compatible = "arm,cortex-a57";310reg = <0x0 0x10000>;311enable-method = "spin-table";312cpu-release-addr = <0 0x20000000>;313};314315CPU5: cpu@10001 {316device_type = "cpu";317compatible = "arm,cortex-a57";318reg = <0x0 0x10001>;319enable-method = "spin-table";320cpu-release-addr = <0 0x20000000>;321};322323CPU6: cpu@10100 {324device_type = "cpu";325compatible = "arm,cortex-a57";326reg = <0x0 0x10100>;327enable-method = "spin-table";328cpu-release-addr = <0 0x20000000>;329};330331CPU7: cpu@10101 {332device_type = "cpu";333compatible = "arm,cortex-a57";334reg = <0x0 0x10101>;335enable-method = "spin-table";336cpu-release-addr = <0 0x20000000>;337};338339CPU8: cpu@100000000 {340device_type = "cpu";341compatible = "arm,cortex-a57";342reg = <0x1 0x0>;343enable-method = "spin-table";344cpu-release-addr = <0 0x20000000>;345};346347CPU9: cpu@100000001 {348device_type = "cpu";349compatible = "arm,cortex-a57";350reg = <0x1 0x1>;351enable-method = "spin-table";352cpu-release-addr = <0 0x20000000>;353};354355CPU10: cpu@100000100 {356device_type = "cpu";357compatible = "arm,cortex-a57";358reg = <0x1 0x100>;359enable-method = "spin-table";360cpu-release-addr = <0 0x20000000>;361};362363CPU11: cpu@100000101 {364device_type = "cpu";365compatible = "arm,cortex-a57";366reg = <0x1 0x101>;367enable-method = "spin-table";368cpu-release-addr = <0 0x20000000>;369};370371CPU12: cpu@100010000 {372device_type = "cpu";373compatible = "arm,cortex-a57";374reg = <0x1 0x10000>;375enable-method = "spin-table";376cpu-release-addr = <0 0x20000000>;377};378379CPU13: cpu@100010001 {380device_type = "cpu";381compatible = "arm,cortex-a57";382reg = <0x1 0x10001>;383enable-method = "spin-table";384cpu-release-addr = <0 0x20000000>;385};386387CPU14: cpu@100010100 {388device_type = "cpu";389compatible = "arm,cortex-a57";390reg = <0x1 0x10100>;391enable-method = "spin-table";392cpu-release-addr = <0 0x20000000>;393};394395CPU15: cpu@100010101 {396device_type = "cpu";397compatible = "arm,cortex-a57";398reg = <0x1 0x10101>;399enable-method = "spin-table";400cpu-release-addr = <0 0x20000000>;401};402};403404Example 2 (ARM 32-bit, dual-cluster, 8-cpu system, no SMT):405406cpus {407#size-cells = <0>;408#address-cells = <1>;409410cpu-map {411cluster0 {412core0 {413cpu = <&CPU0>;414};415core1 {416cpu = <&CPU1>;417};418core2 {419cpu = <&CPU2>;420};421core3 {422cpu = <&CPU3>;423};424};425426cluster1 {427core0 {428cpu = <&CPU4>;429};430core1 {431cpu = <&CPU5>;432};433core2 {434cpu = <&CPU6>;435};436core3 {437cpu = <&CPU7>;438};439};440};441442CPU0: cpu@0 {443device_type = "cpu";444compatible = "arm,cortex-a15";445reg = <0x0>;446};447448CPU1: cpu@1 {449device_type = "cpu";450compatible = "arm,cortex-a15";451reg = <0x1>;452};453454CPU2: cpu@2 {455device_type = "cpu";456compatible = "arm,cortex-a15";457reg = <0x2>;458};459460CPU3: cpu@3 {461device_type = "cpu";462compatible = "arm,cortex-a15";463reg = <0x3>;464};465466CPU4: cpu@100 {467device_type = "cpu";468compatible = "arm,cortex-a7";469reg = <0x100>;470};471472CPU5: cpu@101 {473device_type = "cpu";474compatible = "arm,cortex-a7";475reg = <0x101>;476};477478CPU6: cpu@102 {479device_type = "cpu";480compatible = "arm,cortex-a7";481reg = <0x102>;482};483484CPU7: cpu@103 {485device_type = "cpu";486compatible = "arm,cortex-a7";487reg = <0x103>;488};489};490491Example 3: HiFive Unleashed (RISC-V 64 bit, 4 core system)492493{494#address-cells = <2>;495#size-cells = <2>;496compatible = "sifive,fu540g", "sifive,fu500";497model = "sifive,hifive-unleashed-a00";498499...500cpus {501#address-cells = <1>;502#size-cells = <0>;503cpu-map {504socket0 {505cluster0 {506core0 {507cpu = <&CPU1>;508};509core1 {510cpu = <&CPU2>;511};512core2 {513cpu0 = <&CPU2>;514};515core3 {516cpu0 = <&CPU3>;517};518};519};520};521522CPU1: cpu@1 {523device_type = "cpu";524compatible = "sifive,rocket0", "riscv";525reg = <0x1>;526}527528CPU2: cpu@2 {529device_type = "cpu";530compatible = "sifive,rocket0", "riscv";531reg = <0x2>;532}533CPU3: cpu@3 {534device_type = "cpu";535compatible = "sifive,rocket0", "riscv";536reg = <0x3>;537}538CPU4: cpu@4 {539device_type = "cpu";540compatible = "sifive,rocket0", "riscv";541reg = <0x4>;542}543}544};545===============================================================================546[1] ARM Linux kernel documentation547Documentation/devicetree/bindings/arm/cpus.yaml548[2] Devicetree NUMA binding description549Documentation/devicetree/bindings/numa.txt550[3] RISC-V Linux kernel documentation551Documentation/devicetree/bindings/riscv/cpus.yaml552[4] https://www.devicetree.org/specifications/553554555