The original words of Phanes, tirelessly carved into a slab of "No'".

Proprietary Linux Drivers: FGLRX (Fedora 23)

Why I Know This Will be Painful:

So, fglrx has always been both critical to performance on an AMD-heavy system and poorly supported in Fedora due to their adamant and passive-aggressive refusal to support proprietary drivers well, convenient version mismatches between fglrx’s Xorg server support and the included version, and other components that can only be explained as behaviours that should be triggering a mass exodus from the distribution in this day and age.

The parts of this that are AMD’s fault were largely rectified by ATI’s acquisition by AMD and it’s gotten much better.  The distribution maintainers have failed to adapt to the post-year-2000 situation in lieu of impressive but still poorly performing 2D Foss drivers on most proprietary chipsets and this not only hurts the distribution as a whole, but its users, and the linux reputation.  The uninformed opinion supported only by misleading benchmarks is that many aspects of the 2D drivers perform better but those of us actually working with both drivers simply know better.

Moving on, the last I recall I did not upgrade to Fedora 23 on my last installation due to Xorg on F23 being too new for fglrx to support.  That was almost two years ago, but I don’t expect children to become adults in only two years when they are so old.  If I recall correctly I upgraded all of my system packages to F23’s versions but left the system at F22 with an F22 stock X server after a few painful nights of struggling through religious software zealotry.

Couldn’t remember which card this was because I so rarely need to make changes at this level due to the cards’ reliability, so I checked using the lspci utility:
[highlighter line = 0]

[root@localhost ~]# lspci | grep VGA
01:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Pitcairn PRO [Radeon HD 7850 / R7 265 / R9 270 1024SP]
04:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Pitcairn PRO [Radeon HD 7850 / R7 265 / R9 270 1024SP]
[root@localhost ~]# 

So it looks like I’m on a Radeon HD 7850.

Confirmed RPMFusion still doesn’t have fglrx:

[root@localhost ~]# dnf search fglrx
Last metadata expiration check performed 1:06:38 ago on Sun Feb 14 22:12:45 2016.
Error: No matches found.
[root@localhost ~]# 

So it looks like there’s another completely preventable and fedora-manufactured storm of bullshit ahead that would already be done by now if I’d have just installed Arch Linux.

Behold, A Guide:

Blue Hat Record has a great guide and I have used their how-to articles before, I think on previous fglrx installs, so I’m going to use that as my reference first and finally chronicle the journey as I go from here.

Exclude Xorg packages from the Repos:

exclude=xorg-x11-server-Xorg xorg-x11-server-common

Execution:

[root@localhost ~]# vim /etc/yum.repos.d/fedora.repo 
[root@localhost ~]# vim /etc/yum.repos.d/fedora-updates.repo 
[root@localhost ~]# vim /etc/yum.repos.d/fedora-updates-testing.repo 
[root@localhost ~]# etckeeper vcs diff
diff --git a/yum.repos.d/fedora-updates-testing.repo b/yum.repos.d/fedora-updates-testing.repo
index c99c037..27e4b7a 100644
--- a/yum.repos.d/fedora-updates-testing.repo
+++ b/yum.repos.d/fedora-updates-testing.repo
@@ -8,6 +8,7 @@ gpgcheck=1
 metadata_expire=6h
 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$releasever-$basearch
 skip_if_unavailable=False
+exclude=xorg-x11-server-Xorg xorg-x11-server-common
 
 [updates-testing-debuginfo]
 name=Fedora $releasever - $basearch - Test Updates Debug
diff --git a/yum.repos.d/fedora-updates.repo b/yum.repos.d/fedora-updates.repo
index 72ec146..27c2da2 100644
--- a/yum.repos.d/fedora-updates.repo
+++ b/yum.repos.d/fedora-updates.repo
@@ -8,6 +8,7 @@ gpgcheck=1
 metadata_expire=6h
 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$releasever-$basearch
 skip_if_unavailable=False
+exclude=xorg-x11-server-Xorg xorg-x11-server-common
 
 [updates-debuginfo]
 name=Fedora $releasever - $basearch - Updates - Debug
diff --git a/yum.repos.d/fedora.repo b/yum.repos.d/fedora.repo
index ba46cd3..101cddb 100644
--- a/yum.repos.d/fedora.repo
+++ b/yum.repos.d/fedora.repo
@@ -8,6 +8,7 @@ metadata_expire=28d
 gpgcheck=1
 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$releasever-$basearch
 skip_if_unavailable=False
+exclude=xorg-x11-server-Xorg xorg-x11-server-common
 
 [fedora-debuginfo]
 name=Fedora $releasever - $basearch - Debug
[root@localhost ~]# etckeeper commit "Excluded xorg-x11-server-Xorg, xorg-x11-server-common on fedora,fedora-updates,fedora-updates-testing repos"
[master 9918cd9] Excluded xorg-x11-server-Xorg, xorg-x11-server-common on fedora,fedora-updates,fedora-updates-testing repos
 Author: phanes <phanes@localhost>
 3 files changed, 3 insertions(+)

Downgrade xorg-x11-server-Xorg and xorg-x11-server-common to the F22 version:

dnf downgrade xorg-x11-server-Xorg xorg-x11-server-common –-allowerasing –-releasever=22

But first, let’s see what versions we have for reference later:

