linux/drivers
James Clark 9ca4ba2425 net: macb: fix ordering around PTP timestamp read
PTP_SYS_OFFSET_EXTENDED returns system timestamps that do not correctly
bracket the PHC register read on MACB/GEM. On a Raspberry Pi 5, the
returned interval can be as short as 37 ns, while an ordered register
read takes approximately 1 us. This biases the midpoint used by phc2sys,
causing CLOCK_REALTIME to run approximately 0.5 us ahead when synchronized
to the PHC.

gem_tsu_get_time() reads the nanoseconds register using the driver's
relaxed MMIO accessor. On weakly ordered systems, the subsequent system
timestamp can be taken before the register read completes. The internal
smp_rmb() in the pre-timestamp path also does not guarantee ordering
against the subsequent MMIO read.

Add rmb() before and after the bracketed nanoseconds read in both the
normal and seconds rollover paths so the system timestamps bracket the
PHC read. Adding the post-read barrier increases the minimum interval on
the same Raspberry Pi 5 to approximately 1 us.

Fixes: e51bb5c278 ("net: macb: ptp: Switch to gettimex64() interface")
Tested-by: Nicolai Buchwitz <nb@tipi-net.de> # Raspberry Pi CM5, min bracket 37 ns -> 981 ns
Reviewed-by: Nicolai Buchwitz <nb@tipi-net.de>
Reviewed-by: Théo Lebrun <theo.lebrun@bootlin.com>
Assisted-by: LLM
Signed-off-by: James Clark <jjc@jclark.com>
Link: https://patch.msgid.link/20260915045823.76100-1-jjc@jclark.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2026-09-17 14:25:52 +02:00
..
accel kmalloc_obj conversions for v7.3-rc2 2026-09-05 20:45:18 -07:00
accessibility
acpi treewide: refresh kmalloc_obj() conversions 2026-09-04 21:37:00 -07:00
amba
android Char/Misc/IIO/etc driver update for 7.3-rc1 2026-08-25 09:38:50 -07:00
ata ata: libata-scsi: do not raise UA for storage element depopulation and restoration 2026-09-03 16:10:44 +02:00
atm
auxdisplay auxdisplay for v7.3-1 2026-08-24 08:15:59 -07:00
base kmalloc_obj conversions for v7.3-rc2 2026-09-05 20:45:18 -07:00
bcma
block kmalloc_obj conversions for v7.3-rc2 2026-09-05 20:45:18 -07:00
bluetooth Bluetooth: btintel_pcie: fix off-by-one bounds check in RX submit 2026-09-15 14:55:27 -04:00
bus Char/Misc/IIO/etc driver update for 7.3-rc1 2026-08-25 09:38:50 -07:00
cache
cdrom
cdx
char virtio_console: do not free control-out buffers on remove 2026-09-07 18:54:02 -04:00
clk treewide: refresh kmalloc_obj() conversions 2026-09-04 21:37:00 -07:00
clocksource hyperv-next for v7.3-rc1 2026-08-26 16:47:40 -07:00
comedi
connector
counter Char/Misc/IIO/etc driver update for 7.3-rc1 2026-08-25 09:38:50 -07:00
cpufreq treewide: refresh kmalloc_obj() conversions 2026-09-04 21:37:00 -07:00
cpuidle cpuidle: dt_idle_genpd: kfree() the original name allocation 2026-09-01 17:28:56 +02:00
crypto treewide: refresh kmalloc_obj() conversions 2026-09-04 21:37:00 -07:00
cxl
dax mm.git review status for mm-hotfixes-stable..mm-stable 2026-08-20 18:17:08 -07:00
dca
devfreq treewide: refresh kmalloc_obj() conversions 2026-09-04 21:37:00 -07:00
dibs dibs: Unregister dibs_class after error 2026-09-04 16:12:24 -07:00
dio
dma treewide: refresh kmalloc_obj() conversions 2026-09-04 21:37:00 -07:00
dma-buf kmalloc_obj conversions for v7.3-rc2 2026-09-05 20:45:18 -07:00
dpll Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2026-08-18 10:42:41 -07:00
edac treewide: refresh kmalloc_obj() conversions 2026-09-04 21:37:00 -07:00
eisa
extcon
firewire firewire updates for v7.3 2026-08-22 08:41:28 -07:00
firmware treewide: refresh kmalloc_obj() conversions 2026-09-04 21:37:00 -07:00
fpga treewide: refresh kmalloc_obj() conversions 2026-09-04 21:37:00 -07:00
fsi
fwctl rust: introduce abstractions for fwctl 2026-08-14 19:21:17 -03:00
gnss
gpib Char/Misc/IIO/etc driver update for 7.3-rc1 2026-08-25 09:38:50 -07:00
gpio treewide: refresh kmalloc_obj() conversions 2026-09-04 21:37:00 -07:00
gpu kmalloc_obj conversions for v7.3-rc2 2026-09-05 20:45:18 -07:00
greybus
hid treewide: refresh kmalloc_obj() conversions 2026-09-04 21:37:00 -07:00
hsi HSI changes for the 7.3 series 2026-08-21 12:01:23 -07:00
hte
hv treewide: refresh kmalloc_obj() conversions 2026-09-04 21:37:00 -07:00
hwmon treewide: refresh kmalloc_obj() conversions 2026-09-04 21:37:00 -07:00
hwspinlock
hwtracing treewide: refresh kmalloc_obj() conversions 2026-09-04 21:37:00 -07:00
i2c treewide: refresh kmalloc_obj() conversions 2026-09-04 21:37:00 -07:00
i3c treewide: refresh kmalloc_obj() conversions 2026-09-04 21:37:00 -07:00
idle
iio treewide: refresh kmalloc_obj() conversions 2026-09-04 21:37:00 -07:00
infiniband treewide: refresh kmalloc_obj() conversions 2026-09-04 21:37:00 -07:00
input treewide: refresh kmalloc_obj() conversions 2026-09-04 21:37:00 -07:00
interconnect This pull request contains the following interconnect updates for 2026-08-19 09:55:37 +02:00
iommu treewide: refresh kmalloc_obj() conversions 2026-09-04 21:37:00 -07:00
ipack Char/Misc/IIO/etc driver update for 7.3-rc1 2026-08-25 09:38:50 -07:00
irqchip Miscellaneous IRQ subsystem fixes: 2026-09-06 10:35:24 -07:00
leds LEDs for v7.3 2026-08-27 11:05:51 -07:00
macintosh
mailbox treewide: refresh kmalloc_obj() conversions 2026-09-04 21:37:00 -07:00
mcb
md treewide: refresh kmalloc_obj() conversions 2026-09-04 21:37:00 -07:00
media treewide: refresh kmalloc_obj() conversions 2026-09-04 21:37:00 -07:00
memory * Raw NAND changes 2026-08-23 09:11:21 -07:00
memstick
message
mfd treewide: refresh kmalloc_obj() conversions 2026-09-04 21:37:00 -07:00
misc Merge drm/drm-fixes into drm-misc-fixes 2026-09-01 09:38:51 +02:00
mmc MMC core: 2026-08-21 11:58:08 -07:00
most
mtd treewide: refresh kmalloc_obj() conversions 2026-09-04 21:37:00 -07:00
mux
net net: macb: fix ordering around PTP timestamp read 2026-09-17 14:25:52 +02:00
nfc Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2026-08-18 10:42:41 -07:00
ntb NTB: ntb_transport: Reject oversized TX buffers 2026-08-20 13:43:24 -07:00
nubus
nvdimm treewide: refresh kmalloc_obj() conversions 2026-09-04 21:37:00 -07:00
nvme kmalloc_obj conversions for v7.3-rc2 2026-09-05 20:45:18 -07:00
nvmem Char/Misc/IIO/etc driver update for 7.3-rc1 2026-08-25 09:38:50 -07:00
of Devicetree fixes for v7.3, part 1: 2026-08-27 12:53:43 -07:00
opp treewide: refresh kmalloc_obj() conversions 2026-09-04 21:37:00 -07:00
parisc parisc: eisa: Fix infinite loop when parsing invalid IRQ value 2026-08-18 11:43:05 +02:00
parport
pci treewide: refresh kmalloc_obj() conversions 2026-09-04 21:37:00 -07:00
pcmcia
peci
perf RISC-V updates for v7.3 2026-08-20 14:53:54 -07:00
phy Mostly the usual clk driver updates and new SoC additions plus non-critical 2026-08-26 11:14:30 -07:00
pinctrl Pin control bulk changes for kernel v7.3 2026-08-24 08:46:03 -07:00
platform treewide: refresh kmalloc_obj() conversions 2026-09-04 21:37:00 -07:00
pmdomain treewide: refresh kmalloc_obj() conversions 2026-09-04 21:37:00 -07:00
pnp
power treewide: refresh kmalloc_obj() conversions 2026-09-04 21:37:00 -07:00
powercap More power management updates for 7.3-rc1 2026-08-26 14:13:26 -07:00
pps
ps3
ptp treewide: refresh kmalloc_obj() conversions 2026-09-04 21:37:00 -07:00
pwm Driver core changes for 7.3-rc1 2026-08-19 10:42:18 -07:00
rapidio
ras - Mark the mpc85xx and ThunderX EDAC drivers as orphaned due to lack of 2026-08-31 20:10:39 -07:00
regulator regulator: Fix for v7.3 2026-08-27 12:21:56 -07:00
remoteproc
resctrl arm64 updates for 7.3 2026-08-18 11:57:17 -07:00
reset Mostly the usual clk driver updates and new SoC additions plus non-critical 2026-08-26 11:14:30 -07:00
rpmsg
rtc RTC for 7.3 2026-08-28 09:53:43 -07:00
s390 Nothing too exciting, usual stream of fixes. 2026-09-10 14:07:48 -07:00
sbus
scsi kmalloc_obj conversions for v7.3-rc2 2026-09-05 20:45:18 -07:00
sh
siox
slimbus
soc treewide: refresh kmalloc_obj() conversions 2026-09-04 21:37:00 -07:00
soundwire soundwire updates for 7.3 2026-08-24 12:16:16 -07:00
spi treewide: refresh kmalloc_obj() conversions 2026-09-04 21:37:00 -07:00
spmi
ssb
staging Staging driver fixes for 7.3-rc2 2026-09-06 09:49:06 -07:00
target scsi: target: iscsi: Reserve a terminator byte for the login payload 2026-09-01 22:08:31 -04:00
tc
tee treewide: refresh kmalloc_obj() conversions 2026-09-04 21:37:00 -07:00
thermal MFD for v7.3 2026-08-27 10:45:08 -07:00
thunderbolt treewide: refresh kmalloc_obj() conversions 2026-09-04 21:37:00 -07:00
tty treewide: refresh kmalloc_obj() conversions 2026-09-04 21:37:00 -07:00
ufs kmalloc_obj conversions for v7.3-rc2 2026-09-05 20:45:18 -07:00
uio
usb USB fixes for 7.3-rc2 2026-09-06 08:50:20 -07:00
vdpa vduse: return compat ioctl results directly 2026-09-08 03:58:27 -04:00
vfio mm.git review status for mm-hotfixes-stable..mm-stable 2026-08-20 18:17:08 -07:00
vhost vhost: invalidate vring access on IOTLB transitions 2026-09-07 18:54:04 -04:00
video Backlight for v7.3 2026-08-27 11:16:39 -07:00
virt arm64 updates for 7.3 2026-08-18 11:57:17 -07:00
virtio virtio_input: stop callbacks before unregistering input device 2026-09-07 18:54:04 -04:00
w1
watchdog watchdog: msc313e: Sync timeout value if WDT was running at boot 2026-09-09 14:18:25 -07:00
xen treewide: refresh kmalloc_obj() conversions 2026-09-04 21:37:00 -07:00
zorro
Kconfig
Makefile