Skip to contentSkip to conversation

clockevents for 4.11

GIT PULL New Daniel Lezcano 1 participant 11 messages Feb 8, 2017

Subsystems (10)
lore
Share & tools
lore
#0 lore raw

Hi Thomas,

these are the changes for 4.11:

- Add the new timer renesas ostm (Chris Brandt)

- Add a clkevt-of macro like the clksrc-of (Daniel Lezcano)

- Use the 32 bits tcb as the sched_clock (David Engraf)

- Handle errata for the arm architected timer (Ding Tianhong)

- Move Cortina Gemini to the drivers directory (Linus Walleij)

Thanks !

-- Daniel

The following changes since commit 668802c25729a8e3423015c33c05f1c3be3858e9:

tick/broadcast: Reduce lock cacheline contention (2017-02-04 08:54:46 +0100)

are available in the git repository at:

https://git.linaro.org/people/daniel.lezcano/linux.git clockevents/4.11

for you to fetch changes up to bb42ca47401010fc02901b5e8f79e40a26f208cb:

clocksource/drivers/arm_arch_timer: Work around Hisilicon erratum 161010101 (2017-02-08 00:14:04 +0100)

----------------------------------------------------------------
Chris Brandt (2):
clocksource/drivers/ostm: Document renesas-ostm timer DT bindings clocksource/drivers/ostm: Add renesas-ostm timer driver

Daniel Lezcano (1):
clockevents: Add a clkevt-of mechanism like clksrc-of

David Engraf (1):
clocksource/drivers/tcb_clksrc: Use 32 bit tcb as sched_clock

Ding Tianhong (4):
clocksource/drivers/arm_arch_timer: Add dt binding for hisilicon-161010101 erratum clocksource/drivers/arm_arch_timer: Remove fsl-a008585 parameter clocksource/drivers/arm_arch_timer: Introduce generic errata handling infrastructure clocksource/drivers/arm_arch_timer: Work around Hisilicon erratum 161010101

Linus Walleij (2):
clocksource: add DT bindings for Cortina Gemini clocksource/drivers/gemini: Add driver for the Cortina Gemini

 Documentation/admin-guide/kernel-parameters.txt    |   9 -
 .../devicetree/bindings/arm/arch_timer.txt         |   6 +
 .../bindings/timer/cortina,gemini-timer.txt        |  22 ++
 .../devicetree/bindings/timer/renesas,ostm.txt     |  30 +++
 arch/arm/mach-shmobile/Kconfig                     |   1 +
 arch/arm64/include/asm/arch_timer.h                |  38 +--
 drivers/clocksource/Kconfig                        |  38 +++
 drivers/clocksource/Makefile                       |   3 +
 drivers/clocksource/arm_arch_timer.c               | 151 ++++++++---
 drivers/clocksource/clkevt-probe.c                 |  56 +++++
 drivers/clocksource/renesas-ostm.c                 | 265 ++++++++++++++++++++
 drivers/clocksource/tcb_clksrc.c                   |  16 +-
 drivers/clocksource/timer-gemini.c                 | 277 +++++++++++++++++++++
 include/linux/clockchips.h                         |   9 +
 14 files changed, 845 insertions(+), 76 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/timer/cortina,gemini-timer.txt
 create mode 100644 Documentation/devicetree/bindings/timer/renesas,ostm.txt
 create mode 100644 drivers/clocksource/clkevt-probe.c
 create mode 100644 drivers/clocksource/renesas-ostm.c
 create mode 100644 drivers/clocksource/timer-gemini.c
Signature · 5 lines
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
#1 lore raw

PATCH 1/10 clockevents: Add a clkevt-of mechanism like clksrc-of

The current code uses the CLOCKSOURCE_OF_DECLARE macro to fill the clksrc table with a t-uple (name, init_function).

Unfortunately it ends up to the clockevent and the clocksource being both initialized with this macro. It is not a problem by itself but there is not a clear distinction between a clockevent and a clocksource in the code initialization path. Somebody can argue there are the same IP block and the same DT node. But conceptually from the software side, there are two distincts entities and as is they should be initialized separetely. Some drivers which do not have a clocksource end up by using the CLOCKSOURCE_OF_DECLARE macro to declare a clockevent.

