Lenovo Thinkpad T495

From Gentoo Wiki
Jump to:navigation Jump to:search

Lenovo Thinkpad T495 is a business notebook based on 2nd generation of AMD Ryzen™ processors with Radeon™ Vega graphics, supporting AMD FreeSync™, and delivering up to 14.9 hours of battery life.

Hardware

Standard

Lenovo Thinkpad T495 specification:

Device Make/model Status Bus ID Driver Notes
CPU AMD Ryzen 3 PRO 3300U, AMD Ryzen 5 PRO 3500U, or AMD Ryzen 7 PRO 3700U Works N/A N/A
Memory DDR4 2400MHz (8/16GB soldered) Works N/A N/A 1 extra slot allows for up to 48GB of total RAM
Graphics Integrated AMD Radeon™ Vega 6, 8, or 10 (Picasso) Works PCIe 06:00.0 amdgpu GPU reserves 2GB of the system memory, requires kernel version >=5.1
Display 14.0", HD 1366x768 TN, 220 nits, or FHD 1920 x 1080 IPS, 250/300/400 nits Works N/A N/A multitouch option for FHD 300 nits
Storage M.2 PCIe-NVMe, Opal, 256GB/512GB/1TB Works PCIe 02:00.0 nvme Samsung NVMe PM981a or Western Digital PC SN720
Ethernet Realtek RTL8211E Gigabit Ethernet Works PCIe 03:00.0 r8169
Wireless Intel® 9260 Wireless AC Works PCIe 01:00.0 iwlwifi
Bluetooth Intel® Bluetooth® 5.0 Works USB 004:002 btusb
Mobile Broadband Fibocom L850-GL 4G LTE CAT9 Not tested N/A N/A
Audio Realtek ALC892 Works PCIe 06:00.6 snd_hda_intel, snd_hda_codec_realtek
Camera Chicony 720p Works USB 004:004 uvcvideo
Keyboard Backlit Works N/A N/A
Touchpad Synaptics Works N/A libinput
Fingerprint Reader Synaptics UWP WBDI Works USB 004:006 N/A Requires version 1.90 or newer of sys-auth/libfprint and sys-auth/fprintd
Smartcard Reader Alcor Micro AU95403 Works USB 004:005 sdhci-pci Supports microSD cards only.
Battery 3 Cell Li-Polymer, 50Wh Works N/A N/A

Accessories

Device Make/model Status Bus ID Kernel driver(s) Kernel version Notes
Docking station Lenovo ThinkPad Basic Docking (40AG) Works N/A USB-C/USB 5.5.13 Everything works, no special driver needed.
Docking station Lenovo ThinkPad Pro Docking (40AH) Not tested N/A N/A
Docking station Lenovo ThinkPad Ultra Docking (40AJ) Not tested N/A N/A

CPU and its features:

root #lscpu

List of PCI devices:

root #lspci -k

List of USB devices:

root #lsusb

Installation

Kernel configuration

Note
Full hardware support and recognition relies heavily on the 5.x branch linux kernel. Do not use 4.x linux kernels.

Processor

KERNEL Kernel 5.4.1 (gentoo-sources)
Processor type and features  --->
      Processor family (Generic-x86-64)
  [*] CPU microcode loading support
  [*]   AMD microcode loading support

Power management and ACPI options  --->
      CPU Frequency scaling  --->
             Default CPUFreq governor (performance)
        <*>  'performance' governor

Device Drivers  --->
      Generic Driver Options  --->
            Firmware loader  --->
              -*- Firmware loading facility
              (amd-ucode/microcode_amd_fam17h.bin)
              (/lib/firmware) Firmware blobs root directory

  <*> Hardware Monitoring support  --->
        <M> AMD Family 10h+ temperature sensor

  [*] IOMMU Hardware Support  --->
        [*] AMD IOMMU support
        <*>   AMD IOMMU Version 2 driver
        [*] Support for Interrupt Remapping

