Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc/time: Expose boot_tb via accessor

- Define accessor function get_boot_tb() to safely return boot_tb value,
this is only needed when running in SPLPAR environments, so the
accessor is built conditionally under CONFIG_PPC_SPLPAR.

- Tag boot_tb as __ro_after_init since it is written once at initialized
and never updated afterwards.

Signed-off-by: Aboorva Devarajan <aboorvad@linux.ibm.com>
Tested-by: Tejas Manhas <tejas05@linux.ibm.com>
Tested-by: Venkat Rao Bagalkote <venkat88@linux.ibm.com>
Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Link: https://patch.msgid.link/20250915102947.26681-2-atrajeev@linux.ibm.com

authored by

Aboorva Devarajan and committed by
Madhavan Srinivasan
2dc019ca 9316512b

+11 -1
+4
arch/powerpc/include/asm/time.h
··· 29 29 30 30 extern void generic_calibrate_decr(void); 31 31 32 + #ifdef CONFIG_PPC_SPLPAR 33 + extern u64 get_boot_tb(void); 34 + #endif 35 + 32 36 /* Some sane defaults: 125 MHz timebase, 1GHz processor */ 33 37 extern unsigned long ppc_proc_freq; 34 38 #define DEFAULT_PROC_FREQ (DEFAULT_TB_FREQ * 8)
+7 -1
arch/powerpc/kernel/time.c
··· 137 137 138 138 static u64 tb_to_ns_scale __read_mostly; 139 139 static unsigned tb_to_ns_shift __read_mostly; 140 - static u64 boot_tb __read_mostly; 140 + static u64 boot_tb __ro_after_init; 141 141 142 142 extern struct timezone sys_tz; 143 143 static long timezone_offset; ··· 639 639 return mulhdu(get_tb() - boot_tb, tb_to_ns_scale) << tb_to_ns_shift; 640 640 } 641 641 642 + #ifdef CONFIG_PPC_SPLPAR 643 + u64 get_boot_tb(void) 644 + { 645 + return boot_tb; 646 + } 647 + #endif 642 648 643 649 #ifdef CONFIG_PPC_PSERIES 644 650