Skip to content

Commit 0dd57fe

Browse files
author
Marc Zyngier
committed
irqchip/gic-v3-its: Make is_v4 use a TYPER copy
Instead of caching the GICv4 compatibility in a discrete way, cache the TYPER register instead, which can then be used to implement the same functionnality. This will get used more extensively in subsequent patches. Signed-off-by: Marc Zyngier <maz@kernel.org> Reviewed-by: Zenghui Yu <yuzenghui@huawei.com> Link: https://lore.kernel.org/r/20191027144234.8395-5-maz@kernel.org Link: https://lore.kernel.org/r/20191108165805.3071-5-maz@kernel.org
1 parent 425c09b commit 0dd57fe

1 file changed

Lines changed: 14 additions & 12 deletions

File tree

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

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ struct its_node {
102102
struct its_collection *collections;
103103
struct fwnode_handle *fwnode_handle;
104104
u64 (*get_msi_base)(struct its_device *its_dev);
105+
u64 typer;
105106
u64 cbaser_save;
106107
u32 ctlr_save;
107108
struct list_head its_device_list;
@@ -112,10 +113,11 @@ struct its_node {
112113
int numa_node;
113114
unsigned int msi_domain_flags;
114115
u32 pre_its_base; /* for Socionext Synquacer */
115-
bool is_v4;
116116
int vlpi_redist_offset;
117117
};
118118

119+
#define is_v4(its) (!!((its)->typer & GITS_TYPER_VLPIS))
120+
119121
#define ITS_ITT_ALIGN SZ_256
120122

121123
/* The maximum number of VPEID bits supported by VLPI commands */
@@ -181,7 +183,7 @@ static u16 get_its_list(struct its_vm *vm)
181183
unsigned long its_list = 0;
182184

183185
list_for_each_entry(its, &its_nodes, entry) {
184-
if (!its->is_v4)
186+
if (!is_v4(its))
185187
continue;
186188

187189
if (vm->vlpi_count[its->list_nr])
@@ -1037,7 +1039,7 @@ static void its_send_vmovp(struct its_vpe *vpe)
10371039

10381040
/* Emit VMOVPs */
10391041
list_for_each_entry(its, &its_nodes, entry) {
1040-
if (!its->is_v4)
1042+
if (!is_v4(its))
10411043
continue;
10421044

10431045
if (!vpe->its_vm->vlpi_count[its->list_nr])
@@ -1448,7 +1450,7 @@ static int its_irq_set_vcpu_affinity(struct irq_data *d, void *vcpu_info)
14481450
struct its_cmd_info *info = vcpu_info;
14491451

14501452
/* Need a v4 ITS */
1451-
if (!its_dev->its->is_v4)
1453+
if (!is_v4(its_dev->its))
14521454
return -EINVAL;
14531455

14541456
/* Unmap request? */
@@ -2412,7 +2414,7 @@ static bool its_alloc_vpe_table(u32 vpe_id)
24122414
list_for_each_entry(its, &its_nodes, entry) {
24132415
struct its_baser *baser;
24142416

2415-
if (!its->is_v4)
2417+
if (!is_v4(its))
24162418
continue;
24172419

24182420
baser = its_get_baser(its, GITS_BASER_TYPE_VCPU);
@@ -2900,7 +2902,7 @@ static void its_vpe_invall(struct its_vpe *vpe)
29002902
struct its_node *its;
29012903

29022904
list_for_each_entry(its, &its_nodes, entry) {
2903-
if (!its->is_v4)
2905+
if (!is_v4(its))
29042906
continue;
29052907

29062908
if (its_list_map && !vpe->its_vm->vlpi_count[its->list_nr])
@@ -3168,7 +3170,7 @@ static int its_vpe_irq_domain_activate(struct irq_domain *domain,
31683170
vpe->col_idx = cpumask_first(cpu_online_mask);
31693171

31703172
list_for_each_entry(its, &its_nodes, entry) {
3171-
if (!its->is_v4)
3173+
if (!is_v4(its))
31723174
continue;
31733175

31743176
its_send_vmapp(its, vpe, true);
@@ -3194,7 +3196,7 @@ static void its_vpe_irq_domain_deactivate(struct irq_domain *domain,
31943196
return;
31953197

31963198
list_for_each_entry(its, &its_nodes, entry) {
3197-
if (!its->is_v4)
3199+
if (!is_v4(its))
31983200
continue;
31993201

32003202
its_send_vmapp(its, vpe, false);
@@ -3632,12 +3634,12 @@ static int __init its_probe_one(struct resource *res,
36323634
INIT_LIST_HEAD(&its->entry);
36333635
INIT_LIST_HEAD(&its->its_device_list);
36343636
typer = gic_read_typer(its_base + GITS_TYPER);
3637+
its->typer = typer;
36353638
its->base = its_base;
36363639
its->phys_base = res->start;
36373640
its->ite_size = GITS_TYPER_ITT_ENTRY_SIZE(typer);
36383641
its->device_ids = GITS_TYPER_DEVBITS(typer);
3639-
its->is_v4 = !!(typer & GITS_TYPER_VLPIS);
3640-
if (its->is_v4) {
3642+
if (is_v4(its)) {
36413643
if (!(typer & GITS_TYPER_VMOVP)) {
36423644
err = its_compute_its_list_map(res, its_base);
36433645
if (err < 0)
@@ -3704,7 +3706,7 @@ static int __init its_probe_one(struct resource *res,
37043706
gits_write_cwriter(0, its->base + GITS_CWRITER);
37053707
ctlr = readl_relaxed(its->base + GITS_CTLR);
37063708
ctlr |= GITS_CTLR_ENABLE;
3707-
if (its->is_v4)
3709+
if (is_v4(its))
37083710
ctlr |= GITS_CTLR_ImDe;
37093711
writel_relaxed(ctlr, its->base + GITS_CTLR);
37103712

@@ -4029,7 +4031,7 @@ int __init its_init(struct fwnode_handle *handle, struct rdists *rdists,
40294031
return err;
40304032

40314033
list_for_each_entry(its, &its_nodes, entry)
4032-
has_v4 |= its->is_v4;
4034+
has_v4 |= is_v4(its);
40334035

40344036
if (has_v4 & rdists->has_vlpis) {
40354037
if (its_init_vpe_domain() ||

0 commit comments

Comments
 (0)