Skip to content

ioctl() errors that started to appear with kernel 6.1.21 #5524

Closed

Description

@vanfanel

Describe the bug

Using some SDL2 programs on MESA on KMS/DRM or Wayland, I see this on the TTY:


ioctl (GFEATURE): Broken pipe
ioctl (GFEATURE): Broken pipe
ioctl (GFEATURE): Broken pipe
ioctl (GFEATURE): Invalid argument
ioctl (GFEATURE): Invalid argument
ioctl (GFEATURE): Invalid argument
ioctl (GFEATURE): Invalid argument
ioctl (GFEATURE): Invalid argument
ioctl (GFEATURE): Invalid argument
ioctl (GFEATURE): Broken pipe
ioctl (GFEATURE): Broken pipe
ioctl (GFEATURE): Broken pipe

Which in dmesg means:

[   91.600471] vc4-drm gpu: swiotlb buffer is full (sz: 393216 bytes), total 32768 (slots), used 1074 (slots)
[   91.603514] vc4-drm gpu: swiotlb buffer is full (sz: 393216 bytes), total 32768 (slots), used 1074 (slots)
[   91.712747] vc4-drm gpu: swiotlb buffer is full (sz: 1638400 bytes), total 32768 (slots), used 104 (slots)
[   91.713764] vc4-drm gpu: swiotlb buffer is full (sz: 1638400 bytes), total 32768 (slots), used 104 (slots)
[   91.737476] vc4-drm gpu: swiotlb buffer is full (sz: 1941504 bytes), total 32768 (slots), used 0 (slots)
[   91.738289] vc4-drm gpu: swiotlb buffer is full (sz: 1941504 bytes), total 32768 (slots), used 0 (slots)
[   91.756947] vc4-drm gpu: swiotlb buffer is full (sz: 524288 bytes), total 32768 (slots), used 1916 (slots)
[   91.761632] vc4-drm gpu: swiotlb buffer is full (sz: 524288 bytes), total 32768 (slots), used 1916 (slots)

This started to happen somewhere between kernel 6.1.25-v8+ and kernel 6.1.34-v8+

A good game to reproduce this is SDLPoP:
https://github.com/NagyD/SDLPoP

I am using the vc4-kms-v3d video overlay, and direct ALSA audio with the vc4hdmi audio device, and latest stable MESA 23.1.3

Steps to reproduce the behaviour

