Skip to contentSkip to conversation

pwm: th1520: Fix 32-bit build with COMPILE_TEST

PATCH Superseded FUJITA Tomonori 4 participants 7 messages Sep 30 – Oct 1

Subsystems (4)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

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
index 729776086879..abecd95b0c3c 100644
@@ -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
#1 lore raw
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_TEST to 64BIT instead of changing the arithmetic to use the div64 helpers.

Quoted 7 lines

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

Reviewed-by on v2 1/1
#2 lore raw
In reply to FUJITA Tomonori
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_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
index 729776086879..abecd95b0c3c 100644
@@ -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

#3 lore raw
In reply to FUJITA Tomonori
Quoted 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_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 +0 -0
index 729776086879..abecd95b0c3c 100644

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

#4 lore raw
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
index 729776086879..abecd95b0c3c 100644
@@ -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 -1
 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.

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.

#5 lore raw

Hello,

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
index 729776086879..abecd95b0c3c 100644
@@ -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 -1
 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.

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
index 729776086879..4cc2911a0673 100644
@@ -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

#6 lore raw
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
index 729776086879..4cc2911a0673 100644
@@ -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.