Skip to contentSkip to conversation

clocksource: fttmr010: Detect back-pressure for Aspeed controllers

RFC In review Andrew Jeffery 2 participants 4 messages Jan 11, 2019 – Jan 14, 2019

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

RFC 1/1 clocksource: fttmr010: Detect back-pressure for Aspeed controllers

---

See the cover letter on the corresponding qemu RFC series, to be sent after this patch.

 arch/arm/mach-aspeed/Kconfig         | 1 +
 drivers/clocksource/timer-fttmr010.c | 7 +++++++
 2 files changed, 8 insertions(+)
arch/arm/mach-aspeed/Kconfig +1 -0
index 2d5570e6e186..6b82d5416cf0 100644
@@ -7,6 +7,7 @@ menuconfig ARCH_ASPEED
 	select FTTMR010_TIMER
 	select MFD_SYSCON
 	select PINCTRL
+	select GENERIC_CLOCKEVENTS_MIN_ADJUST
 	help
 	  Say Y here if you want to run your kernel on an ASpeed BMC SoC.
 
drivers/clocksource/timer-fttmr010.c +7 -0
index cf93f6419b51..f15386b98289 100644
@@ -124,6 +124,7 @@ static int fttmr010_timer_set_next_event(unsigned long cycles,
 {
 	struct fttmr010 *fttmr010 = to_fttmr010(evt);
 	u32 cr;
+	u32 l;
 
 	/* Stop */
 	cr = readl(fttmr010->base + TIMER_CR);
@@ -136,6 +137,12 @@ static int fttmr010_timer_set_next_event(unsigned long cycles,
 		 * into TIMER1_COUNT register when the timer is re-enabled.
 		 */
 		writel(cycles, fttmr010->base + TIMER1_LOAD);
+#if CONFIG_GENERIC_CLOCKEVENTS_MIN_ADJUST
+		/* QEMU model may provide back-pressure on requested period */
+		l = readl(fttmr010->base + TIMER1_LOAD);
+		if (l > cycles)
+			return -EINVAL;
+#endif
 	} else {
 		/* Setup the match register forward in time */
 		cr = readl(fttmr010->base + TIMER1_COUNT);
Signature · 1 line
2.19.1
#1 lore raw
Quoted 1 line · Andrew Jeffery

This patch should not have any impact on a real system where l == cycles. It might be difficult to merge though.

C.

Quoted 46 lines

---

See the cover letter on the corresponding qemu RFC series, to be sent after this patch.

 arch/arm/mach-aspeed/Kconfig         | 1 +
 drivers/clocksource/timer-fttmr010.c | 7 +++++++
 2 files changed, 8 insertions(+)
arch/arm/mach-aspeed/Kconfig +1 -0
index 2d5570e6e186..6b82d5416cf0 100644
@@ -7,6 +7,7 @@ menuconfig ARCH_ASPEED
 	select FTTMR010_TIMER
 	select MFD_SYSCON
 	select PINCTRL
+	select GENERIC_CLOCKEVENTS_MIN_ADJUST
 	help
 	  Say Y here if you want to run your kernel on an ASpeed BMC SoC.
 
drivers/clocksource/timer-fttmr010.c +6 -0
index cf93f6419b51..f15386b98289 100644
@@ -124,6 +124,7 @@ static int fttmr010_timer_set_next_event(unsigned long cycles,
 {
 	struct fttmr010 *fttmr010 = to_fttmr010(evt);
 	u32 cr;
+	u32 l;
 
 	/* Stop */
 	cr = readl(fttmr010->base + TIMER_CR);
@@ -136,6 +137,12 @@ static int fttmr010_timer_set_next_event(unsigned long cycles,
 		 * into TIMER1_COUNT register when the timer is re-enabled.
 		 */
 		writel(cycles, fttmr010->base + TIMER1_LOAD);
+#if CONFIG_GENERIC_CLOCKEVENTS_MIN_ADJUST> +		/* QEMU model may provide back-pressure on requested period */
+		l = readl(fttmr010->base + TIMER1_LOAD);
+		if (l > cycles)
+			return -EINVAL;
+#endif
 	} else {
 		/* Setup the match register forward in time */
 		cr = readl(fttmr010->base + TIMER1_COUNT);
#2 lore raw
Quoted 5 lines · Cédric Le Goater
Quoted 1 line · Andrew Jeffery

This patch should not have any impact on a real system where l == cycles. It might be difficult to merge though.

I agree.

Note however that the qemu patches resolve the issue regardless of whether this patch to Linux is applied, just if it's not Linux will not be aware that the timer isn't behaving how Linux requested.

Maybe we live with that?

Andrew

Quoted 50 lines

C.

Quoted 46 lines

---

See the cover letter on the corresponding qemu RFC series, to be sent after this patch.

 arch/arm/mach-aspeed/Kconfig         | 1 +
 drivers/clocksource/timer-fttmr010.c | 7 +++++++
 2 files changed, 8 insertions(+)
arch/arm/mach-aspeed/Kconfig +1 -0
index 2d5570e6e186..6b82d5416cf0 100644
@@ -7,6 +7,7 @@ menuconfig ARCH_ASPEED
 	select FTTMR010_TIMER
 	select MFD_SYSCON
 	select PINCTRL
+	select GENERIC_CLOCKEVENTS_MIN_ADJUST
 	help
 	  Say Y here if you want to run your kernel on an ASpeed BMC SoC.
 
drivers/clocksource/timer-fttmr010.c +6 -0
index cf93f6419b51..f15386b98289 100644
@@ -124,6 +124,7 @@ static int fttmr010_timer_set_next_event(unsigned long cycles,
 {
 	struct fttmr010 *fttmr010 = to_fttmr010(evt);
 	u32 cr;
+	u32 l;
 
 	/* Stop */
 	cr = readl(fttmr010->base + TIMER_CR);
@@ -136,6 +137,12 @@ static int fttmr010_timer_set_next_event(unsigned long cycles,
 		 * into TIMER1_COUNT register when the timer is re-enabled.
 		 */
 		writel(cycles, fttmr010->base + TIMER1_LOAD);
+#if CONFIG_GENERIC_CLOCKEVENTS_MIN_ADJUST> +		/* QEMU model may provide back-pressure on requested period */
+		l = readl(fttmr010->base + TIMER1_LOAD);
+		if (l > cycles)
+			return -EINVAL;
+#endif
 	} else {
 		/* Setup the match register forward in time */
 		cr = readl(fttmr010->base + TIMER1_COUNT);
#3 lore raw
Quoted 4 lines · Andrew Jeffery
Quoted 3 lines · Cédric Le Goater
Quoted 1 line · Andrew Jeffery
Quoted 8 lines
Quoted 2 lines

This patch should not have any impact on a real system where l == cycles. It might be difficult to merge though.

I agree.

Note however that the qemu patches resolve the issue regardless of whether this patch to Linux is applied, just if it's not Linux will not be aware that the timer isn't behaving how Linux requested.

Indeed. I checked on a ppc64el.

Quoted 1 line

Maybe we live with that?

yes ! Could please send your QEMU patchset ?

Thanks,

C.

Quoted 52 lines

Andrew

Quoted 50 lines

C.

Quoted 46 lines

---

See the cover letter on the corresponding qemu RFC series, to be sent after this patch.

 arch/arm/mach-aspeed/Kconfig         | 1 +
 drivers/clocksource/timer-fttmr010.c | 7 +++++++
 2 files changed, 8 insertions(+)
arch/arm/mach-aspeed/Kconfig +1 -0
index 2d5570e6e186..6b82d5416cf0 100644
@@ -7,6 +7,7 @@ menuconfig ARCH_ASPEED
 	select FTTMR010_TIMER
 	select MFD_SYSCON
 	select PINCTRL
+	select GENERIC_CLOCKEVENTS_MIN_ADJUST
 	help
 	  Say Y here if you want to run your kernel on an ASpeed BMC SoC.
 
drivers/clocksource/timer-fttmr010.c +6 -0
index cf93f6419b51..f15386b98289 100644
@@ -124,6 +124,7 @@ static int fttmr010_timer_set_next_event(unsigned long cycles,
 {
 	struct fttmr010 *fttmr010 = to_fttmr010(evt);
 	u32 cr;
+	u32 l;
 
 	/* Stop */
 	cr = readl(fttmr010->base + TIMER_CR);
@@ -136,6 +137,12 @@ static int fttmr010_timer_set_next_event(unsigned long cycles,
 		 * into TIMER1_COUNT register when the timer is re-enabled.
 		 */
 		writel(cycles, fttmr010->base + TIMER1_LOAD);
+#if CONFIG_GENERIC_CLOCKEVENTS_MIN_ADJUST> +		/* QEMU model may provide back-pressure on requested period */
+		l = readl(fttmr010->base + TIMER1_LOAD);
+		if (l > cycles)
+			return -EINVAL;
+#endif
 	} else {
 		/* Setup the match register forward in time */
 		cr = readl(fttmr010->base + TIMER1_COUNT);