# xorg acceleration broken on r600



## hlindh (Mar 14, 2017)

Card is radeon 5xxx, machine macpro1,1. I'm quite certain that with 10.3 and ports from around the end of last year, acceleration was working fine on the same machine. Now I upgraded to stable/11 and the latest xorg/mesa packages from ports/head (r436131) and I'm getting no accelerated GL.

startx says:

```
X.Org X Server 1.18.4
Release Date: 2016-07-19
...
(II) [KMS] Kernel modesetting enabled.
pci id for fd 6: 0000:0000, driver (null)
EGL_MESA_drm_image required.
pci id for fd 7: 0000:0000, driver (null)
```

In X.org.log, there is:

```
[ 12832.966] (II) glamor: OpenGL accelerated X.org driver based.
[ 12833.118] (II) glamor: EGL version 1.4 (DRI2):
[ 12833.119] EGL_MESA_drm_image required.
[ 12833.121] (EE) RADEON(0): glamor detected, failed to initialize EGL.
...
[ 12833.355] (--) RandR disabled
[ 12833.420] (EE) AIGLX error: Calling driver entry point failed
[ 12833.422] (EE) AIGLX: reverting to software rendering
[ 12833.488] (II) AIGLX: enabled GLX_MESA_copy_sub_buffer
[ 12833.489] (II) AIGLX: Loaded and initialized swrast
[ 12833.489] (II) GLX: Initialized DRISWRAST GL provider for screen 0
```

And glxinfo and other GL apps say:

```
pci id for fd 4: 0000:0000, driver (null)
pci id for fd 7: 0000:0000, driver (null)
libGL error: failed to create dri screen
libGL error: failed to load driver: r600
```

Radeonkms, radeon firmware and drm2 load and seem to work.


----------



## rigoletto@ (Mar 15, 2017)

I apparently managed to "solve" using adding


```
Option "DRI" "2"
```

to Xorg Device section. However I am still getting some mouse pointer lagging, but I do not know  yet if it is related with the same problem, or with i3/compton I am using.


----------



## hlindh (Mar 16, 2017)

lebarondemerde said:


> I apparently managed to "solve" using adding
> 
> 
> ```
> ...



Thanks, but no dice here. It was already "using" DRI2 so forcing it did absolutely nothing. Are you sure acceleration is working for you? What does `glxinfo | grep Device` output?


----------



## rigoletto@ (Mar 16, 2017)

The mine one also was using DRI2 already but the message just disappeared after I add in the option on in there.

I am quite sure acceleration is working because I am using x11-wm/compton with GLX backend. 


```
Device: AMD RS880 (DRM 2.29.0 / 11.0-RELEASE-p8, LLVM 3.9.1) (0x9715)
```


----------



## hlindh (Mar 16, 2017)

lebarondemerde said:


> The mine one also was using DRI2 already but the message just disappeared after I add in the option on in there.
> 
> I am quite sure acceleration is working because I am using x11-wm/compton with GLX backend.
> 
> ...



Yeah, that's about right. It's llvmpipe software renderer along with all the above mentioned errors here regardless of forcing DRI2 or not.

In my previous setup I had hald running because of GNOME and I installed everything using pkg. Now I did a clean install from ports and didn't want GNOME or hald and configured xorg to use devd accordingly.


----------



## hlindh (Mar 16, 2017)

lebarondemerde said:


> The mine one also was using DRI2 already but the message just disappeared after I add in the option on in there.
> 
> I am quite sure acceleration is working because I am using x11-wm/compton with GLX backend.



Maybe you can help me analyse the problem. I'm pretty sure it's something trivial - something not getting built or something built with the wrong options, such as wrong CPU SIMD stuff.

Could you provide the following from your system:

`pkg info |grep -E "libGL|gles|xorg|xf86|dri|drm|vdpau"`
`find /usr/ -iname "*r600*" 2> /dev/null`
`find /usr/ -name "libGL*" 2> /dev/null`
Did you use pkg or ports?
CPU model?


----------



## rigoletto@ (Mar 16, 2017)

I am using ports, but until a few of days ago it was all pkgs. This installation was made on last friday.
*
AMD FX(tm)-8120 Eight-Core*

`pkg info |grep -E "libGL|gles|xorg|xf86|dri|drm|vdpau"`


```
dri-13.0.5,2                   OpenGL hardware acceleration drivers for the DRI
dri2proto-2.8                  DRI2 prototype headers
libGL-13.0.5                   OpenGL library that renders using GLX or DRI
libGLU-9.0.0_2                 OpenGL utility library
libXxf86dga-1.1.4_3            X DGA Extension
libXxf86misc-1.0.3_3           X XF86-Misc Extension
libXxf86vm-1.1.4_1             X Vidmode Extension
libdrm-2.4.75_2,1              Userspace interface to kernel Direct Rendering Module services
libglesv2-13.0.5               OpenGL ES v2 library
libva-1.7.3                    VAAPI wrapper and dummy driver
libvdpau-1.1.1                 VDPAU wrapper and tracing library
qt5-sqldrivers-sqlite3-5.7.1   Qt SQLite 3 database plugin
uhidd-0.2.1_3                  Userland USB HID device driver using libusb20
xdriinfo-1.0.5                 Query configuration information of DRI drivers
xf86-input-keyboard-1.9.0_1    X.Org keyboard input driver
xf86-input-mouse-1.9.2_1       X.Org mouse input driver
xf86-video-ati-7.8.0_1,1       X.Org ati display driver
xf86dga-1.0.3_1                Test program for the XFree86-DGA extension
xf86dgaproto-2.1               XFree86-DGA extension headers
xf86miscproto-0.9.3            XFree86-Misc extension headers
xf86vidmodeproto-2.3.1         XFree86-VidModeExtension extension headers
xorg-7.7_2                     X.Org complete distribution metaport
xorg-apps-7.7_2                X.org apps meta-port
xorg-drivers-7.7_5             X.org drivers meta-port
xorg-fonts-7.7_1               X.org fonts meta-port
xorg-fonts-100dpi-7.7          X.Org 100dpi bitmap fonts
xorg-fonts-75dpi-7.7           X.Org 75dpi bitmap fonts
xorg-fonts-cyrillic-7.7        X.Org Cyrillic bitmap fonts
xorg-fonts-miscbitmaps-7.7     X.Org miscellaneous bitmap fonts
xorg-fonts-truetype-7.7_1      X.Org TrueType fonts
xorg-fonts-type1-7.7           X.Org Type1 fonts
xorg-libraries-7.7_2           X.org libraries meta-port
xorg-server-1.18.4,1           X.Org X server and related programs
```

`find /usr/ -iname "*r600*" 2> /dev/null`

```
/usr/src/contrib/llvm/lib/Target/AMDGPU/R600MachineFunctionInfo.cpp
/usr/src/contrib/llvm/lib/Target/AMDGPU/R600RegisterInfo.h
/usr/src/contrib/llvm/lib/Target/AMDGPU/R600ClauseMergePass.cpp
/usr/src/contrib/llvm/lib/Target/AMDGPU/R600MachineScheduler.h
/usr/src/contrib/llvm/lib/Target/AMDGPU/R600ISelLowering.h
/usr/src/contrib/llvm/lib/Target/AMDGPU/R600InstrInfo.h
/usr/src/contrib/llvm/lib/Target/AMDGPU/R600Defines.h
/usr/src/contrib/llvm/lib/Target/AMDGPU/R600ExpandSpecialInstrs.cpp
/usr/src/contrib/llvm/lib/Target/AMDGPU/R600TextureIntrinsicsReplacer.cpp
/usr/src/contrib/llvm/lib/Target/AMDGPU/R600OptimizeVectorRegisters.cpp
/usr/src/contrib/llvm/lib/Target/AMDGPU/R600ControlFlowFinalizer.cpp
/usr/src/contrib/llvm/lib/Target/AMDGPU/R600Schedule.td
/usr/src/contrib/llvm/lib/Target/AMDGPU/R600InstrFormats.td
/usr/src/contrib/llvm/lib/Target/AMDGPU/R600ISelLowering.cpp
/usr/src/contrib/llvm/lib/Target/AMDGPU/R600MachineScheduler.cpp
/usr/src/contrib/llvm/lib/Target/AMDGPU/R600EmitClauseMarkers.cpp
/usr/src/contrib/llvm/lib/Target/AMDGPU/R600RegisterInfo.cpp
/usr/src/contrib/llvm/lib/Target/AMDGPU/R600MachineFunctionInfo.h
/usr/src/contrib/llvm/lib/Target/AMDGPU/R600Intrinsics.td
/usr/src/contrib/llvm/lib/Target/AMDGPU/R600Packetizer.cpp
/usr/src/contrib/llvm/lib/Target/AMDGPU/R600InstrInfo.cpp
/usr/src/contrib/llvm/lib/Target/AMDGPU/R600RegisterInfo.td
/usr/src/contrib/llvm/lib/Target/AMDGPU/R600Instructions.td
/usr/src/contrib/llvm/lib/Target/AMDGPU/MCTargetDesc/R600MCCodeEmitter.cpp
/usr/src/sys/modules/drm2/radeonkmsfw/R600_pfp
/usr/src/sys/modules/drm2/radeonkmsfw/R600_me
/usr/src/sys/modules/drm2/radeonkmsfw/R600_rlc
/usr/src/sys/gnu/dts/arm/spear600-evb.dts
/usr/src/sys/gnu/dts/arm/spear600.dtsi
/usr/src/sys/contrib/dev/drm2/radeonkmsfw/R600_rlc.bin.uu
/usr/src/sys/contrib/dev/drm2/radeonkmsfw/R600_pfp.bin.uu
/usr/src/sys/contrib/dev/drm2/radeonkmsfw/R600_me.bin.uu
/usr/src/sys/dev/drm2/radeon/r600_cs.h
/usr/src/sys/dev/drm2/radeon/r600_audio.c
/usr/src/sys/dev/drm2/radeon/r600_blit_shaders.h
/usr/src/sys/dev/drm2/radeon/r600_cp.h
/usr/src/sys/dev/drm2/radeon/r600.c
/usr/src/sys/dev/drm2/radeon/r600_blit.c
/usr/src/sys/dev/drm2/radeon/r600_blit_kms.c
/usr/src/sys/dev/drm2/radeon/r600_cs.c
/usr/src/sys/dev/drm2/radeon/r600_reg_safe.h
/usr/src/sys/dev/drm2/radeon/reg_srcs/r600
/usr/src/sys/dev/drm2/radeon/r600_cp.c
/usr/src/sys/dev/drm2/radeon/r600_hdmi.c
/usr/src/sys/dev/drm2/radeon/r600_reg.h
/usr/src/sys/dev/drm2/radeon/r600d.h
/usr/src/sys/dev/drm2/radeon/r600_blit_shaders.c
/usr/src/sys/dev/drm/r600_blit.c
/usr/src/sys/dev/drm/r600_cp.c
/usr/src/sys/dev/drm/r600_microcode.h
/usr/local/lib/libXvMCr600.so.1
/usr/local/lib/libXvMCr600.so.1.0
/usr/local/lib/libXvMCr600.so.1.0.0
/usr/local/lib/libXvMCr600.so
/usr/local/lib/dri/r600_dri.so
/usr/local/include/libdrm/r600_pci_ids.h
/usr/lib/debug/boot/kernel/radeonkmsfw_R600_pfp.ko.debug
/usr/lib/debug/boot/kernel/radeonkmsfw_R600_me.ko.debug
/usr/lib/debug/boot/kernel/radeonkmsfw_R600_rlc.ko.debug
```

`find /usr/ -name "libGL*" 2> /dev/null`

```
/usr/local/lib/libGLU.so
/usr/local/lib/libGL.so.1.2.0
/usr/local/lib/libGL.so
/usr/local/lib/libGLEWmx.so.1
/usr/local/lib/libGL.so.1
/usr/local/lib/libGLESv2.so.2.0.0
/usr/local/lib/libGLESv2.so.2
/usr/local/lib/libGLEWmx.a
/usr/local/lib/libGLEW.so.1
/usr/local/lib/libGLEW.so
/usr/local/lib/libGLEWmx.so
/usr/local/lib/libGLESv2.so
/usr/local/lib/libGLU.so.1
/usr/local/lib/libGLEW.a
/usr/local/lib/libGLU.so.1.3.1
/usr/ports/graphics/libGL
/usr/ports/graphics/libGLw
/usr/ports/graphics/libGLU
```

In regards to the mouse issue I said before, this night I build world/kernel and that (EDIT: NOT) desapeared. I did not take a look on why but I had found out it was with a intermittent connection, like this. So, not related with the present subject.


----------



## rigoletto@ (Mar 16, 2017)

You may wanna try this solution, libGL error.


----------



## hlindh (Mar 17, 2017)

lebarondemerde said:


> You may wanna try this solution, libGL error.



I see the same problem as in the bug report you linked earlier. Mine is different. Your dir listings confirmed that everything is getting built and so I started tracing the code and it looks like the actual error is:

```
pci id for fd 6: 0000:0000, driver (null)
```
It comes from mesa/EGL and points to libdrm not giving the correct pci id for the card, thus handing a null driver over to EGL, which then fails to init. Maybe it's a kernel problem, or something in libdrm. I'll look further when I have more time.


----------



## rigoletto@ (Mar 17, 2017)

Glad you find the source of your issue. You can try setting


```
BusID "PCI:6:0:0"
```


----------



## hlindh (Mar 18, 2017)

lebarondemerde said:


> Glad you find the source of your issue. You can try setting
> 
> 
> ```
> ...



Thanks, but forcing BusID won't do anything, already tried that.

I fixed the problem: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=217886

I wonder, though, why it works at all for anyone else..


----------

