Skip to contentSkip to conversation

timer: dw-apb: Add missing 64bit up-conversion

PATCH New Marek Vasut 2 participants 4 messages Apr 10, 2019 – Apr 11, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 timer: dw-apb: Add missing 64bit up-conversion

The generic timer count is an incrementing 64bit value and a timer driver must return an incrementing 64bit value. The DW APB timer only provides a 32bit timer counting down, thus the result must be inverted and converted to a 64bit value. The current implementation is however missing the 64bit up-conversion and this results in random timer roll-overs, which in turn triggers random timeouts throughout the codebase.

This patch adds the missing 64bit up-conversion to fix the issue.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Ley Foon Tan <[email protected]>
Cc Simon Goldschmidt <[email protected]>
Cc Tien Fong Chee <[email protected]>
---
 drivers/timer/dw-apb-timer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/timer/dw-apb-timer.c +1 -1
index 085bfb02c5..cb48801af1 100644
@@ -32,7 +32,7 @@ static int dw_apb_timer_get_count(struct udevice *dev, u64 *count)
 	 * requires the count to be incrementing. Invert the
 	 * result.
 	 */
-	*count = ~readl(priv->regs + DW_APB_CURR_VAL);
+	*count = timer_conv_64(~readl(priv->regs + DW_APB_CURR_VAL));
 
 	return 0;
 }
Signature · 1 line
2.20.1
#1 lore raw

PATCH 1/1 timer: dw-apb: Add missing 64bit up-conversion

Quoted 8 lines · Marek Vasut

The generic timer count is an incrementing 64bit value and a timer driver must return an incrementing 64bit value. The DW APB timer only provides a 32bit timer counting down, thus the result must be inverted and converted to a 64bit value. The current implementation is however missing the 64bit up-conversion and this results in random timer roll-overs, which in turn triggers random timeouts throughout the codebase.

Quoted 8 lines

This patch adds the missing 64bit up-conversion to fix the issue.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Ley Foon Tan <[email protected]>
Cc Simon Goldschmidt <[email protected]>
Cc Tien Fong Chee <[email protected]>
Quoted 20 lines
---
 drivers/timer/dw-apb-timer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/timer/dw-apb-timer.c +1 -2
index 085bfb02c5..cb48801af1 100644
@@ -32,7 +32,7 @@ static int dw_apb_timer_get_count(struct udevice *dev, u64 *count)
         * requires the count to be incrementing. Invert the
         * result.
         */
-       *count = ~readl(priv->regs + DW_APB_CURR_VAL);
+       *count = timer_conv_64(~readl(priv->regs + DW_APB_CURR_VAL));
 
        return 0;
 }
--

2.20.1

#2 lore raw

PATCH 1/1 timer: dw-apb: Add missing 64bit up-conversion

Quoted 11 lines · Simon Goldschmidt
Quoted 10 lines · Marek Vasut

The generic timer count is an incrementing 64bit value and a timer driver must return an incrementing 64bit value. The DW APB timer only provides a 32bit timer counting down, thus the result must be inverted and converted to a 64bit value. The current implementation is however missing the 64bit up-conversion and this results in random timer roll-overs, which in turn triggers random timeouts throughout the codebase.

This patch adds the missing 64bit up-conversion to fix the issue.

Quoted 8 lines
Quoted 6 lines
Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Ley Foon Tan <[email protected]>
Cc Simon Goldschmidt <[email protected]>
Cc Tien Fong Chee <[email protected]>

Maybe it's time to convert Gen5 to this timer driver too :)

Signature · 2 lines
Best regards,
Marek Vasut
#3 lore raw

PATCH 1/1 timer: dw-apb: Add missing 64bit up-conversion

Quoted 20 lines · Marek Vasut
Quoted 18 lines · Simon Goldschmidt
Quoted 16 lines · Marek Vasut

The generic timer count is an incrementing 64bit value and a timer driver must return an incrementing 64bit value. The DW APB timer only provides a 32bit timer counting down, thus the result must be inverted and converted to a 64bit value. The current implementation is however missing the 64bit up-conversion and this results in random timer roll-overs, which in turn triggers random timeouts throughout the codebase.

This patch adds the missing 64bit up-conversion to fix the issue.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Ley Foon Tan <[email protected]>
Cc Simon Goldschmidt <[email protected]>
Cc Tien Fong Chee <[email protected]>
Quoted 3 lines
Quoted 1 line

Maybe it's time to convert Gen5 to this timer driver too :)

Yes, well, let's see when I find the time. Converting clock and pinctrl to devicetree is on my list as well...

Regards,
Simon