After upgrading graphics/drm-61-kmod to commit ac934345a14f, X11 with graphics/nvidia-drm-61-kmod hesitates to start with error logged in /var/log/Xorg.0.log like below (relevant parts only). stable/15, amd64 at commit base 1aad58b919d3. No differences in dmesg between previous version and problematic version which relates with VGA / GPU. Not tested drm-66-kmod and corresponding nvidia-drm-66-kmod. Related thread at freebsd-ports ML: https://lists.freebsd.org/archives/freebsd-ports/2025-September/008467.html ===== Part of /var/tmp/Xorg.0.log ===== (snip) [ 138.092] (WW) modeset(0): Option "PrimaryGPU" is not used [ 138.093] (EE) modeset(0): [DRI2] No driver mapping found for PCI device 0x0000 / 0x0000 [ 138.093] (EE) modeset(0): Failed to initialize the DRI2 extension. (snip) [ 138.316] (EE) modeset(0): Failed to create pixmap [ 138.316] (EE) Fatal server error: [ 138.316] (EE) failed to create screen resources(EE)
Adding Austin to CC.
^Triage: Cc: committer.
Created attachment 263851 [details] Full Xorg.0.log on error Full Xorg.0.log on error with drm-61-kmod drm_v6.1.128_5.
(In reply to Tomoaki AOKI from comment #3) No driver mapping found for PCI device 0x0000 / 0x0000 xorg-server-21.1.18/hw/xfree86/dri2/dri2.c::dri2_probe_driver_name() Without much investigation: drm_public int drmGetDevice(int fd, drmDevicePtr *device) { return drmGetDevice2(fd, DRM_DEVICE_GET_PCI_REVISION, device); } ... drmGetDeviceFromDevId ... But that path seems to use native FreeBSD PCI ioctl and not LinuxKPI or drm. I am not sure where it all comes together and how it is supposed to clash. We do a sscanf from the sysctl in libdrm get_sysctl_pci_bus_info() So a sysctl -a hw.dri from before the update and after the update would be really good. I fear what we all missed is a format change in printing a string (which no one would assume would be used for anything but logging). Specifically all the hw.dri.%d.busid values. I am seeing: hw.dri.0.busid: pci:0000:00:06.0 which matches "pci:%04x:%02x:%02x.%u" for: vgapci0@pci0:0:6:0: class=0x030000 rev=0x07 hdr=0x00 vendor=0x8086 device=0x5917 subvendor=0x103c subdevice=0x83b2 I'll do comparative builds later myself for i915kms.
That’s my hypothesis as well as mentioned on the mailing list. I remember that some pieces of code (libdrm?) use sysctl to discover and query a few things. I think that on Linux, they use sysfs, but my memory is bad.
Created attachment 263859 [details] Result of sysctl -a | grep hw.dri (successful case, with previous version) Sorry, cannot take time for faulty case for now. So uploading successful case for comparison.
You have (good case): hw.dri.0.busid: pci:0000:01:00.0 I have (old cases): hw.dri.0.busid: pci:0000:00:02.0 hw.dri.0.busid: pci:0000:00:06.0 Difference: for you is that the bus number is non-zero, so that could be the culprit? We used to get that number from: - bsddev = dev->dev->bsddev; - bus = pci_get_bus(bsddev); Now we get it via: + struct pci_dev *pdev = to_pci_dev(dev->dev); + bus = pdev->bus->number; The latter is set by nvidia-drm in src/nvidia-drm/nvidia-drm-freebsd-lkpi.c nv_drm_probe_devices -> linux_pci_attach_device -> lkpifill_pci_dev: pdev->bus->number = pci_get_bus(dev); So unless it is set on the wrong pdev this makes little sense. If I am right, in your "bad" case the sysctl would report: hw.dri.0.busid: pci:0000:00:00.0 If it does not the problem is elsewhere and we'll need to track that down. If this is the case we'll still need to figure out why we end up on the wrong (bsd)dev. It would be easy to do this having an nvidia + ports tree and patching things and reinstalling, given we roughly seem to know the places to look at. Hmm, I seem to have an amdgpu at vgapci0@pci0:195:0:0 . It'd be a while as the machine is doing anything but graphics currently buy I could try to set that up. Might still work as unlike nvidia amdgpu uses LinuxKPI PCI and not a mixture of native PCI and LinuxKPI PCI.
(In reply to Bjoern A. Zeeb from comment #7) Compared relevant parts of good and NG Xorg.0.log. In good case, PCI:*(1@0:0:0), while NG case PCI: (1@0:0:0). [No "*" in NG case] Not sure why (not installed), in good case, nv driver is matched, while NG case it's not. Does the below help? Currently running Xorg.0.log is: [ 224.164] (II) xfree86: Adding drm device (/dev/dri/card0) [ 224.164] (II) Platform probe for /dev/dri/card0 [ 225.296] (**) OutputClass "nvidia" ModulePath extended to "/usr/local/lib/nvidia/xorg,/usr/local/lib/xorg/modules,/usr/local/lib/xorg/modules" [ 225.296] (**) OutputClass "nvidia" ModulePath extended to "/usr/local/lib/nvidia/xorg,/usr/local/lib/xorg/modules,/usr/local/lib/nvidia/xorg,/usr/local/lib/xorg/modules,/usr/local/lib/xorg/modules" [ 225.296] (**) OutputClass "nvidia" setting /dev/dri/card0 as PrimaryGPU [ 225.296] (--) PCI:*(1@0:0:0) 10de:1cbb:17aa:2262 rev 161, Mem @ 0xa3000000/16777216, 0x60000000/268435456, 0x70000000/33554432, I/O @ 0x00002000/128, BIOS @ 0x????????/65536 [ 225.296] (II) LoadModule: "glx" [ 225.297] (II) Loading /usr/local/lib/xorg/modules/extensions/libglx.so [ 225.303] (II) Module glx: vendor="X.Org Foundation" [ 225.303] compiled for 1.21.1.18, module version = 1.0.0 [ 225.303] ABI class: X.Org Server Extension, version 10.0 [ 225.304] (II) Applying OutputClass "nvidia" to /dev/dri/card0 [ 225.304] loading driver: nvidia [ 225.304] (II) Applying OutputClass "nvidia" to /dev/dri/card0 [ 225.304] loading driver: nvidia [ 225.304] (==) Matched nvidia as autoconfigured driver 0 [ 225.304] (==) Matched nv as autoconfigured driver 1 [ 225.304] (==) Matched modesetting as autoconfigured driver 2 [ 225.304] (==) Matched scfb as autoconfigured driver 3 [ 225.304] (==) Matched vesa as autoconfigured driver 4 [ 225.304] (==) Assigned the driver to the xf86ConfigLayout Hesitated to start Xorg.0.log is: [ 136.679] (II) Platform probe for /dev/dri/card0 [ 137.816] (**) OutputClass "nvidia" ModulePath extended to "/usr/local/lib/nvidia/xorg,/usr/local/lib/xorg/modules,/usr/local/lib/xorg/modules" [ 137.817] (**) OutputClass "nvidia" ModulePath extended to "/usr/local/lib/nvidia/xorg,/usr/local/lib/xorg/modules,/usr/local/lib/nvidia/xorg,/usr/local/lib/xorg/modules,/usr/local/lib/xorg/modules" [ 137.817] (**) OutputClass "nvidia" setting /dev/dri/card0 as PrimaryGPU [ 137.817] (--) PCI: (1@0:0:0) 10de:1cbb:17aa:2262 rev 161, Mem @ 0xa3000000/16777216, 0x60000000/268435456, 0x70000000/33554432, I/O @ 0x00002000/128, BIOS @ 0x????????/65536[ 137.817] (II) LoadModule: "glx" [ 137.818] (II) Loading /usr/local/lib/xorg/modules/extensions/libglx.so [ 137.824] (II) Module glx: vendor="X.Org Foundation" [ 137.824] compiled for 1.21.1.18, module version = 1.0.0 [ 137.824] ABI class: X.Org Server Extension, version 10.0 [ 137.824] (II) Applying OutputClass "nvidia" to /dev/dri/card0 [ 137.824] loading driver: nvidia [ 137.824] (II) Applying OutputClass "nvidia" to /dev/dri/card0 [ 137.824] loading driver: nvidia [ 137.824] (==) Matched nvidia as autoconfigured driver 0 [ 137.824] (==) Matched modesetting as autoconfigured driver 1 [ 137.824] (==) Matched scfb as autoconfigured driver 2 [ 137.824] (==) Matched vesa as autoconfigured driver 3 [ 137.824] (==) Assigned the driver to the xf86ConfigLayout
Created attachment 263876 [details] Result of sysctl -a | grep hw.dri (faulty case, with previous version) Obtained sysctl for faulty case. The meaningful difference is as follows. Successful case: hw.dri.0.busid: pci:0000:01:00.0 Faulty case: hw.dri.0.busid: pci:0000:01:1a.0
Therefore, it is value of the PCI slot which changes between both sysctls. The old value was computed like this: slot = pci_get_slot(bsddev); The new value is computed like this: slot = PCI_SLOT(pdev->devfn); `pdev->devfn` is computed like this by linux_pci_attach_device() in linuxkpi (linux_pci.c): if (isdrm) PCI_GET_ID(device_get_parent(parent), parent, PCI_ID_RID, &rid); else PCI_GET_ID(parent, dev, PCI_ID_RID, &rid); pdev->devfn = rid; The `isdrm` boolean is true if the driver name is "drmn", which is probably (?) not the case for the NVIDIA drivers. So I assume `devfn` is computed from the `else` branch above. The code quoted by Bjoern in comment #7 from nvidia-drm-freebsd-lkpi.c is only running on FreeBSD before version 13.x. That same devfn value was set like this: pdev->devfn = PCI_DEVFN(pci_get_slot(dev), pci_get_function(dev)); It would be interesting to get the device tree on a working system with: devinfo -v With a DRM device, we have one extra level in the tree (drmn). Here is an example from my laptop: ... pci0<ACPI PCI bus> hostb0<Host to PCI bridge> pnpinfo vendor=0x8086 device=0x4621 subvendor=0xf111 subdevice=0x0002 class=0x060000 at slot=0 function=0 dbsf=pci0:0:0:0 handle=\_SB_.PC00.MC__ vgapci0<VGA-compatible display> pnpinfo vendor=0x8086 device=0x46a6 subvendor=0xf111 subdevice=0x0002 class=0x030000 at slot=2 function=0 dbsf=pci0:0:2:0 handle=\_SB_.PC00.GFX0 drmn0<drmn> drm129 lkpi_iic9<LinuxKPI I2C> iicbus12<Philips I2C bus> iic12<I2C generic I/O> at addr=0 ...
(In reply to Jean-Sébastien Pédron from comment #10) and a full pciconf -l . I have another patch for NVIDIA out to Adrian and Austin which would actually make sure that isdrm would be set. Now I wonder what has happened here before (the right thing or worked accidentally? in the NVIDIA case) and what will happen with my patch? It is hard to have a look when having to remote-debug this through someone else; I was pondering getting an (older NVIDIA) but it also would have meant to get a oculink base etc. and it may only have arrived after Friday, so no good for me until after Euro. I think it would be worthwhile at some point to get "one of each" (intel, amd, nvidia, possibly some arm64 one) somewhere in a Lab like at Sentex so it would be possible to remotely debug most of this at least so LinuxKPI work could be done more easily without breaking untested bits. (Cc: emaste, jrm). Mind you, this all stems from trying to get wifi forward.
(In reply to Jean-Sébastien Pédron from comment #10) Relevant part (including iwlwifi part for Bjoern) of devinfo -v on successful case. nexus0 ... acpi0<LENOVO TP-N2C> acpi_ec0<Embedded Controller: GPE 0x16, ECDT> pnpinfo _HID=PNP0C09 _UID=0 _CID=none at handle=\_SB_.PCI0.LPCB.EC__ pcib0<ACPI Host-PCI bridge> pnpinfo _HID=PNP0A08 _UID=0 _CID=PNP0A03 at handle=\_SB_.PCI0 pci0<ACPI PCI bus> hostb0<Host to PCI bridge> pnpinfo vendor=0x8086 device=0x3ec4 subvendor=0x17aa subdevice=0x225f class=0x060000 at slot=0 function=0 dbsf=pci0:0:0:0 pcib1<ACPI PCI-PCI bridge> pnpinfo vendor=0x8086 device=0x1901 subvendor=0x17aa subdevice=0x225f class=0x060400 at slot=1 function=0 dbsf=pci0:0:1:0 handle=\_SB_.PCI0.PEG0 pci1<ACPI PCI bus> vgapci0<VGA-compatible display> pnpinfo vendor=0x10de device=0x1cbb subvendor=0x17aa subdevice=0x2262 class=0x030000 at slot=0 function=0 dbsf=pci0:1:0:0 handle=\_SB_.PCI0.PEG0.PEGP drmn0 acpi_video0 nvidia0<Quadro P1000> drm128 drm0 drm1 drm2 drm3 drm4 drm5 hdac0<NVIDIA (0x0fb9) HDA Controller> pnpinfo vendor=0x10de device=0x0fb9 subvendor=0x0000 subdevice=0x0000 class=0x040300 at slot=0 function=1 dbsf=pci0:1:0:1 handle=\_SB_.PCI0.PEG0.PEGA ... unknown pnpinfo vendor=0x8086 device=0xa36f subvendor=0x17aa subdevice=0x225f class=0x050000 at slot=20 function=2 dbsf=pci0:0:20:2 iwlwifi0<iwlwifi> pnpinfo vendor=0x8086 device=0xa370 subvendor=0x8086 subdevice=0x0030 class=0x028000 at slot=20 function=3 dbsf=pci0:0:20:3 handle=\_SB_.PCI0.CNVW ig4iic0<Intel Cannon Lake-H I2C Controller-0> pnpinfo vendor=0x8086 device=0xa368 subvendor=0x17aa subdevice=0x225f class=0x0c8000 at slot=21 function=0 dbsf=pci0:0:21:0 handle=\_SB_.PCI0.I2C0 ...
Created attachment 263896 [details] Full devinfo -v on successful case I'll try faulty case hopefully tonight (JST).
Created attachment 263897 [details] Full pciconf -l on successful case Will try for faulty case (hopefully) tonight (JST).
(In reply to Tomoaki AOKI from comment #14) no need for pciconf as that is hopefully not to change ;-)
Created attachment 263902 [details] Check "nvidia" in the computation of "isdrm" The NVIDIA driver also creates a child device below `vgapci`, like `drmn`: vgapci0<VGA-compatible display> (...) drmn0 acpi_video0 nvidia0<Quadro P1000> Therefore, we must handle it like `drmn` and ajust the "isdrm" boolean. Could you please try the attached kernel patch?
(In reply to Bjoern A. Zeeb from comment #15) Both `devinfo -v` and `pciconf -l` of fault case matched with the successful case. So stopped uploading files for faulty case.
(In reply to Jean-Sébastien Pédron from comment #16) Thanks for investigating! Build failed by unrelated reason with your patch. Simply updating src to commit 7140f620a569 didn't help. So I'm now rebuilding world and kernel with /usr/obj/ deleted. It would take several hours to finish. I'll report back once build/install finishes.
(In reply to Jean-Sébastien Pédron from comment #16) That patch won't work as nvidia is native PCI code and never calls pci_register_driver. So no need to test it. The patch I emailed to Adrian and Austin adds the pdrv to the linux_pci_attach_device() with isdrm already set but I haven't heard back. That said, that would change the code path in this case and do set things differently to what is currently done, so I am not sure if that's where the change of value comes from. Are you thinking that it is currently not properly set and previously the partial native PCI calls in drm concealed that? I'll attach both the nvidia-drm patch and a debugging patch I made (but my amdgpu still panics so I cannot test) later today, once I can get back to that machine.
Comment on attachment 263902 [details] Check "nvidia" in the computation of "isdrm" Oh, I see what you mean Bjoern, you are right. I misread the code and thought it went through the same code path as DRM drivers. Tomoaki, as Bjoern says, no need to test the patch :-)
Created attachment 263904 [details] Patch for pdrv against nvidia-drm-66 This is the patch which would give a pdrv to linux_pci_attach_device() with isdrm set hard. It adds dummy callback functions as not all of LinuxKPI checks for NULL there (and some functions may probably not be NULL in Linux either). This would change the current behaviour as to how pdev->devfn is calculated. If this fixes the problem then we catch two for one likely and in any previous version the native PCI calls in drm did hide the fact that this was never calculated correctly. If it does not help I'll email the debug patch later today as well.
Comment on attachment 263904 [details] Patch for pdrv against nvidia-drm-66 Looking at this I wonder if we should set .name to "drmn" as well but I think we reduced the check (at least in LinuxKPI) to pci_register_driver(). I wonder if drm itself has any further "drmn" checks?
(In reply to Bjoern A. Zeeb from comment #22) Tried, but failed to build, both on graphics/nvidia-drm-61-kmod-devel and graphics/nvidia-drm-66-kmod-devel. Note that graphics/nvidia-drm-*-kmod-devel are slave ports of corresponding graphics/nvidia-drm-*-kmod, and currently both are at exactly same version (as Production Branch of driver has the newest version now). And also note that nvidia side of distfiles are exactly the same. (Only DRM side of distfiles differ.) Same as with my pending patch to upgrade to 580.82.09. The error is as follows. (All the same error). --- nvidia-drm-freebsd-lkpi.o --- nvidia-drm-freebsd-lkpi.c:125:11: error: use of undeclared identifier 'MODULE_NAME' 125 | .name = MODULE_NAME, | ^ nvidia-drm-freebsd-lkpi.c:128:12: error: use of undeclared identifier 'dummy_nv_pci_remove'; did you mean 'dummy_nv_pci_probe'? 128 | .remove = dummy_nv_pci_remove, | ^~~~~~~~~~~~~~~~~~~ | dummy_nv_pci_probe nvidia-drm-freebsd-lkpi.c:108:1: note: 'dummy_nv_pci_probe' declared here 108 | dummy_nv_pci_probe(struct pci_dev *pci_dev __unused, | ^ nvidia-drm-freebsd-lkpi.c:132:15: error: unexpected ';' before '}' 132 | .isdrm = true; | ^ nvidia-drm-freebsd-lkpi.c:185:52: error: incompatible pointer types passing 'struct pci_driver *' to parameter of type 'const struct pci_device_id *' [-Werror,-Wincompatible-pointer-types] 185 | if (linux_pci_attach_device(sc->dev, NULL, &nv_pci_driver, pdev)) { | ^~~~~~~~~~~~~~ /usr/src/sys/compat/linuxkpi/common/include/linux/pci.h:1292:33: note: passing argument to parameter here 1292 | const struct pci_device_id *, struct pci_dev *); | ^ 4 errors generated. *** [nvidia-drm-freebsd-lkpi.o] Error code 1 make: stopped making "all" in /usr/ports/graphics/nvidia-drm-66-kmod-devel/work/NVIDIA-FreeBSD-x86_64-580.82.07/src/nvidia-drm make: 1 error make: stopped making "all" in /usr/ports/graphics/nvidia-drm-66-kmod-devel/work/NVIDIA-FreeBSD-x86_64-580.82.07/src/nvidia-drm ===> Compilation failed unexpectedly. Try to set MAKE_JOBS_UNSAFE=yes and rebuild before reporting the failure to the maintainer. *** Error code 1 Stop. make: stopped making "all" in /usr/ports/graphics/nvidia-drm-66-kmod-devel
Created attachment 263910 [details] nvidia-drm-6.1 patch for linuxkpi pdrv Updated, should compile now. For 6.1. this time.
I manually applied the latest patch and it seems to run fine. I didn't try the Xorg issue, just verified it compiles and runs. Here's the devinfo snippet with it applied: vgapci0<VGA-compatible display> pnpinfo vendor=0x10de device=0x25e0 subvendor=0x17aa subdevice=0x3aac class=0x030000 at slot=0 function=0 dbsf=pci0:1:0:0 handle=\_SB_.PCI0.GPP0.P EGP <Interrupt request lines> 0x4d <pcib1 I/O port window> 0x3000-0x307f <pcib1 memory window> 0xd0000000-0xd0ffffff <pcib1 prefetch window> 0xfb00000000-0xfbffffffff 0xfc00000000-0xfc01ffffff drmn0 nvidia0<NVIDIA GeForce RTX 3050 Ti Laptop GPU> drm128 drm0 drm1 drm2 drm3 drm4 Maybe I applied it wrong but it looks like this is the same as before the patch? Is that expected?
(In reply to Austin Shafer from comment #25) Yes, resources don't change. The problem is (was) what drm queried internally (and likely wasn't there by the current hypothesis). You'll likely have to start X to find out? Ah or can you also check what the sysctl says for you if that looks sane (see comment #c9)? If this patch works, the next question (unrelated to this PR) but for the other issue we encountered is whether re-applying bbeeb585315645db20118ef349a4e3dc83b148cc now also works?
I think this looks sane: hw.dri.timestamp_precision: 20 hw.dri.vblank_offdelay: 5000 hw.dri.0.modesetting: 1 hw.dri.0.busid: pci:0000:01:00.0 hw.dri.0.vblank: crtc ref count last enabled inmodeset hw.dri.0.clients: a dev pid uid magic ioctls hw.dri.0.name: nvidia-drm 0xc4 hw.dri.dp_aux_i2c_transfer_size: 16 hw.dri.dp_aux_i2c_speed_khz: 10 hw.dri.drm_fbdev_overalloc: 100 hw.dri.fbdev_emulation: 1 hw.dri.timestamp_precision_usec: 20 hw.dri.vblankoffdelay: 5000 hw.dri.poll: 1 hw.dri.debug: 0 hw.dri.drm_debug_persist: 0 hw.dri.skip_ddb: 1 hw.dri.__drm_debug: 0 hw.dri.edid_fixup: 6
(In reply to Austin Shafer from comment #27) hw.dri.0.busid: pci:0000:01:00.0 Indeed. THANK YOU! So could be we solved two for one? Are you one main and also could recompile the kernel with the backed out change re-applied? If this works, updating the nvidia ports and then I can go ahead and put the remaining LinuxKPI changes into the tree and be back to wifi :)
I can't at the moment, about to step away. If nobody else is able to get to it I hopefully can tomorrow.
(In reply to Bjoern A. Zeeb from comment #28) Works fine for me, too. Thanks! hw.dri.0.busid: pci:0000:01:00.0 Not actually tested, but the same patch should be applicable and work for graphics/nvidia-drm-66-kmod, too. TBH, it would be nice if both FreeBSD native and via LinuxKPI returns the same expected value, though.
(In reply to Tomoaki AOKI from comment #30) Yes the patch applies equally to both branches. Well they should now (with the patch) as before it just worked by accident of using the native PCI interface (mind you not for everything; there was one PCI_FUNC(pdev->devfn) in drm already); now it seems we also set it up better for LinuxKPI so we can use these values. It's been an omission in the nvidia-drm code gluing native and LinuxKPI bits together. Thanks a lot for testing/reporting back! In case you are running main or stable/15 you could also try to apply bbeeb585315645db20118ef349a4e3dc83b148cc again and see if that works too now with the patched nvidia-drm? Also are you and or Austin (or dumbbell?) going to add the patch to the ports? I hope we don't need a #if __FreeBSD_version >= 1300093 #endif around the dummy functions and nv_pci_driver (otherwise unused) given we don't support that old releases anymore.
(In reply to Bjoern A. Zeeb from comment #31) Cherry-picked commit bbeeb585315645db20118ef349a4e3dc83b148cc alone to stable/15 at commit 7140f620a5695b023e76e482dab50133479f0a0b. With your patch, works fine (hw.dri.0.busid: pci:0000:01:00.0). Just to be sure, tried without your patch, resulting failure (hw.dri.0.busid: pci:0000:01:00.6). Busid differs with both successful case and previous failure case. And I agree with that already out-of-support version on ports tree can be dropped here, too. (My understanding is that pre-13.5 of branch 13 can be dropped.) As I'm not a committer, I cannot commit the patch by myself.
Hello, Just to confirm that patch is working fine on 16 main hw.dri.0.busid: pci:0000:01:00.0 Thanks!
hi! I'll test this soon too. Do we need suspend/resume methods here as well? for laptops w/ nvidia?
(In reply to Adrian Chadd from comment #34) Not sure, as suspend/resume never worked for me after FreeBSD switche from AMP to ACPI. Thus, no experiences on me. The last time suspend/resume worked was on APM with PAO.IIRC, GPU was ATI (far before purchased by AMD).
Created attachment 263951 [details] Xorg.0.log I was using the nvidia-drm-66-kmod until my dual monitor setup broke. I followed your bug report from ML and found I have the exact same issue. ``` [ 146.420] (II) Initializing extension DRI2 [ 147.985] (II) modeset(G0): Damage tracking initialized [ 147.985] (EE) modeset(0): Failed to create pixmap [ 147.985] (EE) Fatal server error: [ 147.985] (EE) failed to create screen resources(EE) [ 147.985] (EE) Please consult the The X.Org Foundation support ``` I have deinstalled the nvidia-drm-66-kmod, compiled nvidia-drm-61-kmod with your patch, then rebooted, and got a kernel panic. devinfo -v ``` acpi0<COREv4 COREBOOT> acpi_sysresource0<System Resource> pnpinfo _HID=PNP0C02 _UID=0 _CID=none at handle=\_SB_.PERC pcib0<ACPI Host-PCI bridge> pnpinfo _HID=PNP0A08 _UID=0 _CID=PNP0A03 at handle=\_SB_.PCI0 pci0<ACPI PCI bus> hostb0<Host to PCI bridge> pnpinfo vendor=0x8086 device=0xa702 subvendor=0x1558 subdevice=0xd502 class=0x060000 at slot=0 function=0 dbsf=pci0:0:0:0 handle=\_SB_.PCI0.MCHC pcib1<ACPI PCI-PCI bridge> pnpinfo vendor=0x8086 device=0xa70d subvendor=0x1558 subdevice=0xd502 class=0x060400 at slot=1 function=0 dbsf=pci0:0:1:0 handle=\_SB_.PCI0.PEG1 pci1<ACPI PCI bus> vgapci0<VGA-compatible display> pnpinfo vendor=0x10de device=0x28e0 subvendor=0x10de subdevice=0x0000 class=0x030000 at slot=0 function=0 dbsf=pci0:1:0:0 handle=\_SB_.PCI0.PEG1.DEV0 drmn0 nvidia0<NVIDIA GeForce RTX 4060 Laptop GPU> drm128 drm0 drm1 drm5 lkpi_iic9<LinuxKPI I2C> iicbus11<Philips I2C bus> iic11<I2C generic I/O> at addr=0 drm6 lkpi_iic10<LinuxKPI I2C> iicbus12<Philips I2C bus> iic12<I2C generic I/O> at addr=0 drm7 drm8 lkpi_iic11<LinuxKPI I2C> iicbus13<Philips I2C bus> iic13<I2C generic I/O> at addr=0 drm9 drm2 drm3 drm4 hdac0<NVIDIA (0x22be) HDA Controller> pnpinfo vendor=0x10de device=0x22be subvendor=0x10de subdevice=0x0000 class=0x040300 at slot=0 function=1 dbsf=pci0:1:0:1 hdacc0<NVIDIA (0x00a7) HDA CODEC> pnpinfo vendor=0x10de device=0x00a7 revision=0x01 stepping=0x00 at cad=0 hdaa0<NVIDIA (0x00a7) Audio Function Group> pnpinfo type=0x01 subsystem=0x10de0000 at nid=1 pcm0<NVIDIA (0x00a7) (HDMI/DP 8ch)> at nid=4 pcm1<NVIDIA (0x00a7) (HDMI/DP 8ch)> at nid=6 pcm2<NVIDIA (0x00a7) (HDMI/DP 8ch)> at nid=7 vgapci1<VGA-compatible display> pnpinfo vendor=0x8086 device=0xa788 subvendor=0x1558 subdevice=0xd502 class=0x030000 at slot=2 function=0 dbsf=pci0:0:2:0 handle=\_SB_.PCI0.GFX0 drmn1<drmn> drm129 lkpi_iic0<LinuxKPI I2C> iicbus2<Philips I2C bus> ``` with nvidia-drm-66-kmod: ``` hw.dri.0.name: nvidia-drm 0xe6 hw.dri.1.name: i915 0xe7 hw.dri.0.busid: pci:0000:01:1a.0 hw.dri.1.busid: pci:0000:00:02.0 ``` freebsd-version -kr 16.0-CURRENT (main-n280520-4c3a868d13c0) 16.0-CURRENT
(In reply to Seyed Pouria Mousavizadeh Tehrani from comment #36) I have the coredump file ``` iic0: <I2C generic I/O> on iicbus0 iic1: <I2C generic I/O> on iicbus1 nvidia0: <NVIDIA GeForce RTX 4060 Laptop GPU> on vgapci0 vgapci0: child nvidia0 requested pci_enable_io vgapci0: child nvidia0 requested pci_enable_io <6>nvidia-modeset: Loading NVIDIA Kernel Mode Setting Driver for UNIX platforms 580.82.07 Wed Aug 27 18:00:26 UTC 2025 <6>[drm] [nvidia-drm] [GPU ID 0x00000100] Loading driver Fatal trap 12: page fault while in kernel mode cpuid = 14; apic id = 38 fault virtual address = 0x44 fault code = supervisor read data, page not present instruction pointer = 0x20:0xffffffff83a430cc stack pointer = 0x28:0xfffffe0228ad4550 frame pointer = 0x28:0xfffffe0228ad45a0 code segment = base rx0, limit 0xfffff, type 0x1b = DPL 0, pres 1, long 1, def32 0, gran 1 processor eflags = interrupt enabled, resume, IOPL = 0 current process = 11799 (kldload) rdi: fffff80021cf1000 rsi: 0000000000000000 rdx: 000000000000436b rcx: 1b4e3efc61b787d0 r8: 000000000000000a r9: 8080808080808080 rax: 0000000000000000 rbx: fffffffffffffff8 rbp: fffffe0228ad45a0 r10: 0000000000000001 r11: 0000000000000039 r12: ffffffff83a0d1f0 r13: fffff80001e7ff00 r14: fffff80021cf13d0 r15: 0000000000000000 trap number = 12 panic: page fault cpuid = 14 time = 1758419354 KDB: stack backtrace: db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xfffffe0228ad42a0 vpanic() at vpanic+0x136/frame 0xfffffe0228ad43d0 panic() at panic+0x43/frame 0xfffffe0228ad4430 trap_pfault() at trap_pfault+0x3c9/frame 0xfffffe0228ad4480 calltrap() at calltrap+0x8/frame 0xfffffe0228ad4480 --- trap 0xc, rip = 0xffffffff83a430cc, rsp = 0xfffffe0228ad4550, rbp = 0xfffffe0228ad45a0 --- drm_mode_config_validate() at drm_mode_config_validate+0x5c/frame 0xfffffe0228ad45a0 drm_dev_register() at drm_dev_register+0x2d/frame 0xfffffe0228ad45d0 nv_drm_register_drm_device() at nv_drm_register_drm_device+0xed2/frame 0xfffffe0228ad49d0 nv_drm_probe_devices() at nv_drm_probe_devices+0x107/frame 0xfffffe0228ad4a30 nvidia_drm_evh() at nvidia_drm_evh+0x14/frame 0xfffffe0228ad4a50 module_register_init() at module_register_init+0x85/frame 0xfffffe0228ad4a80 linker_load_module() at linker_load_module+0xc0f/frame 0xfffffe0228ad4d80 kern_kldload() at kern_kldload+0x165/frame 0xfffffe0228ad4dd0 sys_kldload() at sys_kldload+0x59/frame 0xfffffe0228ad4e00 amd64_syscall() at amd64_syscall+0x126/frame 0xfffffe0228ad4f30 fast_syscall_common() at fast_syscall_common+0xf8/frame 0xfffffe0228ad4f30 --- syscall (304, FreeBSD ELF64, kldload), rip = 0x20c2aca8dfca, rsp = 0x20c2aa1059e8, rbp = 0x20c2aa105f60 --- ```
(In reply to Seyed Pouria Mousavizadeh Tehrani from comment #37) That panic looks like a NULL pointer but shoudl likely be looked into separately. The patch from nividia-drm-6.1 applies 1:1 to 6.6 as well; You can just copy the new file over to the other port and compile 6.6 with it.
(In reply to Seyed Pouria Mousavizadeh Tehrani from comment #37) As Bjoern already noted, the patch can be applied for nvidia-drm-66-kmod, too (need modifying patch here to apply, though). Or simply copy patch-nvidia-drm-freebsd-lkpi.c-20250918-01 in graphics/nvidia-drm-61-kmod/files/ into graphics/nvidia-drm-66-kmod/files/ and rebuild / reinstall should be OK. And for driver crash, are you sure you switched corresponding graphics/drm-66-kmod to graphics/drm-61-kmod, too? And note that the versions of x11/nvidia-driver and nvidia part of graphics/nvidia-drm-*-kmod SHALL match. Are you sure they are?
I applied the patch to the nvidia-drm-66-kmod and it works perfectly! About my kernel panic, you were right, I hadn't downgraded my nvidia-driver. Thank you!
Created attachment 264029 [details] Made Bjoern's patch into committable form. Apply to graphics/nvidia-drm-66-kmod, too. Bump PORTREVISIONs of below, which are affected and need rebuilding. graphics/nvidia-drm-61-kmod graphics/nvidia-drm-61-kmod-devel graphics/nvidia-drm-66-kmod graphics/nvidia-drm-66-kmod-devel As already commented, didn't guard for 13.0, which is already EoL'ed.
(In reply to Tomoaki AOKI from comment #41) Change LGTM. Do you need me to commit it or Bjoern do you want to since it's your change?
(In reply to Austin Shafer from comment #42) Although this would be urgent, I'm not the actual author of the patch (just reorganized), so it should be on Bjoern. Can you commit it if Bjoern is OK with my reorganized patch but having not enough time to do himself?
(In reply to Tomoaki AOKI from comment #43) Anyone please go ahead and commit it. I am not setup to commit to ports from the road and test before.
(In reply to Bjoern A. Zeeb from comment #44) I can commit it in an hour.
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/ports/commit/?id=971606f3493fbbc77c156ab84243ab952d89a81b commit 971606f3493fbbc77c156ab84243ab952d89a81b Author: Bjoern A. Zeeb <bz@FreeBSD.org> AuthorDate: 2025-09-26 21:10:08 +0000 Commit: Nuno Teixeira <eduardo@FreeBSD.org> CommitDate: 2025-09-26 21:19:14 +0000 graphics/nvidia-drm-{61,66}-kmod{,-devel}: Fix runtime regression after commit ac934345a14f PR: 289647 Fixes: ac934345a14f (Update distinfo after drm-{61,66}-kmod updates) graphics/nvidia-drm-61-kmod-devel/Makefile | 2 +- graphics/nvidia-drm-61-kmod/Makefile | 2 +- ...tch-nvidia-drm-freebsd-lkpi.c-20250918-01 (new) | 47 ++++++++++++++++++++++ graphics/nvidia-drm-66-kmod-devel/Makefile | 2 +- graphics/nvidia-drm-66-kmod/Makefile | 2 +- ...tch-nvidia-drm-freebsd-lkpi.c-20250918-01 (new) | 47 ++++++++++++++++++++++ 6 files changed, 98 insertions(+), 4 deletions(-)
Committed, thanks. I will leave PR open.
(In reply to Nuno Teixeira from comment #47) Thanks!
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=52ce810302f70cc7b995651eb1b19adfa014b351 commit 52ce810302f70cc7b995651eb1b19adfa014b351 Author: Bjoern A. Zeeb <bz@FreeBSD.org> AuthorDate: 2025-09-29 23:10:10 +0000 Commit: Bjoern A. Zeeb <bz@FreeBSD.org> CommitDate: 2025-09-29 23:16:51 +0000 UPDATING: bump __FreeBSD_version for drm-kmod/nvidia-drm vs. LinuxLPI Both drm-kmod and nvidia-drm were updated to keep compiling and/or working after the latest LinuxKPI PCI changes. Some of what should have worked for a long time but did not or conflicted was hidden behind native PCI calls instead of using LinuxKPI. We cleaned this up. Bump __FreeBSD_version so that users will get the updated packages. MFC after: 3 days PR: 289647 UPDATING | 7 +++++++ sys/sys/param.h | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-)
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=123c2dc6e15a62ceba3469caf0f1a6801214a7d3 commit 123c2dc6e15a62ceba3469caf0f1a6801214a7d3 Author: Bjoern A. Zeeb <bz@FreeBSD.org> AuthorDate: 2025-09-29 21:29:17 +0000 Commit: Bjoern A. Zeeb <bz@FreeBSD.org> CommitDate: 2025-09-29 23:16:18 +0000 Reapply "LinuxKPI: pci: allocate entire pci_dev hiereachy up to root port on attach" In linux_pci_attach_device() allocate a LinuxKPI pci_dev for each device in the hierarchy up to the root port[1] as we cannot do that later on demand as we may be in a context where we may not sleep. Take special care of DRM as there is a non-PCI device in the chain which needs to be skipped. iwlwifi(4) can hit this case called from a callout. While here leave a comment sa the cleanup order of linux_pci_attach_device() needs correction seperately. This reverts commit 3860afe99ec39b9942967941181f28f27f3fc548. Sponsored by: The FreeBSD Foundation (initially) PR: 283027 PR: 289647 Suggested by: jhb [1] MFC after: 3 days Reviewed by: dumbbell Differential Revision: https://reviews.freebsd.org/D52069 sys/compat/linuxkpi/common/src/linux_pci.c | 47 +++++++++++++++++++++++++----- 1 file changed, 40 insertions(+), 7 deletions(-)
Anyone running main, if you update now after the __FreeBSD_version bump to 1600001, can you confirm all still works?
(In reply to Bjoern A. Zeeb from comment #51) We kill the version check routine in upstream tarball to disallow building on main in generic way like below. # We should support -CURRENT: kill the check (first #if __FreeBSD_version) linenum=$$(${SED} -ne '/^#if __FreeBSD_version/ { = ; q ; }' \ ${WRKSRC}/src/${NVSRC}/nv-freebsd.h) ; ${REINPLACE_CMD} \ -e "$$linenum,+2d" ${WRKSRC}/src/${NVSRC}/nv-freebsd.h This is in the Makefile of x11/nvidia-driver (would move to x11/nvidia-kmod once review D52178 lands). https://cgit.freebsd.org/ports/tree/x11/nvidia-driver/Makefile#n181 So it should still work (I cannot take time to switch to main recently, though) unless some KPI breakages are introduced.
A commit in branch stable/15 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=a38672e64a1ce9a156d1888ffc505252da3e4cf1 commit a38672e64a1ce9a156d1888ffc505252da3e4cf1 Author: Bjoern A. Zeeb <bz@FreeBSD.org> AuthorDate: 2025-09-29 23:10:10 +0000 Commit: Bjoern A. Zeeb <bz@FreeBSD.org> CommitDate: 2025-09-30 22:20:36 +0000 UPDATING: bump __FreeBSD_version for drm-kmod/nvidia-drm vs. LinuxKPI Both drm-kmod and nvidia-drm were updated to keep compiling and/or working after the latest LinuxKPI PCI changes. Some of what should have worked for a long time but did not or conflicted was hidden behind native PCI calls instead of using LinuxKPI. We cleaned this up. Bump __FreeBSD_version so that users will get the updated packages. PR: 289647 (cherry picked from commit 52ce810302f70cc7b995651eb1b19adfa014b351) UPDATING | 7 +++++++ sys/sys/param.h | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-)
A commit in branch stable/15 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=d8972ad2f6e7113d779d4ec975ce32552030b2a3 commit d8972ad2f6e7113d779d4ec975ce32552030b2a3 Author: Bjoern A. Zeeb <bz@FreeBSD.org> AuthorDate: 2025-09-04 20:22:00 +0000 Commit: Bjoern A. Zeeb <bz@FreeBSD.org> CommitDate: 2025-09-30 21:45:28 +0000 LinuxKPI: pci: allocate entire pci_dev hiereachy up to root port on attach In linux_pci_attach_device() allocate a LinuxKPI pci_dev for each device in the hierarchy up to the root port[1] as we cannot do that later on demand as we may be in a context where we may not sleep. Take special care of DRM as there is a non-PCI device in the chain which needs to be skipped. iwlwifi(4) can hit this case called from a callout. While here leave a comment as the cleanup order of linux_pci_attach_device() needs correction seperately. Sponsored by: The FreeBSD Foundation (initially) PR: 283027 PR: 289647 Suggested by: jhb [1] Reviewed by: dumbbell Differential Revision: https://reviews.freebsd.org/D52069 (cherry picked from commit bbeeb585315645db20118ef349a4e3dc83b148cc) (cherry picked from commit 3860afe99ec39b9942967941181f28f27f3fc548) (cherry picked from commit 123c2dc6e15a62ceba3469caf0f1a6801214a7d3) sys/compat/linuxkpi/common/src/linux_pci.c | 47 +++++++++++++++++++++++++----- 1 file changed, 40 insertions(+), 7 deletions(-)
(In reply to Tomoaki AOKI from comment #52) Now also in stable/15 in case that is an option for someone (else) to test.
(In reply to Bjoern A. Zeeb from comment #55) I think it should be safe as I already noted on Comment32.
It looks like all fixes were committed. Is there anything left to do on this issue?
(In reply to Jean-Sébastien Pédron from comment #57) In theory not, in practise I was still hoping someone would confirm it all works after the LinuxKPI changes also went in. I'll take the PR, close it and if someone hits the problem (again) they can re-open. Oh and I still have to MFC LinuxKPI to 14... but that'll only happen in a longer while.
(In reply to Jean-Sébastien Pédron from comment #57) Just waiting a while to see whether anyone still affected pops in or not. Especially for multi GPU (SLI and so on) cases and passed through (on bhyve or any other VMs) cases which I don't have and cannot test.
(In reply to Bjoern A. Zeeb from comment #58) Working fine for me on stable/15 at commit ports 0cd22970019e2efa5e98ad5671c454bd420a51e1, amd64. This should be after your MFC of LinuxKPI codes. But I was just waiting to see whether someone bitten by edge cases we're overlooking pops in or not.
A commit in branch stable/14 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=2f4700c4dc1598c1b99996412a932764d5cbac45 commit 2f4700c4dc1598c1b99996412a932764d5cbac45 Author: Bjoern A. Zeeb <bz@FreeBSD.org> AuthorDate: 2025-09-04 20:22:00 +0000 Commit: Bjoern A. Zeeb <bz@FreeBSD.org> CommitDate: 2026-01-16 19:37:50 +0000 LinuxKPI: pci: allocate entire pci_dev hiereachy up to root port on attach In linux_pci_attach_device() allocate a LinuxKPI pci_dev for each device in the hierarchy up to the root port[1] as we cannot do that later on demand as we may be in a context where we may not sleep. Take special care of DRM as there is a non-PCI device in the chain which needs to be skipped. iwlwifi(4) can hit this case called from a callout. While here leave a comment as the cleanup order of linux_pci_attach_device() needs correction seperately. Sponsored by: The FreeBSD Foundation (initially) PR: 283027 PR: 289647 Suggested by: jhb [1] Reviewed by: dumbbell Differential Revision: https://reviews.freebsd.org/D52069 (cherry picked from commit bbeeb585315645db20118ef349a4e3dc83b148cc) (cherry picked from commit 3860afe99ec39b9942967941181f28f27f3fc548) (cherry picked from commit 123c2dc6e15a62ceba3469caf0f1a6801214a7d3) (cherry picked from commit d8972ad2f6e7113d779d4ec975ce32552030b2a3) sys/compat/linuxkpi/common/src/linux_pci.c | 47 +++++++++++++++++++++++++----- 1 file changed, 40 insertions(+), 7 deletions(-)