When a sync_file is exported from a syncobj point > 0 via
DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD and then imported into another syncobj
point > 0 via DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE, the following warning is
logged:

    ------------[ cut here ]------------
    dma_fence_is_chain(fence)
    WARNING: drivers/dma-buf/dma-fence-chain.c:286 at
dma_fence_chain_init+0xd7/0xf0, CPU#15: jay/356576
    Modules linked in: uinput snd_seq_dummy snd_hrtimer snd_seq
overlay vrf wireguard libcurve25519 ip6_udp_tunnel udp_tunnel bridge
stp llc cfg80211 nft_masq nft_chain_nat nf_nat nft_reject_inet
nf_reject_ipv4 nf_reject_ipv6 nft_reject nft_ct nf_conntrack
nf_defrag_ipv6 nf_defrag_ipv4 nf_tables nls_iso8859_1 vfat fat amd_atl
intel_rapl_msr amdgpu intel_rapl_common snd_hda_codec_alc662
snd_hda_codec_realtek_lib snd_hda_codec_generic snd_hda_codec_atihdmi
snd_hda_codec_hdmi drm_buddy amdxcp btusb drm_panel_backlight_quirks
snd_hda_intel gpu_sched btmtk btrtl snd_usb_audio drm_exec kvm_amd
snd_hda_codec drm_suballoc_helper btbcm btintel snd_hda_core
snd_usbmidi_lib drm_ttm_helper spd5118 wmi_bmof kvm snd_ump ttm
snd_intel_dspcfg sp5100_tco bluetooth snd_intel_sdw_acpi snd_rawmidi
i2c_algo_bit r8169 snd_hwdep snd_seq_device irqbypass
drm_display_helper i2c_piix4 realtek mousedev ledtrig_pattern snd_pcm
rapl pcspkr joydev i2c_smbus k10temp rfkill cec mc phy_package
mdio_devres snd_timer video libphy snd gpio_amdpt
     mdio_bus soundcore gpio_generic wmi mac_hid i2c_dev
pkcs8_key_parser ntsync crypto_user nfnetlink dm_crypt encrypted_keys
trusted asn1_encoder tee dm_mod hid_playstation led_class_multicolor
ff_memless nvme uas aesni_intel usb_storage gf128mul nvme_core aead
nvme_keyring nvme_auth ccp
    CPU: 15 UID: 1000 PID: 356576 Comm: jay Tainted: G        W
   7.1.0-rc3-00375-g73d60ad4c0db #160 PREEMPT(full)
45d3079a60f4a6447320c11f1e9b56e4eb3186d2
    Tainted: [W]=WARN
    Hardware name: ASRock B650 PG Lightning/B650 PG Lightning, BIOS
2.02 11/17/2023
    RIP: 0010:dma_fence_chain_init+0xd7/0xf0
    Code: c0 eb a9 4c 89 04 24 48 89 73 40 bf 01 00 00 00 48 89 6b 50
48 c7 43 48 00 00 00 00 e8 32 d8 ff ff 4c 8b 04 24 48 89 c1 eb 82 <0f>
0b 48 83 c4 10 5b 5d e9 97 35 09 ff 90 66 66 2e 0f 1f 84 00 00
    RSP: 0018:ffffce3f4ae9bb70 EFLAGS: 00010246
    RAX: ffff89467ed80a90 RBX: ffff89467ed80a80 RCX: 00000000000ceb00
    RDX: 0000000000000000 RSI: ffffffffac1e3c80 RDI: ffff89467ed80a80
    RBP: ffff894c8c29f400 R08: 00000000000001d4 R09: ffff89467ed80a80
    R10: 0000000000000018 R11: 0000000000000000 R12: ffff894c8c29f400
    R13: ffffffffab9d4bb0 R14: ffff89467ed80a80 R15: ffff89418580e7c0
    FS:  00007f2347fd8c00(0000) GS:ffff894f90712000(0000) knlGS:0000000000000000
    CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    CR2: 0000561aa92dc0b8 CR3: 00000004b05f8000 CR4: 0000000000f50ef0
    PKRU: 55555554
    Call Trace:
     <TASK>
     ? __pfx_drm_mode_atomic_ioctl+0x10/0x10
     ? srso_alias_return_thunk+0x5/0xfbef5
     drm_syncobj_add_point+0xe6/0x2a0
     ? __kmalloc_cache_noprof+0x135/0x480
     drm_syncobj_import_sync_file+0x65/0xd0
     drm_syncobj_fd_to_handle_ioctl+0x168/0x280
     ? srso_alias_return_thunk+0x5/0xfbef5
     drm_ioctl_kernel+0xae/0x100
     drm_ioctl+0x2d8/0x570
     ? __pfx_drm_syncobj_fd_to_handle_ioctl+0x10/0x10
     amdgpu_drm_ioctl+0x4a/0x80 [amdgpu
1768195bf8c3668eee55aa832ee8f8298eb07023]
     __x64_sys_ioctl+0xb9/0x100
     ? kmem_cache_free+0x284/0x470
     do_syscall_64+0xaa/0x1620
     ? srso_alias_return_thunk+0x5/0xfbef5
     ? __x64_sys_close+0x47/0xa0
     ? srso_alias_return_thunk+0x5/0xfbef5
     ? do_syscall_64+0xaa/0x1620
     ? srso_alias_return_thunk+0x5/0xfbef5
     ? do_syscall_64+0xaa/0x1620
     ? srso_alias_return_thunk+0x5/0xfbef5
     ? __do_sys_io_uring_enter+0x2ee/0x830
     ? srso_alias_return_thunk+0x5/0xfbef5
     ? do_syscall_64+0x252/0x1620
     ? srso_alias_return_thunk+0x5/0xfbef5
     ? srso_alias_return_thunk+0x5/0xfbef5
     ? do_syscall_64+0x5f/0x1620
     ? srso_alias_return_thunk+0x5/0xfbef5
     entry_SYSCALL_64_after_hwframe+0x76/0x7e
    RIP: 0033:0x7f2348d18edd
    Code: 04 25 28 00 00 00 48 89 45 c8 31 c0 48 8d 45 10 c7 45 b0 10
00 00 00 48 89 45 b8 48 8d 45 d0 48 89 45 c0 b8 10 00 00 00 0f 05 <89>
c2 3d 00 f0 ff ff 77 1a 48 8b 45 c8 64 48 2b 04 25 28 00 00 00
    RSP: 002b:00007fffe126c1b0 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
    RAX: ffffffffffffffda RBX: 00007fffe126c2e0 RCX: 00007f2348d18edd
    RDX: 00007fffe126c210 RSI: 00000000c01864c2 RDI: 0000000000000036
    RBP: 00007fffe126c200 R08: 0000000000000000 R09: 0000000000000002
    R10: 0000561aa8eb00b0 R11: 0000000000000246 R12: 00000000000001d4
    R13: 00007fffe126c2a0 R14: 8000000000000029 R15: 00007f2340154960
     </TASK>
    ---[ end trace 0000000000000000 ]---

The cause seems to be that drm_syncobj_import_sync_file_fence (or some
other function) does not use dma_fence_unwrap_merge which is used by
drm_syncobj_transfer_to_timeline.

Working around this by first importing to a secondary syncobj at point
0, and then using DRM_IOCTL_SYNCOBJ_TRANSFER to transfer to the
desired point, fixes the issue.

Being able to import directly to a point > 0 is a new feature that
requires the use of the DRM_SYNCOBJ_FD_TO_HANDLE_FLAGS_TIMELINE flag.
Adding the required merge call was probably forgotten when that flag
was added.

Julian

Reply via email to