mirror of
https://github.com/torvalds/linux.git
synced 2025-04-12 06:49:52 +00:00
s390/time: Convert MACHINE_HAS_SCC to machine_has_scc()
Use static branch(es) to implement and use machine_has_scc() instead of a runtime check via MACHINE_HAS_SCC. This comes with a cleanup of early time initialization: the initial tod_clock_base value is now passed via the bootdata mechanism, instead of using absolute lowcore as transport vehicle from the decompressor to the kernel. Also the early tod clock initialization is moved to the decompressor which allows to use a static branch with machine_has_scc() within the kernel. Reviewed-by: Vasily Gorbik <gor@linux.ibm.com> Signed-off-by: Heiko Carstens <hca@linux.ibm.com> Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
This commit is contained in:
parent
a1a8da0dec
commit
f931f67cfc
@ -254,8 +254,9 @@ SYM_CODE_START_LOCAL(startup_normal)
|
||||
xc 0xf00(256),0xf00
|
||||
larl %r13,.Lctl
|
||||
lctlg %c0,%c15,0(%r13) # load control registers
|
||||
stcke __LC_BOOT_CLOCK
|
||||
mvc __LC_LAST_UPDATE_CLOCK(8),__LC_BOOT_CLOCK+1
|
||||
larl %r13,tod_clock_base
|
||||
stcke 0(%r13)
|
||||
mvc __LC_LAST_UPDATE_CLOCK(8),1(%r13)
|
||||
larl %r13,6f
|
||||
spt 0(%r13)
|
||||
mvc __LC_LAST_UPDATE_TIMER(8),0(%r13)
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <asm/sections.h>
|
||||
#include <asm/lowcore.h>
|
||||
#include <asm/setup.h>
|
||||
#include <asm/timex.h>
|
||||
#include <asm/sclp.h>
|
||||
#include <asm/uv.h>
|
||||
#include "boot.h"
|
||||
@ -199,8 +200,7 @@ static void boot_console_earlyprintk(const char *buf)
|
||||
static char *add_timestamp(char *buf)
|
||||
{
|
||||
#ifdef CONFIG_PRINTK_TIME
|
||||
union tod_clock *boot_clock = (union tod_clock *)&get_lowcore()->boot_clock;
|
||||
unsigned long ns = tod_to_ns(get_tod_clock() - boot_clock->tod);
|
||||
unsigned long ns = tod_to_ns(__get_tod_clock_monotonic());
|
||||
char ts[MAX_NUMLEN];
|
||||
|
||||
*buf++ = '[';
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <asm/machine.h>
|
||||
#include <asm/cpu_mf.h>
|
||||
#include <asm/setup.h>
|
||||
#include <asm/timex.h>
|
||||
#include <asm/kasan.h>
|
||||
#include <asm/kexec.h>
|
||||
#include <asm/sclp.h>
|
||||
@ -35,6 +36,8 @@ unsigned long __bootdata_preserved(max_mappable);
|
||||
unsigned long __bootdata_preserved(page_noexec_mask);
|
||||
unsigned long __bootdata_preserved(segment_noexec_mask);
|
||||
unsigned long __bootdata_preserved(region_noexec_mask);
|
||||
union tod_clock __bootdata_preserved(tod_clock_base);
|
||||
u64 __bootdata_preserved(clock_comparator_max) = -1UL;
|
||||
|
||||
u64 __bootdata_preserved(stfle_fac_list[16]);
|
||||
struct oldmem_data __bootdata_preserved(oldmem_data);
|
||||
@ -46,6 +49,20 @@ void error(char *x)
|
||||
disabled_wait();
|
||||
}
|
||||
|
||||
static void reset_tod_clock(void)
|
||||
{
|
||||
union tod_clock clk;
|
||||
|
||||
if (store_tod_clock_ext_cc(&clk) == 0)
|
||||
return;
|
||||
/* TOD clock not running. Set the clock to Unix Epoch. */
|
||||
if (set_tod_clock(TOD_UNIX_EPOCH) || store_tod_clock_ext_cc(&clk))
|
||||
disabled_wait();
|
||||
memset(&tod_clock_base, 0, sizeof(tod_clock_base));
|
||||
tod_clock_base.tod = TOD_UNIX_EPOCH;
|
||||
get_lowcore()->last_update_clock = TOD_UNIX_EPOCH;
|
||||
}
|
||||
|
||||
static void detect_facilities(void)
|
||||
{
|
||||
if (cpu_has_edat1())
|
||||
@ -60,6 +77,13 @@ static void detect_facilities(void)
|
||||
}
|
||||
if (IS_ENABLED(CONFIG_PCI) && test_facility(153))
|
||||
set_machine_feature(MFEATURE_PCI_MIO);
|
||||
reset_tod_clock();
|
||||
if (test_facility(139) && (tod_clock_base.tod >> 63)) {
|
||||
/* Enable signed clock comparator comparisons */
|
||||
set_machine_feature(MFEATURE_SCC);
|
||||
clock_comparator_max = -1UL >> 1;
|
||||
local_ctl_set_bit(0, CR0_CLOCK_COMPARATOR_SIGN_BIT);
|
||||
}
|
||||
}
|
||||
|
||||
static int cmma_test_essa(void)
|
||||
|
@ -127,7 +127,7 @@ struct lowcore {
|
||||
__u64 int_clock; /* 0x0318 */
|
||||
__u8 pad_0x0320[0x0328-0x0320]; /* 0x0320 */
|
||||
__u64 clock_comparator; /* 0x0328 */
|
||||
__u64 boot_clock[2]; /* 0x0330 */
|
||||
__u8 pad_0x0330[0x0340-0x0330]; /* 0x0330 */
|
||||
|
||||
/* Current process. */
|
||||
__u64 current_task; /* 0x0340 */
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
#define MFEATURE_LOWCORE 0
|
||||
#define MFEATURE_PCI_MIO 1
|
||||
#define MFEATURE_SCC 2
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
@ -78,6 +79,7 @@ static __always_inline bool machine_has_##name(void) \
|
||||
}
|
||||
|
||||
DEFINE_MACHINE_HAS_FEATURE(relocated_lowcore, MFEATURE_LOWCORE)
|
||||
DEFINE_MACHINE_HAS_FEATURE(scc, MFEATURE_SCC)
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* __ASM_S390_MACHINE_H */
|
||||
|
@ -24,7 +24,6 @@
|
||||
#define MACHINE_FLAG_ESOP BIT(4)
|
||||
#define MACHINE_FLAG_TE BIT(11)
|
||||
#define MACHINE_FLAG_TLB_GUEST BIT(14)
|
||||
#define MACHINE_FLAG_SCC BIT(17)
|
||||
|
||||
#define LPP_MAGIC BIT(31)
|
||||
#define LPP_PID_MASK _AC(0xffffffff, UL)
|
||||
@ -76,7 +75,6 @@ extern unsigned long mio_wb_bit_mask;
|
||||
#define MACHINE_HAS_ESOP (get_lowcore()->machine_flags & MACHINE_FLAG_ESOP)
|
||||
#define MACHINE_HAS_TE (get_lowcore()->machine_flags & MACHINE_FLAG_TE)
|
||||
#define MACHINE_HAS_TLB_GUEST (get_lowcore()->machine_flags & MACHINE_FLAG_TLB_GUEST)
|
||||
#define MACHINE_HAS_SCC (get_lowcore()->machine_flags & MACHINE_FLAG_SCC)
|
||||
|
||||
/*
|
||||
* Console mode. Override with conmode=
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include <linux/preempt.h>
|
||||
#include <linux/time64.h>
|
||||
#include <asm/lowcore.h>
|
||||
#include <asm/machine.h>
|
||||
#include <asm/asm.h>
|
||||
|
||||
/* The value of the TOD clock for 1.1.1970. */
|
||||
@ -267,7 +268,7 @@ static __always_inline u128 eitod_to_ns(u128 todval)
|
||||
*/
|
||||
static inline int tod_after(unsigned long a, unsigned long b)
|
||||
{
|
||||
if (MACHINE_HAS_SCC)
|
||||
if (machine_has_scc())
|
||||
return (long) a > (long) b;
|
||||
return a > b;
|
||||
}
|
||||
@ -281,7 +282,7 @@ static inline int tod_after(unsigned long a, unsigned long b)
|
||||
*/
|
||||
static inline int tod_after_eq(unsigned long a, unsigned long b)
|
||||
{
|
||||
if (MACHINE_HAS_SCC)
|
||||
if (machine_has_scc())
|
||||
return (long) a >= (long) b;
|
||||
return a >= b;
|
||||
}
|
||||
|
@ -122,7 +122,6 @@ int main(void)
|
||||
OFFSET(__LC_LAST_UPDATE_TIMER, lowcore, last_update_timer);
|
||||
OFFSET(__LC_LAST_UPDATE_CLOCK, lowcore, last_update_clock);
|
||||
OFFSET(__LC_INT_CLOCK, lowcore, int_clock);
|
||||
OFFSET(__LC_BOOT_CLOCK, lowcore, boot_clock);
|
||||
OFFSET(__LC_CURRENT, lowcore, current_task);
|
||||
OFFSET(__LC_KERNEL_STACK, lowcore, kernel_stack);
|
||||
OFFSET(__LC_ASYNC_STACK, lowcore, async_stack);
|
||||
|
@ -64,21 +64,6 @@ static void __init kasan_early_init(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
static void __init reset_tod_clock(void)
|
||||
{
|
||||
union tod_clock clk;
|
||||
|
||||
if (store_tod_clock_ext_cc(&clk) == 0)
|
||||
return;
|
||||
/* TOD clock not running. Set the clock to Unix Epoch. */
|
||||
if (set_tod_clock(TOD_UNIX_EPOCH) || store_tod_clock_ext_cc(&clk))
|
||||
disabled_wait();
|
||||
|
||||
memset(&tod_clock_base, 0, sizeof(tod_clock_base));
|
||||
tod_clock_base.tod = TOD_UNIX_EPOCH;
|
||||
get_lowcore()->last_update_clock = TOD_UNIX_EPOCH;
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize storage key for kernel pages
|
||||
*/
|
||||
@ -243,12 +228,6 @@ static __init void detect_machine_facilities(void)
|
||||
}
|
||||
if (test_facility(129))
|
||||
system_ctl_set_bit(0, CR0_VECTOR_BIT);
|
||||
if (test_facility(139) && (tod_clock_base.tod >> 63)) {
|
||||
/* Enabled signed clock comparator comparisons */
|
||||
get_lowcore()->machine_flags |= MACHINE_FLAG_SCC;
|
||||
clock_comparator_max = -1ULL >> 1;
|
||||
system_ctl_set_bit(0, CR0_CLOCK_COMPARATOR_SIGN_BIT);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void save_vector_registers(void)
|
||||
@ -286,7 +265,6 @@ static void __init sort_amode31_extable(void)
|
||||
void __init startup_init(void)
|
||||
{
|
||||
kasan_early_init();
|
||||
reset_tod_clock();
|
||||
time_early_init();
|
||||
init_kernel_storage_key();
|
||||
lockdep_off();
|
||||
|
@ -18,12 +18,10 @@
|
||||
|
||||
__HEAD
|
||||
SYM_CODE_START(startup_continue)
|
||||
larl %r1,tod_clock_base
|
||||
GET_LC %r2
|
||||
mvc 0(16,%r1),__LC_BOOT_CLOCK(%r2)
|
||||
#
|
||||
# Setup stack
|
||||
#
|
||||
GET_LC %r2
|
||||
larl %r14,init_task
|
||||
stg %r14,__LC_CURRENT(%r2)
|
||||
larl %r15,init_thread_union+STACK_INIT_OFFSET
|
||||
|
@ -54,10 +54,10 @@
|
||||
#include <asm/cio.h>
|
||||
#include "entry.h"
|
||||
|
||||
union tod_clock tod_clock_base __section(".data");
|
||||
union tod_clock __bootdata_preserved(tod_clock_base);
|
||||
EXPORT_SYMBOL_GPL(tod_clock_base);
|
||||
|
||||
u64 clock_comparator_max = -1ULL;
|
||||
u64 __bootdata_preserved(clock_comparator_max);
|
||||
EXPORT_SYMBOL_GPL(clock_comparator_max);
|
||||
|
||||
static DEFINE_PER_CPU(struct clock_event_device, comparators);
|
||||
|
Loading…
x
Reference in New Issue
Block a user