Skip to content

Commit 6fe5c68

Browse files
Lorenzo PieralisiMarc Zyngier
authored andcommitted
irqchip/gic-v3: Workaround for GIC-700 erratum 2941627
GIC700 erratum 2941627 may cause GIC-700 missing SPIs wake requests when SPIs are deactivated while targeting a sleeping CPU - ie a CPU for which the redistributor: GICR_WAKER.ProcessorSleep == 1 This runtime situation can happen if an SPI that has been activated on a core is retargeted to a different core, it becomes pending and the target core subsequently enters a power state quiescing the respective redistributor. When this situation is hit, the de-activation carried out on the core that activated the SPI (through either ICC_EOIR1_EL1 or ICC_DIR_EL1 register writes) does not trigger a wake requests for the sleeping GIC redistributor even if the SPI is pending. Work around the erratum by de-activating the SPI using the redistributor GICD_ICACTIVER register if the runtime conditions require it (ie the IRQ was retargeted between activation and de-activation). Signed-off-by: Lorenzo Pieralisi <lpieralisi@kernel.org> Signed-off-by: Marc Zyngier <maz@kernel.org> Link: https://lore.kernel.org/r/20230704155034.148262-1-lpieralisi@kernel.org
1 parent 567f67a commit 6fe5c68

File tree

2 files changed

+64
-1
lines changed

2 files changed

+64
-1
lines changed

Documentation/arm64/silicon-errata.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@ stable kernels.
141141
| ARM | MMU-500 | #841119,826419 | N/A |
142142
+----------------+-----------------+-----------------+-----------------------------+
143143
+----------------+-----------------+-----------------+-----------------------------+
144+
| ARM | GIC-700 | #2941627 | ARM64_ERRATUM_2941627 |
145+
+----------------+-----------------+-----------------+-----------------------------+
146+
+----------------+-----------------+-----------------+-----------------------------+
144147
| Broadcom | Brahma-B53 | N/A | ARM64_ERRATUM_845719 |
145148
+----------------+-----------------+-----------------+-----------------------------+
146149
| Broadcom | Brahma-B53 | N/A | ARM64_ERRATUM_843419 |

drivers/irqchip/irq-gic-v3.c

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ struct gic_chip_data {
6969
static void __iomem *t241_dist_base_alias[T241_CHIPS_MAX] __read_mostly;
7070
static DEFINE_STATIC_KEY_FALSE(gic_nvidia_t241_erratum);
7171

72+
static DEFINE_STATIC_KEY_FALSE(gic_arm64_2941627_erratum);
73+
7274
static struct gic_chip_data gic_data __read_mostly;
7375
static DEFINE_STATIC_KEY_TRUE(supports_deactivate_key);
7476

@@ -592,10 +594,39 @@ static void gic_irq_nmi_teardown(struct irq_data *d)
592594
gic_irq_set_prio(d, GICD_INT_DEF_PRI);
593595
}
594596

597+
static bool gic_arm64_erratum_2941627_needed(struct irq_data *d)
598+
{
599+
enum gic_intid_range range;
600+
601+
if (!static_branch_unlikely(&gic_arm64_2941627_erratum))
602+
return false;
603+
604+
range = get_intid_range(d);
605+
606+
/*
607+
* The workaround is needed if the IRQ is an SPI and
608+
* the target cpu is different from the one we are
609+
* executing on.
610+
*/
611+
return (range == SPI_RANGE || range == ESPI_RANGE) &&
612+
!cpumask_test_cpu(raw_smp_processor_id(),
613+
irq_data_get_effective_affinity_mask(d));
614+
}
615+
595616
static void gic_eoi_irq(struct irq_data *d)
596617
{
597618
write_gicreg(gic_irq(d), ICC_EOIR1_EL1);
598619
isb();
620+
621+
if (gic_arm64_erratum_2941627_needed(d)) {
622+
/*
623+
* Make sure the GIC stream deactivate packet
624+
* issued by ICC_EOIR1_EL1 has completed before
625+
* deactivating through GICD_IACTIVER.
626+
*/
627+
dsb(sy);
628+
gic_poke_irq(d, GICD_ICACTIVER);
629+
}
599630
}
600631

601632
static void gic_eoimode1_eoi_irq(struct irq_data *d)
@@ -606,7 +637,11 @@ static void gic_eoimode1_eoi_irq(struct irq_data *d)
606637
*/
607638
if (gic_irq(d) >= 8192 || irqd_is_forwarded_to_vcpu(d))
608639
return;
609-
gic_write_dir(gic_irq(d));
640+
641+
if (!gic_arm64_erratum_2941627_needed(d))
642+
gic_write_dir(gic_irq(d));
643+
else
644+
gic_poke_irq(d, GICD_ICACTIVER);
610645
}
611646

612647
static int gic_set_type(struct irq_data *d, unsigned int type)
@@ -1816,6 +1851,12 @@ static bool gic_enable_quirk_asr8601(void *data)
18161851
return true;
18171852
}
18181853

1854+
static bool gic_enable_quirk_arm64_2941627(void *data)
1855+
{
1856+
static_branch_enable(&gic_arm64_2941627_erratum);
1857+
return true;
1858+
}
1859+
18191860
static const struct gic_quirk gic_quirks[] = {
18201861
{
18211862
.desc = "GICv3: Qualcomm MSM8996 broken firmware",
@@ -1863,6 +1904,25 @@ static const struct gic_quirk gic_quirks[] = {
18631904
.mask = 0xffffffff,
18641905
.init = gic_enable_quirk_nvidia_t241,
18651906
},
1907+
{
1908+
/*
1909+
* GIC-700: 2941627 workaround - IP variant [0,1]
1910+
*
1911+
*/
1912+
.desc = "GICv3: ARM64 erratum 2941627",
1913+
.iidr = 0x0400043b,
1914+
.mask = 0xff0e0fff,
1915+
.init = gic_enable_quirk_arm64_2941627,
1916+
},
1917+
{
1918+
/*
1919+
* GIC-700: 2941627 workaround - IP variant [2]
1920+
*/
1921+
.desc = "GICv3: ARM64 erratum 2941627",
1922+
.iidr = 0x0402043b,
1923+
.mask = 0xff0f0fff,
1924+
.init = gic_enable_quirk_arm64_2941627,
1925+
},
18661926
{
18671927
}
18681928
};

0 commit comments

Comments
 (0)