Another result is the fuzzy organization in the clocksource directory, where the clockevents are implemented in the same file than the clocksources or file labelled timer-something implementing a clocksource.

This patch provides another macro to specifically declare a clockevent in the same way than the clocksource and gives the opportunity to write two separate drivers, one for the clocksource and another for the clockevents.

Hopefully, that can help to do some housework in the directory, perhaps split the drivers in to entities, for example:
- clksrc-rockchip.c
- clkevt-rockchip.c

Also, it gives the possibility to declare clocksources separately in the DT and then use a clocksource from IP block while while clockevents are used from another IP block.

---
 drivers/clocksource/Kconfig        |  7 +++++
 drivers/clocksource/Makefile       |  1 +
 drivers/clocksource/clkevt-probe.c | 56 ++++++++++++++++++++++++++++++++++++++
 include/linux/clockchips.h         |  9 ++++++
 4 files changed, 73 insertions(+)
 create mode 100644 drivers/clocksource/clkevt-probe.c
drivers/clocksource/Kconfig +7 -0
index 4866f7a..3dc06f0 100644
@@ -5,6 +5,10 @@ config CLKSRC_OF
 	bool
 	select CLKSRC_PROBE
 
+config CLKEVT_OF
+	bool
+	select CLKEVT_PROBE
+
 config CLKSRC_ACPI
 	bool
 	select CLKSRC_PROBE
@@ -12,6 +16,9 @@ config CLKSRC_ACPI
 config CLKSRC_PROBE
 	bool
 
+config CLKEVT_PROBE
+	bool
+
 config CLKSRC_I8253
 	bool
 
drivers/clocksource/Makefile +1 -0
index a14111e..4b7e9a2 100644
@@ -1,4 +1,5 @@
 obj-$(CONFIG_CLKSRC_PROBE)	+= clksrc-probe.o
+obj-$(CONFIG_CLKEVT_PROBE)	+= clkevt-probe.o
 obj-$(CONFIG_ATMEL_PIT)		+= timer-atmel-pit.o
 obj-$(CONFIG_ATMEL_ST)		+= timer-atmel-st.o
 obj-$(CONFIG_ATMEL_TCB_CLKSRC)	+= tcb_clksrc.o
drivers/clocksource/clkevt-probe.c new file +56 -0

56 lines not on this page · raw message

include/linux/clockchips.h +9 -0
index 0d442e3..5d3053c 100644
@@ -224,4 +224,13 @@ static inline void tick_setup_hrtimer_broadcast(void) { }
 
 #endif /* !CONFIG_GENERIC_CLOCKEVENTS */
 
+#define CLOCKEVENT_OF_DECLARE(name, compat, fn) \
+	OF_DECLARE_1_RET(clkevt, name, compat, fn)
+
+#ifdef CONFIG_CLKEVT_PROBE
+extern int clockevent_probe(void);
+#els
+static inline int clockevent_probe(void) { return 0; }
+#endif
+
 #endif /* _LINUX_CLOCKCHIPS_H */
Signature · 1 line
2.7.4
#2 lore raw

PATCH 2/10 clocksource: add DT bindings for Cortina Gemini

From: Linus Walleij <[email protected]>

This adds device tree bindings for the Cortina Systems Gemini timer block used in these SoCs.

Cc Janos Laube <[email protected]>
Cc Paulius Zaleckas <[email protected]>
Cc Hans Ulli Kroll <ulli.kroll-gM/[email protected]>
Cc Florian Fainelli <[email protected]>
---
 .../bindings/timer/cortina,gemini-timer.txt        | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/timer/cortina,gemini-timer.txt
