2

I have a desktop with a Gigabyte B650 AORUS ELITE AX motherboard, to which I've installed Ubuntu 22.04.3. I am trying to use this desktop as an IEEE-1588 (Precision Time Protocol) master, in a small local network which contains only an unmanaged switch and another device which I hope to synchronize time with.

I noticed when I went to launch ptp4l that I did not have any /dev/ptpX nodes, and after investingating with ethtool -T, I see that my interface seems to support neither hardware nor software timestamping (unless this page is incorrect, which says that my output indicates no support; either way I tried with software mode and the results were not stable enough for me to use):

$ ethtool -T enp8s0
Time stamping parameters for enp8s0:
Capabilities:
    software-transmit
    software-receive
    software-system-clock
PTP Hardware Clock: none
Hardware Transmit Timestamp Modes: none
Hardware Receive Filter Modes: none

Looking into the controller on my mobo, I find that its a RealTek RTL8125:

$ lspci | grep Ethernet
08:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8125 2.5GbE Controller (rev 05)

Which according to RealTek, I think should support PTP hardware timestamping. RealTek does provide linux drivers for this device, however the driver I need (2.5G/5G Ethernet LINUX driver r8125) is listed as 'for up to kernel version 6.4' (I am on 6.5.0). I tried build/installing that anyway and was able to after enabling PTP in the makefile, and ethtool is now showing support:

ethtool -T enp8s0
Time stamping parameters for enp8s0:
Capabilities:
    hardware-transmit
    software-transmit
    hardware-receive
    software-receive
    software-system-clock
    hardware-raw-clock
PTP Hardware Clock: 0
Hardware Transmit Timestamp Modes:
    off
    on
Hardware Receive Filter Modes:
    none
    ptpv2-l4-event
    ptpv2-l4-sync
    ptpv2-l4-delay-req
    ptpv2-event
    ptpv2-sync
    ptpv2-delay-req

However, when I try to launch ptp4l, it is killed, and I see the following in the kernel log:

