Page MenuHomeFreeBSD

LinuxKPI: acpi: provide union [linuxkpi]_acpi_(object|buffer)
ClosedPublic

Authored by bz on Jun 15 2025, 11:01 AM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Jul 16, 2:56 AM
Unknown Object (File)
Wed, Jul 9, 8:30 PM
Unknown Object (File)
Mon, Jul 7, 1:59 AM
Unknown Object (File)
Sat, Jul 5, 2:58 PM
Unknown Object (File)
Sat, Jul 5, 5:23 AM
Unknown Object (File)
Fri, Jul 4, 8:28 PM
Unknown Object (File)
Fri, Jul 4, 9:10 AM
Unknown Object (File)
Fri, Jul 4, 4:05 AM

Details

Summary

Provide union acpi_(object|buffer) as linuxkpi_ versions and in Linux
native lower case spelling so that driver code compiles unmodified.

Use the linuxkpi_ prefix to avoid name clashes with the native ACPI
implementation which uses CamelCase.

Use the linuxkpi_ names internally and redefine the linuxkpi_ unions
to their native names so they are avail as expected in drivers.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 65100
Build 61983: arc lint + arc unit

Event Timeline

bz requested review of this revision.Jun 15 2025, 11:01 AM
dumbbell added a subscriber: dumbbell.

Looks good to me!

This revision is now accepted and ready to land.Jun 15 2025, 5:01 PM
wulf requested changes to this revision.EditedJun 15 2025, 5:17 PM
wulf added a subscriber: wulf.

General convention in at least drm-kmod is to not redefine ACPICA objects if it is possible. Porting of this code is mostly just a changing of symbol case and adding/removing of underscores. drm-kmod does not even guards these changes with #ifdefs

This revision now requires changes to proceed.Jun 15 2025, 5:17 PM

General convention in at least drm-kmod is to not redefine ACPICA objects if it is possible. Porting of this code is mostly just a changing of symbol case and adding/removing of underscores. drm-kmod does not even guards these changes with #ifdefs

I picked a random file ( in v6.6 drivers/gpu/drm/radeon/radeon_acpi.c ) and it seems everything there got CamelCased without any #ifdefs. It's just an unnecessary diff to vendor and maintenance.

No idea how much of this was done in drm-kmod but I am not going to rewrite case in entire files because of this. I had not compiled files or #ifdef'ed out the entire logic. Not gong to fly anymore. Remove the #ifdefs from drm-kmod and reduce the diff to upstream and make maintenance easier by having one place to edit and not 117. That's what LinuxKPI is for.

In D50863#1161012, @bz wrote:

General convention in at least drm-kmod is to not redefine ACPICA objects if it is possible. Porting of this code is mostly just a changing of symbol case and adding/removing of underscores. drm-kmod does not even guards these changes with #ifdefs

I picked a random file ( in v6.6 drivers/gpu/drm/radeon/radeon_acpi.c ) and it seems everything there got CamelCased without any #ifdefs. It's just an unnecessary diff to vendor and maintenance.

No idea how much of this was done in drm-kmod but I am not going to rewrite case in entire files because of this. I had not compiled files or #ifdef'ed out the entire logic. Not gong to fly anymore. Remove the #ifdefs from drm-kmod and reduce the diff to upstream and make maintenance easier by having one place to edit and not 117. That's what LinuxKPI is for.

Yes, I need to spend some time to expand linuxkpi so that we can get rid of all these ifdefs in drm-kmod.

In D50863#1161012, @bz wrote:

General convention in at least drm-kmod is to not redefine ACPICA objects if it is possible. Porting of this code is mostly just a changing of symbol case and adding/removing of underscores. drm-kmod does not even guards these changes with #ifdefs

I picked a random file ( in v6.6 drivers/gpu/drm/radeon/radeon_acpi.c ) and it seems everything there got CamelCased without any #ifdefs. It's just an unnecessary diff to vendor and maintenance.

