# 3D problems on AMD Radeon RX 580

## Levenstein

Hello everyone !

I've recently acquired a brand new computer with a Ryzen 5 1600 and an AMD Radeon RX 580 graphics card, for which I wanted to install a Gentoo system. After quite a bit of trial and error, I have a mostly working system, with a few weirdies however. For one thing, Blender has some strange interface flickering problems, which is quite sad since I especially intended to do 3D modeling ; the program seems to work, but the interface sometimes flickers, especially on input like when the mouse is moving or a button is clicked. Also, when making it fullscreen (with the WM bar button), some areas randomly start displaying random pixel values, or at least what seems to be random colors. Still with quite a bit of flickering and quick oscillation. So it might in fact be about input, I'm afraid I can't tell, but I just assumed the GPU and drivers where causing some kind of problem since everything worked fine up until installing graphics. I've installed the official gentoo amdgpu (non pro) drivers without a problem, and other 3D applications seem to work, like Supertuxkart, though. And the Linux firmware too, in case it helps.

Another problem is that some applications seem to randomly segfault ; it happend a few times while emerging some packages after having installed Xorg and the Mate desktop environment, though just restarting the emerge made it work. Similar problem with Firefox, which sometimes crashes randomly.

Anways, if someone has a clue or a direction to explore, I'd be very glad to learn about it  :Smile: 

----------

## NeddySeagoon

Levenstein,

Welcome to Gentoo.

We need something to work with. Make friends with wgetpaste.

Put the output of 

```
lspci -nnk
```

 in a post.

Use wgetpaste to post the output of the following commands.

```
dmesg

emerge --info
```

and the following files

```
/var/log/Xorg.0.log

/usr/src/linux/.config
```

Post the links you gen from wgetpaste.

lspci will tell about your hardware, dmesg is your kernel log. It will be especially interesting if it contains a segfault.

emerge --info gives your basic system configuration and versions of key packages in use.

var/log/Xorg.0.log tells what Xorg did when it started.

/usr/src/linux/.config is your kernel setup file.

----------

## Levenstein

Hi,

Here is the output of lspci :

