Page MenuHomeFreeBSD

linuxkpi: Add device under parent, not under class
ClosedPublic

Authored by dumbbell on Feb 8 2026, 10:55 AM.
Referenced Files
F171583901: D55175.diff
Fri, Sep 11, 10:06 PM
F171553212: D55175.id186302.diff
Fri, Sep 11, 5:39 PM
F171552469: D55175.id171443.diff
Fri, Sep 11, 5:33 PM
Unknown Object (File)
Wed, Sep 9, 7:23 AM
Unknown Object (File)
Tue, Sep 8, 10:39 PM
Unknown Object (File)
Fri, Sep 4, 10:08 PM
Unknown Object (File)
Fri, Sep 4, 7:25 PM
Unknown Object (File)
Wed, Sep 2, 7:27 AM
Subscribers

Details

Summary

In device_add(), the function used to add the given device under its class. This is used to build a sysctl tree. We ended up with devices or "pseudo" devices (like the output connectors of a GPU). For example with an output connector:

sysctl sys.class.drm.card0-DP-1

This device should be added under its parent if it has one. With this fix, the same output connector is now:

sysctl sys.device.drmn1.card0.card0-DP-1

Sponsored by: The FreeBSD Foundation

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

I dislike this idea.
The sysctl sys.class.drm.card0-DP-1 path matches Linux while sysctl sys.device.drmn1.card0.card0-DP-1 not

Here is an example on a computer running Linux 6.18:

# ls -l /sys/class/drm
total 0
lrwxrwxrwx 1 root root    0  9 mars   2026 card0 -> ../../devices/pci0000:00/0000:00:08.1/0000:17:00.0/drm/card0
lrwxrwxrwx 1 root root    0  9 mars   2026 card0-DP-3 -> ../../devices/pci0000:00/0000:00:08.1/0000:17:00.0/drm/card0/card0-DP-3
lrwxrwxrwx 1 root root    0  9 mars   2026 card0-DP-4 -> ../../devices/pci0000:00/0000:00:08.1/0000:17:00.0/drm/card0/card0-DP-4
lrwxrwxrwx 1 root root    0  9 mars   2026 card0-DP-5 -> ../../devices/pci0000:00/0000:00:08.1/0000:17:00.0/drm/card0/card0-DP-5
lrwxrwxrwx 1 root root    0  9 mars   2026 card0-HDMI-A-3 -> ../../devices/pci0000:00/0000:00:08.1/0000:17:00.0/drm/card0/card0-HDMI-A-3
...

So the correct path on Linux is /sys/devices/pci0000:00/0000:00:08.1/0000:17:00.0/drm/card0/card0-DP-3. The difference with my proposal is that they use the PCI address (pci0000:00/0000:00:08.1/0000:17:00.0/drm), and here, we have the device name (drmn0). The other difference is that they use plural for "devices" while we use the singular "device".

The file in /sys/class/drm/... is a symlink to /sys/devices/....

I don’t find the use of /sys/class/drm logical, as the connector should be a child of the device, not a class.

Let’s collect other opinions :-)

I have no opinion but a question: what uses this sysctl or is it purely for information?

I’m not sure anything uses it from the Ports tree as all applications and librairies will certainly be designed around sysfs.

I personnaly use it to determine which display is connected to the computer. This is useful to change my window manager configuration between the laptop’s display and my external monitor.

I like the fact that it now should drmn<n> .

The real answer to the problem is sysfs.

This revision is now accepted and ready to land.Mon, Sep 7, 7:08 PM