Using sys-kernel/gentoo-sources with the experimental USE flag will have additional Processor family options made available:

KERNEL Kernel 5.4.1 (gentoo-sources)
Processor type and features  --->
  Processor family  --->
    (X) AMD Zen 2

or simply autodetecting the processor options by the compiler:

KERNEL Kernel 5.4.1 (gentoo-sources)
Processor type and features  --->
  Processor family  --->
    (X) Native optimizations autodetected by GCC

For more information see the wiki page on AMD Ryzen processors.

Drivers

KERNEL Kernel 5.4.1 (gentoo-sources)
Power management and ACPI options  --->
  [*] ACPI (Advanced Configuration and Power Interface) Support  --->
        <*>  Battery
        <*>  Video

Networking support  --->
  <M> Bluetooth subsystem support  --->
      Bluetooth device drivers  --->
        <M> HCI USB driver

  <*> Wireless  --->
    <M>  cfg80211 - wireless configuration API
    [*]  enable powersave by default
    <M>  Generic IEEE 802.11 Networking Stack (mac80211)

Device Drivers  --->
  [*] PCI support  --->
        [*] PCI Express Port Bus support
      NVME Support  --->
        <*> NVM Express block device
      SCSI device support  --->
        <*> SCSI disk support

      Generic Driver Options  --->
            Firmware loader  --->
              -*- Firmware loading facility
              (amd-ucode/microcode_amd_fam17h.bin ... iwlwifi-9260-th-b0-jf-b0-34.ucode)                                    
              (/lib/firmware) Firmware blobs root directory

  <*> Serial ATA and Parallel ATA drivers (libata)  --->
        <*> AHCI SATA support

      Character devices  --->
        <M> TPM Hardware Support  --->
            [*] TPM HW Random Number Generator support
            <M> TPM Interface Specification 1.2 Interface / TPM 2.0 FIFO Interface
            <M> TPM 2.0 CRB Interface

  [*] Network device support  --->
        [*] Ethernet driver support  --->
            [*] Realtek devices
            <*>   Realtek 8169 gigabit ethernet support
        [*] Wireless LAN  --->
            [*] Intel devices
            <M>   Intel Wireless WiFi Next Gen AGN - Wireless-N/Advanced-N/Ultimate-N (iwlwifi)
            < >   Intel Wireless WiFi DVM Firmware support
            <M>   Intel Wireless WiFi MVM Firmware support

      I2C support  --->
        I2C Hardware Bus support  --->
          <M> Intel PIIX4 and compatible (ATI/AMD/Serverworks/Broadcom/SMSC)

  -*- Power supply class support  --->
        [*] Expose power supply sensors as hwmon device

  [*] Watchdog Timer Support  --->
        <M> AMD/ATI SP5100 TCO Timer/Watchdog

  <*> Multimedia support  --->
        [*] Media USB Adapters  --->
              <*> USB Video Class (UVC)

      Graphics support  --->
        <*> Direct Rendering Manager (XFree86 4.1.0 and higher DRI support)
        <*> AMD GPU
            Display Engine Configuration  --->
              [*] AMD DC - Enable new display engine
            Frame buffer Devices  --->
              -*- Support for frame buffer devices  --->
                    [*] EFI-based Framebuffer Support
                    [*] Simple framebuffer support
            Console display driver support  --->
              <*> Framebuffer Console support

  <*> Sound card support  --->
        <*> Advanced Linux Sound Architecture  --->
        [*] PCI sound devices  --->
        <*> HD-Audio  --->
              <*> HD Audio PCI
              <*> Build Realtek HD-audio codec support
              <*> Build HDMI/DisplayPort HD-audio codec support

  [*] USB support  --->
    <*> xHCI HCD (USB 3.0) support
    <*> EHCI HCD (USB 2.0) support

  <M> MMC/SD/SDIO card support  --->
        <M> Secure Digital Host Controller Interface support
        <M>   SDHCI support on PCI bus

  [*] X86 Platform Specific Device Drivers  --->
        <*> ThinkPad ACPI Laptop Extras
        [*]   Console audio control ALSA interface
        [*]   Video output control support
        [*]   Support NVRAM polling for hot keys
