Linux-RISC-V Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] pwm: th1520: Fix 32-bit build with COMPILE_TEST
@ 2026-09-30 10:12 ` FUJITA Tomonori
  2026-09-30 10:27   ` Miguel Ojeda
                     ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: FUJITA Tomonori @ 2026-09-30 10:12 UTC (permalink / raw)
  To: fustini, guoren, ukleinek, wefu
  Cc: a.hindborg, acourbot, aliceryhl, bjorn3_gh, boqun, dakr,
	daniel.almeida, gary, linux-riscv, lossin, m.wilczynski, ojeda,
	tamird, tmgross, work, linux-pwm, rust-for-linux, FUJITA Tomonori,
	stable

From: FUJITA Tomonori <fujita.tomonori@gmail.com>

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.

Fixes: 3c180003dffb ("pwm: th1520: Fix missing Kconfig dependencies")
Cc: stable@vger.kernel.org
Reported-by: Andreas Hindborg <a.hindborg@kernel.org>
Closes: https://rust-for-linux.zulipchat.com/#narrow/channel/291565-Help/topic/64bit.20division.20in.20.60pwm_th1520.2Ers.60/near/626825599
Reviewed-by: Andreas Hindborg <a.hindborg@kernel.org>
Reviewed-by: Gary Guo <gary@garyguo.net>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
---
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/20260929095612.1072417-1-tomo@flapping.org/
---
 drivers/pwm/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig
index 729776086879..abecd95b0c3c 100644
--- a/drivers/pwm/Kconfig
+++ b/drivers/pwm/Kconfig
@@ -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
-- 
2.43.0


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] pwm: th1520: Fix 32-bit build with COMPILE_TEST
  2026-09-30 10:12 ` [PATCH v2] pwm: th1520: Fix 32-bit build with COMPILE_TEST FUJITA Tomonori
@ 2026-09-30 10:27   ` Miguel Ojeda
  2026-09-30 10:33   ` Michal Wilczynski
  2026-09-30 11:57   ` Uwe Kleine-König
  2 siblings, 0 replies; 7+ messages in thread
From: Miguel Ojeda @ 2026-09-30 10:27 UTC (permalink / raw)
  To: FUJITA Tomonori
  Cc: fustini, guoren, ukleinek, wefu, a.hindborg, acourbot, aliceryhl,
	bjorn3_gh, boqun, dakr, daniel.almeida, gary, linux-riscv, lossin,
	m.wilczynski, ojeda, tamird, tmgross, work, linux-pwm,
	rust-for-linux, FUJITA Tomonori, stable

On Wed, Sep 30, 2026 at 12:13 PM FUJITA Tomonori <tomo@flapping.org> wrote:
>
> From: FUJITA Tomonori <fujita.tomonori@gmail.com>
>
> 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.
>
> Fixes: 3c180003dffb ("pwm: th1520: Fix missing Kconfig dependencies")
> Cc: stable@vger.kernel.org
> Reported-by: Andreas Hindborg <a.hindborg@kernel.org>
> Closes: https://rust-for-linux.zulipchat.com/#narrow/channel/291565-Help/topic/64bit.20division.20in.20.60pwm_th1520.2Ers.60/near/626825599
> Reviewed-by: Andreas Hindborg <a.hindborg@kernel.org>
> Reviewed-by: Gary Guo <gary@garyguo.net>
> Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>

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

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] pwm: th1520: Fix 32-bit build with COMPILE_TEST
  2026-09-30 10:12 ` [PATCH v2] pwm: th1520: Fix 32-bit build with COMPILE_TEST FUJITA Tomonori
  2026-09-30 10:27   ` Miguel Ojeda
@ 2026-09-30 10:33   ` Michal Wilczynski
  2026-09-30 11:57   ` Uwe Kleine-König
  2 siblings, 0 replies; 7+ messages in thread
