MadLittleMods / linux-notes

1 stars 0 forks source link

AMD Radeon 7900 XTX support on Manjaro #2

Open MadLittleMods opened 1 year ago

MadLittleMods commented 1 year ago

TLDR

Your AMD 7900 XTX GPU probably mostly works out of the box with the latest Manjaro 22.1.2+.

I had to add amdgpu.aspm=0 as a kernel boot param (see section below for exact instruction) in order to get consistent good performance. This issue is best tracked by https://gitlab.freedesktop.org/drm/amd/-/issues/2434

I still have to use the mesa-git and lib32-mesa-git packages in order to get Halo Infinite to launch although other games worked with just mesa/lib32-mesa. So there is some fix between mesa 23.0.3-1 and 23.2.0_devel.171495.8e53b293f88.932463d268438ce945b21718552d92ab-1 at least for Halo (more context).

My system specs for reference:

Check if your GPU is recognized

See instructions below if your GPU isn't recognized out of the box.

Manjaro Settings Manager -> Hardware configuration where my integrated and dedicated GPU's are showing up (iGPU and dGPU)

Before support (Unknown device name (ATI Technologies Inc)) After supported (it looks exactly the same for the AMD 7900XTX :shrug:)
(no change)

Checking drivers. video-linux seems to be the one to care about and use from my reading :shrug: :

$ mhwd --list
> 0000:03:00.0 (0300:1002:744c) Display controller ATI Technologies Inc:
--------------------------------------------------------------------------------
                  NAME               VERSION          FREEDRIVER           TYPE
--------------------------------------------------------------------------------
           video-linux            2018.05.04                true            PCI
     video-modesetting            2020.01.13                true            PCI
            video-vesa            2017.03.12                true            PCI

$ mhwd --listinstalled
> Installed PCI configs:
--------------------------------------------------------------------------------
                  NAME               VERSION          FREEDRIVER           TYPE
--------------------------------------------------------------------------------
           video-linux            2018.05.04                true            PCI

$ mhwd --listinstalled --detail
   NAME:    video-linux
   ATTACHED:    PCI
   VERSION: 2018.05.04
   INFO:    Standard open source drivers.
   PRIORITY:    2
   FREEDRIVER:  true
   DEPENDS: -
   CONFLICTS:   -
   CLASSIDS:    0300 0380 0302 
   VENDORIDS:   1002 8086 10de
$ glxinfo | grep OpenGL
OpenGL vendor string: AMD
OpenGL renderer string: AMD Radeon RX 7900 XTX (gfx1100, LLVM 15.0.7, DRM 3.49, 6.1.26-1-MANJARO)
OpenGL core profile version string: 4.6 (Core Profile) Mesa 23.2.0-devel (git-ebe3b91ca0)
OpenGL core profile shading language version string: 4.60
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL core profile extensions:
OpenGL version string: 4.6 (Compatibility Profile) Mesa 23.2.0-devel (git-ebe3b91ca0)
OpenGL shading language version string: 4.60
OpenGL context flags: (none)
OpenGL profile mask: compatibility profile
OpenGL extensions:
OpenGL ES profile version string: OpenGL ES 3.2 Mesa 23.2.0-devel (git-ebe3b91ca0)
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.20
OpenGL ES profile extensions:

The 7900XTX is actually named and listed using nvtop though (pamac install nvtop then run nvtop)

$ nvtop
Device 0 [AMD Radeon RX 7900 XTX] PCIe GEN 4@16x RX: N/A TX: N/A
 GPU 1455MHz MEM 1249MHz TEMP  44°C FAN  15% POW 108 / 339 W
 GPU[|||||||||||||||||               49%] MEM[|||||||||||       8.060Gi/23.984Gi]
[...]

Getting the GPU to be recognized

Which kernel?

I don't know of a minimum or anything (I've seen a lot of people recommending upgrading to 6.x) but I am working from a fresh Manjaro install and got Linux 6.1.26-1 out of the box

Are there nonfree drivers?

There are AMDGPU PRO drivers (proprietary) listed from the table on https://wiki.archlinux.org/title/Xorg#Driver_installation. But from some replies on Reddit, it seems like you don't want to use them over the free drivers since they lack something important (can't recall).

