Peios Learn
Documentation

Peios

Peios Peios Kernel Universal Directory Project

Developer Tools

Trail Acta Provium clackatoo CAF GCSL Pekit

Applications

Framewright

Standards and Conventions

Standards and Conventions Peios Specifications
Peios Kernel

Arm

Single-page view · as markdown

ARM Architecture

Peios Kernel / Hardware and drivers / Processor architectures / Arm

  • ARM Linux 2.6 and upper
  • Booting ARM Linux
  • Cluster-wide Power-up/power-down race avoidance algorithm
  • Interface for registering and calling firmware-specific operations for ARM
  • Interrupts
  • Kernel mode NEON
  • Kernel-provided User Helpers
  • Kernel Memory Layout on ARM Linux
  • Memory alignment
  • ARM TCM (Tightly-Coupled Memory) handling in Linux
  • Kernel initialisation parameters on ARM Linux
  • Software emulation of deprecated SWP instruction (CONFIG_SWP_EMULATE)
  • The Unified Extensible Firmware Interface (UEFI)
  • vlocks for Bare-Metal Mutual Exclusion
  • Porting
  • features

SoC-specific documents #

  • Chromebook Boot Flow
  • Release Notes for Linux on Intel's IXP4xx Network Processor
  • ARM Marvell SoCs
  • ARM Microchip SoCs (aka AT91)
  • NetWinder specific documentation
  • NetWinder's floating point emulator
  • TI Keystone Linux Overview
  • Texas Instruments Keystone Navigator Queue Management SubSystem driver
  • TI OMAP
  • MFP Configuration for PXA2xx/PXA3xx Processors
  • Intel StrongARM 1100
  • STM32F746 Overview
  • STM32 ARM Linux Overview
  • STM32H743 Overview
  • STM32H750 Overview
  • STM32F769 Overview
  • STM32F429 Overview
  • STM32MP13 Overview
  • STM32MP151 Overview
  • STM32MP157 Overview
  • STM32 DMA-MDMA chaining
  • ARM Allwinner SoCs
  • Samsung SoC
  • Frequently asked questions about the sunxi clock system
  • SPEAr ARM Linux Overview
  • STiH407 Overview
  • STiH418 Overview
  • STi ARM Linux Overview
  • Release notes for Linux Kernel VFP support code

ARM Linux 2.6 and upper

Peios Kernel / Hardware and drivers / Processor architectures / Arm

Please check <ftp://ftp.arm.linux.org.uk/pub/armlinux> for updates.

Compilation of kernel #

In order to compile ARM Linux, you will need a compiler capable of generating ARM ELF code with GNU extensions. GCC 3.3 is known to be a good compiler. Fortunately, you needn't guess. The kernel will report an error if your compiler is a recognized offender.

To build ARM Linux natively, you shouldn't have to alter the ARCH = line in the top level Makefile. However, if you don't have the ARM Linux ELF tools installed as default, then you should change the CROSS_COMPILE line as detailed below.

If you wish to cross-compile, then alter the following lines in the top level make file:

ARCH = <whatever>

with:

ARCH = arm

and:

CROSS_COMPILE=

to:

CROSS_COMPILE=<your-path-to-your-compiler-without-gcc>

eg.:

CROSS_COMPILE=arm-linux-

Do a 'make config', followed by 'make Image' to build the kernel (arch/arm/boot/Image). A compressed image can be built by doing a 'make zImage' instead of 'make Image'.

Bug reports etc #

Please send patches to the patch system. For more information, see http://www.arm.linux.org.uk/developer/patches/info.php Always include some explanation as to what the patch does and why it is needed.

Bug reports should be sent to linux-arm-kernel@lists.arm.linux.org.uk, or submitted through the web form at http://www.arm.linux.org.uk/developer/

When sending bug reports, please ensure that they contain all relevant information, eg. the kernel messages that were printed before/during the problem, what you were doing, etc.

Include files #

Several new include directories have been created under include/asm-arm, which are there to reduce the clutter in the top-level directory. These directories, and their purpose is listed below:

arch-*

machine/platform specific header files

hardware

driver-internal ARM specific data structures/definitions

mach

descriptions of generic ARM to specific machine interfaces

proc-*

processor dependent header files (currently only two categories)

Machine/Platform support #

The ARM tree contains support for a lot of different machine types. To continue supporting these differences, it has become necessary to split machine-specific parts by directory. For this, the machine category is used to select which directories and files get included (we will use $(MACHINE) to refer to the category)

To this end, we now have arch/arm/mach-$(MACHINE) directories which are designed to house the non-driver files for a particular machine (eg, PCI, memory management, architecture definitions etc). For all future machines, there should be a corresponding arch/arm/mach-$(MACHINE)/include/mach directory.

Modules #

Although modularisation is supported (and required for the FP emulator), each module on an ARM2/ARM250/ARM3 machine when is loaded will take memory up to the next 32k boundary due to the size of the pages. Therefore, is modularisation on these machines really worth it?

However, ARM6 and up machines allow modules to take multiples of 4k, and as such Acorn RiscPCs and other architectures using these processors can make good use of modularisation.

ADFS Image files #

You can access image files on your ADFS partitions by mounting the ADFS partition, and then using the loopback device driver. You must have losetup installed.

Please note that the PCEmulator DOS partitions have a partition table at the start, and as such, you will have to give '-o offset' to losetup.

Request to developers #

When writing device drivers which include a separate assembler file, please include it in with the C file, and not the arch/arm/lib directory. This allows the driver to be compiled as a loadable module without requiring half the code to be compiled into the kernel image.

In general, try to avoid using assembler unless it is really necessary. It makes drivers far less easy to port to other hardware.

ST506 hard drives #

The ST506 hard drive controllers seem to be working fine (if a little slowly). At the moment they will only work off the controllers on an A4x0's motherboard, but for it to work off a Podule just requires someone with a podule to add the addresses for the IRQ mask and the HDC base to the source.

As of 31/3/96 it works with two drives (you should get the ADFS *configure harddrive set to 2). I've got an internal 20MB and a great big external 5.25" FH 64MB drive (who could ever want more :-) ).

I've just got 240K/s off it (a dd with bs=128k); that's about half of what RiscOS gets; but it's a heck of a lot better than the 50K/s I was getting last week :-)

Known bug: Drive data errors can cause a hang; including cases where the controller has fixed the error using ECC. (Possibly ONLY in that case...hmm).

1772 Floppy #

This also seems to work OK, but hasn't been stressed much lately. It hasn't got any code for disc change detection in there at the moment which could be a bit of a problem! Suggestions on the correct way to do this are welcome.

CONFIG_MACH_ and CONFIG_ARCH_ #

A change was made in 2003 to the macro names for new machines. Historically, CONFIG_ARCH_ was used for the bonafide architecture, e.g. SA1100, as well as implementations of the architecture, e.g. Assabet. It was decided to change the implementation macros to read CONFIG_MACH_ for clarity. Moreover, a retroactive fixup has not been made because it would complicate patching.

Previous registrations may be found online.

<http://www.arm.linux.org.uk/developer/machines/>

Kernel entry (head.S) #

The initial entry into the kernel is via head.S, which uses machine independent code. The machine is selected by the value of 'r1' on entry, which must be kept unique.

Due to the large number of machines which the ARM port of Linux provides for, we have a method to manage this which ensures that we don't end up duplicating large amounts of code.

We group machine (or platform) support code into machine classes. A class typically based around one or more system on a chip devices, and acts as a natural container around the actual implementations. These classes are given directories - arch/arm/mach-<class> - which contain the source files and include/mach/ to support the machine class.

For example, the SA1100 class is based upon the SA1100 and SA1110 SoC devices, and contains the code to support the way the on-board and off- board devices are used, or the device is setup, and provides that machine specific "personality."

For platforms that support device tree (DT), the machine selection is controlled at runtime by passing the device tree blob to the kernel. At compile-time, support for the machine type must be selected. This allows for a single multiplatform kernel build to be used for several machine types.

For platforms that do not use device tree, this machine selection is controlled by the machine type ID, which acts both as a run-time and a compile-time code selection method. You can register a new machine via the web site at:

<http://www.arm.linux.org.uk/developer/machines/>

Note: Please do not register a machine type for DT-only platforms. If your platform is DT-only, you do not need a registered machine type.

---

Russell King (15/03/2004)

Booting ARM Linux

Peios Kernel / Hardware and drivers / Processor architectures / Arm

Author: Russell King

Date : 18 May 2002

The following documentation is relevant to 2.4.18-rmk6 and beyond.

In order to boot ARM Linux, you require a boot loader, which is a small program that runs before the main kernel. The boot loader is expected to initialise various devices, and eventually call the Linux kernel, passing information to the kernel.

Essentially, the boot loader should provide (as a minimum) the following:

  1. Setup and initialise the RAM.

  2. Initialise one serial port.

  3. Detect the machine type.

  4. Setup the kernel tagged list.

  5. Load initramfs.

  6. Call the kernel image.

1. Setup and initialise RAM #

  • Existing boot loaders:

    MANDATORY

  • New boot loaders:

    MANDATORY

The boot loader is expected to find and initialise all RAM that the kernel will use for volatile data storage in the system. It performs this in a machine dependent manner. (It may use internal algorithms to automatically locate and size all RAM, or it may use knowledge of the RAM in the machine, or any other method the boot loader designer sees fit.)

2. Initialise one serial port #

  • Existing boot loaders:

    OPTIONAL, RECOMMENDED

  • New boot loaders:

    OPTIONAL, RECOMMENDED

The boot loader should initialise and enable one serial port on the target. This allows the kernel serial driver to automatically detect which serial port it should use for the kernel console (generally used for debugging purposes, or communication with the target.)

As an alternative, the boot loader can pass the relevant 'console=' option to the kernel via the tagged lists specifying the port, and serial format options as described in

Documentation/admin-guide/kernel-parameters.rst.

3. Detect the machine type #

  • Existing boot loaders:

    OPTIONAL

  • New boot loaders:

    MANDATORY except for DT-only platforms

The boot loader should detect the machine type its running on by some method. Whether this is a hard coded value or some algorithm that looks at the connected hardware is beyond the scope of this document. The boot loader must ultimately be able to provide a MACH_TYPE_xxx value to the kernel. (see linux/arch/arm/tools/mach-types). This should be passed to the kernel in register r1.

For DT-only platforms, the machine type will be determined by device tree. set the machine type to all ones (~0). This is not strictly necessary, but assures that it will not match any existing types.

4. Setup boot data #

  • Existing boot loaders:

    OPTIONAL, HIGHLY RECOMMENDED

  • New boot loaders:

    MANDATORY

The boot loader must provide either a tagged list or a dtb image for passing configuration data to the kernel. The physical address of the boot data is passed to the kernel in register r2.

4a. Setup the kernel tagged list #

The boot loader must create and initialise the kernel tagged list. A valid tagged list starts with ATAG_CORE and ends with ATAG_NONE. The ATAG_CORE tag may or may not be empty. An empty ATAG_CORE tag has the size field set to '2' (0x00000002). The ATAG_NONE must set the size field to zero.

Any number of tags can be placed in the list. It is undefined whether a repeated tag appends to the information carried by the previous tag, or whether it replaces the information in its entirety; some tags behave as the former, others the latter.

The boot loader must pass at a minimum the size and location of the system memory, and root filesystem location. Therefore, the minimum tagged list should look:

              +-----------+
base ->       | ATAG_CORE |  |
              +-----------+  |
              | ATAG_MEM  |  | increasing address
              +-----------+  |
              | ATAG_NONE |  |
              +-----------+  v

The tagged list should be stored in system RAM.

The tagged list must be placed in a region of memory where neither the kernel decompressor nor initrd 'bootp' program will overwrite it. The recommended placement is in the first 16KiB of RAM.

4b. Setup the device tree #

The boot loader must load a device tree image (dtb) into system ram at a 64bit aligned address and initialize it with the boot data. The dtb format is documented at https://www.devicetree.org/specifications/. The kernel will look for the dtb magic value of 0xd00dfeed at the dtb physical address to determine if a dtb has been passed instead of a tagged list.

The boot loader must pass at a minimum the size and location of the system memory, and the root filesystem location. The dtb must be placed in a region of memory where the kernel decompressor will not overwrite it, while remaining within the region which will be covered by the kernel's low-memory mapping.

A safe location is just above the 128MiB boundary from start of RAM.

5. Load initramfs. #

  • Existing boot loaders:

    OPTIONAL

  • New boot loaders:

    OPTIONAL

If an initramfs is in use then, as with the dtb, it must be placed in a region of memory where the kernel decompressor will not overwrite it while also with the region which will be covered by the kernel's low-memory mapping.

A safe location is just above the device tree blob which itself will be loaded just above the 128MiB boundary from the start of RAM as recommended above.

6. Calling the kernel image #

  • Existing boot loaders:

    MANDATORY

  • New boot loaders:

    MANDATORY

There are two options for calling the kernel zImage. If the zImage is stored in flash, and is linked correctly to be run from flash, then it is legal for the boot loader to call the zImage in flash directly.

The zImage may also be placed in system RAM and called there. The kernel should be placed in the first 128MiB of RAM. It is recommended that it is loaded above 32MiB in order to avoid the need to relocate prior to decompression, which will make the boot process slightly faster.

When booting a raw (non-zImage) kernel the constraints are tighter. In this case the kernel must be loaded at an offset into system equal to TEXT_OFFSET - PAGE_OFFSET.

In any case, the following conditions must be met:

  • Quiesce all DMA capable devices so that memory does not get corrupted by bogus network packets or disk data. This will save you many hours of debug.

  • CPU register settings

    • r0 = 0,

    • r1 = machine type number discovered in (3) above.

    • r2 = physical address of tagged list in system RAM, or physical address of device tree block (dtb) in system RAM

  • CPU mode

    All forms of interrupts must be disabled (IRQs and FIQs)

    For CPUs which do not include the ARM virtualization extensions, the CPU must be in SVC mode. (A special exception exists for Angel)

    CPUs which include support for the virtualization extensions can be entered in HYP mode in order to enable the kernel to make full use of these extensions. This is the recommended boot method for such CPUs, unless the virtualisations are already in use by a pre-installed hypervisor.

    If the kernel is not entered in HYP mode for any reason, it must be entered in SVC mode.

  • Caches, MMUs

    The MMU must be off.

    Instruction cache may be on or off.

    Data cache must be off.

    If the kernel is entered in HYP mode, the above requirements apply to the HYP mode configuration in addition to the ordinary PL1 (privileged kernel modes) configuration. In addition, all traps into the hypervisor must be disabled, and PL1 access must be granted for all peripherals and CPU resources for which this is architecturally possible. Except for entering in HYP mode, the system configuration should be such that a kernel which does not include support for the virtualization extensions can boot correctly without extra help.

  • The boot loader is expected to call the kernel image by jumping directly to the first instruction of the kernel image.

    On CPUs supporting the ARM instruction set, the entry must be made in ARM state, even for a Thumb-2 kernel.

    On CPUs supporting only the Thumb instruction set such as Cortex-M class CPUs, the entry must be made in Thumb state.

Cluster-wide Power-up/power-down race avoidance algorithm

Peios Kernel / Hardware and drivers / Processor architectures / Arm

This file documents the algorithm which is used to coordinate CPU and cluster setup and teardown operations and to manage hardware coherency controls safely.

The section "Rationale" explains what the algorithm is for and why it is needed. "Basic model" explains general concepts using a simplified view of the system. The other sections explain the actual details of the algorithm in use.

Rationale #

In a system containing multiple CPUs, it is desirable to have the ability to turn off individual CPUs when the system is idle, reducing power consumption and thermal dissipation.

In a system containing multiple clusters of CPUs, it is also desirable to have the ability to turn off entire clusters.

Turning entire clusters off and on is a risky business, because it involves performing potentially destructive operations affecting a group of independently running CPUs, while the OS continues to run. This means that we need some coordination in order to ensure that critical cluster-level operations are only performed when it is truly safe to do so.