No idea how much of this was done in drm-kmod but I am not going to rewrite case in entire files because of this. I had not compiled files or #ifdef'ed out the entire logic. Not gong to fly anymore. Remove the #ifdefs from drm-kmod and reduce the diff to upstream and make maintenance easier by having one place to edit and not 117. That's what LinuxKPI is for.

Yes, I need to spend some time to expand linuxkpi so that we can get rid of all these ifdefs in drm-kmod.

Can you point me at some of these ACPI #ifdefs?

In D50863#1161012, @bz wrote:

General convention in at least drm-kmod is to not redefine ACPICA objects if it is possible. Porting of this code is mostly just a changing of symbol case and adding/removing of underscores. drm-kmod does not even guards these changes with #ifdefs

I picked a random file ( in v6.6 drivers/gpu/drm/radeon/radeon_acpi.c ) and it seems everything there got CamelCased without any #ifdefs. It's just an unnecessary diff to vendor and maintenance.

No idea how much of this was done in drm-kmod but I am not going to rewrite case in entire files because of this. I had not compiled files or #ifdef'ed out the entire logic. Not gong to fly anymore. Remove the #ifdefs from drm-kmod and reduce the diff to upstream and make maintenance easier by having one place to edit and not 117. That's what LinuxKPI is for.

There is no #ifdefs in drm-kmod. Just a trivial changing of cases in couple of files. I am afraid, you are trying to open a can of worms with introduction of ACPICA wrappers.

Proper compat symbols will also make future ports easier

In D50863#1161016, @imp wrote:

Proper compat symbols will also make future ports easier

It is not about of proper symbols. It is about of adding of LKPI objects which differs only in character case in the name

In D50863#1161016, @imp wrote:

Proper compat symbols will also make future ports easier

It is not about of proper symbols. It is about of adding of LKPI objects which differs only in character case in the name

Which is just as trivial to paper over with #defines so you don't have to change it next time which makes future ports faster since you don't have to detour around already solved trivial problems. When I've done it for other things in the tree, it's helped prevent death of a thousand cuts...

In D50863#1161018, @imp wrote:
In D50863#1161016, @imp wrote:

Proper compat symbols will also make future ports easier

It is not about of proper symbols. It is about of adding of LKPI objects which differs only in character case in the name

Which is just as trivial to paper over with #defines so you don't have to change it next time which makes future ports faster since you don't have to detour around already solved trivial problems. When I've done it for other things in the tree, it's helped prevent death of a thousand cuts...

Until something in object you have mirrored in other case is changed.

As number of object types we handle in LKPI does not exceed 10 it may counts as not a rewrite of ACPICA

This revision is now accepted and ready to land.Jun 15 2025, 6:13 PM

Update the change to not break drm-kmod on all supported branches right away.

Go the extra mile to add a preprocessor condition to switch between the current
native FreeBSD-ish implementation and (if enabled) to the Linux ACPI spellings
(the new version becomes opt-in for now).

The suggestion is to commit this with a FreeBSD_verion bump to main.
MFC it to stable/14 with another
FreeBSD_version bump.

Then the supproted drm-kmod branches can be cleaned up conditionally based on
__FreeBSD_version checks and setting LINUXKPI_WANT_LINUX_ACPI for the proper
Linux way. Once it's all done we'll remove the #ifdefs from base LinuxKPI
and should be good.

Sorry for these extra hoops but the unconditional in-place editing in drm-kmod
either means to break drm-kmod or go the extra mile to fix it now and forever
and no new version should have that problem and diff to upstream anymore.

I've compile amd64, arm64, and i386 universe for 5.15-lts, 6.1-lts, and
6.6-lts andeven posted a silly unbreak LINT change for the latter [1].

[1] https://github.com/freebsd/drm-kmod/issues/354

This revision now requires review to proceed.Thu, Jun 26, 8:38 AM
This revision is now accepted and ready to land.Sun, Jun 29, 6:02 PM