xf86-video-amdgpu (driver) -> amdgpu-pro-oglp/lib32-amdgpu-pro-oglp (OpenGL)

Open-source drivers

You might already have some installed. See what you have with pamac search xf86 --installed and compare with the table on https://wiki.archlinux.org/title/Xorg#Driver_installation

xf86-video-amdgpu and xf86-video-ati (drivers) -> mesa and lib32-mesa (OpenGL)

$ pamac search xf86 --installed
libxxf86vm                                                       1.1.5-1                     extra 
    X11 XFree86 video mode extension library
lib32-libxxf86vm                                                 1.1.5-1                     multilib 
    X11 XFree86 video mode extension library (32-bit)
xf86-video-nouveau                                               1.0.17-2                    extra 
    Open Source 3D acceleration driver for nVidia cards
xf86-video-intel                                                 1:2.99.917+923+gb74b67f0-1  extra 
    X.org Intel i810/i830/i915/945G/G965+ video drivers
xf86-video-ati                                                   1:19.1.0.r15.g7a6a34af-1    extra 
    X.org ati video driver
xf86-video-amdgpu                                                23.0.0-1                    extra 
    X.org amdgpu video driver
xf86-input-void                                                  1.4.2-1                     extra 
    X.org void input driver
xf86-input-libinput                                              1.3.0-1                     extra 
    Generic input driver for the X.Org server based on libinput
xf86-input-evdev                                                 2.10.6-3                    extra 
    X.org evdev input driver
xf86-input-elographics                                           1.4.3-1                     extra 
    X.org Elographics TouchScreen input driver

$ pamac search mesa --installed
lib32-mesa-git                                                   23.2.0_devel.170864.ebe3b91ca01.d41d8cd98f00b204e9800998ecf8427e-1  AUR 
    an open-source implementation of the OpenGL specification,
    git version
lib32-mesa-demos                                                 8.5.0-1                                                             multilib 
    Mesa demos (32-bit)
mesa-utils                                                       9.0.0-2                                                             extra 
    Essential Mesa utilities
mesa-git                                                         23.2.0_devel.170864.ebe3b91ca01.dae32bb875358c786b404388bf1ee875-1  AUR 
    an open-source implementation of the OpenGL specification,
    git version
mesa-demos                                                       9.0.0-2                                                             extra 
    Mesa demos

Using mesa and lib32-mesa (works as of 2023-05-08)

The package repositories finally have mesa@23+ compiled with llvm@15 which means you should be able to simply install these stable versions. Or maybe if you're installing Manjaro from scratch, all of this just works out of the box?

$ pamac install mesa
$ pamac install lib32-mesa

And for reference, here is what the repositories look like as of 2023-05-08.

$ pamac search llvm
llvm                                                            [Installed] 15.0.7-2                                                      extra 
    Compiler infrastructure

$ pamac search mesa
mesa                                                       [Installed] 23.0.3-1                                                            extra 
    An open-source implementation of the OpenGL specification

$ pamac search lib32-mesa
lib32-mesa                                                 [Installed] 23.0.3-1                                                            multilib 
    An open-source implementation of the OpenGL specification (32-bit)

Using mesa-git and lib32-mesa-git (no longer needed)

Using mesa-git and lib32-mesa-git The AMD Radeon 7900XTX does not have drivers shipped on Manjaro (Arch) because it's stuck on LLVM 14 and AMD 7900 GPUs need at least LLVM 15 (also recommended to have any kernel 6.1 or higher). According to [*comment in the Manjaro forum*](https://forum.manjaro.org/t/temporary-solution-to-get-7900-xt-x-to-work/129529/14), as of 2023-01-19, [`mesa-git`](https://aur.archlinux.org/packages/mesa-git) from AUR has also been updated to use LLVM/Clang 15.0.7 without setting `WHICH_LLVM` manually. I was able to install [`mesa-git`](https://aur.archlinux.org/packages/mesa-git) and [`lib32-mesa-git`](https://aur.archlinux.org/packages/lib32-mesa-git) with the following commands. Keep in mind that until I figured out `mesa-git` was updated to build out of the box now, I also messed with the below manual build instructions so if you run into any weirdness maybe you also have to uninstall/install some of the same things mentioned below. ```sh $ pamac install directx-headers-git $ pamac install mesa-git $ pamac install lib32-mesa-git # Afterwards $ pamac search mesa-git --installed lib32-mesa-git 23.2.0_devel.170561.040aeb5a23e.d41d8cd98f00b204e9800998ecf8427e-1 AUR an open-source implementation of the OpenGL specification, git version mesa-git 23.2.0_devel.170561.040aeb5a23e.dae32bb875358c786b404388bf1ee875-1 AUR an open-source implementation of the OpenGL specification, git version $ glxinfo|grep -E "OpenGL vendor|OpenGL renderer" OpenGL vendor string: AMD OpenGL renderer string: AMD Radeon RX 7900 XTX (gfx1100, LLVM 15.0.7, DRM 3.49, 6.1.25-1-MANJARO) ``` References: - https://old.reddit.com/r/ManjaroLinux/comments/zr1jhj/manjaroarch_and_radeon_7900_series_a_howto_guide/?sort=new - https://forum.manjaro.org/t/temporary-solution-to-get-7900-xt-x-to-work/129529 - Linked from https://forum.manjaro.org/t/how-to-get-7900-xtx-working/129722 - https://old.reddit.com/r/archlinux/comments/zn8fhb/rx_7900xtx_llvmpipe/j18jfi5/ - Linked from https://old.reddit.com/r/archlinux/comments/yc68pp/comment/j2oyuq9/ - https://forum.level1techs.com/t/manjaro-7900-xtx-issues/192250 - Comments from this video are useful to see other success stories: https://www.youtube.com/watch?v=6iBOmcDZv_E - https://www.reddit.com/r/archlinux/comments/vv6ibz/whats_up_with_mesagit/ - https://aur.archlinux.org/packages/mesa-git - https://aur.archlinux.org/packages/lib32-mesa-git

Manual build steps (no longer needed)

Manual build steps 1. Get some prerequisites to build C++ things: `pamac install make gcc clang base-devel` 1. Remove some conflicting packages: `sudo pacman -Rs shiboken6 pyside6 web-installer-url-handler manjaro-hello` 1. `sudo pacman -S directx-headers libclc` 1. To make the build go faster, you can edit `/etc/makepkg.conf` -> `MAKEFLAGS="-jX"` where X is the number of jobs/cores you want the build to run with. I used `MAKEFLAGS="-j12"` for example. - via https://forum.manjaro.org/t/how-do-i-limit-pamac-or-yays-cpu-core-usage-while-compiling/55043 1. Download latest snapshots for both [`mesa-git`](https://aur.archlinux.org/packages/mesa-git) and [`lib32-mesa-git`](https://aur.archlinux.org/packages/lib32-mesa-git) from AUR. For those of you unaware of what that means, for example, go to https://aur.archlinux.org/packages/mesa-git, on the right of the page you see a link called "Download Snapshot", and you download said gz file. Same for lib32-mesa-git. 1. Run through these commands: ``` $ mkdir ~/build $ cd ~/build $ cp ~/Downloads/mesa-git.tar.gz mesa-git.tar.gz $ cp ~/Downloads/lib32-mesa-git.tar.gz lib32-mesa-git.tar.gz $ tar zxvf mesa-git.tar.gz $ tar zxvf lib32-mesa-git.tar.gz $ yay --mflags "--nocheck" --sudoloop -S llvm-minimal-git lib32-llvm-minimal-git $ cd ~/build/mesa-git $ MESA_WHICH_LLVM=1 makepkg -si $ cd ~/build/lib32-mesa-git $ MESA_WHICH_LLVM=1 makepkg -si $ shutdown -r now ``` 1. If the build ever fails, in order to resume, make sure to answer **N**o to a `cleanBuild` of the given packages - See https://www.reddit.com/r/archlinux/comments/nrojwe/what_does_packages_to_cleanbuild_mean_with_yay/

Do I want the Vulkan drivers?

I don't think so.

From replies around the internet, it seems like you want to uninstall anything amdvlk or vulkan related to get good performance.

GPU usage monitoring

Check if your dedicated GPI is set as the primary OpenGL renderer

$ glxinfo | grep "OpenGL renderer"
OpenGL renderer string: AMD Radeon RX 7900 XTX (gfx1100, LLVM 15.0.7, DRM 3.49, 6.1.26-1-MANJARO)

You can see if you're GPU is being utilized when playing games.

It's still sometimes stuttering/hitching/low FPS, awful load time mess

Sometimes, it seems to regress and there is a lot of hitching and stutter even in the Steam UI but nvtop does have the AMD Radeon RX 7900 XTX name and shows usage when this happens. Although it shows usage on the integrated GPU (iGPU) and dedicated GPU (dGPU).

I can easily tell when it's bad because the steam UI glow around achievements is stuttering/hitching and even just moving the Steam window around is bad. I don't know the cause yet around why it's sometimes good and not.

With stutter Without stutter

One hunch for good vs bad mode in terms of hitching is it happens after I install something like pamac install code which updates and builds all other packages (including mesa-git) and my computer needs a restart to get the "driver" in place again. Although, even after restarting my PC, I have seen it still stutter before :thinking:

Another hunch I had was that it was sometimes choosing my integrated GPU which kinda makes sense in terms of the bad performance I was seeing. After disabling the iGPU (see instructions below), things also appeared good on first boot but then still experienced laggy bad mode later after gaming.

Other references:

Disable integrated GPU (iGPU)

Shut-down your computer and go into your BIOS (F2 or DEL for my Asus Prime x670-P WIFI motherboard) -> Advanced mode -> Advanced -> NB Configuration -> set Integrated Graphics as Disabled -> Save and reset

(on the same page, Primary Video Device was already set to PCIE Video which is the dedicated GPU)

This didn't seem to help.

Related:

Use amdgpu.aspm=0 to disable power management fixed my problems :rocket:

As discovered in https://gitlab.freedesktop.org/drm/amd/-/issues/2434, the workaround by adding amdgpu.aspm=0 as a kernel boot param to disable active state power management worked to give me consistent good performance!

  1. Edit /etc/default/grub
  2. Add amdgpu.aspm=0 to GRUB_CMDLINE_LINUX_DEFAULT="..."
  3. Restart computer

Since that fixed my problem, I replied on that issue with some more reproduction info and explaining the same context from this issue -> https://gitlab.freedesktop.org/drm/amd/-/issues/2434#note_1929459

Restart/reset GPU driver

TBD: needs solution.

I want to restart/reset the GPU driver whenever I see some odd behavior to better debug which layer is going wrong and as a get out of jail free card.

Restart the X server from terminal

To restart the Xorg/X server (X11),

TODO

Restart the display manager:

sudo systemctl restart lightdm

Restart the X server with the Ctrl + Alt + Backspace keyboard shortcut

There is a Ctrl + Alt + Backspace shortcut you can enable with the following config:

/etc/X11/xorg.conf.d/00-keyboard.conf

Section "ServerFlags"
    Option "DontZap" "false"
EndSection

Section "InputClass"
    Identifier      "Keyboard Defaults"
    MatchIsKeyboard "yes"
    Option          "XkbOptions" "terminate:ctrl_alt_bksp"
EndSection

View Xorg server logs

Logs are stored in /var/log/Xorg.*

$ ls -la /var/log/
...
-rw-r--r--   1 root root             79522 May 20 13:38 Xorg.0.log
-rw-r--r--   1 root root             80829 May 20 13:37 Xorg.0.log.old
-rw-r--r--   1 root root             54502 May 20 11:43 Xorg.1.log
-rw-r--r--   1 root root             54574 May 19 10:57 Xorg.1.log.old

To view the most recent logs,

$ less /var/log/Xorg.0.log

# View the logs starting from the bottom
$ less +G /var/log/Xorg.0.log

Here are my logs from 2023-05-20 when it's not working and being laggy (bad mode), https://gist.github.com/MadLittleMods/4ba2d5ab5116c713ab229ddfb93ff30d