This project could get us rid of the last fbdev drivers we're stil shipping: efifb and vesafb.

Platform drivers handle hardware that is not auto-detected, but somehow there. For graphics this would be VGA, VESA, or UEFI framebuffers. In SUSE Linux, we currently support VESA and UEFI with fbdev drivers. Those load early in the boot process and maintain graphics hardware until the actual driver takes over.

It would be nice to support VESA and UEFI with modern DRM drivers. Doing so would give us basic support for very old, very modern or very obscure graphics hardware. This in itself is not complicated. The problem is the handover to the actual HW driver. For the old fbdev, there's a mechanism for the HW driver to disable the platform driver. Not such thing exists for DRM. Implementing this mechanism would be the main goal of the project.

Looking for hackers with the skills:

kernel drm fbdev graphics

This project is part of:

Hack Week 19

Activity

  • over 5 years ago: tdz liked this project.
  • over 5 years ago: MDoucha liked this project.
  • over 5 years ago: vliaskovitis liked this project.
  • over 5 years ago: tdz started this project.
  • over 5 years ago: tdz added keyword "kernel" to this project.
  • over 5 years ago: tdz added keyword "drm" to this project.
  • over 5 years ago: tdz added keyword "fbdev" to this project.
  • over 5 years ago: tdz added keyword "graphics" to this project.
  • over 5 years ago: tdz originated this project.

  • Comments

    • vliaskovitis
      over 5 years ago by vliaskovitis | Reply

      Interested though I only have limited kms experience (I have tested vkms/vgem, igt tools, and written a small vkms-like module in the past). Are the proposed drm drivers supposed to follow the fbdev->drm conversion from the fbconv helpers work https://gitlab.freedesktop.org/tzimmermann/linux/commits/fbconv , or are they meant to be from-scratch drm drivers? No idea about the handover mechanism though. If this is something that could be done and tested with VMs or a standard desktop without specific gfx cards (i assume so as vesafb is generic), and there are separable tasks that you don't plan on hacking, let me know.

      • tdz
        over 5 years ago by tdz | Reply

        Hi!

        I started working on this idea today.

        The drivers are written from scratch. (1) The fbdev drivers are just trivial framebuffers that the screen image is being copied into. At least efifb cannot even do modesetting. It uses the display mode that has been set by the UEFI BIOS.

        The hand-over mechanism is similar to how fbdev does it. The platform driver claims a piece of I/O memory, and once the actual driver wants to take the memory range, it kicks out the platform driver.

        I was a bit optimistic about the number of fbdev drivers. There are 2 or 3 others besides efifb and vesafb. Yet, those would be a significant step forward.

        I don't know about testing in VMs. If the current kernel's efifb works in the VM, the new driver should work as well.

        Best regards Thomas

        (1) It's nice that you recognized my work on fbconv. :)

    • tdz
      over 5 years ago by tdz | Reply

      Day 1: I made a skeleton driver for EFI and for the hand-over mechanism. The plan for tomorrow is to integrate the driver into the kernel's system-fb code and do a basic handover.

    • tdz
      over 5 years ago by tdz | Reply

      Day 2: Reviewing efifb and vesafb shows that these drivers don't actually do any modesetting or even call much of their respective interfaces. They only pick up a preconfigured framebuffer. Therefore I'm changing goal slightly. Instead of recreating these drivers for DRM, I'm porting over simplefb. It also picks up a preconfigured framebuffer, but it's entirely agnostic to the platform and works with firmware, bootloader or device tree. It even support EFI and VESA. AFAICT all the setup is done by the platform and the kernel's boot code. Just as simplefb, the new DRM driver would take these settings and make them available within the graphics framework.

    • tdz
      over 5 years ago by tdz | Reply

      Day 3: After two days of tinkering with the platform setup code, I typed down the driver today. The kernel fetches the framebuffer from GRUB and provides it as framebuffer device. My driver picks up the device and provides it via DRM. So far, the fbdev console emulation works and I was able to get GDM partially working. Apparently, X11 wants a PCI ID, which the device doesn't have. But there's probably a way around this limitation. All in all, this looks really good so far.

      • tdz
        over 5 years ago by tdz | Reply

        And with a little weak, weston now works as well. add-emoji

        • tdz
          over 5 years ago by tdz | Reply

          s/weak/tweak

    • tdz
      over 5 years ago by tdz | Reply

      Day 4: I spent the day on cleaning up what I have and implementing the hand-over code. The hand-over is slightly tricky, as it requires to remove the DRM device while it's being used by the platform driver. And it's concurrent code that requires some locking. It's partially working ATM.

    • tdz
      over 5 years ago by tdz | Reply

      Day 5: Today I finished the hand-over code. My test system is equipped with a Radeon graphics card. The bootloader, grub, configures a display mode before running the kernel. The built-in simplekms takes over early in the boot process and displays typical boot message. Once the radeon driver is ready, it kicks simplekms out and takes over the framebuffer. The hand-over is generic, so arbitrary drivers can kickout any platform driver.

      If there's no native DRM driver for the hardware, simplekms remains active and provides a basic framebuffer for Wayland compositors or the framebuffer console. I did not get native X11 running, as X11 requested a PCI device. I did not look further into this problem. However, Gnome runs fine in Wayland mode and X applications can be started via Xwayland.

      Yeah, I think this was a successful hackweek and the project is complete for now. After a bit more polishing, the driver could go upstream.

    • tdz
      over 5 years ago by tdz | Reply

      I uploaded the current state of the project to the git branch at

      https://gitlab.suse.de/tzimmermann/linux/tree/simplekms

      • tdz
        over 5 years ago by tdz | Reply

        Just an additional note: for simplekms to find the framebuffer, Grub has to run in graphics mode and forward the settings to Linux. The config options are something like:

        GRUBTERMINAL=gfxterm GRUBGFXPAYLOAD_LINUX=keep

    • vliaskovitis
      over 5 years ago by vliaskovitis | Reply

      Thank you for the detailed journal and explanations!

    • favogt
      about 5 years ago by favogt | Reply

      I know that mstaudt was working on this as well before he left - is this based on his work?

      • tdz
        over 4 years ago by tdz | Reply

        Hi!

        It's entirely new. The project moved from a hackweek thing to being one of my goals for this year. Hopefully it will hit upstream in autumn.

    Similar Projects

    early stage kdump support by mbrugger

    Project Description

    When we experience a early boot crash, we are not able to analyze the kernel dump, as user-space wasn't able to load the crash system. The idea is to make the crash system compiled into the host kernel (think of initramfs) so that we can create a kernel dump really early in the boot process.

    Goal for the Hackweeks

    1. Investigate if this is possible and the implications it would have (done in HW21)
    2. Hack up a PoC (done in HW22 and HW23)
    3. Prepare RFC series (giving it's only one week, we are entering wishful thinking territory here).

    update HW23

    • I was able to include the crash kernel into the kernel Image.
    • I'll need to find a way to load that from init/main.c:start_kernel() probably after kcsan_init()
    • I workaround for a smoke test was to hack kexec_file_load() systemcall which has two problems:
      1. My initramfs in the porduction kernel does not have a new enough kexec version, that's not a blocker but where the week ended
      2. As the crash kernel is part of init.data it will be already stale once I can call kexec_file_load() from user-space.

    The solution is probably to rewrite the POC so that the invocation can be done from init.text (that's my theory) but I'm not sure if I can reuse the kexec infrastructure in the kernel from there, which I rely on heavily.

    update HW24

    • Day1
      • rebased on v6.12 with no problems others then me breaking the config
      • setting up a new compilation and qemu/virtme env
      • getting desperate as nothing works that used to work
    • Day 2
      • getting to call the invocation of loading the early kernel from __init after kcsan_init()
    • Day 3

      • fix problem of memdup not being able to alloc so much memory... use 64K page sizes for now
      • code refactoring
      • I'm now able to load the crash kernel
      • When using virtme I can boot into the crash kernel, also it doesn't boot completely (major milestone!), crash in elfcorehdr_read_notes()
    • Day 4

      • crash systems crashes (no pun intended) in copy_old_mempage() link; will need to understand elfcorehdr...
      • call path vmcore_init() -> parse_crash_elf_headers() -> elfcorehdr_read() -> read_from_oldmem() -> copy_oldmem_page() -> copy_to_iter()
    • Day 5

      • hacking arch/arm64/kernel/crash_dump.c:copy_old_mempage() to see if crash system really starts. It does.
      • fun fact: retested with more reserved memory and with UEFI FW, host kernel crashes in init but directly starts the crash kernel, so it works (somehow) \o/
    • TODOs

      • fix elfcorehdr so that we actually can make use of all this...
      • test where in the boot __init() chain we can/should call kexec_early_dump()