[root@localhost etc]# dnf info xorg-x11-server-Xorg xorg-x11-server-common
Last metadata expiration check performed 2:55:58 ago on Sun Feb 14 22:12:45 2016.
Installed Packages
Name        : xorg-x11-server-Xorg
Arch        : x86_64
Epoch       : 0
Version     : 1.18.0
Release     : 2.fc23
Size        : 3.5 M
Repo        : @System
From repo   : updates
Summary     : Xorg X server
URL         : https://www.x.org
License     : MIT
Description : X.org X11 is an open source implementation of the X Window System.  It
            : provides the basic low level functionality which full fledged
            : graphical user interfaces (GUIs) such as GNOME and KDE are designed
            : upon.

Name        : xorg-x11-server-common
Arch        : x86_64
Epoch       : 0
Version     : 1.18.0
Release     : 2.fc23
Size        : 127 k
Repo        : @System
From repo   : updates
Summary     : Xorg server common files
URL         : https://www.x.org
License     : MIT
Description : Common files shared among all X servers.

[root@localhost etc]# 

So 1.18 for both. Let’s see what’s in F22. I did not immediately see a way to check previous release versions that didn’t just report the F23 packages for these, so I literally copied /etc/yum.repos.d/fedora.repo to /etc/yum.repos.d/fedora-22.repo, and then replaced all instances of $releasever:

[root@localhost yum.repos.d]# cp fedora.repo fedora-22.repo
[root@localhost yum.repos.d]# cat fedora-22.repo 
[fedora]
name=Fedora $releasever - $basearch
failovermethod=priority
#baseurl=https://download.fedoraproject.org/pub/fedora/linux/releases/$releasever/Everything/$basearch/os/
metalink=https://mirrors.fedoraproject.org/metalink?repo=fedora-$releasever&arch=$basearch
enabled=1
metadata_expire=28d
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$releasever-$basearch
skip_if_unavailable=False
exclude=xorg-x11-server-Xorg xorg-x11-server-common

[fedora-debuginfo]
name=Fedora $releasever - $basearch - Debug
failovermethod=priority
#baseurl=https://download.fedoraproject.org/pub/fedora/linux/releases/$releasever/Everything/$basearch/debug/
metalink=https://mirrors.fedoraproject.org/metalink?repo=fedora-debug-$releasever&arch=$basearch
enabled=0
metadata_expire=28d
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$releasever-$basearch
skip_if_unavailable=False

[fedora-source]
name=Fedora $releasever - Source
failovermethod=priority
#baseurl=https://download.fedoraproject.org/pub/fedora/linux/releases/$releasever/Everything/source/SRPMS/
metalink=https://mirrors.fedoraproject.org/metalink?repo=fedora-source-$releasever&arch=$basearch
enabled=0
metadata_expire=28d
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$releasever-$basearch
skip_if_unavailable=False
[root@localhost yum.repos.d]# sed -i 's/\$releasever/22/g' fedora-22.repo 
[root@localhost yum.repos.d]# sed -i 's/\[fedora/\[fedora-legacy/g' fedora-22.repo 

And then supplied the named release=22 switch to dnf info after disabling the other repos:

[root@localhost yum.repos.d]# dnf info --disablerepo="*" --enablerepo="fedora-legacy" xorg-x11-server-Xorg xorg-x11-server-common --release=22
Last metadata expiration check performed 0:02:38 ago on Mon Feb 15 01:25:52 2016.
Installed Packages
Name        : xorg-x11-server-Xorg
Arch        : x86_64
Epoch       : 0
Version     : 1.18.0
Release     : 2.fc23
Size        : 3.5 M
Repo        : @System
From repo   : updates
Summary     : Xorg X server
URL         : https://www.x.org
License     : MIT
Description : X.org X11 is an open source implementation of the X Window System.  It
            : provides the basic low level functionality which full fledged
            : graphical user interfaces (GUIs) such as GNOME and KDE are designed
            : upon.

Name        : xorg-x11-server-common
Arch        : x86_64
Epoch       : 0
Version     : 1.18.0
Release     : 2.fc23
Size        : 127 k
Repo        : @System
From repo   : updates
Summary     : Xorg server common files
URL         : https://www.x.org
License     : MIT
Description : Common files shared among all X servers.

Incredible isn’t it? DNF was actually the replacement of yum as one of the most manageable package managers. Yet here we are specifying verbose repositories, verbose distro release versions, and still getting bullshit. I’m sure there’s an excuse, but it is ultimately bad design.

I’m so fed up with Fedora and this is why.

So I was able to find on one of the F22 mirrors the versions from the package filenames:

xorg-x11-server-Xorg-1.17.1-11.fc22.x86_64.rpm
xorg-x11-server-common-1.17.1-11.fc22.x86_64.rpm

And now you won’t have to waste an hour of your life piecing together broken software with broken tools.

Anyway, looks like we are downgrading these specific two packages to these two specific versions:

xorg-x11-server-Xorg 1.18.0 -> 1.17.11
xorg-x11-server-common 1.18.0 -> 1.17.11

Ok, next we’ll go ahead and downgrade. I’ve documented every bit of what I need to do to clone this system so far so I’m not worried about breaking anything yet.

init 3

Will kill your X11.

dnf downgrade xorg-x11-server-Xorg xorg-x11-server-common –-allowerasing –-releasever=22

Works. Perfect. Now we download the FGLRX installer.

This site should have it:
https://support.amd.com/en-us/download/desktop?os=Linux+x86_64

Check the compatibility list for a Radeon HD 7850: R7/HD 7000 and 8000 is on there. We’re good. I go to download, and it’s a zip file. Gross.

https://www2.ati.com/drivers/linux/radeon-crimson-15.12-15.302-151217a-297685e.zip

This creates a folder called fglrx-15.302/

[phanes@localhost fglrx-15.302]$ ls -l
total 183816
-rwxr-xr-x. 1 phanes phanes 188214093 Dec 18 13:50 amd-driver-installer-15.302-x86.x86_64.run
-rwxr--r--. 1 phanes phanes      7823 Dec 18 13:50 check.sh
drwxr-xr-x. 5 phanes phanes      4096 Dec 18 13:50 doc

I already have the kernel headers installed (you need them to build the driver, dnf install kernel-headers).

[root@localhost fglrx-15.302]# ./amd-driver-installer-15.302-x86.x86_64.run 
Created directory fglrx-install.6T4gXQ
Verifying archive integrity... All good.
Uncompressing AMD Proprietary Driver-15.302...........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
=====================================================================
 AMD  Proprietary Driver Installer/Packager 
=====================================================================
Detected configuration:
Architecture: x86_64 (64-bit)
X Server: X.Org 6.9 or later 64-bit
...

Click on shiny things, press random buttons, and…fail. The installer says its missing pre-requisites listed in /usr/share/ati/fglrx-install.log

[root@localhost fglrx-15.302]# cat /usr/share/ati/fglrx-install.log 
Supported adapter detected.
Supported adapter detected.
Check if system has the tools required for installation.
fglrx installation requires that the system have kernel headers for greater than 3.6 release.  /lib/modules/4.3.5-300.fc23.x86_64/build/include/generated/uapi/linux/version.h cannot be found on this system.
One or more tools required for installation cannot be found on the system. Install the required tools before installing the fglrx driver.
Optionally, run the installer with --force option to install without the tools.
Forcing install will disable AMD hardware acceleration and may make your system unstable. Not recommended.

Ah. Looks like my kernel headers aren’t installed. Except that they are:

[root@localhost fglrx-15.302]# dnf info kernel-headers
Last metadata expiration check performed 0:54:09 ago on Mon Feb 15 01:25:52 2016.
Installed Packages
Name        : kernel-headers
Arch        : x86_64
Epoch       : 0
Version     : 4.3.5
Release     : 300.fc23
Size        : 3.5 M
Repo        : @System
From repo   : updates
Summary     : Header files for the Linux kernel for use by glibc
URL         : https://www.kernel.org/
License     : GPLv2 and Redistributable, no modification permitted
Description : Kernel-headers includes the C header files that specify the interface
            : between the Linux kernel and userspace libraries and programs.  The
            : header files define structures and constants that are needed for
            : building most standard programs and are also needed for rebuilding the
            : glibc package.

More Fedora bullshit.

[root@localhost fglrx-15.302]# dnf search kernel | grep -E "^kernel" | grep "devel"
kernel-tools-libs-devel.i686 : Assortment of tools for the Linux kernel
kernel-tools-libs-devel.x86_64 : Assortment of tools for the Linux kernel
kernel-devel.x86_64 : Development package for building kernel modules to match
kernel-debug-devel.x86_64 : Development package for building kernel modules to
[root@localhost fglrx-15.302]# 

Ah. They’ve split the kernel headers into multiple packages. Glad they broke that convention. kernel-devel and kernel-tools-libs-* it is.

dnf install kernel-tools kernel-tools-libs kernel-devel

Drop to runlevel 3 with `init 3` and try rerunning the installer again.

And so, after swimming around in the bowels of Fedora hell for a few hours I came to understand that making the system compatible would not be enough. I would either need to patch the source so that it would compile on a modern GCC version, downgrade GCC and risk breaking a bunch of stuff, or start following success stories in the comments on that original bluehatrecord article.

I’ll try the comment’s instructions from a user named LyPo first and go from there.

Not working.

After running

amd-driver-installer-15.302-x86.x86_64.run --extract

I then used cd to reach fglrx-install.XXXXX/common/lib/modules/fglrx/build_mod.

[root@localhost build_mod]# ./make.sh 
2.6.x/             drmP.h             firegl_public.h    kcl_agp.h          kcl_debug.h        kcl_ioctl.h        kcl_osconfig.h     kcl_str.h          make.sh
drm_compat.h       drm_proc.h         kcl_acpi.c         kcl.c              kcl.h              kcl_io.h           kcl_pci.c          kcl_type.h         
drm.h              fglrxko_pci_ids.h  kcl_acpi.h         kcl_config.h       kcl_io.c           kcl_iommu.c        kcl_pci.h          kcl_wait.c         
drm_os_linux.h     firegl_public.c    kcl_agp.c          kcl_debug.c        kcl_ioctl.c        kcl_iommu.h        kcl_str.c          kcl_wait.h         
[root@localhost build_mod]# ./make.sh 
AMD kernel module generator version 2.1
doing Makefile based build for kernel 2.6.x and higher
rm -rf *.c *.h *.o *.ko *.a .??* *.symvers
make -C /lib/modules/4.3.5-300.fc23.x86_64/build SUBDIRS=/home/phanes/Downloads/fglrx-15.302/fglrx-install.AUkIMX/common/lib/modules/fglrx/build_mod/2.6.x modules
make[1]: Entering directory '/usr/src/kernels/4.3.5-300.fc23.x86_64'
  CC [M]  /home/phanes/Downloads/fglrx-15.302/fglrx-install.AUkIMX/common/lib/modules/fglrx/build_mod/2.6.x/firegl_public.o
