mbox series

[v3,0/6] Proper arch timer support for Exynos5433-based TM2(e) boards

Message ID 20181017134159.9656-1-m.szyprowski@samsung.com
Headers show
Series Proper arch timer support for Exynos5433-based TM2(e) boards | expand

Message

Marek Szyprowski Oct. 17, 2018, 1:41 p.m. UTC
Dear All,

This patchset is an attempt to submit the last piece of missing code
to have proper support for Exynos5433 SoCs based TM2(e) boards. It
performs a cleanup of timer configuration, which so far needed various
out-of-tree workarounds. The fixes provided by this patchset are also
needed for add proper support for system suspend/resume.

Best regards
Marek Szyprowski
Samsung R&D Institute Poland


Changelog:

v3:
- added patch, which splits resources and interrupts allocation
- simplified arch timer cooperation mode
- dropped CPU hotplug priority change patch, it is not really needed
- removed more non-dt dead code

v2:
- dropped arch timer patch, it will be discussed separately
- fixed issues pointed by Krzysztof Kozlowski

v1: https://patchwork.kernel.org/project/linux-samsung-soc/list/?series=27965&state=*&archive=both
- initial version


Patch summary:

Marek Szyprowski (6):
  clocksource: exynos_mct: Remove dead code
  clocksource: exynos_mct: Fix error path in timer resources
    initialization
  clocksource: exynos_mct: Refactor resources allocation
  clocksource: exynos_mct: Add arch_timer cooperation mode for ARM64
  arm64: dts: exynos: Move arch-timer node to right place
  arm64: platform: Add enable Exynos Multi-Core Timer driver

 arch/arm64/Kconfig.platforms               |  1 +
 arch/arm64/boot/dts/exynos/exynos5433.dtsi | 23 +++---
 drivers/clocksource/exynos_mct.c           | 81 ++++++++++++++--------
 3 files changed, 67 insertions(+), 38 deletions(-)

-- 
2.17.1

Comments

Chanwoo Choi Oct. 18, 2018, 3:51 a.m. UTC | #1
Hi Marek,

On 2018년 10월 17일 22:41, Marek Szyprowski wrote:
> To get ARM Architected Timers working on Samsung Exynos SoCs, one has to

> first configure and enable Exynos Multi-Core Timer, because they both

> share some common hardware blocks (global system counter). This patch

> adds a mode of cooperation with arch_timer driver, so kernel can use

> CP15 based timer interface via arch_timer driver, which is mandatory

> on ARM64. In such mode MCT driver only enables its clocks and starts

> global timer. Everything else will be handled by arch_timer driver.

> 

> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>

> ---

>  drivers/clocksource/exynos_mct.c | 9 +++++++++

>  1 file changed, 9 insertions(+)

> 

> diff --git a/drivers/clocksource/exynos_mct.c b/drivers/clocksource/exynos_mct.c

> index 02ad55db390b..1b19a4f03929 100644

> --- a/drivers/clocksource/exynos_mct.c

> +++ b/drivers/clocksource/exynos_mct.c

> @@ -606,6 +606,15 @@ static int __init mct_init_dt(struct device_node *np, unsigned int int_type)

>  	if (ret)

>  		return ret;

>  

> +	if (IS_ENABLED(CONFIG_ARM64) && IS_ENABLED(CONFIG_ARM_ARCH_TIMER)) {

> +		struct device_node *np = of_find_compatible_node(NULL, NULL,

> +							     "arm,armv8-timer");

> +		if (np) {

> +			of_node_put(np);

> +			exynos4_mct_frc_start();

> +			return 0;

> +		}

> +	}

>  

>  	ret = exynos4_timer_interrupts(np, int_type);

>  	if (ret)

> 


I tested it on Exynos5433-based TM2 board.

Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>

Tested-by: Chanwoo Choi <cw00.choi@samsung.com>



-- 
Best Regards,
Chanwoo Choi
Samsung Electronics
Marek Szyprowski Oct. 18, 2018, 9:40 a.m. UTC | #2
Hi Krzysztof,

On 2018-10-17 16:29, Krzysztof Kozlowski wrote:
> On Wed, 17 Oct 2018 at 15:42, Marek Szyprowski <m.szyprowski@samsung.com> wrote:

>> 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.

>>

>> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>

>> ---

>>  drivers/clocksource/exynos_mct.c | 49 +++++++++++++++++++-------------

>>  1 file changed, 30 insertions(+), 19 deletions(-)

>>

>> diff --git a/drivers/clocksource/exynos_mct.c b/drivers/clocksource/exynos_mct.c

>> index 49413900b24c..02ad55db390b 100644

>> --- a/drivers/clocksource/exynos_mct.c

>> +++ b/drivers/clocksource/exynos_mct.c

>> @@ -502,11 +502,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__);

>> @@ -517,9 +520,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 i, err, cpu;

>> +

>> +       mct_int_type = int_type;

> This does not look good. Before, assignment was done before call to

> exynos4_timer_resources(). Now, if I follow the path correctly, it

> will be after. Therefore the exynos4_timer_resources() will use wrong

> value. This should pop up during tests.


After refactoring exynos4_timer_resource() doesn't use int_type, but you
are right, there is one item missing: nr_irqs as local variable, what
causes the driver to mess with the global one, what is fatal to the
system. I will send a fixed version in a few minutes.

> ...


Best regards
-- 
Marek Szyprowski, PhD
Samsung R&D Institute Poland