git: 33ba6077b0f1 - main - linuxkpi: Alias `sd` field of `struct kobject`
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 07 Sep 2026 18:37:21 UTC
The branch main has been updated by dumbbell:
URL: https://cgit.FreeBSD.org/src/commit/?id=33ba6077b0f162091bf0871686304916458420d3
commit 33ba6077b0f162091bf0871686304916458420d3
Author: Jean-Sébastien Pédron <dumbbell@FreeBSD.org>
AuthorDate: 2026-06-12 20:44:43 +0000
Commit: Jean-Sébastien Pédron <dumbbell@FreeBSD.org>
CommitDate: 2026-09-07 18:27:29 +0000
linuxkpi: Alias `sd` field of `struct kobject`
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.
Reviewed by: bz
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D57586
---
sys/compat/linuxkpi/common/include/linux/kobject.h | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/sys/compat/linuxkpi/common/include/linux/kobject.h b/sys/compat/linuxkpi/common/include/linux/kobject.h
index 3d053212f94e..cce604bdfb4e 100644
--- a/sys/compat/linuxkpi/common/include/linux/kobject.h
+++ b/sys/compat/linuxkpi/common/include/linux/kobject.h
@@ -60,7 +60,22 @@ struct kobject {
struct kref kref;
const struct kobj_type *ktype;
struct list_head entry;
- struct sysctl_oid *oidp;
+ union {
+ struct sysctl_oid *oidp;
+
+ /*
+ * 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`. This
+ * pointer is checked by the DRM drivers using:
+ * if (var->kobj.sd) {
+ * ...
+ * }
+ */
+ void *sd;
+ };
struct kset *kset;
};