ARM: global_data: make tbl long long
PATCH 1/1 ARM: global_data: make tbl long long
From: Dirk Behme <[email protected]>
Several ARM timer implementations use gd->arch.tbl to record the absolute tick count of 32-bit counters, including timer overflows. For example arch/arm/imx-common/timer.c does:
ulong lastinc;
ulong now = counter value;
if (no overflow) {
...
} else { /* counter overflow */
gd->arch.tbl += (0xFFFFFFFF - lastinc) + now;
}lastinc = now;
As we use a 32-bit counter and the two ulong (32-bit) variables 'lastinc' and 'now' here, gd->arch.tbl should be long long (64-bit) to not overflow at the same time, too.
--- arch/arm/include/asm/global_data.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/include/asm/global_data.h +1 -1
@@ -41,7 +41,7 @@ struct arch_global_data {/* "static data" needed by most of timer.c on ARM platforms */ unsigned long timer_rate_hz;unsigned long tbu; -unsigned long tbl; +unsigned long long tbl;unsigned long lastinc;unsigned long long timer_reset_value;#ifdef CONFIG_IXP425
Signature · 1 line
1.7.10.4
PATCH 1/1 ARM: global_data: make tbl long long
Dear Dirk Behme,
Quoted 13 lines · In message <[email protected]> you…
From: Dirk Behme <[email protected]>
Several ARM timer implementations use
gd->arch.tblto record the absolute tick count of 32-bit counters, including timer overflows. For examplearch/arm/imx-common/timer.cdoes:ulong lastinc;
ulong now = counter value;if (no overflow) { ... } else { /* counter overflow */ gd->arch.tbl += (0xFFFFFFFF - lastinc) + now; }
Quoted 5 lines
lastinc = now;
As we use a 32-bit counter and the two ulong (32-bit) variables 'lastinc' and 'now' here,
gd->arch.tblshould be long long (64-bit) to not overflow at the same time, too.
I think this is wrong.
"tbl" means "time base, lower 32 bits" and is complemented by "tbu" (time base, upper 32 bits) to form a 64 bit time base counter.
If you need the full 64 bit precision, then please either maintain the carry manually, or use a proper union or similar.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de A consultant is a person who borrows your watch, tells you what time it is, pockets the watch, and sends you a bill for it.
PATCH 1/1 ARM: global_data: make tbl long long
Dear Wolfgang,
Quoted 22 lines · Wolfgang Denk
Dear Dirk Behme,
Quoted 13 lines · In message <[email protected]> you…
From: Dirk Behme <[email protected]>
Several ARM timer implementations use
gd->arch.tblto record the absolute tick count of 32-bit counters, including timer overflows. For examplearch/arm/imx-common/timer.cdoes:ulong lastinc;
ulong now = counter value;if (no overflow) { ... } else { /* counter overflow */ gd->arch.tbl += (0xFFFFFFFF - lastinc) + now; }Quoted 5 lines
lastinc = now;
As we use a 32-bit counter and the two ulong (32-bit) variables 'lastinc' and 'now' here,
gd->arch.tblshould be long long (64-bit) to not overflow at the same time, too.
Quoted 7 lines
I think this is wrong.
"tbl" means "time base, lower 32 bits" and is complemented by "tbu" (time base, upper 32 bits) to form a 64 bit time base counter.
If you need the full 64 bit precision, then please either maintain the carry manually, or use a proper union or similar.
Many thanks for this explanation!
This patch is obsolete now, replaced by
http://patchwork.ozlabs.org/patch/224740/
Thanks
Dirk
PATCH 1/1 ARM: global_data: make tbl long long
Dear Dirk,
Quoted 2 lines · In message <[email protected]> you wrote:
Many thanks for this explanation!
You are welcome...
Quoted 3 lines
This patch is obsolete now, replaced by
Thanks, looks good to me. I hesitate to add an Acked-by: or even
Reviewed-by: as this timer stuff on ARM is a bit of black magic to me...
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Unix: Some say the learning curve is steep, but you only have to climb it once. - Karl Lehenbauer