Recompile Linux Kernel of Ubuntu 18.04 with patch for Intel display drivers

9,848

Solution I got from the related bug report: https://bugs.freedesktop.org/show_bug.cgi?id=105887

Install necessary packages for Kernel compilation and download Ubuntu Kernel patches:

sudo apt install git flex bison bc libssl-dev gawk libudev-dev ocl-icd-opencl-dev libpci-dev libelf-dev python2.7 libncurses-dev fakeroot kernel-wedge binfmt-support ksh lsscsi binfmt-support libpcre16-3 libpcre3-dev libpcre32-3 libpcrecpp0v5 libsepol1-dev libattr1-dev libblkid-dev libpcre16-3 libpcre3-dev libpcre32-3 libpcrecpp0v5 libselinux1-dev libsepol1-dev uuid-dev debugedit libarchive13 libdw1 liblua5.2-0 liblzo2-2 libnspr4 libnss3 librpm8 librpmbuild8 librpmio8 librpmsign8 rpm rpm-common rpm2cpio spl-dkms

git clone --depth 1 --single-branch --branch v4.17.2 git://git.launchpad.net/~ubuntu-kernel-test/ubuntu/+source/linux/+git/mainline-crack v4.17.2

cd v4.17.2
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.17.2/0001-base-packaging.patch
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.17.2/0002-UBUNTU-SAUCE-add-vmlinux.strip-to-BOOT_TARGETS1-on-p.patch
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.17.2/0003-UBUNTU-SAUCE-tools-hv-lsvmbus-add-manual-page.patch
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.17.2/0004-UBUNTU-SAUCE-no-up-disable-pie-when-gcc-has-it-enabl.patch
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.17.2/0005-debian-changelog.patch
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.17.2/0006-configs-based-on-Ubuntu-4.17.0-3.4.patch

Download the patch from https://patchwork.freedesktop.org/patch/229363/ and rename in i915.patch. Apply all patches:

patch -p1 < 0001-base-packaging.patch
patch -p1 < 0002-UBUNTU-SAUCE-add-vmlinux.strip-to-BOOT_TARGETS1-on-p.patch
patch -p1 < 0003-UBUNTU-SAUCE-tools-hv-lsvmbus-add-manual-page.patch
patch -p1 < 0004-UBUNTU-SAUCE-no-up-disable-pie-when-gcc-has-it-enabl.patch
patch -p1 < 0005-debian-changelog.patch
patch -p1 < 0006-configs-based-on-Ubuntu-4.17.0-3.4.patch
patch -p1 < i915.patch

Make Kernel config from current Kernel config:

yes "" | make oldconfig

Disable ZFS if it's not required:

Set do_zfs = false in debian.master/rules.d/amd64.mk

Build Kernel:

make deb-pkg
# find the debian package files first
dpkg -i $KERNEL_DEB_FILES

The drivers seem to be part of kernel-HEADER packages, so it should be sufficient to install these.

After installing the Kernel Debian packages, update Grub:

sudo update-grub

Set the new Default Kernel in Grub settings and update grub again:

sudo vim /etc/default/grub

My HDMI problems are gone now.

Share:
9,848

Related videos on Youtube

Wolkenarchitekt
Author by

Wolkenarchitekt

Updated on September 18, 2022

Comments

  • Wolkenarchitekt
    Wolkenarchitekt over 1 year

    I'm running latest Ubuntu 18.04 with stock Linux kernel 4.15.0-23-generic and have a problem (HDMI is not working occasionally).

    There is a related issue already: https://bugs.freedesktop.org/show_bug.cgi?id=105887

    And here is the patch of the intel display driver as a diff fixing the problem: https://patchwork.freedesktop.org/patch/229363/

    I would like to recompile my kernel / display driver with that patch and have some problems as I did not recompile anything Kernel related yet:

    How do I get the exact Ubuntu Kernel source, including the intel display drivers so I can apply the patch above? What are the steps to recompile and install the modified Kernel / Kernel drivers into my system (with as as little configuration as necessary)?


    Managed to get the Kernel source related to Ubuntu 18.04:

    git clone git://kernel.ubuntu.com/ubuntu/ubuntu-bionic.git
    

    The patch from https://patchwork.freedesktop.org/patch/229363/ cannot be applied - seems its based on a different Kernel:

    $ git apply --stat V2-drm-i915-glk-Add-Quirk-for-GLK-NUC-HDMI-port-issues..patch
     drivers/gpu/drm/i915/i915_drv.h      |    1 +
     drivers/gpu/drm/i915/intel_ddi.c     |    8 ++++++++
     drivers/gpu/drm/i915/intel_display.c |   19 +++++++++++++++++++
     3 files changed, 28 insertions(+)
    gustavo /home/ifischer/src/ubuntu-bionic master [~]
    $ git apply --check V2-drm-i915-glk-Add-Quirk-for-GLK-NUC-HDMI-port-issues..patch
    error: patch failed: drivers/gpu/drm/i915/intel_ddi.c:1800
    error: drivers/gpu/drm/i915/intel_ddi.c: patch does not applygit clone git://kernel.ubuntu.com/ubuntu/ubuntu-bionic.git
    
    • Pilot6
      Pilot6 almost 6 years
    • Wolkenarchitekt
      Wolkenarchitekt almost 6 years
      Thanks, got the source as first step: git clone git://kernel.ubuntu.com/ubuntu/ubuntu-bionic.git
    • Doug Smythies
      Doug Smythies almost 6 years
      Seems you deleted you answer and my comments with it. Try the mainline kernel 4.18-rc1, the patch does apply, with offset adjustments (which git takes care of automatically). Try without the --check option to see if git can figure it out for your kernel. If that doesn't work, then try applying the patch manually, as it is only 28 lines.
    • WinEunuuchs2Unix
      WinEunuuchs2Unix almost 6 years
      @DougSmythies FTR the OP's answer you commented on was nominated for deletion by stumblee during Queue Review. Then three other users voted to delete the answer. The OP did not delete the answer. When you have 4K more points you will be able to see deleted answers too and the reason for deletion.