Skip to content

"vc4-drm gpu: [drm] ERROR Failed to allocate DLIST entry: -28" after running for some period #5674

Closed

Description

@6by9

Describe the bug

Noted from #5649, https://forums.raspberrypi.com/viewtopic.php?t=357826, and https://forums.raspberrypi.com/viewtopic.php?t=358177

It looks like we have a memory leak of dlist entries somewhere.

Steps to reproduce the behaviour

See the other threads

Device (s)

Raspberry Pi 4 Mod. B

System

Bookworm or Ubuntu 23.10

Logs

No response

Additional context

No response

Activity

  1. self-assigned this
    on Oct 23, 2023
  2. 6by9 commented on Oct 26, 2023

    @6by9
    ContributorAuthor

    For anyone watching this issue, #5684 addresses a couple of issues but I haven't been able to reproduce exhausting the DLIST memory.

    If anyone wants to test, then sudo rpi-update pulls/5684 should get the CI build once complete.

  3. WeirdAnalyst commented on Oct 26, 2023

    @WeirdAnalyst

    Same for me. See below:

    Oct 27 00:29:54 kernel: vc4-drm gpu: [drm] ERROR Failed to allocate DLIST entry: -28
    Oct 27 00:29:54 mymachine last message buffered 2 times
    Oct 27 00:29:54 mymachine kernel: ------------[ cut here ]------------
    Oct 27 00:29:54 mymachine kernel: atomic remove_fb failed with -28
    Oct 27 00:29:54 mymachine kernel: WARNING: CPU: 2 PID: 6471 at drivers/gpu/drm/drm_framebuffer.c:1130 drm_framebuffer_remove+0x4b8/0x510 [drm]
    Oct 27 00:29:54 mymachine kernel: Modules linked in: uinput rfcomm fuse 8021q garp stp llc xt_tcpudp xt_conntrack nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 iptable_filter ip_tables x_ta
    Oct 27 00:29:54 mymachine kernel: CPU: 2 PID: 6471 Comm: kworker/2:3 Tainted: G C 6.1.58-v8 #1
    Oct 27 00:29:54 mymachine kernel: Hardware name: Raspberry Pi 4 Model B Rev 1.4 (DT)
    Oct 27 00:29:54 mymachine kernel: Workqueue: events drm_mode_rmfb_work_fn [drm]
    Oct 27 00:29:54 mymachine kernel: pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
    Oct 27 00:29:54 mymachine kernel: pc : drm_framebuffer_remove+0x4b8/0x510 [drm]
    Oct 27 00:29:54 mymachine kernel: lr : drm_framebuffer_remove+0x4b8/0x510 [drm]
    Oct 27 00:29:54 mymachine kernel: sp : ffffffc00b643cb0
    Oct 27 00:29:54 mymachine kernel: x29: ffffffc00b643cb0 x28: ffffff804214f000 x27: ffffff81079a12b8
    Oct 27 00:29:54 mymachine kernel: x26: ffffffd95606a460 x25: 0000000000000000 x24: 0000000000000010
    Oct 27 00:29:54 mymachine kernel: x23: 00000000ffffffe4 x22: ffffff81079a12c0 x21: ffffff81079a1000
    Oct 27 00:29:54 mymachine kernel: x20: ffffff8089b76800 x19: ffffff80ea473000 x18: 00000000fffffffe
    Oct 27 00:29:54 mymachine kernel: x17: 0000000000000000 x16: ffffffd9c02884c0 x15: ffffffc00b643890
    Oct 27 00:29:54 mymachine kernel: x14: 0000000000000000 x13: 38322d2068746977 x12: 2064656c69616620
    Oct 27 00:29:54 mymachine kernel: x11: fffffffffffe0000 x10: ffffffd9c18947c0 x9 : ffffffd9c02face4
    Oct 27 00:29:54 mymachine kernel: x8 : 00000000ffffefff x7 : ffffffd9c18947c0 x6 : 80000000fffff000
    Oct 27 00:29:54 mymachine kernel: x5 : 0000000000000000 x4 : 0000000000000000 x3 : 0000000000000027
    Oct 27 00:29:54 mymachine kernel: x2 : 0000000000000000 x1 : 0000000000000000 x0 : ffffff81d6c4dd00
    Oct 27 00:29:54 mymachine kernel: Call trace:
    Oct 27 00:29:54 mymachine kernel: drm_framebuffer_remove+0x4b8/0x510 [drm]
    Oct 27 00:29:54 mymachine kernel: drm_mode_rmfb_work_fn+0x80/0xac [drm]
    Oct 27 00:29:54 mymachine kernel: process_one_work+0x1dc/0x460
    Oct 27 00:29:54 mymachine kernel: worker_thread+0x22c/0x43c
    Oct 27 00:29:54 mymachine kernel: kthread+0xf8/0x104
    Oct 27 00:29:54 mymachine kernel: ret_from_fork+0x10/0x20
    Oct 27 00:29:54 mymachine kernel: ---[ end trace 0000000000000000 ]---
    Oct 27 00:29:54 mymachine kernel: vc4-drm gpu: [drm] ERROR Failed to allocate DLIST entry: -28
    Oct 27 00:30:07 mymachine last message buffered 50 times
    Oct 27 00:31:47 mymachine last message buffered 118 times

  4. 6by9 commented on Oct 27, 2023

    @6by9
    ContributorAuthor

    Thanks for testing.

    PR updated to add a debugfs entry to print out the allocations. You should be able to do sudo cat /sys/kernel/debug/dri/1/hvs_dlist_allocs to print out the allocations. For me with a triple-head Wayfire session running I get

    pi@bookworm64:~ $ sudo cat /sys/kernel/debug/dri/1/hvs_dlist_allocs 
    Allocated nodes:
    node [00000020 + 0000000b]
    node [0000002b + 00000011]
    node [0000003c + 00000011]
    node [00000056 + 00000009]
    node [0000005f + 00000011]
    node [00000070 + 00000011]
    node [00000092 + 00000009]
    Stale nodes:
    node [0000005f + 00000011] channel 2 frcnt 9
    node [0000002b + 00000011] channel 2 frcnt 9
    

    0x20 is the scaling kernel. Entries that are 0x11 bytes long have a primary and a cursor plane, whilst those 0x9 bytes long only have a primary plane. This can also be confirmed via sudo cat /sys/kernel/debug/dri/1/hvs_dlists to list those which currently active.

    Knowing what it thinks are allocated vs active when it goes wrong would be very useful.

  5. WeirdAnalyst commented on Oct 28, 2023

    @WeirdAnalyst

    Sorry I think I wrote something misleading. I was not meaning that I had the issue after applying your patch. The kernel dump I provided is before before applying it.
    Now I applied your patch and all seems OK.
    Thank you and sorry for the confusion I have generated.

  6. 6by9 commented on Oct 28, 2023

    @6by9
    ContributorAuthor

    Sorry I think I wrote something misleading. I was not meaning that I had the issue after applying your patch. The kernel dump I provided is before before applying it. Now I applied your patch and all seems OK. Thank you and sorry for the confusion I have generated.

    OK, you had me quite confused that we still appeared to have a leak. Having the debugfs hook to dump out the allocations doesn't hurt anyway.
    If anyone else is able to test and confirm that they aren't seeing the error anymore, that would be awesome.

  7. Brunnis commented on Oct 28, 2023

    @Brunnis

    I am the one that initially reported the issue on Ubuntu 23.10 in the forum thread. Since there's no easy way of applying the fix in Ubuntu (right?), I have applied it to a Raspberry Pi OS installation instead and so far so good. However, I don't think I've been able to reproduce the issue on RPi OS before the fix, so the fact that it works may not mean that much. I'll continue using the fix and let you know if I run into any issues.

  8. Dark-Sky commented on Oct 29, 2023

    @Dark-Sky

    I have a guy on our forums keeps having this issue so I compiled the 6.1.58 kernel with your commits using commit 36ed2f9. He only had time for a short test but he appears to still be having the issue. He is using Gnome with Wayland. I do not seem to have the issue here on XFCE. I get no related output in journalctl while playing like he does.

    My terminal output in XFCE:

    [ray@jellyfin AKA.2023]$ mpv nasa.ts 
     (+) Video --vid=1 (hevc 3840x2160 59.940fps)
     (+) Audio --aid=1 (mp2 2ch 48000Hz)
         Audio --aid=2 (aac 2ch 48000Hz)
    Using hardware decoding (drm).
     (+) Video --vid=1 (hevc 3840x2160 59.940fps)
     (+) Audio --aid=1 (mp2 2ch 48000Hz)
         Audio --aid=2 (aac 2ch 48000Hz)
         Subs  --sid=1 (*) (eia_608)
    AO: [pipewire] 48000Hz stereo 2ch s16p
    VO: [gpu] 3840x2160 drm_prime[rpi4_8]
    AV: 00:04:23 / 00:04:24 (100%) A-V:  0.000 Dropped: 8285
    Exiting... (End of file)
    

    Him playing with mpv compiled with jc-kynesim's ffmpeg6:

    oct. 29 19:07:54 bloodmoon-pc kernel: rpivid feb10000.codec: rpivid_h265_start: (3840x2160)
    oct. 29 19:07:54 bloodmoon-pc kernel: rpivid feb10000.codec: SPS changed
    oct. 29 19:07:54 bloodmoon-pc kernel: rpivid feb10000.codec: PPS changed
    oct. 29 19:07:54 bloodmoon-pc kernel: rpivid feb10000.codec: Missing DPB ent 0, timestamp=0
    oct. 29 19:07:54 bloodmoon-pc kernel: rpivid feb10000.codec: Missing DPB ent 1, timestamp=0
    oct. 29 19:07:54 bloodmoon-pc kernel: rpivid feb10000.codec: Missing DPB ent 2, timestamp=0
    oct. 29 19:07:54 bloodmoon-pc kernel: rpivid feb10000.codec: Missing DPB ent 3, timestamp=0
    oct. 29 19:07:55 bloodmoon-pc kernel: vc4-drm gpu: swiotlb buffer is full (sz: 6352896 bytes), total 32768 (slots), used 199 (slots)
    oct. 29 19:07:55 bloodmoon-pc kernel: vc4-drm gpu: swiotlb buffer is full (sz: 5558272 bytes), total 32768 (slots), used 587 (slots)
    oct. 29 19:07:56 bloodmoon-pc kernel: vc4-drm gpu: swiotlb buffer is full (sz: 6496256 bytes), total 32768 (slots), used 129 (slots)
    oct. 29 19:07:59 bloodmoon-pc kernel: rpivid feb10000.codec: PPS changed
    oct. 29 19:08:02 bloodmoon-pc kernel: rpivid feb10000.codec: PPS changed
    oct. 29 19:08:02 bloodmoon-pc kernel: rpivid feb10000.codec: Missing DPB ent 0, timestamp=0
    
    cma: cma_alloc: linux,cma: alloc failed, req-size: 4050 pages, ret: -12
    v3d fec00000.v3d: MMU error from client CLE (4) at 0x1e8a1000, pte invalid
    

    Requested info on his pi4:

    sudo cat /sys/kernel/debug/dri/1/hvs_dlist_allocs
    Allocated nodes:
    node [00000020 + 0000000b]
    node [0000002b + 00000009]
    node [0000003d + 00000009]
    Stale nodes:
    node [0000002b + 00000009] channel 0 frcnt 35
    
  9. 6by9 commented on Oct 30, 2023

    @6by9
    ContributorAuthor

    @Dark-Sky That log doesn't include the
    ERROR Failed to allocate DLIST entry: -28
    error that this issue is about.

    swiotlb buffer is full is a little worrying as I wouldn't expect there to need to be swiotlb usage under most situations. linux,cma: alloc failed is a totally different error.

  10. Brunnis commented on Oct 30, 2023

    @Brunnis

    swiotlb buffer is full is a little worrying as I wouldn't expect there to need to be swiotlb usage under most situations.

    I've been seeing that a lot on my Pi 4 as well. I believe on both RPi OS Bookworm and Ubuntu 23.10. Haven't made a report on it yet.

  11. Dark-Sky commented on Oct 30, 2023

    @Dark-Sky

    @Dark-Sky That log doesn't include the ERROR Failed to allocate DLIST entry: -28 error that this issue is about.

    I had questioned him about that earlier and he said he was getting the same error when he succeeded to open a TTY. Most of the time his system would just lock up was his response later on.

    leaak

  12. Dark-Sky commented on Nov 1, 2023

    @Dark-Sky

    Our forum member had some more time to test today and reported this:

    I think that “vc4-drm gpu: swiotlb buffer is full” is a different problem than
    
    in a tty :
    
    vc4-drm gpu: [drm] ERROR Failed to allocate DLIST entry: -28
    
    or in journalctl
    
    Page flip failed: drmModeAtomicCommit: No space available on the device
    
    who make the freezes.
    
    For the moment no more problems with pull/5684. I will continue to report.
    
  13. 6by9 commented on Nov 1, 2023

    @6by9
    ContributorAuthor

    For the moment no more problems with pull/5684. I will continue to report.

    So does that mean it is working?

    If not, what kernel version are they actually running? And what client software?

    Some of the reports providing the WARN backtrace including drm_mode_rmfb_work_fn is weird.
    drm_mode_rmfb is generally called due to drmModeRmFB in userspace, which is destroying a FB mapping of a bo or DMABUF. This isn't something that I would expect to be happening that often, as you generally addFB during init, and destroy at exit. drm_framebuffer_remove is then doing a commit if the FB was active when removed.

    I'm wondering if this is on some app being killed, hence cleanup coming in and freeing all resources in one hit, thereby generating many commits. Even so, if not directly driving DRM to add lots of planes, then I wouldn't expect there to be lots of active FBs needing actually removing, but the accounting may not be that finely grained.

  14. Dark-Sky commented on Nov 1, 2023

    @Dark-Sky

    So does that mean it is working?

    I asked again today and this was his response still testing the using the kernel I compiled with your commits you had done above:

    I have enabled a maximum of gnome-shell extension and apart from vc4-drm gpu: swiotlb buffer is full, I didn’t have any crash. But I think it takes a few days to be sure.

    Seems to me it should have locked up by now.

  15. 6by9 commented on Nov 2, 2023

    @6by9
    ContributorAuthor

    Seems to me it should have locked up by now.

    That sounds positive. I've updated the PR, and will look to get it merged now.

  16. 67 remaining items

  17. WilkuAgresor commented on Jan 24, 2024

    @WilkuAgresor

    It repeated once before my script rebooted the pi. I'll disable the workaround and report when I catch it again.

  18. 6by9 commented on Jan 24, 2024

    @6by9
    ContributorAuthor

    I think we may have a read-modify-write issue between setting the DSPEISLUR and EOF enables - I'm seeing both bits 7 (0x80) and 9 (0x200) being enabled and disabled in SCALER_DISPCTRL via /sys/kernel/debug/dri/1/hvs_regs over updates, and they're done from different contexts.

    I've created #5891 as a test which disables the underrun interrupt, so it should remove the race condition. It's a hack, but it would be useful if people could test to see if it does solve their issues. Once CI has completed, sudo rpi-update pulls/5891 should get the 6.1 kernel with that patch.

  19. pelwell commented on Jan 24, 2024

    @pelwell
    Contributor

    The builds are done - sudo rpi-update pulls/5891 away (after backing up any important data etc.)

  20. WilkuAgresor commented on Jan 29, 2024

    @WilkuAgresor

    Right now uptime is 5 days after the 'sudo rpi-update pulls/5891' and a reboot.
    Linux testTerminal 6.1.74-v8+ #1 SMP PREEMPT Wed Jan 24 17:15:21 UTC 2024 aarch64 GNU/Linux
    No issues found, everything works ok.

  21. 6by9 commented on Jan 30, 2024

    @6by9
    ContributorAuthor

    Thanks for testing - I was beginning to think no one had tested it.

    I'll have a think about a clean way of implementing both underrun and EOF interrupt handling. It's tempting to just enable EOF permanently, but it adds some overhead triggering interrupts at 60Hz for each HVS channel.

  22. anyc commented on Jan 31, 2024

    @anyc
    Contributor

    I can also confirm that it works for me for over one day now.

  23. TRyan84 commented on Feb 1, 2024

    @TRyan84

    Hello,

    ruining since 7 days on a cm3+, and it works.

    Thanks

  24. 6by9 commented on Feb 1, 2024

    @6by9
    ContributorAuthor

    Thanks @WilkuAgresor, @TRyan84 and @anyc.
    With the three of you confirming that the hack to drop underrun logging works, it gives me confidence that we have identified the cause, and just need to sort the proper fix.

    I don't need any other confirmations that it works now.

  25. hughmcmaster commented on Feb 11, 2024

    @hughmcmaster

    Can someone please tell me which kernel version has the relevant fixes for this issue?

    I'm running Debian 12 Bookworm (arm64) on a RPi4 (8GB).

  26. 6by9 commented on Feb 12, 2024

    @6by9
    ContributorAuthor

    I've dropped underrun detection via #5935 which was merged 7:52PM Fri 8th Feb.
    The last rpi-update bump was 3:41PM Fri 8th Feb, so hasn't picked it up yet.

    AIUI using sudo rpi-update rpi-6.6.y should pick up the latest CI build from that branch, which should include it.

  27. TRyan84 commented on Feb 14, 2024

    @TRyan84

    Hello,

    I update the System with sudo rpi-update rpi-6.6.y

    Now I get this error:
    [ 16.264098] alsactl[701]: memfd_create() called without MFD_EXEC or MFD_NOEXEC_SEAL set
    [ 16.873391] vc4_dsi 3f700000.dsi: transfer interrupt wait timeout
    [ 16.873407] vc4_dsi 3f700000.dsi: instat: 0x00000000
    [ 16.873425] [drm:vc4_dsi_host_transfer [vc4]] ERROR DSI transfer failed, resetting: -110
    [ 17.113409] tc358762 3f700000.dsi.0: error initializing bridge (-110)
    [ 17.115153] Console: switching to colour frame buffer device 100x30
    [ 17.129595] vc4-drm soc:gpu: [drm] fb0: vc4drmfb frame buffer device

    And the Display is kind of fuzzy...

    Thanks.
    Greetings

  28. 6by9 commented on Feb 14, 2024

    @6by9
    ContributorAuthor

    I update the System with sudo rpi-update rpi-6.6.y

    Now I get this error:

    [ 16.264098] alsactl[701]: memfd_create() called without MFD_EXEC or MFD_NOEXEC_SEAL set
    [ 16.873391] vc4_dsi 3f700000.dsi: transfer interrupt wait timeout
    [ 16.873407] vc4_dsi 3f700000.dsi: instat: 0x00000000
    [ 16.873425] [drm:vc4_dsi_host_transfer [vc4]] _ERROR_ DSI transfer failed, resetting: -110
    [ 17.113409] tc358762 3f700000.dsi.0: error initializing bridge (-110)
    [ 17.115153] Console: switching to colour frame buffer device 100x30
    [ 17.129595] vc4-drm soc:gpu: [drm] fb0: vc4drmfb frame buffer device
    

    And the Display is kind of fuzzy...

    What DSI display are you using? Presumably the Pi 7" DSI panel as it's loading tc358762.
    If a clone of the Pi display, then I largely don't care.
    Nothing significant has changed with regard that driver or the DSI host controller.

    Which kernel version were you on previously?

  29. TRyan84 commented on Feb 14, 2024

    @TRyan84

    Hi 6by9

    thanks for your answer.

    Yes, I am using the Pi 7" DSI panel

    The kernel version before was 6.1.63-v7, and I never saw this behavior

    After a few resets, the error is gone.

    I have 10 of them in my office, and after I power cycle 2 of them has the same error.

    Thanks

    Greetings

  30. TRyan84 commented on Feb 16, 2024

    @TRyan84

    Hi 6by9,

    sorry, I think my setup is the problem...

    Greetings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions