linux 6.12 でnvidiaのドライバを使う

linux-6.12.x で nvidiaのドライバ(565.57.01)を使うためのパッチを書いたので公開します.

nvidiaのドライバは

の2種類があります.

このパッチは後者の proprietary NVIDIA kernel modules 用のパッチです.

なお 565.57.01にパッチを当てずに linux-6.12 を使うと,カーネルが以下のエラーを吐きます.

[    8.015347] [   T1075] WARNING: CPU: 2 PID: 1075 at drm_open_helper+0x10b/0x130 [drm]
[    8.015600] [   T1075] Modules linked in: qrtr nls_utf8 nls_cp437 vfat fat cpufreq_powersave cpufreq_userspace cpufreq_conservative cpufreq_ondemand binfmt_misc intel_rapl_msr intel_rapl_common intel_uncore_frequency intel_uncore_frequency_common intel_tcc_cooling x86_pkg_temp_thermal intel_powerclamp snd_hda_codec_realtek snd_hda_codec_generic snd_hda_scodec_component snd_soc_avs snd_soc_hda_codec kvm_intel snd_hda_ext_core snd_hda_codec_hdmi snd_soc_core snd_compress ac97_bus kvm snd_pcm_dmaengine ghash_clmulni_intel sha512_ssse3 snd_hda_intel sha256_ssse3 snd_intel_dspcfg sha1_ssse3 snd_hda_codec sha1_generic ofpart aesni_intel snd_hda_core snd_hwdep gf128mul crypto_simd snd_pcm spi_nor cryptd iTCO_wdt evdev snd_timer rapl intel_pmc_bxt mtd intel_cstate snd wmi_bmof mei_me pcspkr iTCO_vendor_support soundcore 8250 mei 8250_base serial_mctrl_gpio serial_base tpm_crb tpm_tis tpm_tis_core acpi_pad sg button sch_fq_codel nct6775 nct6775_core hwmon_vid coretemp i2c_dev parport_pc ppdev lp parport nvme_fabrics efi_pstore fuse
[    8.015625] [   T1075]  configfs nfnetlink efivarfs tpm libaescfb ecdh_generic rng_core ecc dmi_sysfs ip_tables x_tables ipv6 autofs4 ext4 crc32c_generic mbcache jbd2 nvidia_uvm(PO) onboard_usb_dev nvidia_drm(PO) drm_ttm_helper hid_generic ttm nvidia_modeset(PO) sd_mod usbhid hid nvidia(PO) r8169 realtek mdio_devres i2c_designware_platform of_mdio xhci_pci i2c_designware_core fixed_phy iosf_mbi ahci fwnode_mdio xhci_hcd drm_kms_helper nvme libphy libahci intel_lpss_pci i2c_i801 crc32c_intel rtc_cmos usbcore nvme_core fan led_class drm i2c_mux spi_intel_pci intel_lpss spi_intel i2c_smbus hwmon libata idma64 usb_common vmd video thermal i2c_core wmi pinctrl_alderlake
[    8.017136] [   T1075] CPU: 2 UID: 0 PID: 1075 Comm: Xorg Tainted: P           O       6.12.1-custom #1
[    8.017424] [   T1075] Tainted: [P]=PROPRIETARY_MODULE, [O]=OOT_MODULE
[    8.017709] [   T1075] Hardware name: ASUS ZA9C-R49/PRIME Z790-P, BIOS 1661 06/25/2024
[    8.017995] [   T1075] RIP: 0010:drm_open_helper+0x10b/0x130 [drm]
[    8.018292] [   T1075] Code: 83 c4 08 5b 5d 41 5c c3 cc cc cc cc 48 89 df e8 3b a8 fe ff 85 c0 74 9a 48 89 df 89 44 24 04 e8 bb fa ff ff 8b 44 24 04 eb d5 <0f> 0b b8 ea ff ff ff eb cc b8 ea ff ff ff eb c5 b8 f0 ff ff ff eb
[    8.018587] [   T1075] RSP: 0018:ffffc900022dfbf0 EFLAGS: 00010246
[    8.018881] [   T1075] RAX: ffffffffa0505300 RBX: ffff8881251328c8 RCX: 0000000000000000
[    8.019175] [   T1075] RDX: ffff888106ad8f80 RSI: ffff8881251328c8 RDI: ffff88811b13fd40
[    8.019524] [   T1075] RBP: ffff88811b13fd40 R08: 0000000000000006 R09: ffff888100127dd0
[    8.019817] [   T1075] R10: 00000000000000e2 R11: 0000000000000002 R12: ffff88810588c800
[    8.020107] [   T1075] R13: ffffffffa0505300 R14: 00000000ffffffed R15: ffffc900022dfed4
[    8.020396] [   T1075] FS:  00007fd994a75b00(0000) GS:ffff889fff680000(0000) knlGS:0000000000000000
[    8.020686] [   T1075] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[    8.020973] [   T1075] CR2: 000055dd7731c520 CR3: 0000000107ac4000 CR4: 0000000000752ef0
[    8.021261] [   T1075] PKRU: 55555554
[    8.021546] [   T1075] Call Trace:
[    8.021832] [   T1075]  <TASK>
[    8.022115] [   T1075]  ? drm_open_helper+0x10b/0x130 [drm]
[    8.022410] [   T1075]  ? __warn.cold+0x93/0xed
[    8.022710] [   T1075]  ? drm_open_helper+0x10b/0x130 [drm]
[    8.023035] [   T1075]  ? report_bug+0xe8/0x130
[    8.023308] [   T1075]  ? handle_bug+0x53/0x90
[    8.023584] [   T1075]  ? exc_invalid_op+0x13/0x60
[    8.023860] [   T1075]  ? asm_exc_invalid_op+0x16/0x20
[    8.024140] [   T1075]  ? drm_open_helper+0x10b/0x130 [drm]
[    8.024428] [   T1075]  drm_open+0x6a/0x100 [drm]
[    8.024712] [   T1075]  drm_stub_open+0x92/0xd0 [drm]
[    8.024990] [   T1075]  chrdev_open+0xa7/0x210
[    8.025256] [   T1075]  ? __pfx_chrdev_open+0x10/0x10
[    8.025516] [   T1075]  do_dentry_open+0x135/0x420
[    8.025775] [   T1075]  vfs_open+0x25/0xe0
[    8.026059] [   T1075]  path_openat+0xaef/0x1030
[    8.026315] [   T1075]  ? block_write_end+0x32/0x70
[    8.026567] [   T1075]  do_filp_open+0xaa/0x150
[    8.026822] [   T1075]  do_sys_openat2+0x8f/0xc0
[    8.027085] [   T1075]  __x64_sys_openat+0x4c/0x90
[    8.027346] [   T1075]  do_syscall_64+0x47/0x110
[    8.027607] [   T1075]  entry_SYSCALL_64_after_hwframe+0x71/0x79
[    8.027868] [   T1075] RIP: 0033:0x7fd994e09b3c
[    8.028128] [   T1075] Code: 83 e2 40 75 51 89 f0 f7 d0 a9 00 00 41 00 74 46 80 3d 37 c5 0e 00 00 74 6a 89 da 48 89 ee bf 9c ff ff ff b8 01 01 00 00 0f 05 <48> 3d 00 f0 ff ff 0f 87 90 00 00 00 48 8b 54 24 28 64 48 2b 14 25
[    8.028396] [   T1075] RSP: 002b:00007ffcef8c3c00 EFLAGS: 00000202 ORIG_RAX: 0000000000000101
[    8.028665] [   T1075] RAX: ffffffffffffffda RBX: 0000000000080002 RCX: 00007fd994e09b3c
[    8.028933] [   T1075] RDX: 0000000000080002 RSI: 000055dd7732f2e0 RDI: 00000000ffffff9c
[    8.029198] [   T1075] RBP: 000055dd7732f2e0 R08: 0000000000000000 R09: 00007ffcef8c2d60
[    8.029514] [   T1075] R10: 0000000000000000 R11: 0000000000000202 R12: 0000000000000000
[    8.029801] [   T1075] R13: 000055dd7732f2e0 R14: 000055dd7732f2a0 R15: 000055dd7732ea00
[    8.030051] [   T1075]  </TASK>
[    8.030303] [   T1075] ---[ end trace 0000000000000000 ]---

このように nvidia_drm モジュールの,関数 drm_open_helper の中でクラッシュします

パッチの当て方

パッチはこれです

diff -uNr nvidia-565.57.01.orig/conftest.sh nvidia-565.57.01/conftest.sh
--- nvidia-565.57.01.orig/conftest.sh   2024-10-11 02:21:35.000000000 +0900
+++ nvidia-565.57.01/conftest.sh        2024-11-29 12:09:25.554727553 +0900
@@ -6592,6 +6592,29 @@
             compile_check_conftest "$CODE" "NV_DRM_OUTPUT_POLL_CHANGED_PRESENT" "" "types"
         ;;
 
+        drm_output_poll_changed)
+            #
+            # Determine whether drm_mode_config_funcs.output_poll_changed
+            # callback is present
+            #
+            # Removed by commit 446d0f4849b1 ("drm: Remove struct
+            # drm_mode_config_funcs.output_poll_changed") in v6.12. Hotplug
+            # event support is handled through the fbdev emulation interface
+            # going forward.
+            #
+            CODE="
+            #if defined(NV_DRM_DRM_MODE_CONFIG_H_PRESENT)
+            #include <drm/drm_mode_config.h>
+            #else
+            #include <drm/drm_crtc.h>
+            #endif
+            int conftest_drm_output_poll_changed_available(void) {
+                return offsetof(struct drm_mode_config_funcs, output_poll_changed);
+            }"
+
+            compile_check_conftest "$CODE" "NV_DRM_OUTPUT_POLL_CHANGED_PRESENT" "" "types"
+        ;;
+
         drm_aperture_remove_conflicting_pci_framebuffers)
             #
             # Determine whether drm_aperture_remove_conflicting_pci_framebuffers is present.
diff -uNr nvidia-565.57.01.orig/nvidia-drm/nvidia-drm-drv.c nvidia-565.57.01/nvidia-drm/nvidia-drm-drv.c
--- nvidia-565.57.01.orig/nvidia-drm/nvidia-drm-drv.c   2024-10-10 20:58:12.000000000 +0900
+++ nvidia-565.57.01/nvidia-drm/nvidia-drm-drv.c        2024-11-29 12:33:10.346961800 +0900
@@ -1711,6 +1711,9 @@
     .read           = drm_read,
 
     .llseek         = noop_llseek,
+#if defined(FOP_UNSIGNED_OFFSET)
+    .fop_flags   = FOP_UNSIGNED_OFFSET,
+#endif
 };
 
 static const struct drm_ioctl_desc nv_drm_ioctls[] = {
diff -uNr nvidia-565.57.01.orig/nvidia-drm/nvidia-drm-sources.mk nvidia-565.57.01/nvidia-drm/nvidia-drm-sources.mk
--- nvidia-565.57.01.orig/nvidia-drm/nvidia-drm-sources.mk      2024-10-10 20:52:47.000000000 +0900
+++ nvidia-565.57.01/nvidia-drm/nvidia-drm-sources.mk   2024-11-29 12:28:12.048249098 +0900
@@ -121,6 +121,7 @@
 NV_CONFTEST_TYPE_COMPILE_TESTS += dma_resv_add_fence
 NV_CONFTEST_TYPE_COMPILE_TESTS += dma_resv_reserve_fences
 NV_CONFTEST_TYPE_COMPILE_TESTS += reservation_object_reserve_shared_has_num_fences_arg
+NV_CONFTEST_TYPE_COMPILE_TESTS += drm_output_poll_changed
 NV_CONFTEST_TYPE_COMPILE_TESTS += drm_connector_has_override_edid
 NV_CONFTEST_TYPE_COMPILE_TESTS += drm_master_has_leases
 NV_CONFTEST_TYPE_COMPILE_TESTS += drm_file_get_master


パッチを当てたらカーネルモジュールをリビルドします.

$ sudo /usr/sbin/dkms build nvidia/565.57.01  --force
$ sudo /usr/sbin/dkms install nvidia/565.57.01  --force

dkms コマンドには --force オプションを指定したほうが安全です.--forceをつけると,dkmsはドライバをリビルドして,強制(=上書き)インストールします.

あとは再起動するだけで,完了です.

macOS Sequoia 15.1 がフリーズする原因:AX88179Aのドライバのバグでした

macOS Sequoia 15.1にアップグレードしたところ、

と不具合が続出しました.全く仕事にならない…

が,昨日やっと原因が判りました

原因は Anker 563 USB-C が使っているチップ AX88179A 用のドライバのバグです

ASIX AX88179A のドライバを手動で更新,最新版にすると動作が安定するようになりました.

ドライバは https://www.asix.com.tw/en/product/USBEthernet/Super-Speed_USB_Ethernet/AX88179A からダウンロードできます

ただし更新の手順が少々煩雑です.上記URLにアップグレードの手順も書いてあるので,手順書の通りにやると,更新できます