When using DRI_PRIME=1 pc freezes

when trying to run programs with dedicated gpu with DRI_PRIME=1 prefix whole system freezes. have to force shutdown.
any solution?

DRI_PRIME=1 glxinfo | grep “OpenGL renderer”
OpenGL renderer string: AMD HAINAN (DRM 2.50.0, 5.8.6-1-MANJARO, LLVM 10.0.1)

lshw -c video
*-display
description: Display controller
product: Sun XT [Radeon HD 8670A/8670M/8690M / R5 M330 / M430 / Radeon 520 Mobile]
vendor: Advanced Micro Devices, Inc. [AMD/ATI]
physical id: 0
bus info: pci@0000:01:00.0
version: 83
width: 64 bits
clock: 33MHz
capabilities: pm pciexpress msi bus_master cap_list rom
configuration: driver=radeon latency=0
resources: irq:136 memory:c0000000-cfffffff memory:d0000000-d003ffff ioport:e000(size=256) memory:d0040000-d005ffff

inxi -Fazy

I also have the same problem.

Here are the information that you requested for:

System:
Kernel: 5.10.34-1-MANJARO x86_64 bits: 64 compiler: gcc v: 10.2.0
parameters: BOOT_IMAGE=/boot/vmlinuz-5.10-x86_64
root=UUID=3aca9708-53c5-4250-aa93-e88921a02452 rw quiet apparmor=1
security=apparmor udev.log_priority=3
Desktop: KDE Plasma 5.21.4 tk: Qt 5.15.2 wm: kwin_x11 vt: 1 dm: SDDM
Distro: Manjaro Linux base: Arch Linux
Machine:
Type: Laptop System: HP product: HP Notebook v: Type1ProductConfigId
serial: Chassis: type: 10 serial:
Mobo: HP model: 81EC v: 61.61 serial: UEFI-[Legacy]: Insyde v: F.49
date: 06/26/2020
Battery:
ID-1: BAT1 charge: 30.7 Wh (100.0%) condition: 30.7/41.4 Wh (74.1%)
volts: 17.1 min: 14.8 model: Hewlett-Packard PABAS0241231 type: Li-ion
serial: status: Full
CPU:
Info: Dual Core model: Intel Core i5-6200U bits: 64 type: MT MCP
arch: Skylake family: 6 model-id: 4E (78) stepping: 3 microcode: E2 cache:
L2: 3 MiB
flags: avx avx2 lm nx pae sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx
bogomips: 19200
Speed: 500 MHz min/max: 400/2800 MHz Core speeds (MHz): 1: 500 2: 500 3: 500
4: 501
Vulnerabilities: Type: itlb_multihit status: KVM: VMX disabled
Type: l1tf
mitigation: PTE Inversion; VMX: conditional cache flushes, SMT vulnerable
Type: mds mitigation: Clear CPU buffers; SMT vulnerable
Type: meltdown mitigation: PTI
Type: spec_store_bypass
mitigation: Speculative Store Bypass disabled via prctl and seccomp
Type: spectre_v1
mitigation: usercopy/swapgs barriers and __user pointer sanitization
Type: spectre_v2 mitigation: Full generic retpoline, IBPB: conditional,
IBRS_FW, STIBP: conditional, RSB filling
Type: srbds mitigation: Microcode
Type: tsx_async_abort status: Not affected
Graphics:
Device-1: Intel Skylake GT2 [HD Graphics 520] vendor: Hewlett-Packard
driver: i915 v: kernel bus-ID: 00:02.0 chip-ID: 8086:1916 class-ID: 0300
Device-2: AMD Sun XT [Radeon HD 8670A/8670M/8690M / R5 M330 / M430 / Radeon
520 Mobile]
vendor: Hewlett-Packard driver: radeon v: kernel alternate: amdgpu
bus-ID: 01:00.0 chip-ID: 1002:6660 class-ID: 0380
Device-3: Chicony HP TrueVision HD type: USB driver: uvcvideo bus-ID: 1-5:4
chip-ID: 04f2:b56c class-ID: 0e02 serial:
Display: x11 server: X.Org 1.20.11 compositor: kwin_x11 driver:
loaded: ati,intel,radeon unloaded: modesetting alternate: fbdev,vesa
display-ID: :0 screens: 1
Screen-1: 0 s-res: 1366x768 s-dpi: 96 s-size: 361x203mm (14.2x8.0")
s-diag: 414mm (16.3")
Monitor-1: eDP1 res: 1366x768 hz: 60 dpi: 102 size: 340x190mm (13.4x7.5")
diag: 389mm (15.3")
OpenGL: renderer: AMD HAINAN (DRM 2.50.0 5.10.34-1-MANJARO LLVM 11.1.0)
v: 4.5 Mesa 21.0.3 direct render: Yes
Audio:
Device-1: Intel Sunrise Point-LP HD Audio vendor: Hewlett-Packard
driver: snd_hda_intel v: kernel alternate: snd_soc_skl bus-ID: 00:1f.3
chip-ID: 8086:9d70 class-ID: 0403
Sound Server-1: ALSA v: k5.10.34-1-MANJARO running: yes
Sound Server-2: JACK v: 0.125.0 running: no
Sound Server-3: PulseAudio v: 14.2 running: yes
Sound Server-4: PipeWire v: 0.3.26 running: no
Network:
Device-1: Realtek RTL810xE PCI Express Fast Ethernet vendor: Hewlett-Packard
driver: r8169 v: kernel port: 4000 bus-ID: 02:00.0 chip-ID: 10ec:8136
class-ID: 0200
IF: enp2s0 state: up speed: 100 Mbps duplex: full mac:
Device-2: Realtek RTL8723BE PCIe Wireless Network Adapter
vendor: Hewlett-Packard driver: rtl8723be v: kernel port: 3000
bus-ID: 03:00.0 chip-ID: 10ec:b723 class-ID: 0280
IF: wlo1 state: down mac:
Bluetooth:
Device-1: Realtek Bluetooth Radio type: USB driver: btusb v: 0.8
bus-ID: 1-4:3 chip-ID: 0bda:b008 class-ID: e001 serial:
Report: rfkill ID: hci0 rfk-id: 1 state: down bt-service: enabled,running
rfk-block: hardware: no software: yes address: see --recommends
Drives:
Local Storage: total: 931.51 GiB used: 28.88 GiB (3.1%)
SMART Message: Unable to run smartctl. Root privileges required.
ID-1: /dev/sda maj-min: 8:0 vendor: Toshiba model: MQ01ABD100
size: 931.51 GiB block-size: physical: 4096 B logical: 512 B speed: 6.0 Gb/s
rotation: 5400 rpm serial: rev: 2C scheme: MBR
Partition:
ID-1: / raw-size: 931.51 GiB size: 915.81 GiB (98.31%)
used: 28.88 GiB (3.2%) fs: ext4 dev: /dev/sda1 maj-min: 8:1
Swap:
Alert: No swap data was found.
Sensors:
System Temperatures: cpu: 37.0 C mobo: 29.8 C gpu: radeon temp: 36.0 C
Fan Speeds (RPM): N/A
Info:
Processes: 177 Uptime: 3m wakeups: 1 Memory: 7.67 GiB used: 1.31 GiB (17.1%)
Init: systemd v: 247 tool: systemctl Compilers: gcc: 10.2.0 Packages:
pacman: 1206 lib: 326 flatpak: 0 Shell: Bash v: 5.1.4 running-in: konsole
inxi: 3.3.04

I’ve had same problem, and after some research I figured out that it’s (most likely) kernel bug that exists in every kernel version after 5.4 (I guess), it freezes pc when discrete AMD GPU (Hainan at least) reach ~400MHz clock, so basically whenever it’s used. Solution - use kernel version <=5.4.

I’m fairly certain I have the same symptoms here, but since switching Kernels didn’t fix it for me I might have a different but similar cause