[SOLVED] Early boot framebuffer (amdgpu kms modesetting)

Still need help with Gentoo, and your question doesn't fit in the above forums? Here is your last bastion of hope.
Post Reply
sun_runner
n00b
n00b
Posts: 5
Joined: Fri May 12, 2023 9:07 pm

[SOLVED] Early boot framebuffer (amdgpu kms modesetting)

Post by sun_runner »

Greetings everyone,
I'm having a strange issue occuring both on my main desktop (ryzen 7 5700 + radeon rx 6700) and on my laptop (thinkpad e14 g3, ryzen w/ igpu).
System layout: genkernel w/ default gentoo-sources. efibootmgr w/ LUKS.
Issue: During early boot, I'm prompted to unlock my LUKS device. The resolution for this screen is incorrect, it's rendered lower and results in low-res blocky text. Upon unlocking, it outputs the first few steps of OpenRC. Screen output is wiped and the correct resolution is finally loaded. This results in the first few messages on screen being lost. On the laptop, the initial resolution is CORRECT but the wiping still occurs.

I'm not quite sure where exactly I'm going wrong. I'm almost inclined to think it's NOT a firmware issue, and possibly an issue in the kernel config itself. Under Void Linux w/ their default kernel, this does NOT occur on any machine I have. It will prompt for LUKS key and begin runit with NO screen wipe / resolution correction. I'm no expert, but at cursory glance it seems like there's no massive difference in void's .config and gentoo-source's .config. Possibly relevant, but the same exact efibootmgr entry was utilized on both my Void system and Gentoo, so I'm inclined to think this can be mitigated via alterations to the .config file in some way, but I'm not sure.

I'm stumped, any input would be greatly appreciated!


------------------------- ATTEMPTED FIXES -------------------------


1.) putting relevant drivers in genkernel.conf here so that they may be included in initramfs. This was the recommended fix as per this thread
https://forums.gentoo.org/viewtopic-t-1 ... art-0.html
as well as the wiki here https://wiki.gentoo.org/wiki/Genkernel#Firmware_loading

Result: No change. dmesg | grep -i switching still reports (what i assume is wiping) as below
[ 3.649681] Console: switching to colour frame buffer device 128x48
[ 28.558816] Console: switching to colour dummy device 80x25
[ 31.418234] Console: switching to colour frame buffer device 160x45


2.) compiling the drivers directly into the kernel. I inserted the desired firmware into the menu below and successfully compiled the kernel. This process is described here https://wiki.gentoo.org/wiki/AMDGPU#Inc ... g_firmware

Code: Select all

 │     -> Device Drivers                                                                                                  
 │	 -> Generic Driver Options                                                                                        
 │         -> Firmware loader                                                                                             
 │           -> Firmware loading facility (FW_LOADER [=y])                                                                
 │             -> Build named firmware blobs into the kernel binary (EXTRA_FIRMWARE

CONFIG_EXTRA_FIRMWARE="amdgpu/navy_flounder_sos.bin amdgpu/navy_flounder_ta.bin amdgpu/navy_flounder_smc.bin amdgpu/navy_flounder_dmcub.bin amdgpu/navy_flounder_pfp.bin amdgpu/navy_flounder_me.bin amdgpu/navy_flounder_ce.bin amdgpu/navy_flounder_rlc.bin amdgpu/navy_flounder_mec.bin amdgpu/navy_flounder_mec2.bin amdgpu/navy_flounder_vcn.bin amdgpu/navy_flounder_sdma.bin"
Result: It successfully compiled, however, the behavior still persists.


------------------------- MISC INFO -------------------------


* framebuffer switching. this same order occurs w/ both firmware included and not included.
dmesg | grep switch

Code: Select all

[    0.078431] Spectre V2 : Spectre v2 / SpectreRSB mitigation: Filling RSB on context switch
[    3.649681] Console: switching to colour frame buffer device 128x48
[   28.558816] Console: switching to colour dummy device 80x25
[   31.418234] Console: switching to colour frame buffer device 160x45

* On including the firmware in either/or/both the initramfs/vmlinuz, the firmware isn't actually loaded until after I unlock the device.
dmesg | grep -i firmware

Code: Select all

[    0.078432] Spectre V2 : Enabling Restricted Speculation for firmware calls
[    0.263904] ACPI: [Firmware Bug]: BIOS _OSI(Linux) query ignored
[    0.274222] acpi PNP0A08:00: [Firmware Info]: MMCONFIG for domain 0000 [bus 00-7f] only partially covers this bridge
[   27.666282] Loading firmware: regulatory.db
[   27.667220] Loading firmware: regulatory.db.p7s
[   27.712194] Loading firmware: rtl_bt/rtl8822b_fw.bin
[   27.713119] Loading firmware: rtw88/rtw8822b_fw.bin
[   27.713269] Loading firmware: rtl_bt/rtl8822b_config.bin
[   27.718141] rtw_8822be 0000:07:00.0: Firmware version 27.2.0, H2C version 13
[   28.558747] Loading firmware: amdgpu/navy_flounder_sos.bin
[   28.558748] Loading firmware: amdgpu/navy_flounder_ta.bin
[   28.558751] Loading firmware: amdgpu/navy_flounder_smc.bin
[   28.558752] Loading firmware: amdgpu/navy_flounder_dmcub.bin
[   28.558753] Loading firmware: amdgpu/navy_flounder_pfp.bin
[   28.558754] Loading firmware: amdgpu/navy_flounder_me.bin
[   28.558755] Loading firmware: amdgpu/navy_flounder_ce.bin
[   28.558755] Loading firmware: amdgpu/navy_flounder_rlc.bin
[   28.558756] Loading firmware: amdgpu/navy_flounder_mec.bin
[   28.558757] Loading firmware: amdgpu/navy_flounder_mec2.bin
[   28.558760] Loading firmware: amdgpu/navy_flounder_vcn.bin
[   30.671876] [drm] Loading DMUB firmware via PSP: version=0x02020017
[   30.672605] Loading firmware: amdgpu/navy_flounder_sdma.bin
[   30.672633] [drm] Found VCN firmware Version ENC: 1.26 DEC: 2 VEP: 0 Revision: 0
[   30.672643] amdgpu 0000:03:00.0: amdgpu: Will use PSP to load VCN firmware
* kernel framebuffer device support. I've attempted enabling/disabling MANY of these to no avail. current enabled are as follows. truncated for readability

Code: Select all

 │     -> Device Drivers                                 
 │       -> Graphics support                             
 │         -> Frame buffer Devices                       
 │           -> Support for frame buffer devices (FB [=y]│

  [*]   Enable firmware EDID                           
 │ -*-   Enable Video Mode Handling Helpers             
 │ <*>   VGA 16-color graphics support                   
 │ <*>   Userspace VESA VGA graphics support             
 │ [*]   VESA VGA graphics support                       
 │ [*]   EFI-based Framebuffer Support                   
 │ <M>   ATI Radeon display support                      
 │ [*]     DDC/I2C for ATI Radeon support                
 │ [*]     Support for backlight control                 
 │ <*>   Displaylink USB Framebuffer support             
 │ <M>   Simple framebuffer support                      

* My efibootmgr entry is as follows. My vmlinuz is named "gentoosrc" and initramfs "disk.img"

Code: Select all

sudo efibootmgr -d /dev/nvme0n1 -p 1 -c -L GentooSrc -l /vmlinuz -u 'quiet loglevel=0 crypt_root=UUID=8e455a58-6701-4522-8817-824e39c276ae root=UUID=c16c0e86-31f0-4f26-bffa-e2122047fc9a initrd=\initramfs.img'


* GRUB note: I have attempted, early on, to mitigate this by installing GRUB. This does nothing, as GRUB will point to the vmlinuz/initramfs, which then the same problem as described above occurs.

* EDIT: Possible lead below, going to try and find a way to set the amdgpu device to be the primary framebuffer on boot. Not sure how to do that yet.
dmesg | grep fb0

Code: Select all

[    0.000000] efi: ACPI=0x99fb3000 ACPI 2.0=0x99fb3014 TPMFinalLog=0x9aa35000 SMBIOS=0x9c7fb000 SMBIOS 3.0=0x9c7fa000 MEMATTR=0x9344b018 ESRT=0x9688df18 INITRD=0x8e9cdf18 RNG=0x99eb1018 TPMEventLog=0x89574018
[    0.003333] ACPI: Reserving SSDT table memory at [mem 0x99fa9000-0x99fb02af]
[    1.198650] fb0: EFI VGA frame buffer device
[   31.221984] fbcon: amdgpudrmfb (fb0) is primary device
[   31.426362] amdgpu 0000:03:00.0: [drm] fb0: amdgpudrmfb frame buffer device

sun_runner
n00b
n00b
Posts: 5
Joined: Fri May 12, 2023 9:07 pm

Post by sun_runner »

Solved it! For anyone else who may stumble upon this, the issue was explained in a bit more detail at the bottom of the OP.

Essentially, the default framebuffer is usually either EFI VGA or VESA graphics for maximum compatability out of the box. This works but on every machine I've use it, it results in either font size strangeness and/or flickering that persists until boot runlevel (after LUKS). I'm no expert but I'll the fix, relevant kernel options and related reading below.

1.) Ensure firmware is compiled into kernel. This accepts relative path from /lib/firmware. I added every single relevant firmware found from the command below as space separated values Under "Loading Facility" you may put any/all ".bin" files for your relevant device as space separated values with relative path. Example below. I had 14 total, which worked. Read more here: https://wiki.gentoo.org/wiki/AMDGPU#Inc ... g_firmware

Code: Select all

 │     -> Device Drivers                                                                                
 │	 -> Generic Driver Options                                                                      
 │         -> Firmware loader                                                                           
 │           -> Firmware loading facility (FW_LOADER [=y])                                              
 │             -> Build named firmware blobs into the kernel binary (EXTRA_FIRMWARE)

 -*- Firmware loading facility                                                                         │
 │     (amdgpu/navy_flounder_sos.bin amdgpu/navy_flounder_ta.bin

2.) Kernel options.
Here, admittedly, I am not an expert. I tried various options toggled <M>, <*> and disabled. I'll post what worked for me below. All of these options relate to framebuffer devices. Read more here: https://wiki.gentoo.org/wiki/Xorg/Guide ... odesetting

Code: Select all

> Device Drivers                                                              
     -> Firmware Drivers                                                        
          -> Mark VGA/VBE/EFI FB as generic system framebuffer (SYSFB_SIMPLEFB [=y]) 

 -> Device Drivers                                                                                
     -> Graphics support                                                                            
          -> Direct Rendering Manager (XFree86 4.1.0 and higher DRI support) (DRM [=y])        
          -> Enable legacy fbdev support for your modesetting driver (DRM_FBDEV_EMULATION [=y])	
          -> AMD GPU (DRM_AMDGPU [=y]) 
          -> Simple framebuffer driver (DRM_SIMPLEDRM [=y]) 
          
          -> Frame buffer Devices     (Only have below enabled)                                                                 
                [*]   Enable Video Mode Handling Helpers 
                [*]   Enable Tile Blitting Support
                <*>   VGA 16-color graphics support
                [*]   VESA VGA graphics support
                [*]   EFI-based Framebuffer Support


The resulting setup above resulted in the correct "amdgpudrmfb" to be set on bootup, so the LUKS prompt was not wiped, OpenRC began and no output was lost when I finally logged in. Full disclosure, I'm new to gentoo and may have forgotten to include an option above, so YMMV.
Post Reply