[U-Boot] [PATCH v1 1/4] x86: acpi: Annotate struct acpi_table_header with __packed

GCC starts complaining about possible pointer misalignment of pointers to the unpacked (alignment=4) structures in the packed (alignment=1) ones:
CC arch/x86/cpu/tangier/acpi.o arch/x86/cpu/tangier/acpi.c: In function ‘acpi_create_fadt’: arch/x86/cpu/tangier/acpi.c:22:37: warning: taking address of packed member of ‘struct acpi_fadt’ may result in an unaligned pointer value [-Waddress-of-packed-member] 22 | struct acpi_table_header *header = &(fadt->header);
CC arch/x86/lib/acpi_table.o arch/x86/lib/acpi_table.c: In function ‘acpi_create_spcr’: arch/x86/lib/acpi_table.c:366:37: warning: taking address of packed member of ‘struct acpi_spcr’ may result in an unaligned pointer value [-Waddress-of-packed-member] 366 | struct acpi_table_header *header = &(spcr->header);
Fix the potential issues by annotating embedded structures with __packed even though they are packed naturally.
Signed-off-by: Andy Shevchenko andriy.shevchenko@linux.intel.com --- arch/x86/include/asm/acpi_table.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/include/asm/acpi_table.h b/arch/x86/include/asm/acpi_table.h index 02aea127c1..7588913f93 100644 --- a/arch/x86/include/asm/acpi_table.h +++ b/arch/x86/include/asm/acpi_table.h @@ -34,7 +34,7 @@ struct acpi_rsdp { };
/* Generic ACPI header, provided by (almost) all tables */ -struct acpi_table_header { +struct __packed acpi_table_header { char signature[4]; /* ACPI signature (4 ASCII characters) */ u32 length; /* Table length in bytes (incl. header) */ u8 revision; /* Table version (not ACPI version!) */

Per PCI firmware specification the ACPI has to reserve the memory which is defined as PCI ECAM.
Fixes: 39665beed6f7 ("x86: tangier: Enable ACPI support for Intel Tangier") Signed-off-by: Andy Shevchenko andriy.shevchenko@linux.intel.com --- arch/x86/cpu/tangier/acpi.c | 3 ++- .../include/asm/arch-tangier/acpi/platform.asl | 1 + .../asm/arch-tangier/acpi/southcluster.asl | 17 +++++++++++++++++ arch/x86/include/asm/arch-tangier/iomap.h | 10 ++++++++++ 4 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 arch/x86/include/asm/arch-tangier/iomap.h
diff --git a/arch/x86/cpu/tangier/acpi.c b/arch/x86/cpu/tangier/acpi.c index 61b2642aa9..362e133cf1 100644 --- a/arch/x86/cpu/tangier/acpi.c +++ b/arch/x86/cpu/tangier/acpi.c @@ -14,6 +14,7 @@ #include <asm/mpspec.h> #include <asm/tables.h> #include <asm/arch/global_nvs.h> +#include <asm/arch/iomap.h>
void acpi_create_fadt(struct acpi_fadt *fadt, struct acpi_facs *facs, void *dsdt) @@ -63,7 +64,7 @@ u32 acpi_fill_mcfg(u32 current) /* TODO: Derive parameters from SFI MCFG table */ current += acpi_create_mcfg_mmconfig ((struct acpi_mcfg_mmconfig *)current, - 0x3f500000, 0x0, 0x0, 0x0); + MCFG_BASE_ADDRESS, 0x0, 0x0, 0x0);
return current; } diff --git a/arch/x86/include/asm/arch-tangier/acpi/platform.asl b/arch/x86/include/asm/arch-tangier/acpi/platform.asl index a75b388c47..cf75ca7543 100644 --- a/arch/x86/include/asm/arch-tangier/acpi/platform.asl +++ b/arch/x86/include/asm/arch-tangier/acpi/platform.asl @@ -6,6 +6,7 @@ */
#include <asm/acpi/statdef.asl> +#include <asm/arch/iomap.h>
/* * The _PTS method (Prepare To Sleep) is called before the OS is diff --git a/arch/x86/include/asm/arch-tangier/acpi/southcluster.asl b/arch/x86/include/asm/arch-tangier/acpi/southcluster.asl index 1b9d808b7b..f73a6b351c 100644 --- a/arch/x86/include/asm/arch-tangier/acpi/southcluster.asl +++ b/arch/x86/include/asm/arch-tangier/acpi/southcluster.asl @@ -66,6 +66,23 @@ Device (PCI0) Return (MCRS) }
+ /* Device Resource Consumption */ + Device (PDRC) + { + Name (_HID, EISAID("PNP0C02")) + Name (_UID, One) + + Name (PDRS, ResourceTemplate() + { + Memory32Fixed(ReadWrite, MCFG_BASE_ADDRESS, MCFG_BASE_SIZE) + }) + + Method (_CRS, 0, Serialized) + { + Return (PDRS) + } + } + Method (_OSC, 4) { /* Check for proper GUID */ diff --git a/arch/x86/include/asm/arch-tangier/iomap.h b/arch/x86/include/asm/arch-tangier/iomap.h new file mode 100644 index 0000000000..b0fc03e015 --- /dev/null +++ b/arch/x86/include/asm/arch-tangier/iomap.h @@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* Copyright (c) 2019 Intel Corporation */ + +#ifndef _TANGIER_IOMAP_H +#define _TANGIER_IOMAP_H + +#define MCFG_BASE_ADDRESS 0x3f500000 +#define MCFG_BASE_SIZE 0x00100000 + +#endif /* _TANGIER_IOMAP_H */

On Thu, Aug 29, 2019 at 10:04 PM Andy Shevchenko andriy.shevchenko@linux.intel.com wrote:
Per PCI firmware specification the ACPI has to reserve the memory which is defined as PCI ECAM.
Fixes: 39665beed6f7 ("x86: tangier: Enable ACPI support for Intel Tangier") Signed-off-by: Andy Shevchenko andriy.shevchenko@linux.intel.com
arch/x86/cpu/tangier/acpi.c | 3 ++- .../include/asm/arch-tangier/acpi/platform.asl | 1 + .../asm/arch-tangier/acpi/southcluster.asl | 17 +++++++++++++++++ arch/x86/include/asm/arch-tangier/iomap.h | 10 ++++++++++ 4 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 arch/x86/include/asm/arch-tangier/iomap.h
Reviewed-by: Bin Meng bmeng.cn@gmail.com

On Tue, Sep 10, 2019 at 4:14 PM Bin Meng bmeng.cn@gmail.com wrote:
On Thu, Aug 29, 2019 at 10:04 PM Andy Shevchenko andriy.shevchenko@linux.intel.com wrote:
Per PCI firmware specification the ACPI has to reserve the memory which is defined as PCI ECAM.
Fixes: 39665beed6f7 ("x86: tangier: Enable ACPI support for Intel Tangier") Signed-off-by: Andy Shevchenko andriy.shevchenko@linux.intel.com
arch/x86/cpu/tangier/acpi.c | 3 ++- .../include/asm/arch-tangier/acpi/platform.asl | 1 + .../asm/arch-tangier/acpi/southcluster.asl | 17 +++++++++++++++++ arch/x86/include/asm/arch-tangier/iomap.h | 10 ++++++++++ 4 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 arch/x86/include/asm/arch-tangier/iomap.h
Reviewed-by: Bin Meng bmeng.cn@gmail.com
applied to u-boot-x86, thanks!

Intel iDMA 32-bit controller has 17 bits for the maximum block size value. Due to nature of the binary number representation the maximum value is 2^17 - 1. The original code misses the latter part in equation.
Fixes: 5e99fde34a77 ("x86: tangier: Populate CSRT for shared DMA controller") Signed-off-by: Andy Shevchenko andriy.shevchenko@linux.intel.com --- arch/x86/cpu/tangier/acpi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/cpu/tangier/acpi.c b/arch/x86/cpu/tangier/acpi.c index 362e133cf1..8b128138b0 100644 --- a/arch/x86/cpu/tangier/acpi.c +++ b/arch/x86/cpu/tangier/acpi.c @@ -95,7 +95,7 @@ static u32 acpi_fill_csrt_dma(struct acpi_csrt_group *grp) si->dma_address_width = 32; si->base_request_line = 0; si->num_handshake_signals = 16; - si->max_block_size = 0x20000; + si->max_block_size = 0x1ffff;
return grp->length; }