$ sudo ptp4l -i enp8s0 -p /dev/ptp0 -m
ptp4l[2665.771]: selected /dev/ptp0 as PTP clock
Killed
$ sudo dmesg
...
[ 2891.569055] BUG: kernel NULL pointer dereference, address: 0000000000000000
[ 2891.569059] #PF: supervisor instruction fetch in kernel mode
[ 2891.569061] #PF: error_code(0x0010) - not-present page
[ 2891.569063] PGD 0 P4D 0 
[ 2891.569066] Oops: 0010 [#4] PREEMPT SMP NOPTI
[ 2891.569068] CPU: 19 PID: 7502 Comm: ptp4l Tainted: P      D    OE      6.5.0-15-generic #15~22.04.1-Ubuntu
[ 2891.569070] Hardware name: Gigabyte Technology Co., Ltd. B650 AORUS ELITE AX/B650 AORUS ELITE AX, BIOS FB 07/10/2023
[ 2891.569072] RIP: 0010:0x0
[ 2891.569092] Code: Unable to access opcode bytes at 0xffffffffffffffd6.
[ 2891.569094] RSP: 0018:ffffc115866d3d10 EFLAGS: 00010286
[ 2891.569096] RAX: 0000000000000000 RBX: ffff9b97039de000 RCX: 00000000071c71c7
[ 2891.569097] RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffff9b9722b20768
[ 2891.569098] RBP: ffffc115866d3d40 R08: 0000000000000000 R09: 0000000000000000
[ 2891.569099] R10: 0000000000000000 R11: 0000000000000000 R12: ffffc115866d3d98
[ 2891.569101] R13: ffff9b97039df518 R14: 0000000000000000 R15: 0000000000000000
[ 2891.569102] FS:  00007fdfdaa96740(0000) GS:ffff9ba6186c0000(0000) knlGS:0000000000000000
[ 2891.569103] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 2891.569105] CR2: ffffffffffffffd6 CR3: 000000010eb8e000 CR4: 0000000000750ee0
[ 2891.569106] PKRU: 55555554
[ 2891.569107] Call Trace:
[ 2891.569109]  <TASK>
[ 2891.569111]  ? show_regs+0x6d/0x80
[ 2891.569116]  ? __die+0x24/0x80
[ 2891.569119]  ? page_fault_oops+0x99/0x1b0
[ 2891.569123]  ? do_user_addr_fault+0x31d/0x6b0
[ 2891.569126]  ? exc_page_fault+0x83/0x1b0
[ 2891.569130]  ? asm_exc_page_fault+0x27/0x30
[ 2891.569136]  ptp_clock_adjtime+0xf5/0x230
[ 2891.569140]  pc_clock_adjtime+0x70/0xc0
[ 2891.569143]  __do_sys_clock_adjtime+0x9e/0x140
[ 2891.569149]  __x64_sys_clock_adjtime+0x15/0x20
[ 2891.569151]  do_syscall_64+0x58/0x90
[ 2891.569154]  ? srso_alias_return_thunk+0x5/0x7f
[ 2891.569157]  ? exit_to_user_mode_prepare+0x30/0xb0
[ 2891.569160]  ? srso_alias_return_thunk+0x5/0x7f
[ 2891.569162]  ? syscall_exit_to_user_mode+0x37/0x60
[ 2891.569165]  ? srso_alias_return_thunk+0x5/0x7f
[ 2891.569167]  ? do_syscall_64+0x67/0x90
[ 2891.569169]  ? srso_alias_return_thunk+0x5/0x7f
[ 2891.569171]  ? do_syscall_64+0x67/0x90
[ 2891.569173]  entry_SYSCALL_64_after_hwframe+0x6e/0xd8
[ 2891.569175] RIP: 0033:0x7fdfda92644b
[ 2891.569179] Code: 8b 15 e9 39 0f 00 f7 d8 64 89 02 48 c7 c0 ff ff ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 f3 0f 1e fa b8 31 01 00 00 0f 05 <48> 3d 00 f0 ff ff 77 05 c3 0f 1f 40 00 48 8b 15 b1 39 0f 00 f7 d8
[ 2891.569180] RSP: 002b:00007ffd99830ad8 EFLAGS: 00000286 ORIG_RAX: 0000000000000131
[ 2891.569182] RAX: ffffffffffffffda RBX: 0000556e69a442a0 RCX: 00007fdfda92644b
[ 2891.569183] RDX: 00007ffd99830d70 RSI: 00007ffd99830b00 RDI: 00000000ffffffdb
[ 2891.569185] RBP: 00000000ffffffdb R08: 0000000000000000 R09: 0000000000000000
[ 2891.569186] R10: 0000000000000000 R11: 0000000000000286 R12: 00000000071c71c7
[ 2891.569187] R13: 0000556e688c12db R14: 0000556e688ca720 R15: 0000556e688c136b
[ 2891.569190]  </TASK>
[ 2891.569191] Modules linked in: uhid rfcomm nfnetlink ccm cmac algif_hash algif_skcipher af_alg nvidia_uvm(PO) bnep intel_rapl_msr intel_rapl_common nvidia_drm(PO) snd_hda_codec_realtek edac_mce_amd snd_hda_codec_generic nvidia_modeset(PO) binfmt_misc ledtrig_audio snd_hda_codec_hdmi snd_hda_intel snd_intel_dspcfg snd_intel_sdw_acpi rtw89_8852ce snd_hda_codec rtw89_8852c snd_hda_core snd_hwdep rtw89_pci snd_pcm rtw89_core snd_seq_midi snd_seq_midi_event mac80211 kvm snd_rawmidi btusb btrtl btbcm btintel snd_seq irqbypass nvidia(PO) btmtk nls_iso8859_1 snd_seq_device rapl input_leds bluetooth ftdi_sio cdc_mbim snd_timer usbserial gigabyte_wmi cdc_wdm wmi_bmof cfg80211 ecdh_generic k10temp ccp ecc snd libarc4 soundcore mac_hid sch_fq_codel msr parport_pc ppdev lp parport efi_pstore ip_tables x_tables autofs4 dm_crypt hid_generic cdc_ncm cdc_ether usbnet mii usbhid hid amdgpu amdxcp iommu_v2 drm_buddy gpu_sched i2c_algo_bit drm_suballoc_helper drm_ttm_helper ttm drm_display_helper crct10dif_pclmul cec crc32_pclmul
[ 2891.569257]  polyval_clmulni rc_core polyval_generic ghash_clmulni_intel aesni_intel drm_kms_helper crypto_simd cryptd nvme drm ahci xhci_pci i2c_piix4 libahci xhci_pci_renesas nvme_core r8125(OE) nvme_common video wmi
[ 2891.569273] CR2: 0000000000000000
[ 2891.569276] ---[ end trace 0000000000000000 ]---
[ 2891.915705] RIP: 0010:0x0
[ 2891.915712] Code: Unable to access opcode bytes at 0xffffffffffffffd6.
[ 2891.915713] RSP: 0018:ffffc1159d207cb0 EFLAGS: 00010286
[ 2891.915715] RAX: 0000000000000000 RBX: ffff9b97039de000 RCX: 00000000071c71c7
[ 2891.915717] RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffff9b9722b20768
[ 2891.915718] RBP: ffffc1159d207ce0 R08: 0000000000000000 R09: 0000000000000000
[ 2891.915719] R10: 0000000000000000 R11: 0000000000000000 R12: ffffc1159d207d38
[ 2891.915720] R13: ffff9b97039df518 R14: 0000000000000000 R15: 0000000000000000
[ 2891.915721] FS:  00007fdfdaa96740(0000) GS:ffff9ba6186c0000(0000) knlGS:0000000000000000
[ 2891.915723] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 2891.915724] CR2: ffffffffffffffd6 CR3: 000000010eb8e000 CR4: 0000000000750ee0
[ 2891.915726] PKRU: 55555554
[ 2891.915727] note: ptp4l[7502] exited with irqs disabled

