Skip to content

Commit 846297e

Browse files
Marc ZyngierKAGA-KOKO
authored andcommitted
irqchip/gic-v3-its: Handle non-coherent GICv4 redistributors
Although the GICv3 code base has gained some handling of systems failing to handle the shareability attributes, the GICv4 side of things has been firmly ignored. This is unfortunate, as the new recent addition of the "dma-noncoherent" is supposed to apply to all of the GICR tables, and not just the ones that are common to v3 and v4. Add some checks to handle the VPROPBASE/VPENDBASE shareability and cacheability attributes in the same way we deal with the other GICR_BASE registers, wrapping the flag check in a helper for improved readability. Note that this has been found by inspection only, as I don't have access to HW that suffers from this particular issue. Fixes: 3a0fff0 ("irqchip/gic-v3: Enable non-coherent redistributors/ITSes DT probing") Signed-off-by: Marc Zyngier <maz@kernel.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Lorenzo Pieralisi <lpieralisi@kernel.org> Link: https://lore.kernel.org/r/20240213101206.2137483-2-maz@kernel.org
1 parent 8ad032c commit 846297e

File tree

1 file changed

+25
-12
lines changed

1 file changed

+25
-12
lines changed

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

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,11 @@ static bool require_its_list_vmovp(struct its_vm *vm, struct its_node *its)
207207
return (gic_rdists->has_rvpeid || vm->vlpi_count[its->list_nr]);
208208
}
209209

210+
static bool rdists_support_shareable(void)
211+
{
212+
return !(gic_rdists->flags & RDIST_FLAGS_FORCE_NON_SHAREABLE);
213+
}
214+
210215
static u16 get_its_list(struct its_vm *vm)
211216
{
212217
struct its_node *its;
@@ -2710,10 +2715,12 @@ static u64 inherit_vpe_l1_table_from_its(void)
27102715
break;
27112716
}
27122717
val |= FIELD_PREP(GICR_VPROPBASER_4_1_ADDR, addr >> 12);
2713-
val |= FIELD_PREP(GICR_VPROPBASER_SHAREABILITY_MASK,
2714-
FIELD_GET(GITS_BASER_SHAREABILITY_MASK, baser));
2715-
val |= FIELD_PREP(GICR_VPROPBASER_INNER_CACHEABILITY_MASK,
2716-
FIELD_GET(GITS_BASER_INNER_CACHEABILITY_MASK, baser));
2718+
if (rdists_support_shareable()) {
2719+
val |= FIELD_PREP(GICR_VPROPBASER_SHAREABILITY_MASK,
2720+
FIELD_GET(GITS_BASER_SHAREABILITY_MASK, baser));
2721+
val |= FIELD_PREP(GICR_VPROPBASER_INNER_CACHEABILITY_MASK,
2722+
FIELD_GET(GITS_BASER_INNER_CACHEABILITY_MASK, baser));
2723+
}
27172724
val |= FIELD_PREP(GICR_VPROPBASER_4_1_SIZE, GITS_BASER_NR_PAGES(baser) - 1);
27182725

27192726
return val;
@@ -2936,8 +2943,10 @@ static int allocate_vpe_l1_table(void)
29362943
WARN_ON(!IS_ALIGNED(pa, psz));
29372944

29382945
val |= FIELD_PREP(GICR_VPROPBASER_4_1_ADDR, pa >> 12);
2939-
val |= GICR_VPROPBASER_RaWb;
2940-
val |= GICR_VPROPBASER_InnerShareable;
2946+
if (rdists_support_shareable()) {
2947+
val |= GICR_VPROPBASER_RaWb;
2948+
val |= GICR_VPROPBASER_InnerShareable;
2949+
}
29412950
val |= GICR_VPROPBASER_4_1_Z;
29422951
val |= GICR_VPROPBASER_4_1_VALID;
29432952

@@ -3126,7 +3135,7 @@ static void its_cpu_init_lpis(void)
31263135
gicr_write_propbaser(val, rbase + GICR_PROPBASER);
31273136
tmp = gicr_read_propbaser(rbase + GICR_PROPBASER);
31283137

3129-
if (gic_rdists->flags & RDIST_FLAGS_FORCE_NON_SHAREABLE)
3138+
if (!rdists_support_shareable())
31303139
tmp &= ~GICR_PROPBASER_SHAREABILITY_MASK;
31313140

31323141
if ((tmp ^ val) & GICR_PROPBASER_SHAREABILITY_MASK) {
@@ -3153,7 +3162,7 @@ static void its_cpu_init_lpis(void)
31533162
gicr_write_pendbaser(val, rbase + GICR_PENDBASER);
31543163
tmp = gicr_read_pendbaser(rbase + GICR_PENDBASER);
31553164

3156-
if (gic_rdists->flags & RDIST_FLAGS_FORCE_NON_SHAREABLE)
3165+
if (!rdists_support_shareable())
31573166
tmp &= ~GICR_PENDBASER_SHAREABILITY_MASK;
31583167

31593168
if (!(tmp & GICR_PENDBASER_SHAREABILITY_MASK)) {
@@ -3880,14 +3889,18 @@ static void its_vpe_schedule(struct its_vpe *vpe)
38803889
val = virt_to_phys(page_address(vpe->its_vm->vprop_page)) &
38813890
GENMASK_ULL(51, 12);
38823891
val |= (LPI_NRBITS - 1) & GICR_VPROPBASER_IDBITS_MASK;
3883-
val |= GICR_VPROPBASER_RaWb;
3884-
val |= GICR_VPROPBASER_InnerShareable;
3892+
if (rdists_support_shareable()) {
3893+
val |= GICR_VPROPBASER_RaWb;
3894+
val |= GICR_VPROPBASER_InnerShareable;
3895+
}
38853896
gicr_write_vpropbaser(val, vlpi_base + GICR_VPROPBASER);
38863897

38873898
val = virt_to_phys(page_address(vpe->vpt_page)) &
38883899
GENMASK_ULL(51, 16);
3889-
val |= GICR_VPENDBASER_RaWaWb;
3890-
val |= GICR_VPENDBASER_InnerShareable;
3900+
if (rdists_support_shareable()) {
3901+
val |= GICR_VPENDBASER_RaWaWb;
3902+
val |= GICR_VPENDBASER_InnerShareable;
3903+
}
38913904
/*
38923905
* There is no good way of finding out if the pending table is
38933906
* empty as we can race against the doorbell interrupt very

0 commit comments

Comments
 (0)