Page MenuHomeFreeBSD

linuxkpi: Handle bin attributes in sysfs attribute groups
Needs ReviewPublic

Authored by dumbbell on Sun, Feb 8, 10:56 AM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Mar 2, 3:49 PM
Unknown Object (File)
Mon, Mar 2, 3:49 PM
Unknown Object (File)
Mon, Mar 2, 1:36 AM
Unknown Object (File)
Sun, Mar 1, 12:59 PM
Unknown Object (File)
Sat, Feb 28, 11:56 PM
Unknown Object (File)
Fri, Feb 27, 10:32 AM
Unknown Object (File)
Fri, Feb 27, 10:32 AM
Unknown Object (File)
Thu, Feb 26, 1:45 PM

Details

Reviewers
None
Group Reviewers
linuxkpi
Summary

For instance, this is used by DRM drivers to declare the EDID property of an GPU output connector:

sysctl -b sys.device.drmn1.card0.card0-DP-1.edid | edid-decode

...
Block 0, Base EDID:
  EDID Structure Version & Revision: 1.4
  Vendor & Product Identification:
    Manufacturer: SAM
    Model: 29814
    Serial Number: 810635354 (0x3051505a)
    Made in: week 15 of 2025
...

Sponsored by: The FreeBSD Foundation

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

Thanks for adding this. I updated my laptop over the weekend, and drm-kmod failed to build with

/home/jrm/scm/freebsd/drm-kmod/drivers/gpu/drm/drm_sysfs.c:300:3: error: field designator 'bin_attrs' does not refer to any field in type 'const struct attribute_group'
  300 |         .bin_attrs = connector_bin_attrs,
      |         ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

This patch fixes the build error.

I foolishly tried to come up with a patch to fix the build before checking here first. There were a few differences, but I don't really know what I'm doing here.

  1. To match the layout of Linux struct attribute_group, I also added is_bin_visible. It's clearly not required to fix the build, but is that helpful for anything that may initialize is_bin_visible in the future?
  2. Do we need anything in sysfs_remove_group()?

I think this is a minimal, sufficient change. is_bin_visible could be added later if it becomes necessary. I don't think sysfs_remove_group needs anything, in that it doesn't do anything with grp->attrs now, but probably sysfs_unmerge_group does.

sys/compat/linuxkpi/common/include/linux/sysfs.h
449

We're iterating over grp->attrs here, so grp->bin_attrs seems missing.

@dumbbell any updates? @emaste @jrm can we fix this ourselves and commit it if needed? A month of broken master seems unhelpful.

Fixes: https://github.com/freebsd/drm-kmod/issues/416

wulf added inline comments.
sys/compat/linuxkpi/common/include/linux/sysfs.h
449

And attr != NULL check added previously seems missing too

I've reverted d99f16276e06736ceff9ea3ae5a1ac09135bcfdc for now. Let's get this change fixed up and in to src and we can then reapply it.

I've reverted d99f16276e06736ceff9ea3ae5a1ac09135bcfdc for now. Let's get this change fixed up and in to src and we can then reapply it.

Thanks