linux/drivers/ptp
Íñigo Huguet 67d93ffc0f ptp: vclock: use mutex to fix "sleep on atomic" bug
vclocks were using spinlocks to protect access to its timecounter and
cyclecounter. Access to timecounter/cyclecounter is backed by the same
driver callbacks that are used for non-virtual PHCs, but the usage of
the spinlock imposes a new limitation that didn't exist previously: now
they're called in atomic context so they mustn't sleep.

Some drivers like sfc or ice may sleep on these callbacks, causing
errors like "BUG: scheduling while atomic: ptp5/25223/0x00000002"

Fix it replacing the vclock's spinlock by a mutex. It fix the mentioned
bug and it doesn't introduce longer delays.

I've tested synchronizing various different combinations of clocks:
- vclock->sysclock
- sysclock->vclock
- vclock->vclock
- hardware PHC in different NIC -> vclock
- created 4 vclocks and launch 4 parallel phc2sys processes with
  lockdep enabled

In all cases, comparing the delays reported by phc2sys, they are in the
same range of values than before applying the patch.

Link: https://lore.kernel.org/netdev/69d0ff33-bd32-6aa5-d36c-fbdc3c01337c@redhat.com/
Fixes: 5d43f951b1 ("ptp: add ptp virtual clock driver framework")
Reported-by: Yalin Li <yalli@redhat.com>
Suggested-by: Richard Cochran <richardcochran@gmail.com>
Tested-by: Miroslav Lichvar <mlichvar@redhat.com>
Signed-off-by: Íñigo Huguet <ihuguet@redhat.com>
Acked-by: Richard Cochran <richardcochran@gmail.com>
Link: https://lore.kernel.org/r/20230221130616.21837-1-ihuguet@redhat.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2023-02-22 21:23:48 -08:00
..
Kconfig
Makefile
ptp_chardev.c
ptp_clock.c ptp: remove the .adjfreq interface function 2022-11-11 10:58:39 +00:00
ptp_clockmatrix.c
ptp_clockmatrix.h
ptp_dte.c ptp: convert remaining drivers to adjfine interface 2022-11-11 10:58:39 +00:00
ptp_idt82p33.c ptp: idt82p33: remove PEROUT_ENABLE_OUTPUT_MASK 2022-11-25 10:34:08 +00:00
ptp_idt82p33.h ptp: idt82p33: remove PEROUT_ENABLE_OUTPUT_MASK 2022-11-25 10:34:08 +00:00
ptp_ines.c
ptp_kvm_arm.c
ptp_kvm_common.c drivers: convert unsupported .adjfreq to .adjfine 2022-10-31 11:14:16 +00:00
ptp_kvm_x86.c
ptp_ocp.c net: devlink: let the core report the driver name instead of the drivers 2022-11-30 21:49:38 -08:00
ptp_pch.c ptp_phc: convert .adjfreq to .adjfine 2022-11-11 10:58:39 +00:00
ptp_private.h ptp: vclock: use mutex to fix "sleep on atomic" bug 2023-02-22 21:23:48 -08:00
ptp_qoriq_debugfs.c
ptp_qoriq.c ptp_qoriq: fix latency in ptp_qoriq_adjtime() operation 2023-01-20 18:20:38 -08:00
ptp_sysfs.c
ptp_vclock.c ptp: vclock: use mutex to fix "sleep on atomic" bug 2023-02-22 21:23:48 -08:00
ptp_vmw.c Networking changes for 6.2. 2022-12-13 15:47:48 -08:00