printk: Introduce CONFIG_PRINTK_TIME_FROM_ARM_ARCH_TIMER

Some examples for console output:

Starting kernel ...

[    1.956071][    T0] Booting Linux on physical CPU 0x0000000000 [0x412fd050]

Change-Id: I0ab5914349ad3e0028954c831c5e79d46fe2d420
Signed-off-by: Tao Huang <huangtao@rock-chips.com>
This commit is contained in:
Tao Huang 2021-11-12 11:05:18 +08:00
parent f4f5c36bc6
commit 4214832392
2 changed files with 23 additions and 1 deletions

View File

@ -63,6 +63,24 @@
#include "braille.h"
#include "internal.h"
#ifdef CONFIG_PRINTK_TIME_FROM_ARM_ARCH_TIMER
#include <clocksource/arm_arch_timer.h>
static u64 get_local_clock(void)
{
u64 ns;
ns = arch_timer_read_counter() * 1000;
do_div(ns, 24);
return ns;
}
#else
static inline u64 get_local_clock(void)
{
return local_clock();
}
#endif
int console_printk[4] = {
CONSOLE_LOGLEVEL_DEFAULT, /* console_loglevel */
MESSAGE_LOGLEVEL_DEFAULT, /* default_message_loglevel */
@ -528,7 +546,7 @@ static int log_store(u32 caller_id, int facility, int level,
if (ts_nsec > 0)
r.info->ts_nsec = ts_nsec;
else
r.info->ts_nsec = local_clock();
r.info->ts_nsec = get_local_clock();
r.info->caller_id = caller_id;
if (dev_info)
memcpy(&r.info->dev_info, dev_info, sizeof(r.info->dev_info));

View File

@ -18,6 +18,10 @@ config PRINTK_TIME
The behavior is also controlled by the kernel command line
parameter printk.time=1. See Documentation/admin-guide/kernel-parameters.rst
config PRINTK_TIME_FROM_ARM_ARCH_TIMER
bool "Timing from ARM architected timer"
depends on PRINTK_TIME && ARM_ARCH_TIMER && NO_GKI
config PRINTK_CALLER
bool "Show caller information on printks"
depends on PRINTK