hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/drivers/soc/rockchip/fiq_debugger/rk_fiq_debugger.c
....@@ -179,11 +179,13 @@
179179
180180 if (lsr & UART_LSR_DR) {
181181 temp = rk_fiq_read(t, UART_RX);
182
- buf[n & 0x1f] = temp;
183
- n++;
184
- if (temp == 'q' && n > 2) {
185
- if ((buf[(n - 2) & 0x1f] == 'i') &&
186
- (buf[(n - 3) & 0x1f] == 'f'))
182
+ buf[++n & 0x1f] = temp;
183
+
184
+ if (temp == 'q') {
185
+ if ((buf[(n - 1) & 0x1f] == 'i') &&
186
+ (buf[(n - 2) & 0x1f] == 'f') &&
187
+ (buf[(n - 3) & 0x1f] != '_') &&
188
+ (buf[(n - 3) & 0x1f] != ' '))
187189 return FIQ_DEBUGGER_BREAK;
188190 else
189191 return temp;
....@@ -334,7 +336,7 @@
334336 unsigned int dropped;
335337
336338 set_current_state(TASK_INTERRUPTIBLE);
337
- if (kfifo_is_empty(&fifo) && kfifo_is_empty(&tty_fifo)) {
339
+ if (console_thread_stop || (kfifo_is_empty(&fifo) && kfifo_is_empty(&tty_fifo))) {
338340 smp_store_mb(console_thread_running, false);
339341 schedule();
340342 smp_store_mb(console_thread_running, true);
....@@ -344,13 +346,13 @@
344346 set_current_state(TASK_RUNNING);
345347
346348 while (!console_thread_stop && (!kfifo_is_empty(&fifo) || !kfifo_is_empty(&tty_fifo))) {
347
- while (kfifo_get(&fifo, &c)) {
349
+ while (!console_thread_stop && kfifo_get(&fifo, &c)) {
348350 console_put(pdev, &c, 1);
349351 if (c == '\n')
350352 break;
351353 }
352354
353
- while (kfifo_get(&tty_fifo, &c)) {
355
+ while (!console_thread_stop && kfifo_get(&tty_fifo, &c)) {
354356 console_putc(pdev, c);
355357 len_tty++;
356358 if (c == '\n')
....@@ -418,6 +420,8 @@
418420 unsigned int ret = 0;
419421 struct rk_fiq_debugger *t;
420422
423
+ if (console_thread_stop)
424
+ return count;
421425 t = container_of(dev_get_platdata(&pdev->dev), typeof(*t), pdata);
422426
423427 if (count > 0) {
....@@ -759,6 +763,11 @@
759763 if ((sip_fiq_debugger_is_enabled()) &&
760764 (sip_fiq_debugger_get_target_cpu() == cpu)) {
761765 target_cpu = cpumask_any_but(cpu_online_mask, cpu);
766
+ if (target_cpu >= nr_cpu_ids) {
767
+ pr_err("%s: migrate fiq fail!\n", __func__);
768
+ return -EBUSY;
769
+ }
770
+
762771 sip_fiq_debugger_switch_cpu(target_cpu);
763772 }
764773