clk: divider: handle integer overflow when dividing large clock rates
On 32-bit architectures, 'unsigned long' (the type used to hold clock rates, in Hz) is often only 32 bits wide. DIV_ROUND_UP() (as used in, e.g., commit b11d282d "clk: divider: fix rate calculation for fractional rates") can yield an integer overflow on clock rates that are not (by themselves) too large to fit in 32 bits, because it performs addition before the division. See for example: DIV_ROUND_UP(3000000000, 1500000000) = (3.0G + 1.5G - 1) / 1.5G = OVERFLOW / 1.5G This patch fixes such cases by always promoting the dividend to 64-bits (unsigned long long) before doing the division. While this patch does not resolve the issue with large clock rates across the common clock framework nor address the problems with doing full 64-bit arithmetic on a 32-bit architecture, it does fix some issues seen when using clock dividers on a 3GHz reference clock to produce a 1.5GHz CPU clock for an ARMv7 Brahma B15 SoC. Signed-off-by:Brian Norris <computersforpeace@gmail.com> Reference: http://lkml.kernel.org/g/20150413201433.GQ32500@ld-irv-0074 Signed-off-by:
Stephen Boyd <sboyd@codeaurora.org>
-
mentioned in commit 11bfde66
-
mentioned in commit 31829f47
-
mentioned in commit 235d2ca6
-
mentioned in commit b364e413
-
mentioned in commit 80094450
-
mentioned in commit e648c3a7
-
mentioned in commit 0e9abad9
-
mentioned in commit 70872120
-
mentioned in commit a6366097
-
mentioned in commit 6c90f925
-
mentioned in commit 5beda61d
-
mentioned in commit e1334877
-
mentioned in commit 0b7c7dbe
-
mentioned in commit 677bdf9e
-
mentioned in commit 424927a4
-
mentioned in commit 6242000b
-
mentioned in commit 6a75d63d
-
mentioned in commit efd21f5f
-
mentioned in commit 38e7c9ff
-
mentioned in commit 23541787
-
mentioned in commit b39d4ab8
-
mentioned in commit 967c2181
-
mentioned in commit e7f9b3f8
-
mentioned in commit 145bf12e
-
mentioned in commit ea53d1a6
-
mentioned in commit c03394ce
-
mentioned in commit 9ebfc6b6
-
mentioned in commit 71b28195
-
mentioned in commit 0624d612
-
mentioned in commit 4518b8d4
-
mentioned in commit 119a22cc
-
mentioned in commit b55f6968
-
mentioned in commit a30b72e2
-
mentioned in commit ed72e46f
-
mentioned in commit d1aa70c3
-
mentioned in commit 1252b295
-
mentioned in commit d5fe08c9
-
mentioned in commit 3223961d
-
mentioned in commit 6207ea3a
-
mentioned in commit 853a74ba
-
mentioned in commit 857e5431
-
mentioned in commit c77b5bc7
-
mentioned in commit b527467e
-
mentioned in commit 97e7ab69
-
mentioned in commit aad65c21
-
mentioned in commit 904bc4a2
-
mentioned in commit 1f52a1f0
-
mentioned in commit c3ab2eb6
-
mentioned in commit ddd93e8b
-
mentioned in commit 1be33d6e
-
mentioned in commit 4dfdcbe5
-
mentioned in commit 079b36bb
-
mentioned in commit 81f3db1a
-
mentioned in commit 88a8654c
-
mentioned in commit 01b8a2b7
-
mentioned in commit f44533b9
-
mentioned in commit 0806bab2
-
mentioned in commit 2ae4e3b0
-
mentioned in commit 1a37da07
-
mentioned in commit c4a9619d
-
mentioned in commit 148780b5
-
mentioned in commit ed27c9ca
-
mentioned in commit 49eab96d
-
mentioned in commit c30f5064
-
mentioned in commit 65d3c492
-
mentioned in commit 9d812f54
-
mentioned in commit 5653b86f
-
mentioned in commit 7bce8f89
-
mentioned in commit bba6ab44
-
mentioned in commit fff2f6cf
-
mentioned in commit 9234964c
-
mentioned in commit 2dc11241
-
mentioned in commit 567abd23
-
mentioned in commit 6a7ba8a0
-
mentioned in commit 1758a080
-
mentioned in commit 11bb1597
-
mentioned in commit 828b9f65
-
mentioned in commit fd4f7c59
-
mentioned in commit e5913646
-
mentioned in commit aeb7b7ad
-
mentioned in commit 8185d583
-
mentioned in commit 16b9d06c
-
mentioned in commit 1d148b73
-
mentioned in commit f6e116be
-
mentioned in commit 0dca4cc3
-
mentioned in commit 0dc59549
-
mentioned in commit af19e7c8
-
mentioned in commit 2332c9fc
-
mentioned in commit 281b86c8
-
mentioned in commit 873fd9e0
-
mentioned in commit 329168a1
-
mentioned in commit b562f48a
-
mentioned in commit 2e237756
-
mentioned in commit 18c97d6b
-
mentioned in commit f2ab1847
-
mentioned in commit 9babfe01
-
mentioned in commit 799c9dab
-
mentioned in commit 4c952b81
-
mentioned in commit 79ef0eef
-
mentioned in commit f12c7758
-
mentioned in commit 4ee6549f
-
mentioned in commit 63eb7680
-
mentioned in commit 92950ec1
-
mentioned in commit 94db87fd
-
mentioned in commit 6e396e4d
-
mentioned in commit 5c38fe04
-
mentioned in commit 9279ce39
-
mentioned in commit e88eda10
-
mentioned in commit c7ea1394
-
mentioned in commit f8a98a73
-
mentioned in commit 6026dbf7
-
mentioned in commit b1106851
-
mentioned in commit 10757024
-
mentioned in commit c97a9236
-
mentioned in commit 544d1c62
-
mentioned in commit 5eae3373
-
mentioned in commit d4251864
-
mentioned in commit 2e9102cb
-
mentioned in commit 60f817b6