wifi: iwlwifi: mvm: Use 64-bit division helper in iwl_mvm_get_crosstimestamp_fw()
authorNathan Chancellor <nathan@kernel.org>
Wed, 29 Mar 2023 17:32:46 +0000 (10:32 -0700)
committerJohannes Berg <johannes.berg@intel.com>
Thu, 30 Mar 2023 09:16:21 +0000 (11:16 +0200)
There is a 64-bit division in iwl_mvm_get_crosstimestamp_fw(), which
results in a link failure when building 32-bit architectures with clang:

  ld.lld: error: undefined symbol: __udivdi3
  >>> referenced by ptp.c
  >>>               drivers/net/wireless/intel/iwlwifi/mvm/ptp.o:(iwl_mvm_phc_get_crosstimestamp) in archive vmlinux.a

GCC has optimizations for division by a constant that clang does not
implement, so this issue is not visible when building with GCC.

Use the 64-bit division helper div_u64(), which takes a u64 dividend and
u32 divisor, which matches this situation and prevents the emission of a
libcall for the division.

Fixes: 21fb8da6ebe4 ("wifi: iwlwifi: mvm: read synced time from firmware if supported")
Reported-by: Arnd Bergmann <arnd@arndb.de>
Link: https://github.com/ClangBuiltLinux/linux/issues/1826
Reported-by: "kernelci.org bot" <bot@kernelci.org>
Link: https://lore.kernel.org/6423173a.620a0220.3d5cc.6358@mx.google.com/
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
drivers/net/wireless/intel/iwlwifi/mvm/ptp.c

index 5c2bfc8ed88d88cc5305fb71af3221256c9c11b2..e89259de6f4c3b3438fb49b989acb1410c3292ea 100644 (file)
@@ -116,7 +116,7 @@ iwl_mvm_get_crosstimestamp_fw(struct iwl_mvm *mvm, u32 *gp2, u64 *sys_time)
 
        gp2_10ns = (u64)le32_to_cpu(resp->gp2_timestamp_hi) << 32 |
                le32_to_cpu(resp->gp2_timestamp_lo);
-       *gp2 = gp2_10ns / 100;
+       *gp2 = div_u64(gp2_10ns, 100);
 
        *sys_time = (u64)le32_to_cpu(resp->platform_timestamp_hi) << 32 |
                le32_to_cpu(resp->platform_timestamp_lo);