1. 04 May, 2017 1 commit
    • Jeenu Viswambharan's avatar
      Introduce ARM SiP service to switch execution state · b10d4499
      Jeenu Viswambharan authored
      
      
      In AArch64, privileged exception levels control the execution state
      (a.k.a. register width) of the immediate lower Exception Level; i.e.
      whether the lower exception level executes in AArch64 or AArch32 state.
      For an exception level to have its execution state changed at run time,
      it must request the change by raising a synchronous exception to the
      higher exception level.
      
      This patch implements and adds such a provision to the ARM SiP service,
      by which an immediate lower exception level can request to switch its
      execution state. The execution state is switched if the request is:
      
        - raised from non-secure world;
      
        - raised on the primary CPU, before any secondaries are brought online
          with CPU_ON PSCI call;
      
        - raised from an exception level immediately below EL3: EL2, if
          implemented; otherwise NS EL1.
      
      If successful, the SMC doesn't return to the caller, but to the entry
      point supplied with the call. Otherwise, the caller will observe the SMC
      returning with STATE_SW_E_DENIED code. If ARM Trusted Firmware is built
      for AArch32, the feature is not supported, and the call will always
      fail.
      
      For the ARM SiP service:
      
        - Add SMC function IDs for both AArch32 and AArch64;
        - Increment the SiP service minor version to 2;
        - Adjust the number of supported SiP service calls.
      
      Add documentation for ARM SiP service.
      
      Fixes ARM-software/tf-issues#436
      
      Change-Id: I4347f2d6232e69fbfbe333b340fcd0caed0a4cea
      Signed-off-by: default avatarJeenu Viswambharan <jeenu.viswambharan@arm.com>
      b10d4499
  2. 03 May, 2017 1 commit
  3. 02 Mar, 2017 2 commits
    • Jeenu Viswambharan's avatar
      PSCI: Optimize call paths if all participants are cache-coherent · b0408e87
      Jeenu Viswambharan authored
      
      
      The current PSCI implementation can apply certain optimizations upon the
      assumption that all PSCI participants are cache-coherent.
      
        - Skip performing cache maintenance during power-up.
      
        - Skip performing cache maintenance during power-down:
      
          At present, on the power-down path, CPU driver disables caches and
          MMU, and performs cache maintenance in preparation for powering down
          the CPU. This means that PSCI must perform additional cache
          maintenance on the extant stack for correct functioning.
      
          If all participating CPUs are cache-coherent, CPU driver would
          neither disable MMU nor perform cache maintenance. The CPU being
          powered down, therefore, remain cache-coherent throughout all PSCI
          call paths. This in turn means that PSCI cache maintenance
          operations are not required during power down.
      
        - Choose spin locks instead of bakery locks:
      
          The current PSCI implementation must synchronize both cache-coherent
          and non-cache-coherent participants. Mutual exclusion primitives are
          not guaranteed to function on non-coherent memory. For this reason,
          the current PSCI implementation had to resort to bakery locks.
      
          If all participants are cache-coherent, the implementation can
          enable MMU and data caches early, and substitute bakery locks for
          spin locks. Spin locks make use of architectural mutual exclusion
          primitives, and are lighter and faster.
      
      The optimizations are applied when HW_ASSISTED_COHERENCY build option is
      enabled, as it's expected that all PSCI participants are cache-coherent
      in those systems.
      
      Change-Id: Iac51c3ed318ea7e2120f6b6a46fd2db2eae46ede
      Signed-off-by: default avatarJeenu Viswambharan <jeenu.viswambharan@arm.com>
      b0408e87
    • Jeenu Viswambharan's avatar
      PSCI: Introduce cache and barrier wrappers · a10d3632
      Jeenu Viswambharan authored
      
      
      The PSCI implementation performs cache maintenance operations on its
      data structures to ensure their visibility to both cache-coherent and
      non-cache-coherent participants. These cache maintenance operations
      can be skipped if all PSCI participants are cache-coherent. When
      HW_ASSISTED_COHERENCY build option is enabled, we assume PSCI
      participants are cache-coherent.
      
      For usage abstraction, this patch introduces wrappers for PSCI cache
      maintenance and barrier operations used for state coordination: they are
      effectively NOPs when HW_ASSISTED_COHERENCY is enabled, but are
      applied otherwise.
      
      Also refactor local state usage and associated cache operations to make
      it clearer.
      
      Change-Id: I77f17a90cba41085b7188c1345fe5731c99fad87
      Signed-off-by: default avatarJeenu Viswambharan <jeenu.viswambharan@arm.com>
      a10d3632
  4. 13 Feb, 2017 1 commit
    • dp-arm's avatar
      PSCI: Decouple PSCI stat residency calculation from PMF · 04c1db1e
      dp-arm authored
      
      
      This patch introduces the following three platform interfaces:
      
      * void plat_psci_stat_accounting_start(const psci_power_state_t *state_info)
      
        This is an optional hook that platforms can implement in order
        to perform accounting before entering a low power state.  This
        typically involves capturing a timestamp.
      
      * void plat_psci_stat_accounting_stop(const psci_power_state_t *state_info)
      
        This is an optional hook that platforms can implement in order
        to perform accounting after exiting from a low power state.  This
        typically involves capturing a timestamp.
      
      * u_register_t plat_psci_stat_get_residency(unsigned int lvl,
      	const psci_power_state_t *state_info,
      	unsigned int last_cpu_index)
      
        This is an optional hook that platforms can implement in order
        to calculate the PSCI stat residency.
      
      If any of these interfaces are overridden by the platform, it is
      recommended that all of them are.
      
      By default `ENABLE_PSCI_STAT` is disabled.  If `ENABLE_PSCI_STAT`
      is set but `ENABLE_PMF` is not set then an alternative PSCI stat
      collection backend must be provided.  If both are set, then default
      weak definitions of these functions are provided, using PMF to
      calculate the residency.
      
      NOTE: Previously, platforms did not have to explicitly set
      `ENABLE_PMF` since this was automatically done by the top-level
      Makefile.
      
      Change-Id: I17b47804dea68c77bc284df15ee1ccd66bc4b79b
      Signed-off-by: default avatardp-arm <dimitris.papastamos@arm.com>
      04c1db1e
  5. 06 Feb, 2017 1 commit
    • Douglas Raillard's avatar
      Replace some memset call by zeromem · 32f0d3c6
      Douglas Raillard authored
      
      
      Replace all use of memset by zeromem when zeroing moderately-sized
      structure by applying the following transformation:
      memset(x, 0, sizeof(x)) => zeromem(x, sizeof(x))
      
      As the Trusted Firmware is compiled with -ffreestanding, it forbids the
      compiler from using __builtin_memset and forces it to generate calls to
      the slow memset implementation. Zeromem is a near drop in replacement
      for this use case, with a more efficient implementation on both AArch32
      and AArch64.
      
      Change-Id: Ia7f3a90e888b96d056881be09f0b4d65b41aa79e
      Signed-off-by: default avatarDouglas Raillard <douglas.raillard@arm.com>
      32f0d3c6
  6. 10 Aug, 2016 1 commit
    • Soby Mathew's avatar
      AArch32: Add support to PSCI lib · 727e5238
      Soby Mathew authored
      This patch adds AArch32 support to PSCI library, as follows :
      
      * The `psci_helpers.S` is implemented for AArch32.
      
      * AArch32 version of internal helper function `psci_get_ns_ep_info()` is
        defined.
      
      * The PSCI Library is responsible for the Non Secure context initialization.
        Hence a library interface `psci_prepare_next_non_secure_ctx()` is introduced
        to enable EL3 runtime firmware to initialize the non secure context without
        invoking context management library APIs.
      
      Change-Id: I25595b0cc2dbfdf39dbf7c589b875cba33317b9d
      727e5238
  7. 25 Jul, 2016 1 commit
    • Achin Gupta's avatar
      Fix use of stale power states in PSCI standby finisher · 61eae524
      Achin Gupta authored
      A PSCI CPU_SUSPEND request to place a CPU in retention states at power levels
      higher than the CPU power level is subject to the same state coordination as a
      power down state. A CPU could implement multiple retention states at a
      particular power level. When exiting WFI, the non-CPU power levels may be in a
      different retention state to what was initially requested, therefore each CPU
      should refresh its view of the states of all power levels.
      
      Previously, a CPU re-used the state of the power levels when it entered the
      retention state. This patch fixes this issue by ensuring that a CPU upon exit
      from retention reads the state of each power level afresh.
      
      Change-Id: I93b5f5065c63400c6fd2598dbaafac385748f989
      61eae524
  8. 19 Jul, 2016 1 commit
    • Soby Mathew's avatar
      Introduce PSCI Library Interface · cf0b1492
      Soby Mathew authored
      This patch introduces the PSCI Library interface. The major changes
      introduced are as follows:
      
      * Earlier BL31 was responsible for Architectural initialization during cold
      boot via bl31_arch_setup() whereas PSCI was responsible for the same during
      warm boot. This functionality is now consolidated by the PSCI library
      and it does Architectural initialization via psci_arch_setup() during both
      cold and warm boots.
      
      * Earlier the warm boot entry point was always `psci_entrypoint()`. This was
      not flexible enough as a library interface. Now PSCI expects the runtime
      firmware to provide the entry point via `psci_setup()`. A new function
      `bl31_warm_entrypoint` is introduced in BL31 and the previous
      `psci_entrypoint()` is deprecated.
      
      * The `smc_helpers.h` is reorganized to separate the SMC Calling Convention
      defines from the Trusted Firmware SMC helpers. The former is now in a new
      header file `smcc.h` and the SMC helpers are moved to Architecture specific
      header.
      
      * The CPU context is used by PSCI for context initialization and
      restoration after power down (PSCI Context). It is also used by BL31 for SMC
      handling and context management during Normal-Secure world switch (SMC
      Context). The `psci_smc_handler()` interface is redefined to not use SMC
      helper macros thus enabling to decouple the PSCI context from EL3 runtime
      firmware SMC context. This enables PSCI to be integrated with other runtime
      firmware using a different SMC context.
      
      NOTE: With this patch the architectural setup done in `bl31_arch_setup()`
      is done as part of `psci_setup()` and hence `bl31_platform_setup()` will be
      invoked prior to architectural setup. It is highly unlikely that the platform
      setup will depend on architectural setup and cause any failure. Please be
      be aware of this change in sequence.
      
      Change-Id: I7f497a08d33be234bbb822c28146250cb20dab73
      cf0b1492
  9. 18 Jul, 2016 3 commits
    • Soby Mathew's avatar
      Introduce `el3_runtime` and `PSCI` libraries · 532ed618
      Soby Mathew authored
      This patch moves the PSCI services and BL31 frameworks like context
      management and per-cpu data into new library components `PSCI` and
      `el3_runtime` respectively. This enables PSCI to be built independently from
      BL31. A new `psci_lib.mk` makefile is introduced which adds the relevant
      PSCI library sources and gets included by `bl31.mk`. Other changes which
      are done as part of this patch are:
      
      * The runtime services framework is now moved to the `common/` folder to
        enable reuse.
      * The `asm_macros.S` and `assert_macros.S` helpers are moved to architecture
        specific folder.
      * The `plat_psci_common.c` is moved from the `plat/common/aarch64/` folder
        to `plat/common` folder. The original file location now has a stub which
        just includes the file from new location to maintain platform compatibility.
      
      Most of the changes wouldn't affect platform builds as they just involve
      changes to the generic bl1.mk and bl31.mk makefiles.
      
      NOTE: THE `plat_psci_common.c` FILE HAS MOVED LOCATION AND THE STUB FILE AT
      THE ORIGINAL LOCATION IS NOW DEPRECATED. PLATFORMS SHOULD MODIFY THEIR
      MAKEFILES TO INCLUDE THE FILE FROM THE NEW LOCATION.
      
      Change-Id: I6bd87d5b59424995c6a65ef8076d4fda91ad5e86
      532ed618
    • Soby Mathew's avatar
      Fix coding guideline warnings · da554d74
      Soby Mathew authored
      This patch fixes some coding guideline warnings reported by the checkpatch
      script. Only files related to upcoming feature development have been fixed.
      
      Change-Id: I26fbce75c02ed62f00493ed6c106fe7c863ddbc5
      da554d74
    • Soby Mathew's avatar
      Rework type usage in Trusted Firmware · 4c0d0390
      Soby Mathew authored
      This patch reworks type usage in generic code, drivers and ARM platform files
      to make it more portable. The major changes done with respect to
      type usage are as listed below:
      
      * Use uintptr_t for storing address instead of uint64_t or unsigned long.
      * Review usage of unsigned long as it can no longer be assumed to be 64 bit.
      * Use u_register_t for register values whose width varies depending on
        whether AArch64 or AArch32.
      * Use generic C types where-ever possible.
      
      In addition to the above changes, this patch also modifies format specifiers
      in print invocations so that they are AArch64/AArch32 agnostic. Only files
      related to upcoming feature development have been reworked.
      
      Change-Id: I9f8c78347c5a52ba7027ff389791f1dad63ee5f8
      4c0d0390
  10. 16 Jun, 2016 1 commit
    • Yatharth Kochar's avatar
      Add optional PSCI STAT residency & count functions · 170fb93d
      Yatharth Kochar authored
      This patch adds following optional PSCI STAT functions:
      
      - PSCI_STAT_RESIDENCY: This call returns the amount of time spent
        in power_state in microseconds, by the node represented by the
        `target_cpu` and the highest level of `power_state`.
      
      - PSCI_STAT_COUNT: This call returns the number of times a
        `power_state` has been used by the node represented by the
        `target_cpu` and the highest power level of `power_state`.
      
      These APIs provides residency statistics for power states that has
      been used by the platform. They are implemented according to v1.0
      of the PSCI specification.
      
      By default this optional feature is disabled in the PSCI
      implementation. To enable it, set the boolean flag
      `ENABLE_PSCI_STAT` to 1. This also sets `ENABLE_PMF` to 1.
      
      Change-Id: Ie62e9d37d6d416ccb1813acd7f616d1ddd3e8aff
      170fb93d
  11. 08 Feb, 2016 1 commit
    • Soby Mathew's avatar
      PSCI: Resolve GCC static analysis false positive · 6d18969f
      Soby Mathew authored
      When BL31 is compiled at `-O3` optimization level using Linaro GCC 4.9
      AArch64 toolchain, it reports the following error:
      
      ```
      services/std_svc/psci/psci_common.c: In function 'psci_do_state_coordination':
      services/std_svc/psci/psci_common.c:220:27: error: array subscript is above
      array bounds [-Werror=array-bounds]
        psci_req_local_pwr_states[pwrlvl - 1][cpu_idx] = req_pwr_state;
                                 ^
      ```
      
      This error is a false positive and this patch resolves the error by asserting
      the array bounds in `psci_do_state_coordination()`.
      
      Fixes ARM-software/tf-issues#347
      
      Change-Id: I3584ed7b2e28faf455b082cb3281d6e1d11d6495
      6d18969f
  12. 14 Jan, 2016 1 commit
  13. 11 Sep, 2015 1 commit
    • Andrew Thoelke's avatar
      Re-design bakery lock memory allocation and algorithm · ee7b35c4
      Andrew Thoelke authored
      This patch unifies the bakery lock api's across coherent and normal
      memory implementation of locks by using same data type `bakery_lock_t`
      and similar arguments to functions.
      
      A separate section `bakery_lock` has been created and used to allocate
      memory for bakery locks using `DEFINE_BAKERY_LOCK`. When locks are
      allocated in normal memory, each lock for a core has to spread
      across multiple cache lines. By using the total size allocated in a
      separate cache line for a single core at compile time, the memory for
      other core locks is allocated at link time by multiplying the single
      core locks size with (PLATFORM_CORE_COUNT - 1). The normal memory lock
      algorithm now uses lock address instead of the `id` in the per_cpu_data.
      For locks allocated in coherent memory, it moves locks from
      tzfw_coherent_memory to bakery_lock section.
      
      The bakery locks are allocated as part of bss or in coherent memory
      depending on usage of coherent memory. Both these regions are
      initialised to zero as part of run_time_init before locks are used.
      Hence, bakery_lock_init() is made an empty function as the lock memory
      is already initialised to zero.
      
      The above design lead to the removal of psci bakery locks from
      non_cpu_power_pd_node to psci_locks.
      
      NOTE: THE BAKERY LOCK API WHEN USE_COHERENT_MEM IS NOT SET HAS CHANGED.
      THIS IS A BREAKING CHANGE FOR ALL PLATFORM PORTS THAT ALLOCATE BAKERY
      LOCKS IN NORMAL MEMORY.
      
      Change-Id: Ic3751c0066b8032dcbf9d88f1d4dc73d15f61d8b
      ee7b35c4
  14. 13 Aug, 2015 3 commits
    • Soby Mathew's avatar
      PSCI: Rework generic code to conform to coding guidelines · 9d070b99
      Soby Mathew authored
      This patch reworks the PSCI generic implementation to conform to ARM
      Trusted Firmware coding guidelines as described here:
      https://github.com/ARM-software/arm-trusted-firmware/wiki
      
      This patch also reviews the use of signed data types within PSCI
      Generic code and replaces them with their unsigned counterparts wherever
      they are not appropriate. The PSCI_INVALID_DATA macro which was defined
      to -1 is now replaced with PSCI_INVALID_PWR_LVL macro which is defined
      to PLAT_MAX_PWR_LVL + 1.
      
      Change-Id: Iaea422d0e46fc314e0b173c2b4c16e0d56b2515a
      9d070b99
    • Soby Mathew's avatar
      PSCI: Fix the return code for invalid entrypoint · 617540d8
      Soby Mathew authored
      As per PSCI1.0 specification, the error code to be returned when an invalid
      non secure entrypoint address is specified by the PSCI client for CPU_SUSPEND,
      CPU_ON or SYSTEM_SUSPEND must be PSCI_E_INVALID_ADDRESS. The current PSCI
      implementation returned PSCI_E_INVAL_PARAMS. This patch rectifies this error
      and also implements a common helper function to validate the entrypoint
      information to be used across these PSCI API implementations.
      
      Change-Id: I52d697d236c8bf0cd3297da4008c8e8c2399b170
      617540d8
    • Soby Mathew's avatar
      PSCI: Switch to the new PSCI frameworks · 67487846
      Soby Mathew authored
      This commit does the switch to the new PSCI framework implementation replacing
      the existing files in PSCI folder with the ones in PSCI1.0 folder. The
      corresponding makefiles are modified as required for the new implementation.
      The platform.h header file is also is switched to the new one
      as required by the new frameworks. The build flag ENABLE_PLAT_COMPAT defaults
      to 1 to enable compatibility layer which let the existing platform ports to
      continue to build and run with minimal changes.
      
      The default weak implementation of platform_get_core_pos() is now removed from
      platform_helpers.S and is provided by the compatibility layer.
      
      Note: The Secure Payloads and their dispatchers still use the old platform
      and framework APIs and hence it is expected that the ENABLE_PLAT_COMPAT build
      flag will remain enabled in subsequent patch. The compatibility for SPDs using
      the older APIs on platforms migrated to the new APIs will be added in the
      following patch.
      
      Change-Id: I18c51b3a085b564aa05fdd98d11c9f3335712719
      67487846
  15. 22 Jun, 2015 1 commit
    • Soby Mathew's avatar
      PSCI: Add SYSTEM_SUSPEND API support · c0aff0e0
      Soby Mathew authored
      This patch adds support for SYSTEM_SUSPEND API as mentioned in the PSCI 1.0
      specification. This API, on being invoked on the last running core on a
      supported platform, will put the system into a low power mode with memory
      retention.
      
      The psci_afflvl_suspend() internal API has been reused as most of the actions
      to suspend a system are the same as invoking the PSCI CPU_SUSPEND API with the
      target affinity level as 'system'. This API needs the 'power state' parameter
      for the target low power state. This parameter is not passed by the caller of
      the SYSTEM_SUSPEND API. Hence, the platform needs to implement the
      get_sys_suspend_power_state() platform function to provide this information.
      Also, the platform also needs to add support for suspending the system to the
      existing 'plat_pm_ops' functions: affinst_suspend() and
      affinst_suspend_finish().
      
      Change-Id: Ib6bf10809cb4e9b92f463755608889aedd83cef5
      c0aff0e0
  16. 19 Jun, 2015 1 commit
    • Andrew Thoelke's avatar
      Fix integer extension in mpidr_set_aff_inst() · 9b89613e
      Andrew Thoelke authored
      mpidr_set_aff_inst() is left shifting an int constant and an
      unsigned char value to construct an MPIDR. For affinity level 3 a
      shift of 32 would result in shifting out of the 32-bit type and
      have no effect on the MPIDR.
      
      These values need to be extended to unsigned long before shifting
      to ensure correct results for affinity level 3.
      
      Change-Id: I1ef40afea535f14cfd820c347a065a228e8f4536
      9b89613e
  17. 05 Mar, 2015 1 commit
    • Sandrine Bailleux's avatar
      Fix violations to the coding style · ba592e28
      Sandrine Bailleux authored
      All coding style violations have been fixed in a previous patch and
      since then, each individual patch has been checked in this regard.
      However, the latest version of the checkpatch.pl script from the Linux
      kernel is more advanced and it is able to flag new errors in the
      Trusted Firmware codebase. This patch fixes them.
      
      Change-Id: I1f332f2440984be85d36b231bb83260368987077
      ba592e28
  18. 12 Feb, 2015 1 commit
    • Soby Mathew's avatar
      Export maximum affinity using PLATFORM_MAX_AFFLVL macro · 8c32bc26
      Soby Mathew authored
      This patch removes the plat_get_max_afflvl() platform API
      and instead replaces it with a platform macro PLATFORM_MAX_AFFLVL.
      This is done because the maximum affinity level for a platform
      is a static value and it is more efficient for it to be defined
      as a platform macro.
      
      NOTE: PLATFORM PORTS NEED TO BE UPDATED ON MERGE OF THIS COMMIT
      
      Fixes ARM-Software/tf-issues#265
      
      Change-Id: I31d89b30c2ccda30d28271154d869060d50df7bf
      8c32bc26
  19. 26 Jan, 2015 2 commits
    • Soby Mathew's avatar
      Implement PSCI_FEATURES API · 90e8258e
      Soby Mathew authored
      This patch implements the PSCI_FEATURES function which is a mandatory
      API in the PSCI 1.0 specification. A capability variable is
      constructed during initialization by examining the plat_pm_ops and
      spd_pm_ops exported by the platform and the Secure Payload Dispatcher.
      This is used by the PSCI FEATURES function to determine which
      PSCI APIs are supported by the platform.
      
      Change-Id: I147ffc1bd5d90b469bd3cc4bbe0a20e95c247df7
      90e8258e
    • Soby Mathew's avatar
      Rework the PSCI migrate APIs · 8991eed7
      Soby Mathew authored
      This patch reworks the PSCI MIGRATE, MIGRATE_INFO_TYPE and
      MIGRATE_INFO_UP_CPU support for Trusted Firmware. The
      implementation does the appropriate validation of parameters
      and invokes the appropriate hook exported by the SPD.
      
      The TSP is a MP Trusted OS. Hence the ability to actually
      migrate a Trusted OS has not been implemented. The
      corresponding function is not populated in the spd_pm_hooks
      structure for the TSPD.
      
      The `spd_pm_ops_t` has undergone changes with this patch.
      SPD PORTS MAY NEED TO BE UPDATED.
      
      Fixes ARM-software/tf-issues#249
      
      Change-Id: Iabd87521bf7c530a5e4506b6d3bfd4f1bf87604f
      8991eed7
  20. 23 Jan, 2015 2 commits
    • Soby Mathew's avatar
      Validate power_state and entrypoint when executing PSCI calls · 539dcedb
      Soby Mathew authored
      This patch allows the platform to validate the power_state and
      entrypoint information from the normal world early on in PSCI
      calls so that we can return the error safely. New optional
      pm_ops hooks `validate_power_state` and `validate_ns_entrypoint`
      are introduced to do this.
      
      As a result of these changes, all the other pm_ops handlers except
      the PSCI_ON handler are expected to be successful. Also, the PSCI
      implementation will now assert if a PSCI API is invoked without the
      corresponding pm_ops handler being registered by the platform.
      
      NOTE : PLATFORM PORTS WILL BREAK ON MERGE OF THIS COMMIT. The
      pm hooks have 2 additional optional callbacks and the return type
      of the other hooks have changed.
      
      Fixes ARM-Software/tf-issues#229
      
      Change-Id: I036bc0cff2349187c7b8b687b9ee0620aa7e24dc
      539dcedb
    • Soby Mathew's avatar
      Rework internal API to save non-secure entry point info · 78879b9a
      Soby Mathew authored
      This patch replaces the internal psci_save_ns_entry() API with a
      psci_get_ns_ep_info() API. The new function splits the work done by the
      previous one such that it populates and returns an 'entry_point_info_t'
      structure with the information to enter the normal world upon completion
      of the CPU_SUSPEND or CPU_ON call. This information is used to populate
      the non-secure context structure separately.
      
      This allows the new internal API `psci_get_ns_ep_info` to return error
      and enable the code to return safely.
      
      Change-Id: Ifd87430a4a3168eac0ebac712f59c93cbad1b231
      78879b9a
  21. 22 Jan, 2015 2 commits
    • Soby Mathew's avatar
      Remove coherent memory from the BL memory maps · ab8707e6
      Soby Mathew authored
      This patch extends the build option `USE_COHERENT_MEMORY` to
      conditionally remove coherent memory from the memory maps of
      all boot loader stages. The patch also adds necessary
      documentation for coherent memory removal in firmware-design,
      porting and user guides.
      
      Fixes ARM-Software/tf-issues#106
      
      Change-Id: I260e8768c6a5c2efc402f5804a80657d8ce38773
      ab8707e6
    • Soby Mathew's avatar
      Move bakery algorithm implementation out of coherent memory · 8c5fe0b5
      Soby Mathew authored
      This patch moves the bakery locks out of coherent memory to normal memory.
      This implies that the lock information needs to be placed on a separate cache
      line for each cpu. Hence the bakery_lock_info_t structure is allocated in the
      per-cpu data so as to minimize memory wastage. A similar platform per-cpu
      data is introduced for the platform locks.
      
      As a result of the above changes, the bakery lock api is completely changed.
      Earlier, a reference to the lock structure was passed to the lock implementation.
      Now a unique-id (essentially an index into the per-cpu data array) and an offset
      into the per-cpu data for bakery_info_t needs to be passed to the lock
      implementation.
      
      Change-Id: I1e76216277448713c6c98b4c2de4fb54198b39e0
      8c5fe0b5
  22. 12 Dec, 2014 1 commit
    • Soby Mathew's avatar
      Fix CPU_SUSPEND when invoked with affinity level higher than get_max_afflvl() · 264999fc
      Soby Mathew authored
      This patch fixes the assertion failure when CPU_SUSPEND is invoked with
      an affinity level higher than supported by the platform by adding suitable
      checks for affinity level within `psci_cpu_suspend`. Also added suitable
      bound checks within `psci_aff_map_get_idx` to prevent indexing beyond array
      limits.
      
      Fixes ARM-software/tf-issues#260
      
      Change-Id: I04b75c49729e6c6d1983add590f60146c8fc3630
      264999fc
  23. 19 Aug, 2014 5 commits
    • Achin Gupta's avatar
      Miscellaneous PSCI code cleanups · a4a8eaeb
      Achin Gupta authored
      This patch implements the following cleanups in PSCI generic code:
      
      1. It reworks the affinity level specific handlers in the PSCI implementation
         such that.
      
         a. Usage of the 'rc' local variable is restricted to only where it is
            absolutely needed
      
         b. 'plat_state' local variable is defined only when a direct invocation of
            plat_get_phys_state() does not suffice.
      
         c. If a platform handler is not registered then the level specific handler
            returns early.
      
      2. It limits the use of the mpidr_aff_map_nodes_t typedef to declaration of
         arrays of the type instead of using it in function prototypes as well.
      
      3. It removes dangling declarations of __psci_cpu_off() and
         __psci_cpu_suspend(). The definitions of these functions were removed in
         earlier patches.
      
      Change-Id: I51e851967c148be9c2eeda3a3c41878f7b4d6978
      a4a8eaeb
    • Achin Gupta's avatar
      Add APIs to preserve highest affinity level in OFF state · 0a46e2c3
      Achin Gupta authored
      This patch adds APIs to find, save and retrieve the highest affinity level which
      will enter or exit from the physical OFF state during a PSCI power management
      operation. The level is stored in per-cpu data.
      
      It then reworks the PSCI implementation to perform cache maintenance only
      when the handler for the highest affinity level to enter/exit the OFF state is
      called.
      
      For example. during a CPU_SUSPEND operation, state management is done prior to
      calling the affinity level specific handlers. The highest affinity level which
      will be turned off is determined using the psci_find_max_phys_off_afflvl()
      API. This level is saved using the psci_set_max_phys_off_afflvl() API. In the
      code that does generic handling for each level, prior to performing cache
      maintenance it is first determined if the current affinity level matches the
      value returned by psci_get_max_phys_off_afflvl(). Cache maintenance is done if
      the values match.
      
      This change allows the last CPU in a cluster to perform cache maintenance
      independently. Earlier, cache maintenance was started in the level 0 handler and
      finished in the level 1 handler. This change in approach will facilitate
      implementation of tf-issues#98.
      
      Change-Id: I57233f0a27b3ddd6ddca6deb6a88b234525b0ae6
      0a46e2c3
    • Achin Gupta's avatar
      Rework state management in the PSCI implementation · 84c9f100
      Achin Gupta authored
      This patch pulls out state management from the affinity level specific handlers
      into the top level functions specific to the operation
      i.e. psci_afflvl_suspend(), psci_afflvl_on() etc.
      
      In the power down path this patch will allow an affinity instance at level X to
      determine the state that an affinity instance at level X+1 will enter before the
      level specific handlers are called. This will be useful to determine whether a
      CPU is the last in the cluster during a suspend/off request and so on.
      
      Similarly, in the power up path this patch will allow an affinity instance at
      level X to determine the state that an affinity instance at level X+1 has
      emerged from, even after the level specific handlers have been called. This will
      be useful in determining whether a CPU is the first in the cluster during a
      on/resume request and so on.
      
      As before, while powering down, state is updated before the level specific
      handlers are invoked so that they can perform actions based upon their target
      state. While powering up, state is updated after the level specific handlers have
      been invoked so that they can perform actions based upon the state they emerged
      from.
      
      Change-Id: I40fe64cb61bb096c66f88f6d493a1931243cfd37
      84c9f100
    • Achin Gupta's avatar
      Add PSCI service specific per-CPU data · 776b68ae
      Achin Gupta authored
      This patch adds a structure defined by the PSCI service to the per-CPU data
      array. The structure is used to save the 'power_state' parameter specified
      during a 'cpu_suspend' call on the current CPU. This parameter was being saved
      in the cpu node in the PSCI topology tree earlier.
      
      The existing API to return the state id specified during a PSCI CPU_SUSPEND call
      i.e. psci_get_suspend_stateid(mpidr) has been renamed to
      psci_get_suspend_stateid_by_mpidr(mpidr). The new psci_get_suspend_stateid() API
      returns the state id of the current cpu.
      
      The psci_get_suspend_afflvl() API has been changed to return the target affinity
      level of the current CPU. This was specified using the 'mpidr' parameter in the
      old implementation.
      
      The behaviour of the get_power_on_target_afflvl() has been tweaked such that
      traversal of the PSCI topology tree to locate the affinity instance node for the
      current CPU is done only in the debug build as it is an expensive operation.
      
      Change-Id: Iaad49db75abda471f6a82d697ee6e0df554c4caf
      776b68ae
    • Juan Castillo's avatar
      Add support for PSCI SYSTEM_OFF and SYSTEM_RESET APIs · d5f13093
      Juan Castillo authored
      This patch adds support for SYSTEM_OFF and SYSTEM_RESET PSCI
      operations. A platform should export handlers to complete the
      requested operation. The FVP port exports fvp_system_off() and
      fvp_system_reset() as an example.
      
      If the SPD provides a power management hook for system off and
      system reset, then the SPD is notified about the corresponding
      operation so it can do some bookkeeping. The TSPD exports
      tspd_system_off() and tspd_system_reset() for that purpose.
      
      Versatile Express shutdown and reset methods have been removed
      from the FDT as new PSCI sys_poweroff and sys_reset services
      have been added. For those kernels that do not support yet these
      PSCI services (i.e. GICv3 kernel), the original dtsi files have
      been renamed to *-no_psci.dtsi.
      
      Fixes ARM-software/tf-issues#218
      
      Change-Id: Ic8a3bf801db979099ab7029162af041c4e8330c8
      d5f13093
  24. 28 Jul, 2014 1 commit
    • Achin Gupta's avatar
      Remove the concept of coherent stacks · 539a7b38
      Achin Gupta authored
      This patch removes the allocation of memory for coherent stacks, associated
      accessor function and some dead code which called the accessor function. It also
      updates the porting guide to remove the concept and the motivation behind using
      stacks allocated in coherent memory.
      
      Fixes ARM-software/tf-issues#198
      
      Change-Id: I00ff9a04f693a03df3627ba39727e3497263fc38
      539a7b38
  25. 25 Jun, 2014 1 commit
    • Andrew Thoelke's avatar
      Remove current CPU mpidr from PSCI common code · 56378aa6
      Andrew Thoelke authored
      Many of the interfaces internal to PSCI pass the current CPU
      MPIDR_EL1 value from function to function. This is not required,
      and with inline access to the system registers is less efficient
      than requiring the code to read that register whenever required.
      
      This patch remove the mpidr parameter from the affected interfaces
      and reduces code in FVP BL3-1 size by 160 bytes.
      
      Change-Id: I16120a7c6944de37232016d7e109976540775602
      56378aa6
  26. 24 Jun, 2014 1 commit
  27. 23 Jun, 2014 2 commits
    • Andrew Thoelke's avatar
      Remove calling CPU mpidr from bakery lock API · 634ec6c2
      Andrew Thoelke authored
      The bakery lock code currently expects the calling code to pass
      the MPIDR_EL1 of the current CPU.
      
      This is not always done correctly. Also the change to provide
      inline access to system registers makes it more efficient for the
      bakery lock code to obtain the MPIDR_EL1 directly.
      
      This change removes the mpidr parameter from the bakery lock
      interface, and results in a code reduction of 160 bytes for the
      ARM FVP port.
      
      Fixes ARM-software/tf-issues#213
      
      Change-Id: I7ec7bd117bcc9794a0d948990fcf3336a367d543
      634ec6c2
    • Andrew Thoelke's avatar
      Eliminate psci_suspend_context array · 13ac44a5
      Andrew Thoelke authored
      psci_suspend_context is an array of cache-line aligned structures
      containing the single power_state integer per cpu. This array is
      the only structure indexed by the aff_map_node.data integer.
      
      This patch saves 2KB of BL3-1 memory by placing the CPU
      power_state value directly in the aff_map_node structure. As a
      result, this value is now never cached and the cache clean when
      writing the value is no longer required.
      
      Fixes ARM-software/tf-issues#195
      
      Change-Id: Ib4c70c8f79eed295ea541e7827977a588a19ef9b
      13ac44a5