[PATCH v6 0/6] Add module support for Arm64 Exynos MCT driver

Will McVicker posted 6 patches 1 week, 4 days ago
arch/arm/lib/delay.c             |  2 +-
arch/arm64/Kconfig.platforms     |  1 -
drivers/clocksource/Kconfig      |  3 +-
drivers/clocksource/exynos_mct.c | 87 +++++++++++++++++++++++++++-----
4 files changed, 78 insertions(+), 15 deletions(-)
[PATCH v6 0/6] Add module support for Arm64 Exynos MCT driver
Posted by Will McVicker 1 week, 4 days ago
This series adds support to build the Arm64 Exynos MCT driver as a module.
This is only possible on Arm64 SoCs since they can use the Arm architected
timer as the clocksource. Once the Exynos MCT module is loaded and the
device probes, the MCT is used as the wakeup source for the arch_timer to
ensure the device can wakeup from the "c2" idle state.

These patches are originally from the downstream Pixel 6 (gs101) kernel
found at [1] and have been adapted for upstream. Not only has the Exynos MCT
driver been shipping as a module in the field with Android, but I've also
tested this series with the upstream kernel on my Pixel 6 Pro.

To verify the module on Pixel 6 Pro is used and the arch_timer is used as the
main clocksource, I ran these tests:

# lsmod | grep exynos_mct
exynos_mct             24576  9 [permanent]

$ cat /proc/interrupts | grep -E "mct|arch_timer"
 23:        222        171        211        139        184        124        825        378    GICv3  30 Level     arch_timer
117:          1          0          0          0          0          0          0          0    GICv3 785 Level     mct_comp_irq
118:        228          0          0          0          0          0          0          0    GICv3 789 Level     mct_tick0
119:          0        351          0          0          0          0          0          0    GICv3 790 Level     mct_tick1
120:          0          0       1490          0          0          0          0          0    GICv3 791 Level     mct_tick2
121:          0          0          0        325          0          0          0          0    GICv3 792 Level     mct_tick3
122:          0          0          0          0         97          0          0          0    GICv3 793 Level     mct_tick4
123:          0          0          0          0          0        150          0          0    GICv3 794 Level     mct_tick5
124:          0          0          0          0          0          0        188          0    GICv3 795 Level     mct_tick6
125:          0          0          0          0          0          0          0        157    GICv3 796 Level     mct_tick7

# cat /sys/devices/system/clocksource/clocksource0/current_clocksource
arch_sys_counter

I also compile tested for ARCH=ARM DEFCONFIG=multi_v7_defconfig with the
following debug configs to ensure the section mismatches are fixed:
  CONFIG_DEBUG_SECTION_MISMATCH=y
  # CONFIG_SECTION_MISMATCH_WARN_ONLY is not set

Any additional testing is much appreciated!

Thanks,
Will

Note1, instructions to build and flash a Pixel 6 device with the upstream
kernel can be found at [2].