```
00:00.0 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) Root Complex [1022:1450]

   Subsystem: Micro-Star International Co., Ltd. [MSI] Family 17h (Models 00h-0fh) Root Complex [1462:7b07]

00:00.2 IOMMU [0806]: Advanced Micro Devices, Inc. [AMD] Device [1022:1451]

   Subsystem: Advanced Micro Devices, Inc. [AMD] Device [1022:1451]

00:01.0 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) PCIe Dummy Host Bridge [1022:1452]

00:01.3 PCI bridge [0604]: Advanced Micro Devices, Inc. [AMD] Device [1022:1453]

   Kernel driver in use: pcieport

00:02.0 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) PCIe Dummy Host Bridge [1022:1452]

00:03.0 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) PCIe Dummy Host Bridge [1022:1452]

00:03.1 PCI bridge [0604]: Advanced Micro Devices, Inc. [AMD] Device [1022:1453]

   Kernel driver in use: pcieport

00:04.0 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) PCIe Dummy Host Bridge [1022:1452]

00:07.0 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) PCIe Dummy Host Bridge [1022:1452]

00:07.1 PCI bridge [0604]: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) Internal PCIe GPP Bridge 0 to Bus B [1022:1454]

   Kernel driver in use: pcieport

00:08.0 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) PCIe Dummy Host Bridge [1022:1452]

00:08.1 PCI bridge [0604]: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) Internal PCIe GPP Bridge 0 to Bus B [1022:1454]

   Kernel driver in use: pcieport

00:14.0 SMBus [0c05]: Advanced Micro Devices, Inc. [AMD] FCH SMBus Controller [1022:790b] (rev 59)

   Subsystem: Micro-Star International Co., Ltd. [MSI] FCH SMBus Controller [1462:7b07]

00:14.3 ISA bridge [0601]: Advanced Micro Devices, Inc. [AMD] FCH LPC Bridge [1022:790e] (rev 51)

   Subsystem: Micro-Star International Co., Ltd. [MSI] FCH LPC Bridge [1462:7b07]

00:18.0 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) Data Fabric: Device 18h; Function 0 [1022:1460]

00:18.1 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) Data Fabric: Device 18h; Function 1 [1022:1461]

00:18.2 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) Data Fabric: Device 18h; Function 2 [1022:1462]

00:18.3 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) Data Fabric: Device 18h; Function 3 [1022:1463]

   Kernel driver in use: k10temp

   Kernel modules: k10temp

00:18.4 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) Data Fabric: Device 18h; Function 4 [1022:1464]

00:18.5 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) Data Fabric: Device 18h; Function 5 [1022:1465]

00:18.6 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) Data Fabric Device 18h Function 6 [1022:1466]

00:18.7 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) Data Fabric: Device 18h; Function 7 [1022:1467]

03:00.0 USB controller [0c03]: Advanced Micro Devices, Inc. [AMD] Device [1022:43bc] (rev 02)

   Subsystem: ASMedia Technology Inc. Device [1b21:1142]

   Kernel driver in use: xhci_hcd

   Kernel modules: xhci_pci

03:00.1 SATA controller [0106]: Advanced Micro Devices, Inc. [AMD] Device [1022:43b8] (rev 02)

   Subsystem: ASMedia Technology Inc. Device [1b21:1062]

   Kernel driver in use: ahci

   Kernel modules: ahci

03:00.2 PCI bridge [0604]: Advanced Micro Devices, Inc. [AMD] Device [1022:43b3] (rev 02)

   Kernel driver in use: pcieport

16:04.0 PCI bridge [0604]: Advanced Micro Devices, Inc. [AMD] Device [1022:43b4] (rev 02)

   Kernel driver in use: pcieport

16:05.0 PCI bridge [0604]: Advanced Micro Devices, Inc. [AMD] Device [1022:43b4] (rev 02)

   Kernel driver in use: pcieport

16:06.0 PCI bridge [0604]: Advanced Micro Devices, Inc. [AMD] Device [1022:43b4] (rev 02)

   Kernel driver in use: pcieport

16:07.0 PCI bridge [0604]: Advanced Micro Devices, Inc. [AMD] Device [1022:43b4] (rev 02)

   Kernel driver in use: pcieport

1b:00.0 Ethernet controller [0200]: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller [10ec:8168] (rev 15)

   Subsystem: Micro-Star International Co., Ltd. [MSI] RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller [1462:7b07]

   Kernel driver in use: r8169

   Kernel modules: r8169

1f:00.0 VGA compatible controller [0300]: Advanced Micro Devices, Inc. [AMD/ATI] Ellesmere [Radeon RX 470/480/570/580] [1002:67df] (rev e7)

   Subsystem: Sapphire Technology Limited Radeon RX 570 [1da2:e366]

   Kernel driver in use: amdgpu

   Kernel modules: amdgpu

1f:00.1 Audio device [0403]: Advanced Micro Devices, Inc. [AMD/ATI] Ellesmere [Radeon RX 580] [1002:aaf0]

   Subsystem: Sapphire Technology Limited Ellesmere [Radeon RX 580] [1da2:aaf0]

   Kernel driver in use: snd_hda_intel

   Kernel modules: snd_hda_intel

20:00.0 Non-Essential Instrumentation [1300]: Advanced Micro Devices, Inc. [AMD] Device [1022:145a]

   Subsystem: Advanced Micro Devices, Inc. [AMD] Device [1022:145a]

20:00.2 Encryption controller [1080]: Advanced Micro Devices, Inc. [AMD] Device [1022:1456]

   Subsystem: Advanced Micro Devices, Inc. [AMD] Device [1022:1456]

20:00.3 USB controller [0c03]: Advanced Micro Devices, Inc. [AMD] USB3 Host Controller [1022:145c]

   Subsystem: Micro-Star International Co., Ltd. [MSI] USB3 Host Controller [1462:7b07]

   Kernel driver in use: xhci_hcd

   Kernel modules: xhci_pci

21:00.0 Non-Essential Instrumentation [1300]: Advanced Micro Devices, Inc. [AMD] Device [1022:1455]

   Subsystem: Advanced Micro Devices, Inc. [AMD] Device [1022:1455]

21:00.2 SATA controller [0106]: Advanced Micro Devices, Inc. [AMD] FCH SATA Controller [AHCI mode] [1022:7901] (rev 51)

   Subsystem: Micro-Star International Co., Ltd. [MSI] FCH SATA Controller [AHCI mode] [1462:7b07]

   Kernel driver in use: ahci

   Kernel modules: ahci

21:00.3 Audio device [0403]: Advanced Micro Devices, Inc. [AMD] Device [1022:1457]

   Subsystem: Micro-Star International Co., Ltd. [MSI] Device [1462:fb07]

   Kernel driver in use: snd_hda_intel

   Kernel modules: snd_hda_intel
```

The pastebins of dmesg and emerge --info, though I haven't had a crash on this boot :

http://dpaste.com/297108J

http://dpaste.com/2T0WTMB

And finally Xorg's log and the kernel config :

http://dpaste.com/27N0Q0M

http://dpaste.com/1F3PJKR

Hope this helps !

----------

## NeddySeagoon

Levenstein,

All those things look good. 

The amdgpu is still under fairly heavy development.

Your kernel is Linux version 4.19.27-gentoo-r1.

Try the testing gentoo-sources. Be sure that your linux-firmware is up to date too.

A few amdgpu driver versions have added new firmware files.

There is also a testing version of x11-drivers/xf86-video-amdgpu which is worth trying.

----------

## xdarma

 *Levenstein wrote:*   

> 
> 
> And finally Xorg's log and the kernel config :
> 
> http://dpaste.com/27N0Q0M
> ...

 

Hi, I use a Radeon RX-570 with success, OpenCL support included.

Your kernel config looks correct to me, except for some small things like:

```

CONFIG_AGP=y

CONFIG_AGP_AMD64=y

CONFIG_AGP_INTEL=y

CONFIG_AGP_SIS=y

CONFIG_AGP_VIA=y

```

