hc
2024-05-10 9999e48639b3cecb08ffb37358bcba3b48161b29
kernel/drivers/irqchip/irq-gic-v3-its.c
....@@ -268,13 +268,23 @@
268268 raw_spin_unlock_irqrestore(&vpe->vpe_lock, flags);
269269 }
270270
271
+static struct irq_chip its_vpe_irq_chip;
272
+
271273 static int irq_to_cpuid_lock(struct irq_data *d, unsigned long *flags)
272274 {
273
- struct its_vlpi_map *map = get_vlpi_map(d);
275
+ struct its_vpe *vpe = NULL;
274276 int cpu;
275277
276
- if (map) {
277
- cpu = vpe_to_cpuid_lock(map->vpe, flags);
278
+ if (d->chip == &its_vpe_irq_chip) {
279
+ vpe = irq_data_get_irq_chip_data(d);
280
+ } else {
281
+ struct its_vlpi_map *map = get_vlpi_map(d);
282
+ if (map)
283
+ vpe = map->vpe;
284
+ }
285
+
286
+ if (vpe) {
287
+ cpu = vpe_to_cpuid_lock(vpe, flags);
278288 } else {
279289 /* Physical LPIs are already locked via the irq_desc lock */
280290 struct its_device *its_dev = irq_data_get_irq_chip_data(d);
....@@ -288,10 +298,18 @@
288298
289299 static void irq_to_cpuid_unlock(struct irq_data *d, unsigned long flags)
290300 {
291
- struct its_vlpi_map *map = get_vlpi_map(d);
301
+ struct its_vpe *vpe = NULL;
292302
293
- if (map)
294
- vpe_to_cpuid_unlock(map->vpe, flags);
303
+ if (d->chip == &its_vpe_irq_chip) {
304
+ vpe = irq_data_get_irq_chip_data(d);
305
+ } else {
306
+ struct its_vlpi_map *map = get_vlpi_map(d);
307
+ if (map)
308
+ vpe = map->vpe;
309
+ }
310
+
311
+ if (vpe)
312
+ vpe_to_cpuid_unlock(vpe, flags);
295313 }
296314
297315 static struct its_collection *valid_col(struct its_collection *col)
....@@ -1423,13 +1441,28 @@
14231441 cpu_relax();
14241442 }
14251443
1444
+static void __direct_lpi_inv(struct irq_data *d, u64 val)
1445
+{
1446
+ void __iomem *rdbase;
1447
+ unsigned long flags;
1448
+ int cpu;
1449
+
1450
+ /* Target the redistributor this LPI is currently routed to */
1451
+ cpu = irq_to_cpuid_lock(d, &flags);
1452
+ raw_spin_lock(&gic_data_rdist_cpu(cpu)->rd_lock);
1453
+
1454
+ rdbase = per_cpu_ptr(gic_rdists->rdist, cpu)->rd_base;
1455
+ gic_write_lpir(val, rdbase + GICR_INVLPIR);
1456
+ wait_for_syncr(rdbase);
1457
+
1458
+ raw_spin_unlock(&gic_data_rdist_cpu(cpu)->rd_lock);
1459
+ irq_to_cpuid_unlock(d, flags);
1460
+}
1461
+
14261462 static void direct_lpi_inv(struct irq_data *d)
14271463 {
14281464 struct its_vlpi_map *map = get_vlpi_map(d);
1429
- void __iomem *rdbase;
1430
- unsigned long flags;
14311465 u64 val;
1432
- int cpu;
14331466
14341467 if (map) {
14351468 struct its_device *its_dev = irq_data_get_irq_chip_data(d);
....@@ -1443,15 +1476,7 @@
14431476 val = d->hwirq;
14441477 }
14451478
1446
- /* Target the redistributor this LPI is currently routed to */
1447
- cpu = irq_to_cpuid_lock(d, &flags);
1448
- raw_spin_lock(&gic_data_rdist_cpu(cpu)->rd_lock);
1449
- rdbase = per_cpu_ptr(gic_rdists->rdist, cpu)->rd_base;
1450
- gic_write_lpir(val, rdbase + GICR_INVLPIR);
1451
-
1452
- wait_for_syncr(rdbase);
1453
- raw_spin_unlock(&gic_data_rdist_cpu(cpu)->rd_lock);
1454
- irq_to_cpuid_unlock(d, flags);
1479
+ __direct_lpi_inv(d, val);
14551480 }
14561481
14571482 static void lpi_update_config(struct irq_data *d, u8 clr, u8 set)
....@@ -1493,7 +1518,7 @@
14931518 *
14941519 * Ideally, we'd issue a VMAPTI to set the doorbell to its LPI
14951520 * value or to 1023, depending on the enable bit. But that
1496
- * would be issueing a mapping for an /existing/ DevID+EventID
1521
+ * would be issuing a mapping for an /existing/ DevID+EventID
14971522 * pair, which is UNPREDICTABLE. Instead, let's issue a VMOVI
14981523 * to the /same/ vPE, using this opportunity to adjust the
14991524 * doorbell. Mouahahahaha. We loves it, Precious.
....@@ -2168,7 +2193,9 @@
21682193 {
21692194 struct page *prop_page;
21702195
2171
- if (of_machine_is_compatible("rockchip,rk3568") || of_machine_is_compatible("rockchip,rk3566"))
2196
+ if (of_machine_is_compatible("rockchip,rk3568") ||
2197
+ of_machine_is_compatible("rockchip,rk3567") ||
2198
+ of_machine_is_compatible("rockchip,rk3566"))
21722199 gfp_flags |= GFP_DMA32;
21732200 prop_page = alloc_pages(gfp_flags, get_order(LPI_PROPBASE_SZ));
21742201 if (!prop_page)
....@@ -2306,7 +2333,9 @@
23062333 }
23072334
23082335 gfp_flags = GFP_KERNEL | __GFP_ZERO;
2309
- if (of_machine_is_compatible("rockchip,rk3568") || of_machine_is_compatible("rockchip,rk3566"))
2336
+ if (of_machine_is_compatible("rockchip,rk3568") ||
2337
+ of_machine_is_compatible("rockchip,rk3567") ||
2338
+ of_machine_is_compatible("rockchip,rk3566"))
23102339 gfp_flags |= GFP_DMA32;
23112340 page = alloc_pages_node(its->numa_node, gfp_flags, order);
23122341 if (!page)
....@@ -2357,6 +2386,7 @@
23572386
23582387 if (IS_ENABLED(CONFIG_NO_GKI) &&
23592388 (of_machine_is_compatible("rockchip,rk3568") ||
2389
+ of_machine_is_compatible("rockchip,rk3567") ||
23602390 of_machine_is_compatible("rockchip,rk3566") ||
23612391 of_machine_is_compatible("rockchip,rk3588"))) {
23622392 if (tmp & GITS_BASER_SHAREABILITY_MASK)
....@@ -2947,7 +2977,9 @@
29472977 {
29482978 struct page *pend_page;
29492979
2950
- if (of_machine_is_compatible("rockchip,rk3568") || of_machine_is_compatible("rockchip,rk3566"))
2980
+ if (of_machine_is_compatible("rockchip,rk3568") ||
2981
+ of_machine_is_compatible("rockchip,rk3567") ||
2982
+ of_machine_is_compatible("rockchip,rk3566"))
29512983 gfp_flags |= GFP_DMA32;
29522984 pend_page = alloc_pages(gfp_flags | __GFP_ZERO,
29532985 get_order(LPI_PENDBASE_SZ));
....@@ -3108,6 +3140,7 @@
31083140
31093141 if (IS_ENABLED(CONFIG_NO_GKI) &&
31103142 (of_machine_is_compatible("rockchip,rk3568") ||
3143
+ of_machine_is_compatible("rockchip,rk3567") ||
31113144 of_machine_is_compatible("rockchip,rk3566") ||
31123145 of_machine_is_compatible("rockchip,rk3588")))
31133146 tmp &= ~GICR_PROPBASER_SHAREABILITY_MASK;
....@@ -3138,6 +3171,7 @@
31383171
31393172 if (IS_ENABLED(CONFIG_NO_GKI) &&
31403173 (of_machine_is_compatible("rockchip,rk3568") ||
3174
+ of_machine_is_compatible("rockchip,rk3567") ||
31413175 of_machine_is_compatible("rockchip,rk3566") ||
31423176 of_machine_is_compatible("rockchip,rk3588")))
31433177 tmp &= ~GICR_PENDBASER_SHAREABILITY_MASK;
....@@ -3163,7 +3197,7 @@
31633197
31643198 /*
31653199 * It's possible for CPU to receive VLPIs before it is
3166
- * sheduled as a vPE, especially for the first CPU, and the
3200
+ * scheduled as a vPE, especially for the first CPU, and the
31673201 * VLPI with INTID larger than 2^(IDbits+1) will be considered
31683202 * as out of range and dropped by GIC.
31693203 * So we initialize IDbits to known value to avoid VLPI drop.
....@@ -3306,7 +3340,9 @@
33063340 if (!table[idx]) {
33073341 gfp_t gfp_flags = GFP_KERNEL | __GFP_ZERO;
33083342
3309
- if (of_machine_is_compatible("rockchip,rk3568") || of_machine_is_compatible("rockchip,rk3566"))
3343
+ if (of_machine_is_compatible("rockchip,rk3568") ||
3344
+ of_machine_is_compatible("rockchip,rk3567") ||
3345
+ of_machine_is_compatible("rockchip,rk3566"))
33103346 gfp_flags |= GFP_DMA32;
33113347 page = alloc_pages_node(its->numa_node, gfp_flags,
33123348 get_order(baser->psz));
....@@ -3414,7 +3450,9 @@
34143450 sz = nr_ites * (FIELD_GET(GITS_TYPER_ITT_ENTRY_SIZE, its->typer) + 1);
34153451 sz = max(sz, ITS_ITT_ALIGN) + ITS_ITT_ALIGN - 1;
34163452 gfp_flags = GFP_KERNEL;
3417
- if (of_machine_is_compatible("rockchip,rk3568") || of_machine_is_compatible("rockchip,rk3566")) {
3453
+ if (of_machine_is_compatible("rockchip,rk3568") ||
3454
+ of_machine_is_compatible("rockchip,rk3567") ||
3455
+ of_machine_is_compatible("rockchip,rk3566")) {
34183456 gfp_flags |= GFP_DMA32;
34193457 itt = (void *)__get_free_pages(gfp_flags, get_order(sz));
34203458 } else {
....@@ -3436,6 +3474,7 @@
34363474 kfree(dev);
34373475
34383476 if (of_machine_is_compatible("rockchip,rk3568") ||
3477
+ of_machine_is_compatible("rockchip,rk3567") ||
34393478 of_machine_is_compatible("rockchip,rk3566"))
34403479 free_pages((unsigned long)itt, get_order(sz));
34413480 else
....@@ -3480,6 +3519,7 @@
34803519 kfree(its_dev->event_map.col_map);
34813520
34823521 if (of_machine_is_compatible("rockchip,rk3568") ||
3522
+ of_machine_is_compatible("rockchip,rk3567") ||
34833523 of_machine_is_compatible("rockchip,rk3566"))
34843524 free_pages((unsigned long)its_dev->itt, get_order(its_dev->itt_sz));
34853525 else
....@@ -3679,7 +3719,7 @@
36793719
36803720 /*
36813721 * If all interrupts have been freed, start mopping the
3682
- * floor. This is conditionned on the device not being shared.
3722
+ * floor. This is conditioned on the device not being shared.
36833723 */
36843724 if (!its_dev->shared &&
36853725 bitmap_empty(its_dev->event_map.lpi_map,
....@@ -3984,18 +4024,10 @@
39844024 {
39854025 struct its_vpe *vpe = irq_data_get_irq_chip_data(d);
39864026
3987
- if (gic_rdists->has_direct_lpi) {
3988
- void __iomem *rdbase;
3989
-
3990
- /* Target the redistributor this VPE is currently known on */
3991
- raw_spin_lock(&gic_data_rdist_cpu(vpe->col_idx)->rd_lock);
3992
- rdbase = per_cpu_ptr(gic_rdists->rdist, vpe->col_idx)->rd_base;
3993
- gic_write_lpir(d->parent_data->hwirq, rdbase + GICR_INVLPIR);
3994
- wait_for_syncr(rdbase);
3995
- raw_spin_unlock(&gic_data_rdist_cpu(vpe->col_idx)->rd_lock);
3996
- } else {
4027
+ if (gic_rdists->has_direct_lpi)
4028
+ __direct_lpi_inv(d, d->parent_data->hwirq);
4029
+ else
39974030 its_vpe_send_cmd(vpe, its_send_inv);
3998
- }
39994031 }
40004032
40014033 static void its_vpe_mask_irq(struct irq_data *d)
....@@ -4257,7 +4289,7 @@
42574289 {
42584290 /*
42594291 * There is no notion of affinity for virtual SGIs, at least
4260
- * not on the host (since they can only be targetting a vPE).
4292
+ * not on the host (since they can only be targeting a vPE).
42614293 * Tell the kernel we've done whatever it asked for.
42624294 */
42634295 irq_data_update_effective_affinity(d, mask_val);
....@@ -4302,7 +4334,7 @@
43024334 /*
43034335 * Locking galore! We can race against two different events:
43044336 *
4305
- * - Concurent vPE affinity change: we must make sure it cannot
4337
+ * - Concurrent vPE affinity change: we must make sure it cannot
43064338 * happen, or we'll talk to the wrong redistributor. This is
43074339 * identical to what happens with vLPIs.
43084340 *
....@@ -5085,7 +5117,9 @@
50855117 its->numa_node = numa_node;
50865118
50875119 gfp_flags = GFP_KERNEL | __GFP_ZERO;
5088
- if (of_machine_is_compatible("rockchip,rk3568") || of_machine_is_compatible("rockchip,rk3566"))
5120
+ if (of_machine_is_compatible("rockchip,rk3568") ||
5121
+ of_machine_is_compatible("rockchip,rk3567") ||
5122
+ of_machine_is_compatible("rockchip,rk3566"))
50895123 gfp_flags |= GFP_DMA32;
50905124 page = alloc_pages_node(its->numa_node, gfp_flags,
50915125 get_order(ITS_CMD_QUEUE_SZ));
....@@ -5120,6 +5154,7 @@
51205154
51215155 if (IS_ENABLED(CONFIG_NO_GKI) &&
51225156 (of_machine_is_compatible("rockchip,rk3568") ||
5157
+ of_machine_is_compatible("rockchip,rk3567") ||
51235158 of_machine_is_compatible("rockchip,rk3566") ||
51245159 of_machine_is_compatible("rockchip,rk3588")))
51255160 tmp &= ~GITS_CBASER_SHAREABILITY_MASK;