From: Michal Wilczynski @ 2026-09-30 10:33 UTC (permalink / raw)
  To: FUJITA Tomonori, fustini, guoren, ukleinek, wefu
  Cc: a.hindborg, acourbot, aliceryhl, bjorn3_gh, boqun, dakr,
	daniel.almeida, gary, linux-riscv, lossin, ojeda, tamird, tmgross,
	work, linux-pwm, rust-for-linux, FUJITA Tomonori, stable



On 9/30/26 12:12, FUJITA Tomonori wrote:
> From: FUJITA Tomonori <fujita.tomonori@gmail.com>
> 
> 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.
> 
> Fixes: 3c180003dffb ("pwm: th1520: Fix missing Kconfig dependencies")
> Cc: stable@vger.kernel.org
> Reported-by: Andreas Hindborg <a.hindborg@kernel.org>
> Closes: https://rust-for-linux.zulipchat.com/#narrow/channel/291565-Help/topic/64bit.20division.20in.20.60pwm_th1520.2Ers.60/near/626825599
> Reviewed-by: Andreas Hindborg <a.hindborg@kernel.org>
> Reviewed-by: Gary Guo <gary@garyguo.net>
> Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
> ---
> 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/20260929095612.1072417-1-tomo@flapping.org/
> ---
>  drivers/pwm/Kconfig | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig
> index 729776086879..abecd95b0c3c 100644
> --- a/drivers/pwm/Kconfig
> +++ b/drivers/pwm/Kconfig
> @@ -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

Reviewed-by: Michal Wilczynski <m.wilczynski@samsung.com>


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] pwm: th1520: Fix 32-bit build with COMPILE_TEST
  2026-09-30 10:12 ` [PATCH v2] pwm: th1520: Fix 32-bit build with COMPILE_TEST FUJITA Tomonori
  2026-09-30 10:27   ` Miguel Ojeda
  2026-09-30 10:33   ` Michal Wilczynski
@ 2026-09-30 11:57   ` Uwe Kleine-König
  2026-09-30 22:02     ` FUJITA Tomonori
  2 siblings, 1 reply; 7+ messages in thread
From: Uwe Kleine-König @ 2026-09-30 11:57 UTC (permalink / raw)
  To: FUJITA Tomonori
  Cc: fustini, guoren, wefu, a.hindborg, acourbot, aliceryhl, bjorn3_gh,
	boqun, dakr, daniel.almeida, gary, linux-riscv, lossin,
	m.wilczynski, ojeda, tamird, tmgross, work, linux-pwm,
	rust-for-linux, FUJITA Tomonori, stable


[-- Attachment #1.1: Type: text/plain, Size: 2163 bytes --]

On Wed, Sep 30, 2026 at 07:12:57PM +0900, FUJITA Tomonori wrote:
> From: FUJITA Tomonori <fujita.tomonori@gmail.com>
> 
> 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.
> 
> Fixes: 3c180003dffb ("pwm: th1520: Fix missing Kconfig dependencies")
> Cc: stable@vger.kernel.org
> Reported-by: Andreas Hindborg <a.hindborg@kernel.org>
> Closes: https://rust-for-linux.zulipchat.com/#narrow/channel/291565-Help/topic/64bit.20division.20in.20.60pwm_th1520.2Ers.60/near/626825599
> Reviewed-by: Andreas Hindborg <a.hindborg@kernel.org>
> Reviewed-by: Gary Guo <gary@garyguo.net>
> Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
> ---
> 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/20260929095612.1072417-1-tomo@flapping.org/
> ---
>  drivers/pwm/Kconfig | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig
> index 729776086879..abecd95b0c3c 100644
> --- a/drivers/pwm/Kconfig
> +++ b/drivers/pwm/Kconfig
> @@ -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

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 161 bytes --]

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] pwm: th1520: Fix 32-bit build with COMPILE_TEST
  2026-09-30 11:57   ` Uwe Kleine-König
@ 2026-09-30 22:02     ` FUJITA Tomonori
  2026-10-01  6:27       ` Uwe Kleine-König
  0 siblings, 1 reply; 7+ messages in thread