/home/phanes/Downloads/fglrx-15.302/fglrx-install.AUkIMX/common/lib/modules/fglrx/build_mod/2.6.x/firegl_public.c: In function ‘firegl_major_proc_read’:
/home/phanes/Downloads/fglrx-15.302/fglrx-install.AUkIMX/common/lib/modules/fglrx/build_mod/2.6.x/firegl_public.c:634:9: error: void value not ignored as it ought to be
     len = seq_printf(m, "%d\n", major);
         ^
/home/phanes/Downloads/fglrx-15.302/fglrx-install.AUkIMX/common/lib/modules/fglrx/build_mod/2.6.x/firegl_public.c: At top level:
/home/phanes/Downloads/fglrx-15.302/fglrx-install.AUkIMX/common/lib/modules/fglrx/build_mod/2.6.x/firegl_public.c:6448:12: warning: ‘KCL_fpu_save_init’ defined but not used [-Wunused-function]
 static int KCL_fpu_save_init(struct task_struct *tsk)
            ^
scripts/Makefile.build:258: recipe for target '/home/phanes/Downloads/fglrx-15.302/fglrx-install.AUkIMX/common/lib/modules/fglrx/build_mod/2.6.x/firegl_public.o' failed
make[2]: *** [/home/phanes/Downloads/fglrx-15.302/fglrx-install.AUkIMX/common/lib/modules/fglrx/build_mod/2.6.x/firegl_public.o] Error 1
Makefile:1382: recipe for target '_module_/home/phanes/Downloads/fglrx-15.302/fglrx-install.AUkIMX/common/lib/modules/fglrx/build_mod/2.6.x' failed
make[1]: *** [_module_/home/phanes/Downloads/fglrx-15.302/fglrx-install.AUkIMX/common/lib/modules/fglrx/build_mod/2.6.x] Error 2
make[1]: Leaving directory '/usr/src/kernels/4.3.5-300.fc23.x86_64'
Makefile:88: recipe for target 'kmod_build' failed
make: *** [kmod_build] Error 2
build failed with return value 2

So what I’m seeing there particularly is:

CC [M]  /home/phanes/Downloads/fglrx-15.302/fglrx-install.AUkIMX/common/lib/modules/fglrx/build_mod/2.6.x/firegl_public.o
/home/phanes/Downloads/fglrx-15.302/fglrx-install.AUkIMX/common/lib/modules/fglrx/build_mod/2.6.x/firegl_public.c: In function ‘firegl_major_proc_read’:
/home/phanes/Downloads/fglrx-15.302/fglrx-install.AUkIMX/common/lib/modules/fglrx/build_mod/2.6.x/firegl_public.c:634:9: error: void value not ignored as it ought to be
     len = seq_printf(m, "%d\n", major);

Luckily, I have a fresh license for CLion, so not quite lost. However, without looking at the source, it appears that seq_printf() had a declared return type of void, but a variable named len is being assigned its return value. So, that’s a source issue and it could be a whole can of worms about to be opened up. If return type is really declared void, best scenario I change it to:

seq_printf(m, "%d\n", major);
len = NULL;

To achieve the same effect. Got a feeling that’s not all that’ll need changed though. I’m too tired to work on this any more tonight.

20160220 Update

Round 2.  So before I got started I google the issue I was seeing and came across a somewhat informative stackoverflow entry about just this, and it seems this is some shared code that should have been fixed already.

They reference this Manjaro Linux forum post that shows a very similar patch to what I suggested at the end of my last troubleshooting session but assign len to zero and not NULL:

--- a/firegl_public.c
+++ b/firegl_public.c
@@ -627,7 +627,8 @@ static int firegl_major_proc_read(struct
 
     len = snprintf(buf, request, "%d\n", major);
 #else
-    len = seq_printf(m, "%d\n", major);
+    seq_printf(m, "%d\n", major);
+    len = 0;
 #endif
 
     KCL_DEBUG1(FN_FIREGL_PROC, "return len=%i\n",len);

They were troubleshooting something else but this was actually quite helpful.

After trolling in #ubuntu and #debian on freenode I found a helpful patch, because I know fglrx is pretty reliable on Ubuntu. Also, the operators for Ubuntu are total jerkoffs and I ended up getting banned trying to get the info I needed for this:

diff -Naur fglrx-driver-15.9.orig/common/lib/modules/fglrx/build_mod/firegl_public.c fglrx-driver-15.9/common/lib/modules/fglrx/build_mod/firegl_public.c
7 	--- fglrx-driver-15.9.orig/common/lib/modules/fglrx/build_mod/firegl_public.c   2015-12-31 11:12:34.000000000 +0100
8 	+++ fglrx-driver-15.9/common/lib/modules/fglrx/build_mod/firegl_public.c        2015-12-31 11:14:25.485800244 +0100
9 	@@ -636,7 +636,11 @@
10 	 
11 	     len = snprintf(buf, request, "%d\n", major);
12 	 #else
13 	+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 3, 0)
14 	     len = seq_printf(m, "%d\n", major);
15 	+#else
16 	+    seq_printf(m, "%d\n", major);
17 	+#endif
18 	 #endif
19 	 
20 	     KCL_DEBUG1(FN_FIREGL_PROC, "return len=%i\n",len);
21 	@@ -3440,7 +3444,11 @@
22 	 int ATI_API_CALL KCL_MEM_MTRR_AddRegionWc(unsigned long base, unsigned long size)
23 	 {
24 	 #ifdef CONFIG_MTRR
25 	+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 3, 0)
26 	     return mtrr_add(base, size, MTRR_TYPE_WRCOMB, 1);
27 	+#else
28 	+    return arch_phys_wc_add(base, size);
29 	+#endif
30 	 #else /* !CONFIG_MTRR */
31 	     return -EPERM;
32 	 #endif /* !CONFIG_MTRR */
33 	@@ -3449,7 +3457,12 @@
34 	 int ATI_API_CALL KCL_MEM_MTRR_DeleteRegion(int reg, unsigned long base, unsigned long size)
35 	 {
36 	 #ifdef CONFIG_MTRR
37 	+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 3, 0)
38 	     return mtrr_del(reg, base, size);
39 	+#else
40 	+    arch_phys_wc_del(reg);
41 	+    return reg;
42 	+#endif
43 	 #else /* !CONFIG_MTRR */
44 	     return -EPERM;
45 	 #endif /* !CONFIG_MTRR */

20160222 Update

So, I went ahead an applied the following changes so far:

diff --git a/fglrx-install.c0Svx9/common/lib/modules/fglrx/build_mod/2.6.x/Makefile b/fglrx-install.c0Svx9/common/lib/modules/fglrx/build_mod/2.6.x/Makefile
index a672746..5fcd0c7 100755
--- a/fglrx-install.c0Svx9/common/lib/modules/fglrx/build_mod/2.6.x/Makefile
+++ b/fglrx-install.c0Svx9/common/lib/modules/fglrx/build_mod/2.6.x/Makefile
@@ -27,6 +27,7 @@
 LIBIP_PREFIX   ?= ..
 
 obj-m           += fglrx.o
+#fglrx-libs      += libfglrx_ip.a
 fglrx-libs      += libfglrx_ip.a
 
 fglrx-c-objs    += firegl_public.o      \
@@ -68,6 +69,7 @@ EXTRA_CFLAGS    += \
                 -DFGL_GART_RESERVED_SLOT \
                 -DFGL_LINUX253P1_VMA_API \
                 -DPAGE_ATTR_FIX=$(PAGE_ATTR_FIX) \
+                -Wno-unused-function \
 
 ifeq ($(KERNELRELEASE),)
 # on first call from remote location we get into this path
diff --git a/fglrx-install.c0Svx9/common/lib/modules/fglrx/build_mod/firegl_public.c b/fglrx-install.c0Svx9/common/lib/modules/fglrx/build_mod/firegl_public.c
index 9c70211..72e5f90 100755
--- a/fglrx-install.c0Svx9/common/lib/modules/fglrx/build_mod/firegl_public.c
+++ b/fglrx-install.c0Svx9/common/lib/modules/fglrx/build_mod/firegl_public.c
@@ -631,7 +631,8 @@ static int firegl_major_proc_read(struct seq_file *m, void* data)
 
     len = snprintf(buf, request, "%d\n", major);
 #else
-    len = seq_printf(m, "%d\n", major);
+    seq_printf(m, "%d\n", major);
+    len = 0;
 #endif
 
     KCL_DEBUG1(FN_FIREGL_PROC, "return len=%i\n",len);

And these were my build results:

diff --git a/fglrx-install.c0Svx9/common/lib/modules/fglrx/build_mod/2.6.x/make.sh.log b/fglrx-install.c0Svx9/common/lib/modules/fglrx/build_mod/2.6.x/make.sh.log
new file mode 100644
index 0000000..48aa572
--- /dev/null
+++ b/fglrx-install.c0Svx9/common/lib/modules/fglrx/build_mod/2.6.x/make.sh.log
@@ -0,0 +1,43 @@
+AMD kernel module generator version 2.1
+.
+Active kernel:
+uname -a = Linux localhost.localdomain 4.3.5-300.fc23.x86_64 #1 SMP Mon Feb 1 03:18:41 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
+uname -s = Linux
+uname -m = x86_64
+uname -r = 4.3.5-300.fc23.x86_64
+uname -v = #1 SMP Mon Feb 1 03:18:41 UTC 2016
+.
+Target kernel:
+uname -a = Linux localhost.localdomain 4.3.5-300.fc23.x86_64 #1 SMP Mon Feb 1 03:18:41 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
+uname -s = Linux
+uname -m = x86_64
+uname -r = 4.3.5-300.fc23.x86_64
+uname -v = #1 SMP Mon Feb 1 03:18:41 UTC 2016
+.
+OsVersion says: SMP=1
+file /proc/kallsyms says: SMP=1
+file /lib/modules/4.3.5-300.fc23.x86_64/build/include/generated/autoconf.h says: SMP=1
+file /lib/modules/4.3.5-300.fc23.x86_64/build/include/generated/autoconf.h says: MODVERSIONS=
+file /lib/modules/4.3.5-300.fc23.x86_64/build/arch/x86/include/asm/compat.h says: COMPAT_ALLOC_USER_SPACE=arch_compat_alloc_user_space
+.
+doing Makefile based build for kernel 2.6.x and higher
+make -C /lib/modules/4.3.5-300.fc23.x86_64/build SUBDIRS=/home/phanes/Development/fglrx/fglrx-15.302/fglrx-install.c0Svx9/common/lib/modules/fglrx/build_mod/2.6.x modules
+make[1]: Entering directory '/usr/src/kernels/4.3.5-300.fc23.x86_64'
+  CC [M]  /home/phanes/Development/fglrx/fglrx-15.302/fglrx-install.c0Svx9/common/lib/modules/fglrx/build_mod/2.6.x/firegl_public.o
+  CC [M]  /home/phanes/Development/fglrx/fglrx-15.302/fglrx-install.c0Svx9/common/lib/modules/fglrx/build_mod/2.6.x/kcl_acpi.o
+  CC [M]  /home/phanes/Development/fglrx/fglrx-15.302/fglrx-install.c0Svx9/common/lib/modules/fglrx/build_mod/2.6.x/kcl_agp.o
+  CC [M]  /home/phanes/Development/fglrx/fglrx-15.302/fglrx-install.c0Svx9/common/lib/modules/fglrx/build_mod/2.6.x/kcl_debug.o
+  CC [M]  /home/phanes/Development/fglrx/fglrx-15.302/fglrx-install.c0Svx9/common/lib/modules/fglrx/build_mod/2.6.x/kcl_ioctl.o
+  CC [M]  /home/phanes/Development/fglrx/fglrx-15.302/fglrx-install.c0Svx9/common/lib/modules/fglrx/build_mod/2.6.x/kcl_io.o
+  CC [M]  /home/phanes/Development/fglrx/fglrx-15.302/fglrx-install.c0Svx9/common/lib/modules/fglrx/build_mod/2.6.x/kcl_pci.o
+  CC [M]  /home/phanes/Development/fglrx/fglrx-15.302/fglrx-install.c0Svx9/common/lib/modules/fglrx/build_mod/2.6.x/kcl_str.o
+  CC [M]  /home/phanes/Development/fglrx/fglrx-15.302/fglrx-install.c0Svx9/common/lib/modules/fglrx/build_mod/2.6.x/kcl_iommu.o
+  CC [M]  /home/phanes/Development/fglrx/fglrx-15.302/fglrx-install.c0Svx9/common/lib/modules/fglrx/build_mod/2.6.x/kcl.o
+  CC [M]  /home/phanes/Development/fglrx/fglrx-15.302/fglrx-install.c0Svx9/common/lib/modules/fglrx/build_mod/2.6.x/kcl_wait.o
+make[2]: *** No rule to make target '/home/phanes/Development/fglrx/fglrx-15.302/fglrx-install.c0Svx9/common/lib/modules/fglrx/build_mod/2.6.x/libfglrx_ip.a', needed by '/home/phanes/Development/fglrx/fglrx-15.302/fglrx-install.c0Svx9/common/lib/modules/fglrx/build_mod/2.6.x/fglrx.o'.  Stop.
+Makefile:1382: recipe for target '_module_/home/phanes/Development/fglrx/fglrx-15.302/fglrx-install.c0Svx9/common/lib/modules/fglrx/build_mod/2.6.x' failed
+make[1]: *** [_module_/home/phanes/Development/fglrx/fglrx-15.302/fglrx-install.c0Svx9/common/lib/modules/fglrx/build_mod/2.6.x] Error 2
+make[1]: Leaving directory '/usr/src/kernels/4.3.5-300.fc23.x86_64'
+Makefile:90: recipe for target 'kmod_build' failed
+make: *** [kmod_build] Error 2
+build failed with return value 2

What is libfglrx_ip.a and why isn’t it in the source? No one seems to know about this. You can see the full build results here. I need to pick around the source a little and find out what this .a file is.
In the meantime, I’m still searching through the source here for all mentions of libfglrx_ip.a here.

More updates.

(Add screenshot or code)

Created symlink to libfglrx_ip.a from arch subdirectory in root folder.

It now halfway compiles!

Almost there. Or maybe not.

