From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: "Rafael J. Wysocki (Intel)" <rafael@kernel.org>
Cc: Sakari Ailus <sakari.ailus@linux.intel.com>,
linux-media@vger.kernel.org, linux-acpi@vger.kernel.org,
Daniel Scally <dan.scally@ideasonboard.com>,
Hans de Goede <hansg@kernel.org>,
platform-driver-x86@vger.kernel.org
Subject: Re: [PATCH v2 3/5] ACPI: Support __free() from cleanup.h for ACPI objects
Date: Tue, 25 Aug 2026 16:51:10 +0300 (EEST) [thread overview]
Message-ID: <831afa75-ab9f-b54e-a5a5-6b46f4fe26cc@linux.intel.com> (raw)
In-Reply-To: <CAJZ5v0ggPGEu8YQTpeTC6=tVNr1zponkCbs+UQPieAH5k6ngUg@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 4394 bytes --]
On Tue, 25 Aug 2026, Rafael J. Wysocki (Intel) wrote:
> On Tue, Aug 25, 2026 at 3:02 PM Rafael J. Wysocki (Intel)
> <rafael@kernel.org> wrote:
> >
> > On Tue, Aug 25, 2026 at 2:32 PM Ilpo Järvinen
> > <ilpo.jarvinen@linux.intel.com> wrote:
> > >
> > > On Tue, 25 Aug 2026, Rafael J. Wysocki (Intel) wrote:
> > >
> > > > On Tue, Aug 25, 2026 at 2:07 PM Sakari Ailus
> > > > <sakari.ailus@linux.intel.com> wrote:
> > > > >
> > > > > Hi Rafael,
> > > > >
> > > > > On Tue, Aug 25, 2026 at 01:51:18PM +0200, Rafael J. Wysocki (Intel) wrote:
> > > > > > On Mon, Aug 24, 2026 at 11:13 PM Sakari Ailus
> > > > > > <sakari.ailus@linux.intel.com> wrote:
> > > > > > >
> > > > > > > Use DEFINE_FREE() to allow ACPI objects to be released automatically.
> > > > > >
> > > > > > But at least some of them are allocated by ACPICA functions like
> > > > > > acpi_evaluate_object() and so they have no proper constructors.
> > > > >
> > > > > You could still assign the return buffer to a local variable. It's not
> > > > > ideal API-wise though.
> > > >
> > > > Exactly.
> > > >
> > > > > I'm not quite sure what was the point you wanted to make but I reckon this
> > > > > wasn't an ack. :-)
> > > >
> > > > Using the _FREE with variables that are not initialized through a
> > > > constructor is questionable, so this is generally not particularly
> > > > clean.
> > >
> > > The driver does call ACPI_FREE() for that pointer so clearly it's already
> > > using something ending with "_FREE" already. So unless Rafael is
> > > suggesting ACPI_FREE() should be renamed, I'm a bit lost what that
> > > even means on concrete terms.
> >
> > Sorry for the confusion.
> >
> > I just don't want people to do things like this:
> >
> > struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER };
> > union acpi_object *out_obj __free(ACPI_FREE);
> > acpi_status status;
> >
> > status = acpi_evaluate_object(handle, METHOD_NAME, NULL, &output);
> > if (ACPI_FAILURE(status))
> > return AN_ERROR;
> >
> > out_obj = output.pointer;
> >
> > > > There is no cleanup.h in ACPICA that is a more traditional C code
> > > > base, so mixing up ACPICA code, which ACPI_FREE() is strictly
> > > > speaking, with cleanup.h stuff is not particularly straightforward
> > > > IMV. I'd rather not do it.
> > >
> > > Perhaps add the DEFINE_FREE() into int3472 driver then, it seems to be
> > > what intel/pmc is already doing (I don't seem to anymore recall why it was
> > > added there). Using cleanup.h for that variable it clearly simplifies the
> > > code flow.
> >
> > Well, fair enough, but as I said elsewhere, the code flow
> > simplification can also be achieved in a different way.
> >
> > > It feels a bit stupid to duplicate it there but I guess we'll
> > > just have to live with that if there's no place in any acpi related
> > > headers for cleanup.h.
> >
> > If there is a cleanup.h "free" that can only be used with objects
> > returned by acpi_evaluate_dsm_typed(), I'll be fine with that.
> >
> > Or if everyone agrees that doing
> >
> > union acpi_object *out_obj __free(ACPI_FREE) = NULL;
> >
> > is not confusing and fine, I may just say "Hey, I don't care that much".
>
> And particularly there is this paragraph in a comment in cleanup.h:
>
> * Given that the "__free(...) = NULL" pattern for variables defined at
> * the top of the function poses this potential interdependency problem
> * the recommendation is to always define and assign variables in one
> * statement and not group variable definitions at the top of the
> * function when __free() is used.
>
> regarding a broken code example, so I would think that this is not a
> made-up concern.
That comment relates to how defining the variables at the start of
functions may result in wrong/unexpected cleanup order. More imporantly,
the comment is not an argument for not using __free() but an instruction
on what is the correct pattern to use it so those ordering issues do not
occur.
The cleanups will execute in reverse order the variables where defined so
a variable defined at start may be cleaned up only after releasing a lock
that was taken mid-function (which often is safe but one can easily
envision cases where the lock should be still held when the cleanup runs).
--
i.
next prev parent reply other threads:[~2026-08-25 13:51 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-24 21:13 [PATCH v2 0/5] Fix static analyser and compiler warnings in int3472 Sakari Ailus
2026-08-24 21:13 ` [PATCH v2 1/5] platform/x86: int3472: Address Coccinelle warning on an error print Sakari Ailus
2026-08-24 21:13 ` [PATCH v2 2/5] platform/x86: int3472: Fix uninitialised variable warning Sakari Ailus
2026-08-24 21:13 ` [PATCH v2 3/5] ACPI: Support __free() from cleanup.h for ACPI objects Sakari Ailus
2026-08-25 11:51 ` Rafael J. Wysocki (Intel)
2026-08-25 12:07 ` Sakari Ailus
2026-08-25 12:18 ` Rafael J. Wysocki (Intel)
2026-08-25 12:32 ` Ilpo Järvinen
2026-08-25 13:02 ` Rafael J. Wysocki (Intel)
2026-08-25 13:08 ` Rafael J. Wysocki (Intel)
2026-08-25 13:51 ` Ilpo Järvinen [this message]
2026-08-25 14:42 ` Rafael J. Wysocki (Intel)
2026-08-25 19:35 ` Sakari Ailus
2026-08-26 9:04 ` Ilpo Järvinen
2026-08-26 10:17 ` Rafael J. Wysocki (Intel)
2026-08-25 13:37 ` Ilpo Järvinen
2026-08-25 13:49 ` Rafael J. Wysocki (Intel)
2026-08-24 21:13 ` [PATCH v2 4/5] platform/x86: int3472: Release ACPI objects using __free() Sakari Ailus
2026-08-25 11:54 ` Rafael J. Wysocki (Intel)
2026-08-25 12:04 ` Sakari Ailus
2026-08-25 12:32 ` Rafael J. Wysocki (Intel)
2026-08-24 21:13 ` [PATCH v2 5/5] platform/x86: int3472: Clean up GPIO parsing Sakari Ailus
2026-08-25 10:40 ` Ilpo Järvinen
2026-08-25 10:54 ` Sakari Ailus
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=831afa75-ab9f-b54e-a5a5-6b46f4fe26cc@linux.intel.com \
--to=ilpo.jarvinen@linux.intel.com \
--cc=dan.scally@ideasonboard.com \
--cc=hansg@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=platform-driver-x86@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=sakari.ailus@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox