Skip to contentSkip to conversation

clocksource: exynos_mct: Enable MCT on ARM64

PATCH Applied Sam Protsenko 4 participants 9 messages Nov 1, 2021 – Jan 10, 2022

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

cover clocksource: exynos_mct: Enable MCT on ARM64

This is re-submission of Marek Szyprowski patches, which were sent earlier [1], but weren't applied for some reason. Those two patches look helpful and benign:

- [PATCH 1/2]: cleanup MCT irqs setting up
- [PATCH 2/2]: enable MCT on ARM64

I'm mostly interested in [PATCH 2/2], which allows one to test MCT on Exynos850 (architected timer works fine on Exynos850, but it's nice to have MCT for wakeup and testing too). But cleanup one seems desirable as well, so sending both.

[PATCH 2/2] commit message was rewritten to provide new reasoning and background, as original commit message was related to [1] series.

[1] https://patchwork.kernel.org/project/linux-samsung-soc/cover/[email protected]/

Marek Szyprowski (2):
clocksource: exynos_mct: Refactor resources allocation
arm64: platform: Enable Exynos Multi-Core Timer driver

 arch/arm64/Kconfig.platforms     |  1 +
 drivers/clocksource/exynos_mct.c | 50 +++++++++++++++++++-------------
 2 files changed, 31 insertions(+), 20 deletions(-)
Signature · 1 line
2.30.2
#1 lore raw

PATCH 1/2 clocksource: exynos_mct: Refactor resources allocation

From: Marek Szyprowski <[email protected]>

Move interrupts allocation from exynos4_timer_resources() into separate function together with the interrupt number parsing code from mct_init_dt(), so the code for managing interrupts is kept together. While touching exynos4_timer_resources() function, move of_iomap() to it. No functional changes.

---
 drivers/clocksource/exynos_mct.c | 50 +++++++++++++++++++-------------
 1 file changed, 30 insertions(+), 20 deletions(-)
drivers/clocksource/exynos_mct.c +30 -20
index 5e3e96d3d1b9..857cf12ebe57 100644
@@ -504,11 +504,14 @@ static int exynos4_mct_dying_cpu(unsigned int cpu)
 	return 0;
 }
 
-static int __init exynos4_timer_resources(struct device_node *np, void __iomem *base)
+static int __init exynos4_timer_resources(struct device_node *np)
 {
-	int err, cpu;
 	struct clk *mct_clk, *tick_clk;
 
+	reg_base = of_iomap(np, 0);
+	if (!reg_base)
+		panic("%s: unable to ioremap mct address space\n", __func__);
+
 	tick_clk = of_clk_get_by_name(np, "fin_pll");
 	if (IS_ERR(tick_clk))
 		panic("%s: unable to determine tick clock rate\n", __func__);
@@ -519,9 +522,27 @@ static int __init exynos4_timer_resources(struct device_node *np, void __iomem *
 		panic("%s: unable to retrieve mct clock instance\n", __func__);
 	clk_prepare_enable(mct_clk);
 
-	reg_base = base;
-	if (!reg_base)
-		panic("%s: unable to ioremap mct address space\n", __func__);
+	return 0;
+}
+
+static int __init exynos4_timer_interrupts(struct device_node *np,
+					   unsigned int int_type)
+{
+	int nr_irqs, i, err, cpu;
+
+	mct_int_type = int_type;
+
+	/* This driver uses only one global timer interrupt */
+	mct_irqs[MCT_G0_IRQ] = irq_of_parse_and_map(np, MCT_G0_IRQ);
+
+	/*
+	 * Find out the number of local irqs specified. The local
+	 * timer irqs are specified after the four global timer
+	 * irqs are specified.
+	 */
+	nr_irqs = of_irq_count(np);
+	for (i = MCT_L0_IRQ; i < nr_irqs; i++)
+		mct_irqs[i] = irq_of_parse_and_map(np, i);
 
 	if (mct_int_type == MCT_INT_PPI) {
 
@@ -581,24 +602,13 @@ static int __init exynos4_timer_resources(struct device_node *np, void __iomem *
 
 static int __init mct_init_dt(struct device_node *np, unsigned int int_type)
 {
-	u32 nr_irqs, i;
 	int ret;
 
-	mct_int_type = int_type;
-
-	/* This driver uses only one global timer interrupt */
-	mct_irqs[MCT_G0_IRQ] = irq_of_parse_and_map(np, MCT_G0_IRQ);
-
-	/*
-	 * Find out the number of local irqs specified. The local
-	 * timer irqs are specified after the four global timer
-	 * irqs are specified.
-	 */
-	nr_irqs = of_irq_count(np);
-	for (i = MCT_L0_IRQ; i < nr_irqs; i++)
-		mct_irqs[i] = irq_of_parse_and_map(np, i);
+	ret = exynos4_timer_resources(np);
+	if (ret)
+		return ret;
 
-	ret = exynos4_timer_resources(np, of_iomap(np, 0));
+	ret = exynos4_timer_interrupts(np, int_type);
 	if (ret)
 		return ret;
 
Signature · 1 line
2.30.2
#2 lore raw

Re: [PATCH 1/2] clocksource: exynos_mct: Refactor resources allocation

Quoted 8 lines · Sam Protsenko

From: Marek Szyprowski <[email protected]>

Move interrupts allocation from exynos4_timer_resources() into separate function together with the interrupt number parsing code from mct_init_dt(), so the code for managing interrupts is kept together. While touching exynos4_timer_resources() function, move of_iomap() to it. No functional changes.

Quoted 6 lines

---

Applied, thx

[ ... ]

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
#3 lore raw

Re: [PATCH 1/2] clocksource: exynos_mct: Refactor resources allocation

Quoted 10 lines · Daniel Lezcano
Quoted 8 lines · Sam Protsenko

From: Marek Szyprowski <[email protected]>

Move interrupts allocation from exynos4_timer_resources() into separate function together with the interrupt number parsing code from mct_init_dt(), so the code for managing interrupts is kept together. While touching exynos4_timer_resources() function, move of_iomap() to it. No functional changes.

Quoted 9 lines
Quoted 6 lines

---

Applied, thx

Hi Daniel,

Can you please let me know the URL for your tree where you applied this one? I checked [1] and linux-next, but this patch seems nowhere to be found.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/daniel.lezcano/linux.git/

Thanks!

Quoted 8 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

#4 lore raw

[tip: timers/core] clocksource/drivers/exynos_mct: Refactor resources allocation

In reply to Sam Protsenko
The following commit has been merged into the timers/core branch of tip:

The following commit has been merged into the timers/core branch of tip:

Commit-ID:     7cd925a8823d16de5614d3f0aabea9948747accd
Gitweb:        https://git.kernel.org/tip/7cd925a8823d16de5614d3f0aabea9948747accd
Author:        Marek Szyprowski <[email protected]>
AuthorDate:    Mon, 01 Nov 2021 21:35:30 +02:00
Committer:     Daniel Lezcano <[email protected]>
CommitterDate: Tue, 16 Nov 2021 16:12:00 +01:00

clocksource/drivers/exynos_mct: Refactor resources allocation

Move interrupts allocation from exynos4_timer_resources() into separate function together with the interrupt number parsing code from mct_init_dt(), so the code for managing interrupts is kept together. While touching exynos4_timer_resources() function, move of_iomap() to it. No functional changes.

---
 drivers/clocksource/exynos_mct.c | 50 ++++++++++++++++++-------------
 1 file changed, 30 insertions(+), 20 deletions(-)
drivers/clocksource/exynos_mct.c +30 -20
index 5e3e96d..857cf12 100644
@@ -504,11 +504,14 @@ static int exynos4_mct_dying_cpu(unsigned int cpu)
 	return 0;
 }
 
-static int __init exynos4_timer_resources(struct device_node *np, void __iomem *base)
+static int __init exynos4_timer_resources(struct device_node *np)
 {
-	int err, cpu;
 	struct clk *mct_clk, *tick_clk;
 
+	reg_base = of_iomap(np, 0);
+	if (!reg_base)
+		panic("%s: unable to ioremap mct address space\n", __func__);
+
 	tick_clk = of_clk_get_by_name(np, "fin_pll");
 	if (IS_ERR(tick_clk))
 		panic("%s: unable to determine tick clock rate\n", __func__);
@@ -519,9 +522,27 @@ static int __init exynos4_timer_resources(struct device_node *np, void __iomem *
 		panic("%s: unable to retrieve mct clock instance\n", __func__);
 	clk_prepare_enable(mct_clk);
 
-	reg_base = base;
-	if (!reg_base)
-		panic("%s: unable to ioremap mct address space\n", __func__);
+	return 0;
+}
+
+static int __init exynos4_timer_interrupts(struct device_node *np,
+					   unsigned int int_type)
+{
+	int nr_irqs, i, err, cpu;
+
+	mct_int_type = int_type;
+
+	/* This driver uses only one global timer interrupt */
+	mct_irqs[MCT_G0_IRQ] = irq_of_parse_and_map(np, MCT_G0_IRQ);
+
+	/*
+	 * Find out the number of local irqs specified. The local
+	 * timer irqs are specified after the four global timer
+	 * irqs are specified.
+	 */
+	nr_irqs = of_irq_count(np);
+	for (i = MCT_L0_IRQ; i < nr_irqs; i++)
+		mct_irqs[i] = irq_of_parse_and_map(np, i);
 
 	if (mct_int_type == MCT_INT_PPI) {
 
@@ -581,24 +602,13 @@ out_irq:
 
 static int __init mct_init_dt(struct device_node *np, unsigned int int_type)
 {
-	u32 nr_irqs, i;
 	int ret;
 
-	mct_int_type = int_type;
-
-	/* This driver uses only one global timer interrupt */
-	mct_irqs[MCT_G0_IRQ] = irq_of_parse_and_map(np, MCT_G0_IRQ);
-
-	/*
-	 * Find out the number of local irqs specified. The local
-	 * timer irqs are specified after the four global timer
-	 * irqs are specified.
-	 */
-	nr_irqs = of_irq_count(np);
-	for (i = MCT_L0_IRQ; i < nr_irqs; i++)
-		mct_irqs[i] = irq_of_parse_and_map(np, i);
+	ret = exynos4_timer_resources(np);
+	if (ret)
+		return ret;
 
-	ret = exynos4_timer_resources(np, of_iomap(np, 0));
+	ret = exynos4_timer_interrupts(np, int_type);
 	if (ret)
 		return ret;
 
#5 lore raw

PATCH 2/2 arm64: platform: Enable Exynos Multi-Core Timer driver

In reply to Sam Protsenko

From: Marek Szyprowski <[email protected]>

Some ARM64 Exynos SoCs have MCT timer block, e.g. Exynos850 and Exynos5433. CLKSRC_EXYNOS_MCT option is not visible unless COMPILE_TEST is enabled. Select CLKSRC_EXYNOS_MCT option for ARM64 ARCH_EXYNOS like it's done in arch/arm/mach-exynos/Kconfig, to enable MCT timer support for ARM64 Exynos SoCs.

Even though ARM architected timer is available on all ARM64 SoCs, and used for managing timer hardware and clock source events, MCT timer still can be used as a wakeup source, as stated in commitae460fd9164b ("clocksource/drivers/exynos_mct: Prioritise Arm arch timer on arm64"). It's also nice to be able to test available MCT IP-core.

---
 arch/arm64/Kconfig.platforms | 1 +
 1 file changed, 1 insertion(+)
arch/arm64/Kconfig.platforms +1 -0
index 1aa8b7073218..91f5e9568122 100644
@@ -89,6 +89,7 @@ config ARCH_BRCMSTB
 config ARCH_EXYNOS
 	bool "ARMv8 based Samsung Exynos SoC family"
 	select COMMON_CLK_SAMSUNG
+	select CLKSRC_EXYNOS_MCT
 	select EXYNOS_PM_DOMAINS if PM_GENERIC_DOMAINS
 	select EXYNOS_PMU
 	select PINCTRL
Signature · 1 line
2.30.2
#6 lore raw

Re: (subset) [PATCH 2/2] arm64: platform: Enable Exynos Multi-Core Timer driver

Quoted 9 lines · Sam Protsenko

From: Marek Szyprowski <[email protected]>

Some ARM64 Exynos SoCs have MCT timer block, e.g. Exynos850 and Exynos5433. CLKSRC_EXYNOS_MCT option is not visible unless COMPILE_TEST is enabled. Select CLKSRC_EXYNOS_MCT option for ARM64 ARCH_EXYNOS like it's done in arch/arm/mach-exynos/Kconfig, to enable MCT timer support for ARM64 Exynos SoCs.

[...]

Applied, thanks!

[2/2] arm64: platform: Enable Exynos Multi-Core Timer driver

      commit: ddb0fc6f055d12518b724fd1ee00669e07f03b96

Best regards,

Signature · 1 line
Krzysztof Kozlowski <[email protected]>
#7 lore raw

Re: (subset) [PATCH 2/2] arm64: platform: Enable Exynos Multi-Core Timer driver

Quoted 10 lines · Krzysztof Kozlowski
Quoted 8 lines · Sam Protsenko

From: Marek Szyprowski <[email protected]>

Some ARM64 Exynos SoCs have MCT timer block, e.g. Exynos850 and Exynos5433. CLKSRC_EXYNOS_MCT option is not visible unless COMPILE_TEST is enabled. Select CLKSRC_EXYNOS_MCT option for ARM64 ARCH_EXYNOS like it's done in arch/arm/mach-exynos/Kconfig, to enable MCT timer support for ARM64 Exynos SoCs.

Quoted 7 lines
Quoted 1 line

[...]

Applied, thanks!

[2/2] arm64: platform: Enable Exynos Multi-Core Timer driver

      commit: ddb0fc6f055d12518b724fd1ee00669e07f03b96

Hi Krzysztof,

Can you please let me know where exactly this one is applied? I've checked your tree and linux-next, but wasn't able to find it.

Thanks!

Quoted 3 lines

Best regards,
--
Krzysztof Kozlowski <[email protected]>

#8 lore raw

Re: (subset) [PATCH 2/2] arm64: platform: Enable Exynos Multi-Core Timer driver

Quoted 16 lines · Sam Protsenko
Quoted 14 lines · Krzysztof Kozlowski
Quoted 9 lines · Sam Protsenko

From: Marek Szyprowski <[email protected]>

Some ARM64 Exynos SoCs have MCT timer block, e.g. Exynos850 and Exynos5433. CLKSRC_EXYNOS_MCT option is not visible unless COMPILE_TEST is enabled. Select CLKSRC_EXYNOS_MCT option for ARM64 ARCH_EXYNOS like it's done in arch/arm/mach-exynos/Kconfig, to enable MCT timer support for ARM64 Exynos SoCs.

[...]

Applied, thanks!

Quoted 9 lines
Quoted 3 lines

[2/2] arm64: platform: Enable Exynos Multi-Core Timer driver

      commit: ddb0fc6f055d12518b724fd1ee00669e07f03b96

Hi Krzysztof,

Can you please let me know where exactly this one is applied? I've checked your tree and linux-next, but wasn't able to find it.

It's in my tree. It should be also in linux-next since it was applied a week ago. Commit msg seems valid.

Best regards,
Krzysztof