hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/irqchip/irq-gic-v3.c
....@@ -1,18 +1,7 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (C) 2013-2017 ARM Limited, All Rights Reserved.
34 * Author: Marc Zyngier <marc.zyngier@arm.com>
4
- *
5
- * This program is free software; you can redistribute it and/or modify
6
- * it under the terms of the GNU General Public License version 2 as
7
- * published by the Free Software Foundation.
8
- *
9
- * This program is distributed in the hope that it will be useful,
10
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
- * GNU General Public License for more details.
13
- *
14
- * You should have received a copy of the GNU General Public License
15
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
165 */
176
187 #define pr_fmt(fmt) "GICv3: " fmt
....@@ -27,8 +16,11 @@
2716 #include <linux/of_address.h>
2817 #include <linux/of_irq.h>
2918 #include <linux/percpu.h>
19
+#include <linux/refcount.h>
3020 #include <linux/slab.h>
21
+#include <linux/syscore_ops.h>
3122 #include <linux/wakeup_reason.h>
23
+#include <trace/hooks/gic_v3.h>
3224
3325
3426 #include <linux/irqchip.h>
....@@ -41,7 +33,17 @@
4133 #include <asm/smp_plat.h>
4234 #include <asm/virt.h>
4335
36
+#include <trace/hooks/gic.h>
37
+
4438 #include "irq-gic-common.h"
39
+
40
+#define GICD_INT_NMI_PRI (GICD_INT_DEF_PRI & ~0x80)
41
+
42
+#define FLAGS_WORKAROUND_GICR_WAKER_MSM8996 (1ULL << 0)
43
+#define FLAGS_WORKAROUND_CAVIUM_ERRATUM_38539 (1ULL << 1)
44
+#define FLAGS_WORKAROUND_MTK_GICR_SAVE (1ULL << 2)
45
+
46
+#define GIC_IRQ_TYPE_PARTITION (GIC_IRQ_TYPE_LPI + 1)
4547
4648 struct redist_region {
4749 void __iomem *redist_base;
....@@ -49,21 +51,73 @@
4951 bool single_redist;
5052 };
5153
52
-struct gic_chip_data {
53
- struct fwnode_handle *fwnode;
54
- void __iomem *dist_base;
55
- struct redist_region *redist_regions;
56
- struct rdists rdists;
57
- struct irq_domain *domain;
58
- u64 redist_stride;
59
- u32 nr_redist_regions;
60
- bool has_rss;
61
- unsigned int irq_nr;
62
- struct partition_desc *ppi_descs[16];
63
-};
54
+static DEFINE_STATIC_KEY_FALSE(gic_arm64_2941627_erratum);
6455
6556 static struct gic_chip_data gic_data __read_mostly;
6657 static DEFINE_STATIC_KEY_TRUE(supports_deactivate_key);
58
+
59
+#define GIC_ID_NR (1U << GICD_TYPER_ID_BITS(gic_data.rdists.gicd_typer))
60
+#define GIC_LINE_NR min(GICD_TYPER_SPIS(gic_data.rdists.gicd_typer), 1020U)
61
+#define GIC_ESPI_NR GICD_TYPER_ESPIS(gic_data.rdists.gicd_typer)
62
+
63
+/*
64
+ * The behaviours of RPR and PMR registers differ depending on the value of
65
+ * SCR_EL3.FIQ, and the behaviour of non-secure priority registers of the
66
+ * distributor and redistributors depends on whether security is enabled in the
67
+ * GIC.
68
+ *
69
+ * When security is enabled, non-secure priority values from the (re)distributor
70
+ * are presented to the GIC CPUIF as follow:
71
+ * (GIC_(R)DIST_PRI[irq] >> 1) | 0x80;
72
+ *
73
+ * If SCR_EL3.FIQ == 1, the values writen to/read from PMR and RPR at non-secure
74
+ * EL1 are subject to a similar operation thus matching the priorities presented
75
+ * from the (re)distributor when security is enabled. When SCR_EL3.FIQ == 0,
76
+ * these values are unchanched by the GIC.
77
+ *
78
+ * see GICv3/GICv4 Architecture Specification (IHI0069D):
79
+ * - section 4.8.1 Non-secure accesses to register fields for Secure interrupt
80
+ * priorities.
81
+ * - Figure 4-7 Secure read of the priority field for a Non-secure Group 1
82
+ * interrupt.
83
+ */
84
+static DEFINE_STATIC_KEY_FALSE(supports_pseudo_nmis);
85
+
86
+/*
87
+ * Global static key controlling whether an update to PMR allowing more
88
+ * interrupts requires to be propagated to the redistributor (DSB SY).
89
+ * And this needs to be exported for modules to be able to enable
90
+ * interrupts...
91
+ */
92
+DEFINE_STATIC_KEY_FALSE(gic_pmr_sync);
93
+EXPORT_SYMBOL(gic_pmr_sync);
94
+
95
+DEFINE_STATIC_KEY_FALSE(gic_nonsecure_priorities);
96
+EXPORT_SYMBOL(gic_nonsecure_priorities);
97
+
98
+/*
99
+ * When the Non-secure world has access to group 0 interrupts (as a
100
+ * consequence of SCR_EL3.FIQ == 0), reading the ICC_RPR_EL1 register will
101
+ * return the Distributor's view of the interrupt priority.
102
+ *
103
+ * When GIC security is enabled (GICD_CTLR.DS == 0), the interrupt priority
104
+ * written by software is moved to the Non-secure range by the Distributor.
105
+ *
106
+ * If both are true (which is when gic_nonsecure_priorities gets enabled),
107
+ * we need to shift down the priority programmed by software to match it
108
+ * against the value returned by ICC_RPR_EL1.
109
+ */
110
+#define GICD_INT_RPR_PRI(priority) \
111
+ ({ \
112
+ u32 __priority = (priority); \
113
+ if (static_branch_unlikely(&gic_nonsecure_priorities)) \
114
+ __priority = 0x80 | (__priority >> 1); \
115
+ \
116
+ __priority; \
117
+ })
118
+
119
+/* ppi_nmi_refs[n] == number of cpus having ppi[n + 16] set as NMI */
120
+static refcount_t *ppi_nmi_refs;
67121
68122 static struct gic_kvm_info gic_v3_kvm_info;
69123 static DEFINE_PER_CPU(bool, has_rss);
....@@ -76,32 +130,82 @@
76130 /* Our default, arbitrary priority value. Linux only uses one anyway. */
77131 #define DEFAULT_PMR_VALUE 0xf0
78132
133
+enum gic_intid_range {
134
+ SGI_RANGE,
135
+ PPI_RANGE,
136
+ SPI_RANGE,
137
+ EPPI_RANGE,
138
+ ESPI_RANGE,
139
+ LPI_RANGE,
140
+ __INVALID_RANGE__
141
+};
142
+
143
+static enum gic_intid_range __get_intid_range(irq_hw_number_t hwirq)
144
+{
145
+ switch (hwirq) {
146
+ case 0 ... 15:
147
+ return SGI_RANGE;
148
+ case 16 ... 31:
149
+ return PPI_RANGE;
150
+ case 32 ... 1019:
151
+ return SPI_RANGE;
152
+ case EPPI_BASE_INTID ... (EPPI_BASE_INTID + 63):
153
+ return EPPI_RANGE;
154
+ case ESPI_BASE_INTID ... (ESPI_BASE_INTID + 1023):
155
+ return ESPI_RANGE;
156
+ case 8192 ... GENMASK(23, 0):
157
+ return LPI_RANGE;
158
+ default:
159
+ return __INVALID_RANGE__;
160
+ }
161
+}
162
+
163
+static enum gic_intid_range get_intid_range(struct irq_data *d)
164
+{
165
+ return __get_intid_range(d->hwirq);
166
+}
167
+
79168 static inline unsigned int gic_irq(struct irq_data *d)
80169 {
81170 return d->hwirq;
82171 }
83172
84
-static inline int gic_irq_in_rdist(struct irq_data *d)
173
+static inline bool gic_irq_in_rdist(struct irq_data *d)
85174 {
86
- return gic_irq(d) < 32;
175
+ switch (get_intid_range(d)) {
176
+ case SGI_RANGE:
177
+ case PPI_RANGE:
178
+ case EPPI_RANGE:
179
+ return true;
180
+ default:
181
+ return false;
182
+ }
87183 }
88184
89185 static inline void __iomem *gic_dist_base(struct irq_data *d)
90186 {
91
- if (gic_irq_in_rdist(d)) /* SGI+PPI -> SGI_base for this CPU */
187
+ switch (get_intid_range(d)) {
188
+ case SGI_RANGE:
189
+ case PPI_RANGE:
190
+ case EPPI_RANGE:
191
+ /* SGI+PPI -> SGI_base for this CPU */
92192 return gic_data_rdist_sgi_base();
93193
94
- if (d->hwirq <= 1023) /* SPI -> dist_base */
194
+ case SPI_RANGE:
195
+ case ESPI_RANGE:
196
+ /* SPI -> dist_base */
95197 return gic_data.dist_base;
96198
97
- return NULL;
199
+ default:
200
+ return NULL;
201
+ }
98202 }
99203
100
-static void gic_do_wait_for_rwp(void __iomem *base)
204
+static void gic_do_wait_for_rwp(void __iomem *base, u32 bit)
101205 {
102206 u32 count = 1000000; /* 1s! */
103207
104
- while (readl_relaxed(base + GICD_CTLR) & GICD_CTLR_RWP) {
208
+ while (readl_relaxed(base + GICD_CTLR) & bit) {
105209 count--;
106210 if (!count) {
107211 pr_err_ratelimited("RWP timeout, gone fishing\n");
....@@ -109,19 +213,19 @@
109213 }
110214 cpu_relax();
111215 udelay(1);
112
- };
216
+ }
113217 }
114218
115219 /* Wait for completion of a distributor change */
116220 static void gic_dist_wait_for_rwp(void)
117221 {
118
- gic_do_wait_for_rwp(gic_data.dist_base);
222
+ gic_do_wait_for_rwp(gic_data.dist_base, GICD_CTLR_RWP);
119223 }
120224
121225 /* Wait for completion of a redistributor change */
122226 static void gic_redist_wait_for_rwp(void)
123227 {
124
- gic_do_wait_for_rwp(gic_data_rdist_rd_base());
228
+ gic_do_wait_for_rwp(gic_data_rdist_rd_base(), GICR_CTLR_RWP);
125229 }
126230
127231 #ifdef CONFIG_ARM64
....@@ -140,6 +244,9 @@
140244 void __iomem *rbase;
141245 u32 count = 1000000; /* 1s! */
142246 u32 val;
247
+
248
+ if (gic_data.flags & FLAGS_WORKAROUND_GICR_WAKER_MSM8996)
249
+ return;
143250
144251 rbase = gic_data_rdist_rd_base();
145252
....@@ -163,7 +270,7 @@
163270 break;
164271 cpu_relax();
165272 udelay(1);
166
- };
273
+ }
167274 if (!count)
168275 pr_err_ratelimited("redistributor failed to %s...\n",
169276 enable ? "wakeup" : "sleep");
....@@ -172,24 +279,80 @@
172279 /*
173280 * Routines to disable, enable, EOI and route interrupts
174281 */
282
+static u32 convert_offset_index(struct irq_data *d, u32 offset, u32 *index)
283
+{
284
+ switch (get_intid_range(d)) {
285
+ case SGI_RANGE:
286
+ case PPI_RANGE:
287
+ case SPI_RANGE:
288
+ *index = d->hwirq;
289
+ return offset;
290
+ case EPPI_RANGE:
291
+ /*
292
+ * Contrary to the ESPI range, the EPPI range is contiguous
293
+ * to the PPI range in the registers, so let's adjust the
294
+ * displacement accordingly. Consistency is overrated.
295
+ */
296
+ *index = d->hwirq - EPPI_BASE_INTID + 32;
297
+ return offset;
298
+ case ESPI_RANGE:
299
+ *index = d->hwirq - ESPI_BASE_INTID;
300
+ switch (offset) {
301
+ case GICD_ISENABLER:
302
+ return GICD_ISENABLERnE;
303
+ case GICD_ICENABLER:
304
+ return GICD_ICENABLERnE;
305
+ case GICD_ISPENDR:
306
+ return GICD_ISPENDRnE;
307
+ case GICD_ICPENDR:
308
+ return GICD_ICPENDRnE;
309
+ case GICD_ISACTIVER:
310
+ return GICD_ISACTIVERnE;
311
+ case GICD_ICACTIVER:
312
+ return GICD_ICACTIVERnE;
313
+ case GICD_IPRIORITYR:
314
+ return GICD_IPRIORITYRnE;
315
+ case GICD_ICFGR:
316
+ return GICD_ICFGRnE;
317
+ case GICD_IROUTER:
318
+ return GICD_IROUTERnE;
319
+ default:
320
+ break;
321
+ }
322
+ break;
323
+ default:
324
+ break;
325
+ }
326
+
327
+ WARN_ON(1);
328
+ *index = d->hwirq;
329
+ return offset;
330
+}
331
+
175332 static int gic_peek_irq(struct irq_data *d, u32 offset)
176333 {
177
- u32 mask = 1 << (gic_irq(d) % 32);
178334 void __iomem *base;
335
+ u32 index, mask;
336
+
337
+ offset = convert_offset_index(d, offset, &index);
338
+ mask = 1 << (index % 32);
179339
180340 if (gic_irq_in_rdist(d))
181341 base = gic_data_rdist_sgi_base();
182342 else
183343 base = gic_data.dist_base;
184344
185
- return !!(readl_relaxed(base + offset + (gic_irq(d) / 32) * 4) & mask);
345
+ return !!(readl_relaxed(base + offset + (index / 32) * 4) & mask);
186346 }
187347
188348 static void gic_poke_irq(struct irq_data *d, u32 offset)
189349 {
190
- u32 mask = 1 << (gic_irq(d) % 32);
191350 void (*rwp_wait)(void);
192351 void __iomem *base;
352
+ u32 index, mask;
353
+
354
+ offset = convert_offset_index(d, offset, &index);
355
+ mask = 1 << (index % 32);
193356
194357 if (gic_irq_in_rdist(d)) {
195358 base = gic_data_rdist_sgi_base();
....@@ -199,7 +362,7 @@
199362 rwp_wait = gic_dist_wait_for_rwp;
200363 }
201364
202
- writel_relaxed(mask, base + offset + (gic_irq(d) / 32) * 4);
365
+ writel_relaxed(mask, base + offset + (index / 32) * 4);
203366 rwp_wait();
204367 }
205368
....@@ -228,21 +391,18 @@
228391 gic_poke_irq(d, GICD_ISENABLER);
229392 }
230393
231
-#ifdef CONFIG_ARCH_ROCKCHIP
232
-static int gic_retrigger(struct irq_data *d)
394
+static inline bool gic_supports_nmi(void)
233395 {
234
- gic_poke_irq(d, GICD_ISPENDR);
235
- /* the genirq layer expects 0 if we can't retrigger in hardware */
236
- return 0;
396
+ return IS_ENABLED(CONFIG_ARM64_PSEUDO_NMI) &&
397
+ static_branch_likely(&supports_pseudo_nmis);
237398 }
238
-#endif
239399
240400 static int gic_irq_set_irqchip_state(struct irq_data *d,
241401 enum irqchip_irq_state which, bool val)
242402 {
243403 u32 reg;
244404
245
- if (d->hwirq >= gic_data.irq_nr) /* PPI/SPI only */
405
+ if (d->hwirq >= 8192) /* SGI/PPI/SPI only */
246406 return -EINVAL;
247407
248408 switch (which) {
....@@ -269,7 +429,7 @@
269429 static int gic_irq_get_irqchip_state(struct irq_data *d,
270430 enum irqchip_irq_state which, bool *val)
271431 {
272
- if (d->hwirq >= gic_data.irq_nr) /* PPI/SPI only */
432
+ if (d->hwirq >= 8192) /* PPI/SPI only */
273433 return -EINVAL;
274434
275435 switch (which) {
....@@ -292,9 +452,131 @@
292452 return 0;
293453 }
294454
455
+static void gic_irq_set_prio(struct irq_data *d, u8 prio)
456
+{
457
+ void __iomem *base = gic_dist_base(d);
458
+ u32 offset, index;
459
+
460
+ offset = convert_offset_index(d, GICD_IPRIORITYR, &index);
461
+
462
+ writeb_relaxed(prio, base + offset + index);
463
+}
464
+
465
+static u32 gic_get_ppi_index(struct irq_data *d)
466
+{
467
+ switch (get_intid_range(d)) {
468
+ case PPI_RANGE:
469
+ return d->hwirq - 16;
470
+ case EPPI_RANGE:
471
+ return d->hwirq - EPPI_BASE_INTID + 16;
472
+ default:
473
+ unreachable();
474
+ }
475
+}
476
+
477
+static int gic_irq_nmi_setup(struct irq_data *d)
478
+{
479
+ struct irq_desc *desc = irq_to_desc(d->irq);
480
+
481
+ if (!gic_supports_nmi())
482
+ return -EINVAL;
483
+
484
+ if (gic_peek_irq(d, GICD_ISENABLER)) {
485
+ pr_err("Cannot set NMI property of enabled IRQ %u\n", d->irq);
486
+ return -EINVAL;
487
+ }
488
+
489
+ /*
490
+ * A secondary irq_chip should be in charge of LPI request,
491
+ * it should not be possible to get there
492
+ */
493
+ if (WARN_ON(gic_irq(d) >= 8192))
494
+ return -EINVAL;
495
+
496
+ /* desc lock should already be held */
497
+ if (gic_irq_in_rdist(d)) {
498
+ u32 idx = gic_get_ppi_index(d);
499
+
500
+ /* Setting up PPI as NMI, only switch handler for first NMI */
501
+ if (!refcount_inc_not_zero(&ppi_nmi_refs[idx])) {
502
+ refcount_set(&ppi_nmi_refs[idx], 1);
503
+ desc->handle_irq = handle_percpu_devid_fasteoi_nmi;
504
+ }
505
+ } else {
506
+ desc->handle_irq = handle_fasteoi_nmi;
507
+ }
508
+
509
+ gic_irq_set_prio(d, GICD_INT_NMI_PRI);
510
+
511
+ return 0;
512
+}
513
+
514
+static void gic_irq_nmi_teardown(struct irq_data *d)
515
+{
516
+ struct irq_desc *desc = irq_to_desc(d->irq);
517
+
518
+ if (WARN_ON(!gic_supports_nmi()))
519
+ return;
520
+
521
+ if (gic_peek_irq(d, GICD_ISENABLER)) {
522
+ pr_err("Cannot set NMI property of enabled IRQ %u\n", d->irq);
523
+ return;
524
+ }
525
+
526
+ /*
527
+ * A secondary irq_chip should be in charge of LPI request,
528
+ * it should not be possible to get there
529
+ */
530
+ if (WARN_ON(gic_irq(d) >= 8192))
531
+ return;
532
+
533
+ /* desc lock should already be held */
534
+ if (gic_irq_in_rdist(d)) {
535
+ u32 idx = gic_get_ppi_index(d);
536
+
537
+ /* Tearing down NMI, only switch handler for last NMI */
538
+ if (refcount_dec_and_test(&ppi_nmi_refs[idx]))
539
+ desc->handle_irq = handle_percpu_devid_irq;
540
+ } else {
541
+ desc->handle_irq = handle_fasteoi_irq;
542
+ }
543
+
544
+ gic_irq_set_prio(d, GICD_INT_DEF_PRI);
545
+}
546
+
547
+static bool gic_arm64_erratum_2941627_needed(struct irq_data *d)
548
+{
549
+ enum gic_intid_range range;
550
+
551
+ if (!static_branch_unlikely(&gic_arm64_2941627_erratum))
552
+ return false;
553
+
554
+ range = get_intid_range(d);
555
+
556
+ /*
557
+ * The workaround is needed if the IRQ is an SPI and
558
+ * the target cpu is different from the one we are
559
+ * executing on.
560
+ */
561
+ return (range == SPI_RANGE || range == ESPI_RANGE) &&
562
+ !cpumask_test_cpu(raw_smp_processor_id(),
563
+ irq_data_get_effective_affinity_mask(d));
564
+}
565
+
295566 static void gic_eoi_irq(struct irq_data *d)
296567 {
297
- gic_write_eoir(gic_irq(d));
568
+ write_gicreg(gic_irq(d), ICC_EOIR1_EL1);
569
+ isb();
570
+
571
+ if (gic_arm64_erratum_2941627_needed(d)) {
572
+ /*
573
+ * Make sure the GIC stream deactivate packet
574
+ * issued by ICC_EOIR1_EL1 has completed before
575
+ * deactivating through GICD_IACTIVER.
576
+ */
577
+ dsb(sy);
578
+ gic_poke_irq(d, GICD_ICACTIVER);
579
+ }
298580 }
299581
300582 static void gic_eoimode1_eoi_irq(struct irq_data *d)
....@@ -305,22 +587,31 @@
305587 */
306588 if (gic_irq(d) >= 8192 || irqd_is_forwarded_to_vcpu(d))
307589 return;
308
- gic_write_dir(gic_irq(d));
590
+
591
+ if (!gic_arm64_erratum_2941627_needed(d))
592
+ gic_write_dir(gic_irq(d));
593
+ else
594
+ gic_poke_irq(d, GICD_ICACTIVER);
309595 }
310596
311597 static int gic_set_type(struct irq_data *d, unsigned int type)
312598 {
599
+ enum gic_intid_range range;
313600 unsigned int irq = gic_irq(d);
314601 void (*rwp_wait)(void);
315602 void __iomem *base;
603
+ u32 offset, index;
604
+ int ret;
605
+
606
+ range = get_intid_range(d);
316607
317608 /* Interrupt configuration for SGIs can't be changed */
318
- if (irq < 16)
319
- return -EINVAL;
609
+ if (range == SGI_RANGE)
610
+ return type != IRQ_TYPE_EDGE_RISING ? -EINVAL : 0;
320611
321612 /* SPIs have restrictions on the supported types */
322
- if (irq >= 32 && type != IRQ_TYPE_LEVEL_HIGH &&
323
- type != IRQ_TYPE_EDGE_RISING)
613
+ if ((range == SPI_RANGE || range == ESPI_RANGE) &&
614
+ type != IRQ_TYPE_LEVEL_HIGH && type != IRQ_TYPE_EDGE_RISING)
324615 return -EINVAL;
325616
326617 if (gic_irq_in_rdist(d)) {
....@@ -331,11 +622,23 @@
331622 rwp_wait = gic_dist_wait_for_rwp;
332623 }
333624
334
- return gic_configure_irq(irq, type, base, rwp_wait);
625
+ offset = convert_offset_index(d, GICD_ICFGR, &index);
626
+
627
+ ret = gic_configure_irq(index, type, base + offset, rwp_wait);
628
+ if (ret && (range == PPI_RANGE || range == EPPI_RANGE)) {
629
+ /* Misconfigured PPIs are usually not fatal */
630
+ pr_warn("GIC: PPI INTID%d is secure or misconfigured\n", irq);
631
+ ret = 0;
632
+ }
633
+
634
+ return ret;
335635 }
336636
337637 static int gic_irq_set_vcpu_affinity(struct irq_data *d, void *vcpu)
338638 {
639
+ if (get_intid_range(d) == SGI_RANGE)
640
+ return -EINVAL;
641
+
339642 if (vcpu)
340643 irqd_set_forwarded_to_vcpu(d);
341644 else
....@@ -355,54 +658,143 @@
355658 return aff;
356659 }
357660
661
+static void gic_deactivate_unhandled(u32 irqnr)
662
+{
663
+ if (static_branch_likely(&supports_deactivate_key)) {
664
+ if (irqnr < 8192)
665
+ gic_write_dir(irqnr);
666
+ } else {
667
+ gic_write_eoir(irqnr);
668
+ }
669
+}
670
+
671
+static inline void gic_handle_nmi(u32 irqnr, struct pt_regs *regs)
672
+{
673
+ bool irqs_enabled = interrupts_enabled(regs);
674
+ int err;
675
+
676
+ if (irqs_enabled)
677
+ nmi_enter();
678
+
679
+ if (static_branch_likely(&supports_deactivate_key))
680
+ gic_write_eoir(irqnr);
681
+ /*
682
+ * Leave the PSR.I bit set to prevent other NMIs to be
683
+ * received while handling this one.
684
+ * PSR.I will be restored when we ERET to the
685
+ * interrupted context.
686
+ */
687
+ err = handle_domain_nmi(gic_data.domain, irqnr, regs);
688
+ if (err)
689
+ gic_deactivate_unhandled(irqnr);
690
+
691
+ if (irqs_enabled)
692
+ nmi_exit();
693
+}
694
+
695
+static u32 do_read_iar(struct pt_regs *regs)
696
+{
697
+ u32 iar;
698
+
699
+ if (gic_supports_nmi() && unlikely(!interrupts_enabled(regs))) {
700
+ u64 pmr;
701
+
702
+ /*
703
+ * We were in a context with IRQs disabled. However, the
704
+ * entry code has set PMR to a value that allows any
705
+ * interrupt to be acknowledged, and not just NMIs. This can
706
+ * lead to surprising effects if the NMI has been retired in
707
+ * the meantime, and that there is an IRQ pending. The IRQ
708
+ * would then be taken in NMI context, something that nobody
709
+ * wants to debug twice.
710
+ *
711
+ * Until we sort this, drop PMR again to a level that will
712
+ * actually only allow NMIs before reading IAR, and then
713
+ * restore it to what it was.
714
+ */
715
+ pmr = gic_read_pmr();
716
+ gic_pmr_mask_irqs();
717
+ isb();
718
+
719
+ iar = gic_read_iar();
720
+
721
+ gic_write_pmr(pmr);
722
+ } else {
723
+ iar = gic_read_iar();
724
+ }
725
+
726
+ return iar;
727
+}
728
+
358729 static asmlinkage void __exception_irq_entry gic_handle_irq(struct pt_regs *regs)
359730 {
360731 u32 irqnr;
361732
362
- do {
363
- irqnr = gic_read_iar();
733
+ irqnr = do_read_iar(regs);
364734
365
- if (likely(irqnr > 15 && irqnr < 1020) || irqnr >= 8192) {
366
- int err;
735
+ /* Check for special IDs first */
736
+ if ((irqnr >= 1020 && irqnr <= 1023))
737
+ return;
367738
368
- if (static_branch_likely(&supports_deactivate_key))
369
- gic_write_eoir(irqnr);
370
- else
371
- isb();
739
+ if (gic_supports_nmi() &&
740
+ unlikely(gic_read_rpr() == GICD_INT_RPR_PRI(GICD_INT_NMI_PRI))) {
741
+ gic_handle_nmi(irqnr, regs);
742
+ return;
743
+ }
372744
373
- err = handle_domain_irq(gic_data.domain, irqnr, regs);
374
- if (err) {
375
- WARN_ONCE(true, "Unexpected interrupt received!\n");
376
- log_abnormal_wakeup_reason(
377
- "unexpected HW IRQ %u", irqnr);
378
- if (static_branch_likely(&supports_deactivate_key)) {
379
- if (irqnr < 8192)
380
- gic_write_dir(irqnr);
381
- } else {
382
- gic_write_eoir(irqnr);
383
- }
384
- }
385
- continue;
386
- }
387
- if (irqnr < 16) {
388
- gic_write_eoir(irqnr);
389
- if (static_branch_likely(&supports_deactivate_key))
390
- gic_write_dir(irqnr);
391
-#ifdef CONFIG_SMP
392
- /*
393
- * Unlike GICv2, we don't need an smp_rmb() here.
394
- * The control dependency from gic_read_iar to
395
- * the ISB in gic_write_eoir is enough to ensure
396
- * that any shared data read by handle_IPI will
397
- * be read after the ACK.
398
- */
399
- handle_IPI(irqnr, regs);
400
-#else
401
- WARN_ONCE(true, "Unexpected SGI received!\n");
402
-#endif
403
- continue;
404
- }
405
- } while (irqnr != ICC_IAR1_EL1_SPURIOUS);
745
+ if (gic_prio_masking_enabled()) {
746
+ gic_pmr_mask_irqs();
747
+ gic_arch_enable_irqs();
748
+ }
749
+
750
+ if (static_branch_likely(&supports_deactivate_key))
751
+ gic_write_eoir(irqnr);
752
+ else
753
+ isb();
754
+
755
+ if (handle_domain_irq(gic_data.domain, irqnr, regs)) {
756
+ WARN_ONCE(true, "Unexpected interrupt received!\n");
757
+ log_abnormal_wakeup_reason("unexpected HW IRQ %u", irqnr);
758
+ gic_deactivate_unhandled(irqnr);
759
+ }
760
+}
761
+
762
+static u32 gic_get_pribits(void)
763
+{
764
+ u32 pribits;
765
+
766
+ pribits = gic_read_ctlr();
767
+ pribits &= ICC_CTLR_EL1_PRI_BITS_MASK;
768
+ pribits >>= ICC_CTLR_EL1_PRI_BITS_SHIFT;
769
+ pribits++;
770
+
771
+ return pribits;
772
+}
773
+
774
+static bool gic_has_group0(void)
775
+{
776
+ u32 val;
777
+ u32 old_pmr;
778
+
779
+ old_pmr = gic_read_pmr();
780
+
781
+ /*
782
+ * Let's find out if Group0 is under control of EL3 or not by
783
+ * setting the highest possible, non-zero priority in PMR.
784
+ *
785
+ * If SCR_EL3.FIQ is set, the priority gets shifted down in
786
+ * order for the CPU interface to set bit 7, and keep the
787
+ * actual priority in the non-secure range. In the process, it
788
+ * looses the least significant bit and the actual priority
789
+ * becomes 0x80. Reading it back returns 0, indicating that
790
+ * we're don't have access to Group0.
791
+ */
792
+ gic_write_pmr(BIT(8 - gic_get_pribits()));
793
+ val = gic_read_pmr();
794
+
795
+ gic_write_pmr(old_pmr);
796
+
797
+ return val != 0;
406798 }
407799
408800 static void __init gic_dist_init(void)
....@@ -410,6 +802,7 @@
410802 unsigned int i;
411803 u64 affinity;
412804 void __iomem *base = gic_data.dist_base;
805
+ u32 val;
413806
414807 /* Disable the distributor */
415808 writel_relaxed(0, base + GICD_CTLR);
....@@ -421,22 +814,46 @@
421814 * do the right thing if the kernel is running in secure mode,
422815 * but that's not the intended use case anyway.
423816 */
424
- for (i = 32; i < gic_data.irq_nr; i += 32)
817
+ for (i = 32; i < GIC_LINE_NR; i += 32)
425818 writel_relaxed(~0, base + GICD_IGROUPR + i / 8);
426819
427
- gic_dist_config(base, gic_data.irq_nr, gic_dist_wait_for_rwp);
820
+ /* Extended SPI range, not handled by the GICv2/GICv3 common code */
821
+ for (i = 0; i < GIC_ESPI_NR; i += 32) {
822
+ writel_relaxed(~0U, base + GICD_ICENABLERnE + i / 8);
823
+ writel_relaxed(~0U, base + GICD_ICACTIVERnE + i / 8);
824
+ }
825
+
826
+ for (i = 0; i < GIC_ESPI_NR; i += 32)
827
+ writel_relaxed(~0U, base + GICD_IGROUPRnE + i / 8);
828
+
829
+ for (i = 0; i < GIC_ESPI_NR; i += 16)
830
+ writel_relaxed(0, base + GICD_ICFGRnE + i / 4);
831
+
832
+ for (i = 0; i < GIC_ESPI_NR; i += 4)
833
+ writel_relaxed(GICD_INT_DEF_PRI_X4, base + GICD_IPRIORITYRnE + i);
834
+
835
+ /* Now do the common stuff, and wait for the distributor to drain */
836
+ gic_dist_config(base, GIC_LINE_NR, gic_dist_wait_for_rwp);
837
+
838
+ val = GICD_CTLR_ARE_NS | GICD_CTLR_ENABLE_G1A | GICD_CTLR_ENABLE_G1;
839
+ if (gic_data.rdists.gicd_typer2 & GICD_TYPER2_nASSGIcap) {
840
+ pr_info("Enabling SGIs without active state\n");
841
+ val |= GICD_CTLR_nASSGIreq;
842
+ }
428843
429844 /* Enable distributor with ARE, Group1 */
430
- writel_relaxed(GICD_CTLR_ARE_NS | GICD_CTLR_ENABLE_G1A | GICD_CTLR_ENABLE_G1,
431
- base + GICD_CTLR);
845
+ writel_relaxed(val, base + GICD_CTLR);
432846
433847 /*
434848 * Set all global interrupts to the boot CPU only. ARE must be
435849 * enabled.
436850 */
437851 affinity = gic_mpidr_to_affinity(cpu_logical_map(smp_processor_id()));
438
- for (i = 32; i < gic_data.irq_nr; i++)
852
+ for (i = 32; i < GIC_LINE_NR; i++)
439853 gic_write_irouter(affinity, base + GICD_IROUTER + i * 8);
854
+
855
+ for (i = 0; i < GIC_ESPI_NR; i++)
856
+ gic_write_irouter(affinity, base + GICD_IROUTERnE + i * 8);
440857 }
441858
442859 static int gic_iterate_rdists(int (*fn)(struct redist_region *, void __iomem *))
....@@ -496,6 +913,7 @@
496913 typer = gic_read_typer(ptr + GICR_TYPER);
497914 if ((typer >> 32) == aff) {
498915 u64 offset = ptr - region->redist_base;
916
+ raw_spin_lock_init(&gic_data_rdist()->rd_lock);
499917 gic_data_rdist_rd_base() = ptr;
500918 gic_data_rdist()->phys_base = region->phys_base + offset;
501919
....@@ -522,22 +940,65 @@
522940 return -ENODEV;
523941 }
524942
525
-static int __gic_update_vlpi_properties(struct redist_region *region,
526
- void __iomem *ptr)
943
+static int __gic_update_rdist_properties(struct redist_region *region,
944
+ void __iomem *ptr)
527945 {
528946 u64 typer = gic_read_typer(ptr + GICR_TYPER);
947
+
948
+ /* Boot-time cleanip */
949
+ if ((typer & GICR_TYPER_VLPIS) && (typer & GICR_TYPER_RVPEID)) {
950
+ u64 val;
951
+
952
+ /* Deactivate any present vPE */
953
+ val = gicr_read_vpendbaser(ptr + SZ_128K + GICR_VPENDBASER);
954
+ if (val & GICR_VPENDBASER_Valid)
955
+ gicr_write_vpendbaser(GICR_VPENDBASER_PendingLast,
956
+ ptr + SZ_128K + GICR_VPENDBASER);
957
+
958
+ /* Mark the VPE table as invalid */
959
+ val = gicr_read_vpropbaser(ptr + SZ_128K + GICR_VPROPBASER);
960
+ val &= ~GICR_VPROPBASER_4_1_VALID;
961
+ gicr_write_vpropbaser(val, ptr + SZ_128K + GICR_VPROPBASER);
962
+ }
963
+
529964 gic_data.rdists.has_vlpis &= !!(typer & GICR_TYPER_VLPIS);
530
- gic_data.rdists.has_direct_lpi &= !!(typer & GICR_TYPER_DirectLPIS);
965
+
966
+ /* RVPEID implies some form of DirectLPI, no matter what the doc says... :-/ */
967
+ gic_data.rdists.has_rvpeid &= !!(typer & GICR_TYPER_RVPEID);
968
+ gic_data.rdists.has_direct_lpi &= (!!(typer & GICR_TYPER_DirectLPIS) |
969
+ gic_data.rdists.has_rvpeid);
970
+ gic_data.rdists.has_vpend_valid_dirty &= !!(typer & GICR_TYPER_DIRTY);
971
+
972
+ /* Detect non-sensical configurations */
973
+ if (WARN_ON_ONCE(gic_data.rdists.has_rvpeid && !gic_data.rdists.has_vlpis)) {
974
+ gic_data.rdists.has_direct_lpi = false;
975
+ gic_data.rdists.has_vlpis = false;
976
+ gic_data.rdists.has_rvpeid = false;
977
+ }
978
+
979
+ gic_data.ppi_nr = min(GICR_TYPER_NR_PPIS(typer), gic_data.ppi_nr);
531980
532981 return 1;
533982 }
534983
535
-static void gic_update_vlpi_properties(void)
984
+static void gic_update_rdist_properties(void)
536985 {
537
- gic_iterate_rdists(__gic_update_vlpi_properties);
538
- pr_info("%sVLPI support, %sdirect LPI support\n",
539
- !gic_data.rdists.has_vlpis ? "no " : "",
540
- !gic_data.rdists.has_direct_lpi ? "no " : "");
986
+ gic_data.ppi_nr = UINT_MAX;
987
+ gic_iterate_rdists(__gic_update_rdist_properties);
988
+ if (WARN_ON(gic_data.ppi_nr == UINT_MAX))
989
+ gic_data.ppi_nr = 0;
990
+ pr_info("%d PPIs implemented\n", gic_data.ppi_nr);
991
+ if (gic_data.rdists.has_vlpis)
992
+ pr_info("GICv4 features: %s%s%s\n",
993
+ gic_data.rdists.has_direct_lpi ? "DirectLPI " : "",
994
+ gic_data.rdists.has_rvpeid ? "RVPEID " : "",
995
+ gic_data.rdists.has_vpend_valid_dirty ? "Valid+Dirty " : "");
996
+}
997
+
998
+/* Check whether it's single security state view */
999
+static inline bool gic_dist_security_disabled(void)
1000
+{
1001
+ return readl_relaxed(gic_data.dist_base + GICD_CTLR) & GICD_CTLR_DS;
5411002 }
5421003
5431004 static void gic_cpu_sys_reg_init(void)
....@@ -546,7 +1007,7 @@
5461007 u64 mpidr = cpu_logical_map(cpu);
5471008 u64 need_rss = MPIDR_RS(mpidr);
5481009 bool group0;
549
- u32 val, pribits;
1010
+ u32 pribits;
5501011
5511012 /*
5521013 * Need to check that the SRE bit has actually been set. If
....@@ -558,28 +1019,28 @@
5581019 if (!gic_enable_sre())
5591020 pr_err("GIC: unable to set SRE (disabled at EL2), panic ahead\n");
5601021
561
- pribits = gic_read_ctlr();
562
- pribits &= ICC_CTLR_EL1_PRI_BITS_MASK;
563
- pribits >>= ICC_CTLR_EL1_PRI_BITS_SHIFT;
564
- pribits++;
1022
+ pribits = gic_get_pribits();
5651023
566
- /*
567
- * Let's find out if Group0 is under control of EL3 or not by
568
- * setting the highest possible, non-zero priority in PMR.
569
- *
570
- * If SCR_EL3.FIQ is set, the priority gets shifted down in
571
- * order for the CPU interface to set bit 7, and keep the
572
- * actual priority in the non-secure range. In the process, it
573
- * looses the least significant bit and the actual priority
574
- * becomes 0x80. Reading it back returns 0, indicating that
575
- * we're don't have access to Group0.
576
- */
577
- write_gicreg(BIT(8 - pribits), ICC_PMR_EL1);
578
- val = read_gicreg(ICC_PMR_EL1);
579
- group0 = val != 0;
1024
+ group0 = gic_has_group0();
5801025
5811026 /* Set priority mask register */
582
- write_gicreg(DEFAULT_PMR_VALUE, ICC_PMR_EL1);
1027
+ if (!gic_prio_masking_enabled()) {
1028
+ write_gicreg(DEFAULT_PMR_VALUE, ICC_PMR_EL1);
1029
+ } else if (gic_supports_nmi()) {
1030
+ /*
1031
+ * Mismatch configuration with boot CPU, the system is likely
1032
+ * to die as interrupt masking will not work properly on all
1033
+ * CPUs
1034
+ *
1035
+ * The boot CPU calls this function before enabling NMI support,
1036
+ * and as a result we'll never see this warning in the boot path
1037
+ * for that CPU.
1038
+ */
1039
+ if (static_branch_unlikely(&gic_nonsecure_priorities))
1040
+ WARN_ON(!group0 || gic_dist_security_disabled());
1041
+ else
1042
+ WARN_ON(group0 && !gic_dist_security_disabled());
1043
+ }
5831044
5841045 /*
5851046 * Some firmwares hand over to the kernel with the BPR changed from
....@@ -604,8 +1065,10 @@
6041065 case 7:
6051066 write_gicreg(0, ICC_AP0R3_EL1);
6061067 write_gicreg(0, ICC_AP0R2_EL1);
1068
+ fallthrough;
6071069 case 6:
6081070 write_gicreg(0, ICC_AP0R1_EL1);
1071
+ fallthrough;
6091072 case 5:
6101073 case 4:
6111074 write_gicreg(0, ICC_AP0R0_EL1);
....@@ -619,8 +1082,10 @@
6191082 case 7:
6201083 write_gicreg(0, ICC_AP1R3_EL1);
6211084 write_gicreg(0, ICC_AP1R2_EL1);
1085
+ fallthrough;
6221086 case 6:
6231087 write_gicreg(0, ICC_AP1R1_EL1);
1088
+ fallthrough;
6241089 case 5:
6251090 case 4:
6261091 write_gicreg(0, ICC_AP1R0_EL1);
....@@ -666,12 +1131,15 @@
6661131
6671132 static int gic_dist_supports_lpis(void)
6681133 {
669
- return !!(readl_relaxed(gic_data.dist_base + GICD_TYPER) & GICD_TYPER_LPIS) && !gicv3_nolpi;
1134
+ return (IS_ENABLED(CONFIG_ARM_GIC_V3_ITS) &&
1135
+ !!(readl_relaxed(gic_data.dist_base + GICD_TYPER) & GICD_TYPER_LPIS) &&
1136
+ !gicv3_nolpi);
6701137 }
6711138
6721139 static void gic_cpu_init(void)
6731140 {
6741141 void __iomem *rbase;
1142
+ int i;
6751143
6761144 /* Register ourselves with the rest of the world */
6771145 if (gic_populate_rdist())
....@@ -679,16 +1147,18 @@
6791147
6801148 gic_enable_redist(true);
6811149
1150
+ WARN((gic_data.ppi_nr > 16 || GIC_ESPI_NR != 0) &&
1151
+ !(gic_read_ctlr() & ICC_CTLR_EL1_ExtRange),
1152
+ "Distributor has extended ranges, but CPU%d doesn't\n",
1153
+ smp_processor_id());
1154
+
6821155 rbase = gic_data_rdist_sgi_base();
6831156
6841157 /* Configure SGIs/PPIs as non-secure Group-1 */
685
- writel_relaxed(~0, rbase + GICR_IGROUPR0);
1158
+ for (i = 0; i < gic_data.ppi_nr + 16; i += 32)
1159
+ writel_relaxed(~0, rbase + GICR_IGROUPR0 + i / 8);
6861160
687
- gic_cpu_config(rbase, gic_redist_wait_for_rwp);
688
-
689
- /* Give LPIs a spin */
690
- if (IS_ENABLED(CONFIG_ARM_GIC_V3_ITS) && gic_dist_supports_lpis())
691
- its_cpu_init();
1161
+ gic_cpu_config(rbase, gic_data.ppi_nr + 16, gic_redist_wait_for_rwp);
6921162
6931163 /* initialise system registers */
6941164 gic_cpu_sys_reg_init();
....@@ -702,6 +1172,10 @@
7021172 static int gic_starting_cpu(unsigned int cpu)
7031173 {
7041174 gic_cpu_init();
1175
+
1176
+ if (gic_dist_supports_lpis())
1177
+ its_cpu_init();
1178
+
7051179 return 0;
7061180 }
7071181
....@@ -751,11 +1225,11 @@
7511225 gic_write_sgi1r(val);
7521226 }
7531227
754
-static void gic_raise_softirq(const struct cpumask *mask, unsigned int irq)
1228
+static void gic_ipi_send_mask(struct irq_data *d, const struct cpumask *mask)
7551229 {
7561230 int cpu;
7571231
758
- if (WARN_ON(irq >= 16))
1232
+ if (WARN_ON(d->hwirq >= 16))
7591233 return;
7601234
7611235 /*
....@@ -769,25 +1243,40 @@
7691243 u16 tlist;
7701244
7711245 tlist = gic_compute_target_list(&cpu, mask, cluster_id);
772
- gic_send_sgi(cluster_id, tlist, irq);
1246
+ gic_send_sgi(cluster_id, tlist, d->hwirq);
7731247 }
7741248
7751249 /* Force the above writes to ICC_SGI1R_EL1 to be executed */
7761250 isb();
7771251 }
7781252
779
-static void gic_smp_init(void)
1253
+static void __init gic_smp_init(void)
7801254 {
781
- set_smp_cross_call(gic_raise_softirq);
1255
+ struct irq_fwspec sgi_fwspec = {
1256
+ .fwnode = gic_data.fwnode,
1257
+ .param_count = 1,
1258
+ };
1259
+ int base_sgi;
1260
+
7821261 cpuhp_setup_state_nocalls(CPUHP_AP_IRQ_GIC_STARTING,
7831262 "irqchip/arm/gicv3:starting",
7841263 gic_starting_cpu, NULL);
1264
+
1265
+ /* Register all 8 non-secure SGIs */
1266
+ base_sgi = __irq_domain_alloc_irqs(gic_data.domain, -1, 8,
1267
+ NUMA_NO_NODE, &sgi_fwspec,
1268
+ false, NULL);
1269
+ if (WARN_ON(base_sgi <= 0))
1270
+ return;
1271
+
1272
+ set_smp_ipi_range(base_sgi, 8);
7851273 }
7861274
7871275 static int gic_set_affinity(struct irq_data *d, const struct cpumask *mask_val,
7881276 bool force)
7891277 {
7901278 unsigned int cpu;
1279
+ u32 offset, index;
7911280 void __iomem *reg;
7921281 int enabled;
7931282 u64 val;
....@@ -808,9 +1297,11 @@
8081297 if (enabled)
8091298 gic_mask_irq(d);
8101299
811
- reg = gic_dist_base(d) + GICD_IROUTER + (gic_irq(d) * 8);
1300
+ offset = convert_offset_index(d, GICD_IROUTER, &index);
1301
+ reg = gic_dist_base(d) + offset + (index * 8);
8121302 val = gic_mpidr_to_affinity(cpu_logical_map(cpu));
8131303
1304
+ trace_android_rvh_gic_v3_set_affinity(d, mask_val, &val, force, gic_dist_base(d));
8141305 gic_write_irouter(val, reg);
8151306
8161307 /*
....@@ -828,16 +1319,16 @@
8281319 }
8291320 #else
8301321 #define gic_set_affinity NULL
1322
+#define gic_ipi_send_mask NULL
8311323 #define gic_smp_init() do { } while(0)
8321324 #endif
8331325
834
-#ifdef CONFIG_CPU_PM
835
-/* Check whether it's single security state view */
836
-static bool gic_dist_security_disabled(void)
1326
+static int gic_retrigger(struct irq_data *data)
8371327 {
838
- return readl_relaxed(gic_data.dist_base + GICD_CTLR) & GICD_CTLR_DS;
1328
+ return !gic_irq_set_irqchip_state(data, IRQCHIP_STATE_PENDING, true);
8391329 }
8401330
1331
+#ifdef CONFIG_CPU_PM
8411332 static int gic_cpu_pm_notifier(struct notifier_block *self,
8421333 unsigned long cmd, void *v)
8431334 {
....@@ -865,18 +1356,41 @@
8651356 static inline void gic_cpu_pm_init(void) { }
8661357 #endif /* CONFIG_CPU_PM */
8671358
1359
+#ifdef CONFIG_PM
1360
+void gic_resume(void)
1361
+{
1362
+ trace_android_vh_gic_resume(&gic_data);
1363
+}
1364
+EXPORT_SYMBOL_GPL(gic_resume);
1365
+
1366
+static struct syscore_ops gic_syscore_ops = {
1367
+ .resume = gic_resume,
1368
+};
1369
+
1370
+static void gic_syscore_init(void)
1371
+{
1372
+ register_syscore_ops(&gic_syscore_ops);
1373
+}
1374
+
1375
+#else
1376
+static inline void gic_syscore_init(void) { }
1377
+void gic_resume(void) { }
1378
+#endif
1379
+
1380
+
8681381 static struct irq_chip gic_chip = {
8691382 .name = "GICv3",
8701383 .irq_mask = gic_mask_irq,
8711384 .irq_unmask = gic_unmask_irq,
8721385 .irq_eoi = gic_eoi_irq,
8731386 .irq_set_type = gic_set_type,
874
-#ifdef CONFIG_ARCH_ROCKCHIP
875
- .irq_retrigger = gic_retrigger,
876
-#endif
8771387 .irq_set_affinity = gic_set_affinity,
1388
+ .irq_retrigger = gic_retrigger,
8781389 .irq_get_irqchip_state = gic_irq_get_irqchip_state,
8791390 .irq_set_irqchip_state = gic_irq_set_irqchip_state,
1391
+ .irq_nmi_setup = gic_irq_nmi_setup,
1392
+ .irq_nmi_teardown = gic_irq_nmi_teardown,
1393
+ .ipi_send_mask = gic_ipi_send_mask,
8801394 .flags = IRQCHIP_SET_TYPE_MASKED |
8811395 IRQCHIP_SKIP_SET_WAKE |
8821396 IRQCHIP_MASK_ON_SUSPEND,
....@@ -887,71 +1401,79 @@
8871401 .irq_mask = gic_eoimode1_mask_irq,
8881402 .irq_unmask = gic_unmask_irq,
8891403 .irq_eoi = gic_eoimode1_eoi_irq,
890
-#ifdef CONFIG_ARCH_ROCKCHIP
891
- .irq_retrigger = gic_retrigger,
892
-#endif
8931404 .irq_set_type = gic_set_type,
8941405 .irq_set_affinity = gic_set_affinity,
1406
+ .irq_retrigger = gic_retrigger,
8951407 .irq_get_irqchip_state = gic_irq_get_irqchip_state,
8961408 .irq_set_irqchip_state = gic_irq_set_irqchip_state,
8971409 .irq_set_vcpu_affinity = gic_irq_set_vcpu_affinity,
1410
+ .irq_nmi_setup = gic_irq_nmi_setup,
1411
+ .irq_nmi_teardown = gic_irq_nmi_teardown,
1412
+ .ipi_send_mask = gic_ipi_send_mask,
8981413 .flags = IRQCHIP_SET_TYPE_MASKED |
8991414 IRQCHIP_SKIP_SET_WAKE |
9001415 IRQCHIP_MASK_ON_SUSPEND,
9011416 };
9021417
903
-#define GIC_ID_NR (1U << GICD_TYPER_ID_BITS(gic_data.rdists.gicd_typer))
904
-
9051418 static int gic_irq_domain_map(struct irq_domain *d, unsigned int irq,
9061419 irq_hw_number_t hw)
9071420 {
9081421 struct irq_chip *chip = &gic_chip;
1422
+ struct irq_data *irqd = irq_desc_get_irq_data(irq_to_desc(irq));
9091423
9101424 if (static_branch_likely(&supports_deactivate_key))
9111425 chip = &gic_eoimode1_chip;
9121426
913
- /* SGIs are private to the core kernel */
914
- if (hw < 16)
915
- return -EPERM;
916
- /* Nothing here */
917
- if (hw >= gic_data.irq_nr && hw < 8192)
918
- return -EPERM;
919
- /* Off limits */
920
- if (hw >= GIC_ID_NR)
921
- return -EPERM;
1427
+ switch (__get_intid_range(hw)) {
1428
+ case SGI_RANGE:
1429
+ irq_set_percpu_devid(irq);
1430
+ irq_domain_set_info(d, irq, hw, chip, d->host_data,
1431
+ handle_percpu_devid_fasteoi_ipi,
1432
+ NULL, NULL);
1433
+ break;
9221434
923
- /* PPIs */
924
- if (hw < 32) {
1435
+ case PPI_RANGE:
1436
+ case EPPI_RANGE:
9251437 irq_set_percpu_devid(irq);
9261438 irq_domain_set_info(d, irq, hw, chip, d->host_data,
9271439 handle_percpu_devid_irq, NULL, NULL);
928
- irq_set_status_flags(irq, IRQ_NOAUTOEN);
929
- }
930
- /* SPIs */
931
- if (hw >= 32 && hw < gic_data.irq_nr) {
1440
+ break;
1441
+
1442
+ case SPI_RANGE:
1443
+ case ESPI_RANGE:
9321444 irq_domain_set_info(d, irq, hw, chip, d->host_data,
9331445 handle_fasteoi_irq, NULL, NULL);
9341446 irq_set_probe(irq);
935
- irqd_set_single_target(irq_desc_get_irq_data(irq_to_desc(irq)));
936
- }
937
- /* LPIs */
938
- if (hw >= 8192 && hw < GIC_ID_NR) {
1447
+ irqd_set_single_target(irqd);
1448
+ break;
1449
+
1450
+ case LPI_RANGE:
9391451 if (!gic_dist_supports_lpis())
9401452 return -EPERM;
9411453 irq_domain_set_info(d, irq, hw, chip, d->host_data,
9421454 handle_fasteoi_irq, NULL, NULL);
1455
+ break;
1456
+
1457
+ default:
1458
+ return -EPERM;
9431459 }
9441460
1461
+ /* Prevents SW retriggers which mess up the ACK/EOI ordering */
1462
+ irqd_set_handle_enforce_irqctx(irqd);
9451463 return 0;
9461464 }
947
-
948
-#define GIC_IRQ_TYPE_PARTITION (GIC_IRQ_TYPE_LPI + 1)
9491465
9501466 static int gic_irq_domain_translate(struct irq_domain *d,
9511467 struct irq_fwspec *fwspec,
9521468 unsigned long *hwirq,
9531469 unsigned int *type)
9541470 {
1471
+ if (fwspec->param_count == 1 && fwspec->param[0] < 16) {
1472
+ *hwirq = fwspec->param[0];
1473
+ *type = IRQ_TYPE_EDGE_RISING;
1474
+ return 0;
1475
+ }
1476
+
9551477 if (is_of_node(fwspec->fwnode)) {
9561478 if (fwspec->param_count < 3)
9571479 return -EINVAL;
....@@ -961,11 +1483,23 @@
9611483 *hwirq = fwspec->param[1] + 32;
9621484 break;
9631485 case 1: /* PPI */
964
- case GIC_IRQ_TYPE_PARTITION:
9651486 *hwirq = fwspec->param[1] + 16;
1487
+ break;
1488
+ case 2: /* ESPI */
1489
+ *hwirq = fwspec->param[1] + ESPI_BASE_INTID;
1490
+ break;
1491
+ case 3: /* EPPI */
1492
+ *hwirq = fwspec->param[1] + EPPI_BASE_INTID;
9661493 break;
9671494 case GIC_IRQ_TYPE_LPI: /* LPI */
9681495 *hwirq = fwspec->param[1];
1496
+ break;
1497
+ case GIC_IRQ_TYPE_PARTITION:
1498
+ *hwirq = fwspec->param[1];
1499
+ if (fwspec->param[1] >= 16)
1500
+ *hwirq += EPPI_BASE_INTID - 16;
1501
+ else
1502
+ *hwirq += 16;
9691503 break;
9701504 default:
9711505 return -EINVAL;
....@@ -975,7 +1509,7 @@
9751509
9761510 /*
9771511 * Make it clear that broken DTs are... broken.
978
- * Partitionned PPIs are an unfortunate exception.
1512
+ * Partitioned PPIs are an unfortunate exception.
9791513 */
9801514 WARN_ON(*type == IRQ_TYPE_NONE &&
9811515 fwspec->param[0] != GIC_IRQ_TYPE_PARTITION);
....@@ -985,6 +1519,12 @@
9851519 if (is_fwnode_irqchip(fwspec->fwnode)) {
9861520 if(fwspec->param_count != 2)
9871521 return -EINVAL;
1522
+
1523
+ if (fwspec->param[0] < 16) {
1524
+ pr_err(FW_BUG "Illegal GSI%d translation request\n",
1525
+ fwspec->param[0]);
1526
+ return -EINVAL;
1527
+ }
9881528
9891529 *hwirq = fwspec->param[0];
9901530 *type = fwspec->param[1];
....@@ -1046,7 +1586,8 @@
10461586 * then we need to match the partition domain.
10471587 */
10481588 if (fwspec->param_count >= 4 &&
1049
- fwspec->param[0] == 1 && fwspec->param[3] != 0)
1589
+ fwspec->param[0] == 1 && fwspec->param[3] != 0 &&
1590
+ gic_data.ppi_descs)
10501591 return d == partition_get_domain(gic_data.ppi_descs[fwspec->param[1]]);
10511592
10521593 return d == gic_data.domain;
....@@ -1066,6 +1607,9 @@
10661607 {
10671608 struct device_node *np;
10681609 int ret;
1610
+
1611
+ if (!gic_data.ppi_descs)
1612
+ return -ENOMEM;
10691613
10701614 np = of_find_node_by_phandle(fwspec->param[3]);
10711615 if (WARN_ON(!np))
....@@ -1087,6 +1631,186 @@
10871631 .select = gic_irq_domain_select,
10881632 };
10891633
1634
+static bool gic_enable_quirk_msm8996(void *data)
1635
+{
1636
+ struct gic_chip_data *d = data;
1637
+
1638
+ d->flags |= FLAGS_WORKAROUND_GICR_WAKER_MSM8996;
1639
+
1640
+ return true;
1641
+}
1642
+
1643
+static bool gic_enable_quirk_mtk_gicr(void *data)
1644
+{
1645
+ struct gic_chip_data *d = data;
1646
+
1647
+ d->flags |= FLAGS_WORKAROUND_MTK_GICR_SAVE;
1648
+
1649
+ return true;
1650
+}
1651
+
1652
+static bool gic_enable_quirk_cavium_38539(void *data)
1653
+{
1654
+ struct gic_chip_data *d = data;
1655
+
1656
+ d->flags |= FLAGS_WORKAROUND_CAVIUM_ERRATUM_38539;
1657
+
1658
+ return true;
1659
+}
1660
+
1661
+static bool gic_enable_quirk_hip06_07(void *data)
1662
+{
1663
+ struct gic_chip_data *d = data;
1664
+
1665
+ /*
1666
+ * HIP06 GICD_IIDR clashes with GIC-600 product number (despite
1667
+ * not being an actual ARM implementation). The saving grace is
1668
+ * that GIC-600 doesn't have ESPI, so nothing to do in that case.
1669
+ * HIP07 doesn't even have a proper IIDR, and still pretends to
1670
+ * have ESPI. In both cases, put them right.
1671
+ */
1672
+ if (d->rdists.gicd_typer & GICD_TYPER_ESPI) {
1673
+ /* Zero both ESPI and the RES0 field next to it... */
1674
+ d->rdists.gicd_typer &= ~GENMASK(9, 8);
1675
+ return true;
1676
+ }
1677
+
1678
+ return false;
1679
+}
1680
+
1681
+static bool gic_enable_quirk_arm64_2941627(void *data)
1682
+{
1683
+ static_branch_enable(&gic_arm64_2941627_erratum);
1684
+ return true;
1685
+}
1686
+
1687
+static const struct gic_quirk gic_quirks[] = {
1688
+ {
1689
+ .desc = "GICv3: Qualcomm MSM8996 broken firmware",
1690
+ .compatible = "qcom,msm8996-gic-v3",
1691
+ .init = gic_enable_quirk_msm8996,
1692
+ },
1693
+ {
1694
+ .desc = "GICv3: Mediatek Chromebook GICR save problem",
1695
+ .property = "mediatek,broken-save-restore-fw",
1696
+ .init = gic_enable_quirk_mtk_gicr,
1697
+ },
1698
+ {
1699
+ .desc = "GICv3: HIP06 erratum 161010803",
1700
+ .iidr = 0x0204043b,
1701
+ .mask = 0xffffffff,
1702
+ .init = gic_enable_quirk_hip06_07,
1703
+ },
1704
+ {
1705
+ .desc = "GICv3: HIP07 erratum 161010803",
1706
+ .iidr = 0x00000000,
1707
+ .mask = 0xffffffff,
1708
+ .init = gic_enable_quirk_hip06_07,
1709
+ },
1710
+ {
1711
+ /*
1712
+ * Reserved register accesses generate a Synchronous
1713
+ * External Abort. This erratum applies to:
1714
+ * - ThunderX: CN88xx
1715
+ * - OCTEON TX: CN83xx, CN81xx
1716
+ * - OCTEON TX2: CN93xx, CN96xx, CN98xx, CNF95xx*
1717
+ */
1718
+ .desc = "GICv3: Cavium erratum 38539",
1719
+ .iidr = 0xa000034c,
1720
+ .mask = 0xe8f00fff,
1721
+ .init = gic_enable_quirk_cavium_38539,
1722
+ },
1723
+ {
1724
+ /*
1725
+ * GIC-700: 2941627 workaround - IP variant [0,1]
1726
+ *
1727
+ */
1728
+ .desc = "GICv3: ARM64 erratum 2941627",
1729
+ .iidr = 0x0400043b,
1730
+ .mask = 0xff0e0fff,
1731
+ .init = gic_enable_quirk_arm64_2941627,
1732
+ },
1733
+ {
1734
+ /*
1735
+ * GIC-700: 2941627 workaround - IP variant [2]
1736
+ */
1737
+ .desc = "GICv3: ARM64 erratum 2941627",
1738
+ .iidr = 0x0402043b,
1739
+ .mask = 0xff0f0fff,
1740
+ .init = gic_enable_quirk_arm64_2941627,
1741
+ },
1742
+ {
1743
+ }
1744
+};
1745
+
1746
+static void gic_enable_nmi_support(void)
1747
+{
1748
+ int i;
1749
+
1750
+ if (!gic_prio_masking_enabled())
1751
+ return;
1752
+
1753
+ if (gic_data.flags & FLAGS_WORKAROUND_MTK_GICR_SAVE) {
1754
+ pr_warn("Skipping NMI enable due to firmware issues\n");
1755
+ return;
1756
+ }
1757
+
1758
+ ppi_nmi_refs = kcalloc(gic_data.ppi_nr, sizeof(*ppi_nmi_refs), GFP_KERNEL);
1759
+ if (!ppi_nmi_refs)
1760
+ return;
1761
+
1762
+ for (i = 0; i < gic_data.ppi_nr; i++)
1763
+ refcount_set(&ppi_nmi_refs[i], 0);
1764
+
1765
+ /*
1766
+ * Linux itself doesn't use 1:N distribution, so has no need to
1767
+ * set PMHE. The only reason to have it set is if EL3 requires it
1768
+ * (and we can't change it).
1769
+ */
1770
+ if (gic_read_ctlr() & ICC_CTLR_EL1_PMHE_MASK)
1771
+ static_branch_enable(&gic_pmr_sync);
1772
+
1773
+ pr_info("Pseudo-NMIs enabled using %s ICC_PMR_EL1 synchronisation\n",
1774
+ static_branch_unlikely(&gic_pmr_sync) ? "forced" : "relaxed");
1775
+
1776
+ /*
1777
+ * How priority values are used by the GIC depends on two things:
1778
+ * the security state of the GIC (controlled by the GICD_CTRL.DS bit)
1779
+ * and if Group 0 interrupts can be delivered to Linux in the non-secure
1780
+ * world as FIQs (controlled by the SCR_EL3.FIQ bit). These affect the
1781
+ * the ICC_PMR_EL1 register and the priority that software assigns to
1782
+ * interrupts:
1783
+ *
1784
+ * GICD_CTRL.DS | SCR_EL3.FIQ | ICC_PMR_EL1 | Group 1 priority
1785
+ * -----------------------------------------------------------
1786
+ * 1 | - | unchanged | unchanged
1787
+ * -----------------------------------------------------------
1788
+ * 0 | 1 | non-secure | non-secure
1789
+ * -----------------------------------------------------------
1790
+ * 0 | 0 | unchanged | non-secure
1791
+ *
1792
+ * where non-secure means that the value is right-shifted by one and the
1793
+ * MSB bit set, to make it fit in the non-secure priority range.
1794
+ *
1795
+ * In the first two cases, where ICC_PMR_EL1 and the interrupt priority
1796
+ * are both either modified or unchanged, we can use the same set of
1797
+ * priorities.
1798
+ *
1799
+ * In the last case, where only the interrupt priorities are modified to
1800
+ * be in the non-secure range, we use a different PMR value to mask IRQs
1801
+ * and the rest of the values that we use remain unchanged.
1802
+ */
1803
+ if (gic_has_group0() && !gic_dist_security_disabled())
1804
+ static_branch_enable(&gic_nonsecure_priorities);
1805
+
1806
+ static_branch_enable(&supports_pseudo_nmis);
1807
+
1808
+ if (static_branch_likely(&supports_deactivate_key))
1809
+ gic_eoimode1_chip.flags |= IRQCHIP_SUPPORTS_NMI;
1810
+ else
1811
+ gic_chip.flags |= IRQCHIP_SUPPORTS_NMI;
1812
+}
1813
+
10901814 static int __init gic_init_bases(void __iomem *dist_base,
10911815 struct redist_region *rdist_regs,
10921816 u32 nr_redist_regions,
....@@ -1094,7 +1818,6 @@
10941818 struct fwnode_handle *handle)
10951819 {
10961820 u32 typer;
1097
- int gic_irqs;
10981821 int err;
10991822
11001823 if (!is_hyp_mode_available())
....@@ -1111,26 +1834,37 @@
11111834
11121835 /*
11131836 * Find out how many interrupts are supported.
1114
- * The GIC only supports up to 1020 interrupt sources (SGI+PPI+SPI)
11151837 */
11161838 typer = readl_relaxed(gic_data.dist_base + GICD_TYPER);
11171839 gic_data.rdists.gicd_typer = typer;
1118
- gic_irqs = GICD_TYPER_IRQS(typer);
1119
- if (gic_irqs > 1020)
1120
- gic_irqs = 1020;
1121
- gic_data.irq_nr = gic_irqs;
1840
+
1841
+ gic_enable_quirks(readl_relaxed(gic_data.dist_base + GICD_IIDR),
1842
+ gic_quirks, &gic_data);
1843
+
1844
+ pr_info("%d SPIs implemented\n", GIC_LINE_NR - 32);
1845
+ pr_info("%d Extended SPIs implemented\n", GIC_ESPI_NR);
1846
+
1847
+ /*
1848
+ * ThunderX1 explodes on reading GICD_TYPER2, in violation of the
1849
+ * architecture spec (which says that reserved registers are RES0).
1850
+ */
1851
+ if (!(gic_data.flags & FLAGS_WORKAROUND_CAVIUM_ERRATUM_38539))
1852
+ gic_data.rdists.gicd_typer2 = readl_relaxed(gic_data.dist_base + GICD_TYPER2);
11221853
11231854 gic_data.domain = irq_domain_create_tree(handle, &gic_irq_domain_ops,
11241855 &gic_data);
1125
- irq_domain_update_bus_token(gic_data.domain, DOMAIN_BUS_WIRED);
11261856 gic_data.rdists.rdist = alloc_percpu(typeof(*gic_data.rdists.rdist));
1857
+ gic_data.rdists.has_rvpeid = true;
11271858 gic_data.rdists.has_vlpis = true;
11281859 gic_data.rdists.has_direct_lpi = true;
1860
+ gic_data.rdists.has_vpend_valid_dirty = true;
11291861
11301862 if (WARN_ON(!gic_data.domain) || WARN_ON(!gic_data.rdists.rdist)) {
11311863 err = -ENOMEM;
11321864 goto out_free;
11331865 }
1866
+
1867
+ irq_domain_update_bus_token(gic_data.domain, DOMAIN_BUS_WIRED);
11341868
11351869 gic_data.has_rss = !!(typer & GICD_TYPER_RSS);
11361870 pr_info("Distributor has %sRange Selector support\n",
....@@ -1144,15 +1878,23 @@
11441878
11451879 set_handle_irq(gic_handle_irq);
11461880
1147
- gic_update_vlpi_properties();
1881
+ gic_update_rdist_properties();
11481882
1149
- if (IS_ENABLED(CONFIG_ARM_GIC_V3_ITS) && gic_dist_supports_lpis())
1150
- its_init(handle, &gic_data.rdists, gic_data.domain);
1151
-
1152
- gic_smp_init();
11531883 gic_dist_init();
11541884 gic_cpu_init();
1885
+ gic_smp_init();
11551886 gic_cpu_pm_init();
1887
+ gic_syscore_init();
1888
+
1889
+ if (gic_dist_supports_lpis()) {
1890
+ its_init(handle, &gic_data.rdists, gic_data.domain);
1891
+ its_cpu_init();
1892
+ } else {
1893
+ if (IS_ENABLED(CONFIG_ARM_GIC_V2M))
1894
+ gicv2m_init(handle, gic_data.domain);
1895
+ }
1896
+
1897
+ gic_enable_nmi_support();
11561898
11571899 return 0;
11581900
....@@ -1185,6 +1927,10 @@
11851927 if (!parts_node)
11861928 return;
11871929
1930
+ gic_data.ppi_descs = kcalloc(gic_data.ppi_nr, sizeof(*gic_data.ppi_descs), GFP_KERNEL);
1931
+ if (!gic_data.ppi_descs)
1932
+ goto out_put_node;
1933
+
11881934 nr_parts = of_get_child_count(parts_node);
11891935
11901936 if (!nr_parts)
....@@ -1202,8 +1948,8 @@
12021948
12031949 part->partition_id = of_node_to_fwnode(child_part);
12041950
1205
- pr_info("GIC: PPI partition %s[%d] { ",
1206
- child_part->name, part_idx);
1951
+ pr_info("GIC: PPI partition %pOFn[%d] { ",
1952
+ child_part, part_idx);
12071953
12081954 n = of_property_count_elems_of_size(child_part, "affinity",
12091955 sizeof(u32));
....@@ -1224,19 +1970,22 @@
12241970 continue;
12251971
12261972 cpu = of_cpu_node_to_id(cpu_node);
1227
- if (WARN_ON(cpu < 0))
1973
+ if (WARN_ON(cpu < 0)) {
1974
+ of_node_put(cpu_node);
12281975 continue;
1976
+ }
12291977
12301978 pr_cont("%pOF[%d] ", cpu_node, cpu);
12311979
12321980 cpumask_set_cpu(cpu, &part->mask);
1981
+ of_node_put(cpu_node);
12331982 }
12341983
12351984 pr_cont("}\n");
12361985 part_idx++;
12371986 }
12381987
1239
- for (i = 0; i < 16; i++) {
1988
+ for (i = 0; i < gic_data.ppi_nr; i++) {
12401989 unsigned int irq;
12411990 struct partition_desc *desc;
12421991 struct irq_fwspec ppi_fwspec = {
....@@ -1286,10 +2035,11 @@
12862035 gic_v3_kvm_info.vcpu = r;
12872036
12882037 gic_v3_kvm_info.has_v4 = gic_data.rdists.has_vlpis;
2038
+ gic_v3_kvm_info.has_v4_1 = gic_data.rdists.has_rvpeid;
12892039 gic_set_kvm_info(&gic_v3_kvm_info);
12902040 }
12912041
1292
-static int __init gicv3_of_init(struct device_node *node, struct device_node *parent)
2042
+static int __init gic_of_init(struct device_node *node, struct device_node *parent)
12932043 {
12942044 void __iomem *dist_base;
12952045 struct redist_region *rdist_regs;
....@@ -1336,6 +2086,8 @@
13362086 if (of_property_read_u64(node, "redistributor-stride", &redist_stride))
13372087 redist_stride = 0;
13382088
2089
+ gic_enable_of_quirks(node, gic_quirks, &gic_data);
2090
+
13392091 err = gic_init_bases(dist_base, rdist_regs, nr_redist_regions,
13402092 redist_stride, &node->fwnode);
13412093 if (err)
....@@ -1357,7 +2109,7 @@
13572109 return err;
13582110 }
13592111
1360
-IRQCHIP_DECLARE(gic_v3, "arm,gic-v3", gicv3_of_init);
2112
+IRQCHIP_DECLARE(gic_v3, "arm,gic-v3", gic_of_init);
13612113
13622114 #ifdef CONFIG_ACPI
13632115 static struct
....@@ -1384,7 +2136,7 @@
13842136 }
13852137
13862138 static int __init
1387
-gic_acpi_parse_madt_redist(struct acpi_subtable_header *header,
2139
+gic_acpi_parse_madt_redist(union acpi_subtable_headers *header,
13882140 const unsigned long end)
13892141 {
13902142 struct acpi_madt_generic_redistributor *redist =
....@@ -1402,7 +2154,7 @@
14022154 }
14032155
14042156 static int __init
1405
-gic_acpi_parse_madt_gicc(struct acpi_subtable_header *header,
2157
+gic_acpi_parse_madt_gicc(union acpi_subtable_headers *header,
14062158 const unsigned long end)
14072159 {
14082160 struct acpi_madt_generic_interrupt *gicc =
....@@ -1444,14 +2196,14 @@
14442196 return -ENODEV;
14452197 }
14462198
1447
-static int __init gic_acpi_match_gicr(struct acpi_subtable_header *header,
2199
+static int __init gic_acpi_match_gicr(union acpi_subtable_headers *header,
14482200 const unsigned long end)
14492201 {
14502202 /* Subtable presence means that redist exists, that's it */
14512203 return 0;
14522204 }
14532205
1454
-static int __init gic_acpi_match_gicc(struct acpi_subtable_header *header,
2206
+static int __init gic_acpi_match_gicc(union acpi_subtable_headers *header,
14552207 const unsigned long end)
14562208 {
14572209 struct acpi_madt_generic_interrupt *gicc =
....@@ -1521,7 +2273,7 @@
15212273 return true;
15222274 }
15232275
1524
-static int __init gic_acpi_parse_virt_madt_gicc(struct acpi_subtable_header *header,
2276
+static int __init gic_acpi_parse_virt_madt_gicc(union acpi_subtable_headers *header,
15252277 const unsigned long end)
15262278 {
15272279 struct acpi_madt_generic_interrupt *gicc =
....@@ -1599,11 +2351,12 @@
15992351 }
16002352
16012353 gic_v3_kvm_info.has_v4 = gic_data.rdists.has_vlpis;
2354
+ gic_v3_kvm_info.has_v4_1 = gic_data.rdists.has_rvpeid;
16022355 gic_set_kvm_info(&gic_v3_kvm_info);
16032356 }
16042357
16052358 static int __init
1606
-gic_acpi_init(struct acpi_subtable_header *header, const unsigned long end)
2359
+gic_acpi_init(union acpi_subtable_headers *header, const unsigned long end)
16072360 {
16082361 struct acpi_madt_generic_distributor *dist;
16092362 struct fwnode_handle *domain_handle;
....@@ -1637,7 +2390,7 @@
16372390 if (err)
16382391 goto out_redist_unmap;
16392392
1640
- domain_handle = irq_domain_alloc_fwnode(acpi_data.dist_base);
2393
+ domain_handle = irq_domain_alloc_fwnode(&dist->base_address);
16412394 if (!domain_handle) {
16422395 err = -ENOMEM;
16432396 goto out_redist_unmap;