On Thu, Aug 29, 2019 at 10:04 PM Andy Shevchenko andriy.shevchenko@linux.intel.com wrote:
Intel iDMA 32-bit controller has 17 bits for the maximum block size value. Due to nature of the binary number representation the maximum value is 2^17 - 1. The original code misses the latter part in equation.
Fixes: 5e99fde34a77 ("x86: tangier: Populate CSRT for shared DMA controller") Signed-off-by: Andy Shevchenko andriy.shevchenko@linux.intel.com
arch/x86/cpu/tangier/acpi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by: Bin Meng bmeng.cn@gmail.com

On Tue, Sep 10, 2019 at 4:14 PM Bin Meng bmeng.cn@gmail.com wrote:
On Thu, Aug 29, 2019 at 10:04 PM Andy Shevchenko andriy.shevchenko@linux.intel.com wrote:
Intel iDMA 32-bit controller has 17 bits for the maximum block size value. Due to nature of the binary number representation the maximum value is 2^17 - 1. The original code misses the latter part in equation.
Fixes: 5e99fde34a77 ("x86: tangier: Populate CSRT for shared DMA controller") Signed-off-by: Andy Shevchenko andriy.shevchenko@linux.intel.com
arch/x86/cpu/tangier/acpi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by: Bin Meng bmeng.cn@gmail.com
applied to u-boot-x86, thanks!