Simple locking may not be sufficient to solve this problem, because mechanisms like Linux spinlocks may rely on coherency mechanisms which are not immediately enabled when a cluster powers up. Since enabling or disabling those mechanisms may itself be a non-atomic operation (such as writing some hardware registers and invalidating large caches), other methods of coordination are required in order to guarantee safe power-down and power-up at the cluster level.

The mechanism presented in this document describes a coherent memory based protocol for performing the needed coordination. It aims to be as lightweight as possible, while providing the required safety properties.

Basic model #

Each cluster and CPU is assigned a state, as follows:

  • DOWN

  • COMING_UP

  • UP

  • GOING_DOWN

    +---------> UP ----------+
    |                        v

COMING_UP                GOING_DOWN

    ^                        |
    +--------- DOWN <--------+
  • DOWN:

    The CPU or cluster is not coherent, and is either powered off or suspended, or is ready to be powered off or suspended.

  • COMING_UP:

    The CPU or cluster has committed to moving to the UP state. It may be part way through the process of initialisation and enabling coherency.

  • UP:

    The CPU or cluster is active and coherent at the hardware level. A CPU in this state is not necessarily being used actively by the kernel.

  • GOING_DOWN:

    The CPU or cluster has committed to moving to the DOWN state. It may be part way through the process of teardown and coherency exit.

Each CPU has one of these states assigned to it at any point in time. The CPU states are described in the "CPU state" section, below.

Each cluster is also assigned a state, but it is necessary to split the state value into two parts (the "cluster" state and "inbound" state) and to introduce additional states in order to avoid races between different CPUs in the cluster simultaneously modifying the state. The cluster- level states are described in the "Cluster state" section.

To help distinguish the CPU states from cluster states in this discussion, the state names are given a CPU_ prefix for the CPU states, and a CLUSTER_ or INBOUND_ prefix for the cluster states.

CPU state #

In this algorithm, each individual core in a multi-core processor is referred to as a "CPU". CPUs are assumed to be single-threaded: therefore, a CPU can only be doing one thing at a single point in time.

This means that CPUs fit the basic model closely.

The algorithm defines the following states for each CPU in the system:

  • CPU_DOWN

  • CPU_COMING_UP

  • CPU_UP

  • CPU_GOING_DOWN

 cluster setup and
CPU setup complete          policy decision
      +-----------> CPU_UP ------------+
      |                                v

CPU_COMING_UP                   CPU_GOING_DOWN

      ^                                |
      +----------- CPU_DOWN <----------+
 policy decision           CPU teardown complete
or hardware event

The definitions of the four states correspond closely to the states of the basic model.

Transitions between states occur as follows.

A trigger event (spontaneous) means that the CPU can transition to the next state as a result of making local progress only, with no requirement for any external event to happen.

  • CPU_DOWN:

    A CPU reaches the CPU_DOWN state when it is ready for power-down. On reaching this state, the CPU will typically power itself down or suspend itself, via a WFI instruction or a firmware call.

    • Next state:

      CPU_COMING_UP

    • Conditions:

      none

    • Trigger events:

      • a) an explicit hardware power-up operation, resulting from a policy decision on another CPU;

      • b) a hardware event, such as an interrupt.

  • CPU_COMING_UP:

    A CPU cannot start participating in hardware coherency until the cluster is set up and coherent. If the cluster is not ready, then the CPU will wait in the CPU_COMING_UP state until the cluster has been set up.

    • Next state:

      CPU_UP

    • Conditions:

      The CPU's parent cluster must be in CLUSTER_UP.

    • Trigger events:

      Transition of the parent cluster to CLUSTER_UP.

    Refer to the "Cluster state" section for a description of the CLUSTER_UP state.

  • CPU_UP:

    When a CPU reaches the CPU_UP state, it is safe for the CPU to start participating in local coherency.

    This is done by jumping to the kernel's CPU resume code.

    Note that the definition of this state is slightly different from the basic model definition: CPU_UP does not mean that the CPU is coherent yet, but it does mean that it is safe to resume the kernel. The kernel handles the rest of the resume procedure, so the remaining steps are not visible as part of the race avoidance algorithm.

    The CPU remains in this state until an explicit policy decision is made to shut down or suspend the CPU.

    • Next state:

      CPU_GOING_DOWN

    • Conditions:

      none

    • Trigger events:

      explicit policy decision

  • CPU_GOING_DOWN:

    While in this state, the CPU exits coherency, including any operations required to achieve this (such as cleaning data caches).

    • Next state:

      CPU_DOWN

    • Conditions:

      local CPU teardown complete

    • Trigger events:

      (spontaneous)

Cluster state #

A cluster is a group of connected CPUs with some common resources. Because a cluster contains multiple CPUs, it can be doing multiple things at the same time. This has some implications. In particular, a CPU can start up while another CPU is tearing the cluster down.

In this discussion, the "outbound side" is the view of the cluster state as seen by a CPU tearing the cluster down. The "inbound side" is the view of the cluster state as seen by a CPU setting the CPU up.

In order to enable safe coordination in such situations, it is important that a CPU which is setting up the cluster can advertise its state independently of the CPU which is tearing down the cluster. For this reason, the cluster state is split into two parts:

"cluster" state: The global state of the cluster; or the state on the outbound side:

  • CLUSTER_DOWN

  • CLUSTER_UP

  • CLUSTER_GOING_DOWN

"inbound" state: The state of the cluster on the inbound side.

  • INBOUND_NOT_COMING_UP

  • INBOUND_COMING_UP

The different pairings of these states results in six possible states for the cluster as a whole:

                          CLUSTER_UP
        +==========> INBOUND_NOT_COMING_UP -------------+
        #                                               |
                                                        |
   CLUSTER_UP     <----+                                |
INBOUND_COMING_UP      |                                v

        ^             CLUSTER_GOING_DOWN       CLUSTER_GOING_DOWN
        #              INBOUND_COMING_UP <=== INBOUND_NOT_COMING_UP

  CLUSTER_DOWN         |                                |
INBOUND_COMING_UP <----+                                |
                                                        |
        ^                                               |
        +===========     CLUSTER_DOWN      <------------+
                     INBOUND_NOT_COMING_UP

Transitions -----> can only be made by the outbound CPU, and only involve changes to the "cluster" state.

Transitions ===##> can only be made by the inbound CPU, and only involve changes to the "inbound" state, except where there is no further transition possible on the outbound side (i.e., the outbound CPU has put the cluster into the CLUSTER_DOWN state).

The race avoidance algorithm does not provide a way to determine which exact CPUs within the cluster play these roles. This must be decided in advance by some other means. Refer to the section "Last man and first man selection" for more explanation.

CLUSTER_DOWN/INBOUND_NOT_COMING_UP is the only state where the cluster can actually be powered down.

The parallelism of the inbound and outbound CPUs is observed by the existence of two different paths from CLUSTER_GOING_DOWN/ INBOUND_NOT_COMING_UP (corresponding to GOING_DOWN in the basic model) to CLUSTER_DOWN/INBOUND_COMING_UP (corresponding to COMING_UP in the basic model). The second path avoids cluster teardown completely.

CLUSTER_UP/INBOUND_COMING_UP is equivalent to UP in the basic model. The final transition to CLUSTER_UP/INBOUND_NOT_COMING_UP is trivial and merely resets the state machine ready for the next cycle.

Details of the allowable transitions follow.

The next state in each case is notated

<cluster state>/<inbound state> (<transitioner>)

where the <transitioner> is the side on which the transition can occur; either the inbound or the outbound side.

  • CLUSTER_DOWN/INBOUND_NOT_COMING_UP:

    • Next state:

      CLUSTER_DOWN/INBOUND_COMING_UP (inbound)

    • Conditions:

      none

    • Trigger events:

      • a) an explicit hardware power-up operation, resulting from a policy decision on another CPU;

      • b) a hardware event, such as an interrupt.

CLUSTER_DOWN/INBOUND_COMING_UP:

In this state, an inbound CPU sets up the cluster, including enabling of hardware coherency at the cluster level and any other operations (such as cache invalidation) which are required in order to achieve this.

The purpose of this state is to do sufficient cluster-level setup to enable other CPUs in the cluster to enter coherency safely.

  • Next state:

    CLUSTER_UP/INBOUND_COMING_UP (inbound)

  • Conditions:

    cluster-level setup and hardware coherency complete

  • Trigger events:

    (spontaneous)

CLUSTER_UP/INBOUND_COMING_UP:

Cluster-level setup is complete and hardware coherency is enabled for the cluster. Other CPUs in the cluster can safely enter coherency.

This is a transient state, leading immediately to CLUSTER_UP/INBOUND_NOT_COMING_UP. All other CPUs on the cluster should consider treat these two states as equivalent.

  • Next state:

    CLUSTER_UP/INBOUND_NOT_COMING_UP (inbound)

  • Conditions:

    none

  • Trigger events:

    (spontaneous)

CLUSTER_UP/INBOUND_NOT_COMING_UP:

Cluster-level setup is complete and hardware coherency is enabled for the cluster. Other CPUs in the cluster can safely enter coherency.

The cluster will remain in this state until a policy decision is made to power the cluster down.

  • Next state:

    CLUSTER_GOING_DOWN/INBOUND_NOT_COMING_UP (outbound)

  • Conditions:

    none

  • Trigger events:

    policy decision to power down the cluster

CLUSTER_GOING_DOWN/INBOUND_NOT_COMING_UP:

An outbound CPU is tearing the cluster down. The selected CPU must wait in this state until all CPUs in the cluster are in the CPU_DOWN state.

When all CPUs are in the CPU_DOWN state, the cluster can be torn down, for example by cleaning data caches and exiting cluster-level coherency.

To avoid wasteful unnecessary teardown operations, the outbound should check the inbound cluster state for asynchronous transitions to INBOUND_COMING_UP. Alternatively, individual CPUs can be checked for entry into CPU_COMING_UP or CPU_UP.

Next states:

  • CLUSTER_DOWN/INBOUND_NOT_COMING_UP (outbound)

    • Conditions:

      cluster torn down and ready to power off

    • Trigger events:

      (spontaneous)

  • CLUSTER_GOING_DOWN/INBOUND_COMING_UP (inbound)

    • Conditions:

      none

    • Trigger events:

      • a) an explicit hardware power-up operation, resulting from a policy decision on another CPU;

      • b) a hardware event, such as an interrupt.

CLUSTER_GOING_DOWN/INBOUND_COMING_UP:

The cluster is (or was) being torn down, but another CPU has come online in the meantime and is trying to set up the cluster again.

If the outbound CPU observes this state, it has two choices:

  • a) back out of teardown, restoring the cluster to the CLUSTER_UP state;

  • b) finish tearing the cluster down and put the cluster in the CLUSTER_DOWN state; the inbound CPU will set up the cluster again from there.

Choice (a) permits the removal of some latency by avoiding unnecessary teardown and setup operations in situations where the cluster is not really going to be powered down.

Next states:

  • CLUSTER_UP/INBOUND_COMING_UP (outbound)

    • Conditions:

      cluster-level setup and hardware coherency complete

    • Trigger events:

      (spontaneous)

  • CLUSTER_DOWN/INBOUND_COMING_UP (outbound)

    • Conditions:

      cluster torn down and ready to power off

    • Trigger events:

      (spontaneous)

Last man and First man selection #

The CPU which performs cluster tear-down operations on the outbound side is commonly referred to as the "last man".

The CPU which performs cluster setup on the inbound side is commonly referred to as the "first man".

The race avoidance algorithm documented above does not provide a mechanism to choose which CPUs should play these roles.

Last man:

When shutting down the cluster, all the CPUs involved are initially executing Linux and hence coherent. Therefore, ordinary spinlocks can be used to select a last man safely, before the CPUs become non-coherent.

First man:

Because CPUs may power up asynchronously in response to external wake-up events, a dynamic mechanism is needed to make sure that only one CPU attempts to play the first man role and do the cluster-level initialisation: any other CPUs must wait for this to complete before proceeding.

Cluster-level initialisation may involve actions such as configuring coherency controls in the bus fabric.

The current implementation in mcpm_head.S uses a separate mutual exclusion mechanism to do this arbitration. This mechanism is documented in detail in vlocks.txt.

Features and Limitations #

Implementation:

The current ARM-based implementation is split between arch/arm/common/mcpm_head.S (low-level inbound CPU operations) and arch/arm/common/mcpm_entry.c (everything else):

__mcpm_cpu_going_down() signals the transition of a CPU to the CPU_GOING_DOWN state.

__mcpm_cpu_down() signals the transition of a CPU to the CPU_DOWN state.

A CPU transitions to CPU_COMING_UP and then to CPU_UP via the low-level power-up code in mcpm_head.S. This could involve CPU-specific setup code, but in the current implementation it does not.

__mcpm_outbound_enter_critical() and __mcpm_outbound_leave_critical() handle transitions from CLUSTER_UP to CLUSTER_GOING_DOWN and from there to CLUSTER_DOWN or back to CLUSTER_UP (in the case of an aborted cluster power-down).

These functions are more complex than the __mcpm_cpu_*() functions due to the extra inter-CPU coordination which is needed for safe transitions at the cluster level.

A cluster transitions from CLUSTER_DOWN back to CLUSTER_UP via the low-level power-up code in mcpm_head.S. This typically involves platform-specific setup code, provided by the platform-specific power_up_setup function registered via mcpm_sync_init.

Deep topologies:

As currently described and implemented, the algorithm does not support CPU topologies involving more than two levels (i.e., clusters of clusters are not supported). The algorithm could be extended by replicating the cluster-level states for the additional topological levels, and modifying the transition rules for the intermediate (non-outermost) cluster levels.

Colophon #

Originally created and documented by Dave Martin for Linaro Limited, in collaboration with Nicolas Pitre and Achin Gupta.

Copyright (C) 2012-2013 Linaro Limited Distributed under the terms of Version 2 of the GNU General Public License, as defined in linux/COPYING.

Feature status on arm architecture

Peios Kernel / Hardware and drivers / Processor architectures / Arm

SubsystemFeatureKconfigStatusDescription
corecBPF-JITHAVE_CBPF_JITTODOarch supports cBPF JIT optimizations
coreeBPF-JITHAVE_EBPF_JITokarch supports eBPF JIT optimizations
coregeneric-idle-threadGENERIC_SMP_IDLE_THREADokarch makes use of the generic SMP idle thread facility
corejump-labelsHAVE_ARCH_JUMP_LABELokarch supports live patched, high efficiency branches
coremseal-system-mappingsARCH_SUPPORTS_MSEAL_SYSTEM_MAPPINGSN/Aarch supports mseal system mappings
corethread-info-in-taskTHREAD_INFO_IN_TASKokarch makes use of the core kernel facility to embed thread_info in task_struct
coretracehookHAVE_ARCH_TRACEHOOKokarch supports tracehook (ptrace) register handling APIs
debugdebug-vm-pgtableARCH_HAS_DEBUG_VM_PGTABLETODOarch supports pgtable tests for semantics compliance
debuggcov-profile-allARCH_HAS_GCOV_PROFILE_ALLokarch supports whole-kernel GCOV code coverage profiling
debugKASANHAVE_ARCH_KASANokarch supports the KASAN runtime memory checker
debugkcovARCH_HAS_KCOVokarch supports kcov for coverage-guided fuzzing
debugkgdbHAVE_ARCH_KGDBokarch supports the kGDB kernel debugger
debugkmemleakHAVE_DEBUG_KMEMLEAKokarch supports the kernel memory leak detector
debugkprobesHAVE_KPROBESokarch supports live patched kernel probe
debugkprobes-on-ftraceHAVE_KPROBES_ON_FTRACETODOarch supports combined kprobes and ftrace live patching
debugkretprobesHAVE_KRETPROBESokarch supports kernel function-return probes
debugoptprobesHAVE_OPTPROBESokarch supports live patched optprobes
debugstackprotectorHAVE_STACKPROTECTORokarch supports compiler driven stack overflow protection
debuguprobesARCH_SUPPORTS_UPROBESokarch supports live patched user probes
debuguser-ret-profilerHAVE_USER_RETURN_NOTIFIERTODOarch supports user-space return from system call profiler
iodma-contiguousHAVE_DMA_CONTIGUOUSokarch supports the DMA CMA (continuous memory allocator)
lockingcmpxchg-localHAVE_CMPXCHG_LOCALTODOarch supports the this_cpu_cmpxchg() API
lockinglockdepLOCKDEP_SUPPORTokarch supports the runtime locking correctness debug facility
lockingqueued-rwlocksARCH_USE_QUEUED_RWLOCKSTODOarch supports queued rwlocks
lockingqueued-spinlocksARCH_USE_QUEUED_SPINLOCKSTODOarch supports queued spinlocks
perfkprobes-eventHAVE_REGS_AND_STACK_ACCESS_APIokarch supports kprobes with perf events
perfperf-regsHAVE_PERF_REGSokarch supports perf events register access
perfperf-stackdumpHAVE_PERF_USER_STACK_DUMPokarch supports perf events stack dumps
schedmembarrier-sync-coreARCH_HAS_MEMBARRIER_SYNC_COREokarch supports core serializing membarrier
schednuma-balancingARCH_SUPPORTS_NUMA_BALANCINGNot compatiblearch supports NUMA balancing
seccompseccomp-filterHAVE_ARCH_SECCOMP_FILTERokarch supports seccomp filters
timearch-tick-broadcastARCH_HAS_TICK_BROADCASTokarch provides tick_broadcast()
timeclockevents!LEGACY_TIMER_TICKTODOarch support generic clock events
timeirq-time-acctHAVE_IRQ_TIME_ACCOUNTINGokarch supports precise IRQ time accounting
timeuser-context-trackingHAVE_CONTEXT_TRACKING_USERokarch supports user context tracking for NO_HZ_FULL
timevirt-cpuacctHAVE_VIRT_CPU_ACCOUNTINGokarch supports precise virtual CPU time accounting
vmbatch-unmap-tlb-flushARCH_WANT_BATCHED_UNMAP_TLB_FLUSHTODOarch supports deferral of TLB flush until multiple pages are unmapped
vmELF-ASLRARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUTokarch randomizes the stack, heap and binary images of ELF binaries
vmhuge-vmapHAVE_ARCH_HUGE_VMAPTODOarch supports the arch_vmap_pud_supported() and arch_vmap_pmd_supported() VM APIs
vmioremap_protHAVE_IOREMAP_PROTTODOarch has ioremap_prot()
vmpte_specialARCH_HAS_PTE_SPECIALokarch supports the pte_special()/pte_mkspecial() VM APIs
vmTHPHAVE_ARCH_TRANSPARENT_HUGEPAGEokarch supports transparent hugepages

Interface for registering and calling firmware-specific operations for ARM

Peios Kernel / Hardware and drivers / Processor architectures / Arm

Written by Tomasz Figa <t.figa@samsung.com>

Some boards are running with secure firmware running in TrustZone secure world, which changes the way some things have to be initialized. This makes a need to provide an interface for such platforms to specify available firmware operations and call them when needed.

Firmware operations can be specified by filling in a struct firmware_ops with appropriate callbacks and then registering it with register_firmware_ops() function:

void register_firmware_ops(const struct firmware_ops *ops)

The ops pointer must be non-NULL. More information about struct firmware_ops and its members can be found in arch/arm/include/asm/firmware.h header.

There is a default, empty set of operations provided, so there is no need to set anything if platform does not require firmware operations.

To call a firmware operation, a helper macro is provided:

#define call_firmware_op(op, ...)                               \
        ((firmware_ops->op) ? firmware_ops->op(__VA_ARGS__) : (-ENOSYS))

the macro checks if the operation is provided and calls it or otherwise returns -ENOSYS to signal that given operation is not available (for example, to allow fallback to legacy operation).

Example of registering firmware operations:

/* board file */

static int platformX_do_idle(void)
{
        /* tell platformX firmware to enter idle */
        return 0;
}

static int platformX_cpu_boot(int i)
{
        /* tell platformX firmware to boot CPU i */
        return 0;
}

static const struct firmware_ops platformX_firmware_ops = {
        .do_idle        = exynos_do_idle,
        .cpu_boot       = exynos_cpu_boot,
        /* other operations not available on platformX */
};

/* init_early callback of machine descriptor */
static void __init board_init_early(void)
{
        register_firmware_ops(&platformX_firmware_ops);
}

Example of using a firmware operation:

/* some platform code, e.g. SMP initialization */

__raw_writel(__pa_symbol(exynos4_secondary_startup),
        CPU1_BOOT_REG);

/* Call Exynos specific smc call */
if (call_firmware_op(cpu_boot, cpu) == -ENOSYS)
        cpu_boot_legacy(...); /* Try legacy way */

gic_raise_softirq(cpumask_of(cpu), 1);

Interrupts

Peios Kernel / Hardware and drivers / Processor architectures / Arm

  • 2.5.2-rmk5:

    This is the first kernel that contains a major shake up of some of the major architecture-specific subsystems.

Firstly, it contains some pretty major changes to the way we handle the MMU TLB. Each MMU TLB variant is now handled completely separately - we have TLB v3, TLB v4 (without write buffer), TLB v4 (with write buffer), and finally TLB v4 (with write buffer, with I TLB invalidate entry). There is more assembly code inside each of these functions, mainly to allow more flexible TLB handling for the future.

Secondly, the IRQ subsystem.

The 2.5 kernels will be having major changes to the way IRQs are handled. Unfortunately, this means that machine types that touch the irq_desc[] array (basically all machine types) will break, and this means every machine type that we currently have.

Lets take an example. On the Assabet with Neponset, we have:

          GPIO25                 IRR:2
SA1100 ------------> Neponset -----------> SA1111
                                 IIR:1
                              -----------> USAR
                                 IIR:0
                              -----------> SMC9196

The way stuff currently works, all SA1111 interrupts are mutually exclusive of each other - if you're processing one interrupt from the SA1111 and another comes in, you have to wait for that interrupt to finish processing before you can service the new interrupt. Eg, an IDE PIO-based interrupt on the SA1111 excludes all other SA1111 and SMC9196 interrupts until it has finished transferring its multi-sector data, which can be a long time. Note also that since we loop in the SA1111 IRQ handler, SA1111 IRQs can hold off SMC9196 IRQs indefinitely.

The new approach brings several new ideas...

We introduce the concept of a "parent" and a "child". For example, to the Neponset handler, the "parent" is GPIO25, and the "children"d are SA1111, SMC9196 and USAR.

We also bring the idea of an IRQ "chip" (mainly to reduce the size of the irqdesc array). This doesn't have to be a real "IC"; indeed the SA11x0 IRQs are handled by two separate "chip" structures, one for GPIO0-10, and another for all the rest. It is just a container for the various operations (maybe this'll change to a better name). This structure has the following operations:

struct irqchip {
        /*
         * Acknowledge the IRQ.
         * If this is a level-based IRQ, then it is expected to mask the IRQ
         * as well.
         */
        void (*ack)(unsigned int irq);
        /*
         * Mask the IRQ in hardware.
         */
        void (*mask)(unsigned int irq);
        /*
         * Unmask the IRQ in hardware.
         */
        void (*unmask)(unsigned int irq);
        /*
         * Re-run the IRQ
         */
        void (*rerun)(unsigned int irq);
        /*
         * Set the type of the IRQ.
         */
        int (*type)(unsigned int irq, unsigned int, type);
};
  • ack

    • required. May be the same function as mask for IRQs handled by do_level_IRQ.
  • mask

    • required.
  • unmask

    • required.
  • rerun

    • optional. Not required if you're using do_level_IRQ for all IRQs that use this 'irqchip'. Generally expected to re-trigger the hardware IRQ if possible. If not, may call the handler directly.
  • type

    • optional. If you don't support changing the type of an IRQ, it should be null so people can detect if they are unable to set the IRQ type.

For each IRQ, we keep the following information:

  • "disable" depth (number of disable_irq()s without enable_irq()s)

  • flags indicating what we can do with this IRQ (valid, probe, noautounmask) as before

  • status of the IRQ (probing, enable, etc)

  • chip

  • per-IRQ handler

  • irqaction structure list

The handler can be one of the 3 standard handlers - "level", "edge" and "simple", or your own specific handler if you need to do something special.

The "level" handler is what we currently have - its pretty simple. "edge" knows about the brokenness of such IRQ implementations - that you need to leave the hardware IRQ enabled while processing it, and queueing further IRQ events should the IRQ happen again while processing. The "simple" handler is very basic, and does not perform any hardware manipulation, nor state tracking. This is useful for things like the SMC9196 and USAR above.

So, what's changed? #

  1. Machine implementations must not write to the irqdesc array.

  2. New functions to manipulate the irqdesc array. The first 4 are expected to be useful only to machine specific code. The last is recommended to only be used by machine specific code, but may be used in drivers if absolutely necessary.

    • set_irq_chip(irq,chip)

      Set the mask/unmask methods for handling this IRQ

    • set_irq_handler(irq,handler)

      Set the handler for this IRQ (level, edge, simple)

    • set_irq_chained_handler(irq,handler)

      Set a "chained" handler for this IRQ - automatically enables this IRQ (eg, Neponset and SA1111 handlers).

    • set_irq_flags(irq,flags)

      Set the valid/probe/noautoenable flags.

    • set_irq_type(irq,type)

      Set active the IRQ edge(s)/level. This replaces the SA1111 INTPOL manipulation, and the set_GPIO_IRQ_edge() function. Type should be one of IRQ_TYPE_xxx defined in <linux/irq.h>

  3. set_GPIO_IRQ_edge() is obsolete, and should be replaced by set_irq_type.

  4. Direct access to SA1111 INTPOL is deprecated. Use set_irq_type instead.

  5. A handler is expected to perform any necessary acknowledgement of the parent IRQ via the correct chip specific function. For instance, if the SA1111 is directly connected to a SA1110 GPIO, then you should acknowledge the SA1110 IRQ each time you re-read the SA1111 IRQ status.

  6. For any child which doesn't have its own IRQ enable/disable controls (eg, SMC9196), the handler must mask or acknowledge the parent IRQ while the child handler is called, and the child handler should be the "simple" handler (not "edge" nor "level"). After the handler completes, the parent IRQ should be unmasked, and the status of all children must be re-checked for pending events. (see the Neponset IRQ handler for details).

  7. fixup_irq() is gone, as is arch/arm/mach-*/include/mach/irq.h

Please note that this will not solve all problems - some of them are hardware based. Mixing level-based and edge-based IRQs on the same parent signal (eg neponset) is one such area where a software based solution can't provide the full answer to low IRQ latency.

Release Notes for Linux on Intel's IXP4xx Network Processor

Peios Kernel / Hardware and drivers / Processor architectures / Arm

Maintained by Deepak Saxena <dsaxena@plexity.net> #

  1. Overview

Intel's IXP4xx network processor is a highly integrated SOC that is targeted for network applications, though it has become popular in industrial control and other areas due to low cost and power consumption. The IXP4xx family currently consists of several processors that support different network offload functions such as encryption, routing, firewalling, etc. The IXP46x family is an updated version which supports faster speeds, new memory and flash configurations, and more integration such as an on-chip I2C controller.

For more information on the various versions of the CPU, see:

http://developer.intel.com/design/network/products/npfamily/ixp4xx.htm

Intel also made the IXCP1100 CPU for sometime which is an IXP4xx stripped of much of the network intelligence.

  1. Linux Support

Linux currently supports the following features on the IXP4xx chips:

  • Dual serial ports

  • PCI interface

  • Flash access (MTD/JFFS)

  • I2C through GPIO on IXP42x

  • GPIO for input/output/interrupts See arch/arm/mach-ixp4xx/include/mach/platform.h for access functions.

  • Timers (watchdog, OS)

The following components of the chips are not supported by Linux and require the use of Intel's proprietary CSR software:

  • USB device interface

  • Network interfaces (HSS, Utopia, NPEs, etc)

  • Network offload functionality

If you need to use any of the above, you need to download Intel's software from:

http://developer.intel.com/design/network/products/npfamily/ixp425.htm

DO NOT POST QUESTIONS TO THE LINUX MAILING LISTS REGARDING THE PROPRIETARY SOFTWARE.

There are several websites that provide directions/pointers on using Intel's software:

  • http://sourceforge.net/projects/ixp4xx-osdg/ Open Source Developer's Guide for using uClinux and the Intel libraries

  • http://gatewaymaker.sourceforge.net/ Simple one page summary of building a gateway using an IXP425 and Linux

  • http://ixp425.sourceforge.net/ ATM device driver for IXP425 that relies on Intel's libraries

  1. Known Issues/Limitations

3a. Limited inbound PCI window

The IXP4xx family allows for up to 256MB of memory but the PCI interface can only expose 64MB of that memory to the PCI bus. This means that if you are running with > 64MB, all PCI buffers outside of the accessible range will be bounced using the routines in arch/arm/common/dmabounce.c.

3b. Limited outbound PCI window

IXP4xx provides two methods of accessing PCI memory space:

  1. A direct mapped window from 0x48000000 to 0x4bffffff (64MB). To access PCI via this space, we simply ioremap() the BAR into the kernel and we can use the standard read[bwl]/write[bwl] macros. This is the preferred method due to speed but it limits the system to just 64MB of PCI memory. This can be problematic if using video cards and other memory-heavy devices.

  2. If > 64MB of memory space is required, the IXP4xx can be configured to use indirect registers to access PCI This allows for up to 128MB (0x48000000 to 0x4fffffff) of memory on the bus. The disadvantage of this is that every PCI access requires three local register accesses plus a spinlock, but in some cases the performance hit is acceptable. In addition, you cannot mmap() PCI devices in this case due to the indirect nature of the PCI window.

By default, the direct method is used for performance reasons. If you need more PCI memory, enable the IXP4XX_INDIRECT_PCI config option.

3c. GPIO as Interrupts

Currently the code only handles level-sensitive GPIO interrupts

  1. Supported platforms

ADI Engineering Coyote Gateway Reference Platform http://www.adiengineering.com/productsCoyote.html

The ADI Coyote platform is reference design for those building small residential/office gateways. One NPE is connected to a 10/100 interface, one to 4-port 10/100 switch, and the third to and ADSL interface. In addition, it also supports to POTs interfaces connected via SLICs. Note that those are not supported by Linux ATM. Finally, the platform has two mini-PCI slots used for 802.11[bga] cards. Finally, there is an IDE port hanging off the expansion bus.

Gateworks Avila Network Platform http://www.gateworks.com/support/overview.php

The Avila platform is basically and IXDP425 with the 4 PCI slots replaced with mini-PCI slots and a CF IDE interface hanging off the expansion bus.

Intel IXDP425 Development Platform http://www.intel.com/design/network/products/npfamily/ixdpg425.htm

This is Intel's standard reference platform for the IXDP425 and is also known as the Richfield board. It contains 4 PCI slots, 16MB of flash, two 10/100 ports and one ADSL port.

Intel IXDP465 Development Platform http://www.intel.com/design/network/products/npfamily/ixdp465.htm

This is basically an IXDP425 with an IXP465 and 32M of flash instead of just 16.

Intel IXDPG425 Development Platform

This is basically and ADI Coyote board with a NEC EHCI controller added. One issue with this board is that the mini-PCI slots only have the 3.3v line connected, so you can't use a PCI to mini-PCI adapter with an E100 card. So to NFS root you need to use either the CSR or a WiFi card and a ramdisk that BOOTPs and then does a pivot_root to NFS.

Motorola PrPMC1100 Processor Mezanine Card http://www.fountainsys.com

