Skip to content

Commit de99090

Browse files
committed
Merge tag 'irqchip-fixes-6.5-1' of git://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms into irq/urgent
Pull irqchip fixes from Marc Zyngier: - Work around an erratum on GIC700, where a race between a CPU handling a wake-up interrupt, a change of affinity, and another CPU going to sleep can result in a lack of wake-up event on the next interrupt. - Fix the locking required on a VPE for GICv4 - Enable Rockchip 3588001 erratum workaround for RK3588S - Fix the irq-bcm6345-l1 assumtions of the boot CPU always be the first CPU in the system Link: https://lore.kernel.org/lkml/20230717113857.304919-1-maz@kernel.org
2 parents 67a4e1a + 6fe5c68 commit de99090

File tree

4 files changed

+117
-40
lines changed

4 files changed

+117
-40
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-bcm6345-l1.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ struct bcm6345_l1_chip {
8282
};
8383

8484
struct bcm6345_l1_cpu {
85+
struct bcm6345_l1_chip *intc;
8586
void __iomem *map_base;
8687
unsigned int parent_irq;
8788
u32 enable_cache[];
@@ -115,17 +116,11 @@ static inline unsigned int cpu_for_irq(struct bcm6345_l1_chip *intc,
115116

116117
static void bcm6345_l1_irq_handle(struct irq_desc *desc)
117118
{
118-
struct bcm6345_l1_chip *intc = irq_desc_get_handler_data(desc);
119-
struct bcm6345_l1_cpu *cpu;
119+
struct bcm6345_l1_cpu *cpu = irq_desc_get_handler_data(desc);
120+
struct bcm6345_l1_chip *intc = cpu->intc;
120121
struct irq_chip *chip = irq_desc_get_chip(desc);
121122
unsigned int idx;
122123

123-
#ifdef CONFIG_SMP
124-
cpu = intc->cpus[cpu_logical_map(smp_processor_id())];
125-
#else
126-
cpu = intc->cpus[0];
127-
#endif
128-
129124
chained_irq_enter(chip, desc);
130125

131126
for (idx = 0; idx < intc->n_words; idx++) {
@@ -253,6 +248,7 @@ static int __init bcm6345_l1_init_one(struct device_node *dn,
253248
if (!cpu)
254249
return -ENOMEM;
255250

251+
cpu->intc = intc;
256252
cpu->map_base = ioremap(res.start, sz);
257253
if (!cpu->map_base)
258254
return -ENOMEM;
@@ -271,7 +267,7 @@ static int __init bcm6345_l1_init_one(struct device_node *dn,
271267
return -EINVAL;
272268
}
273269
irq_set_chained_handler_and_data(cpu->parent_irq,
274-
bcm6345_l1_irq_handle, intc);
270+
bcm6345_l1_irq_handle, cpu);
275271

276272
return 0;
277273
}

drivers/irqchip/irq-gic-v3-its.c

Lines changed: 48 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -273,13 +273,23 @@ static void vpe_to_cpuid_unlock(struct its_vpe *vpe, unsigned long flags)
273273
raw_spin_unlock_irqrestore(&vpe->vpe_lock, flags);
274274
}
275275

276+
static struct irq_chip its_vpe_irq_chip;
277+
276278
static int irq_to_cpuid_lock(struct irq_data *d, unsigned long *flags)
277279
{
278-
struct its_vlpi_map *map = get_vlpi_map(d);
280+
struct its_vpe *vpe = NULL;
279281
int cpu;
280282

281-
if (map) {
282-
cpu = vpe_to_cpuid_lock(map->vpe, flags);
283+
if (d->chip == &its_vpe_irq_chip) {
284+
vpe = irq_data_get_irq_chip_data(d);
285+
} else {
286+
struct its_vlpi_map *map = get_vlpi_map(d);
287+
if (map)
288+
vpe = map->vpe;
289+
}
290+
291+
if (vpe) {
292+
cpu = vpe_to_cpuid_lock(vpe, flags);
283293
} else {
284294
/* Physical LPIs are already locked via the irq_desc lock */
285295
struct its_device *its_dev = irq_data_get_irq_chip_data(d);
@@ -293,10 +303,18 @@ static int irq_to_cpuid_lock(struct irq_data *d, unsigned long *flags)
293303

294304
static void irq_to_cpuid_unlock(struct irq_data *d, unsigned long flags)
295305
{
296-
struct its_vlpi_map *map = get_vlpi_map(d);
306+
struct its_vpe *vpe = NULL;
307+
308+
if (d->chip == &its_vpe_irq_chip) {
309+
vpe = irq_data_get_irq_chip_data(d);
310+
} else {
311+
struct its_vlpi_map *map = get_vlpi_map(d);
312+
if (map)
313+
vpe = map->vpe;
314+
}
297315

298-
if (map)
299-
vpe_to_cpuid_unlock(map->vpe, flags);
316+
if (vpe)
317+
vpe_to_cpuid_unlock(vpe, flags);
300318
}
301319

302320
static struct its_collection *valid_col(struct its_collection *col)
@@ -1433,14 +1451,29 @@ static void wait_for_syncr(void __iomem *rdbase)
14331451
cpu_relax();
14341452
}
14351453

1436-
static void direct_lpi_inv(struct irq_data *d)
1454+
static void __direct_lpi_inv(struct irq_data *d, u64 val)
14371455
{
1438-
struct its_vlpi_map *map = get_vlpi_map(d);
14391456
void __iomem *rdbase;
14401457
unsigned long flags;
1441-
u64 val;
14421458
int cpu;
14431459

1460+
/* Target the redistributor this LPI is currently routed to */
1461+
cpu = irq_to_cpuid_lock(d, &flags);
1462+
raw_spin_lock(&gic_data_rdist_cpu(cpu)->rd_lock);
1463+
1464+
rdbase = per_cpu_ptr(gic_rdists->rdist, cpu)->rd_base;
1465+
gic_write_lpir(val, rdbase + GICR_INVLPIR);
1466+
wait_for_syncr(rdbase);
1467+
1468+
raw_spin_unlock(&gic_data_rdist_cpu(cpu)->rd_lock);
1469+
irq_to_cpuid_unlock(d, flags);
1470+
}
1471+
1472+
static void direct_lpi_inv(struct irq_data *d)
1473+
{
1474+
struct its_vlpi_map *map = get_vlpi_map(d);
1475+
u64 val;
1476+
14441477
if (map) {
14451478
struct its_device *its_dev = irq_data_get_irq_chip_data(d);
14461479

@@ -1453,15 +1486,7 @@ static void direct_lpi_inv(struct irq_data *d)
14531486
val = d->hwirq;
14541487
}
14551488

1456-
/* Target the redistributor this LPI is currently routed to */
1457-
cpu = irq_to_cpuid_lock(d, &flags);
1458-
raw_spin_lock(&gic_data_rdist_cpu(cpu)->rd_lock);
1459-
rdbase = per_cpu_ptr(gic_rdists->rdist, cpu)->rd_base;
1460-
gic_write_lpir(val, rdbase + GICR_INVLPIR);
1461-
1462-
wait_for_syncr(rdbase);
1463-
raw_spin_unlock(&gic_data_rdist_cpu(cpu)->rd_lock);
1464-
irq_to_cpuid_unlock(d, flags);
1489+
__direct_lpi_inv(d, val);
14651490
}
14661491

14671492
static void lpi_update_config(struct irq_data *d, u8 clr, u8 set)
@@ -3953,18 +3978,10 @@ static void its_vpe_send_inv(struct irq_data *d)
39533978
{
39543979
struct its_vpe *vpe = irq_data_get_irq_chip_data(d);
39553980

3956-
if (gic_rdists->has_direct_lpi) {
3957-
void __iomem *rdbase;
3958-
3959-
/* Target the redistributor this VPE is currently known on */
3960-
raw_spin_lock(&gic_data_rdist_cpu(vpe->col_idx)->rd_lock);
3961-
rdbase = per_cpu_ptr(gic_rdists->rdist, vpe->col_idx)->rd_base;
3962-
gic_write_lpir(d->parent_data->hwirq, rdbase + GICR_INVLPIR);
3963-
wait_for_syncr(rdbase);
3964-
raw_spin_unlock(&gic_data_rdist_cpu(vpe->col_idx)->rd_lock);
3965-
} else {
3981+
if (gic_rdists->has_direct_lpi)
3982+
__direct_lpi_inv(d, d->parent_data->hwirq);
3983+
else
39663984
its_vpe_send_cmd(vpe, its_send_inv);
3967-
}
39683985
}
39693986

39703987
static void its_vpe_mask_irq(struct irq_data *d)
@@ -4727,7 +4744,8 @@ static bool __maybe_unused its_enable_rk3588001(void *data)
47274744
{
47284745
struct its_node *its = data;
47294746

4730-
if (!of_machine_is_compatible("rockchip,rk3588"))
4747+
if (!of_machine_is_compatible("rockchip,rk3588") &&
4748+
!of_machine_is_compatible("rockchip,rk3588s"))
47314749
return false;
47324750

47334751
its->flags |= ITS_FLAGS_FORCE_NON_SHAREABLE;

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)