Page MenuHomeFreeBSD

linuxkpi: Alias `sd` field of `struct kobject`
ClosedPublic

Authored by dumbbell on Jun 14 2026, 9:24 AM.
Referenced Files
Unknown Object (File)
Mon, Sep 7, 10:01 AM
Unknown Object (File)
Sun, Sep 6, 6:42 PM
Unknown Object (File)
Sat, Sep 5, 8:04 PM
Unknown Object (File)
Fri, Sep 4, 9:10 PM
Unknown Object (File)
Fri, Sep 4, 9:04 PM
Unknown Object (File)
Fri, Sep 4, 4:51 PM
Unknown Object (File)
Fri, Sep 4, 5:01 AM
Unknown Object (File)
Thu, Sep 3, 1:06 AM
Subscribers

Details

Summary

On Linux, a struct kernfs_node * pointer, representing a directory in sysfs, is kept in the sd struct field.

We don't have that on FreeBSD because we use sysctls instead. Let's alias the sysctl OID pointer to sd using an union.

This pointer is checked by the DRM drivers using:

if (var->kobj.sd) {
    ...
}

The amdgpu DRM driver started to use these checks in Linux 6.13.

This is part of the update of DRM drivers to Linux 6.13.

Sponsored by: The FreeBSD Foundation

Diff Detail

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

Event Timeline

bz added a subscriber: bz.

No objections though I don't use that part of ... and hope the checks will hold up in the future.

sys/compat/linuxkpi/common/include/linux/kobject.h
70

One day we should probably fix this -- would be a nice GSoC project next year?

This revision is now accepted and ready to land.Sat, Sep 5, 9:54 AM
dumbbell added inline comments.
sys/compat/linuxkpi/common/include/linux/kobject.h
70

Yes, I would love to have proper sysfs support. This would improve compatibility with Linux: all the libraries that expect sysfs and all the forum posts from people helping other users would be valid for FreeBSD as well.

This revision was automatically updated to reflect the committed changes.
dumbbell marked an inline comment as done.