The PrPMC1100 is based on the IXCP1100 and is meant to plug into and IXP2400/2800 system to act as the system controller. It simply contains a CPU and 16MB of flash on the board and needs to be plugged into a carrier board to function. Currently Linux only supports the Motorola PrPMC carrier board for this platform.

  1. TODO LIST
  • Add support for Coyote IDE

  • Add support for edge-based GPIO interrupts

  • Add support for CF IDE on expansion bus

  1. Thanks

The IXP4xx work has been funded by Intel Corp. and MontaVista Software, Inc.

The following people have contributed patches/comments/etc:

  • Lennerty Buytenhek

  • Lutz Jaenicke

  • Justin Mayfield

  • Robert E. Ranslam

[I know I've forgotten others, please email me to be added]


Last Update: 01/04/2005

Kernel mode NEON

Peios Kernel / Hardware and drivers / Processor architectures / Arm

TL;DR summary #

  • Use only NEON instructions, or VFP instructions that don't rely on support code

  • Isolate your NEON code in a separate compilation unit, and compile it with '-march=armv7-a -mfpu=neon -mfloat-abi=softfp'

  • Put kernel_neon_begin() and kernel_neon_end() calls around the calls into your NEON code

  • Don't sleep in your NEON code, and be aware that it will be executed with preemption disabled

Introduction #

It is possible to use NEON instructions (and in some cases, VFP instructions) in code that runs in kernel mode. However, for performance reasons, the NEON/VFP register file is not preserved and restored at every context switch or taken exception like the normal register file is, so some manual intervention is required. Furthermore, special care is required for code that may sleep [i.e., may call schedule()], as NEON or VFP instructions will be executed in a non-preemptible section for reasons outlined below.

Lazy preserve and restore #

The NEON/VFP register file is managed using lazy preserve (on UP systems) and lazy restore (on both SMP and UP systems). This means that the register file is kept 'live', and is only preserved and restored when multiple tasks are contending for the NEON/VFP unit (or, in the SMP case, when a task migrates to another core). Lazy restore is implemented by disabling the NEON/VFP unit after every context switch, resulting in a trap when subsequently a NEON/VFP instruction is issued, allowing the kernel to step in and perform the restore if necessary.

Any use of the NEON/VFP unit in kernel mode should not interfere with this, so it is required to do an 'eager' preserve of the NEON/VFP register file, and enable the NEON/VFP unit explicitly so no exceptions are generated on first subsequent use. This is handled by the function kernel_neon_begin(), which should be called before any kernel mode NEON or VFP instructions are issued. Likewise, the NEON/VFP unit should be disabled again after use to make sure user mode will hit the lazy restore trap upon next use. This is handled by the function kernel_neon_end().

Interruptions in kernel mode #

For reasons of performance and simplicity, it was decided that there shall be no preserve/restore mechanism for the kernel mode NEON/VFP register contents. This implies that interruptions of a kernel mode NEON section can only be allowed if they are guaranteed not to touch the NEON/VFP registers. For this reason, the following rules and restrictions apply in the kernel: * NEON/VFP code is not allowed in interrupt context; * NEON/VFP code is not allowed to sleep; * NEON/VFP code is executed with preemption disabled.

If latency is a concern, it is possible to put back to back calls to kernel_neon_end() and kernel_neon_begin() in places in your code where none of the NEON registers are live. (Additional calls to kernel_neon_begin() should be reasonably cheap if no context switch occurred in the meantime)

VFP and support code #

Earlier versions of VFP (prior to version 3) rely on software support for things like IEEE-754 compliant underflow handling etc. When the VFP unit needs such software assistance, it signals the kernel by raising an undefined instruction exception. The kernel responds by inspecting the VFP control registers and the current instruction and arguments, and emulates the instruction in software.

Such software assistance is currently not implemented for VFP instructions executed in kernel mode. If such a condition is encountered, the kernel will fail and generate an OOPS.

Separating NEON code from ordinary code #

The compiler is not aware of the special significance of kernel_neon_begin() and kernel_neon_end(), i.e., that it is only allowed to issue NEON/VFP instructions between calls to these respective functions. Furthermore, GCC may generate NEON instructions of its own at -O3 level if -mfpu=neon is selected, and even if the kernel is currently compiled at -O2, future changes may result in NEON/VFP instructions appearing in unexpected places if no special care is taken.

Therefore, the recommended and only supported way of using NEON/VFP in the kernel is by adhering to the following rules:

  • isolate the NEON code in a separate compilation unit and compile it with '-march=armv7-a -mfpu=neon -mfloat-abi=softfp';

  • issue the calls to kernel_neon_begin(), kernel_neon_end() as well as the calls into the unit containing the NEON code from a compilation unit which is not built with the GCC flag '-mfpu=neon' set.

As the kernel is compiled with '-msoft-float', the above will guarantee that both NEON and VFP instructions will only ever appear in designated compilation units at any optimization level.

NEON assembler #

NEON assembler is supported with no additional caveats as long as the rules above are followed.

NEON code generated by GCC #

The GCC option -ftree-vectorize (implied by -O3) tries to exploit implicit parallelism, and generates NEON code from ordinary C source code. This is fully supported as long as the rules above are followed.

NEON intrinsics #

NEON intrinsics are also supported. However, as code using NEON intrinsics relies on the GCC header <arm_neon.h>, (which #includes <stdint.h>), you should observe the following in addition to the rules above:

  • Compile the unit containing the NEON intrinsics with '-ffreestanding' so GCC uses its builtin version of <stdint.h> (this is a C99 header which the kernel does not supply);

  • Include <arm_neon.h> last, or at least after <linux/types.h>

Kernel-provided User Helpers

Peios Kernel / Hardware and drivers / Processor architectures / Arm

These are segment of kernel provided user code reachable from user space at a fixed address in kernel memory. This is used to provide user space with some operations which require kernel help because of unimplemented native feature and/or instructions in many ARM CPUs. The idea is for this code to be executed directly in user mode for best efficiency but which is too intimate with the kernel counter part to be left to user libraries. In fact this code might even differ from one CPU to another depending on the available instruction set, or whether it is a SMP systems. In other words, the kernel reserves the right to change this code as needed without warning. Only the entry points and their results as documented here are guaranteed to be stable.

This is different from (but doesn't preclude) a full blown VDSO implementation, however a VDSO would prevent some assembly tricks with constants that allows for efficient branching to those code segments. And since those code segments only use a few cycles before returning to user code, the overhead of a VDSO indirect far call would add a measurable overhead to such minimalistic operations.

User space is expected to bypass those helpers and implement those things inline (either in the code emitted directly by the compiler, or part of the implementation of a library call) when optimizing for a recent enough processor that has the necessary native support, but only if resulting binaries are already to be incompatible with earlier ARM processors due to usage of similar native instructions for other things. In other words don't make binaries unable to run on earlier processors just for the sake of not using these kernel helpers if your compiled code is not going to use new instructions for other purpose.

New helpers may be added over time, so an older kernel may be missing some helpers present in a newer kernel. For this reason, programs must check the value of __kuser_helper_version (see below) before assuming that it is safe to call any particular helper. This check should ideally be performed only once at process startup time, and execution aborted early if the required helpers are not provided by the kernel version that process is running on.

kuser_helper_version #

Location: 0xffff0ffc

Reference declaration:

extern int32_t __kuser_helper_version;

Definition:

This field contains the number of helpers being implemented by the running kernel. User space may read this to determine the availability of a particular helper.

Usage example:

#define __kuser_helper_version (*(int32_t *)0xffff0ffc)

void check_kuser_version(void)
{
      if (__kuser_helper_version < 2) {
              fprintf(stderr, "can't do atomic operations, kernel too old\n");
              abort();
      }
}

Notes:

User space may assume that the value of this field never changes during the lifetime of any single process. This means that this field can be read once during the initialisation of a library or startup phase of a program.

kuser_get_tls #

Location: 0xffff0fe0

Reference prototype:

void * __kuser_get_tls(void);

Input:

lr = return address

Output:

r0 = TLS value

Clobbered registers:

none

Definition:

Get the TLS value as previously set via the __ARM_NR_set_tls syscall.

Usage example:

typedef void * (__kuser_get_tls_t)(void);
#define __kuser_get_tls (*(__kuser_get_tls_t *)0xffff0fe0)

void foo()
{
      void *tls = __kuser_get_tls();
      printf("TLS = %p\n", tls);
}

Notes:

  • Valid only if __kuser_helper_version >= 1 (from kernel version 2.6.12).

kuser_cmpxchg #

Location: 0xffff0fc0

Reference prototype:

int __kuser_cmpxchg(int32_t oldval, int32_t newval, volatile int32_t *ptr);

Input:

r0 = oldval r1 = newval r2 = ptr lr = return address

Output:

r0 = success code (zero or non-zero) C flag = set if r0 == 0, clear if r0 != 0

Clobbered registers:

r3, ip, flags

Definition:

Atomically store newval in *ptr only if *ptr is equal to oldval. Return zero if *ptr was changed or non-zero if no exchange happened. The C flag is also set if *ptr was changed to allow for assembly optimization in the calling code.

Usage example:

typedef int (__kuser_cmpxchg_t)(int oldval, int newval, volatile int *ptr);
#define __kuser_cmpxchg (*(__kuser_cmpxchg_t *)0xffff0fc0)

int atomic_add(volatile int *ptr, int val)
{
      int old, new;

      do {
              old = *ptr;
              new = old + val;
      } while(__kuser_cmpxchg(old, new, ptr));

      return new;
}

Notes:

  • This routine already includes memory barriers as needed.

  • Valid only if __kuser_helper_version >= 2 (from kernel version 2.6.12).

kuser_memory_barrier #

Location: 0xffff0fa0

Reference prototype:

void __kuser_memory_barrier(void);

Input:

lr = return address

Output:

none

Clobbered registers:

none

Definition:

Apply any needed memory barrier to preserve consistency with data modified manually and __kuser_cmpxchg usage.

Usage example:

typedef void (__kuser_dmb_t)(void);
#define __kuser_dmb (*(__kuser_dmb_t *)0xffff0fa0)

Notes:

  • Valid only if __kuser_helper_version >= 3 (from kernel version 2.6.15).

kuser_cmpxchg64 #

Location: 0xffff0f60

Reference prototype:

int __kuser_cmpxchg64(const int64_t *oldval,
                      const int64_t *newval,
                      volatile int64_t *ptr);

Input:

r0 = pointer to oldval r1 = pointer to newval r2 = pointer to target value lr = return address

Output:

r0 = success code (zero or non-zero) C flag = set if r0 == 0, clear if r0 != 0

Clobbered registers:

r3, lr, flags

Definition:

Atomically store the 64-bit value pointed by *newval in *ptr only if *ptr is equal to the 64-bit value pointed by *oldval. Return zero if *ptr was changed or non-zero if no exchange happened.

The C flag is also set if *ptr was changed to allow for assembly optimization in the calling code.

Usage example:

typedef int (__kuser_cmpxchg64_t)(const int64_t *oldval,
                                  const int64_t *newval,
                                  volatile int64_t *ptr);
#define __kuser_cmpxchg64 (*(__kuser_cmpxchg64_t *)0xffff0f60)

int64_t atomic_add64(volatile int64_t *ptr, int64_t val)
{
      int64_t old, new;

      do {
              old = *ptr;
              new = old + val;
      } while(__kuser_cmpxchg64(&old, &new, ptr));

      return new;
}

Notes:

  • This routine already includes memory barriers as needed.

  • Due to the length of this sequence, this spans 2 conventional kuser "slots", therefore 0xffff0f80 is not used as a valid entry point.

  • Valid only if __kuser_helper_version >= 5 (from kernel version 3.1).

ARM Marvell SoCs

Peios Kernel / Hardware and drivers / Processor architectures / Arm

This document lists all the ARM Marvell SoCs that are currently supported in mainline by the Linux kernel. As the Marvell families of SoCs are large and complex, it is hard to understand where the support for a particular SoC is available in the Linux kernel. This document tries to help in understanding where those SoCs are supported, and to match them with their corresponding public datasheet, when available.

Orion family #

  • Flavors:

    • 88F5082

    • 88F5181 a.k.a Orion-1

    • 88F5181L a.k.a Orion-VoIP

    • 88F5182 a.k.a Orion-NAS

      • Datasheet: https://web.archive.org/web/20210124231420/http://csclub.uwaterloo.ca/~board/ts7800/MV88F5182-datasheet.pdf

      • Programmer's User Guide: https://web.archive.org/web/20210124231536/http://csclub.uwaterloo.ca/~board/ts7800/MV88F5182-opensource-manual.pdf

      • User Manual: https://web.archive.org/web/20210124231631/http://csclub.uwaterloo.ca/~board/ts7800/MV88F5182-usermanual.pdf

      • Functional Errata: https://web.archive.org/web/20210704165540/https://www.digriz.org.uk/ts78xx/88F5182_Functional_Errata.pdf

    • 88F5281 a.k.a Orion-2

      • Datasheet: https://web.archive.org/web/20131028144728/http://www.ocmodshop.com/images/reviews/networking/qnap_ts409u/marvel_88f5281_data_sheet.pdf
    • 88F6183 a.k.a Orion-1-90

  • Homepage:

    https://web.archive.org/web/20080607215437/http://www.marvell.com/products/media/index.jsp

  • Core:

    Feroceon 88fr331 (88f51xx) or 88fr531-vd (88f52xx) ARMv5 compatible

  • Linux kernel mach directory:

    arch/arm/mach-orion5x

  • Linux kernel plat directory:

    arch/arm/plat-orion

Kirkwood family #

  • Flavors:

    • 88F6282 a.k.a Armada 300

      • Product Brief : https://web.archive.org/web/20111027032509/http://www.marvell.com/embedded-processors/armada-300/assets/armada_310.pdf
    • 88F6283 a.k.a Armada 310

      • Product Brief : https://web.archive.org/web/20111027032509/http://www.marvell.com/embedded-processors/armada-300/assets/armada_310.pdf
    • 88F6190

      • Product Brief : https://web.archive.org/web/20130730072715/http://www.marvell.com/embedded-processors/kirkwood/assets/88F6190-003_WEB.pdf

      • Hardware Spec : https://web.archive.org/web/20121021182835/http://www.marvell.com/embedded-processors/kirkwood/assets/HW_88F619x_OpenSource.pdf

      • Functional Spec: https://web.archive.org/web/20130730091033/http://www.marvell.com/embedded-processors/kirkwood/assets/FS_88F6180_9x_6281_OpenSource.pdf

    • 88F6192

      • Product Brief : https://web.archive.org/web/20131113121446/http://www.marvell.com/embedded-processors/kirkwood/assets/88F6192-003_ver1.pdf

      • Hardware Spec : https://web.archive.org/web/20121021182835/http://www.marvell.com/embedded-processors/kirkwood/assets/HW_88F619x_OpenSource.pdf

      • Functional Spec: https://web.archive.org/web/20130730091033/http://www.marvell.com/embedded-processors/kirkwood/assets/FS_88F6180_9x_6281_OpenSource.pdf

    • 88F6182

    • 88F6180

      • Product Brief : https://web.archive.org/web/20120616201621/http://www.marvell.com/embedded-processors/kirkwood/assets/88F6180-003_ver1.pdf

      • Hardware Spec : https://web.archive.org/web/20130730091654/http://www.marvell.com/embedded-processors/kirkwood/assets/HW_88F6180_OpenSource.pdf

      • Functional Spec: https://web.archive.org/web/20130730091033/http://www.marvell.com/embedded-processors/kirkwood/assets/FS_88F6180_9x_6281_OpenSource.pdf

    • 88F6280

      • Product Brief : https://web.archive.org/web/20130730091058/http://www.marvell.com/embedded-processors/kirkwood/assets/88F6280_SoC_PB-001.pdf
    • 88F6281

      • Product Brief : https://web.archive.org/web/20120131133709/http://www.marvell.com/embedded-processors/kirkwood/assets/88F6281-004_ver1.pdf

      • Hardware Spec : https://web.archive.org/web/20120620073511/http://www.marvell.com/embedded-processors/kirkwood/assets/HW_88F6281_OpenSource.pdf

      • Functional Spec: https://web.archive.org/web/20130730091033/http://www.marvell.com/embedded-processors/kirkwood/assets/FS_88F6180_9x_6281_OpenSource.pdf

    • 88F6321

    • 88F6322

    • 88F6323

      • Product Brief : https://web.archive.org/web/20120616201639/http://www.marvell.com/embedded-processors/kirkwood/assets/88f632x_pb.pdf
  • Homepage:

    https://web.archive.org/web/20160513194943/http://www.marvell.com/embedded-processors/kirkwood/

  • Core:

    Feroceon 88fr131 ARMv5 compatible

  • Linux kernel mach directory:

    arch/arm/mach-mvebu

  • Linux kernel plat directory:

    none

Discovery family #

  • Flavors:

    • MV78100

      • Product Brief : https://web.archive.org/web/20120616194711/http://www.marvell.com/embedded-processors/discovery-innovation/assets/MV78100-003_WEB.pdf

      • Hardware Spec : https://web.archive.org/web/20141005120451/http://www.marvell.com/embedded-processors/discovery-innovation/assets/HW_MV78100_OpenSource.pdf

      • Functional Spec: https://web.archive.org/web/20111110081125/http://www.marvell.com/embedded-processors/discovery-innovation/assets/FS_MV76100_78100_78200_OpenSource.pdf

    • MV78200

      • Product Brief : https://web.archive.org/web/20140801121623/http://www.marvell.com/embedded-processors/discovery-innovation/assets/MV78200-002_WEB.pdf

      • Hardware Spec : https://web.archive.org/web/20141005120458/http://www.marvell.com/embedded-processors/discovery-innovation/assets/HW_MV78200_OpenSource.pdf

      • Functional Spec: https://web.archive.org/web/20111110081125/http://www.marvell.com/embedded-processors/discovery-innovation/assets/FS_MV76100_78100_78200_OpenSource.pdf

    • MV76100

      • Product Brief : https://web.archive.org/web/20140722064429/http://www.marvell.com/embedded-processors/discovery-innovation/assets/MV76100-002_WEB.pdf

      • Hardware Spec : https://web.archive.org/web/20140722064425/http://www.marvell.com/embedded-processors/discovery-innovation/assets/HW_MV76100_OpenSource.pdf

      • Functional Spec: https://web.archive.org/web/20111110081125/http://www.marvell.com/embedded-processors/discovery-innovation/assets/FS_MV76100_78100_78200_OpenSource.pdf

      Not supported by the Linux kernel.

  • Homepage:

    https://web.archive.org/web/20110924171043/http://www.marvell.com/embedded-processors/discovery-innovation/

  • Core:

    Feroceon 88fr571-vd ARMv5 compatible

  • Linux kernel mach directory:

    arch/arm/mach-mv78xx0

  • Linux kernel plat directory:

    arch/arm/plat-orion

EBU Armada family #

  • Armada 370 Flavors:

    • 88F6710

    • 88F6707

    • 88F6W11

    • Product infos: https://web.archive.org/web/20141002083258/http://www.marvell.com/embedded-processors/armada-370/

    • Product Brief: https://web.archive.org/web/20121115063038/http://www.marvell.com/embedded-processors/armada-300/assets/Marvell_ARMADA_370_SoC.pdf

    • Hardware Spec: https://web.archive.org/web/20140617183747/http://www.marvell.com/embedded-processors/armada-300/assets/ARMADA370-datasheet.pdf

    • Functional Spec: https://web.archive.org/web/20140617183701/http://www.marvell.com/embedded-processors/armada-300/assets/ARMADA370-FunctionalSpec-datasheet.pdf

  • Core:

    Sheeva ARMv7 compatible PJ4B

  • Armada XP Flavors:

    • MV78230

    • MV78260

    • MV78460

    • NOTE:

      not to be confused with the non-SMP 78xx0 SoCs

    • Product infos: https://web.archive.org/web/20150101215721/http://www.marvell.com/embedded-processors/armada-xp/

    • Product Brief: https://web.archive.org/web/20121021173528/http://www.marvell.com/embedded-processors/armada-xp/assets/Marvell-ArmadaXP-SoC-product%20brief.pdf

    • Functional Spec: https://web.archive.org/web/20180829171131/http://www.marvell.com/embedded-processors/armada-xp/assets/ARMADA-XP-Functional-SpecDatasheet.pdf

      • Hardware Specs:

        • https://web.archive.org/web/20141127013651/http://www.marvell.com/embedded-processors/armada-xp/assets/HW_MV78230_OS.PDF

        • https://web.archive.org/web/20141222000224/http://www.marvell.com/embedded-processors/armada-xp/assets/HW_MV78260_OS.PDF

        • https://web.archive.org/web/20141222000230/http://www.marvell.com/embedded-processors/armada-xp/assets/HW_MV78460_OS.PDF

  • Core:

    Sheeva ARMv7 compatible Dual-core or Quad-core PJ4B-MP

  • Armada 375 Flavors:

    • 88F6720
    • Product infos: https://web.archive.org/web/20140108032402/http://www.marvell.com/embedded-processors/armada-375/

    • Product Brief: https://web.archive.org/web/20131216023516/http://www.marvell.com/embedded-processors/armada-300/assets/ARMADA_375_SoC-01_product_brief.pdf

  • Core:

    ARM Cortex-A9

  • Armada 38x Flavors:

    • 88F6810 Armada 380

    • 88F6811 Armada 381

    • 88F6821 Armada 382

    • 88F6W21 Armada 383

    • 88F6820 Armada 385

    • 88F6825

    • 88F6828 Armada 388

    • Product infos: https://web.archive.org/web/20181006144616/http://www.marvell.com/embedded-processors/armada-38x/

    • Functional Spec: https://web.archive.org/web/20200420191927/https://www.marvell.com/content/dam/marvell/en/public-collateral/embedded-processors/marvell-embedded-processors-armada-38x-functional-specifications-2015-11.pdf

    • Hardware Spec: https://web.archive.org/web/20180713105318/https://www.marvell.com/docs/embedded-processors/assets/marvell-embedded-processors-armada-38x-hardware-specifications-2017-03.pdf

    • Design guide: https://web.archive.org/web/20180712231737/https://www.marvell.com/docs/embedded-processors/assets/marvell-embedded-processors-armada-38x-hardware-design-guide-2017-08.pdf

  • Core:

    ARM Cortex-A9

  • Armada 39x Flavors:

    • 88F6920 Armada 390

    • 88F6925 Armada 395

    • 88F6928 Armada 398

    • Product infos: https://web.archive.org/web/20181020222559/http://www.marvell.com/embedded-processors/armada-39x/
  • Core:

    ARM Cortex-A9

  • Linux kernel mach directory:

    arch/arm/mach-mvebu

  • Linux kernel plat directory:

    none

EBU Armada family ARMv8 #

  • Armada 3710/3720 Flavors:

    • 88F3710

    • 88F3720

  • Core:

    ARM Cortex A53 (ARMv8)

  • Homepage:

    https://web.archive.org/web/20181103003602/http://www.marvell.com/embedded-processors/armada-3700/

  • Product Brief:

    https://web.archive.org/web/20210121194810/https://www.marvell.com/content/dam/marvell/en/public-collateral/embedded-processors/marvell-embedded-processors-armada-37xx-product-brief-2016-01.pdf

  • Hardware Spec:

    https://web.archive.org/web/20210202162011/http://www.marvell.com/content/dam/marvell/en/public-collateral/embedded-processors/marvell-embedded-processors-armada-37xx-hardware-specifications-2019-09.pdf

  • Device tree files:

    arch/arm64/boot/dts/marvell/armada-37*

  • Armada 7K Flavors:

    • 88F6040 (AP806 Quad 600 MHz + one CP110)

    • 88F7020 (AP806 Dual + one CP110)

    • 88F7040 (AP806 Quad + one CP110)

Core: ARM Cortex A72

  • Homepage:

    https://web.archive.org/web/20181020222606/http://www.marvell.com/embedded-processors/armada-70xx/

  • Product Brief:

    • https://web.archive.org/web/20161010105541/http://www.marvell.com/embedded-processors/assets/Armada7020PB-Jan2016.pdf

    • https://web.archive.org/web/20160928154533/http://www.marvell.com/embedded-processors/assets/Armada7040PB-Jan2016.pdf

  • Device tree files:

    arch/arm64/boot/dts/marvell/armada-70*

  • Armada 8K Flavors:

    • 88F8020 (AP806 Dual + two CP110)

    • 88F8040 (AP806 Quad + two CP110)

  • Core:

    ARM Cortex A72

  • Homepage:

    https://web.archive.org/web/20181022004830/http://www.marvell.com/embedded-processors/armada-80xx/

  • Product Brief:

    • https://web.archive.org/web/20210124233728/https://www.marvell.com/content/dam/marvell/en/public-collateral/embedded-processors/marvell-embedded-processors-armada-8020-product-brief-2017-12.pdf

    • https://web.archive.org/web/20161010105532/http://www.marvell.com/embedded-processors/assets/Armada8040PB-Jan2016.pdf

  • Device tree files:

    arch/arm64/boot/dts/marvell/armada-80*

  • Octeon TX2 CN913x Flavors:

    • CN9130 (AP807 Quad + one internal CP115)

    • CN9131 (AP807 Quad + one internal CP115 + one external CP115 / 88F8215)

    • CN9132 (AP807 Quad + one internal CP115 + two external CP115 / 88F8215)

  • Core:

    ARM Cortex A72

  • Homepage:

    https://web.archive.org/web/20200803150818/https://www.marvell.com/products/infrastructure-processors/multi-core-processors/octeon-tx2/octeon-tx2-cn9130.html

  • Product Brief:

    https://web.archive.org/web/20200803150818/https://www.marvell.com/content/dam/marvell/en/public-collateral/embedded-processors/marvell-infrastructure-processors-octeon-tx2-cn913x-product-brief-2020-02.pdf

  • Device tree files:

    arch/arm64/boot/dts/marvell/cn913*

Avanta family #

  • Flavors:

    • 88F6500

    • 88F6510

    • 88F6530P

    • 88F6550

    • 88F6560

    • 88F6601

  • Homepage:

    https://web.archive.org/web/20181005145041/http://www.marvell.com/broadband/

  • Product Brief:

    https://web.archive.org/web/20180829171057/http://www.marvell.com/broadband/assets/Marvell_Avanta_88F6510_305_060-001_product_brief.pdf

No public datasheet available.

  • Core:

    ARMv5 compatible

  • Linux kernel mach directory:

    no code in mainline yet, planned for the future

  • Linux kernel plat directory:

    no code in mainline yet, planned for the future

Storage family #

  • Armada SP:

    • 88RC1580
  • Product infos:

    https://web.archive.org/web/20191129073953/http://www.marvell.com/storage/armada-sp/

  • Core:

    Sheeva ARMv7 compatible Quad-core PJ4C

(not supported in upstream Linux kernel)

Dove family (application processor) #

  • Flavors:

    • 88AP510 a.k.a Armada 510
    • Product Brief:

      https://web.archive.org/web/20111102020643/http://www.marvell.com/application-processors/armada-500/assets/Marvell_Armada510_SoC.pdf

    • Hardware Spec:

      https://web.archive.org/web/20160428160231/http://www.marvell.com/application-processors/armada-500/assets/Armada-510-Hardware-Spec.pdf

  • Functional Spec:

    https://web.archive.org/web/20120130172443/http://www.marvell.com/application-processors/armada-500/assets/Armada-510-Functional-Spec.pdf

  • Homepage:

    https://web.archive.org/web/20160822232651/http://www.marvell.com/application-processors/armada-500/

  • Core:

    ARMv7 compatible

  • Directory:

    • arch/arm/mach-mvebu (DT enabled platforms)

    • arch/arm/mach-dove (non-DT enabled platforms)

PXA 2xx/3xx/93x/95x family #

  • Flavors:

      • PXA21x, PXA25x, PXA26x

        • Application processor only

        • Core: ARMv5 XScale1 core

      • PXA270, PXA271, PXA272

        • Product Brief : https://web.archive.org/web/20150927135510/http://www.marvell.com/application-processors/pxa-family/assets/pxa_27x_pb.pdf

        • Design guide : https://web.archive.org/web/20120111181937/http://www.marvell.com/application-processors/pxa-family/assets/pxa_27x_design_guide.pdf

        • Developers manual : https://web.archive.org/web/20150927164805/http://www.marvell.com/application-processors/pxa-family/assets/pxa_27x_dev_man.pdf

        • Specification : https://web.archive.org/web/20140211221535/http://www.marvell.com/application-processors/pxa-family/assets/pxa_27x_emts.pdf

        • Specification update : https://web.archive.org/web/20120111104906/http://www.marvell.com/application-processors/pxa-family/assets/pxa_27x_spec_update.pdf

        • Application processor only

        • Core: ARMv5 XScale2 core

      • PXA300, PXA310, PXA320

        • PXA 300 Product Brief : https://web.archive.org/web/20120111121203/http://www.marvell.com/application-processors/pxa-family/assets/PXA300_PB_R4.pdf

        • PXA 310 Product Brief : https://web.archive.org/web/20120111104515/http://www.marvell.com/application-processors/pxa-family/assets/PXA310_PB_R4.pdf

        • PXA 320 Product Brief : https://web.archive.org/web/20121021182826/http://www.marvell.com/application-processors/pxa-family/assets/PXA320_PB_R4.pdf

        • Design guide : https://web.archive.org/web/20130727144625/http://www.marvell.com/application-processors/pxa-family/assets/PXA3xx_Design_Guide.pdf

        • Developers manual : https://web.archive.org/web/20130727144605/http://www.marvell.com/application-processors/pxa-family/assets/PXA3xx_Developers_Manual.zip

        • Specifications : https://web.archive.org/web/20130727144559/http://www.marvell.com/application-processors/pxa-family/assets/PXA3xx_EMTS.pdf

        • Specification Update : https://web.archive.org/web/20150927183411/http://www.marvell.com/application-processors/pxa-family/assets/PXA3xx_Spec_Update.zip

        • Reference Manual : https://web.archive.org/web/20120111103844/http://www.marvell.com/application-processors/pxa-family/assets/PXA3xx_TavorP_BootROM_Ref_Manual.pdf

        • Application processor only

        • Core: ARMv5 XScale3 core

      • PXA930, PXA935

        • Application processor with Communication processor

        • Core: ARMv5 XScale3 core

      • PXA955

        • Application processor with Communication processor

        • Core: ARMv7 compatible Sheeva PJ4 core

    Comments:

    • This line of SoCs originates from the XScale family developed by Intel and acquired by Marvell in ~2006. The PXA21x, PXA25x, PXA26x, PXA27x, PXA3xx and PXA93x were developed by Intel, while the later PXA95x were developed by Marvell.

    • Due to their XScale origin, these SoCs have virtually nothing in common with the other (Kirkwood, Dove, etc.) families of Marvell SoCs, except with the MMP/MMP2 family of SoCs.

    • Linux kernel mach directory:

      arch/arm/mach-pxa

MMP/MMP2/MMP3 family (communication processor) #

  • Flavors:

      • PXA168, a.k.a Armada 168

        • Homepage : https://web.archive.org/web/20110926014256/http://www.marvell.com/application-processors/armada-100/armada-168.jsp

        • Product brief : https://web.archive.org/web/20111102030100/http://www.marvell.com/application-processors/armada-100/assets/pxa_168_pb.pdf

        • Hardware manual : https://web.archive.org/web/20160428165359/http://www.marvell.com/application-processors/armada-100/assets/armada_16x_datasheet.pdf

        • Software manual : https://web.archive.org/web/20160428154454/http://www.marvell.com/application-processors/armada-100/assets/armada_16x_software_manual.pdf

        • Specification update : https://web.archive.org/web/20150927160338/http://www.marvell.com/application-processors/armada-100/assets/ARMADA16x_Spec_update.pdf

        • Boot ROM manual : https://web.archive.org/web/20130727205559/http://www.marvell.com/application-processors/armada-100/assets/armada_16x_ref_manual.pdf

        • App node package : https://web.archive.org/web/20141005090706/http://www.marvell.com/application-processors/armada-100/assets/armada_16x_app_note_package.pdf

        • Application processor only

        • Core: ARMv5 compatible Marvell PJ1 88sv331 (Mohawk)

      • PXA910/PXA920

        • Homepage : https://web.archive.org/web/20150928121236/http://www.marvell.com/communication-processors/pxa910/

        • Product Brief : https://archive.org/download/marvell-pxa910-pb/Marvell_PXA910_Platform-001_PB.pdf

        • Application processor with Communication processor

        • Core: ARMv5 compatible Marvell PJ1 88sv331 (Mohawk)

      • PXA688, a.k.a. MMP2, a.k.a Armada 610 (OLPC XO-1.75)

        • Product Brief : https://web.archive.org/web/20111102023255/http://www.marvell.com/application-processors/armada-600/assets/armada610_pb.pdf

        • Application processor only

        • Core: ARMv7 compatible Sheeva PJ4 88sv581x core

      • PXA2128, a.k.a. MMP3, a.k.a Armada 620 (OLPC XO-4)

        • Product Brief : https://web.archive.org/web/20120824055155/http://www.marvell.com/application-processors/armada/pxa2128/assets/Marvell-ARMADA-PXA2128-SoC-PB.pdf

        • Application processor only

        • Core: Dual-core ARMv7 compatible Sheeva PJ4C core

      • PXA960/PXA968/PXA978 (Linux support not upstream)

        • Application processor with Communication Processor

        • Core: ARMv7 compatible Sheeva PJ4 core

      • PXA986/PXA988 (Linux support not upstream)

        • Application processor with Communication Processor

        • Core: Dual-core ARMv7 compatible Sheeva PJ4B-MP core

      • PXA1088/PXA1920 (Linux support not upstream)

        • Application processor with Communication Processor

        • Core: quad-core ARMv7 Cortex-A7

      • PXA1908/PXA1928/PXA1936

        • Application processor with Communication Processor

        • Core: multi-core ARMv8 Cortex-A53

Comments:

  • This line of SoCs originates from the XScale family developed by Intel and acquired by Marvell in ~2006. All the processors of this MMP/MMP2 family were developed by Marvell.

  • Due to their XScale origin, these SoCs have virtually nothing in common with the other (Kirkwood, Dove, etc.) families of Marvell SoCs, except with the PXA family of SoCs listed above.

  • Linux kernel mach directory:

    arch/arm/mach-mmp

Berlin family (Multimedia Solutions) #

    • Flavors:

        • 88DE3010, Armada 1000 (no Linux support)

          • Core: Marvell PJ1 (ARMv5TE), Dual-core

          • Product Brief: https://web.archive.org/web/20131103162620/http://www.marvell.com/digital-entertainment/assets/armada_1000_pb.pdf

        • 88DE3005, Armada 1500 Mini

          • Design name: BG2CD

          • Core: ARM Cortex-A9, PL310 L2CC

        • 88DE3006, Armada 1500 Mini Plus

          • Design name: BG2CDP

          • Core: Dual Core ARM Cortex-A7

        • 88DE3100, Armada 1500

          • Design name: BG2

          • Core: Marvell PJ4B-MP (ARMv7), Tauros3 L2CC

        • 88DE3114, Armada 1500 Pro

          • Design name: BG2Q

          • Core: Quad Core ARM Cortex-A9, PL310 L2CC

        • 88DE3214, Armada 1500 Pro 4K

          • Design name: BG3

          • Core: ARM Cortex-A15, CA15 integrated L2CC

        • 88DE3218, ARMADA 1500 Ultra

          • Core: ARM Cortex-A53

Homepage: https://www.synaptics.com/products/multimedia-solutions Directory: arch/arm/mach-berlin

Comments:

  • This line of SoCs is based on Marvell Sheeva or ARM Cortex CPUs with Synopsys DesignWare (IRQ, GPIO, Timers, ...) and PXA IP (SDHCI, USB, ETH, ...).

  • The Berlin family was acquired by Synaptics from Marvell in 2017.

CPU Cores #

The XScale cores were designed by Intel, and shipped by Marvell in the older PXA processors. Feroceon is a Marvell designed core that developed in-house, and that evolved into Sheeva. The XScale and Feroceon cores were phased out over time and replaced with Sheeva cores in later products, which subsequently got replaced with licensed ARM Cortex-A cores.

  • XScale 1

    CPUID 0x69052xxx ARMv5, iWMMXt

  • XScale 2

    CPUID 0x69054xxx ARMv5, iWMMXt

  • XScale 3

    CPUID 0x69056xxx or 0x69056xxx ARMv5, iWMMXt

  • Feroceon-1850 88fr331 "Mohawk"

    CPUID 0x5615331x or 0x41xx926x ARMv5TE, single issue

  • Feroceon-2850 88fr531-vd "Jolteon"

    CPUID 0x5605531x or 0x41xx926x ARMv5TE, VFP, dual-issue

  • Feroceon 88fr571-vd "Jolteon"

    CPUID 0x5615571x ARMv5TE, VFP, dual-issue

  • Feroceon 88fr131 "Mohawk-D"

    CPUID 0x5625131x ARMv5TE, single-issue in-order

  • Sheeva PJ1 88sv331 "Mohawk"

    CPUID 0x561584xx ARMv5, single-issue iWMMXt v2

  • Sheeva PJ4 88sv581x "Flareon"

    CPUID 0x560f581x ARMv7, idivt, optional iWMMXt v2

  • Sheeva PJ4B 88sv581x

    CPUID 0x561f581x ARMv7, idivt, optional iWMMXt v2

  • Sheeva PJ4B-MP / PJ4C

    CPUID 0x562f584x ARMv7, idivt/idiva, LPAE, optional iWMMXt v2 and/or NEON

Long-term plans #

  • Unify the mach-dove/, mach-mv78xx0/, mach-orion5x/ into the mach-mvebu/ to support all SoCs from the Marvell EBU (Engineering Business Unit) in a single mach-<foo> directory. The plat-orion/ would therefore disappear.

Credits #

  • Maen Suleiman <maen@marvell.com>

  • Lior Amsalem <alior@marvell.com>

  • Thomas Petazzoni <thomas.petazzoni@free-electrons.com>

  • Andrew Lunn <andrew@lunn.ch>

  • Nicolas Pitre <nico@fluxnic.net>

  • Eric Miao <eric.y.miao@gmail.com>

Memory alignment

Peios Kernel / Hardware and drivers / Processor architectures / Arm

Too many problems popped up because of unnoticed misaligned memory access in kernel code lately. Therefore the alignment fixup is now unconditionally configured in for SA11x0 based targets. According to Alan Cox, this is a bad idea to configure it out, but Russell King has some good reasons for doing so on some f***ed up ARM architectures like the EBSA110. However this is not the case on many design I'm aware of, like all SA11x0 based ones.

Of course this is a bad idea to rely on the alignment trap to perform unaligned memory access in general. If those access are predictable, you are better to use the macros provided by include/linux/unaligned.h. The alignment trap can fixup misaligned access for the exception cases, but at a high performance cost. It better be rare.

Now for user space applications, it is possible to configure the alignment trap to SIGBUS any code performing unaligned access (good for debugging bad code), or even fixup the access by software like for kernel code. The later mode isn't recommended for performance reasons (just think about the floating point emulation that works about the same way). Fix your code instead!

Please note that randomly changing the behaviour without good thought is real bad - it changes the behaviour of all unaligned instructions in user space, and might cause programs to fail unexpectedly.

To change the alignment trap behavior, simply echo a number into /proc/cpu/alignment. The number is made up from various bits:

bit

behavior when set

0

A user process performing an unaligned memory access will cause the kernel to print a message indicating process name, pid, pc, instruction, address, and the fault code.

1

The kernel will attempt to fix up the user process performing the unaligned access. This is of course slow (think about the floating point emulator) and not recommended for production use.

2

The kernel will send a SIGBUS signal to the user process performing the unaligned access.

Note that not all combinations are supported - only values 0 through 5. (6 and 7 don't make sense).

For example, the following will turn on the warnings, but without fixing up or sending SIGBUS signals:

echo 1 > /proc/cpu/alignment

You can also read the content of the same file to get statistical information on unaligned access occurrences plus the current mode of operation for user space code.

Nicolas Pitre, Mar 13, 2001. Modified Russell King, Nov 30, 2001.

Kernel Memory Layout on ARM Linux

Peios Kernel / Hardware and drivers / Processor architectures / Arm

Russell King <rmk@arm.linux.org.uk>

November 17, 2005 (2.6.15)

This document describes the virtual memory layout which the Linux kernel uses for ARM processors. It indicates which regions are free for platforms to use, and which are used by generic code.

The ARM CPU is capable of addressing a maximum of 4GB virtual memory space, and this must be shared between user space processes, the kernel, and hardware devices.

As the ARM architecture matures, it becomes necessary to reserve certain regions of VM space for use for new facilities; therefore this document may reserve more VM space over time.

Start

End

Use

ffff8000

ffffffff

copy_user_page / clear_user_page use. For SA11xx and Xscale, this is used to setup a minicache mapping.

ffff4000

ffffffff

cache aliasing on ARMv6 and later CPUs.

ffff1000

ffff7fff

Reserved. Platforms must not use this address range.

ffff0000

ffff0fff

CPU vector page. The CPU vectors are mapped here if the CPU supports vector relocation (control register V bit.)

fffe0000

fffeffff

XScale cache flush area. This is used in proc-xscale.S to flush the whole data cache. (XScale does not have TCM.)

fffe8000

fffeffff

DTCM mapping area for platforms with DTCM mounted inside the CPU.

fffe0000

fffe7fff

ITCM mapping area for platforms with ITCM mounted inside the CPU.

ffc80000

ffefffff

Fixmap mapping region. Addresses provided by fix_to_virt() will be located here.

ffc00000

ffc7ffff

Guard region

ff800000

ffbfffff

Permanent, fixed read-only mapping of the firmware provided DT blob

fee00000

feffffff

Mapping of PCI I/O space. This is a static mapping within the vmalloc space.

VMALLOC_START

VMALLOC_END-1

vmalloc() / ioremap() space. Memory returned by vmalloc/ioremap will be dynamically placed in this region. Machine specific static mappings are also located here through iotable_init(). VMALLOC_START is based upon the value of the high_memory variable, and VMALLOC_END is equal to 0xff800000.

PAGE_OFFSET

high_memory-1

Kernel direct-mapped RAM region. This maps the platforms RAM, and typically maps all platform RAM in a 1:1 relationship.

PKMAP_BASE

PAGE_OFFSET-1

Permanent kernel mappings One way of mapping HIGHMEM pages into kernel space.

MODULES_VADDR

MODULES_END-1

Kernel module space Kernel modules inserted via insmod are placed here using dynamic mappings.

TASK_SIZE

MODULES_VADDR-1

KASAn shadow memory when KASan is in use. The range from MODULES_VADDR to the top of the memory is shadowed here with 1 bit per byte of memory.

00001000

TASK_SIZE-1

User space mappings Per-thread mappings are placed here via the mmap() system call.

00000000

00000fff

CPU vector page / null pointer trap CPUs which do not support vector remapping place their vector page here. NULL pointer dereferences by both the kernel and user space are also caught via this mapping.

Please note that mappings which collide with the above areas may result in a non-bootable kernel, or may cause the kernel to (eventually) panic at run time.

Since future CPUs may impact the kernel mapping layout, user programs must not access any memory which is not mapped inside their 0x0001000 to TASK_SIZE address range. If they wish to access these areas, they must set up their own mappings using open() and mmap().

ARM Microchip SoCs (aka AT91)

Peios Kernel / Hardware and drivers / Processor architectures / Arm

Introduction #

This document gives useful information about the ARM Microchip SoCs that are currently supported in Linux Mainline (you know, the one on kernel.org).

It is important to note that the Microchip (previously Atmel) ARM-based MPU product line is historically named "AT91" or "at91" throughout the Linux kernel development process even if this product prefix has completely disappeared from the official Microchip product name. Anyway, files, directories, git trees, git branches/tags and email subject always contain this "at91" sub-string.

AT91 SoCs #

Documentation and detailed datasheet for each product are available on the Microchip website: http://www.microchip.com.

  • Flavors:

    • ARM 920 based SoC - at91rm9200

      • Datasheet

      http://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-1768-32-bit-ARM920T-Embedded-Microprocessor-AT91RM9200_Datasheet.pdf

    • ARM 926 based SoCs - at91sam9260

      • Datasheet

      http://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-6221-32-bit-ARM926EJ-S-Embedded-Microprocessor-SAM9260_Datasheet.pdf

      • at91sam9xe

        • Datasheet

        http://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-6254-32-bit-ARM926EJ-S-Embedded-Microprocessor-SAM9XE_Datasheet.pdf

      • at91sam9261

        • Datasheet

        http://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-6062-ARM926EJ-S-Microprocessor-SAM9261_Datasheet.pdf

      • at91sam9263

        • Datasheet

        http://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-6249-32-bit-ARM926EJ-S-Embedded-Microprocessor-SAM9263_Datasheet.pdf

      • at91sam9rl

        • Datasheet

        http://ww1.microchip.com/downloads/en/DeviceDoc/doc6289.pdf

      • at91sam9g20

        • Datasheet

        http://ww1.microchip.com/downloads/en/DeviceDoc/DS60001516A.pdf

      • at91sam9g45 family - at91sam9g45 - at91sam9g46 - at91sam9m10 - at91sam9m11 (device superset)

        • Datasheet

        http://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-6437-32-bit-ARM926-Embedded-Microprocessor-SAM9M11_Datasheet.pdf

      • at91sam9x5 family (aka "The 5 series") - at91sam9g15 - at91sam9g25 - at91sam9g35 - at91sam9x25 - at91sam9x35

        • Datasheet (can be considered as covering the whole family)

        http://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-11055-32-bit-ARM926EJ-S-Microcontroller-SAM9X35_Datasheet.pdf

      • at91sam9n12

        • Datasheet

        http://ww1.microchip.com/downloads/en/DeviceDoc/DS60001517A.pdf

      • sam9x60

        • Datasheet

        http://ww1.microchip.com/downloads/en/DeviceDoc/SAM9X60-Data-Sheet-DS60001579A.pdf

    • ARM Cortex-A5 based SoCs - sama5d3 family

      • sama5d31

      • sama5d33

      • sama5d34

      • sama5d35

      • sama5d36 (device superset)

        • Datasheet

        http://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-11121-32-bit-Cortex-A5-Microcontroller-SAMA5D3_Datasheet_B.pdf

    • ARM Cortex-A5 + NEON based SoCs - sama5d4 family

      • sama5d41

      • sama5d42

      • sama5d43

      • sama5d44 (device superset)

        • Datasheet

        http://ww1.microchip.com/downloads/en/DeviceDoc/60001525A.pdf

      • sama5d2 family

        • sama5d21

        • sama5d22

        • sama5d23

        • sama5d24

        • sama5d26

        • sama5d27 (device superset)

        • sama5d28 (device superset + environmental monitors)

          • Datasheet

          http://ww1.microchip.com/downloads/en/DeviceDoc/DS60001476B.pdf

    • ARM Cortex-A7 based SoCs - sama7g5 family

      • sama7g51

      • sama7g52

      • sama7g53

      • sama7g54 (device superset)

        • Datasheet

        Coming soon

      • lan966 family - lan9662 - lan9668

        • Datasheet

        Coming soon

    • ARM Cortex-M7 MCUs - sams70 family

      • sams70j19

      • sams70j20

      • sams70j21

      • sams70n19

      • sams70n20

      • sams70n21

      • sams70q19

      • sams70q20

      • sams70q21

      • samv70 family

        • samv70j19

        • samv70j20

        • samv70n19

        • samv70n20

        • samv70q19

        • samv70q20

      • samv71 family

        • samv71j19

        • samv71j20

        • samv71j21

        • samv71n19

        • samv71n20

        • samv71n21

        • samv71q19

        • samv71q20

        • samv71q21

          • Datasheet

          http://ww1.microchip.com/downloads/en/DeviceDoc/SAM-E70-S70-V70-V71-Family-Data-Sheet-DS60001527D.pdf

Linux kernel information #

Linux kernel mach directory: arch/arm/mach-at91 MAINTAINERS entry is: "ARM/Microchip (AT91) SoC support"

Device Tree for AT91 SoCs and boards #

All AT91 SoCs are converted to Device Tree. Since Linux 3.19, these products must use this method to boot the Linux kernel.

Work In Progress statement: Device Tree files and Device Tree bindings that apply to AT91 SoCs and boards are considered as "Unstable". To be completely clear, any at91 binding can change at any time. So, be sure to use a Device Tree Binary and a Kernel Image generated from the same source tree. Please refer to the Documentation/devicetree/bindings/ABI.rst file for a definition of a "Stable" binding/ABI. This statement will be removed by AT91 MAINTAINERS when appropriate.

Naming conventions and best practice:

  • SoCs Device Tree Source Include files are named after the official name of the product (at91sam9g20.dtsi or sama5d33.dtsi for instance).

  • Device Tree Source Include files (.dtsi) are used to collect common nodes that can be shared across SoCs or boards (sama5d3.dtsi or at91sam9x5cm.dtsi for instance). When collecting nodes for a particular peripheral or topic, the identifier have to be placed at the end of the file name, separated with a "_" (at91sam9x5_can.dtsi or sama5d3_gmac.dtsi for example).

  • board Device Tree Source files (.dts) are prefixed by the string "at91-" so that they can be identified easily. Note that some files are historical exceptions to this rule (sama5d3[13456]ek.dts, usb_a9g20.dts or animeo_ip.dts for example).

NetWinder specific documentation

Peios Kernel / Hardware and drivers / Processor architectures / Arm

The NetWinder is a small low-power computer, primarily designed to run Linux. It is based around the StrongARM RISC processor, DC21285 PCI bridge, with PC-type hardware glued around it.

Port usage #

Min

Max

Description

0x0000

0x000f

DMA1

0x0020

0x0021

PIC1

0x0060

0x006f

Keyboard

0x0070

0x007f

RTC

0x0080

0x0087

DMA1

0x0088

0x008f

DMA2

0x00a0

0x00a3

PIC2

0x00c0

0x00df

DMA2

0x0180

0x0187

IRDA

0x01f0

0x01f6

ide0

0x0201

Game port

0x0203

RWA010 configuration read

0x0220

?

SoundBlaster

0x0250

?

WaveArtist

0x0279

RWA010 configuration index

0x02f8

0x02ff

Serial ttyS1

0x0300

0x031f

Ether10

0x0338

GPIO1

0x033a

GPIO2

0x0370

0x0371

W83977F configuration registers

0x0388

?

AdLib

0x03c0

0x03df

VGA

0x03f6

ide0

0x03f8

0x03ff

Serial ttyS0

0x0400

0x0408

DC21143

0x0480

0x0487

DMA1

0x0488

0x048f

DMA2

0x0a79

RWA010 configuration write

0xe800

0xe80f

ide0/ide1 BM DMA

Interrupt usage #

IRQ

type

Description

0

ISA

100Hz timer

1

ISA

Keyboard

2

ISA

cascade

3

ISA

Serial ttyS1

4

ISA

Serial ttyS0

5

ISA

PS/2 mouse

6

ISA

IRDA

7

ISA

Printer

8

ISA

RTC alarm

9

ISA

10

ISA

GP10 (Orange reset button)

11

ISA

12

ISA

WaveArtist

13

ISA

14

ISA

hda1

15

ISA

DMA usage #

DMA

type

Description

0

ISA

IRDA

1

ISA

2

ISA

cascade

3

ISA

WaveArtist

4

ISA

5

ISA

6

ISA

7

ISA

WaveArtist

Porting

Peios Kernel / Hardware and drivers / Processor architectures / Arm

Taken from list archive at http://lists.arm.linux.org.uk/pipermail/linux-arm-kernel/2001-July/004064.html

Initial definitions #

The following symbol definitions rely on you knowing the translation that __virt_to_phys() does for your machine. This macro converts the passed virtual address to a physical address. Normally, it is simply:

phys = virt - PAGE_OFFSET + PHYS_OFFSET

Decompressor Symbols #

  • ZTEXTADDR

    Start address of decompressor. There's no point in talking about virtual or physical addresses here, since the MMU will be off at the time when you call the decompressor code. You normally call the kernel at this address to start it booting. This doesn't have to be located in RAM, it can be in flash or other read-only or read-write addressable medium.

  • ZBSSADDR

    Start address of zero-initialised work area for the decompressor. This must be pointing at RAM. The decompressor will zero initialise this for you. Again, the MMU will be off.

  • ZRELADDR

    This is the address where the decompressed kernel will be written, and eventually executed. The following constraint must be valid:

    __virt_to_phys(TEXTADDR) == ZRELADDR

    The initial part of the kernel is carefully coded to be position independent.

  • INITRD_PHYS

    Physical address to place the initial RAM disk. Only relevant if you are using the bootpImage stuff (which only works on the old struct param_struct).

  • INITRD_VIRT

    Virtual address of the initial RAM disk. The following constraint must be valid:

    __virt_to_phys(INITRD_VIRT) == INITRD_PHYS

  • PARAMS_PHYS

    Physical address of the struct param_struct or tag list, giving the kernel various parameters about its execution environment.

Kernel Symbols #

  • PHYS_OFFSET

    Physical start address of the first bank of RAM.

  • PAGE_OFFSET

    Virtual start address of the first bank of RAM. During the kernel boot phase, virtual address PAGE_OFFSET will be mapped to physical address PHYS_OFFSET, along with any other mappings you supply. This should be the same value as TASK_SIZE.

  • TASK_SIZE

    The maximum size of a user process in bytes. Since user space always starts at zero, this is the maximum address that a user process can access+1. The user space stack grows down from this address.

    Any virtual address below TASK_SIZE is deemed to be user process area, and therefore managed dynamically on a process by process basis by the kernel. I'll call this the user segment.

    Anything above TASK_SIZE is common to all processes. I'll call this the kernel segment.

    (In other words, you can't put IO mappings below TASK_SIZE, and hence PAGE_OFFSET).

  • TEXTADDR

    Virtual start address of kernel, normally PAGE_OFFSET + 0x8000. This is where the kernel image ends up. With the latest kernels, it must be located at 32768 bytes into a 128MB region. Previous kernels placed a restriction of 256MB here.

  • DATAADDR

    Virtual address for the kernel data segment. Must not be defined when using the decompressor.

  • VMALLOC_START / VMALLOC_END

    Virtual addresses bounding the vmalloc() area. There must not be any static mappings in this area; vmalloc will overwrite them. The addresses must also be in the kernel segment (see above). Normally, the vmalloc() area starts VMALLOC_OFFSET bytes above the last virtual RAM address (found using variable high_memory).

  • VMALLOC_OFFSET

    Offset normally incorporated into VMALLOC_START to provide a hole between virtual RAM and the vmalloc area. We do this to allow out of bounds memory accesses (eg, something writing off the end of the mapped memory map) to be caught. Normally set to 8MB.

Architecture Specific Macros #

  • BOOT_MEM(pram,pio,vio)

    pram specifies the physical start address of RAM. Must always be present, and should be the same as PHYS_OFFSET.

    pio is the physical address of an 8MB region containing IO for use with the debugging macros in arch/arm/kernel/debug-armv.S.

    vio is the virtual address of the 8MB debugging region.

    It is expected that the debugging region will be re-initialised by the architecture specific code later in the code (via the MAPIO function).

  • BOOT_PARAMS

    Same as, and see PARAMS_PHYS.

  • FIXUP(func)

    Machine specific fixups, run before memory subsystems have been initialised.

  • MAPIO(func)

    Machine specific function to map IO areas (including the debug region above).

  • INITIRQ(func)

    Machine specific function to initialise interrupts.

Kernel initialisation parameters on ARM Linux

Peios Kernel / Hardware and drivers / Processor architectures / Arm

The following document describes the kernel initialisation parameter structure, otherwise known as 'struct param_struct' which is used for most ARM Linux architectures.

This structure is used to pass initialisation parameters from the kernel loader to the Linux kernel proper, and may be short lived through the kernel initialisation process. As a general rule, it should not be referenced outside of arch/arm/kernel/setup.c:setup_arch().

There are a lot of parameters listed in there, and they are described below:

  • page_size

    This parameter must be set to the page size of the machine, and will be checked by the kernel.

  • nr_pages

    This is the total number of pages of memory in the system. If the memory is banked, then this should contain the total number of pages in the system.

    If the system contains separate VRAM, this value should not include this information.

  • ramdisk_size

    This is now obsolete, and should not be used.

  • flags

    Various kernel flags, including:

    bit 0

    1 = mount root read only

    bit 1

    unused

    bit 2

    0 = load ramdisk

    bit 3

    0 = prompt for ramdisk

  • rootdev

    major/minor number pair of device to mount as the root filesystem.

  • video_num_cols / video_num_rows

    These two together describe the character size of the dummy console, or VGA console character size. They should not be used for any other purpose.

    It's generally a good idea to set these to be either standard VGA, or the equivalent character size of your fbcon display. This then allows all the bootup messages to be displayed correctly.

  • video_x / video_y

    This describes the character position of cursor on VGA console, and is otherwise unused. (should not be used for other console types, and should not be used for other purposes).

  • memc_control_reg

    MEMC chip control register for Acorn Archimedes and Acorn A5000 based machines. May be used differently by different architectures.

  • sounddefault

    Default sound setting on Acorn machines. May be used differently by different architectures.

  • adfsdrives

    Number of ADFS/MFM disks. May be used differently by different architectures.

  • bytes_per_char_h / bytes_per_char_v

    These are now obsolete, and should not be used.

  • pages_in_bank[4]

    Number of pages in each bank of the systems memory (used for RiscPC). This is intended to be used on systems where the physical memory is non-contiguous from the processors point of view.

  • pages_in_vram

    Number of pages in VRAM (used on Acorn RiscPC). This value may also be used by loaders if the size of the video RAM can't be obtained from the hardware.

  • initrd_start / initrd_size

    This describes the kernel virtual start address and size of the initial ramdisk.

  • rd_start

    Start address in sectors of the ramdisk image on a floppy disk.

  • system_rev

    system revision number.

  • system_serial_low / system_serial_high

    system 64-bit serial number

  • mem_fclk_21285

    The speed of the external oscillator to the 21285 (footbridge), which control's the speed of the memory bus, timer & serial port. Depending upon the speed of the cpu its value can be between 0-66 MHz. If no params are passed or a value of zero is passed, then a value of 50 Mhz is the default on 21285 architectures.

  • paths[8][128]

    These are now obsolete, and should not be used.

  • commandline

    Kernel command line parameters. Details can be found elsewhere.

ARM Allwinner SoCs

Peios Kernel / Hardware and drivers / Processor architectures / Arm

This document lists all the ARM Allwinner SoCs that are currently supported in mainline by the Linux kernel. This document will also provide links to documentation and/or datasheet for these SoCs.

SunXi family #

Linux kernel mach directory: arch/arm/mach-sunxi

Flavors:

  • ARM926 based SoCs - Allwinner F20 (sun3i)

    • Not Supported
  • ARM Cortex-A8 based SoCs - Allwinner A10 (sun4i)

    • Datasheet

      http://dl.linux-sunxi.org/A10/A10%20Datasheet%20-%20v1.21%20%282012-04-06%29.pdf

    • User Manual

      http://dl.linux-sunxi.org/A10/A10%20User%20Manual%20-%20v1.20%20%282012-04-09%2c%20DECRYPTED%29.pdf

    • Allwinner A10s (sun5i)

      • Datasheet

        http://dl.linux-sunxi.org/A10s/A10s%20Datasheet%20-%20v1.20%20%282012-03-27%29.pdf

    • Allwinner A13 / R8 (sun5i)

      • Datasheet

        http://dl.linux-sunxi.org/A13/A13%20Datasheet%20-%20v1.12%20%282012-03-29%29.pdf

      • User Manual

        http://dl.linux-sunxi.org/A13/A13%20User%20Manual%20-%20v1.2%20%282013-01-08%29.pdf

    • Next Thing Co GR8 (sun5i)

  • Single ARM Cortex-A7 based SoCs - Allwinner V3s (sun8i)

    • Datasheet

      http://linux-sunxi.org/File:Allwinner_V3s_Datasheet_V1.0.pdf

  • Dual ARM Cortex-A7 based SoCs - Allwinner A20 (sun7i)

    • User Manual

      http://dl.linux-sunxi.org/A20/A20%20User%20Manual%202013-03-22.pdf

    • Allwinner A23 (sun8i)

      • Datasheet

        http://dl.linux-sunxi.org/A23/A23%20Datasheet%20V1.0%2020130830.pdf

      • User Manual

        http://dl.linux-sunxi.org/A23/A23%20User%20Manual%20V1.0%2020130830.pdf

  • Quad ARM Cortex-A7 based SoCs - Allwinner A31 (sun6i)

    • Datasheet

      http://dl.linux-sunxi.org/A31/A3x_release_document/A31/IC/A31%20datasheet%20V1.3%2020131106.pdf

    • User Manual

      http://dl.linux-sunxi.org/A31/A3x_release_document/A31/IC/A31%20user%20manual%20V1.1%2020130630.pdf

    • Allwinner A31s (sun6i)

      • Datasheet

        http://dl.linux-sunxi.org/A31/A3x_release_document/A31s/IC/A31s%20datasheet%20V1.3%2020131106.pdf

      • User Manual

        http://dl.linux-sunxi.org/A31/A3x_release_document/A31s/IC/A31s%20User%20Manual%20%20V1.0%2020130322.pdf

    • Allwinner A33 (sun8i)

      • Datasheet

        http://dl.linux-sunxi.org/A33/A33%20Datasheet%20release%201.1.pdf

      • User Manual

        http://dl.linux-sunxi.org/A33/A33%20user%20manual%20release%201.1.pdf

    • Allwinner H2+ (sun8i)

      • No document available now, but is known to be working properly with H3 drivers and memory map.
    • Allwinner H3 (sun8i)

      • Datasheet

        https://linux-sunxi.org/images/4/4b/Allwinner_H3_Datasheet_V1.2.pdf

    • Allwinner R40 (sun8i)

      • Datasheet

        https://github.com/tinalinux/docs/raw/r40-v1.y/R40_Datasheet_V1.0.pdf

      • User Manual

        https://github.com/tinalinux/docs/raw/r40-v1.y/Allwinner_R40_User_Manual_V1.0.pdf

  • Quad ARM Cortex-A15, Quad ARM Cortex-A7 based SoCs - Allwinner A80

    • Datasheet

      http://dl.linux-sunxi.org/A80/A80_Datasheet_Revision_1.0_0404.pdf

  • Octa ARM Cortex-A7 based SoCs - Allwinner A83T

    • Datasheet

      https://github.com/allwinner-zh/documents/raw/master/A83T/A83T_Datasheet_v1.3_20150510.pdf

    • User Manual

      https://github.com/allwinner-zh/documents/raw/master/A83T/A83T_User_Manual_v1.5.1_20150513.pdf

  • Quad ARM Cortex-A53 based SoCs - Allwinner A64

    • Datasheet

      http://dl.linux-sunxi.org/A64/A64_Datasheet_V1.1.pdf

    • User Manual

      http://dl.linux-sunxi.org/A64/Allwinner%20A64%20User%20Manual%20v1.0.pdf

    • Allwinner H6

      • Datasheet

        https://linux-sunxi.org/images/5/5c/Allwinner_H6_V200_Datasheet_V1.1.pdf

      • User Manual

        https://linux-sunxi.org/images/4/46/Allwinner_H6_V200_User_Manual_V1.1.pdf

    • Allwinner H616

      • Datasheet

        https://linux-sunxi.org/images/b/b9/H616_Datasheet_V1.0_cleaned.pdf

      • User Manual

        https://linux-sunxi.org/images/2/24/H616_User_Manual_V1.0_cleaned.pdf

Software emulation of deprecated SWP instruction (CONFIG_SWP_EMULATE)

Peios Kernel / Hardware and drivers / Processor architectures / Arm

ARMv6 architecture deprecates use of the SWP/SWPB instructions, and recommends moving to the load-locked/store-conditional instructions LDREX and STREX.

ARMv7 multiprocessing extensions introduce the ability to disable these instructions, triggering an undefined instruction exception when executed. Trapped instructions are emulated using an LDREX/STREX or LDREXB/STREXB sequence. If a memory access fault (an abort) occurs, a segmentation fault is signalled to the triggering process.

/proc/cpu/swp_emulation holds some statistics/information, including the PID of the last process to trigger the emulation to be invocated. For example:

Emulated SWP:         12
Emulated SWPB:                0
Aborted SWP{B}:               1
Last process:         314
  • NOTE:

    when accessing uncached shared regions, LDREX/STREX rely on an external transaction monitoring block called a global monitor to maintain update atomicity. If your system does not implement a global monitor, this option can cause programs that perform SWP operations to uncached memory to deadlock, as the STREX operation will always fail.

ARM TCM (Tightly-Coupled Memory) handling in Linux

Peios Kernel / Hardware and drivers / Processor architectures / Arm

Written by Linus Walleij <linus.walleij@stericsson.com>

Some ARM SoCs have a so-called TCM (Tightly-Coupled Memory). This is usually just a few (4-64) KiB of RAM inside the ARM processor.

Due to being embedded inside the CPU, the TCM has a Harvard-architecture, so there is an ITCM (instruction TCM) and a DTCM (data TCM). The DTCM can not contain any instructions, but the ITCM can actually contain data. The size of DTCM or ITCM is minimum 4KiB so the typical minimum configuration is 4KiB ITCM and 4KiB DTCM.

ARM CPUs have special registers to read out status, physical location and size of TCM memories. arch/arm/include/asm/cputype.h defines a CPUID_TCM register that you can read out from the system control coprocessor. Documentation from ARM can be found at http://infocenter.arm.com, search for "TCM Status Register" to see documents for all CPUs. Reading this register you can determine if ITCM (bits 1-0) and/or DTCM (bit 17-16) is present in the machine.

There is further a TCM region register (search for "TCM Region Registers" at the ARM site) that can report and modify the location size of TCM memories at runtime. This is used to read out and modify TCM location and size. Notice that this is not a MMU table: you actually move the physical location of the TCM around. At the place you put it, it will mask any underlying RAM from the CPU so it is usually wise not to overlap any physical RAM with the TCM.

The TCM memory can then be remapped to another address again using the MMU, but notice that the TCM is often used in situations where the MMU is turned off. To avoid confusion the current Linux implementation will map the TCM 1 to 1 from physical to virtual memory in the location specified by the kernel. Currently Linux will map ITCM to 0xfffe0000 and on, and DTCM to 0xfffe8000 and on, supporting a maximum of 32KiB of ITCM and 32KiB of DTCM.

Newer versions of the region registers also support dividing these TCMs in two separate banks, so for example an 8KiB ITCM is divided into two 4KiB banks with its own control registers. The idea is to be able to lock and hide one of the banks for use by the secure world (TrustZone).

TCM is used for a few things:

  • FIQ and other interrupt handlers that need deterministic timing and cannot wait for cache misses.

  • Idle loops where all external RAM is set to self-refresh retention mode, so only on-chip RAM is accessible by the CPU and then we hang inside ITCM waiting for an interrupt.

  • Other operations which implies shutting off or reconfiguring the external RAM controller.

There is an interface for using TCM on the ARM architecture in <asm/tcm.h>. Using this interface it is possible to:

  • Define the physical address and size of ITCM and DTCM.

  • Tag functions to be compiled into ITCM.

  • Tag data and constants to be allocated to DTCM and ITCM.

  • Have the remaining TCM RAM added to a special allocation pool with gen_pool_create() and gen_pool_add() and provide tcm_alloc() and tcm_free() for this memory. Such a heap is great for things like saving device state when shutting off device power domains.

A machine that has TCM memory shall select HAVE_TCM from arch/arm/Kconfig for itself. Code that needs to use TCM shall #include <asm/tcm.h>

Functions to go into itcm can be tagged like this: int __tcmfunc foo(int bar);

Since these are marked to become long_calls and you may want to have functions called locally inside the TCM without wasting space, there is also the __tcmlocalfunc prefix that will make the call relative.

Variables to go into dtcm can be tagged like this:

int __tcmdata foo;

Constants can be tagged like this:

int __tcmconst foo;

To put assembler into TCM just use:

.section ".tcm.text" or .section ".tcm.data"

respectively.

Example code:

#include <asm/tcm.h>

/* Uninitialized data */
static u32 __tcmdata tcmvar;
/* Initialized data */
static u32 __tcmdata tcmassigned = 0x2BADBABEU;
/* Constant */
static const u32 __tcmconst tcmconst = 0xCAFEBABEU;

static void __tcmlocalfunc tcm_to_tcm(void)
{
      int i;
      for (i = 0; i < 100; i++)
              tcmvar ++;
}

static void __tcmfunc hello_tcm(void)
{
      /* Some abstract code that runs in ITCM */
      int i;
      for (i = 0; i < 100; i++) {
              tcmvar ++;
      }
      tcm_to_tcm();
}

static void __init test_tcm(void)
{
      u32 *tcmem;
      int i;

      hello_tcm();
      printk("Hello TCM executed from ITCM RAM\n");

      printk("TCM variable from testrun: %u @ %p\n", tcmvar, &tcmvar);
      tcmvar = 0xDEADBEEFU;
      printk("TCM variable: 0x%x @ %p\n", tcmvar, &tcmvar);

      printk("TCM assigned variable: 0x%x @ %p\n", tcmassigned, &tcmassigned);

      printk("TCM constant: 0x%x @ %p\n", tcmconst, &tcmconst);

      /* Allocate some TCM memory from the pool */
      tcmem = tcm_alloc(20);
      if (tcmem) {
              printk("TCM Allocated 20 bytes of TCM @ %p\n", tcmem);
              tcmem[0] = 0xDEADBEEFU;
              tcmem[1] = 0x2BADBABEU;
              tcmem[2] = 0xCAFEBABEU;
              tcmem[3] = 0xDEADBEEFU;
              tcmem[4] = 0x2BADBABEU;
              for (i = 0; i < 5; i++)
                      printk("TCM tcmem[%d] = %08x\n", i, tcmem[i]);
              tcm_free(tcmem, 20);
      }
}

The Unified Extensible Firmware Interface (UEFI)

Peios Kernel / Hardware and drivers / Processor architectures / Arm

UEFI, the Unified Extensible Firmware Interface, is a specification governing the behaviours of compatible firmware interfaces. It is maintained by the UEFI Forum - http://www.uefi.org/.

UEFI is an evolution of its predecessor 'EFI', so the terms EFI and UEFI are used somewhat interchangeably in this document and associated source code. As a rule, anything new uses 'UEFI', whereas 'EFI' refers to legacy code or specifications.

UEFI support in Linux #

Booting on a platform with firmware compliant with the UEFI specification makes it possible for the kernel to support additional features:

  • UEFI Runtime Services

  • Retrieving various configuration information through the standardised interface of UEFI configuration tables. (ACPI, SMBIOS, ...)

For actually enabling [U]EFI support, enable:

  • CONFIG_EFI=y

  • CONFIG_EFIVAR_FS=y or m

The implementation depends on receiving information about the UEFI environment in a Flattened Device Tree (FDT) - so is only available with CONFIG_OF.

UEFI stub #

The "stub" is a feature that extends the Image/zImage into a valid UEFI PE/COFF executable, including a loader application that makes it possible to load the kernel directly from the UEFI shell, boot menu, or one of the lightweight bootloaders like Gummiboot or rEFInd.

The kernel image built with stub support remains a valid kernel image for booting in non-UEFI environments.

UEFI kernel support on ARM #

UEFI kernel support on the ARM architectures (arm and arm64) is only available when boot is performed through the stub.

When booting in UEFI mode, the stub deletes any memory nodes from a provided DT. Instead, the kernel reads the UEFI memory map.

The stub populates the FDT /chosen node with (and the kernel scans for) the following parameters:

Name

Type

Description

linux,uefi-system-table

64-bit

Physical address of the UEFI System Table.

linux,uefi-mmap-start

64-bit

Physical address of the UEFI memory map, populated by the UEFI GetMemoryMap() call.

linux,uefi-mmap-size

32-bit

Size in bytes of the UEFI memory map pointed to in previous entry.

linux,uefi-mmap-desc-size

32-bit

Size in bytes of each entry in the UEFI memory map.

linux,uefi-mmap-desc-ver

32-bit

Version of the mmap descriptor format.

kaslr-seed

64-bit

Entropy used to randomize the kernel image base address location.

bootargs

String

Kernel command line

vlocks for Bare-Metal Mutual Exclusion

Peios Kernel / Hardware and drivers / Processor architectures / Arm

Voting Locks, or "vlocks" provide a simple low-level mutual exclusion mechanism, with reasonable but minimal requirements on the memory system.

These are intended to be used to coordinate critical activity among CPUs which are otherwise non-coherent, in situations where the hardware provides no other mechanism to support this and ordinary spinlocks cannot be used.

vlocks make use of the atomicity provided by the memory system for writes to a single memory location. To arbitrate, every CPU "votes for itself", by storing a unique number to a common memory location. The final value seen in that memory location when all the votes have been cast identifies the winner.

In order to make sure that the election produces an unambiguous result in finite time, a CPU will only enter the election in the first place if no winner has been chosen and the election does not appear to have started yet.

Algorithm #

The easiest way to explain the vlocks algorithm is with some pseudo-code:

int currently_voting[NR_CPUS] = { 0, };
int last_vote = -1; /* no votes yet */

bool vlock_trylock(int this_cpu)
{
        /* signal our desire to vote */
        currently_voting[this_cpu] = 1;
        if (last_vote != -1) {
                /* someone already volunteered himself */
                currently_voting[this_cpu] = 0;
                return false; /* not ourself */
        }

        /* let's suggest ourself */
        last_vote = this_cpu;
        currently_voting[this_cpu] = 0;

        /* then wait until everyone else is done voting */
        for_each_cpu(i) {
                while (currently_voting[i] != 0)
                        /* wait */;
        }

        /* result */
        if (last_vote == this_cpu)
                return true; /* we won */
        return false;
}

bool vlock_unlock(void)
{
        last_vote = -1;
}

The currently_voting[] array provides a way for the CPUs to determine whether an election is in progress, and plays a role analogous to the "entering" array in Lamport's bakery algorithm [1].

However, once the election has started, the underlying memory system atomicity is used to pick the winner. This avoids the need for a static priority rule to act as a tie-breaker, or any counters which could overflow.

As long as the last_vote variable is globally visible to all CPUs, it will contain only one value that won't change once every CPU has cleared its currently_voting flag.

Features and limitations #

  • vlocks are not intended to be fair. In the contended case, it is the _last_ CPU which attempts to get the lock which will be most likely to win.

    vlocks are therefore best suited to situations where it is necessary to pick a unique winner, but it does not matter which CPU actually wins.

  • Like other similar mechanisms, vlocks will not scale well to a large number of CPUs.

    vlocks can be cascaded in a voting hierarchy to permit better scaling if necessary, as in the following hypothetical example for 4096 CPUs:

    /* first level: local election */
    my_town = towns[(this_cpu >> 4) & 0xf];
    I_won = vlock_trylock(my_town, this_cpu & 0xf);
    if (I_won) {
            /* we won the town election, let's go for the state */
            my_state = states[(this_cpu >> 8) & 0xf];
            I_won = vlock_lock(my_state, this_cpu & 0xf));
            if (I_won) {
                    /* and so on */
                    I_won = vlock_lock(the_whole_country, this_cpu & 0xf];
                    if (I_won) {
                            /* ... */
                    }
                    vlock_unlock(the_whole_country);
            }
            vlock_unlock(my_state);
    }
    vlock_unlock(my_town);
    

ARM implementation #

The current ARM implementation [2] contains some optimisations beyond the basic algorithm:

  • By packing the members of the currently_voting array close together, we can read the whole array in one transaction (providing the number of CPUs potentially contending the lock is small enough). This reduces the number of round-trips required to external memory.

    In the ARM implementation, this means that we can use a single load and comparison:

    LDR     Rt, [Rn]
    CMP     Rt, #0
    

    ...in place of code equivalent to:

    LDRB    Rt, [Rn]
    CMP     Rt, #0
    LDRBEQ  Rt, [Rn, #1]
    CMPEQ   Rt, #0
    LDRBEQ  Rt, [Rn, #2]
    CMPEQ   Rt, #0
    LDRBEQ  Rt, [Rn, #3]
    CMPEQ   Rt, #0
    

    This cuts down on the fast-path latency, as well as potentially reducing bus contention in contended cases.

    The optimisation relies on the fact that the ARM memory system guarantees coherency between overlapping memory accesses of different sizes, similarly to many other architectures. Note that we do not care which element of currently_voting appears in which bits of Rt, so there is no need to worry about endianness in this optimisation.

    If there are too many CPUs to read the currently_voting array in one transaction then multiple transactions are still required. The implementation uses a simple loop of word-sized loads for this case. The number of transactions is still fewer than would be required if bytes were loaded individually.

    In principle, we could aggregate further by using LDRD or LDM, but to keep the code simple this was not attempted in the initial implementation.

  • vlocks are currently only used to coordinate between CPUs which are unable to enable their caches yet. This means that the implementation removes many of the barriers which would be required when executing the algorithm in cached memory.

    packing of the currently_voting array does not work with cached memory unless all CPUs contending the lock are cache-coherent, due to cache writebacks from one CPU clobbering values written by other CPUs. (Though if all the CPUs are cache-coherent, you should be probably be using proper spinlocks instead anyway).

  • The "no votes yet" value used for the last_vote variable is 0 (not -1 as in the pseudocode). This allows statically-allocated vlocks to be implicitly initialised to an unlocked state simply by putting them in .bss.

    An offset is added to each CPU's ID for the purpose of setting this variable, so that no CPU uses the value 0 for its ID.

Colophon #

Originally created and documented by Dave Martin for Linaro Limited, for use in ARM-based big.LITTLE platforms, with review and input gratefully received from Nicolas Pitre and Achin Gupta. Thanks to Nicolas for grabbing most of this text out of the relevant mail thread and writing up the pseudocode.

Copyright (C) 2012-2013 Linaro Limited Distributed under the terms of Version 2 of the GNU General Public License, as defined in linux/COPYING.

References #

  • [1] Lamport, L. "A New Solution of Dijkstra's Concurrent Programming

    Problem", Communications of the ACM 17, 8 (August 1974), 453-455.

    https://en.wikipedia.org/wiki/Lamport%27s_bakery_algorithm

[2] linux/arch/arm/common/vlock.S, www.kernel.org.

Peios Learn — documentation for Peios software.

Built with Trail.