4

I have a Lenovo G710 laptop that ran Ubuntu flawlessly since 15.04.

After updating to 20.04 there were occasional random complete freezes of the desktop. Having updated to 20.10, it now boots okay and the login screen appears normal. The desktop is fine until I try to open any application. The application name appears at the top, and then the desktop completely freezes. In some cases the app icon in the dock becomes pixelated. Sometimes a portion of the desktop flickers to solid black.

The mouse still moves occasionally, and I can CTRL+ALT+F3 to a command line.

Various searches suggest a graphics driver problem. It's an Intel Haswell graphics chip.

I've tried both the Ubuntuand Ubuntu on Wayland options at log in, both give the same results.

What is the best way to approach this?

EDIT:

Output of ls -al ~/.local/share/gnome-shell/extensions

drwxrwxr-x 4 carl carl 4096 Oct 26 18:29 gTile@vibou
drwxrwxr-x 3 carl carl 4096 Aug 13 18:55 systemMonitor@gnome-shell-extensions.gcampax.github.com
drwxrwxr-x 3 carl carl 4096 Oct 30 14:53 user-theme@gnome-shell-extensions.gcampax.github.com
drwxrwxr-x 2 carl carl 4096 Sep 10 18:11 weatherintheclock@JasonLG1979.github.io
drwxrwxr-x 3 carl carl 4096 Oct 30 14:53 workspace-indicator@gnome-shell-extensions.gcampax.github.com

Output of ls -al /usr/share/gnome-shell/extensions

drwxr-xr-x 2 root root 4096 Oct 30 13:53 desktop-icons@csoriano
drwxr-xr-x 3 root root 4096 Oct 30 13:53 ubuntu-appindicators@ubuntu.com
drwxr-xr-x 3 root root 4096 Oct 30 13:53 ubuntu-dock@ubuntu.com

Output of free -h

              total        used        free      shared  buff/cache   available
Mem:          5.7Gi       735Mi       4.2Gi        73Mi       855Mi       4.7Gi
Swap:         2.0Gi          0B       2.0Gi

Output of sysctl vm.swappiness

vm.swappiness = 60

EDIT 2 Output of dmesg includes i915 GPU HANG

Carl H
  • 6,181
  • 6
  • 27
  • 41
  • 1
    You may have a GNOME Shell extension that doesn't work in 20.10. Edit your question and show me ls -al ~/.local/share/gnome-shell/extensions and ls -al /usr/share/gnome-shell/extensions and free -h and sysctl vm.swappiness. – heynnema Oct 30 '20 at 20:14
  • @heynnema I've done that. – Carl H Oct 31 '20 at 14:06
  • Go to https://extensions.gnome.org/local/ and temporarily disable the 5 gnome-shell extensions that you see in ~/.local/share/gnome-shell/extensions, and then restart gnome-shell or log out/in, and see if the problem is gone. Report back. – heynnema Oct 31 '20 at 14:15
  • @heynnema I removed the extensions via the command line as using any app just causes a crash. It seems to have made some difference, there's no freeze now, but apps don't open, and after a while the GNOME session restarts itself. – Carl H Oct 31 '20 at 15:29
  • Reboot your computer and retest. Edit your question and show me ls -al /var/crash. Do you have any startup applications enabled? Are you running with Wayland, or just stock Ubuntu? – heynnema Oct 31 '20 at 15:41
  • @heynnema I've since found that this is a known bug in the latest i915 driver, so I'm going to reinstall 18.04. Thanks for your time with this., – Carl H Nov 01 '20 at 19:10
  • Where did you learn that the i915 driver has a problem? It doesn't sound right. – heynnema Nov 01 '20 at 19:12
  • Show me sudo dmidecode -s bios-version. – heynnema Nov 01 '20 at 19:18
  • @heynnema dmesg mentioned GPU HANG and referred to https://gitlab.freedesktop.org/drm/intel/-/issues - many of the issues listed are the same or similar to the one I was having. – Carl H Nov 01 '20 at 19:19
  • @heynnema 8ECN95WW – Carl H Nov 01 '20 at 19:21
  • You never showed me ls -al /var/crash. Also, was there a specific article you refer to at the link that you gave. Your BIOS is current. – heynnema Nov 01 '20 at 19:39
  • The way to prove/disprove that the i915 driver may be a problem, is to boot with nomodeset. Do you know how to do that? – heynnema Nov 01 '20 at 19:40
  • Do you have access to a Ubuntu Live DVD/USB for 20.10? If so, boot to it, and see if the same problems occur. – heynnema Nov 01 '20 at 19:42