Documentation/devicetree/bindings/timer/cortina,gemini-timer.txt new file +22 -0
new file mode 100644
index 0000000..16ea1d3
@@ -0,0 +1,22 @@
+Cortina Systems Gemini timer
+
+This timer is embedded in the Cortina Systems Gemini SoCs.
+
+Required properties:
+
+- compatible : Must be "cortina,gemini-timer"
+- reg : Should contain registers location and length
+- interrupts : Should contain the three timer interrupts with
+  flags for rising edge
+- syscon : a phandle to the global Gemini system controller
+
+Example:
+
+timer@43000000 {
+	compatible = "cortina,gemini-timer";
+	reg = <0x43000000 0x1000>;
+	interrupts = <14 IRQ_TYPE_EDGE_RISING>, /* Timer 1 */
+		   <15 IRQ_TYPE_EDGE_RISING>, /* Timer 2 */
+		   <16 IRQ_TYPE_EDGE_RISING>; /* Timer 3 */
+	syscon = <&syscon>;
+};
Signature · 6 lines
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#3 lore raw

PATCH 3/10 clocksource/drivers/gemini: Add driver for the Cortina Gemini

In reply to Daniel Lezcano

From: Linus Walleij <[email protected]>

This is a rewrite of the Gemini timer
driver in arch/arm/mach-gemini/timer.c trying to do everything the device tree way:

- Make every IO-access relative to a base address and dynamic so we can do a dynamic ioremap and get going.
- Do not poke around directly in the global syscon registers, access them using the syscon regmap style design pattern for the one register we need to check.
- Find register range and interrupt from the device tree.

Cc Janos Laube <[email protected]>
Cc Paulius Zaleckas <[email protected]>
Cc Hans Ulli Kroll <[email protected]>
Cc Florian Fainelli <[email protected]>
---
 drivers/clocksource/Kconfig        |  10 ++
 drivers/clocksource/Makefile       |   1 +
 drivers/clocksource/timer-gemini.c | 277 +++++++++++++++++++++++++++++++++++++
 3 files changed, 288 insertions(+)
 create mode 100644 drivers/clocksource/timer-gemini.c
drivers/clocksource/Kconfig +10 -0
index 3dc06f0..afef0e8 100644
@@ -67,6 +67,16 @@ config DW_APB_TIMER_OF
 	select DW_APB_TIMER
 	select CLKSRC_OF
 
+config GEMINI_TIMER
+	bool "Cortina Gemini timer driver" if COMPILE_TEST
+	depends on GENERIC_CLOCKEVENTS
+	depends on HAS_IOMEM
+	select CLKSRC_MMIO
+	select CLKSRC_OF
+	select MFD_SYSCON
+	help
+	  Enables support for the Gemini timer
+
 config ROCKCHIP_TIMER
 	bool "Rockchip timer driver" if COMPILE_TEST
 	depends on ARM || ARM64
drivers/clocksource/Makefile +1 -0
index 4b7e9a2..dbbee80 100644
@@ -16,6 +16,7 @@ obj-$(CONFIG_CLKSRC_MMIO)	+= mmio.o
 obj-$(CONFIG_DIGICOLOR_TIMER)	+= timer-digicolor.o
 obj-$(CONFIG_DW_APB_TIMER)	+= dw_apb_timer.o
 obj-$(CONFIG_DW_APB_TIMER_OF)	+= dw_apb_timer_of.o
+obj-$(CONFIG_GEMINI_TIMER)	+= timer-gemini.o
 obj-$(CONFIG_ROCKCHIP_TIMER)      += rockchip_timer.o
 obj-$(CONFIG_CLKSRC_NOMADIK_MTU)	+= nomadik-mtu.o
 obj-$(CONFIG_CLKSRC_DBX500_PRCMU)	+= clksrc-dbx500-prcmu.o
drivers/clocksource/timer-gemini.c new file +277 -0

277 lines not on this page · raw message

Signature · 1 line
2.7.4
#4 lore raw

PATCH 4/10 clocksource/drivers/tcb_clksrc: Use 32 bit tcb as sched_clock

In reply to Daniel Lezcano

From: David Engraf <[email protected]>

On newer boards the TC can be read as single 32 bit value without locking. Thus the clock can be used as reference for sched_clock which is much more accurate than the jiffies implementation.

Tested on a Atmel SAMA5D2 board.

