From 2f7c68cb55ecb7331f2381deb497c27155f32faf Mon Sep 17 00:00:00 2001
From: hc <hc@nodka.com>
Date: Wed, 03 Jan 2024 09:43:39 +0000
Subject: [PATCH] update kernel to 5.10.198

---
 kernel/drivers/soc/rockchip/fiq_debugger/fiq_debugger.c |   40 +++++++++++++++++++++++++++++-----------
 1 files changed, 29 insertions(+), 11 deletions(-)

diff --git a/kernel/drivers/soc/rockchip/fiq_debugger/fiq_debugger.c b/kernel/drivers/soc/rockchip/fiq_debugger/fiq_debugger.c
index 1f8e88e..4647144 100644
--- a/kernel/drivers/soc/rockchip/fiq_debugger/fiq_debugger.c
+++ b/kernel/drivers/soc/rockchip/fiq_debugger/fiq_debugger.c
@@ -50,6 +50,7 @@
 #endif
 
 #include <linux/uaccess.h>
+#include <linux/cpuhotplug.h>
 
 #include "fiq_debugger.h"
 #include "fiq_debugger_priv.h"
@@ -148,10 +149,7 @@
 static bool initial_console_enable;
 #endif
 
-#ifdef CONFIG_FIQ_DEBUGGER_TRUST_ZONE
-static struct fiq_debugger_state *state_tf;
-#endif
-
+static struct fiq_debugger_state *g_state;
 static bool fiq_kgdb_enable;
 static bool fiq_debugger_disable;
 
@@ -1077,7 +1075,7 @@
 #ifdef CONFIG_FIQ_DEBUGGER_TRUST_ZONE
 void fiq_debugger_fiq(void *regs, u32 cpu)
 {
-	struct fiq_debugger_state *state = state_tf;
+	struct fiq_debugger_state *state = g_state;
 	bool need_irq;
 
 	if (!state)
@@ -1444,6 +1442,18 @@
 	return 0;
 }
 
+static int fiq_debugger_cpu_offine_migrate_irq(unsigned int cpu)
+{
+	if (g_state && cpu == g_state->current_cpu) {
+		unsigned int new_cpu = cpumask_any_but(cpu_online_mask, cpu);
+
+		if (new_cpu < nr_cpu_ids)
+			g_state->current_cpu = new_cpu;
+	}
+
+	return 0;
+}
+
 static int fiq_debugger_probe(struct platform_device *pdev)
 {
 	int ret;
@@ -1451,6 +1461,7 @@
 	struct fiq_debugger_state *state;
 	int fiq;
 	int uart_irq;
+	enum cpuhp_state cs = -1;
 
 	if (pdev->id >= MAX_FIQ_DEBUGGER_PORTS)
 		return -EINVAL;
@@ -1556,7 +1567,7 @@
 			pr_err("%s: could not install nmi irq handler\n", __func__);
 			irq_clear_status_flags(state->uart_irq, IRQ_NOAUTOEN);
 			ret = request_irq(state->uart_irq, fiq_debugger_uart_irq,
-					  IRQF_NO_SUSPEND, "debug", state);
+					  IRQF_NO_SUSPEND | IRQF_NOBALANCING, "debug", state);
 		} else {
 			enable_nmi(state->uart_irq);
 		}
@@ -1570,6 +1581,15 @@
 		 * can.
 		 */
 		enable_irq_wake(state->uart_irq);
+
+		ret = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN,
+						"soc/fiq_debugger",
+						NULL,
+						fiq_debugger_cpu_offine_migrate_irq);
+		if (ret < 0)
+			pr_err("%s: could not setup cpu offine handler\n", __func__);
+		else
+			cs = ret;
 	}
 
 	if (state->signal_irq >= 0) {
@@ -1600,10 +1620,6 @@
 	if (state->no_sleep)
 		fiq_debugger_handle_wakeup(state);
 
-#ifdef CONFIG_FIQ_DEBUGGER_TRUST_ZONE
-	state_tf = state;
-#endif
-
 	if (pdata->uart_init) {
 		ret = pdata->uart_init(pdev);
 		if (ret)
@@ -1630,7 +1646,7 @@
 
 	/* switch to cpu0 default */
 	fiq_debugger_switch_cpu(state, 0);
-
+	g_state = state;
 	return 0;
 
 err_register_irq:
@@ -1641,6 +1657,8 @@
 		clk_disable(state->clk);
 	if (state->clk)
 		clk_put(state->clk);
+	if (cs >= 0)
+		cpuhp_remove_state_nocalls(cs);
 	wakeup_source_remove(&state->debugger_wake_src);
 	__pm_relax(&state->debugger_wake_src);
 	platform_set_drvdata(pdev, NULL);

--
Gitblit v1.6.2