Commit 98e720f7 authored by Jiaxun Yang's avatar Jiaxun Yang Committed by Huacai Chen
Browse files

LoongArch: Derive timer max_delta from PRCFG1's timer_bits



As per arch spec, maximum timer bits is configurable and should not be
hardcoded in any way.

Probe timer bits from PRCFG1 and use that to determine the clockevent's
max_delta to be conformance.

Signed-off-by: default avatarJiaxun Yang <jiaxun.yang@flygoat.com>
Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
parent 341cf992
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -57,6 +57,7 @@ struct cpuinfo_loongarch {
	int			global_id; /* physical global thread number */
	int			vabits; /* Virtual Address size in bits */
	int			pabits; /* Physical Address size in bits */
	int			timerbits; /* Width of arch timer in bits */
	unsigned int		ksave_mask; /* Usable KSave mask. */
	unsigned int		watch_dreg_count;   /* Number data breakpoints */
	unsigned int		watch_ireg_count;   /* Number instruction breakpoints */
+0 −1
Original line number Diff line number Diff line
@@ -466,7 +466,6 @@

#define LOONGARCH_CSR_TCFG		0x41	/* Timer config */
#define  CSR_TCFG_VAL_SHIFT		2
#define	 CSR_TCFG_VAL_WIDTH		48
#define  CSR_TCFG_VAL			(_ULCAST_(0x3fffffffffff) << CSR_TCFG_VAL_SHIFT)
#define  CSR_TCFG_PERIOD_SHIFT		1
#define  CSR_TCFG_PERIOD		(_ULCAST_(0x1) << CSR_TCFG_PERIOD_SHIFT)
+1 −0
Original line number Diff line number Diff line
@@ -190,6 +190,7 @@ static void cpu_probe_common(struct cpuinfo_loongarch *c)
	set_cpu_asid_mask(c, asid_mask);

	config = read_csr_prcfg1();
	c->timerbits = (config & CSR_CONF1_TMRBITS) >> CSR_CONF1_TMRBITS_SHIFT;
	c->ksave_mask = GENMASK((config & CSR_CONF1_KSNUM) - 1, 0);
	c->ksave_mask &= ~(EXC_KSAVE_MASK | PERCPU_KSAVE_MASK | KVM_KSAVE_MASK);

+1 −1
Original line number Diff line number Diff line
@@ -132,7 +132,7 @@ int constant_clockevent_init(void)
#else
	unsigned long min_delta = 1000;
#endif
	unsigned long max_delta = (1UL << 48) - 1;
	unsigned long max_delta = GENMASK_ULL(boot_cpu_data.timerbits, 0);
	struct clock_event_device *cd;
	static int irq = 0, timer_irq_installed = 0;