Note
The option for the built-in firmware files below option "-*- Firmware loading facility" is incomplete. See the next section Firmware for the complete list of the firmware files.

Firmware

In order for the graphics and wireless to work properly, it is necessary to install the proper firmware (or microcode) files and build them into the kernel, as shown below.

FILE /usr/src/linux/.config
CONFIG_EXTRA_FIRMWARE="amd-ucode/microcode_amd_fam17h.bin amdgpu/picasso_asd.bin amdgpu/picasso_ce.bin amdgpu/picasso_gpu_info.bin amdgpu/picasso_me.bin amdgpu/picasso_mec.bin amdgpu/picasso_mec2.bin amdgpu/picasso_pfp.bin amdgpu/picasso_rlc.bin amdgpu/picasso_rlc_am4.bin amdgpu/picasso_sdma.bin amdgpu/picasso_ta.bin amdgpu/picasso_vcn.bin iwlwifi-9260-th-b0-jf-b0-34.ucode regulatory.db regulatory.db.p7s"

These files should be installed in the system before the kernel recompilation using, for example, the command

root #emerge --ask sys-kernel/linux-firmware net-wireless/wireless-regdb

See amdgpu and iwlwifi wiki pages for more information.

GRUB settings

Edit/update the following line in the following file:

FILE /etc/default/grub
GRUB_CMDLINE_LINUX_DEFAULT="acpi_backlight=vendor"

Configuration

Portage

