1. Apr 19, 2023
    • Greg Kroah-Hartman's avatar
      Merge tag 'cacheinfo-updates-6.4' of... · a7b3a470
      Greg Kroah-Hartman authored
      Merge tag 'cacheinfo-updates-6.4' of git://git.kernel.org/pub/scm/linux/kernel/git/sudeep.holla/linux into driver-core-next
      
      Sudeep writes:
      
      cacheinfo and arch_topology updates for v6.4
      
      The cache information can be extracted from either a Device Tree(DT),
      the PPTT ACPI table, or arch registers (clidr_el1 for arm64).
      
      When the DT is used but no cache properties are advertised, the current
      code doesn't correctly fallback to using arch information. The changes
      fixes the same and also assuse the that L1 data/instruction caches
      are private and L2/higher caches are shared when the cache information
      is missing in DT/ACPI and is derived form clidr_el1/arch registers.
      
      Currently the cacheinfo is built from the primary CPU prior to secondary
      CPUs boot, if the DT/ACPI description contains cache information.
      However, if not present, it still reverts to the old behavior, which
      allocates the cacheinfo memory on each secondary CPUs which causes
      RT kernels to triggers a "BUG: sleeping function called from invalid
      context".
      
      The changes here attempts to enable automatic detection for RT kernels
      when no DT/ACPI cache information is available, by pre-allocating
      cacheinfo memory on the primary CPU.
      
      * tag 'cacheinfo-updates-6.4' of git://git.kernel.org/pub/scm/linux/kernel/git/sudeep.holla/linux:
        cacheinfo: Add use_arch[|_cache]_info field/function
        arch_topology: Remove early cacheinfo error message if -ENOENT
        cacheinfo: Check cache properties are present in DT
        cacheinfo: Check sib_leaf in cache_leaves_are_shared()
        cacheinfo: Allow early level detection when DT/ACPI info is missing/broken
        cacheinfo: Add arm64 early level initializer implementation
        cacheinfo: Add arch specific early level initializer
      a7b3a470
  2. Apr 18, 2023
  3. Apr 14, 2023
  4. Apr 13, 2023
    • Radu Rendec's avatar
      cacheinfo: Allow early level detection when DT/ACPI info is missing/broken · e103d554
      Radu Rendec authored
      
      
      Recent work enables cacheinfo memory for secondary CPUs to be allocated
      early, while still running on the primary CPU. That allows cacheinfo
      memory to be allocated safely on RT kernels. To make that work, the
      number of cache levels/leaves must be defined in the device tree or ACPI
      tables. Further work adds a path for early detection of the number of
      cache levels/leaves, which makes it possible to allocate the cacheinfo
      memory early without requiring extra DT/ACPI information.
      
      This patch addresses a specific issue with ACPI systems with no PPTT. In
      that case, parse_acpi_topology() returns an error code, which in turn
      makes init_cpu_topology() return early, before fetch_cache_info() is
      called. In that case, the early cache level detection doesn't run.
      
      The solution is to simply remove the "return" statement and let the code
      flow fall through to calling fetch_cache_info().
      
      Signed-off-by: default avatarRadu Rendec <rrendec@redhat.com>
      Reported-by: default avatarPierre Gondois <pierre.gondois@arm.com>
      Link: https://lore.kernel.org/all/dea94484-797f-3034-7b86-6d88801c0d91@arm.com/
      
      
      Reviewed-by: default avatarPierre Gondois <pierre.gondois@arm.com>
      Link: https://lore.kernel.org/r/20230412185759.755408-4-rrendec@redhat.com
      
      
      Signed-off-by: default avatarSudeep Holla <sudeep.holla@arm.com>
      e103d554
    • Radu Rendec's avatar
      cacheinfo: Add arm64 early level initializer implementation · c931680c
      Radu Rendec authored
      This patch adds an architecture specific early cache level detection
      handler for arm64. This is basically the CLIDR_EL1 based detection that
      was previously done (only) in init_cache_level().
      
      This is part of a patch series that attempts to further the work in
      commit 5944ce09
      
       ("arch_topology: Build cacheinfo from primary CPU").
      Previously, in the absence of any DT/ACPI cache info, architecture
      specific cache detection and info allocation for secondary CPUs would
      happen in non-preemptible context during early CPU initialization and
      trigger a "BUG: sleeping function called from invalid context" splat on
      an RT kernel.
      
      This patch does not solve the problem completely for RT kernels. It
      relies on the assumption that on most systems, the CPUs are symmetrical
      and therefore have the same number of cache leaves. The cacheinfo memory
      is allocated early (on the primary CPU), relying on the new handler. If
      later (when CLIDR_EL1 based detection runs again on the secondary CPU)
      the initial assumption proves to be wrong and the CPU has in fact more
      leaves, the cacheinfo memory is reallocated, and that still triggers a
      splat on an RT kernel.
      
      In other words, asymmetrical CPU systems *must* still provide cacheinfo
      data in DT/ACPI to avoid the splat on RT kernels (unless secondary CPUs
      happen to have less leaves than the primary CPU). But symmetrical CPU
      systems (the majority) can now get away without the additional DT/ACPI
      data and rely on CLIDR_EL1 based detection.
      
      Signed-off-by: default avatarRadu Rendec <rrendec@redhat.com>
      Reviewed-by: default avatarPierre Gondois <pierre.gondois@arm.com>
      Link: https://lore.kernel.org/r/20230412185759.755408-3-rrendec@redhat.com
      
      
      Signed-off-by: default avatarSudeep Holla <sudeep.holla@arm.com>
      c931680c
    • Radu Rendec's avatar
      cacheinfo: Add arch specific early level initializer · 6539cffa
      Radu Rendec authored
      This patch gives architecture specific code the ability to initialize
      the cache level and allocate cacheinfo memory early, when cache level
      initialization runs on the primary CPU for all possible CPUs.
      
      This is part of a patch series that attempts to further the work in
      commit 5944ce09
      
       ("arch_topology: Build cacheinfo from primary CPU").
      Previously, in the absence of any DT/ACPI cache info, architecture
      specific cache detection and info allocation for secondary CPUs would
      happen in non-preemptible context during early CPU initialization and
      trigger a "BUG: sleeping function called from invalid context" splat on
      an RT kernel.
      
      More specifically, this patch adds the early_cache_level() function,
      which is called by fetch_cache_info() as a fallback when the number of
      cache leaves cannot be extracted from DT/ACPI. In the default generic
      (weak) implementation, this new function returns -ENOENT, which
      preserves the original behavior for architectures that do not implement
      the function.
      
      Since early detection can get the number of cache leaves wrong in some
      cases*, additional logic is added to still call init_cache_level() later
      on the secondary CPU, therefore giving the architecture specific code an
      opportunity to go back and fix the initial guess. Again, the original
      behavior is preserved for architectures that do not implement the new
      function.
      
      * For example, on arm64, CLIDR_EL1 detection works only when it runs on
        the current CPU. In other words, a CPU cannot detect the cache depth
        for any other CPU than itself.
      
      Signed-off-by: default avatarRadu Rendec <rrendec@redhat.com>
      Reviewed-by: default avatarPierre Gondois <pierre.gondois@arm.com>
      Link: https://lore.kernel.org/r/20230412185759.755408-2-rrendec@redhat.com
      
      
      Signed-off-by: default avatarSudeep Holla <sudeep.holla@arm.com>
      6539cffa
  5. Apr 04, 2023
  6. Apr 03, 2023
  7. Apr 02, 2023
  8. Apr 01, 2023