Page MenuHomeFreeBSD

LinuxKPI: Create `linux/util_macros.h`
AcceptedPublic

Authored by siri_racha.ca on Jun 5 2026, 7:39 AM.
Tags
None
Referenced Files
F164199403: D57465.diff
Wed, Jul 29, 2:14 PM
Unknown Object (File)
Mon, Jul 27, 7:48 AM
Unknown Object (File)
Sun, Jul 26, 3:41 PM
Unknown Object (File)
Sat, Jul 25, 8:19 AM
Unknown Object (File)
Fri, Jul 24, 11:39 PM
Unknown Object (File)
Thu, Jul 23, 9:31 AM
Unknown Object (File)
Thu, Jul 23, 7:23 AM
Unknown Object (File)
Wed, Jul 22, 11:58 AM

Details

Reviewers
emaste
dumbbell
bz
Group Reviewers
linuxkpi
Summary

In new amdgpu patches, the for_each_if macro starts being used. It is defined in linux/util_macros.h. This macro begins being used in the amdgpu driver provided in Linux kernel version 6.12, and 6.14. The macro is gaurded to only be used if LINUXKPI_VERSION is above `

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

siri_racha.ca updated this revision to Diff 179264.
This revision is now accepted and ready to land.Jun 5 2026, 1:41 PM
dumbbell requested changes to this revision.EditedJun 14 2026, 8:22 AM
dumbbell added a subscriber: dumbbell.

for_each_if() already exists in the DRM drivers. It was moved to <linux/util_macros.h> in Linux 6.15 (https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=b2108fc82a0acda34388bff3e3ee3544013b1623). Therefore it will need to be wrapped with:

#if defined(LINUXKPI_VERSION) && LINUXKPI_VERSION >= 61500
#define for_each_if...
#endif

This is to avoid the risk of double definitions when used with DRM drivers from versions before 6.15.

sys/compat/linuxkpi/common/include/linux/pm.h
35 ↗(On Diff #179264)

Linux doesn’t do that, even on e.g. 7.0.

When the macro was moved to <linux/util_macros.h>, <drm/drm_util.h> started to include it directly. There should be no need for this include.

This revision now requires changes to proceed.Jun 14 2026, 8:22 AM
sys/compat/linuxkpi/common/include/linux/pm.h
35 ↗(On Diff #179264)

Oh, I see. I originally made the patch the header wasn't there yet. I'm looking at Linux 6.18.4, and it seems to still include it here. Should I remove the include?

Now guarded so it is only used if LinuxKPI version is abov 61500

siri_racha.ca retitled this revision from LinuxKPI: Create linux/util_macros.h, and add it to linux/pm.h to satisify transitivie include in new amdgpu patches to LinuxKPI: Create `linux/util_macros.h`.Jun 14 2026, 11:35 PM
siri_racha.ca edited the summary of this revision. (Show Details)
dumbbell added inline comments.
sys/compat/linuxkpi/common/include/linux/util_macros.h
34

I believe the second part has reversed logic: for_each_if() should be defined here if LINUXKPI_VERSION >= 61500. Before that, it is defined in <drm/drm_util.h>.

The first part is fine.

This revision now requires changes to proceed.Jun 15 2026, 7:50 AM
siri_racha.ca added inline comments.
sys/compat/linuxkpi/common/include/linux/util_macros.h
34

Should be fixed

This revision is now accepted and ready to land.Sat, Jul 11, 8:24 AM
bz added inline comments.
sys/compat/linuxkpi/common/include/linux/util_macros.h
1
  • no longer needed
2

I cannot remember what @imp said last time if this according to style goes below or if this was to be relaxed again?

9

Do we need the full copy of the license given we have the SPDX?

34

If this is used by drm-kmod 6.12 already why do we only enable it for >= 6.15? Ah I see @dumbbell 's comment. Please make sure the commit message gets adjusted before push!

sys/compat/linuxkpi/common/include/linux/util_macros.h
2

Had a look at style(9) and it says to just do Copyright + "SPDX-License-Identifier: BSD-2-Clause", I'll remove the rest in a bit, I kinda just copied it from another file

34

Will update in next revision, thanks for the catch!!

This revision now requires review to proceed.Mon, Jul 13, 1:14 AM
This revision is now accepted and ready to land.Mon, Jul 13, 7:58 AM
sys/compat/linuxkpi/common/include/linux/util_macros.h
1

While it is still true that the *-* is no longer needed, you can just remove it before committing or leaving it.