NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.65k stars 13.8k forks source link

rtw89 kernel module broken on current default kernel 5.15 #177844

Closed Melkor333 closed 2 months ago

Melkor333 commented 2 years ago

Describe the bug

Working with nixos-unstable

I have a notebook T14s Gen1 which requires the rtw89 kernel module for wifi. This module worked for me until an upgrade on May 20 (after roughly a month of no updates). Since then, the module doesn't work anymore on Kernel 5.15 (but I had a working configuration on 5.15.36). The config I had until it broke, was simply the following line in my config:

    boot.extraModulePackages = with config.boot.kernelPackages; [ rtw89 ];

Since nothing has happened with the kernel module itself I assume it relates to following issue splitting up firmwares. Another possibility is that there is simply a bug in the kernel module which might already be fixed upstream and we need to upgrade it.

Steps To Reproduce

  1. Have a laptop with a Realtek 8852:
    lspci | grep Network
    03:00.0 Network controller: Realtek Semiconductor Co., Ltd. Device 8852
  2. Use the following in your hardware-configuration.nix and use Kernel 5.15.X
    boot.extraModulePackages = with config.boot.kernelPackages; [ rtw89 ];
    hardware.firmware = [ pkgs.rtw89-firmware ];
    # optionally make sure you use kernel 5.15
    #boot.kernelPackages = pkgs.linuxPackages_5_15;
  3. Rebuild the config and reboot

The following stack trace appears in dmesg and wifi won't work:

[   11.387364] rtw89_pci 0000:03:00.0: Firmware version 0.13.24.0, cmd version 0, type 1
[   11.387371] rtw89_pci 0000:03:00.0: Firmware version 0.13.24.0, cmd version 0, type 3
[   11.389419] BUG: unable to handle page fault for address: ffffb2e9427f25d4
[   11.390477] #PF: supervisor write access in kernel mode
[   11.391428] #PF: error_code(0x0003) - permissions violation
[   11.392056] PGD 100000067 P4D 100000067 PUD 100193067 PMD 10981e067 PTE 80000001061f8161
[   11.392975] Oops: 0003 [#1] SMP NOPTI
[   11.393572] CPU: 2 PID: 910 Comm: systemd-udevd Tainted: G           O      5.15.46 #1-NixOS
[   11.394270] Hardware name: LENOVO 20UH0056MZ/20UH0056MZ, BIOS R1CET67W(1.36 ) 10/20/2021
[   11.394958] RIP: 0010:rtw89_fw_download+0x6a/0x3e0 [rtw89core]
[   11.395496] Code: c2 48 8b 28 44 8b 48 08 48 85 ed 0f 84 7f 0e 02 00 45 85 c9 0f 84 76 0e 02 00 0f b6 45 19 b9 e4 07 00 00 49 01 e9 48 8d 75 20 <66> 89 4d 1c 8d 78 02 88 44 24 10 c1 e7 04 89 7c 24 14 48 63 ff 48
[   11.396292] RSP: 0018:ffffb2e94174ba98 EFLAGS: 00010296
[   11.397184] RAX: 0000000000000003 RBX: 00000000000000ff RCX: 00000000000007e4
[   11.397327] RDX: ffffa05574402120 RSI: ffffb2e9427f25d8 RDI: ffffa05574402000
[   11.398330] RBP: ffffb2e9427f25b8 R08: 0000000000000088 R09: ffffb2e942853930
[   11.399119] R10: 0000000000000000 R11: 0000000000000002 R12: 0000000000000000
[   11.400265] R13: ffffa05574402000 R14: ffffa05574402000 R15: ffffa05540ff10c8
[   11.400710] FS:  00007f770818cd40(0000) GS:ffffa0583f880000(0000) knlGS:0000000000000000
[   11.401302] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[   11.402054] CR2: ffffb2e9427f25d4 CR3: 0000000102434000 CR4: 0000000000350ee0
[   11.402908] Call Trace:
[   11.403531]  <TASK>
[   11.404990]  ? schedule+0x44/0xa0
[   11.404990]  ? schedule_hrtimeout_range_clock+0x9d/0x120
[   11.404990]  ? __hrtimer_init+0xc0/0xc0
[   11.407080]  ? usleep_range_state+0x60/0x90
[   11.408046]  ? rtw89_pci_txbd_recalc+0x50/0x50 [rtw89pci]
[   11.408046]  ? hfc_func_en+0x26/0x70 [rtw89core]
[   11.409761]  ? rtw89_pci_ops_write16+0x20/0x20 [rtw89pci]
[   11.410051]  ? hfc_init.constprop.0+0x72c/0x750 [rtw89core]
[   11.410918]  rtw89_chip_info_setup+0x8c/0xf0 [rtw89core]
[   11.410918]  rtw89_pci_probe+0x9d6/0xb70 [rtw89pci]
[   11.413050]  local_pci_probe+0x42/0x80
[   11.413807]  ? __cond_resched+0x16/0x40
[   11.414596]  pci_device_probe+0xfa/0x1b0
[   11.415246]  really_probe+0x1f5/0x3f0
[   11.415820]  __driver_probe_device+0xfe/0x180
[   11.416796]  driver_probe_device+0x1e/0x90
[   11.417494]  __driver_attach+0xc0/0x1c0
[   11.418450]  ? __device_attach_driver+0xe0/0xe0
[   11.419048]  ? __device_attach_driver+0xe0/0xe0
[   11.419482]  bus_for_each_dev+0x78/0xc0
[   11.420115]  bus_add_driver+0x12b/0x1e0
[   11.421043]  driver_register+0x8f/0xe0
[   11.421760]  ? 0xffffffffc1339000
[   11.422702]  do_one_initcall+0x44/0x1d0
[   11.423460]  ? __cond_resched+0x16/0x40
[   11.424130]  ? kmem_cache_alloc_trace+0x44/0x3c0
[   11.424560]  do_init_module+0x4c/0x250
[   11.425420]  __do_sys_init_module+0x121/0x1a0
[   11.426381]  do_syscall_64+0x3b/0x90
[   11.427081]  entry_SYSCALL_64_after_hwframe+0x44/0xae
[   11.427081] RIP: 0033:0x7f7708ab3eda
[   11.427896] Code: 48 8b 0d 41 5f 0e 00 f7 d8 64 89 01 48 83 c8 ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 49 89 ca b8 af 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d 0e 5f 0e 00 f7 d8 64 89 01 48
[   11.428641] RSP: 002b:00007ffcb98fdfd8 EFLAGS: 00000246 ORIG_RAX: 00000000000000af
[   11.428641] RAX: ffffffffffffffda RBX: 0000561a07d6afc0 RCX: 00007f7708ab3eda
[   11.428641] RDX: 00007f7708c12b1d RSI: 0000000000133e58 RDI: 0000561a07d72220
[   11.431323] RBP: 0000561a07d72220 R08: 0000000000000007 R09: 0000561a07d12c00
[   11.431958] R10: 0000000000000005 R11: 0000000000000246 R12: 00007f7708c12b1d
[   11.433309] R13: 0000561a07d6afc0 R14: 0000561a07bc1110 R15: 0000561a07d6afc0
[   11.433419]  </TASK>

lshw is also missing all the networking capabilities:

# lshw -C network
...
  *-network
       physical id: 0
       bus info: pci@0000:03:00.0
       version: 00
       width: 64 bits
       clock: 33MHz
       capabilities: pm msi pciexpress bus_master cap_list
       configuration: driver=rtw89_pci latency=0
       resources: irq:89 ioport:2000(size=256) memory:fd600000-fd6fffff

Expected behavior

No stack trace in dmesg and working Wifi.

Additional context

I worked around it by using the newest kernel which has rtw89 built into the kernel and the rtw89-firmware (the extraModulePackages isn't necessary:

boot.kernelPackages = pkgs.linuxPackages_5_18;
hardware.firmware = [ pkgs.rtw89-firmware ];

Notify maintainers

@TvoroG

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
nix-shell -p nix-info --run "nix-info -m"
this path will be fetched (0.06 MiB download, 0.30 MiB unpacked):
  /nix/store/6pkx11fz05v4m8jgx76y1q1ri6llpf3i-bash-interactive-5.1-p16-dev
copying path '/nix/store/6pkx11fz05v4m8jgx76y1q1ri6llpf3i-bash-interactive-5.1-p16-dev' from 'https://cache.nixos.org'...
 - system: `"x86_64-linux"`
 - host os: `Linux 5.15.46, NixOS, 22.11 (Raccoon), 22.11pre385289.6616de389ed`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.9.1`
 - channels(root): `"nixos"`
 - channels(samuelh): `""`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
GlassGhost commented 2 years ago

isn't kernel 5.16 supposed to support the 8852ae?

When is the next kernel update?

Melkor333 commented 2 years ago

@GlassGhost That is correct, but the current default Kernel is 5.15 (which is also LTS). On Kernel 5.16+ you only need hardware.firmware = [ pkgs.rtw89-firmware ]; which works (i created a PR in nixos-hardware to circumvent the broken kernel module by using the latest kernel).

It's just that the Kernel module does not work anymore. Even if the default kernel is bumped to 5.16+ this will persist for anyone manually setting an older kernel and including the module.

nixos-discourse commented 1 year ago

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/getting-realtek-8852be-driver-to-work-under-nixos/22526/1

tokudan commented 1 year ago

I have the exact same message: RIP: 0010:rtw89_fw_download+0x6a/0x3e0 [rtw89core]

Just in case someone else is still fighting this on 22.05, updating the rtw89 module to today's git version seems to fix this issue for me, though I'm about to switch to 22.11.

nixos-discourse commented 1 year ago

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/wireless-device-not-working-during-install/29208/10

CutestNekoAqua commented 3 months ago

@TvoroG do you oppose updating the driver?

Melkor333 commented 2 months ago

Closing this, since 22.05 has been out of support for a long time now.