]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
powerpc/time: Expose boot_tb via accessor
authorAboorva Devarajan <aboorvad@linux.ibm.com>
Mon, 15 Sep 2025 10:29:41 +0000 (15:59 +0530)
committerMadhavan Srinivasan <maddy@linux.ibm.com>
Mon, 22 Sep 2025 09:18:56 +0000 (14:48 +0530)
- 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
arch/powerpc/include/asm/time.h
arch/powerpc/kernel/time.c

index f8885586efafb395ec189c4b92ca63c00442ca8f..7991ab1d4cb8938f11de2b01aa554dc51086b00e 100644 (file)
@@ -29,6 +29,10 @@ extern u64 decrementer_max;
 
 extern void generic_calibrate_decr(void);
 
+#ifdef CONFIG_PPC_SPLPAR
+extern u64 get_boot_tb(void);
+#endif
+
 /* Some sane defaults: 125 MHz timebase, 1GHz processor */
 extern unsigned long ppc_proc_freq;
 #define DEFAULT_PROC_FREQ      (DEFAULT_TB_FREQ * 8)
index 8224381c1dba344c53d4933771d8de8b45d8bfcd..4bbeb8644d3da44e246f87d116f9780b5a7d1251 100644 (file)
@@ -137,7 +137,7 @@ EXPORT_SYMBOL_GPL(rtc_lock);
 
 static u64 tb_to_ns_scale __read_mostly;
 static unsigned tb_to_ns_shift __read_mostly;
-static u64 boot_tb __read_mostly;
+static u64 boot_tb __ro_after_init;
 
 extern struct timezone sys_tz;
 static long timezone_offset;
@@ -639,6 +639,12 @@ notrace unsigned long long sched_clock(void)
        return mulhdu(get_tb() - boot_tb, tb_to_ns_scale) << tb_to_ns_shift;
 }
 
+#ifdef CONFIG_PPC_SPLPAR
+u64 get_boot_tb(void)
+{
+       return boot_tb;
+}
+#endif
 
 #ifdef CONFIG_PPC_PSERIES