Page MenuHomeFreeBSD

linuxkpi: Add device under parent, not under class
Needs ReviewPublic

Authored by dumbbell on Feb 8 2026, 10:55 AM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Mar 18, 1:44 PM
Unknown Object (File)
Fri, Mar 13, 11:39 AM
Unknown Object (File)
Fri, Mar 13, 11:39 AM
Unknown Object (File)
Feb 28 2026, 1:40 AM
Unknown Object (File)
Feb 26 2026, 1:45 PM
Unknown Object (File)
Feb 25 2026, 10:43 PM
Unknown Object (File)
Feb 24 2026, 5:50 AM
Unknown Object (File)
Feb 22 2026, 5:56 AM
Subscribers

Details

Reviewers
None
Group Reviewers
linuxkpi
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

Lint
Lint Skipped
Unit
Tests Skipped

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 :-)