Run and SDL2 program on KMS/DRM or Wayland (like SDLPoP: https://github.com/NagyD/SDLPoP) and look at console and dmesg.

Device (s)

Raspberry Pi 4 Mod. B

System

bullseye
Linux debian 6.1.34-v8+ #1657 SMP PREEMPT Fri Jun 16 12:36:29 BST 2023 aarch64 GNU/Linux

Logs

No response

Additional context

No response

Activity

  1. pelwell commented on Jun 28, 2023

    @pelwell
    Contributor

    How much RAM does the Pi 4 have? If it's 8GB, does putting total_mem=4096 in config.txt get rid of the warnings?

  2. vanfanel commented on Jun 28, 2023

    @vanfanel
    Author

    How much RAM does the Pi 4 have? If it's 8GB, does putting total_mem=4096 in config.txt get rid of the warnings?

    It has 2 GBs. All my Pi4s are 2 GB.

  3. pelwell commented on Jun 28, 2023

    @pelwell
    Contributor

    Do you just get a few at startup, or are they more continuous than that? I ended up installing Batocera (based on 6.1.25) a few weels ago for some testing (on an 8GB Pi 4) and SDLPoP runs OK, but the shell gets a few swiotlb full messages on startup:

    [   24.455905] vc4-drm gpu: swiotlb buffer is full (sz: 1622016 bytes), total 32768 (slots), used 5 (slots)
    [   24.456940] vc4-drm gpu: swiotlb buffer is full (sz: 1622016 bytes), total 32768 (slots), used 5 (slots)
    [   24.492240] vc4-drm gpu: swiotlb buffer is full (sz: 3235840 bytes), total 32768 (slots), used 455 (slots)
    [   24.494049] vc4-drm gpu: swiotlb buffer is full (sz: 3235840 bytes), total 32768 (slots), used 519 (slots)
    

    However, there was a significant change in the way DMA addresses are derived in our 6.1.28 kernel releases, and Batocera is currently still stuck on 6.1.25.

  4. vanfanel commented on Jun 28, 2023

    @vanfanel
    Author

    Do you just get a few at startup, or are they more continuous than that? I ended up installing Batocera (based on 6.1.25) a few weels ago for some testing (on an 8GB Pi 4) and SDLPoP runs OK, but the shell gets a few swiotlb full messages on startup:

    [   24.455905] vc4-drm gpu: swiotlb buffer is full (sz: 1622016 bytes), total 32768 (slots), used 5 (slots)
    [   24.456940] vc4-drm gpu: swiotlb buffer is full (sz: 1622016 bytes), total 32768 (slots), used 5 (slots)
    [   24.492240] vc4-drm gpu: swiotlb buffer is full (sz: 3235840 bytes), total 32768 (slots), used 455 (slots)
    [   24.494049] vc4-drm gpu: swiotlb buffer is full (sz: 3235840 bytes), total 32768 (slots), used 519 (slots)
    

    However, there was a significant change in the way DMA addresses are derived in our 6.1.28 kernel releases, and Batocera is currently still stuck on 6.1.25.

    I get them at SDLPop startup only, apparently there are no more after that.

  5. pelwell commented on Jun 28, 2023

    @pelwell
    Contributor

    Running SDLPop from the RPiOs desktop launcher under 6.1.35 + KMS on both 2GB and 8GB Pis, and I see no errors.

  6. pelwell commented on Jun 28, 2023

    @pelwell
    Contributor

    What does dmesg | grep TLB show?

    BTW, my mesa seems to be on 20.3.5.

  7. pelwell commented on Jun 28, 2023

    @pelwell
    Contributor

    Make that dmesg | grep -E "(TLB|CMA)"...

  8. vanfanel commented on Jun 28, 2023

    @vanfanel
    Author

    dmesg | grep -E "(TLB|CMA)"..

    
    dmesg | grep -E "(TLB|CMA)"
    [    0.000000] Reserved memory: created CMA memory pool at 0x000000000ec00000, size 512 MiB
    [    0.000000] software IO TLB: area num 4.
    [    0.000000] software IO TLB: mapped [mem 0x0000000037400000-0x000000003b400000] (64MB)
    
    

    That's it.

  9. pelwell commented on Jun 28, 2023

    @pelwell
    Contributor

    Thanks. Can you tell me the top commit for one of the builds, and upload /sys/firmware/fdt somewhere I can grab it? Or email it to phil@raspberrypi.com if you prefer.

  10. vanfanel commented on Jun 28, 2023

    @vanfanel
    Author

    Thanks. Can you tell me the top commit for one of the builds, and upload /sys/firmware/fdt somewhere I can grab it? Or email it to phil@raspberrypi.com if you prefer.

    I don't have a /sys/firmware/fdt directory. This is a pretty minimal system. Is there a service that mounts that?

    Also, I don't know what software build do you mean: kernel/fw? MESA? SDL2? Other?

  11. vanfanel commented on Jun 28, 2023

    @vanfanel
    Author

    Ah well, sorry, ftd seems to be a file.
    This is it:
    fdt.zip

    Still, I don't understand what top commit do you need.

  12. pelwell commented on Jun 28, 2023

    @pelwell
    Contributor

    The bug report is about the kernel, this is the kernel repo, I want the kernel top commit. Or is it one of our pre-built kernels?

  13. vanfanel commented on Jun 28, 2023

    @vanfanel
    Author

    The bug report is about the kernel, this is the kernel repo, I want the kernel top commit. Or is it one of our pre-built kernels?

    It is the latest kernel available in rpi-update.
    So this is one of your prebuilt ones.
    6.1.34-v8+ to be precise.

    Sorry if my question sounded obtuse, but theres a graphics software stack on top of the kernel. Thats why I asked.

  14. pelwell commented on Jun 29, 2023

    @pelwell
    Contributor

    A clean, fully-updated installation of 32-bit Raspberry Pi OS (but with the 64-bit kernel) shows no problems when I launch a freshly built SDLPoP. Running rpi-update on that gets the same kernel as you, and it is also showing no errors or issues of any kind with SDLPoP, even running at 4K.

  15. vanfanel commented on Jun 29, 2023

    @vanfanel
    Author

    A clean, fully-updated installation of 32-bit Raspberry Pi OS (but with the 64-bit kernel) shows no problems when I launch a freshly built SDLPoP. Running rpi-update on that gets the same kernel as you, and it is also showing no errors or issues of any kind with SDLPoP, even running at 4K.

    I have a full 64bit system, both kernel and libs. In fact, it's Raspberry Pi OS 64bit LITE.
    I am definitely seeing the errors there.

    In fact, weren't you seeing them here? --> #5524 (comment)

  16. 21 remaining items

  17. vanfanel commented on Jul 5, 2023

    @vanfanel
    Author

    @pelwell Found what causes the errors on my Pi4 but not on yours, since Pi kernel 6.2.21.
    Guess what?
    USB keyboard/mouse receiver.
    This one in lsusb:

    Bus 001 Device 004: ID 046d:c534 Logitech, Inc. Unifying Receiver

    If I unplug it, the errors are gone. If I plug it, errors appear when launching SDL2 games:

    ioctl (GFEATURE): Broken pipe
    ioctl (GFEATURE): Broken pipe
    ioctl (GFEATURE): Broken pipe
    ioctl (GFEATURE): Invalid argument
    ioctl (GFEATURE): Invalid argument
    ioctl (GFEATURE): Invalid argument
    ioctl (GFEATURE): Invalid argument
    ioctl (GFEATURE): Invalid argument
    ioctl (GFEATURE): Invalid argument
    ioctl (GFEATURE): Broken pipe
    ioctl (GFEATURE): Broken pipe
    ioctl (GFEATURE): Broken pipe
    
  18. pelwell commented on Jul 5, 2023

    @pelwell
    Contributor

    Oh well done. I'll continue to look in that area as time allows.

  19. vanfanel commented on Jul 6, 2023

    @vanfanel
    Author

    @pelwell The modules used by Logitech receivers (I have several and they all use the same) are:

    hid_logitech_hidpp     45056  0
    hid_logitech_dj        28672  0
    

    The errors only happen on the Raspberry Pi (let's not forget they are vc4-drm gpu: swiotlb errors).
    Loading the cores manually via modprobe without the receiver being physically connected doesn't cause the errors: the receiver must be connected to trigger the bug.

  20. pelwell commented on Jul 6, 2023

    @pelwell
    Contributor

    (let's not forget they are vc4-drm gpu: swiotlb errors).

    So I don't misunderstand you, can you confirm that without the receiver plugged in both the swiotlb and ioctl error messages disappear?

  21. vanfanel commented on Jul 6, 2023

    @vanfanel
    Author

    without the receiver plugged in both the swiotlb and ioctl error messages disappear

    That is true.

    Plus: with NO logitech receiver connected, loading the modules manually and then running the game, the errors don't appear.

    Errors appear ONLY when receiver is connected and the modules are loaded.

    In fact, I can connect the receiver, unload the modules, and the errors DO appear.

    So the determining factor is the device being connected.
    Connected = errors.
    Not connected = no errors, even if the modules are loaded.

  22. vanfanel commented on Jul 6, 2023

    @vanfanel
    Author

    And one more strange thing: the devices connected to the logitech receiver DO work after UNLOADING the modules hid_logitech_hidpp and hid_logitech_dj

    But in that case, only half of the errors appear.

    So:

    With the DEVICE CONNECTED, and MODULES LOADED:

    
    ioctl (GFEATURE): Broken pipe
    ioctl (GFEATURE): Broken pipe
    ioctl (GFEATURE): Broken pipe
    ioctl (GFEATURE): Invalid argument
    ioctl (GFEATURE): Invalid argument
    ioctl (GFEATURE): Invalid argument
    ioctl (GFEATURE): Invalid argument
    ioctl (GFEATURE): Invalid argument
    ioctl (GFEATURE): Invalid argument
    ioctl (GFEATURE): Broken pipe
    ioctl (GFEATURE): Broken pipe
    ioctl (GFEATURE): Broken pipe
    

    In dmesg:

    
    [ 2278.920013] vc4-drm gpu: swiotlb buffer is full (sz: 323584 bytes), total 32768 (slots), used 0 (slots)
    [ 2278.920761] vc4-drm gpu: swiotlb buffer is full (sz: 323584 bytes), total 32768 (slots), used 0 (slots)
    [ 2278.946357] vc4-drm gpu: swiotlb buffer is full (sz: 438272 bytes), total 32768 (slots), used 0 (slots)
    [ 2278.947417] vc4-drm gpu: swiotlb buffer is full (sz: 438272 bytes), total 32768 (slots), used 0 (slots)
    

    With DEVICE CONNECTED, and modules UNLOADED:

    ioctl (GFEATURE): Broken pipe
    ioctl (GFEATURE): Broken pipe
    ioctl (GFEATURE): Broken pipe
    ioctl (GFEATURE): Broken pipe
    ioctl (GFEATURE): Broken pipe
    ioctl (GFEATURE): Broken pipe
    

    In dmesg:

    [ 2171.665681] vc4-drm gpu: swiotlb buffer is full (sz: 458752 bytes), total 32768 (slots), used 0 (slots)
    [ 2171.666443] vc4-drm gpu: swiotlb buffer is full (sz: 458752 bytes), total 32768 (slots), used 0 (slots)
    [ 2171.689858] vc4-drm gpu: swiotlb buffer is full (sz: 1048576 bytes), total 32768 (slots), used 12 (slots)
    [ 2171.690812] vc4-drm gpu: swiotlb buffer is full (sz: 1048576 bytes), total 32768 (slots), used 12 (slots)
    
  23. pelwell commented on Jul 7, 2023

    @pelwell
    Contributor

    I don't believe it - with a Logitech wireless dongle (and mouse) I see exactly the same ioctl errors as you but the kernel message log is clean - no swiotlb warnings. Even running a memory stresser to randomly allocate most of the RAM doesn't change things.

  24. vanfanel commented on Aug 8, 2023

    @vanfanel
    Author

    @pelwell Any other experiments I should do with this? Do you need more info? Did you find out something new?

  25. pelwell commented on Aug 8, 2023

    @pelwell
    Contributor

    I stopped looking at this after trying and failing to recreate the swiotlb errors (which are definitely my field). I haven't investigate the ioctl() error messages. Is there any obvious malfunction?

  26. vanfanel commented on Aug 8, 2023

    @vanfanel
    Author

    @pelwell No, everything seems to be working fine otherwise.
    Is there a way to ride out of these errors on the TTY/terminal emulator? I currently pass loglevel=3 to the kernel, but they are still there.

  27. detiam commented on Aug 11, 2023

    @detiam

    No, everything seems to be working fine otherwise.
    Is there a way to ride out of these errors on the TTY/terminal emulator? I currently pass loglevel=3 to the kernel, but they are still there.

    @vanfanel Hi, I found a related issue on SDL side: libsdl-org/SDL#6799
    according to that, I first get vendor ID by

    $ lsusb
    Bus 004 Device 002: ID 17ef:109b Lenovo USB3.0 Hub
    Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
    Bus 003 Device 005: ID 046d:c539 Logitech, Inc. Lightspeed Receiver
    Bus 003 Device 004: ID 2109:8883 VIA Labs, Inc. USB Billboard Device
    Bus 003 Device 003: ID 045e:02fe Microsoft Corp. XBOX ACC
    Bus 003 Device 002: ID 17ef:109a Lenovo USB2.0 Hub
    Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
    Bus 001 Device 005: ID 8087:0aa7 Intel Corp. Wireless-AC 3168 Bluetooth
    Bus 001 Device 004: ID 26ce:01a2 ASRock LED Controller
    Bus 001 Device 002: ID 056a:037a Wacom Co., Ltd CTL-472 [One by Wacom (S)]
    Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

    and run SDL program with that env var

    $ sdl2-jstest --list
    ioctl (GFEATURE): Broken pipe
    ioctl (GFEATURE): Broken pipe
    ioctl (GFEATURE): Broken pipe
    ioctl (GFEATURE): Broken pipe
    ioctl (GFEATURE): Broken pipe
    ioctl (GFEATURE): Broken pipe
    ioctl (GFEATURE): Invalid argument
    ioctl (GFEATURE): Invalid argument
    ioctl (GFEATURE): Invalid argument
    ioctl (GFEATURE): Broken pipe
    ioctl (GFEATURE): Broken pipe
    ioctl (GFEATURE): Broken pipe
    No joysticks were found
    
    $ env SDL_HIDAPI_IGNORE_DEVICES=0x046d/0x0000 sdl2-jstest --list
    No joysticks were found

    ioctl (GFEATURE): * are gone!

  28. vanfanel commented on Aug 11, 2023

    @vanfanel
    Author

    @detiam Ah, I guess it should be fixed on SDL's side then?
    I will try to replicate and send a PR to SDL in that case.
    Why are you passing SDL_HIDAPI_IGNORE_DEVICES=0x046d/0x0000 instead of SDL_HIDAPI_IGNORE_DEVICES=0x046d/0xc539?

  29. vanfanel commented on Aug 11, 2023

    @vanfanel
    Author

    Oh well, lsusb says this here:

    
    root@DietPi:~/src/SDL-release-2.28.1/test# lsusb
    Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
    Bus 001 Device 005: ID 045e:028e Microsoft Corp. Xbox360 Controller
    **Bus 001 Device 006: ID 046d:c534 Logitech, Inc. Unifying Receiver**
    Bus 001 Device 004: ID 2341:8036 Arduino SA Leonardo (CDC ACM, HID)
    Bus 001 Device 002: ID 2109:3431 VIA Labs, Inc. Hub
    Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    

    And if I do:
    env SDL_HIDAPI_IGNORE_DEVICES=0x046d/0x0000 testjoystick

    I get no errors at all. Great! Let's PR this...

  30. vanfanel commented on Aug 19, 2023

    @vanfanel
    Author

    Ok, this was fixed on the SDL2 side, so closing this.

    Thanks all involved! :)

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

Metadata

Metadata

Assignees

No one assigned

    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