I have configured all as module.

You have disabled AMD_IOMMU_V2, in my system is a module.

Contrary to me, you have configured amdgpu for debug: does this options gives you something useful?

----------

## Levenstein

Hi,

Sorry for the delay, but I've tried a lot of things and nothing seems to work. In fact, recompiling Blender seemed to solve its flickering problem ; but then the system freezed while I was using it. I tried the latest testing kernel (5.0.4 that is), same for linux-firmware, same for the xf86-video-amdgpu driver, but the system still eventually freezes. It does seem to be linked to graphic, as it only seems to happen when the X server is running. Especially, I've had one freeze when I was in the linux console, while the display manager (lightdm) was running, as I forgot to stop it. But never when I did stop the service and stayed in the console.

The last freeze I had seems consistent with the graphics-problem hypothesis, since I launched a few instances of glxgears and vkcube, not quite to strength test the system, but just to see if it would freeze again, and it did. Also, there is a new flickering problem, which is global this time : there are some black bands which appear in the lower part of the screen, apparently when there is some significant change in the displayed image, in particular when I move windows.

Kernel conf seems ok, installation went without problems, so I'm running out of ideas... The curious part is that in the beginning, just to test the system, I installed a Debian with a more recent kernel, and it did not have any of those problems ; maybe are there some distribution specific patches ?

----------

## Elleni

Did you build with CFLAGS="-O2 -march=znver1" in make.conf ? Are you sure, its graphics related? I have a ryzen 5 1600 box with rx580 and the only time I had freezes - they were cpu related if I remember correctly. Using gentoo-sources with experimental useflag and enabling Zen family in processor type and features solved that for me. Sorry for posting if this is unrelated to your problem.

My .config kernel config file: 

https://bpaste.net/show/1a8ee6b3a0d3

Maybe worth a read: 

https://bugzilla.kernel.org/show_bug.cgi?id=196683#c9

----------

## Levenstein

I built everything with "-O2 -march=native -pipe", as advised in the Handbook  :Smile:  And I'm not sure, it seemed related to graphics to me, but I could very well be wrong. If I understand the bugzilla feed correctly, the problem might be linked to power management in some Ryzen processors ? I've rebuilt the latest, testing and experimental gentoo-sources with the Zen option as you advised, and I got a kernel crash this time, not a freeze, but it seems consistent with the feed.

 I am very new to Gentoo though, what would the solution then be ?

----------

## NeddySeagoon

Levenstein,

Add 

```
pci=nomsi
```

to the kernel line in grub.conf

It forces the system to revert to the old IRQ system everywhere.

Its more robust and there is a small performance hit.

----------

## Elleni

Do you have CONFIG_RCU_NOCB_CPU=y in your kernel .config ?

----------

## Levenstein

Hi,

I've tried both options (the kernel command-line and recompiling with the RCU option) and for now the system seems stable, we'll see how it evolves. It did not solve the screen flickering problem though ; I discovered it depends on the frequency of the screen : at 50 everything seems fine, at 60 there are black stripes flashing randomly maybe every two second, more so when I move windows around or they are in fullscreen, and at 75 it's basically the same than 60, but a tad worse. Also, the black stripes are a bit lower on the screen, so I'm wondering if there isn't something like a synchronisation problem between the screen and the GPU.

I also noticed that sometimes, the complete screen flashes, either white or black, though my eyes are probably not good enough to tell the difference at this speed, but it definitely flashes from time to time (at 60 Hz or 75 Hz, but not 50 Hz again). Finally, the garbage window content still sometimes appears, especially when I launch Blender ; but a screenshot will be much easier to understand, how can I share an image on the forum  :Smile:  ?

----------

## NeddySeagoon

Levenstein,

That description fits 'video tearing', which happens when the GPU cannot draw the next image in less time than it takes to refresh the screen with the current image.

You cant trigger it by turning off double buffering, so that the GPU draws directly to to the displayed pixel buffer.

Don't do that, its really ugly.

Please put your /var/log/xorg.0.log onto a pastebin. There may be hints there. That's what Xorg did when it started.

The output of 

```
cat /etc/X11/xorg.conf/* 
```

  will be useful too. That's what you asked it to do.

The two are not always the same.

-- edit --

A screenshot may not show what's actually on the screen. Screenshots capture the content of the pixel buffer in the video card.

If you are getting video artefacts for whatever reason, they will not appear. The pixel buffer will be correct.

Post the image to a picture hosting site and post a link on the forums.

----------

## Levenstein

Hi,

I don't think it's video tearing, at least not the usual kind ; it did appear in the begginning, but I configured xorg.conf and the "stepping effect" on windows borders, for instance, gladly went away. The black flickering stripes are still there, though. Here is Xorg's log though :

http://dpaste.com/22GNXFH

As you pointed out NeddySeagoon, can't get the black stripes in a screenshot :p But the colorful thingies happening only in Blender do appear, so here is one :

https://pasteboard.co/IbWL3lZ.png

And I also managed to obtain a screenshot of Blender's interface when it's doing one of these blinks :

https://pasteboard.co/IbWLm2B.png

----------

