Skip to content

Commit e64fab1

Browse files
author
Marc Zyngier
committed
irqchip/gic-v4.1: Add VPE eviction callback
When descheduling a VPE, special care must be taken to tell the GIC about whether we want to receive a doorbell or not. This is a major improvement on GICv4.0, where the doorbell had to be separately enabled/disabled. Signed-off-by: Marc Zyngier <[email protected]> Reviewed-by: Zenghui Yu <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 91bf639 commit e64fab1

File tree

1 file changed

+42
-11
lines changed

1 file changed

+42
-11
lines changed

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

Lines changed: 42 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2630,14 +2630,16 @@ static int __init allocate_lpi_tables(void)
26302630
return 0;
26312631
}
26322632

2633-
static u64 its_clear_vpend_valid(void __iomem *vlpi_base)
2633+
static u64 its_clear_vpend_valid(void __iomem *vlpi_base, u64 clr, u64 set)
26342634
{
26352635
u32 count = 1000000; /* 1s! */
26362636
bool clean;
26372637
u64 val;
26382638

26392639
val = gits_read_vpendbaser(vlpi_base + GICR_VPENDBASER);
26402640
val &= ~GICR_VPENDBASER_Valid;
2641+
val &= ~clr;
2642+
val |= set;
26412643
gits_write_vpendbaser(val, vlpi_base + GICR_VPENDBASER);
26422644

26432645
do {
@@ -2650,6 +2652,11 @@ static u64 its_clear_vpend_valid(void __iomem *vlpi_base)
26502652
}
26512653
} while (!clean && count);
26522654

2655+
if (unlikely(val & GICR_VPENDBASER_Dirty)) {
2656+
pr_err_ratelimited("ITS virtual pending table not cleaning\n");
2657+
val |= GICR_VPENDBASER_PendingLast;
2658+
}
2659+
26532660
return val;
26542661
}
26552662

@@ -2758,7 +2765,7 @@ static void its_cpu_init_lpis(void)
27582765
* ancient programming gets left in and has possibility of
27592766
* corrupting memory.
27602767
*/
2761-
val = its_clear_vpend_valid(vlpi_base);
2768+
val = its_clear_vpend_valid(vlpi_base, 0, 0);
27622769
WARN_ON(val & GICR_VPENDBASER_Dirty);
27632770
}
27642771

@@ -3438,16 +3445,10 @@ static void its_vpe_deschedule(struct its_vpe *vpe)
34383445
void __iomem *vlpi_base = gic_data_rdist_vlpi_base();
34393446
u64 val;
34403447

3441-
val = its_clear_vpend_valid(vlpi_base);
3448+
val = its_clear_vpend_valid(vlpi_base, 0, 0);
34423449

3443-
if (unlikely(val & GICR_VPENDBASER_Dirty)) {
3444-
pr_err_ratelimited("ITS virtual pending table not cleaning\n");
3445-
vpe->idai = false;
3446-
vpe->pending_last = true;
3447-
} else {
3448-
vpe->idai = !!(val & GICR_VPENDBASER_IDAI);
3449-
vpe->pending_last = !!(val & GICR_VPENDBASER_PendingLast);
3450-
}
3450+
vpe->idai = !!(val & GICR_VPENDBASER_IDAI);
3451+
vpe->pending_last = !!(val & GICR_VPENDBASER_PendingLast);
34513452
}
34523453

34533454
static void its_vpe_invall(struct its_vpe *vpe)
@@ -3639,6 +3640,35 @@ static void its_vpe_4_1_schedule(struct its_vpe *vpe,
36393640
gits_write_vpendbaser(val, vlpi_base + GICR_VPENDBASER);
36403641
}
36413642

3643+
static void its_vpe_4_1_deschedule(struct its_vpe *vpe,
3644+
struct its_cmd_info *info)
3645+
{
3646+
void __iomem *vlpi_base = gic_data_rdist_vlpi_base();
3647+
u64 val;
3648+
3649+
if (info->req_db) {
3650+
/*
3651+
* vPE is going to block: make the vPE non-resident with
3652+
* PendingLast clear and DB set. The GIC guarantees that if
3653+
* we read-back PendingLast clear, then a doorbell will be
3654+
* delivered when an interrupt comes.
3655+
*/
3656+
val = its_clear_vpend_valid(vlpi_base,
3657+
GICR_VPENDBASER_PendingLast,
3658+
GICR_VPENDBASER_4_1_DB);
3659+
vpe->pending_last = !!(val & GICR_VPENDBASER_PendingLast);
3660+
} else {
3661+
/*
3662+
* We're not blocking, so just make the vPE non-resident
3663+
* with PendingLast set, indicating that we'll be back.
3664+
*/
3665+
val = its_clear_vpend_valid(vlpi_base,
3666+
0,
3667+
GICR_VPENDBASER_PendingLast);
3668+
vpe->pending_last = true;
3669+
}
3670+
}
3671+
36423672
static int its_vpe_4_1_set_vcpu_affinity(struct irq_data *d, void *vcpu_info)
36433673
{
36443674
struct its_vpe *vpe = irq_data_get_irq_chip_data(d);
@@ -3650,6 +3680,7 @@ static int its_vpe_4_1_set_vcpu_affinity(struct irq_data *d, void *vcpu_info)
36503680
return 0;
36513681

36523682
case DESCHEDULE_VPE:
3683+
its_vpe_4_1_deschedule(vpe, info);
36533684
return 0;
36543685

36553686
case INVALL_VPE:

0 commit comments

Comments
 (0)