I did find another question which mentions that there is a version of this driver in apt repos: r8125-dkms which uses dkms (something I just learned of today). That version compiles without PTP support however:

$ ethtool -i enp8s0
driver: r8125
$ ethtool -T enp8s0
Time stamping parameters for enp8s0:
Capabilities:
    software-transmit
    software-receive
    software-system-clock
PTP Hardware Clock: none
Hardware Transmit Timestamp Modes: none
Hardware Receive Filter Modes: none

I tried changing the makefile in /usr/src/ and un/reinstalling using dkms, but that did not seem to change anything, although I may have gotten it wrong. the version that is in apt (9.007.01) is pretty significantly different from the version from realtek (9.012.04) and will not compile (kernel structs relating to PTP changed, among other things).

I am hoping someone can help me solve this problem at any level; be it through some ptp4l configuration or patching the driver/something else. I would really like to have hardware timestamping support, but a functional ptp synchronization is the main ask. (In software mode, I was not able to achieve offset stable under 1000ns, with may large jumps to +-100000ns)


Progress:

Still a ways off from the solution, and at risk of straying too far into stackoverflow territory, what I've found:

  • At some point, kernel struct ptp_clock_info removed adjfreq member and seem to have replaced it with adjfine
  • Driver 9.012.04 correctly does not set adjfreq but also fails to set many other member funcs, including the new adjfine which is being called for some reason now here (I say for some reason because apparently this was not the case up to kernel version 4).
static int ptp_clock_adjtime(struct posix_clock *pc, struct __kernel_timex *tx)
{
    struct ptp_clock *ptp = container_of(pc, struct ptp_clock, clock);
    struct ptp_clock_info *ops;
...
    ops = ptp->info;
...
    } else if (tx->modes & ADJ_FREQUENCY) {
        long ppb = scaled_ppm_to_ppb(tx->freq);
        if (ppb > ops->max_adj || ppb < -ops->max_adj)
            return -ERANGE;
        err = ops->adjfine(ops, tx->freq);
        ptp->dialed_frequency = tx->freq;
    }
...
    return err;
}

Unfortunately, 'spoofing' these functions with empty ones causes ptp4l to hang during port 1: assuming the grand master role step, so it looks like I either have to replace the tx->modes being used (not sure how I would go about that) or impl the driver functions correctly. I will look more into this, and have reached out to the team maintaining the drivers in the meantime.

0

You must log in to answer this question.

Browse other questions tagged .