pwm: th1520: Fix 32-bit build with COMPILE_TEST
Subsystems (4)
PATCH v2 1/1 pwm: th1520: Fix 32-bit build with COMPILE_TEST
From: FUJITA Tomonori <[email protected]>
Fix the following build error on 32-bit ARM with COMPILE_TEST:
ERROR: modpost: drivers/pwm/pwm_th1520.ko: symbol '__aeabi_uldivmod' undefined!
The driver divides u64 values when it converts between nanoseconds and clock cycles. On 32-bit ARM, these divisions are compiled to calls to __aeabi_uldivmod, which the kernel does not provide.
The TH1520 is a 64-bit RISC-V SoC, so the driver is only used on 64-bit kernels. There is no point in compile testing it on 32-bit. Limit COMPILE_TEST to 64BIT instead of changing the arithmetic to use the div64 helpers.
---
v2:
- Fix a typo in the commit message
- Add Cc: stable, Reported-by and Closes tags
- Add Reviewed-by tags from Andreas and Gary
- Rebase on v7.3-rc5
v1: https://lore.kernel.org/all/[email protected]/
--- drivers/pwm/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pwm/Kconfig +1 -1
@@ -772,7 +772,7 @@ config PWM_TEGRA config PWM_TH1520 tristate "TH1520 PWM support" - depends on ARCH_THEAD || COMPILE_TEST + depends on ARCH_THEAD || (COMPILE_TEST && 64BIT) depends on RUST depends on HAS_IOMEM && COMMON_CLK select RUST_PWM_ABSTRACTIONS
base-commit: 72d3fcf802c45d00b300f25b848a93c3a2bd7c7e
Signature · 1 line
2.43.0
Quoted 16 lines · FUJITA Tomonori
From: FUJITA Tomonori <[email protected]>
Fix the following build error on 32-bit ARM with
COMPILE_TEST:ERROR: modpost:
drivers/pwm/pwm_th1520.ko: symbol '__aeabi_uldivmod' undefined!The driver divides u64 values when it converts between nanoseconds and clock cycles. On 32-bit ARM, these divisions are compiled to calls to
__aeabi_uldivmod, which the kernel does not provide.The TH1520 is a 64-bit RISC-V SoC, so the driver is only used on 64-bit kernels. There is no point in compile testing it on 32-bit. Limit
COMPILE_TESTto 64BIT instead of changing the arithmetic to use the div64 helpers.
Quoted 7 lines
Fixes 3c180003dffb ("pwm: th1520: Fix missing Kconfig dependencies")Reported-by Andreas Hindborg <[email protected]>Reviewed-by Andreas Hindborg <[email protected]>Reviewed-by Gary Guo <[email protected]>Signed-off-by FUJITA Tomonori <[email protected]>
Thanks Tomo!
If PWM wants me to pick it up for some reason, please let me know (I don't plan at the moment to send a fixes PR, though).
Cheers,
Miguel
Quoted 48 lines · FUJITA Tomonori
From: FUJITA Tomonori <[email protected]>
Fix the following build error on 32-bit ARM with
COMPILE_TEST:ERROR: modpost:
drivers/pwm/pwm_th1520.ko: symbol '__aeabi_uldivmod' undefined!The driver divides u64 values when it converts between nanoseconds and clock cycles. On 32-bit ARM, these divisions are compiled to calls to
__aeabi_uldivmod, which the kernel does not provide.The TH1520 is a 64-bit RISC-V SoC, so the driver is only used on 64-bit kernels. There is no point in compile testing it on 32-bit. Limit
COMPILE_TESTto 64BIT instead of changing the arithmetic to use the div64 helpers.Fixes 3c180003dffb ("pwm: th1520: Fix missing Kconfig dependencies")Reported-by Andreas Hindborg <[email protected]>Reviewed-by Andreas Hindborg <[email protected]>Reviewed-by Gary Guo <[email protected]>Signed-off-by FUJITA Tomonori <[email protected]>---
v2:
- Fix a typo in the commit message
- Add Cc: stable, Reported-by and Closes tags
- Add Reviewed-by tags from Andreas and Gary
- Rebase on v7.3-rc5v1: https://lore.kernel.org/all/[email protected]/
--- drivers/pwm/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/pwm/Kconfig +1
-1@@ -772,7 +772,7 @@ config PWM_TEGRA config PWM_TH1520 tristate "TH1520 PWM support" - depends on ARCH_THEAD || COMPILE_TEST + depends on ARCH_THEAD || (COMPILE_TEST && 64BIT) depends on RUST depends on HAS_IOMEM && COMMON_CLK select RUST_PWM_ABSTRACTIONS
Quoted 1 line
base-commit:
72d3fcf802c45d00b300f25b848a93c3a2bd7c7e
Uwe Kleine-König
maintainerQuoted 39 lines · FUJITA Tomonori
From: FUJITA Tomonori <[email protected]>
Fix the following build error on 32-bit ARM with
COMPILE_TEST:ERROR: modpost:
drivers/pwm/pwm_th1520.ko: symbol '__aeabi_uldivmod' undefined!The driver divides u64 values when it converts between nanoseconds and clock cycles. On 32-bit ARM, these divisions are compiled to calls to
__aeabi_uldivmod, which the kernel does not provide.The TH1520 is a 64-bit RISC-V SoC, so the driver is only used on 64-bit kernels. There is no point in compile testing it on 32-bit. Limit
COMPILE_TESTto 64BIT instead of changing the arithmetic to use the div64 helpers.Fixes 3c180003dffb ("pwm: th1520: Fix missing Kconfig dependencies")Reported-by Andreas Hindborg <[email protected]>Reviewed-by Andreas Hindborg <[email protected]>Reviewed-by Gary Guo <[email protected]>Signed-off-by FUJITA Tomonori <[email protected]>---
v2:
- Fix a typo in the commit message
- Add Cc: stable, Reported-by and Closes tags
- Add Reviewed-by tags from Andreas and Gary
- Rebase on v7.3-rc5v1: https://lore.kernel.org/all/[email protected]/
--- drivers/pwm/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/pwm/Kconfig +0
-0
drivers/pwm/Kconfig config PWM_TEGRA · line 778
Quoted 8 lines
drivers/pwm/Kconfig +1
-1@@ -772,7 +772,7 @@ config PWM_TEGRA config PWM_TH1520 tristate "TH1520 PWM support" - depends on ARCH_THEAD || COMPILE_TEST + depends on ARCH_THEAD || (COMPILE_TEST && 64BIT) depends on RUST depends on HAS_IOMEM && COMMON_CLK select RUST_PWM_ABSTRACTIONS
Can't we do better than that? For C code the right thing to do is to use one of the div helpers instead of a plain / for types bigger than long.
Best regards
Uwe
Quoted 6 lines · On Wed, 30 Sep 2026 13:57:31 +0200 Uwe Kleine-König <[email protected]> wrote:
Quoted 6 lines
drivers/pwm/Kconfig +0
-0@@ -772,7 +772,7 @@ config PWM_TEGRA
Quoted 10 lines
drivers/pwm/Kconfig config PWM_TEGRA · line 778
Quoted 7 lines
drivers/pwm/Kconfig +1
-1config PWM_TH1520 tristate "TH1520 PWM support" - depends on ARCH_THEAD || COMPILE_TEST + depends on ARCH_THEAD || (COMPILE_TEST && 64BIT) depends on RUST depends on HAS_IOMEM && COMMON_CLK select RUST_PWM_ABSTRACTIONSCan't we do better than that? For C code the right thing to do is to use one of the div helpers instead of a plain / for types bigger than long.
Indeed. Rust code already uses some div helpers. However, the kernel crate does not have Rust wrappers for the helpers this driver needs, such as mul_u64_u64_div_u64(), so we need to add them first. The changes would be too large for stable.
So how about merging this as a fix? I will work on patches to use div helpers in the driver.
Uwe Kleine-König
maintainerHello,
Quoted 20 lines · FUJITA Tomonori
Quoted 6 lines · On Wed, 30 Sep 2026 13:57:31 +0200 Uwe Kleine-König <[email protected]> wrote:
Quoted 6 lines
drivers/pwm/Kconfig +0
-0@@ -772,7 +772,7 @@ config PWM_TEGRAQuoted 10 lines
drivers/pwm/Kconfig config PWM_TEGRA · line 778
Quoted 7 lines
drivers/pwm/Kconfig +1
-1config PWM_TH1520 tristate "TH1520 PWM support" - depends on ARCH_THEAD || COMPILE_TEST + depends on ARCH_THEAD || (COMPILE_TEST && 64BIT) depends on RUST depends on HAS_IOMEM && COMMON_CLK select RUST_PWM_ABSTRACTIONSCan't we do better than that? For C code the right thing to do is to use one of the div helpers instead of a plain / for types bigger than long.
Quoted 7 lines
Indeed. Rust code already uses some div helpers. However, the kernel crate does not have Rust wrappers for the helpers this driver needs, such as
mul_u64_u64_div_u64(), so we need to add them first. The changes would be too large for stable.So how about merging this as a fix? I will work on patches to use div helpers in the driver.
Fine, then let me just wonder about the expression you chose, that makes it look as if 64BIT was only needed for COMPILE_TEST.
How about making this
drivers/pwm/Kconfig +1 -0
@@ -774,6 +774,7 @@ config PWM_TH1520 tristate "TH1520 PWM support" depends on ARCH_THEAD || COMPILE_TEST depends on RUST + depends on 64BIT # no 64bit division available on 32 bit builds depends on HAS_IOMEM && COMMON_CLK select RUST_PWM_ABSTRACTIONS help
instead?
Best regards
Uwe
Quoted 29 lines · On Thu, 1 Oct 2026 08:27:45 +0200 Uwe Kleine-König <[email protected]> wrote:
Quoted 10 lines
Quoted 2 lines
Can't we do better than that? For C code the right thing to do is to use one of the div helpers instead of a plain / for types bigger than long.
Indeed. Rust code already uses some div helpers. However, the kernel crate does not have Rust wrappers for the helpers this driver needs, such as
mul_u64_u64_div_u64(), so we need to add them first. The changes would be too large for stable.So how about merging this as a fix? I will work on patches to use div helpers in the driver.
Fine, then let me just wonder about the expression you chose, that makes it look as if 64BIT was only needed for
COMPILE_TEST.How about making this
drivers/pwm/Kconfig +1
-0@@ -774,6 +774,7 @@ config PWM_TH1520 tristate "TH1520 PWM support" depends on ARCH_THEAD || COMPILE_TEST depends on RUST + depends on 64BIT # no 64bit division available on 32 bit builds depends on HAS_IOMEM && COMMON_CLK select RUST_PWM_ABSTRACTIONS help
Quoted 1 line
instead?
Yeah, it's cleaner.