Avoid build failure on veyron board
cover Avoid build failure on veyron board
I noticed that u-boot stopped building for Veyron boards since commit 533ad9dc, which may also affect other 32bit boards.
This series fixes compilation by using div_u64 operation.
I apologize for any inconvenient, this is my first patch.
Alvaro Fernando García (1):
video: avoid build failure on veyron board
drivers/video/pwm_backlight.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
Signature · 1 line
2.41.0
PATCH 1/1 video: avoid build failure on veyron board
533ad9dc avoided an overflow but causes compilation failure on 32bit boards (eg. veyron speedy)
this commit uses div_u64 which has a fallback codepath for 32bit platforms
---
drivers/video/pwm_backlight.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/video/pwm_backlight.c +5 -2
@@ -14,6 +14,7 @@#include <pwm.h> #include <asm/gpio.h> #include <linux/delay.h> +#include <linux/math64.h> #include <power/regulator.h> /**
@@ -59,12 +60,14 @@ struct pwm_backlight_priv {static int set_pwm (struct pwm_backlight_priv *priv) { +u64 width;uint duty_cycle;int ret;if (priv->period_ns) { - duty_cycle = (u64 )priv->period_ns * (priv->cur_level - priv->min_level) / - (priv->max_level - priv->min_level); + width = priv->period_ns * (priv->cur_level - priv->min_level); + duty_cycle =div_u64 (width, + (priv->max_level - priv->min_level)); ret =pwm_set_config (priv->pwm, priv->channel, priv->period_ns, duty_cycle); }else {
Signature · 1 line
2.41.0
Re: [PATCH 1/1] video: avoid build failure on veyron board
Hi,
Quoted 4 lines · Alvaro Fernando García
533ad9dcavoided an overflow but causes compilation failure on 32bit boards (eg. veyron speedy)
Quoted 8 lines
this commit uses
div_u64which has a fallback codepath for 32bit platformsSigned-off-by Alvaro Fernando García <[email protected]>---
drivers/video/pwm_backlight.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
Can you please advise which toolchain you are using and what the warning actually says? I don't see this on my board.
Quoted 31 lines
drivers/video/pwm_backlight.c +5
-3@@ -14,6 +14,7 @@#include <pwm.h> #include <asm/gpio.h> #include <linux/delay.h> +#include <linux/math64.h> #include <power/regulator.h> /** @@ -59,12 +60,14 @@ struct pwm_backlight_priv {static int set_pwm (struct pwm_backlight_priv *priv) { +u64 width;uint duty_cycle;int ret;if (priv->period_ns) { - duty_cycle = (u64 )priv->period_ns * (priv->cur_level - priv->min_level) / - (priv->max_level - priv->min_level); + width = priv->period_ns * (priv->cur_level - priv->min_level); + duty_cycle =div_u64 (width, + (priv->max_level - priv->min_level)); ret =pwm_set_config (priv->pwm, priv->channel, priv->period_ns, duty_cycle); }else { --
Quoted 2 lines
2.41.0
Regards,
Simon
Re: [PATCH 1/1] video: avoid build failure on veyron board
Hello Simon,
Quoted 55 lines · Simon Glass
Hi,
Quoted 4 lines · Alvaro Fernando García
533ad9dcavoided an overflow but causes compilation failure on 32bit boards (eg. veyron speedy)Quoted 8 lines
this commit uses
div_u64which has a fallback codepath for 32bit platformsSigned-off-by Alvaro Fernando García <[email protected]>---
drivers/video/pwm_backlight.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)Can you please advise which toolchain you are using and what the warning actually says? I don't see this on my board.
Review
Quoted 2 lines
(quoted diff) +0
-0
b/drivers/video/pwm_backlight.cQuoted 12 lines
index
46c16a8f44..aa0e292866100644drivers/video/pwm_backlight.c +1
-0@@ -14,6 +14,7 @@#include <pwm.h> #include <asm/gpio.h> #include <linux/delay.h> +#include <linux/math64.h> #include <power/regulator.h> /** drivers/video/pwm_backlight.c struct pwm_backlight_priv { · line 66
Quoted 9 lines
drivers/video/pwm_backlight.c +1
-1@@ -59,12 +60,14 @@ struct pwm_backlight_priv {static int set_pwm (struct pwm_backlight_priv *priv) { +u64 width;uint duty_cycle;int ret;if (priv->period_ns) { - duty_cycle = (u64)priv->period_ns * (priv->cur_level -
priv->min_level) /drivers/video/pwm_backlight.c struct pwm_backlight_priv { · line 68
Quoted 2 lines
drivers/video/pwm_backlight.c +1
-1- (priv->max_level - priv->min_level); + width = priv->period_ns * (priv->cur_level -
priv->min_level);drivers/video/pwm_backlight.c struct pwm_backlight_priv { · line 70
Quoted 2 lines
drivers/video/pwm_backlight.c +2
-0+ duty_cycle = div_u64(width, + (priv->max_level -
priv->min_level));drivers/video/pwm_backlight.c struct pwm_backlight_priv { · line 71
Quoted 1 line
drivers/video/pwm_backlight.c +0
-0ret = pwm_set_config(priv->pwm, priv->channel,
priv->period_ns,
Quoted 9 lines
Quoted 5 lines
drivers/video/pwm_backlight.c +0
-1duty_cycle); }else { --2.41.0
Regards,
Simon
I built U-Boot on a Debian Bookworm container following these steps:
make distclean
Quoted 2 lines
make
chromebook_speedy_defconfig
make -j8
Container is using these gcc and linker versions:
# gcc --version
Quoted 1 line
gcc (Debian 12.2.0-14) 12.2.0
# ld --version
Quoted 1 line
GNU ld (GNU Binutils for Debian) 2.40
The error I was getting before the patch is this one:
ld.bfd: error: /usr/lib/gcc/arm-linux-gnueabihf/12/libgcc.a(_udivmoddi4.o)
Quoted 8 lines
uses VFP register arguments, u-boot does not
ld.bfd: warning:
/usr/lib/gcc/arm-linux-gnueabihf/12/libgcc.a(_udivmoddi4.o) uses 4-bytewchar_tyet the output is to use 2-bytewchar_t; use ofwchar_tvalues across objects may fail
ld.bfd: failed to merge target specific data of file /usr/lib/gcc/arm-linux-gnueabihf/12/libgcc.a(_udivmoddi4.o)
make: *** [Makefile:1764: u-boot] Error 1
Please do tell me if there is any other information I can provide.
Signature · 2 lines
Alvaro F. García Functional-oriented Software Architect
Re: [PATCH 1/1] video: avoid build failure on veyron board
Hi Alvaro,
Quoted 84 lines · Alvaro Fernando García
Hello Simon,
Quoted 44 lines · Simon Glass
Hi,
Quoted 4 lines · Alvaro Fernando García
533ad9dcavoided an overflow but causes compilation failure on 32bit boards (eg. veyron speedy)Quoted 8 lines
this commit uses
div_u64which has a fallback codepath for 32bit platformsSigned-off-by Alvaro Fernando García <[email protected]>---
drivers/video/pwm_backlight.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)Can you please advise which toolchain you are using and what the warning actually says? I don't see this on my board.
Quoted 21 lines
drivers/video/pwm_backlight.c +2
-0@@ -14,6 +14,7 @@#include <pwm.h> #include <asm/gpio.h> #include <linux/delay.h> +#include <linux/math64.h> #include <power/regulator.h> /** @@ -59,12 +60,14 @@ struct pwm_backlight_priv {static int set_pwm (struct pwm_backlight_priv *priv) { +u64 width;uint duty_cycle;int ret;Quoted 15 lines
Quoted 10 lines
drivers/video/pwm_backlight.c +3
-3if (priv->period_ns) { - duty_cycle = (u64 )priv->period_ns * (priv->cur_level - priv->min_level) / - (priv->max_level - priv->min_level); + width = priv->period_ns * (priv->cur_level - priv->min_level); + duty_cycle =div_u64 (width, + (priv->max_level - priv->min_level)); ret =pwm_set_config (priv->pwm, priv->channel, priv->period_ns, duty_cycle); }else { --Quoted 2 lines
2.41.0
Regards,
SimonI built U-Boot on a Debian Bookworm container following these steps:
Quoted 3 lines
make distclean
makechromebook_speedy_defconfig
make -j8Container is using these gcc and linker versions:
Quoted 6 lines
# gcc --version gcc (Debian 12.2.0-14) 12.2.0# ld --version GNU ld (GNU Binutils for Debian) 2.40The error I was getting before the patch is this one:
Quoted 7 lines
Quoted 4 lines
ld.bfd: error: /usr/lib/gcc/arm-linux-gnueabihf/12/libgcc.a(_udivmoddi4.o) uses VFP register arguments, u-boot does not
ld.bfd: warning: /usr/lib/gcc/arm-linux-gnueabihf/12/libgcc.a(_udivmoddi4.o) uses 4-bytewchar_tyet the output is to use 2-bytewchar_t; use ofwchar_tvalues across objects may fail ld.bfd: failed to merge target specific data of file /usr/lib/gcc/arm-linux-gnueabihf/12/libgcc.a(_udivmoddi4.o)
make: *** [Makefile:1764: u-boot] Error 1Please do tell me if there is any other information I can provide.
OK, thank you.
Regards,
Simon
Re: [PATCH 1/1] video: avoid build failure on veyron board
In reply to Alvaro Fernando GarcíaQuoted 7 lines · Alvaro Fernando García
533ad9dcavoided an overflow but causes compilation failure on 32bit boards (eg. veyron speedy)this commit uses
div_u64which has a fallback codepath for 32bit platformsSigned-off-by Alvaro Fernando García <[email protected]>
Thanks,
- Kever
Quoted 34 lines
---
drivers/video/pwm_backlight.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)drivers/video/pwm_backlight.c +5
-2@@ -14,6 +14,7 @@#include <pwm.h> #include <asm/gpio.h> #include <linux/delay.h> +#include <linux/math64.h> #include <power/regulator.h> /** @@ -59,12 +60,14 @@ struct pwm_backlight_priv {static int set_pwm (struct pwm_backlight_priv *priv) { +u64 width;uint duty_cycle;int ret;if (priv->period_ns) { - duty_cycle = (u64 )priv->period_ns * (priv->cur_level - priv->min_level) / - (priv->max_level - priv->min_level); + width = priv->period_ns * (priv->cur_level - priv->min_level); + duty_cycle =div_u64 (width, + (priv->max_level - priv->min_level)); ret =pwm_set_config (priv->pwm, priv->channel, priv->period_ns, duty_cycle); }else {