FILE /etc/portage/package.use/00input
*/* INPUT_DEVICES: libinput
FILE /etc/portage/package.use/00video
*/* VIDEO_CARDS: -* amdgpu radeonsi
FILE /etc/portage/package.use/00cpu-flags
*/*  CPU_FLAGS_X86: aes avx avx2 f16c fma3 mmx mmxext pclmul popcnt sha sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3

Xorg

FILE /etc/X11/xorg.conf.d/10-device.confDevice section
Section "Device"
   Identifier  "device_default"
   Driver      "amdgpu"
   Option      "DRI" "3"
   Option      "TearFree" "on"
   Option      "monitor-eDP" "monitor_default"
EndSection
FILE /etc/X11/xorg.conf.d/20-monitor.confMonitor section
Section "Monitor"
  Identifier   "monitor_default"
  DisplaySize  309 174                      # 14.0" and 1920x1080 => 157dpi
  Option       "PreferredMode"  "1920x1080"
  Option       "DPMS"           "On"
EndSection
FILE /etc/X11/xorg.conf.d/30-monitor.confScreen section
Section "Screen"
  Identifier       "screen_default"
  Device           "device_default"
  Monitor          "monitor_default"
  DefaultDepth     24
  SubSection "Display"
    Depth          24
  EndSubSection
EndSection

Sensors

FILE /etc/sensors.d/amdgpu.conf
chip "amdgpu-*"

    label temp1 "GPU temperature"
    ignore in0
    ignore in1
FILE /etc/sensors.d/battery.conf
chip "BAT0-acpi-*"

    label in0 "BAT voltage"
FILE /etc/sensors.d/iwlwifi.conf
chip "iwlwifi-*"

    label temp1 "WiFi temperature"
FILE /etc/sensors.d/thinkpad.conf
chip "thinkpad-isa-*"

  label fan1   "Fan speed"
  label temp1  "CPU temperature"
  label temp11 "Power circuitry temperature"
  ignore temp2
  ignore temp3
  ignore temp4
  ignore temp5
  ignore temp6
  ignore temp7
  ignore temp8
  ignore temp9
  ignore temp10
  ignore temp12
  ignore temp13
  ignore temp14
  ignore temp15
  ignore temp16

Display backlight

To control the display backlight install sys-power/acpilight. This comes with a system udev rule recommended by the upstream author.

root #emerge --ask sys-power/acpilight

Regular system users are not prohibited to alter files in the sys filesystem. The included udev rule allows users in the video group to set the display brightness.

Keyboard backlight

The keyboard backlight is working out of the box, and can be controlled by using the Fn+Space keys without any further adjustments. There are 3 predefined steps of the keyboard backlight. 0, 50 and 100. To display the current setting of keyboard backlight use the -ctrl tpacpi::kbd_backlight command line option for xbacklight.

To show the available adjustment steps use following command, it will show 3 steps.

user $xbacklight -ctrl tpacpi::kbd_backlight -get-steps

To display the current setting use following command:

user $ xbacklight -ctrl tpacpi::kbd_backlight -getf

Troubleshooting

Unable to write to IOMMU

Sometimes (most of the time) I am getting the following kernel message when booting the system:

pci 0000:00:00.2: AMD-Vi: Unable to write to IOMMU perf counter.
pci 0000:00:00.2: can't derive routing for PCI INT A
pci 0000:00:00.2: PCI INT A: not connected

Later, in the kernel log, one can find the following line:

pci 0000:00:00.2: AMD-Vi: Found IOMMU cap 0x40

It seems that IOMMU works just fine and the first message is a result of a premature initialization of the IOMMU system. According to other reports found on the internet, it can be ignored. Still, it pollutes the screen during a silent boot process.

Slow/unresponsive system after direct reboot from Microsoft Window 10

In kernel versions from 5.4 to 5.6.13 some issues related to MMC/SDHCI driver for Genesys Logic GLI9750 occur after direct reboot from Microsoft Windows 10. The system becomes slow with a few kernel threads using 100% of CPU trying to access MMC/SDHCI device. The issue has been reported (kernel bug #205871) and fixed in kernels 5.4.42 and 5.6.14.

AMDGPU always on 100%

Note
The bug1455 is closed. Fix using sys-kernel/linux-firmware-20220310

Steps to verfiy if hardware is hit by this bug:

Verify frequency GPU currently uses, it should be at 400MHz, but it is stucked permanently at 1200MHz and does not get back to the lowest frequency available. Verify using the command below:

user $cat /sys/class/drm/card0/device/pp_dpm_mclk
0: 400Mhz
1: 933Mhz
2: 1067Mhz
3: 1200Mhz *

Verify the Memory Clock using the hardware specific app-misc/radeontop tool.

user $radeontop
Collecting data, please wait....
            radeontop 1.4, running on RAVEN bus 06, 120 samples/sec
                                         │
                   Graphics pipe   0.00% │
─────────────────────────────────────────┼─────────────────────────────────────────
                    Event Engine   0.00% │
                                         │
     Vertex Grouper + Tesselator   0.00% │
                                         │
               Texture Addresser   0.00% │
                                         │
                   Shader Export   0.00% │
     Sequencer Instruction Cache   0.00% │
             Shader Interpolator   0.00% │
                                         │
                  Scan Converter   0.00% │
              Primitive Assembly   0.00% │
                                         │
                     Depth Block   0.00% │
                     Color Block   0.00% │
                                         │
                67M / 2016M VRAM   3.35% │ 
                 23M / 3063M GTT   0.76% │
      1.20G / 1.20G Memory Clock 100.00% │█████████████████████████████████████████
      0.20G / 1.20G Shader Clock  16.67% │██████
                                         │

Create a file dump:

user $radeontop -d /tmp/test

View dump:

user $head /tmp/test
1642627259.573360: bus 06, gpu 0.00%, ee 0.00%, vgt 0.00%, ta 0.00%, sx 0.00%, sh 0.00%, spi 0.00%, sc 0.00%, pa 0.00%, db 0.0
0%, cb 0.00%, vram 3.35% 67.49mb, gtt 0.76% 23.21mb, mclk 100.00% 1.200ghz, sclk 16.67% 0.200ghz

Notice mclk is always at 100%, making the laptop heat up more than usual and consume the battery faster.

External resources