Skip to content

Instantly share code, notes, and snippets.

@simonheb
Last active June 9, 2023 02:22
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save simonheb/b54b91358c3d7e2960a4f6e13e95ac54 to your computer and use it in GitHub Desktop.
Save simonheb/b54b91358c3d7e2960a4f6e13e95ac54 to your computer and use it in GitHub Desktop.
Patching the 5.12 Linux kernel to support new Intel hardware (e.g., Intel Iris Xe for Thinkpad X1 Titanium Yoga) on Ubuntu/Debian/Pop!_OS

Get a 5.12 Linux kernel with support for newer Intel hardware (e.g., Intel Iris Xe for Thinkpad X1 Titanium Yoga) on Ubuntu/Debian/Pop!_OS

Prologue: Do I need this?

I recently got a Thinkpad sporting an Intel® Core™ i5-1140G7 Processor 11. gen (1,80 GHz, Turbo Boost, 4 Cores, 8 Threads, 8 MB Cache with an Integrated Intel® Iris® Xe. Sadly graphics drivers did not work out-of-the-box and also not with the latets 5.12 kernel from xenmod. You can tell it's not working when graphics are slow, backlight adjustment buttons don't work and this is the output of inxi -G (you might need to sudo apt install inxi):

simon@pop-os:~$ inxi -G
Graphics:
  Device-1: Intel driver: N/A 
  Device-2: IMC Networks Integrated Camera type: USB driver: uvcvideo 
  Display: x11 server: X.Org 1.20.9 driver: fbdev unloaded: modesetting,vesa 
  resolution: 2256x1504~95Hz 
  OpenGL: renderer: llvmpipe (LLVM 11.0.0 256 bits) v: 4.5 Mesa 21.0.0 

Seems the hardware is too new and support will only come around in future kernel updates. I found a friendly frugalware developer(?) on the Lenovo support forum who did the work of collecting and backporting kernel patchs efrom 5.13 to the 5.12 kernel. It's been ~15 years since I compiled my last kernel, but I managed to apply the patches and compile a kernal that runs on my Ubuntu/Pop!_OS worked. This guide should work for all systems for which the xanmod kernel works. If you're in the same shoes hardware-wise, here's what I did:

Why so complicated?

I basically rebuild a patched version of the 5.12 kernel by xanmod. There may be an easier way, whereby you only rebuild the i915-module. I have no clue. That's for others to figure out. Let me know if you find a simpler way.

How long does that take?

Active work: 4 minutes

Watching the kernel compile: some hours (go get some fresh air)

Preparations

You might need to install a few things if you haven't already (see https://wiki.ubuntu.com/Kernel/BuildYourOwnKernel):

sudo apt install libncurses-dev gawk flex bison openssl libssl-dev dkms libelf-dev libudev-dev libpci-dev libiberty-dev autoconf build-dep git zstd

Patching, compiling and installing the kernel

I have good experiences with the xanmod kernel, so I use that as base kernel source and config for 5.12 to start from. Follow these steps (You might have to add a few sudos):

  1. Go to whatever folder you want to work in. I did cd /usr/src
  2. Download the xanmod kernel source: git clone https://github.com/xanmod/linux.git and cd into that folder
  3. Download the i915-patch wget https://crazy.dev.frugalware.org/Intel-i915-backport-MSO-fixes-to-kernel-5.12.patch
  4. Apply the patch patch -p1 < Intel-i915-backport-MSO-fixes-to-kernel-5.12.patch
  5. Build the kernel make (takes > 2hrs)
  6. Go grab a coffee
  7. Install modules sudo make modules_install
  8. Install kernel sudo make install
  9. Reboot into your new kernel

Epilogue: This is a temporary fix.

In spite of everything running well now. I see this as a temporary fix and will switch to the Ubuntu version of 5.13 as soon as it comes out.

AT YOUR OWN RISK

I have no clue what I am doing, I am just hacking together pieces of code and commands I found online. If you follow my and fry you computer that's on you!

@simonheb
Copy link
Author

simonheb commented Jul 5, 2021

It seems your driver is fine. So changing the kernel will probably not help. Maybe it is related to the hotkey settings? I am not on Ubuntu so I cannot help you with this part. Sorry.

@M-M-Akash
Copy link

Are you using pop os? I also installed the pop!_os 20.04 but the problem still persists.

@simonheb
Copy link
Author

Oh, yes. I am on pop.os. But since your inxi -G output indicate that the driver is successfully loaded, it seems that your problem is a different one. Sorry i have no idea where to look for a solution

@aminmr
Copy link

aminmr commented Apr 10, 2022

Dear Simon
I have this problem with Pop OS 21.10
My kernel version is 5.16.11
and still, the patch hasn't been deployed to the kernel.
Do you have any updates on this problem?

in addition, I can't follow your steps for compiling my own kernel because the prerequisites packages are not available to install.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment