Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 548118 - x11-drivers/ati-drivers-15.1 fails to build with kernel 4.0.0 - kcl_str.o failed
Summary: x11-drivers/ati-drivers-15.1 fails to build with kernel 4.0.0 - kcl_str.o failed
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Unspecified (show other bugs)
Hardware: AMD64 Linux
: Normal normal with 5 votes (vote)
Assignee: Gentoo X packagers
URL:
Whiteboard:
Keywords:
: 554910 560958 (view as bug list)
Depends on:
Blocks:
 
Reported: 2015-04-29 10:51 UTC by Machredsch
Modified: 2015-09-23 10:14 UTC (History)
23 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
build.log (x11-drivers:ati-drivers-15.1:20150429-095750.log,8.66 KB, text/x-log)
2015-04-29 10:52 UTC, Machredsch
Details
Kernel 4 Patch for ati-drivers-15.1 (ati-drivers-15.1-kernel4.patch,6.94 KB, patch)
2015-05-03 11:16 UTC, Machredsch
Details | Diff
kernel-4.0.0-kcl_acpi.c.patch (kernel-4.0.0-kcl_acpi.c.patch,583 bytes, text/plain)
2015-05-04 19:13 UTC, Drake Donahue
Details
kernel-4.0.0-firegl.c.patch (kernel-4.0.0-firegl.c.patch,2.33 KB, text/plain)
2015-05-04 19:15 UTC, Drake Donahue
Details
kernel-4.0.0-kcl_str.c.patch (kernel-4.0.0-kcl_str.c.patch,494 bytes, text/plain)
2015-05-04 19:16 UTC, Drake Donahue
Details
build.log (build.log,8.40 KB, text/x-log)
2015-05-10 20:19 UTC, Alex Barker
Details
kernel-4.1.0-firegl_public.c.patch (kernel-4.1.0-firegl_public.c.patch,546 bytes, text/plain)
2015-05-11 21:29 UTC, Drake Donahue
Details
complete update to fglrx-core-15.200 for kernel-4.1.0-rc3.patch (kernel-4.1.0-rc3.patch,5.75 KB, patch)
2015-05-16 19:32 UTC, Drake Donahue
Details | Diff
kernel-4.* patch (kernel-4.1.patch,3.87 KB, patch)
2015-06-23 17:22 UTC, Machredsch
Details | Diff
clear license, kernel 4/4.1 compatible, kernel must be patched and recompiled first (kernel-4plus-ati-drivers-15.5.patch,12.05 KB, patch)
2015-06-26 04:51 UTC, Drake Donahue
Details | Diff
15.7.patch (15.7.patch,13.62 KB, patch)
2015-07-14 19:55 UTC, Drake Donahue
Details | Diff
15.7-r1.patch (15.7-r1.patch,6.21 KB, patch)
2015-07-17 02:25 UTC, Drake Donahue
Details | Diff
ati-drivers-15.7.patch (ati-drivers-15.7.patch,5.74 KB, patch)
2015-09-06 19:43 UTC, Oleg Ageev
Details | Diff
dont-use-gpl-symbols.patch (dont-use-gpl-symbols.patch,1.53 KB, patch)
2015-09-12 23:16 UTC, Fernando Rodriguez
Details | Diff
dont-use-gpl-symbols.patch (dont-use-gpl-symbols.patch,1.53 KB, patch)
2015-09-13 00:42 UTC, Fernando Rodriguez
Details | Diff
dont-use-gpl-symbols.patch (dont-use-gpl-symbols.patch,1.90 KB, patch)
2015-09-13 16:48 UTC, Fernando Rodriguez
Details | Diff
ati-drivers-5.7-unified.patch (ati-drivers-5.7-unified.patch,4.30 KB, patch)
2015-09-13 19:52 UTC, Fernando Rodriguez
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Machredsch 2015-04-29 10:51:25 UTC
x11-drivers/ati-drivers-15.1 fails to build with Kernel 4.0.0. Successfull builds with <=3.19.4.


Reproducible: Always

Steps to Reproduce:
1.Build and install Kernel 4 and eselect the kernel
2.emerge ati-drivers
3.
Actual Results:  
.../work/common/lib/modules/fglrx/build_mod/2.6.x/kcl_str.o' failed
leads to:
make: *** [kmod_build] Error 2

Expected Results:  
fglrx module was built

emerge -pqv:

[ebuild   R   ] x11-drivers/ati-drivers-15.1 [15.1] USE="modules qt4 -debug -gdm-hack -pax_kernel -static-libs" ABI_X86="32 (64)" 

emerge --info:

Portage 2.2.18 (python 3.3.5-final-0, default/linux/amd64/13.0/desktop, gcc-4.9.2, glibc-2.20-r2, 4.0.0-gentoo x86_64)
=================================================================
                         System Settings
=================================================================
System uname: Linux-4.0.0-gentoo-x86_64-Intel-R-_Core-TM-_i5-2400_CPU_@_3.10GHz-with-gentoo-2.2
KiB Mem:     8119372 total,   4263432 free
KiB Swap:    2097148 total,   2097148 free
Timestamp of repository gentoo: Wed, 29 Apr 2015 08:15:01 +0000
sh bash 4.2_p53
ld GNU ld (Gentoo 2.24 p1.4) 2.24
ccache version 3.1.9 [enabled]
app-shells/bash:          4.2_p53::gentoo
dev-java/java-config:     2.2.0::gentoo
dev-lang/perl:            5.20.2::gentoo
dev-lang/python:          2.7.9-r1::gentoo, 3.3.5-r1::gentoo, 3.4.1::gentoo
dev-util/ccache:          3.1.9-r4::gentoo
dev-util/cmake:           2.8.12.2-r1::gentoo
dev-util/pkgconfig:       0.28-r2::gentoo
sys-apps/baselayout:      2.2::gentoo
sys-apps/openrc:          0.13.11::gentoo
sys-apps/sandbox:         2.6-r1::gentoo
sys-devel/autoconf:       2.13::gentoo, 2.69::gentoo
sys-devel/automake:       1.11.6-r1::gentoo, 1.13.4::gentoo
sys-devel/binutils:       2.24-r3::gentoo
sys-devel/gcc:            4.9.2::gentoo
sys-devel/gcc-config:     1.7.3::gentoo
sys-devel/libtool:        2.4.6::gentoo
sys-devel/make:           4.1-r1::gentoo
sys-kernel/linux-headers: 4.0::gentoo (virtual/os-headers)
sys-libs/glibc:           2.20-r2::gentoo
Repositories:

gentoo
    location: /usr/portage/ebuilds/gentoo
    sync-type: rsync
    sync-uri: rsync://rsync.de.gentoo.org/gentoo-portage
    priority: -1000

machredsch
    location: /usr/portage/ebuilds/machredsch
    masters: gentoo
    priority: 0

dotnet
    location: /usr/portage/ebuilds/layman/dotnet
    sync-type: laymansync
    sync-uri: git://anongit.gentoo.org/proj/dotnet.git
    masters: gentoo
    priority: 50

steam-overlay
    location: /usr/portage/ebuilds/layman/steam-overlay
    sync-type: laymansync
    sync-uri: git://github.com/anyc/steam-overlay.git
    masters: gentoo
    priority: 50

x11
    location: /usr/portage/ebuilds/layman/x11
    sync-type: laymansync
    sync-uri: git://anongit.gentoo.org/proj/x11
    masters: gentoo
    priority: 50

ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="*"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=native -O2 -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/config /usr/share/gnupg/qualified.txt /var/bind"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/php/apache2-php5.5/ext-active/ /etc/php/cgi-php5.5/ext-active/ /etc/php/cli-php5.5/ext-active/ /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-march=native -O2 -pipe"
DISTDIR="/usr/portage/distfiles"
EMERGE_DEFAULT_OPTS="--with-bdeps y"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-logs ccache clean-logs config-protect-if-modified distlocks ebuild-locks fixlafiles merge-sync news parallel-fetch preserve-libs protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS="http://de-mirror.org/gentoo/ http://ftp.uni-erlangen.de/pub/mirrors/gentoo"
LANG="de_DE.utf8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
MAKEOPTS="-j5 -l5"
PKGDIR="/usr/portage/distfiles/binpkg"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_EXTRA_OPTS="--human-readable --exclude-from=/etc/portage/rsync_excludes"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp/portage/tmpfs"
USE="X a52 aac aalib acl acpi alsa amd64 apm bash-completion bcmath bluetooth bzip2 cairo cdda cddb cdr cleartype cli consolekit cracklib crypt ctype cups curl cxx dbus dga djvu dri dts dvd dvdr encode exif fat fbcon ffmpeg firefox flac fontconfig fortran ftp fuse gallium gdbm geoip gif glamor gles gles2 glut gnutls gpm gtk gtk3 iconv idn imagemagick imap imlib innodb ipv6 jpeg lame lcms libkms libnotify llvm lm_sensors mad matroska mbox mime mmap mms mmx mmxext mng modules mp3 mp4 mpeg multilib musepack ncurses nls nptl ntfs ogg opencl opengl openmp opus pam pcre pdf png policykit posix ppds readline rss sasl sdl session smp sockets spell sse sse2 ssl startup-notification svg tcpd theora threads tiff truetype udev udisks unicode upower usb vaapi vcd vdpau vhosts vorbis wavpack wxwidgets x264 x265 xattr xcb xcomposite xml xmp xpm xv xvid zip zlib" ABI_X86="64" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" APACHE2_MODULES="access_compat actions alias asis auth_basic auth_digest authn_core authn_file authz_core authz_groupfile authz_host authz_owner authz_user autoindex cache cache_disk cgid charset_lite dbd dir dumpio env expires ext_filter file_cache filter headers imagemap info log_config logio mime mime_magic negotiation reqtimeout rewrite setenvif socache_shmcb speling status substitute unixd usertrack vhost_alias" CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump author" CAMERAS="canon" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="aes avx mmx mmxext popcnt sse sse2 sse3 sse4_1 sse4_2 ssse3" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ublox ubx" GRUB_PLATFORMS="efi-64" INPUT_DEVICES="evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer pdfimport" LINGUAS="de" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-5" PYTHON_SINGLE_TARGET="python3_3" PYTHON_TARGETS="python2_7 python3_3" RUBY_TARGETS="ruby20" SANE_BACKENDS="pixma" USERLAND="GNU" VIDEO_CARDS="fbdev radeon radeonsi fglrx" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  CPPFLAGS, CTARGET, INSTALL_MASK, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, USE_PYTHON
Comment 1 Machredsch 2015-04-29 10:52:16 UTC
Created attachment 402220 [details]
build.log

