Bug 289647 - graphics/drm-61-kmod: X11 with nvidia-drm-61-kmod fails to start after commit ac934345a14f
Summary: graphics/drm-61-kmod: X11 with nvidia-drm-61-kmod fails to start after commit...
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Bjoern A. Zeeb
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-09-16 14:11 UTC by Tomoaki AOKI
Modified: 2026-01-16 19:42 UTC (History)
14 users (show)

See Also:
kbowling: maintainer-feedback+


Attachments
Full Xorg.0.log on error (13.21 KB, text/plain)
2025-09-16 14:34 UTC, Tomoaki AOKI
no flags Details
Result of sysctl -a | grep hw.dri (successful case, with previous version) (1.20 KB, text/plain)
2025-09-16 16:46 UTC, Tomoaki AOKI
no flags Details
Result of sysctl -a | grep hw.dri (faulty case, with previous version) (1.25 KB, text/plain)
2025-09-17 11:00 UTC, Tomoaki AOKI
no flags Details
Full devinfo -v on successful case (20.01 KB, text/plain)
2025-09-17 22:01 UTC, Tomoaki AOKI
no flags Details
Full pciconf -l on successful case (2.68 KB, text/plain)
2025-09-17 22:03 UTC, Tomoaki AOKI
no flags Details
Check "nvidia" in the computation of "isdrm" (580 bytes, patch)
2025-09-18 07:47 UTC, Jean-Sébastien Pédron
dumbbell: maintainer-approval+
Details | Diff
Patch for pdrv against nvidia-drm-66 (1.68 KB, patch)
2025-09-18 09:19 UTC, Bjoern A. Zeeb
no flags Details | Diff
nvidia-drm-6.1 patch for linuxkpi pdrv (1.64 KB, patch)
2025-09-18 20:08 UTC, Bjoern A. Zeeb
no flags Details | Diff
Xorg.0.log (39.48 KB, application/x-trash)
2025-09-20 22:03 UTC, Pouria Mousavizadeh Tehrani
no flags Details
Made Bjoern's patch into committable form. (4.94 KB, patch)
2025-09-23 14:08 UTC, Tomoaki AOKI
junchoon: maintainer-approval? (x11)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tomoaki AOKI 2025-09-16 14:11:45 UTC
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)
Comment 1 Gleb Popov freebsd_committer freebsd_triage 2025-09-16 14:30:34 UTC
Adding Austin to CC.
Comment 2 Mark Linimon freebsd_committer freebsd_triage 2025-09-16 14:34:16 UTC
^Triage: Cc: committer.
Comment 3 Tomoaki AOKI 2025-09-16 14:34:28 UTC
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.
Comment 4 Bjoern A. Zeeb freebsd_committer freebsd_triage 2025-09-16 16:11:05 UTC
(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.
Comment 5 Jean-Sébastien Pédron freebsd_committer freebsd_triage 2025-09-16 16:17:30 UTC
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.
Comment 6 Tomoaki AOKI 2025-09-16 16:46:09 UTC
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.
Comment 7 Bjoern A. Zeeb freebsd_committer freebsd_triage 2025-09-16 20:39:55 UTC
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.
Comment 8 Tomoaki AOKI 2025-09-16 21:46:58 UTC
(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
Comment 9 Tomoaki AOKI 2025-09-17 11:00:38 UTC
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
Comment 10 Jean-Sébastien Pédron freebsd_committer freebsd_triage 2025-09-17 17:45:30 UTC
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
    ...
Comment 11 Bjoern A. Zeeb freebsd_committer freebsd_triage 2025-09-17 18:03:03 UTC
(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.
Comment 12 Tomoaki AOKI 2025-09-17 21:58:29 UTC
(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

     ...
Comment 13 Tomoaki AOKI 2025-09-17 22:01:59 UTC
Created attachment 263896 [details]
Full devinfo -v on successful case

I'll try faulty case hopefully tonight (JST).
Comment 14 Tomoaki AOKI 2025-09-17 22:03:46 UTC
Created attachment 263897 [details]
Full pciconf -l on successful case

Will try for faulty case (hopefully) tonight (JST).
Comment 15 Bjoern A. Zeeb freebsd_committer freebsd_triage 2025-09-17 22:06:49 UTC
(In reply to Tomoaki AOKI from comment #14)

no need for pciconf as that is hopefully not to change ;-)
Comment 16 Jean-Sébastien Pédron freebsd_committer freebsd_triage 2025-09-18 07:47:58 UTC
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?
Comment 17 Tomoaki AOKI 2025-09-18 09:09:44 UTC
(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.
Comment 18 Tomoaki AOKI 2025-09-18 09:14:30 UTC
(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.
Comment 19 Bjoern A. Zeeb freebsd_committer freebsd_triage 2025-09-18 09:14:40 UTC
(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 20 Jean-Sébastien Pédron freebsd_committer freebsd_triage 2025-09-18 09:19:32 UTC
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 :-)
Comment 21 Bjoern A. Zeeb freebsd_committer freebsd_triage 2025-09-18 09:19:36 UTC
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 22 Bjoern A. Zeeb freebsd_committer freebsd_triage 2025-09-18 09:21:16 UTC
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?
Comment 23 Tomoaki AOKI 2025-09-18 13:29:20 UTC
(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
Comment 24 Bjoern A. Zeeb freebsd_committer freebsd_triage 2025-09-18 20:08:27 UTC
Created attachment 263910 [details]
nvidia-drm-6.1 patch for linuxkpi pdrv

Updated, should compile now.  For 6.1. this time.
Comment 25 Austin Shafer 2025-09-18 20:33:37 UTC
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?
Comment 26 Bjoern A. Zeeb freebsd_committer freebsd_triage 2025-09-18 20:54:33 UTC
(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?
Comment 27 Austin Shafer 2025-09-18 21:01:14 UTC
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
Comment 28 Bjoern A. Zeeb freebsd_committer freebsd_triage 2025-09-18 21:05:01 UTC
(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 :)
Comment 29 Austin Shafer 2025-09-18 21:20:08 UTC
I can't at the moment, about to step away. If nobody else is able to get to it I hopefully can tomorrow.
Comment 30 Tomoaki AOKI 2025-09-18 23:32:11 UTC
(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.
Comment 31 Bjoern A. Zeeb freebsd_committer freebsd_triage 2025-09-18 23:45:43 UTC
(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.
Comment 32 Tomoaki AOKI 2025-09-19 09:29:53 UTC
(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.
Comment 33 Nuno Teixeira freebsd_committer freebsd_triage 2025-09-19 22:55:08 UTC
Hello,

Just to confirm that patch is working fine on 16 main

hw.dri.0.busid: pci:0000:01:00.0

Thanks!
Comment 34 Adrian Chadd freebsd_committer freebsd_triage 2025-09-20 15:03:36 UTC
hi!

I'll test this soon too.

Do we need suspend/resume methods here as well? for laptops w/ nvidia?
Comment 35 Tomoaki AOKI 2025-09-20 15:38:26 UTC
(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).
Comment 36 Pouria Mousavizadeh Tehrani freebsd_committer freebsd_triage 2025-09-20 22:03:26 UTC
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
Comment 37 Pouria Mousavizadeh Tehrani freebsd_committer freebsd_triage 2025-09-20 22:34:39 UTC
(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 ---
```
Comment 38 Bjoern A. Zeeb freebsd_committer freebsd_triage 2025-09-21 00:05:54 UTC
(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.
Comment 39 Tomoaki AOKI 2025-09-21 00:25:57 UTC
(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?
Comment 40 Pouria Mousavizadeh Tehrani freebsd_committer freebsd_triage 2025-09-21 20:11:13 UTC
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!
Comment 41 Tomoaki AOKI 2025-09-23 14:08:02 UTC
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.
Comment 42 Austin Shafer 2025-09-24 16:37:40 UTC
(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?
Comment 43 Tomoaki AOKI 2025-09-24 22:14:23 UTC
(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?
Comment 44 Bjoern A. Zeeb freebsd_committer freebsd_triage 2025-09-25 09:17:12 UTC
(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.
Comment 45 Nuno Teixeira freebsd_committer freebsd_triage 2025-09-26 21:00:28 UTC
(In reply to Bjoern A. Zeeb from comment #44)

I can commit it in an hour.
Comment 46 commit-hook freebsd_committer freebsd_triage 2025-09-26 21:32:02 UTC
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(-)
Comment 47 Nuno Teixeira freebsd_committer freebsd_triage 2025-09-26 21:35:46 UTC
Committed, thanks.

I will leave PR open.
Comment 48 Tomoaki AOKI 2025-09-27 01:35:18 UTC
(In reply to Nuno Teixeira from comment #47)
Thanks!
Comment 49 commit-hook freebsd_committer freebsd_triage 2025-09-29 23:17:53 UTC
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(-)
Comment 50 commit-hook freebsd_committer freebsd_triage 2025-09-29 23:17:57 UTC
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(-)
Comment 51 Bjoern A. Zeeb freebsd_committer freebsd_triage 2025-09-29 23:19:19 UTC
Anyone running main, if you update now after the __FreeBSD_version bump to 1600001, can you confirm all still works?
Comment 52 Tomoaki AOKI 2025-09-29 23:37:47 UTC
(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.
Comment 53 commit-hook freebsd_committer freebsd_triage 2025-09-30 22:21:51 UTC
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(-)
Comment 54 commit-hook freebsd_committer freebsd_triage 2025-09-30 22:21:55 UTC
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(-)
Comment 55 Bjoern A. Zeeb freebsd_committer freebsd_triage 2025-09-30 22:22:43 UTC
(In reply to Tomoaki AOKI from comment #52)

Now also in stable/15 in case that is an option for someone (else) to test.
Comment 56 Tomoaki AOKI 2025-09-30 23:56:41 UTC
(In reply to Bjoern A. Zeeb from comment #55)
I think it should be safe as I already noted on Comment32.
Comment 57 Jean-Sébastien Pédron freebsd_committer freebsd_triage 2025-10-06 10:06:27 UTC
It looks like all fixes were committed. Is there anything left to do on this issue?
Comment 58 Bjoern A. Zeeb freebsd_committer freebsd_triage 2025-10-06 10:37:30 UTC
(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.
Comment 59 Tomoaki AOKI 2025-10-06 10:42:33 UTC
(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.
Comment 60 Tomoaki AOKI 2025-10-06 10:46:27 UTC
(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.
Comment 61 commit-hook freebsd_committer freebsd_triage 2026-01-16 19:42:34 UTC
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(-)