drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c:397 mlx5_ptp_freq_adj_real_time() warn: always true condition '(scaled_ppm <= (((~0) >> 1))) => (s32min-s32max <= s32max)'

From: kernel test robot
Date: Mon Dec 30 2024 - 08:35:58 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: fc033cf25e612e840e545f8d5ad2edd6ba613ed5
commit: 78c1b26754d9df062c3c8e08f5d6427967e3ba4b net/mlx5: Convert scaled ppm values outside the s32 range for PHC frequency adjustments
date: 1 year, 2 months ago
config: xtensa-randconfig-r073-20241229 (https://download.01.org/0day-ci/archive/20241230/202412302112.rtTcbfVd-lkp@xxxxxxxxx/config)
compiler: xtensa-linux-gcc (GCC) 14.2.0

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202412302112.rtTcbfVd-lkp@xxxxxxxxx/

New smatch warnings:
drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c:397 mlx5_ptp_freq_adj_real_time() warn: always true condition '(scaled_ppm <= (((~0) >> 1))) => (s32min-s32max <= s32max)'
drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c:397 mlx5_ptp_freq_adj_real_time() warn: always true condition '(scaled_ppm >= ((-(((~0) >> 1)) - 1))) => (s32min-s32max >= s32min)'

Old smatch warnings:
arch/xtensa/include/asm/thread_info.h:97 current_thread_info() warn: inconsistent indenting

vim +397 drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c

389
390 static int mlx5_ptp_freq_adj_real_time(struct mlx5_core_dev *mdev, long scaled_ppm)
391 {
392 u32 in[MLX5_ST_SZ_DW(mtutc_reg)] = {};
393
394 MLX5_SET(mtutc_reg, in, operation, MLX5_MTUTC_OPERATION_ADJUST_FREQ_UTC);
395
396 if (MLX5_CAP_MCAM_FEATURE(mdev, mtutc_freq_adj_units) &&
> 397 scaled_ppm <= S32_MAX && scaled_ppm >= S32_MIN) {
398 /* HW scaled_ppm support on mlx5 devices only supports a 32-bit value */
399 MLX5_SET(mtutc_reg, in, freq_adj_units,
400 MLX5_MTUTC_FREQ_ADJ_UNITS_SCALED_PPM);
401 MLX5_SET(mtutc_reg, in, freq_adjustment, (s32)scaled_ppm);
402 } else {
403 MLX5_SET(mtutc_reg, in, freq_adj_units, MLX5_MTUTC_FREQ_ADJ_UNITS_PPB);
404 MLX5_SET(mtutc_reg, in, freq_adjustment, scaled_ppm_to_ppb(scaled_ppm));
405 }
406
407 return mlx5_set_mtutc(mdev, in, sizeof(in));
408 }
409

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki