Skip to content

Commit f4a81f5

Browse files
author
Marc Zyngier
committed
irqchip/gic-v4.1: Allow direct invalidation of VLPIs
Just like for INVALL, GICv4.1 has grown a VPE-aware INVLPI register. Let's plumb it in and make use of the DirectLPI code in that case. Signed-off-by: Marc Zyngier <[email protected]> Reviewed-by: Zenghui Yu <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 3858d4d commit f4a81f5

File tree

2 files changed

+37
-19
lines changed

2 files changed

+37
-19
lines changed

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

Lines changed: 36 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -227,11 +227,27 @@ static struct its_vlpi_map *dev_event_to_vlpi_map(struct its_device *its_dev,
227227
return &its_dev->event_map.vlpi_maps[event];
228228
}
229229

230-
static struct its_collection *irq_to_col(struct irq_data *d)
230+
static struct its_vlpi_map *get_vlpi_map(struct irq_data *d)
231+
{
232+
if (irqd_is_forwarded_to_vcpu(d)) {
233+
struct its_device *its_dev = irq_data_get_irq_chip_data(d);
234+
u32 event = its_get_event_id(d);
235+
236+
return dev_event_to_vlpi_map(its_dev, event);
237+
}
238+
239+
return NULL;
240+
}
241+
242+
static int irq_to_cpuid(struct irq_data *d)
231243
{
232244
struct its_device *its_dev = irq_data_get_irq_chip_data(d);
245+
struct its_vlpi_map *map = get_vlpi_map(d);
246+
247+
if (map)
248+
return map->vpe->col_idx;
233249

234-
return dev_event_to_col(its_dev, its_get_event_id(d));
250+
return its_dev->event_map.col_map[its_get_event_id(d)];
235251
}
236252

237253
static struct its_collection *valid_col(struct its_collection *col)
@@ -1269,18 +1285,6 @@ static void its_send_invdb(struct its_node *its, struct its_vpe *vpe)
12691285
/*
12701286
* irqchip functions - assumes MSI, mostly.
12711287
*/
1272-
static struct its_vlpi_map *get_vlpi_map(struct irq_data *d)
1273-
{
1274-
if (irqd_is_forwarded_to_vcpu(d)) {
1275-
struct its_device *its_dev = irq_data_get_irq_chip_data(d);
1276-
u32 event = its_get_event_id(d);
1277-
1278-
return dev_event_to_vlpi_map(its_dev, event);
1279-
}
1280-
1281-
return NULL;
1282-
}
1283-
12841288
static void lpi_write_config(struct irq_data *d, u8 clr, u8 set)
12851289
{
12861290
struct its_vlpi_map *map = get_vlpi_map(d);
@@ -1323,13 +1327,25 @@ static void wait_for_syncr(void __iomem *rdbase)
13231327

13241328
static void direct_lpi_inv(struct irq_data *d)
13251329
{
1326-
struct its_collection *col;
1330+
struct its_vlpi_map *map = get_vlpi_map(d);
13271331
void __iomem *rdbase;
1332+
u64 val;
1333+
1334+
if (map) {
1335+
struct its_device *its_dev = irq_data_get_irq_chip_data(d);
1336+
1337+
WARN_ON(!is_v4_1(its_dev->its));
1338+
1339+
val = GICR_INVLPIR_V;
1340+
val |= FIELD_PREP(GICR_INVLPIR_VPEID, map->vpe->vpe_id);
1341+
val |= FIELD_PREP(GICR_INVLPIR_INTID, map->vintid);
1342+
} else {
1343+
val = d->hwirq;
1344+
}
13281345

13291346
/* Target the redistributor this LPI is currently routed to */
1330-
col = irq_to_col(d);
1331-
rdbase = per_cpu_ptr(gic_rdists->rdist, col->col_id)->rd_base;
1332-
gic_write_lpir(d->hwirq, rdbase + GICR_INVLPIR);
1347+
rdbase = per_cpu_ptr(gic_rdists->rdist, irq_to_cpuid(d))->rd_base;
1348+
gic_write_lpir(val, rdbase + GICR_INVLPIR);
13331349

13341350
wait_for_syncr(rdbase);
13351351
}
@@ -1339,7 +1355,8 @@ static void lpi_update_config(struct irq_data *d, u8 clr, u8 set)
13391355
struct its_device *its_dev = irq_data_get_irq_chip_data(d);
13401356

13411357
lpi_write_config(d, clr, set);
1342-
if (gic_rdists->has_direct_lpi && !irqd_is_forwarded_to_vcpu(d))
1358+
if (gic_rdists->has_direct_lpi &&
1359+
(is_v4_1(its_dev->its) || !irqd_is_forwarded_to_vcpu(d)))
13431360
direct_lpi_inv(d);
13441361
else if (!irqd_is_forwarded_to_vcpu(d))
13451362
its_send_inv(its_dev, its_get_event_id(d));

include/linux/irqchip/arm-gic-v3.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@
247247
#define GICR_TYPER_COMMON_LPI_AFF GENMASK_ULL(25, 24)
248248
#define GICR_TYPER_AFFINITY GENMASK_ULL(63, 32)
249249

250+
#define GICR_INVLPIR_INTID GENMASK_ULL(31, 0)
250251
#define GICR_INVLPIR_VPEID GENMASK_ULL(47, 32)
251252
#define GICR_INVLPIR_V GENMASK_ULL(63, 63)
252253

0 commit comments

Comments
 (0)