[phanes@localhost build_mod]$ ln -s ../../../../../arch/x86
x86/    x86_64/ 
[phanes@localhost build_mod]$ ln -s ../../../../../arch/x86_64/lib/modules/fglrx/build_mod/libfglrx_ip.a libfglrx_ip.a
[phanes@localhost build_mod]$ sudo ./make.sh 
AMD kernel module generator version 2.1
doing Makefile based build for kernel 2.6.x and higher
rm -rf *.c *.h *.o *.ko *.a .??* *.symvers
make -C /lib/modules/4.3.5-300.fc23.x86_64/build SUBDIRS=/home/phanes/Development/fglrx/fglrx-15.302/fglrx-install.c0Svx9/common/lib/modules/fglrx/build_mod/2.6.x modules
make[1]: Entering directory '/usr/src/kernels/4.3.5-300.fc23.x86_64'
  CC [M]  /home/phanes/Development/fglrx/fglrx-15.302/fglrx-install.c0Svx9/common/lib/modules/fglrx/build_mod/2.6.x/firegl_public.o
  CC [M]  /home/phanes/Development/fglrx/fglrx-15.302/fglrx-install.c0Svx9/common/lib/modules/fglrx/build_mod/2.6.x/kcl_acpi.o
  CC [M]  /home/phanes/Development/fglrx/fglrx-15.302/fglrx-install.c0Svx9/common/lib/modules/fglrx/build_mod/2.6.x/kcl_agp.o
  CC [M]  /home/phanes/Development/fglrx/fglrx-15.302/fglrx-install.c0Svx9/common/lib/modules/fglrx/build_mod/2.6.x/kcl_debug.o
  CC [M]  /home/phanes/Development/fglrx/fglrx-15.302/fglrx-install.c0Svx9/common/lib/modules/fglrx/build_mod/2.6.x/kcl_ioctl.o
  CC [M]  /home/phanes/Development/fglrx/fglrx-15.302/fglrx-install.c0Svx9/common/lib/modules/fglrx/build_mod/2.6.x/kcl_io.o
  CC [M]  /home/phanes/Development/fglrx/fglrx-15.302/fglrx-install.c0Svx9/common/lib/modules/fglrx/build_mod/2.6.x/kcl_pci.o
  CC [M]  /home/phanes/Development/fglrx/fglrx-15.302/fglrx-install.c0Svx9/common/lib/modules/fglrx/build_mod/2.6.x/kcl_str.o
  CC [M]  /home/phanes/Development/fglrx/fglrx-15.302/fglrx-install.c0Svx9/common/lib/modules/fglrx/build_mod/2.6.x/kcl_iommu.o
  CC [M]  /home/phanes/Development/fglrx/fglrx-15.302/fglrx-install.c0Svx9/common/lib/modules/fglrx/build_mod/2.6.x/kcl.o
  CC [M]  /home/phanes/Development/fglrx/fglrx-15.302/fglrx-install.c0Svx9/common/lib/modules/fglrx/build_mod/2.6.x/kcl_wait.o
  LD [M]  /home/phanes/Development/fglrx/fglrx-15.302/fglrx-install.c0Svx9/common/lib/modules/fglrx/build_mod/2.6.x/fglrx.o
  Building modules, stage 2.
  MODPOST 1 modules
WARNING: "mtrr_add" [/home/phanes/Development/fglrx/fglrx-15.302/fglrx-install.c0Svx9/common/lib/modules/fglrx/build_mod/2.6.x/fglrx.ko] undefined!
WARNING: "mtrr_del" [/home/phanes/Development/fglrx/fglrx-15.302/fglrx-install.c0Svx9/common/lib/modules/fglrx/build_mod/2.6.x/fglrx.ko] undefined!
  CC      /home/phanes/Development/fglrx/fglrx-15.302/fglrx-install.c0Svx9/common/lib/modules/fglrx/build_mod/2.6.x/fglrx.mod.o
  LD [M]  /home/phanes/Development/fglrx/fglrx-15.302/fglrx-install.c0Svx9/common/lib/modules/fglrx/build_mod/2.6.x/fglrx.ko
make[1]: Leaving directory '/usr/src/kernels/4.3.5-300.fc23.x86_64'
build succeeded with return value 0
duplicating results into driver repository...
done.
You must change your working directory to /home/phanes/Development/fglrx/fglrx-15.302/fglrx-install.c0Svx9/common/lib/modules/fglrx
and then call ./make_install.sh in order to install the built module.
[phanes@localhost build_mod]$ git status -s
 M make.sh.log
?? ../../../../../ATI_STATUS
?? 2.6.x/.fglrx.ko.cmd
?? 2.6.x/.fglrx.mod.o.cmd
?? 2.6.x/.fglrx.o.cmd
?? 2.6.x/.firegl_public.o.cmd
?? 2.6.x/.kcl.o.cmd
?? 2.6.x/.kcl_acpi.o.cmd
?? 2.6.x/.kcl_agp.o.cmd
?? 2.6.x/.kcl_debug.o.cmd
?? 2.6.x/.kcl_io.o.cmd
?? 2.6.x/.kcl_ioctl.o.cmd
?? 2.6.x/.kcl_iommu.o.cmd
?? 2.6.x/.kcl_pci.o.cmd
?? 2.6.x/.kcl_str.o.cmd
?? 2.6.x/.kcl_wait.o.cmd
?? 2.6.x/.libfglrx_ip.a.cmd
?? 2.6.x/.tmp_versions/
?? 2.6.x/Module.symvers
?? 2.6.x/drm.h
?? 2.6.x/drmP.h
?? 2.6.x/drm_compat.h
?? 2.6.x/drm_os_linux.h
?? 2.6.x/drm_proc.h
?? 2.6.x/fglrx.ko
?? 2.6.x/fglrx.mod.c
?? 2.6.x/fglrx.mod.o
?? 2.6.x/fglrx.o
?? 2.6.x/fglrxko_pci_ids.h
?? 2.6.x/firegl_public.c
?? 2.6.x/firegl_public.h
?? 2.6.x/firegl_public.o
?? 2.6.x/kcl.c
?? 2.6.x/kcl.h
?? 2.6.x/kcl.o
?? 2.6.x/kcl_acpi.c
?? 2.6.x/kcl_acpi.h
?? 2.6.x/kcl_acpi.o
?? 2.6.x/kcl_agp.c
?? 2.6.x/kcl_agp.h
?? 2.6.x/kcl_agp.o
?? 2.6.x/kcl_config.h
?? 2.6.x/kcl_debug.c
?? 2.6.x/kcl_debug.h
?? 2.6.x/kcl_debug.o
?? 2.6.x/kcl_io.c
?? 2.6.x/kcl_io.h
?? 2.6.x/kcl_io.o
?? 2.6.x/kcl_ioctl.c
?? 2.6.x/kcl_ioctl.h
?? 2.6.x/kcl_ioctl.o
?? 2.6.x/kcl_iommu.c
?? 2.6.x/kcl_iommu.h
?? 2.6.x/kcl_iommu.o
?? 2.6.x/kcl_osconfig.h
?? 2.6.x/kcl_pci.c
?? 2.6.x/kcl_pci.h
?? 2.6.x/kcl_pci.o
?? 2.6.x/kcl_str.c
?? 2.6.x/kcl_str.h
?? 2.6.x/kcl_str.o
?? 2.6.x/kcl_type.h
?? 2.6.x/kcl_wait.c
?? 2.6.x/kcl_wait.h
?? 2.6.x/kcl_wait.o
?? 2.6.x/libfglrx_ip.a
?? 2.6.x/modules.order
?? fglrx.ko
?? libfglrx_ip.a
?? ../fglrx.4.3.5-300.fc23.x86_64.ko
?? ../make.4.3.5-300.fc23.x86_64.log