---
 drivers/clocksource/tcb_clksrc.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)
drivers/clocksource/tcb_clksrc.c +15 -1
index d4ca996..745844e 100644
@@ -10,6 +10,7 @@
 #include <linux/io.h>
 #include <linux/platform_device.h>
 #include <linux/atmel_tc.h>
+#include <linux/sched_clock.h>
 
 
 /*
@@ -56,11 +57,16 @@ static u64 tc_get_cycles(struct clocksource *cs)
 	return (upper << 16) | lower;
 }
 
-static u64 tc_get_cycles32(struct clocksource *cs)
+static u32 tc_get_cv32(void)
 {
 	return __raw_readl(tcaddr + ATMEL_TC_REG(0, CV));
 }
 
+static u64 tc_get_cycles32(struct clocksource *cs)
+{
+	return tc_get_cv32();
+}
+
 static struct clocksource clksrc = {
 	.name           = "tcb_clksrc",
 	.rating         = 200,
@@ -69,6 +75,11 @@ static struct clocksource clksrc = {
 	.flags		= CLOCK_SOURCE_IS_CONTINUOUS,
 };
 
+static u64 notrace tc_read_sched_clock(void)
+{
+	return tc_get_cv32();
+}
+
 #ifdef CONFIG_GENERIC_CLOCKEVENTS
 
 struct tc_clkevt_device {
@@ -339,6 +350,9 @@ static int __init tcb_clksrc_init(void)
 		clksrc.read = tc_get_cycles32;
 		/* setup ony channel 0 */
 		tcb_setup_single_chan(tc, best_divisor_idx);