From: FUJITA Tomonori @ 2026-09-30 22:02 UTC (permalink / raw)
  To: ukleinek
  Cc: tomo, fustini, guoren, wefu, a.hindborg, acourbot, aliceryhl,
	bjorn3_gh, boqun, dakr, daniel.almeida, gary, linux-riscv, lossin,
	m.wilczynski, ojeda, tamird, tmgross, work, linux-pwm,
	rust-for-linux, fujita.tomonori, stable

On Wed, 30 Sep 2026 13:57:31 +0200
Uwe Kleine-König <ukleinek@kernel.org> wrote:

>> diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig
>> index 729776086879..abecd95b0c3c 100644
>> --- a/drivers/pwm/Kconfig
>> +++ b/drivers/pwm/Kconfig
>> @@ -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.

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.


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] pwm: th1520: Fix 32-bit build with COMPILE_TEST
  2026-09-30 22:02     ` FUJITA Tomonori
@ 2026-10-01  6:27       ` Uwe Kleine-König
  2026-10-01  9:07         ` FUJITA Tomonori
  0 siblings, 1 reply; 7+ messages in thread
From: Uwe Kleine-König @ 2026-10-01  6:27 UTC (permalink / raw)
  To: FUJITA Tomonori
  Cc: fustini, guoren, wefu, a.hindborg, acourbot, aliceryhl, bjorn3_gh,
	boqun, dakr, daniel.almeida, gary, linux-riscv, lossin,
	m.wilczynski, ojeda, tamird, tmgross, work, linux-pwm,
	rust-for-linux, fujita.tomonori, stable


[-- Attachment #1.1: Type: text/plain, Size: 1800 bytes --]

Hello,

On Thu, Oct 01, 2026 at 07:02:15AM +0900, FUJITA Tomonori wrote:
> On Wed, 30 Sep 2026 13:57:31 +0200
> Uwe Kleine-König <ukleinek@kernel.org> wrote:
> 
> >> diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig
> >> index 729776086879..abecd95b0c3c 100644
> >> --- a/drivers/pwm/Kconfig
> >> +++ b/drivers/pwm/Kconfig
> >> @@ -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.
> 
> 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

diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig
index 729776086879..4cc2911a0673 100644
--- a/drivers/pwm/Kconfig
+++ b/drivers/pwm/Kconfig
@@ -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

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 161 bytes --]

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] pwm: th1520: Fix 32-bit build with COMPILE_TEST
  2026-10-01  6:27       ` Uwe Kleine-König
@ 2026-10-01  9:07         ` FUJITA Tomonori
  0 siblings, 0 replies; 7+ messages in thread
From: FUJITA Tomonori @ 2026-10-01  9:07 UTC (permalink / raw)
  To: ukleinek
  Cc: tomo, fustini, guoren, wefu, a.hindborg, acourbot, aliceryhl,
	bjorn3_gh, boqun, dakr, daniel.almeida, gary, linux-riscv, lossin,
	m.wilczynski, ojeda, tamird, tmgross, work, linux-pwm,
	rust-for-linux, fujita.tomonori, stable

On Thu, 1 Oct 2026 08:27:45 +0200
Uwe Kleine-König <ukleinek@kernel.org> wrote:

>> > 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
> 
> diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig
> index 729776086879..4cc2911a0673 100644
> --- a/drivers/pwm/Kconfig
> +++ b/drivers/pwm/Kconfig
> @@ -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?

Yeah, it's cleaner.


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-10-01  9:07 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <CGME20260930101334eucas1p2ec64abcf499a296767711f13ad70c486@eucas1p2.samsung.com>
2026-09-30 10:12 ` [PATCH v2] pwm: th1520: Fix 32-bit build with COMPILE_TEST FUJITA Tomonori
2026-09-30 10:27   ` Miguel Ojeda
2026-09-30 10:33   ` Michal Wilczynski
2026-09-30 11:57   ` Uwe Kleine-König
2026-09-30 22:02     ` FUJITA Tomonori
2026-10-01  6:27       ` Uwe Kleine-König
2026-10-01  9:07         ` FUJITA Tomonori

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox