Skip to content

Commit 64edfaa

Browse files
author
Marc Zyngier
committed
irqchip/gic-v4.1: Implement the v4.1 flavour of VMAPP
The ITS VMAPP command gains some new fields with GICv4.1: - a default doorbell, which allows a single doorbell to be used for all the VLPIs routed to a given VPE - a pointer to the configuration table (instead of having it in a register that gets context switched) - a flag indicating whether this is the first map or the last unmap for this particular VPE - a flag indicating whether the pending table is known to be zeroed, or not Plumb in the new fields in the VMAPP builder, and add the map/unmap refcounting so that the ITS can do the right thing. Signed-off-by: Marc Zyngier <[email protected]> Reviewed-by: Zenghui Yu <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 5e51684 commit 64edfaa

File tree

2 files changed

+69
-9
lines changed

2 files changed

+69
-9
lines changed

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

Lines changed: 55 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,27 @@ static void its_encode_vpt_size(struct its_cmd_block *cmd, u8 vpt_size)
449449
its_mask_encode(&cmd->raw_cmd[3], vpt_size, 4, 0);
450450
}
451451

452+
static void its_encode_vconf_addr(struct its_cmd_block *cmd, u64 vconf_pa)
453+
{
454+
its_mask_encode(&cmd->raw_cmd[0], vconf_pa >> 16, 51, 16);
455+
}
456+
457+
static void its_encode_alloc(struct its_cmd_block *cmd, bool alloc)
458+
{
459+
its_mask_encode(&cmd->raw_cmd[0], alloc, 8, 8);
460+
}
461+
462+
static void its_encode_ptz(struct its_cmd_block *cmd, bool ptz)
463+
{
464+
its_mask_encode(&cmd->raw_cmd[0], ptz, 9, 9);
465+
}
466+
467+
static void its_encode_vmapp_default_db(struct its_cmd_block *cmd,
468+
u32 vpe_db_lpi)
469+
{
470+
its_mask_encode(&cmd->raw_cmd[1], vpe_db_lpi, 31, 0);
471+
}
472+
452473
static inline void its_fixup_cmd(struct its_cmd_block *cmd)
453474
{
454475
/* Let's fixup BE commands */
@@ -632,19 +653,45 @@ static struct its_vpe *its_build_vmapp_cmd(struct its_node *its,
632653
struct its_cmd_block *cmd,
633654
struct its_cmd_desc *desc)
634655
{
635-
unsigned long vpt_addr;
656+
unsigned long vpt_addr, vconf_addr;
636657
u64 target;
637-
638-
vpt_addr = virt_to_phys(page_address(desc->its_vmapp_cmd.vpe->vpt_page));
639-
target = desc->its_vmapp_cmd.col->target_address + its->vlpi_redist_offset;
658+
bool alloc;
640659

641660
its_encode_cmd(cmd, GITS_CMD_VMAPP);
642661
its_encode_vpeid(cmd, desc->its_vmapp_cmd.vpe->vpe_id);
643662
its_encode_valid(cmd, desc->its_vmapp_cmd.valid);
663+
664+
if (!desc->its_vmapp_cmd.valid) {
665+
if (is_v4_1(its)) {
666+
alloc = !atomic_dec_return(&desc->its_vmapp_cmd.vpe->vmapp_count);
667+
its_encode_alloc(cmd, alloc);
668+
}
669+
670+
goto out;
671+
}
672+
673+
vpt_addr = virt_to_phys(page_address(desc->its_vmapp_cmd.vpe->vpt_page));
674+
target = desc->its_vmapp_cmd.col->target_address + its->vlpi_redist_offset;
675+
644676
its_encode_target(cmd, target);
645677
its_encode_vpt_addr(cmd, vpt_addr);
646678
its_encode_vpt_size(cmd, LPI_NRBITS - 1);
647679

680+
if (!is_v4_1(its))
681+
goto out;
682+
683+
vconf_addr = virt_to_phys(page_address(desc->its_vmapp_cmd.vpe->its_vm->vprop_page));
684+
685+
alloc = !atomic_fetch_inc(&desc->its_vmapp_cmd.vpe->vmapp_count);
686+
687+
its_encode_alloc(cmd, alloc);
688+
689+
/* We can only signal PTZ when alloc==1. Why do we have two bits? */
690+
its_encode_ptz(cmd, alloc);
691+
its_encode_vconf_addr(cmd, vconf_addr);
692+
its_encode_vmapp_default_db(cmd, desc->its_vmapp_cmd.vpe->vpe_db_lpi);
693+
694+
out:
648695
its_fixup_cmd(cmd);
649696

650697
return valid_vpe(its, desc->its_vmapp_cmd.vpe);
@@ -3492,7 +3539,10 @@ static int its_vpe_init(struct its_vpe *vpe)
34923539

34933540
vpe->vpe_id = vpe_id;
34943541
vpe->vpt_page = vpt_page;
3495-
vpe->vpe_proxy_event = -1;
3542+
if (gic_rdists->has_rvpeid)
3543+
atomic_set(&vpe->vmapp_count, 0);
3544+
else
3545+
vpe->vpe_proxy_event = -1;
34963546

34973547
return 0;
34983548
}

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

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,20 @@ struct its_vpe {
3939
irq_hw_number_t vpe_db_lpi;
4040
/* VPE resident */
4141
bool resident;
42-
/* VPE proxy mapping */
43-
int vpe_proxy_event;
42+
union {
43+
/* GICv4.0 implementations */
44+
struct {
45+
/* VPE proxy mapping */
46+
int vpe_proxy_event;
47+
/* Implementation Defined Area Invalid */
48+
bool idai;
49+
};
50+
/* GICv4.1 implementations */
51+
struct {
52+
atomic_t vmapp_count;
53+
};
54+
};
55+
4456
/*
4557
* This collection ID is used to indirect the target
4658
* redistributor for this VPE. The ID itself isn't involved in
@@ -49,8 +61,6 @@ struct its_vpe {
4961
u16 col_idx;
5062
/* Unique (system-wide) VPE identifier */
5163
u16 vpe_id;
52-
/* Implementation Defined Area Invalid */
53-
bool idai;
5464
/* Pending VLPIs on schedule out? */
5565
bool pending_last;
5666
};

0 commit comments

Comments
 (0)