5 Answers5

12

UPDATE : Ubuntu 21.04 current ISO image was tested, it includes kernel 5.11.0-11 and the installation proceeded normally.

The 5.11 Ubuntu distribution kernels are causing the same instability problems with Gnome, KDE, XFCE (at least) like the home-compiled 5.11 kernels, if you are facing the same problems stay with kernels before 5.11 .

UPDATE 2 : Kernel was upgraded to 5.11.0-22, everything works fine.

TIP : You can download and test the Latest Development ISO by synchronizing with the following command.

zsync http://cdimage.ubuntu.com/daily-live/current/jammy-desktop-amd64.iso.zsync

The first time you run the command the ISO will be downloaded, any other time you run the same command in the ISO's directory the system will check whether there are any changes and it will update the ISO if necessary.


Recommended Solution : Install a kernel version that works, from your distribution's repository

Note : If you want to perform a fresh installation from an image that crashes the graphical installation environment due to this i915 problem, select (Safe Graphics) in the ISO's boot menu and after the installation perform the necessary steps.

For example a Focal Fossa user will download and install the following packages from

https://packages.ubuntu.com/focal/kernel/

  1. linux-image-(kernel_version)-generic
  2. linux-modules-(kernel_version)-generic
  3. linux-modules-extra-(kernel_version)-generic

Install with command,

sudo apt install <package>

Reboot.

The system will automatically boot with the new kernel if you haven't installed any newer kernel, in any other case select the kernel from the GRUB menu.


Advanced approach

The solution for kernels before 5.11 is here Red Hat Bugzilla – Bug 1843274

The GUI system can become usable if you boot with your old kernel 5.4.0 . The terminal is still usable with 5.8.0 kernel, try CTRL+ALT+F3.

The solution is to patch the i915 module. Download the patch from here

To understand the patch have a look at Intel's Manual page 50, it has to do with the command MEDIA_VFE_STATE which has to be provided with the right number of threads according to the model of the GPU.

First method: Patch and recompile a new kernel