For sake of consistency use spaces over TABs in ASL code.
Signed-off-by: Andy Shevchenko andriy.shevchenko@linux.intel.com --- .../asm/arch-tangier/acpi/southcluster.asl | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/arch/x86/include/asm/arch-tangier/acpi/southcluster.asl b/arch/x86/include/asm/arch-tangier/acpi/southcluster.asl index f73a6b351c..c622783f44 100644 --- a/arch/x86/include/asm/arch-tangier/acpi/southcluster.asl +++ b/arch/x86/include/asm/arch-tangier/acpi/southcluster.asl @@ -382,19 +382,19 @@ Device (PCI0) Name (RBUF, ResourceTemplate() { /* - * Shadow registers in SRAM for PMIC: - * SRAM PMIC register - * -------------------- - * 0x00- Unknown - * 0x03 THRMIRQ (0x04) - * 0x04 BCUIRQ (0x05) - * 0x05 ADCIRQ (0x06) - * 0x06 CHGRIRQ0 (0x07) - * 0x07 CHGRIRQ1 (0x08) - * 0x08- Unknown - * 0x0a PBSTATUS (0x27) - * 0x0b- Unknown - */ + * Shadow registers in SRAM for PMIC: + * SRAM PMIC register + * -------------------- + * 0x00- Unknown + * 0x03 THRMIRQ (0x04) + * 0x04 BCUIRQ (0x05) + * 0x05 ADCIRQ (0x06) + * 0x06 CHGRIRQ0 (0x07) + * 0x07 CHGRIRQ1 (0x08) + * 0x08- Unknown + * 0x0a PBSTATUS (0x27) + * 0x0b- Unknown + */ Memory32Fixed(ReadWrite, 0xFFFFF610, 0x00000010) Interrupt(ResourceConsumer, Level, ActiveHigh, Shared, ,, ) { 30 } Interrupt(ResourceConsumer, Level, ActiveHigh, Shared, ,, ) { 23 }

On Thu, Aug 29, 2019 at 10:04 PM Andy Shevchenko andriy.shevchenko@linux.intel.com wrote:
For sake of consistency use spaces over TABs in ASL code.
Signed-off-by: Andy Shevchenko andriy.shevchenko@linux.intel.com
.../asm/arch-tangier/acpi/southcluster.asl | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-)
Reviewed-by: Bin Meng bmeng.cn@gmail.com

On Tue, Sep 10, 2019 at 4:14 PM Bin Meng bmeng.cn@gmail.com wrote:
On Thu, Aug 29, 2019 at 10:04 PM Andy Shevchenko andriy.shevchenko@linux.intel.com wrote:
For sake of consistency use spaces over TABs in ASL code.
Signed-off-by: Andy Shevchenko andriy.shevchenko@linux.intel.com
.../asm/arch-tangier/acpi/southcluster.asl | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-)
Reviewed-by: Bin Meng bmeng.cn@gmail.com
applied to u-boot-x86, thanks!

Hi Andy,
On Thu, Aug 29, 2019 at 10:04 PM Andy Shevchenko andriy.shevchenko@linux.intel.com wrote:
GCC starts complaining about possible pointer misalignment of pointers to the
Which GCC version?
unpacked (alignment=4) structures in the packed (alignment=1) ones:
CC arch/x86/cpu/tangier/acpi.o arch/x86/cpu/tangier/acpi.c: In function ‘acpi_create_fadt’: arch/x86/cpu/tangier/acpi.c:22:37: warning: taking address of packed member of ‘struct acpi_fadt’ may result in an unaligned pointer value [-Waddress-of-packed-member] 22 | struct acpi_table_header *header = &(fadt->header);
CC arch/x86/lib/acpi_table.o arch/x86/lib/acpi_table.c: In function ‘acpi_create_spcr’: arch/x86/lib/acpi_table.c:366:37: warning: taking address of packed member of ‘struct acpi_spcr’ may result in an unaligned pointer value [-Waddress-of-packed-member] 366 | struct acpi_table_header *header = &(spcr->header);
Fix the potential issues by annotating embedded structures with __packed even though they are packed naturally.
Signed-off-by: Andy Shevchenko andriy.shevchenko@linux.intel.com
arch/x86/include/asm/acpi_table.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Regards, Bin

On Thu, Aug 29, 2019 at 5:13 PM Bin Meng bmeng.cn@gmail.com wrote:
Hi Andy,
On Thu, Aug 29, 2019 at 10:04 PM Andy Shevchenko andriy.shevchenko@linux.intel.com wrote:
GCC starts complaining about possible pointer misalignment of pointers to the
Which GCC version?
gcc (Debian 9.2.1-4) 9.2.1 20190821 Copyright (C) 2019 Free Software Foundation, Inc.

Hi Andy,
On Thu, Aug 29, 2019 at 10:29 PM Andy Shevchenko andy.shevchenko@gmail.com wrote:
On Thu, Aug 29, 2019 at 5:13 PM Bin Meng bmeng.cn@gmail.com wrote:
Hi Andy,
On Thu, Aug 29, 2019 at 10:04 PM Andy Shevchenko andriy.shevchenko@linux.intel.com wrote:
GCC starts complaining about possible pointer misalignment of pointers to the
Which GCC version?
gcc (Debian 9.2.1-4) 9.2.1 20190821 Copyright (C) 2019 Free Software Foundation, Inc.
I will add such information in the commit message when applying. Reviewed-by: Bin Meng bmeng.cn@gmail.com
Regards, Bin

On Tue, Sep 10, 2019 at 4:14 PM Bin Meng bmeng.cn@gmail.com wrote:
Hi Andy,
On Thu, Aug 29, 2019 at 10:29 PM Andy Shevchenko andy.shevchenko@gmail.com wrote:
On Thu, Aug 29, 2019 at 5:13 PM Bin Meng bmeng.cn@gmail.com wrote:
Hi Andy,
On Thu, Aug 29, 2019 at 10:04 PM Andy Shevchenko andriy.shevchenko@linux.intel.com wrote:
GCC starts complaining about possible pointer misalignment of pointers to the
Which GCC version?
gcc (Debian 9.2.1-4) 9.2.1 20190821 Copyright (C) 2019 Free Software Foundation, Inc.
I will add such information in the commit message when applying. Reviewed-by: Bin Meng bmeng.cn@gmail.com
applied to u-boot-x86, thanks!
participants (3)
-
Andy Shevchenko
-
Andy Shevchenko
-
Bin Meng