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
F163626984: D57465.id181868.diff
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
Unknown Object (File)
Tue, Jul 21, 11:09 PM
Unknown Object (File)
Tue, Jul 21, 6:24 PM
Unknown Object (File)
Tue, Jul 21, 10:26 AM
Unknown Object (File)
Mon, Jul 20, 11:35 PM

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
35

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
35

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
2
  • no longer needed
3

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

10

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

35

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
3

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

35

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
2

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