+
+		/* register sched_clock on chips with single 32 bit counter */
+		sched_clock_register(tc_read_sched_clock, 32, divided_rate);
 	} else {
 		/* tclib will give us three clocks no matter what the
 		 * underlying platform supports.
Signature · 1 line
2.7.4
#5 lore raw

PATCH 5/10 clocksource/drivers/ostm: Document renesas-ostm timer DT bindings

In reply to Daniel Lezcano

From: Chris Brandt <[email protected]>

---
 .../devicetree/bindings/timer/renesas,ostm.txt     | 30 ++++++++++++++++++++++
 1 file changed, 30 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/timer/renesas,ostm.txt
Documentation/devicetree/bindings/timer/renesas,ostm.txt new file +30 -0
new file mode 100644
index 0000000..be3ae0f
@@ -0,0 +1,30 @@
+* Renesas OS Timer (OSTM)
+
+The OSTM is a multi-channel 32-bit timer/counter with fixed clock
+source that can operate in either interval count down timer or free-running
+compare match mode.
+
+Channels are independent from each other.
+
+Required Properties:
+
+  - compatible: must be one or more of the following:
+    - "renesas,r7s72100-ostm" for the r7s72100 OSTM
+    - "renesas,ostm" for any OSTM
+		This is a fallback for the above renesas,*-ostm entries
+
+  - reg: base address and length of the register block for a timer channel.
+
+  - interrupts: interrupt specifier for the timer channel.
+
+  - clocks: clock specifier for the timer channel.
+
+Example: R7S72100 (RZ/A1H) OSTM node
+
+	ostm0: timer@fcfec000 {
+		compatible = "renesas,r7s72100-ostm", "renesas,ostm";
+		reg = <0xfcfec000 0x30>;
+		interrupts = <GIC_SPI 102 IRQ_TYPE_EDGE_RISING>;
+		clocks = <&mstp5_clks R7S72100_CLK_OSTM0>;
+		power-domains = <&cpg_clocks>;
+	};
Signature · 1 line
2.7.4
#6 lore raw

PATCH 6/10 clocksource/drivers/ostm: Add renesas-ostm timer driver

In reply to Daniel Lezcano

From: Chris Brandt <[email protected]>

This patch adds a OSTM driver for the Renesas architecture. The OS Timer (OSTM) has independent channels that can be used as a freerun or interval times.
This driver uses the first probed device as a clocksource and then any additional devices as clock events.

---
 arch/arm/mach-shmobile/Kconfig     |   1 +
 drivers/clocksource/Kconfig        |   7 +
 drivers/clocksource/Makefile       |   1 +
 drivers/clocksource/renesas-ostm.c | 265 +++++++++++++++++++++++++++++++++++++
 4 files changed, 274 insertions(+)
 create mode 100644 drivers/clocksource/renesas-ostm.c
arch/arm/mach-shmobile/Kconfig +1 -0
index 2bb4b09..ad7d604 100644
@@ -57,6 +57,7 @@ config ARCH_R7S72100
 	select PM
 	select PM_GENERIC_DOMAINS
 	select SYS_SUPPORTS_SH_MTU2
+	select RENESAS_OSTM
 
 config ARCH_R8A73A4
 	bool "R-Mobile APE6 (R8A73A40)"
drivers/clocksource/Kconfig +7 -0
index afef0e8..4002d6d 100644
@@ -484,6 +484,13 @@ config SH_TIMER_MTU2
 	  Timer Pulse Unit 2 (MTU2) hardware available on SoCs from Renesas.
 	  This hardware comes with 16 bit-timer registers.
 
+config RENESAS_OSTM
+	bool "Renesas OSTM timer driver" if COMPILE_TEST
+	depends on GENERIC_CLOCKEVENTS
+	select CLKSRC_MMIO
+	help
+	  Enables the support for the Renesas OSTM.
+
 config SH_TIMER_TMU
 	bool "Renesas TMU timer driver" if COMPILE_TEST
 	depends on GENERIC_CLOCKEVENTS
drivers/clocksource/Makefile +1 -0
index dbbee80..d227d13 100644
@@ -9,6 +9,7 @@ obj-$(CONFIG_CS5535_CLOCK_EVENT_SRC)	+= cs5535-clockevt.o
 obj-$(CONFIG_CLKSRC_JCORE_PIT)		+= jcore-pit.o
 obj-$(CONFIG_SH_TIMER_CMT)	+= sh_cmt.o
 obj-$(CONFIG_SH_TIMER_MTU2)	+= sh_mtu2.o
+obj-$(CONFIG_RENESAS_OSTM)	+= renesas-ostm.o
 obj-$(CONFIG_SH_TIMER_TMU)	+= sh_tmu.o
 obj-$(CONFIG_EM_TIMER_STI)	+= em_sti.o
 obj-$(CONFIG_CLKBLD_I8253)	+= i8253.o
drivers/clocksource/renesas-ostm.c new file +265 -0

265 lines not on this page · raw message

Signature · 1 line
2.7.4
#7 lore raw

PATCH 7/10 clocksource/drivers/arm_arch_timer: Add dt binding for hisilicon-161010101 erratum

In reply to Daniel Lezcano

From: Ding Tianhong <[email protected]>

This erratum describes a bug in logic outside the core, so MIDR can't be used to identify its presence, and reading an SoC-specific revision register from common arch timer code would be awkward. So, describe it in the device tree.

---
 Documentation/devicetree/bindings/arm/arch_timer.txt | 6 ++++++
 1 file changed, 6 insertions(+)
Documentation/devicetree/bindings/arm/arch_timer.txt +6 -0
index ad440a2..e926aea 100644
@@ -31,6 +31,12 @@ to deliver its interrupts via SPIs.
   This also affects writes to the tval register, due to the implicit
   counter read.
 
+- hisilicon,erratum-161010101 : A boolean property. Indicates the
+  presence of Hisilicon erratum 161010101, which says that reading the
+  counters is unreliable in some cases, and reads may return a value 32
+  beyond the correct value. This also affects writes to the tval
+  registers, due to the implicit counter read.
+
 ** Optional properties:
 
 - arm,cpu-registers-not-fw-configured : Firmware does not initialize
Signature · 1 line
2.7.4
#8 lore raw

PATCH 8/10 clocksource/drivers/arm_arch_timer: Remove fsl-a008585 parameter

In reply to Daniel Lezcano

From: Ding Tianhong <[email protected]>

Having a command line option to flip the errata handling for a particular erratum is a little bit unusual, and it's vastly superior to pass this in the DT. By common consensus, it's best to kill off the command line parameter.

[Mark: split patch, reword commit message]
---
 Documentation/admin-guide/kernel-parameters.txt |  9 ---------
 drivers/clocksource/arm_arch_timer.c            | 14 --------------
 2 files changed, 23 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +0 -9
index be7c0d9..d8fc55a 100644
@@ -549,15 +549,6 @@
 			loops can be debugged more effectively on production
 			systems.
 
-	clocksource.arm_arch_timer.fsl-a008585=
-			[ARM64]
-			Format: <bool>
-			Enable/disable the workaround of Freescale/NXP
-			erratum A-008585.  This can be useful for KVM
-			guests, if the guest device tree doesn't show the
-			erratum.  If unspecified, the workaround is
-			enabled based on the device tree.
-
 	clearcpuid=BITNUM [X86]
 			Disable CPUID feature X for the kernel. See
 			arch/x86/include/asm/cpufeatures.h for the valid bit
drivers/clocksource/arm_arch_timer.c +0 -14
index 4c8c3fb..6a9d031 100644
@@ -101,20 +101,6 @@ EXPORT_SYMBOL_GPL(arch_timer_read_ool_enabled);
 
 static int fsl_a008585_enable = -1;
 
-static int __init early_fsl_a008585_cfg(char *buf)
-{
-	int ret;
-	bool val;
-
-	ret = strtobool(buf, &val);
-	if (ret)
-		return ret;
-
-	fsl_a008585_enable = val;
-	return 0;
-}
-early_param("clocksource.arm_arch_timer.fsl-a008585", early_fsl_a008585_cfg);
-
 u32 __fsl_a008585_read_cntp_tval_el0(void)
 {
 	return __fsl_a008585_read_reg(cntp_tval_el0);
Signature · 1 line
2.7.4
#9 lore raw

PATCH 9/10 clocksource/drivers/arm_arch_timer: Introduce generic errata handling infrastructure

In reply to Daniel Lezcano

From: Ding Tianhong <[email protected]>

Currently we have code inline in the arch timer probe path to cater for Freescale erratum A-008585, complete with ifdeffery. This is a little ugly, and will get worse as we try to add more errata handling.

This patch refactors the handling of Freescale erratum A-008585. Now the erratum is described in a generic arch_timer_erratum_workaround structure, and the probe path can iterate over these to detect errata and enable workarounds.

This will simplify the addition and maintenance of code handling Hisilicon erratum 161010101.

[Mark: split patch, correct Kconfig, reword commit message]
---
 arch/arm64/include/asm/arch_timer.h  | 38 +++++----------
 drivers/clocksource/Kconfig          |  4 ++
 drivers/clocksource/arm_arch_timer.c | 92 ++++++++++++++++++++++++------------
 3 files changed, 80 insertions(+), 54 deletions(-)
arch/arm64/include/asm/arch_timer.h +13 -25
index eaa5bbe..b4b3400 100644
@@ -29,41 +29,29 @@
 
 #include <clocksource/arm_arch_timer.h>
 
-#if IS_ENABLED(CONFIG_FSL_ERRATUM_A008585)
+#if IS_ENABLED(CONFIG_ARM_ARCH_TIMER_OOL_WORKAROUND)
 extern struct static_key_false arch_timer_read_ool_enabled;
-#define needs_fsl_a008585_workaround() \
+#define needs_unstable_timer_counter_workaround() \
 	static_branch_unlikely(&arch_timer_read_ool_enabled)
 #else
-#define needs_fsl_a008585_workaround()  false
+#define needs_unstable_timer_counter_workaround()  false
 #endif
 
-u32 __fsl_a008585_read_cntp_tval_el0(void);
-u32 __fsl_a008585_read_cntv_tval_el0(void);
-u64 __fsl_a008585_read_cntvct_el0(void);
 
-/*
- * The number of retries is an arbitrary value well beyond the highest number
- * of iterations the loop has been observed to take.
- */
-#define __fsl_a008585_read_reg(reg) ({			\
-	u64 _old, _new;					\
-	int _retries = 200;				\
-							\
-	do {						\
-		_old = read_sysreg(reg);		\
-		_new = read_sysreg(reg);		\
-		_retries--;				\
-	} while (unlikely(_old != _new) && _retries);	\
-							\
-	WARN_ON_ONCE(!_retries);			\
-	_new;						\
-})
+struct arch_timer_erratum_workaround {
+	const char *id;		/* Indicate the Erratum ID */
+	u32 (*read_cntp_tval_el0)(void);
+	u32 (*read_cntv_tval_el0)(void);
+	u64 (*read_cntvct_el0)(void);
+};
+
+extern const struct arch_timer_erratum_workaround *timer_unstable_counter_workaround;
 
 #define arch_timer_reg_read_stable(reg) 		\
 ({							\
 	u64 _val;					\
-	if (needs_fsl_a008585_workaround())		\
-		_val = __fsl_a008585_read_##reg();	\
+	if (needs_unstable_timer_counter_workaround())		\
+		_val = timer_unstable_counter_workaround->read_##reg();\
 	else						\
 		_val = read_sysreg(reg);		\
 	_val;						\
drivers/clocksource/Kconfig +4 -0
index 4002d6d..1945af2 100644
@@ -342,10 +342,14 @@ config ARM_ARCH_TIMER_EVTSTREAM
 	  This must be disabled for hardware validation purposes to detect any
 	  hardware anomalies of missing events.
 
+config ARM_ARCH_TIMER_OOL_WORKAROUND
+	bool
+
 config FSL_ERRATUM_A008585
 	bool "Workaround for Freescale/NXP Erratum A-008585"
 	default y
 	depends on ARM_ARCH_TIMER && ARM64
+	select ARM_ARCH_TIMER_OOL_WORKAROUND
 	help
 	  This option enables a workaround for Freescale/NXP Erratum
 	  A-008585 ("ARM generic timer may contain an erroneous
drivers/clocksource/arm_arch_timer.c +63 -29

160 lines not on this page · raw message

Signature · 1 line
2.7.4
#10 lore raw

PATCH 10/10 clocksource/drivers/arm_arch_timer: Work around Hisilicon erratum 161010101

In reply to Daniel Lezcano

From: Ding Tianhong <[email protected]>

Erratum Hisilicon-161010101 says that the ARM generic timer counter "has the potential to contain an erroneous value when the timer value changes". Accesses to TVAL (both read and write) are also affected due to the implicit counter read. Accesses to CVAL are not affected.

The workaround is to reread the system count registers until the value of the second read is larger than the first one by less than 32, the system counter can be guaranteed not to return wrong value twice by back-to-back read and the error value is always larger than the correct one by 32. Writes to TVAL are replaced with an equivalent write to CVAL.

[Mark: split patch, fix Kconfig, reword commit message]
---
 drivers/clocksource/Kconfig          | 10 ++++++++
 drivers/clocksource/arm_arch_timer.c | 49 ++++++++++++++++++++++++++++++++++++
 2 files changed, 59 insertions(+)
drivers/clocksource/Kconfig +10 -0
index 1945af2..3356ab8 100644
@@ -356,6 +356,16 @@ config FSL_ERRATUM_A008585
 	  value").  The workaround will only be active if the
 	  fsl,erratum-a008585 property is found in the timer node.
 
+config HISILICON_ERRATUM_161010101
+	bool "Workaround for Hisilicon Erratum 161010101"
+	default y
+	select ARM_ARCH_TIMER_OOL_WORKAROUND
+	depends on ARM_ARCH_TIMER && ARM64
+	help
+	  This option enables a workaround for Hisilicon Erratum
+	  161010101. The workaround will be active if the hisilicon,erratum-161010101
+	  property is found in the timer node.
+
 config ARM_GLOBAL_TIMER
 	bool "Support for the ARM global timer" if COMPILE_TEST
 	select CLKSRC_OF if OF
drivers/clocksource/arm_arch_timer.c +49 -0

61 lines not on this page · raw message

Signature · 1 line
2.7.4