complete build.log
Comment 2 Drake Donahue 2015-05-01 19:37:57 UTC
same result with gentoo-sources-4.0.3
Comment 3 Drake Donahue 2015-05-02 14:31:06 UTC
ati-drivers-14-12-r3 has the same problems with kernel-4.0.3. At least in the case of str.c, 14-12-r3 and 15.1 appear to be the same file 

https://github.com/kolasa/fglrx-core-15.200/commit/66a25e76c538f7844568a20243bfe015ee0315a1 is entitled "changes for kernel 4.0.0" 

the change applicable to str.c is not in /var/tmp/portage/x11-drivers/ati-drivers-15.1/work/common/lib/modules/fglrx/build_mod/2.6.x/kcl_str.c

Whether or not amd/ubuntu has a package hidden somewhere that works with kernel-4.0.0 ?
Comment 4 Drake Donahue 2015-05-03 01:04:52 UTC
The diffs for patches provided at https://github.com/kolasa/fglrx-core-15.200/commit/66a25e76c538f7844568a20243bfe015ee0315a1 are incorporated in the files provided at https://github.com/kolasa/fglrx-core-15.200 . Since I lack native patch writing skills I tested the changes by running the following set of commands: 
ebuild /usr/portage/x11-drivers/ati-drivers/ati-drivers-15.1.ebuild fetch
ebuild /usr/portage/x11-drivers/ati-drivers/ati-drivers-15.1.ebuild unpack
wget -O /var/tmp/portage/x11-drivers/ati-drivers-15.1/work/common/lib/modules/fglrx/build_mod/2.6.x/firegl_public.c https://github.com/kolasa/fglrx-core-15.200/blob/master/firegl_public.c 
wget -O /var/tmp/portage/x11-drivers/ati-drivers-15.1/work/common/lib/modules/fglrx/build_mod/2.6.x/kcl_acpi.c https://github.com/kolasa/fglrx-core-15.200/blob/master/kcl_acpi.c 
wget -O /var/tmp/portage/x11-drivers/ati-drivers-15.1/work/common/lib/modules/fglrx/build_mod/2.6.x/kcl_str.c https://github.com/kolasa/fglrx-core-15.200/blob/master/kcl_str.c 
ebuild /usr/portage/x11-drivers/ati-drivers/ati-drivers-15.1.ebuild compile
ebuild /usr/portage/x11-drivers/ati-drivers/ati-drivers-15.1.ebuild install
ebuild /usr/portage/x11-drivers/ati-drivers/ati-drivers-15.1.ebuild qmerge
 All steps succeeded, ati-drivers compiled and installed and ran after reboot of kernel-4.0.1 on this particular machine.
 Will test these steps for ati-drivers-14.12.3 and a kernel-4.0.* and report back
Comment 5 Drake Donahue 2015-05-03 01:59:14 UTC
ati-drivers-14.12-r3 also compiles, installs, and runs with the changed files.

Commands used:
ebuild /usr/portage/x11-drivers/ati-drivers/ati-drivers-14.12-r3.ebuild fetch 
ebuild /usr/portage/x11-drivers/ati-drivers/ati-drivers-14.12-r3.ebuild unpack
wget -O /var/tmp/portage/x11-drivers/ati-drivers-14.12-r3/work/common/lib/modules/fglrx/build_mod/2.6.x/firegl_public.c https://raw.github.com/kolasa/fglrx-core-15.200/blob/master/firegl_public.c 
wget -O /var/tmp/portage/x11-drivers/ati-drivers-14.12-r3/work/common/lib/modules/fglrx/build_mod/2.6.x/kcl_acpi.c https://raw.github.com/kolasa/fglrx-core-15.200/blob/master/kcl_acpi.c 
wget -O /var/tmp/portage/x11-drivers/ati-drivers-14.12-r3/work/common/lib/modules/fglrx/build_mod/2.6.x/kcl_str.c https://raw.github.com/kolasa/fglrx-core-15.200/blob/master/kcl_str.c 
ebuild /usr/portage/x11-drivers/ati-drivers/ati-drivers-14.12-r3.ebuild compile
ebuild /usr/portage/x11-drivers/ati-drivers/ati-drivers-14.12-r3.ebuild install
ebuild /usr/portage/x11-drivers/ati-drivers/ati-drivers-14.12-r3.ebuild qmerge

raw.github.com is now required instead of github.com, site changed modes apparently

Correcting 15.1 commands to add raw:
ebuild /usr/portage/x11-drivers/ati-drivers/ati-drivers-15.1.ebuild fetch
ebuild /usr/portage/x11-drivers/ati-drivers/ati-drivers-15.1.ebuild unpack
wget -O /var/tmp/portage/x11-drivers/ati-drivers-15.1/work/common/lib/modules/fglrx/build_mod/2.6.x/firegl_public.c https://raw.github.com/kolasa/fglrx-core-15.200/blob/master/firegl_public.c 
wget -O /var/tmp/portage/x11-drivers/ati-drivers-15.1/work/common/lib/modules/fglrx/build_mod/2.6.x/kcl_acpi.c https://raw.github.com/kolasa/fglrx-core-15.200/blob/master/kcl_acpi.c 
wget -O /var/tmp/portage/x11-drivers/ati-drivers-15.1/work/common/lib/modules/fglrx/build_mod/2.6.x/kcl_str.c https://raw.github.com/kolasa/fglrx-core-15.200/blob/master/kcl_str.c 
ebuild /usr/portage/x11-drivers/ati-drivers/ati-drivers-15.1.ebuild compile
ebuild /usr/portage/x11-drivers/ati-drivers/ati-drivers-15.1.ebuild install
ebuild /usr/portage/x11-drivers/ati-drivers/ati-drivers-15.1.ebuild qmerge
Comment 6 Machredsch 2015-05-03 11:16:50 UTC
Created attachment 402514 [details, diff]
Kernel 4 Patch for ati-drivers-15.1

According to your researches @Drake Donahue and the upstream diffs by kolasa, I made a patch, which worked for me and ati-drivers-15.1. Just add it as a user patch in /etc/portage/patches or make a new ebuild, respecting it.
Comment 7 emil karlson 2015-05-03 11:53:13 UTC
Thanks for providing the patch (at least for end users), however I believe that forging module license can be problematic on Gentoo foundation side.
Comment 8 Ian Delaney (RETIRED) gentoo-dev 2015-05-04 05:28:25 UTC
(In reply to emil karlson from comment #7)
> Thanks for providing the patch (at least for end users), however I believe
> that forging module license can be problematic on Gentoo foundation side.

A bit of a grenade that. Care to elaborate?
Comment 9 emil karlson 2015-05-04 06:29:48 UTC
Just like _GNU_SOURCE etc. cpp macros on C code MODULE_LICENSE and EXPORT_SYMBOL_GPL are a technical (DRM) measure to ensure that someone doesn't accidentally link to GPL only parts of kernel/glibc and thus make the whole code distributed under GPL. As Gentoo foundation can't distribute this stuff under GPL it can't be done legally (at least in binary form/bindist USE). Individual can (AFAIK) apply this patch at home, if they don't redistribute it.

Possibly this could be done with bindist USE flag, but I am not sure whether that is typically considered as an option here as this will will eventually get fixed without it.

IANAL etc.
Comment 10 Drake Donahue 2015-05-04 19:13:49 UTC
Created attachment 402646 [details]
kernel-4.0.0-kcl_acpi.c.patch
Comment 11 Drake Donahue 2015-05-04 19:15:36 UTC
Created attachment 402648 [details]
kernel-4.0.0-firegl.c.patch
Comment 12 Drake Donahue 2015-05-04 19:16:56 UTC
Created attachment 402650 [details]
kernel-4.0.0-kcl_str.c.patch
Comment 13 Drake Donahue 2015-05-04 19:42:53 UTC
About half the hunks in the firegl_public.c part of the earlier patch by Machredsch had location problems and were skipped when I attempted emerge -1 ati-drivers. Lacking patching skills, I failed to detect a cause for the problem. Set out to acquire patching skills, still don't have skills, but I did end up with 3 patches provided as attachments above. I put these patches in /etc/portage/patches/x11-drivers/ati-drivers and emerge -1 ati-drivers worked, YRMV. A triumph of brute force and ignorance. I think Machredsch said he used kolasa's diffs; if so the base source code unpacked from fglrx-installer_15.200.orig.tar.gz may have differences with the source in kolasa's git.
Comment 14 Drake Donahue 2015-05-04 21:12:32 UTC
https://github.com/kolasa/fglrx-core-15.200/commit/66a25e76c538f7844568a20243bfe015ee0315a1#commitcomment-11033298 now provides background information on the license question.
Comment 15 Machredsch 2015-05-05 15:02:54 UTC
I have no problems at all, emerging my patch as a user patch. If some hunks would fail, the emerge process would fail with error.
And why you make 3 patches instead of one file? Just concatenate the files. I am no friend of this, because all of them together are belonging to the same problem.
Because you have a different version of firegl_public.c.patch than mine(which bases on kolasas changes of version 66a25e7), what version do you have, what have you removed or where is it from?
Comment 16 Drake Donahue 2015-05-05 17:23:01 UTC
Never doubted that your patch worked for you. 
For me, a message that the patch failed with a list of hunks that failed and hunks that succeeded.
I did not use kolasa's diff as you already had done that.
I made my own diffs using the complete patched firegl_public.c, kcl_acpi.c, and kcl_str.c I downloaded from https://github.com/kolasa/fglrx-core-15.200.
As I could not master the art of using diff -Naur to produce a single working patch, I used diff -u to produce three separate patches.
In spite of 24 hours or so studying the arts of diff and patch, I remain unskilled. Concatenating 3 diffs into 1 patch that works I leave to the wizards. The corpses of my many many failed patches litter my hard drive, RIP.
Comment 17 Machredsch 2015-05-06 15:12:34 UTC
Than your source must be different, my diffs are made against the unpacked and  unmodified distfiles provided by gentoo (x11-drivers/ati-drivers-15.1) under /var/tmp/portage. So this patch should apply for everyone, who uses the gentoo ebuild and at least the same use flags.
We can stop our conversation at this point and have to wait, until others confirm the one or the other version. Than we can delete the wrong patch(es).
Comment 18 Alex Barker 2015-05-10 20:19:33 UTC
Created attachment 403006 [details]
build.log

Getting similar errors with 4.0.2.
Comment 19 Drake Donahue 2015-05-10 21:34:37 UTC
Agree same problem on 4.0.2. Still fixed in 4.0.2 for me by the 3 patches I provided above. I would expect Machredsch will still fixed by the patch he provided.
Comment 20 Drake Donahue 2015-05-11 19:45:28 UTC
kernel-4.1-rc2 has a new problem:
/var/tmp/portage/x11-drivers/ati-drivers-15.1/work/common/lib/modules/fglrx/build_mod/2.6.x/firegl_public.c: In function ‘KCL_InstallInterruptHandler’:
/var/tmp/portage/x11-drivers/ati-drivers-15.1/work/common/lib/modules/fglrx/build_mod/2.6.x/firegl_public.c:3505:22: error: ‘IRQF_DISABLED’ undeclared (first use in this function)
         ((useMSI) ? (IRQF_DISABLED | IRQF_NOBALANCING) : (IRQF_SHARED)), 

   
http://lists.infradead.org/pipermail/linux-mtd/2015-March/058135.html is titled: [PATCH] Remove deprecated IRQF_DISABLED flag entirely 

The affected code in firegl_public being:
// Interrupt support

/** \brief Pointer to the private interrupt handling function
 * Points to an interrupt handler located in the private ASIC dependent library
 * NOTE: per-device handlers are not supported
 * \param context Pointer to device specific data (whatever driver passed when
 *                registering the handler)
 */
static void ATI_API_CALL (*KCL_PRIV_InterruptHandler)(void* context);

/** \brief Interrupt handler to be called by the OS
 * Has to fit OS defined declaration
 * \param irq IRQ number
 * \param context Pointer to device specific data (whatever driver passed when
 *                registering the handler)
 * \param regs CPU registers on the moment of the interrupt
 * \return IRQ_HANDLED (TODO: return value reflecting whether the interrupt has
 *                     been actually handled)
 */
static irqreturn_t KCL_PUB_InterruptHandlerWrap(int irq, void *context
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
                                       ,struct pt_regs *regs
#endif
                                      )
{
    KCL_DEBUG5(FN_FIREGL_IRQ, NULL);
    KCL_PRIV_InterruptHandler(context);
    KCL_DEBUG5(FN_FIREGL_IRQ, NULL);
    return IRQ_HANDLED;
}

/** \brief Install interrupt handler
 * \param irq IRQ number
 * \param handler Pointer to the private ASIC dependent handler
 * \param dev_name Unique device name
 * \param context Pointer to the unique device context
 * \return 0 on success, nonzero otherwise
 */
int ATI_API_CALL KCL_InstallInterruptHandler(
    unsigned int irq,
    void (*ATI_API_CALL handler)(void*),
    const char *dev_name,
    void *context, int useMSI)
{
    KCL_PRIV_InterruptHandler = handler;

    return request_irq(
        irq,
        KCL_PUB_InterruptHandlerWrap,
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)
        ((useMSI) ? (SA_INTERRUPT) : (SA_SHIRQ)),
#else
        //when MSI enabled. keep irq disabled when calling the action handler,
        //exclude this IRQ from irq balancing (only on one CPU) 
        ((useMSI) ? (IRQF_DISABLED | IRQF_NOBALANCING) : (IRQF_SHARED)),    
#endif
        dev_name,
        context);
}

/** \brief Uninstall interrupt handler
 * \param irq IRQ number
 * \param context Pointer to the unique device context (using this value, OS
 *                will indentify for which device the handler has to be
 *                uninstalled)
 */
void ATI_API_CALL KCL_UninstallInterruptHandler(unsigned int irq, void* context)
{
    free_irq(irq, context);
}

/** \brief Request MSI
 * \param context Pointer to the unique device context (using this value, OS
 *                will indentify for which device msi interrupts have to be
 *                enabled)
 * \return 0 on success, nonzero otherwise
 */
int ATI_API_CALL KCL_RequestMSI(void* context)
{
    return    pci_enable_msi(context);
}

/** \brief Disable MSI
 * \param context Pointer to the unique device context (using this value, OS
 *                will indentify for which device msi interrupts have to be
 *                disabled)
 */
void ATI_API_CALL KCL_DisableMSI(void* context)
{
    pci_disable_msi((struct pci_dev *)context);               //returns void
}
Comment 21 Drake Donahue 2015-05-11 21:29:36 UTC
Created attachment 403068 [details]
kernel-4.1.0-firegl_public.c.patch
Comment 22 Drake Donahue 2015-05-11 21:42:01 UTC
Attachment kernel-4.1.0-firegl_public.c.patch provides a patch that allows compiling against kernel-4.1-rc2 and running ati-drivers with kernel 4.1-rc2 by the simple expedient of removing the reference IRQF_DISABLED | in firegl_public.c Whether this is a proper and correct solution ?? IDK
Comment 23 Drake Donahue 2015-05-16 19:32:12 UTC
Created attachment 403430 [details, diff]
complete update to fglrx-core-15.200 for kernel-4.1.0-rc3.patch

All files with changes at https://github.com/kolasa/fglrx-core-15.200 are patched in a single file this time. Tested by emerge with patch in /etc/portage/patches/x11-drivers/ati-drivers-15.1/kernel-4.1.0-rc3.patch against kernel 4.1.0-rc3 , 4.0.2 , and 3.18.12 successfully. 
Patch was created and tested as follows:
eselect kernel set linux-4.1-rc3
ebuild /usr/portage/x11-drivers/ati-drivers/ati-drivers-15.1.ebuild clean
ebuild /usr/portage/x11-drivers/ati-drivers/ati-drivers-15.1.ebuild fetch
ebuild /usr/portage/x11-drivers/ati-drivers/ati-drivers-15.1.ebuild unpack
mkdir /var/tmp/portage/x11-drivers/ati-drivers-15.1/work/common-r1
cp -aR /var/tmp/portage/x11-drivers/ati-drivers-15.1/work/common/* /var/tmp/portage/x11-drivers/ati-drivers-15.1/work/common-r1
wget -O /root/Downloads/fglrx-core-master.zip https://github.com/kolasa/fglrx-core-15.200/archive/master.zip
unzip /root/Downloads/fglrx-core-master.zip
cp -aR /root/Downloads/fglrx-core-15.200-master/* /var/tmp/portage/x11-drivers/ati-drivers-15.1/work/common-r1/lib/modules/fglrx/build_mod
cd /var/tmp/portage/x11-drivers/ati-drivers-15.1/work
diff -Naru common common-r1 > kernel-4.1.0-rc3.patch
mkdir --parents /etc/portage/patches/x11-drivers/ati-drivers
cp -a kernel-4.1.0-rc3.patch /etc/portage/patches/x11-drivers/ati-drivers
patch -Np1 -d common < kernel-4.1.0-rc3.patch
ebuild /usr/portage/x11-drivers/ati-drivers/ati-drivers-15.1.ebuild install
cd
ebuild /usr/portage/x11-drivers/ati-drivers/ati-drivers-15.1.ebuild qmerge
reboot
startxfce4
emerge -1 ati-drivers
reboot
startxfce4
eselect kernel set linux-4.0.2-gentoo
emerge -1 ati-drivers
reboot
startxfce4
eselect kernel set linux-3.18.12-gentoo
emerge -1 ati-drivers
reboot
startxfce4
Comment 24 Captain Crutches 2015-05-19 01:38:14 UTC
I can confirm this, ati-drivers fails to build with any 4.0.x kernel - but succeeds with Drake's patch.

Portage 2.3.6-r9 (funtoo/1.0/linux-gnu/arch/x86-64bit, gcc-4.9.2, glibc-2.20-r1, 4.0.3-hardened-r1 x86_64)
=================================================================
System uname: Linux-4.0.3-hardened-r1-x86_64-Intel-R-_Core-TM-_i7-3930K_CPU_@_3.20GHz-with-gentoo-2.2.0
KiB Mem:    65954152 total,  37881760 free
KiB Swap:    2283348 total,   2283348 free
Timestamp of tree: Unknown
ld GNU ld (Funtoo 2.25) 2.25.0
app-shells/bash:          4.3_p30-r1
dev-java/java-config:     2.2.0-r1000
dev-lang/perl:            5.20.2-r1
dev-lang/python:          2.7.9-r1000, 3.3.6-r1000
dev-util/cmake:           3.2.1
sys-apps/baselayout:      2.2.0-r6
sys-apps/openrc:          0.12.4-r4
sys-apps/sandbox:         2.6-r2
sys-devel/autoconf:       2.13, 2.69-r1
sys-devel/automake:       1.10.3-r1, 1.11.6-r1, 1.13.4, 1.14.1, 1.15
sys-devel/binutils:       2.25-r1
sys-devel/gcc:            4.9.2-r1
sys-devel/gcc-config:     1.8
sys-devel/libtool:        2.4.3-r2
sys-devel/make:           4.1-r1
sys-kernel/linux-headers: 4.0 (virtual/os-headers)
sys-libs/glibc:           2.20-r1
Repositories: gentoo steam-overlay sunrise wine-overlay x11 kde
Installed sets: @toolchain
ACCEPT_KEYWORDS="amd64 ~amd64"
ACCEPT_LICENSE="* -@EULA Oracle-BCLA-JavaSE"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=corei7 -O2 -pipe -maes -fomit-frame-pointer -freorder-blocks-and-partition -fno-stack-protector -frename-registers -fweb -fgcse-las -fgcse-sm -fgcse-after-reload -fpredictive-commoning -fipa-pta -ftree-loop-ivcanon -ftree-loop-im -fivopts -ftracer -ftree-partial-pre -ftree-loop-distribution -ftree-loop-distribute-patterns -ftree-loop-if-convert -ftree-vectorize  "
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/lib64/libreoffice/program/sofficerc /usr/share/config /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-march=corei7 -O2 -pipe -maes -fomit-frame-pointer -freorder-blocks-and-partition -fno-stack-protector -frename-registers -fweb -fgcse-las -fgcse-sm -fgcse-after-reload -fpredictive-commoning -fipa-pta -ftree-loop-ivcanon -ftree-loop-im -fivopts -ftracer -ftree-partial-pre -ftree-loop-distribution -ftree-loop-distribute-patterns -ftree-loop-if-convert -ftree-vectorize  "
DISTDIR="/usr/portage/distfiles"
FEATURES="assume-digests binpkg-logs config-protect-if-modified distlocks ebuild-locks fixlafiles merge-sync news parallel-fetch preserve-libs protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch xattr"
FFLAGS="-march=corei7 -O2 -pipe"
GENTOO_MIRRORS="http://distfiles.gentoo.org"
INSTALL_MASK="/usr/lib/systemd/ /lib/systemd/"
LANG="en_US.UTF-8"
LDFLAGS="-Wl,-O1 -Wl,--sort-common -Wl,--as-needed"
MAKEOPTS="-j13"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/var/lib/layman/steam-overlay /var/lib/layman/sunrise /var/lib/layman/wine-overlay /var/lib/layman/x11 /var/lib/layman/kde"
SYNC="git://github.com/funtoo/ports-2012.git"
SYNC_USER="root"
USE="X a52 aac acl alsa amd64 apng berkdb bluray bzip2 cdda cddb cdio cdr consolekit cracklib crypt cups cxx dbus dga dri dts dvd dvdr dvdread encode exif faac faad fbcon ffmpeg flac fortran gdbm gif gpm gstreamer gtk hardened ico iconv icu ieee1394 introspection ios ipod ipv6 jpeg jpeg2k kde lame libass libguess libmpeg2 mad matroska mjpeg mmx modules mp3 mpeg mtp mudflap multilib ncurses nls nptl nsplugin ogg openal opencl opengl openmp osmesa pam pax_kernel pcre pdf pic png policykit postproc pppd pulseaudio python qt4 qt5 quicktime readline resolvconf scanner sdl semantic-desktop sndfile sse sse2 ssl svg taglib tcpd theora tiff truetype twolame udev unicode urandom usb v4l vorbis vpx wav wavpack webp win32codecs wmf x264 x265 xattr xinerama xml xtpax xvid zlib" ABI_X86="64" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel ice1724 intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias authn_core authz_core socache_shmcb unixd" CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump author" CAMERAS="ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="mmx mmxext popcnt sse sse2 sse3 sse4_1 sse4_2 ssse3" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ublox ubx" GRUB_PLATFORMS="efi-64 pc" INPUT_DEVICES="evdev synaptics keyboard mouse" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-5" PYTHON_ABIS="2.7 3.3" PYTHON_SINGLE_TARGET="python2_7" PYTHON_TARGETS="python2_7 python3_3" QEMU_SOFTMMU_TARGETS="i386 x86_64" QEMU_USER_TARGETS="i386 x86_64" RUBY_TARGETS="ruby19 ruby20 ruby21 ruby22" USERLAND="GNU" VIDEO_CARDS="fglrx" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, LC_ALL, LINGUAS, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, SYNC_UMASK
Comment 25 Ian Delaney (RETIRED) gentoo-dev 2015-05-20 02:29:32 UTC
So, afaict this bug started out a bug of  x11-drivers/ati-drivers-15.1 however considering the drivers are compiled against a kernel, it's quite expected for the source of the deficit to lie in the kernel. Does this not mean that x11-drivers/ati-drivers-15.1 is the effect and not the cause, and that the fix means patching the kernel?
Does this not mean that the assignee really ought to be the kernel team?
Well done to all users for the patching efforts. The art of patch making is tedious and does take some effort. It appears there is a fix here except it requires at face value the kernel team to have all this and for them to review, test and commit. Also the patches come from users other than the proxy maintainer who could do to acquire and test and confirm these latest patches on the kernel-4.1.0-rc3
Comment 26 Ben de Groot (RETIRED) gentoo-dev 2015-05-21 13:38:46 UTC
(In reply to Ian Delaney from comment #25)
> Does this not mean that the assignee really ought to be the kernel team?
> Well done to all users for the patching efforts. The art of patch making is
> tedious and does take some effort. It appears there is a fix here except it
> requires at face value the kernel team to have all this and for them to
> review, test and commit.

See comment #9. It seems not legally possible for us to ship this.
Comment 27 Scott Alfter 2015-06-19 16:24:18 UTC
Still an issue with gentoo-sources-4.0.5, which was recently keyworded stable.  The Machredsch patch failed with multiple hunks not matched, but the Drake Donahue patch worked and the kernel module built without error.

Upstream is now at 15.5, for which I found an ebuild in the ROKO__ [sic] overlay.  It doesn't build against gentoo-sources-4.0.5 either.  I haven't tested these patches to see if they'd work.
Comment 28 Machredsch 2015-06-19 16:49:54 UTC
Comment on attachment 402514 [details, diff]
Kernel 4 Patch for ati-drivers-15.1

Still working for me, but Drake's patch is more up-to-date and is working for others.
Comment 29 Alex H 2015-06-23 03:55:01 UTC
Are there any plans on resolving this problem without the need for a patch ?
Comment 30 Machredsch 2015-06-23 17:22:58 UTC
Created attachment 405598 [details, diff]
kernel-4.* patch

I uploaded a cleaned patch, which should work for kernel 4.0 and 4.1.
I removed all unnecessary hunks from my previous patch (where I used koalasa raw firegl_public.c as a source, which contains more changes than the diffs for kernel 4) and from Drake's patch (readme.md and dkms.conf).
Can someone please test the patch to be sure, Drake Donahue maybe?
Comment 31 Machredsch 2015-06-23 18:30:33 UTC
(In reply to Machredsch from comment #30)
> Created attachment 405598 [details, diff] [details, diff]
> kernel-4.* patch

patch should be usable as a user patch under /etc/portage/patches tree, it's diffs are against the unpacked emerge working dir ($PORTAGE_TMPDIR).
Comment 32 Drake Donahue 2015-06-24 16:37:19 UTC
Machredsch -- your patch worked here on a 4.0.5 kernel
Comment 33 Ian Delaney (RETIRED) gentoo-dev 2015-06-25 02:47:02 UTC
(In reply to Ben de Groot from comment #26)

> 
> See comment #9. It seems not legally possible for us to ship this.

Ben how is this looking? If it's really not legally possible do we, like you or I, simply close this CANTFIX? Seems a waste of alot of input.
Comment 34 Giczi Levente 2015-06-25 12:20:29 UTC
(In reply to Machredsch from comment #30)
> Created attachment 405598 [details, diff] [details, diff]
> kernel-4.* patch
> 
> I uploaded a cleaned patch, which should work for kernel 4.0 and 4.1.
> I removed all unnecessary hunks from my previous patch (where I used koalasa
> raw firegl_public.c as a source, which contains more changes than the diffs
> for kernel 4) and from Drake's patch (readme.md and dkms.conf).
> Can someone please test the patch to be sure, Drake Donahue maybe?

Patch is in the /etc/portage/patches/x11-drivers/ati-drivers directory. I use kernel 4.0.5 and ati-drivers-15.1 and nothing happen.
Comment 35 Machredsch 2015-06-25 12:31:32 UTC
(In reply to Giczi Levente from comment #34)
> Patch is in the /etc/portage/patches/x11-drivers/ati-drivers directory. I
> use kernel 4.0.5 and ati-drivers-15.1 and nothing happen.

Pls follow this guide, especially bashrc:
https://wiki.gentoo.org/wiki//etc/portage/patches

you should rename "ati-drivers" dir to "ati-drivers-15.1" to avoid future problems, I suggest.
Comment 36 Giczi Levente 2015-06-25 13:08:34 UTC
(In reply to Machredsch from comment #35)
> (In reply to Giczi Levente from comment #34)
> > Patch is in the /etc/portage/patches/x11-drivers/ati-drivers directory. I
> > use kernel 4.0.5 and ati-drivers-15.1 and nothing happen.
> 
> Pls follow this guide, especially bashrc:
> https://wiki.gentoo.org/wiki//etc/portage/patches
> 
> you should rename "ati-drivers" dir to "ati-drivers-15.1" to avoid future
> problems, I suggest.

Thanks a lot, working on amd64.
Comment 37 Drake Donahue 2015-06-26 04:51:45 UTC
Created attachment 405770 [details, diff]
clear license, kernel 4/4.1 compatible, kernel must be patched and recompiled first

kernel needs a patch as shown at http://www.gentooforum.de/artikel/22061/linux-4-0-5-ati-drivers-cpu-tlbstate-problem.html
Comment 38 Drake Donahue 2015-06-26 04:54:15 UTC
I think it should be possible to produce a patched ati-drivers version bump that has no licensing problems based on kolasa's latest update with a kernel patch suggested http://www.gentooforum.de/index.php?page=ExternalLink&url=http%3A%2F%2Fmy.mail.ru%2Fcommunity%2Fblog_theism%2F71E06A0554E919E3.html relayed by http://www.gentooforum.de/artikel/22061/linux-4-0-5-ati-drivers-cpu-tlbstate-problem.html . User style patch provided. Discussion follows.

http://support.amd.com/en-us/download/desktop?os=Linux+x86 has AMD Catalyst™ 15.5 Proprietary Linux x86 Display Driver. 

The Downloaded file is amd-catalyst-omega-15.5-linux-run-installers.zip .

The unzipped file is amd-catalyst-omega-15.5-linux-run-installers.run (a shell scipt that accesses the 149 MB package).

sh amd-catalyst-omega-15.5-linux-run-installers.run --extract executed from the containing directory generates "Created directory fglrx-install.gNjzRq
Verifying archive integrity... All good.
Uncompressing AMD Catalyst(TM) Proprietary Driver-15.101.1001" Directory fglrx-install.gNjzRq allows inspection of 475MB of source code.

sh amd-catalyst-omega-15.5-linux-run-installers.run --help executed from the containing directory generates "Makeself version 2.2.0 
 1) Getting help or info about amd-catalyst-omega-15.5-linux-run-installers.run :
  amd-catalyst-omega-15.5-linux-run-installers.run -h|--help                     Print this message
  amd-catalyst-omega-15.5-linux-run-installers.run -i|--info                     Print embedded info : title, default target directory, embedded script 
  amd-catalyst-omega-15.5-linux-run-installers.run -l|--list                     Print the list of files in the archive
  amd-catalyst-omega-15.5-linux-run-installers.run -c|--check                    Checks integrity of the archive
  amd-catalyst-omega-15.5-linux-run-installers.run --extract NewDirectory        Extract this package to NewDirectory only
 
 2) Running amd-catalyst-omega-15.5-linux-run-installers.run :
  amd-catalyst-omega-15.5-linux-run-installers.run [options] [additional arguments to embedded script] with following options (in that order)
  --keep                              Do not erase target directory after running the embedded script
  --uninstall[=force|dryrun]          Run AMD Catalyst(TM) Proprietary Driver Uninstall
  Following arguments will be passed to the embedded script:
  --install                           Install the driver(default)
  --listpkg                           List all the generatable packages 
  --buildpkg package                  Build "package" if generatable ("package" as returned by --listpkg)
  --buildandinstallpkg package        Build and Install "package" as returned by --listpkg"

sh amd-catalyst-omega-15.5-linux-run-installers.run --listpkg  executed from the containing directory generates "Created directory fglrx-install.Uujvio
Verifying archive integrity... All good.
Uncompressing AMD Catalyst(TM) Proprietary Driver-15.101.1001............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
=====================================================================
 AMD Catalyst(TM) Proprietary Driver Installer/Packager 
=====================================================================
List of generatable packages:

Package Maintainer(s): Aric Cyr <aric.cyr@gmail.com>
                      Mario Limonciello <superm1@gmail.com>
Status: *UNVERIFIED*
Debian Packages:
	Debian/sid
	Debian/unstable
	Debian/etch
	Debian/stable
	Debian/lenny
	Debian/testing
	Debian/experimental

Package Maintainer(s): Niko Mirthes <nmirthes@gmail.com>
                      Michael Larabel <michael@phoronix.com>
Status: *UNVERIFIED*
Fedora Packages:
	Fedora/FC3
	Fedora/FC4
	Fedora/FC5
	Fedora/FC6
	Fedora/F7
	Fedora/F8
	Fedora/F9
	Fedora/F10
	Fedora/RHEL3
	Fedora/RHEL4

Package Maintainer(s): AMD
Status: Verified
RedHat Packages:
	RedHat/RHEL5_64a
	RedHat/RHEL6_64a
	RedHat/RHEL7_64a
	RedHat/RHEL5
	RedHat/RHEL6
	RedHat/RHEL7

Package Maintainer(s): Emanuele Tomasi <tomasi@cli.di.unipi.it>
Status: *UNVERIFIED*
Slackware Packages:
	Slackware/Slackware

Package Maintainer(s): Sebastian Siebert <freespacer@gmx.de>
Status: *UNVERIFIED*
SuSE Packages:
	SuSE/SLE10-IA32
	SuSE/SLE10-AMD64
	SuSE/SLE11-IA32
	SuSE/SLE11-AMD64
	SuSE/SLE12-AMD64
	SuSE/SUSE121-IA32
	SuSE/SUSE121-AMD64
	SuSE/SUSE122-IA32
	SuSE/SUSE122-AMD64
	SuSE/SUSE123-IA32
	SuSE/SUSE123-AMD64
	SuSE/SUSE131-IA32
	SuSE/SUSE131-AMD64
	SuSE/SUSE-autodetection

Package Maintainer(s): Alberto Milone <alberto.milone@canonical.com>
Status: *UNVERIFIED*
Ubuntu Packages:
	Ubuntu/gutsy
	Ubuntu/hardy
	Ubuntu/intrepid
	Ubuntu/jaunty
	Ubuntu/karmic
	Ubuntu/lucid
	Ubuntu/maverick
	Ubuntu/natty
	Ubuntu/oneiric
	Ubuntu/precise
	Ubuntu/quantal
	Ubuntu/raring
	Ubuntu/saucy
	Ubuntu/source
	Ubuntu/trusty
	Ubuntu/utopic

For example, to build a Debian Etch package, run the following:
% ./amd-driver-installer-<version>-<architecture>.run --buildpkg Debian/etch

Removing temporary directory: fglrx-install.Uujvio" Unfortunately no Gentoo. 

sh amd-catalyst-omega-15.5-linux-run-installers.run --listpkg  executed from the containing directory failed; unable to avoid an fglrx already installed failure unless --force was used in which case the compile and install appeared to succeed but startx failed and ati-drivers-15.1 reinstall was made difficult.

sh amd-catalyst-omega-15.5-linux-run-installers.run --buildpkg  Ubuntu/utopic failed citing structure.

ubuntu vivid package fglrx-installer_15.500.orig.tar.gz is not yet available. As portage ati-drivers-15.1 uses ubuntu package fglrx-installer_15.200.orig.tar.gz as distfile an ebuild by analogy is ????

My /root/Downloads/fglrx-install.gNjzRq/common/lib/modules/fglrx/build_mod/ seems to contain the same set of files as https://github.com/kolasa/fglrx-core-15.200 which has been updated in https://github.com/kolasa/fglrx-core-15.101 . The update in https://github.com/kolasa/fglrx-core-15.101 and amd-catalyst-omega-15.5-linux no longer needs to have the lines "#ifdef MODULE_LICENSE
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0)
MODULE_LICENSE("GPL\0Proprietary. (C) 2002 - ATI Technologies, Starnberg, GERMANY");
#else
MODULE_LICENSE("Proprietary. (C) 2002 - ATI Technologies, Starnberg, GERMANY");
#endif
#endif
#ifdef MODULE_DEVICE_TABLE
MODULE_DEVICE_TABLE(pci, fglrx_pci_table);
#endif" in firegl_public.c . Replaced by "#ifdef MODULE_LICENSE
MODULE_LICENSE("Proprietary. (C) 2002 - ATI Technologies, Starnberg, GERMANY");
#endif
#ifdef MODULE_DEVICE_TABLE
MODULE_DEVICE_TABLE(pci, fglrx_pci_table);
#endif"

Created a patch to use the latest files with the existing ati-drivers-15.1 ebuild using the techniques previously recounted except downloaded https://github.com/kolasa/fglrx-core-15.101/archive/master.zip in a browser, unzipped it in archive manager GUI, and removed .gitignore from the unzipped package because of problems using previous CLI technique. Installed patch at /etc/portage/patches/x11-drivers/ati-drivers/kernel-4plus-ati-drivers-15.5.patch . This patch compiled until the kernel's modpost was called. Failure cited EXPORT_SYMBOL_GPL(cpu_tlbstate) . A lucky google found http://www.gentooforum.de/artikel/22061/linux-4-0-5-ati-drivers-cpu-tlbstate-problem.html . Edited /usr/src/linux/arch/x86/mm/init.c to change "EXPORT_SYMBOL_GPL (Cpu_tlbstate);" to "EXPORT_SYMBOL (cpu_tlbstate);" . Ran "cd /usr/src/linux;make && make modules_install && make install && emerge ati-drivers" successfully.
Comment 39 Ben de Groot (RETIRED) gentoo-dev 2015-06-27 02:27:28 UTC
(In reply to Ian Delaney from comment #33)
> (In reply to Ben de Groot from comment #26)
> > 
> > See comment #9. It seems not legally possible for us to ship this.
> 
> Ben how is this looking? If it's really not legally possible do we, like you
> or I, simply close this CANTFIX? Seems a waste of alot of input.

I'm not sure. Let's ping Ulm.

Ulm, can you say something about the legal side of these patches? As a user, I would like to see this happen, but I'm not sure if it could get us into trouble.
Comment 40 Ulrich Müller gentoo-dev 2015-06-27 06:19:34 UTC
(In reply to Ben de Groot from comment #39)
> I'm not sure. Let's ping Ulm.

[Please CC licences@gentoo.org in such cases.]

> Ulm, can you say something about the legal side of these patches? As a user,
> I would like to see this happen, but I'm not sure if it could get us into
> trouble.

What I extract from the previous discussion, the question is if we can patch a module so that its MODULE_LICENSE is effectively changed from "Proprietary" to "GPL", or patch the kernel to use EXPORT_SYMBOL instead of EXPORT_SYMBOL_GPL?

I think the answer is no to both questions:
- The module is copyrighted by AMD. Its license (and therefore also
  MODULE_LICENSE) can only be changed by the copyright holder.
- Similarly, EXPORT_SYMBOL and EXPORT_SYMBOL_GPL are a statement of the
  upstream kernel team about what module linkage is allowed, and cannot
  be changed ad libitum.

IANAL, TINLA.
Comment 41 mimosinnet 2015-06-28 11:32:27 UTC
(In reply to Machredsch from comment #31)
> > Created attachment 405598 [details, diff] [details, diff] [details, diff]
> > kernel-4.* patch
> 
> patch should be usable as a user patch under /etc/portage/patches tree, it's
> diffs are against the unpacked emerge working dir ($PORTAGE_TMPDIR).

The patch has worked (kernel 4.0.5, ati-drivers-15,1) after Enabling /etc/portage/patches for all ebuilds (https://wiki.gentoo.org/wiki//etc/portage/patches). Thanks!
Comment 42 Scott Alfter 2015-06-28 22:34:14 UTC
The patch in attachment #405770 [details, diff] is working for me (in conjunction with a one-line change to the kernel source) with one caveat: power management appears to not work properly.  When the screen wakes up after having gone asleep, the KDE taskbar and "start menu" (application launcher?) no longer work.  Pressing Alt-F2 doesn't bring up the usual pop-up at the top of the screen, though if you type in a program name and hit Enter, it'll start.  I don't recall these problems having been present with 14.x drivers and 3.8.x kernels.
Comment 43 Scott Alfter 2015-06-28 23:27:18 UTC
Additional test data: I had been running with an R7 260X I had purchased recently along with a 4K monitor.  I tried subbing in the 15.5 driver (ebuild in the ROKO__ overlay) to see if it'd behave differently...it didn't.  

I then swapped in the HD6870 I had previously been using.  When it booted up, I was pleasantly surprised to see it'd do 4K at all (at 30 Hz, but it's working).  I then proceeded to test recovery from power management.  With the 15.5 driver, it worked once or twice.  I then reverted to the 15.1 driver that is the subject of this bug...no dice.  I then went back to 15.5, and while I'd swear it was working once, now it isn't.

Now I'm on the fence: take the R7 260X back for a refund and run on the HD6870 (and live with 30 Hz 4K), keep the R7 260X (and hope that AMD gets these driver issues sorted out eventually), or take the R7 260X back and trade it in for an nVidia card (which would make these issues moot...can't say I've ever had trouble getting nVidia hardware playing nice with Linux).
Comment 44 Drake Donahue 2015-07-09 17:15:36 UTC
Submitted kernel bug hoping the responsible parties will fix the license problem in the 4 series kernels /arch/x86/mm/init.c https://bugzilla.kernel.org/show_bug.cgi?id=101281
Comment 45 Ben Kohler gentoo-dev 2015-07-14 18:53:56 UTC
*** Bug 554910 has been marked as a duplicate of this bug. ***
Comment 46 Drake Donahue 2015-07-14 19:55:23 UTC
Created attachment 406814 [details, diff]
15.7.patch

Previous patches will not work with ati-drivers-15.7 which is in the x11 overlay. 
This patch corrects the 15.7 errors and the driver will compile. The compiled driver will not install unless the firegl_public.c license is changed or the kernel source is edited and the kernel recompiled. I favor editing /usr/src/linux/arch/x86/mm/init.c to change EXPORT_SYMBOL_GPL(cpu_tlbstate) to EXPORT_SYMBOL(cpu_tlbstate) . 

Excruciating detail: Add the x11 overlay, https://wiki.gentoo.org/wiki/Layman refers. Add ~amd64 for =x11-drivers/ati-drivers-15.7 in /etc/portage/package.keywords. mkdir -p /etc/portage/patches/x11-drivers/ati-drivers . Download the 15.7.patch to the directory just created. Download the AMD Catalyst™ 15.7 Proprietary Linux Graphics Driver to /usr/portage/distfiles as amd-driver-installer-15.20.1046-x86.x86_64.zip . run chown portage:portage /usr/portage/distfiles/amd-driver-installer-15.20.1046-x86.x86_64.zip . emerge unzip. Edit the kernel source by running:
sed -i 's/EXPORT_SYMBOL_GPL(cpu_tlbstate)/EXPORT_SYMBOL(cpu_tlbstate)/g' /usr/src/linux/arch/x86/mm/init.c then emerge ati-drivers. Reverse the kernel edit if desired.
Comment 47 Ulrich Müller gentoo-dev 2015-07-15 05:09:49 UTC
(In reply to Drake Donahue from comment #46)
> The compiled driver will not install unless the firegl_public.c license is
> changed or the kernel source is edited and the kernel recompiled. I favor
> editing /usr/src/linux/arch/x86/mm/init.c to change
> EXPORT_SYMBOL_GPL(cpu_tlbstate) to EXPORT_SYMBOL(cpu_tlbstate) . 

Please read comment #40 again. As a distro, we cannot endorse any of these two "solutions".
Comment 48 Drake Donahue 2015-07-15 05:15:14 UTC
I agree, the distro can't. The distro could file upstream bugs at kernel.org and amd.com though.
Comment 49 Chí-Thanh Christopher Nguyễn gentoo-dev 2015-07-16 09:36:43 UTC
(In reply to Ulrich Müller from comment #40)
> - Similarly, EXPORT_SYMBOL and EXPORT_SYMBOL_GPL are a statement of the
>   upstream kernel team about what module linkage is allowed, and cannot
>   be changed ad libitum.

I think they can be changed (as GPL provides freedom #1), but the result will become non-redistributable.

USE="kernel-patch" in ati-drivers could implement this (in a similar fashion to sys-fs/aufs4).
While probably legal, of course this would be a blatant disregard of the kernel developer's wishes regarding this function.
Comment 50 Markus Giese 2015-07-16 11:39:59 UTC
in /usr/src/linux/arch/x86/mm/init.c to change
EXPORT_SYMBOL_GPL(cpu_tlbstate) to EXPORT_SYMBOL(cpu_tlbstate) is not enough.

i did make clean, recompiled the kernel. i still cannot compile ati-drivers-15.7 with kernel-4.1.2


thanks for any hints...
Comment 51 Drake Donahue 2015-07-16 16:53:27 UTC
https://bugs.gentoo.org/show_bug.cgi?id=554590 may be causing action also.

A day passes and an ati-drivers-15.7 ebuild is now present in portage as well as in the x11 overlay. A new distfile is on the mirrors.
I deleted the x11 overlay. The ati-drivers-15.7 ebuild fetches  mirror://gentoo/amd-driver-installer-15.20.1046-x86.x86_64.zip eliminating the need for a manual download. 
I ran emerge -1 ati-drivers several times for testing against kernel-4.1.2. I still needed the user patch, /etc/portage/patches/x11-drivers/ati-drivers-15.7/15.7.patch . I still needed /usr/src/linux/arch/x86/mm/init.c edited to change EXPORT_SYMBOL_GPL(cpu_tlbstate); to EXPORT_SYMBOL(cpu_tlbstate); followed by a kernel recompile and install.
Comment 52 Michael Gn. Gajda 2015-07-16 23:18:04 UTC
I added the 15.7.patch patchfile and edited my kernel gentoo-sources-4.0.8.

ati-drivers compiles successfully and is loaded after a reboot. But it fails because the kernel module fails to load.

[   87.356221] fglrx: Unknown symbol KCL_IOMMU_SetByPass (err 0)
[   87.356241] fglrx: Unknown symbol KCL_LockReadOnlyUserPages (err 0)

Sincerely
Michael
Comment 53 Drake Donahue 2015-07-17 02:25:42 UTC
Created attachment 406958 [details, diff]
15.7-r1.patch

15.7-r1.patch has been tested with kernel 4.1.2; the ati-drivers-15.7 ebuild from portage; and the /usr/portage/distfiles/amd-driver-installer-15.20.1046-x86.x86_64.zip from the gentoo mirror. This should eliminate the "fglrx: Unknown symbol KCL_IOMMU_SetByPass (err 0) and 
fglrx: Unknown symbol KCL_LockReadOnlyUserPages (err 0)" errors reported by Michael Gajda. Oddly, I only received a warning for those two and had no problem compiling fglrx. Installing fgrlx still requires editing /usr/src/linux/arch/x86/mm/init.c to replace EXPORT_SYMBOL_GPL(cpu_tlbstate) to EXPORT_SYMBOL(cpu_tlbstate) and recompiling the kernel before running emerge -1 ati-drivers.
Comment 54 Drake Donahue 2015-07-17 03:09:15 UTC
Need a scoreboard!!! Rapidly changing.
/usr/portage/distfiles/amd-driver-installer-15.20.1046-x86.x86_64.zip has vanished from the mirror. 
Back to the nofetch message: !!! Couldn't download 'amd-driver-installer-15.20.1046-x86.x86_64.zip'. Aborting.
 * Fetch failed for 'x11-drivers/ati-drivers-15.7', Log file:
 *  '/var/tmp/portage/x11-drivers/ati-drivers-15.7/temp/build.log'
 * The driver packages
 * amd-driver-installer-15.20.1046-x86.x86_64.zip xvba-sdk-0.74-404001.tar.gz
 * need to be downloaded manually from
 * http://support.amd.com/en-us/download/desktop?os=Linux%20x86_64
 * and http://developer.amd.com/wordpress/media/2012/10/xvba-sdk-0.74-404001.tar.gz

Back to testing patch versus manual download.

manual download to /usr/portage/distfiles
chown portage:portage /usr/portage/distfiles/usr/portage/distfiles/amd-driver-installer-15.20.1046-x86.x86_64.zip
15.7-r1.patch at /etc/portage/patches/x11-drivers/ati-drivers-15.7/
emerge -1 ati-drivers 

Compiled, installed, worked.
Comment 55 Michael Gn. Gajda 2015-07-17 10:09:08 UTC
Yup, I can confirm that with the last patch, the module loads  and works on kernel 4.0.4 and 4.0.8.

Oh dear, AMD :-P
Comment 56 Markus Giese 2015-07-17 11:33:38 UTC
where to get ati-drivers-15.7 patch ? and how to apply it and where to(kernel) ? thanks
Comment 57 Drake Donahue 2015-07-20 03:41:36 UTC
https://bugs.gentoo.org/show_bug.cgi?id=554590 has a proposed ati-drivers-15.7-r2 and 15.7-r2.patch that can be installed by the user on their local x11 overlay. testing comments welcome.

manual download from amd, user patching eliminated, installing fgrlx still requires editing /usr/src/linux/arch/x86/mm/init.c to replace EXPORT_SYMBOL_GPL(cpu_tlbstate) to EXPORT_SYMBOL(cpu_tlbstate) and recompiling the kernel before running emerge -1 ati-drivers. If you forget this the ebuild will die with a reminder. If a /etc/portage/patches directory with an ati-drivers  user patch exists remove or rename is recommended.
Comment 58 Drake Donahue 2015-07-25 18:44:19 UTC
kernel-4.1.3 adds a further problem. A new line, EXPORT_SYMBOL_GPL(pci_ignore_hotplug); added to /usr/src/linux/drivers/pci/pci.c; prevents installing ati-drivers with " Building modules, stage 2.
  MODPOST 1 modules
FATAL: modpost: GPL-incompatible module fglrx.ko uses GPL-only symbol 'pci_ignore_hotplug'
scripts/Makefile.modpost:90: recipe for target '__modpost' failed "

The user can run: 
sed -i 's/EXPORT_SYMBOL_GPL(cpu_tlbstate)/EXPORT_SYMBOL(cpu_tlbstate)/g' /usr/src/linux/arch/x86/mm/init.c'
and 
sed -i 's/EXPORT_SYMBOL_GPL(pci_ignore_hotplug)/EXPORT_SYMBOL(pci_ignore_hotplug)/g' /usr/src/linux/arch/x86/mm/init.c' in a terminal.
After the edit; recompile/reinstall the kernel and emerge ati-drivers."
Comment 59 Y Jafar 2015-07-26 19:56:17 UTC
Using Drakes patch 15.7 with 4.0.8 with *hardened sources*, seems to compile and run as described OK, the Kernel patch is mandatory here, as is the 15.7 user patch. However since I have a more exotic setup (portrait via xrandr on 3 monitors) crashes to login screen, not sure if it is me being out of my depth.

Reverting back to 3.18.9 and hard masking anything > 3.18.9 until someone upstream kernel/amd sorts this silliness out, I would persevere but it's my workstation.

Also would be nice for emerge to give us mere mortals the "We can't distribute this package, now go download it yourself and put it in /usr/portage/distfiles/" as it is the case for Java. :)
Comment 60 Drake Donahue 2015-07-26 20:49:38 UTC
Download 15.7-r1.patch to 
/etc/portage/patches/x11-drivers/ati-drivers/15.7-r1.patch 
Kernel-4.1.3 requires two patches to be run in a terminal:

sed -i 's/EXPORT_SYMBOL_GPL(cpu_tlbstate)/EXPORT_SYMBOL(cpu_tlbstate)/g' /usr/src/linux/arch/x86/mm/init.c'

and 

sed -i 's/EXPORT_SYMBOL_GPL(pci_ignore_hotplug)/EXPORT_SYMBOL(pci_ignore_hotplug)/g' /usr/src/linux/arch/x86/mm/init.c'

After these edits; recompile/reinstall the kernel and then emerge ati-drivers.
Comment 61 Nick 2015-07-26 22:24:51 UTC
For me with kernel 4.1.3, EXPORT_SYMBOL_GPL(pci_ignore_hotplug) occurs in file /usr/src/linux/drivers/pci/pci.c, not /usr/src/linux/arch/x86/mm/init.c

When I changed it to EXPORT_SYMBOL in /usr/src/linux/drivers/pci/pci.c, the ati-drivers-15.7 ebuild worked.
Comment 62 Drake Donahue 2015-07-26 22:32:06 UTC
Sorry, too much pasting too little editing. As Nick points out should be:

Download 15.7-r1.patch to 
/etc/portage/patches/x11-drivers/ati-drivers/15.7-r1.patch 
Kernel-4.1.3 requires two patches to be run in a terminal:

sed -i 's/EXPORT_SYMBOL_GPL(cpu_tlbstate)/EXPORT_SYMBOL(cpu_tlbstate)/g' /usr/src/linux/arch/x86/mm/init.c'

and 

sed -i 's/EXPORT_SYMBOL_GPL(pci_ignore_hotplug)/EXPORT_SYMBOL(pci_ignore_hotplug)/g' /usr/src/linux/drivers/pci/pci.c'

After these edits; recompile/reinstall the kernel and then emerge ati-drivers.
Comment 63 Abulhair Saparov 2015-08-18 04:56:18 UTC
Some feedback on ati-drivers-15.7-r2 patches and ebuild:
  Make sure to use xorg-server-1.16 (and possibly older) otherwise X will throw a segmentation fault when it tries to start.
  Also I had to delete a broken symbolic link /usr/lib32/xorg/modules/extensions/libglx.so (not sure if this was supposed to be removed by portage).
Comment 64 Alexey Shildyakov 2015-08-20 08:18:37 UTC
(In reply to Abulhair Saparov from comment #63)
> Some feedback on ati-drivers-15.7-r2 patches and ebuild:
>   Make sure to use xorg-server-1.16 (and possibly older) otherwise X will
> throw a segmentation fault when it tries to start.

Are you talking about newer >xorg-server-1.16 or older (<=xorg-server-1.16) versions?
Comment 65 Drake Donahue 2015-08-20 14:13:04 UTC
Proposed ati-drivers-15.7-r2.ebuild with non-user patch 15.7-r2.patch is backgrounded and presented in a parallel bug, at
https://bugs.gentoo.org/show_bug.cgi?id=554590.
Based on 2 tests, it appears the chances of using ati-drivers-15.7-r2 and xorg-server more recent than 1.16 is 50%.  
Abulhair Saparov encountered a segmentation fault with ati-drivers-15.7-r2 and xorg-server(s) more recent than xorg-server-1.16.
I had been using xorg-server-1.16.4 with gentoo-sources-4.1.5 (EXPORT_SYMBOL edits done) and ati-drivers-15.7-r2 with no problems.
I keyworded xorg-server-1.17.2 as ~amd64. Despite several blockers and required dependency keyword changes, xorg-server-1.17.2 and ati-drivers-15.7-r2 emerged against gentoo-sources-4.1.5. After reboot, no problems were encountered. As the latest update had installed gentoo-sources-4.1.6, I edited the kernel-4.1.6 source to EXPORT_SYMBOL(cpu_tlbstate) and EXPORT_SYMBOL(pci_ignore_hotplug), compiled and installed the 4.1.6 kernel, emerged ati-drivers, rebooted, no problems.
What variations in equipment and software caused the disparate results is unknown.
Comment 66 Abulhair Saparov 2015-08-20 22:57:35 UTC
(In reply to Alexey Shildyakov from comment #64)
> (In reply to Abulhair Saparov from comment #63)
> > Some feedback on ati-drivers-15.7-r2 patches and ebuild:
> >   Make sure to use xorg-server-1.16 (and possibly older) otherwise X will
> > throw a segmentation fault when it tries to start.
> 
> Are you talking about newer >xorg-server-1.16 or older (<=xorg-server-1.16)
> versions?

I have no problems when I run <=xorg-server-1.16. But I run into a segfault on 1.17.2.
Comment 67 Drake Donahue 2015-08-31 04:37:47 UTC
The 4.2 kernel replaces
/usr/src/linux-4.1.6-gentoo/arch/x86/include/asm/i387.h with a directory
structure: as in /usr/src/linux-4.2-rc8/arch/x86/include/asm/fpu
containing api.h internal.h regset.h signal.h types.h xstate.h
Also adds a couple more EXPORT_SYMBOL_GPL() calls. Correcting those
problems exposed an implicit declaration error. 

Patches and ebuild at https://bugs.gentoo.org/show_bug.cgi?id=554590
layman/x11 insatallation needed. 

Save the attachments as
/var/lib/layman/x11/x11-drivers/ati-drivers/ati-drivers-15.7-r3.ebuild 
/var/lib/layman/x11/x11-drivers/ati-drivers/files/15.7-r2.patch
/var/lib/layman/x11/x11-drivers/ati-drivers/files/15.7-r3.patch
run ebuild /var/lib/layman/x11/x11-drivers/ati-drivers manifest
Run the sed commands listed in the ebuild, recompile the kernel, emerge ati-drivers. 

Expect to see WARNING: "__fgl_cmpxchg" [/var/tmp/portage/x11-drivers/ati-drivers-15.7-r3/work/common/lib/modules/fglrx/build_mod/2.6.x/fglrx.ko] undefined!
Which seems to be harmless and probably results from my inept resolution of the implicit declaration of __fgl_cmpxchg error.
Comment 68 Oleg Ageev 2015-09-06 19:43:58 UTC
Created attachment 411210 [details, diff]
ati-drivers-15.7.patch

Patches from Drake Donahue have some strange changes, which I don't understand. I'm rewrite patch from scratch based on changes from Machredsch.
Comment 69 Fernando Rodriguez 2015-09-12 23:16:43 UTC
Created attachment 411758 [details, diff]
dont-use-gpl-symbols.patch

Here's a patch that you can endorse. 

For the cpu_tlbstate symbol AFAIU it's only used to read the cached state of the CR4 register, so I just read it directly from the CPU. This code was derived from looking at the kernel headers but that is definitely fair use as we're just reading/writing registers.

As for the pci_ignore_hotplug one, it seems to me that it would only be used for really exotic setups, like kvm, so I just commented that call.

This was tested with the kernel version 3.18.21, it also needs the CR4 patch to compile, I got a cleaner version of it in my overlay[1]. IIRC 4.0 also needs another minor patch but it's trivial.

[1] https://github.com/fernando-rodriguez/portage-overlay/blob/master/x11-drivers/ati-drivers/files/ati-drivers-cr4.patch
Comment 70 Fernando Rodriguez 2015-09-12 23:41:55 UTC
(In reply to Fernando Rodriguez from comment #69)
> Created attachment 411758 [details, diff] [details, diff]
> dont-use-gpl-symbols.patch
> 
> Here's a patch that you can endorse. 
> 
> For the cpu_tlbstate symbol AFAIU it's only used to read the cached state of
> the CR4 register, so I just read it directly from the CPU. This code was
> derived from looking at the kernel headers but that is definitely fair use
> as we're just reading/writing registers.

Actually it looks like it's cached there so we can read the setting of one CPU while executing from another. All the same since in this case we're only reading it for the current CPU (this_cpu_read(cpu_tlbstate.cr4)). So the patch actually makes it a little faster :P
Comment 71 Fernando Rodriguez 2015-09-13 00:42:37 UTC
Created attachment 411760 [details, diff]
dont-use-gpl-symbols.patch

Fixed typo in patch
Comment 72 Fernando Rodriguez 2015-09-13 16:48:13 UTC
Created attachment 411802 [details, diff]
dont-use-gpl-symbols.patch

The pci_ignore_hotplug() call is actually needed for power management in some cases. Here I reverted to using the same method used prior to Linux 3.17 which works fine.

The 2nd hunk of the patch to kcl_acpi.c is in effect just a comment. I included it for informational purposes only as it comes from Linux so it cannot be used legally. If anyone wants to enable it just remove the first hunk and it will take effect. It is exactly what happens (at least on Linux 3.18.21) when pci_ignore_hotplug is called.
Comment 73 Fernando Rodriguez 2015-09-13 19:52:16 UTC
Created attachment 411818 [details, diff]
ati-drivers-5.7-unified.patch

This is a unified patch with everything needed to compile on 3.18.x, 4.0.x, 4.1.x, and 4.2 without lincense forgery or kernel patches.

Tested to work on 3.18.21 and to compile on all the above.

I have an ebuild with all these patches plus the one for bug #542320 at:
https://github.com/fernando-rodriguez/portage-overlay/tree/master/x11-drivers/ati-drivers
Comment 74 Drake Donahue 2015-09-14 06:33:42 UTC
Fernando Rodriguez solution at https://github.com/fernando-rodriguez/portage-overlay/tree/master/x11-drivers/ati-drivers has been tested on amd64 and compiles, installs, and runs. It appears ready for addition to the testing branch. His work has no EXPORT_SYMBOL_GPL issues. It supports glxinfo and glxgears on kernel-4.2 . Manual download from the amd driver page is required. Fetch instructions are in the ebuild. Thanks, Fernando.
Comment 75 Manuel Rüger (RETIRED) gentoo-dev 2015-09-16 19:38:15 UTC
(In reply to Drake Donahue from comment #74)
> Fernando Rodriguez solution at
> https://github.com/fernando-rodriguez/portage-overlay/tree/master/x11-
> drivers/ati-drivers has been tested on amd64 and compiles, installs, and
> runs. It appears ready for addition to the testing branch. His work has no
> EXPORT_SYMBOL_GPL issues. It supports glxinfo and glxgears on kernel-4.2 .
> Manual download from the amd driver page is required. Fetch instructions are
> in the ebuild. Thanks, Fernando.

Could you please rebase on 15.9 and add a pull request to https://github.com/gentoo/gentoo ? Thanks!
Comment 76 Fernando Rodriguez 2015-09-16 20:29:43 UTC
(In reply to Manuel Rüger from comment #75)
> Could you please rebase on 15.9 and add a pull request to
> https://github.com/gentoo/gentoo ? Thanks!

It kind of sucks that I did all this work and AMD finally releases an update the next day! 15.9 compiles just fine as-is on 3.18.x and only a few trivial patches are needed for the latest 4.x kernels. They all apply cleanly. I need to do some testing to see if the preempt patch is still needed and I'll do a pull request. Thanks.
Comment 77 Fernando Rodriguez 2015-09-16 23:00:19 UTC
(In reply to Fernando Rodriguez from comment #76)
> (In reply to Manuel Rüger from comment #75)
> > Could you please rebase on 15.9 and add a pull request to
> > https://github.com/gentoo/gentoo ? Thanks!
> 
> It kind of sucks that I did all this work and AMD finally releases an update
> the next day! 15.9 compiles just fine as-is on 3.18.x and only a few trivial
> patches are needed for the latest 4.x kernels. They all apply cleanly. I
> need to do some testing to see if the preempt patch is still needed and I'll
> do a pull request. Thanks.

They didn't actually fixed anything, they just did something to that it links successfuly but the kernel still refuses to load the module. And they added a fix for the pci_ignore_hotplug() call by copying Linux code but they used ubuntu defines to enable it. I submitted a github PR:

https://github.com/gentoo/gentoo/pull/98
Comment 78 Mike H. 2015-09-19 02:03:58 UTC
(In reply to Drake Donahue from comment #74)
> Fernando Rodriguez solution at
> https://github.com/fernando-rodriguez/portage-overlay/tree/master/x11-
> drivers/ati-drivers has been tested on amd64 and compiles, installs, and
> runs. It appears ready for addition to the testing branch. His work has no
> EXPORT_SYMBOL_GPL issues. It supports glxinfo and glxgears on kernel-4.2 .
> Manual download from the amd driver page is required. Fetch instructions are
> in the ebuild. Thanks, Fernando.

Can't seem to replicate it compiling without error using your overlay on kernel 4.2.0-gentoo-r1 along with ati-drivers-15.9. Works fine on kernel 4.1.6
Comment 79 Fernando Rodriguez 2015-09-19 02:44:31 UTC
(In reply to Mike H. from comment #78)
> Can't seem to replicate it compiling without error using your overlay on
> kernel 4.2.0-gentoo-r1 along with ati-drivers-15.9. Works fine on kernel
> 4.1.6

What error are you getting?
Did you grab all the patch files from the overlay?
I don't have 4.2.0-gentoo-r1 but I tested that it works on vanilla 4.2 from git.
Comment 80 Mike H. 2015-09-19 03:27:53 UTC
> What error are you getting?
> Did you grab all the patch files from the overlay?
> I don't have 4.2.0-gentoo-r1 but I tested that it works on vanilla 4.2 from
> git.

Actually cloned everything from your overlay and all files/*.patches are there. here is the result.

https://bpaste.net/show/e53fd011d97d

FATAL: modpost: GPL-incompatible module fglrx.ko uses GPL-only symbol 'kernel_fpu_end'
Comment 81 Fernando Rodriguez 2015-09-19 04:19:53 UTC
(In reply to Mike H. from comment #80)
> > What error are you getting?
> > Did you grab all the patch files from the overlay?
> > I don't have 4.2.0-gentoo-r1 but I tested that it works on vanilla 4.2 from
> > git.
> 
> Actually cloned everything from your overlay and all files/*.patches are
> there. here is the result.
> 
> https://bpaste.net/show/e53fd011d97d
> 
> FATAL: modpost: GPL-incompatible module fglrx.ko uses GPL-only symbol
> 'kernel_fpu_end'

Ah, it didn't fail at modpost for me because I just ran make modules_prepare but didn't compile the kernel.

I just pushed an updated patch, I haven't tested it yet but it removes that GPL symbol, you may still get an error from another symbol, if so please post the error and I'll update the patch. I'm building kernel 4.2 to test it out.
Comment 82 Mike H. 2015-09-19 05:21:38 UTC
(In reply to Fernando Rodriguez from comment #81)
> (In reply to Mike H. from comment #80)
 
> Ah, it didn't fail at modpost for me because I just ran make modules_prepare
> but didn't compile the kernel.
> 
> I just pushed an updated patch, I haven't tested it yet but it removes that
> GPL symbol, you may still get an error from another symbol, if so please
> post the error and I'll update the patch. I'm building kernel 4.2 to test it
> out.

Ok compiled sucesfully :) Haven't rebooted into new kernel, so good job, patches now work for kernel 4.2.0-gentoo-r1, Thanks Fernando.
Comment 83 Mike H. 2015-09-19 05:22:46 UTC
(In reply to Fernando Rodriguez from comment #81)
> (In reply to Mike H. from comment #80)
 
> Ah, it didn't fail at modpost for me because I just ran make modules_prepare
> but didn't compile the kernel.
> 
> I just pushed an updated patch, I haven't tested it yet but it removes that
> GPL symbol, you may still get an error from another symbol, if so please
> post the error and I'll update the patch. I'm building kernel 4.2 to test it
> out.

Ok compiled sucesfully :) Haven't rebooted into new kernel, so good job, patches now work for kernel 4.2.0-gentoo-r1, Thanks Fernando.
Comment 84 Manuel Rüger (RETIRED) gentoo-dev 2015-09-21 00:05:27 UTC
*** Bug 560958 has been marked as a duplicate of this bug. ***
Comment 85 Drake Donahue 2015-09-21 00:34:11 UTC
https://github.com/gentoo/gentoo/blob/master/x11-drivers/ati-drivers/files does not contain all needed patches.
https://github.com/gentoo/gentoo/blob/master/x11-drivers/ati-drivers/ati-drivers-15.9.ebuild does not list all required epatches

https://github.com/fernando-rodriguez/portage-overlay/tree/master/x11-drivers/ati-drivers contains all required updates.

https://github.com/fernando-rodriguez/portage-overlay/tree/master/x11-drivers/ati-drivers has been installed in a local overlay. ati-drivers-15.9 was then emerged and tested against gentoo-sources-3.18.16, gentoo-sources-4.1.6, gentoo-sources-4.2.0-r1, git-sources-4.2-rc8, and git-sources-4.3-rc1. All emerges were successful and supported xfce4, glxinfo, glxgears, and usual desktop applications.
Recommend updating https://github.com/gentoo/gentoo/blob/master/x11-drivers/ati-drivers with current, complete, and working x11-drivers/ati-drivers from Fernando Rodriguez's overlay. 
The last pull was 4 days ago; Fernando last updated his overlay 20 hours ago.
Comment 86 Drake Donahue 2015-09-22 16:49:12 UTC
<snip>
> I'm building kernel 4.2 to test it out.


The work you finished 3 days ago has been tested against gentoo-sources-3.18.16, gentoo-sources-4.1.6, gentoo-sources-4.2.0-r1, gentoo-sources-4.2.0-r2, git-sources-4.2-rc8, git-sources-4.3-rc1, and git-sources-4.3-rc2. Works beautifully.
Perhaps a pull request?
Comment 87 Manuel Rüger (RETIRED) gentoo-dev 2015-09-23 10:14:50 UTC
commit 3ee13140db47e37adf0a0c7fb88c094a39cf1a83
Author: Ian Delaney <idella4@gentoo.org>
Date:   Wed Sep 23 17:20:32 2015 +0800

    x11-drivers/ati-drivers: revbump required to ati-drivers-15.9-r1
    
    of the ati-drivers-15.9.ebuild prepared by fernando-rodriguez
    in /gentoo/pull/98
    
    Package-Manager: portage-2.2.20.1

commit 6913a35966d89d28ed6208ab9a58c20fd8a80396
Author: Fernando Rodriguez <frodriguez.developer@outlook.com>
Date:   Wed Sep 16 18:24:47 2015 -0400

    x11-drivers/ati-drivers: Fix compile errors and preemption bug
    
    Ebuild cleanup and patches to compile against recent kernels by
    replacing calls that use GPL'd kernel symbols with our own
    implementation and several others to fix compile errors caused
    by API changes on recent kernels.
    
    Also adds patch to disable preemption before calling certain
    kernel functions that trigger the following error:
    
    BUG: using smp_processor_id() in preemptible [00000000] code:firegl/3657
    
    Gentoo-Bug: 548118
    Gentoo-Bug: 542320