Quick guide

  1. The basic dependencies to build the kernel are sudo apt install libncurses-dev flex bison openssl libssl-dev dkms libelf-dev libudev-dev libpci-dev libiberty-dev autoconf
  2. Download the kernel source of your choice from www.kernel.org and extract it.
  3. Go inside the kernel source directory.
  4. Clean the kernel with sudo make mrproper in the kernel's directory.
  5. Download the patch into the kernel's source code parent directory.
  6. Apply the patch with patch -p1 < ../drm-i915-gt-Limit-VFE-threads-based-on-GT.patch
  7. Configure the kernel or run sudo make localmodconfig to finish quickly, hold the Enter key until all the questions are answered
  8. Compile the kernel with sudo make -j (# of CPU threads) bindeb-pkg
  9. Install the linux-image and the linux-headers deb packages produced in the parent directory of the kernel source directory
  10. Reboot and if necessary choose the new kernel from the GRUB menu

Optimize the above procedure according to your preferences, your hardware etc

Second method: Patch and recompile the module only

It is also possible to rebuild the patched module for an already installed kernel so as to be able to use the official distribution kernels or any other precompiled kernels.

The official i915 compilation guide from Intel is here, if you download it as a PDF go to page 41.

You can follow the steps exactly as they are presented but notice the following.

  1. If you are going to recompile the module for another kernel version than the one you are running then you have to replace $(uname -r) with the version you are targeting, for example 5.8.0-29-generic .

  2. If you use the /tmp/kernel directory as in the guide then this directory will be lost after a reboot.

  3. After step 5 you have to patch the kernel with patch -p1 < ../drm-i915-gt-Limit-VFE-threads-based-on-GT.patch assuming the patch is located into the kernel's source code parent directory

  4. Step 9 can be skipped.

  5. After step 12 you may get an error concerning the cryptographic verification of the module, there is no problem, the module has been installed in /lib/modules/5.8.0-29-generic/extradrivers and the system knows that it is there and should be loaded through step 13.

  6. Step 14 should be performed stating the target kernel version, for 5.8.0-29-generic alter the commands like this sudo depmod -v 5.8.0-29-generic and sudo update-initramfs -k 5.8.0-29-generic -u .

After a reboot your system will be usable again.

This procedure should be performed for any new kernel until the problem is solved by Ubuntu.

Mouffa
  • 136
  • On Ubuntu 20.04.2 LTS, after $ sudo apt -y build-dep linux linux-image-$(uname -r) I see: Picking 'linux-signed-hwe-5.8' as source package instead of 'linux-image-5.8.0-45-generic' and then E: Unable to find a source package for linux-image-5.8.0-45-generic – matthew Mar 12 '21 at 23:16
  • I'm Following the second method. Also when I try to apply the patch I see can't find file to patch at input line 5 – matthew Mar 12 '21 at 23:36
  • I am aware of these problems, try the "Recommended method" to have a working system first. For some reason the 20.04.1 & 2 versions don't download the right source packages, so you have to go to the Groovy Gorilla repository and download linux_5.8.0.orig.tar.gz and the patch linux_5.8.0-45.<something>.diff.gz, then you unzip the kernel and the patch and you first apply the .diff patch to the kernel and then the i915 patch. You should be inside the kernel directory and the patches should be one directory above in order for the patch command to work as it stated in the guide. – Mouffa Mar 13 '21 at 10:54
  • You can download the files from here https://packages.ubuntu.com/groovy/linux-source-5.8.0, you can see them on the right side of the page, again for some reason the latest listed patch is linux_5.8.0-44.50.diff.gz though on 20.10 it automatically downloads the 5.8.0-45 patch, I don't know where it resides, I am very confused with the Ubuntu repositories. – Mouffa Mar 13 '21 at 11:00
  • I think I found something, go here https://launchpad.net/ubuntu/+source/linux/ and at the bottom of the page click the arrow to drop the menu for the 5.8.0-45.51 for Groovy, scroll down to the list of packages and you will find the patch linux_5.8.0-45.51.diff.gz as well as a .deb package with the 5.8.0 source already patched for 45.51 (linux-source-5.8.0_5.8.0-45.51_all.deb), if you install the package you will find the source somewhere in the /usr/src directory I reckon. – Mouffa Mar 13 '21 at 11:22
  • Many thanks Mouffa. I've downgraded the kernel from 5.8 to 5.4 and my system is working now. I've also just installed the Hirsute Hippo kernel packages as you recommend. I'll reboot soon and check if these work too. I'll have another go at patching and recompiling the module with your additional tips too. – matthew Mar 13 '21 at 18:43
5

I migrated from Kubuntu 20.04 to 20.10 and have the same "GPU Hang" bug with an Acer 720p. While waiting fro a fix I downgraded the kernel from 5.8 to 5.4 and it's now working well.

2

This is an existing bug with the i915 driver in recent Linux kernels.

See https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1872001 and https://gitlab.freedesktop.org/drm/intel/-/issues/673

As yet, there is no solution or workaround. I have replaced Ubuntu 20.10 with Ubuntu 18.04.

UPDATE - I've accepted the other answer as judging by the upvotes it is correct, which should be more useful to anyone else having this problem.
(Disclaimer - I haven't tried it myself)

Carl H
  • 6,181
  • 6
  • 27
  • 41
1

This issue is caused due to a bug in the kernel. You can easily get this resolved, by booting Ubuntu in previous kernels wherein the terminal is usable. You can do this by reaching the grub menu, and selecting 'advanced options' and then selecting any of the previous kernel for booting in.

Once you boot in and terminal is open, type in the following commands to upgrade your kernel to latest version available (5.10.13 and above will solve this issue)

  1. This command installs the wget utility that will be used for downloading a kernel upgrader script:

    sudo apt install wget
    
  2. This command will pull the script from github and store it in your home directory

    wget https://raw.githubusercontent.com/pimlie/ubuntu-mainline-kernel.sh/master/ubuntu-mainline-kernel.sh 
    
  3. This command will install the script in your bin directory, so that its easier to execute in the terminal with the following command:

    sudo install ubuntu-mainline-kernel.sh /usr/local/bin/
    
  4. Install the latest mainline kernel:

    sudo ubuntu-mainline-kernel.sh -i 
    

Alternatively, you can even install a particular kernel version:

sudo ubuntu-mainline-kernel.sh -i 5.10.13 

After executing this command, it will take a few minutes to install the kernel headers and images, post which you need to reboot your system

sudo reboot

After reboot, confirm the kernel version by executing the following command:

uname -r 

You should see an output similar to:

5.10.13-051013-generic

Done. Bug resolved!

Kevin Bowen
  • 19,615
  • 55
  • 79
  • 83
Dimmy
  • 21
0

nomodeset is not the soulution!

Unless you don't want to use any graphics driver, don't use nomodeset in grub!

appending i915.enable_psr=0 to /etc/default/grub GRUB_CMDLINE_LINUX_DEFAULT and sudo update-grub2 then reboot