linux-aspeed.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] watchdog: aspeed: fix 64-bit division
@ 2025-03-14 16:02 Arnd Bergmann
  2025-03-14 17:37 ` Guenter Roeck
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Arnd Bergmann @ 2025-03-14 16:02 UTC (permalink / raw)
  To: Wim Van Sebroeck, Guenter Roeck, Joel Stanley, Andrew Jeffery,
	Chin-Ting Kuo
  Cc: Arnd Bergmann, linux-watchdog, linux-arm-kernel, linux-aspeed,
	linux-kernel

From: Arnd Bergmann <arnd@arndb.de>

On 32-bit architectures, the new calculation causes a build failure:

ld.lld-21: error: undefined symbol: __aeabi_uldivmod

Since neither value is ever larger than a register, cast both
sides into a uintptr_t.

Fixes: 5c03f9f4d362 ("watchdog: aspeed: Update bootstatus handling")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/watchdog/aspeed_wdt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/watchdog/aspeed_wdt.c b/drivers/watchdog/aspeed_wdt.c
index 369635b38ca0..837e15701c0e 100644
--- a/drivers/watchdog/aspeed_wdt.c
+++ b/drivers/watchdog/aspeed_wdt.c
@@ -254,7 +254,7 @@ static void aspeed_wdt_update_bootstatus(struct platform_device *pdev,
 
 	if (!of_device_is_compatible(pdev->dev.of_node, "aspeed,ast2400-wdt")) {
 		res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-		idx = ((intptr_t)wdt->base & 0x00000fff) / resource_size(res);
+		idx = ((intptr_t)wdt->base & 0x00000fff) / (uintptr_t)resource_size(res);
 	}
 
 	scu_base = syscon_regmap_lookup_by_compatible(scu.compatible);
-- 
2.39.5



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

* Re: [PATCH] watchdog: aspeed: fix 64-bit division
  2025-03-14 16:02 [PATCH] watchdog: aspeed: fix 64-bit division Arnd Bergmann
@ 2025-03-14 17:37 ` Guenter Roeck
  2025-03-14 17:39   ` Arnd Bergmann
  2025-03-14 17:55 ` Guenter Roeck
  2025-03-18  0:30 ` Andrew Jeffery
  2 siblings, 1 reply; 6+ messages in thread
From: Guenter Roeck @ 2025-03-14 17:37 UTC (permalink / raw)
  To: Arnd Bergmann, Wim Van Sebroeck, Joel Stanley, Andrew Jeffery,
	Chin-Ting Kuo
  Cc: Arnd Bergmann, linux-watchdog, linux-arm-kernel, linux-aspeed,
	linux-kernel

On 3/14/25 09:02, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> On 32-bit architectures, the new calculation causes a build failure:
> 
> ld.lld-21: error: undefined symbol: __aeabi_uldivmod
> 
> Since neither value is ever larger than a register, cast both
> sides into a uintptr_t.
> 
> Fixes: 5c03f9f4d362 ("watchdog: aspeed: Update bootstatus handling")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>   drivers/watchdog/aspeed_wdt.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/watchdog/aspeed_wdt.c b/drivers/watchdog/aspeed_wdt.c
> index 369635b38ca0..837e15701c0e 100644
> --- a/drivers/watchdog/aspeed_wdt.c
> +++ b/drivers/watchdog/aspeed_wdt.c
> @@ -254,7 +254,7 @@ static void aspeed_wdt_update_bootstatus(struct platform_device *pdev,
>   
>   	if (!of_device_is_compatible(pdev->dev.of_node, "aspeed,ast2400-wdt")) {
>   		res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -		idx = ((intptr_t)wdt->base & 0x00000fff) / resource_size(res);
> +		idx = ((intptr_t)wdt->base & 0x00000fff) / (uintptr_t)resource_size(res);
>   	}
>   
>   	scu_base = syscon_regmap_lookup_by_compatible(scu.compatible);
Does that help if the pointers are 64-bit on a 32-bit platform (multi_v7_lpae_defconfig) ?

Guenter



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

* Re: [PATCH] watchdog: aspeed: fix 64-bit division
  2025-03-14 17:37 ` Guenter Roeck
@ 2025-03-14 17:39   ` Arnd Bergmann
  2025-03-14 17:54     ` Guenter Roeck
  0 siblings, 1 reply; 6+ messages in thread
From: Arnd Bergmann @ 2025-03-14 17:39 UTC (permalink / raw)
  To: Guenter Roeck, Arnd Bergmann, Wim Van Sebroeck, Joel Stanley,
	Andrew Jeffery, Chin-Ting Kuo
  Cc: linux-watchdog, linux-arm-kernel, linux-aspeed, linux-kernel

On Fri, Mar 14, 2025, at 18:37, Guenter Roeck wrote:
> On 3/14/25 09:02, Arnd Bergmann wrote:
>>   
>>   	if (!of_device_is_compatible(pdev->dev.of_node, "aspeed,ast2400-wdt")) {
>>   		res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>> -		idx = ((intptr_t)wdt->base & 0x00000fff) / resource_size(res);
>> +		idx = ((intptr_t)wdt->base & 0x00000fff) / (uintptr_t)resource_size(res);
>>   	}
>>   
>>   	scu_base = syscon_regmap_lookup_by_compatible(scu.compatible);
> Does that help if the pointers are 64-bit on a 32-bit platform 
> (multi_v7_lpae_defconfig) ?

Yes, that is the problem: resource_size() returns a resource_size_t,
so this is a 32-bit by 64-bit division.

Pointers are always 32-bit, CONFIG_LPAE only changes phys_addr_t
and resource_size_t.

     Arnd


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