So, next is to find out why we’re seeing this:

WARNING: "mtrr_add" [/home/phanes/Development/fglrx/fglrx-15.302/fglrx-install.c0Svx9/common/lib/modules/fglrx/build_mod/2.6.x/fglrx.ko] undefined!
WARNING: "mtrr_del" [/home/phanes/Development/fglrx/fglrx-15.302/fglrx-install.c0Svx9/common/lib/modules/fglrx/build_mod/2.6.x/fglrx.ko] undefined!

Idea for the symlink obtained from here.

After looking at this it’s now clear that my fglrx kernel module did build successfully. Woot! Did it. I was ready to put together a team for this if it didn’t pull through.

Proof:

fglrx_complete

From here we’ll want to go through the actual install, then the install of all the amd crap tools that comes with it, and then I need to trim this whole article down.

20160221 Update

So, tried the make_install.sh script bundled with it and I’m still getting mtrr_add and mtrr_del unknown symbol issues.  Since we are in uncharted territory I’m going to reach out to bluehatrecord’s main author and see if he can provide some insight into the source since he’s looked at it a lot longer and may be able to save me a few days (weeks).

In the meantime, I’m downgrading to the last known working kernel version and using the 15.20 drivers and just making it work until I get this to build right in a VM.

20160222 Update

Christ.  Apparently that’s not an option either on Fedora 23.  I’m getting real sick of Fedora’s shit as they apparently pull old packages that I would need to do this.  I’ve got the FOSS radeon driver going but this is a temporary fix.

Next Post

Previous Post

3 Comments

  1. Carlos 2016-02-27

    This patch fixed the compilation and link problems for me. I just use my video cards just as GPUs, so no guarantees that it will work as a video driver.

    — common/lib/modules/fglrx/build_mod/firegl_public.c.orig 2016-02-27 17:43:19.227816618 -0500
    +++ common/lib/modules/fglrx/build_mod/firegl_public.c 2016-02-27 09:11:24.043777977 -0500
    @@ -631,7 +631,7 @@

    len = snprintf(buf, request, “%d\n”, major);
    #else
    – len = seq_printf(m, “%d\n”, major);
    + seq_printf(m, “%d\n”, major);
    #endif

    KCL_DEBUG1(FN_FIREGL_PROC, “return len=%i\n”,len);
    @@ -3424,7 +3424,11 @@
    int ATI_API_CALL KCL_MEM_MTRR_AddRegionWc(unsigned long base, unsigned long size)
    {
    #ifdef CONFIG_MTRR
    +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,3,0)
    return mtrr_add(base, size, MTRR_TYPE_WRCOMB, 1);
    +#else
    + return arch_phys_wc_add(base, size);
    +#endif
    #else /* !CONFIG_MTRR */
    return -EPERM;
    #endif /* !CONFIG_MTRR */
    @@ -3433,7 +3437,12 @@
    int ATI_API_CALL KCL_MEM_MTRR_DeleteRegion(int reg, unsigned long base, unsigned long size)
    {
    #ifdef CONFIG_MTRR
    +#if LINUX_VERSION_CODE = KERNEL_VERSION(3,15,0)
    static int KCL_fpu_save_init(struct task_struct *tsk)
    {
    @@ -6483,6 +6493,7 @@
    return 1;
    }
    #endif
    +#endif

    /** \brief Prepare for using FPU
    * \param none

    • Phanes 2016-03-07 — Post Author

      Thanks for this.

      Can you please confirm what Kernel version this compiled for you under?

      Can you please confirm what FGLRX version?

  2. Maurice 2016-05-19

    I have been using linux on and off and on and off precisely because of the elitist nature of the sums of bitches who create the product.

    I have fedora 23 and a radeon 6950 card.
    Every other video I play on youtube freezes, gets choppy, crashes etc.

    Even if there was a better driver than this gallium crap I’ll take it.

Leave a Reply to Maurice Cancel reply

© 2021 Phanes' Canon

The Personal Blog of Chris Punches