Skip to content

Commit fbf8f40

Browse files
Ganapatrao KulkarniMarc Zyngier
authored andcommitted
irqchip/gicv3-its: numa: Enable workaround for Cavium thunderx erratum 23144
The erratum fixes the hang of ITS SYNC command by avoiding inter node io and collections/cpu mapping on thunderx dual-socket platform. This fix is only applicable for Cavium's ThunderX dual-socket platform. Reviewed-by: Robert Richter <[email protected]> Signed-off-by: Ganapatrao Kulkarni <[email protected]> Signed-off-by: Robert Richter <[email protected]> Signed-off-by: Marc Zyngier <[email protected]>
1 parent cf1d9d1 commit fbf8f40

File tree

3 files changed

+57
-2
lines changed

3 files changed

+57
-2
lines changed

Documentation/arm64/silicon-errata.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ stable kernels.
5656
| ARM | MMU-500 | #841119,#826419 | N/A |
5757
| | | | |
5858
| Cavium | ThunderX ITS | #22375, #24313 | CAVIUM_ERRATUM_22375 |
59+
| Cavium | ThunderX ITS | #23144 | CAVIUM_ERRATUM_23144 |
5960
| Cavium | ThunderX GICv3 | #23154 | CAVIUM_ERRATUM_23154 |
6061
| Cavium | ThunderX Core | #27456 | CAVIUM_ERRATUM_27456 |
6162
| Cavium | ThunderX SMMUv2 | #27704 | N/A |

arch/arm64/Kconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,15 @@ config CAVIUM_ERRATUM_22375
426426

427427
If unsure, say Y.
428428

429+
config CAVIUM_ERRATUM_23144
430+
bool "Cavium erratum 23144: ITS SYNC hang on dual socket system"
431+
depends on NUMA
432+
default y
433+
help
434+
ITS SYNC command hang for cross node io and collections/cpu mapping.
435+
436+
If unsure, say Y.
437+
429438
config CAVIUM_ERRATUM_23154
430439
bool "Cavium erratum 23154: Access to ICC_IAR1_EL1 is not sync'ed"
431440
default y

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

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141

4242
#define ITS_FLAGS_CMDQ_NEEDS_FLUSHING (1ULL << 0)
4343
#define ITS_FLAGS_WORKAROUND_CAVIUM_22375 (1ULL << 1)
44+
#define ITS_FLAGS_WORKAROUND_CAVIUM_23144 (1ULL << 2)
4445

4546
#define RDIST_FLAGS_PROPBASE_NEEDS_FLUSHING (1 << 0)
4647

@@ -82,6 +83,7 @@ struct its_node {
8283
u64 flags;
8384
u32 ite_size;
8485
u32 device_ids;
86+
int numa_node;
8587
};
8688

8789
#define ITS_ITT_ALIGN SZ_256
@@ -613,11 +615,23 @@ static void its_unmask_irq(struct irq_data *d)
613615
static int its_set_affinity(struct irq_data *d, const struct cpumask *mask_val,
614616
bool force)
615617
{
616-
unsigned int cpu = cpumask_any_and(mask_val, cpu_online_mask);
618+
unsigned int cpu;
619+
const struct cpumask *cpu_mask = cpu_online_mask;
617620
struct its_device *its_dev = irq_data_get_irq_chip_data(d);
618621
struct its_collection *target_col;
619622
u32 id = its_get_event_id(d);
620623

624+
/* lpi cannot be routed to a redistributor that is on a foreign node */
625+
if (its_dev->its->flags & ITS_FLAGS_WORKAROUND_CAVIUM_23144) {
626+
if (its_dev->its->numa_node >= 0) {
627+
cpu_mask = cpumask_of_node(its_dev->its->numa_node);
628+
if (!cpumask_intersects(mask_val, cpu_mask))
629+
return -EINVAL;
630+
}
631+
}
632+
633+
cpu = cpumask_any_and(mask_val, cpu_mask);
634+
621635
if (cpu >= nr_cpu_ids)
622636
return -EINVAL;
623637

@@ -1101,6 +1115,16 @@ static void its_cpu_init_collection(void)
11011115
list_for_each_entry(its, &its_nodes, entry) {
11021116
u64 target;
11031117

1118+
/* avoid cross node collections and its mapping */
1119+
if (its->flags & ITS_FLAGS_WORKAROUND_CAVIUM_23144) {
1120+
struct device_node *cpu_node;
1121+
1122+
cpu_node = of_get_cpu_node(cpu, NULL);
1123+
if (its->numa_node != NUMA_NO_NODE &&
1124+
its->numa_node != of_node_to_nid(cpu_node))
1125+
continue;
1126+
}
1127+
11041128
/*
11051129
* We now have to bind each collection to its target
11061130
* redistributor.
@@ -1351,9 +1375,14 @@ static void its_irq_domain_activate(struct irq_domain *domain,
13511375
{
13521376
struct its_device *its_dev = irq_data_get_irq_chip_data(d);
13531377
u32 event = its_get_event_id(d);
1378+
const struct cpumask *cpu_mask = cpu_online_mask;
1379+
1380+
/* get the cpu_mask of local node */
1381+
if (its_dev->its->numa_node >= 0)
1382+
cpu_mask = cpumask_of_node(its_dev->its->numa_node);
13541383

13551384
/* Bind the LPI to the first possible CPU */
1356-
its_dev->event_map.col_map[event] = cpumask_first(cpu_online_mask);
1385+
its_dev->event_map.col_map[event] = cpumask_first(cpu_mask);
13571386

13581387
/* Map the GIC IRQ and event to the device */
13591388
its_send_mapvi(its_dev, d->hwirq, event);
@@ -1443,6 +1472,13 @@ static void __maybe_unused its_enable_quirk_cavium_22375(void *data)
14431472
its->flags |= ITS_FLAGS_WORKAROUND_CAVIUM_22375;
14441473
}
14451474

1475+
static void __maybe_unused its_enable_quirk_cavium_23144(void *data)
1476+
{
1477+
struct its_node *its = data;
1478+
1479+
its->flags |= ITS_FLAGS_WORKAROUND_CAVIUM_23144;
1480+
}
1481+
14461482
static const struct gic_quirk its_quirks[] = {
14471483
#ifdef CONFIG_CAVIUM_ERRATUM_22375
14481484
{
@@ -1451,6 +1487,14 @@ static const struct gic_quirk its_quirks[] = {
14511487
.mask = 0xffff0fff,
14521488
.init = its_enable_quirk_cavium_22375,
14531489
},
1490+
#endif
1491+
#ifdef CONFIG_CAVIUM_ERRATUM_23144
1492+
{
1493+
.desc = "ITS: Cavium erratum 23144",
1494+
.iidr = 0xa100034c, /* ThunderX pass 1.x */
1495+
.mask = 0xffff0fff,
1496+
.init = its_enable_quirk_cavium_23144,
1497+
},
14541498
#endif
14551499
{
14561500
}
@@ -1514,6 +1558,7 @@ static int __init its_probe(struct device_node *node,
15141558
its->base = its_base;
15151559
its->phys_base = res.start;
15161560
its->ite_size = ((readl_relaxed(its_base + GITS_TYPER) >> 4) & 0xf) + 1;
1561+
its->numa_node = of_node_to_nid(node);
15171562

15181563
its->cmd_base = kzalloc(ITS_CMD_QUEUE_SZ, GFP_KERNEL);
15191564
if (!its->cmd_base) {

0 commit comments

Comments
 (0)