* Re: [PATCH] watchdog: aspeed: fix 64-bit division
  2025-03-14 17:39   ` Arnd Bergmann
@ 2025-03-14 17:54     ` Guenter Roeck
  0 siblings, 0 replies; 6+ messages in thread
From: Guenter Roeck @ 2025-03-14 17:54 UTC (permalink / raw)
  To: Arnd Bergmann, Arnd Bergmann, Wim Van Sebroeck, Joel Stanley,
	Andrew Jeffery, Chin-Ting Kuo
  Cc: linux-watchdog, linux-arm-kernel, linux-aspeed, linux-kernel

On 3/14/25 10:39, Arnd Bergmann wrote:
> On Fri, Mar 14, 2025, at 18:37, Guenter Roeck wrote:
>> On 3/14/25 09:02, Arnd Bergmann wrote:
>>>    
>>>    	if (!of_device_is_compatible(pdev->dev.of_node, "aspeed,ast2400-wdt")) {
>>>    		res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>>> -		idx = ((intptr_t)wdt->base & 0x00000fff) / resource_size(res);
>>> +		idx = ((intptr_t)wdt->base & 0x00000fff) / (uintptr_t)resource_size(res);
>>>    	}
>>>    
>>>    	scu_base = syscon_regmap_lookup_by_compatible(scu.compatible);
>> Does that help if the pointers are 64-bit on a 32-bit platform
>> (multi_v7_lpae_defconfig) ?
> 
> Yes, that is the problem: resource_size() returns a resource_size_t,
> so this is a 32-bit by 64-bit division.
> 
> Pointers are always 32-bit, CONFIG_LPAE only changes phys_addr_t
> and resource_size_t.
> 
Ok. Thanks for the clarification.

Guenter




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

* Re: [PATCH] watchdog: aspeed: fix 64-bit division
  2025-03-14 16:02 [PATCH] watchdog: aspeed: fix 64-bit division Arnd Bergmann
  2025-03-14 17:37 ` Guenter Roeck
@ 2025-03-14 17:55 ` Guenter Roeck
  2025-03-18  0:30 ` Andrew Jeffery
  2 siblings, 0 replies; 6+ messages in thread
From: Guenter Roeck @ 2025-03-14 17:55 UTC (permalink / raw)
  To: Arnd Bergmann, Wim Van Sebroeck, Joel Stanley, Andrew Jeffery,
	Chin-Ting Kuo
  Cc: Arnd Bergmann, linux-watchdog, linux-arm-kernel, linux-aspeed,
	linux-kernel

On 3/14/25 09:02, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> On 32-bit architectures, the new calculation causes a build failure:
> 
> ld.lld-21: error: undefined symbol: __aeabi_uldivmod
> 
> Since neither value is ever larger than a register, cast both
> sides into a uintptr_t.
> 
> Fixes: 5c03f9f4d362 ("watchdog: aspeed: Update bootstatus handling")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Reviewed-by: Guenter Roeck <linux@roeck-us.net>

> ---
>   drivers/watchdog/aspeed_wdt.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/watchdog/aspeed_wdt.c b/drivers/watchdog/aspeed_wdt.c
> index 369635b38ca0..837e15701c0e 100644
> --- a/drivers/watchdog/aspeed_wdt.c
> +++ b/drivers/watchdog/aspeed_wdt.c
> @@ -254,7 +254,7 @@ static void aspeed_wdt_update_bootstatus(struct platform_device *pdev,
>   
>   	if (!of_device_is_compatible(pdev->dev.of_node, "aspeed,ast2400-wdt")) {
>   		res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -		idx = ((intptr_t)wdt->base & 0x00000fff) / resource_size(res);
> +		idx = ((intptr_t)wdt->base & 0x00000fff) / (uintptr_t)resource_size(res);
>   	}
>   
>   	scu_base = syscon_regmap_lookup_by_compatible(scu.compatible);



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

* Re: [PATCH] watchdog: aspeed: fix 64-bit division
  2025-03-14 16:02 [PATCH] watchdog: aspeed: fix 64-bit division Arnd Bergmann
  2025-03-14 17:37 ` Guenter Roeck
  2025-03-14 17:55 ` Guenter Roeck
@ 2025-03-18  0:30 ` Andrew Jeffery
  2 siblings, 0 replies; 6+ messages in thread
From: Andrew Jeffery @ 2025-03-18  0:30 UTC (permalink / raw)
  To: Arnd Bergmann, Wim Van Sebroeck, Guenter Roeck, Joel Stanley,
	Chin-Ting Kuo
  Cc: Arnd Bergmann, linux-watchdog, linux-arm-kernel, linux-aspeed,
	linux-kernel

On Fri, 2025-03-14 at 17:02 +0100, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> On 32-bit architectures, the new calculation causes a build failure:
> 
> ld.lld-21: error: undefined symbol: __aeabi_uldivmod
> 
> Since neither value is ever larger than a register, cast both
> sides into a uintptr_t.
> 
> Fixes: 5c03f9f4d362 ("watchdog: aspeed: Update bootstatus handling")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Reviewed-by: Andrew Jeffery <andrew@codeconstruct.com.au>

Thanks,

Andrew



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

end of thread, other threads:[~2025-03-18  0:30 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-14 16:02 [PATCH] watchdog: aspeed: fix 64-bit division Arnd Bergmann
2025-03-14 17:37 ` Guenter Roeck
2025-03-14 17:39   ` Arnd Bergmann
2025-03-14 17:54     ` Guenter Roeck
2025-03-14 17:55 ` Guenter Roeck
2025-03-18  0:30 ` Andrew Jeffery

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).