1. 02 11月, 2017 1 次提交
    • M
      irqchip/gic: Deal with broken firmware exposing only 4kB of GICv2 CPU interface · 0962289b
      Marc Zyngier 提交于
      There is a lot of broken firmware out there that don't really
      expose the information the kernel requires when it comes with dealing
      with GICv2:
      
      (1) Firmware that only describes the first 4kB of GICv2
      (2) Firmware that describe 128kB of CPU interface, while
          the usable portion of the address space is between
          60 and 68kB
      
      So far, we only deal with (2). But we have platforms exhibiting
      behaviour (1), resulting in two sub-cases:
      (a) The GIC is occupying 8kB, as required by the GICv2 architecture
      (b) It is actually spread 128kB, and this is likely to be a version
          of (2)
      
      This patch tries to work around both (a) and (b) by poking at
      the outside of the described memory region, and try to work out
      what is actually there. This is of course unsafe, and should
      only be enabled if there is no way to otherwise fix the DT provided
      by the firmware (we provide a "irqchip.gicv2_force_probe" option
      to that effect).
      
      Note that for the time being, we restrict ourselves to GICv2
      implementations provided by ARM, since there I have no knowledge
      of an alternative implementations. This could be relaxed if such
      an implementation comes to light on a broken platform.
      Reviewed-by: NChristoffer Dall <cdall@linaro.org>
      Signed-off-by: NMarc Zyngier <marc.zyngier@arm.com>
      0962289b
  2. 31 8月, 2017 1 次提交
  3. 18 8月, 2017 1 次提交
  4. 02 8月, 2017 1 次提交
    • W
      irqchip/gic: Ensure we have an ISB between ack and ->handle_irq · 39a06b67
      Will Deacon 提交于
      Devices that expose their interrupt status registers via system
      registers (e.g. Statistical profiling, CPU PMU, DynamIQ PMU, arch timer,
      vgic (although unused by Linux), ...) rely on a context synchronising
      operation on the CPU to ensure that the updated status register is
      visible to the CPU when handling the interrupt. This usually happens as
      a result of taking the IRQ exception in the first place, but there are
      two race scenarios where this isn't the case.
      
      For example, let's say we have two peripherals (X and Y), where Y uses a
      system register for its interrupt status.
      
      Case 1:
      1. CPU takes an IRQ exception as a result of X raising an interrupt
      2. Y then raises its interrupt line, but the update to its system
         register is not yet visible to the CPU
      3. The GIC decides to expose Y's interrupt number first in the Ack
         register
      4. The CPU runs the IRQ handler for Y, but the status register is stale
      
      Case 2:
      1. CPU takes an IRQ exception as a result of X raising an interrupt
      2. CPU reads the interrupt number for X from the Ack register and runs
         its IRQ handler
      3. Y raises its interrupt line and the Ack register is updated, but
         again, the update to its system register is not yet visible to the
         CPU.
      4. Since the GIC drivers poll the Ack register, we read Y's interrupt
         number and run its handler without a context synchronisation
         operation, therefore seeing the stale register value.
      
      In either case, we run the risk of missing an IRQ. This patch solves the
      problem by ensuring that we execute an ISB in the GIC drivers prior
      to invoking the interrupt handler. This is already the case for GICv3
      and EOIMode 1 (the usual case for the host).
      
      Cc: Marc Zyngier <marc.zyngier@arm.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      Signed-off-by: NMarc Zyngier <marc.zyngier@arm.com>
      39a06b67
  5. 04 7月, 2017 1 次提交
  6. 25 12月, 2016 1 次提交
  7. 20 10月, 2016 1 次提交
  8. 13 9月, 2016 2 次提交
    • B
      irqchip/gic: Mark gic_init_physaddr() static · 89c59cca
      Baoyou Xie 提交于
      We get 1 warning when building kernel with W=1:
      drivers/irqchip/irq-gic.c:917:13: warning: no previous prototype for 'gic_init_physaddr' [-Wmissing-prototypes]
      
      In fact, this function is only used in the file in which it is
      declared and don't need a declaration, but can be made static.
      so this patch marks this function with 'static'.
      Signed-off-by: NBaoyou Xie <baoyou.xie@linaro.org>
      Signed-off-by: NMarc Zyngier <marc.zyngier@arm.com>
      89c59cca
    • M
      irqchip/gic: Make locking a BL_SWITCHER only feature · 04c8b0f8
      Marc Zyngier 提交于
      The BL switcher code manipulates the logical/physical CPU mapping,
      forcing a lock to be taken on the IPI path. With an IPI heavy load,
      this single lock becomes contended.
      
      But when CONFIG_BL_SWITCHER is not enabled, there is no reason
      to take this lock at all since the CPU mapping is immutable.
      
      This patch allows the lock to be entierely removed when BL_SWITCHER
      is not enabled (which is the case in most configurations), leading
      to a small improvement of "perf bench sched pipe" (measured on
      an 8 core AMD Seattle system):
      
      Before: 101370 ops/sec
      After:  103680 ops/sec
      
      Take this opportunity to remove a useless lock being taken when
      handling an interrupt on a secondary GIC.
      Signed-off-by: NMarc Zyngier <marc.zyngier@arm.com>
      04c8b0f8
  9. 18 8月, 2016 1 次提交
  10. 14 7月, 2016 1 次提交
  11. 13 6月, 2016 4 次提交
    • J
      irqchip/gic: Add platform driver for non-root GICs that require RPM · 9c8edddf
      Jon Hunter 提交于
      Add a platform driver to support non-root GICs that require runtime
      power-management. Currently, only non-root GICs are supported because
      the functions, smp_cross_call() and set_handle_irq(), that need to
      be called for a root controller are located in the __init section and
      so cannot be called by the platform driver.
      
      The GIC platform driver re-uses many functions from the existing GIC
      driver including some functions to save and restore the GIC context
      during power transitions. The functions for saving and restoring the
      GIC context are currently only defined if CONFIG_CPU_PM is enabled and
      to ensure that these functions are always defined when the platform
      driver is enabled, a dependency on CONFIG_ARM_GIC_PM (which selects the
      platform driver) has been added.
      
      In order to re-use the private GIC initialisation code, a new public
      function, gic_of_init_child(), has been added which calls various
      private functions to initialise the GIC. This is different from the
      existing gic_of_init() because it only supports non-root GICs (ie. does
      not call smp_cross_call() is set_handle_irq()) and is not located in
      the __init section (so can be used by platform drivers). Furthermore,
      gic_of_init_child() dynamically allocates memory for the GIC chip data
      which is also different from gic_of_init().
      
      There is no specific suspend handling for GICs registered as platform
      devices. Non-wakeup interrupts will be disabled by the kernel during
      late suspend, however, this alone will not power down the GIC if
      interrupts have been requested and not freed. Therefore, requestors of
      non-wakeup interrupts will need to free them on entering suspend in
      order to power-down the GIC.
      Signed-off-by: NJon Hunter <jonathanh@nvidia.com>
      Signed-off-by: NMarc Zyngier <marc.zyngier@arm.com>
      9c8edddf
    • J
      irqchip/gic: Prepare for adding platform driver · cdbb813d
      Jon Hunter 提交于
      To support GICs that require runtime power management, it is necessary
      to add a platform driver, so that the probing of the chip can be
      deferred if resources, such as a power-domain, is not yet available.
      
      To prepare for adding a platform driver:
       1. Drop the __init section from the gic_dist_config() so this can be
          re-used by the platform driver.
       2. Add prototypes for functions required by the platform driver to the
          GIC header file so they can be re-used.
      Signed-off-by: NJon Hunter <jonathanh@nvidia.com>
      Signed-off-by: NMarc Zyngier <marc.zyngier@arm.com>
      cdbb813d
    • J
      irqchip/gic: Add helper function for chip initialisation · faea6455
      Jon Hunter 提交于
      For GICs that require runtime power-management it is necessary to
      populate the 'parent_device' member of the irqchip structure. In
      preparation for supporting such GICs, move the code that initialises
      the irqchip structure for a GIC into its own function called
      gic_init_chip() where the parent device pointer is also set.
      
      Instead of calling gic_init_chip() from within gic_init_bases(), move
      the calls to outside of this function, so that in the future we can
      avoid having to pass additional parameters to gic_init_bases() in order
      set the parent device pointer or set the name to a specific string.
      Signed-off-by: NJon Hunter <jonathanh@nvidia.com>
      Signed-off-by: NMarc Zyngier <marc.zyngier@arm.com>
      faea6455
    • J
      irqchip/gic: Isolate early GIC initialisation code · d6ce564c
      Jon Hunter 提交于
      To re-use the code that initialises the GIC (found in
      __gic_init_bases()), from within a platform driver, it is necessary to
      move the code from the __init section so that it is always present and
      not removed. Unfortunately, it is not possible to simply drop the __init
      from the function declaration for __gic_init_bases() because it contains
      calls to set_smp_cross_call() and set_handle_irq() which are both
      located in the __init section. Fortunately, these calls are only
      required for the root controller and because the initial platform driver
      will only support non-root controllers that can be initialised later in
      the boot process, we can move these calls to another function.
      
      Move the bulk of the code from __gic_init_bases() to a new function
      called gic_init_bases() which is not located in the __init section and
      can be used by the platform driver. Update __gic_init_bases() to call
      gic_init_bases() and if necessary, set_smp_cross_call() and
      set_handle_irq().
      Signed-off-by: NJon Hunter <jonathanh@nvidia.com>
      Signed-off-by: NMarc Zyngier <marc.zyngier@arm.com>
      d6ce564c
  12. 28 5月, 2016 1 次提交
    • A
      remove lots of IS_ERR_VALUE abuses · 287980e4
      Arnd Bergmann 提交于
      Most users of IS_ERR_VALUE() in the kernel are wrong, as they
      pass an 'int' into a function that takes an 'unsigned long'
      argument. This happens to work because the type is sign-extended
      on 64-bit architectures before it gets converted into an
      unsigned type.
      
      However, anything that passes an 'unsigned short' or 'unsigned int'
      argument into IS_ERR_VALUE() is guaranteed to be broken, as are
      8-bit integers and types that are wider than 'unsigned long'.
      
      Andrzej Hajda has already fixed a lot of the worst abusers that
      were causing actual bugs, but it would be nice to prevent any
      users that are not passing 'unsigned long' arguments.
      
      This patch changes all users of IS_ERR_VALUE() that I could find
      on 32-bit ARM randconfig builds and x86 allmodconfig. For the
      moment, this doesn't change the definition of IS_ERR_VALUE()
      because there are probably still architecture specific users
      elsewhere.
      
      Almost all the warnings I got are for files that are better off
      using 'if (err)' or 'if (err < 0)'.
      The only legitimate user I could find that we get a warning for
      is the (32-bit only) freescale fman driver, so I did not remove
      the IS_ERR_VALUE() there but changed the type to 'unsigned long'.
      For 9pfs, I just worked around one user whose calling conventions
      are so obscure that I did not dare change the behavior.
      
      I was using this definition for testing:
      
       #define IS_ERR_VALUE(x) ((unsigned long*)NULL == (typeof (x)*)NULL && \
             unlikely((unsigned long long)(x) >= (unsigned long long)(typeof(x))-MAX_ERRNO))
      
      which ends up making all 16-bit or wider types work correctly with
      the most plausible interpretation of what IS_ERR_VALUE() was supposed
      to return according to its users, but also causes a compile-time
      warning for any users that do not pass an 'unsigned long' argument.
      
      I suggested this approach earlier this year, but back then we ended
      up deciding to just fix the users that are obviously broken. After
      the initial warning that caused me to get involved in the discussion
      (fs/gfs2/dir.c) showed up again in the mainline kernel, Linus
      asked me to send the whole thing again.
      
      [ Updated the 9p parts as per Al Viro  - Linus ]
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Cc: Andrzej Hajda <a.hajda@samsung.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Link: https://lkml.org/lkml/2016/1/7/363
      Link: https://lkml.org/lkml/2016/5/27/486
      Acked-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> # For nvmem part
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      287980e4
  13. 11 5月, 2016 7 次提交
    • J
      irqchip/gic: Add helper functions for GIC setup and teardown · d6490461
      Jon Hunter 提交于
      Move the code that sets-up a GIC via device-tree into it's own
      function and add a generic function for GIC teardown that can be used
      for both device-tree and ACPI to unmap the GIC memory.
      Signed-off-by: NJon Hunter <jonathanh@nvidia.com>
      Signed-off-by: NMarc Zyngier <marc.zyngier@arm.com>
      d6490461
    • J
      irqchip/gic: Store GIC configuration parameters · f673b9b5
      Jon Hunter 提交于
      Store the GIC configuration parameters in the GIC chip data structure.
      This will allow us to simplify the code by reducing the number of
      parameters passed between functions.
      
      Update the __gic_init_bases() function so that we only need to pass a
      pointer to the GIC chip data structure and no longer need to pass the
      GIC index in order to look-up the chip data.
      Signed-off-by: NJon Hunter <jonathanh@nvidia.com>
      Signed-off-by: NMarc Zyngier <marc.zyngier@arm.com>
      f673b9b5
    • J
      irqchip/gic: Pass GIC pointer to save/restore functions · 6e5b5924
      Jon Hunter 提交于
      Instead of passing the GIC index to the save/restore functions pass a
      pointer to the GIC chip data. This will allow these save/restore
      functions to be re-used by a platform driver where the GIC chip data
      structure is allocated dynamically and so there is no applicable index
      for identifying the GIC.
      Signed-off-by: NJon Hunter <jonathanh@nvidia.com>
      Acked-by: NMarc Zyngier <marc.zyngier@arm.com>
      Signed-off-by: NMarc Zyngier <marc.zyngier@arm.com>
      6e5b5924
    • J
      irqchip/gic: Return an error if GIC initialisation fails · dc9722cc
      Jon Hunter 提交于
      If the GIC initialisation fails, then currently we do not return an error
      or clean-up afterwards. Although for root controllers, this failure may be
      fatal anyway, for secondary controllers, it may not be fatal and so return
      an error on failure and clean-up.
      
      Update the functions gic_cpu_init() and gic_pm_init() to return an error
      instead of calling BUG() and perform any necessary clean-up.
      
      For non-banked GIC controllers, make sure that we free any memory
      allocated if we fail to initialise the IRQ domain. Please note that
      free_percpu() only frees memory if the pointer passed to it is not NULL
      and so it is unnecessary to check if both pointers are valid or not.
      Signed-off-by: NJon Hunter <jonathanh@nvidia.com>
      Signed-off-by: NMarc Zyngier <marc.zyngier@arm.com>
      dc9722cc
    • J
      irqchip/gic: Remove static irq_chip definition for eoimode1 · c2baa2f3
      Jon Hunter 提交于
      There are only 3 differences (not including the name) in the definitions
      of the gic_chip and gic_eoimode1_chip structures. Instead of statically
      defining the gic_eoimode1_chip structure, remove it and populate the
      eoimode1 functions dynamically for the appropriate GIC irqchips.
      Signed-off-by: NJon Hunter <jonathanh@nvidia.com>
      Acked-by: NMarc Zyngier <marc.zyngier@arm.com>
      Signed-off-by: NMarc Zyngier <marc.zyngier@arm.com>
      c2baa2f3
    • J
      irqchip/gic: Don't initialise chip if mapping IO space fails · 26acfe74
      Jon Hunter 提交于
      If we fail to map the address space for the GIC distributor or CPU
      interface, then don't attempt to initialise the chip, just WARN and
      return.
      Signed-off-by: NJon Hunter <jonathanh@nvidia.com>
      Acked-by: NMarc Zyngier <marc.zyngier@arm.com>
      Signed-off-by: NMarc Zyngier <marc.zyngier@arm.com>
      26acfe74
    • W
      irqchip/gic: Ensure ordering between read of INTACK and shared data · f86c4fbd
      Will Deacon 提交于
      When an IPI is generated by a CPU, the pattern looks roughly like:
      
        <write shared data>
        smp_wmb();
        <write to GIC to signal SGI>
      
      On the receiving CPU we rely on the fact that, once we've taken the
      interrupt, then the freshly written shared data must be visible to us.
      Put another way, the CPU isn't going to speculate taking an interrupt.
      
      Unfortunately, this assumption turns out to be broken.
      
      Consider that CPUx wants to send an IPI to CPUy, which will cause CPUy
      to read some shared_data. Before CPUx has done anything, a random
      peripheral raises an IRQ to the GIC and the IRQ line on CPUy is raised.
      CPUy then takes the IRQ and starts executing the entry code, heading
      towards gic_handle_irq. Furthermore, let's assume that a bunch of the
      previous interrupts handled by CPUy were SGIs, so the branch predictor
      kicks in and speculates that irqnr will be <16 and we're likely to
      head into handle_IPI. The prefetcher then grabs a speculative copy of
      shared_data which contains a stale value.
      
      Meanwhile, CPUx gets round to updating shared_data and asking the GIC
      to send an SGI to CPUy. Internally, the GIC decides that the SGI is
      more important than the peripheral interrupt (which hasn't yet been
      ACKed) but doesn't need to do anything to CPUy, because the IRQ line
      is already raised.
      
      CPUy then reads the ACK register on the GIC, sees the SGI value which
      confirms the branch prediction and we end up with a stale shared_data
      value.
      
      This patch fixes the problem by adding an smp_rmb() to the IPI entry
      code in gic_handle_irq. As it turns out, the combination of a control
      dependency and an ISB instruction from the EOI in the GICv3 driver is
      enough to provide the ordering we need, so we add a comment there
      justifying the absence of an explicit smp_rmb().
      
      Cc: stable@vger.kernel.org
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      Signed-off-by: NMarc Zyngier <marc.zyngier@arm.com>
      f86c4fbd
  14. 03 5月, 2016 2 次提交
  15. 25 4月, 2016 1 次提交
  16. 19 2月, 2016 1 次提交
  17. 11 2月, 2016 2 次提交
  18. 21 12月, 2015 2 次提交
  19. 18 12月, 2015 1 次提交
    • L
      irqchip/gic: Kconfig the number of instances · a27d21e0
      Linus Walleij 提交于
      There is currently a hack in the GIC driver making it possible
      to pass the number of GIC instances from the platform-specific
      include files and thus override the variable MAX_GIC_NR.
      
      With multiplatform deployments, this will not work as we need
      to get rid of the platform-specific include files.
      
      It turns out that this feature is only used by the RealView
      platform which has a cascaded GIC. So move the configuration
      to Kconfig and bump to 2 instances if we're building for the
      RealView. The include file hacks can then be removed.
      
      Tested on the ARM PB11MPCore with its cascaded GIC.
      Suggested-by: NArnd Bergmann <arnd@arndb.de>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: NMarc Zyngier <marc.zyngier@arm.com>
      a27d21e0
  20. 16 12月, 2015 3 次提交
    • M
      irqchip/gic: Make interrupt ID 1020 invalid · 327ebe1f
      Marc Zyngier 提交于
      The GIC has no such thing as interrupt 1020: the last valid ID is
      1019, and the range 1020-1023 is reserved - 1023 indicating that
      no interrupt is pending. So let's make sure we don't try to handle
      this ID.
      
      This bug has been in since the initial GIC code was introduced in
      8ad68bbf ("[ARM] Add support for ARM RealView board").
      Reported-by: NEric Auger <eric.auger@linaro.org>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Signed-off-by: NMarc Zyngier <marc.zyngier@arm.com>
      327ebe1f
    • L
      irqchip/gic: Assign irqchip dynamically · 58b89649
      Linus Walleij 提交于
      Instead of having the irqchip being a static struct, make it part
      of the per-instance data so we can assign it a dynamic name. This
      has the usable side effect of displaying the GIC with an instance
      number as GIC0, GIC1 ... GICn in /proc/interrupts, which is helpful
      when debugging cascaded GICs, such as on the ARM PB11MPCore.
      
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Jason Cooper <jason@lakedaemon.net>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: NMarc Zyngier <marc.zyngier@arm.com>
      58b89649
    • L
      irqchip/gic: Support RealView variant setup · 8673c1d7
      Linus Walleij 提交于
      The ARM RealView PB11MPCore reference design has some special
      bits in a system controller register to set up the GIC in one
      of three modes: legacy, new with DCC, new without DCC. The
      register is also used to enable FIQ.
      
      Since the platform will not boot unless this register is set
      up to "new with DCC" mode, we need a special quirk to be
      compiled-in for the RealView platforms.
      
      If we find the right compatible string on the GIC TestChip,
      we enable this quirk by looking up the system controller and
      enabling the special bits.
      
      We depend on the CONFIG_REALVIEW_DT Kconfig symbol as the old
      boardfile code has the same fix hardcoded, and this is only
      needed for the attempts to modernize the RealView code using
      device tree.
      
      After fixing this, the PB11MPCore boots with device tree
      only.
      
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Jason Cooper <jason@lakedaemon.net>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: NMarc Zyngier <marc.zyngier@arm.com>
      8673c1d7
  21. 17 11月, 2015 2 次提交
  22. 14 10月, 2015 3 次提交