From 6778948f9de86c3cfaf36725a7c87dcff9ba247f Mon Sep 17 00:00:00 2001
From: hc <hc@nodka.com>
Date: Mon, 11 Dec 2023 08:20:59 +0000
Subject: [PATCH] kernel_5.10 no rt

---
 kernel/drivers/soc/rockchip/fiq_debugger/rk_fiq_debugger.c |   20 ++++++++++++--------
 1 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/kernel/drivers/soc/rockchip/fiq_debugger/rk_fiq_debugger.c b/kernel/drivers/soc/rockchip/fiq_debugger/rk_fiq_debugger.c
index 3c85c83..1fb72a5 100644
--- a/kernel/drivers/soc/rockchip/fiq_debugger/rk_fiq_debugger.c
+++ b/kernel/drivers/soc/rockchip/fiq_debugger/rk_fiq_debugger.c
@@ -179,11 +179,13 @@
 
 	if (lsr & UART_LSR_DR) {
 		temp = rk_fiq_read(t, UART_RX);
-		buf[n & 0x1f] = temp;
-		n++;
-		if (temp == 'q' && n > 2) {
-			if ((buf[(n - 2) & 0x1f] == 'i') &&
-			    (buf[(n - 3) & 0x1f] == 'f'))
+		buf[++n & 0x1f] = temp;
+
+		if (temp == 'q') {
+			if ((buf[(n - 1) & 0x1f] == 'i') &&
+			    (buf[(n - 2) & 0x1f] == 'f') &&
+			    (buf[(n - 3) & 0x1f] != '_') &&
+			    (buf[(n - 3) & 0x1f] != ' '))
 				return FIQ_DEBUGGER_BREAK;
 			else
 				return temp;
@@ -334,7 +336,7 @@
 		unsigned int dropped;
 
 		set_current_state(TASK_INTERRUPTIBLE);
-		if (kfifo_is_empty(&fifo) && kfifo_is_empty(&tty_fifo)) {
+		if (console_thread_stop || (kfifo_is_empty(&fifo) && kfifo_is_empty(&tty_fifo))) {
 			smp_store_mb(console_thread_running, false);
 			schedule();
 			smp_store_mb(console_thread_running, true);
@@ -344,13 +346,13 @@
 		set_current_state(TASK_RUNNING);
 
 		while (!console_thread_stop && (!kfifo_is_empty(&fifo) || !kfifo_is_empty(&tty_fifo))) {
-			while (kfifo_get(&fifo, &c)) {
+			while (!console_thread_stop && kfifo_get(&fifo, &c)) {
 				console_put(pdev, &c, 1);
 				if (c == '\n')
 					break;
 			}
 
-			while (kfifo_get(&tty_fifo, &c)) {
+			while (!console_thread_stop && kfifo_get(&tty_fifo, &c)) {
 				console_putc(pdev, c);
 				len_tty++;
 				if (c == '\n')
@@ -418,6 +420,8 @@
 	unsigned int ret = 0;
 	struct rk_fiq_debugger *t;
 
+	if (console_thread_stop)
+		return count;
 	t = container_of(dev_get_platdata(&pdev->dev), typeof(*t), pdata);
 
 	if (count > 0) {

--
Gitblit v1.6.2