From: Dave Jiang <dave.jiang@intel.com>
To: "Rafael J. Wysocki" <rafael@kernel.org>,
Sam Edwards <cfsworks@gmail.com>
Cc: Linus Walleij <linus.walleij@linaro.org>,
Len Brown <lenb@kernel.org>,
Robert Moore <robert.moore@intel.com>,
Jonathan Cameron <Jonathan.Cameron@huawei.com>,
Dan Williams <dan.j.williams@intel.com>,
Hanjun Guo <guohanjun@huawei.com>, Arnd Bergmann <arnd@arndb.de>,
"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
<linux-acpi@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH] ACPI: acenv: Permit compilation from within the kernel
Date: Mon, 20 Nov 2023 09:19:14 -0700 [thread overview]
Message-ID: <41160dbf-d8c8-4dc0-9fda-42cc97df5b77@intel.com> (raw)
In-Reply-To: <CAJZ5v0idWdJq3JSqQWLG5q+b+b=zkEdWR55rGYEoxh7R6N8kFQ@mail.gmail.com>
On 11/20/23 08:46, Rafael J. Wysocki wrote:
> On Tue, Nov 14, 2023 at 7:09 PM Sam Edwards <cfsworks@gmail.com> wrote:
>>
>> On 11/13/23 16:08, Linus Walleij wrote:
>>> After commit a103f46633fd the kernel stopped compiling for
>>> several ARM32 platforms that I am building with a bare metal
>>> compiler. Bare metal compilers (arm-none-eabi-) don't
>>> define __linux__.
>>
>> Hi Linus,
>>
>> I saw the same baremetal-compiler error here on the ARM64 side of the
>> fence, and narrowed the problem to the same commit as you.
>>
>>>
>>> This is because the header <acpi/platform/acenv.h> is now
>>> in the include path for <linux/irq.h>:
>>
>> More generally, I think it's because of this addition to linux/acpi.h:
>> +#include <linux/fw_table.h>
>>
>> linux/acpi.h is supposed to ensure _LINUX is defined (if it isn't
>> already done by a non-baremetal compiler) before we start pulling in
>> ACPICA includes, so that ACPICA knows the platform. But because
>> fw_table.h contains:
>> #include <linux/acpi.h>
>> #include <acpi/acpi.h>
>>
>> ...the circular include does nothing (linux/acpi.h's include guard stops
>> the include before _LINUX is defined) and we end up pulling in
>> acpi/acpi.h before we're ready.
Not including either causes compile errors for me. And directly including acpi/acpi.h w/o linux/acpi.h causes triggering the #error and some other stuff:
./include/acpi/platform/aclinux.h:18:2: error: #error "Please don't include <acpi/acpi.h> directly, include <linux/acpi.h> instead."
18 | #error "Please don't include <acpi/acpi.h> directly, include <linux/acpi.h> instead."
| ^~~~~
Only including linux/acpi.h:
In file included from ./include/linux/acpi.h:18,
from init/main.c:30:
./include/linux/fw_table.h:32:37: error: field ‘common’ has incomplete type
32 | struct acpi_subtable_header common;
| ^~~~~~
./include/linux/fw_table.h:33:36: error: field ‘hmat’ has incomplete type
33 | struct acpi_hmat_structure hmat;
| ^~~~
./include/linux/fw_table.h:34:40: error: field ‘prmt’ has incomplete type
34 | struct acpi_prmt_module_header prmt;
| ^~~~
./include/linux/fw_table.h:35:33: error: field ‘cedt’ has incomplete type
35 | struct acpi_cedt_header cedt;
| ^~~~
>
> Yes, that's the problem AFAICS. Dave?
>
> What about moving the fw_table.h include in linux/acpi.h below the
> mutex.h one, along with the EXPORT_SYMBOL_ACPI_LIB-related
> definitions?
This builds cleanly for me.
>
> BTW, I'm not really sure why fw_table.h needs to include both
> linux/acpi.h and acpi/acpi.h, because it should get the latter through
> the former anyway.
>
>>>
>>> CC arch/arm/kernel/irq.o
>>> CC kernel/sysctl.o
>>> CC crypto/api.o
>>> In file included from ../include/acpi/acpi.h:22,
>>> from ../include/linux/fw_table.h:29,
>>> from ../include/linux/acpi.h:18,
>>> from ../include/linux/irqchip.h:14,
>>> from ../arch/arm/kernel/irq.c:25:
>>> ../include/acpi/platform/acenv.h:218:2: error: #error Unknown target environment
>>> 218 | #error Unknown target environment
>>> | ^~~~~
>>>
>>> One solution to make compilation with a bare metal compiler
>>> work again is to say the file is used with Linux from within
>>> the kernel if __KERNEL__ is defined so I did that.
>>
>> I am not an ACPI subsystem maintainer, but my understanding is that the
>> files in include/acpi/ are copied verbatim from ACPICA, so any change to
>> those files will have to be sent to the ACPICA project and wouldn't be
>> accepted here.
>
> There are exceptions, but generally you are right.
>
>> More likely, we'd want to do something about the circular-include
>> situation between linux/fw_table.h<->linux/acpi.h. That may have further
>> consequences down the road than just our problem here. Perhaps just
>> dropping both #includes from fw_table.h, and lowering the fw_table.h
>> include from within linux/acpi.h to be below <acpi/acpi.h>, is the way
>> to go?
>
> Something like that.
next prev parent reply other threads:[~2023-11-20 16:19 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-13 23:08 Linus Walleij
2023-11-14 18:09 ` Sam Edwards
2023-11-14 20:20 ` Linus Walleij
2023-11-20 15:25 ` Sam Protsenko
2023-11-20 15:46 ` Rafael J. Wysocki
2023-11-20 16:19 ` Dave Jiang [this message]
2023-11-20 16:38 ` Rafael J. Wysocki
2023-11-20 16:53 ` Dave Jiang
2023-11-21 13:32 ` Linus Walleij
2023-11-21 16:01 ` Dave Jiang
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=41160dbf-d8c8-4dc0-9fda-42cc97df5b77@intel.com \
--to=dave.jiang@intel.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=arnd@arndb.de \
--cc=cfsworks@gmail.com \
--cc=dan.j.williams@intel.com \
--cc=guohanjun@huawei.com \
--cc=lenb@kernel.org \
--cc=linus.walleij@linaro.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rafael.j.wysocki@intel.com \
--cc=rafael@kernel.org \
--cc=robert.moore@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
all inboxes | Powered by JetHome®