--- zzzz-none-000/linux-5.4.213/kernel/printk/printk.c 2022-09-15 10:04:56.000000000 +0000 +++ miami-7690-761/linux-5.4.213/kernel/printk/printk.c 2024-05-29 11:20:02.000000000 +0000 @@ -17,6 +17,11 @@ * 01Mar01 Andrew Morton */ +#ifdef CONFIG_AVM_FASTIRQ +#include +#define CLIENT_FIQ_PRIO FIQ_PRIO_WATCHDOG +#endif + #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include @@ -49,6 +54,8 @@ #include #include +#include + #include #include @@ -93,6 +100,17 @@ */ int __read_mostly suppress_printk; +/* AVM RTE extension for caller_id */ +#define PRINTK_CALLER_IRQ 0x80000000 /* Same as in mainline */ +#define PRINTK_CALLER_AVM_RTE 0x40000000 +#define PRINTK_CALLER_MASK (PRINTK_CALLER_IRQ | PRINTK_CALLER_AVM_RTE) + +#define __avm_caller_char(id) \ + (((id) & PRINTK_CALLER_IRQ) ? 'C' : \ + ((id) & PRINTK_CALLER_AVM_RTE) ? 'F' : \ + 'T') +#define __avm_caller_nr(id) ((id) & ~PRINTK_CALLER_MASK) + #ifdef CONFIG_LOCKDEP static struct lockdep_map console_lock_dep_map = { .name = "console_lock" @@ -221,7 +239,7 @@ * macros instead of functions so that _RET_IP_ contains useful information. */ #define down_console_sem() do { \ - down(&console_sem);\ + __raw_rte_down(&console_sem);\ mutex_acquire(&console_lock_dep_map, 0, 0, _RET_IP_);\ } while (0) @@ -236,12 +254,13 @@ * deadlock in printk()->down_trylock_console_sem() otherwise. */ printk_safe_enter_irqsave(flags); - lock_failed = down_trylock(&console_sem); + lock_failed = __raw_rte_down_trylock(&console_sem); printk_safe_exit_irqrestore(flags); if (lock_failed) return 1; - mutex_acquire(&console_lock_dep_map, 0, 1, ip); + if (!__raw_is_rte_context()) + mutex_acquire(&console_lock_dep_map, 0, 1, ip); return 0; } #define down_trylock_console_sem() __down_trylock_console_sem(_RET_IP_) @@ -250,10 +269,11 @@ { unsigned long flags; - mutex_release(&console_lock_dep_map, 1, ip); + if (!__raw_is_rte_context()) + mutex_release(&console_lock_dep_map, 1, ip); printk_safe_enter_irqsave(flags); - up(&console_sem); + __raw_rte_up(&console_sem); printk_safe_exit_irqrestore(flags); } #define up_console_sem() __up_console_sem(_RET_IP_) @@ -398,24 +418,24 @@ #define logbuf_lock_irq() \ do { \ printk_safe_enter_irq(); \ - raw_spin_lock(&logbuf_lock); \ + __raw_rte_raw_spin_lock(&logbuf_lock); \ } while (0) #define logbuf_unlock_irq() \ do { \ - raw_spin_unlock(&logbuf_lock); \ + __raw_rte_raw_spin_unlock(&logbuf_lock); \ printk_safe_exit_irq(); \ } while (0) #define logbuf_lock_irqsave(flags) \ do { \ printk_safe_enter_irqsave(flags); \ - raw_spin_lock(&logbuf_lock); \ + __raw_rte_raw_spin_lock(&logbuf_lock); \ } while (0) #define logbuf_unlock_irqrestore(flags) \ do { \ - raw_spin_unlock(&logbuf_lock); \ + __raw_rte_raw_spin_unlock(&logbuf_lock); \ printk_safe_exit_irqrestore(flags); \ } while (0) @@ -460,7 +480,8 @@ #define LOG_BUF_LEN_MAX (u32)(1 << 31) static char __log_buf[__LOG_BUF_LEN] __aligned(LOG_ALIGN); static char *log_buf = __log_buf; -static u32 log_buf_len = __LOG_BUF_LEN; +u32 log_buf_len = __LOG_BUF_LEN; +EXPORT_SYMBOL(log_buf_len); /* * We cannot access per-CPU data (e.g. per-CPU flush irq_work) before @@ -662,7 +683,7 @@ if (ts_nsec > 0) msg->ts_nsec = ts_nsec; else - msg->ts_nsec = local_clock(); + msg->ts_nsec = __raw_rte_local_clock(); #ifdef CONFIG_PRINTK_CALLER msg->caller_id = caller_id; #endif @@ -734,7 +755,8 @@ u32 id = msg->caller_id; snprintf(caller, sizeof(caller), ",caller=%c%u", - id & 0x80000000 ? 'C' : 'T', id & ~0x80000000); + __avm_caller_char(id), + __avm_caller_nr(id)); #else caller[0] = '\0'; #endif @@ -1308,7 +1330,8 @@ char caller[12]; snprintf(caller, sizeof(caller), "%c%u", - id & 0x80000000 ? 'C' : 'T', id & ~0x80000000); + __avm_caller_char(id), + __avm_caller_nr(id)); return sprintf(buf, "[%6s]", caller); } #else @@ -1838,8 +1861,14 @@ static inline u32 printk_caller_id(void) { + BUILD_BUG_ON(PID_MAX_LIMIT > ~PRINTK_CALLER_MASK); + + if (is_rte_context()) + return PRINTK_CALLER_AVM_RTE + raw_smp_processor_id(); + + /* In Linux context, use unchanged upstream format */ return in_task() ? task_pid_nr(current) : - 0x80000000 + raw_smp_processor_id(); + PRINTK_CALLER_IRQ + raw_smp_processor_id(); } /* @@ -1881,7 +1910,7 @@ cont.facility = facility; cont.level = level; cont.caller_id = caller_id; - cont.ts_nsec = local_clock(); + cont.ts_nsec = __raw_rte_local_clock(); cont.flags = flags; } @@ -2090,6 +2119,14 @@ } EXPORT_SYMBOL(printk); +#ifdef CONFIG_QCA_MINIDUMP +void minidump_get_log_buf_info(uint64_t *plog_buf, uint64_t *plog_buf_len) +{ + *plog_buf = (uint64_t)(uintptr_t)log_buf; + *plog_buf_len = (uint64_t)__pa(&log_buf_len); +} +#endif /* CONFIG_QCA_MINIDUMP */ + #else /* CONFIG_PRINTK */ #define LOG_LINE_MAX 0 @@ -2451,7 +2488,7 @@ size_t len; printk_safe_enter_irqsave(flags); - raw_spin_lock(&logbuf_lock); + __raw_rte_raw_spin_lock(&logbuf_lock); if (console_seq < log_first_seq) { len = sprintf(text, "** %llu printk messages dropped **\n", @@ -2499,7 +2536,7 @@ } console_idx = log_next(console_idx); console_seq++; - raw_spin_unlock(&logbuf_lock); + __raw_rte_raw_spin_unlock(&logbuf_lock); /* * While actively printing out messages, if another printk() @@ -2509,9 +2546,9 @@ */ console_lock_spinning_enable(); - stop_critical_timings(); /* don't trace print latency */ + __raw_rte_stop_critical_timings(); /* don't trace print latency */ call_console_drivers(ext_text, ext_len, text, len); - start_critical_timings(); + __raw_rte_start_critical_timings(); if (console_lock_spinning_disable_and_check()) { printk_safe_exit_irqrestore(flags); @@ -2526,7 +2563,7 @@ console_locked = 0; - raw_spin_unlock(&logbuf_lock); + __raw_rte_raw_spin_unlock(&logbuf_lock); up_console_sem(); @@ -2536,9 +2573,9 @@ * there's a new owner and the console_unlock() from them will do the * flush, no worries. */ - raw_spin_lock(&logbuf_lock); + __raw_rte_raw_spin_lock(&logbuf_lock); retry = console_seq != log_next_seq; - raw_spin_unlock(&logbuf_lock); + __raw_rte_raw_spin_unlock(&logbuf_lock); printk_safe_exit_irqrestore(flags); if (retry && console_trylock()) @@ -2853,7 +2890,7 @@ int unregister_console(struct console *console) { - struct console *a, *b; + struct console *a, *b; int res; pr_info("%sconsole [%s%d] disabled\n",