hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/soc/rockchip/fiq_debugger/fiq_debugger.c
....@@ -50,6 +50,7 @@
5050 #endif
5151
5252 #include <linux/uaccess.h>
53
+#include <linux/cpuhotplug.h>
5354
5455 #include "fiq_debugger.h"
5556 #include "fiq_debugger_priv.h"
....@@ -148,10 +149,7 @@
148149 static bool initial_console_enable;
149150 #endif
150151
151
-#ifdef CONFIG_FIQ_DEBUGGER_TRUST_ZONE
152
-static struct fiq_debugger_state *state_tf;
153
-#endif
154
-
152
+static struct fiq_debugger_state *g_state;
155153 static bool fiq_kgdb_enable;
156154 static bool fiq_debugger_disable;
157155
....@@ -1077,7 +1075,7 @@
10771075 #ifdef CONFIG_FIQ_DEBUGGER_TRUST_ZONE
10781076 void fiq_debugger_fiq(void *regs, u32 cpu)
10791077 {
1080
- struct fiq_debugger_state *state = state_tf;
1078
+ struct fiq_debugger_state *state = g_state;
10811079 bool need_irq;
10821080
10831081 if (!state)
....@@ -1444,6 +1442,18 @@
14441442 return 0;
14451443 }
14461444
1445
+static int fiq_debugger_cpu_offine_migrate_irq(unsigned int cpu)
1446
+{
1447
+ if (g_state && cpu == g_state->current_cpu) {
1448
+ unsigned int new_cpu = cpumask_any_but(cpu_online_mask, cpu);
1449
+
1450
+ if (new_cpu < nr_cpu_ids)
1451
+ g_state->current_cpu = new_cpu;
1452
+ }
1453
+
1454
+ return 0;
1455
+}
1456
+
14471457 static int fiq_debugger_probe(struct platform_device *pdev)
14481458 {
14491459 int ret;
....@@ -1451,6 +1461,7 @@
14511461 struct fiq_debugger_state *state;
14521462 int fiq;
14531463 int uart_irq;
1464
+ enum cpuhp_state cs = -1;
14541465
14551466 if (pdev->id >= MAX_FIQ_DEBUGGER_PORTS)
14561467 return -EINVAL;
....@@ -1556,7 +1567,7 @@
15561567 pr_err("%s: could not install nmi irq handler\n", __func__);
15571568 irq_clear_status_flags(state->uart_irq, IRQ_NOAUTOEN);
15581569 ret = request_irq(state->uart_irq, fiq_debugger_uart_irq,
1559
- IRQF_NO_SUSPEND, "debug", state);
1570
+ IRQF_NO_SUSPEND | IRQF_NOBALANCING, "debug", state);
15601571 } else {
15611572 enable_nmi(state->uart_irq);
15621573 }
....@@ -1570,6 +1581,15 @@
15701581 * can.
15711582 */
15721583 enable_irq_wake(state->uart_irq);
1584
+
1585
+ ret = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN,
1586
+ "soc/fiq_debugger",
1587
+ NULL,
1588
+ fiq_debugger_cpu_offine_migrate_irq);
1589
+ if (ret < 0)
1590
+ pr_err("%s: could not setup cpu offine handler\n", __func__);
1591
+ else
1592
+ cs = ret;
15731593 }
15741594
15751595 if (state->signal_irq >= 0) {
....@@ -1600,10 +1620,6 @@
16001620 if (state->no_sleep)
16011621 fiq_debugger_handle_wakeup(state);
16021622
1603
-#ifdef CONFIG_FIQ_DEBUGGER_TRUST_ZONE
1604
- state_tf = state;
1605
-#endif
1606
-
16071623 if (pdata->uart_init) {
16081624 ret = pdata->uart_init(pdev);
16091625 if (ret)
....@@ -1630,7 +1646,7 @@
16301646
16311647 /* switch to cpu0 default */
16321648 fiq_debugger_switch_cpu(state, 0);
1633
-
1649
+ g_state = state;
16341650 return 0;
16351651
16361652 err_register_irq:
....@@ -1641,6 +1657,8 @@
16411657 clk_disable(state->clk);
16421658 if (state->clk)
16431659 clk_put(state->clk);
1660
+ if (cs >= 0)
1661
+ cpuhp_remove_state_nocalls(cs);
16441662 wakeup_source_remove(&state->debugger_wake_src);
16451663 __pm_relax(&state->debugger_wake_src);
16461664 platform_set_drvdata(pdev, NULL);