1. 22 2月, 2022 1 次提交
    • B
      irqchip/gic-v3: Use dsb(ishst) to order writes with ICC_SGI1R_EL1 accesses · 80e4e1f4
      Barry Song 提交于
      A dsb(ishst) barrier should be enough to order previous writes with
      the system register generating the SGI, as we only need to guarantee
      the visibility of data to other CPUs in the inner shareable domain
      before we send the SGI.
      
      A micro-benchmark is written to verify the performance impact on
      kunpeng920 machine with 2 sockets, each socket has 2 dies, and
      each die has 24 CPUs, so totally the system has 2 * 2 * 24 = 96
      CPUs. ~2% performance improvement can be seen by this benchmark.
      
      The code of benchmark module:
      
       #include <linux/module.h>
       #include <linux/timekeeping.h>
      
       volatile int data0 ____cacheline_aligned;
       volatile int data1 ____cacheline_aligned;
       volatile int data2 ____cacheline_aligned;
       volatile int data3 ____cacheline_aligned;
       volatile int data4 ____cacheline_aligned;
       volatile int data5 ____cacheline_aligned;
       volatile int data6 ____cacheline_aligned;
      
       static void ipi_latency_func(void *val)
       {
       }
      
       static int __init ipi_latency_init(void)
       {
       	ktime_t stime, etime, delta;
       	int cpu, i;
       	int start = smp_processor_id();
      
       	stime = ktime_get();
       	for ( i = 0; i < 1000; i++)
       		for (cpu = 0; cpu < 96; cpu++) {
       			data0 = data1 = data2 = data3 = data4 = data5 = data6 = cpu;
       			smp_call_function_single(cpu, ipi_latency_func, NULL, 1);
       		}
       	etime = ktime_get();
      
       	delta = ktime_sub(etime, stime);
      
       	printk("%s ipi from cpu%d to cpu0-95 delta of 1000times:%lld\n",
       			__func__, start, delta);
      
       	return 0;
       }
       module_init(ipi_latency_init);
      
       static void ipi_latency_exit(void)
       {
       }
       module_exit(ipi_latency_exit);
      
       MODULE_DESCRIPTION("IPI benchmark");
       MODULE_LICENSE("GPL");
      
      run the below commands 10 times on both Vanilla and the kernel with this
      patch:
       # taskset -c 0 insmod test.ko
       # rmmod test
      
      The result on vanilla:
       ipi_latency_init ipi from cpu0 to cpu0-95 delta of 1000times:126757449
       ipi_latency_init ipi from cpu0 to cpu0-95 delta of 1000times:126784249
       ipi_latency_init ipi from cpu0 to cpu0-95 delta of 1000times:126177703
       ipi_latency_init ipi from cpu0 to cpu0-95 delta of 1000times:127022281
       ipi_latency_init ipi from cpu0 to cpu0-95 delta of 1000times:126184883
       ipi_latency_init ipi from cpu0 to cpu0-95 delta of 1000times:127374585
       ipi_latency_init ipi from cpu0 to cpu0-95 delta of 1000times:125778089
       ipi_latency_init ipi from cpu0 to cpu0-95 delta of 1000times:126974441
       ipi_latency_init ipi from cpu0 to cpu0-95 delta of 1000times:127357625
       ipi_latency_init ipi from cpu0 to cpu0-95 delta of 1000times:126228184
      
      The result on the kernel with this patch:
       ipi_latency_init ipi from cpu0 to cpu0-95 delta of 1000times:124467401
       ipi_latency_init ipi from cpu0 to cpu0-95 delta of 1000times:123474209
       ipi_latency_init ipi from cpu0 to cpu0-95 delta of 1000times:123558497
       ipi_latency_init ipi from cpu0 to cpu0-95 delta of 1000times:122993951
       ipi_latency_init ipi from cpu0 to cpu0-95 delta of 1000times:122984223
       ipi_latency_init ipi from cpu0 to cpu0-95 delta of 1000times:123323609
       ipi_latency_init ipi from cpu0 to cpu0-95 delta of 1000times:124507583
       ipi_latency_init ipi from cpu0 to cpu0-95 delta of 1000times:123386963
       ipi_latency_init ipi from cpu0 to cpu0-95 delta of 1000times:123340664
       ipi_latency_init ipi from cpu0 to cpu0-95 delta of 1000times:123285324
      Signed-off-by: NBarry Song <song.bao.hua@hisilicon.com>
      [maz: tidied up commit message]
      Signed-off-by: NMarc Zyngier <maz@kernel.org>
      Link: https://lore.kernel.org/r/20220220061910.6155-1-21cnbao@gmail.com
      80e4e1f4
  2. 16 12月, 2021 2 次提交
  3. 26 10月, 2021 1 次提交
    • M
      irq: remove handle_domain_{irq,nmi}() · 0953fb26
      Mark Rutland 提交于
      Now that entry code handles IRQ entry (including setting the IRQ regs)
      before calling irqchip code, irqchip code can safely call
      generic_handle_domain_irq(), and there's no functional reason for it to
      call handle_domain_irq().
      
      Let's cement this split of responsibility and remove handle_domain_irq()
      entirely, updating irqchip drivers to call generic_handle_domain_irq().
      
      For consistency, handle_domain_nmi() is similarly removed and replaced
      with a generic_handle_domain_nmi() function which also does not perform
      any entry logic.
      
      Previously handle_domain_{irq,nmi}() had a WARN_ON() which would fire
      when they were called in an inappropriate context. So that we can
      identify similar issues going forward, similar WARN_ON_ONCE() logic is
      added to the generic_handle_*() functions, and comments are updated for
      clarity and consistency.
      Signed-off-by: NMark Rutland <mark.rutland@arm.com>
      Reviewed-by: NMarc Zyngier <maz@kernel.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      0953fb26
  4. 20 8月, 2021 1 次提交
  5. 12 8月, 2021 2 次提交
  6. 11 6月, 2021 1 次提交
  7. 01 6月, 2021 1 次提交
  8. 23 4月, 2021 1 次提交
    • H
      irqchip/gic-v3: Do not enable irqs when handling spurious interrups · a97709f5
      He Ying 提交于
      We triggered the following error while running our 4.19 kernel
      with the pseudo-NMI patches backported to it:
      
      [   14.816231] ------------[ cut here ]------------
      [   14.816231] kernel BUG at irq.c:99!
      [   14.816232] Internal error: Oops - BUG: 0 [#1] SMP
      [   14.816232] Process swapper/0 (pid: 0, stack limit = 0x(____ptrval____))
      [   14.816233] CPU: 0 PID: 0 Comm: swapper/0 Tainted: G           O      4.19.95.aarch64 #14
      [   14.816233] Hardware name: evb (DT)
      [   14.816234] pstate: 80400085 (Nzcv daIf +PAN -UAO)
      [   14.816234] pc : asm_nmi_enter+0x94/0x98
      [   14.816235] lr : asm_nmi_enter+0x18/0x98
      [   14.816235] sp : ffff000008003c50
      [   14.816235] pmr_save: 00000070
      [   14.816237] x29: ffff000008003c50 x28: ffff0000095f56c0
      [   14.816238] x27: 0000000000000000 x26: ffff000008004000
      [   14.816239] x25: 00000000015e0000 x24: ffff8008fb916000
      [   14.816240] x23: 0000000020400005 x22: ffff0000080817cc
      [   14.816241] x21: ffff000008003da0 x20: 0000000000000060
      [   14.816242] x19: 00000000000003ff x18: ffffffffffffffff
      [   14.816243] x17: 0000000000000008 x16: 003d090000000000
      [   14.816244] x15: ffff0000095ea6c8 x14: ffff8008fff5ab40
      [   14.816244] x13: ffff8008fff58b9d x12: 0000000000000000
      [   14.816245] x11: ffff000008c8a200 x10: 000000008e31fca5
      [   14.816246] x9 : ffff000008c8a208 x8 : 000000000000000f
      [   14.816247] x7 : 0000000000000004 x6 : ffff8008fff58b9e
      [   14.816248] x5 : 0000000000000000 x4 : 0000000080000000
      [   14.816249] x3 : 0000000000000000 x2 : 0000000080000000
      [   14.816250] x1 : 0000000000120000 x0 : ffff0000095f56c0
      [   14.816251] Call trace:
      [   14.816251]  asm_nmi_enter+0x94/0x98
      [   14.816251]  el1_irq+0x8c/0x180                    (IRQ C)
      [   14.816252]  gic_handle_irq+0xbc/0x2e4
      [   14.816252]  el1_irq+0xcc/0x180                    (IRQ B)
      [   14.816253]  arch_timer_handler_virt+0x38/0x58
      [   14.816253]  handle_percpu_devid_irq+0x90/0x240
      [   14.816253]  generic_handle_irq+0x34/0x50
      [   14.816254]  __handle_domain_irq+0x68/0xc0
      [   14.816254]  gic_handle_irq+0xf8/0x2e4
      [   14.816255]  el1_irq+0xcc/0x180                    (IRQ A)
      [   14.816255]  arch_cpu_idle+0x34/0x1c8
      [   14.816255]  default_idle_call+0x24/0x44
      [   14.816256]  do_idle+0x1d0/0x2c8
      [   14.816256]  cpu_startup_entry+0x28/0x30
      [   14.816256]  rest_init+0xb8/0xc8
      [   14.816257]  start_kernel+0x4c8/0x4f4
      [   14.816257] Code: 940587f1 d5384100 b9401001 36a7fd01 (d4210000)
      [   14.816258] Modules linked in: start_dp(O) smeth(O)
      [   15.103092] ---[ end trace 701753956cb14aa8 ]---
      [   15.103093] Kernel panic - not syncing: Fatal exception in interrupt
      [   15.103099] SMP: stopping secondary CPUs
      [   15.103100] Kernel Offset: disabled
      [   15.103100] CPU features: 0x36,a2400218
      [   15.103100] Memory Limit: none
      
      which is cause by a 'BUG_ON(in_nmi())' in nmi_enter().
      
      From the call trace, we can find three interrupts (noted A, B, C above):
      interrupt (A) is preempted by (B), which is further interrupted by (C).
      
      Subsequent investigations show that (B) results in nmi_enter() being
      called, but that it actually is a spurious interrupt. Furthermore,
      interrupts are reenabled in the context of (B), and (C) fires with
      NMI priority. We end-up with a nested NMI situation, something
      we definitely do not want to (and cannot) handle.
      
      The bug here is that spurious interrupts should never result in any
      state change, and we should just return to the interrupted context.
      Moving the handling of spurious interrupts as early as possible in
      the GICv3 handler fixes this issue.
      
      Fixes: 3f1f3234 ("irqchip/gic-v3: Switch to PMR masking before calling IRQ handler")
      Acked-by: NMark Rutland <mark.rutland@arm.com>
      Signed-off-by: NHe Ying <heying24@huawei.com>
      [maz: rewrote commit message, corrected Fixes: tag]
      Signed-off-by: NMarc Zyngier <maz@kernel.org>
      Link: https://lore.kernel.org/r/20210423083516.170111-1-heying24@huawei.com
      Cc: stable@vger.kernel.org
      a97709f5
  9. 22 3月, 2021 1 次提交
  10. 22 1月, 2021 1 次提交
  11. 11 12月, 2020 1 次提交
  12. 17 9月, 2020 1 次提交
  13. 14 9月, 2020 3 次提交
  14. 07 9月, 2020 2 次提交
  15. 24 8月, 2020 1 次提交
  16. 27 6月, 2020 1 次提交
  17. 25 5月, 2020 1 次提交
  18. 18 5月, 2020 1 次提交
  19. 16 4月, 2020 1 次提交
    • M
      irqchip/gic-v4.1: Add support for VPENDBASER's Dirty+Valid signaling · 96806229
      Marc Zyngier 提交于
      When a vPE is made resident, the GIC starts parsing the virtual pending
      table to deliver pending interrupts. This takes place asynchronously,
      and can at times take a long while. Long enough that the vcpu enters
      the guest and hits WFI before any interrupt has been signaled yet.
      The vcpu then exits, blocks, and now gets a doorbell. Rince, repeat.
      
      In order to avoid the above, a (optional on GICv4, mandatory on v4.1)
      feature allows the GIC to feedback to the hypervisor whether it is
      done parsing the VPT by clearing the GICR_VPENDBASER.Dirty bit.
      The hypervisor can then wait until the GIC is ready before actually
      running the vPE.
      
      Plug the detection code as well as polling on vPE schedule. While
      at it, tidy-up the kernel message that displays the GICv4 optional
      features.
      Reviewed-by: NZenghui Yu <yuzenghui@huawei.com>
      Signed-off-by: NMarc Zyngier <maz@kernel.org>
      96806229
  20. 22 3月, 2020 1 次提交
  21. 21 3月, 2020 2 次提交
  22. 19 3月, 2020 1 次提交
    • M
      irqchip/gic-v3: Use SGIs without active state if offered · 0b04758b
      Marc Zyngier 提交于
      To allow the direct injection of SGIs into a guest, the GICv4.1
      architecture has to sacrifice the Active state so that SGIs look
      a lot like LPIs (they are injected by the same mechanism).
      
      In order not to break existing software, the architecture gives
      offers guests OSs the choice: SGIs with or without an active
      state. It is the hypervisors duty to honor the guest's choice.
      
      For this, the architecture offers a discovery bit indicating whether
      the GIC supports GICv4.1 SGIs (GICD_TYPER2.nASSGIcap), and another
      bit indicating whether the guest wants Active-less SGIs or not
      (controlled by GICD_CTLR.nASSGIreq).
      
      A hypervisor not supporting GICv4.1 SGIs would leave nASSGIcap
      clear, and a guest not knowing about GICv4.1 SGIs (or definitely
      wanting an Active state) would leave nASSGIreq clear (both being
      thankfully backward compatible with older revisions of the GIC).
      
      Since Linux is perfectly happy without an active state on SGIs,
      inform the hypervisor that we'll use that if offered.
      Signed-off-by: NMarc Zyngier <maz@kernel.org>
      Reviewed-by: NZenghui Yu <yuzenghui@huawei.com>
      Link: https://lore.kernel.org/r/20200304203330.4967-2-maz@kernel.org
      0b04758b
  23. 14 3月, 2020 1 次提交
    • M
      irqchip/gic-v3: Workaround Cavium erratum 38539 when reading GICD_TYPER2 · d01fd161
      Marc Zyngier 提交于
      Despite the architecture spec requiring that reserved registers in the GIC
      distributor memory map are RES0 (and thus are not allowed to generate
      an exception), the Cavium ThunderX (aka TX1) SoC explodes as such:
      
      [    0.000000] GICv3: GIC: Using split EOI/Deactivate mode
      [    0.000000] GICv3: 128 SPIs implemented
      [    0.000000] GICv3: 0 Extended SPIs implemented
      [    0.000000] Internal error: synchronous external abort: 96000210 [#1] SMP
      [    0.000000] Modules linked in:
      [    0.000000] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.4.0-rc4-00035-g3cf6a3d5725f #7956
      [    0.000000] Hardware name: cavium,thunder-88xx (DT)
      [    0.000000] pstate: 60000085 (nZCv daIf -PAN -UAO)
      [    0.000000] pc : __raw_readl+0x0/0x8
      [    0.000000] lr : gic_init_bases+0x110/0x560
      [    0.000000] sp : ffff800011243d90
      [    0.000000] x29: ffff800011243d90 x28: 0000000000000000
      [    0.000000] x27: 0000000000000018 x26: 0000000000000002
      [    0.000000] x25: ffff8000116f0000 x24: ffff000fbe6a2c80
      [    0.000000] x23: 0000000000000000 x22: ffff010fdc322b68
      [    0.000000] x21: ffff800010a7a208 x20: 00000000009b0404
      [    0.000000] x19: ffff80001124dad0 x18: 0000000000000010
      [    0.000000] x17: 000000004d8d492b x16: 00000000f67eb9af
      [    0.000000] x15: ffffffffffffffff x14: ffff800011249908
      [    0.000000] x13: ffff800091243ae7 x12: ffff800011243af4
      [    0.000000] x11: ffff80001126e000 x10: ffff800011243a70
      [    0.000000] x9 : 00000000ffffffd0 x8 : ffff80001069c828
      [    0.000000] x7 : 0000000000000059 x6 : ffff8000113fb4d1
      [    0.000000] x5 : 0000000000000001 x4 : 0000000000000000
      [    0.000000] x3 : 0000000000000000 x2 : 0000000000000000
      [    0.000000] x1 : 0000000000000000 x0 : ffff8000116f000c
      [    0.000000] Call trace:
      [    0.000000]  __raw_readl+0x0/0x8
      [    0.000000]  gic_of_init+0x188/0x224
      [    0.000000]  of_irq_init+0x200/0x3cc
      [    0.000000]  irqchip_init+0x1c/0x40
      [    0.000000]  init_IRQ+0x160/0x1d0
      [    0.000000]  start_kernel+0x2ec/0x4b8
      [    0.000000] Code: a8c47bfd d65f03c0 d538d080 d65f03c0 (b9400000)
      
      when reading the GICv4.1 GICD_TYPER2 register, which is unexpected...
      
      Work around it by adding a new quirk for the following variants:
      
       ThunderX: CN88xx
       OCTEON TX: CN83xx, CN81xx
       OCTEON TX2: CN93xx, CN96xx, CN98xx, CNF95xx*
      
      and use this flag to avoid accessing GICD_TYPER2. Note that all
      reserved registers (including redistributors and ITS) are impacted
      by this erratum, but that only GICD_TYPER2 has to be worked around
      so far.
      Signed-off-by: NMarc Zyngier <maz@kernel.org>
      Tested-by: NRobert Richter <rrichter@marvell.com>
      Tested-by: NMark Salter <msalter@redhat.com>
      Tested-by: NTim Harvey <tharvey@gateworks.com>
      Acked-by: NCatalin Marinas <catalin.marinas@arm.com>
      Acked-by: NRobert Richter <rrichter@marvell.com>
      Link: https://lore.kernel.org/r/20191027144234.8395-11-maz@kernel.org
      Link: https://lore.kernel.org/r/20200311115649.26060-1-maz@kernel.org
      d01fd161
  24. 28 1月, 2020 1 次提交
  25. 22 1月, 2020 2 次提交
  26. 11 11月, 2019 1 次提交
  27. 15 10月, 2019 1 次提交
    • M
      arm64: Relax ICC_PMR_EL1 accesses when ICC_CTLR_EL1.PMHE is clear · f2266504
      Marc Zyngier 提交于
      The GICv3 architecture specification is incredibly misleading when it
      comes to PMR and the requirement for a DSB. It turns out that this DSB
      is only required if the CPU interface sends an Upstream Control
      message to the redistributor in order to update the RD's view of PMR.
      
      This message is only sent when ICC_CTLR_EL1.PMHE is set, which isn't
      the case in Linux. It can still be set from EL3, so some special care
      is required. But the upshot is that in the (hopefuly large) majority
      of the cases, we can drop the DSB altogether.
      
      This relies on a new static key being set if the boot CPU has PMHE
      set. The drawback is that this static key has to be exported to
      modules.
      
      Cc: Will Deacon <will@kernel.org>
      Cc: James Morse <james.morse@arm.com>
      Cc: Julien Thierry <julien.thierry.kdev@gmail.com>
      Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
      Signed-off-by: NMarc Zyngier <maz@kernel.org>
      Signed-off-by: NCatalin Marinas <catalin.marinas@arm.com>
      f2266504
  28. 18 9月, 2019 1 次提交
  29. 20 8月, 2019 5 次提交