Skip to contentSkip to conversation

drm/msm/dpu: avoid open-coded 64-bit division

PATCH In review Arnd Bergmann 2 participants 2 messages May 27, 2020 Interconnect API

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/msm/dpu: avoid open-coded 64-bit division

64-bit integer division is normally not allowed in the kernel because of the large overhead on 32-bit machines:

drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.o: in function `_dpu_core_perf_crtc_update_bus':
dpu_core_perf.c:(.text+0x810): undefined reference to `__aeabi_uldivmod'

The function already contains a call to do_div(), so I assume this is never called in a performance critical context, and we can use div_u64 for the second one as well.

Fixes 04d9044f6c57 ("drm/msm/dpu: add support for clk and bw scaling for display")
---
 include/linux/interconnect.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/interconnect.h +1 -1
index 3a63d98613fc..8279fe9b2082 100644
@@ -11,7 +11,7 @@
 #include <linux/types.h>
 
 /* macros for converting to icc units */
-#define Bps_to_icc(x)	((x) / 1000)
+#define Bps_to_icc(x)	div_u64((x), 1000)
 #define kBps_to_icc(x)	(x)
 #define MBps_to_icc(x)	((x) * 1000)
 #define GBps_to_icc(x)	((x) * 1000 * 1000)
Signature · 1 line
2.26.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Arnd Bergmann

64-bit integer division is normally not allowed in the kernel because of the large overhead on 32-bit machines:

drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.o: in function `_dpu_core_perf_crtc_update_bus':
dpu_core_perf.c:(.text+0x810): undefined reference to `__aeabi_uldivmod'

Quoted 6 lines

The function already contains a call to do_div(), so I assume this is never called in a performance critical context, and we can use div_u64 for the second one as well.

Fixes 04d9044f6c57 ("drm/msm/dpu: add support for clk and bw scaling for display")

Thanks for the patch Arnd. I just noticed this in linux-next.

Rob, could you please take it into msm-next, as the patch which triggers the issue is also there?

Thanks,
Georgi

Quoted 18 lines
---
 include/linux/interconnect.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/interconnect.h +1 -1
index 3a63d98613fc..8279fe9b2082 100644
@@ -11,7 +11,7 @@
 #include <linux/types.h>
 
 /* macros for converting to icc units */
-#define Bps_to_icc(x)	((x) / 1000)
+#define Bps_to_icc(x)	div_u64((x), 1000)
 #define kBps_to_icc(x)	(x)
 #define MBps_to_icc(x)	((x) * 1000)
 #define GBps_to_icc(x)	((x) * 1000 * 1000)