Skip to contentSkip to conversation

x86: acpi: Annotate struct acpi_table_header with __packed

PATCH New Andy Shevchenko 3 participants 14 messages Aug 29, 2019 – Sep 10, 2019 x86

lore
Share & tools
lore
#0 lore raw

PATCH 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.

---
 arch/x86/include/asm/acpi_table.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/include/asm/acpi_table.h +1 -1
index 02aea127c1..7588913f93 100644
@@ -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!) */
Signature · 1 line
2.23.0.rc1
#1 lore raw

PATCH 2/4 x86: tangier: Reserve PCI ECAM in motherboard resources

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")
---
 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
arch/x86/cpu/tangier/acpi.c +2 -1
index 61b2642aa9..362e133cf1 100644
@@ -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;
 }
arch/x86/include/asm/arch-tangier/acpi/platform.asl +1 -0
index a75b388c47..cf75ca7543 100644
@@ -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
arch/x86/include/asm/arch-tangier/acpi/southcluster.asl +17 -0
index 1b9d808b7b..f73a6b351c 100644
@@ -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 */
arch/x86/include/asm/arch-tangier/iomap.h new file +10 -0
new file mode 100644
index 0000000000..b0fc03e015
@@ -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 */
Signature · 1 line
2.23.0.rc1
#2 lore raw

PATCH 2/4 x86: tangier: Reserve PCI ECAM in motherboard resources

Quoted 6 lines · Andy Shevchenko

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")
Quoted 8 lines
---
 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
#3 lore raw

PATCH 2/4 x86: tangier: Reserve PCI ECAM in motherboard resources

Quoted 18 lines · Bin Meng
Quoted 6 lines · Andy Shevchenko

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")
Quoted 8 lines
---
 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
Quoted 1 line

applied to u-boot-x86, thanks!

#4 lore raw

PATCH 3/4 x86: tangier: Fix off-by-one error when preparing CSRT

In reply to Andy Shevchenko

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")
---
 arch/x86/cpu/tangier/acpi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/cpu/tangier/acpi.c +1 -1
index 362e133cf1..8b128138b0 100644
@@ -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;
 }
Signature · 1 line
2.23.0.rc1
#5 lore raw

PATCH 3/4 x86: tangier: Fix off-by-one error when preparing CSRT

Quoted 11 lines · Andy Shevchenko

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")
---
 arch/x86/cpu/tangier/acpi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
#6 lore raw

PATCH 3/4 x86: tangier: Fix off-by-one error when preparing CSRT

Quoted 8 lines · Bin Meng
Quoted 5 lines · Andy Shevchenko

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.

Quoted 8 lines
Quoted 6 lines
Fixes 5e99fde34a77 ("x86: tangier: Populate CSRT for shared DMA controller")
---
 arch/x86/cpu/tangier/acpi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

applied to u-boot-x86, thanks!

#7 lore raw

PATCH 4/4 x86: tangier: Use spaces over TABs in ASL code

In reply to Andy Shevchenko

For sake of consistency use spaces over TABs in ASL code.

---
 .../asm/arch-tangier/acpi/southcluster.asl    | 26 +++++++++----------
 1 file changed, 13 insertions(+), 13 deletions(-)
arch/x86/include/asm/arch-tangier/acpi/southcluster.asl +13 -13
index f73a6b351c..c622783f44 100644
@@ -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 }
Signature · 1 line
2.23.0.rc1
#9 lore raw

PATCH 4/4 x86: tangier: Use spaces over TABs in ASL code

Quoted 6 lines · Bin Meng
Quoted 3 lines · Andy Shevchenko

For sake of consistency use spaces over TABs in ASL code.

Quoted 7 lines
Quoted 5 lines
---
 .../asm/arch-tangier/acpi/southcluster.asl    | 26 +++++++++----------
 1 file changed, 13 insertions(+), 13 deletions(-)

applied to u-boot-x86, thanks!

#10 lore raw

PATCH 1/4 x86: acpi: Annotate struct acpi_table_header with __packed

In reply to Andy Shevchenko

Hi Andy,

Quoted 2 lines · Andy Shevchenko

GCC starts complaining about possible pointer misalignment of pointers to the

Which GCC version?

Quoted 12 lines

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);

Quoted 8 lines

Fix the potential issues by annotating embedded structures with __packed even though they are packed naturally.

---
 arch/x86/include/asm/acpi_table.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Regards,
Bin

#11 lore raw

PATCH 1/4 x86: acpi: Annotate struct acpi_table_header with __packed

Quoted 9 lines · Bin Meng

Hi Andy,

Quoted 2 lines · Andy Shevchenko

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.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#12 lore raw

PATCH 1/4 x86: acpi: Annotate struct acpi_table_header with __packed

Hi Andy,

Quoted 8 lines · Andy Shevchenko
Quoted 6 lines · Bin Meng

Hi Andy,

Quoted 1 line · Andy Shevchenko
Quoted 7 lines
Quoted 3 lines
Quoted 1 line

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.

Regards,
Bin

#13 lore raw

PATCH 1/4 x86: acpi: Annotate struct acpi_table_header with __packed

Quoted 15 lines · Bin Meng

Hi Andy,

Quoted 10 lines · Andy Shevchenko
Quoted 8 lines · Bin Meng

Hi Andy,

Quoted 2 lines · Andy Shevchenko

GCC starts complaining about possible pointer misalignment of pointers to the

Quoted 9 lines
Quoted 5 lines
Quoted 1 line

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.

applied to u-boot-x86, thanks!