Skip to content

Commit 2dc019c

Browse files
AboorvaDevarajanmaddy-kerneldev
authored andcommitted
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
1 parent 9316512 commit 2dc019c

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

arch/powerpc/include/asm/time.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ extern u64 decrementer_max;
2929

3030
extern void generic_calibrate_decr(void);
3131

32+
#ifdef CONFIG_PPC_SPLPAR
33+
extern u64 get_boot_tb(void);
34+
#endif
35+
3236
/* Some sane defaults: 125 MHz timebase, 1GHz processor */
3337
extern unsigned long ppc_proc_freq;
3438
#define DEFAULT_PROC_FREQ (DEFAULT_TB_FREQ * 8)

arch/powerpc/kernel/time.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ EXPORT_SYMBOL_GPL(rtc_lock);
137137

138138
static u64 tb_to_ns_scale __read_mostly;
139139
static unsigned tb_to_ns_shift __read_mostly;
140-
static u64 boot_tb __read_mostly;
140+
static u64 boot_tb __ro_after_init;
141141

142142
extern struct timezone sys_tz;
143143
static long timezone_offset;
@@ -639,6 +639,12 @@ notrace unsigned long long sched_clock(void)
639639
return mulhdu(get_tb() - boot_tb, tb_to_ns_scale) << tb_to_ns_shift;
640640
}
641641

642+
#ifdef CONFIG_PPC_SPLPAR
643+
u64 get_boot_tb(void)
644+
{
645+
return boot_tb;
646+
}
647+
#endif
642648

643649
#ifdef CONFIG_PPC_PSERIES
644650

0 commit comments

Comments
 (0)