Note2, this series is based off of krzk/for-next commit 870f6ca955ea ("Merge
branch 'next/clk' into for-next").

[1] https://android.googlesource.com/kernel/gs/+log/refs/heads/android-gs-raviole-5.10-android12-d1
[2] https://gitlab.com/LinaroLtd/googlelt/pixelscripts/-/blob/clo/main/README.md?ref_type=heads

Cc: Alim Akhtar <alim.akhtar@samsung.com>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: Donghoon Yu <hoony.yu@samsung.com>
Cc: Hosung Kim <hosung0.kim@samsung.com>
Cc: Rob Herring <robh@kernel.org>
Cc: John Stultz <jstultz@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Youngmin Nam <youngmin.nam@samsung.com>
Cc: Peter Griffin <peter.griffin@linaro.org>
Cc: Tudor Ambarus <tudor.ambarus@linaro.org>
Cc: André Draszik <andre.draszik@linaro.org>
Cc: Will Deacon <will@kernel.org>
Cc: Conor Dooley <conor+dt@kernel.org>
Cc: Krzysztof Kozlowski <krzk@kernel.org>
Cc: Marek Szyprowski <m.szyprowski@samsung.com>
Cc: linux-samsung-soc@vger.kernel.org
Cc: kernel-team@android.com
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
---

Changes in v6:
- Updated module support to only register the MCT driver as a platform driver
  for ARM64 to ensure ARM 32-bit SoCs continue to probe the MCT driver very
  early.
- Squashed the percpu fix suggested by Marek Szyprowski in
  https://lore.kernel.org/all/20250827102645.1964659-1-m.szyprowski@samsung.com/
  together with patch 3/6.

Changes in v5:
- Fixed section mismatch issues.
- Addressed Arnd's concerns regarding potential issues with unloading and/or
  unbinding the driver.
- Fixed SoB concerns to clarify the development chain from AOSP to Linux.
- Pulled in https://lore.kernel.org/all/20250827102645.1964659-1-m.szyprowski@samsung.com/
  to limit percpu interrupts only for ARM64.

Changes in v4:
- Missed the "v3" string in the previous series for the actual patches
- Re-generated patches with --base a15edf91668beefdb5171c53fa698c9b43dd1e0d
  for kernel test robot.

Changes in v3:
- Rebased on top of Daniel's timer modularization prep series [3] and
  krzk/for-next commit a15edf91668b ("Merge branch 'next/dt64' into
  for-next")
- Added owner references to Exynos MCT clocksource and clockevent objects.
- Dropped #ifdef MODULE conditional section in favor of just using
  module_platform_driver() which will properly handle setting up the
  of_device_id table based on if the driver is built-in or a module.
- Update commit message for patch 2 based on John's feedback.
- Dropped DT change from v2 as it was picked up by Krzysztof for CPU Idle.

Changes in v2:
- Re-worked patch v1 5 based on Rob Herring's review to use the compatible
  data for retrieving the mct_init function pointer.
- Updated the Kconfig logic to disallow building the Exynos MCT driver as
  a module for ARM32 configurations based on Krzysztof Kozlowski's findings.
- Added comments and clarified commit messages in patches 1 and 2 based on
  reviews from John Stultz and Youngmin Nam.
- Fixed an issue found during testing that resulted in the device getting
  stuck on boot. This is included in v2 as patch 5.
- Collected *-by tags
- Rebased to the latest linux-next/master.
---

Donghoon Yu (2):
  clocksource/drivers/exynos_mct: Don't register as a sched_clock on
    arm64
  clocksource/drivers/exynos_mct: Add module support for ARM64

Hosung Kim (1):
  clocksource/drivers/exynos_mct: Set percpu local timer interrupts for
    ARM64

Will McVicker (3):
  ARM: make register_current_timer_delay() accessible after init
  clocksource/drivers/exynos_mct: Fix uninitialized irq name warning
  arm64: exynos: Drop select CLKSRC_EXYNOS_MCT

 arch/arm/lib/delay.c             |  2 +-
 arch/arm64/Kconfig.platforms     |  1 -
 drivers/clocksource/Kconfig      |  3 +-
 drivers/clocksource/exynos_mct.c | 87 +++++++++++++++++++++++++++-----
 4 files changed, 78 insertions(+), 15 deletions(-)


base-commit: 870f6ca955ea3f23b4d7824c815c81180a6d7c48
-- 
2.52.0.rc2.455.g230fcf2819-goog
Re: [PATCH v6 0/6] Add module support for Arm64 Exynos MCT driver
Posted by Russell King (Oracle) 1 week, 3 days ago
On Thu, Nov 20, 2025 at 06:42:28PM +0000, Will McVicker wrote:
> This series adds support to build the Arm64 Exynos MCT driver as a module.

There are parts of this that are just totally incompatible with it
being a module. For example, you can't register a replacement udelay
loop after the system has booted.

This is the second time I've faced a patch series wanting to remove
__init anntations to call it from a module, where the author has
clearly not analysed the code to see whether that is a valid thing
to do. This is unfair on reviewers - it is the submitters
responsibility to check that what they are doing is valid.

Moreover, in _this_ case, you will have received a kernel diagnostic
message stating that the call to register_current_timer_delay()
was ignored, so I also question whether you bothered to run-time
test this change.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
Re: [PATCH v6 0/6] Add module support for Arm64 Exynos MCT driver
Posted by William McVicker 1 week, 3 days ago
Hi Russell,

On 11/21/2025, Russell King (Oracle) wrote:
> On Thu, Nov 20, 2025 at 06:42:28PM +0000, Will McVicker wrote:
> > This series adds support to build the Arm64 Exynos MCT driver as a module.
> 
> There are parts of this that are just totally incompatible with it
> being a module. For example, you can't register a replacement udelay
> loop after the system has booted.
> 
> This is the second time I've faced a patch series wanting to remove
> __init anntations to call it from a module, where the author has
> clearly not analysed the code to see whether that is a valid thing
> to do. This is unfair on reviewers - it is the submitters
> responsibility to check that what they are doing is valid.
> 
> Moreover, in _this_ case, you will have received a kernel diagnostic
> message stating that the call to register_current_timer_delay()
> was ignored, so I also question whether you bothered to run-time
> test this change.

Sorry for wasting your time on this due to my lack of explanation. PTAL at my
response in the other patch set.

To address your testing concerns, this series has been thoroughly tested on
Pixel 6 (ARM64) since 2021 starting with the 5.10 kernel version and is
continually being tested on the latest kernel version today.

Thanks,
Will
Re: [PATCH v6 0/6] Add module support for Arm64 Exynos MCT driver
Posted by Marek Szyprowski 1 week, 3 days ago
On 20.11.2025 19:42, Will McVicker wrote:
> This series adds support to build the Arm64 Exynos MCT driver as a module.
> This is only possible on Arm64 SoCs since they can use the Arm architected
> timer as the clocksource. Once the Exynos MCT module is loaded and the
> device probes, the MCT is used as the wakeup source for the arch_timer to
> ensure the device can wakeup from the "c2" idle state.
>
> These patches are originally from the downstream Pixel 6 (gs101) kernel
> found at [1] and have been adapted for upstream. Not only has the Exynos MCT
> driver been shipping as a module in the field with Android, but I've also
> tested this series with the upstream kernel on my Pixel 6 Pro.
>
> To verify the module on Pixel 6 Pro is used and the arch_timer is used as the
> main clocksource, I ran these tests:
>
> # lsmod | grep exynos_mct
> exynos_mct             24576  9 [permanent]
>
> $ cat /proc/interrupts | grep -E "mct|arch_timer"
>   23:        222        171        211        139        184        124        825        378    GICv3  30 Level     arch_timer
> 117:          1          0          0          0          0          0          0          0    GICv3 785 Level     mct_comp_irq
> 118:        228          0          0          0          0          0          0          0    GICv3 789 Level     mct_tick0
> 119:          0        351          0          0          0          0          0          0    GICv3 790 Level     mct_tick1
> 120:          0          0       1490          0          0          0          0          0    GICv3 791 Level     mct_tick2
> 121:          0          0          0        325          0          0          0          0    GICv3 792 Level     mct_tick3
> 122:          0          0          0          0         97          0          0          0    GICv3 793 Level     mct_tick4
> 123:          0          0          0          0          0        150          0          0    GICv3 794 Level     mct_tick5
> 124:          0          0          0          0          0          0        188          0    GICv3 795 Level     mct_tick6
> 125:          0          0          0          0          0          0          0        157    GICv3 796 Level     mct_tick7
>
> # cat /sys/devices/system/clocksource/clocksource0/current_clocksource
> arch_sys_counter
>
> I also compile tested for ARCH=ARM DEFCONFIG=multi_v7_defconfig with the
> following debug configs to ensure the section mismatches are fixed:
>    CONFIG_DEBUG_SECTION_MISMATCH=y
>    # CONFIG_SECTION_MISMATCH_WARN_ONLY is not set
>
> Any additional testing is much appreciated!

Works fine on 32bit Exynos systems in my test farm!

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

> Thanks,
> Will
>
> Note1, instructions to build and flash a Pixel 6 device with the upstream
> kernel can be found at [2].
>
> Note2, this series is based off of krzk/for-next commit 870f6ca955ea ("Merge
> branch 'next/clk' into for-next").
>
> [1] https://android.googlesource.com/kernel/gs/+log/refs/heads/android-gs-raviole-5.10-android12-d1
> [2] https://gitlab.com/LinaroLtd/googlelt/pixelscripts/-/blob/clo/main/README.md?ref_type=heads
>
> Cc: Alim Akhtar <alim.akhtar@samsung.com>
> Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
> Cc: Donghoon Yu <hoony.yu@samsung.com>
> Cc: Hosung Kim <hosung0.kim@samsung.com>
> Cc: Rob Herring <robh@kernel.org>
> Cc: John Stultz <jstultz@google.com>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Youngmin Nam <youngmin.nam@samsung.com>
> Cc: Peter Griffin <peter.griffin@linaro.org>
> Cc: Tudor Ambarus <tudor.ambarus@linaro.org>
> Cc: André Draszik <andre.draszik@linaro.org>
> Cc: Will Deacon <will@kernel.org>
> Cc: Conor Dooley <conor+dt@kernel.org>
> Cc: Krzysztof Kozlowski <krzk@kernel.org>
> Cc: Marek Szyprowski <m.szyprowski@samsung.com>
> Cc: linux-samsung-soc@vger.kernel.org
> Cc: kernel-team@android.com
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linux-kernel@vger.kernel.org
> ---
>
> Changes in v6:
> - Updated module support to only register the MCT driver as a platform driver
>    for ARM64 to ensure ARM 32-bit SoCs continue to probe the MCT driver very
>    early.
> - Squashed the percpu fix suggested by Marek Szyprowski in
>    https://lore.kernel.org/all/20250827102645.1964659-1-m.szyprowski@samsung.com/
>    together with patch 3/6.
>
> Changes in v5:
> - Fixed section mismatch issues.
> - Addressed Arnd's concerns regarding potential issues with unloading and/or
>    unbinding the driver.
> - Fixed SoB concerns to clarify the development chain from AOSP to Linux.
> - Pulled in https://lore.kernel.org/all/20250827102645.1964659-1-m.szyprowski@samsung.com/
>    to limit percpu interrupts only for ARM64.
>
> Changes in v4:
> - Missed the "v3" string in the previous series for the actual patches
> - Re-generated patches with --base a15edf91668beefdb5171c53fa698c9b43dd1e0d
>    for kernel test robot.
>
> Changes in v3:
> - Rebased on top of Daniel's timer modularization prep series [3] and
>    krzk/for-next commit a15edf91668b ("Merge branch 'next/dt64' into
>    for-next")
> - Added owner references to Exynos MCT clocksource and clockevent objects.
> - Dropped #ifdef MODULE conditional section in favor of just using
>    module_platform_driver() which will properly handle setting up the
>    of_device_id table based on if the driver is built-in or a module.
> - Update commit message for patch 2 based on John's feedback.
> - Dropped DT change from v2 as it was picked up by Krzysztof for CPU Idle.
>
> Changes in v2:
> - Re-worked patch v1 5 based on Rob Herring's review to use the compatible
>    data for retrieving the mct_init function pointer.
> - Updated the Kconfig logic to disallow building the Exynos MCT driver as
>    a module for ARM32 configurations based on Krzysztof Kozlowski's findings.
> - Added comments and clarified commit messages in patches 1 and 2 based on
>    reviews from John Stultz and Youngmin Nam.
> - Fixed an issue found during testing that resulted in the device getting
>    stuck on boot. This is included in v2 as patch 5.
> - Collected *-by tags
> - Rebased to the latest linux-next/master.
> ---
>
> Donghoon Yu (2):
>    clocksource/drivers/exynos_mct: Don't register as a sched_clock on
>      arm64
>    clocksource/drivers/exynos_mct: Add module support for ARM64
>
> Hosung Kim (1):
>    clocksource/drivers/exynos_mct: Set percpu local timer interrupts for
>      ARM64
>
> Will McVicker (3):
>    ARM: make register_current_timer_delay() accessible after init
>    clocksource/drivers/exynos_mct: Fix uninitialized irq name warning
>    arm64: exynos: Drop select CLKSRC_EXYNOS_MCT
>
>   arch/arm/lib/delay.c             |  2 +-
>   arch/arm64/Kconfig.platforms     |  1 -
>   drivers/clocksource/Kconfig      |  3 +-
>   drivers/clocksource/exynos_mct.c | 87 +++++++++++++++++++++++++++-----
>   4 files changed, 78 insertions(+), 15 deletions(-)
>
>
> base-commit: 870f6ca955ea3f23b4d7824c815c81180a6d7c48

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