linux/drivers/net/ethernet/stmicro/stmmac
Alexis Lothoré 7b7491372f net: stmmac: fix multiplication overflow when reading timestamp
The current way of reading a timestamp snapshot in stmmac can lead to
integer overflow, as the computation is done on 32 bits. The issue has
been observed on a dwmac-socfpga platform returning chaotic timestamp
values due to this overflow. The corresponding multiplication is done
with a MUL instruction, which returns 32 bit values. Explicitly casting
the value to 64 bits replaced the MUL with a UMLAL, which computes and
returns the result on 64 bits, and so returns correctly the timestamps.

Prevent this overflow by explicitly casting the intermediate value to
u64 to make sure that the whole computation is made on u64. While at it,
apply the same cast on the other dwmac variant (GMAC4) method for
snapshot retrieval.

Fixes: 477c3e1f63 ("net: stmmac: Introduce dwmac1000 timestamping operations")
Signed-off-by: Alexis Lothoré <alexis.lothore@bootlin.com>
Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Link: https://patch.msgid.link/20250423-stmmac_ts-v2-2-e2cf2bbd61b1@bootlin.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2025-04-24 11:50:20 +02:00
..
Kconfig net: stmmac: Add glue layer for Sophgo SG2044 SoC 2025-03-07 19:06:36 -08:00
Makefile net: stmmac: Add glue layer for Sophgo SG2044 SoC 2025-03-07 19:06:36 -08:00
chain_mode.c
common.h net: stmmac: Correct usage of maximum queue number macros 2025-02-24 14:24:14 -08:00
descs.h
descs_com.h
dwmac-anarion.c net: stmmac: anarion: remove of_get_phy_mode() 2025-03-18 15:53:15 +01:00
dwmac-dwc-qos-eth.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2025-03-20 21:38:01 +01:00
dwmac-generic.c net: stmmac: add support for dwmac 3.72a 2024-11-05 17:45:17 -08:00
dwmac-imx.c net: stmmac: imx: use generic stmmac_set_clk_tx_rate() 2025-02-28 10:20:48 -08:00
dwmac-ingenic.c net: ethernet: Switch back to struct platform_driver::remove() 2024-10-04 16:39:56 -07:00
dwmac-intel-plat.c net: stmmac: intel: use generic stmmac_set_clk_tx_rate() 2025-02-28 10:20:47 -08:00
dwmac-intel.c stmmac: intel: interface switching support for RPL-P platform 2025-03-25 10:37:38 -07:00
dwmac-intel.h net: stmmac: configure SerDes according to the interface mode 2025-03-05 19:02:47 -08:00
dwmac-ipq806x.c net: stmmac: ipq806x: remove of_get_phy_mode() 2025-03-18 15:53:15 +01:00
dwmac-loongson.c stmmac: Replace deprecated PCI functions 2025-03-25 10:36:45 -07:00
dwmac-loongson1.c
dwmac-lpc18xx.c net: ethernet: Switch back to struct platform_driver::remove() 2024-10-04 16:39:56 -07:00
dwmac-mediatek.c net: stmmac: mediatek: remove of_get_phy_mode() 2025-03-18 15:53:15 +01:00
dwmac-meson.c net: stmmac: meson: switch to use set_clk_tx_rate() hook 2025-02-28 10:20:48 -08:00
dwmac-meson8b.c net: stmmac: meson8b: remove of_get_phy_mode() 2025-03-18 15:53:15 +01:00
dwmac-qcom-ethqos.c net: stmmac: qcom-ethqos: remove of_get_phy_mode() 2025-03-18 15:53:15 +01:00
dwmac-rk.c net: stmmac: dwmac-rk: Add initial support for RK3528 integrated PHY 2025-03-25 08:00:56 -07:00
dwmac-rzn1.c net: ethernet: Switch back to struct platform_driver::remove() 2024-10-04 16:39:56 -07:00
dwmac-s32.c net: stmmac: s32: use generic stmmac_set_clk_tx_rate() 2025-02-28 10:20:47 -08:00
dwmac-socfpga.c net: stmmac: socfpga: remove phy_resume() call 2025-03-25 07:58:04 -07:00
dwmac-sophgo.c net: stmmac: Add glue layer for Sophgo SG2044 SoC 2025-03-07 19:06:36 -08:00
dwmac-starfive.c net: stmmac: starfive: use PHY capability for TX clock stop 2025-03-19 18:06:32 +01:00
dwmac-sti.c net: stmmac: sti: remove of_get_phy_mode() 2025-03-18 15:53:15 +01:00
dwmac-stm32.c net: stmmac: stm32: use PHY capability for TX clock stop 2025-03-19 18:06:32 +01:00
dwmac-sun8i.c net: stmmac: sun8i: remove of_get_phy_mode() 2025-03-18 15:53:15 +01:00
dwmac-sunxi.c net: stmmac: sunxi: remove of_get_phy_mode() 2025-03-18 15:53:16 +01:00
dwmac-tegra.c net: stmmac: dwmac-tegra: Read iommu stream id from device tree 2025-01-09 08:20:34 -08:00
dwmac-thead.c net: stmmac: thead: switch to use set_clk_tx_rate() hook 2025-02-28 10:20:48 -08:00
dwmac-visconti.c net: stmmac: "speed" passed to fix_mac_speed is an int 2025-02-19 18:57:28 -08:00
dwmac4.h net: stmmac: use common LPI_CTRL_STATUS bit definitions 2025-02-07 11:56:10 -08:00
dwmac4_core.c net: stmmac: remove old EEE methods 2025-02-07 11:56:10 -08:00
dwmac4_descs.c net: stmmac: Add DW QoS Eth v4/v5 ip payload error statistics 2024-10-09 19:48:58 -07:00
dwmac4_descs.h net: stmmac: Relocate extern declarations in common.h and hwif.h 2024-12-10 18:24:36 -08:00
dwmac4_dma.c net: stmmac: dwmac4: Fix the MTL_OP_MODE_*_MASK operation 2024-11-11 16:45:23 -08:00
dwmac4_dma.h net: stmmac: dwmac4: Fix high address display by updating reg_space[] from register values 2024-10-29 11:29:40 +01:00
dwmac4_lib.c net: stmmac: dwmac4: Receive Watchdog Timeout is not in abnormal interrupt summary 2024-11-11 16:45:23 -08:00
dwmac5.c net: stmmac: Introduce separate files for FPE implementation 2024-11-03 15:31:23 -08:00
dwmac5.h net: stmmac: Introduce separate files for FPE implementation 2024-11-03 15:31:23 -08:00
dwmac100.h
dwmac100_core.c
dwmac100_dma.c net: stmmac: Move the atds flag to the stmmac_dma_cfg structure 2024-08-13 09:48:00 +02:00
dwmac1000.h net: stmmac: fix dwmac1000 ptp timestamp status offset 2025-04-24 11:50:20 +02:00
dwmac1000_core.c net: stmmac: fix multiplication overflow when reading timestamp 2025-04-24 11:50:20 +02:00
dwmac1000_dma.c net: stmmac: Export dwmac1000_dma_ops 2024-08-13 09:48:00 +02:00
dwmac_dma.h net: stmmac: Add multi-channel support 2024-08-13 09:48:00 +02:00
dwmac_lib.c net: stmmac: Add multi-channel support 2024-08-13 09:48:00 +02:00
dwxgmac2.h net: stmmac: use common LPI_CTRL_STATUS bit definitions 2025-02-07 11:56:10 -08:00
dwxgmac2_core.c net: stmmac: remove old EEE methods 2025-02-07 11:56:10 -08:00
dwxgmac2_descs.c net: stmmac: Batch set RX OWN flag and other flags 2024-09-05 11:19:07 +02:00
dwxgmac2_dma.c net: stmmac: Move the atds flag to the stmmac_dma_cfg structure 2024-08-13 09:48:00 +02:00
dwxlgmac2.h
enh_desc.c
hwif.c net: stmmac: Drop redundant dwxgmac_tc_ops variable 2024-12-13 19:32:29 -08:00
hwif.h net: stmmac: remove old EEE methods 2025-02-07 11:56:10 -08:00
mmc.h net: stmmac: Relocate extern declarations in common.h and hwif.h 2024-12-10 18:24:36 -08:00
mmc_core.c
norm_desc.c
ring_mode.c
stmmac.h net: stmmac: allow platforms to use PHY tx clock stop capability 2025-03-19 18:06:32 +01:00
stmmac_est.c
stmmac_est.h net: stmmac: Relocate extern declarations in common.h and hwif.h 2024-12-10 18:24:36 -08:00
stmmac_ethtool.c net: stmmac: report EEE error statistics if EEE is supported 2025-01-10 17:51:01 -08:00
stmmac_fpe.c net: stmmac: xgmac: Complete FPE support 2024-11-03 15:31:24 -08:00
stmmac_fpe.h net: stmmac: xgmac: Complete FPE support 2024-11-03 15:31:24 -08:00
stmmac_hwtstamp.c net: stmmac: fix multiplication overflow when reading timestamp 2025-04-24 11:50:20 +02:00
stmmac_main.c treewide: Switch/rename to timer_delete[_sync]() 2025-04-05 10:30:12 +02:00
stmmac_mdio.c net: stmmac: Call xpcs_config_eee_mult_fact() only when xpcs is present 2025-03-24 13:26:02 -07:00
stmmac_pci.c stmmac: Replace deprecated PCI functions 2025-03-25 10:36:45 -07:00
stmmac_pcs.h
stmmac_platform.c net: stmmac: deprecate "snps,en-tx-lpi-clockgating" property 2025-03-19 18:06:33 +01:00
stmmac_platform.h net: stmmac: unexport stmmac_pltfr_init/exit() 2024-06-20 19:29:34 -07:00
stmmac_ptp.c net: stmmac: Don't include dwmac4 definitions in stmmac_ptp 2024-11-13 18:52:13 -08:00
stmmac_ptp.h net: stmmac: Relocate extern declarations in common.h and hwif.h 2024-12-10 18:24:36 -08:00
stmmac_selftests.c net: phy: Support speed selection for PHY loopback 2025-03-20 08:45:08 +01:00
stmmac_tc.c net: stmmac: Drop redundant dwxgmac_tc_ops variable 2024-12-13 19:32:29 -08:00
stmmac_xdp.c
stmmac_xdp.h net: stmmac: Set page_pool_params.max_len to a precise size 2025-01-16 12:14:22 +01:00