linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v9 00/21] Introduce ACPI for ARM64 based on ACPI 5.1
@ 2015-02-25  8:39 Hanjun Guo
  2015-02-25  8:39 ` [PATCH v9 01/21] ACPI / table: Use pr_debug() instead of pr_info() for MADT table scanning Hanjun Guo
                   ` (23 more replies)
  0 siblings, 24 replies; 106+ messages in thread
From: Hanjun Guo @ 2015-02-25  8:39 UTC (permalink / raw)
  To: Catalin Marinas, Rafael J. Wysocki, Will Deacon, Olof Johansson,
	Grant Likely
  Cc: Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi, Hanjun Guo

Changes since v8:
  - remove MPIDR packing things by introducing phys_cpuid_t;

  - update patch acpi: fix acpi_os_ioremap for arm64 to follow
    Rafael's suggestion;

  - Squash patch (disable ACPI if ACPI less than 5.1) to patch
    (Get RSDP and ACPI boot-time table);

  - Move sleep_arm.c to arch/arm64/ and rename it as acpi_sleep.c 

  - Rework the uefi generated empty dtb to enable acpi when no dtb
    is available, thanks Ard for the updated patch.

  - rework the function of register cpu for kexec case

  - use pr_debug() instead of pr_info() when scanning MADT.

  - rebase on top of 4.0-rc1

Thanks
Hanjun

Al Stone (4):
  ARM64 / ACPI: Get RSDP and ACPI boot-time tables
  ARM64 / ACPI: Introduce early_param "acpi=" to enable/disable ACPI
  ARM64 / ACPI: Select ACPI_REDUCED_HARDWARE_ONLY if ACPI is enabled on
    ARM64
  ARM64 / ACPI: additions of ACPI documentation for arm64

Graeme Gregory (6):
  ACPI: add arm64 to the platforms that use ioremap
  ACPI / sleep: Introduce arm64 specific acpi_sleep.c
  ARM64 / ACPI: If we chose to boot from acpi then disable FDT
  ARM64 / ACPI: Get PSCI flags in FADT for PSCI init
  ARM64 / ACPI: Enable ARM64 in Kconfig
  Documentation: ACPI for ARM64

Hanjun Guo (8):
  ACPI / table: Use pr_debug() instead of pr_info() for MADT table
    scanning
  ACPI / processor: Introduce phys_cpuid_t for CPU hardware ID
  ARM64 / ACPI: Introduce PCI stub functions for ACPI
  ACPI / table: Print GIC information when MADT is parsed
  ARM64 / ACPI: Parse MADT for SMP initialization
  ACPI / processor: Make it possible to get CPU hardware ID via GICC
  ARM64 / ACPI: Introduce ACPI_IRQ_MODEL_GIC and register device's gsi
  clocksource / arch_timer: Parse GTDT to initialize arch timer

Mark Salter (2):
  ARM64: allow late use of early_ioremap
  ACPI: fix acpi_os_ioremap for arm64

Tomasz Nowicki (1):
  irqchip: Add GICv2 specific ACPI boot support

 Documentation/arm64/acpi_object_usage.txt | 594 ++++++++++++++++++++++++++++++
 Documentation/arm64/arm-acpi.txt          | 506 +++++++++++++++++++++++++
 Documentation/arm64/why_use_acpi.txt      | 231 ++++++++++++
 Documentation/kernel-parameters.txt       |   3 +-
 arch/arm64/Kconfig                        |   3 +
 arch/arm64/include/asm/acenv.h            |  18 +
 arch/arm64/include/asm/acpi.h             |  96 +++++
 arch/arm64/include/asm/cpu_ops.h          |   1 +
 arch/arm64/include/asm/fixmap.h           |   3 +
 arch/arm64/include/asm/pci.h              |   6 +
 arch/arm64/include/asm/psci.h             |   3 +-
 arch/arm64/include/asm/smp.h              |   5 +-
 arch/arm64/kernel/Makefile                |   1 +
 arch/arm64/kernel/acpi.c                  | 386 +++++++++++++++++++
 arch/arm64/kernel/acpi_sleep.c            |  28 ++
 arch/arm64/kernel/cpu_ops.c               |   2 +-
 arch/arm64/kernel/pci.c                   |  25 ++
 arch/arm64/kernel/psci.c                  |  78 ++--
 arch/arm64/kernel/setup.c                 |  21 +-
 arch/arm64/kernel/smp.c                   |   2 +-
 arch/arm64/kernel/time.c                  |   7 +
 arch/ia64/include/asm/acpi.h              |   4 +
 arch/ia64/kernel/acpi.c                   |   2 +-
 arch/x86/include/asm/acpi.h               |   4 +
 arch/x86/kernel/acpi/boot.c               |   2 +-
 drivers/acpi/Kconfig                      |   3 +-
 drivers/acpi/Makefile                     |   2 +
 drivers/acpi/acpi_processor.c             |   7 +-
 drivers/acpi/bus.c                        |   3 +
 drivers/acpi/osl.c                        |   6 +-
 drivers/acpi/processor_core.c             |  60 ++-
 drivers/acpi/tables.c                     |  52 ++-
 drivers/clocksource/arm_arch_timer.c      | 132 +++++--
 drivers/irqchip/irq-gic.c                 | 102 +++++
 drivers/irqchip/irqchip.c                 |   3 +
 include/acpi/acpi_io.h                    |   4 +
 include/acpi/processor.h                  |   6 +-
 include/linux/acpi.h                      |  17 +-
 include/linux/clocksource.h               |   6 +
 include/linux/irqchip/arm-gic-acpi.h      |  29 ++
 40 files changed, 2359 insertions(+), 104 deletions(-)
 create mode 100644 Documentation/arm64/acpi_object_usage.txt
 create mode 100644 Documentation/arm64/arm-acpi.txt
 create mode 100644 Documentation/arm64/why_use_acpi.txt
 create mode 100644 arch/arm64/include/asm/acenv.h
 create mode 100644 arch/arm64/include/asm/acpi.h
 create mode 100644 arch/arm64/kernel/acpi.c
 create mode 100644 arch/arm64/kernel/acpi_sleep.c
 create mode 100644 include/linux/irqchip/arm-gic-acpi.h

-- 
1.9.1


^ permalink raw reply	[flat|nested] 106+ messages in thread

* [PATCH v9 01/21] ACPI / table: Use pr_debug() instead of pr_info() for MADT table scanning
  2015-02-25  8:39 [PATCH v9 00/21] Introduce ACPI for ARM64 based on ACPI 5.1 Hanjun Guo
@ 2015-02-25  8:39 ` Hanjun Guo
  2015-03-04 22:33   ` Rafael J. Wysocki
                     ` (2 more replies)
  2015-02-25  8:39 ` [PATCH v9 02/21] ACPI / processor: Introduce phys_cpuid_t for CPU hardware ID Hanjun Guo
                   ` (22 subsequent siblings)
  23 siblings, 3 replies; 106+ messages in thread
From: Hanjun Guo @ 2015-02-25  8:39 UTC (permalink / raw)
  To: Catalin Marinas, Rafael J. Wysocki, Will Deacon, Olof Johansson,
	Grant Likely
  Cc: Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi, Hanjun Guo

For a normal 8 cpu sockets system, it will up to 240 cpu threads (Xeon E7
v2 family for now), and we need 240 entries for local apic or local x2apic
in MADT table, so it will be much verbose information printed with a slow
uart console when system booted, this will be even worse with large system
with 16/32 cpu sockets.

This patch just use pr_debug() instead of pr_info() for ioapic/iosapic,
local apic/x2apic/sapic structures when scanning the MADT table to remove
those verbose information, but leave other structures unchanged.

CC: Rafael J Wysocki <rjw@rjwysocki.net>
Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
---
 drivers/acpi/tables.c | 30 ++++++++++++++++--------------
 1 file changed, 16 insertions(+), 14 deletions(-)

diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c
index 93b8152..f4e5b88 100644
--- a/drivers/acpi/tables.c
+++ b/drivers/acpi/tables.c
@@ -23,6 +23,8 @@
  *
  */
 
+/* Uncomment next line to get verbose printout */
+/* #define DEBUG */
 #define pr_fmt(fmt) "ACPI: " fmt
 
 #include <linux/init.h>
@@ -61,9 +63,9 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header)
 		{
 			struct acpi_madt_local_apic *p =
 			    (struct acpi_madt_local_apic *)header;
-			pr_info("LAPIC (acpi_id[0x%02x] lapic_id[0x%02x] %s)\n",
-				p->processor_id, p->id,
-				(p->lapic_flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled");
+			pr_debug("LAPIC (acpi_id[0x%02x] lapic_id[0x%02x] %s)\n",
+				 p->processor_id, p->id,
+				 (p->lapic_flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled");
 		}
 		break;
 
@@ -71,9 +73,9 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header)
 		{
 			struct acpi_madt_local_x2apic *p =
 			    (struct acpi_madt_local_x2apic *)header;
-			pr_info("X2APIC (apic_id[0x%02x] uid[0x%02x] %s)\n",
-				p->local_apic_id, p->uid,
-				(p->lapic_flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled");
+			pr_debug("X2APIC (apic_id[0x%02x] uid[0x%02x] %s)\n",
+				 p->local_apic_id, p->uid,
+				 (p->lapic_flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled");
 		}
 		break;
 
@@ -81,8 +83,8 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header)
 		{
 			struct acpi_madt_io_apic *p =
 			    (struct acpi_madt_io_apic *)header;
-			pr_info("IOAPIC (id[0x%02x] address[0x%08x] gsi_base[%d])\n",
-				p->id, p->address, p->global_irq_base);
+			pr_debug("IOAPIC (id[0x%02x] address[0x%08x] gsi_base[%d])\n",
+				 p->id, p->address, p->global_irq_base);
 		}
 		break;
 
@@ -155,9 +157,9 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header)
 		{
 			struct acpi_madt_io_sapic *p =
 			    (struct acpi_madt_io_sapic *)header;
-			pr_info("IOSAPIC (id[0x%x] address[%p] gsi_base[%d])\n",
-				p->id, (void *)(unsigned long)p->address,
-				p->global_irq_base);
+			pr_debug("IOSAPIC (id[0x%x] address[%p] gsi_base[%d])\n",
+				 p->id, (void *)(unsigned long)p->address,
+				 p->global_irq_base);
 		}
 		break;
 
@@ -165,9 +167,9 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header)
 		{
 			struct acpi_madt_local_sapic *p =
 			    (struct acpi_madt_local_sapic *)header;
-			pr_info("LSAPIC (acpi_id[0x%02x] lsapic_id[0x%02x] lsapic_eid[0x%02x] %s)\n",
-				p->processor_id, p->id, p->eid,
-				(p->lapic_flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled");
+			pr_debug("LSAPIC (acpi_id[0x%02x] lsapic_id[0x%02x] lsapic_eid[0x%02x] %s)\n",
+				 p->processor_id, p->id, p->eid,
+				 (p->lapic_flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled");
 		}
 		break;
 
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v9 02/21] ACPI / processor: Introduce phys_cpuid_t for CPU hardware ID
  2015-02-25  8:39 [PATCH v9 00/21] Introduce ACPI for ARM64 based on ACPI 5.1 Hanjun Guo
  2015-02-25  8:39 ` [PATCH v9 01/21] ACPI / table: Use pr_debug() instead of pr_info() for MADT table scanning Hanjun Guo
@ 2015-02-25  8:39 ` Hanjun Guo
  2015-03-04 22:29   ` Rafael J. Wysocki
  2015-03-06 20:19   ` Grant Likely
  2015-02-25  8:39 ` [PATCH v9 03/21] ACPI: add arm64 to the platforms that use ioremap Hanjun Guo
                   ` (21 subsequent siblings)
  23 siblings, 2 replies; 106+ messages in thread
From: Hanjun Guo @ 2015-02-25  8:39 UTC (permalink / raw)
  To: Catalin Marinas, Rafael J. Wysocki, Will Deacon, Olof Johansson,
	Grant Likely
  Cc: Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi, Hanjun Guo

CPU hardware ID (phys_id) is defined as u32 in structure acpi_processor,
but phys_id is used as int in acpi processor driver, so it will lead to
some inconsistence for the drivers.

Furthermore, to cater for ACPI arch ports that implement 64 bits CPU
ids a generic CPU physical id type is required.

So introduce typedef u32 phys_cpuid_t for x86 and ia64, and introduce
a macro CPU_PHYS_ID_INVALID as (u32)(-1), use phys_cpuid_t when phys_id
defined in acpi processor driver, and replace CPU_PHYS_ID_INVALID as -1
for phys_id, this will solve the inconsistence in acpi processor driver,
and will prepare for the ACPI on ARM64 too.

CC: Rafael J Wysocki <rjw@rjwysocki.net>
Suggested-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Acked-by: Sudeep Holla <sudeep.holla@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
[hj: reworked cpu physid map return codes]
Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
---
 arch/ia64/include/asm/acpi.h  |  4 ++++
 arch/ia64/kernel/acpi.c       |  2 +-
 arch/x86/include/asm/acpi.h   |  4 ++++
 arch/x86/kernel/acpi/boot.c   |  2 +-
 drivers/acpi/acpi_processor.c |  7 ++++---
 drivers/acpi/processor_core.c | 30 +++++++++++++++---------------
 include/acpi/processor.h      |  6 +++---
 include/linux/acpi.h          |  2 +-
 8 files changed, 33 insertions(+), 24 deletions(-)

diff --git a/arch/ia64/include/asm/acpi.h b/arch/ia64/include/asm/acpi.h
index a1d91ab..ca1f0e4 100644
--- a/arch/ia64/include/asm/acpi.h
+++ b/arch/ia64/include/asm/acpi.h
@@ -34,6 +34,10 @@
 #include <linux/numa.h>
 #include <asm/numa.h>
 
+typedef u32 phys_cpuid_t;
+
+#define CPU_PHYS_ID_INVALID (u32)(-1)
+
 #ifdef	CONFIG_ACPI
 extern int acpi_lapic;
 #define acpi_disabled 0	/* ACPI always enabled on IA64 */
diff --git a/arch/ia64/kernel/acpi.c b/arch/ia64/kernel/acpi.c
index 2c44989..067ef44 100644
--- a/arch/ia64/kernel/acpi.c
+++ b/arch/ia64/kernel/acpi.c
@@ -887,7 +887,7 @@ static int _acpi_map_lsapic(acpi_handle handle, int physid, int *pcpu)
 }
 
 /* wrapper to silence section mismatch warning */
-int __ref acpi_map_cpu(acpi_handle handle, int physid, int *pcpu)
+int __ref acpi_map_cpu(acpi_handle handle, phys_cpuid_t physid, int *pcpu)
 {
 	return _acpi_map_lsapic(handle, physid, pcpu);
 }
diff --git a/arch/x86/include/asm/acpi.h b/arch/x86/include/asm/acpi.h
index 3a45668..cd788dd 100644
--- a/arch/x86/include/asm/acpi.h
+++ b/arch/x86/include/asm/acpi.h
@@ -32,6 +32,10 @@
 #include <asm/mpspec.h>
 #include <asm/realmode.h>
 
+typedef u32 phys_cpuid_t;
+
+#define CPU_PHYS_ID_INVALID (u32)(-1)
+
 #ifdef CONFIG_ACPI
 extern int acpi_lapic;
 extern int acpi_ioapic;
diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index 3d525c6..e4f8582 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -757,7 +757,7 @@ static int _acpi_map_lsapic(acpi_handle handle, int physid, int *pcpu)
 }
 
 /* wrapper to silence section mismatch warning */
-int __ref acpi_map_cpu(acpi_handle handle, int physid, int *pcpu)
+int __ref acpi_map_cpu(acpi_handle handle, phys_cpuid_t physid, int *pcpu)
 {
 	return _acpi_map_lsapic(handle, physid, pcpu);
 }
diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c
index 1020b1b..e6c7c56 100644
--- a/drivers/acpi/acpi_processor.c
+++ b/drivers/acpi/acpi_processor.c
@@ -170,7 +170,7 @@ static int acpi_processor_hotadd_init(struct acpi_processor *pr)
 	acpi_status status;
 	int ret;
 
-	if (pr->phys_id == -1)
+	if (pr->phys_id == CPU_PHYS_ID_INVALID)
 		return -ENODEV;
 
 	status = acpi_evaluate_integer(pr->handle, "_STA", NULL, &sta);
@@ -215,7 +215,8 @@ static int acpi_processor_get_info(struct acpi_device *device)
 	union acpi_object object = { 0 };
 	struct acpi_buffer buffer = { sizeof(union acpi_object), &object };
 	struct acpi_processor *pr = acpi_driver_data(device);
-	int phys_id, cpu_index, device_declaration = 0;
+	phys_cpuid_t phys_id;
+	int cpu_index, device_declaration = 0;
 	acpi_status status = AE_OK;
 	static int cpu0_initialized;
 	unsigned long long value;
@@ -263,7 +264,7 @@ static int acpi_processor_get_info(struct acpi_device *device)
 	}
 
 	phys_id = acpi_get_phys_id(pr->handle, device_declaration, pr->acpi_id);
-	if (phys_id < 0)
+	if (phys_id == CPU_PHYS_ID_INVALID)
 		acpi_handle_debug(pr->handle, "failed to get CPU physical ID.\n");
 	pr->phys_id = phys_id;
 
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c
index 7962651..a5547dc 100644
--- a/drivers/acpi/processor_core.c
+++ b/drivers/acpi/processor_core.c
@@ -32,7 +32,7 @@ static struct acpi_table_madt *get_madt_table(void)
 }
 
 static int map_lapic_id(struct acpi_subtable_header *entry,
-		 u32 acpi_id, int *apic_id)
+		 u32 acpi_id, phys_cpuid_t *apic_id)
 {
 	struct acpi_madt_local_apic *lapic =
 		container_of(entry, struct acpi_madt_local_apic, header);
@@ -48,7 +48,7 @@ static int map_lapic_id(struct acpi_subtable_header *entry,
 }
 
 static int map_x2apic_id(struct acpi_subtable_header *entry,
-			 int device_declaration, u32 acpi_id, int *apic_id)
+		int device_declaration, u32 acpi_id, phys_cpuid_t *apic_id)
 {
 	struct acpi_madt_local_x2apic *apic =
 		container_of(entry, struct acpi_madt_local_x2apic, header);
@@ -65,7 +65,7 @@ static int map_x2apic_id(struct acpi_subtable_header *entry,
 }
 
 static int map_lsapic_id(struct acpi_subtable_header *entry,
-		int device_declaration, u32 acpi_id, int *apic_id)
+		int device_declaration, u32 acpi_id, phys_cpuid_t *apic_id)
 {
 	struct acpi_madt_local_sapic *lsapic =
 		container_of(entry, struct acpi_madt_local_sapic, header);
@@ -83,10 +83,10 @@ static int map_lsapic_id(struct acpi_subtable_header *entry,
 	return 0;
 }
 
-static int map_madt_entry(int type, u32 acpi_id)
+static phys_cpuid_t map_madt_entry(int type, u32 acpi_id)
 {
 	unsigned long madt_end, entry;
-	int phys_id = -1;	/* CPU hardware ID */
+	phys_cpuid_t phys_id = CPU_PHYS_ID_INVALID;	/* CPU hardware ID */
 	struct acpi_table_madt *madt;
 
 	madt = get_madt_table();
@@ -117,12 +117,12 @@ static int map_madt_entry(int type, u32 acpi_id)
 	return phys_id;
 }
 
-static int map_mat_entry(acpi_handle handle, int type, u32 acpi_id)
+static phys_cpuid_t map_mat_entry(acpi_handle handle, int type, u32 acpi_id)
 {
 	struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
 	union acpi_object *obj;
 	struct acpi_subtable_header *header;
-	int phys_id = -1;
+	phys_cpuid_t phys_id = CPU_PHYS_ID_INVALID;
 
 	if (ACPI_FAILURE(acpi_evaluate_object(handle, "_MAT", NULL, &buffer)))
 		goto exit;
@@ -149,27 +149,27 @@ exit:
 	return phys_id;
 }
 
-int acpi_get_phys_id(acpi_handle handle, int type, u32 acpi_id)
+phys_cpuid_t acpi_get_phys_id(acpi_handle handle, int type, u32 acpi_id)
 {
-	int phys_id;
+	phys_cpuid_t phys_id;
 
 	phys_id = map_mat_entry(handle, type, acpi_id);
-	if (phys_id == -1)
+	if (phys_id == CPU_PHYS_ID_INVALID)
 		phys_id = map_madt_entry(type, acpi_id);
 
 	return phys_id;
 }
 
-int acpi_map_cpuid(int phys_id, u32 acpi_id)
+int acpi_map_cpuid(phys_cpuid_t phys_id, u32 acpi_id)
 {
 #ifdef CONFIG_SMP
 	int i;
 #endif
 
-	if (phys_id == -1) {
+	if (phys_id == CPU_PHYS_ID_INVALID) {
 		/*
 		 * On UP processor, there is no _MAT or MADT table.
-		 * So above phys_id is always set to -1.
+		 * So above phys_id is always set to CPU_PHYS_ID_INVALID.
 		 *
 		 * BIOS may define multiple CPU handles even for UP processor.
 		 * For example,
@@ -190,7 +190,7 @@ int acpi_map_cpuid(int phys_id, u32 acpi_id)
 		if (nr_cpu_ids <= 1 && acpi_id == 0)
 			return acpi_id;
 		else
-			return phys_id;
+			return -1;
 	}
 
 #ifdef CONFIG_SMP
@@ -208,7 +208,7 @@ int acpi_map_cpuid(int phys_id, u32 acpi_id)
 
 int acpi_get_cpuid(acpi_handle handle, int type, u32 acpi_id)
 {
-	int phys_id;
+	phys_cpuid_t phys_id;
 
 	phys_id = acpi_get_phys_id(handle, type, acpi_id);
 
diff --git a/include/acpi/processor.h b/include/acpi/processor.h
index b95dc32..4188a4d 100644
--- a/include/acpi/processor.h
+++ b/include/acpi/processor.h
@@ -196,7 +196,7 @@ struct acpi_processor_flags {
 struct acpi_processor {
 	acpi_handle handle;
 	u32 acpi_id;
-	u32 phys_id;	/* CPU hardware ID such as APIC ID for x86 */
+	phys_cpuid_t phys_id;	/* CPU hardware ID such as APIC ID for x86 */
 	u32 id;		/* CPU logical ID allocated by OS */
 	u32 pblk;
 	int performance_platform_limit;
@@ -310,8 +310,8 @@ static inline int acpi_processor_get_bios_limit(int cpu, unsigned int *limit)
 #endif				/* CONFIG_CPU_FREQ */
 
 /* in processor_core.c */
-int acpi_get_phys_id(acpi_handle, int type, u32 acpi_id);
-int acpi_map_cpuid(int phys_id, u32 acpi_id);
+phys_cpuid_t acpi_get_phys_id(acpi_handle, int type, u32 acpi_id);
+int acpi_map_cpuid(phys_cpuid_t phys_id, u32 acpi_id);
 int acpi_get_cpuid(acpi_handle, int type, u32 acpi_id);
 
 /* in processor_pdc.c */
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 24c7aa8..0eabd15 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -148,7 +148,7 @@ void acpi_numa_arch_fixup(void);
 
 #ifdef CONFIG_ACPI_HOTPLUG_CPU
 /* Arch dependent functions for cpu hotplug support */
-int acpi_map_cpu(acpi_handle handle, int physid, int *pcpu);
+int acpi_map_cpu(acpi_handle handle, phys_cpuid_t physid, int *pcpu);
 int acpi_unmap_cpu(int cpu);
 #endif /* CONFIG_ACPI_HOTPLUG_CPU */
 
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v9 03/21] ACPI: add arm64 to the platforms that use ioremap
  2015-02-25  8:39 [PATCH v9 00/21] Introduce ACPI for ARM64 based on ACPI 5.1 Hanjun Guo
  2015-02-25  8:39 ` [PATCH v9 01/21] ACPI / table: Use pr_debug() instead of pr_info() for MADT table scanning Hanjun Guo
  2015-02-25  8:39 ` [PATCH v9 02/21] ACPI / processor: Introduce phys_cpuid_t for CPU hardware ID Hanjun Guo
@ 2015-02-25  8:39 ` Hanjun Guo
  2015-03-04 22:33   ` Rafael J. Wysocki
  2015-03-06 20:20   ` Grant Likely
  2015-02-25  8:39 ` [PATCH v9 04/21] ARM64: allow late use of early_ioremap Hanjun Guo
                   ` (20 subsequent siblings)
  23 siblings, 2 replies; 106+ messages in thread
From: Hanjun Guo @ 2015-02-25  8:39 UTC (permalink / raw)
  To: Catalin Marinas, Rafael J. Wysocki, Will Deacon, Olof Johansson,
	Grant Likely
  Cc: Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi, Al Stone, Hanjun Guo

From: Graeme Gregory <graeme.gregory@linaro.org>

Now with the base changes to the arm memory mapping it is safe
to convert to using ioremap to map in the tables after
acpi_gbl_permanent_mmap is set.

CC: Rafael J Wysocki <rjw@rjwysocki.net>
Tested-by: Robert Richter <rrichter@cavium.com>
Acked-by: Robert Richter <rrichter@cavium.com>
Signed-off-by: Al Stone <al.stone@linaro.org>
Signed-off-by: Graeme Gregory <graeme.gregory@linaro.org>
Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
---
 drivers/acpi/osl.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index f9eeae8..39748bb 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -336,11 +336,11 @@ acpi_map_lookup_virt(void __iomem *virt, acpi_size size)
 	return NULL;
 }
 
-#ifndef CONFIG_IA64
-#define should_use_kmap(pfn)   page_is_ram(pfn)
-#else
+#if defined(CONFIG_IA64) || defined(CONFIG_ARM64)
 /* ioremap will take care of cache attributes */
 #define should_use_kmap(pfn)   0
+#else
+#define should_use_kmap(pfn)   page_is_ram(pfn)
 #endif
 
 static void __iomem *acpi_map(acpi_physical_address pg_off, unsigned long pg_sz)
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v9 04/21] ARM64: allow late use of early_ioremap
  2015-02-25  8:39 [PATCH v9 00/21] Introduce ACPI for ARM64 based on ACPI 5.1 Hanjun Guo
                   ` (2 preceding siblings ...)
  2015-02-25  8:39 ` [PATCH v9 03/21] ACPI: add arm64 to the platforms that use ioremap Hanjun Guo
@ 2015-02-25  8:39 ` Hanjun Guo
  2015-03-06 20:24   ` Grant Likely
  2015-02-25  8:39 ` [PATCH v9 05/21] ARM64 / ACPI: Get RSDP and ACPI boot-time tables Hanjun Guo
                   ` (19 subsequent siblings)
  23 siblings, 1 reply; 106+ messages in thread
From: Hanjun Guo @ 2015-02-25  8:39 UTC (permalink / raw)
  To: Catalin Marinas, Rafael J. Wysocki, Will Deacon, Olof Johansson,
	Grant Likely
  Cc: Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi, Mark Salter, Leif Lindholm,
	Ard Biesheuvel, Hanjun Guo

From: Mark Salter <msalter@redhat.com>

Commit 0e63ea48b4d8 (arm64/efi: add missing call to early_ioremap_reset())
added a missing call to early_ioremap_reset(). This triggers a BUG if code
tries using early_ioremap() after the early_ioremap_reset(). This is a
problem for some ACPI code which needs short-lived temporary mappings
after paging_init() but before acpi_early_init() in start_kernel(). This
patch adds definitions for the __late_set_fixmap() and __late_clear_fixmap()
which avoids the BUG by allowing later use of early_ioremap().

CC: Leif Lindholm <leif.lindholm@linaro.org>
CC: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Tested-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
Tested-by: Mark Langsdorf <mlangsdo@redhat.com>
Tested-by: Jon Masters <jcm@redhat.com>
Tested-by: Robert Richter <rrichter@cavium.com>
Acked-by: Robert Richter <rrichter@cavium.com>
Signed-off-by: Mark Salter <msalter@redhat.com>
Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
---
 arch/arm64/include/asm/fixmap.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/arm64/include/asm/fixmap.h b/arch/arm64/include/asm/fixmap.h
index defa0ff9..f196e40 100644
--- a/arch/arm64/include/asm/fixmap.h
+++ b/arch/arm64/include/asm/fixmap.h
@@ -62,6 +62,9 @@ void __init early_fixmap_init(void);
 
 #define __early_set_fixmap __set_fixmap
 
+#define __late_set_fixmap __set_fixmap
+#define __late_clear_fixmap(idx) __set_fixmap((idx), 0, FIXMAP_PAGE_CLEAR)
+
 extern void __set_fixmap(enum fixed_addresses idx, phys_addr_t phys, pgprot_t prot);
 
 #include <asm-generic/fixmap.h>
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v9 05/21] ARM64 / ACPI: Get RSDP and ACPI boot-time tables
  2015-02-25  8:39 [PATCH v9 00/21] Introduce ACPI for ARM64 based on ACPI 5.1 Hanjun Guo
                   ` (3 preceding siblings ...)
  2015-02-25  8:39 ` [PATCH v9 04/21] ARM64: allow late use of early_ioremap Hanjun Guo
@ 2015-02-25  8:39 ` Hanjun Guo
  2015-03-05 18:10   ` Olof Johansson
                     ` (2 more replies)
  2015-02-25  8:39 ` [PATCH v9 06/21] ACPI: fix acpi_os_ioremap for arm64 Hanjun Guo
                   ` (18 subsequent siblings)
  23 siblings, 3 replies; 106+ messages in thread
From: Hanjun Guo @ 2015-02-25  8:39 UTC (permalink / raw)
  To: Catalin Marinas, Rafael J. Wysocki, Will Deacon, Olof Johansson,
	Grant Likely
  Cc: Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi, Al Stone, Lorenzo Pieralisi,
	Tomasz Nowicki, Hanjun Guo

From: Al Stone <al.stone@linaro.org>

As we want to get ACPI tables to parse and then use the information
for system initialization, we should get the RSDP (Root System
Description Pointer) first, it then locates Extended Root Description
Table (XSDT) which contains all the 64-bit physical address that
pointer to other boot-time tables.

Introduce acpi.c and its related head file in this patch to provide
fundamental needs of extern variables and functions for ACPI core,
and then get boot-time tables as needed.
  - asm/acenv.h for arch specific ACPICA environments and
    implementation, It is needed unconditionally by ACPI core;
  - asm/acpi.h for arch specific variables and functions needed by
    ACPI driver core;
  - acpi.c for ARM64 related ACPI implementation for ACPI driver
    core;

acpi_boot_table_init() is introduced to get RSDP and boot-time tables,
it will be called in setup_arch() before paging_init(), so we should
use eary_memremap() mechanism here to get the RSDP and all the table
pointers.

FADT Major.Minor version was introduced in ACPI 5.1, it is the same
as ACPI version.

In ACPI 5.1, some major gaps are fixed for ARM, such as updates in
MADT table for GIC and SMP init, without those updates, we can not
get the MPIDR for SMP init, and GICv2/3 related init information, so
we can't boot arm64 ACPI properly with table versions predating 5.1.

If firmware provides ACPI tables with ACPI version less than 5.1,
OS has no way to retrieve the configuration data that is necessary
to init SMP boot protocol and the GIC properly, so disable ACPI if
we get an FADT table with version less that 5.1 when acpi_boot_table_init()
called.

CC: Catalin Marinas <catalin.marinas@arm.com>
CC: Will Deacon <will.deacon@arm.com>
CC: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Tested-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
Tested-by: Yijing Wang <wangyijing@huawei.com>
Tested-by: Mark Langsdorf <mlangsdo@redhat.com>
Tested-by: Jon Masters <jcm@redhat.com>
Tested-by: Timur Tabi <timur@codeaurora.org>
Tested-by: Robert Richter <rrichter@cavium.com>
Acked-by: Robert Richter <rrichter@cavium.com>
Signed-off-by: Al Stone <al.stone@linaro.org>
Signed-off-by: Graeme Gregory <graeme.gregory@linaro.org>
Signed-off-by: Tomasz Nowicki <tomasz.nowicki@linaro.org>
Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
---
 arch/arm64/include/asm/acenv.h |  18 ++++++++
 arch/arm64/include/asm/acpi.h  |  45 ++++++++++++++++++
 arch/arm64/kernel/Makefile     |   1 +
 arch/arm64/kernel/acpi.c       | 101 +++++++++++++++++++++++++++++++++++++++++
 arch/arm64/kernel/setup.c      |   5 ++
 5 files changed, 170 insertions(+)
 create mode 100644 arch/arm64/include/asm/acenv.h
 create mode 100644 arch/arm64/include/asm/acpi.h
 create mode 100644 arch/arm64/kernel/acpi.c

diff --git a/arch/arm64/include/asm/acenv.h b/arch/arm64/include/asm/acenv.h
new file mode 100644
index 0000000..b49166f
--- /dev/null
+++ b/arch/arm64/include/asm/acenv.h
@@ -0,0 +1,18 @@
+/*
+ * ARM64 specific ACPICA environments and implementation
+ *
+ * Copyright (C) 2014, Linaro Ltd.
+ *   Author: Hanjun Guo <hanjun.guo@linaro.org>
+ *   Author: Graeme Gregory <graeme.gregory@linaro.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef _ASM_ACENV_H
+#define _ASM_ACENV_H
+
+/* It is required unconditionally by ACPI core, update it when needed. */
+
+#endif /* _ASM_ACENV_H */
diff --git a/arch/arm64/include/asm/acpi.h b/arch/arm64/include/asm/acpi.h
new file mode 100644
index 0000000..8b837ab
--- /dev/null
+++ b/arch/arm64/include/asm/acpi.h
@@ -0,0 +1,45 @@
+/*
+ *  Copyright (C) 2013-2014, Linaro Ltd.
+ *	Author: Al Stone <al.stone@linaro.org>
+ *	Author: Graeme Gregory <graeme.gregory@linaro.org>
+ *	Author: Hanjun Guo <hanjun.guo@linaro.org>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation;
+ */
+
+#ifndef _ASM_ACPI_H
+#define _ASM_ACPI_H
+
+/* Basic configuration for ACPI */
+#ifdef	CONFIG_ACPI
+#define acpi_strict 1	/* No out-of-spec workarounds on ARM64 */
+extern int acpi_disabled;
+extern int acpi_noirq;
+extern int acpi_pci_disabled;
+
+static inline void disable_acpi(void)
+{
+	acpi_disabled = 1;
+	acpi_pci_disabled = 1;
+	acpi_noirq = 1;
+}
+
+/*
+ * It's used from ACPI core in kdump to boot UP system with SMP kernel,
+ * with this check the ACPI core will not override the CPU index
+ * obtained from GICC with 0 and not print some error message as well.
+ * Since MADT must provide at least one GICC structure for GIC
+ * initialization, CPU will be always available in MADT on ARM64.
+ */
+static inline bool acpi_has_cpu_in_madt(void)
+{
+	return true;
+}
+
+static inline void arch_fix_phys_package_id(int num, u32 slot) { }
+
+#endif /* CONFIG_ACPI */
+
+#endif /*_ASM_ACPI_H*/
diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile
index bef04af..218eb7e 100644
--- a/arch/arm64/kernel/Makefile
+++ b/arch/arm64/kernel/Makefile
@@ -34,6 +34,7 @@ arm64-obj-$(CONFIG_KGDB)		+= kgdb.o
 arm64-obj-$(CONFIG_EFI)			+= efi.o efi-stub.o efi-entry.o
 arm64-obj-$(CONFIG_PCI)			+= pci.o
 arm64-obj-$(CONFIG_ARMV8_DEPRECATED)	+= armv8_deprecated.o
+arm64-obj-$(CONFIG_ACPI)		+= acpi.o
 
 obj-y					+= $(arm64-obj-y) vdso/
 obj-m					+= $(arm64-obj-m)
diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c
new file mode 100644
index 0000000..f052e7a
--- /dev/null
+++ b/arch/arm64/kernel/acpi.c
@@ -0,0 +1,101 @@
+/*
+ *  ARM64 Specific Low-Level ACPI Boot Support
+ *
+ *  Copyright (C) 2013-2014, Linaro Ltd.
+ *	Author: Al Stone <al.stone@linaro.org>
+ *	Author: Graeme Gregory <graeme.gregory@linaro.org>
+ *	Author: Hanjun Guo <hanjun.guo@linaro.org>
+ *	Author: Tomasz Nowicki <tomasz.nowicki@linaro.org>
+ *	Author: Naresh Bhat <naresh.bhat@linaro.org>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ */
+
+#define pr_fmt(fmt) "ACPI: " fmt
+
+#include <linux/acpi.h>
+#include <linux/bootmem.h>
+#include <linux/cpumask.h>
+#include <linux/init.h>
+#include <linux/irq.h>
+#include <linux/irqdomain.h>
+#include <linux/memblock.h>
+#include <linux/smp.h>
+
+int acpi_noirq;			/* skip ACPI IRQ initialization */
+int acpi_disabled;
+EXPORT_SYMBOL(acpi_disabled);
+
+int acpi_pci_disabled;		/* skip ACPI PCI scan and IRQ initialization */
+EXPORT_SYMBOL(acpi_pci_disabled);
+
+/*
+ * __acpi_map_table() will be called before page_init(), so early_ioremap()
+ * or early_memremap() should be called here to for ACPI table mapping.
+ */
+char *__init __acpi_map_table(unsigned long phys, unsigned long size)
+{
+	if (!phys || !size)
+		return NULL;
+
+	return early_memremap(phys, size);
+}
+
+void __init __acpi_unmap_table(char *map, unsigned long size)
+{
+	if (!map || !size)
+		return;
+
+	early_memunmap(map, size);
+}
+
+static int __init acpi_parse_fadt(struct acpi_table_header *table)
+{
+	struct acpi_table_fadt *fadt = (struct acpi_table_fadt *)table;
+
+	/*
+	 * Revision in table header is the FADT Major revision, and there
+	 * is a minor revision of FADT which was introduced by ACPI 5.1,
+	 * we only deal with ACPI 5.1 or newer revision to get GIC and SMP
+	 * boot protocol configuration data, or we will disable ACPI.
+	 */
+	if (table->revision > 5 ||
+	    (table->revision == 5 && fadt->minor_revision >= 1))
+		return 0;
+
+	pr_warn("Unsupported FADT revision %d.%d, should be 5.1+, will disable ACPI\n",
+		table->revision, fadt->minor_revision);
+	disable_acpi();
+
+	return -EINVAL;
+}
+
+/*
+ * acpi_boot_table_init() called from setup_arch(), always.
+ *	1. find RSDP and get its address, and then find XSDT
+ *	2. extract all tables and checksums them all
+ *	3. check ACPI FADT revision
+ *
+ * We can parse ACPI boot-time tables such as MADT after
+ * this function is called.
+ */
+void __init acpi_boot_table_init(void)
+{
+	/* If acpi_disabled, bail out */
+	if (acpi_disabled)
+		return;
+
+	/* Initialize the ACPI boot-time table parser. */
+	if (acpi_table_init()) {
+		disable_acpi();
+		return;
+	}
+
+	if (acpi_table_parse(ACPI_SIG_FADT, acpi_parse_fadt)) {
+		/* disable ACPI if no FADT is found */
+		disable_acpi();
+		pr_err("Can't find FADT\n");
+	}
+}
diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
index e8420f6..4f1a014 100644
--- a/arch/arm64/kernel/setup.c
+++ b/arch/arm64/kernel/setup.c
@@ -17,6 +17,7 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include <linux/acpi.h>
 #include <linux/export.h>
 #include <linux/kernel.h>
 #include <linux/stddef.h>
@@ -46,6 +47,7 @@
 #include <linux/efi.h>
 #include <linux/personality.h>
 
+#include <asm/acpi.h>
 #include <asm/fixmap.h>
 #include <asm/cpu.h>
 #include <asm/cputype.h>
@@ -380,6 +382,9 @@ void __init setup_arch(char **cmdline_p)
 	efi_init();
 	arm64_memblock_init();
 
+	/* Parse the ACPI tables for possible boot-time configuration */
+	acpi_boot_table_init();
+
 	paging_init();
 	request_standard_resources();
 
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v9 06/21] ACPI: fix acpi_os_ioremap for arm64
  2015-02-25  8:39 [PATCH v9 00/21] Introduce ACPI for ARM64 based on ACPI 5.1 Hanjun Guo
                   ` (4 preceding siblings ...)
  2015-02-25  8:39 ` [PATCH v9 05/21] ARM64 / ACPI: Get RSDP and ACPI boot-time tables Hanjun Guo
@ 2015-02-25  8:39 ` Hanjun Guo
  2015-03-04 22:36   ` Rafael J. Wysocki
  2015-03-06 20:30   ` Grant Likely
  2015-02-25  8:39 ` [PATCH v9 07/21] ACPI / sleep: Introduce arm64 specific acpi_sleep.c Hanjun Guo
                   ` (17 subsequent siblings)
  23 siblings, 2 replies; 106+ messages in thread
From: Hanjun Guo @ 2015-02-25  8:39 UTC (permalink / raw)
  To: Catalin Marinas, Rafael J. Wysocki, Will Deacon, Olof Johansson,
	Grant Likely
  Cc: Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi, Mark Salter, Hanjun Guo

From: Mark Salter <msalter@redhat.com>

The acpi_os_ioremap() function may be used to map normal RAM or IO
regions. The current implementation simply uses ioremap_cache(). This
will work for some architectures, but arm64 ioremap_cache() cannot be
used to map IO regions which don't support caching. So for arm64, use
ioremap() for non-RAM regions.

CC: Rafael J Wysocki <rjw@rjwysocki.net>
CC: Catalin Marinas <catalin.marinas@arm.com>
Tested-by: Robert Richter <rrichter@cavium.com>
Acked-by: Robert Richter <rrichter@cavium.com>
Signed-off-by: Mark Salter <msalter@redhat.com>
Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
---
 arch/arm64/include/asm/acpi.h | 13 +++++++++++++
 include/acpi/acpi_io.h        |  4 ++++
 2 files changed, 17 insertions(+)

diff --git a/arch/arm64/include/asm/acpi.h b/arch/arm64/include/asm/acpi.h
index 8b837ab..40e0924 100644
--- a/arch/arm64/include/asm/acpi.h
+++ b/arch/arm64/include/asm/acpi.h
@@ -12,8 +12,21 @@
 #ifndef _ASM_ACPI_H
 #define _ASM_ACPI_H
 
+#include <linux/mm.h>
+
 /* Basic configuration for ACPI */
 #ifdef	CONFIG_ACPI
+/* ACPI table mapping after acpi_gbl_permanent_mmap is set */
+static inline void __iomem *acpi_os_ioremap(acpi_physical_address phys,
+					    acpi_size size)
+{
+	if (!page_is_ram(phys >> PAGE_SHIFT))
+		return ioremap(phys, size);
+
+	return ioremap_cache(phys, size);
+}
+#define acpi_os_ioremap acpi_os_ioremap
+
 #define acpi_strict 1	/* No out-of-spec workarounds on ARM64 */
 extern int acpi_disabled;
 extern int acpi_noirq;
diff --git a/include/acpi/acpi_io.h b/include/acpi/acpi_io.h
index 444671e..dd86c5f 100644
--- a/include/acpi/acpi_io.h
+++ b/include/acpi/acpi_io.h
@@ -3,11 +3,15 @@
 
 #include <linux/io.h>
 
+#include <asm/acpi.h>
+
+#ifndef acpi_os_ioremap
 static inline void __iomem *acpi_os_ioremap(acpi_physical_address phys,
 					    acpi_size size)
 {
        return ioremap_cache(phys, size);
 }
+#endif
 
 void __iomem *__init_refok
 acpi_os_map_iomem(acpi_physical_address phys, acpi_size size);
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v9 07/21] ACPI / sleep: Introduce arm64 specific acpi_sleep.c
  2015-02-25  8:39 [PATCH v9 00/21] Introduce ACPI for ARM64 based on ACPI 5.1 Hanjun Guo
                   ` (5 preceding siblings ...)
  2015-02-25  8:39 ` [PATCH v9 06/21] ACPI: fix acpi_os_ioremap for arm64 Hanjun Guo
@ 2015-02-25  8:39 ` Hanjun Guo
  2015-03-04 22:38   ` Rafael J. Wysocki
  2015-03-06 20:34   ` Grant Likely
  2015-02-25  8:39 ` [PATCH v9 08/21] ARM64 / ACPI: Introduce PCI stub functions for ACPI Hanjun Guo
                   ` (16 subsequent siblings)
  23 siblings, 2 replies; 106+ messages in thread
From: Hanjun Guo @ 2015-02-25  8:39 UTC (permalink / raw)
  To: Catalin Marinas, Rafael J. Wysocki, Will Deacon, Olof Johansson,
	Grant Likely
  Cc: Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi, Tomasz Nowicki, Hanjun Guo

From: Graeme Gregory <graeme.gregory@linaro.org>

ACPI 5.1 does not currently support S states for ARM64 hardware but
ACPI code will call acpi_target_system_state() for device power
management, so introduce acpi_sleep.c to allow other drivers to function
until S states are defined.

Since it is arm64 specific stub holder, so let acpi_sleep.c to ARM64
specific.

TODO: merge this with drivers/acpi/sleep.c once we fix the specification.

CC: Rafael J. Wysocki <rjw@rjwysocki.net>
Tested-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
Tested-by: Yijing Wang <wangyijing@huawei.com>
Tested-by: Mark Langsdorf <mlangsdo@redhat.com>
Tested-by: Jon Masters <jcm@redhat.com>
Tested-by: Timur Tabi <timur@codeaurora.org>
Tested-by: Robert Richter <rrichter@cavium.com>
Acked-by: Robert Richter <rrichter@cavium.com>
Signed-off-by: Graeme Gregory <graeme.gregory@linaro.org>
Signed-off-by: Tomasz Nowicki <tomasz.nowicki@linaro.org>
Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
---
 arch/arm64/kernel/Makefile     |  2 +-
 arch/arm64/kernel/acpi_sleep.c | 28 ++++++++++++++++++++++++++++
 drivers/acpi/Makefile          |  2 ++
 3 files changed, 31 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm64/kernel/acpi_sleep.c

diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile
index 218eb7e..4435943 100644
--- a/arch/arm64/kernel/Makefile
+++ b/arch/arm64/kernel/Makefile
@@ -34,7 +34,7 @@ arm64-obj-$(CONFIG_KGDB)		+= kgdb.o
 arm64-obj-$(CONFIG_EFI)			+= efi.o efi-stub.o efi-entry.o
 arm64-obj-$(CONFIG_PCI)			+= pci.o
 arm64-obj-$(CONFIG_ARMV8_DEPRECATED)	+= armv8_deprecated.o
-arm64-obj-$(CONFIG_ACPI)		+= acpi.o
+arm64-obj-$(CONFIG_ACPI)		+= acpi.o acpi_sleep.o
 
 obj-y					+= $(arm64-obj-y) vdso/
 obj-m					+= $(arm64-obj-m)
diff --git a/arch/arm64/kernel/acpi_sleep.c b/arch/arm64/kernel/acpi_sleep.c
new file mode 100644
index 0000000..54578ef
--- /dev/null
+++ b/arch/arm64/kernel/acpi_sleep.c
@@ -0,0 +1,28 @@
+/*
+ *  ARM64 Specific Sleep Functionality
+ *
+ *  Copyright (C) 2013-2014, Linaro Ltd.
+ *      Author: Graeme Gregory <graeme.gregory@linaro.org>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ */
+
+#include <linux/acpi.h>
+
+/*
+ * Currently the ACPI 5.1 standard does not define S states in a
+ * manner which is usable for ARM64. These two stubs are sufficient
+ * that system initialises and device PM works.
+ */
+u32 acpi_target_system_state(void)
+{
+	return ACPI_STATE_S0;
+}
+EXPORT_SYMBOL_GPL(acpi_target_system_state);
+
+int __init acpi_sleep_init(void)
+{
+	return -ENOSYS;
+}
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
index 623b117..c32edf5 100644
--- a/drivers/acpi/Makefile
+++ b/drivers/acpi/Makefile
@@ -23,7 +23,9 @@ acpi-y				+= nvs.o
 
 # Power management related files
 acpi-y				+= wakeup.o
+ifneq (,$(findstring $(ARCH),x86 ia64))
 acpi-y				+= sleep.o
+endif
 acpi-y				+= device_pm.o
 acpi-$(CONFIG_ACPI_SLEEP)	+= proc.o
 
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v9 08/21] ARM64 / ACPI: Introduce PCI stub functions for ACPI
  2015-02-25  8:39 [PATCH v9 00/21] Introduce ACPI for ARM64 based on ACPI 5.1 Hanjun Guo
                   ` (6 preceding siblings ...)
  2015-02-25  8:39 ` [PATCH v9 07/21] ACPI / sleep: Introduce arm64 specific acpi_sleep.c Hanjun Guo
@ 2015-02-25  8:39 ` Hanjun Guo
  2015-03-06 18:31   ` Lorenzo Pieralisi
                     ` (2 more replies)
  2015-02-25  8:39 ` [PATCH v9 09/21] ARM64 / ACPI: Introduce early_param "acpi=" to enable/disable ACPI Hanjun Guo
                   ` (15 subsequent siblings)
  23 siblings, 3 replies; 106+ messages in thread
From: Hanjun Guo @ 2015-02-25  8:39 UTC (permalink / raw)
  To: Catalin Marinas, Rafael J. Wysocki, Will Deacon, Olof Johansson,
	Grant Likely
  Cc: Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi, Hanjun Guo, Liviu Dudau

CONFIG_ACPI depends CONFIG_PCI on x86 and ia64, in ARM64 server
world we will have PCIe in most cases, but some of them may not,
make CONFIG_ACPI depend CONFIG_PCI on ARM64 will satisfy both.

With that case, we need some arch dependent PCI functions to
access the config space before the PCI root bridge is created, and
pci_acpi_scan_root() to create the PCI root bus. So introduce
some stub function here to make ACPI core compile and revisit
them later when implemented on ARM64.

CC: Liviu Dudau <Liviu.Dudau@arm.com>
CC: Catalin Marinas <catalin.marinas@arm.com>
CC: Will Deacon <will.deacon@arm.com>
Tested-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
Tested-by: Yijing Wang <wangyijing@huawei.com>
Tested-by: Mark Langsdorf <mlangsdo@redhat.com>
Tested-by: Jon Masters <jcm@redhat.com>
Tested-by: Timur Tabi <timur@codeaurora.org>
Tested-by: Robert Richter <rrichter@cavium.com>
Acked-by: Robert Richter <rrichter@cavium.com>
Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
---
 arch/arm64/include/asm/pci.h |  6 ++++++
 arch/arm64/kernel/pci.c      | 25 +++++++++++++++++++++++++
 2 files changed, 31 insertions(+)

diff --git a/arch/arm64/include/asm/pci.h b/arch/arm64/include/asm/pci.h
index 872ba93..fded096 100644
--- a/arch/arm64/include/asm/pci.h
+++ b/arch/arm64/include/asm/pci.h
@@ -24,6 +24,12 @@
  */
 #define PCI_DMA_BUS_IS_PHYS	(0)
 
+static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
+{
+	/* no legacy IRQ on arm64 */
+	return -ENODEV;
+}
+
 extern int isa_dma_bridge_buggy;
 
 #ifdef CONFIG_PCI
diff --git a/arch/arm64/kernel/pci.c b/arch/arm64/kernel/pci.c
index 6f93c24..4095379 100644
--- a/arch/arm64/kernel/pci.c
+++ b/arch/arm64/kernel/pci.c
@@ -10,6 +10,7 @@
  *
  */
 
+#include <linux/acpi.h>
 #include <linux/init.h>
 #include <linux/io.h>
 #include <linux/kernel.h>
@@ -46,3 +47,27 @@ int pcibios_add_device(struct pci_dev *dev)
 
 	return 0;
 }
+
+/*
+ * raw_pci_read/write - Platform-specific PCI config space access.
+ */
+int raw_pci_read(unsigned int domain, unsigned int bus,
+		  unsigned int devfn, int reg, int len, u32 *val)
+{
+	return -ENXIO;
+}
+
+int raw_pci_write(unsigned int domain, unsigned int bus,
+		unsigned int devfn, int reg, int len, u32 val)
+{
+	return -ENXIO;
+}
+
+#ifdef CONFIG_ACPI
+/* Root bridge scanning */
+struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
+{
+	/* TODO: Should be revisited when implementing PCI on ACPI */
+	return NULL;
+}
+#endif
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v9 09/21] ARM64 / ACPI: Introduce early_param "acpi=" to enable/disable ACPI
  2015-02-25  8:39 [PATCH v9 00/21] Introduce ACPI for ARM64 based on ACPI 5.1 Hanjun Guo
                   ` (7 preceding siblings ...)
  2015-02-25  8:39 ` [PATCH v9 08/21] ARM64 / ACPI: Introduce PCI stub functions for ACPI Hanjun Guo
@ 2015-02-25  8:39 ` Hanjun Guo
  2015-03-05 18:11   ` Olof Johansson
  2015-03-06 20:37   ` Grant Likely
  2015-02-25  8:39 ` [PATCH v9 10/21] ARM64 / ACPI: If we chose to boot from acpi then disable FDT Hanjun Guo
                   ` (14 subsequent siblings)
  23 siblings, 2 replies; 106+ messages in thread
From: Hanjun Guo @ 2015-02-25  8:39 UTC (permalink / raw)
  To: Catalin Marinas, Rafael J. Wysocki, Will Deacon, Olof Johansson,
	Grant Likely
  Cc: Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi, Al Stone, Hanjun Guo, Ard Biesheuvel

From: Al Stone <al.stone@linaro.org>

This implements the following policy to decide whether ACPI should
be used to boot the system:
- acpi=off: ACPI will not be used to boot the system, even if there is
  no alternative available (e.g., device tree is empty)
- acpi=force: only ACPI will be used to boot the system; if that fails,
  there will be no fallback to alternative methods (such as device tree)
- otherwise, ACPI will be used as a fallback if the device tree turns out
  to lack a platform description; the heuristic to decide this is whether
  /chosen is the only node present at depth 1

CC: Catalin Marinas <catalin.marinas@arm.com>
CC: Will Deacon <will.deacon@arm.com>
CC: Rafael J. Wysocki <rjw@rjwysocki.net>
Signed-off-by: Al Stone <al.stone@linaro.org>
Signed-off-by: Graeme Gregory <graeme.gregory@linaro.org>
Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 Documentation/kernel-parameters.txt |  3 ++-
 arch/arm64/include/asm/acpi.h       |  7 +++++
 arch/arm64/kernel/acpi.c            | 52 +++++++++++++++++++++++++++++++++----
 3 files changed, 56 insertions(+), 6 deletions(-)

diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index bfcb1a6..d6c35a7 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -165,7 +165,7 @@ multipliers 'Kilo', 'Mega', and 'Giga', equalling 2^10, 2^20, and 2^30
 bytes respectively. Such letter suffixes can also be entirely omitted.
 
 
-	acpi=		[HW,ACPI,X86]
+	acpi=		[HW,ACPI,X86,ARM64]
 			Advanced Configuration and Power Interface
 			Format: { force | off | strict | noirq | rsdt }
 			force -- enable ACPI if default was off
@@ -175,6 +175,7 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
 				strictly ACPI specification compliant.
 			rsdt -- prefer RSDT over (default) XSDT
 			copy_dsdt -- copy DSDT to memory
+			For ARM64, ONLY "acpi=off" or "acpi=force" are available
 
 			See also Documentation/power/runtime_pm.txt, pci=noacpi
 
diff --git a/arch/arm64/include/asm/acpi.h b/arch/arm64/include/asm/acpi.h
index 40e0924..c5a9b97 100644
--- a/arch/arm64/include/asm/acpi.h
+++ b/arch/arm64/include/asm/acpi.h
@@ -39,6 +39,13 @@ static inline void disable_acpi(void)
 	acpi_noirq = 1;
 }
 
+static inline void enable_acpi(void)
+{
+	acpi_disabled = 0;
+	acpi_pci_disabled = 0;
+	acpi_noirq = 0;
+}
+
 /*
  * It's used from ACPI core in kdump to boot UP system with SMP kernel,
  * with this check the ACPI core will not override the CPU index
diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c
index f052e7a..bdcc9fc 100644
--- a/arch/arm64/kernel/acpi.c
+++ b/arch/arm64/kernel/acpi.c
@@ -22,15 +22,49 @@
 #include <linux/irq.h>
 #include <linux/irqdomain.h>
 #include <linux/memblock.h>
+#include <linux/of_fdt.h>
 #include <linux/smp.h>
 
-int acpi_noirq;			/* skip ACPI IRQ initialization */
-int acpi_disabled;
+int acpi_noirq = 1;		/* skip ACPI IRQ initialization */
+int acpi_disabled = 1;
 EXPORT_SYMBOL(acpi_disabled);
 
-int acpi_pci_disabled;		/* skip ACPI PCI scan and IRQ initialization */
+int acpi_pci_disabled = 1;	/* skip ACPI PCI scan and IRQ initialization */
 EXPORT_SYMBOL(acpi_pci_disabled);
 
+static bool __initdata param_acpi_off;
+static bool __initdata param_acpi_force;
+
+static int __init parse_acpi(char *arg)
+{
+	if (!arg)
+		return -EINVAL;
+
+	/* "acpi=off" disables both ACPI table parsing and interpreter */
+	if (strcmp(arg, "off") == 0)
+		param_acpi_off = true;
+	else if (strcmp(arg, "force") == 0) /* force ACPI to be enabled */
+		param_acpi_force = true;
+	else
+		return -EINVAL;	/* Core will print when we return error */
+
+	return 0;
+}
+early_param("acpi", parse_acpi);
+
+static int __init dt_scan_depth1_nodes(unsigned long node,
+				       const char *uname, int depth,
+				       void *data)
+{
+	/*
+	 * Return 1 as soon as we encounter a node at depth 1 that is
+	 * not the /chosen node.
+	 */
+	if (depth == 1 && (strcmp(uname, "chosen") != 0))
+		return 1;
+	return 0;
+}
+
 /*
  * __acpi_map_table() will be called before page_init(), so early_ioremap()
  * or early_memremap() should be called here to for ACPI table mapping.
@@ -83,10 +117,18 @@ static int __init acpi_parse_fadt(struct acpi_table_header *table)
  */
 void __init acpi_boot_table_init(void)
 {
-	/* If acpi_disabled, bail out */
-	if (acpi_disabled)
+	/*
+	 * Enable ACPI instead of device tree unless
+	 * - ACPI has been disabled explicitly (acpi=off), or
+	 * - the device tree is not empty (it has more than just a /chosen node)
+	 *   and ACPI has not been force enabled (acpi=force)
+	 */
+	if (param_acpi_off ||
+	    (!param_acpi_force && of_scan_flat_dt(dt_scan_depth1_nodes, NULL)))
 		return;
 
+	enable_acpi();
+
 	/* Initialize the ACPI boot-time table parser. */
 	if (acpi_table_init()) {
 		disable_acpi();
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v9 10/21] ARM64 / ACPI: If we chose to boot from acpi then disable FDT
  2015-02-25  8:39 [PATCH v9 00/21] Introduce ACPI for ARM64 based on ACPI 5.1 Hanjun Guo
                   ` (8 preceding siblings ...)
  2015-02-25  8:39 ` [PATCH v9 09/21] ARM64 / ACPI: Introduce early_param "acpi=" to enable/disable ACPI Hanjun Guo
@ 2015-02-25  8:39 ` Hanjun Guo
  2015-03-05 18:12   ` Olof Johansson
  2015-03-06 20:38   ` Grant Likely
  2015-02-25  8:39 ` [PATCH v9 11/21] ARM64 / ACPI: Get PSCI flags in FADT for PSCI init Hanjun Guo
                   ` (13 subsequent siblings)
  23 siblings, 2 replies; 106+ messages in thread
From: Hanjun Guo @ 2015-02-25  8:39 UTC (permalink / raw)
  To: Catalin Marinas, Rafael J. Wysocki, Will Deacon, Olof Johansson,
	Grant Likely
  Cc: Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi, Hanjun Guo

From: Graeme Gregory <graeme.gregory@linaro.org>

If the early boot methods of acpi are happy that we have valid ACPI
tables and acpi=force has been passed, then do not unflat devicetree
effectively disabling further hardware probing from DT.

CC: Catalin Marinas <catalin.marinas@arm.com>
CC: Will Deacon <will.deacon@arm.com>
Tested-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
Tested-by: Yijing Wang <wangyijing@huawei.com>
Tested-by: Mark Langsdorf <mlangsdo@redhat.com>
Tested-by: Jon Masters <jcm@redhat.com>
Tested-by: Timur Tabi <timur@codeaurora.org>
Tested-by: Robert Richter <rrichter@cavium.com>
Acked-by: Robert Richter <rrichter@cavium.com>
Signed-off-by: Graeme Gregory <graeme.gregory@linaro.org>
Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
---
 arch/arm64/kernel/setup.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
index 4f1a014..e8c7000 100644
--- a/arch/arm64/kernel/setup.c
+++ b/arch/arm64/kernel/setup.c
@@ -390,7 +390,8 @@ void __init setup_arch(char **cmdline_p)
 
 	early_ioremap_reset();
 
-	unflatten_device_tree();
+	if (acpi_disabled)
+		unflatten_device_tree();
 
 	psci_init();
 
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v9 11/21] ARM64 / ACPI: Get PSCI flags in FADT for PSCI init
  2015-02-25  8:39 [PATCH v9 00/21] Introduce ACPI for ARM64 based on ACPI 5.1 Hanjun Guo
                   ` (9 preceding siblings ...)
  2015-02-25  8:39 ` [PATCH v9 10/21] ARM64 / ACPI: If we chose to boot from acpi then disable FDT Hanjun Guo
@ 2015-02-25  8:39 ` Hanjun Guo
  2015-03-05 18:19   ` Olof Johansson
  2015-03-06 20:40   ` Grant Likely
  2015-02-25  8:39 ` [PATCH v9 12/21] ACPI / table: Print GIC information when MADT is parsed Hanjun Guo
                   ` (12 subsequent siblings)
  23 siblings, 2 replies; 106+ messages in thread
From: Hanjun Guo @ 2015-02-25  8:39 UTC (permalink / raw)
  To: Catalin Marinas, Rafael J. Wysocki, Will Deacon, Olof Johansson,
	Grant Likely
  Cc: Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi, Lorenzo Pieralisi, Tomasz Nowicki,
	Hanjun Guo

From: Graeme Gregory <graeme.gregory@linaro.org>

There are two flags: PSCI_COMPLIANT and PSCI_USE_HVC. When set,
the former signals to the OS that the firmware is PSCI compliant.
The latter selects the appropriate conduit for PSCI calls by
toggling between Hypervisor Calls (HVC) and Secure Monitor Calls
(SMC).

FADT table contains such information in ACPI 5.1, FADT table was
parsed in ACPI table init and copy to struct acpi_gbl_FADT, so
use the flags in struct acpi_gbl_FADT for PSCI init.

Since ACPI 5.1 doesn't support self defined PSCI function IDs,
which means that only PSCI 0.2+ is supported in ACPI.

CC: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
CC: Catalin Marinas <catalin.marinas@arm.com>
CC: Will Deacon <will.deacon@arm.com>
Tested-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
Tested-by: Yijing Wang <wangyijing@huawei.com>
Tested-by: Mark Langsdorf <mlangsdo@redhat.com>
Tested-by: Jon Masters <jcm@redhat.com>
Tested-by: Timur Tabi <timur@codeaurora.org>
Tested-by: Robert Richter <rrichter@cavium.com>
Acked-by: Robert Richter <rrichter@cavium.com>
Signed-off-by: Graeme Gregory <graeme.gregory@linaro.org>
Signed-off-by: Tomasz Nowicki <tomasz.nowicki@linaro.org>
Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
---
 arch/arm64/include/asm/acpi.h | 15 +++++++++
 arch/arm64/include/asm/psci.h |  3 +-
 arch/arm64/kernel/psci.c      | 78 ++++++++++++++++++++++++++++++-------------
 arch/arm64/kernel/setup.c     |  8 +++--
 4 files changed, 76 insertions(+), 28 deletions(-)

diff --git a/arch/arm64/include/asm/acpi.h b/arch/arm64/include/asm/acpi.h
index c5a9b97..9ea650c 100644
--- a/arch/arm64/include/asm/acpi.h
+++ b/arch/arm64/include/asm/acpi.h
@@ -32,6 +32,18 @@ extern int acpi_disabled;
 extern int acpi_noirq;
 extern int acpi_pci_disabled;
 
+/* 1 to indicate PSCI 0.2+ is implemented */
+static inline bool acpi_psci_present(void)
+{
+	return acpi_gbl_FADT.arm_boot_flags & ACPI_FADT_PSCI_COMPLIANT;
+}
+
+/* 1 to indicate HVC must be used instead of SMC as the PSCI conduit */
+static inline bool acpi_psci_use_hvc(void)
+{
+	return acpi_gbl_FADT.arm_boot_flags & ACPI_FADT_PSCI_USE_HVC;
+}
+
 static inline void disable_acpi(void)
 {
 	acpi_disabled = 1;
@@ -60,6 +72,9 @@ static inline bool acpi_has_cpu_in_madt(void)
 
 static inline void arch_fix_phys_package_id(int num, u32 slot) { }
 
+#else
+static inline bool acpi_psci_present(void) { return false; }
+static inline bool acpi_psci_use_hvc(void) { return false; }
 #endif /* CONFIG_ACPI */
 
 #endif /*_ASM_ACPI_H*/
diff --git a/arch/arm64/include/asm/psci.h b/arch/arm64/include/asm/psci.h
index e5312ea..2454bc5 100644
--- a/arch/arm64/include/asm/psci.h
+++ b/arch/arm64/include/asm/psci.h
@@ -14,6 +14,7 @@
 #ifndef __ASM_PSCI_H
 #define __ASM_PSCI_H
 
-int psci_init(void);
+int psci_dt_init(void);
+int psci_acpi_init(void);
 
 #endif /* __ASM_PSCI_H */
diff --git a/arch/arm64/kernel/psci.c b/arch/arm64/kernel/psci.c
index 3425f31..bab2bea 100644
--- a/arch/arm64/kernel/psci.c
+++ b/arch/arm64/kernel/psci.c
@@ -15,6 +15,7 @@
 
 #define pr_fmt(fmt) "psci: " fmt
 
+#include <linux/acpi.h>
 #include <linux/init.h>
 #include <linux/of.h>
 #include <linux/smp.h>
@@ -24,6 +25,7 @@
 #include <linux/slab.h>
 #include <uapi/linux/psci.h>
 
+#include <asm/acpi.h>
 #include <asm/compiler.h>
 #include <asm/cpu_ops.h>
 #include <asm/errno.h>
@@ -304,6 +306,33 @@ static void psci_sys_poweroff(void)
 	invoke_psci_fn(PSCI_0_2_FN_SYSTEM_OFF, 0, 0, 0);
 }
 
+static void __init psci_0_2_set_functions(void)
+{
+	pr_info("Using standard PSCI v0.2 function IDs\n");
+	psci_function_id[PSCI_FN_CPU_SUSPEND] = PSCI_0_2_FN64_CPU_SUSPEND;
+	psci_ops.cpu_suspend = psci_cpu_suspend;
+
+	psci_function_id[PSCI_FN_CPU_OFF] = PSCI_0_2_FN_CPU_OFF;
+	psci_ops.cpu_off = psci_cpu_off;
+
+	psci_function_id[PSCI_FN_CPU_ON] = PSCI_0_2_FN64_CPU_ON;
+	psci_ops.cpu_on = psci_cpu_on;
+
+	psci_function_id[PSCI_FN_MIGRATE] = PSCI_0_2_FN64_MIGRATE;
+	psci_ops.migrate = psci_migrate;
+
+	psci_function_id[PSCI_FN_AFFINITY_INFO] = PSCI_0_2_FN64_AFFINITY_INFO;
+	psci_ops.affinity_info = psci_affinity_info;
+
+	psci_function_id[PSCI_FN_MIGRATE_INFO_TYPE] =
+		PSCI_0_2_FN_MIGRATE_INFO_TYPE;
+	psci_ops.migrate_info_type = psci_migrate_info_type;
+
+	arm_pm_restart = psci_sys_reset;
+
+	pm_power_off = psci_sys_poweroff;
+}
+
 /*
  * PSCI Function IDs for v0.2+ are well defined so use
  * standard values.
@@ -337,29 +366,7 @@ static int __init psci_0_2_init(struct device_node *np)
 		}
 	}
 
-	pr_info("Using standard PSCI v0.2 function IDs\n");
-	psci_function_id[PSCI_FN_CPU_SUSPEND] = PSCI_0_2_FN64_CPU_SUSPEND;
-	psci_ops.cpu_suspend = psci_cpu_suspend;
-
-	psci_function_id[PSCI_FN_CPU_OFF] = PSCI_0_2_FN_CPU_OFF;
-	psci_ops.cpu_off = psci_cpu_off;
-
-	psci_function_id[PSCI_FN_CPU_ON] = PSCI_0_2_FN64_CPU_ON;
-	psci_ops.cpu_on = psci_cpu_on;
-
-	psci_function_id[PSCI_FN_MIGRATE] = PSCI_0_2_FN64_MIGRATE;
-	psci_ops.migrate = psci_migrate;
-
-	psci_function_id[PSCI_FN_AFFINITY_INFO] = PSCI_0_2_FN64_AFFINITY_INFO;
-	psci_ops.affinity_info = psci_affinity_info;
-
-	psci_function_id[PSCI_FN_MIGRATE_INFO_TYPE] =
-		PSCI_0_2_FN_MIGRATE_INFO_TYPE;
-	psci_ops.migrate_info_type = psci_migrate_info_type;
-
-	arm_pm_restart = psci_sys_reset;
-
-	pm_power_off = psci_sys_poweroff;
+	psci_0_2_set_functions();
 
 out_put_node:
 	of_node_put(np);
@@ -412,7 +419,7 @@ static const struct of_device_id psci_of_match[] __initconst = {
 	{},
 };
 
-int __init psci_init(void)
+int __init psci_dt_init(void)
 {
 	struct device_node *np;
 	const struct of_device_id *matched_np;
@@ -427,6 +434,29 @@ int __init psci_init(void)
 	return init_fn(np);
 }
 
+/*
+ * We use PSCI 0.2+ when ACPI is deployed on ARM64 and it's
+ * explicitly clarified in SBBR
+ */
+int __init psci_acpi_init(void)
+{
+	if (!acpi_psci_present()) {
+		pr_info("is not implemented in ACPI.\n");
+		return -EOPNOTSUPP;
+	}
+
+	pr_info("probing for conduit method from ACPI.\n");
+
+	if (acpi_psci_use_hvc())
+		invoke_psci_fn = __invoke_psci_fn_hvc;
+	else
+		invoke_psci_fn = __invoke_psci_fn_smc;
+
+	psci_0_2_set_functions();
+
+	return 0;
+}
+
 #ifdef CONFIG_SMP
 
 static int __init cpu_psci_cpu_init(struct device_node *dn, unsigned int cpu)
diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
index e8c7000..97fa7f3 100644
--- a/arch/arm64/kernel/setup.c
+++ b/arch/arm64/kernel/setup.c
@@ -390,10 +390,12 @@ void __init setup_arch(char **cmdline_p)
 
 	early_ioremap_reset();
 
-	if (acpi_disabled)
+	if (acpi_disabled) {
 		unflatten_device_tree();
-
-	psci_init();
+		psci_dt_init();
+	} else {
+		psci_acpi_init();
+	}
 
 	cpu_read_bootcpu_ops();
 #ifdef CONFIG_SMP
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v9 12/21] ACPI / table: Print GIC information when MADT is parsed
  2015-02-25  8:39 [PATCH v9 00/21] Introduce ACPI for ARM64 based on ACPI 5.1 Hanjun Guo
                   ` (10 preceding siblings ...)
  2015-02-25  8:39 ` [PATCH v9 11/21] ARM64 / ACPI: Get PSCI flags in FADT for PSCI init Hanjun Guo
@ 2015-02-25  8:39 ` Hanjun Guo
  2015-03-04 22:40   ` Rafael J. Wysocki
                     ` (2 more replies)
  2015-02-25  8:39 ` [PATCH v9 13/21] ARM64 / ACPI: Parse MADT for SMP initialization Hanjun Guo
                   ` (11 subsequent siblings)
  23 siblings, 3 replies; 106+ messages in thread
From: Hanjun Guo @ 2015-02-25  8:39 UTC (permalink / raw)
  To: Catalin Marinas, Rafael J. Wysocki, Will Deacon, Olof Johansson,
	Grant Likely
  Cc: Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi, Hanjun Guo, Tomasz Nowicki

When MADT is parsed, print GIC information as debug message:

ACPI: GICC (acpi_id[0x0000] address[00000000e112f000] MPIDR[0x0] enabled)
ACPI: GICC (acpi_id[0x0001] address[00000000e112f000] MPIDR[0x1] enabled)
...
ACPI: GICC (acpi_id[0x0201] address[00000000e112f000] MPIDR[0x201] enabled)

Those debug information will be very helpful to bring up early systems to
see if acpi_id and MPIDR are matched or not as spec defined.

CC: Rafael J. Wysocki <rjw@rjwysocki.net>
Tested-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
Tested-by: Yijing Wang <wangyijing@huawei.com>
Tested-by: Mark Langsdorf <mlangsdo@redhat.com>
Tested-by: Jon Masters <jcm@redhat.com>
Tested-by: Timur Tabi <timur@codeaurora.org>
Tested-by: Robert Richter <rrichter@cavium.com>
Acked-by: Robert Richter <rrichter@cavium.com>
Acked-by: Sudeep Holla <sudeep.holla@arm.com>
Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
Signed-off-by: Tomasz Nowicki <tomasz.nowicki@linaro.org>
---
 drivers/acpi/tables.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c
index f4e5b88..2e19189 100644
--- a/drivers/acpi/tables.c
+++ b/drivers/acpi/tables.c
@@ -185,6 +185,28 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header)
 		}
 		break;
 
+	case ACPI_MADT_TYPE_GENERIC_INTERRUPT:
+		{
+			struct acpi_madt_generic_interrupt *p =
+				(struct acpi_madt_generic_interrupt *)header;
+			pr_debug("GICC (acpi_id[0x%04x] address[%llx] MPIDR[0x%llx] %s)\n",
+				 p->uid, p->base_address,
+				 p->arm_mpidr,
+				 (p->flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled");
+
+		}
+		break;
+
+	case ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR:
+		{
+			struct acpi_madt_generic_distributor *p =
+				(struct acpi_madt_generic_distributor *)header;
+			pr_debug("GIC Distributor (gic_id[0x%04x] address[%llx] gsi_base[%d])\n",
+				 p->gic_id, p->base_address,
+				 p->global_irq_base);
+		}
+		break;
+
 	default:
 		pr_warn("Found unsupported MADT entry (type = 0x%x)\n",
 			header->type);
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v9 13/21] ARM64 / ACPI: Parse MADT for SMP initialization
  2015-02-25  8:39 [PATCH v9 00/21] Introduce ACPI for ARM64 based on ACPI 5.1 Hanjun Guo
                   ` (11 preceding siblings ...)
  2015-02-25  8:39 ` [PATCH v9 12/21] ACPI / table: Print GIC information when MADT is parsed Hanjun Guo
@ 2015-02-25  8:39 ` Hanjun Guo
  2015-03-05 18:49   ` Olof Johansson
  2015-03-07 22:49   ` Grant Likely
  2015-02-25  8:39 ` [PATCH v9 14/21] ACPI / processor: Make it possible to get CPU hardware ID via GICC Hanjun Guo
                   ` (10 subsequent siblings)
  23 siblings, 2 replies; 106+ messages in thread
From: Hanjun Guo @ 2015-02-25  8:39 UTC (permalink / raw)
  To: Catalin Marinas, Rafael J. Wysocki, Will Deacon, Olof Johansson,
	Grant Likely
  Cc: Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi, Hanjun Guo, Lorenzo Pieralisi,
	Tomasz Nowicki

MADT contains the information for MPIDR which is essential for
SMP initialization, parse the GIC cpu interface structures to
get the MPIDR value and map it to cpu_logical_map(), and add
enabled cpu with valid MPIDR into cpu_possible_map.

ACPI 5.1 only has two explicit methods to boot up SMP, PSCI and
Parking protocol, but the Parking protocol is only specified for
ARMv7 now, so make PSCI as the only way for the SMP boot protocol
before some updates for the ACPI spec or the Parking protocol spec.

Parking protocol patches for SMP boot will be sent to upstream when
the new version of Parking protocol is ready.

CC: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
CC: Catalin Marinas <catalin.marinas@arm.com>
CC: Will Deacon <will.deacon@arm.com>
CC: Mark Rutland <mark.rutland@arm.com>
Tested-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
Tested-by: Yijing Wang <wangyijing@huawei.com>
Tested-by: Mark Langsdorf <mlangsdo@redhat.com>
Tested-by: Jon Masters <jcm@redhat.com>
Tested-by: Timur Tabi <timur@codeaurora.org>
Tested-by: Robert Richter <rrichter@cavium.com>
Acked-by: Robert Richter <rrichter@cavium.com>
Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
Signed-off-by: Tomasz Nowicki <tomasz.nowicki@linaro.org>
---
 arch/arm64/include/asm/acpi.h    |   2 +
 arch/arm64/include/asm/cpu_ops.h |   1 +
 arch/arm64/include/asm/smp.h     |   5 +-
 arch/arm64/kernel/acpi.c         | 149 ++++++++++++++++++++++++++++++++++++++-
 arch/arm64/kernel/cpu_ops.c      |   2 +-
 arch/arm64/kernel/setup.c        |   7 +-
 arch/arm64/kernel/smp.c          |   2 +-
 7 files changed, 160 insertions(+), 8 deletions(-)

diff --git a/arch/arm64/include/asm/acpi.h b/arch/arm64/include/asm/acpi.h
index 9ea650c..9719921 100644
--- a/arch/arm64/include/asm/acpi.h
+++ b/arch/arm64/include/asm/acpi.h
@@ -71,10 +71,12 @@ static inline bool acpi_has_cpu_in_madt(void)
 }
 
 static inline void arch_fix_phys_package_id(int num, u32 slot) { }
+void __init acpi_init_cpus(void);
 
 #else
 static inline bool acpi_psci_present(void) { return false; }
 static inline bool acpi_psci_use_hvc(void) { return false; }
+static inline void acpi_init_cpus(void) { }
 #endif /* CONFIG_ACPI */
 
 #endif /*_ASM_ACPI_H*/
diff --git a/arch/arm64/include/asm/cpu_ops.h b/arch/arm64/include/asm/cpu_ops.h
index da301ee..5a31d67 100644
--- a/arch/arm64/include/asm/cpu_ops.h
+++ b/arch/arm64/include/asm/cpu_ops.h
@@ -66,5 +66,6 @@ struct cpu_operations {
 extern const struct cpu_operations *cpu_ops[NR_CPUS];
 int __init cpu_read_ops(struct device_node *dn, int cpu);
 void __init cpu_read_bootcpu_ops(void);
+const struct cpu_operations *cpu_get_ops(const char *name);
 
 #endif /* ifndef __ASM_CPU_OPS_H */
diff --git a/arch/arm64/include/asm/smp.h b/arch/arm64/include/asm/smp.h
index 780f82c..bf22650 100644
--- a/arch/arm64/include/asm/smp.h
+++ b/arch/arm64/include/asm/smp.h
@@ -39,9 +39,10 @@ extern void show_ipi_list(struct seq_file *p, int prec);
 extern void handle_IPI(int ipinr, struct pt_regs *regs);
 
 /*
- * Setup the set of possible CPUs (via set_cpu_possible)
+ * Discover the set of possible CPUs and determine their
+ * SMP operations.
  */
-extern void smp_init_cpus(void);
+extern void of_smp_init_cpus(void);
 
 /*
  * Provide a function to raise an IPI cross call on CPUs in callmap.
diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c
index bdcc9fc..0f35d87 100644
--- a/arch/arm64/kernel/acpi.c
+++ b/arch/arm64/kernel/acpi.c
@@ -25,6 +25,10 @@
 #include <linux/of_fdt.h>
 #include <linux/smp.h>
 
+#include <asm/cputype.h>
+#include <asm/cpu_ops.h>
+#include <asm/smp_plat.h>
+
 int acpi_noirq = 1;		/* skip ACPI IRQ initialization */
 int acpi_disabled = 1;
 EXPORT_SYMBOL(acpi_disabled);
@@ -32,6 +36,12 @@ EXPORT_SYMBOL(acpi_disabled);
 int acpi_pci_disabled = 1;	/* skip ACPI PCI scan and IRQ initialization */
 EXPORT_SYMBOL(acpi_pci_disabled);
 
+/* Processors with enabled flag and sane MPIDR */
+static int enabled_cpus;
+
+/* Boot CPU is valid or not in MADT */
+static bool __initdata bootcpu_valid;
+
 static bool __initdata param_acpi_off;
 static bool __initdata param_acpi_force;
 
@@ -85,6 +95,129 @@ void __init __acpi_unmap_table(char *map, unsigned long size)
 	early_memunmap(map, size);
 }
 
+/**
+ * acpi_map_gic_cpu_interface - generates a logical cpu number
+ * and map to MPIDR represented by GICC structure
+ * @mpidr: CPU's hardware id to register, MPIDR represented in MADT
+ * @enabled: this cpu is enabled or not
+ *
+ * Returns the logical cpu number which maps to MPIDR
+ */
+static int __init acpi_map_gic_cpu_interface(u64 mpidr, u8 enabled)
+{
+	int i;
+
+	if (mpidr == INVALID_HWID) {
+		pr_info("Skip MADT cpu entry with invalid MPIDR\n");
+		return -EINVAL;
+	}
+
+	total_cpus++;
+	if (!enabled)
+		return -EINVAL;
+
+	if (enabled_cpus >=  NR_CPUS) {
+		pr_warn("NR_CPUS limit of %d reached, Processor %d/0x%llx ignored.\n",
+			NR_CPUS, total_cpus, mpidr);
+		return -EINVAL;
+	}
+
+	/* Check if GICC structure of boot CPU is available in the MADT */
+	if (cpu_logical_map(0) == mpidr) {
+		if (bootcpu_valid) {
+			pr_err("Firmware bug, duplicate CPU MPIDR: 0x%llx in MADT\n",
+			       mpidr);
+			return -EINVAL;
+		}
+
+		bootcpu_valid = true;
+	}
+
+	/*
+	 * Duplicate MPIDRs are a recipe for disaster. Scan
+	 * all initialized entries and check for
+	 * duplicates. If any is found just ignore the CPU.
+	 */
+	for (i = 1; i < enabled_cpus; i++) {
+		if (cpu_logical_map(i) == mpidr) {
+			pr_err("Firmware bug, duplicate CPU MPIDR: 0x%llx in MADT\n",
+			       mpidr);
+			return -EINVAL;
+		}
+	}
+
+	if (!acpi_psci_present())
+		return -EOPNOTSUPP;
+
+	cpu_ops[enabled_cpus] = cpu_get_ops("psci");
+	/* CPU 0 was already initialized */
+	if (enabled_cpus) {
+		if (!cpu_ops[enabled_cpus])
+			return -EINVAL;
+
+		if (cpu_ops[enabled_cpus]->cpu_init(NULL, enabled_cpus))
+			return -EOPNOTSUPP;
+
+		/* map the logical cpu id to cpu MPIDR */
+		cpu_logical_map(enabled_cpus) = mpidr;
+	}
+
+	enabled_cpus++;
+	return enabled_cpus;
+}
+
+static int __init
+acpi_parse_gic_cpu_interface(struct acpi_subtable_header *header,
+				const unsigned long end)
+{
+	struct acpi_madt_generic_interrupt *processor;
+
+	processor = (struct acpi_madt_generic_interrupt *)header;
+
+	if (BAD_MADT_ENTRY(processor, end))
+		return -EINVAL;
+
+	acpi_table_print_madt_entry(header);
+
+	acpi_map_gic_cpu_interface(processor->arm_mpidr & MPIDR_HWID_BITMASK,
+		processor->flags & ACPI_MADT_ENABLED);
+
+	return 0;
+}
+
+/* Parse GIC cpu interface entries in MADT for SMP init */
+void __init acpi_init_cpus(void)
+{
+	int count, i;
+
+	/*
+	 * do a partial walk of MADT to determine how many CPUs
+	 * we have including disabled CPUs, and get information
+	 * we need for SMP init
+	 */
+	count = acpi_table_parse_madt(ACPI_MADT_TYPE_GENERIC_INTERRUPT,
+			acpi_parse_gic_cpu_interface, 0);
+
+	if (!count) {
+		pr_err("No GIC CPU interface entries present\n");
+		return;
+	} else if (count < 0) {
+		pr_err("Error parsing GIC CPU interface entry\n");
+		return;
+	}
+
+	if (!bootcpu_valid) {
+		pr_err("MADT missing boot CPU MPIDR, not enabling secondaries\n");
+		return;
+	}
+
+	for (i = 0; i < enabled_cpus; i++)
+		set_cpu_possible(i, true);
+
+	/* Make boot-up look pretty */
+	pr_info("%d CPUs enabled, %d CPUs total\n", enabled_cpus, total_cpus);
+}
+
 static int __init acpi_parse_fadt(struct acpi_table_header *table)
 {
 	struct acpi_table_fadt *fadt = (struct acpi_table_fadt *)table;
@@ -96,8 +229,20 @@ static int __init acpi_parse_fadt(struct acpi_table_header *table)
 	 * boot protocol configuration data, or we will disable ACPI.
 	 */
 	if (table->revision > 5 ||
-	    (table->revision == 5 && fadt->minor_revision >= 1))
-		return 0;
+	    (table->revision == 5 && fadt->minor_revision >= 1)) {
+		/*
+		 * ACPI 5.1 only has two explicit methods to boot up SMP,
+		 * PSCI and Parking protocol, but the Parking protocol is
+		 * only specified for ARMv7 now, so make PSCI as the only
+		 * way for the SMP boot protocol before some updates for
+		 * the Parking protocol spec.
+		 */
+		if (acpi_psci_present())
+			return 0;
+
+		pr_warn("No PSCI support, will not bring up secondary CPUs\n");
+		return -EOPNOTSUPP;
+	}
 
 	pr_warn("Unsupported FADT revision %d.%d, should be 5.1+, will disable ACPI\n",
 		table->revision, fadt->minor_revision);
diff --git a/arch/arm64/kernel/cpu_ops.c b/arch/arm64/kernel/cpu_ops.c
index cce9524..fb8ff9b 100644
--- a/arch/arm64/kernel/cpu_ops.c
+++ b/arch/arm64/kernel/cpu_ops.c
@@ -35,7 +35,7 @@ static const struct cpu_operations *supported_cpu_ops[] __initconst = {
 	NULL,
 };
 
-static const struct cpu_operations * __init cpu_get_ops(const char *name)
+const struct cpu_operations * __init cpu_get_ops(const char *name)
 {
 	const struct cpu_operations **ops = supported_cpu_ops;
 
diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
index 97fa7f3..b278311 100644
--- a/arch/arm64/kernel/setup.c
+++ b/arch/arm64/kernel/setup.c
@@ -393,13 +393,16 @@ void __init setup_arch(char **cmdline_p)
 	if (acpi_disabled) {
 		unflatten_device_tree();
 		psci_dt_init();
+		cpu_read_bootcpu_ops();
+#ifdef CONFIG_SMP
+		of_smp_init_cpus();
+#endif
 	} else {
 		psci_acpi_init();
+		acpi_init_cpus();
 	}
 
-	cpu_read_bootcpu_ops();
 #ifdef CONFIG_SMP
-	smp_init_cpus();
 	smp_build_mpidr_hash();
 #endif
 
diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c
index 328b8ce..52998b7 100644
--- a/arch/arm64/kernel/smp.c
+++ b/arch/arm64/kernel/smp.c
@@ -322,7 +322,7 @@ void __init smp_prepare_boot_cpu(void)
  * cpu logical map array containing MPIDR values related to logical
  * cpus. Assumes that cpu_logical_map(0) has already been initialized.
  */
-void __init smp_init_cpus(void)
+void __init of_smp_init_cpus(void)
 {
 	struct device_node *dn = NULL;
 	unsigned int i, cpu = 1;
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v9 14/21] ACPI / processor: Make it possible to get CPU hardware ID via GICC
  2015-02-25  8:39 [PATCH v9 00/21] Introduce ACPI for ARM64 based on ACPI 5.1 Hanjun Guo
                   ` (12 preceding siblings ...)
  2015-02-25  8:39 ` [PATCH v9 13/21] ARM64 / ACPI: Parse MADT for SMP initialization Hanjun Guo
@ 2015-02-25  8:39 ` Hanjun Guo
  2015-03-04 22:46   ` Rafael J. Wysocki
  2015-03-07 22:52   ` Grant Likely
  2015-02-25  8:39 ` [PATCH v9 15/21] ARM64 / ACPI: Introduce ACPI_IRQ_MODEL_GIC and register device's gsi Hanjun Guo
                   ` (9 subsequent siblings)
  23 siblings, 2 replies; 106+ messages in thread
From: Hanjun Guo @ 2015-02-25  8:39 UTC (permalink / raw)
  To: Catalin Marinas, Rafael J. Wysocki, Will Deacon, Olof Johansson,
	Grant Likely
  Cc: Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi, Hanjun Guo

Introduce a new function map_gicc_mpidr() to allow MPIDRs to be obtained
from the GICC Structure introduced by ACPI 5.1.

The ARM architecture defines the MPIDR register as the CPU hardware
identifier. This patch adds the code infrastructure to retrieve the MPIDR
values from the ARM ACPI GICC structure in order to look-up the kernel CPU
hardware ids required by the ACPI core code to identify CPUs.

CC: Rafael J. Wysocki <rjw@rjwysocki.net>
CC: Catalin Marinas <catalin.marinas@arm.com>
CC: Will Deacon <will.deacon@arm.com>
Tested-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
Tested-by: Yijing Wang <wangyijing@huawei.com>
Tested-by: Mark Langsdorf <mlangsdo@redhat.com>
Tested-by: Jon Masters <jcm@redhat.com>
Tested-by: Timur Tabi <timur@codeaurora.org>
Tested-by: Robert Richter <rrichter@cavium.com>
Acked-by: Robert Richter <rrichter@cavium.com>
Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
---
 arch/arm64/include/asm/acpi.h | 12 ++++++++++++
 drivers/acpi/processor_core.c | 30 ++++++++++++++++++++++++++++++
 2 files changed, 42 insertions(+)

diff --git a/arch/arm64/include/asm/acpi.h b/arch/arm64/include/asm/acpi.h
index 9719921..9a23369 100644
--- a/arch/arm64/include/asm/acpi.h
+++ b/arch/arm64/include/asm/acpi.h
@@ -13,6 +13,8 @@
 #define _ASM_ACPI_H
 
 #include <linux/mm.h>
+#include <asm/cputype.h>
+#include <asm/smp_plat.h>
 
 /* Basic configuration for ACPI */
 #ifdef	CONFIG_ACPI
@@ -27,6 +29,9 @@ static inline void __iomem *acpi_os_ioremap(acpi_physical_address phys,
 }
 #define acpi_os_ioremap acpi_os_ioremap
 
+typedef u64 phys_cpuid_t;
+#define CPU_PHYS_ID_INVALID INVALID_HWID
+
 #define acpi_strict 1	/* No out-of-spec workarounds on ARM64 */
 extern int acpi_disabled;
 extern int acpi_noirq;
@@ -59,6 +64,13 @@ static inline void enable_acpi(void)
 }
 
 /*
+ * The ACPI processor driver for ACPI core code needs this macro
+ * to find out this cpu was already mapped (mapping from CPU hardware
+ * ID to CPU logical ID) or not.
+ */
+#define cpu_physical_id(cpu) cpu_logical_map(cpu)
+
+/*
  * It's used from ACPI core in kdump to boot UP system with SMP kernel,
  * with this check the ACPI core will not override the CPU index
  * obtained from GICC with 0 and not print some error message as well.
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c
index a5547dc..8654adb 100644
--- a/drivers/acpi/processor_core.c
+++ b/drivers/acpi/processor_core.c
@@ -83,6 +83,31 @@ static int map_lsapic_id(struct acpi_subtable_header *entry,
 	return 0;
 }
 
+/*
+ * Retrieve the ARM CPU physical identifier (MPIDR)
+ */
+static int map_gicc_mpidr(struct acpi_subtable_header *entry,
+		int device_declaration, u32 acpi_id, phys_cpuid_t *mpidr)
+{
+	struct acpi_madt_generic_interrupt *gicc =
+	    container_of(entry, struct acpi_madt_generic_interrupt, header);
+
+	if (!(gicc->flags & ACPI_MADT_ENABLED))
+		return -ENODEV;
+
+	/* device_declaration means Device object in DSDT, In the
+	 * GIC interrupt model, logical processors are required to
+	 * have a Processor Device object in the DSDT, so we should
+	 * check device_declaration here
+	 */
+	if (device_declaration && (gicc->uid == acpi_id)) {
+		*mpidr = gicc->arm_mpidr;
+		return 0;
+	}
+
+	return -EINVAL;
+}
+
 static phys_cpuid_t map_madt_entry(int type, u32 acpi_id)
 {
 	unsigned long madt_end, entry;
@@ -111,6 +136,9 @@ static phys_cpuid_t map_madt_entry(int type, u32 acpi_id)
 		} else if (header->type == ACPI_MADT_TYPE_LOCAL_SAPIC) {
 			if (!map_lsapic_id(header, type, acpi_id, &phys_id))
 				break;
+		} else if (header->type == ACPI_MADT_TYPE_GENERIC_INTERRUPT) {
+			if (!map_gicc_mpidr(header, type, acpi_id, &phys_id))
+				break;
 		}
 		entry += header->length;
 	}
@@ -143,6 +171,8 @@ static phys_cpuid_t map_mat_entry(acpi_handle handle, int type, u32 acpi_id)
 		map_lsapic_id(header, type, acpi_id, &phys_id);
 	else if (header->type == ACPI_MADT_TYPE_LOCAL_X2APIC)
 		map_x2apic_id(header, type, acpi_id, &phys_id);
+	else if (header->type == ACPI_MADT_TYPE_GENERIC_INTERRUPT)
+		map_gicc_mpidr(header, type, acpi_id, &phys_id);
 
 exit:
 	kfree(buffer.pointer);
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v9 15/21] ARM64 / ACPI: Introduce ACPI_IRQ_MODEL_GIC and register device's gsi
  2015-02-25  8:39 [PATCH v9 00/21] Introduce ACPI for ARM64 based on ACPI 5.1 Hanjun Guo
                   ` (13 preceding siblings ...)
  2015-02-25  8:39 ` [PATCH v9 14/21] ACPI / processor: Make it possible to get CPU hardware ID via GICC Hanjun Guo
@ 2015-02-25  8:39 ` Hanjun Guo
  2015-03-04 22:47   ` Rafael J. Wysocki
  2015-03-07 23:05   ` Grant Likely
  2015-02-25  8:39 ` [PATCH v9 16/21] irqchip: Add GICv2 specific ACPI boot support Hanjun Guo
                   ` (8 subsequent siblings)
  23 siblings, 2 replies; 106+ messages in thread
From: Hanjun Guo @ 2015-02-25  8:39 UTC (permalink / raw)
  To: Catalin Marinas, Rafael J. Wysocki, Will Deacon, Olof Johansson,
	Grant Likely
  Cc: Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi, Hanjun Guo

Introduce ACPI_IRQ_MODEL_GIC which is needed for ARM64 as GIC is
used, and then register device's gsi with the core IRQ subsystem.

acpi_register_gsi() is similar to DT based irq_of_parse_and_map(),
since gsi is unique in the system, so use hwirq number directly
for the mapping.

We are going to implement stacked domains when GICv2m, GICv3, ITS
support are added.

CC: Marc Zyngier <marc.zyngier@arm.com>
Originally-by: Amit Daniel Kachhap <amit.daniel@samsung.com>
Tested-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
Tested-by: Yijing Wang <wangyijing@huawei.com>
Tested-by: Mark Langsdorf <mlangsdo@redhat.com>
Tested-by: Jon Masters <jcm@redhat.com>
Tested-by: Timur Tabi <timur@codeaurora.org>
Tested-by: Robert Richter <rrichter@cavium.com>
Acked-by: Robert Richter <rrichter@cavium.com>
Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
---
 arch/arm64/kernel/acpi.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++++
 drivers/acpi/bus.c       |  3 ++
 include/linux/acpi.h     |  1 +
 3 files changed, 77 insertions(+)

diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c
index 0f35d87..31f080e 100644
--- a/arch/arm64/kernel/acpi.c
+++ b/arch/arm64/kernel/acpi.c
@@ -76,6 +76,12 @@ static int __init dt_scan_depth1_nodes(unsigned long node,
 }
 
 /*
+ * Since we're on ARM, the default interrupt routing model
+ * clearly has to be GIC.
+ */
+enum acpi_irq_model_id acpi_irq_model = ACPI_IRQ_MODEL_GIC;
+
+/*
  * __acpi_map_table() will be called before page_init(), so early_ioremap()
  * or early_memremap() should be called here to for ACPI table mapping.
  */
@@ -218,6 +224,73 @@ void __init acpi_init_cpus(void)
 	pr_info("%d CPUs enabled, %d CPUs total\n", enabled_cpus, total_cpus);
 }
 
+int acpi_gsi_to_irq(u32 gsi, unsigned int *irq)
+{
+	*irq = irq_find_mapping(NULL, gsi);
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(acpi_gsi_to_irq);
+
+/*
+ * success: return IRQ number (>0)
+ * failure: return =< 0
+ */
+int acpi_register_gsi(struct device *dev, u32 gsi, int trigger, int polarity)
+{
+	unsigned int irq;
+	unsigned int irq_type;
+
+	/*
+	 * ACPI have no bindings to indicate SPI or PPI, so we
+	 * use different mappings from DT in ACPI.
+	 *
+	 * For FDT
+	 * PPI interrupt: in the range [0, 15];
+	 * SPI interrupt: in the range [0, 987];
+	 *
+	 * For ACPI, GSI should be unique so using
+	 * the hwirq directly for the mapping:
+	 * PPI interrupt: in the range [16, 31];
+	 * SPI interrupt: in the range [32, 1019];
+	 */
+
+	if (trigger == ACPI_EDGE_SENSITIVE &&
+				polarity == ACPI_ACTIVE_LOW)
+		irq_type = IRQ_TYPE_EDGE_FALLING;
+	else if (trigger == ACPI_EDGE_SENSITIVE &&
+				polarity == ACPI_ACTIVE_HIGH)
+		irq_type = IRQ_TYPE_EDGE_RISING;
+	else if (trigger == ACPI_LEVEL_SENSITIVE &&
+				polarity == ACPI_ACTIVE_LOW)
+		irq_type = IRQ_TYPE_LEVEL_LOW;
+	else if (trigger == ACPI_LEVEL_SENSITIVE &&
+				polarity == ACPI_ACTIVE_HIGH)
+		irq_type = IRQ_TYPE_LEVEL_HIGH;
+	else
+		irq_type = IRQ_TYPE_NONE;
+
+	/*
+	 * Since only one GIC is supported in ACPI 5.0, we can
+	 * create mapping refer to the default domain
+	 */
+	irq = irq_create_mapping(NULL, gsi);
+	if (!irq)
+		return irq;
+
+	/* Set irq type if specified and different than the current one */
+	if (irq_type != IRQ_TYPE_NONE &&
+		irq_type != irq_get_trigger_type(irq))
+		irq_set_irq_type(irq, irq_type);
+	return irq;
+}
+EXPORT_SYMBOL_GPL(acpi_register_gsi);
+
+void acpi_unregister_gsi(u32 gsi)
+{
+}
+EXPORT_SYMBOL_GPL(acpi_unregister_gsi);
+
 static int __init acpi_parse_fadt(struct acpi_table_header *table)
 {
 	struct acpi_table_fadt *fadt = (struct acpi_table_fadt *)table;
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index 8b67bd0..c412fdb 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -448,6 +448,9 @@ static int __init acpi_bus_init_irq(void)
 	case ACPI_IRQ_MODEL_IOSAPIC:
 		message = "IOSAPIC";
 		break;
+	case ACPI_IRQ_MODEL_GIC:
+		message = "GIC";
+		break;
 	case ACPI_IRQ_MODEL_PLATFORM:
 		message = "platform specific model";
 		break;
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 0eabd15..c03d8d1 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -73,6 +73,7 @@ enum acpi_irq_model_id {
 	ACPI_IRQ_MODEL_IOAPIC,
 	ACPI_IRQ_MODEL_IOSAPIC,
 	ACPI_IRQ_MODEL_PLATFORM,
+	ACPI_IRQ_MODEL_GIC,
 	ACPI_IRQ_MODEL_COUNT
 };
 
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v9 16/21] irqchip: Add GICv2 specific ACPI boot support
  2015-02-25  8:39 [PATCH v9 00/21] Introduce ACPI for ARM64 based on ACPI 5.1 Hanjun Guo
                   ` (14 preceding siblings ...)
  2015-02-25  8:39 ` [PATCH v9 15/21] ARM64 / ACPI: Introduce ACPI_IRQ_MODEL_GIC and register device's gsi Hanjun Guo
@ 2015-02-25  8:39 ` Hanjun Guo
  2015-03-04 22:50   ` Rafael J. Wysocki
                     ` (2 more replies)
  2015-02-25  8:39 ` [PATCH v9 17/21] clocksource / arch_timer: Parse GTDT to initialize arch timer Hanjun Guo
                   ` (7 subsequent siblings)
  23 siblings, 3 replies; 106+ messages in thread
From: Hanjun Guo @ 2015-02-25  8:39 UTC (permalink / raw)
  To: Catalin Marinas, Rafael J. Wysocki, Will Deacon, Olof Johansson,
	Grant Likely
  Cc: Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi, Tomasz Nowicki, Jason Cooper,
	Thomas Gleixner, Hanjun Guo

From: Tomasz Nowicki <tomasz.nowicki@linaro.org>

ACPI kernel uses MADT table for proper GIC initialization. It needs to
parse GIC related subtables, collect CPU interface and distributor
addresses and call driver initialization function (which is hardware
abstraction agnostic). In a similar way, FDT initialize GICv1/2.

NOTE: This commit allow to initialize GICv1/2 basic functionality.
While now simple GICv2 init call is used, any further GIC features
require generic infrastructure for proper ACPI irqchip initialization.
That mechanism and stacked irqdomains to support GICv2 MSI/virtualization
extension, GICv3/4 and its ITS are considered as next steps.

CC: Jason Cooper <jason@lakedaemon.net>
CC: Marc Zyngier <marc.zyngier@arm.com>
CC: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
Tested-by: Yijing Wang <wangyijing@huawei.com>
Tested-by: Mark Langsdorf <mlangsdo@redhat.com>
Tested-by: Jon Masters <jcm@redhat.com>
Tested-by: Timur Tabi <timur@codeaurora.org>
Tested-by: Robert Richter <rrichter@cavium.com>
Acked-by: Robert Richter <rrichter@cavium.com>
Signed-off-by: Tomasz Nowicki <tomasz.nowicki@linaro.org>
Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
---
 arch/arm64/include/asm/acpi.h        |   2 +
 arch/arm64/kernel/acpi.c             |  25 +++++++++
 drivers/irqchip/irq-gic.c            | 102 +++++++++++++++++++++++++++++++++++
 drivers/irqchip/irqchip.c            |   3 ++
 include/linux/acpi.h                 |  14 +++++
 include/linux/irqchip/arm-gic-acpi.h |  29 ++++++++++
 6 files changed, 175 insertions(+)
 create mode 100644 include/linux/irqchip/arm-gic-acpi.h

diff --git a/arch/arm64/include/asm/acpi.h b/arch/arm64/include/asm/acpi.h
index 9a23369..a720a61 100644
--- a/arch/arm64/include/asm/acpi.h
+++ b/arch/arm64/include/asm/acpi.h
@@ -13,6 +13,8 @@
 #define _ASM_ACPI_H
 
 #include <linux/mm.h>
+#include <linux/irqchip/arm-gic-acpi.h>
+
 #include <asm/cputype.h>
 #include <asm/smp_plat.h>
 
diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c
index 31f080e..af308c3 100644
--- a/arch/arm64/kernel/acpi.c
+++ b/arch/arm64/kernel/acpi.c
@@ -359,3 +359,28 @@ void __init acpi_boot_table_init(void)
 		pr_err("Can't find FADT\n");
 	}
 }
+
+void __init acpi_gic_init(void)
+{
+	struct acpi_table_header *table;
+	acpi_status status;
+	acpi_size tbl_size;
+	int err;
+
+	if (acpi_disabled)
+		return;
+
+	status = acpi_get_table_with_size(ACPI_SIG_MADT, 0, &table, &tbl_size);
+	if (ACPI_FAILURE(status)) {
+		const char *msg = acpi_format_exception(status);
+
+		pr_err("Failed to get MADT table, %s\n", msg);
+		return;
+	}
+
+	err = gic_v2_acpi_init(table);
+	if (err)
+		pr_err("Failed to initialize GIC IRQ controller");
+
+	early_acpi_os_unmap_memory((char *)table, tbl_size);
+}
diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
index 4634cf7..929d668 100644
--- a/drivers/irqchip/irq-gic.c
+++ b/drivers/irqchip/irq-gic.c
@@ -33,12 +33,14 @@
 #include <linux/of.h>
 #include <linux/of_address.h>
 #include <linux/of_irq.h>
+#include <linux/acpi.h>
 #include <linux/irqdomain.h>
 #include <linux/interrupt.h>
 #include <linux/percpu.h>
 #include <linux/slab.h>
 #include <linux/irqchip/chained_irq.h>
 #include <linux/irqchip/arm-gic.h>
+#include <linux/irqchip/arm-gic-acpi.h>
 
 #include <asm/cputype.h>
 #include <asm/irq.h>
@@ -1086,3 +1088,103 @@ IRQCHIP_DECLARE(msm_8660_qgic, "qcom,msm-8660-qgic", gic_of_init);
 IRQCHIP_DECLARE(msm_qgic2, "qcom,msm-qgic2", gic_of_init);
 
 #endif
+
+#ifdef CONFIG_ACPI
+static phys_addr_t dist_phy_base, cpu_phy_base __initdata;
+
+static int __init
+gic_acpi_parse_madt_cpu(struct acpi_subtable_header *header,
+			const unsigned long end)
+{
+	struct acpi_madt_generic_interrupt *processor;
+	phys_addr_t gic_cpu_base;
+	static int cpu_base_assigned;
+
+	processor = (struct acpi_madt_generic_interrupt *)header;
+
+	if (BAD_MADT_ENTRY(processor, end))
+		return -EINVAL;
+
+	/*
+	 * There is no support for non-banked GICv1/2 register in ACPI spec.
+	 * All CPU interface addresses have to be the same.
+	 */
+	gic_cpu_base = processor->base_address;
+	if (cpu_base_assigned && gic_cpu_base != cpu_phy_base)
+		return -EINVAL;
+
+	cpu_phy_base = gic_cpu_base;
+	cpu_base_assigned = 1;
+	return 0;
+}
+
+static int __init
+gic_acpi_parse_madt_distributor(struct acpi_subtable_header *header,
+				const unsigned long end)
+{
+	struct acpi_madt_generic_distributor *dist;
+
+	dist = (struct acpi_madt_generic_distributor *)header;
+
+	if (BAD_MADT_ENTRY(dist, end))
+		return -EINVAL;
+
+	dist_phy_base = dist->base_address;
+	return 0;
+}
+
+int __init
+gic_v2_acpi_init(struct acpi_table_header *table)
+{
+	void __iomem *cpu_base, *dist_base;
+	int count;
+
+	/* Collect CPU base addresses */
+	count = acpi_parse_entries(ACPI_SIG_MADT,
+				   sizeof(struct acpi_table_madt),
+				   gic_acpi_parse_madt_cpu, table,
+				   ACPI_MADT_TYPE_GENERIC_INTERRUPT, 0);
+	if (count <= 0) {
+		pr_err("No valid GICC entries exist\n");
+		return -EINVAL;
+	}
+
+	/*
+	 * Find distributor base address. We expect one distributor entry since
+	 * ACPI 5.1 spec neither support multi-GIC instances nor GIC cascade.
+	 */
+	count = acpi_parse_entries(ACPI_SIG_MADT,
+				   sizeof(struct acpi_table_madt),
+				   gic_acpi_parse_madt_distributor, table,
+				   ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR, 0);
+	if (count <= 0) {
+		pr_err("No valid GICD entries exist\n");
+		return -EINVAL;
+	} else if (count > 1) {
+		pr_err("More than one GICD entry detected\n");
+		return -EINVAL;
+	}
+
+	cpu_base = ioremap(cpu_phy_base, ACPI_GIC_CPU_IF_MEM_SIZE);
+	if (!cpu_base) {
+		pr_err("Unable to map GICC registers\n");
+		return -ENOMEM;
+	}
+
+	dist_base = ioremap(dist_phy_base, ACPI_GICV2_DIST_MEM_SIZE);
+	if (!dist_base) {
+		pr_err("Unable to map GICD registers\n");
+		iounmap(cpu_base);
+		return -ENOMEM;
+	}
+
+	/*
+	 * Initialize zero GIC instance (no multi-GIC support). Also, set GIC
+	 * as default IRQ domain to allow for GSI registration and GSI to IRQ
+	 * number translation (see acpi_register_gsi() and acpi_gsi_to_irq()).
+	 */
+	gic_init_bases(0, -1, dist_base, cpu_base, 0, NULL);
+	irq_set_default_host(gic_data[0].domain);
+	return 0;
+}
+#endif
diff --git a/drivers/irqchip/irqchip.c b/drivers/irqchip/irqchip.c
index 0fe2f71..5855240 100644
--- a/drivers/irqchip/irqchip.c
+++ b/drivers/irqchip/irqchip.c
@@ -8,6 +8,7 @@
  * warranty of any kind, whether express or implied.
  */
 
+#include <linux/acpi.h>
 #include <linux/init.h>
 #include <linux/of_irq.h>
 #include <linux/irqchip.h>
@@ -26,4 +27,6 @@ extern struct of_device_id __irqchip_of_table[];
 void __init irqchip_init(void)
 {
 	of_irq_init(__irqchip_of_table);
+
+	acpi_irq_init();
 }
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index c03d8d1..e27117a 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -557,6 +557,20 @@ static inline int acpi_device_modalias(struct device *dev,
 
 #endif	/* !CONFIG_ACPI */
 
+#if defined(CONFIG_ACPI) && defined(CONFIG_ARM64)
+static inline void acpi_irq_init(void)
+{
+	/*
+	 * Hardcode ACPI IRQ chip initialization to GICv2 for now.
+	 * Proper irqchip infrastructure will be implemented along with
+	 * incoming  GICv2m|GICv3|ITS bits.
+	 */
+	acpi_gic_init();
+}
+#else
+static inline void acpi_irq_init(void) { }
+#endif
+
 #ifdef CONFIG_ACPI
 void acpi_os_set_prepare_sleep(int (*func)(u8 sleep_state,
 			       u32 pm1a_ctrl,  u32 pm1b_ctrl));
diff --git a/include/linux/irqchip/arm-gic-acpi.h b/include/linux/irqchip/arm-gic-acpi.h
new file mode 100644
index 0000000..d5b2c79
--- /dev/null
+++ b/include/linux/irqchip/arm-gic-acpi.h
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2014, Linaro Ltd.
+ *	Author: Tomasz Nowicki <tomasz.nowicki@linaro.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef ARM_GIC_ACPI_H_
+#define ARM_GIC_ACPI_H_
+
+#ifdef CONFIG_ACPI
+
+/*
+ * Hard code here, we can not get memory size from MADT (but FDT does),
+ * Actually no need to do that, because this size can be inferred
+ * from GIC spec.
+ */
+#define ACPI_GICV2_DIST_MEM_SIZE	(SZ_4K)
+#define ACPI_GIC_CPU_IF_MEM_SIZE	(SZ_8K)
+
+struct acpi_table_header;
+
+int gic_v2_acpi_init(struct acpi_table_header *table);
+void acpi_gic_init(void);
+#endif
+
+#endif /* ARM_GIC_ACPI_H_ */
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v9 17/21] clocksource / arch_timer: Parse GTDT to initialize arch timer
  2015-02-25  8:39 [PATCH v9 00/21] Introduce ACPI for ARM64 based on ACPI 5.1 Hanjun Guo
                   ` (15 preceding siblings ...)
  2015-02-25  8:39 ` [PATCH v9 16/21] irqchip: Add GICv2 specific ACPI boot support Hanjun Guo
@ 2015-02-25  8:39 ` Hanjun Guo
  2015-03-07 23:16   ` Grant Likely
  2015-02-25  8:39 ` [PATCH v9 18/21] ARM64 / ACPI: Select ACPI_REDUCED_HARDWARE_ONLY if ACPI is enabled on ARM64 Hanjun Guo
                   ` (6 subsequent siblings)
  23 siblings, 1 reply; 106+ messages in thread
From: Hanjun Guo @ 2015-02-25  8:39 UTC (permalink / raw)
  To: Catalin Marinas, Rafael J. Wysocki, Will Deacon, Olof Johansson,
	Grant Likely
  Cc: Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi, Hanjun Guo, Daniel Lezcano,
	Thomas Gleixner

Using the information presented by GTDT (Generic Timer Description Table)
to initialize the arch timer (not memory-mapped).

CC: Daniel Lezcano <daniel.lezcano@linaro.org>
CC: Thomas Gleixner <tglx@linutronix.de>
Originally-by: Amit Daniel Kachhap <amit.daniel@samsung.com>
Tested-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
Tested-by: Yijing Wang <wangyijing@huawei.com>
Tested-by: Mark Langsdorf <mlangsdo@redhat.com>
Tested-by: Jon Masters <jcm@redhat.com>
Tested-by: Timur Tabi <timur@codeaurora.org>
Tested-by: Robert Richter <rrichter@cavium.com>
Acked-by: Robert Richter <rrichter@cavium.com>
Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
---
 arch/arm64/kernel/time.c             |   7 ++
 drivers/clocksource/arm_arch_timer.c | 132 ++++++++++++++++++++++++++++-------
 include/linux/clocksource.h          |   6 ++
 3 files changed, 118 insertions(+), 27 deletions(-)

diff --git a/arch/arm64/kernel/time.c b/arch/arm64/kernel/time.c
index 1a7125c..42f9195 100644
--- a/arch/arm64/kernel/time.c
+++ b/arch/arm64/kernel/time.c
@@ -35,6 +35,7 @@
 #include <linux/delay.h>
 #include <linux/clocksource.h>
 #include <linux/clk-provider.h>
+#include <linux/acpi.h>
 
 #include <clocksource/arm_arch_timer.h>
 
@@ -72,6 +73,12 @@ void __init time_init(void)
 
 	tick_setup_hrtimer_broadcast();
 
+	/*
+	 * Since ACPI or FDT will only one be available in the system,
+	 * we can use acpi_generic_timer_init() here safely
+	 */
+	acpi_generic_timer_init();
+
 	arch_timer_rate = arch_timer_get_rate();
 	if (!arch_timer_rate)
 		panic("Unable to initialise architected timer.\n");
diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
index a3025e7..ea62fc7 100644
--- a/drivers/clocksource/arm_arch_timer.c
+++ b/drivers/clocksource/arm_arch_timer.c
@@ -22,6 +22,7 @@
 #include <linux/io.h>
 #include <linux/slab.h>
 #include <linux/sched_clock.h>
+#include <linux/acpi.h>
 
 #include <asm/arch_timer.h>
 #include <asm/virt.h>
@@ -371,8 +372,12 @@ arch_timer_detect_rate(void __iomem *cntbase, struct device_node *np)
 	if (arch_timer_rate)
 		return;
 
-	/* Try to determine the frequency from the device tree or CNTFRQ */
-	if (of_property_read_u32(np, "clock-frequency", &arch_timer_rate)) {
+	/*
+	 * Try to determine the frequency from the device tree or CNTFRQ,
+	 * if ACPI is enabled, get the frequency from CNTFRQ ONLY.
+	 */
+	if (!acpi_disabled ||
+	    of_property_read_u32(np, "clock-frequency", &arch_timer_rate)) {
 		if (cntbase)
 			arch_timer_rate = readl_relaxed(cntbase + CNTFRQ);
 		else
@@ -691,28 +696,8 @@ static void __init arch_timer_common_init(void)
 	arch_timer_arch_init();
 }
 
-static void __init arch_timer_init(struct device_node *np)
+static void __init arch_timer_init(void)
 {
-	int i;
-
-	if (arch_timers_present & ARCH_CP15_TIMER) {
-		pr_warn("arch_timer: multiple nodes in dt, skipping\n");
-		return;
-	}
-
-	arch_timers_present |= ARCH_CP15_TIMER;
-	for (i = PHYS_SECURE_PPI; i < MAX_TIMER_PPI; i++)
-		arch_timer_ppi[i] = irq_of_parse_and_map(np, i);
-	arch_timer_detect_rate(NULL, np);
-
-	/*
-	 * If we cannot rely on firmware initializing the timer registers then
-	 * we should use the physical timers instead.
-	 */
-	if (IS_ENABLED(CONFIG_ARM) &&
-	    of_property_read_bool(np, "arm,cpu-registers-not-fw-configured"))
-			arch_timer_use_virtual = false;
-
 	/*
 	 * If HYP mode is available, we know that the physical timer
 	 * has been configured to be accessible from PL1. Use it, so
@@ -731,13 +716,39 @@ static void __init arch_timer_init(struct device_node *np)
 		}
 	}
 
-	arch_timer_c3stop = !of_property_read_bool(np, "always-on");
-
 	arch_timer_register();
 	arch_timer_common_init();
 }
-CLOCKSOURCE_OF_DECLARE(armv7_arch_timer, "arm,armv7-timer", arch_timer_init);
-CLOCKSOURCE_OF_DECLARE(armv8_arch_timer, "arm,armv8-timer", arch_timer_init);
+
+static void __init arch_timer_of_init(struct device_node *np)
+{
+	int i;
+
+	if (arch_timers_present & ARCH_CP15_TIMER) {
+		pr_warn("arch_timer: multiple nodes in dt, skipping\n");
+		return;
+	}
+
+	arch_timers_present |= ARCH_CP15_TIMER;
+	for (i = PHYS_SECURE_PPI; i < MAX_TIMER_PPI; i++)
+		arch_timer_ppi[i] = irq_of_parse_and_map(np, i);
+
+	arch_timer_detect_rate(NULL, np);
+
+	arch_timer_c3stop = !of_property_read_bool(np, "always-on");
+
+	/*
+	 * If we cannot rely on firmware initializing the timer registers then
+	 * we should use the physical timers instead.
+	 */
+	if (IS_ENABLED(CONFIG_ARM) &&
+	    of_property_read_bool(np, "arm,cpu-registers-not-fw-configured"))
+			arch_timer_use_virtual = false;
+
+	arch_timer_init();
+}
+CLOCKSOURCE_OF_DECLARE(armv7_arch_timer, "arm,armv7-timer", arch_timer_of_init);
+CLOCKSOURCE_OF_DECLARE(armv8_arch_timer, "arm,armv8-timer", arch_timer_of_init);
 
 static void __init arch_timer_mem_init(struct device_node *np)
 {
@@ -804,3 +815,70 @@ static void __init arch_timer_mem_init(struct device_node *np)
 }
 CLOCKSOURCE_OF_DECLARE(armv7_arch_timer_mem, "arm,armv7-timer-mem",
 		       arch_timer_mem_init);
+
+#ifdef CONFIG_ACPI
+static int __init map_generic_timer_interrupt(u32 interrupt, u32 flags)
+{
+	int trigger, polarity;
+
+	if (!interrupt)
+		return 0;
+
+	trigger = (flags & ACPI_GTDT_INTERRUPT_MODE) ? ACPI_EDGE_SENSITIVE
+			: ACPI_LEVEL_SENSITIVE;
+
+	polarity = (flags & ACPI_GTDT_INTERRUPT_POLARITY) ? ACPI_ACTIVE_LOW
+			: ACPI_ACTIVE_HIGH;
+
+	return acpi_register_gsi(NULL, interrupt, trigger, polarity);
+}
+
+/* Initialize per-processor generic timer */
+static int __init arch_timer_acpi_init(struct acpi_table_header *table)
+{
+	struct acpi_table_gtdt *gtdt;
+
+	if (arch_timers_present & ARCH_CP15_TIMER) {
+		pr_warn("arch_timer: already initialized, skipping\n");
+		return -EINVAL;
+	}
+
+	gtdt = container_of(table, struct acpi_table_gtdt, header);
+
+	arch_timers_present |= ARCH_CP15_TIMER;
+
+	arch_timer_ppi[PHYS_SECURE_PPI] =
+		map_generic_timer_interrupt(gtdt->secure_el1_interrupt,
+		gtdt->secure_el1_flags);
+
+	arch_timer_ppi[PHYS_NONSECURE_PPI] =
+		map_generic_timer_interrupt(gtdt->non_secure_el1_interrupt,
+		gtdt->non_secure_el1_flags);
+
+	arch_timer_ppi[VIRT_PPI] =
+		map_generic_timer_interrupt(gtdt->virtual_timer_interrupt,
+		gtdt->virtual_timer_flags);
+
+	arch_timer_ppi[HYP_PPI] =
+		map_generic_timer_interrupt(gtdt->non_secure_el2_interrupt,
+		gtdt->non_secure_el2_flags);
+
+	/* Get the frequency from CNTFRQ */
+	arch_timer_detect_rate(NULL, NULL);
+
+	/* Always-on capability */
+	arch_timer_c3stop = !(gtdt->non_secure_el1_flags & ACPI_GTDT_ALWAYS_ON);
+
+	arch_timer_init();
+	return 0;
+}
+
+/* Initialize all the generic timers presented in GTDT */
+void __init acpi_generic_timer_init(void)
+{
+	if (acpi_disabled)
+		return;
+
+	acpi_table_parse(ACPI_SIG_GTDT, arch_timer_acpi_init);
+}
+#endif
diff --git a/include/linux/clocksource.h b/include/linux/clocksource.h
index 9c78d15..2b2e1f8 100644
--- a/include/linux/clocksource.h
+++ b/include/linux/clocksource.h
@@ -244,4 +244,10 @@ extern void clocksource_of_init(void);
 static inline void clocksource_of_init(void) {}
 #endif
 
+#ifdef CONFIG_ACPI
+void acpi_generic_timer_init(void);
+#else
+static inline void acpi_generic_timer_init(void) { }
+#endif
+
 #endif /* _LINUX_CLOCKSOURCE_H */
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v9 18/21] ARM64 / ACPI: Select ACPI_REDUCED_HARDWARE_ONLY if ACPI is enabled on ARM64
  2015-02-25  8:39 [PATCH v9 00/21] Introduce ACPI for ARM64 based on ACPI 5.1 Hanjun Guo
                   ` (16 preceding siblings ...)
  2015-02-25  8:39 ` [PATCH v9 17/21] clocksource / arch_timer: Parse GTDT to initialize arch timer Hanjun Guo
@ 2015-02-25  8:39 ` Hanjun Guo
  2015-03-06 17:47   ` Lorenzo Pieralisi
  2015-03-07 23:16   ` Grant Likely
  2015-02-25  8:39 ` [PATCH v9 19/21] ARM64 / ACPI: Enable ARM64 in Kconfig Hanjun Guo
                   ` (5 subsequent siblings)
  23 siblings, 2 replies; 106+ messages in thread
From: Hanjun Guo @ 2015-02-25  8:39 UTC (permalink / raw)
  To: Catalin Marinas, Rafael J. Wysocki, Will Deacon, Olof Johansson,
	Grant Likely
  Cc: Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi, Al Stone, Hanjun Guo

From: Al Stone <al.stone@linaro.org>

ACPI reduced hardware mode is disabled by default, but ARM64
can only run properly in ACPI hardware reduced mode, so select
ACPI_REDUCED_HARDWARE_ONLY if ACPI is enabled on ARM64.

CC: Catalin Marinas <catalin.marinas@arm.com>
CC: Will Deacon <will.deacon@arm.com>
Reviewed-by: Grant Likely <grant.likely@linaro.org>
Tested-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
Tested-by: Yijing Wang <wangyijing@huawei.com>
Tested-by: Mark Langsdorf <mlangsdo@redhat.com>
Tested-by: Jon Masters <jcm@redhat.com>
Tested-by: Timur Tabi <timur@codeaurora.org>
Tested-by: Robert Richter <rrichter@cavium.com>
Acked-by: Robert Richter <rrichter@cavium.com>
Signed-off-by: Al Stone <al.stone@linaro.org>
Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
---
 arch/arm64/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 1b8e973..d00ab9a 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -1,5 +1,6 @@
 config ARM64
 	def_bool y
+	select ACPI_REDUCED_HARDWARE_ONLY if ACPI
 	select ARCH_BINFMT_ELF_RANDOMIZE_PIE
 	select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE
 	select ARCH_HAS_GCOV_PROFILE_ALL
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v9 19/21] ARM64 / ACPI: Enable ARM64 in Kconfig
  2015-02-25  8:39 [PATCH v9 00/21] Introduce ACPI for ARM64 based on ACPI 5.1 Hanjun Guo
                   ` (17 preceding siblings ...)
  2015-02-25  8:39 ` [PATCH v9 18/21] ARM64 / ACPI: Select ACPI_REDUCED_HARDWARE_ONLY if ACPI is enabled on ARM64 Hanjun Guo
@ 2015-02-25  8:39 ` Hanjun Guo
  2015-03-04 22:52   ` Rafael J. Wysocki
  2015-03-07 23:17   ` Grant Likely
  2015-02-25  8:40 ` [PATCH v9 20/21] Documentation: ACPI for ARM64 Hanjun Guo
                   ` (4 subsequent siblings)
  23 siblings, 2 replies; 106+ messages in thread
From: Hanjun Guo @ 2015-02-25  8:39 UTC (permalink / raw)
  To: Catalin Marinas, Rafael J. Wysocki, Will Deacon, Olof Johansson,
	Grant Likely
  Cc: Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi, Al Stone, Hanjun Guo

From: Graeme Gregory <graeme.gregory@linaro.org>

Add Kconfigs to build ACPI on ARM64, and make ACPI available on ARM64.

acpi_idle driver is x86/IA64 dependent now, so make CONFIG_ACPI_PROCESSOR
depend on X86 || IA64, and implement it on ARM64 in the future.

CC: Rafael J. Wysocki <rjw@rjwysocki.net>
CC: Catalin Marinas <catalin.marinas@arm.com>
CC: Will Deacon <will.deacon@arm.com>
Reviewed-by: Grant Likely <grant.likely@linaro.org>
Tested-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
Tested-by: Yijing Wang <wangyijing@huawei.com>
Tested-by: Mark Langsdorf <mlangsdo@redhat.com>
Tested-by: Jon Masters <jcm@redhat.com>
Tested-by: Timur Tabi <timur@codeaurora.org>
Tested-by: Robert Richter <rrichter@cavium.com>
Acked-by: Robert Richter <rrichter@cavium.com>
Signed-off-by: Graeme Gregory <graeme.gregory@linaro.org>
Signed-off-by: Al Stone <al.stone@linaro.org>
Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
---
 arch/arm64/Kconfig   | 2 ++
 drivers/acpi/Kconfig | 3 ++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index d00ab9a..e5aa081 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -713,6 +713,8 @@ source "drivers/Kconfig"
 
 source "drivers/firmware/Kconfig"
 
+source "drivers/acpi/Kconfig"
+
 source "fs/Kconfig"
 
 source "arch/arm64/kvm/Kconfig"
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index e6c3ddd..7aa3288 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -5,7 +5,7 @@
 menuconfig ACPI
 	bool "ACPI (Advanced Configuration and Power Interface) Support"
 	depends on !IA64_HP_SIM
-	depends on IA64 || X86
+	depends on IA64 || X86 || (ARM64 && EXPERT)
 	depends on PCI
 	select PNP
 	default y
@@ -163,6 +163,7 @@ config ACPI_PROCESSOR
 	tristate "Processor"
 	select THERMAL
 	select CPU_IDLE
+	depends on X86 || IA64
 	default y
 	help
 	  This driver installs ACPI as the idle handler for Linux and uses
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v9 20/21] Documentation: ACPI for ARM64
  2015-02-25  8:39 [PATCH v9 00/21] Introduce ACPI for ARM64 based on ACPI 5.1 Hanjun Guo
                   ` (18 preceding siblings ...)
  2015-02-25  8:39 ` [PATCH v9 19/21] ARM64 / ACPI: Enable ARM64 in Kconfig Hanjun Guo
@ 2015-02-25  8:40 ` Hanjun Guo
  2015-02-27 10:53   ` Shannon Zhao
  2015-02-27 11:20   ` Shannon Zhao
  2015-02-25  8:40 ` [PATCH v9 21/21] ARM64 / ACPI: additions of ACPI documentation for arm64 Hanjun Guo
                   ` (3 subsequent siblings)
  23 siblings, 2 replies; 106+ messages in thread
From: Hanjun Guo @ 2015-02-25  8:40 UTC (permalink / raw)
  To: Catalin Marinas, Rafael J. Wysocki, Will Deacon, Olof Johansson,
	Grant Likely
  Cc: Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi, Al Stone, Hanjun Guo

From: Graeme Gregory <graeme.gregory@linaro.org>

Add documentation for the guidelines of how to use ACPI
on ARM64.

Reviewed-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
Reviewed-by: Yi Li <phoenix.liyi@huawei.com>
Reviewed-by: Mark Langsdorf <mlangsdo@redhat.com>
Reviewed-by: Ashwin Chaugule <ashwinc@codeaurora.org>
Acked-by: Robert Richter <rrichter@cavium.com>
Signed-off-by: Graeme Gregory <graeme.gregory@linaro.org>
Signed-off-by: Al Stone <al.stone@linaro.org>
Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
---
 Documentation/arm64/arm-acpi.txt | 506 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 506 insertions(+)
 create mode 100644 Documentation/arm64/arm-acpi.txt

diff --git a/Documentation/arm64/arm-acpi.txt b/Documentation/arm64/arm-acpi.txt
new file mode 100644
index 0000000..24cf832
--- /dev/null
+++ b/Documentation/arm64/arm-acpi.txt
@@ -0,0 +1,506 @@
+ACPI on ARMv8 Servers
+---------------------
+ACPI can be used for ARMv8 general purpose servers designed to follow
+the ARM SBSA (Server Base System Architecture) [0] and SBBR (Server
+Base Boot Requirements) [1] specifications.  Please note that the SBBR
+can be retrieved simply by visiting [1], but the SBSA is currently only
+available to those with an ARM login due to ARM IP licensing concerns.
+
+The ARMv8 kernel implements the reduced hardware model of ACPI version
+5.1 or later.  Links to the specification and all external documents
+it refers to are managed by the UEFI Forum.  The specification is
+available at http://www.uefi.org/specifications and documents referenced
+by the specification can be found via http://www.uefi.org/acpi.
+
+If an ARMv8 system does not meet the requirements of the SBSA and SBBR,
+or cannot be described using the mechanisms defined in the required ACPI
+specifications, then ACPI may not be a good fit for the hardware.
+
+While the documents mentioned above set out the requirements for building
+industry-standard ARMv8 servers, they also apply to more than one operating
+system.  The purpose of this document is to describe the interaction between
+ACPI and Linux only, on an ARMv8 system -- that is, what Linux expects of
+ACPI and what ACPI can expect of Linux.
+
+
+Why ACPI on ARM?
+----------------
+Before examining the details of the interface between ACPI and Linux, it is
+useful to understand why ACPI is being used.  Several technologies already
+exist in Linux for describing non-enumerable hardware, after all.  In this
+section we summarize a blog post [2] from Grant Likely that outlines the
+reasoning behind ACPI on ARMv8 servers.  Actually, we snitch a good portion
+of the summary text almost directly, to be honest.
+
+The short form of the rationale for ACPI on ARM is:
+
+-- ACPI’s bytecode (AML) allows the platform to encode hardware behavior,
+   while DT explicitly does not support this.  For hardware vendors, being
+   able to encode behavior is a key tool used in supporting operating
+   system releases on new hardware.
+
+-- ACPI’s OSPM defines a power management model that constrains what the
+   platform is allowed to do into a specific model, while still providing
+   flexibility in hardware design.
+
+-- In the enterprise server environment, ACPI has established bindings (such
+   as for RAS) which are currently used in production systems.  DT does not.
+   Such bindings could be defined in DT at some point, but doing so means ARM
+   and x86 would end up using completely different code paths in both firmware
+   and the kernel.
+
+-- Choosing a single interface to describe the abstraction between a platform
+   and an OS is important.  Hardware vendors would not be required to implement
+   both DT and ACPI if they want to support multiple operating systems.  And,
+   agreeing on a single interface instead of being fragmented into per OS
+   interfaces makes for better interoperability overall.
+
+-- The new ACPI governance process works well and Linux is now at the same
+   table as hardware vendors and other OS vendors.  In fact, there is no
+   longer any reason to feel that ACPI is only belongs to Windows or that
+   Linux is in any way secondary to Microsoft in this arena.  The move of
+   ACPI governance into the UEFI forum has significantly opened up the
+   specification development process, and currently, a large portion of the
+   changes being made to ACPI is being driven by Linux.
+
+Key to the use of ACPI is the support model.  For servers in general, the
+responsibility for hardware behaviour cannot solely be the domain of the
+kernel, but rather must be split between the platform and the kernel, in
+order to allow for orderly change over time.  ACPI frees the OS from needing
+to understand all the minute details of the hardware so that the OS doesn’t
+need to be ported to each and every device individually.  It allows the
+hardware vendors to take responsibility for power management behaviour without
+depending on an OS release cycle which is not under their control.
+
+ACPI is also important because hardware and OS vendors have already worked
+out the mechanisms for supporting a general purpose computing ecosystem.  The
+infrastructure is in place, the bindings are in place, and the processes are
+in place.  DT does exactly what Linux needs it to when working with vertically
+integrated devices, but there are no good processes for supporting what the
+server vendors need.  Linux could potentially get there with DT, but doing so
+really just duplicates something that already works.  ACPI already does what
+the hardware vendors need, Microsoft won’t collaborate on DT, and hardware
+vendors would still end up providing two completely separate firmware
+interfaces -- one for Linux and one for Windows.
+
+
+Kernel Compatibility
+--------------------
+One of the primary motivations for ACPI is standardization, and using that
+to provide backward compatibility for Linux kernels.  In the server market,
+software and hardware are often used for long periods.  ACPI allows the
+kernel and firmware to agree on a consistent abstraction that can be
+maintained over time, even as hardware or software change.  As long as the
+abstraction is supported, systems can be updated without necessarily having
+to replace the kernel.
+
+When a Linux driver or subsystem is first implemented using ACPI, it by
+definition ends up requiring a specific version of the ACPI specification
+-- it's baseline.  ACPI firmware must continue to work, even though it may
+not be optimal, with the earliest kernel version that first provides support
+for that baseline version of ACPI.  There may be a need for additional drivers,
+but adding new functionality (e.g., CPU power management) should not break
+older kernel versions.  Further, ACPI firmware must also work with the most
+recent version of the kernel.
+
+
+Relationship with Device Tree
+-----------------------------
+ACPI support in drivers and subsystems for ARMv8 should never be mutually
+exclusive with DT support at compile time.
+
+At boot time the kernel will only use one description method depending on
+parameters passed from the bootloader (including kernel bootargs).
+
+Regardless of whether DT or ACPI is used, the kernel must always be capable
+of booting with either scheme (in kernels with both schemes enabled at compile
+time).
+
+
+Booting using ACPI tables
+-------------------------
+The only defined method for passing ACPI tables to the kernel on ARMv8
+is via the UEFI system configuration table.  Just so it is explicit, this
+means that ACPI is only supported on platforms that boot via UEFI.
+
+When an ARMv8 system boots, it can either have DT information, ACPI tables,
+or in some very unusual cases, both.  If no command line parameters are used,
+the kernel will try to use DT for device enumeration; if there is no DT
+present, the kernel will try to use ACPI tables, but only if they are present.
+In neither is available, the kernel will not boot.  If acpi=force is used
+on the command line, the kernel will attempt to use ACPI tables first, but
+fall back to DT if there are no ACPI tables present.  The basic idea is that
+the kernel will not fail to boot unless it absolutely has no other choice.
+
+Processing of ACPI tables may be disabled by passing acpi=off on the kernel
+command line; this is the default behavior.
+
+In order for the kernel to load and use ACPI tables, the UEFI implementation
+MUST set the ACPI_20_TABLE_GUID to point to the RSDP table (the table with
+the ACPI signature "RSD PTR ").  If this pointer is incorrect and acpi=force
+is used, the kernel will disable ACPI and try to use DT to boot instead; the
+kernel has, in effect, determined that ACPI tables are not present at that
+point.
+
+If the pointer to the RSDP table is correct, the table will be mapped into
+the kernel by the ACPI core, using the address provided by UEFI.
+
+The ACPI core will then locate and map in all other ACPI tables provided by
+using the addresses in the RSDP table to find the XSDT (eXtended System
+Description Table).  The XSDT in turn provides the addresses to all other
+ACPI tables provided by the system firmware; the ACPI core will then traverse
+this table and map in the tables listed.
+
+The ACPI core will ignore any provided RSDT (Root System Description Table).
+RSDTs have been deprecated and are ignored on arm64 since they only allow
+for 32-bit addresses.
+
+Further, the ACPI core will only use the 64-bit address fields in the FADT
+(Fixed ACPI Description Table).  Any 32-bit address fields in the FADT will
+be ignored on arm64.
+
+Hardware reduced mode (see Section 4.1 of the ACPI 5.1 specification) will
+be enforced by the ACPI core on arm64.  Doing so allows the ACPI core to
+run less complex code since it no longer has to provide support for legacy
+hardware from other architectures.  Any fields that are not to be used for
+hardware reduced mode must be set to zero.
+
+For the ACPI core to operate properly, and in turn provide the information
+the kernel needs to configure devices, it expects to find the following
+tables (all section numbers refer to the ACPI 5.1 specfication):
+
+    -- RSDP (Root System Description Pointer), section 5.2.5
+
+    -- XSDT (eXtended System Description Table), section 5.2.8
+
+    -- FADT (Fixed ACPI Description Table), section 5.2.9
+
+    -- DSDT (Differentiated System Description Table), section
+       5.2.11.1
+
+    -- MADT (Multiple APIC Description Table), section 5.2.12
+
+    -- GTDT (Generic Timer Description Table), section 5.2.24
+
+    -- If PCI is supported, the MCFG (Memory mapped ConFiGuration
+       Table), section 5.2.6, specifically Table 5-31.
+
+If the above tables are not all present, the kernel may or may not be
+able to boot properly since it may not be able to configure all of the
+devices available.
+
+
+ACPI Detection
+--------------
+Drivers should determine their probe() type by checking for a null
+value for ACPI_HANDLE, or checking .of_node, or other information in
+the device structure.  This is detailed further in the "Driver
+Recommendations" section.
+
+In non-driver code, if the presence of ACPI needs to be detected at
+runtime, then check the value of acpi_disabled. If CONFIG_ACPI is not
+set, acpi_disabled will always be 1.
+
+
+Device Enumeration
+------------------
+Device descriptions in ACPI should use standard recognized ACPI interfaces.
+These may contain less information than is typically provided via a Device
+Tree description for the same device.  This is also one of the reasons that
+ACPI can be useful -- the driver takes into account that it may have less
+detailed information about the device and uses sensible defaults instead.
+If done properly in the driver, the hardware can change and improve over
+time without the driver having to change at all.
+
+Clocks provide an excellent example.  In DT, clocks need to be specified
+and the drivers need to take them into account.  In ACPI, the assumption
+is that UEFI will leave the device in a reasonable default state, including
+any clock settings.  If for some reason the driver needs to change a clock
+value, this can be done in an ACPI method; all the driver needs to do is
+invoke the method and not concern itself with what the method needs to do
+to change the clock.  Changing the hardware can then take place over time
+by changing what the ACPI method does, and not the driver.
+
+In DT, the parameters needed by the driver to set up clocks as in the example
+above are known as "bindings"; in ACPI, these are known as "Device Properties"
+and provided to a driver via the _DSD object.
+
+ACPI tables are described with a formal language called ASL, the ACPI
+Source Language (section 19 of the specification).  This means that there
+are always multiple ways to describe the same thing -- including device
+properties.  For example, device properties could use an ASL construct
+that looks like this: Name(KEY0, "value0").  An ACPI device driver would
+then retrieve the value of the property by evaluating the KEY0 object.
+However, using Name() this way has multiple problems: (1) ACPI limits
+names ("KEY0") to four characters unlike DT; (2) there is no industry
+wide registry that maintains a list of names, minimzing re-use; (3)
+there is also no registry for the definition of property values ("value0"),
+again making re-use difficult; and (4) how does one maintain backward
+compatibility as new hardware comes out?  The _DSD method was created
+to solve precisely these sorts of problems; Linux drivers should ALWAYS
+use the _DSD method for device properties and nothing else.
+
+The _DSM object (ACPI Section 9.14.1) could also be used for conveying
+device properties to a driver.  Linux drivers should only expect it to
+be used if _DSD cannot represent the data required, and there is no way
+to create a new UUID for the _DSD object.  Note that there is even less
+regulation of the use of _DSM than there is of _DSD.  Drivers that depend
+on the contents of _DSM objects will be more difficult to maintain over
+time because of this; as of this writing, the use of _DSM is the cause
+of quite a few firmware problems and is not recommended.
+
+Drivers should look for device properties in the _DSD object ONLY; the _DSD
+object is described in the ACPI specification section 6.2.5, but this only
+describes how to define the structure of an object returned via _DSD, and
+how specific data structures are defined by specific UUIDs.  Linux should
+only use the _DSD Device Properties UUID [5]:
+
+   -- UUID: daffd814-6eba-4d8c-8a91-bc9bbf4aa301
+
+   -- http://www.uefi.org/sites/default/files/resources/_DSD-device-properties-UUID.pdf
+
+The UEFI Forum provides a mechanism for registering device properties [4]
+so that they may be used across all operating systems supporting ACPI.
+Device properties that have not been registered with the UEFI Forum should
+not be used.
+
+Before creating new device properties, check to be sure that they have not
+been defined before and either registered in the Linux kernel documentation
+as DT bindings, or the UEFI Forum as device properties.  While we do not want
+to simply move all DT bindings into ACPI device properties, we can learn from
+what has been previously defined.
+
+If it is necessary to define a new device property, or if it makes sense to
+synthesize the definition of a binding so it can be used in any firmware,
+both DT bindings and ACPI device properties for device drivers have review
+processes.  Use them both.  When the driver itself is submitted for review
+to the Linux mailing lists, the device property definitions needed must be
+submitted at the same time.  A driver that supports ACPI and uses device
+properties will not be considered complete without their definitions.  Once
+the device property has been accepted by the Linux community, it must be
+registered with the UEFI Forum [4], which will review it again for consistency
+within the registry.  This may require iteration.  The UEFI Forum, though,
+will always be the canonical site for device property definitions.
+
+It may make sense to provide notice to the UEFI Forum that there is the
+intent to register a previously unused device property name as a means of
+reserving the name for later use.  Other operating system vendors will
+also be submitting registration requests and this may help smooth the
+process.
+
+Once registration and review have been completed, the kernel provides an
+interface for looking up device properties in a manner independent of
+whether DT or ACPI is being used.  This API should be used [6]; it can
+eliminate some duplication of code paths in driver probing functions and
+discourage divergence between DT bindings and ACPI device properties.
+
+
+Programmable Power Control Resources
+------------------------------------
+Programmable power control resources include such resources as voltage/current
+providers (regulators) and clock sources.
+
+With ACPI, the kernel clock and regulator framework is not expected to be used
+at all.
+
+The kernel assumes that power control of these resources is represented with
+Power Resource Objects (ACPI section 7.1).  The ACPI core will then handle
+correctly enabling and disabling resources as they are needed.  In order to
+get that to work, ACPI assumes each device has defined D-states and that these
+can be controlled through the optional ACPI methods _PS0, _PS1, _PS2, and _PS3;
+in ACPI, _PS0 is the method to invoke to turn a device full on, and _PS3 is for
+turning a device full off.
+
+There are two options for using those Power Resources.  They can:
+
+   -- be managed in a _PSx method which gets called on entry to power
+      state Dx.
+
+   -- be declared separately as power resources with their own _ON and _OFF
+      methods.  They are then tied back to D-states for a particular device
+      via _PRx which specifies which power resources a device needs to be on
+      while in Dx.  Kernel then tracks number of devices using a power resource
+      and calls _ON/_OFF as needed.
+
+The kernel ACPI code will also assume that the _PSx methods follow the normal
+ACPI rules for such methods:
+
+   -- If either _PS0 or _PS3 is implemented, then the other method must also
+      be implemented.
+
+   -- If a device requires usage or setup of a power resource when on, the ASL
+      should organize that it is allocated/enabled using the _PS0 method.
+
+   -- Resources allocated or enabled in the _PS0 method should be disabled
+      or de-allocated in the _PS3 method.
+
+   -- Firmware will leave the resources in a reasonable state before handing
+      over control to the kernel.
+
+Such code in _PSx methods will of course be very platform specific.  But,
+this allows the driver to abstract out the interface for operating the device
+and avoid having to read special non-standard values from ACPI tables. Further,
+abstracting the use of these resources allows the hardware to change over time
+without requiring updates to the driver.
+
+
+Clocks
+------
+ACPI makes the assumption that clocks are initialized by the firmware --
+UEFI, in this case -- to some working value before control is handed over
+to the kernel.  This has implications for devices such as UARTs, or SoC-driven
+LCD displays, for example.
+
+When the kernel boots, the clocks are assumed to be set to reasonable
+working values.  If for some reason the frequency needs to change -- e.g.,
+throttling for power management -- the device driver should expect that
+process to be abstracted out into some ACPI method that can be invoked
+(please see the ACPI specification for further recommendations on standard
+methods to be expected).  The only exceptions to this are CPU clocks where
+CPPC provides a much richer interface than ACPI methods.  If the clocks
+are not set, there is no direct way for Linux to control them.
+
+If an SoC vendor wants to provide fine-grained control of the system clocks,
+they could do so by providing ACPI methods that could be invoked by Linux
+drivers.  However, this is NOT recommended and Linux drivers should NOT use
+such methods, even if they are provided.  Such methods are not currently
+standardized in the ACPI specification, and using them could tie a kernel
+to a very specific SoC, or tie an SoC to a very specific version of the
+kernel, both of which we are trying to avoid.
+
+
+Driver Recommendations
+----------------------
+DO NOT remove any DT handling when adding ACPI support for a driver.  The
+same device may be used on many different systems.
+
+DO try to structure the driver so that it is data-driven.  That is, set up
+a struct containing internal per-device state based on defaults and whatever
+else must be discovered by the driver probe function.  Then, have the rest
+of the driver operate off of the contents of that struct.  Doing so should
+allow most divergence between ACPI and DT functionality to be kept local to
+the probe function instead of being scattered throughout the driver.  For
+example:
+
+static int device_probe_dt(struct platform_device *pdev)
+{
+	/* DT specific functionality */
+	...
+}
+
+static int device_probe_acpi(struct platform_device *pdev)
+{
+	/* ACPI specific functionality */
+	...
+}
+
+static int device_probe(struct platform_device *pdev)
+{
+	...
+	struct device_node node = pdev->dev.of_node;
+	...
+
+	if (node)
+		ret = device_probe_dt(pdev);
+	else if (ACPI_HANDLE(&pdev->dev))
+		ret = device_probe_acpi(pdev);
+	else
+		/* other initialization */
+		...
+	/* Continue with any generic probe operations */
+	...
+}
+
+DO keep the MODULE_DEVICE_TABLE entries together in the driver to make it
+clear the different names the driver is probed for, both from DT and from
+ACPI:
+
+static struct of_device_id virtio_mmio_match[] = {
+        { .compatible = "virtio,mmio", },
+        { }
+};
+MODULE_DEVICE_TABLE(of, virtio_mmio_match);
+
+static const struct acpi_device_id virtio_mmio_acpi_match[] = {
+        { "LNRO0005", },
+        { }
+};
+MODULE_DEVICE_TABLE(acpi, virtio_mmio_acpi_match);
+
+
+ASWG
+----
+The ACPI specification changes regularly.  During the year 2014, for instance,
+version 5.1 was released and version 6.0 substantially completed, with most of
+the changes being driven by ARM-specific requirements.  Proposed changes are
+presented and discussed in the ASWG (ACPI Specification Working Group) which
+is a part of the UEFI Forum.
+
+Participation in this group is open to all UEFI members.  Please see
+http://www.uefi.org/workinggroup for details on group membership.
+
+It is the intent of the ARMv8 ACPI kernel code to follow the ACPI specification
+as closely as possible, and to only implement functionality that complies with
+the released standards from UEFI ASWG.  As a practical matter, there will be
+vendors that provide bad ACPI tables or violate the standards in some way.
+If this is because of errors, quirks and fixups may be necessary, but will
+be avoided if possible.  If there are features missing from ACPI that preclude
+it from being used on a platform, ECRs (Engineering Change Requests) should be
+submitted to ASWG and go through the normal approval process; for those that
+are not UEFI members, many other members of the Linux community are and would
+likely be willing to assist in submitting ECRs.
+
+
+Linux Code
+----------
+Individual items specific to Linux on ARM, contained in the the Linux
+source code, are in the list that follows:
+
+ACPI_OS_NAME		This macro defines the string to be returned when
+			an ACPI method invokes the _OS method.  On ARM64
+			systems, this macro will be "Linux" by default.
+			The command line parameter acpi_os=<string>
+			can be used to set it to some other value.  The
+			default value for other architectures is "Microsoft
+			Windows NT", for example.
+
+ACPI Objects
+------------
+Detailed expectations for ACPI tables and object are listed in the file
+Documentation/arm64/acpi_object_usage.txt.
+
+
+References
+----------
+[0] http://silver.arm.com -- document ARM-DEN-0029, or newer
+    "Server Base System Architecture", version 2.3, dated 27 Mar 2014
+
+[1] http://infocenter.arm.com/help/topic/com.arm.doc.den0044a/Server_Base_Boot_Requirements.pdf
+    Document ARM-DEN-0044A, or newer: "Server Base Boot Requirements, System
+    Software on ARM Platforms", dated 16 Aug 2014
+
+[2] http://www.secretlab.ca/archives/151, 10 Jan 2015, Copyright (c) 2015,
+    Linaro Ltd., written by Grant Likely.  A copy of the verbatim text (apart
+    from formatting) is also in Documentation/arm64/why_use_acpi.txt.
+
+[3] AMD ACPI for Seattle platform documentation:
+    http://amd-dev.wpengine.netdna-cdn.com/wordpress/media/2012/10/Seattle_ACPI_Guide.pdf
+
+[4] http://www.uefi.org/acpi -- please see the link for the "ACPI _DSD Device
+    Property Registry Instructions"
+
+[5] http://www.uefi.org/acpi -- please see the link for the "_DSD (Device
+    Specific Data) Implementation Guide"
+
+[6] Kernel code for the unified device property interface can be found in
+    include/linux/property.h and drivers/base/property.c.
+
+
+Authors
+-------
+Al Stone <al.stone@linaro.org>
+Graeme Gregory <graeme.gregory@linaro.org>
+Hanjun Guo <hanjun.guo@linaro.org>
+
+Grant Likely <grant.likely@linaro.org>, for the "Why ACPI on ARM?" section
+
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v9 21/21] ARM64 / ACPI: additions of ACPI documentation for arm64
  2015-02-25  8:39 [PATCH v9 00/21] Introduce ACPI for ARM64 based on ACPI 5.1 Hanjun Guo
                   ` (19 preceding siblings ...)
  2015-02-25  8:40 ` [PATCH v9 20/21] Documentation: ACPI for ARM64 Hanjun Guo
@ 2015-02-25  8:40 ` Hanjun Guo
  2015-02-27 11:22   ` Shannon Zhao
  2015-03-05 18:54   ` Olof Johansson
  2015-02-27  3:20 ` [PATCH v9 00/21] Introduce ACPI for ARM64 based on ACPI 5.1 Timur Tabi
                   ` (2 subsequent siblings)
  23 siblings, 2 replies; 106+ messages in thread
From: Hanjun Guo @ 2015-02-25  8:40 UTC (permalink / raw)
  To: Catalin Marinas, Rafael J. Wysocki, Will Deacon, Olof Johansson,
	Grant Likely
  Cc: Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi, Al Stone, Suravee Suthikulpanit,
	Yi Li, Mark Langsdorf, Hanjun Guo

From: Al Stone <al.stone@linaro.org>

Two more documentation files are also being added:
(1) A verbatim copy of the "Why ACPI on ARM?" blog posting by Grant Likely,
    which is also summarized in arm-acpi.txt, and

(2) A section by section review of the ACPI spec (acpi_object_usage.txt)
    to note recommendations and prohibitions on the use of the numerous
    ACPI tables and objects.  This sets out the current expectations of
    the firmware by Linux very explicitly (or as explicitly as I can, for
    now).

CC: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
CC: Yi Li <phoenix.liyi@huawei.com>
CC: Mark Langsdorf <mlangsdo@redhat.com>
CC: Ashwin Chaugule <ashwinc@codeaurora.org>
Acked-by: Robert Richter <rrichter@cavium.com>
Signed-off-by: Al Stone <al.stone@linaro.org>
Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
---
 Documentation/arm64/acpi_object_usage.txt | 594 ++++++++++++++++++++++++++++++
 Documentation/arm64/why_use_acpi.txt      | 231 ++++++++++++
 2 files changed, 825 insertions(+)
 create mode 100644 Documentation/arm64/acpi_object_usage.txt
 create mode 100644 Documentation/arm64/why_use_acpi.txt

diff --git a/Documentation/arm64/acpi_object_usage.txt b/Documentation/arm64/acpi_object_usage.txt
new file mode 100644
index 0000000..b49b288
--- /dev/null
+++ b/Documentation/arm64/acpi_object_usage.txt
@@ -0,0 +1,594 @@
+ACPI Tables
+-----------
+The expectations of individual ACPI tables are discussed in the list that
+follows.
+
+If a section number is used, it refers to a section number in the ACPI
+specification where the object is defined.  If "Signature Reserved" is used,
+the table signature (the first four bytes of the table) is the only portion
+of the table recognized by the specification, and the actual table is defined
+outside of the UEFI Forum (see Section 5.2.6 of the specification).
+
+For ACPI on arm64, tables also fall into the following categories:
+
+	-- Required: DSDT, FADT, GTDT, MADT, MCFG, RSDP, SPCR, XSDT
+
+	-- Recommended: BERT, EINJ, ERST, HEST, SSDT
+
+	-- Optional: BGRT, CPEP, CSRT, DRTM, ECDT, FACS, FPDT, MCHI, MPST,
+	   MSCT, RASF, SBST, SLIT, SPMI, SRAT, TCPA, TPM2, UEFI
+
+	-- Not supported: BOOT, DBG2, DBGP, DMAR, ETDT, HPET, IBFT, IVRS,
+	   LPIT, MSDM, RSDT, SLIC, WAET, WDAT, WDRT, WPBT
+
+
+Table	Usage for ARMv8 Linux
+-----	----------------------------------------------------------------
+BERT	Section 18.3 (signature == "BERT")
+	== Boot Error Record Table ==
+	Must be supplied if RAS support is provided by the platform.  It
+	is recommended this table be supplied.
+
+BOOT	Signature Reserved (signature == "BOOT")
+	== simple BOOT flag table ==
+	Microsoft only table, will not be supported.
+
+BGRT	Section 5.2.22 (signature == "BGRT")
+	== Boot Graphics Resource Table ==
+	Optional, not currently supported, with no real use-case for an
+	ARM server.
+
+CPEP	Section 5.2.18 (signature == "CPEP")
+	== Corrected Platform Error Polling table ==
+	Optional, not currently supported, and not recommended until such
+	time as ARM-compatible hardware is available, and the specification
+	suitably modified.
+
+CSRT	Signature Reserved (signature == "CSRT")
+	== Core System Resources Table ==
+	Optional, not currently supported.
+
+DBG2	Signature Reserved (signature == "DBG2")
+	== DeBuG port table 2 ==
+	Microsoft only table, will not be supported.
+
+DBGP	Signature Reserved (signature == "DBGP")
+	== DeBuG Port table ==
+	Microsoft only table, will not be supported.
+
+DSDT	Section 5.2.11.1 (signature == "DSDT")
+	== Differentiated System Description Table ==
+	A DSDT is required; see also SSDT.
+
+	ACPI tables contain only one DSDT but can contain one or more SSDTs,
+	which are optional.  Each SSDT can only add to the ACPI namespace,
+	but cannot modify or replace anything in the DSDT.
+
+DMAR	Signature Reserved (signature == "DMAR")
+	== DMA Remapping table ==
+	x86 only table, will not be supported.
+
+DRTM	Signature Reserved (signature == "DRTM")
+	== Dynamic Root of Trust for Measurement table ==
+	Optional, not currently supported.
+
+ECDT	Section 5.2.16 (signature == "ECDT")
+	== Embedded Controller Description Table ==
+	Optional, not currently supported, but could be used on ARM if and
+	only if one uses the GPE_BIT field to represent an IRQ number, since
+	there are no GPE blocks defined in hardware reduced mode.  This would
+	need to be modified in the ACPI specification.
+
+EINJ	Section 18.6 (signature == "EINJ")
+	== Error Injection table ==
+	This table is very useful for testing platform response to error
+	conditions; it allows one to inject an error into the system as
+	if it had actually occurred.  However, this table should not be
+	shipped with a production system; it should be dynamically loaded
+	and executed with the ACPICA tools only during testing.
+
+ERST	Section 18.5 (signature == "ERST")
+	== Error Record Serialization Table ==
+	On a platform supports RAS, this table must be supplied if it is not
+	UEFI-based; if it is UEFI-based, this table may be supplied. When this
+	table is not present, UEFI run time service will be utilized to save
+	and retrieve hardware error information to and from a persistent store.
+
+ETDT	Signature Reserved (signature == "ETDT")
+	== Event Timer Description Table ==
+	Obsolete table, will not be supported.
+
+FACS	Section 5.2.10 (signature == "FACS")
+	== Firmware ACPI Control Structure ==
+	It is unlikely that this table will be terribly useful.  If it is
+	provided, the Global Lock will NOT be used since it is not part of
+	the hardware reduced profile, and only 64-bit address fields will
+	be considered valid.
+
+FADT	Section 5.2.9 (signature == "FACP")
+	== Fixed ACPI Description Table ==
+	Required for arm64.
+
+	The HW_REDUCED_ACPI flag must be set.  All of the fields that are
+	to be ignored when HW_REDUCED_ACPI is set are expected to be set to
+	zero.
+
+	If an FACS table is provided, the X_FIRMWARE_CTRL field is to be
+	used, not FIRMWARE_CTRL.
+
+	If PSCI is used (as is recommended), make sure that ARM_BOOT_ARCH is
+	filled in properly -- that the PSCI_COMPLIANT flag is set and that
+	PSCI_USE_HVC is set or unset as needed (see table 5-37).
+
+	For the DSDT that is also required, the X_DSDT field is to be used,
+	not the DSDT field.
+
+FPDT	Section 5.2.23 (signature == "FPDT")
+	== Firmware Performance Data Table ==
+	Optional, not currently supported.
+
+GTDT	Section 5.2.24 (signature == "GTDT")
+	== Generic Timer Description Table ==
+	Required for arm64.
+
+HEST	Section 18.3.2 (signature == "HEST")
+	== Hardware Error Source Table ==
+	Until further error source types are defined, use only types 6 (AER
+	Root Port), 7 (AER Endpoint), 8 (AER Bridge), or 9 (Generic Hardware
+	Error Source).  Firmware first error handling is possible if and only
+	if Trusted Firmware is being used on arm64.
+
+	Must be supplied if RAS support is provided by the platform.  It
+	is recommended this table be supplied.
+
+HPET	Signature Reserved (signature == "HPET")
+	== High Precision Event timer Table ==
+	x86 only table, will not be supported.
+
+IBFT	Signature Reserved (signature == "IBFT")
+	== iSCSI Boot Firmware Table ==
+	Microsoft defined table, support TBD.
+
+IVRS	Signature Reserved (signature == "IVRS")
+	== I/O Virtualization Reporting Structure ==
+	x86_64 (AMD) only table, will not be supported.
+
+LPIT	Signature Reserved (signature == "LPIT")
+	== Low Power Idle Table ==
+	x86 only table as of ACPI 5.1; future versions have been adapted for
+	use with ARM and will be recommended in order to support ACPI power
+	management.
+
+MADT	Section 5.2.12 (signature == "APIC")
+	== Multiple APIC Description Table ==
+	Required for arm64.  Only the GIC interrupt controller structures
+	should be used (types 0xA - 0xE).
+
+MCFG	Signature Reserved (signature == "MCFG")
+	== Memory-mapped ConFiGuration space ==
+	If the platform supports PCI/PCIe, an MCFG table is required.
+
+MCHI	Signature Reserved (signature == "MCHI")
+	== Management Controller Host Interface table ==
+	Optional, not currently supported.
+
+MPST	Section 5.2.21 (signature == "MPST")
+	== Memory Power State Table ==
+	Optional, not currently supported.
+
+MSDM	Signature Reserved (signature == "MSDM")
+	== Microsoft Data Management table ==
+	Microsoft only table, will not be supported.
+
+MSCT	Section 5.2.19 (signature == "MSCT")
+	== Maximum System Characteristic Table ==
+	Optional, not currently supported.
+
+RASF	Section 5.2.20 (signature == "RASF")
+	== RAS Feature table ==
+	Optional, not currently supported.
+
+RSDP	Section 5.2.5 (signature == "RSD PTR")
+	== Root System Description PoinTeR ==
+	Required for arm64.
+
+RSDT	Section 5.2.7 (signature == "RSDT")
+	== Root System Description Table ==
+	Since this table can only provide 32-bit addresses, it is deprecated
+	on arm64, and will not be used.
+
+SBST	Section 5.2.14 (signature == "SBST")
+	== Smart Battery Subsystem Table ==
+	Optional, not currently supported.
+
+SLIC	Signature Reserved (signature == "SLIC")
+	== Software LIcensing table ==
+	Microsoft only table, will not be supported.
+
+SLIT	Section 5.2.17 (signature == "SLIT")
+	== System Locality distance Information Table ==
+	Optional in general, but required for NUMA systems.
+
+SPCR	Signature Reserved (signature == "SPCR")
+	== Serial Port Console Redirection table ==
+	Required for arm64.
+
+SPMI	Signature Reserved (signature == "SPMI")
+	== Server Platform Management Interface table ==
+	Optional, not currently supported.
+
+SRAT	Section 5.2.16 (signature == "SRAT")
+	== System Resource Affinity Table ==
+	Optional, but if used, only the GICC Affinity structures are read.
+	To support NUMA, this table is required.
+
+SSDT	Section 5.2.11.2 (signature == "SSDT")
+	== Secondary System Description Table ==
+	These tables are a continuation of the DSDT; these are recommended
+	for use with devices that can be added to a running system, but can
+	also serve the purpose of dividing up device descriptions into more
+	manageable pieces.
+
+	An SSDT can only ADD to the ACPI namespace.  It cannot modify or
+	replace existing device descriptions already in the namespace.
+
+	These tables are optional, however.  ACPI tables should contain only
+	one DSDT but can contain many SSDTs.
+
+TCPA	Signature Reserved (signature == "TCPA")
+	== Trusted Computing Platform Alliance table ==
+	Optional, not currently supported, and may need changes to fully
+	interoperate with arm64.
+
+TPM2	Signature Reserved (signature == "TPM2")
+	== Trusted Platform Module 2 table ==
+	Optional, not currently supported, and may need changes to fully
+	interoperate with arm64.
+
+UEFI	Signature Reserved (signature == "UEFI")
+	== UEFI ACPI data table ==
+	Optional, not currently supported.  No known use case for arm64,
+	at present.
+
+WAET	Signature Reserved (signature == "WAET")
+	== Windows ACPI Emulated devices Table ==
+	Microsoft only table, will not be supported.
+
+WDAT	Signature Reserved (signature == "WDAT")
+	== Watch Dog Action Table ==
+	Microsoft only table, will not be supported.
+
+WDRT	Signature Reserved (signature == "WDRT")
+	== Watch Dog Resource Table ==
+	Microsoft only table, will not be supported.
+
+WPBT	Signature Reserved (signature == "WPBT")
+	== Windows Platform Binary Table ==
+	Microsoft only table, will not be supported.
+
+XSDT	Section 5.2.8 (signature == "XSDT")
+	== eXtended System Description Table ==
+	Required for arm64.
+
+
+ACPI Objects
+------------
+The expectations on individual ACPI objects are discussed in the list that
+follows:
+
+Name	Section		Usage for ARMv8 Linux
+----	------------	-------------------------------------------------
+_ADR	6.1.1		Use as needed.
+
+_BBN	6.5.5		Use as needed; PCI-specific.
+
+_BDN	6.5.3		Optional; not likely to be used on arm64.
+
+_CCA	6.2.17		This method should be defined for all bus masters
+			on arm64.  While cache coherency is assumed, making
+			it explicit ensures the kernel will set up DMA as
+			it should.
+
+_CDM	6.2.1		Optional, to be used only for processor devices.
+
+_CID	6.1.2		Use as needed.
+
+_CLS	6.1.3		Use as needed.
+
+_CRS	6.2.2		Required on arm64.
+
+_DCK	6.5.2		Optional; not likely to be used on arm64.
+
+_DDN	6.1.4		This field can be used for a device name.  However,
+			it is meant for DOS device names (e.g., COM1), so be
+			careful of its use across OSes.
+
+_DEP	6.5.8		Use as needed.
+
+_DIS	6.2.3		Optional, for power management use.
+
+_DLM	5.7.5		Optional.
+
+_DMA	6.2.4		Optional.
+
+_DSD	6.2.5		To be used with caution.  If this object is used, try
+			to use it within the constraints already defined by the
+			Device Properties UUID.  Only in rare circumstances
+			should it be necessary to create a new _DSD UUID.
+
+			In either case, submit the _DSD definition along with
+			any driver patches for discussion, especially when
+			device properties are used.  A driver will not be
+			considered complete without a corresponding _DSD
+			description.  Once approved by kernel maintainers,
+			the UUID or device properties must then be registered
+			with the UEFI Forum; this may cause some iteration as
+			more than one OS will be registering entries.
+
+_DSM			Do not use this method.  It is not standardized, the
+			return values are not well documented, and it is
+			currently a frequent source of error.
+
+_DSW	7.2.1		Use as needed; power management specific.
+
+_EDL	6.3.1		Optional.
+
+_EJD	6.3.2		Optional.
+
+_EJx	6.3.3		Optional.
+
+_FIX	6.2.7		x86 specific, not used on arm64.
+
+\_GL	5.7.1		This object is not to be used in hardware reduced
+			mode, and therefore should not be used on arm64.
+
+_GLK	6.5.7		This object requires a global lock be defined; there
+			is no global lock on arm64 since it runs in hardware
+			reduced mode.  Hence, do not use this object on arm64.
+
+\_GPE	5.3.1		This namespace is for x86 use only.  Do not use it
+			on arm64.
+
+_GSB	6.2.7		Optional.
+
+_HID	6.1.5		Use as needed.  This is the primary object to use in
+			device probing, though _CID and _CLS may also be used.
+
+_HPP	6.2.8		Optional, PCI specific.
+
+_HPX	6.2.9		Optional, PCI specific.
+
+_HRV	6.1.6		Optional, use as needed to clarify device behavior; in
+			some cases, this may be easier to use than _DSD.
+
+_INI	6.5.1		Not required, but can be useful in setting up devices
+			when UEFI leaves them in a state that may not be what
+			the driver expects before it starts probing.
+
+_IRC	7.2.15		Use as needed; power management specific.
+
+_LCK	6.3.4		Optional.
+
+_MAT	6.2.10		Optional; see also the MADT.
+
+_MLS	6.1.7		Optional, but highly recommended for use in
+			internationalization.
+
+_OFF	7.1.2		It is recommended to define this method for any device
+			that can be turned on or off.
+
+_ON	7.1.3		It is recommended to define this method for any device
+			that can be turned on or off.
+
+\_OS	5.7.3		This method will return "Linux" by default (this is
+			the value of the macro ACPI_OS_NAME on Linux).  The
+			command line parameter acpi_os=<string> can be used
+			to set it to some other value.
+
+_OSC	6.2.11		This method can be a global method in ACPI (i.e.,
+			\_SB._OSC), or it may be associated with a specific
+			device (e.g., \_SB.DEV0._OSC), or both.  When used
+			as a global method, only capabilities published in
+			the ACPI specification are allowed.  When used as
+			a device-specific method, the process described for
+			using _DSD MUST be used to create an _OSC definition;
+			out-of-process use of _OSC is not allowed.  That is,
+			submit the device-specific _OSC usage description as
+			part of the kernel driver submission, get it approved
+			by the kernel community, then register it with the
+			UEFI Forum.
+
+\_OSI	5.7.2		Deprecated on ARM64.  Any invocation of this method
+			will print a warning on the console and return false.
+			That is, as far as ACPI firmware is concerned, _OSI
+			cannot be used to determine what sort of system is
+			being used or what functionality is provided.  The
+			_OSC method is to be used instead.
+
+_OST	6.3.5		Optional.
+
+_PDC	8.4.1		Deprecated, do not use on arm64.
+
+\_PIC	5.8.1		The method should not be used.  On arm64, the only
+			interrupt model available is GIC.
+
+_PLD	6.1.8		Optional.
+
+\_PR	5.3.1		This namespace is for x86 use only on legacy systems.
+			Do not use it on arm64.
+
+_PRS	6.2.12		Optional.
+
+_PRT	6.2.13		Required as part of the definition of all PCI root
+			devices.
+
+_PRW	7.2.13		Use as needed; power management specific.
+
+_PRx	7.2.8-11	Use as needed; power management specific.  If _PR0 is
+			defined, _PR3 must also be defined.
+
+_PSC	7.2.6		Use as needed; power management specific.
+
+_PSE	7.2.7		Use as needed; power management specific.
+
+_PSW	7.2.14		Use as needed; power management specific.
+
+_PSx	7.2.2-5		Use as needed; power management specific.  If _PS0 is
+			defined, _PS3 must also be defined.  If clocks or
+			regulators need adjusting to be consistent with power
+			usage, change them in these methods.
+
+\_PTS	7.3.1		Use as needed; power management specific.
+
+_PXM	6.2.14		Optional.
+
+_REG	6.5.4		Use as needed.
+
+\_REV	5.7.4		Always returns the latest version of ACPI supported.
+
+_RMV	6.3.6		Optional.
+
+\_SB	5.3.1		Required on arm64; all devices must be defined in this
+			namespace.
+
+_SEG	6.5.6		Use as needed; PCI-specific.
+
+\_SI	5.3.1,		Optional.
+	9.1
+
+_SLI	6.2.15		Optional; recommended when SLIT table is in use.
+
+_STA	6.3.7,		It is recommended to define this method for any device
+	7.1.4		that can be turned on or off.
+
+_SRS	6.2.16		Optional; see also _PRS.
+
+_STR	6.1.10		Recommended for conveying device names to end users;
+			this is preferred over using _DDN.
+
+_SUB	6.1.9		Use as needed; _HID or _CID are preferred.
+
+_SUN	6.1.11		Optional.
+
+\_Sx	7.3.2		Use as needed; power management specific.
+
+_SxD	7.2.16-19	Use as needed; power management specific.
+
+_SxW	7.2.20-24	Use as needed; power management specific.
+
+_SWS	7.3.3		Use as needed; power management specific; this may
+			require specification changes for use on arm64.
+
+\_TTS	7.3.4		Use as needed; power management specific.
+
+\_TZ	5.3.1		Optional.
+
+_UID	6.1.12		Recommended for distinguishing devices of the same
+			class; define it if at all possible.
+
+\_WAK	7.3.5		Use as needed; power management specific.
+
+
+ACPI Event Model
+----------------
+Do not use GPE block devices; these are not supported in the hardware reduced
+profile used by arm64.  Since there are no GPE blocks defined for use on ARM
+platforms, GPIO-signaled interrupts should be used for creating system events.
+
+
+ACPI Processor Control
+----------------------
+Section 8 of the ACPI specification is currently undergoing change that
+should be completed in the 6.0 version of the specification.  Processor
+performance control will be handled differently for arm64 at that point
+in time.  Processor aggregator devices (section 8.5) will not be used,
+for example, but another similar mechanism instead.
+
+While UEFI constrains what we can say until the release of 6.0, it is
+recommended that CPPC (8.4.5) be used as the primary model.  This will
+still be useful into the future.  C-states and P-states will still be
+provided, but most of the current design work appears to favor CPPC.
+
+Further, it is essential that the ARMv8 SoC provide a fully functional
+implementation of PSCI; this will be the only mechanism supported by ACPI
+to control CPU power state (including secondary CPU booting).
+
+More details will be provided on the release of the ACPI 6.0 specification.
+
+
+ACPI System Address Map Interfaces
+----------------------------------
+In Section 15 of the ACPI specification, several methods are mentioned as
+possible mechanisms for conveying memory resource information to the kernel.
+For arm64, we will only support UEFI for booting with ACPI, hence the UEFI
+GetMemoryMap() boot service is the only mechanism that will be used.
+
+
+ACPI Platform Error Interfaces (APEI)
+-------------------------------------
+The APEI tables supported are described above.
+
+APEI requires the equivalent of an SCI and an NMI on ARMv8.  The SCI is used
+to notify the OSPM of errors that have occurred but can be corrected and the
+system can continue correct operation, even if possibly degraded.  The NMI is
+used to indicate fatal errors that cannot be corrected, and require immediate
+attention.
+
+Since there is no direct equivalent of the x86 SCI or NMI, arm64 handles
+these slightly differently.  The SCI is handled as a normal GPIO-signaled
+interrupt; given that these are corrected (or correctable) errors being
+reported, this is sufficient.  The NMI is emulated as the highest priority
+GPIO-signaled interrupt possible.  This implies some caution must be used
+since there could be interrupts at higher privilege levels or even interrupts
+at the same priority as the emulated NMI.  In Linux, this should not be the
+case but one should be aware it could happen.
+
+
+ACPI Objects Not Supported on ARM64
+-----------------------------------
+While this may change in the future, there are several classes of objects
+that can be defined, but are not currently of general interest to ARM servers.
+
+These are not supported:
+
+	-- Section 9.2: ambient light sensor devices
+
+	-- Section 9.3: battery devices
+
+	-- Section 9.4: lids (e.g., laptop lids)
+
+	-- Section 9.8.2: IDE controllers
+
+	-- Section 9.9: floppy controllers
+
+	-- Section 9.10: GPE block devices
+
+	-- Section 9.15: PC/AT RTC/CMOS devices
+
+	-- Section 9.16: user presence detection devices
+
+	-- Section 9.17: I/O APIC devices; all GICs must be enumerable via MADT
+
+	-- Section 9.18: time and alarm devices (see 9.15)
+
+
+ACPI Objects Not Yet Implemented
+--------------------------------
+While these objects have x86 equivalents, and they do make some sense in ARM
+servers, there is either no hardware available at present, or in some cases
+there may not yet be a non-ARM implementation.  Hence, they are currently not
+implemented though that may change in the future.
+
+Not yet implemented are:
+
+	-- Section 10: power source and power meter devices
+
+	-- Section 11: thermal management
+
+	-- Section 12: embedded controllers interface
+
+	-- Section 13: SMBus interfaces
+
+	-- Section 17: NUMA support (prototypes have been submitted for
+	   review)
+
diff --git a/Documentation/arm64/why_use_acpi.txt b/Documentation/arm64/why_use_acpi.txt
new file mode 100644
index 0000000..4388abb
--- /dev/null
+++ b/Documentation/arm64/why_use_acpi.txt
@@ -0,0 +1,231 @@
+Why ACPI on ARM?
+----------------
+Copyright (c) 2015, Linaro, Ltd.
+Author: Grant Likely <grant.likely@linaro.org>
+
+Why are we doing ACPI on ARM? That question has been asked many times, but
+we haven’t yet had a good summary of the most important reasons for wanting
+ACPI on ARM. This article is an attempt to state the rationale clearly.
+
+During an email conversation late last year, Catalin Marinas asked for
+a summary of exactly why we want ACPI on ARM, Dong Wei replied with the
+following list:
+> 1. Support multiple OSes, including Linux and Windows
+> 2. Support device configurations
+> 3. Support dynamic device configurations (hot add/removal)
+> 4. Support hardware abstraction through control methods
+> 5. Support power management
+> 6. Support thermal management
+> 7. Support RAS interfaces
+
+The above list is certainly true in that all of them need to be supported.
+However, that list doesn’t give the rationale for choosing ACPI. We already
+have DT mechanisms for doing most of the above, and can certainly create
+new bindings for anything that is missing. So, if it isn’t an issue of
+functionality, then how does ACPI differ from DT and why is ACPI a better
+fit for general purpose ARM servers?
+
+The difference is in the support model. To explain what I mean, I’m first
+going to expand on each of the items above and discuss the similarities and
+differences between ACPI and DT. Then, with that as the groundwork, I’ll
+discuss how ACPI is a better fit for the general purpose hardware support
+model.
+
+
+Device Configurations
+---------------------
+2. Support device configurations
+3. Support dynamic device configurations (hot add/removal)
+
+From day one, DT was about device configurations. There isn’t any significant
+difference between ACPI & DT here. In fact, the majority of ACPI tables are
+completely analogous to DT descriptions. With the exception of the DSDT and
+SSDT tables, most ACPI tables are merely flat data used to describe hardware.
+
+DT platforms have also supported dynamic configuration and hotplug for years.
+There isn’t a lot here that differentiates between ACPI and DT. The biggest
+difference is that dynamic changes to the ACPI namespace can be triggered by
+ACPI methods, whereas for DT changes are received as messages from firmware
+and have been very much platform specific (e.g. IBM pSeries does this)
+
+
+Power Management
+----------------
+4. Support hardware abstraction through control methods
+5. Support power management
+6. Support thermal management
+
+Power, thermal, and clock management can all be dealt with as a group. ACPI
+defines a power management model (OSPM) that both the platform and the OS
+conform to. The OS implements the OSPM state machine, but the platform can
+provide state change behaviour in the form of bytecode methods. Methods can
+access hardware directly or hand off PM operations to a coprocessor. The OS
+really doesn’t have to care about the details as long as the platform obeys
+the rules of the OSPM model.
+
+With DT, the kernel has device drivers for each and every component in the
+platform, and configures them using DT data. DT itself doesn’t have a PM model.
+Rather the PM model is an implementation detail of the kernel. Device drivers
+use DT data to decide how to handle PM state changes. We have clock, pinctrl,
+and regulator frameworks in the kernel for working out runtime PM. However,
+this only works when all the drivers and support code have been merged into
+the kernel. When the kernel’s PM model doesn’t work for new hardware, then we
+change the model. This works very well for mobile/embedded because the vendor
+controls the kernel. We can change things when we need to, but we also struggle
+with getting board support mainlined.
+
+This difference has a big impact when it comes to OS support. Engineers from
+hardware vendors, Microsoft, and most vocally Red Hat have all told me bluntly
+that rebuilding the kernel doesn’t work for enterprise OS support. Their model
+is based around a fixed OS release that ideally boots out-of-the-box. It may
+still need additional device drivers for specific peripherals/features, but
+from a system view, the OS works. When additional drivers are provided
+separately, those drivers fit within the existing OSPM model for power
+management. This is where ACPI has a technical advantage over DT. The ACPI
+OSPM model and it’s bytecode gives the HW vendors a level of abstraction
+under their control, not the kernel’s. When the hardware behaves differently
+from what the OS expects, the vendor is able to change the behaviour without
+changing the HW or patching the OS.
+
+At this point you’d be right to point out that it is harder to get the whole
+system working correctly when behaviour is split between the kernel and the
+platform. The OS must trust that the platform doesn’t violate the OSPM model.
+All manner of bad things happen if it does. That is exactly why the DT model
+doesn’t encode behaviour: It is easier to make changes and fix bugs when
+everything is within the same code base. We don’t need a platform/kernel
+split when we can modify the kernel.
+
+However, the enterprise folks don’t have that luxury. The platform/kernel
+split isn’t a design choice. It is a characteristic of the market. Hardware
+and OS vendors each have their own product timetables, and they don’t line
+up. The timeline for getting patches into the kernel and flowing through into
+OS releases puts OS support far downstream from the actual release of hardware.
+Hardware vendors simply cannot wait for OS support to come online to be able to
+release their products. They need to be able to work with available releases,
+and make their hardware behave in the way the OS expects. The advantage of ACPI
+OSPM is that it defines behaviour and limits what the hardware is allowed to do
+without involving the kernel.
+
+What remains is sorting out how we make sure everything works. How do we make
+sure there is enough cross platform testing to ensure new hardware doesn’t
+ship broken and that new OS releases don’t break on old hardware? Those are
+the reasons why a UEFI/ACPI firmware summit is being organized, it’s why the
+UEFI forum holds plugfests 3 times a year, and it is why we’re working on
+FWTS and LuvOS.
+
+
+Reliability, Availability & Serviceability (RAS)
+------------------------------------------------
+7. Support RAS interfaces
+
+This isn’t a question of whether or not DT can support RAS. Of course it can.
+Rather it is a matter of RAS bindings already existing for ACPI, including a
+usage model. We’ve barely begun to explore this on DT. This item doesn’t make
+ACPI technically superior to DT, but it certainly makes it more mature.
+
+
+Multiplatform Support
+---------------------
+1. Support multiple OSes, including Linux and Windows
+
+I’m tackling this item last because I think it is the most contentious for
+those of us in the Linux world. I wanted to get the other issues out of the
+way before addressing it.
+
+The separation between hardware vendors and OS vendors in the server market
+is new for ARM. For the first time ARM hardware and OS release cycles are
+completely decoupled from each other, and neither are expected to have specific
+knowledge of the other (ie. the hardware vendor doesn’t control the choice of
+OS). ARM and their partners want to create an ecosystem of independent OSes
+and hardware platforms that don’t explicitly require the former to be ported
+to the latter.
+
+Now, one could argue that Linux is driving the potential market for ARM
+servers, and therefore Linux is the only thing that matters, but hardware
+vendors don’t see it that way. For hardware vendors it is in their best
+interest to support as wide a choice of OSes as possible in order to catch
+the widest potential customer base. Even if the majority choose Linux, some
+will choose BSD, some will choose Windows, and some will choose something
+else. Whether or not we think this is foolish is beside the point; it isn’t
+something we have influence over.
+
+During early ARM server planning meetings between ARM, its partners and other
+industry representatives (myself included) we discussed this exact point.
+Before us were two options, DT and ACPI. As one of the Linux people in the
+room, I advised that ACPI’s closed governance model was a show stopper for
+Linux and that DT is the working interface. Microsoft on the other hand made
+it abundantly clear that ACPI was the only interface that they would support.
+For their part, the hardware vendors stated the platform abstraction behaviour
+of ACPI is a hard requirement for their support model and that they would not
+close the door on either Linux or Windows.
+
+However, the one thing that all of us could agree on was that supporting
+multiple interfaces doesn’t help anyone: It would require twice as much
+effort on defining bindings (once for Linux-DT and once for Windows-ACPI)
+and it would require firmware to describe everything twice. Eventually we
+reached the compromise to use ACPI, but on the condition of opening the
+governance process to give Linux engineers equal influence over the
+specification. The fact that we now have a much better seat at the ACPI
+table, for both ARM and x86, is a direct result of these early ARM server
+negotiations. We are no longer second class citizens in the ACPI world and
+are actually driving much of the recent development.
+
+I know that this line of thought is more about market forces rather than a
+hard technical argument between ACPI and DT, but it is an equally significant
+one. Agreeing on a single way of doing things is important. The ARM server
+ecosystem is better for the agreement to use the same interface for all
+operating systems. This is what is meant by standards compliant. The standard
+is a codification of the mutually agreed interface. It provides confidence
+that all vendors are using the same rules for interoperability.
+
+
+Summary
+-------
+To summarize, here is the short form rationale for ACPI on ARM:
+
+-- ACPI’s bytecode allows the platform to encode behaviour. DT explicitly
+   does not support this. For hardware vendors, being able to encode behaviour
+   is an important tool for supporting operating system releases on new
+   hardware.
+
+-- ACPI’s OSPM defines a power management model that constrains what the
+   platform is allowed into a specific model while still having flexibility
+   in hardware design.
+
+-- For enterprise use-cases, ACPI has extablished bindings, such as for RAS,
+   which are used in production. DT does not. Yes, we can define those bindings
+   but doing so means ARM and x86 will use completely different code paths in
+   both firmware and the kernel.
+
+-- Choosing a single interface for platform/OS abstraction is important. It
+   is not reasonable to require vendors to implement both DT and ACPI if they
+   want to support multiple operating systems. Agreeing on a single interface
+   instead of being fragmented into per-OS interfaces makes for better
+   interoperability overall.
+
+-- The ACPI governance process works well and we’re at the same table as HW
+   vendors and other OS vendors. In fact, there is no longer any reason to
+   feel that ACPI is a Windows thing or that we are playing second fiddle to
+   Microsoft. The move of ACPI governance into the UEFI forum has significantly
+   opened up the processes, and currently, a large portion of the changes being
+   made to ACPI is being driven by Linux.
+
+At the beginning of this article I made the statement that the difference
+is in the support model. For servers, responsibility for hardware behaviour
+cannot be purely the domain of the kernel, but rather is split between the
+platform and the kernel. ACPI frees the OS from needing to understand all
+the minute details of the hardware so that the OS doesn’t need to be ported
+to each and every device individually. It allows the hardware vendors to take
+responsibility for PM behaviour without depending on an OS release cycle which
+it is not under their control.
+
+ACPI is also important because hardware and OS vendors have already worked
+out how to use it to support the general purpose ecosystem. The infrastructure
+is in place, the bindings are in place, and the process is in place. DT does
+exactly what we need it to when working with vertically integrated devices,
+but we don’t have good processes for supporting what the server vendors need.
+We could potentially get there with DT, but doing so doesn’t buy us anything.
+ACPI already does what the hardware vendors need, Microsoft won’t collaborate
+with us on DT, and the hardware vendors would still need to provide two
+completely separate firmware interface; one for Linux and one for Windows.
+
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 00/21] Introduce ACPI for ARM64 based on ACPI 5.1
  2015-02-25  8:39 [PATCH v9 00/21] Introduce ACPI for ARM64 based on ACPI 5.1 Hanjun Guo
                   ` (20 preceding siblings ...)
  2015-02-25  8:40 ` [PATCH v9 21/21] ARM64 / ACPI: additions of ACPI documentation for arm64 Hanjun Guo
@ 2015-02-27  3:20 ` Timur Tabi
  2015-02-27  8:37   ` Hanjun Guo
  2015-02-27  8:50   ` Ard Biesheuvel
  2015-03-04 22:56 ` Rafael J. Wysocki
  2015-03-05 18:57 ` Olof Johansson
  23 siblings, 2 replies; 106+ messages in thread
From: Timur Tabi @ 2015-02-27  3:20 UTC (permalink / raw)
  To: Hanjun Guo, Catalin Marinas, Rafael J. Wysocki, Will Deacon,
	Olof Johansson, Grant Likely
  Cc: Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Ashwin Chaugule, suravee.suthikulpanit,
	linux-acpi, linux-arm-kernel, linux-kernel, linaro-acpi

On 02/25/2015 02:39 AM, Hanjun Guo wrote:
> Changes since v8:

I'm still debugging it, but v9 on the 4.0-rc1 kernel crashes after 
calling the UEFI boot time services exit function.  That is, this line:

status = sys_table->boottime->exit_boot_services(handle, mmap_key);

in allocate_new_fdt_and_exit_boot() gets called, and then soon after it 
returns, the kernel crashes.  It's really early because the UEFI 
exception handler is called.

I did not have this problem with v8 patchset on 3.19.


Also, you still have a couple whitespace problems in these patches:

Applying: ARM64 / ACPI: additions of ACPI documentation for arm64
/local/mnt/workspace/linux.0/.git/rebase-apply/patch:607: new blank line 
at EOF.
+
/local/mnt/workspace/linux.0/.git/rebase-apply/patch:844: new blank line 
at EOF.
+
warning: 2 lines add whitespace errors.
Applying: Documentation: ACPI for ARM64
/local/mnt/workspace/linux.0/.git/rebase-apply/patch:517: new blank line 
at EOF.
+
warning: 1 line adds whitespace errors.


-- 
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the
Code Aurora Forum, hosted by The Linux Foundation.

^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 00/21] Introduce ACPI for ARM64 based on ACPI 5.1
  2015-02-27  3:20 ` [PATCH v9 00/21] Introduce ACPI for ARM64 based on ACPI 5.1 Timur Tabi
@ 2015-02-27  8:37   ` Hanjun Guo
  2015-02-27 10:51     ` Shannon Zhao
  2015-02-27  8:50   ` Ard Biesheuvel
  1 sibling, 1 reply; 106+ messages in thread
From: Hanjun Guo @ 2015-02-27  8:37 UTC (permalink / raw)
  To: Timur Tabi, Catalin Marinas, Rafael J. Wysocki, Will Deacon,
	Olof Johansson, Grant Likely
  Cc: Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Ashwin Chaugule, suravee.suthikulpanit,
	linux-acpi, linux-arm-kernel, linux-kernel, linaro-acpi

Hi Timur,

On 2015年02月27日 11:20, Timur Tabi wrote:
> On 02/25/2015 02:39 AM, Hanjun Guo wrote:
>> Changes since v8:
>
> I'm still debugging it, but v9 on the 4.0-rc1 kernel crashes after
> calling the UEFI boot time services exit function.  That is, this line:
>
> status = sys_table->boottime->exit_boot_services(handle, mmap_key);
>
> in allocate_new_fdt_and_exit_boot() gets called, and then soon after it
> returns, the kernel crashes.  It's really early because the UEFI
> exception handler is called.
>
> I did not have this problem with v8 patchset on 3.19.

I tested this patch set on FVP base model with UEFI, and booted ok.
Can you boot the system without this ACPI patch set?

>
>
> Also, you still have a couple whitespace problems in these patches:
>
> Applying: ARM64 / ACPI: additions of ACPI documentation for arm64
> /local/mnt/workspace/linux.0/.git/rebase-apply/patch:607: new blank line
> at EOF.
> +
> /local/mnt/workspace/linux.0/.git/rebase-apply/patch:844: new blank line
> at EOF.
> +
> warning: 2 lines add whitespace errors.
> Applying: Documentation: ACPI for ARM64
> /local/mnt/workspace/linux.0/.git/rebase-apply/patch:517: new blank line
> at EOF.
> +
> warning: 1 line adds whitespace errors.

Weired, When I checked the patch locally there were no whitespace
problems:

./scripts/checkpatch.pl 0020-Documentation-ACPI-for-ARM64.patch
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#23:
new file mode 100644

WARNING: use relative pathname instead of absolute in changelog text
#25:
--- /dev/null

total: 0 errors, 2 warnings, 506 lines checked

0020-Documentation-ACPI-for-ARM64.patch has style problems, please review.

./scripts/checkpatch.pl 
0021-ARM64-ACPI-additions-of-ACPI-documentation-for-arm64.patch
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#32:
new file mode 100644

WARNING: use relative pathname instead of absolute in changelog text
#34:
--- /dev/null

WARNING: use relative pathname instead of absolute in changelog text
#634:
--- /dev/null

total: 0 errors, 3 warnings, 825 lines checked

0021-ARM64-ACPI-additions-of-ACPI-documentation-for-arm64.patch has 
style problems, please review.

Can you provide me the exact line of code which have whitespace problems?

Thanks
Hanjun

^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 00/21] Introduce ACPI for ARM64 based on ACPI 5.1
  2015-02-27  3:20 ` [PATCH v9 00/21] Introduce ACPI for ARM64 based on ACPI 5.1 Timur Tabi
  2015-02-27  8:37   ` Hanjun Guo
@ 2015-02-27  8:50   ` Ard Biesheuvel
  2015-02-27 10:36     ` Mark Rutland
                       ` (2 more replies)
  1 sibling, 3 replies; 106+ messages in thread
From: Ard Biesheuvel @ 2015-02-27  8:50 UTC (permalink / raw)
  To: Timur Tabi
  Cc: Hanjun Guo, Catalin Marinas, Rafael J. Wysocki, Will Deacon,
	Olof Johansson, Grant Likely, Mark Rutland, Ashwin Chaugule,
	Lorenzo Pieralisi, Robert Richter, Arnd Bergmann, Graeme Gregory,
	Linaro ACPI Mailman List, Marc Zyngier, Jon Masters,
	linux-kernel, linux-acpi, Mark Brown, Suravee Suthikulpanit,
	Sudeep Holla, linux-arm-kernel

On 27 February 2015 at 03:20, Timur Tabi <timur@codeaurora.org> wrote:
> On 02/25/2015 02:39 AM, Hanjun Guo wrote:
>>
>> Changes since v8:
>
>
> I'm still debugging it, but v9 on the 4.0-rc1 kernel crashes after calling
> the UEFI boot time services exit function.  That is, this line:
>
> status = sys_table->boottime->exit_boot_services(handle, mmap_key);
>
> in allocate_new_fdt_and_exit_boot() gets called, and then soon after it
> returns, the kernel crashes.  It's really early because the UEFI exception
> handler is called.
>
> I did not have this problem with v8 patchset on 3.19.
>

Are you not seeing this on v4.0-rc1 without the patchset applied?

Could the crash be inside the subsequent call to
SetVirtualAddressMap() instead of inside ExitBootServices()?

If so, you have a firmware bug: Mark Rutland spotted a similar bug in
the AMD Seattle firmware, which has been fixed in the mean time.
It has to do with the firmware dereferencing the virtual mapping as it
is being installed, which violates the UEFI spec.


>
> Also, you still have a couple whitespace problems in these patches:
>
> Applying: ARM64 / ACPI: additions of ACPI documentation for arm64
> /local/mnt/workspace/linux.0/.git/rebase-apply/patch:607: new blank line at
> EOF.
> +
> /local/mnt/workspace/linux.0/.git/rebase-apply/patch:844: new blank line at
> EOF.
> +
> warning: 2 lines add whitespace errors.
> Applying: Documentation: ACPI for ARM64
> /local/mnt/workspace/linux.0/.git/rebase-apply/patch:517: new blank line at
> EOF.
> +
> warning: 1 line adds whitespace errors.
>
>
> --
> Sent by an employee of the Qualcomm Innovation Center, Inc.
> The Qualcomm Innovation Center, Inc. is a member of the
> Code Aurora Forum, hosted by The Linux Foundation.
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 00/21] Introduce ACPI for ARM64 based on ACPI 5.1
  2015-02-27  8:50   ` Ard Biesheuvel
@ 2015-02-27 10:36     ` Mark Rutland
  2015-02-27 21:05     ` Timur Tabi
  2015-03-04 23:18     ` Timur Tabi
  2 siblings, 0 replies; 106+ messages in thread
From: Mark Rutland @ 2015-02-27 10:36 UTC (permalink / raw)
  To: Ard Biesheuvel
  Cc: Timur Tabi, hanjun.guo, Catalin Marinas, Rafael J. Wysocki,
	Will Deacon, Olof Johansson, grant.likely, Ashwin Chaugule,
	Lorenzo Pieralisi, Robert Richter, Arnd Bergmann, graeme.gregory,
	Linaro ACPI Mailman List, Marc Zyngier, jcm, linux-kernel,
	linux-acpi, Mark Brown, suravee.suthikulpanit, Sudeep Holla,
	linux-arm-kernel

> > I'm still debugging it, but v9 on the 4.0-rc1 kernel crashes after calling
> > the UEFI boot time services exit function.  That is, this line:
> >
> > status = sys_table->boottime->exit_boot_services(handle, mmap_key);
> >
> > in allocate_new_fdt_and_exit_boot() gets called, and then soon after it
> > returns, the kernel crashes.  It's really early because the UEFI exception
> > handler is called.
> >
> > I did not have this problem with v8 patchset on 3.19.
> >
> 
> Are you not seeing this on v4.0-rc1 without the patchset applied?
> 
> Could the crash be inside the subsequent call to
> SetVirtualAddressMap() instead of inside ExitBootServices()?
> 
> If so, you have a firmware bug: Mark Rutland spotted a similar bug in
> the AMD Seattle firmware, which has been fixed in the mean time.
> It has to do with the firmware dereferencing the virtual mapping as it
> is being installed, which violates the UEFI spec.

A simple way to test is to change EFI_RT_VIRTUAL_BASE to point to the
(unmapped) high half of the address space (e.g. set it to
0xffff000000000000). If EFI is using pointers erroneously then something
should fault within SetVirtualAddressMap(), and you can catch this with
your favourite debugger.

Otherwise it's possible that the virtual address space chosen will cover
memory and/or devices in the existing idmap, and any erroneous accesses
will corrupt memory and/or cause devices to explode.

Thanks,
Mark

^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 00/21] Introduce ACPI for ARM64 based on ACPI 5.1
  2015-02-27  8:37   ` Hanjun Guo
@ 2015-02-27 10:51     ` Shannon Zhao
  0 siblings, 0 replies; 106+ messages in thread
From: Shannon Zhao @ 2015-02-27 10:51 UTC (permalink / raw)
  To: Hanjun Guo, Timur Tabi, Catalin Marinas, Rafael J. Wysocki,
	Will Deacon, Olof Johansson, Grant Likely
  Cc: Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Ashwin Chaugule, suravee.suthikulpanit,
	linux-acpi, linux-arm-kernel, linux-kernel, linaro-acpi,
	Huangpeng (Peter)

On 2015/2/27 16:37, Hanjun Guo wrote:
> Hi Timur,
> 
> On 2015年02月27日 11:20, Timur Tabi wrote:
>> On 02/25/2015 02:39 AM, Hanjun Guo wrote:
>>> Changes since v8:
>>
>> I'm still debugging it, but v9 on the 4.0-rc1 kernel crashes after
>> calling the UEFI boot time services exit function.  That is, this line:
>>
>> status = sys_table->boottime->exit_boot_services(handle, mmap_key);
>>
>> in allocate_new_fdt_and_exit_boot() gets called, and then soon after it
>> returns, the kernel crashes.  It's really early because the UEFI
>> exception handler is called.
>>
>> I did not have this problem with v8 patchset on 3.19.
> 
> I tested this patch set on FVP base model with UEFI, and booted ok.
> Can you boot the system without this ACPI patch set?
> 
>>
>>
>> Also, you still have a couple whitespace problems in these patches:
>>
>> Applying: ARM64 / ACPI: additions of ACPI documentation for arm64
>> /local/mnt/workspace/linux.0/.git/rebase-apply/patch:607: new blank line
>> at EOF.
>> +
>> /local/mnt/workspace/linux.0/.git/rebase-apply/patch:844: new blank line
>> at EOF.
>> +
>> warning: 2 lines add whitespace errors.
>> Applying: Documentation: ACPI for ARM64
>> /local/mnt/workspace/linux.0/.git/rebase-apply/patch:517: new blank line
>> at EOF.
>> +
>> warning: 1 line adds whitespace errors.
> 
> Weired, When I checked the patch locally there were no whitespace
> problems:

I found those whitespace errors too. Please see the comments in each patch.

-- 
Thanks,
Shannon


^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 20/21] Documentation: ACPI for ARM64
  2015-02-25  8:40 ` [PATCH v9 20/21] Documentation: ACPI for ARM64 Hanjun Guo
@ 2015-02-27 10:53   ` Shannon Zhao
  2015-02-27 11:13     ` Shannon Zhao
  2015-02-27 11:20   ` Shannon Zhao
  1 sibling, 1 reply; 106+ messages in thread
From: Shannon Zhao @ 2015-02-27 10:53 UTC (permalink / raw)
  To: Hanjun Guo, Catalin Marinas, Rafael J. Wysocki, Will Deacon,
	Olof Johansson, Grant Likely
  Cc: Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi, Al Stone, Huangpeng (Peter)

On 2015/2/25 16:40, Hanjun Guo wrote:
> From: Graeme Gregory <graeme.gregory@linaro.org>
> 
> Add documentation for the guidelines of how to use ACPI
> on ARM64.
> 
> Reviewed-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
> Reviewed-by: Yi Li <phoenix.liyi@huawei.com>
> Reviewed-by: Mark Langsdorf <mlangsdo@redhat.com>
> Reviewed-by: Ashwin Chaugule <ashwinc@codeaurora.org>
> Acked-by: Robert Richter <rrichter@cavium.com>
> Signed-off-by: Graeme Gregory <graeme.gregory@linaro.org>
> Signed-off-by: Al Stone <al.stone@linaro.org>
> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
> ---
>  Documentation/arm64/arm-acpi.txt | 506 +++++++++++++++++++++++++++++++++++++++
>  1 file changed, 506 insertions(+)
>  create mode 100644 Documentation/arm64/arm-acpi.txt
> 
> diff --git a/Documentation/arm64/arm-acpi.txt b/Documentation/arm64/arm-acpi.txt
> new file mode 100644
> index 0000000..24cf832
> --- /dev/null
> +++ b/Documentation/arm64/arm-acpi.txt
> @@ -0,0 +1,506 @@
> +ACPI on ARMv8 Servers
> +---------------------
> +ACPI can be used for ARMv8 general purpose servers designed to follow
> +the ARM SBSA (Server Base System Architecture) [0] and SBBR (Server
> +Base Boot Requirements) [1] specifications.  Please note that the SBBR
> +can be retrieved simply by visiting [1], but the SBSA is currently only
> +available to those with an ARM login due to ARM IP licensing concerns.
> +
> +The ARMv8 kernel implements the reduced hardware model of ACPI version
> +5.1 or later.  Links to the specification and all external documents
> +it refers to are managed by the UEFI Forum.  The specification is
> +available at http://www.uefi.org/specifications and documents referenced
> +by the specification can be found via http://www.uefi.org/acpi.
> +
> +If an ARMv8 system does not meet the requirements of the SBSA and SBBR,
> +or cannot be described using the mechanisms defined in the required ACPI
> +specifications, then ACPI may not be a good fit for the hardware.
> +
> +While the documents mentioned above set out the requirements for building
> +industry-standard ARMv8 servers, they also apply to more than one operating
> +system.  The purpose of this document is to describe the interaction between
> +ACPI and Linux only, on an ARMv8 system -- that is, what Linux expects of
> +ACPI and what ACPI can expect of Linux.
> +
> +

Here. Two blank lines.

> +Why ACPI on ARM?


-- 
Thanks,
Shannon


^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 20/21] Documentation: ACPI for ARM64
  2015-02-27 10:53   ` Shannon Zhao
@ 2015-02-27 11:13     ` Shannon Zhao
  0 siblings, 0 replies; 106+ messages in thread
From: Shannon Zhao @ 2015-02-27 11:13 UTC (permalink / raw)
  To: Hanjun Guo, Catalin Marinas, Rafael J. Wysocki, Will Deacon,
	Olof Johansson, Grant Likely
  Cc: Mark Rutland, Ashwin Chaugule, Lorenzo Pieralisi, Robert Richter,
	Arnd Bergmann, Graeme Gregory, linaro-acpi, Marc Zyngier,
	Jon Masters, Timur Tabi, linux-kernel, Al Stone, linux-acpi,
	Mark Brown, suravee.suthikulpanit, Sudeep Holla,
	Huangpeng (Peter),
	linux-arm-kernel

On 2015/2/27 18:53, Shannon Zhao wrote:
> On 2015/2/25 16:40, Hanjun Guo wrote:
>> From: Graeme Gregory <graeme.gregory@linaro.org>
>>
>> Add documentation for the guidelines of how to use ACPI
>> on ARM64.
>>
>> Reviewed-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
>> Reviewed-by: Yi Li <phoenix.liyi@huawei.com>
>> Reviewed-by: Mark Langsdorf <mlangsdo@redhat.com>
>> Reviewed-by: Ashwin Chaugule <ashwinc@codeaurora.org>
>> Acked-by: Robert Richter <rrichter@cavium.com>
>> Signed-off-by: Graeme Gregory <graeme.gregory@linaro.org>
>> Signed-off-by: Al Stone <al.stone@linaro.org>
>> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
>> ---
>>  Documentation/arm64/arm-acpi.txt | 506 +++++++++++++++++++++++++++++++++++++++
>>  1 file changed, 506 insertions(+)
>>  create mode 100644 Documentation/arm64/arm-acpi.txt
>>
>> diff --git a/Documentation/arm64/arm-acpi.txt b/Documentation/arm64/arm-acpi.txt
>> new file mode 100644
>> index 0000000..24cf832
>> --- /dev/null
>> +++ b/Documentation/arm64/arm-acpi.txt
>> @@ -0,0 +1,506 @@
>> +ACPI on ARMv8 Servers
>> +---------------------
>> +ACPI can be used for ARMv8 general purpose servers designed to follow
>> +the ARM SBSA (Server Base System Architecture) [0] and SBBR (Server
>> +Base Boot Requirements) [1] specifications.  Please note that the SBBR
>> +can be retrieved simply by visiting [1], but the SBSA is currently only
>> +available to those with an ARM login due to ARM IP licensing concerns.
>> +
>> +The ARMv8 kernel implements the reduced hardware model of ACPI version
>> +5.1 or later.  Links to the specification and all external documents
>> +it refers to are managed by the UEFI Forum.  The specification is
>> +available at http://www.uefi.org/specifications and documents referenced
>> +by the specification can be found via http://www.uefi.org/acpi.
>> +
>> +If an ARMv8 system does not meet the requirements of the SBSA and SBBR,
>> +or cannot be described using the mechanisms defined in the required ACPI
>> +specifications, then ACPI may not be a good fit for the hardware.
>> +
>> +While the documents mentioned above set out the requirements for building
>> +industry-standard ARMv8 servers, they also apply to more than one operating
>> +system.  The purpose of this document is to describe the interaction between
>> +ACPI and Linux only, on an ARMv8 system -- that is, what Linux expects of
>> +ACPI and what ACPI can expect of Linux.
>> +
>> +
> 
> Here. Two blank lines.
> 
>> +Why ACPI on ARM?
> 
> 
not here. ignore this :-)

-- 
Thanks,
Shannon


^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 20/21] Documentation: ACPI for ARM64
  2015-02-25  8:40 ` [PATCH v9 20/21] Documentation: ACPI for ARM64 Hanjun Guo
  2015-02-27 10:53   ` Shannon Zhao
@ 2015-02-27 11:20   ` Shannon Zhao
  1 sibling, 0 replies; 106+ messages in thread
From: Shannon Zhao @ 2015-02-27 11:20 UTC (permalink / raw)
  To: Hanjun Guo, Catalin Marinas, Rafael J. Wysocki, Will Deacon,
	Olof Johansson, Grant Likely
  Cc: Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi, Al Stone, Huangpeng (Peter)

On 2015/2/25 16:40, Hanjun Guo wrote:
> +Authors
> +-------
> +Al Stone <al.stone@linaro.org>
> +Graeme Gregory <graeme.gregory@linaro.org>
> +Hanjun Guo <hanjun.guo@linaro.org>
> +
> +Grant Likely <grant.likely@linaro.org>, for the "Why ACPI on ARM?" section
> +

It's here at the end of the file. Redundant blank line.

-- 
Thanks,
Shannon


^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 21/21] ARM64 / ACPI: additions of ACPI documentation for arm64
  2015-02-25  8:40 ` [PATCH v9 21/21] ARM64 / ACPI: additions of ACPI documentation for arm64 Hanjun Guo
@ 2015-02-27 11:22   ` Shannon Zhao
  2015-02-27 14:19     ` Hanjun Guo
  2015-03-05 18:54   ` Olof Johansson
  1 sibling, 1 reply; 106+ messages in thread
From: Shannon Zhao @ 2015-02-27 11:22 UTC (permalink / raw)
  To: Hanjun Guo, Catalin Marinas, Rafael J. Wysocki, Will Deacon,
	Olof Johansson, Grant Likely
  Cc: Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi, Al Stone, Yi Li, Mark Langsdorf,
	Huangpeng (Peter)

On 2015/2/25 16:40, Hanjun Guo wrote:
> +Not yet implemented are:
> +
> +	-- Section 10: power source and power meter devices
> +
> +	-- Section 11: thermal management
> +
> +	-- Section 12: embedded controllers interface
> +
> +	-- Section 13: SMBus interfaces
> +
> +	-- Section 17: NUMA support (prototypes have been submitted for
> +	   review)
> +
> 

Here at the end of the file. Redundant blank line.

> +ACPI is also important because hardware and OS vendors have already worked
> +out how to use it to support the general purpose ecosystem. The infrastructure
> +is in place, the bindings are in place, and the process is in place. DT does
> +exactly what we need it to when working with vertically integrated devices,
> +but we don’t have good processes for supporting what the server vendors need.
> +We could potentially get there with DT, but doing so doesn’t buy us anything.
> +ACPI already does what the hardware vendors need, Microsoft won’t collaborate
> +with us on DT, and the hardware vendors would still need to provide two
> +completely separate firmware interface; one for Linux and one for Windows.
> +

And Here at the end of the file. Redundant blank line.

-- 
Thanks,
Shannon


^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 21/21] ARM64 / ACPI: additions of ACPI documentation for arm64
  2015-02-27 11:22   ` Shannon Zhao
@ 2015-02-27 14:19     ` Hanjun Guo
  0 siblings, 0 replies; 106+ messages in thread
From: Hanjun Guo @ 2015-02-27 14:19 UTC (permalink / raw)
  To: Shannon Zhao, Catalin Marinas, Rafael J. Wysocki, Will Deacon,
	Olof Johansson, Grant Likely
  Cc: Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi, Al Stone, Yi Li, Mark Langsdorf,
	Huangpeng (Peter)

Hi Shannon,

On 2015年02月27日 19:22, Shannon Zhao wrote:
> On 2015/2/25 16:40, Hanjun Guo wrote:
>> +Not yet implemented are:
>> +
>> +	-- Section 10: power source and power meter devices
>> +
>> +	-- Section 11: thermal management
>> +
>> +	-- Section 12: embedded controllers interface
>> +
>> +	-- Section 13: SMBus interfaces
>> +
>> +	-- Section 17: NUMA support (prototypes have been submitted for
>> +	   review)
>> +
>>
>
> Here at the end of the file. Redundant blank line.
>
>> +ACPI is also important because hardware and OS vendors have already worked
>> +out how to use it to support the general purpose ecosystem. The infrastructure
>> +is in place, the bindings are in place, and the process is in place. DT does
>> +exactly what we need it to when working with vertically integrated devices,
>> +but we don’t have good processes for supporting what the server vendors need.
>> +We could potentially get there with DT, but doing so doesn’t buy us anything.
>> +ACPI already does what the hardware vendors need, Microsoft won’t collaborate
>> +with us on DT, and the hardware vendors would still need to provide two
>> +completely separate firmware interface; one for Linux and one for Windows.
>> +
>
> And Here at the end of the file. Redundant blank line.

Thanks a lot for the pointer, I will update it :)

Regards
Hanjun

^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 00/21] Introduce ACPI for ARM64 based on ACPI 5.1
  2015-02-27  8:50   ` Ard Biesheuvel
  2015-02-27 10:36     ` Mark Rutland
@ 2015-02-27 21:05     ` Timur Tabi
  2015-03-04 23:18     ` Timur Tabi
  2 siblings, 0 replies; 106+ messages in thread
From: Timur Tabi @ 2015-02-27 21:05 UTC (permalink / raw)
  To: Ard Biesheuvel
  Cc: Hanjun Guo, Catalin Marinas, Rafael J. Wysocki, Will Deacon,
	Olof Johansson, Grant Likely, Mark Rutland, Ashwin Chaugule,
	Lorenzo Pieralisi, Robert Richter, Arnd Bergmann, Graeme Gregory,
	Linaro ACPI Mailman List, Marc Zyngier, Jon Masters,
	linux-kernel, linux-acpi, Mark Brown, Suravee Suthikulpanit,
	Sudeep Holla, linux-arm-kernel

On 02/27/2015 02:50 AM, Ard Biesheuvel wrote:
> On 27 February 2015 at 03:20, Timur Tabi <timur@codeaurora.org> wrote:
>> On 02/25/2015 02:39 AM, Hanjun Guo wrote:
>>>
>>> Changes since v8:
>>
>>
>> I'm still debugging it, but v9 on the 4.0-rc1 kernel crashes after calling
>> the UEFI boot time services exit function.  That is, this line:
>>
>> status = sys_table->boottime->exit_boot_services(handle, mmap_key);
>>
>> in allocate_new_fdt_and_exit_boot() gets called, and then soon after it
>> returns, the kernel crashes.  It's really early because the UEFI exception
>> handler is called.
>>
>> I did not have this problem with v8 patchset on 3.19.
>>
>
> Are you not seeing this on v4.0-rc1 without the patchset applied?

You're right -- I get the same crash even without the patchset applied.

> Could the crash be inside the subsequent call to
> SetVirtualAddressMap() instead of inside ExitBootServices()?

It looks that way.  I'm going to have to debug that.

> If so, you have a firmware bug: Mark Rutland spotted a similar bug in
> the AMD Seattle firmware, which has been fixed in the mean time.
> It has to do with the firmware dereferencing the virtual mapping as it
> is being installed, which violates the UEFI spec.

Thanks.

-- 
Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.

^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 02/21] ACPI / processor: Introduce phys_cpuid_t for CPU hardware ID
  2015-02-25  8:39 ` [PATCH v9 02/21] ACPI / processor: Introduce phys_cpuid_t for CPU hardware ID Hanjun Guo
@ 2015-03-04 22:29   ` Rafael J. Wysocki
  2015-03-05  7:44     ` Hanjun Guo
  2015-03-06 20:19   ` Grant Likely
  1 sibling, 1 reply; 106+ messages in thread
From: Rafael J. Wysocki @ 2015-03-04 22:29 UTC (permalink / raw)
  To: Hanjun Guo
  Cc: Catalin Marinas, Will Deacon, Olof Johansson, Grant Likely,
	Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi

On Wednesday, February 25, 2015 04:39:42 PM Hanjun Guo wrote:
> CPU hardware ID (phys_id) is defined as u32 in structure acpi_processor,
> but phys_id is used as int in acpi processor driver, so it will lead to
> some inconsistence for the drivers.
> 
> Furthermore, to cater for ACPI arch ports that implement 64 bits CPU
> ids a generic CPU physical id type is required.
> 
> So introduce typedef u32 phys_cpuid_t for x86 and ia64, and introduce
> a macro CPU_PHYS_ID_INVALID as (u32)(-1), use phys_cpuid_t when phys_id
> defined in acpi processor driver, and replace CPU_PHYS_ID_INVALID as -1
> for phys_id, this will solve the inconsistence in acpi processor driver,
> and will prepare for the ACPI on ARM64 too.
> 
> CC: Rafael J Wysocki <rjw@rjwysocki.net>
> Suggested-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
> Acked-by: Sudeep Holla <sudeep.holla@arm.com>
> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
> [hj: reworked cpu physid map return codes]
> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
> ---
>  arch/ia64/include/asm/acpi.h  |  4 ++++
>  arch/ia64/kernel/acpi.c       |  2 +-
>  arch/x86/include/asm/acpi.h   |  4 ++++
>  arch/x86/kernel/acpi/boot.c   |  2 +-
>  drivers/acpi/acpi_processor.c |  7 ++++---
>  drivers/acpi/processor_core.c | 30 +++++++++++++++---------------
>  include/acpi/processor.h      |  6 +++---
>  include/linux/acpi.h          |  2 +-
>  8 files changed, 33 insertions(+), 24 deletions(-)
> 
> diff --git a/arch/ia64/include/asm/acpi.h b/arch/ia64/include/asm/acpi.h
> index a1d91ab..ca1f0e4 100644
> --- a/arch/ia64/include/asm/acpi.h
> +++ b/arch/ia64/include/asm/acpi.h
> @@ -34,6 +34,10 @@
>  #include <linux/numa.h>
>  #include <asm/numa.h>
>  
> +typedef u32 phys_cpuid_t;
> +
> +#define CPU_PHYS_ID_INVALID (u32)(-1)
> +
>  #ifdef	CONFIG_ACPI
>  extern int acpi_lapic;
>  #define acpi_disabled 0	/* ACPI always enabled on IA64 */
> diff --git a/arch/ia64/kernel/acpi.c b/arch/ia64/kernel/acpi.c
> index 2c44989..067ef44 100644
> --- a/arch/ia64/kernel/acpi.c
> +++ b/arch/ia64/kernel/acpi.c
> @@ -887,7 +887,7 @@ static int _acpi_map_lsapic(acpi_handle handle, int physid, int *pcpu)
>  }
>  
>  /* wrapper to silence section mismatch warning */
> -int __ref acpi_map_cpu(acpi_handle handle, int physid, int *pcpu)
> +int __ref acpi_map_cpu(acpi_handle handle, phys_cpuid_t physid, int *pcpu)
>  {
>  	return _acpi_map_lsapic(handle, physid, pcpu);
>  }
> diff --git a/arch/x86/include/asm/acpi.h b/arch/x86/include/asm/acpi.h
> index 3a45668..cd788dd 100644
> --- a/arch/x86/include/asm/acpi.h
> +++ b/arch/x86/include/asm/acpi.h
> @@ -32,6 +32,10 @@
>  #include <asm/mpspec.h>
>  #include <asm/realmode.h>
>  
> +typedef u32 phys_cpuid_t;
> +
> +#define CPU_PHYS_ID_INVALID (u32)(-1)

Can we define those things in one common place instead of having to duplicate
the definitions for every arch?

Also, I'd like to have

static inline bool invalid_cpu_phys_id(phys_cpuid_t phys_id)
{
	return (int)phys_id < 0;
}

as that would cover error codes too.

Moreover, why don't you use (phys_cpuid_t)(-1) in the #define?  And call is
PHYS_CPUID_INVALID for that matter (so that the name of the symbol corresponds
to the name of the type)?


> +
>  #ifdef CONFIG_ACPI
>  extern int acpi_lapic;
>  extern int acpi_ioapic;
> diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
> index 3d525c6..e4f8582 100644
> --- a/arch/x86/kernel/acpi/boot.c
> +++ b/arch/x86/kernel/acpi/boot.c
> @@ -757,7 +757,7 @@ static int _acpi_map_lsapic(acpi_handle handle, int physid, int *pcpu)
>  }
>  
>  /* wrapper to silence section mismatch warning */
> -int __ref acpi_map_cpu(acpi_handle handle, int physid, int *pcpu)
> +int __ref acpi_map_cpu(acpi_handle handle, phys_cpuid_t physid, int *pcpu)
>  {
>  	return _acpi_map_lsapic(handle, physid, pcpu);
>  }
> diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c
> index 1020b1b..e6c7c56 100644
> --- a/drivers/acpi/acpi_processor.c
> +++ b/drivers/acpi/acpi_processor.c
> @@ -170,7 +170,7 @@ static int acpi_processor_hotadd_init(struct acpi_processor *pr)
>  	acpi_status status;
>  	int ret;
>  
> -	if (pr->phys_id == -1)
> +	if (pr->phys_id == CPU_PHYS_ID_INVALID)
>  		return -ENODEV;
>  
>  	status = acpi_evaluate_integer(pr->handle, "_STA", NULL, &sta);
> @@ -215,7 +215,8 @@ static int acpi_processor_get_info(struct acpi_device *device)
>  	union acpi_object object = { 0 };
>  	struct acpi_buffer buffer = { sizeof(union acpi_object), &object };
>  	struct acpi_processor *pr = acpi_driver_data(device);
> -	int phys_id, cpu_index, device_declaration = 0;
> +	phys_cpuid_t phys_id;
> +	int cpu_index, device_declaration = 0;
>  	acpi_status status = AE_OK;
>  	static int cpu0_initialized;
>  	unsigned long long value;
> @@ -263,7 +264,7 @@ static int acpi_processor_get_info(struct acpi_device *device)
>  	}
>  
>  	phys_id = acpi_get_phys_id(pr->handle, device_declaration, pr->acpi_id);
> -	if (phys_id < 0)
> +	if (phys_id == CPU_PHYS_ID_INVALID)
>  		acpi_handle_debug(pr->handle, "failed to get CPU physical ID.\n");
>  	pr->phys_id = phys_id;
>  
> diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c
> index 7962651..a5547dc 100644
> --- a/drivers/acpi/processor_core.c
> +++ b/drivers/acpi/processor_core.c
> @@ -32,7 +32,7 @@ static struct acpi_table_madt *get_madt_table(void)
>  }
>  
>  static int map_lapic_id(struct acpi_subtable_header *entry,
> -		 u32 acpi_id, int *apic_id)
> +		 u32 acpi_id, phys_cpuid_t *apic_id)
>  {
>  	struct acpi_madt_local_apic *lapic =
>  		container_of(entry, struct acpi_madt_local_apic, header);
> @@ -48,7 +48,7 @@ static int map_lapic_id(struct acpi_subtable_header *entry,
>  }
>  
>  static int map_x2apic_id(struct acpi_subtable_header *entry,
> -			 int device_declaration, u32 acpi_id, int *apic_id)
> +		int device_declaration, u32 acpi_id, phys_cpuid_t *apic_id)
>  {
>  	struct acpi_madt_local_x2apic *apic =
>  		container_of(entry, struct acpi_madt_local_x2apic, header);
> @@ -65,7 +65,7 @@ static int map_x2apic_id(struct acpi_subtable_header *entry,
>  }
>  
>  static int map_lsapic_id(struct acpi_subtable_header *entry,
> -		int device_declaration, u32 acpi_id, int *apic_id)
> +		int device_declaration, u32 acpi_id, phys_cpuid_t *apic_id)
>  {
>  	struct acpi_madt_local_sapic *lsapic =
>  		container_of(entry, struct acpi_madt_local_sapic, header);
> @@ -83,10 +83,10 @@ static int map_lsapic_id(struct acpi_subtable_header *entry,
>  	return 0;
>  }
>  
> -static int map_madt_entry(int type, u32 acpi_id)
> +static phys_cpuid_t map_madt_entry(int type, u32 acpi_id)
>  {
>  	unsigned long madt_end, entry;
> -	int phys_id = -1;	/* CPU hardware ID */
> +	phys_cpuid_t phys_id = CPU_PHYS_ID_INVALID;	/* CPU hardware ID */
>  	struct acpi_table_madt *madt;
>  
>  	madt = get_madt_table();
> @@ -117,12 +117,12 @@ static int map_madt_entry(int type, u32 acpi_id)
>  	return phys_id;
>  }
>  
> -static int map_mat_entry(acpi_handle handle, int type, u32 acpi_id)
> +static phys_cpuid_t map_mat_entry(acpi_handle handle, int type, u32 acpi_id)
>  {
>  	struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
>  	union acpi_object *obj;
>  	struct acpi_subtable_header *header;
> -	int phys_id = -1;
> +	phys_cpuid_t phys_id = CPU_PHYS_ID_INVALID;
>  
>  	if (ACPI_FAILURE(acpi_evaluate_object(handle, "_MAT", NULL, &buffer)))
>  		goto exit;
> @@ -149,27 +149,27 @@ exit:
>  	return phys_id;
>  }
>  
> -int acpi_get_phys_id(acpi_handle handle, int type, u32 acpi_id)
> +phys_cpuid_t acpi_get_phys_id(acpi_handle handle, int type, u32 acpi_id)
>  {
> -	int phys_id;
> +	phys_cpuid_t phys_id;
>  
>  	phys_id = map_mat_entry(handle, type, acpi_id);
> -	if (phys_id == -1)
> +	if (phys_id == CPU_PHYS_ID_INVALID)
>  		phys_id = map_madt_entry(type, acpi_id);
>  
>  	return phys_id;
>  }
>  
> -int acpi_map_cpuid(int phys_id, u32 acpi_id)
> +int acpi_map_cpuid(phys_cpuid_t phys_id, u32 acpi_id)
>  {
>  #ifdef CONFIG_SMP
>  	int i;
>  #endif
>  
> -	if (phys_id == -1) {
> +	if (phys_id == CPU_PHYS_ID_INVALID) {
>  		/*
>  		 * On UP processor, there is no _MAT or MADT table.
> -		 * So above phys_id is always set to -1.
> +		 * So above phys_id is always set to CPU_PHYS_ID_INVALID.
>  		 *
>  		 * BIOS may define multiple CPU handles even for UP processor.
>  		 * For example,
> @@ -190,7 +190,7 @@ int acpi_map_cpuid(int phys_id, u32 acpi_id)
>  		if (nr_cpu_ids <= 1 && acpi_id == 0)
>  			return acpi_id;
>  		else
> -			return phys_id;
> +			return -1;

Can we use a proper error code here?

>  	}
>  
>  #ifdef CONFIG_SMP


-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 01/21] ACPI / table: Use pr_debug() instead of pr_info() for MADT table scanning
  2015-02-25  8:39 ` [PATCH v9 01/21] ACPI / table: Use pr_debug() instead of pr_info() for MADT table scanning Hanjun Guo
@ 2015-03-04 22:33   ` Rafael J. Wysocki
  2015-03-05 17:55   ` Olof Johansson
  2015-03-06 20:17   ` Grant Likely
  2 siblings, 0 replies; 106+ messages in thread
From: Rafael J. Wysocki @ 2015-03-04 22:33 UTC (permalink / raw)
  To: Hanjun Guo
  Cc: Catalin Marinas, Will Deacon, Olof Johansson, Grant Likely,
	Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi

On Wednesday, February 25, 2015 04:39:41 PM Hanjun Guo wrote:
> For a normal 8 cpu sockets system, it will up to 240 cpu threads (Xeon E7
> v2 family for now), and we need 240 entries for local apic or local x2apic
> in MADT table, so it will be much verbose information printed with a slow
> uart console when system booted, this will be even worse with large system
> with 16/32 cpu sockets.
> 
> This patch just use pr_debug() instead of pr_info() for ioapic/iosapic,
> local apic/x2apic/sapic structures when scanning the MADT table to remove
> those verbose information, but leave other structures unchanged.
> 
> CC: Rafael J Wysocki <rjw@rjwysocki.net>
> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>

Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

> ---
>  drivers/acpi/tables.c | 30 ++++++++++++++++--------------
>  1 file changed, 16 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c
> index 93b8152..f4e5b88 100644
> --- a/drivers/acpi/tables.c
> +++ b/drivers/acpi/tables.c
> @@ -23,6 +23,8 @@
>   *
>   */
>  
> +/* Uncomment next line to get verbose printout */
> +/* #define DEBUG */
>  #define pr_fmt(fmt) "ACPI: " fmt
>  
>  #include <linux/init.h>
> @@ -61,9 +63,9 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header)
>  		{
>  			struct acpi_madt_local_apic *p =
>  			    (struct acpi_madt_local_apic *)header;
> -			pr_info("LAPIC (acpi_id[0x%02x] lapic_id[0x%02x] %s)\n",
> -				p->processor_id, p->id,
> -				(p->lapic_flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled");
> +			pr_debug("LAPIC (acpi_id[0x%02x] lapic_id[0x%02x] %s)\n",
> +				 p->processor_id, p->id,
> +				 (p->lapic_flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled");
>  		}
>  		break;
>  
> @@ -71,9 +73,9 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header)
>  		{
>  			struct acpi_madt_local_x2apic *p =
>  			    (struct acpi_madt_local_x2apic *)header;
> -			pr_info("X2APIC (apic_id[0x%02x] uid[0x%02x] %s)\n",
> -				p->local_apic_id, p->uid,
> -				(p->lapic_flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled");
> +			pr_debug("X2APIC (apic_id[0x%02x] uid[0x%02x] %s)\n",
> +				 p->local_apic_id, p->uid,
> +				 (p->lapic_flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled");
>  		}
>  		break;
>  
> @@ -81,8 +83,8 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header)
>  		{
>  			struct acpi_madt_io_apic *p =
>  			    (struct acpi_madt_io_apic *)header;
> -			pr_info("IOAPIC (id[0x%02x] address[0x%08x] gsi_base[%d])\n",
> -				p->id, p->address, p->global_irq_base);
> +			pr_debug("IOAPIC (id[0x%02x] address[0x%08x] gsi_base[%d])\n",
> +				 p->id, p->address, p->global_irq_base);
>  		}
>  		break;
>  
> @@ -155,9 +157,9 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header)
>  		{
>  			struct acpi_madt_io_sapic *p =
>  			    (struct acpi_madt_io_sapic *)header;
> -			pr_info("IOSAPIC (id[0x%x] address[%p] gsi_base[%d])\n",
> -				p->id, (void *)(unsigned long)p->address,
> -				p->global_irq_base);
> +			pr_debug("IOSAPIC (id[0x%x] address[%p] gsi_base[%d])\n",
> +				 p->id, (void *)(unsigned long)p->address,
> +				 p->global_irq_base);
>  		}
>  		break;
>  
> @@ -165,9 +167,9 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header)
>  		{
>  			struct acpi_madt_local_sapic *p =
>  			    (struct acpi_madt_local_sapic *)header;
> -			pr_info("LSAPIC (acpi_id[0x%02x] lsapic_id[0x%02x] lsapic_eid[0x%02x] %s)\n",
> -				p->processor_id, p->id, p->eid,
> -				(p->lapic_flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled");
> +			pr_debug("LSAPIC (acpi_id[0x%02x] lsapic_id[0x%02x] lsapic_eid[0x%02x] %s)\n",
> +				 p->processor_id, p->id, p->eid,
> +				 (p->lapic_flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled");
>  		}
>  		break;
>  
> 

-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 03/21] ACPI: add arm64 to the platforms that use ioremap
  2015-02-25  8:39 ` [PATCH v9 03/21] ACPI: add arm64 to the platforms that use ioremap Hanjun Guo
@ 2015-03-04 22:33   ` Rafael J. Wysocki
  2015-03-06 20:20   ` Grant Likely
  1 sibling, 0 replies; 106+ messages in thread
From: Rafael J. Wysocki @ 2015-03-04 22:33 UTC (permalink / raw)
  To: Hanjun Guo
  Cc: Catalin Marinas, Will Deacon, Olof Johansson, Grant Likely,
	Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi, Al Stone

On Wednesday, February 25, 2015 04:39:43 PM Hanjun Guo wrote:
> From: Graeme Gregory <graeme.gregory@linaro.org>
> 
> Now with the base changes to the arm memory mapping it is safe
> to convert to using ioremap to map in the tables after
> acpi_gbl_permanent_mmap is set.
> 
> CC: Rafael J Wysocki <rjw@rjwysocki.net>
> Tested-by: Robert Richter <rrichter@cavium.com>
> Acked-by: Robert Richter <rrichter@cavium.com>
> Signed-off-by: Al Stone <al.stone@linaro.org>
> Signed-off-by: Graeme Gregory <graeme.gregory@linaro.org>
> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>

Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

> ---
>  drivers/acpi/osl.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
> index f9eeae8..39748bb 100644
> --- a/drivers/acpi/osl.c
> +++ b/drivers/acpi/osl.c
> @@ -336,11 +336,11 @@ acpi_map_lookup_virt(void __iomem *virt, acpi_size size)
>  	return NULL;
>  }
>  
> -#ifndef CONFIG_IA64
> -#define should_use_kmap(pfn)   page_is_ram(pfn)
> -#else
> +#if defined(CONFIG_IA64) || defined(CONFIG_ARM64)
>  /* ioremap will take care of cache attributes */
>  #define should_use_kmap(pfn)   0
> +#else
> +#define should_use_kmap(pfn)   page_is_ram(pfn)
>  #endif
>  
>  static void __iomem *acpi_map(acpi_physical_address pg_off, unsigned long pg_sz)
> 

-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 06/21] ACPI: fix acpi_os_ioremap for arm64
  2015-02-25  8:39 ` [PATCH v9 06/21] ACPI: fix acpi_os_ioremap for arm64 Hanjun Guo
@ 2015-03-04 22:36   ` Rafael J. Wysocki
  2015-03-06 20:30   ` Grant Likely
  1 sibling, 0 replies; 106+ messages in thread
From: Rafael J. Wysocki @ 2015-03-04 22:36 UTC (permalink / raw)
  To: Hanjun Guo
  Cc: Catalin Marinas, Will Deacon, Olof Johansson, Grant Likely,
	Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi, Mark Salter

On Wednesday, February 25, 2015 04:39:46 PM Hanjun Guo wrote:
> From: Mark Salter <msalter@redhat.com>
> 
> The acpi_os_ioremap() function may be used to map normal RAM or IO
> regions. The current implementation simply uses ioremap_cache(). This
> will work for some architectures, but arm64 ioremap_cache() cannot be
> used to map IO regions which don't support caching. So for arm64, use
> ioremap() for non-RAM regions.
> 
> CC: Rafael J Wysocki <rjw@rjwysocki.net>
> CC: Catalin Marinas <catalin.marinas@arm.com>
> Tested-by: Robert Richter <rrichter@cavium.com>
> Acked-by: Robert Richter <rrichter@cavium.com>
> Signed-off-by: Mark Salter <msalter@redhat.com>
> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>

Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

> ---
>  arch/arm64/include/asm/acpi.h | 13 +++++++++++++
>  include/acpi/acpi_io.h        |  4 ++++
>  2 files changed, 17 insertions(+)
> 
> diff --git a/arch/arm64/include/asm/acpi.h b/arch/arm64/include/asm/acpi.h
> index 8b837ab..40e0924 100644
> --- a/arch/arm64/include/asm/acpi.h
> +++ b/arch/arm64/include/asm/acpi.h
> @@ -12,8 +12,21 @@
>  #ifndef _ASM_ACPI_H
>  #define _ASM_ACPI_H
>  
> +#include <linux/mm.h>
> +
>  /* Basic configuration for ACPI */
>  #ifdef	CONFIG_ACPI
> +/* ACPI table mapping after acpi_gbl_permanent_mmap is set */
> +static inline void __iomem *acpi_os_ioremap(acpi_physical_address phys,
> +					    acpi_size size)
> +{
> +	if (!page_is_ram(phys >> PAGE_SHIFT))
> +		return ioremap(phys, size);
> +
> +	return ioremap_cache(phys, size);
> +}
> +#define acpi_os_ioremap acpi_os_ioremap
> +
>  #define acpi_strict 1	/* No out-of-spec workarounds on ARM64 */
>  extern int acpi_disabled;
>  extern int acpi_noirq;
> diff --git a/include/acpi/acpi_io.h b/include/acpi/acpi_io.h
> index 444671e..dd86c5f 100644
> --- a/include/acpi/acpi_io.h
> +++ b/include/acpi/acpi_io.h
> @@ -3,11 +3,15 @@
>  
>  #include <linux/io.h>
>  
> +#include <asm/acpi.h>
> +
> +#ifndef acpi_os_ioremap
>  static inline void __iomem *acpi_os_ioremap(acpi_physical_address phys,
>  					    acpi_size size)
>  {
>         return ioremap_cache(phys, size);
>  }
> +#endif
>  
>  void __iomem *__init_refok
>  acpi_os_map_iomem(acpi_physical_address phys, acpi_size size);
> 

-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 07/21] ACPI / sleep: Introduce arm64 specific acpi_sleep.c
  2015-02-25  8:39 ` [PATCH v9 07/21] ACPI / sleep: Introduce arm64 specific acpi_sleep.c Hanjun Guo
@ 2015-03-04 22:38   ` Rafael J. Wysocki
  2015-03-04 22:49     ` G Gregory
  2015-03-06 20:34   ` Grant Likely
  1 sibling, 1 reply; 106+ messages in thread
From: Rafael J. Wysocki @ 2015-03-04 22:38 UTC (permalink / raw)
  To: Hanjun Guo
  Cc: Catalin Marinas, Will Deacon, Olof Johansson, Grant Likely,
	Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi, Tomasz Nowicki

On Wednesday, February 25, 2015 04:39:47 PM Hanjun Guo wrote:
> From: Graeme Gregory <graeme.gregory@linaro.org>
> 
> ACPI 5.1 does not currently support S states for ARM64 hardware but
> ACPI code will call acpi_target_system_state() for device power
> management, so introduce acpi_sleep.c to allow other drivers to function
> until S states are defined.
> 
> Since it is arm64 specific stub holder, so let acpi_sleep.c to ARM64
> specific.
> 
> TODO: merge this with drivers/acpi/sleep.c once we fix the specification.
> 
> CC: Rafael J. Wysocki <rjw@rjwysocki.net>
> Tested-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
> Tested-by: Yijing Wang <wangyijing@huawei.com>
> Tested-by: Mark Langsdorf <mlangsdo@redhat.com>
> Tested-by: Jon Masters <jcm@redhat.com>
> Tested-by: Timur Tabi <timur@codeaurora.org>
> Tested-by: Robert Richter <rrichter@cavium.com>
> Acked-by: Robert Richter <rrichter@cavium.com>
> Signed-off-by: Graeme Gregory <graeme.gregory@linaro.org>
> Signed-off-by: Tomasz Nowicki <tomasz.nowicki@linaro.org>
> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
> ---
>  arch/arm64/kernel/Makefile     |  2 +-
>  arch/arm64/kernel/acpi_sleep.c | 28 ++++++++++++++++++++++++++++
>  drivers/acpi/Makefile          |  2 ++
>  3 files changed, 31 insertions(+), 1 deletion(-)
>  create mode 100644 arch/arm64/kernel/acpi_sleep.c
> 
> diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile
> index 218eb7e..4435943 100644
> --- a/arch/arm64/kernel/Makefile
> +++ b/arch/arm64/kernel/Makefile
> @@ -34,7 +34,7 @@ arm64-obj-$(CONFIG_KGDB)		+= kgdb.o
>  arm64-obj-$(CONFIG_EFI)			+= efi.o efi-stub.o efi-entry.o
>  arm64-obj-$(CONFIG_PCI)			+= pci.o
>  arm64-obj-$(CONFIG_ARMV8_DEPRECATED)	+= armv8_deprecated.o
> -arm64-obj-$(CONFIG_ACPI)		+= acpi.o
> +arm64-obj-$(CONFIG_ACPI)		+= acpi.o acpi_sleep.o
>  
>  obj-y					+= $(arm64-obj-y) vdso/
>  obj-m					+= $(arm64-obj-m)
> diff --git a/arch/arm64/kernel/acpi_sleep.c b/arch/arm64/kernel/acpi_sleep.c
> new file mode 100644
> index 0000000..54578ef
> --- /dev/null
> +++ b/arch/arm64/kernel/acpi_sleep.c
> @@ -0,0 +1,28 @@
> +/*
> + *  ARM64 Specific Sleep Functionality
> + *
> + *  Copyright (C) 2013-2014, Linaro Ltd.
> + *      Author: Graeme Gregory <graeme.gregory@linaro.org>
> + *
> + *  This program is free software; you can redistribute it and/or modify
> + *  it under the terms of the GNU General Public License version 2 as
> + *  published by the Free Software Foundation.
> + */
> +
> +#include <linux/acpi.h>
> +
> +/*
> + * Currently the ACPI 5.1 standard does not define S states in a
> + * manner which is usable for ARM64. These two stubs are sufficient
> + * that system initialises and device PM works.
> + */
> +u32 acpi_target_system_state(void)
> +{
> +	return ACPI_STATE_S0;
> +}
> +EXPORT_SYMBOL_GPL(acpi_target_system_state);
> +
> +int __init acpi_sleep_init(void)
> +{
> +	return -ENOSYS;
> +}
> diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
> index 623b117..c32edf5 100644
> --- a/drivers/acpi/Makefile
> +++ b/drivers/acpi/Makefile
> @@ -23,7 +23,9 @@ acpi-y				+= nvs.o
>  
>  # Power management related files
>  acpi-y				+= wakeup.o
> +ifneq (,$(findstring $(ARCH),x86 ia64))

This is super-ugly.  Isn't there a better way to do that?

>  acpi-y				+= sleep.o
> +endif
>  acpi-y				+= device_pm.o
>  acpi-$(CONFIG_ACPI_SLEEP)	+= proc.o
>  
> 

-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 12/21] ACPI / table: Print GIC information when MADT is parsed
  2015-02-25  8:39 ` [PATCH v9 12/21] ACPI / table: Print GIC information when MADT is parsed Hanjun Guo
@ 2015-03-04 22:40   ` Rafael J. Wysocki
  2015-03-06 18:06   ` Lorenzo Pieralisi
  2015-03-06 20:40   ` Grant Likely
  2 siblings, 0 replies; 106+ messages in thread
From: Rafael J. Wysocki @ 2015-03-04 22:40 UTC (permalink / raw)
  To: Hanjun Guo
  Cc: Catalin Marinas, Will Deacon, Olof Johansson, Grant Likely,
	Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi, Tomasz Nowicki

On Wednesday, February 25, 2015 04:39:52 PM Hanjun Guo wrote:
> When MADT is parsed, print GIC information as debug message:
> 
> ACPI: GICC (acpi_id[0x0000] address[00000000e112f000] MPIDR[0x0] enabled)
> ACPI: GICC (acpi_id[0x0001] address[00000000e112f000] MPIDR[0x1] enabled)
> ...
> ACPI: GICC (acpi_id[0x0201] address[00000000e112f000] MPIDR[0x201] enabled)
> 
> Those debug information will be very helpful to bring up early systems to
> see if acpi_id and MPIDR are matched or not as spec defined.
> 
> CC: Rafael J. Wysocki <rjw@rjwysocki.net>
> Tested-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
> Tested-by: Yijing Wang <wangyijing@huawei.com>
> Tested-by: Mark Langsdorf <mlangsdo@redhat.com>
> Tested-by: Jon Masters <jcm@redhat.com>
> Tested-by: Timur Tabi <timur@codeaurora.org>
> Tested-by: Robert Richter <rrichter@cavium.com>
> Acked-by: Robert Richter <rrichter@cavium.com>
> Acked-by: Sudeep Holla <sudeep.holla@arm.com>
> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
> Signed-off-by: Tomasz Nowicki <tomasz.nowicki@linaro.org>

Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

> ---
>  drivers/acpi/tables.c | 22 ++++++++++++++++++++++
>  1 file changed, 22 insertions(+)
> 
> diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c
> index f4e5b88..2e19189 100644
> --- a/drivers/acpi/tables.c
> +++ b/drivers/acpi/tables.c
> @@ -185,6 +185,28 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header)
>  		}
>  		break;
>  
> +	case ACPI_MADT_TYPE_GENERIC_INTERRUPT:
> +		{
> +			struct acpi_madt_generic_interrupt *p =
> +				(struct acpi_madt_generic_interrupt *)header;
> +			pr_debug("GICC (acpi_id[0x%04x] address[%llx] MPIDR[0x%llx] %s)\n",
> +				 p->uid, p->base_address,
> +				 p->arm_mpidr,
> +				 (p->flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled");
> +
> +		}
> +		break;
> +
> +	case ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR:
> +		{
> +			struct acpi_madt_generic_distributor *p =
> +				(struct acpi_madt_generic_distributor *)header;
> +			pr_debug("GIC Distributor (gic_id[0x%04x] address[%llx] gsi_base[%d])\n",
> +				 p->gic_id, p->base_address,
> +				 p->global_irq_base);
> +		}
> +		break;
> +
>  	default:
>  		pr_warn("Found unsupported MADT entry (type = 0x%x)\n",
>  			header->type);
> 

-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 14/21] ACPI / processor: Make it possible to get CPU hardware ID via GICC
  2015-02-25  8:39 ` [PATCH v9 14/21] ACPI / processor: Make it possible to get CPU hardware ID via GICC Hanjun Guo
@ 2015-03-04 22:46   ` Rafael J. Wysocki
  2015-03-05  8:03     ` Hanjun Guo
  2015-03-07 22:52   ` Grant Likely
  1 sibling, 1 reply; 106+ messages in thread
From: Rafael J. Wysocki @ 2015-03-04 22:46 UTC (permalink / raw)
  To: Hanjun Guo
  Cc: Catalin Marinas, Will Deacon, Olof Johansson, Grant Likely,
	Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi

On Wednesday, February 25, 2015 04:39:54 PM Hanjun Guo wrote:
> Introduce a new function map_gicc_mpidr() to allow MPIDRs to be obtained
> from the GICC Structure introduced by ACPI 5.1.
> 
> The ARM architecture defines the MPIDR register as the CPU hardware
> identifier. This patch adds the code infrastructure to retrieve the MPIDR
> values from the ARM ACPI GICC structure in order to look-up the kernel CPU
> hardware ids required by the ACPI core code to identify CPUs.
> 
> CC: Rafael J. Wysocki <rjw@rjwysocki.net>
> CC: Catalin Marinas <catalin.marinas@arm.com>
> CC: Will Deacon <will.deacon@arm.com>
> Tested-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
> Tested-by: Yijing Wang <wangyijing@huawei.com>
> Tested-by: Mark Langsdorf <mlangsdo@redhat.com>
> Tested-by: Jon Masters <jcm@redhat.com>
> Tested-by: Timur Tabi <timur@codeaurora.org>
> Tested-by: Robert Richter <rrichter@cavium.com>
> Acked-by: Robert Richter <rrichter@cavium.com>
> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
> ---
>  arch/arm64/include/asm/acpi.h | 12 ++++++++++++
>  drivers/acpi/processor_core.c | 30 ++++++++++++++++++++++++++++++
>  2 files changed, 42 insertions(+)
> 
> diff --git a/arch/arm64/include/asm/acpi.h b/arch/arm64/include/asm/acpi.h
> index 9719921..9a23369 100644
> --- a/arch/arm64/include/asm/acpi.h
> +++ b/arch/arm64/include/asm/acpi.h
> @@ -13,6 +13,8 @@
>  #define _ASM_ACPI_H
>  
>  #include <linux/mm.h>
> +#include <asm/cputype.h>
> +#include <asm/smp_plat.h>
>  
>  /* Basic configuration for ACPI */
>  #ifdef	CONFIG_ACPI
> @@ -27,6 +29,9 @@ static inline void __iomem *acpi_os_ioremap(acpi_physical_address phys,
>  }
>  #define acpi_os_ioremap acpi_os_ioremap
>  
> +typedef u64 phys_cpuid_t;
> +#define CPU_PHYS_ID_INVALID INVALID_HWID
> +

Any chance to combine this with patch [2/21]?  Or at least put them next to each
other in the series so as to indicate that they are related or *mention* patch
[2/21] in the changelog here?

IMO, you really need to define phys_cpuid_t in a common place or people will
forget that it may be 64-bit, because they'll only be looking at their arch.

>  #define acpi_strict 1	/* No out-of-spec workarounds on ARM64 */
>  extern int acpi_disabled;
>  extern int acpi_noirq;
> @@ -59,6 +64,13 @@ static inline void enable_acpi(void)
>  }
>  
>  /*
> + * The ACPI processor driver for ACPI core code needs this macro
> + * to find out this cpu was already mapped (mapping from CPU hardware
> + * ID to CPU logical ID) or not.
> + */
> +#define cpu_physical_id(cpu) cpu_logical_map(cpu)
> +
> +/*
>   * It's used from ACPI core in kdump to boot UP system with SMP kernel,
>   * with this check the ACPI core will not override the CPU index
>   * obtained from GICC with 0 and not print some error message as well.
> diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c
> index a5547dc..8654adb 100644
> --- a/drivers/acpi/processor_core.c
> +++ b/drivers/acpi/processor_core.c
> @@ -83,6 +83,31 @@ static int map_lsapic_id(struct acpi_subtable_header *entry,
>  	return 0;
>  }
>  
> +/*
> + * Retrieve the ARM CPU physical identifier (MPIDR)
> + */
> +static int map_gicc_mpidr(struct acpi_subtable_header *entry,
> +		int device_declaration, u32 acpi_id, phys_cpuid_t *mpidr)
> +{
> +	struct acpi_madt_generic_interrupt *gicc =
> +	    container_of(entry, struct acpi_madt_generic_interrupt, header);
> +
> +	if (!(gicc->flags & ACPI_MADT_ENABLED))
> +		return -ENODEV;
> +
> +	/* device_declaration means Device object in DSDT, In the
> +	 * GIC interrupt model, logical processors are required to
> +	 * have a Processor Device object in the DSDT, so we should
> +	 * check device_declaration here
> +	 */
> +	if (device_declaration && (gicc->uid == acpi_id)) {
> +		*mpidr = gicc->arm_mpidr;
> +		return 0;
> +	}
> +
> +	return -EINVAL;
> +}
> +
>  static phys_cpuid_t map_madt_entry(int type, u32 acpi_id)
>  {
>  	unsigned long madt_end, entry;
> @@ -111,6 +136,9 @@ static phys_cpuid_t map_madt_entry(int type, u32 acpi_id)
>  		} else if (header->type == ACPI_MADT_TYPE_LOCAL_SAPIC) {
>  			if (!map_lsapic_id(header, type, acpi_id, &phys_id))
>  				break;
> +		} else if (header->type == ACPI_MADT_TYPE_GENERIC_INTERRUPT) {
> +			if (!map_gicc_mpidr(header, type, acpi_id, &phys_id))
> +				break;
>  		}
>  		entry += header->length;
>  	}
> @@ -143,6 +171,8 @@ static phys_cpuid_t map_mat_entry(acpi_handle handle, int type, u32 acpi_id)
>  		map_lsapic_id(header, type, acpi_id, &phys_id);
>  	else if (header->type == ACPI_MADT_TYPE_LOCAL_X2APIC)
>  		map_x2apic_id(header, type, acpi_id, &phys_id);
> +	else if (header->type == ACPI_MADT_TYPE_GENERIC_INTERRUPT)
> +		map_gicc_mpidr(header, type, acpi_id, &phys_id);
>  
>  exit:
>  	kfree(buffer.pointer);
> 

-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 15/21] ARM64 / ACPI: Introduce ACPI_IRQ_MODEL_GIC and register device's gsi
  2015-02-25  8:39 ` [PATCH v9 15/21] ARM64 / ACPI: Introduce ACPI_IRQ_MODEL_GIC and register device's gsi Hanjun Guo
@ 2015-03-04 22:47   ` Rafael J. Wysocki
  2015-03-07 23:05   ` Grant Likely
  1 sibling, 0 replies; 106+ messages in thread
From: Rafael J. Wysocki @ 2015-03-04 22:47 UTC (permalink / raw)
  To: Hanjun Guo
  Cc: Catalin Marinas, Will Deacon, Olof Johansson, Grant Likely,
	Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi

On Wednesday, February 25, 2015 04:39:55 PM Hanjun Guo wrote:
> Introduce ACPI_IRQ_MODEL_GIC which is needed for ARM64 as GIC is
> used, and then register device's gsi with the core IRQ subsystem.
> 
> acpi_register_gsi() is similar to DT based irq_of_parse_and_map(),
> since gsi is unique in the system, so use hwirq number directly
> for the mapping.
> 
> We are going to implement stacked domains when GICv2m, GICv3, ITS
> support are added.
> 
> CC: Marc Zyngier <marc.zyngier@arm.com>
> Originally-by: Amit Daniel Kachhap <amit.daniel@samsung.com>
> Tested-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
> Tested-by: Yijing Wang <wangyijing@huawei.com>
> Tested-by: Mark Langsdorf <mlangsdo@redhat.com>
> Tested-by: Jon Masters <jcm@redhat.com>
> Tested-by: Timur Tabi <timur@codeaurora.org>
> Tested-by: Robert Richter <rrichter@cavium.com>
> Acked-by: Robert Richter <rrichter@cavium.com>
> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>

For the changes in bus.c:

Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

> ---
>  arch/arm64/kernel/acpi.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++++
>  drivers/acpi/bus.c       |  3 ++
>  include/linux/acpi.h     |  1 +
>  3 files changed, 77 insertions(+)
> 
> diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c
> index 0f35d87..31f080e 100644
> --- a/arch/arm64/kernel/acpi.c
> +++ b/arch/arm64/kernel/acpi.c
> @@ -76,6 +76,12 @@ static int __init dt_scan_depth1_nodes(unsigned long node,
>  }
>  
>  /*
> + * Since we're on ARM, the default interrupt routing model
> + * clearly has to be GIC.
> + */
> +enum acpi_irq_model_id acpi_irq_model = ACPI_IRQ_MODEL_GIC;
> +
> +/*
>   * __acpi_map_table() will be called before page_init(), so early_ioremap()
>   * or early_memremap() should be called here to for ACPI table mapping.
>   */
> @@ -218,6 +224,73 @@ void __init acpi_init_cpus(void)
>  	pr_info("%d CPUs enabled, %d CPUs total\n", enabled_cpus, total_cpus);
>  }
>  
> +int acpi_gsi_to_irq(u32 gsi, unsigned int *irq)
> +{
> +	*irq = irq_find_mapping(NULL, gsi);
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL_GPL(acpi_gsi_to_irq);
> +
> +/*
> + * success: return IRQ number (>0)
> + * failure: return =< 0
> + */
> +int acpi_register_gsi(struct device *dev, u32 gsi, int trigger, int polarity)
> +{
> +	unsigned int irq;
> +	unsigned int irq_type;
> +
> +	/*
> +	 * ACPI have no bindings to indicate SPI or PPI, so we
> +	 * use different mappings from DT in ACPI.
> +	 *
> +	 * For FDT
> +	 * PPI interrupt: in the range [0, 15];
> +	 * SPI interrupt: in the range [0, 987];
> +	 *
> +	 * For ACPI, GSI should be unique so using
> +	 * the hwirq directly for the mapping:
> +	 * PPI interrupt: in the range [16, 31];
> +	 * SPI interrupt: in the range [32, 1019];
> +	 */
> +
> +	if (trigger == ACPI_EDGE_SENSITIVE &&
> +				polarity == ACPI_ACTIVE_LOW)
> +		irq_type = IRQ_TYPE_EDGE_FALLING;
> +	else if (trigger == ACPI_EDGE_SENSITIVE &&
> +				polarity == ACPI_ACTIVE_HIGH)
> +		irq_type = IRQ_TYPE_EDGE_RISING;
> +	else if (trigger == ACPI_LEVEL_SENSITIVE &&
> +				polarity == ACPI_ACTIVE_LOW)
> +		irq_type = IRQ_TYPE_LEVEL_LOW;
> +	else if (trigger == ACPI_LEVEL_SENSITIVE &&
> +				polarity == ACPI_ACTIVE_HIGH)
> +		irq_type = IRQ_TYPE_LEVEL_HIGH;
> +	else
> +		irq_type = IRQ_TYPE_NONE;
> +
> +	/*
> +	 * Since only one GIC is supported in ACPI 5.0, we can
> +	 * create mapping refer to the default domain
> +	 */
> +	irq = irq_create_mapping(NULL, gsi);
> +	if (!irq)
> +		return irq;
> +
> +	/* Set irq type if specified and different than the current one */
> +	if (irq_type != IRQ_TYPE_NONE &&
> +		irq_type != irq_get_trigger_type(irq))
> +		irq_set_irq_type(irq, irq_type);
> +	return irq;
> +}
> +EXPORT_SYMBOL_GPL(acpi_register_gsi);
> +
> +void acpi_unregister_gsi(u32 gsi)
> +{
> +}
> +EXPORT_SYMBOL_GPL(acpi_unregister_gsi);
> +
>  static int __init acpi_parse_fadt(struct acpi_table_header *table)
>  {
>  	struct acpi_table_fadt *fadt = (struct acpi_table_fadt *)table;
> diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
> index 8b67bd0..c412fdb 100644
> --- a/drivers/acpi/bus.c
> +++ b/drivers/acpi/bus.c
> @@ -448,6 +448,9 @@ static int __init acpi_bus_init_irq(void)
>  	case ACPI_IRQ_MODEL_IOSAPIC:
>  		message = "IOSAPIC";
>  		break;
> +	case ACPI_IRQ_MODEL_GIC:
> +		message = "GIC";
> +		break;
>  	case ACPI_IRQ_MODEL_PLATFORM:
>  		message = "platform specific model";
>  		break;
> diff --git a/include/linux/acpi.h b/include/linux/acpi.h
> index 0eabd15..c03d8d1 100644
> --- a/include/linux/acpi.h
> +++ b/include/linux/acpi.h
> @@ -73,6 +73,7 @@ enum acpi_irq_model_id {
>  	ACPI_IRQ_MODEL_IOAPIC,
>  	ACPI_IRQ_MODEL_IOSAPIC,
>  	ACPI_IRQ_MODEL_PLATFORM,
> +	ACPI_IRQ_MODEL_GIC,
>  	ACPI_IRQ_MODEL_COUNT
>  };
>  
> 

-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 07/21] ACPI / sleep: Introduce arm64 specific acpi_sleep.c
  2015-03-04 22:38   ` Rafael J. Wysocki
@ 2015-03-04 22:49     ` G Gregory
  2015-03-04 23:25       ` Rafael J. Wysocki
  0 siblings, 1 reply; 106+ messages in thread
From: G Gregory @ 2015-03-04 22:49 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Hanjun Guo, Catalin Marinas, Will Deacon, Olof Johansson,
	Grant Likely, Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	Suravee Suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, Linaro ACPI Mailman List, Tomasz Nowicki

On 4 March 2015 at 22:38, Rafael J. Wysocki <rjw@rjwysocki.net> wrote:
> On Wednesday, February 25, 2015 04:39:47 PM Hanjun Guo wrote:
>> From: Graeme Gregory <graeme.gregory@linaro.org>
>>
>> ACPI 5.1 does not currently support S states for ARM64 hardware but
>> ACPI code will call acpi_target_system_state() for device power
>> management, so introduce acpi_sleep.c to allow other drivers to function
>> until S states are defined.
>>
>> Since it is arm64 specific stub holder, so let acpi_sleep.c to ARM64
>> specific.
>>
>> TODO: merge this with drivers/acpi/sleep.c once we fix the specification.
>>
>> CC: Rafael J. Wysocki <rjw@rjwysocki.net>
>> Tested-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
>> Tested-by: Yijing Wang <wangyijing@huawei.com>
>> Tested-by: Mark Langsdorf <mlangsdo@redhat.com>
>> Tested-by: Jon Masters <jcm@redhat.com>
>> Tested-by: Timur Tabi <timur@codeaurora.org>
>> Tested-by: Robert Richter <rrichter@cavium.com>
>> Acked-by: Robert Richter <rrichter@cavium.com>
>> Signed-off-by: Graeme Gregory <graeme.gregory@linaro.org>
>> Signed-off-by: Tomasz Nowicki <tomasz.nowicki@linaro.org>
>> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
>> ---
>>  arch/arm64/kernel/Makefile     |  2 +-
>>  arch/arm64/kernel/acpi_sleep.c | 28 ++++++++++++++++++++++++++++
>>  drivers/acpi/Makefile          |  2 ++
>>  3 files changed, 31 insertions(+), 1 deletion(-)
>>  create mode 100644 arch/arm64/kernel/acpi_sleep.c
>>
>> diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile
>> index 218eb7e..4435943 100644
>> --- a/arch/arm64/kernel/Makefile
>> +++ b/arch/arm64/kernel/Makefile
>> @@ -34,7 +34,7 @@ arm64-obj-$(CONFIG_KGDB)            += kgdb.o
>>  arm64-obj-$(CONFIG_EFI)                      += efi.o efi-stub.o efi-entry.o
>>  arm64-obj-$(CONFIG_PCI)                      += pci.o
>>  arm64-obj-$(CONFIG_ARMV8_DEPRECATED) += armv8_deprecated.o
>> -arm64-obj-$(CONFIG_ACPI)             += acpi.o
>> +arm64-obj-$(CONFIG_ACPI)             += acpi.o acpi_sleep.o
>>
>>  obj-y                                        += $(arm64-obj-y) vdso/
>>  obj-m                                        += $(arm64-obj-m)
>> diff --git a/arch/arm64/kernel/acpi_sleep.c b/arch/arm64/kernel/acpi_sleep.c
>> new file mode 100644
>> index 0000000..54578ef
>> --- /dev/null
>> +++ b/arch/arm64/kernel/acpi_sleep.c
>> @@ -0,0 +1,28 @@
>> +/*
>> + *  ARM64 Specific Sleep Functionality
>> + *
>> + *  Copyright (C) 2013-2014, Linaro Ltd.
>> + *      Author: Graeme Gregory <graeme.gregory@linaro.org>
>> + *
>> + *  This program is free software; you can redistribute it and/or modify
>> + *  it under the terms of the GNU General Public License version 2 as
>> + *  published by the Free Software Foundation.
>> + */
>> +
>> +#include <linux/acpi.h>
>> +
>> +/*
>> + * Currently the ACPI 5.1 standard does not define S states in a
>> + * manner which is usable for ARM64. These two stubs are sufficient
>> + * that system initialises and device PM works.
>> + */
>> +u32 acpi_target_system_state(void)
>> +{
>> +     return ACPI_STATE_S0;
>> +}
>> +EXPORT_SYMBOL_GPL(acpi_target_system_state);
>> +
>> +int __init acpi_sleep_init(void)
>> +{
>> +     return -ENOSYS;
>> +}
>> diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
>> index 623b117..c32edf5 100644
>> --- a/drivers/acpi/Makefile
>> +++ b/drivers/acpi/Makefile
>> @@ -23,7 +23,9 @@ acpi-y                              += nvs.o
>>
>>  # Power management related files
>>  acpi-y                               += wakeup.o
>> +ifneq (,$(findstring $(ARCH),x86 ia64))
>
> This is super-ugly.  Isn't there a better way to do that?
>
Its the standard example in the GNU Make manual, I would certainly
love if someone had a batter suggestion.

Graeme

^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 16/21] irqchip: Add GICv2 specific ACPI boot support
  2015-02-25  8:39 ` [PATCH v9 16/21] irqchip: Add GICv2 specific ACPI boot support Hanjun Guo
@ 2015-03-04 22:50   ` Rafael J. Wysocki
  2015-03-05  9:06     ` Hanjun Guo
  2015-03-05 11:53     ` Catalin Marinas
  2015-03-05  8:21   ` Hanjun Guo
  2015-03-07 23:14   ` Grant Likely
  2 siblings, 2 replies; 106+ messages in thread
From: Rafael J. Wysocki @ 2015-03-04 22:50 UTC (permalink / raw)
  To: Hanjun Guo
  Cc: Catalin Marinas, Will Deacon, Olof Johansson, Grant Likely,
	Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi, Tomasz Nowicki, Jason Cooper,
	Thomas Gleixner

On Wednesday, February 25, 2015 04:39:56 PM Hanjun Guo wrote:
> From: Tomasz Nowicki <tomasz.nowicki@linaro.org>
> 
> ACPI kernel uses MADT table for proper GIC initialization. It needs to
> parse GIC related subtables, collect CPU interface and distributor
> addresses and call driver initialization function (which is hardware
> abstraction agnostic). In a similar way, FDT initialize GICv1/2.
> 
> NOTE: This commit allow to initialize GICv1/2 basic functionality.
> While now simple GICv2 init call is used, any further GIC features
> require generic infrastructure for proper ACPI irqchip initialization.
> That mechanism and stacked irqdomains to support GICv2 MSI/virtualization
> extension, GICv3/4 and its ITS are considered as next steps.
> 
> CC: Jason Cooper <jason@lakedaemon.net>
> CC: Marc Zyngier <marc.zyngier@arm.com>
> CC: Thomas Gleixner <tglx@linutronix.de>
> Tested-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
> Tested-by: Yijing Wang <wangyijing@huawei.com>
> Tested-by: Mark Langsdorf <mlangsdo@redhat.com>
> Tested-by: Jon Masters <jcm@redhat.com>
> Tested-by: Timur Tabi <timur@codeaurora.org>
> Tested-by: Robert Richter <rrichter@cavium.com>
> Acked-by: Robert Richter <rrichter@cavium.com>
> Signed-off-by: Tomasz Nowicki <tomasz.nowicki@linaro.org>
> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
> ---
>  arch/arm64/include/asm/acpi.h        |   2 +
>  arch/arm64/kernel/acpi.c             |  25 +++++++++
>  drivers/irqchip/irq-gic.c            | 102 +++++++++++++++++++++++++++++++++++
>  drivers/irqchip/irqchip.c            |   3 ++
>  include/linux/acpi.h                 |  14 +++++
>  include/linux/irqchip/arm-gic-acpi.h |  29 ++++++++++
>  6 files changed, 175 insertions(+)
>  create mode 100644 include/linux/irqchip/arm-gic-acpi.h
> 
> diff --git a/arch/arm64/include/asm/acpi.h b/arch/arm64/include/asm/acpi.h
> index 9a23369..a720a61 100644
> --- a/arch/arm64/include/asm/acpi.h
> +++ b/arch/arm64/include/asm/acpi.h
> @@ -13,6 +13,8 @@
>  #define _ASM_ACPI_H
>  
>  #include <linux/mm.h>
> +#include <linux/irqchip/arm-gic-acpi.h>
> +
>  #include <asm/cputype.h>
>  #include <asm/smp_plat.h>
>  
> diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c
> index 31f080e..af308c3 100644
> --- a/arch/arm64/kernel/acpi.c
> +++ b/arch/arm64/kernel/acpi.c
> @@ -359,3 +359,28 @@ void __init acpi_boot_table_init(void)
>  		pr_err("Can't find FADT\n");
>  	}
>  }
> +
> +void __init acpi_gic_init(void)
> +{
> +	struct acpi_table_header *table;
> +	acpi_status status;
> +	acpi_size tbl_size;
> +	int err;
> +
> +	if (acpi_disabled)
> +		return;
> +
> +	status = acpi_get_table_with_size(ACPI_SIG_MADT, 0, &table, &tbl_size);
> +	if (ACPI_FAILURE(status)) {
> +		const char *msg = acpi_format_exception(status);
> +
> +		pr_err("Failed to get MADT table, %s\n", msg);
> +		return;
> +	}
> +
> +	err = gic_v2_acpi_init(table);
> +	if (err)
> +		pr_err("Failed to initialize GIC IRQ controller");
> +
> +	early_acpi_os_unmap_memory((char *)table, tbl_size);
> +}
> diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
> index 4634cf7..929d668 100644
> --- a/drivers/irqchip/irq-gic.c
> +++ b/drivers/irqchip/irq-gic.c
> @@ -33,12 +33,14 @@
>  #include <linux/of.h>
>  #include <linux/of_address.h>
>  #include <linux/of_irq.h>
> +#include <linux/acpi.h>
>  #include <linux/irqdomain.h>
>  #include <linux/interrupt.h>
>  #include <linux/percpu.h>
>  #include <linux/slab.h>
>  #include <linux/irqchip/chained_irq.h>
>  #include <linux/irqchip/arm-gic.h>
> +#include <linux/irqchip/arm-gic-acpi.h>
>  
>  #include <asm/cputype.h>
>  #include <asm/irq.h>
> @@ -1086,3 +1088,103 @@ IRQCHIP_DECLARE(msm_8660_qgic, "qcom,msm-8660-qgic", gic_of_init);
>  IRQCHIP_DECLARE(msm_qgic2, "qcom,msm-qgic2", gic_of_init);
>  
>  #endif
> +
> +#ifdef CONFIG_ACPI
> +static phys_addr_t dist_phy_base, cpu_phy_base __initdata;
> +
> +static int __init
> +gic_acpi_parse_madt_cpu(struct acpi_subtable_header *header,
> +			const unsigned long end)
> +{
> +	struct acpi_madt_generic_interrupt *processor;
> +	phys_addr_t gic_cpu_base;
> +	static int cpu_base_assigned;
> +
> +	processor = (struct acpi_madt_generic_interrupt *)header;
> +
> +	if (BAD_MADT_ENTRY(processor, end))
> +		return -EINVAL;
> +
> +	/*
> +	 * There is no support for non-banked GICv1/2 register in ACPI spec.
> +	 * All CPU interface addresses have to be the same.
> +	 */
> +	gic_cpu_base = processor->base_address;
> +	if (cpu_base_assigned && gic_cpu_base != cpu_phy_base)
> +		return -EINVAL;
> +
> +	cpu_phy_base = gic_cpu_base;
> +	cpu_base_assigned = 1;
> +	return 0;
> +}
> +
> +static int __init
> +gic_acpi_parse_madt_distributor(struct acpi_subtable_header *header,
> +				const unsigned long end)
> +{
> +	struct acpi_madt_generic_distributor *dist;
> +
> +	dist = (struct acpi_madt_generic_distributor *)header;
> +
> +	if (BAD_MADT_ENTRY(dist, end))
> +		return -EINVAL;
> +
> +	dist_phy_base = dist->base_address;
> +	return 0;
> +}
> +
> +int __init
> +gic_v2_acpi_init(struct acpi_table_header *table)
> +{
> +	void __iomem *cpu_base, *dist_base;
> +	int count;
> +
> +	/* Collect CPU base addresses */
> +	count = acpi_parse_entries(ACPI_SIG_MADT,
> +				   sizeof(struct acpi_table_madt),
> +				   gic_acpi_parse_madt_cpu, table,
> +				   ACPI_MADT_TYPE_GENERIC_INTERRUPT, 0);
> +	if (count <= 0) {
> +		pr_err("No valid GICC entries exist\n");
> +		return -EINVAL;
> +	}
> +
> +	/*
> +	 * Find distributor base address. We expect one distributor entry since
> +	 * ACPI 5.1 spec neither support multi-GIC instances nor GIC cascade.
> +	 */
> +	count = acpi_parse_entries(ACPI_SIG_MADT,
> +				   sizeof(struct acpi_table_madt),
> +				   gic_acpi_parse_madt_distributor, table,
> +				   ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR, 0);
> +	if (count <= 0) {
> +		pr_err("No valid GICD entries exist\n");
> +		return -EINVAL;
> +	} else if (count > 1) {
> +		pr_err("More than one GICD entry detected\n");
> +		return -EINVAL;
> +	}
> +
> +	cpu_base = ioremap(cpu_phy_base, ACPI_GIC_CPU_IF_MEM_SIZE);
> +	if (!cpu_base) {
> +		pr_err("Unable to map GICC registers\n");
> +		return -ENOMEM;
> +	}
> +
> +	dist_base = ioremap(dist_phy_base, ACPI_GICV2_DIST_MEM_SIZE);
> +	if (!dist_base) {
> +		pr_err("Unable to map GICD registers\n");
> +		iounmap(cpu_base);
> +		return -ENOMEM;
> +	}
> +
> +	/*
> +	 * Initialize zero GIC instance (no multi-GIC support). Also, set GIC
> +	 * as default IRQ domain to allow for GSI registration and GSI to IRQ
> +	 * number translation (see acpi_register_gsi() and acpi_gsi_to_irq()).
> +	 */
> +	gic_init_bases(0, -1, dist_base, cpu_base, 0, NULL);
> +	irq_set_default_host(gic_data[0].domain);
> +	return 0;
> +}
> +#endif
> diff --git a/drivers/irqchip/irqchip.c b/drivers/irqchip/irqchip.c
> index 0fe2f71..5855240 100644
> --- a/drivers/irqchip/irqchip.c
> +++ b/drivers/irqchip/irqchip.c
> @@ -8,6 +8,7 @@
>   * warranty of any kind, whether express or implied.
>   */
>  
> +#include <linux/acpi.h>
>  #include <linux/init.h>
>  #include <linux/of_irq.h>
>  #include <linux/irqchip.h>
> @@ -26,4 +27,6 @@ extern struct of_device_id __irqchip_of_table[];
>  void __init irqchip_init(void)
>  {
>  	of_irq_init(__irqchip_of_table);
> +
> +	acpi_irq_init();
>  }
> diff --git a/include/linux/acpi.h b/include/linux/acpi.h
> index c03d8d1..e27117a 100644
> --- a/include/linux/acpi.h
> +++ b/include/linux/acpi.h
> @@ -557,6 +557,20 @@ static inline int acpi_device_modalias(struct device *dev,
>  
>  #endif	/* !CONFIG_ACPI */
>  
> +#if defined(CONFIG_ACPI) && defined(CONFIG_ARM64)
> +static inline void acpi_irq_init(void)
> +{
> +	/*
> +	 * Hardcode ACPI IRQ chip initialization to GICv2 for now.
> +	 * Proper irqchip infrastructure will be implemented along with
> +	 * incoming  GICv2m|GICv3|ITS bits.
> +	 */
> +	acpi_gic_init();
> +}
> +#else
> +static inline void acpi_irq_init(void) { }
> +#endif

I don't want this in a common header.


-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 19/21] ARM64 / ACPI: Enable ARM64 in Kconfig
  2015-02-25  8:39 ` [PATCH v9 19/21] ARM64 / ACPI: Enable ARM64 in Kconfig Hanjun Guo
@ 2015-03-04 22:52   ` Rafael J. Wysocki
  2015-03-07 23:17   ` Grant Likely
  1 sibling, 0 replies; 106+ messages in thread
From: Rafael J. Wysocki @ 2015-03-04 22:52 UTC (permalink / raw)
  To: Hanjun Guo
  Cc: Catalin Marinas, Will Deacon, Olof Johansson, Grant Likely,
	Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi, Al Stone

On Wednesday, February 25, 2015 04:39:59 PM Hanjun Guo wrote:
> From: Graeme Gregory <graeme.gregory@linaro.org>
> 
> Add Kconfigs to build ACPI on ARM64, and make ACPI available on ARM64.
> 
> acpi_idle driver is x86/IA64 dependent now, so make CONFIG_ACPI_PROCESSOR
> depend on X86 || IA64, and implement it on ARM64 in the future.
> 
> CC: Rafael J. Wysocki <rjw@rjwysocki.net>
> CC: Catalin Marinas <catalin.marinas@arm.com>
> CC: Will Deacon <will.deacon@arm.com>
> Reviewed-by: Grant Likely <grant.likely@linaro.org>
> Tested-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
> Tested-by: Yijing Wang <wangyijing@huawei.com>
> Tested-by: Mark Langsdorf <mlangsdo@redhat.com>
> Tested-by: Jon Masters <jcm@redhat.com>
> Tested-by: Timur Tabi <timur@codeaurora.org>
> Tested-by: Robert Richter <rrichter@cavium.com>
> Acked-by: Robert Richter <rrichter@cavium.com>
> Signed-off-by: Graeme Gregory <graeme.gregory@linaro.org>
> Signed-off-by: Al Stone <al.stone@linaro.org>
> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>

For the changes in drivers/acpi/Kconfig:

Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

> ---
>  arch/arm64/Kconfig   | 2 ++
>  drivers/acpi/Kconfig | 3 ++-
>  2 files changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
> index d00ab9a..e5aa081 100644
> --- a/arch/arm64/Kconfig
> +++ b/arch/arm64/Kconfig
> @@ -713,6 +713,8 @@ source "drivers/Kconfig"
>  
>  source "drivers/firmware/Kconfig"
>  
> +source "drivers/acpi/Kconfig"
> +
>  source "fs/Kconfig"
>  
>  source "arch/arm64/kvm/Kconfig"
> diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
> index e6c3ddd..7aa3288 100644
> --- a/drivers/acpi/Kconfig
> +++ b/drivers/acpi/Kconfig
> @@ -5,7 +5,7 @@
>  menuconfig ACPI
>  	bool "ACPI (Advanced Configuration and Power Interface) Support"
>  	depends on !IA64_HP_SIM
> -	depends on IA64 || X86
> +	depends on IA64 || X86 || (ARM64 && EXPERT)
>  	depends on PCI
>  	select PNP
>  	default y
> @@ -163,6 +163,7 @@ config ACPI_PROCESSOR
>  	tristate "Processor"
>  	select THERMAL
>  	select CPU_IDLE
> +	depends on X86 || IA64
>  	default y
>  	help
>  	  This driver installs ACPI as the idle handler for Linux and uses
> 

-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 00/21] Introduce ACPI for ARM64 based on ACPI 5.1
  2015-02-25  8:39 [PATCH v9 00/21] Introduce ACPI for ARM64 based on ACPI 5.1 Hanjun Guo
                   ` (21 preceding siblings ...)
  2015-02-27  3:20 ` [PATCH v9 00/21] Introduce ACPI for ARM64 based on ACPI 5.1 Timur Tabi
@ 2015-03-04 22:56 ` Rafael J. Wysocki
  2015-03-05  7:03   ` Hanjun Guo
  2015-03-05 18:57 ` Olof Johansson
  23 siblings, 1 reply; 106+ messages in thread
From: Rafael J. Wysocki @ 2015-03-04 22:56 UTC (permalink / raw)
  To: Hanjun Guo
  Cc: Catalin Marinas, Will Deacon, Olof Johansson, Grant Likely,
	Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi

On Wednesday, February 25, 2015 04:39:40 PM Hanjun Guo wrote:
> Changes since v8:
>   - remove MPIDR packing things by introducing phys_cpuid_t;
> 
>   - update patch acpi: fix acpi_os_ioremap for arm64 to follow
>     Rafael's suggestion;
> 
>   - Squash patch (disable ACPI if ACPI less than 5.1) to patch
>     (Get RSDP and ACPI boot-time table);
> 
>   - Move sleep_arm.c to arch/arm64/ and rename it as acpi_sleep.c 
> 
>   - Rework the uefi generated empty dtb to enable acpi when no dtb
>     is available, thanks Ard for the updated patch.
> 
>   - rework the function of register cpu for kexec case
> 
>   - use pr_debug() instead of pr_info() when scanning MADT.
> 
>   - rebase on top of 4.0-rc1
> 
> Thanks
> Hanjun
> 
> Al Stone (4):
>   ARM64 / ACPI: Get RSDP and ACPI boot-time tables
>   ARM64 / ACPI: Introduce early_param "acpi=" to enable/disable ACPI
>   ARM64 / ACPI: Select ACPI_REDUCED_HARDWARE_ONLY if ACPI is enabled on
>     ARM64
>   ARM64 / ACPI: additions of ACPI documentation for arm64
> 
> Graeme Gregory (6):
>   ACPI: add arm64 to the platforms that use ioremap
>   ACPI / sleep: Introduce arm64 specific acpi_sleep.c
>   ARM64 / ACPI: If we chose to boot from acpi then disable FDT
>   ARM64 / ACPI: Get PSCI flags in FADT for PSCI init
>   ARM64 / ACPI: Enable ARM64 in Kconfig
>   Documentation: ACPI for ARM64
> 
> Hanjun Guo (8):
>   ACPI / table: Use pr_debug() instead of pr_info() for MADT table
>     scanning
>   ACPI / processor: Introduce phys_cpuid_t for CPU hardware ID
>   ARM64 / ACPI: Introduce PCI stub functions for ACPI
>   ACPI / table: Print GIC information when MADT is parsed
>   ARM64 / ACPI: Parse MADT for SMP initialization
>   ACPI / processor: Make it possible to get CPU hardware ID via GICC
>   ARM64 / ACPI: Introduce ACPI_IRQ_MODEL_GIC and register device's gsi
>   clocksource / arch_timer: Parse GTDT to initialize arch timer
> 
> Mark Salter (2):
>   ARM64: allow late use of early_ioremap
>   ACPI: fix acpi_os_ioremap for arm64
> 
> Tomasz Nowicki (1):
>   irqchip: Add GICv2 specific ACPI boot support

I've ACKed or commented the ones relevant for me.  As for the ARM64-specific
code, I don't think I can give any meaningful input.


-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 00/21] Introduce ACPI for ARM64 based on ACPI 5.1
  2015-02-27  8:50   ` Ard Biesheuvel
  2015-02-27 10:36     ` Mark Rutland
  2015-02-27 21:05     ` Timur Tabi
@ 2015-03-04 23:18     ` Timur Tabi
  2 siblings, 0 replies; 106+ messages in thread
From: Timur Tabi @ 2015-03-04 23:18 UTC (permalink / raw)
  To: Ard Biesheuvel
  Cc: Hanjun Guo, Catalin Marinas, Rafael J. Wysocki, Will Deacon,
	Olof Johansson, Grant Likely, Mark Rutland, Ashwin Chaugule,
	Lorenzo Pieralisi, Robert Richter, Arnd Bergmann, Graeme Gregory,
	Linaro ACPI Mailman List, Marc Zyngier, Jon Masters,
	linux-kernel, linux-acpi, Mark Brown, Suravee Suthikulpanit,
	Sudeep Holla, linux-arm-kernel

On 02/27/2015 02:50 AM, Ard Biesheuvel wrote:
> Are you not seeing this on v4.0-rc1 without the patchset applied?
>
> Could the crash be inside the subsequent call to
> SetVirtualAddressMap() instead of inside ExitBootServices()?
>
> If so, you have a firmware bug: Mark Rutland spotted a similar bug in
> the AMD Seattle firmware, which has been fixed in the mean time.
> It has to do with the firmware dereferencing the virtual mapping as it
> is being installed, which violates the UEFI spec.

It looks like you are right.  We fixed the bug in our UEFI and now this 
patchset works.

So all 21 patches:

Tested-by: Timur Tabi <timur@codeaurora.org>


However, I did notice one thing.  Booting the kernel displays this line:

	[   69.424001] Failed to find cpu0 device node

That's because CONFIG_OF is still defined (part of "config ARM64"), and 
therefore cache_setup_of_node() attempts to get the cache information 
from the device tree.

Should CONFIG_OF still be defined?

-- 
Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.

^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 07/21] ACPI / sleep: Introduce arm64 specific acpi_sleep.c
  2015-03-04 22:49     ` G Gregory
@ 2015-03-04 23:25       ` Rafael J. Wysocki
  2015-03-05  0:16         ` Rafael J. Wysocki
  0 siblings, 1 reply; 106+ messages in thread
From: Rafael J. Wysocki @ 2015-03-04 23:25 UTC (permalink / raw)
  To: G Gregory
  Cc: Hanjun Guo, Catalin Marinas, Will Deacon, Olof Johansson,
	Grant Likely, Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	Suravee Suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, Linaro ACPI Mailman List, Tomasz Nowicki

On Wednesday, March 04, 2015 10:49:25 PM G Gregory wrote:
> On 4 March 2015 at 22:38, Rafael J. Wysocki <rjw@rjwysocki.net> wrote:
> > On Wednesday, February 25, 2015 04:39:47 PM Hanjun Guo wrote:
> >> From: Graeme Gregory <graeme.gregory@linaro.org>
> >>
> >> ACPI 5.1 does not currently support S states for ARM64 hardware but
> >> ACPI code will call acpi_target_system_state() for device power
> >> management, so introduce acpi_sleep.c to allow other drivers to function
> >> until S states are defined.
> >>
> >> Since it is arm64 specific stub holder, so let acpi_sleep.c to ARM64
> >> specific.
> >>
> >> TODO: merge this with drivers/acpi/sleep.c once we fix the specification.
> >>
> >> CC: Rafael J. Wysocki <rjw@rjwysocki.net>
> >> Tested-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
> >> Tested-by: Yijing Wang <wangyijing@huawei.com>
> >> Tested-by: Mark Langsdorf <mlangsdo@redhat.com>
> >> Tested-by: Jon Masters <jcm@redhat.com>
> >> Tested-by: Timur Tabi <timur@codeaurora.org>
> >> Tested-by: Robert Richter <rrichter@cavium.com>
> >> Acked-by: Robert Richter <rrichter@cavium.com>
> >> Signed-off-by: Graeme Gregory <graeme.gregory@linaro.org>
> >> Signed-off-by: Tomasz Nowicki <tomasz.nowicki@linaro.org>
> >> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
> >> ---
> >>  arch/arm64/kernel/Makefile     |  2 +-
> >>  arch/arm64/kernel/acpi_sleep.c | 28 ++++++++++++++++++++++++++++
> >>  drivers/acpi/Makefile          |  2 ++
> >>  3 files changed, 31 insertions(+), 1 deletion(-)
> >>  create mode 100644 arch/arm64/kernel/acpi_sleep.c
> >>
> >> diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile
> >> index 218eb7e..4435943 100644
> >> --- a/arch/arm64/kernel/Makefile
> >> +++ b/arch/arm64/kernel/Makefile
> >> @@ -34,7 +34,7 @@ arm64-obj-$(CONFIG_KGDB)            += kgdb.o
> >>  arm64-obj-$(CONFIG_EFI)                      += efi.o efi-stub.o efi-entry.o
> >>  arm64-obj-$(CONFIG_PCI)                      += pci.o
> >>  arm64-obj-$(CONFIG_ARMV8_DEPRECATED) += armv8_deprecated.o
> >> -arm64-obj-$(CONFIG_ACPI)             += acpi.o
> >> +arm64-obj-$(CONFIG_ACPI)             += acpi.o acpi_sleep.o
> >>
> >>  obj-y                                        += $(arm64-obj-y) vdso/
> >>  obj-m                                        += $(arm64-obj-m)
> >> diff --git a/arch/arm64/kernel/acpi_sleep.c b/arch/arm64/kernel/acpi_sleep.c
> >> new file mode 100644
> >> index 0000000..54578ef
> >> --- /dev/null
> >> +++ b/arch/arm64/kernel/acpi_sleep.c
> >> @@ -0,0 +1,28 @@
> >> +/*
> >> + *  ARM64 Specific Sleep Functionality
> >> + *
> >> + *  Copyright (C) 2013-2014, Linaro Ltd.
> >> + *      Author: Graeme Gregory <graeme.gregory@linaro.org>
> >> + *
> >> + *  This program is free software; you can redistribute it and/or modify
> >> + *  it under the terms of the GNU General Public License version 2 as
> >> + *  published by the Free Software Foundation.
> >> + */
> >> +
> >> +#include <linux/acpi.h>
> >> +
> >> +/*
> >> + * Currently the ACPI 5.1 standard does not define S states in a
> >> + * manner which is usable for ARM64. These two stubs are sufficient
> >> + * that system initialises and device PM works.
> >> + */
> >> +u32 acpi_target_system_state(void)
> >> +{
> >> +     return ACPI_STATE_S0;
> >> +}
> >> +EXPORT_SYMBOL_GPL(acpi_target_system_state);
> >> +
> >> +int __init acpi_sleep_init(void)
> >> +{
> >> +     return -ENOSYS;
> >> +}
> >> diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
> >> index 623b117..c32edf5 100644
> >> --- a/drivers/acpi/Makefile
> >> +++ b/drivers/acpi/Makefile
> >> @@ -23,7 +23,9 @@ acpi-y                              += nvs.o
> >>
> >>  # Power management related files
> >>  acpi-y                               += wakeup.o
> >> +ifneq (,$(findstring $(ARCH),x86 ia64))
> >
> > This is super-ugly.  Isn't there a better way to do that?
> >
> Its the standard example in the GNU Make manual,

It is never used in the kernel this way, though, and I'm not going to let
that slip through.

> I would certainly love if someone had a batter suggestion.

Define ACPI_GENERIC_SLEEP in drivers/acpi/Kconfig as

	config ACPI_GENERIC_SLEEP
		bool
		depends on IA64 || X86

and build the file conditional on that.


-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 07/21] ACPI / sleep: Introduce arm64 specific acpi_sleep.c
  2015-03-04 23:25       ` Rafael J. Wysocki
@ 2015-03-05  0:16         ` Rafael J. Wysocki
  2015-03-06 12:36           ` Lorenzo Pieralisi
  0 siblings, 1 reply; 106+ messages in thread
From: Rafael J. Wysocki @ 2015-03-05  0:16 UTC (permalink / raw)
  To: G Gregory
  Cc: Hanjun Guo, Catalin Marinas, Will Deacon, Olof Johansson,
	Grant Likely, Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	Suravee Suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, Linaro ACPI Mailman List, Tomasz Nowicki

On Thursday, March 05, 2015 12:25:54 AM Rafael J. Wysocki wrote:
> On Wednesday, March 04, 2015 10:49:25 PM G Gregory wrote:
> > On 4 March 2015 at 22:38, Rafael J. Wysocki <rjw@rjwysocki.net> wrote:
> > > On Wednesday, February 25, 2015 04:39:47 PM Hanjun Guo wrote:
> > >> From: Graeme Gregory <graeme.gregory@linaro.org>
> > >>
> > >> ACPI 5.1 does not currently support S states for ARM64 hardware but
> > >> ACPI code will call acpi_target_system_state() for device power
> > >> management, so introduce acpi_sleep.c to allow other drivers to function
> > >> until S states are defined.
> > >>
> > >> Since it is arm64 specific stub holder, so let acpi_sleep.c to ARM64
> > >> specific.
> > >>
> > >> TODO: merge this with drivers/acpi/sleep.c once we fix the specification.
> > >>
> > >> CC: Rafael J. Wysocki <rjw@rjwysocki.net>
> > >> Tested-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
> > >> Tested-by: Yijing Wang <wangyijing@huawei.com>
> > >> Tested-by: Mark Langsdorf <mlangsdo@redhat.com>
> > >> Tested-by: Jon Masters <jcm@redhat.com>
> > >> Tested-by: Timur Tabi <timur@codeaurora.org>
> > >> Tested-by: Robert Richter <rrichter@cavium.com>
> > >> Acked-by: Robert Richter <rrichter@cavium.com>
> > >> Signed-off-by: Graeme Gregory <graeme.gregory@linaro.org>
> > >> Signed-off-by: Tomasz Nowicki <tomasz.nowicki@linaro.org>
> > >> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
> > >> ---
> > >>  arch/arm64/kernel/Makefile     |  2 +-
> > >>  arch/arm64/kernel/acpi_sleep.c | 28 ++++++++++++++++++++++++++++
> > >>  drivers/acpi/Makefile          |  2 ++
> > >>  3 files changed, 31 insertions(+), 1 deletion(-)
> > >>  create mode 100644 arch/arm64/kernel/acpi_sleep.c
> > >>
> > >> diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile
> > >> index 218eb7e..4435943 100644
> > >> --- a/arch/arm64/kernel/Makefile
> > >> +++ b/arch/arm64/kernel/Makefile
> > >> @@ -34,7 +34,7 @@ arm64-obj-$(CONFIG_KGDB)            += kgdb.o
> > >>  arm64-obj-$(CONFIG_EFI)                      += efi.o efi-stub.o efi-entry.o
> > >>  arm64-obj-$(CONFIG_PCI)                      += pci.o
> > >>  arm64-obj-$(CONFIG_ARMV8_DEPRECATED) += armv8_deprecated.o
> > >> -arm64-obj-$(CONFIG_ACPI)             += acpi.o
> > >> +arm64-obj-$(CONFIG_ACPI)             += acpi.o acpi_sleep.o
> > >>
> > >>  obj-y                                        += $(arm64-obj-y) vdso/
> > >>  obj-m                                        += $(arm64-obj-m)
> > >> diff --git a/arch/arm64/kernel/acpi_sleep.c b/arch/arm64/kernel/acpi_sleep.c
> > >> new file mode 100644
> > >> index 0000000..54578ef
> > >> --- /dev/null
> > >> +++ b/arch/arm64/kernel/acpi_sleep.c
> > >> @@ -0,0 +1,28 @@
> > >> +/*
> > >> + *  ARM64 Specific Sleep Functionality
> > >> + *
> > >> + *  Copyright (C) 2013-2014, Linaro Ltd.
> > >> + *      Author: Graeme Gregory <graeme.gregory@linaro.org>
> > >> + *
> > >> + *  This program is free software; you can redistribute it and/or modify
> > >> + *  it under the terms of the GNU General Public License version 2 as
> > >> + *  published by the Free Software Foundation.
> > >> + */
> > >> +
> > >> +#include <linux/acpi.h>
> > >> +
> > >> +/*
> > >> + * Currently the ACPI 5.1 standard does not define S states in a
> > >> + * manner which is usable for ARM64. These two stubs are sufficient
> > >> + * that system initialises and device PM works.
> > >> + */
> > >> +u32 acpi_target_system_state(void)
> > >> +{
> > >> +     return ACPI_STATE_S0;
> > >> +}
> > >> +EXPORT_SYMBOL_GPL(acpi_target_system_state);
> > >> +
> > >> +int __init acpi_sleep_init(void)
> > >> +{
> > >> +     return -ENOSYS;
> > >> +}
> > >> diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
> > >> index 623b117..c32edf5 100644
> > >> --- a/drivers/acpi/Makefile
> > >> +++ b/drivers/acpi/Makefile
> > >> @@ -23,7 +23,9 @@ acpi-y                              += nvs.o
> > >>
> > >>  # Power management related files
> > >>  acpi-y                               += wakeup.o
> > >> +ifneq (,$(findstring $(ARCH),x86 ia64))
> > >
> > > This is super-ugly.  Isn't there a better way to do that?
> > >
> > Its the standard example in the GNU Make manual,
> 
> It is never used in the kernel this way, though, and I'm not going to let
> that slip through.
> 
> > I would certainly love if someone had a batter suggestion.
> 
> Define ACPI_GENERIC_SLEEP in drivers/acpi/Kconfig as
> 
> 	config ACPI_GENERIC_SLEEP
> 		bool
> 		depends on IA64 || X86
> 
> and build the file conditional on that.

Or define

	config ACPI_GENERIC_SLEEP
		bool

and then make both x86 and ia64 do

	select ACPI_GENERIC_SLEEP if ACPI

which kind of will make it clear where the choice takes place.


-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 00/21] Introduce ACPI for ARM64 based on ACPI 5.1
  2015-03-04 22:56 ` Rafael J. Wysocki
@ 2015-03-05  7:03   ` Hanjun Guo
  0 siblings, 0 replies; 106+ messages in thread
From: Hanjun Guo @ 2015-03-05  7:03 UTC (permalink / raw)
  To: Rafael J. Wysocki, Hanjun Guo
  Cc: Catalin Marinas, Will Deacon, Olof Johansson, Grant Likely,
	Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi

On 2015/3/5 6:56, Rafael J. Wysocki wrote:
> On Wednesday, February 25, 2015 04:39:40 PM Hanjun Guo wrote:
>> Changes since v8:
>>   - remove MPIDR packing things by introducing phys_cpuid_t;
>>
>>   - update patch acpi: fix acpi_os_ioremap for arm64 to follow
>>     Rafael's suggestion;
>>
>>   - Squash patch (disable ACPI if ACPI less than 5.1) to patch
>>     (Get RSDP and ACPI boot-time table);
>>
>>   - Move sleep_arm.c to arch/arm64/ and rename it as acpi_sleep.c 
>>
>>   - Rework the uefi generated empty dtb to enable acpi when no dtb
>>     is available, thanks Ard for the updated patch.
>>
>>   - rework the function of register cpu for kexec case
>>
>>   - use pr_debug() instead of pr_info() when scanning MADT.
>>
>>   - rebase on top of 4.0-rc1
>>
>> Thanks
>> Hanjun
>>
>> Al Stone (4):
>>   ARM64 / ACPI: Get RSDP and ACPI boot-time tables
>>   ARM64 / ACPI: Introduce early_param "acpi=" to enable/disable ACPI
>>   ARM64 / ACPI: Select ACPI_REDUCED_HARDWARE_ONLY if ACPI is enabled on
>>     ARM64
>>   ARM64 / ACPI: additions of ACPI documentation for arm64
>>
>> Graeme Gregory (6):
>>   ACPI: add arm64 to the platforms that use ioremap
>>   ACPI / sleep: Introduce arm64 specific acpi_sleep.c
>>   ARM64 / ACPI: If we chose to boot from acpi then disable FDT
>>   ARM64 / ACPI: Get PSCI flags in FADT for PSCI init
>>   ARM64 / ACPI: Enable ARM64 in Kconfig
>>   Documentation: ACPI for ARM64
>>
>> Hanjun Guo (8):
>>   ACPI / table: Use pr_debug() instead of pr_info() for MADT table
>>     scanning
>>   ACPI / processor: Introduce phys_cpuid_t for CPU hardware ID
>>   ARM64 / ACPI: Introduce PCI stub functions for ACPI
>>   ACPI / table: Print GIC information when MADT is parsed
>>   ARM64 / ACPI: Parse MADT for SMP initialization
>>   ACPI / processor: Make it possible to get CPU hardware ID via GICC
>>   ARM64 / ACPI: Introduce ACPI_IRQ_MODEL_GIC and register device's gsi
>>   clocksource / arch_timer: Parse GTDT to initialize arch timer
>>
>> Mark Salter (2):
>>   ARM64: allow late use of early_ioremap
>>   ACPI: fix acpi_os_ioremap for arm64
>>
>> Tomasz Nowicki (1):
>>   irqchip: Add GICv2 specific ACPI boot support
> I've ACKed or commented the ones relevant for me.  As for the ARM64-specific
> code, I don't think I can give any meaningful input.

Hi Rafael, thank you very much for the ACKs and review comments, I will
wait for other maintainers comments and then update this patch set.

Regards
Hanjun


^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 02/21] ACPI / processor: Introduce phys_cpuid_t for CPU hardware ID
  2015-03-04 22:29   ` Rafael J. Wysocki
@ 2015-03-05  7:44     ` Hanjun Guo
  2015-03-05 13:23       ` Rafael J. Wysocki
  0 siblings, 1 reply; 106+ messages in thread
From: Hanjun Guo @ 2015-03-05  7:44 UTC (permalink / raw)
  To: Rafael J. Wysocki, Hanjun Guo
  Cc: Catalin Marinas, Will Deacon, Olof Johansson, Grant Likely,
	Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi

On 2015/3/5 6:29, Rafael J. Wysocki wrote:
> On Wednesday, February 25, 2015 04:39:42 PM Hanjun Guo wrote:
>> CPU hardware ID (phys_id) is defined as u32 in structure acpi_processor,
>> but phys_id is used as int in acpi processor driver, so it will lead to
>> some inconsistence for the drivers.
>>
>> Furthermore, to cater for ACPI arch ports that implement 64 bits CPU
>> ids a generic CPU physical id type is required.
>>
>> So introduce typedef u32 phys_cpuid_t for x86 and ia64, and introduce
>> a macro CPU_PHYS_ID_INVALID as (u32)(-1), use phys_cpuid_t when phys_id
>> defined in acpi processor driver, and replace CPU_PHYS_ID_INVALID as -1
>> for phys_id, this will solve the inconsistence in acpi processor driver,
>> and will prepare for the ACPI on ARM64 too.
>>
>> CC: Rafael J Wysocki <rjw@rjwysocki.net>
>> Suggested-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
>> Acked-by: Sudeep Holla <sudeep.holla@arm.com>
>> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
>> [hj: reworked cpu physid map return codes]
>> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
>> ---
>>  arch/ia64/include/asm/acpi.h  |  4 ++++
>>  arch/ia64/kernel/acpi.c       |  2 +-
>>  arch/x86/include/asm/acpi.h   |  4 ++++
>>  arch/x86/kernel/acpi/boot.c   |  2 +-
>>  drivers/acpi/acpi_processor.c |  7 ++++---
>>  drivers/acpi/processor_core.c | 30 +++++++++++++++---------------
>>  include/acpi/processor.h      |  6 +++---
>>  include/linux/acpi.h          |  2 +-
>>  8 files changed, 33 insertions(+), 24 deletions(-)
>>
>> diff --git a/arch/ia64/include/asm/acpi.h b/arch/ia64/include/asm/acpi.h
>> index a1d91ab..ca1f0e4 100644
>> --- a/arch/ia64/include/asm/acpi.h
>> +++ b/arch/ia64/include/asm/acpi.h
>> @@ -34,6 +34,10 @@
>>  #include <linux/numa.h>
>>  #include <asm/numa.h>
>>  
>> +typedef u32 phys_cpuid_t;
>> +
>> +#define CPU_PHYS_ID_INVALID (u32)(-1)
>> +
>>  #ifdef	CONFIG_ACPI
>>  extern int acpi_lapic;
>>  #define acpi_disabled 0	/* ACPI always enabled on IA64 */
>> diff --git a/arch/ia64/kernel/acpi.c b/arch/ia64/kernel/acpi.c
>> index 2c44989..067ef44 100644
>> --- a/arch/ia64/kernel/acpi.c
>> +++ b/arch/ia64/kernel/acpi.c
>> @@ -887,7 +887,7 @@ static int _acpi_map_lsapic(acpi_handle handle, int physid, int *pcpu)
>>  }
>>  
>>  /* wrapper to silence section mismatch warning */
>> -int __ref acpi_map_cpu(acpi_handle handle, int physid, int *pcpu)
>> +int __ref acpi_map_cpu(acpi_handle handle, phys_cpuid_t physid, int *pcpu)
>>  {
>>  	return _acpi_map_lsapic(handle, physid, pcpu);
>>  }
>> diff --git a/arch/x86/include/asm/acpi.h b/arch/x86/include/asm/acpi.h
>> index 3a45668..cd788dd 100644
>> --- a/arch/x86/include/asm/acpi.h
>> +++ b/arch/x86/include/asm/acpi.h
>> @@ -32,6 +32,10 @@
>>  #include <asm/mpspec.h>
>>  #include <asm/realmode.h>
>>  
>> +typedef u32 phys_cpuid_t;
>> +
>> +#define CPU_PHYS_ID_INVALID (u32)(-1)
> Can we define those things in one common place instead of having to duplicate
> the definitions for every arch?

As in your reply in patch 14/21, ARM64 will use 64-bit for

phys_cpuid_t.


>
> Also, I'd like to have
>
> static inline bool invalid_cpu_phys_id(phys_cpuid_t phys_id)
> {
> 	return (int)phys_id < 0;
> }
>
> as that would cover error codes too.
>
> Moreover, why don't you use (phys_cpuid_t)(-1) in the #define?  And call is
> PHYS_CPUID_INVALID for that matter (so that the name of the symbol corresponds
> to the name of the type)?

That's pretty fine to me too.

>
>
>> +
>>  #ifdef CONFIG_ACPI
>>  extern int acpi_lapic;
>>  extern int acpi_ioapic;
>> diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
>> index 3d525c6..e4f8582 100644
>> --- a/arch/x86/kernel/acpi/boot.c
>> +++ b/arch/x86/kernel/acpi/boot.c
>> @@ -757,7 +757,7 @@ static int _acpi_map_lsapic(acpi_handle handle, int physid, int *pcpu)
>>  }
>>  
>>  /* wrapper to silence section mismatch warning */
>> -int __ref acpi_map_cpu(acpi_handle handle, int physid, int *pcpu)
>> +int __ref acpi_map_cpu(acpi_handle handle, phys_cpuid_t physid, int *pcpu)
>>  {
>>  	return _acpi_map_lsapic(handle, physid, pcpu);
>>  }
>> diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c
>> index 1020b1b..e6c7c56 100644
>> --- a/drivers/acpi/acpi_processor.c
>> +++ b/drivers/acpi/acpi_processor.c
>> @@ -170,7 +170,7 @@ static int acpi_processor_hotadd_init(struct acpi_processor *pr)
>>  	acpi_status status;
>>  	int ret;
>>  
>> -	if (pr->phys_id == -1)
>> +	if (pr->phys_id == CPU_PHYS_ID_INVALID)
>>  		return -ENODEV;
>>  
>>  	status = acpi_evaluate_integer(pr->handle, "_STA", NULL, &sta);
>> @@ -215,7 +215,8 @@ static int acpi_processor_get_info(struct acpi_device *device)
>>  	union acpi_object object = { 0 };
>>  	struct acpi_buffer buffer = { sizeof(union acpi_object), &object };
>>  	struct acpi_processor *pr = acpi_driver_data(device);
>> -	int phys_id, cpu_index, device_declaration = 0;
>> +	phys_cpuid_t phys_id;
>> +	int cpu_index, device_declaration = 0;
>>  	acpi_status status = AE_OK;
>>  	static int cpu0_initialized;
>>  	unsigned long long value;
>> @@ -263,7 +264,7 @@ static int acpi_processor_get_info(struct acpi_device *device)
>>  	}
>>  
>>  	phys_id = acpi_get_phys_id(pr->handle, device_declaration, pr->acpi_id);
>> -	if (phys_id < 0)
>> +	if (phys_id == CPU_PHYS_ID_INVALID)
>>  		acpi_handle_debug(pr->handle, "failed to get CPU physical ID.\n");
>>  	pr->phys_id = phys_id;
>>  
>> diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c
>> index 7962651..a5547dc 100644
>> --- a/drivers/acpi/processor_core.c
>> +++ b/drivers/acpi/processor_core.c
>> @@ -32,7 +32,7 @@ static struct acpi_table_madt *get_madt_table(void)
>>  }
>>  
>>  static int map_lapic_id(struct acpi_subtable_header *entry,
>> -		 u32 acpi_id, int *apic_id)
>> +		 u32 acpi_id, phys_cpuid_t *apic_id)
>>  {
>>  	struct acpi_madt_local_apic *lapic =
>>  		container_of(entry, struct acpi_madt_local_apic, header);
>> @@ -48,7 +48,7 @@ static int map_lapic_id(struct acpi_subtable_header *entry,
>>  }
>>  
>>  static int map_x2apic_id(struct acpi_subtable_header *entry,
>> -			 int device_declaration, u32 acpi_id, int *apic_id)
>> +		int device_declaration, u32 acpi_id, phys_cpuid_t *apic_id)
>>  {
>>  	struct acpi_madt_local_x2apic *apic =
>>  		container_of(entry, struct acpi_madt_local_x2apic, header);
>> @@ -65,7 +65,7 @@ static int map_x2apic_id(struct acpi_subtable_header *entry,
>>  }
>>  
>>  static int map_lsapic_id(struct acpi_subtable_header *entry,
>> -		int device_declaration, u32 acpi_id, int *apic_id)
>> +		int device_declaration, u32 acpi_id, phys_cpuid_t *apic_id)
>>  {
>>  	struct acpi_madt_local_sapic *lsapic =
>>  		container_of(entry, struct acpi_madt_local_sapic, header);
>> @@ -83,10 +83,10 @@ static int map_lsapic_id(struct acpi_subtable_header *entry,
>>  	return 0;
>>  }
>>  
>> -static int map_madt_entry(int type, u32 acpi_id)
>> +static phys_cpuid_t map_madt_entry(int type, u32 acpi_id)
>>  {
>>  	unsigned long madt_end, entry;
>> -	int phys_id = -1;	/* CPU hardware ID */
>> +	phys_cpuid_t phys_id = CPU_PHYS_ID_INVALID;	/* CPU hardware ID */
>>  	struct acpi_table_madt *madt;
>>  
>>  	madt = get_madt_table();
>> @@ -117,12 +117,12 @@ static int map_madt_entry(int type, u32 acpi_id)
>>  	return phys_id;
>>  }
>>  
>> -static int map_mat_entry(acpi_handle handle, int type, u32 acpi_id)
>> +static phys_cpuid_t map_mat_entry(acpi_handle handle, int type, u32 acpi_id)
>>  {
>>  	struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
>>  	union acpi_object *obj;
>>  	struct acpi_subtable_header *header;
>> -	int phys_id = -1;
>> +	phys_cpuid_t phys_id = CPU_PHYS_ID_INVALID;
>>  
>>  	if (ACPI_FAILURE(acpi_evaluate_object(handle, "_MAT", NULL, &buffer)))
>>  		goto exit;
>> @@ -149,27 +149,27 @@ exit:
>>  	return phys_id;
>>  }
>>  
>> -int acpi_get_phys_id(acpi_handle handle, int type, u32 acpi_id)
>> +phys_cpuid_t acpi_get_phys_id(acpi_handle handle, int type, u32 acpi_id)
>>  {
>> -	int phys_id;
>> +	phys_cpuid_t phys_id;
>>  
>>  	phys_id = map_mat_entry(handle, type, acpi_id);
>> -	if (phys_id == -1)
>> +	if (phys_id == CPU_PHYS_ID_INVALID)
>>  		phys_id = map_madt_entry(type, acpi_id);
>>  
>>  	return phys_id;
>>  }
>>  
>> -int acpi_map_cpuid(int phys_id, u32 acpi_id)
>> +int acpi_map_cpuid(phys_cpuid_t phys_id, u32 acpi_id)
>>  {
>>  #ifdef CONFIG_SMP
>>  	int i;
>>  #endif
>>  
>> -	if (phys_id == -1) {
>> +	if (phys_id == CPU_PHYS_ID_INVALID) {
>>  		/*
>>  		 * On UP processor, there is no _MAT or MADT table.
>> -		 * So above phys_id is always set to -1.
>> +		 * So above phys_id is always set to CPU_PHYS_ID_INVALID.
>>  		 *
>>  		 * BIOS may define multiple CPU handles even for UP processor.
>>  		 * For example,
>> @@ -190,7 +190,7 @@ int acpi_map_cpuid(int phys_id, u32 acpi_id)
>>  		if (nr_cpu_ids <= 1 && acpi_id == 0)
>>  			return acpi_id;
>>  		else
>> -			return phys_id;
>> +			return -1;
> Can we use a proper error code here?

I'm afraid not. In ACPI processor drivers, -1 will be deemed to
invalid cpu logical number, if we return error code here, we need
to modify multi places of "if (cpu_logical_num == -1)" to
"if (! (cpu_logical_num < 0))" too, so for me, I prefer to keep it as
-1, but I'm open for suggestions.

Thanks
Hanjun


^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 14/21] ACPI / processor: Make it possible to get CPU hardware ID via GICC
  2015-03-04 22:46   ` Rafael J. Wysocki
@ 2015-03-05  8:03     ` Hanjun Guo
  2015-03-05 11:27       ` Catalin Marinas
  0 siblings, 1 reply; 106+ messages in thread
From: Hanjun Guo @ 2015-03-05  8:03 UTC (permalink / raw)
  To: Rafael J. Wysocki, Hanjun Guo
  Cc: Catalin Marinas, Will Deacon, Olof Johansson, Grant Likely,
	Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi

On 2015/3/5 6:46, Rafael J. Wysocki wrote:
> On Wednesday, February 25, 2015 04:39:54 PM Hanjun Guo wrote:
>> Introduce a new function map_gicc_mpidr() to allow MPIDRs to be obtained
>> from the GICC Structure introduced by ACPI 5.1.
>>
>> The ARM architecture defines the MPIDR register as the CPU hardware
>> identifier. This patch adds the code infrastructure to retrieve the MPIDR
>> values from the ARM ACPI GICC structure in order to look-up the kernel CPU
>> hardware ids required by the ACPI core code to identify CPUs.
>>
>> CC: Rafael J. Wysocki <rjw@rjwysocki.net>
>> CC: Catalin Marinas <catalin.marinas@arm.com>
>> CC: Will Deacon <will.deacon@arm.com>
>> Tested-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
>> Tested-by: Yijing Wang <wangyijing@huawei.com>
>> Tested-by: Mark Langsdorf <mlangsdo@redhat.com>
>> Tested-by: Jon Masters <jcm@redhat.com>
>> Tested-by: Timur Tabi <timur@codeaurora.org>
>> Tested-by: Robert Richter <rrichter@cavium.com>
>> Acked-by: Robert Richter <rrichter@cavium.com>
>> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
>> ---
>>  arch/arm64/include/asm/acpi.h | 12 ++++++++++++
>>  drivers/acpi/processor_core.c | 30 ++++++++++++++++++++++++++++++
>>  2 files changed, 42 insertions(+)
>>
>> diff --git a/arch/arm64/include/asm/acpi.h b/arch/arm64/include/asm/acpi.h
>> index 9719921..9a23369 100644
>> --- a/arch/arm64/include/asm/acpi.h
>> +++ b/arch/arm64/include/asm/acpi.h
>> @@ -13,6 +13,8 @@
>>  #define _ASM_ACPI_H
>>  
>>  #include <linux/mm.h>
>> +#include <asm/cputype.h>
>> +#include <asm/smp_plat.h>
>>  
>>  /* Basic configuration for ACPI */
>>  #ifdef	CONFIG_ACPI
>> @@ -27,6 +29,9 @@ static inline void __iomem *acpi_os_ioremap(acpi_physical_address phys,
>>  }
>>  #define acpi_os_ioremap acpi_os_ioremap
>>  
>> +typedef u64 phys_cpuid_t;
>> +#define CPU_PHYS_ID_INVALID INVALID_HWID
>> +
> Any chance to combine this with patch [2/21]?  Or at least put them next to each
> other in the series so as to indicate that they are related or *mention* patch
> [2/21] in the changelog here?

Both are ok to me. I separated those two patches for the assumption that you will merge
the first two patches in your tree, I will put them next to each other.

>
> IMO, you really need to define phys_cpuid_t in a common place or people will
> forget that it may be 64-bit, because they'll only be looking at their arch.

Since x86 and ARM64 are using different types for phys_cpuid_t, we need to
introduce something like following if define it in common place:

in linux/acpi.h,

#if defined(CONFIG_X86) || defined(CONFIG_IA64)
typedef u32 phys_cpuid_t;
#define PHYS_CPUID_INVALID (phys_cpuid_t)(-1)
#else if defined(CONFIG_ARM64)
typedef u64 phys_cpuid_t;
#define PHYS_CPUID_INVALID INVALID_HWID
#endif

I think it's awful, did I miss something?

Thanks
Hanjun


^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 16/21] irqchip: Add GICv2 specific ACPI boot support
  2015-02-25  8:39 ` [PATCH v9 16/21] irqchip: Add GICv2 specific ACPI boot support Hanjun Guo
  2015-03-04 22:50   ` Rafael J. Wysocki
@ 2015-03-05  8:21   ` Hanjun Guo
  2015-03-07 23:14   ` Grant Likely
  2 siblings, 0 replies; 106+ messages in thread
From: Hanjun Guo @ 2015-03-05  8:21 UTC (permalink / raw)
  To: Thomas Gleixner, Will Deacon
  Cc: Catalin Marinas, Rafael J. Wysocki, Olof Johansson, Grant Likely,
	Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi, Tomasz Nowicki, Jason Cooper,
	Hanjun Guo

On 2015/2/25 16:39, Hanjun Guo wrote:
> From: Tomasz Nowicki <tomasz.nowicki@linaro.org>
>
> ACPI kernel uses MADT table for proper GIC initialization. It needs to
> parse GIC related subtables, collect CPU interface and distributor
> addresses and call driver initialization function (which is hardware
> abstraction agnostic). In a similar way, FDT initialize GICv1/2.
>
> NOTE: This commit allow to initialize GICv1/2 basic functionality.
> While now simple GICv2 init call is used, any further GIC features
> require generic infrastructure for proper ACPI irqchip initialization.
> That mechanism and stacked irqdomains to support GICv2 MSI/virtualization
> extension, GICv3/4 and its ITS are considered as next steps.
>
> CC: Jason Cooper <jason@lakedaemon.net>
> CC: Marc Zyngier <marc.zyngier@arm.com>
> CC: Thomas Gleixner <tglx@linutronix.de>

Hi Thomas,

Any comments for this patch and the following one "[PATCH v9 17/21]
clocksource / arch_timer: Parse GTDT to initialize arch timer" ?

If it is ok for you, could you please ACK those two patches, Catalin
needs your ACK before it's merged via ARM64 tree.

Thanks
Hanjun

> Tested-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
> Tested-by: Yijing Wang <wangyijing@huawei.com>
> Tested-by: Mark Langsdorf <mlangsdo@redhat.com>
> Tested-by: Jon Masters <jcm@redhat.com>
> Tested-by: Timur Tabi <timur@codeaurora.org>
> Tested-by: Robert Richter <rrichter@cavium.com>
> Acked-by: Robert Richter <rrichter@cavium.com>
> Signed-off-by: Tomasz Nowicki <tomasz.nowicki@linaro.org>
> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
> ---
>  arch/arm64/include/asm/acpi.h        |   2 +
>  arch/arm64/kernel/acpi.c             |  25 +++++++++
>  drivers/irqchip/irq-gic.c            | 102 +++++++++++++++++++++++++++++++++++
>  drivers/irqchip/irqchip.c            |   3 ++
>  include/linux/acpi.h                 |  14 +++++
>  include/linux/irqchip/arm-gic-acpi.h |  29 ++++++++++
>  6 files changed, 175 insertions(+)
>  create mode 100644 include/linux/irqchip/arm-gic-acpi.h
>
> diff --git a/arch/arm64/include/asm/acpi.h b/arch/arm64/include/asm/acpi.h
> index 9a23369..a720a61 100644
> --- a/arch/arm64/include/asm/acpi.h
> +++ b/arch/arm64/include/asm/acpi.h
> @@ -13,6 +13,8 @@
>  #define _ASM_ACPI_H
>  
>  #include <linux/mm.h>
> +#include <linux/irqchip/arm-gic-acpi.h>
> +
>  #include <asm/cputype.h>
>  #include <asm/smp_plat.h>
>  
> diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c
> index 31f080e..af308c3 100644
> --- a/arch/arm64/kernel/acpi.c
> +++ b/arch/arm64/kernel/acpi.c
> @@ -359,3 +359,28 @@ void __init acpi_boot_table_init(void)
>  		pr_err("Can't find FADT\n");
>  	}
>  }
> +
> +void __init acpi_gic_init(void)
> +{
> +	struct acpi_table_header *table;
> +	acpi_status status;
> +	acpi_size tbl_size;
> +	int err;
> +
> +	if (acpi_disabled)
> +		return;
> +
> +	status = acpi_get_table_with_size(ACPI_SIG_MADT, 0, &table, &tbl_size);
> +	if (ACPI_FAILURE(status)) {
> +		const char *msg = acpi_format_exception(status);
> +
> +		pr_err("Failed to get MADT table, %s\n", msg);
> +		return;
> +	}
> +
> +	err = gic_v2_acpi_init(table);
> +	if (err)
> +		pr_err("Failed to initialize GIC IRQ controller");
> +
> +	early_acpi_os_unmap_memory((char *)table, tbl_size);
> +}
> diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
> index 4634cf7..929d668 100644
> --- a/drivers/irqchip/irq-gic.c
> +++ b/drivers/irqchip/irq-gic.c
> @@ -33,12 +33,14 @@
>  #include <linux/of.h>
>  #include <linux/of_address.h>
>  #include <linux/of_irq.h>
> +#include <linux/acpi.h>
>  #include <linux/irqdomain.h>
>  #include <linux/interrupt.h>
>  #include <linux/percpu.h>
>  #include <linux/slab.h>
>  #include <linux/irqchip/chained_irq.h>
>  #include <linux/irqchip/arm-gic.h>
> +#include <linux/irqchip/arm-gic-acpi.h>
>  
>  #include <asm/cputype.h>
>  #include <asm/irq.h>
> @@ -1086,3 +1088,103 @@ IRQCHIP_DECLARE(msm_8660_qgic, "qcom,msm-8660-qgic", gic_of_init);
>  IRQCHIP_DECLARE(msm_qgic2, "qcom,msm-qgic2", gic_of_init);
>  
>  #endif
> +
> +#ifdef CONFIG_ACPI
> +static phys_addr_t dist_phy_base, cpu_phy_base __initdata;
> +
> +static int __init
> +gic_acpi_parse_madt_cpu(struct acpi_subtable_header *header,
> +			const unsigned long end)
> +{
> +	struct acpi_madt_generic_interrupt *processor;
> +	phys_addr_t gic_cpu_base;
> +	static int cpu_base_assigned;
> +
> +	processor = (struct acpi_madt_generic_interrupt *)header;
> +
> +	if (BAD_MADT_ENTRY(processor, end))
> +		return -EINVAL;
> +
> +	/*
> +	 * There is no support for non-banked GICv1/2 register in ACPI spec.
> +	 * All CPU interface addresses have to be the same.
> +	 */
> +	gic_cpu_base = processor->base_address;
> +	if (cpu_base_assigned && gic_cpu_base != cpu_phy_base)
> +		return -EINVAL;
> +
> +	cpu_phy_base = gic_cpu_base;
> +	cpu_base_assigned = 1;
> +	return 0;
> +}
> +
> +static int __init
> +gic_acpi_parse_madt_distributor(struct acpi_subtable_header *header,
> +				const unsigned long end)
> +{
> +	struct acpi_madt_generic_distributor *dist;
> +
> +	dist = (struct acpi_madt_generic_distributor *)header;
> +
> +	if (BAD_MADT_ENTRY(dist, end))
> +		return -EINVAL;
> +
> +	dist_phy_base = dist->base_address;
> +	return 0;
> +}
> +
> +int __init
> +gic_v2_acpi_init(struct acpi_table_header *table)
> +{
> +	void __iomem *cpu_base, *dist_base;
> +	int count;
> +
> +	/* Collect CPU base addresses */
> +	count = acpi_parse_entries(ACPI_SIG_MADT,
> +				   sizeof(struct acpi_table_madt),
> +				   gic_acpi_parse_madt_cpu, table,
> +				   ACPI_MADT_TYPE_GENERIC_INTERRUPT, 0);
> +	if (count <= 0) {
> +		pr_err("No valid GICC entries exist\n");
> +		return -EINVAL;
> +	}
> +
> +	/*
> +	 * Find distributor base address. We expect one distributor entry since
> +	 * ACPI 5.1 spec neither support multi-GIC instances nor GIC cascade.
> +	 */
> +	count = acpi_parse_entries(ACPI_SIG_MADT,
> +				   sizeof(struct acpi_table_madt),
> +				   gic_acpi_parse_madt_distributor, table,
> +				   ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR, 0);
> +	if (count <= 0) {
> +		pr_err("No valid GICD entries exist\n");
> +		return -EINVAL;
> +	} else if (count > 1) {
> +		pr_err("More than one GICD entry detected\n");
> +		return -EINVAL;
> +	}
> +
> +	cpu_base = ioremap(cpu_phy_base, ACPI_GIC_CPU_IF_MEM_SIZE);
> +	if (!cpu_base) {
> +		pr_err("Unable to map GICC registers\n");
> +		return -ENOMEM;
> +	}
> +
> +	dist_base = ioremap(dist_phy_base, ACPI_GICV2_DIST_MEM_SIZE);
> +	if (!dist_base) {
> +		pr_err("Unable to map GICD registers\n");
> +		iounmap(cpu_base);
> +		return -ENOMEM;
> +	}
> +
> +	/*
> +	 * Initialize zero GIC instance (no multi-GIC support). Also, set GIC
> +	 * as default IRQ domain to allow for GSI registration and GSI to IRQ
> +	 * number translation (see acpi_register_gsi() and acpi_gsi_to_irq()).
> +	 */
> +	gic_init_bases(0, -1, dist_base, cpu_base, 0, NULL);
> +	irq_set_default_host(gic_data[0].domain);
> +	return 0;
> +}
> +#endif
> diff --git a/drivers/irqchip/irqchip.c b/drivers/irqchip/irqchip.c
> index 0fe2f71..5855240 100644
> --- a/drivers/irqchip/irqchip.c
> +++ b/drivers/irqchip/irqchip.c
> @@ -8,6 +8,7 @@
>   * warranty of any kind, whether express or implied.
>   */
>  
> +#include <linux/acpi.h>
>  #include <linux/init.h>
>  #include <linux/of_irq.h>
>  #include <linux/irqchip.h>
> @@ -26,4 +27,6 @@ extern struct of_device_id __irqchip_of_table[];
>  void __init irqchip_init(void)
>  {
>  	of_irq_init(__irqchip_of_table);
> +
> +	acpi_irq_init();
>  }
> diff --git a/include/linux/acpi.h b/include/linux/acpi.h
> index c03d8d1..e27117a 100644
> --- a/include/linux/acpi.h
> +++ b/include/linux/acpi.h
> @@ -557,6 +557,20 @@ static inline int acpi_device_modalias(struct device *dev,
>  
>  #endif	/* !CONFIG_ACPI */
>  
> +#if defined(CONFIG_ACPI) && defined(CONFIG_ARM64)
> +static inline void acpi_irq_init(void)
> +{
> +	/*
> +	 * Hardcode ACPI IRQ chip initialization to GICv2 for now.
> +	 * Proper irqchip infrastructure will be implemented along with
> +	 * incoming  GICv2m|GICv3|ITS bits.
> +	 */
> +	acpi_gic_init();
> +}
> +#else
> +static inline void acpi_irq_init(void) { }
> +#endif
> +
>  #ifdef CONFIG_ACPI
>  void acpi_os_set_prepare_sleep(int (*func)(u8 sleep_state,
>  			       u32 pm1a_ctrl,  u32 pm1b_ctrl));
> diff --git a/include/linux/irqchip/arm-gic-acpi.h b/include/linux/irqchip/arm-gic-acpi.h
> new file mode 100644
> index 0000000..d5b2c79
> --- /dev/null
> +++ b/include/linux/irqchip/arm-gic-acpi.h
> @@ -0,0 +1,29 @@
> +/*
> + * Copyright (C) 2014, Linaro Ltd.
> + *	Author: Tomasz Nowicki <tomasz.nowicki@linaro.org>
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + */
> +
> +#ifndef ARM_GIC_ACPI_H_
> +#define ARM_GIC_ACPI_H_
> +
> +#ifdef CONFIG_ACPI
> +
> +/*
> + * Hard code here, we can not get memory size from MADT (but FDT does),
> + * Actually no need to do that, because this size can be inferred
> + * from GIC spec.
> + */
> +#define ACPI_GICV2_DIST_MEM_SIZE	(SZ_4K)
> +#define ACPI_GIC_CPU_IF_MEM_SIZE	(SZ_8K)
> +
> +struct acpi_table_header;
> +
> +int gic_v2_acpi_init(struct acpi_table_header *table);
> +void acpi_gic_init(void);
> +#endif
> +
> +#endif /* ARM_GIC_ACPI_H_ */



^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 16/21] irqchip: Add GICv2 specific ACPI boot support
  2015-03-04 22:50   ` Rafael J. Wysocki
@ 2015-03-05  9:06     ` Hanjun Guo
  2015-03-05 11:53     ` Catalin Marinas
  1 sibling, 0 replies; 106+ messages in thread
From: Hanjun Guo @ 2015-03-05  9:06 UTC (permalink / raw)
  To: Rafael J. Wysocki, Hanjun Guo
  Cc: Catalin Marinas, Will Deacon, Olof Johansson, Grant Likely,
	Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi, Tomasz Nowicki, Jason Cooper,
	Thomas Gleixner

On 2015/3/5 6:50, Rafael J. Wysocki wrote:
> On Wednesday, February 25, 2015 04:39:56 PM Hanjun Guo wrote:
>> From: Tomasz Nowicki <tomasz.nowicki@linaro.org>
>>
>> ACPI kernel uses MADT table for proper GIC initialization. It needs to
>> parse GIC related subtables, collect CPU interface and distributor
>> addresses and call driver initialization function (which is hardware
>> abstraction agnostic). In a similar way, FDT initialize GICv1/2.
>>
>> NOTE: This commit allow to initialize GICv1/2 basic functionality.
>> While now simple GICv2 init call is used, any further GIC features
>> require generic infrastructure for proper ACPI irqchip initialization.
>> That mechanism and stacked irqdomains to support GICv2 MSI/virtualization
>> extension, GICv3/4 and its ITS are considered as next steps.
[...]
>> diff --git a/drivers/irqchip/irqchip.c b/drivers/irqchip/irqchip.c
>> index 0fe2f71..5855240 100644
>> --- a/drivers/irqchip/irqchip.c
>> +++ b/drivers/irqchip/irqchip.c
>> @@ -8,6 +8,7 @@
>>   * warranty of any kind, whether express or implied.
>>   */
>>  
>> +#include <linux/acpi.h>
>>  #include <linux/init.h>
>>  #include <linux/of_irq.h>
>>  #include <linux/irqchip.h>
>> @@ -26,4 +27,6 @@ extern struct of_device_id __irqchip_of_table[];
>>  void __init irqchip_init(void)
>>  {
>>  	of_irq_init(__irqchip_of_table);
>> +
>> +	acpi_irq_init();
>>  }
>> diff --git a/include/linux/acpi.h b/include/linux/acpi.h
>> index c03d8d1..e27117a 100644
>> --- a/include/linux/acpi.h
>> +++ b/include/linux/acpi.h
>> @@ -557,6 +557,20 @@ static inline int acpi_device_modalias(struct device *dev,
>>  
>>  #endif	/* !CONFIG_ACPI */
>>  
>> +#if defined(CONFIG_ACPI) && defined(CONFIG_ARM64)
>> +static inline void acpi_irq_init(void)
>> +{
>> +	/*
>> +	 * Hardcode ACPI IRQ chip initialization to GICv2 for now.
>> +	 * Proper irqchip infrastructure will be implemented along with
>> +	 * incoming  GICv2m|GICv3|ITS bits.
>> +	 */
>> +	acpi_gic_init();
>> +}
>> +#else
>> +static inline void acpi_irq_init(void) { }
>> +#endif
> I don't want this in a common header.

This is because of irqchip_init(void) in drivers/irqchip/irqchip.c
will be called by PowerPC too, so we need to put it in a common
head file, I will discuss with Tomasz to see if we have any further
solution.

Thanks
Hanjun


^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 14/21] ACPI / processor: Make it possible to get CPU hardware ID via GICC
  2015-03-05  8:03     ` Hanjun Guo
@ 2015-03-05 11:27       ` Catalin Marinas
  2015-03-05 13:13         ` Rafael J. Wysocki
  0 siblings, 1 reply; 106+ messages in thread
From: Catalin Marinas @ 2015-03-05 11:27 UTC (permalink / raw)
  To: Hanjun Guo
  Cc: Rafael J. Wysocki, Hanjun Guo, Mark Rutland, Ashwin Chaugule,
	Lorenzo Pieralisi, Robert Richter, Graeme Gregory, Arnd Bergmann,
	linux-acpi, Marc Zyngier, Timur Tabi, linaro-acpi, Will Deacon,
	linux-kernel, Grant Likely, Mark Brown, linux-arm-kernel,
	suravee.suthikulpanit, Sudeep Holla, Olof Johansson, Jon Masters

On Thu, Mar 05, 2015 at 04:03:21PM +0800, Hanjun Guo wrote:
> On 2015/3/5 6:46, Rafael J. Wysocki wrote:
> > IMO, you really need to define phys_cpuid_t in a common place or people will
> > forget that it may be 64-bit, because they'll only be looking at their arch.
> 
> Since x86 and ARM64 are using different types for phys_cpuid_t, we need to
> introduce something like following if define it in common place:
> 
> in linux/acpi.h,
> 
> #if defined(CONFIG_X86) || defined(CONFIG_IA64)
> typedef u32 phys_cpuid_t;
> #define PHYS_CPUID_INVALID (phys_cpuid_t)(-1)
> #else if defined(CONFIG_ARM64)
> typedef u64 phys_cpuid_t;
> #define PHYS_CPUID_INVALID INVALID_HWID
> #endif
> 
> I think it's awful, did I miss something?

I also think that's awful. I'm rather in favour of a per-arch
phys_cpuid_t.

-- 
Catalin

^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 16/21] irqchip: Add GICv2 specific ACPI boot support
  2015-03-04 22:50   ` Rafael J. Wysocki
  2015-03-05  9:06     ` Hanjun Guo
@ 2015-03-05 11:53     ` Catalin Marinas
  2015-03-06  0:42       ` Rafael J. Wysocki
  1 sibling, 1 reply; 106+ messages in thread
From: Catalin Marinas @ 2015-03-05 11:53 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Hanjun Guo, Mark Rutland, linaro-acpi, Will Deacon,
	Lorenzo Pieralisi, Timur Tabi, linux-acpi, Grant Likely,
	Robert Richter, Jason Cooper, Arnd Bergmann, Marc Zyngier,
	Jon Masters, Tomasz Nowicki, Mark Brown, Thomas Gleixner,
	linux-arm-kernel, Graeme Gregory, Ashwin Chaugule, linux-kernel,
	suravee.suthikulpanit, Sudeep Holla, Olof Johansson

On Wed, Mar 04, 2015 at 11:50:36PM +0100, Rafael J. Wysocki wrote:
> On Wednesday, February 25, 2015 04:39:56 PM Hanjun Guo wrote:
> > From: Tomasz Nowicki <tomasz.nowicki@linaro.org>
> > 
> > ACPI kernel uses MADT table for proper GIC initialization. It needs to
> > parse GIC related subtables, collect CPU interface and distributor
> > addresses and call driver initialization function (which is hardware
> > abstraction agnostic). In a similar way, FDT initialize GICv1/2.
> > 
> > NOTE: This commit allow to initialize GICv1/2 basic functionality.
> > While now simple GICv2 init call is used, any further GIC features
> > require generic infrastructure for proper ACPI irqchip initialization.
> > That mechanism and stacked irqdomains to support GICv2 MSI/virtualization
> > extension, GICv3/4 and its ITS are considered as next steps.
> > 
> > CC: Jason Cooper <jason@lakedaemon.net>
> > CC: Marc Zyngier <marc.zyngier@arm.com>
> > CC: Thomas Gleixner <tglx@linutronix.de>
> > Tested-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
> > Tested-by: Yijing Wang <wangyijing@huawei.com>
> > Tested-by: Mark Langsdorf <mlangsdo@redhat.com>
> > Tested-by: Jon Masters <jcm@redhat.com>
> > Tested-by: Timur Tabi <timur@codeaurora.org>
> > Tested-by: Robert Richter <rrichter@cavium.com>
> > Acked-by: Robert Richter <rrichter@cavium.com>
> > Signed-off-by: Tomasz Nowicki <tomasz.nowicki@linaro.org>
> > Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
> > ---
> >  arch/arm64/include/asm/acpi.h        |   2 +
> >  arch/arm64/kernel/acpi.c             |  25 +++++++++
> >  drivers/irqchip/irq-gic.c            | 102 +++++++++++++++++++++++++++++++++++
> >  drivers/irqchip/irqchip.c            |   3 ++
> >  include/linux/acpi.h                 |  14 +++++
> >  include/linux/irqchip/arm-gic-acpi.h |  29 ++++++++++
> >  6 files changed, 175 insertions(+)
> >  create mode 100644 include/linux/irqchip/arm-gic-acpi.h
> > 
> > diff --git a/arch/arm64/include/asm/acpi.h b/arch/arm64/include/asm/acpi.h
> > index 9a23369..a720a61 100644
> > --- a/arch/arm64/include/asm/acpi.h
> > +++ b/arch/arm64/include/asm/acpi.h
> > @@ -13,6 +13,8 @@
> >  #define _ASM_ACPI_H
> >  
> >  #include <linux/mm.h>
> > +#include <linux/irqchip/arm-gic-acpi.h>
> > +
> >  #include <asm/cputype.h>
> >  #include <asm/smp_plat.h>
> >  
> > diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c
> > index 31f080e..af308c3 100644
> > --- a/arch/arm64/kernel/acpi.c
> > +++ b/arch/arm64/kernel/acpi.c
> > @@ -359,3 +359,28 @@ void __init acpi_boot_table_init(void)
> >  		pr_err("Can't find FADT\n");
> >  	}
> >  }
> > +
> > +void __init acpi_gic_init(void)
> > +{
> > +	struct acpi_table_header *table;
> > +	acpi_status status;
> > +	acpi_size tbl_size;
> > +	int err;
> > +
> > +	if (acpi_disabled)
> > +		return;
> > +
> > +	status = acpi_get_table_with_size(ACPI_SIG_MADT, 0, &table, &tbl_size);
> > +	if (ACPI_FAILURE(status)) {
> > +		const char *msg = acpi_format_exception(status);
> > +
> > +		pr_err("Failed to get MADT table, %s\n", msg);
> > +		return;
> > +	}
> > +
> > +	err = gic_v2_acpi_init(table);
> > +	if (err)
> > +		pr_err("Failed to initialize GIC IRQ controller");
> > +
> > +	early_acpi_os_unmap_memory((char *)table, tbl_size);
> > +}
> > diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
> > index 4634cf7..929d668 100644
> > --- a/drivers/irqchip/irq-gic.c
> > +++ b/drivers/irqchip/irq-gic.c
> > @@ -33,12 +33,14 @@
> >  #include <linux/of.h>
> >  #include <linux/of_address.h>
> >  #include <linux/of_irq.h>
> > +#include <linux/acpi.h>
> >  #include <linux/irqdomain.h>
> >  #include <linux/interrupt.h>
> >  #include <linux/percpu.h>
> >  #include <linux/slab.h>
> >  #include <linux/irqchip/chained_irq.h>
> >  #include <linux/irqchip/arm-gic.h>
> > +#include <linux/irqchip/arm-gic-acpi.h>
> >  
> >  #include <asm/cputype.h>
> >  #include <asm/irq.h>
> > @@ -1086,3 +1088,103 @@ IRQCHIP_DECLARE(msm_8660_qgic, "qcom,msm-8660-qgic", gic_of_init);
> >  IRQCHIP_DECLARE(msm_qgic2, "qcom,msm-qgic2", gic_of_init);
> >  
> >  #endif
> > +
> > +#ifdef CONFIG_ACPI
> > +static phys_addr_t dist_phy_base, cpu_phy_base __initdata;
> > +
> > +static int __init
> > +gic_acpi_parse_madt_cpu(struct acpi_subtable_header *header,
> > +			const unsigned long end)
> > +{
> > +	struct acpi_madt_generic_interrupt *processor;
> > +	phys_addr_t gic_cpu_base;
> > +	static int cpu_base_assigned;
> > +
> > +	processor = (struct acpi_madt_generic_interrupt *)header;
> > +
> > +	if (BAD_MADT_ENTRY(processor, end))
> > +		return -EINVAL;
> > +
> > +	/*
> > +	 * There is no support for non-banked GICv1/2 register in ACPI spec.
> > +	 * All CPU interface addresses have to be the same.
> > +	 */
> > +	gic_cpu_base = processor->base_address;
> > +	if (cpu_base_assigned && gic_cpu_base != cpu_phy_base)
> > +		return -EINVAL;
> > +
> > +	cpu_phy_base = gic_cpu_base;
> > +	cpu_base_assigned = 1;
> > +	return 0;
> > +}
> > +
> > +static int __init
> > +gic_acpi_parse_madt_distributor(struct acpi_subtable_header *header,
> > +				const unsigned long end)
> > +{
> > +	struct acpi_madt_generic_distributor *dist;
> > +
> > +	dist = (struct acpi_madt_generic_distributor *)header;
> > +
> > +	if (BAD_MADT_ENTRY(dist, end))
> > +		return -EINVAL;
> > +
> > +	dist_phy_base = dist->base_address;
> > +	return 0;
> > +}
> > +
> > +int __init
> > +gic_v2_acpi_init(struct acpi_table_header *table)
> > +{
> > +	void __iomem *cpu_base, *dist_base;
> > +	int count;
> > +
> > +	/* Collect CPU base addresses */
> > +	count = acpi_parse_entries(ACPI_SIG_MADT,
> > +				   sizeof(struct acpi_table_madt),
> > +				   gic_acpi_parse_madt_cpu, table,
> > +				   ACPI_MADT_TYPE_GENERIC_INTERRUPT, 0);
> > +	if (count <= 0) {
> > +		pr_err("No valid GICC entries exist\n");
> > +		return -EINVAL;
> > +	}
> > +
> > +	/*
> > +	 * Find distributor base address. We expect one distributor entry since
> > +	 * ACPI 5.1 spec neither support multi-GIC instances nor GIC cascade.
> > +	 */
> > +	count = acpi_parse_entries(ACPI_SIG_MADT,
> > +				   sizeof(struct acpi_table_madt),
> > +				   gic_acpi_parse_madt_distributor, table,
> > +				   ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR, 0);
> > +	if (count <= 0) {
> > +		pr_err("No valid GICD entries exist\n");
> > +		return -EINVAL;
> > +	} else if (count > 1) {
> > +		pr_err("More than one GICD entry detected\n");
> > +		return -EINVAL;
> > +	}
> > +
> > +	cpu_base = ioremap(cpu_phy_base, ACPI_GIC_CPU_IF_MEM_SIZE);
> > +	if (!cpu_base) {
> > +		pr_err("Unable to map GICC registers\n");
> > +		return -ENOMEM;
> > +	}
> > +
> > +	dist_base = ioremap(dist_phy_base, ACPI_GICV2_DIST_MEM_SIZE);
> > +	if (!dist_base) {
> > +		pr_err("Unable to map GICD registers\n");
> > +		iounmap(cpu_base);
> > +		return -ENOMEM;
> > +	}
> > +
> > +	/*
> > +	 * Initialize zero GIC instance (no multi-GIC support). Also, set GIC
> > +	 * as default IRQ domain to allow for GSI registration and GSI to IRQ
> > +	 * number translation (see acpi_register_gsi() and acpi_gsi_to_irq()).
> > +	 */
> > +	gic_init_bases(0, -1, dist_base, cpu_base, 0, NULL);
> > +	irq_set_default_host(gic_data[0].domain);
> > +	return 0;
> > +}
> > +#endif
> > diff --git a/drivers/irqchip/irqchip.c b/drivers/irqchip/irqchip.c
> > index 0fe2f71..5855240 100644
> > --- a/drivers/irqchip/irqchip.c
> > +++ b/drivers/irqchip/irqchip.c
> > @@ -8,6 +8,7 @@
> >   * warranty of any kind, whether express or implied.
> >   */
> >  
> > +#include <linux/acpi.h>
> >  #include <linux/init.h>
> >  #include <linux/of_irq.h>
> >  #include <linux/irqchip.h>
> > @@ -26,4 +27,6 @@ extern struct of_device_id __irqchip_of_table[];
> >  void __init irqchip_init(void)
> >  {
> >  	of_irq_init(__irqchip_of_table);
> > +
> > +	acpi_irq_init();
> >  }
> > diff --git a/include/linux/acpi.h b/include/linux/acpi.h
> > index c03d8d1..e27117a 100644
> > --- a/include/linux/acpi.h
> > +++ b/include/linux/acpi.h
> > @@ -557,6 +557,20 @@ static inline int acpi_device_modalias(struct device *dev,
> >  
> >  #endif	/* !CONFIG_ACPI */
> >  
> > +#if defined(CONFIG_ACPI) && defined(CONFIG_ARM64)
> > +static inline void acpi_irq_init(void)
> > +{
> > +	/*
> > +	 * Hardcode ACPI IRQ chip initialization to GICv2 for now.
> > +	 * Proper irqchip infrastructure will be implemented along with
> > +	 * incoming  GICv2m|GICv3|ITS bits.
> > +	 */
> > +	acpi_gic_init();
> > +}
> > +#else
> > +static inline void acpi_irq_init(void) { }
> > +#endif
> 
> I don't want this in a common header.

I don't like it either. What about adding it to a new header,
linux/acpi_irq.h just for the dummy acpi_irq_init()? This would be
similar to the DT equivalent, of_irq_init() in linux/of_irq.h and at
some point it will gain more macros for declaring interrupt controllers
in the ACPI context.

What we objected to previously was calling acpi_gic_init() directly from
the core irqchip_init() and asked for something similar to the more
generic of_irq_init(). The arm64-specific patch above is clearly a
temporary hack until full support for multiple interrupt controllers is
added (we asked for this several times in the past, but the ARM ACPI
guys thought it's too much hassle ;). I don't fully get it since one of
the platforms they target needs GICv2m support anyway).

Anyway, if we are to keep the temporary hack, I think we could define
something like below (possibly in a new linux/acpi_irq.h which includes
asm/irq.h):

#ifndef acpi_irq_init
static inline void acpi_irq_init(void)
{
}
#endif

And in the arm64 asm/irq.h:

static inline void acpi_irq_init(void)
{
	/*
	 * Hardcode ACPI IRQ chip initialization to GICv2 for now.
	 * Proper irqchip infrastructure will be implemented along with
	 * incoming  GICv2m|GICv3|ITS bits.
	 */
	acpi_gic_init();
}
#define acpi_irq_init acpi_irq_init

When the new infrastructure is in place, we can get rid of the #ifndef
and arm64-specific acpi_irq_init().

-- 
Catalin

^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 14/21] ACPI / processor: Make it possible to get CPU hardware ID via GICC
  2015-03-05 11:27       ` Catalin Marinas
@ 2015-03-05 13:13         ` Rafael J. Wysocki
  2015-03-05 15:19           ` Catalin Marinas
  0 siblings, 1 reply; 106+ messages in thread
From: Rafael J. Wysocki @ 2015-03-05 13:13 UTC (permalink / raw)
  To: Catalin Marinas
  Cc: Hanjun Guo, Rafael J. Wysocki, Hanjun Guo, Mark Rutland,
	Ashwin Chaugule, Lorenzo Pieralisi, Robert Richter,
	Graeme Gregory, Arnd Bergmann, ACPI Devel Maling List,
	Marc Zyngier, Timur Tabi, linaro-acpi, Will Deacon,
	Linux Kernel Mailing List, Grant Likely, Mark Brown,
	linux-arm-kernel, suravee.suthikulpanit, Sudeep Holla,
	Olof Johansson, Jon Masters

On Thu, Mar 5, 2015 at 12:27 PM, Catalin Marinas
<catalin.marinas@arm.com> wrote:
> On Thu, Mar 05, 2015 at 04:03:21PM +0800, Hanjun Guo wrote:
>> On 2015/3/5 6:46, Rafael J. Wysocki wrote:
>> > IMO, you really need to define phys_cpuid_t in a common place or people will
>> > forget that it may be 64-bit, because they'll only be looking at their arch.
>>
>> Since x86 and ARM64 are using different types for phys_cpuid_t, we need to
>> introduce something like following if define it in common place:
>>
>> in linux/acpi.h,
>>
>> #if defined(CONFIG_X86) || defined(CONFIG_IA64)
>> typedef u32 phys_cpuid_t;
>> #define PHYS_CPUID_INVALID (phys_cpuid_t)(-1)
>> #else if defined(CONFIG_ARM64)
>> typedef u64 phys_cpuid_t;
>> #define PHYS_CPUID_INVALID INVALID_HWID
>> #endif
>>
>> I think it's awful, did I miss something?

Well, you can define the type and PHYS_CPUID_INVALID in the arch
code and then do this in a common header:

#ifndef PHYS_CPUID_INVALID
typedef u32 phys_cpuid_t;
#define PHYS_CPUID_INVALID (phys_cpuid_t)(-1)
#endif

That would allow you to avoid the need to duplicate the
definitions where it is not necessary.

> I also think that's awful. I'm rather in favour of a per-arch
> phys_cpuid_t.

OK, so what about the above?

Rafael

^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 02/21] ACPI / processor: Introduce phys_cpuid_t for CPU hardware ID
  2015-03-05  7:44     ` Hanjun Guo
@ 2015-03-05 13:23       ` Rafael J. Wysocki
  2015-03-06  6:48         ` Hanjun Guo
  0 siblings, 1 reply; 106+ messages in thread
From: Rafael J. Wysocki @ 2015-03-05 13:23 UTC (permalink / raw)
  To: Hanjun Guo
  Cc: Rafael J. Wysocki, Hanjun Guo, Catalin Marinas, Will Deacon,
	Olof Johansson, Grant Likely, Lorenzo Pieralisi, Arnd Bergmann,
	Mark Rutland, Graeme Gregory, Sudeep Holla, Jon Masters,
	Marc Zyngier, Mark Brown, Robert Richter, Timur Tabi,
	Ashwin Chaugule, suravee.suthikulpanit, ACPI Devel Maling List,
	linux-arm-kernel, Linux Kernel Mailing List, linaro-acpi

On Thu, Mar 5, 2015 at 8:44 AM, Hanjun Guo <guohanjun@huawei.com> wrote:
> On 2015/3/5 6:29, Rafael J. Wysocki wrote:
>> On Wednesday, February 25, 2015 04:39:42 PM Hanjun Guo wrote:

[cut]

>>> @@ -190,7 +190,7 @@ int acpi_map_cpuid(int phys_id, u32 acpi_id)
>>>              if (nr_cpu_ids <= 1 && acpi_id == 0)
>>>                      return acpi_id;
>>>              else
>>> -                    return phys_id;
>>> +                    return -1;
>> Can we use a proper error code here?
>
> I'm afraid not. In ACPI processor drivers, -1 will be deemed to
> invalid cpu logical number, if we return error code here, we need
> to modify multi places of "if (cpu_logical_num == -1)" to

Oh, silly stuff.

> "if (! (cpu_logical_num < 0))" too, so for me, I prefer to keep it as
> -1, but I'm open for suggestions.

OK

I think we need something like invalid_logical_cpuid() and use it
in all of those checks instead of the direct comparisons, but we
can make those changes later.

Rafael

^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 14/21] ACPI / processor: Make it possible to get CPU hardware ID via GICC
  2015-03-05 13:13         ` Rafael J. Wysocki
@ 2015-03-05 15:19           ` Catalin Marinas
  2015-03-06  6:51             ` Hanjun Guo
  0 siblings, 1 reply; 106+ messages in thread
From: Catalin Marinas @ 2015-03-05 15:19 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Mark Rutland, linaro-acpi, Will Deacon, Hanjun Guo,
	Lorenzo Pieralisi, Timur Tabi, ACPI Devel Maling List,
	Grant Likely, Robert Richter, Arnd Bergmann, Marc Zyngier,
	Jon Masters, Mark Brown, linux-arm-kernel, Ashwin Chaugule,
	Graeme Gregory, Rafael J. Wysocki, Linux Kernel Mailing List,
	Hanjun Guo, suravee.suthikulpanit, Sudeep Holla, Olof Johansson

On Thu, Mar 05, 2015 at 02:13:58PM +0100, Rafael J. Wysocki wrote:
> On Thu, Mar 5, 2015 at 12:27 PM, Catalin Marinas
> <catalin.marinas@arm.com> wrote:
> > On Thu, Mar 05, 2015 at 04:03:21PM +0800, Hanjun Guo wrote:
> >> On 2015/3/5 6:46, Rafael J. Wysocki wrote:
> >> > IMO, you really need to define phys_cpuid_t in a common place or people will
> >> > forget that it may be 64-bit, because they'll only be looking at their arch.
> >>
> >> Since x86 and ARM64 are using different types for phys_cpuid_t, we need to
> >> introduce something like following if define it in common place:
> >>
> >> in linux/acpi.h,
> >>
> >> #if defined(CONFIG_X86) || defined(CONFIG_IA64)
> >> typedef u32 phys_cpuid_t;
> >> #define PHYS_CPUID_INVALID (phys_cpuid_t)(-1)
> >> #else if defined(CONFIG_ARM64)
> >> typedef u64 phys_cpuid_t;
> >> #define PHYS_CPUID_INVALID INVALID_HWID
> >> #endif
> >>
> >> I think it's awful, did I miss something?
> 
> Well, you can define the type and PHYS_CPUID_INVALID in the arch
> code and then do this in a common header:
> 
> #ifndef PHYS_CPUID_INVALID
> typedef u32 phys_cpuid_t;
> #define PHYS_CPUID_INVALID (phys_cpuid_t)(-1)
> #endif
> 
> That would allow you to avoid the need to duplicate the
> definitions where it is not necessary.

It's fine by me.

-- 
Catalin

^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 01/21] ACPI / table: Use pr_debug() instead of pr_info() for MADT table scanning
  2015-02-25  8:39 ` [PATCH v9 01/21] ACPI / table: Use pr_debug() instead of pr_info() for MADT table scanning Hanjun Guo
  2015-03-04 22:33   ` Rafael J. Wysocki
@ 2015-03-05 17:55   ` Olof Johansson
  2015-03-06 20:17   ` Grant Likely
  2 siblings, 0 replies; 106+ messages in thread
From: Olof Johansson @ 2015-03-05 17:55 UTC (permalink / raw)
  To: Hanjun Guo
  Cc: Catalin Marinas, Rafael J. Wysocki, Will Deacon, Grant Likely,
	Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi

On Wed, Feb 25, 2015 at 04:39:41PM +0800, Hanjun Guo wrote:
> For a normal 8 cpu sockets system, it will up to 240 cpu threads (Xeon E7
> v2 family for now), and we need 240 entries for local apic or local x2apic
> in MADT table, so it will be much verbose information printed with a slow
> uart console when system booted, this will be even worse with large system
> with 16/32 cpu sockets.
> 
> This patch just use pr_debug() instead of pr_info() for ioapic/iosapic,
> local apic/x2apic/sapic structures when scanning the MADT table to remove
> those verbose information, but leave other structures unchanged.
> 
> CC: Rafael J Wysocki <rjw@rjwysocki.net>
> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>

Acked-by: Olof Johansson <olof@lixom.net>

(This can surely go in now and not be pending on the rest of the patch set)


-Olof

^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 05/21] ARM64 / ACPI: Get RSDP and ACPI boot-time tables
  2015-02-25  8:39 ` [PATCH v9 05/21] ARM64 / ACPI: Get RSDP and ACPI boot-time tables Hanjun Guo
@ 2015-03-05 18:10   ` Olof Johansson
  2015-03-05 18:51   ` Lorenzo Pieralisi
  2015-03-06 20:28   ` Grant Likely
  2 siblings, 0 replies; 106+ messages in thread
From: Olof Johansson @ 2015-03-05 18:10 UTC (permalink / raw)
  To: Hanjun Guo
  Cc: Catalin Marinas, Rafael J. Wysocki, Will Deacon, Grant Likely,
	Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi, Al Stone, Tomasz Nowicki

On Wed, Feb 25, 2015 at 04:39:45PM +0800, Hanjun Guo wrote:
> From: Al Stone <al.stone@linaro.org>
> 
> As we want to get ACPI tables to parse and then use the information
> for system initialization, we should get the RSDP (Root System
> Description Pointer) first, it then locates Extended Root Description
> Table (XSDT) which contains all the 64-bit physical address that
> pointer to other boot-time tables.
> 
> Introduce acpi.c and its related head file in this patch to provide
> fundamental needs of extern variables and functions for ACPI core,
> and then get boot-time tables as needed.
>   - asm/acenv.h for arch specific ACPICA environments and
>     implementation, It is needed unconditionally by ACPI core;
>   - asm/acpi.h for arch specific variables and functions needed by
>     ACPI driver core;
>   - acpi.c for ARM64 related ACPI implementation for ACPI driver
>     core;
> 
> acpi_boot_table_init() is introduced to get RSDP and boot-time tables,
> it will be called in setup_arch() before paging_init(), so we should
> use eary_memremap() mechanism here to get the RSDP and all the table
> pointers.
> 
> FADT Major.Minor version was introduced in ACPI 5.1, it is the same
> as ACPI version.
> 
> In ACPI 5.1, some major gaps are fixed for ARM, such as updates in
> MADT table for GIC and SMP init, without those updates, we can not
> get the MPIDR for SMP init, and GICv2/3 related init information, so
> we can't boot arm64 ACPI properly with table versions predating 5.1.
> 
> If firmware provides ACPI tables with ACPI version less than 5.1,
> OS has no way to retrieve the configuration data that is necessary
> to init SMP boot protocol and the GIC properly, so disable ACPI if
> we get an FADT table with version less that 5.1 when acpi_boot_table_init()
> called.
> 
> CC: Catalin Marinas <catalin.marinas@arm.com>
> CC: Will Deacon <will.deacon@arm.com>
> CC: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
> Tested-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
> Tested-by: Yijing Wang <wangyijing@huawei.com>
> Tested-by: Mark Langsdorf <mlangsdo@redhat.com>
> Tested-by: Jon Masters <jcm@redhat.com>
> Tested-by: Timur Tabi <timur@codeaurora.org>
> Tested-by: Robert Richter <rrichter@cavium.com>
> Acked-by: Robert Richter <rrichter@cavium.com>
> Signed-off-by: Al Stone <al.stone@linaro.org>
> Signed-off-by: Graeme Gregory <graeme.gregory@linaro.org>
> Signed-off-by: Tomasz Nowicki <tomasz.nowicki@linaro.org>
> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>

As long as it goes in together with later patches that adjust what's
enabled by default:

Acked-by: Olof Johansson <olof@lixom.net>


-Olof

^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 09/21] ARM64 / ACPI: Introduce early_param "acpi=" to enable/disable ACPI
  2015-02-25  8:39 ` [PATCH v9 09/21] ARM64 / ACPI: Introduce early_param "acpi=" to enable/disable ACPI Hanjun Guo
@ 2015-03-05 18:11   ` Olof Johansson
  2015-03-06 20:37   ` Grant Likely
  1 sibling, 0 replies; 106+ messages in thread
From: Olof Johansson @ 2015-03-05 18:11 UTC (permalink / raw)
  To: Hanjun Guo
  Cc: Catalin Marinas, Rafael J. Wysocki, Will Deacon, Grant Likely,
	Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi, Al Stone, Ard Biesheuvel

On Wed, Feb 25, 2015 at 04:39:49PM +0800, Hanjun Guo wrote:
> From: Al Stone <al.stone@linaro.org>
> 
> This implements the following policy to decide whether ACPI should
> be used to boot the system:
> - acpi=off: ACPI will not be used to boot the system, even if there is
>   no alternative available (e.g., device tree is empty)
> - acpi=force: only ACPI will be used to boot the system; if that fails,
>   there will be no fallback to alternative methods (such as device tree)
> - otherwise, ACPI will be used as a fallback if the device tree turns out
>   to lack a platform description; the heuristic to decide this is whether
>   /chosen is the only node present at depth 1
> 
> CC: Catalin Marinas <catalin.marinas@arm.com>
> CC: Will Deacon <will.deacon@arm.com>
> CC: Rafael J. Wysocki <rjw@rjwysocki.net>
> Signed-off-by: Al Stone <al.stone@linaro.org>
> Signed-off-by: Graeme Gregory <graeme.gregory@linaro.org>
> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

Acked-by: Olof Johansson <olof@lixom.net>



-Olof

^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 10/21] ARM64 / ACPI: If we chose to boot from acpi then disable FDT
  2015-02-25  8:39 ` [PATCH v9 10/21] ARM64 / ACPI: If we chose to boot from acpi then disable FDT Hanjun Guo
@ 2015-03-05 18:12   ` Olof Johansson
  2015-03-06 20:38   ` Grant Likely
  1 sibling, 0 replies; 106+ messages in thread
From: Olof Johansson @ 2015-03-05 18:12 UTC (permalink / raw)
  To: Hanjun Guo
  Cc: Catalin Marinas, Rafael J. Wysocki, Will Deacon, Grant Likely,
	Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi

On Wed, Feb 25, 2015 at 04:39:50PM +0800, Hanjun Guo wrote:
> From: Graeme Gregory <graeme.gregory@linaro.org>
> 
> If the early boot methods of acpi are happy that we have valid ACPI
> tables and acpi=force has been passed, then do not unflat devicetree
> effectively disabling further hardware probing from DT.
> 
> CC: Catalin Marinas <catalin.marinas@arm.com>
> CC: Will Deacon <will.deacon@arm.com>
> Tested-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
> Tested-by: Yijing Wang <wangyijing@huawei.com>
> Tested-by: Mark Langsdorf <mlangsdo@redhat.com>
> Tested-by: Jon Masters <jcm@redhat.com>
> Tested-by: Timur Tabi <timur@codeaurora.org>
> Tested-by: Robert Richter <rrichter@cavium.com>
> Acked-by: Robert Richter <rrichter@cavium.com>
> Signed-off-by: Graeme Gregory <graeme.gregory@linaro.org>
> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>

Acked-by: Olof Johansson <olof@lixom.net>

^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 11/21] ARM64 / ACPI: Get PSCI flags in FADT for PSCI init
  2015-02-25  8:39 ` [PATCH v9 11/21] ARM64 / ACPI: Get PSCI flags in FADT for PSCI init Hanjun Guo
@ 2015-03-05 18:19   ` Olof Johansson
  2015-03-06 20:40   ` Grant Likely
  1 sibling, 0 replies; 106+ messages in thread
From: Olof Johansson @ 2015-03-05 18:19 UTC (permalink / raw)
  To: Hanjun Guo
  Cc: Catalin Marinas, Rafael J. Wysocki, Will Deacon, Grant Likely,
	Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi, Tomasz Nowicki

Hi,

On Wed, Feb 25, 2015 at 04:39:51PM +0800, Hanjun Guo wrote:
> From: Graeme Gregory <graeme.gregory@linaro.org>
> 
> There are two flags: PSCI_COMPLIANT and PSCI_USE_HVC. When set,
> the former signals to the OS that the firmware is PSCI compliant.
> The latter selects the appropriate conduit for PSCI calls by
> toggling between Hypervisor Calls (HVC) and Secure Monitor Calls
> (SMC).
> 
> FADT table contains such information in ACPI 5.1, FADT table was
> parsed in ACPI table init and copy to struct acpi_gbl_FADT, so
> use the flags in struct acpi_gbl_FADT for PSCI init.
> 
> Since ACPI 5.1 doesn't support self defined PSCI function IDs,
> which means that only PSCI 0.2+ is supported in ACPI.
> 
> CC: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
> CC: Catalin Marinas <catalin.marinas@arm.com>
> CC: Will Deacon <will.deacon@arm.com>
> Tested-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
> Tested-by: Yijing Wang <wangyijing@huawei.com>
> Tested-by: Mark Langsdorf <mlangsdo@redhat.com>
> Tested-by: Jon Masters <jcm@redhat.com>
> Tested-by: Timur Tabi <timur@codeaurora.org>
> Tested-by: Robert Richter <rrichter@cavium.com>
> Acked-by: Robert Richter <rrichter@cavium.com>
> Signed-off-by: Graeme Gregory <graeme.gregory@linaro.org>
> Signed-off-by: Tomasz Nowicki <tomasz.nowicki@linaro.org>
> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>

Acked-by: Olof Johansson <olof@lixom.net>


However, a comment on the color of the bike shed below. I'm fine with this
being addressed with an incremental patch instead of respun:

> diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
> index e8c7000..97fa7f3 100644
> --- a/arch/arm64/kernel/setup.c
> +++ b/arch/arm64/kernel/setup.c
> @@ -390,10 +390,12 @@ void __init setup_arch(char **cmdline_p)
>  
>  	early_ioremap_reset();
>  
> -	if (acpi_disabled)
> +	if (acpi_disabled) {
>  		unflatten_device_tree();
> -
> -	psci_init();
> +		psci_dt_init();
> +	} else {
> +		psci_acpi_init();
> +	}

I would prefer having a common psci_init() in psci.c, which in turn calls
either the dt or the acpi version, and after that calls the set_functions
if the init function passed -- it'll keep more code common as new versions
of PSCI is added.

It also keeps setup_arch() somewhat cleaner, and avoids bubbling up the
dt-vs-acpi differences to the top level.


-Olof

^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 13/21] ARM64 / ACPI: Parse MADT for SMP initialization
  2015-02-25  8:39 ` [PATCH v9 13/21] ARM64 / ACPI: Parse MADT for SMP initialization Hanjun Guo
@ 2015-03-05 18:49   ` Olof Johansson
  2015-03-10 11:33     ` Hanjun Guo
  2015-03-07 22:49   ` Grant Likely
  1 sibling, 1 reply; 106+ messages in thread
From: Olof Johansson @ 2015-03-05 18:49 UTC (permalink / raw)
  To: Hanjun Guo
  Cc: Catalin Marinas, Rafael J. Wysocki, Will Deacon, Grant Likely,
	Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi, Tomasz Nowicki

Hi,

On Wed, Feb 25, 2015 at 04:39:53PM +0800, Hanjun Guo wrote:
> MADT contains the information for MPIDR which is essential for
> SMP initialization, parse the GIC cpu interface structures to
> get the MPIDR value and map it to cpu_logical_map(), and add
> enabled cpu with valid MPIDR into cpu_possible_map.
> 
> ACPI 5.1 only has two explicit methods to boot up SMP, PSCI and
> Parking protocol, but the Parking protocol is only specified for
> ARMv7 now, so make PSCI as the only way for the SMP boot protocol
> before some updates for the ACPI spec or the Parking protocol spec.
> 
> Parking protocol patches for SMP boot will be sent to upstream when
> the new version of Parking protocol is ready.
> 
> CC: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
> CC: Catalin Marinas <catalin.marinas@arm.com>
> CC: Will Deacon <will.deacon@arm.com>
> CC: Mark Rutland <mark.rutland@arm.com>
> Tested-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
> Tested-by: Yijing Wang <wangyijing@huawei.com>
> Tested-by: Mark Langsdorf <mlangsdo@redhat.com>
> Tested-by: Jon Masters <jcm@redhat.com>
> Tested-by: Timur Tabi <timur@codeaurora.org>
> Tested-by: Robert Richter <rrichter@cavium.com>
> Acked-by: Robert Richter <rrichter@cavium.com>
> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
> Signed-off-by: Tomasz Nowicki <tomasz.nowicki@linaro.org>

Some nits below. Up to you if you fix incrementally or respin, but I'd like to
see them fixed for consistency's sake.

Acked-by: Olof Johansson <olof@lixom.net>

> diff --git a/arch/arm64/include/asm/smp.h b/arch/arm64/include/asm/smp.h
> index 780f82c..bf22650 100644
> --- a/arch/arm64/include/asm/smp.h
> +++ b/arch/arm64/include/asm/smp.h
> @@ -39,9 +39,10 @@ extern void show_ipi_list(struct seq_file *p, int prec);
>  extern void handle_IPI(int ipinr, struct pt_regs *regs);
>  
>  /*
> - * Setup the set of possible CPUs (via set_cpu_possible)
> + * Discover the set of possible CPUs and determine their
> + * SMP operations.
>   */
> -extern void smp_init_cpus(void);
> +extern void of_smp_init_cpus(void);

This is inconsistent naming, we use dt some places, of elsewhere.

> diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c
> index bdcc9fc..0f35d87 100644
> --- a/arch/arm64/kernel/acpi.c
> +++ b/arch/arm64/kernel/acpi.c
> @@ -25,6 +25,10 @@
>  #include <linux/of_fdt.h>
>  #include <linux/smp.h>
>  
> +#include <asm/cputype.h>
> +#include <asm/cpu_ops.h>
> +#include <asm/smp_plat.h>
> +
>  int acpi_noirq = 1;		/* skip ACPI IRQ initialization */
>  int acpi_disabled = 1;
>  EXPORT_SYMBOL(acpi_disabled);
> @@ -32,6 +36,12 @@ EXPORT_SYMBOL(acpi_disabled);
>  int acpi_pci_disabled = 1;	/* skip ACPI PCI scan and IRQ initialization */
>  EXPORT_SYMBOL(acpi_pci_disabled);
>  
> +/* Processors with enabled flag and sane MPIDR */
> +static int enabled_cpus;
> +
> +/* Boot CPU is valid or not in MADT */
> +static bool __initdata bootcpu_valid;
> +
>  static bool __initdata param_acpi_off;
>  static bool __initdata param_acpi_force;
>  
> @@ -85,6 +95,129 @@ void __init __acpi_unmap_table(char *map, unsigned long size)
>  	early_memunmap(map, size);
>  }
>  
> +/**
> + * acpi_map_gic_cpu_interface - generates a logical cpu number
> + * and map to MPIDR represented by GICC structure
> + * @mpidr: CPU's hardware id to register, MPIDR represented in MADT
> + * @enabled: this cpu is enabled or not
> + *
> + * Returns the logical cpu number which maps to MPIDR
> + */
> +static int __init acpi_map_gic_cpu_interface(u64 mpidr, u8 enabled)
> +{
> +	int i;
> +
> +	if (mpidr == INVALID_HWID) {
> +		pr_info("Skip MADT cpu entry with invalid MPIDR\n");
> +		return -EINVAL;
> +	}
> +
> +	total_cpus++;
> +	if (!enabled)
> +		return -EINVAL;
> +
> +	if (enabled_cpus >=  NR_CPUS) {
> +		pr_warn("NR_CPUS limit of %d reached, Processor %d/0x%llx ignored.\n",
> +			NR_CPUS, total_cpus, mpidr);
> +		return -EINVAL;
> +	}
> +
> +	/* Check if GICC structure of boot CPU is available in the MADT */
> +	if (cpu_logical_map(0) == mpidr) {
> +		if (bootcpu_valid) {
> +			pr_err("Firmware bug, duplicate CPU MPIDR: 0x%llx in MADT\n",
> +			       mpidr);
> +			return -EINVAL;
> +		}
> +
> +		bootcpu_valid = true;
> +	}
> +
> +	/*
> +	 * Duplicate MPIDRs are a recipe for disaster. Scan
> +	 * all initialized entries and check for
> +	 * duplicates. If any is found just ignore the CPU.
> +	 */
> +	for (i = 1; i < enabled_cpus; i++) {
> +		if (cpu_logical_map(i) == mpidr) {
> +			pr_err("Firmware bug, duplicate CPU MPIDR: 0x%llx in MADT\n",
> +			       mpidr);
> +			return -EINVAL;
> +		}
> +	}
> +
> +	if (!acpi_psci_present())
> +		return -EOPNOTSUPP;
> +
> +	cpu_ops[enabled_cpus] = cpu_get_ops("psci");
> +	/* CPU 0 was already initialized */
> +	if (enabled_cpus) {
> +		if (!cpu_ops[enabled_cpus])
> +			return -EINVAL;
> +
> +		if (cpu_ops[enabled_cpus]->cpu_init(NULL, enabled_cpus))
> +			return -EOPNOTSUPP;
> +
> +		/* map the logical cpu id to cpu MPIDR */
> +		cpu_logical_map(enabled_cpus) = mpidr;
> +	}
> +
> +	enabled_cpus++;
> +	return enabled_cpus;
> +}
> +
> +static int __init
> +acpi_parse_gic_cpu_interface(struct acpi_subtable_header *header,
> +				const unsigned long end)
> +{
> +	struct acpi_madt_generic_interrupt *processor;
> +
> +	processor = (struct acpi_madt_generic_interrupt *)header;
> +
> +	if (BAD_MADT_ENTRY(processor, end))
> +		return -EINVAL;
> +
> +	acpi_table_print_madt_entry(header);
> +
> +	acpi_map_gic_cpu_interface(processor->arm_mpidr & MPIDR_HWID_BITMASK,
> +		processor->flags & ACPI_MADT_ENABLED);
> +
> +	return 0;
> +}
> +
> +/* Parse GIC cpu interface entries in MADT for SMP init */
> +void __init acpi_init_cpus(void)
> +{
> +	int count, i;
> +
> +	/*
> +	 * do a partial walk of MADT to determine how many CPUs
> +	 * we have including disabled CPUs, and get information
> +	 * we need for SMP init
> +	 */
> +	count = acpi_table_parse_madt(ACPI_MADT_TYPE_GENERIC_INTERRUPT,
> +			acpi_parse_gic_cpu_interface, 0);
> +
> +	if (!count) {
> +		pr_err("No GIC CPU interface entries present\n");
> +		return;
> +	} else if (count < 0) {
> +		pr_err("Error parsing GIC CPU interface entry\n");
> +		return;
> +	}
> +
> +	if (!bootcpu_valid) {
> +		pr_err("MADT missing boot CPU MPIDR, not enabling secondaries\n");
> +		return;
> +	}
> +
> +	for (i = 0; i < enabled_cpus; i++)
> +		set_cpu_possible(i, true);
> +
> +	/* Make boot-up look pretty */
> +	pr_info("%d CPUs enabled, %d CPUs total\n", enabled_cpus, total_cpus);
> +}
> +
>  static int __init acpi_parse_fadt(struct acpi_table_header *table)
>  {
>  	struct acpi_table_fadt *fadt = (struct acpi_table_fadt *)table;
> @@ -96,8 +229,20 @@ static int __init acpi_parse_fadt(struct acpi_table_header *table)
>  	 * boot protocol configuration data, or we will disable ACPI.
>  	 */
>  	if (table->revision > 5 ||
> -	    (table->revision == 5 && fadt->minor_revision >= 1))
> -		return 0;
> +	    (table->revision == 5 && fadt->minor_revision >= 1)) {
> +		/*
> +		 * ACPI 5.1 only has two explicit methods to boot up SMP,
> +		 * PSCI and Parking protocol, but the Parking protocol is
> +		 * only specified for ARMv7 now, so make PSCI as the only
> +		 * way for the SMP boot protocol before some updates for
> +		 * the Parking protocol spec.
> +		 */
> +		if (acpi_psci_present())
> +			return 0;
> +
> +		pr_warn("No PSCI support, will not bring up secondary CPUs\n");
> +		return -EOPNOTSUPP;
> +	}
>  
>  	pr_warn("Unsupported FADT revision %d.%d, should be 5.1+, will disable ACPI\n",
>  		table->revision, fadt->minor_revision);
> diff --git a/arch/arm64/kernel/cpu_ops.c b/arch/arm64/kernel/cpu_ops.c
> index cce9524..fb8ff9b 100644
> --- a/arch/arm64/kernel/cpu_ops.c
> +++ b/arch/arm64/kernel/cpu_ops.c
> @@ -35,7 +35,7 @@ static const struct cpu_operations *supported_cpu_ops[] __initconst = {
>  	NULL,
>  };
>  
> -static const struct cpu_operations * __init cpu_get_ops(const char *name)
> +const struct cpu_operations * __init cpu_get_ops(const char *name)
>  {
>  	const struct cpu_operations **ops = supported_cpu_ops;
>  
> diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
> index 97fa7f3..b278311 100644
> --- a/arch/arm64/kernel/setup.c
> +++ b/arch/arm64/kernel/setup.c
> @@ -393,13 +393,16 @@ void __init setup_arch(char **cmdline_p)
>  	if (acpi_disabled) {
>  		unflatten_device_tree();
>  		psci_dt_init();
> +		cpu_read_bootcpu_ops();
> +#ifdef CONFIG_SMP
> +		of_smp_init_cpus();
> +#endif
>  	} else {
>  		psci_acpi_init();
> +		acpi_init_cpus();
>  	}
>  
> -	cpu_read_bootcpu_ops();
>  #ifdef CONFIG_SMP
> -	smp_init_cpus();
>  	smp_build_mpidr_hash();
>  #endif

I'd rather do without another ifdef above and provide a stub for that function,
but again it might make sense to just keep a small smp_init_cpus() just as with
the psci setup.

The cpu_read_bootcpu_ops() should be pushed down to the dt implementation to
keep the paths more common between acpi and dt.


-Olof

^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 05/21] ARM64 / ACPI: Get RSDP and ACPI boot-time tables
  2015-02-25  8:39 ` [PATCH v9 05/21] ARM64 / ACPI: Get RSDP and ACPI boot-time tables Hanjun Guo
  2015-03-05 18:10   ` Olof Johansson
@ 2015-03-05 18:51   ` Lorenzo Pieralisi
  2015-03-10  8:01     ` Hanjun Guo
  2015-03-06 20:28   ` Grant Likely
  2 siblings, 1 reply; 106+ messages in thread
From: Lorenzo Pieralisi @ 2015-03-05 18:51 UTC (permalink / raw)
  To: Hanjun Guo
  Cc: Catalin Marinas, Rafael J. Wysocki, Will Deacon, Olof Johansson,
	grant.likely, Arnd Bergmann, Mark Rutland, graeme.gregory,
	Sudeep Holla, jcm, Marc Zyngier, Mark Brown, Robert Richter,
	Timur Tabi, Ashwin Chaugule, suravee.suthikulpanit, linux-acpi,
	linux-arm-kernel, linux-kernel, linaro-acpi, Al Stone,
	Tomasz Nowicki

On Wed, Feb 25, 2015 at 08:39:45AM +0000, Hanjun Guo wrote:
> From: Al Stone <al.stone@linaro.org>
> 
> As we want to get ACPI tables to parse and then use the information
> for system initialization, we should get the RSDP (Root System
> Description Pointer) first, it then locates Extended Root Description
> Table (XSDT) which contains all the 64-bit physical address that
> pointer to other boot-time tables.
> 
> Introduce acpi.c and its related head file in this patch to provide
> fundamental needs of extern variables and functions for ACPI core,
> and then get boot-time tables as needed.
>   - asm/acenv.h for arch specific ACPICA environments and
>     implementation, It is needed unconditionally by ACPI core;

I am not sure we will ever need it since the global lock is not
needed on HW reduced ACPI (ie ACPI on arm64), and instructions to
flush the caches are not needed either on arm64.

Anyway, I will have a look if it is worth writing optimized div/shift,
to give it a purpose to exist.

[...]

> diff --git a/arch/arm64/include/asm/acpi.h b/arch/arm64/include/asm/acpi.h
> new file mode 100644
> index 0000000..8b837ab
> --- /dev/null
> +++ b/arch/arm64/include/asm/acpi.h
> @@ -0,0 +1,45 @@
> +/*
> + *  Copyright (C) 2013-2014, Linaro Ltd.
> + *	Author: Al Stone <al.stone@linaro.org>
> + *	Author: Graeme Gregory <graeme.gregory@linaro.org>
> + *	Author: Hanjun Guo <hanjun.guo@linaro.org>
> + *
> + *  This program is free software; you can redistribute it and/or modify
> + *  it under the terms of the GNU General Public License version 2 as
> + *  published by the Free Software Foundation;
> + */
> +
> +#ifndef _ASM_ACPI_H
> +#define _ASM_ACPI_H
> +
> +/* Basic configuration for ACPI */
> +#ifdef	CONFIG_ACPI
> +#define acpi_strict 1	/* No out-of-spec workarounds on ARM64 */
> +extern int acpi_disabled;
> +extern int acpi_noirq;
> +extern int acpi_pci_disabled;
> +
> +static inline void disable_acpi(void)
> +{
> +	acpi_disabled = 1;
> +	acpi_pci_disabled = 1;
> +	acpi_noirq = 1;
> +}
> +
> +/*
> + * It's used from ACPI core in kdump to boot UP system with SMP kernel,
> + * with this check the ACPI core will not override the CPU index
> + * obtained from GICC with 0 and not print some error message as well.
> + * Since MADT must provide at least one GICC structure for GIC
> + * initialization, CPU will be always available in MADT on ARM64.
> + */
> +static inline bool acpi_has_cpu_in_madt(void)
> +{
> +	return true;
> +}

I am still trying to make sense of what's this is used for, to me
it looks like a legacy hack in acpi_processor.c. It is a shame that we need
to define functions to paper over legacy hacks that make no sense
whatsoever on arm64.

> +static inline void arch_fix_phys_package_id(int num, u32 slot) { }

This is only used on ia64 to pass the _SUN value to arch code to fix up
the socket id. See above.

You could define last two functions in generic code, and let the
arch code that needs them override them.

Whether we do it in this series or later, this stuff needs cleaning up.

> +
> +#endif /* CONFIG_ACPI */
> +
> +#endif /*_ASM_ACPI_H*/
> diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile
> index bef04af..218eb7e 100644
> --- a/arch/arm64/kernel/Makefile
> +++ b/arch/arm64/kernel/Makefile
> @@ -34,6 +34,7 @@ arm64-obj-$(CONFIG_KGDB)		+= kgdb.o
>  arm64-obj-$(CONFIG_EFI)			+= efi.o efi-stub.o efi-entry.o
>  arm64-obj-$(CONFIG_PCI)			+= pci.o
>  arm64-obj-$(CONFIG_ARMV8_DEPRECATED)	+= armv8_deprecated.o
> +arm64-obj-$(CONFIG_ACPI)		+= acpi.o
>  
>  obj-y					+= $(arm64-obj-y) vdso/
>  obj-m					+= $(arm64-obj-m)
> diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c
> new file mode 100644
> index 0000000..f052e7a
> --- /dev/null
> +++ b/arch/arm64/kernel/acpi.c
> @@ -0,0 +1,101 @@
> +/*
> + *  ARM64 Specific Low-Level ACPI Boot Support
> + *
> + *  Copyright (C) 2013-2014, Linaro Ltd.
> + *	Author: Al Stone <al.stone@linaro.org>
> + *	Author: Graeme Gregory <graeme.gregory@linaro.org>
> + *	Author: Hanjun Guo <hanjun.guo@linaro.org>
> + *	Author: Tomasz Nowicki <tomasz.nowicki@linaro.org>
> + *	Author: Naresh Bhat <naresh.bhat@linaro.org>
> + *
> + *  This program is free software; you can redistribute it and/or modify
> + *  it under the terms of the GNU General Public License version 2 as
> + *  published by the Free Software Foundation.
> + */
> +
> +#define pr_fmt(fmt) "ACPI: " fmt
> +
> +#include <linux/acpi.h>
> +#include <linux/bootmem.h>
> +#include <linux/cpumask.h>
> +#include <linux/init.h>
> +#include <linux/irq.h>
> +#include <linux/irqdomain.h>
> +#include <linux/memblock.h>
> +#include <linux/smp.h>
> +
> +int acpi_noirq;			/* skip ACPI IRQ initialization */
> +int acpi_disabled;
> +EXPORT_SYMBOL(acpi_disabled);
> +
> +int acpi_pci_disabled;		/* skip ACPI PCI scan and IRQ initialization */
> +EXPORT_SYMBOL(acpi_pci_disabled);
> +
> +/*
> + * __acpi_map_table() will be called before page_init(), so early_ioremap()
> + * or early_memremap() should be called here to for ACPI table mapping.
> + */
> +char *__init __acpi_map_table(unsigned long phys, unsigned long size)
> +{
> +	if (!phys || !size)

Is there a reason to rule out physical address 0x0 ?

Thanks,
Lorenzo

> +		return NULL;
> +
> +	return early_memremap(phys, size);
> +}
> +
> +void __init __acpi_unmap_table(char *map, unsigned long size)
> +{
> +	if (!map || !size)
> +		return;
> +
> +	early_memunmap(map, size);
> +}
> +
> +static int __init acpi_parse_fadt(struct acpi_table_header *table)
> +{
> +	struct acpi_table_fadt *fadt = (struct acpi_table_fadt *)table;
> +
> +	/*
> +	 * Revision in table header is the FADT Major revision, and there
> +	 * is a minor revision of FADT which was introduced by ACPI 5.1,
> +	 * we only deal with ACPI 5.1 or newer revision to get GIC and SMP
> +	 * boot protocol configuration data, or we will disable ACPI.
> +	 */
> +	if (table->revision > 5 ||
> +	    (table->revision == 5 && fadt->minor_revision >= 1))
> +		return 0;
> +
> +	pr_warn("Unsupported FADT revision %d.%d, should be 5.1+, will disable ACPI\n",
> +		table->revision, fadt->minor_revision);
> +	disable_acpi();
> +
> +	return -EINVAL;
> +}
> +
> +/*
> + * acpi_boot_table_init() called from setup_arch(), always.
> + *	1. find RSDP and get its address, and then find XSDT
> + *	2. extract all tables and checksums them all
> + *	3. check ACPI FADT revision
> + *
> + * We can parse ACPI boot-time tables such as MADT after
> + * this function is called.
> + */
> +void __init acpi_boot_table_init(void)
> +{
> +	/* If acpi_disabled, bail out */
> +	if (acpi_disabled)
> +		return;
> +
> +	/* Initialize the ACPI boot-time table parser. */
> +	if (acpi_table_init()) {
> +		disable_acpi();
> +		return;
> +	}
> +
> +	if (acpi_table_parse(ACPI_SIG_FADT, acpi_parse_fadt)) {
> +		/* disable ACPI if no FADT is found */
> +		disable_acpi();
> +		pr_err("Can't find FADT\n");
> +	}
> +}
> diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
> index e8420f6..4f1a014 100644
> --- a/arch/arm64/kernel/setup.c
> +++ b/arch/arm64/kernel/setup.c
> @@ -17,6 +17,7 @@
>   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
>   */
>  
> +#include <linux/acpi.h>
>  #include <linux/export.h>
>  #include <linux/kernel.h>
>  #include <linux/stddef.h>
> @@ -46,6 +47,7 @@
>  #include <linux/efi.h>
>  #include <linux/personality.h>
>  
> +#include <asm/acpi.h>
>  #include <asm/fixmap.h>
>  #include <asm/cpu.h>
>  #include <asm/cputype.h>
> @@ -380,6 +382,9 @@ void __init setup_arch(char **cmdline_p)
>  	efi_init();
>  	arm64_memblock_init();
>  
> +	/* Parse the ACPI tables for possible boot-time configuration */
> +	acpi_boot_table_init();
> +
>  	paging_init();
>  	request_standard_resources();
>  
> -- 
> 1.9.1
> 
> 

^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 21/21] ARM64 / ACPI: additions of ACPI documentation for arm64
  2015-02-25  8:40 ` [PATCH v9 21/21] ARM64 / ACPI: additions of ACPI documentation for arm64 Hanjun Guo
  2015-02-27 11:22   ` Shannon Zhao
@ 2015-03-05 18:54   ` Olof Johansson
  1 sibling, 0 replies; 106+ messages in thread
From: Olof Johansson @ 2015-03-05 18:54 UTC (permalink / raw)
  To: Hanjun Guo
  Cc: Catalin Marinas, Rafael J. Wysocki, Will Deacon, Grant Likely,
	Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi, Al Stone, Yi Li, Mark Langsdorf

On Wed, Feb 25, 2015 at 04:40:01PM +0800, Hanjun Guo wrote:
> From: Al Stone <al.stone@linaro.org>
> 
> Two more documentation files are also being added:
> (1) A verbatim copy of the "Why ACPI on ARM?" blog posting by Grant Likely,
>     which is also summarized in arm-acpi.txt, and

This doesn't belong in the kernel tree.

> (2) A section by section review of the ACPI spec (acpi_object_usage.txt)
>     to note recommendations and prohibitions on the use of the numerous
>     ACPI tables and objects.  This sets out the current expectations of
>     the firmware by Linux very explicitly (or as explicitly as I can, for
>     now).

I'll follow up with any comments on this separately (I.e. haven't read it yet).


-Olof

^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 00/21] Introduce ACPI for ARM64 based on ACPI 5.1
  2015-02-25  8:39 [PATCH v9 00/21] Introduce ACPI for ARM64 based on ACPI 5.1 Hanjun Guo
                   ` (22 preceding siblings ...)
  2015-03-04 22:56 ` Rafael J. Wysocki
@ 2015-03-05 18:57 ` Olof Johansson
  2015-03-06  4:26   ` Hanjun Guo
  23 siblings, 1 reply; 106+ messages in thread
From: Olof Johansson @ 2015-03-05 18:57 UTC (permalink / raw)
  To: Hanjun Guo
  Cc: Catalin Marinas, Rafael J. Wysocki, Will Deacon, Grant Likely,
	Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi

Hi,

On Wed, Feb 25, 2015 at 04:39:40PM +0800, Hanjun Guo wrote:
> Changes since v8:
>   - remove MPIDR packing things by introducing phys_cpuid_t;
> 
>   - update patch acpi: fix acpi_os_ioremap for arm64 to follow
>     Rafael's suggestion;
> 
>   - Squash patch (disable ACPI if ACPI less than 5.1) to patch
>     (Get RSDP and ACPI boot-time table);
> 
>   - Move sleep_arm.c to arch/arm64/ and rename it as acpi_sleep.c 
> 
>   - Rework the uefi generated empty dtb to enable acpi when no dtb
>     is available, thanks Ard for the updated patch.
> 
>   - rework the function of register cpu for kexec case
> 
>   - use pr_debug() instead of pr_info() when scanning MADT.
> 
>   - rebase on top of 4.0-rc1
> 

I've looked at most of the arch code besides GIC and some of the timer stuff,
which I might revisit later, but the pieces I've seen seem reasonable. I've
acked individual patches.

There are some cleanups to be made, but that can be done incrementally on top,
it's all internal implementation details.

I also haven't looked closely at the documentation patches yet, so I might have
some comments on those showing up.


-Olof

^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 16/21] irqchip: Add GICv2 specific ACPI boot support
  2015-03-05 11:53     ` Catalin Marinas
@ 2015-03-06  0:42       ` Rafael J. Wysocki
  0 siblings, 0 replies; 106+ messages in thread
From: Rafael J. Wysocki @ 2015-03-06  0:42 UTC (permalink / raw)
  To: Catalin Marinas
  Cc: Hanjun Guo, Mark Rutland, linaro-acpi, Will Deacon,
	Lorenzo Pieralisi, Timur Tabi, linux-acpi, Grant Likely,
	Robert Richter, Jason Cooper, Arnd Bergmann, Marc Zyngier,
	Jon Masters, Tomasz Nowicki, Mark Brown, Thomas Gleixner,
	linux-arm-kernel, Graeme Gregory, Ashwin Chaugule, linux-kernel,
	suravee.suthikulpanit, Sudeep Holla, Olof Johansson

On Thursday, March 05, 2015 11:53:22 AM Catalin Marinas wrote:
> On Wed, Mar 04, 2015 at 11:50:36PM +0100, Rafael J. Wysocki wrote:
> > On Wednesday, February 25, 2015 04:39:56 PM Hanjun Guo wrote:

[cut]

> > > diff --git a/include/linux/acpi.h b/include/linux/acpi.h
> > > index c03d8d1..e27117a 100644
> > > --- a/include/linux/acpi.h
> > > +++ b/include/linux/acpi.h
> > > @@ -557,6 +557,20 @@ static inline int acpi_device_modalias(struct device *dev,
> > >  
> > >  #endif	/* !CONFIG_ACPI */
> > >  
> > > +#if defined(CONFIG_ACPI) && defined(CONFIG_ARM64)
> > > +static inline void acpi_irq_init(void)
> > > +{
> > > +	/*
> > > +	 * Hardcode ACPI IRQ chip initialization to GICv2 for now.
> > > +	 * Proper irqchip infrastructure will be implemented along with
> > > +	 * incoming  GICv2m|GICv3|ITS bits.
> > > +	 */
> > > +	acpi_gic_init();
> > > +}
> > > +#else
> > > +static inline void acpi_irq_init(void) { }
> > > +#endif
> > 
> > I don't want this in a common header.
> 
> I don't like it either. What about adding it to a new header,
> linux/acpi_irq.h just for the dummy acpi_irq_init()? This would be
> similar to the DT equivalent, of_irq_init() in linux/of_irq.h and at
> some point it will gain more macros for declaring interrupt controllers
> in the ACPI context.
> 
> What we objected to previously was calling acpi_gic_init() directly from
> the core irqchip_init() and asked for something similar to the more
> generic of_irq_init(). The arm64-specific patch above is clearly a
> temporary hack until full support for multiple interrupt controllers is
> added (we asked for this several times in the past, but the ARM ACPI
> guys thought it's too much hassle ;). I don't fully get it since one of
> the platforms they target needs GICv2m support anyway).
> 
> Anyway, if we are to keep the temporary hack, I think we could define
> something like below (possibly in a new linux/acpi_irq.h which includes
> asm/irq.h):
> 
> #ifndef acpi_irq_init
> static inline void acpi_irq_init(void)
> {
> }
> #endif
> 
> And in the arm64 asm/irq.h:
> 
> static inline void acpi_irq_init(void)
> {
> 	/*
> 	 * Hardcode ACPI IRQ chip initialization to GICv2 for now.
> 	 * Proper irqchip infrastructure will be implemented along with
> 	 * incoming  GICv2m|GICv3|ITS bits.
> 	 */
> 	acpi_gic_init();
> }
> #define acpi_irq_init acpi_irq_init
> 
> When the new infrastructure is in place, we can get rid of the #ifndef
> and arm64-specific acpi_irq_init().

Well, that sounds much better than the original patch.

Rafael


^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 00/21] Introduce ACPI for ARM64 based on ACPI 5.1
  2015-03-05 18:57 ` Olof Johansson
@ 2015-03-06  4:26   ` Hanjun Guo
  0 siblings, 0 replies; 106+ messages in thread
From: Hanjun Guo @ 2015-03-06  4:26 UTC (permalink / raw)
  To: Olof Johansson, Hanjun Guo
  Cc: Catalin Marinas, Rafael J. Wysocki, Will Deacon, Grant Likely,
	Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi

On 2015/3/6 2:57, Olof Johansson wrote:
> Hi,

Hi Olof,

>
> On Wed, Feb 25, 2015 at 04:39:40PM +0800, Hanjun Guo wrote:
>> Changes since v8:
>>   - remove MPIDR packing things by introducing phys_cpuid_t;
>>
>>   - update patch acpi: fix acpi_os_ioremap for arm64 to follow
>>     Rafael's suggestion;
>>
>>   - Squash patch (disable ACPI if ACPI less than 5.1) to patch
>>     (Get RSDP and ACPI boot-time table);
>>
>>   - Move sleep_arm.c to arch/arm64/ and rename it as acpi_sleep.c 
>>
>>   - Rework the uefi generated empty dtb to enable acpi when no dtb
>>     is available, thanks Ard for the updated patch.
>>
>>   - rework the function of register cpu for kexec case
>>
>>   - use pr_debug() instead of pr_info() when scanning MADT.
>>
>>   - rebase on top of 4.0-rc1
>>
> I've looked at most of the arch code besides GIC and some of the timer stuff,
> which I might revisit later, but the pieces I've seen seem reasonable. I've
> acked individual patches.

Thank you very much for the ACKs and review comments!

>
> There are some cleanups to be made, but that can be done incrementally on top,
> it's all internal implementation details.

Definitely in my TODO list :)

>
> I also haven't looked closely at the documentation patches yet, so I might have
> some comments on those showing up.

OK, thanks.

Regards
Hanjun


^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 02/21] ACPI / processor: Introduce phys_cpuid_t for CPU hardware ID
  2015-03-05 13:23       ` Rafael J. Wysocki
@ 2015-03-06  6:48         ` Hanjun Guo
  0 siblings, 0 replies; 106+ messages in thread
From: Hanjun Guo @ 2015-03-06  6:48 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Rafael J. Wysocki, Hanjun Guo, Catalin Marinas, Will Deacon,
	Olof Johansson, Grant Likely, Lorenzo Pieralisi, Arnd Bergmann,
	Mark Rutland, Graeme Gregory, Sudeep Holla, Jon Masters,
	Marc Zyngier, Mark Brown, Robert Richter, Timur Tabi,
	Ashwin Chaugule, suravee.suthikulpanit, ACPI Devel Maling List,
	linux-arm-kernel, Linux Kernel Mailing List, linaro-acpi

On 2015/3/5 21:23, Rafael J. Wysocki wrote:
> On Thu, Mar 5, 2015 at 8:44 AM, Hanjun Guo <guohanjun@huawei.com> wrote:
>> On 2015/3/5 6:29, Rafael J. Wysocki wrote:
>>> On Wednesday, February 25, 2015 04:39:42 PM Hanjun Guo wrote:
> [cut]
>
>>>> @@ -190,7 +190,7 @@ int acpi_map_cpuid(int phys_id, u32 acpi_id)
>>>>              if (nr_cpu_ids <= 1 && acpi_id == 0)
>>>>                      return acpi_id;
>>>>              else
>>>> -                    return phys_id;
>>>> +                    return -1;
>>> Can we use a proper error code here?
>> I'm afraid not. In ACPI processor drivers, -1 will be deemed to
>> invalid cpu logical number, if we return error code here, we need
>> to modify multi places of "if (cpu_logical_num == -1)" to
> Oh, silly stuff.
>
>> "if (! (cpu_logical_num < 0))" too, so for me, I prefer to keep it as
>> -1, but I'm open for suggestions.
> OK
>
> I think we need something like invalid_logical_cpuid() and use it
> in all of those checks instead of the direct comparisons, but we
> can make those changes later.

OK, I recorded this as one of my TODO list, thanks for the suggestions.

Thanks
Hanjun


^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 14/21] ACPI / processor: Make it possible to get CPU hardware ID via GICC
  2015-03-05 15:19           ` Catalin Marinas
@ 2015-03-06  6:51             ` Hanjun Guo
  0 siblings, 0 replies; 106+ messages in thread
From: Hanjun Guo @ 2015-03-06  6:51 UTC (permalink / raw)
  To: Catalin Marinas, Rafael J. Wysocki
  Cc: Mark Rutland, linaro-acpi, Will Deacon, Lorenzo Pieralisi,
	Timur Tabi, ACPI Devel Maling List, Grant Likely, Robert Richter,
	Arnd Bergmann, Marc Zyngier, Jon Masters, Mark Brown,
	linux-arm-kernel, Ashwin Chaugule, Graeme Gregory,
	Rafael J. Wysocki, Linux Kernel Mailing List, Hanjun Guo,
	suravee.suthikulpanit, Sudeep Holla, Olof Johansson

On 2015/3/5 23:19, Catalin Marinas wrote:
> On Thu, Mar 05, 2015 at 02:13:58PM +0100, Rafael J. Wysocki wrote:
>> On Thu, Mar 5, 2015 at 12:27 PM, Catalin Marinas
>> <catalin.marinas@arm.com> wrote:
>>> On Thu, Mar 05, 2015 at 04:03:21PM +0800, Hanjun Guo wrote:
>>>> On 2015/3/5 6:46, Rafael J. Wysocki wrote:
>>>>> IMO, you really need to define phys_cpuid_t in a common place or people will
>>>>> forget that it may be 64-bit, because they'll only be looking at their arch.
>>>> Since x86 and ARM64 are using different types for phys_cpuid_t, we need to
>>>> introduce something like following if define it in common place:
>>>>
>>>> in linux/acpi.h,
>>>>
>>>> #if defined(CONFIG_X86) || defined(CONFIG_IA64)
>>>> typedef u32 phys_cpuid_t;
>>>> #define PHYS_CPUID_INVALID (phys_cpuid_t)(-1)
>>>> #else if defined(CONFIG_ARM64)
>>>> typedef u64 phys_cpuid_t;
>>>> #define PHYS_CPUID_INVALID INVALID_HWID
>>>> #endif
>>>>
>>>> I think it's awful, did I miss something?
>> Well, you can define the type and PHYS_CPUID_INVALID in the arch
>> code and then do this in a common header:
>>
>> #ifndef PHYS_CPUID_INVALID
>> typedef u32 phys_cpuid_t;
>> #define PHYS_CPUID_INVALID (phys_cpuid_t)(-1)
>> #endif
>>
>> That would allow you to avoid the need to duplicate the
>> definitions where it is not necessary.
> It's fine by me.

I will update the patch.

Thanks
Hanjun


^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 07/21] ACPI / sleep: Introduce arm64 specific acpi_sleep.c
  2015-03-05  0:16         ` Rafael J. Wysocki
@ 2015-03-06 12:36           ` Lorenzo Pieralisi
  0 siblings, 0 replies; 106+ messages in thread
From: Lorenzo Pieralisi @ 2015-03-06 12:36 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: graeme.gregory, hanjun.guo, Catalin Marinas, Will Deacon,
	Olof Johansson, grant.likely, Arnd Bergmann, Mark Rutland,
	Sudeep Holla, jcm, Marc Zyngier, Mark Brown, Robert Richter,
	Timur Tabi, Ashwin Chaugule, suravee.suthikulpanit, linux-acpi,
	linux-arm-kernel, linux-kernel, Linaro ACPI Mailman List,
	Tomasz Nowicki

On Thu, Mar 05, 2015 at 12:16:29AM +0000, Rafael J. Wysocki wrote:
> On Thursday, March 05, 2015 12:25:54 AM Rafael J. Wysocki wrote:
> > On Wednesday, March 04, 2015 10:49:25 PM G Gregory wrote:
> > > On 4 March 2015 at 22:38, Rafael J. Wysocki <rjw@rjwysocki.net> wrote:
> > > > On Wednesday, February 25, 2015 04:39:47 PM Hanjun Guo wrote:
> > > >> From: Graeme Gregory <graeme.gregory@linaro.org>
> > > >>
> > > >> ACPI 5.1 does not currently support S states for ARM64 hardware but
> > > >> ACPI code will call acpi_target_system_state() for device power
> > > >> management, so introduce acpi_sleep.c to allow other drivers to function
> > > >> until S states are defined.
> > > >>
> > > >> Since it is arm64 specific stub holder, so let acpi_sleep.c to ARM64
> > > >> specific.
> > > >>
> > > >> TODO: merge this with drivers/acpi/sleep.c once we fix the specification.
> > > >>
> > > >> CC: Rafael J. Wysocki <rjw@rjwysocki.net>
> > > >> Tested-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
> > > >> Tested-by: Yijing Wang <wangyijing@huawei.com>
> > > >> Tested-by: Mark Langsdorf <mlangsdo@redhat.com>
> > > >> Tested-by: Jon Masters <jcm@redhat.com>
> > > >> Tested-by: Timur Tabi <timur@codeaurora.org>
> > > >> Tested-by: Robert Richter <rrichter@cavium.com>
> > > >> Acked-by: Robert Richter <rrichter@cavium.com>
> > > >> Signed-off-by: Graeme Gregory <graeme.gregory@linaro.org>
> > > >> Signed-off-by: Tomasz Nowicki <tomasz.nowicki@linaro.org>
> > > >> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
> > > >> ---
> > > >>  arch/arm64/kernel/Makefile     |  2 +-
> > > >>  arch/arm64/kernel/acpi_sleep.c | 28 ++++++++++++++++++++++++++++
> > > >>  drivers/acpi/Makefile          |  2 ++
> > > >>  3 files changed, 31 insertions(+), 1 deletion(-)
> > > >>  create mode 100644 arch/arm64/kernel/acpi_sleep.c
> > > >>
> > > >> diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile
> > > >> index 218eb7e..4435943 100644
> > > >> --- a/arch/arm64/kernel/Makefile
> > > >> +++ b/arch/arm64/kernel/Makefile
> > > >> @@ -34,7 +34,7 @@ arm64-obj-$(CONFIG_KGDB)            += kgdb.o
> > > >>  arm64-obj-$(CONFIG_EFI)                      += efi.o efi-stub.o efi-entry.o
> > > >>  arm64-obj-$(CONFIG_PCI)                      += pci.o
> > > >>  arm64-obj-$(CONFIG_ARMV8_DEPRECATED) += armv8_deprecated.o
> > > >> -arm64-obj-$(CONFIG_ACPI)             += acpi.o
> > > >> +arm64-obj-$(CONFIG_ACPI)             += acpi.o acpi_sleep.o
> > > >>
> > > >>  obj-y                                        += $(arm64-obj-y) vdso/
> > > >>  obj-m                                        += $(arm64-obj-m)
> > > >> diff --git a/arch/arm64/kernel/acpi_sleep.c b/arch/arm64/kernel/acpi_sleep.c
> > > >> new file mode 100644
> > > >> index 0000000..54578ef
> > > >> --- /dev/null
> > > >> +++ b/arch/arm64/kernel/acpi_sleep.c
> > > >> @@ -0,0 +1,28 @@
> > > >> +/*
> > > >> + *  ARM64 Specific Sleep Functionality
> > > >> + *
> > > >> + *  Copyright (C) 2013-2014, Linaro Ltd.
> > > >> + *      Author: Graeme Gregory <graeme.gregory@linaro.org>
> > > >> + *
> > > >> + *  This program is free software; you can redistribute it and/or modify
> > > >> + *  it under the terms of the GNU General Public License version 2 as
> > > >> + *  published by the Free Software Foundation.
> > > >> + */
> > > >> +
> > > >> +#include <linux/acpi.h>
> > > >> +
> > > >> +/*
> > > >> + * Currently the ACPI 5.1 standard does not define S states in a
> > > >> + * manner which is usable for ARM64. These two stubs are sufficient
> > > >> + * that system initialises and device PM works.
> > > >> + */
> > > >> +u32 acpi_target_system_state(void)
> > > >> +{
> > > >> +     return ACPI_STATE_S0;
> > > >> +}
> > > >> +EXPORT_SYMBOL_GPL(acpi_target_system_state);
> > > >> +
> > > >> +int __init acpi_sleep_init(void)
> > > >> +{
> > > >> +     return -ENOSYS;
> > > >> +}
> > > >> diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
> > > >> index 623b117..c32edf5 100644
> > > >> --- a/drivers/acpi/Makefile
> > > >> +++ b/drivers/acpi/Makefile
> > > >> @@ -23,7 +23,9 @@ acpi-y                              += nvs.o
> > > >>
> > > >>  # Power management related files
> > > >>  acpi-y                               += wakeup.o
> > > >> +ifneq (,$(findstring $(ARCH),x86 ia64))
> > > >
> > > > This is super-ugly.  Isn't there a better way to do that?
> > > >
> > > Its the standard example in the GNU Make manual,
> > 
> > It is never used in the kernel this way, though, and I'm not going to let
> > that slip through.
> > 
> > > I would certainly love if someone had a batter suggestion.
> > 
> > Define ACPI_GENERIC_SLEEP in drivers/acpi/Kconfig as
> > 
> > 	config ACPI_GENERIC_SLEEP
> > 		bool
> > 		depends on IA64 || X86
> > 
> > and build the file conditional on that.
> 
> Or define
> 
> 	config ACPI_GENERIC_SLEEP
> 		bool
> 
> and then make both x86 and ia64 do
> 
> 	select ACPI_GENERIC_SLEEP if ACPI
> 
> which kind of will make it clear where the choice takes place.

While at it, use the newly defined config entry to add the required static
inline in the respective headers and get rid of acpi_sleep.c from arm64.

Thanks,
Lorenzo

^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 18/21] ARM64 / ACPI: Select ACPI_REDUCED_HARDWARE_ONLY if ACPI is enabled on ARM64
  2015-02-25  8:39 ` [PATCH v9 18/21] ARM64 / ACPI: Select ACPI_REDUCED_HARDWARE_ONLY if ACPI is enabled on ARM64 Hanjun Guo
@ 2015-03-06 17:47   ` Lorenzo Pieralisi
  2015-03-10 12:23     ` Hanjun Guo
  2015-03-07 23:16   ` Grant Likely
  1 sibling, 1 reply; 106+ messages in thread
From: Lorenzo Pieralisi @ 2015-03-06 17:47 UTC (permalink / raw)
  To: Hanjun Guo
  Cc: Catalin Marinas, Rafael J. Wysocki, Will Deacon, Olof Johansson,
	grant.likely, Arnd Bergmann, Mark Rutland, graeme.gregory,
	Sudeep Holla, jcm, Marc Zyngier, Mark Brown, Robert Richter,
	Timur Tabi, Ashwin Chaugule, suravee.suthikulpanit, linux-acpi,
	linux-arm-kernel, linux-kernel, linaro-acpi, Al Stone

On Wed, Feb 25, 2015 at 08:39:58AM +0000, Hanjun Guo wrote:
> From: Al Stone <al.stone@linaro.org>
> 
> ACPI reduced hardware mode is disabled by default, but ARM64
> can only run properly in ACPI hardware reduced mode, so select
> ACPI_REDUCED_HARDWARE_ONLY if ACPI is enabled on ARM64.

Agreed. This will remove unneeded acpica code. I think though,
you should also check the FADT flag HW_REDUCED_ACPI at boot to
make sure that the tables are HW reduced compliant. I am flagging
this up because I noticed code in core code (not guarded by
ifdef) that checks:

acpi_gbl_reduced_hardware

and if it is not set it goes on instantiating fixed HW devices.

drivers/acpi/scan.c:2567

It is just a heads up, I think it is harmless, but one thing is
removing acpica code on ACPI HW reduced only, the other is to make
sure the kernel does not try to use ACPI HW features that acpica
can't support.

Lorenzo

> CC: Catalin Marinas <catalin.marinas@arm.com>
> CC: Will Deacon <will.deacon@arm.com>
> Reviewed-by: Grant Likely <grant.likely@linaro.org>
> Tested-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
> Tested-by: Yijing Wang <wangyijing@huawei.com>
> Tested-by: Mark Langsdorf <mlangsdo@redhat.com>
> Tested-by: Jon Masters <jcm@redhat.com>
> Tested-by: Timur Tabi <timur@codeaurora.org>
> Tested-by: Robert Richter <rrichter@cavium.com>
> Acked-by: Robert Richter <rrichter@cavium.com>
> Signed-off-by: Al Stone <al.stone@linaro.org>
> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
> ---
>  arch/arm64/Kconfig | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
> index 1b8e973..d00ab9a 100644
> --- a/arch/arm64/Kconfig
> +++ b/arch/arm64/Kconfig
> @@ -1,5 +1,6 @@
>  config ARM64
>  	def_bool y
> +	select ACPI_REDUCED_HARDWARE_ONLY if ACPI
>  	select ARCH_BINFMT_ELF_RANDOMIZE_PIE
>  	select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE
>  	select ARCH_HAS_GCOV_PROFILE_ALL
> -- 
> 1.9.1
> 
> 

^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 12/21] ACPI / table: Print GIC information when MADT is parsed
  2015-02-25  8:39 ` [PATCH v9 12/21] ACPI / table: Print GIC information when MADT is parsed Hanjun Guo
  2015-03-04 22:40   ` Rafael J. Wysocki
@ 2015-03-06 18:06   ` Lorenzo Pieralisi
  2015-03-06 20:40   ` Grant Likely
  2 siblings, 0 replies; 106+ messages in thread
From: Lorenzo Pieralisi @ 2015-03-06 18:06 UTC (permalink / raw)
  To: Hanjun Guo
  Cc: Catalin Marinas, Rafael J. Wysocki, Will Deacon, Olof Johansson,
	grant.likely, Arnd Bergmann, Mark Rutland, graeme.gregory,
	Sudeep Holla, jcm, Marc Zyngier, Mark Brown, Robert Richter,
	Timur Tabi, Ashwin Chaugule, suravee.suthikulpanit, linux-acpi,
	linux-arm-kernel, linux-kernel, linaro-acpi, Tomasz Nowicki

On Wed, Feb 25, 2015 at 08:39:52AM +0000, Hanjun Guo wrote:
> When MADT is parsed, print GIC information as debug message:
> 
> ACPI: GICC (acpi_id[0x0000] address[00000000e112f000] MPIDR[0x0] enabled)
> ACPI: GICC (acpi_id[0x0001] address[00000000e112f000] MPIDR[0x1] enabled)
> ...
> ACPI: GICC (acpi_id[0x0201] address[00000000e112f000] MPIDR[0x201] enabled)
> 
> Those debug information will be very helpful to bring up early systems to
> see if acpi_id and MPIDR are matched or not as spec defined.

Nit: "This debug information"

> CC: Rafael J. Wysocki <rjw@rjwysocki.net>
> Tested-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
> Tested-by: Yijing Wang <wangyijing@huawei.com>
> Tested-by: Mark Langsdorf <mlangsdo@redhat.com>
> Tested-by: Jon Masters <jcm@redhat.com>
> Tested-by: Timur Tabi <timur@codeaurora.org>
> Tested-by: Robert Richter <rrichter@cavium.com>
> Acked-by: Robert Richter <rrichter@cavium.com>
> Acked-by: Sudeep Holla <sudeep.holla@arm.com>
> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
> Signed-off-by: Tomasz Nowicki <tomasz.nowicki@linaro.org>

Acked-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>

> ---
>  drivers/acpi/tables.c | 22 ++++++++++++++++++++++
>  1 file changed, 22 insertions(+)
> 
> diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c
> index f4e5b88..2e19189 100644
> --- a/drivers/acpi/tables.c
> +++ b/drivers/acpi/tables.c
> @@ -185,6 +185,28 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header)
>  		}
>  		break;
>  
> +	case ACPI_MADT_TYPE_GENERIC_INTERRUPT:
> +		{
> +			struct acpi_madt_generic_interrupt *p =
> +				(struct acpi_madt_generic_interrupt *)header;
> +			pr_debug("GICC (acpi_id[0x%04x] address[%llx] MPIDR[0x%llx] %s)\n",
> +				 p->uid, p->base_address,
> +				 p->arm_mpidr,
> +				 (p->flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled");
> +
> +		}
> +		break;
> +
> +	case ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR:
> +		{
> +			struct acpi_madt_generic_distributor *p =
> +				(struct acpi_madt_generic_distributor *)header;
> +			pr_debug("GIC Distributor (gic_id[0x%04x] address[%llx] gsi_base[%d])\n",
> +				 p->gic_id, p->base_address,
> +				 p->global_irq_base);
> +		}
> +		break;
> +
>  	default:
>  		pr_warn("Found unsupported MADT entry (type = 0x%x)\n",
>  			header->type);
> -- 
> 1.9.1
> 
> 

^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 08/21] ARM64 / ACPI: Introduce PCI stub functions for ACPI
  2015-02-25  8:39 ` [PATCH v9 08/21] ARM64 / ACPI: Introduce PCI stub functions for ACPI Hanjun Guo
@ 2015-03-06 18:31   ` Lorenzo Pieralisi
  2015-03-10  9:21     ` Hanjun Guo
  2015-03-06 20:36   ` Grant Likely
  2015-03-09 15:01   ` Liviu Dudau
  2 siblings, 1 reply; 106+ messages in thread
From: Lorenzo Pieralisi @ 2015-03-06 18:31 UTC (permalink / raw)
  To: Hanjun Guo
  Cc: Catalin Marinas, Rafael J. Wysocki, Will Deacon, Olof Johansson,
	grant.likely, Arnd Bergmann, Mark Rutland, graeme.gregory,
	Sudeep Holla, jcm, Marc Zyngier, Mark Brown, Robert Richter,
	Timur Tabi, Ashwin Chaugule, suravee.suthikulpanit, linux-acpi,
	linux-arm-kernel, linux-kernel, linaro-acpi, Liviu Dudau

On Wed, Feb 25, 2015 at 08:39:48AM +0000, Hanjun Guo wrote:

[...]

> diff --git a/arch/arm64/kernel/pci.c b/arch/arm64/kernel/pci.c
> index 6f93c24..4095379 100644
> --- a/arch/arm64/kernel/pci.c
> +++ b/arch/arm64/kernel/pci.c
> @@ -10,6 +10,7 @@
>   *
>   */
>  
> +#include <linux/acpi.h>
>  #include <linux/init.h>
>  #include <linux/io.h>
>  #include <linux/kernel.h>
> @@ -46,3 +47,27 @@ int pcibios_add_device(struct pci_dev *dev)
>  
>  	return 0;
>  }
> +
> +/*
> + * raw_pci_read/write - Platform-specific PCI config space access.
> + */
> +int raw_pci_read(unsigned int domain, unsigned int bus,
> +		  unsigned int devfn, int reg, int len, u32 *val)
> +{
> +	return -ENXIO;
> +}
> +
> +int raw_pci_write(unsigned int domain, unsigned int bus,
> +		unsigned int devfn, int reg, int len, u32 val)
> +{
> +	return -ENXIO;
> +}
> +

It would be nice to see:

https://lkml.org/lkml/2015/2/27/264

merged at the same time, so that the two functions above disappear :)

Lorenzo

^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 01/21] ACPI / table: Use pr_debug() instead of pr_info() for MADT table scanning
  2015-02-25  8:39 ` [PATCH v9 01/21] ACPI / table: Use pr_debug() instead of pr_info() for MADT table scanning Hanjun Guo
  2015-03-04 22:33   ` Rafael J. Wysocki
  2015-03-05 17:55   ` Olof Johansson
@ 2015-03-06 20:17   ` Grant Likely
  2015-03-06 20:31     ` Joe Perches
  2 siblings, 1 reply; 106+ messages in thread
From: Grant Likely @ 2015-03-06 20:17 UTC (permalink / raw)
  To: Hanjun Guo, Catalin Marinas, Rafael J. Wysocki, Will Deacon,
	Olof Johansson
  Cc: Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi, Hanjun Guo

On Wed, 25 Feb 2015 16:39:41 +0800
, Hanjun Guo <hanjun.guo@linaro.org>
 wrote:
> For a normal 8 cpu sockets system, it will up to 240 cpu threads (Xeon E7
> v2 family for now), and we need 240 entries for local apic or local x2apic
> in MADT table, so it will be much verbose information printed with a slow
> uart console when system booted, this will be even worse with large system
> with 16/32 cpu sockets.
> 
> This patch just use pr_debug() instead of pr_info() for ioapic/iosapic,
> local apic/x2apic/sapic structures when scanning the MADT table to remove
> those verbose information, but leave other structures unchanged.
> 
> CC: Rafael J Wysocki <rjw@rjwysocki.net>
> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>

One nitpick below, but don't respin over this, and don't do a fixup.

Acked-by: Grant Likely <grant.likely@linaro.org>

> ---
>  drivers/acpi/tables.c | 30 ++++++++++++++++--------------
>  1 file changed, 16 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c
> index 93b8152..f4e5b88 100644
> --- a/drivers/acpi/tables.c
> +++ b/drivers/acpi/tables.c
> @@ -23,6 +23,8 @@
>   *
>   */
>  
> +/* Uncomment next line to get verbose printout */
> +/* #define DEBUG */
>  #define pr_fmt(fmt) "ACPI: " fmt
>  
>  #include <linux/init.h>
> @@ -61,9 +63,9 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header)
>  		{
>  			struct acpi_madt_local_apic *p =
>  			    (struct acpi_madt_local_apic *)header;
> -			pr_info("LAPIC (acpi_id[0x%02x] lapic_id[0x%02x] %s)\n",
> -				p->processor_id, p->id,
> -				(p->lapic_flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled");
> +			pr_debug("LAPIC (acpi_id[0x%02x] lapic_id[0x%02x] %s)\n",
> +				 p->processor_id, p->id,
> +				 (p->lapic_flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled");

The whitespace changes makes each 1 line change into 3 line changes. In
these situations, I would chose to leave the whitespace alone to keep
the diffstat as small as possible. It makes it less likely to conflict
with other patches and easier to find context.

>  		}
>  		break;
>  
> @@ -71,9 +73,9 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header)
>  		{
>  			struct acpi_madt_local_x2apic *p =
>  			    (struct acpi_madt_local_x2apic *)header;
> -			pr_info("X2APIC (apic_id[0x%02x] uid[0x%02x] %s)\n",
> -				p->local_apic_id, p->uid,
> -				(p->lapic_flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled");
> +			pr_debug("X2APIC (apic_id[0x%02x] uid[0x%02x] %s)\n",
> +				 p->local_apic_id, p->uid,
> +				 (p->lapic_flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled");
>  		}
>  		break;
>  
> @@ -81,8 +83,8 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header)
>  		{
>  			struct acpi_madt_io_apic *p =
>  			    (struct acpi_madt_io_apic *)header;
> -			pr_info("IOAPIC (id[0x%02x] address[0x%08x] gsi_base[%d])\n",
> -				p->id, p->address, p->global_irq_base);
> +			pr_debug("IOAPIC (id[0x%02x] address[0x%08x] gsi_base[%d])\n",
> +				 p->id, p->address, p->global_irq_base);
>  		}
>  		break;
>  
> @@ -155,9 +157,9 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header)
>  		{
>  			struct acpi_madt_io_sapic *p =
>  			    (struct acpi_madt_io_sapic *)header;
> -			pr_info("IOSAPIC (id[0x%x] address[%p] gsi_base[%d])\n",
> -				p->id, (void *)(unsigned long)p->address,
> -				p->global_irq_base);
> +			pr_debug("IOSAPIC (id[0x%x] address[%p] gsi_base[%d])\n",
> +				 p->id, (void *)(unsigned long)p->address,
> +				 p->global_irq_base);
>  		}
>  		break;
>  
> @@ -165,9 +167,9 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header)
>  		{
>  			struct acpi_madt_local_sapic *p =
>  			    (struct acpi_madt_local_sapic *)header;
> -			pr_info("LSAPIC (acpi_id[0x%02x] lsapic_id[0x%02x] lsapic_eid[0x%02x] %s)\n",
> -				p->processor_id, p->id, p->eid,
> -				(p->lapic_flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled");
> +			pr_debug("LSAPIC (acpi_id[0x%02x] lsapic_id[0x%02x] lsapic_eid[0x%02x] %s)\n",
> +				 p->processor_id, p->id, p->eid,
> +				 (p->lapic_flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled");
>  		}
>  		break;
>  
> -- 
> 1.9.1
> 


^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 02/21] ACPI / processor: Introduce phys_cpuid_t for CPU hardware ID
  2015-02-25  8:39 ` [PATCH v9 02/21] ACPI / processor: Introduce phys_cpuid_t for CPU hardware ID Hanjun Guo
  2015-03-04 22:29   ` Rafael J. Wysocki
@ 2015-03-06 20:19   ` Grant Likely
  1 sibling, 0 replies; 106+ messages in thread
From: Grant Likely @ 2015-03-06 20:19 UTC (permalink / raw)
  To: Hanjun Guo, Catalin Marinas, Rafael J. Wysocki, Will Deacon,
	Olof Johansson
  Cc: Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi, Hanjun Guo

On Wed, 25 Feb 2015 16:39:42 +0800
, Hanjun Guo <hanjun.guo@linaro.org>
 wrote:
> CPU hardware ID (phys_id) is defined as u32 in structure acpi_processor,
> but phys_id is used as int in acpi processor driver, so it will lead to
> some inconsistence for the drivers.
> 
> Furthermore, to cater for ACPI arch ports that implement 64 bits CPU
> ids a generic CPU physical id type is required.
> 
> So introduce typedef u32 phys_cpuid_t for x86 and ia64, and introduce
> a macro CPU_PHYS_ID_INVALID as (u32)(-1), use phys_cpuid_t when phys_id
> defined in acpi processor driver, and replace CPU_PHYS_ID_INVALID as -1
> for phys_id, this will solve the inconsistence in acpi processor driver,
> and will prepare for the ACPI on ARM64 too.
> 
> CC: Rafael J Wysocki <rjw@rjwysocki.net>
> Suggested-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
> Acked-by: Sudeep Holla <sudeep.holla@arm.com>
> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
> [hj: reworked cpu physid map return codes]
> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>

Looks okay to me.

Reviewed-by: Grant Likely <grant.likely@linaro.org>

> ---
>  arch/ia64/include/asm/acpi.h  |  4 ++++
>  arch/ia64/kernel/acpi.c       |  2 +-
>  arch/x86/include/asm/acpi.h   |  4 ++++
>  arch/x86/kernel/acpi/boot.c   |  2 +-
>  drivers/acpi/acpi_processor.c |  7 ++++---
>  drivers/acpi/processor_core.c | 30 +++++++++++++++---------------
>  include/acpi/processor.h      |  6 +++---
>  include/linux/acpi.h          |  2 +-
>  8 files changed, 33 insertions(+), 24 deletions(-)
> 
> diff --git a/arch/ia64/include/asm/acpi.h b/arch/ia64/include/asm/acpi.h
> index a1d91ab..ca1f0e4 100644
> --- a/arch/ia64/include/asm/acpi.h
> +++ b/arch/ia64/include/asm/acpi.h
> @@ -34,6 +34,10 @@
>  #include <linux/numa.h>
>  #include <asm/numa.h>
>  
> +typedef u32 phys_cpuid_t;
> +
> +#define CPU_PHYS_ID_INVALID (u32)(-1)
> +
>  #ifdef	CONFIG_ACPI
>  extern int acpi_lapic;
>  #define acpi_disabled 0	/* ACPI always enabled on IA64 */
> diff --git a/arch/ia64/kernel/acpi.c b/arch/ia64/kernel/acpi.c
> index 2c44989..067ef44 100644
> --- a/arch/ia64/kernel/acpi.c
> +++ b/arch/ia64/kernel/acpi.c
> @@ -887,7 +887,7 @@ static int _acpi_map_lsapic(acpi_handle handle, int physid, int *pcpu)
>  }
>  
>  /* wrapper to silence section mismatch warning */
> -int __ref acpi_map_cpu(acpi_handle handle, int physid, int *pcpu)
> +int __ref acpi_map_cpu(acpi_handle handle, phys_cpuid_t physid, int *pcpu)
>  {
>  	return _acpi_map_lsapic(handle, physid, pcpu);
>  }
> diff --git a/arch/x86/include/asm/acpi.h b/arch/x86/include/asm/acpi.h
> index 3a45668..cd788dd 100644
> --- a/arch/x86/include/asm/acpi.h
> +++ b/arch/x86/include/asm/acpi.h
> @@ -32,6 +32,10 @@
>  #include <asm/mpspec.h>
>  #include <asm/realmode.h>
>  
> +typedef u32 phys_cpuid_t;
> +
> +#define CPU_PHYS_ID_INVALID (u32)(-1)
> +
>  #ifdef CONFIG_ACPI
>  extern int acpi_lapic;
>  extern int acpi_ioapic;
> diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
> index 3d525c6..e4f8582 100644
> --- a/arch/x86/kernel/acpi/boot.c
> +++ b/arch/x86/kernel/acpi/boot.c
> @@ -757,7 +757,7 @@ static int _acpi_map_lsapic(acpi_handle handle, int physid, int *pcpu)
>  }
>  
>  /* wrapper to silence section mismatch warning */
> -int __ref acpi_map_cpu(acpi_handle handle, int physid, int *pcpu)
> +int __ref acpi_map_cpu(acpi_handle handle, phys_cpuid_t physid, int *pcpu)
>  {
>  	return _acpi_map_lsapic(handle, physid, pcpu);
>  }
> diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c
> index 1020b1b..e6c7c56 100644
> --- a/drivers/acpi/acpi_processor.c
> +++ b/drivers/acpi/acpi_processor.c
> @@ -170,7 +170,7 @@ static int acpi_processor_hotadd_init(struct acpi_processor *pr)
>  	acpi_status status;
>  	int ret;
>  
> -	if (pr->phys_id == -1)
> +	if (pr->phys_id == CPU_PHYS_ID_INVALID)
>  		return -ENODEV;
>  
>  	status = acpi_evaluate_integer(pr->handle, "_STA", NULL, &sta);
> @@ -215,7 +215,8 @@ static int acpi_processor_get_info(struct acpi_device *device)
>  	union acpi_object object = { 0 };
>  	struct acpi_buffer buffer = { sizeof(union acpi_object), &object };
>  	struct acpi_processor *pr = acpi_driver_data(device);
> -	int phys_id, cpu_index, device_declaration = 0;
> +	phys_cpuid_t phys_id;
> +	int cpu_index, device_declaration = 0;
>  	acpi_status status = AE_OK;
>  	static int cpu0_initialized;
>  	unsigned long long value;
> @@ -263,7 +264,7 @@ static int acpi_processor_get_info(struct acpi_device *device)
>  	}
>  
>  	phys_id = acpi_get_phys_id(pr->handle, device_declaration, pr->acpi_id);
> -	if (phys_id < 0)
> +	if (phys_id == CPU_PHYS_ID_INVALID)
>  		acpi_handle_debug(pr->handle, "failed to get CPU physical ID.\n");
>  	pr->phys_id = phys_id;
>  
> diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c
> index 7962651..a5547dc 100644
> --- a/drivers/acpi/processor_core.c
> +++ b/drivers/acpi/processor_core.c
> @@ -32,7 +32,7 @@ static struct acpi_table_madt *get_madt_table(void)
>  }
>  
>  static int map_lapic_id(struct acpi_subtable_header *entry,
> -		 u32 acpi_id, int *apic_id)
> +		 u32 acpi_id, phys_cpuid_t *apic_id)
>  {
>  	struct acpi_madt_local_apic *lapic =
>  		container_of(entry, struct acpi_madt_local_apic, header);
> @@ -48,7 +48,7 @@ static int map_lapic_id(struct acpi_subtable_header *entry,
>  }
>  
>  static int map_x2apic_id(struct acpi_subtable_header *entry,
> -			 int device_declaration, u32 acpi_id, int *apic_id)
> +		int device_declaration, u32 acpi_id, phys_cpuid_t *apic_id)
>  {
>  	struct acpi_madt_local_x2apic *apic =
>  		container_of(entry, struct acpi_madt_local_x2apic, header);
> @@ -65,7 +65,7 @@ static int map_x2apic_id(struct acpi_subtable_header *entry,
>  }
>  
>  static int map_lsapic_id(struct acpi_subtable_header *entry,
> -		int device_declaration, u32 acpi_id, int *apic_id)
> +		int device_declaration, u32 acpi_id, phys_cpuid_t *apic_id)
>  {
>  	struct acpi_madt_local_sapic *lsapic =
>  		container_of(entry, struct acpi_madt_local_sapic, header);
> @@ -83,10 +83,10 @@ static int map_lsapic_id(struct acpi_subtable_header *entry,
>  	return 0;
>  }
>  
> -static int map_madt_entry(int type, u32 acpi_id)
> +static phys_cpuid_t map_madt_entry(int type, u32 acpi_id)
>  {
>  	unsigned long madt_end, entry;
> -	int phys_id = -1;	/* CPU hardware ID */
> +	phys_cpuid_t phys_id = CPU_PHYS_ID_INVALID;	/* CPU hardware ID */
>  	struct acpi_table_madt *madt;
>  
>  	madt = get_madt_table();
> @@ -117,12 +117,12 @@ static int map_madt_entry(int type, u32 acpi_id)
>  	return phys_id;
>  }
>  
> -static int map_mat_entry(acpi_handle handle, int type, u32 acpi_id)
> +static phys_cpuid_t map_mat_entry(acpi_handle handle, int type, u32 acpi_id)
>  {
>  	struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
>  	union acpi_object *obj;
>  	struct acpi_subtable_header *header;
> -	int phys_id = -1;
> +	phys_cpuid_t phys_id = CPU_PHYS_ID_INVALID;
>  
>  	if (ACPI_FAILURE(acpi_evaluate_object(handle, "_MAT", NULL, &buffer)))
>  		goto exit;
> @@ -149,27 +149,27 @@ exit:
>  	return phys_id;
>  }
>  
> -int acpi_get_phys_id(acpi_handle handle, int type, u32 acpi_id)
> +phys_cpuid_t acpi_get_phys_id(acpi_handle handle, int type, u32 acpi_id)
>  {
> -	int phys_id;
> +	phys_cpuid_t phys_id;
>  
>  	phys_id = map_mat_entry(handle, type, acpi_id);
> -	if (phys_id == -1)
> +	if (phys_id == CPU_PHYS_ID_INVALID)
>  		phys_id = map_madt_entry(type, acpi_id);
>  
>  	return phys_id;
>  }
>  
> -int acpi_map_cpuid(int phys_id, u32 acpi_id)
> +int acpi_map_cpuid(phys_cpuid_t phys_id, u32 acpi_id)
>  {
>  #ifdef CONFIG_SMP
>  	int i;
>  #endif
>  
> -	if (phys_id == -1) {
> +	if (phys_id == CPU_PHYS_ID_INVALID) {
>  		/*
>  		 * On UP processor, there is no _MAT or MADT table.
> -		 * So above phys_id is always set to -1.
> +		 * So above phys_id is always set to CPU_PHYS_ID_INVALID.
>  		 *
>  		 * BIOS may define multiple CPU handles even for UP processor.
>  		 * For example,
> @@ -190,7 +190,7 @@ int acpi_map_cpuid(int phys_id, u32 acpi_id)
>  		if (nr_cpu_ids <= 1 && acpi_id == 0)
>  			return acpi_id;
>  		else
> -			return phys_id;
> +			return -1;
>  	}
>  
>  #ifdef CONFIG_SMP
> @@ -208,7 +208,7 @@ int acpi_map_cpuid(int phys_id, u32 acpi_id)
>  
>  int acpi_get_cpuid(acpi_handle handle, int type, u32 acpi_id)
>  {
> -	int phys_id;
> +	phys_cpuid_t phys_id;
>  
>  	phys_id = acpi_get_phys_id(handle, type, acpi_id);
>  
> diff --git a/include/acpi/processor.h b/include/acpi/processor.h
> index b95dc32..4188a4d 100644
> --- a/include/acpi/processor.h
> +++ b/include/acpi/processor.h
> @@ -196,7 +196,7 @@ struct acpi_processor_flags {
>  struct acpi_processor {
>  	acpi_handle handle;
>  	u32 acpi_id;
> -	u32 phys_id;	/* CPU hardware ID such as APIC ID for x86 */
> +	phys_cpuid_t phys_id;	/* CPU hardware ID such as APIC ID for x86 */
>  	u32 id;		/* CPU logical ID allocated by OS */
>  	u32 pblk;
>  	int performance_platform_limit;
> @@ -310,8 +310,8 @@ static inline int acpi_processor_get_bios_limit(int cpu, unsigned int *limit)
>  #endif				/* CONFIG_CPU_FREQ */
>  
>  /* in processor_core.c */
> -int acpi_get_phys_id(acpi_handle, int type, u32 acpi_id);
> -int acpi_map_cpuid(int phys_id, u32 acpi_id);
> +phys_cpuid_t acpi_get_phys_id(acpi_handle, int type, u32 acpi_id);
> +int acpi_map_cpuid(phys_cpuid_t phys_id, u32 acpi_id);
>  int acpi_get_cpuid(acpi_handle, int type, u32 acpi_id);
>  
>  /* in processor_pdc.c */
> diff --git a/include/linux/acpi.h b/include/linux/acpi.h
> index 24c7aa8..0eabd15 100644
> --- a/include/linux/acpi.h
> +++ b/include/linux/acpi.h
> @@ -148,7 +148,7 @@ void acpi_numa_arch_fixup(void);
>  
>  #ifdef CONFIG_ACPI_HOTPLUG_CPU
>  /* Arch dependent functions for cpu hotplug support */
> -int acpi_map_cpu(acpi_handle handle, int physid, int *pcpu);
> +int acpi_map_cpu(acpi_handle handle, phys_cpuid_t physid, int *pcpu);
>  int acpi_unmap_cpu(int cpu);
>  #endif /* CONFIG_ACPI_HOTPLUG_CPU */
>  
> -- 
> 1.9.1
> 


^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 03/21] ACPI: add arm64 to the platforms that use ioremap
  2015-02-25  8:39 ` [PATCH v9 03/21] ACPI: add arm64 to the platforms that use ioremap Hanjun Guo
  2015-03-04 22:33   ` Rafael J. Wysocki
@ 2015-03-06 20:20   ` Grant Likely
  1 sibling, 0 replies; 106+ messages in thread
From: Grant Likely @ 2015-03-06 20:20 UTC (permalink / raw)
  To: Hanjun Guo, Catalin Marinas, Rafael J. Wysocki, Will Deacon,
	Olof Johansson
  Cc: Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi, Al Stone, Hanjun Guo

On Wed, 25 Feb 2015 16:39:43 +0800
, Hanjun Guo <hanjun.guo@linaro.org>
 wrote:
> From: Graeme Gregory <graeme.gregory@linaro.org>
> 
> Now with the base changes to the arm memory mapping it is safe
> to convert to using ioremap to map in the tables after
> acpi_gbl_permanent_mmap is set.
> 
> CC: Rafael J Wysocki <rjw@rjwysocki.net>
> Tested-by: Robert Richter <rrichter@cavium.com>
> Acked-by: Robert Richter <rrichter@cavium.com>
> Signed-off-by: Al Stone <al.stone@linaro.org>
> Signed-off-by: Graeme Gregory <graeme.gregory@linaro.org>
> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>

LGTM.

Reviewed-by: Grant Likely <grant.likely@linaro.org>

> ---
>  drivers/acpi/osl.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
> index f9eeae8..39748bb 100644
> --- a/drivers/acpi/osl.c
> +++ b/drivers/acpi/osl.c
> @@ -336,11 +336,11 @@ acpi_map_lookup_virt(void __iomem *virt, acpi_size size)
>  	return NULL;
>  }
>  
> -#ifndef CONFIG_IA64
> -#define should_use_kmap(pfn)   page_is_ram(pfn)
> -#else
> +#if defined(CONFIG_IA64) || defined(CONFIG_ARM64)
>  /* ioremap will take care of cache attributes */
>  #define should_use_kmap(pfn)   0
> +#else
> +#define should_use_kmap(pfn)   page_is_ram(pfn)
>  #endif
>  
>  static void __iomem *acpi_map(acpi_physical_address pg_off, unsigned long pg_sz)
> -- 
> 1.9.1
> 


^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 04/21] ARM64: allow late use of early_ioremap
  2015-02-25  8:39 ` [PATCH v9 04/21] ARM64: allow late use of early_ioremap Hanjun Guo
@ 2015-03-06 20:24   ` Grant Likely
  0 siblings, 0 replies; 106+ messages in thread
From: Grant Likely @ 2015-03-06 20:24 UTC (permalink / raw)
  To: Hanjun Guo, Catalin Marinas, Rafael J. Wysocki, Will Deacon,
	Olof Johansson
  Cc: Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi, Mark Salter, Leif Lindholm,
	Ard Biesheuvel, Hanjun Guo

On Wed, 25 Feb 2015 16:39:44 +0800
, Hanjun Guo <hanjun.guo@linaro.org>
 wrote:
> From: Mark Salter <msalter@redhat.com>
> 
> Commit 0e63ea48b4d8 (arm64/efi: add missing call to early_ioremap_reset())
> added a missing call to early_ioremap_reset(). This triggers a BUG if code
> tries using early_ioremap() after the early_ioremap_reset(). This is a
> problem for some ACPI code which needs short-lived temporary mappings
> after paging_init() but before acpi_early_init() in start_kernel(). This
> patch adds definitions for the __late_set_fixmap() and __late_clear_fixmap()
> which avoids the BUG by allowing later use of early_ioremap().
> 
> CC: Leif Lindholm <leif.lindholm@linaro.org>
> CC: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> Tested-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
> Tested-by: Mark Langsdorf <mlangsdo@redhat.com>
> Tested-by: Jon Masters <jcm@redhat.com>
> Tested-by: Robert Richter <rrichter@cavium.com>
> Acked-by: Robert Richter <rrichter@cavium.com>
> Signed-off-by: Mark Salter <msalter@redhat.com>
> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>

Reviewed-by: Grant Likely <grant.likely@linaro.org>

> ---
>  arch/arm64/include/asm/fixmap.h | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/arch/arm64/include/asm/fixmap.h b/arch/arm64/include/asm/fixmap.h
> index defa0ff9..f196e40 100644
> --- a/arch/arm64/include/asm/fixmap.h
> +++ b/arch/arm64/include/asm/fixmap.h
> @@ -62,6 +62,9 @@ void __init early_fixmap_init(void);
>  
>  #define __early_set_fixmap __set_fixmap
>  
> +#define __late_set_fixmap __set_fixmap
> +#define __late_clear_fixmap(idx) __set_fixmap((idx), 0, FIXMAP_PAGE_CLEAR)
> +
>  extern void __set_fixmap(enum fixed_addresses idx, phys_addr_t phys, pgprot_t prot);
>  
>  #include <asm-generic/fixmap.h>
> -- 
> 1.9.1
> 


^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 05/21] ARM64 / ACPI: Get RSDP and ACPI boot-time tables
  2015-02-25  8:39 ` [PATCH v9 05/21] ARM64 / ACPI: Get RSDP and ACPI boot-time tables Hanjun Guo
  2015-03-05 18:10   ` Olof Johansson
  2015-03-05 18:51   ` Lorenzo Pieralisi
@ 2015-03-06 20:28   ` Grant Likely
  2 siblings, 0 replies; 106+ messages in thread
From: Grant Likely @ 2015-03-06 20:28 UTC (permalink / raw)
  To: Hanjun Guo, Catalin Marinas, Rafael J. Wysocki, Will Deacon,
	Olof Johansson
  Cc: Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi, Al Stone, Lorenzo Pieralisi,
	Tomasz Nowicki, Hanjun Guo

On Wed, 25 Feb 2015 16:39:45 +0800
, Hanjun Guo <hanjun.guo@linaro.org>
 wrote:
> From: Al Stone <al.stone@linaro.org>
> 
> As we want to get ACPI tables to parse and then use the information
> for system initialization, we should get the RSDP (Root System
> Description Pointer) first, it then locates Extended Root Description
> Table (XSDT) which contains all the 64-bit physical address that
> pointer to other boot-time tables.
> 
> Introduce acpi.c and its related head file in this patch to provide
> fundamental needs of extern variables and functions for ACPI core,
> and then get boot-time tables as needed.
>   - asm/acenv.h for arch specific ACPICA environments and
>     implementation, It is needed unconditionally by ACPI core;
>   - asm/acpi.h for arch specific variables and functions needed by
>     ACPI driver core;
>   - acpi.c for ARM64 related ACPI implementation for ACPI driver
>     core;
> 
> acpi_boot_table_init() is introduced to get RSDP and boot-time tables,
> it will be called in setup_arch() before paging_init(), so we should
> use eary_memremap() mechanism here to get the RSDP and all the table
> pointers.
> 
> FADT Major.Minor version was introduced in ACPI 5.1, it is the same
> as ACPI version.
> 
> In ACPI 5.1, some major gaps are fixed for ARM, such as updates in
> MADT table for GIC and SMP init, without those updates, we can not
> get the MPIDR for SMP init, and GICv2/3 related init information, so
> we can't boot arm64 ACPI properly with table versions predating 5.1.
> 
> If firmware provides ACPI tables with ACPI version less than 5.1,
> OS has no way to retrieve the configuration data that is necessary
> to init SMP boot protocol and the GIC properly, so disable ACPI if
> we get an FADT table with version less that 5.1 when acpi_boot_table_init()
> called.
> 
> CC: Catalin Marinas <catalin.marinas@arm.com>
> CC: Will Deacon <will.deacon@arm.com>
> CC: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
> Tested-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
> Tested-by: Yijing Wang <wangyijing@huawei.com>
> Tested-by: Mark Langsdorf <mlangsdo@redhat.com>
> Tested-by: Jon Masters <jcm@redhat.com>
> Tested-by: Timur Tabi <timur@codeaurora.org>
> Tested-by: Robert Richter <rrichter@cavium.com>
> Acked-by: Robert Richter <rrichter@cavium.com>
> Signed-off-by: Al Stone <al.stone@linaro.org>
> Signed-off-by: Graeme Gregory <graeme.gregory@linaro.org>
> Signed-off-by: Tomasz Nowicki <tomasz.nowicki@linaro.org>
> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>

Acked-by: Grant Likely <grant.likely@linaro.org>

> ---
>  arch/arm64/include/asm/acenv.h |  18 ++++++++
>  arch/arm64/include/asm/acpi.h  |  45 ++++++++++++++++++
>  arch/arm64/kernel/Makefile     |   1 +
>  arch/arm64/kernel/acpi.c       | 101 +++++++++++++++++++++++++++++++++++++++++
>  arch/arm64/kernel/setup.c      |   5 ++
>  5 files changed, 170 insertions(+)
>  create mode 100644 arch/arm64/include/asm/acenv.h
>  create mode 100644 arch/arm64/include/asm/acpi.h
>  create mode 100644 arch/arm64/kernel/acpi.c
> 
> diff --git a/arch/arm64/include/asm/acenv.h b/arch/arm64/include/asm/acenv.h
> new file mode 100644
> index 0000000..b49166f
> --- /dev/null
> +++ b/arch/arm64/include/asm/acenv.h
> @@ -0,0 +1,18 @@
> +/*
> + * ARM64 specific ACPICA environments and implementation
> + *
> + * Copyright (C) 2014, Linaro Ltd.
> + *   Author: Hanjun Guo <hanjun.guo@linaro.org>
> + *   Author: Graeme Gregory <graeme.gregory@linaro.org>
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + */
> +
> +#ifndef _ASM_ACENV_H
> +#define _ASM_ACENV_H
> +
> +/* It is required unconditionally by ACPI core, update it when needed. */
> +
> +#endif /* _ASM_ACENV_H */
> diff --git a/arch/arm64/include/asm/acpi.h b/arch/arm64/include/asm/acpi.h
> new file mode 100644
> index 0000000..8b837ab
> --- /dev/null
> +++ b/arch/arm64/include/asm/acpi.h
> @@ -0,0 +1,45 @@
> +/*
> + *  Copyright (C) 2013-2014, Linaro Ltd.
> + *	Author: Al Stone <al.stone@linaro.org>
> + *	Author: Graeme Gregory <graeme.gregory@linaro.org>
> + *	Author: Hanjun Guo <hanjun.guo@linaro.org>
> + *
> + *  This program is free software; you can redistribute it and/or modify
> + *  it under the terms of the GNU General Public License version 2 as
> + *  published by the Free Software Foundation;
> + */
> +
> +#ifndef _ASM_ACPI_H
> +#define _ASM_ACPI_H
> +
> +/* Basic configuration for ACPI */
> +#ifdef	CONFIG_ACPI
> +#define acpi_strict 1	/* No out-of-spec workarounds on ARM64 */
> +extern int acpi_disabled;
> +extern int acpi_noirq;
> +extern int acpi_pci_disabled;
> +
> +static inline void disable_acpi(void)
> +{
> +	acpi_disabled = 1;
> +	acpi_pci_disabled = 1;
> +	acpi_noirq = 1;
> +}
> +
> +/*
> + * It's used from ACPI core in kdump to boot UP system with SMP kernel,
> + * with this check the ACPI core will not override the CPU index
> + * obtained from GICC with 0 and not print some error message as well.
> + * Since MADT must provide at least one GICC structure for GIC
> + * initialization, CPU will be always available in MADT on ARM64.
> + */
> +static inline bool acpi_has_cpu_in_madt(void)
> +{
> +	return true;
> +}
> +
> +static inline void arch_fix_phys_package_id(int num, u32 slot) { }
> +
> +#endif /* CONFIG_ACPI */
> +
> +#endif /*_ASM_ACPI_H*/
> diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile
> index bef04af..218eb7e 100644
> --- a/arch/arm64/kernel/Makefile
> +++ b/arch/arm64/kernel/Makefile
> @@ -34,6 +34,7 @@ arm64-obj-$(CONFIG_KGDB)		+= kgdb.o
>  arm64-obj-$(CONFIG_EFI)			+= efi.o efi-stub.o efi-entry.o
>  arm64-obj-$(CONFIG_PCI)			+= pci.o
>  arm64-obj-$(CONFIG_ARMV8_DEPRECATED)	+= armv8_deprecated.o
> +arm64-obj-$(CONFIG_ACPI)		+= acpi.o
>  
>  obj-y					+= $(arm64-obj-y) vdso/
>  obj-m					+= $(arm64-obj-m)
> diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c
> new file mode 100644
> index 0000000..f052e7a
> --- /dev/null
> +++ b/arch/arm64/kernel/acpi.c
> @@ -0,0 +1,101 @@
> +/*
> + *  ARM64 Specific Low-Level ACPI Boot Support
> + *
> + *  Copyright (C) 2013-2014, Linaro Ltd.
> + *	Author: Al Stone <al.stone@linaro.org>
> + *	Author: Graeme Gregory <graeme.gregory@linaro.org>
> + *	Author: Hanjun Guo <hanjun.guo@linaro.org>
> + *	Author: Tomasz Nowicki <tomasz.nowicki@linaro.org>
> + *	Author: Naresh Bhat <naresh.bhat@linaro.org>
> + *
> + *  This program is free software; you can redistribute it and/or modify
> + *  it under the terms of the GNU General Public License version 2 as
> + *  published by the Free Software Foundation.
> + */
> +
> +#define pr_fmt(fmt) "ACPI: " fmt
> +
> +#include <linux/acpi.h>
> +#include <linux/bootmem.h>
> +#include <linux/cpumask.h>
> +#include <linux/init.h>
> +#include <linux/irq.h>
> +#include <linux/irqdomain.h>
> +#include <linux/memblock.h>
> +#include <linux/smp.h>
> +
> +int acpi_noirq;			/* skip ACPI IRQ initialization */
> +int acpi_disabled;
> +EXPORT_SYMBOL(acpi_disabled);
> +
> +int acpi_pci_disabled;		/* skip ACPI PCI scan and IRQ initialization */
> +EXPORT_SYMBOL(acpi_pci_disabled);
> +
> +/*
> + * __acpi_map_table() will be called before page_init(), so early_ioremap()
> + * or early_memremap() should be called here to for ACPI table mapping.
> + */
> +char *__init __acpi_map_table(unsigned long phys, unsigned long size)
> +{
> +	if (!phys || !size)
> +		return NULL;
> +
> +	return early_memremap(phys, size);
> +}
> +
> +void __init __acpi_unmap_table(char *map, unsigned long size)
> +{
> +	if (!map || !size)
> +		return;
> +
> +	early_memunmap(map, size);
> +}
> +
> +static int __init acpi_parse_fadt(struct acpi_table_header *table)
> +{
> +	struct acpi_table_fadt *fadt = (struct acpi_table_fadt *)table;
> +
> +	/*
> +	 * Revision in table header is the FADT Major revision, and there
> +	 * is a minor revision of FADT which was introduced by ACPI 5.1,
> +	 * we only deal with ACPI 5.1 or newer revision to get GIC and SMP
> +	 * boot protocol configuration data, or we will disable ACPI.
> +	 */
> +	if (table->revision > 5 ||
> +	    (table->revision == 5 && fadt->minor_revision >= 1))
> +		return 0;
> +
> +	pr_warn("Unsupported FADT revision %d.%d, should be 5.1+, will disable ACPI\n",
> +		table->revision, fadt->minor_revision);
> +	disable_acpi();
> +
> +	return -EINVAL;
> +}
> +
> +/*
> + * acpi_boot_table_init() called from setup_arch(), always.
> + *	1. find RSDP and get its address, and then find XSDT
> + *	2. extract all tables and checksums them all
> + *	3. check ACPI FADT revision
> + *
> + * We can parse ACPI boot-time tables such as MADT after
> + * this function is called.
> + */
> +void __init acpi_boot_table_init(void)
> +{
> +	/* If acpi_disabled, bail out */
> +	if (acpi_disabled)
> +		return;
> +
> +	/* Initialize the ACPI boot-time table parser. */
> +	if (acpi_table_init()) {
> +		disable_acpi();
> +		return;
> +	}
> +
> +	if (acpi_table_parse(ACPI_SIG_FADT, acpi_parse_fadt)) {
> +		/* disable ACPI if no FADT is found */
> +		disable_acpi();
> +		pr_err("Can't find FADT\n");
> +	}
> +}
> diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
> index e8420f6..4f1a014 100644
> --- a/arch/arm64/kernel/setup.c
> +++ b/arch/arm64/kernel/setup.c
> @@ -17,6 +17,7 @@
>   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
>   */
>  
> +#include <linux/acpi.h>
>  #include <linux/export.h>
>  #include <linux/kernel.h>
>  #include <linux/stddef.h>
> @@ -46,6 +47,7 @@
>  #include <linux/efi.h>
>  #include <linux/personality.h>
>  
> +#include <asm/acpi.h>
>  #include <asm/fixmap.h>
>  #include <asm/cpu.h>
>  #include <asm/cputype.h>
> @@ -380,6 +382,9 @@ void __init setup_arch(char **cmdline_p)
>  	efi_init();
>  	arm64_memblock_init();
>  
> +	/* Parse the ACPI tables for possible boot-time configuration */
> +	acpi_boot_table_init();
> +
>  	paging_init();
>  	request_standard_resources();
>  
> -- 
> 1.9.1
> 


^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 06/21] ACPI: fix acpi_os_ioremap for arm64
  2015-02-25  8:39 ` [PATCH v9 06/21] ACPI: fix acpi_os_ioremap for arm64 Hanjun Guo
  2015-03-04 22:36   ` Rafael J. Wysocki
@ 2015-03-06 20:30   ` Grant Likely
  1 sibling, 0 replies; 106+ messages in thread
From: Grant Likely @ 2015-03-06 20:30 UTC (permalink / raw)
  To: Hanjun Guo, Catalin Marinas, Rafael J. Wysocki, Will Deacon,
	Olof Johansson
  Cc: Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi, Mark Salter, Hanjun Guo

On Wed, 25 Feb 2015 16:39:46 +0800
, Hanjun Guo <hanjun.guo@linaro.org>
 wrote:
> From: Mark Salter <msalter@redhat.com>
> 
> The acpi_os_ioremap() function may be used to map normal RAM or IO
> regions. The current implementation simply uses ioremap_cache(). This
> will work for some architectures, but arm64 ioremap_cache() cannot be
> used to map IO regions which don't support caching. So for arm64, use
> ioremap() for non-RAM regions.
> 
> CC: Rafael J Wysocki <rjw@rjwysocki.net>
> CC: Catalin Marinas <catalin.marinas@arm.com>
> Tested-by: Robert Richter <rrichter@cavium.com>
> Acked-by: Robert Richter <rrichter@cavium.com>
> Signed-off-by: Mark Salter <msalter@redhat.com>
> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>

Reviewed-by: Grant Likely <grant.likely@linaro.org>

> ---
>  arch/arm64/include/asm/acpi.h | 13 +++++++++++++
>  include/acpi/acpi_io.h        |  4 ++++
>  2 files changed, 17 insertions(+)
> 
> diff --git a/arch/arm64/include/asm/acpi.h b/arch/arm64/include/asm/acpi.h
> index 8b837ab..40e0924 100644
> --- a/arch/arm64/include/asm/acpi.h
> +++ b/arch/arm64/include/asm/acpi.h
> @@ -12,8 +12,21 @@
>  #ifndef _ASM_ACPI_H
>  #define _ASM_ACPI_H
>  
> +#include <linux/mm.h>
> +
>  /* Basic configuration for ACPI */
>  #ifdef	CONFIG_ACPI
> +/* ACPI table mapping after acpi_gbl_permanent_mmap is set */
> +static inline void __iomem *acpi_os_ioremap(acpi_physical_address phys,
> +					    acpi_size size)
> +{
> +	if (!page_is_ram(phys >> PAGE_SHIFT))
> +		return ioremap(phys, size);
> +
> +	return ioremap_cache(phys, size);
> +}
> +#define acpi_os_ioremap acpi_os_ioremap
> +
>  #define acpi_strict 1	/* No out-of-spec workarounds on ARM64 */
>  extern int acpi_disabled;
>  extern int acpi_noirq;
> diff --git a/include/acpi/acpi_io.h b/include/acpi/acpi_io.h
> index 444671e..dd86c5f 100644
> --- a/include/acpi/acpi_io.h
> +++ b/include/acpi/acpi_io.h
> @@ -3,11 +3,15 @@
>  
>  #include <linux/io.h>
>  
> +#include <asm/acpi.h>
> +
> +#ifndef acpi_os_ioremap
>  static inline void __iomem *acpi_os_ioremap(acpi_physical_address phys,
>  					    acpi_size size)
>  {
>         return ioremap_cache(phys, size);
>  }
> +#endif
>  
>  void __iomem *__init_refok
>  acpi_os_map_iomem(acpi_physical_address phys, acpi_size size);
> -- 
> 1.9.1
> 


^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 01/21] ACPI / table: Use pr_debug() instead of pr_info() for MADT table scanning
  2015-03-06 20:17   ` Grant Likely
@ 2015-03-06 20:31     ` Joe Perches
  2015-03-10  2:35       ` Hanjun Guo
  0 siblings, 1 reply; 106+ messages in thread
From: Joe Perches @ 2015-03-06 20:31 UTC (permalink / raw)
  To: Grant Likely
  Cc: Hanjun Guo, Catalin Marinas, Rafael J. Wysocki, Will Deacon,
	Olof Johansson, Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland,
	Graeme Gregory, Sudeep Holla, Jon Masters, Marc Zyngier,
	Mark Brown, Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi

On Fri, 2015-03-06 at 20:17 +0000, Grant Likely wrote:
> On Wed, 25 Feb 2015 16:39:41 +0800 Hanjun Guo <hanjun.guo@linaro.org> wrote:
> > This patch just use pr_debug() instead of pr_info() for ioapic/iosapic,
> > local apic/x2apic/sapic structures when scanning the MADT table to remove
> > those verbose information, but leave other structures unchanged.
[]
> One nitpick below, but don't respin over this, and don't do a fixup.
[]
> > diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c
[]
> > @@ -61,9 +63,9 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header)
> >  		{
> >  			struct acpi_madt_local_apic *p =
> >  			    (struct acpi_madt_local_apic *)header;
> > -			pr_info("LAPIC (acpi_id[0x%02x] lapic_id[0x%02x] %s)\n",
> > -				p->processor_id, p->id,
> > -				(p->lapic_flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled");
> > +			pr_debug("LAPIC (acpi_id[0x%02x] lapic_id[0x%02x] %s)\n",
> > +				 p->processor_id, p->id,
> > +				 (p->lapic_flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled");
> 
> The whitespace changes makes each 1 line change into 3 line changes. In
> these situations, I would chose to leave the whitespace alone to keep
> the diffstat as small as possible. It makes it less likely to conflict
> with other patches and easier to find context.

I think it's mostly better to use a consistent indentation style
regardless of the number in whitespace changes surrounding the change.



^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 07/21] ACPI / sleep: Introduce arm64 specific acpi_sleep.c
  2015-02-25  8:39 ` [PATCH v9 07/21] ACPI / sleep: Introduce arm64 specific acpi_sleep.c Hanjun Guo
  2015-03-04 22:38   ` Rafael J. Wysocki
@ 2015-03-06 20:34   ` Grant Likely
  1 sibling, 0 replies; 106+ messages in thread
From: Grant Likely @ 2015-03-06 20:34 UTC (permalink / raw)
  To: Hanjun Guo, Catalin Marinas, Rafael J. Wysocki, Will Deacon,
	Olof Johansson
  Cc: Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi, Tomasz Nowicki, Hanjun Guo

On Wed, 25 Feb 2015 16:39:47 +0800
, Hanjun Guo <hanjun.guo@linaro.org>
 wrote:
> From: Graeme Gregory <graeme.gregory@linaro.org>
> 
> ACPI 5.1 does not currently support S states for ARM64 hardware but
> ACPI code will call acpi_target_system_state() for device power
> management, so introduce acpi_sleep.c to allow other drivers to function
> until S states are defined.
> 
> Since it is arm64 specific stub holder, so let acpi_sleep.c to ARM64
> specific.
> 
> TODO: merge this with drivers/acpi/sleep.c once we fix the specification.
> 
> CC: Rafael J. Wysocki <rjw@rjwysocki.net>
> Tested-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
> Tested-by: Yijing Wang <wangyijing@huawei.com>
> Tested-by: Mark Langsdorf <mlangsdo@redhat.com>
> Tested-by: Jon Masters <jcm@redhat.com>
> Tested-by: Timur Tabi <timur@codeaurora.org>
> Tested-by: Robert Richter <rrichter@cavium.com>
> Acked-by: Robert Richter <rrichter@cavium.com>
> Signed-off-by: Graeme Gregory <graeme.gregory@linaro.org>
> Signed-off-by: Tomasz Nowicki <tomasz.nowicki@linaro.org>
> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
> ---
>  arch/arm64/kernel/Makefile     |  2 +-
>  arch/arm64/kernel/acpi_sleep.c | 28 ++++++++++++++++++++++++++++
>  drivers/acpi/Makefile          |  2 ++
>  3 files changed, 31 insertions(+), 1 deletion(-)
>  create mode 100644 arch/arm64/kernel/acpi_sleep.c
> 
> diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile
> index 218eb7e..4435943 100644
> --- a/arch/arm64/kernel/Makefile
> +++ b/arch/arm64/kernel/Makefile
> @@ -34,7 +34,7 @@ arm64-obj-$(CONFIG_KGDB)		+= kgdb.o
>  arm64-obj-$(CONFIG_EFI)			+= efi.o efi-stub.o efi-entry.o
>  arm64-obj-$(CONFIG_PCI)			+= pci.o
>  arm64-obj-$(CONFIG_ARMV8_DEPRECATED)	+= armv8_deprecated.o
> -arm64-obj-$(CONFIG_ACPI)		+= acpi.o
> +arm64-obj-$(CONFIG_ACPI)		+= acpi.o acpi_sleep.o
>  
>  obj-y					+= $(arm64-obj-y) vdso/
>  obj-m					+= $(arm64-obj-m)
> diff --git a/arch/arm64/kernel/acpi_sleep.c b/arch/arm64/kernel/acpi_sleep.c
> new file mode 100644
> index 0000000..54578ef
> --- /dev/null
> +++ b/arch/arm64/kernel/acpi_sleep.c
> @@ -0,0 +1,28 @@
> +/*
> + *  ARM64 Specific Sleep Functionality
> + *
> + *  Copyright (C) 2013-2014, Linaro Ltd.
> + *      Author: Graeme Gregory <graeme.gregory@linaro.org>
> + *
> + *  This program is free software; you can redistribute it and/or modify
> + *  it under the terms of the GNU General Public License version 2 as
> + *  published by the Free Software Foundation.
> + */
> +
> +#include <linux/acpi.h>
> +
> +/*
> + * Currently the ACPI 5.1 standard does not define S states in a
> + * manner which is usable for ARM64. These two stubs are sufficient
> + * that system initialises and device PM works.
> + */
> +u32 acpi_target_system_state(void)
> +{
> +	return ACPI_STATE_S0;
> +}
> +EXPORT_SYMBOL_GPL(acpi_target_system_state);
> +
> +int __init acpi_sleep_init(void)
> +{
> +	return -ENOSYS;
> +}
> diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
> index 623b117..c32edf5 100644
> --- a/drivers/acpi/Makefile
> +++ b/drivers/acpi/Makefile
> @@ -23,7 +23,9 @@ acpi-y				+= nvs.o
>  
>  # Power management related files
>  acpi-y				+= wakeup.o
> +ifneq (,$(findstring $(ARCH),x86 ia64))
>  acpi-y				+= sleep.o
> +endif

I think this is the typical way of doing the above in kernel makefiles:

+ifeq ($(CONFIG_X86),y)
 acpi-y				+= sleep.o
+endif

g.


^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 08/21] ARM64 / ACPI: Introduce PCI stub functions for ACPI
  2015-02-25  8:39 ` [PATCH v9 08/21] ARM64 / ACPI: Introduce PCI stub functions for ACPI Hanjun Guo
  2015-03-06 18:31   ` Lorenzo Pieralisi
@ 2015-03-06 20:36   ` Grant Likely
  2015-03-09 15:01   ` Liviu Dudau
  2 siblings, 0 replies; 106+ messages in thread
From: Grant Likely @ 2015-03-06 20:36 UTC (permalink / raw)
  To: Hanjun Guo, Catalin Marinas, Rafael J. Wysocki, Will Deacon,
	Olof Johansson
  Cc: Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi, Hanjun Guo, Liviu Dudau

On Wed, 25 Feb 2015 16:39:48 +0800
, Hanjun Guo <hanjun.guo@linaro.org>
 wrote:
> CONFIG_ACPI depends CONFIG_PCI on x86 and ia64, in ARM64 server
> world we will have PCIe in most cases, but some of them may not,
> make CONFIG_ACPI depend CONFIG_PCI on ARM64 will satisfy both.
> 
> With that case, we need some arch dependent PCI functions to
> access the config space before the PCI root bridge is created, and
> pci_acpi_scan_root() to create the PCI root bus. So introduce
> some stub function here to make ACPI core compile and revisit
> them later when implemented on ARM64.
> 
> CC: Liviu Dudau <Liviu.Dudau@arm.com>
> CC: Catalin Marinas <catalin.marinas@arm.com>
> CC: Will Deacon <will.deacon@arm.com>
> Tested-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
> Tested-by: Yijing Wang <wangyijing@huawei.com>
> Tested-by: Mark Langsdorf <mlangsdo@redhat.com>
> Tested-by: Jon Masters <jcm@redhat.com>
> Tested-by: Timur Tabi <timur@codeaurora.org>
> Tested-by: Robert Richter <rrichter@cavium.com>
> Acked-by: Robert Richter <rrichter@cavium.com>
> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>

Reviewed-by: Grant Likely <grant.likely@linaro.org>

> ---
>  arch/arm64/include/asm/pci.h |  6 ++++++
>  arch/arm64/kernel/pci.c      | 25 +++++++++++++++++++++++++
>  2 files changed, 31 insertions(+)
> 
> diff --git a/arch/arm64/include/asm/pci.h b/arch/arm64/include/asm/pci.h
> index 872ba93..fded096 100644
> --- a/arch/arm64/include/asm/pci.h
> +++ b/arch/arm64/include/asm/pci.h
> @@ -24,6 +24,12 @@
>   */
>  #define PCI_DMA_BUS_IS_PHYS	(0)
>  
> +static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
> +{
> +	/* no legacy IRQ on arm64 */
> +	return -ENODEV;
> +}
> +
>  extern int isa_dma_bridge_buggy;
>  
>  #ifdef CONFIG_PCI
> diff --git a/arch/arm64/kernel/pci.c b/arch/arm64/kernel/pci.c
> index 6f93c24..4095379 100644
> --- a/arch/arm64/kernel/pci.c
> +++ b/arch/arm64/kernel/pci.c
> @@ -10,6 +10,7 @@
>   *
>   */
>  
> +#include <linux/acpi.h>
>  #include <linux/init.h>
>  #include <linux/io.h>
>  #include <linux/kernel.h>
> @@ -46,3 +47,27 @@ int pcibios_add_device(struct pci_dev *dev)
>  
>  	return 0;
>  }
> +
> +/*
> + * raw_pci_read/write - Platform-specific PCI config space access.
> + */
> +int raw_pci_read(unsigned int domain, unsigned int bus,
> +		  unsigned int devfn, int reg, int len, u32 *val)
> +{
> +	return -ENXIO;
> +}
> +
> +int raw_pci_write(unsigned int domain, unsigned int bus,
> +		unsigned int devfn, int reg, int len, u32 val)
> +{
> +	return -ENXIO;
> +}
> +
> +#ifdef CONFIG_ACPI
> +/* Root bridge scanning */
> +struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
> +{
> +	/* TODO: Should be revisited when implementing PCI on ACPI */
> +	return NULL;
> +}
> +#endif
> -- 
> 1.9.1
> 


^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 09/21] ARM64 / ACPI: Introduce early_param "acpi=" to enable/disable ACPI
  2015-02-25  8:39 ` [PATCH v9 09/21] ARM64 / ACPI: Introduce early_param "acpi=" to enable/disable ACPI Hanjun Guo
  2015-03-05 18:11   ` Olof Johansson
@ 2015-03-06 20:37   ` Grant Likely
  1 sibling, 0 replies; 106+ messages in thread
From: Grant Likely @ 2015-03-06 20:37 UTC (permalink / raw)
  To: Hanjun Guo, Catalin Marinas, Rafael J. Wysocki, Will Deacon,
	Olof Johansson
  Cc: Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi, Al Stone, Hanjun Guo, Ard Biesheuvel

On Wed, 25 Feb 2015 16:39:49 +0800
, Hanjun Guo <hanjun.guo@linaro.org>
 wrote:
> From: Al Stone <al.stone@linaro.org>
> 
> This implements the following policy to decide whether ACPI should
> be used to boot the system:
> - acpi=off: ACPI will not be used to boot the system, even if there is
>   no alternative available (e.g., device tree is empty)
> - acpi=force: only ACPI will be used to boot the system; if that fails,
>   there will be no fallback to alternative methods (such as device tree)
> - otherwise, ACPI will be used as a fallback if the device tree turns out
>   to lack a platform description; the heuristic to decide this is whether
>   /chosen is the only node present at depth 1
> 
> CC: Catalin Marinas <catalin.marinas@arm.com>
> CC: Will Deacon <will.deacon@arm.com>
> CC: Rafael J. Wysocki <rjw@rjwysocki.net>
> Signed-off-by: Al Stone <al.stone@linaro.org>
> Signed-off-by: Graeme Gregory <graeme.gregory@linaro.org>
> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

Acked-by: Grant Likely <grant.likely@linaro.org>

> ---
>  Documentation/kernel-parameters.txt |  3 ++-
>  arch/arm64/include/asm/acpi.h       |  7 +++++
>  arch/arm64/kernel/acpi.c            | 52 +++++++++++++++++++++++++++++++++----
>  3 files changed, 56 insertions(+), 6 deletions(-)
> 
> diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
> index bfcb1a6..d6c35a7 100644
> --- a/Documentation/kernel-parameters.txt
> +++ b/Documentation/kernel-parameters.txt
> @@ -165,7 +165,7 @@ multipliers 'Kilo', 'Mega', and 'Giga', equalling 2^10, 2^20, and 2^30
>  bytes respectively. Such letter suffixes can also be entirely omitted.
>  
>  
> -	acpi=		[HW,ACPI,X86]
> +	acpi=		[HW,ACPI,X86,ARM64]
>  			Advanced Configuration and Power Interface
>  			Format: { force | off | strict | noirq | rsdt }
>  			force -- enable ACPI if default was off
> @@ -175,6 +175,7 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
>  				strictly ACPI specification compliant.
>  			rsdt -- prefer RSDT over (default) XSDT
>  			copy_dsdt -- copy DSDT to memory
> +			For ARM64, ONLY "acpi=off" or "acpi=force" are available
>  
>  			See also Documentation/power/runtime_pm.txt, pci=noacpi
>  
> diff --git a/arch/arm64/include/asm/acpi.h b/arch/arm64/include/asm/acpi.h
> index 40e0924..c5a9b97 100644
> --- a/arch/arm64/include/asm/acpi.h
> +++ b/arch/arm64/include/asm/acpi.h
> @@ -39,6 +39,13 @@ static inline void disable_acpi(void)
>  	acpi_noirq = 1;
>  }
>  
> +static inline void enable_acpi(void)
> +{
> +	acpi_disabled = 0;
> +	acpi_pci_disabled = 0;
> +	acpi_noirq = 0;
> +}
> +
>  /*
>   * It's used from ACPI core in kdump to boot UP system with SMP kernel,
>   * with this check the ACPI core will not override the CPU index
> diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c
> index f052e7a..bdcc9fc 100644
> --- a/arch/arm64/kernel/acpi.c
> +++ b/arch/arm64/kernel/acpi.c
> @@ -22,15 +22,49 @@
>  #include <linux/irq.h>
>  #include <linux/irqdomain.h>
>  #include <linux/memblock.h>
> +#include <linux/of_fdt.h>
>  #include <linux/smp.h>
>  
> -int acpi_noirq;			/* skip ACPI IRQ initialization */
> -int acpi_disabled;
> +int acpi_noirq = 1;		/* skip ACPI IRQ initialization */
> +int acpi_disabled = 1;
>  EXPORT_SYMBOL(acpi_disabled);
>  
> -int acpi_pci_disabled;		/* skip ACPI PCI scan and IRQ initialization */
> +int acpi_pci_disabled = 1;	/* skip ACPI PCI scan and IRQ initialization */
>  EXPORT_SYMBOL(acpi_pci_disabled);
>  
> +static bool __initdata param_acpi_off;
> +static bool __initdata param_acpi_force;
> +
> +static int __init parse_acpi(char *arg)
> +{
> +	if (!arg)
> +		return -EINVAL;
> +
> +	/* "acpi=off" disables both ACPI table parsing and interpreter */
> +	if (strcmp(arg, "off") == 0)
> +		param_acpi_off = true;
> +	else if (strcmp(arg, "force") == 0) /* force ACPI to be enabled */
> +		param_acpi_force = true;
> +	else
> +		return -EINVAL;	/* Core will print when we return error */
> +
> +	return 0;
> +}
> +early_param("acpi", parse_acpi);
> +
> +static int __init dt_scan_depth1_nodes(unsigned long node,
> +				       const char *uname, int depth,
> +				       void *data)
> +{
> +	/*
> +	 * Return 1 as soon as we encounter a node at depth 1 that is
> +	 * not the /chosen node.
> +	 */
> +	if (depth == 1 && (strcmp(uname, "chosen") != 0))
> +		return 1;
> +	return 0;
> +}
> +
>  /*
>   * __acpi_map_table() will be called before page_init(), so early_ioremap()
>   * or early_memremap() should be called here to for ACPI table mapping.
> @@ -83,10 +117,18 @@ static int __init acpi_parse_fadt(struct acpi_table_header *table)
>   */
>  void __init acpi_boot_table_init(void)
>  {
> -	/* If acpi_disabled, bail out */
> -	if (acpi_disabled)
> +	/*
> +	 * Enable ACPI instead of device tree unless
> +	 * - ACPI has been disabled explicitly (acpi=off), or
> +	 * - the device tree is not empty (it has more than just a /chosen node)
> +	 *   and ACPI has not been force enabled (acpi=force)
> +	 */
> +	if (param_acpi_off ||
> +	    (!param_acpi_force && of_scan_flat_dt(dt_scan_depth1_nodes, NULL)))
>  		return;
>  
> +	enable_acpi();
> +
>  	/* Initialize the ACPI boot-time table parser. */
>  	if (acpi_table_init()) {
>  		disable_acpi();
> -- 
> 1.9.1
> 


^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 10/21] ARM64 / ACPI: If we chose to boot from acpi then disable FDT
  2015-02-25  8:39 ` [PATCH v9 10/21] ARM64 / ACPI: If we chose to boot from acpi then disable FDT Hanjun Guo
  2015-03-05 18:12   ` Olof Johansson
@ 2015-03-06 20:38   ` Grant Likely
  1 sibling, 0 replies; 106+ messages in thread
From: Grant Likely @ 2015-03-06 20:38 UTC (permalink / raw)
  To: Hanjun Guo, Catalin Marinas, Rafael J. Wysocki, Will Deacon,
	Olof Johansson
  Cc: Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi, Hanjun Guo

On Wed, 25 Feb 2015 16:39:50 +0800
, Hanjun Guo <hanjun.guo@linaro.org>
 wrote:
> From: Graeme Gregory <graeme.gregory@linaro.org>
> 
> If the early boot methods of acpi are happy that we have valid ACPI
> tables and acpi=force has been passed, then do not unflat devicetree
> effectively disabling further hardware probing from DT.
> 
> CC: Catalin Marinas <catalin.marinas@arm.com>
> CC: Will Deacon <will.deacon@arm.com>
> Tested-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
> Tested-by: Yijing Wang <wangyijing@huawei.com>
> Tested-by: Mark Langsdorf <mlangsdo@redhat.com>
> Tested-by: Jon Masters <jcm@redhat.com>
> Tested-by: Timur Tabi <timur@codeaurora.org>
> Tested-by: Robert Richter <rrichter@cavium.com>
> Acked-by: Robert Richter <rrichter@cavium.com>
> Signed-off-by: Graeme Gregory <graeme.gregory@linaro.org>
> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>

Acked-by: Grant Likely <grant.likely@linaro.org>

> ---
>  arch/arm64/kernel/setup.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
> index 4f1a014..e8c7000 100644
> --- a/arch/arm64/kernel/setup.c
> +++ b/arch/arm64/kernel/setup.c
> @@ -390,7 +390,8 @@ void __init setup_arch(char **cmdline_p)
>  
>  	early_ioremap_reset();
>  
> -	unflatten_device_tree();
> +	if (acpi_disabled)
> +		unflatten_device_tree();
>  
>  	psci_init();
>  
> -- 
> 1.9.1
> 


^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 11/21] ARM64 / ACPI: Get PSCI flags in FADT for PSCI init
  2015-02-25  8:39 ` [PATCH v9 11/21] ARM64 / ACPI: Get PSCI flags in FADT for PSCI init Hanjun Guo
  2015-03-05 18:19   ` Olof Johansson
@ 2015-03-06 20:40   ` Grant Likely
  1 sibling, 0 replies; 106+ messages in thread
From: Grant Likely @ 2015-03-06 20:40 UTC (permalink / raw)
  To: Hanjun Guo, Catalin Marinas, Rafael J. Wysocki, Will Deacon,
	Olof Johansson
  Cc: Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi, Lorenzo Pieralisi, Tomasz Nowicki,
	Hanjun Guo

On Wed, 25 Feb 2015 16:39:51 +0800
, Hanjun Guo <hanjun.guo@linaro.org>
 wrote:
> From: Graeme Gregory <graeme.gregory@linaro.org>
> 
> There are two flags: PSCI_COMPLIANT and PSCI_USE_HVC. When set,
> the former signals to the OS that the firmware is PSCI compliant.
> The latter selects the appropriate conduit for PSCI calls by
> toggling between Hypervisor Calls (HVC) and Secure Monitor Calls
> (SMC).
> 
> FADT table contains such information in ACPI 5.1, FADT table was
> parsed in ACPI table init and copy to struct acpi_gbl_FADT, so
> use the flags in struct acpi_gbl_FADT for PSCI init.
> 
> Since ACPI 5.1 doesn't support self defined PSCI function IDs,
> which means that only PSCI 0.2+ is supported in ACPI.
> 
> CC: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
> CC: Catalin Marinas <catalin.marinas@arm.com>
> CC: Will Deacon <will.deacon@arm.com>
> Tested-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
> Tested-by: Yijing Wang <wangyijing@huawei.com>
> Tested-by: Mark Langsdorf <mlangsdo@redhat.com>
> Tested-by: Jon Masters <jcm@redhat.com>
> Tested-by: Timur Tabi <timur@codeaurora.org>
> Tested-by: Robert Richter <rrichter@cavium.com>
> Acked-by: Robert Richter <rrichter@cavium.com>
> Signed-off-by: Graeme Gregory <graeme.gregory@linaro.org>
> Signed-off-by: Tomasz Nowicki <tomasz.nowicki@linaro.org>
> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>

Acked-by: Grant Likely <grant.likely@linaro.org>

> ---
>  arch/arm64/include/asm/acpi.h | 15 +++++++++
>  arch/arm64/include/asm/psci.h |  3 +-
>  arch/arm64/kernel/psci.c      | 78 ++++++++++++++++++++++++++++++-------------
>  arch/arm64/kernel/setup.c     |  8 +++--
>  4 files changed, 76 insertions(+), 28 deletions(-)
> 
> diff --git a/arch/arm64/include/asm/acpi.h b/arch/arm64/include/asm/acpi.h
> index c5a9b97..9ea650c 100644
> --- a/arch/arm64/include/asm/acpi.h
> +++ b/arch/arm64/include/asm/acpi.h
> @@ -32,6 +32,18 @@ extern int acpi_disabled;
>  extern int acpi_noirq;
>  extern int acpi_pci_disabled;
>  
> +/* 1 to indicate PSCI 0.2+ is implemented */
> +static inline bool acpi_psci_present(void)
> +{
> +	return acpi_gbl_FADT.arm_boot_flags & ACPI_FADT_PSCI_COMPLIANT;
> +}
> +
> +/* 1 to indicate HVC must be used instead of SMC as the PSCI conduit */
> +static inline bool acpi_psci_use_hvc(void)
> +{
> +	return acpi_gbl_FADT.arm_boot_flags & ACPI_FADT_PSCI_USE_HVC;
> +}
> +
>  static inline void disable_acpi(void)
>  {
>  	acpi_disabled = 1;
> @@ -60,6 +72,9 @@ static inline bool acpi_has_cpu_in_madt(void)
>  
>  static inline void arch_fix_phys_package_id(int num, u32 slot) { }
>  
> +#else
> +static inline bool acpi_psci_present(void) { return false; }
> +static inline bool acpi_psci_use_hvc(void) { return false; }
>  #endif /* CONFIG_ACPI */
>  
>  #endif /*_ASM_ACPI_H*/
> diff --git a/arch/arm64/include/asm/psci.h b/arch/arm64/include/asm/psci.h
> index e5312ea..2454bc5 100644
> --- a/arch/arm64/include/asm/psci.h
> +++ b/arch/arm64/include/asm/psci.h
> @@ -14,6 +14,7 @@
>  #ifndef __ASM_PSCI_H
>  #define __ASM_PSCI_H
>  
> -int psci_init(void);
> +int psci_dt_init(void);
> +int psci_acpi_init(void);
>  
>  #endif /* __ASM_PSCI_H */
> diff --git a/arch/arm64/kernel/psci.c b/arch/arm64/kernel/psci.c
> index 3425f31..bab2bea 100644
> --- a/arch/arm64/kernel/psci.c
> +++ b/arch/arm64/kernel/psci.c
> @@ -15,6 +15,7 @@
>  
>  #define pr_fmt(fmt) "psci: " fmt
>  
> +#include <linux/acpi.h>
>  #include <linux/init.h>
>  #include <linux/of.h>
>  #include <linux/smp.h>
> @@ -24,6 +25,7 @@
>  #include <linux/slab.h>
>  #include <uapi/linux/psci.h>
>  
> +#include <asm/acpi.h>
>  #include <asm/compiler.h>
>  #include <asm/cpu_ops.h>
>  #include <asm/errno.h>
> @@ -304,6 +306,33 @@ static void psci_sys_poweroff(void)
>  	invoke_psci_fn(PSCI_0_2_FN_SYSTEM_OFF, 0, 0, 0);
>  }
>  
> +static void __init psci_0_2_set_functions(void)
> +{
> +	pr_info("Using standard PSCI v0.2 function IDs\n");
> +	psci_function_id[PSCI_FN_CPU_SUSPEND] = PSCI_0_2_FN64_CPU_SUSPEND;
> +	psci_ops.cpu_suspend = psci_cpu_suspend;
> +
> +	psci_function_id[PSCI_FN_CPU_OFF] = PSCI_0_2_FN_CPU_OFF;
> +	psci_ops.cpu_off = psci_cpu_off;
> +
> +	psci_function_id[PSCI_FN_CPU_ON] = PSCI_0_2_FN64_CPU_ON;
> +	psci_ops.cpu_on = psci_cpu_on;
> +
> +	psci_function_id[PSCI_FN_MIGRATE] = PSCI_0_2_FN64_MIGRATE;
> +	psci_ops.migrate = psci_migrate;
> +
> +	psci_function_id[PSCI_FN_AFFINITY_INFO] = PSCI_0_2_FN64_AFFINITY_INFO;
> +	psci_ops.affinity_info = psci_affinity_info;
> +
> +	psci_function_id[PSCI_FN_MIGRATE_INFO_TYPE] =
> +		PSCI_0_2_FN_MIGRATE_INFO_TYPE;
> +	psci_ops.migrate_info_type = psci_migrate_info_type;
> +
> +	arm_pm_restart = psci_sys_reset;
> +
> +	pm_power_off = psci_sys_poweroff;
> +}
> +
>  /*
>   * PSCI Function IDs for v0.2+ are well defined so use
>   * standard values.
> @@ -337,29 +366,7 @@ static int __init psci_0_2_init(struct device_node *np)
>  		}
>  	}
>  
> -	pr_info("Using standard PSCI v0.2 function IDs\n");
> -	psci_function_id[PSCI_FN_CPU_SUSPEND] = PSCI_0_2_FN64_CPU_SUSPEND;
> -	psci_ops.cpu_suspend = psci_cpu_suspend;
> -
> -	psci_function_id[PSCI_FN_CPU_OFF] = PSCI_0_2_FN_CPU_OFF;
> -	psci_ops.cpu_off = psci_cpu_off;
> -
> -	psci_function_id[PSCI_FN_CPU_ON] = PSCI_0_2_FN64_CPU_ON;
> -	psci_ops.cpu_on = psci_cpu_on;
> -
> -	psci_function_id[PSCI_FN_MIGRATE] = PSCI_0_2_FN64_MIGRATE;
> -	psci_ops.migrate = psci_migrate;
> -
> -	psci_function_id[PSCI_FN_AFFINITY_INFO] = PSCI_0_2_FN64_AFFINITY_INFO;
> -	psci_ops.affinity_info = psci_affinity_info;
> -
> -	psci_function_id[PSCI_FN_MIGRATE_INFO_TYPE] =
> -		PSCI_0_2_FN_MIGRATE_INFO_TYPE;
> -	psci_ops.migrate_info_type = psci_migrate_info_type;
> -
> -	arm_pm_restart = psci_sys_reset;
> -
> -	pm_power_off = psci_sys_poweroff;
> +	psci_0_2_set_functions();
>  
>  out_put_node:
>  	of_node_put(np);
> @@ -412,7 +419,7 @@ static const struct of_device_id psci_of_match[] __initconst = {
>  	{},
>  };
>  
> -int __init psci_init(void)
> +int __init psci_dt_init(void)
>  {
>  	struct device_node *np;
>  	const struct of_device_id *matched_np;
> @@ -427,6 +434,29 @@ int __init psci_init(void)
>  	return init_fn(np);
>  }
>  
> +/*
> + * We use PSCI 0.2+ when ACPI is deployed on ARM64 and it's
> + * explicitly clarified in SBBR
> + */
> +int __init psci_acpi_init(void)
> +{
> +	if (!acpi_psci_present()) {
> +		pr_info("is not implemented in ACPI.\n");
> +		return -EOPNOTSUPP;
> +	}
> +
> +	pr_info("probing for conduit method from ACPI.\n");
> +
> +	if (acpi_psci_use_hvc())
> +		invoke_psci_fn = __invoke_psci_fn_hvc;
> +	else
> +		invoke_psci_fn = __invoke_psci_fn_smc;
> +
> +	psci_0_2_set_functions();
> +
> +	return 0;
> +}
> +
>  #ifdef CONFIG_SMP
>  
>  static int __init cpu_psci_cpu_init(struct device_node *dn, unsigned int cpu)
> diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
> index e8c7000..97fa7f3 100644
> --- a/arch/arm64/kernel/setup.c
> +++ b/arch/arm64/kernel/setup.c
> @@ -390,10 +390,12 @@ void __init setup_arch(char **cmdline_p)
>  
>  	early_ioremap_reset();
>  
> -	if (acpi_disabled)
> +	if (acpi_disabled) {
>  		unflatten_device_tree();
> -
> -	psci_init();
> +		psci_dt_init();
> +	} else {
> +		psci_acpi_init();
> +	}
>  
>  	cpu_read_bootcpu_ops();
>  #ifdef CONFIG_SMP
> -- 
> 1.9.1
> 


^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 12/21] ACPI / table: Print GIC information when MADT is parsed
  2015-02-25  8:39 ` [PATCH v9 12/21] ACPI / table: Print GIC information when MADT is parsed Hanjun Guo
  2015-03-04 22:40   ` Rafael J. Wysocki
  2015-03-06 18:06   ` Lorenzo Pieralisi
@ 2015-03-06 20:40   ` Grant Likely
  2 siblings, 0 replies; 106+ messages in thread
From: Grant Likely @ 2015-03-06 20:40 UTC (permalink / raw)
  To: Hanjun Guo, Catalin Marinas, Rafael J. Wysocki, Will Deacon,
	Olof Johansson
  Cc: Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi, Hanjun Guo, Tomasz Nowicki

On Wed, 25 Feb 2015 16:39:52 +0800
, Hanjun Guo <hanjun.guo@linaro.org>
 wrote:
> When MADT is parsed, print GIC information as debug message:
> 
> ACPI: GICC (acpi_id[0x0000] address[00000000e112f000] MPIDR[0x0] enabled)
> ACPI: GICC (acpi_id[0x0001] address[00000000e112f000] MPIDR[0x1] enabled)
> ...
> ACPI: GICC (acpi_id[0x0201] address[00000000e112f000] MPIDR[0x201] enabled)
> 
> Those debug information will be very helpful to bring up early systems to
> see if acpi_id and MPIDR are matched or not as spec defined.
> 
> CC: Rafael J. Wysocki <rjw@rjwysocki.net>
> Tested-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
> Tested-by: Yijing Wang <wangyijing@huawei.com>
> Tested-by: Mark Langsdorf <mlangsdo@redhat.com>
> Tested-by: Jon Masters <jcm@redhat.com>
> Tested-by: Timur Tabi <timur@codeaurora.org>
> Tested-by: Robert Richter <rrichter@cavium.com>
> Acked-by: Robert Richter <rrichter@cavium.com>
> Acked-by: Sudeep Holla <sudeep.holla@arm.com>
> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
> Signed-off-by: Tomasz Nowicki <tomasz.nowicki@linaro.org>

Acked-by: Grant Likely <grant.likely@linaro.org>

> ---
>  drivers/acpi/tables.c | 22 ++++++++++++++++++++++
>  1 file changed, 22 insertions(+)
> 
> diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c
> index f4e5b88..2e19189 100644
> --- a/drivers/acpi/tables.c
> +++ b/drivers/acpi/tables.c
> @@ -185,6 +185,28 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header)
>  		}
>  		break;
>  
> +	case ACPI_MADT_TYPE_GENERIC_INTERRUPT:
> +		{
> +			struct acpi_madt_generic_interrupt *p =
> +				(struct acpi_madt_generic_interrupt *)header;
> +			pr_debug("GICC (acpi_id[0x%04x] address[%llx] MPIDR[0x%llx] %s)\n",
> +				 p->uid, p->base_address,
> +				 p->arm_mpidr,
> +				 (p->flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled");
> +
> +		}
> +		break;
> +
> +	case ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR:
> +		{
> +			struct acpi_madt_generic_distributor *p =
> +				(struct acpi_madt_generic_distributor *)header;
> +			pr_debug("GIC Distributor (gic_id[0x%04x] address[%llx] gsi_base[%d])\n",
> +				 p->gic_id, p->base_address,
> +				 p->global_irq_base);
> +		}
> +		break;
> +
>  	default:
>  		pr_warn("Found unsupported MADT entry (type = 0x%x)\n",
>  			header->type);
> -- 
> 1.9.1
> 


^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 13/21] ARM64 / ACPI: Parse MADT for SMP initialization
  2015-02-25  8:39 ` [PATCH v9 13/21] ARM64 / ACPI: Parse MADT for SMP initialization Hanjun Guo
  2015-03-05 18:49   ` Olof Johansson
@ 2015-03-07 22:49   ` Grant Likely
  1 sibling, 0 replies; 106+ messages in thread
From: Grant Likely @ 2015-03-07 22:49 UTC (permalink / raw)
  To: Hanjun Guo, Catalin Marinas, Rafael J. Wysocki, Will Deacon,
	Olof Johansson
  Cc: Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi, Hanjun Guo, Lorenzo Pieralisi,
	Tomasz Nowicki

On Wed, 25 Feb 2015 16:39:53 +0800
, Hanjun Guo <hanjun.guo@linaro.org>
 wrote:
> MADT contains the information for MPIDR which is essential for
> SMP initialization, parse the GIC cpu interface structures to
> get the MPIDR value and map it to cpu_logical_map(), and add
> enabled cpu with valid MPIDR into cpu_possible_map.
> 
> ACPI 5.1 only has two explicit methods to boot up SMP, PSCI and
> Parking protocol, but the Parking protocol is only specified for
> ARMv7 now, so make PSCI as the only way for the SMP boot protocol
> before some updates for the ACPI spec or the Parking protocol spec.
> 
> Parking protocol patches for SMP boot will be sent to upstream when
> the new version of Parking protocol is ready.
> 
> CC: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
> CC: Catalin Marinas <catalin.marinas@arm.com>
> CC: Will Deacon <will.deacon@arm.com>
> CC: Mark Rutland <mark.rutland@arm.com>
> Tested-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
> Tested-by: Yijing Wang <wangyijing@huawei.com>
> Tested-by: Mark Langsdorf <mlangsdo@redhat.com>
> Tested-by: Jon Masters <jcm@redhat.com>
> Tested-by: Timur Tabi <timur@codeaurora.org>
> Tested-by: Robert Richter <rrichter@cavium.com>
> Acked-by: Robert Richter <rrichter@cavium.com>
> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
> Signed-off-by: Tomasz Nowicki <tomasz.nowicki@linaro.org>

Reviewed-by: Grant Likely <grant.likely@linaro.org>

> ---
>  arch/arm64/include/asm/acpi.h    |   2 +
>  arch/arm64/include/asm/cpu_ops.h |   1 +
>  arch/arm64/include/asm/smp.h     |   5 +-
>  arch/arm64/kernel/acpi.c         | 149 ++++++++++++++++++++++++++++++++++++++-
>  arch/arm64/kernel/cpu_ops.c      |   2 +-
>  arch/arm64/kernel/setup.c        |   7 +-
>  arch/arm64/kernel/smp.c          |   2 +-
>  7 files changed, 160 insertions(+), 8 deletions(-)
> 
> diff --git a/arch/arm64/include/asm/acpi.h b/arch/arm64/include/asm/acpi.h
> index 9ea650c..9719921 100644
> --- a/arch/arm64/include/asm/acpi.h
> +++ b/arch/arm64/include/asm/acpi.h
> @@ -71,10 +71,12 @@ static inline bool acpi_has_cpu_in_madt(void)
>  }
>  
>  static inline void arch_fix_phys_package_id(int num, u32 slot) { }
> +void __init acpi_init_cpus(void);
>  
>  #else
>  static inline bool acpi_psci_present(void) { return false; }
>  static inline bool acpi_psci_use_hvc(void) { return false; }
> +static inline void acpi_init_cpus(void) { }
>  #endif /* CONFIG_ACPI */
>  
>  #endif /*_ASM_ACPI_H*/
> diff --git a/arch/arm64/include/asm/cpu_ops.h b/arch/arm64/include/asm/cpu_ops.h
> index da301ee..5a31d67 100644
> --- a/arch/arm64/include/asm/cpu_ops.h
> +++ b/arch/arm64/include/asm/cpu_ops.h
> @@ -66,5 +66,6 @@ struct cpu_operations {
>  extern const struct cpu_operations *cpu_ops[NR_CPUS];
>  int __init cpu_read_ops(struct device_node *dn, int cpu);
>  void __init cpu_read_bootcpu_ops(void);
> +const struct cpu_operations *cpu_get_ops(const char *name);
>  
>  #endif /* ifndef __ASM_CPU_OPS_H */
> diff --git a/arch/arm64/include/asm/smp.h b/arch/arm64/include/asm/smp.h
> index 780f82c..bf22650 100644
> --- a/arch/arm64/include/asm/smp.h
> +++ b/arch/arm64/include/asm/smp.h
> @@ -39,9 +39,10 @@ extern void show_ipi_list(struct seq_file *p, int prec);
>  extern void handle_IPI(int ipinr, struct pt_regs *regs);
>  
>  /*
> - * Setup the set of possible CPUs (via set_cpu_possible)
> + * Discover the set of possible CPUs and determine their
> + * SMP operations.
>   */
> -extern void smp_init_cpus(void);
> +extern void of_smp_init_cpus(void);
>  
>  /*
>   * Provide a function to raise an IPI cross call on CPUs in callmap.
> diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c
> index bdcc9fc..0f35d87 100644
> --- a/arch/arm64/kernel/acpi.c
> +++ b/arch/arm64/kernel/acpi.c
> @@ -25,6 +25,10 @@
>  #include <linux/of_fdt.h>
>  #include <linux/smp.h>
>  
> +#include <asm/cputype.h>
> +#include <asm/cpu_ops.h>
> +#include <asm/smp_plat.h>
> +
>  int acpi_noirq = 1;		/* skip ACPI IRQ initialization */
>  int acpi_disabled = 1;
>  EXPORT_SYMBOL(acpi_disabled);
> @@ -32,6 +36,12 @@ EXPORT_SYMBOL(acpi_disabled);
>  int acpi_pci_disabled = 1;	/* skip ACPI PCI scan and IRQ initialization */
>  EXPORT_SYMBOL(acpi_pci_disabled);
>  
> +/* Processors with enabled flag and sane MPIDR */
> +static int enabled_cpus;
> +
> +/* Boot CPU is valid or not in MADT */
> +static bool __initdata bootcpu_valid;
> +
>  static bool __initdata param_acpi_off;
>  static bool __initdata param_acpi_force;
>  
> @@ -85,6 +95,129 @@ void __init __acpi_unmap_table(char *map, unsigned long size)
>  	early_memunmap(map, size);
>  }
>  
> +/**
> + * acpi_map_gic_cpu_interface - generates a logical cpu number
> + * and map to MPIDR represented by GICC structure
> + * @mpidr: CPU's hardware id to register, MPIDR represented in MADT
> + * @enabled: this cpu is enabled or not
> + *
> + * Returns the logical cpu number which maps to MPIDR
> + */
> +static int __init acpi_map_gic_cpu_interface(u64 mpidr, u8 enabled)
> +{
> +	int i;
> +
> +	if (mpidr == INVALID_HWID) {
> +		pr_info("Skip MADT cpu entry with invalid MPIDR\n");
> +		return -EINVAL;
> +	}
> +
> +	total_cpus++;
> +	if (!enabled)
> +		return -EINVAL;
> +
> +	if (enabled_cpus >=  NR_CPUS) {
> +		pr_warn("NR_CPUS limit of %d reached, Processor %d/0x%llx ignored.\n",
> +			NR_CPUS, total_cpus, mpidr);
> +		return -EINVAL;
> +	}
> +
> +	/* Check if GICC structure of boot CPU is available in the MADT */
> +	if (cpu_logical_map(0) == mpidr) {
> +		if (bootcpu_valid) {
> +			pr_err("Firmware bug, duplicate CPU MPIDR: 0x%llx in MADT\n",
> +			       mpidr);
> +			return -EINVAL;
> +		}
> +
> +		bootcpu_valid = true;
> +	}
> +
> +	/*
> +	 * Duplicate MPIDRs are a recipe for disaster. Scan
> +	 * all initialized entries and check for
> +	 * duplicates. If any is found just ignore the CPU.
> +	 */
> +	for (i = 1; i < enabled_cpus; i++) {
> +		if (cpu_logical_map(i) == mpidr) {
> +			pr_err("Firmware bug, duplicate CPU MPIDR: 0x%llx in MADT\n",
> +			       mpidr);
> +			return -EINVAL;
> +		}
> +	}
> +
> +	if (!acpi_psci_present())
> +		return -EOPNOTSUPP;
> +
> +	cpu_ops[enabled_cpus] = cpu_get_ops("psci");
> +	/* CPU 0 was already initialized */
> +	if (enabled_cpus) {
> +		if (!cpu_ops[enabled_cpus])
> +			return -EINVAL;
> +
> +		if (cpu_ops[enabled_cpus]->cpu_init(NULL, enabled_cpus))
> +			return -EOPNOTSUPP;
> +
> +		/* map the logical cpu id to cpu MPIDR */
> +		cpu_logical_map(enabled_cpus) = mpidr;
> +	}
> +
> +	enabled_cpus++;
> +	return enabled_cpus;
> +}
> +
> +static int __init
> +acpi_parse_gic_cpu_interface(struct acpi_subtable_header *header,
> +				const unsigned long end)
> +{
> +	struct acpi_madt_generic_interrupt *processor;
> +
> +	processor = (struct acpi_madt_generic_interrupt *)header;
> +
> +	if (BAD_MADT_ENTRY(processor, end))
> +		return -EINVAL;
> +
> +	acpi_table_print_madt_entry(header);
> +
> +	acpi_map_gic_cpu_interface(processor->arm_mpidr & MPIDR_HWID_BITMASK,
> +		processor->flags & ACPI_MADT_ENABLED);
> +
> +	return 0;
> +}
> +
> +/* Parse GIC cpu interface entries in MADT for SMP init */
> +void __init acpi_init_cpus(void)
> +{
> +	int count, i;
> +
> +	/*
> +	 * do a partial walk of MADT to determine how many CPUs
> +	 * we have including disabled CPUs, and get information
> +	 * we need for SMP init
> +	 */
> +	count = acpi_table_parse_madt(ACPI_MADT_TYPE_GENERIC_INTERRUPT,
> +			acpi_parse_gic_cpu_interface, 0);
> +
> +	if (!count) {
> +		pr_err("No GIC CPU interface entries present\n");
> +		return;
> +	} else if (count < 0) {
> +		pr_err("Error parsing GIC CPU interface entry\n");
> +		return;
> +	}
> +
> +	if (!bootcpu_valid) {
> +		pr_err("MADT missing boot CPU MPIDR, not enabling secondaries\n");
> +		return;
> +	}
> +
> +	for (i = 0; i < enabled_cpus; i++)
> +		set_cpu_possible(i, true);
> +
> +	/* Make boot-up look pretty */
> +	pr_info("%d CPUs enabled, %d CPUs total\n", enabled_cpus, total_cpus);
> +}
> +
>  static int __init acpi_parse_fadt(struct acpi_table_header *table)
>  {
>  	struct acpi_table_fadt *fadt = (struct acpi_table_fadt *)table;
> @@ -96,8 +229,20 @@ static int __init acpi_parse_fadt(struct acpi_table_header *table)
>  	 * boot protocol configuration data, or we will disable ACPI.
>  	 */
>  	if (table->revision > 5 ||
> -	    (table->revision == 5 && fadt->minor_revision >= 1))
> -		return 0;
> +	    (table->revision == 5 && fadt->minor_revision >= 1)) {
> +		/*
> +		 * ACPI 5.1 only has two explicit methods to boot up SMP,
> +		 * PSCI and Parking protocol, but the Parking protocol is
> +		 * only specified for ARMv7 now, so make PSCI as the only
> +		 * way for the SMP boot protocol before some updates for
> +		 * the Parking protocol spec.
> +		 */
> +		if (acpi_psci_present())
> +			return 0;
> +
> +		pr_warn("No PSCI support, will not bring up secondary CPUs\n");
> +		return -EOPNOTSUPP;
> +	}
>  
>  	pr_warn("Unsupported FADT revision %d.%d, should be 5.1+, will disable ACPI\n",
>  		table->revision, fadt->minor_revision);
> diff --git a/arch/arm64/kernel/cpu_ops.c b/arch/arm64/kernel/cpu_ops.c
> index cce9524..fb8ff9b 100644
> --- a/arch/arm64/kernel/cpu_ops.c
> +++ b/arch/arm64/kernel/cpu_ops.c
> @@ -35,7 +35,7 @@ static const struct cpu_operations *supported_cpu_ops[] __initconst = {
>  	NULL,
>  };
>  
> -static const struct cpu_operations * __init cpu_get_ops(const char *name)
> +const struct cpu_operations * __init cpu_get_ops(const char *name)
>  {
>  	const struct cpu_operations **ops = supported_cpu_ops;
>  
> diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
> index 97fa7f3..b278311 100644
> --- a/arch/arm64/kernel/setup.c
> +++ b/arch/arm64/kernel/setup.c
> @@ -393,13 +393,16 @@ void __init setup_arch(char **cmdline_p)
>  	if (acpi_disabled) {
>  		unflatten_device_tree();
>  		psci_dt_init();
> +		cpu_read_bootcpu_ops();
> +#ifdef CONFIG_SMP
> +		of_smp_init_cpus();
> +#endif
>  	} else {
>  		psci_acpi_init();
> +		acpi_init_cpus();
>  	}
>  
> -	cpu_read_bootcpu_ops();
>  #ifdef CONFIG_SMP
> -	smp_init_cpus();
>  	smp_build_mpidr_hash();
>  #endif
>  
> diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c
> index 328b8ce..52998b7 100644
> --- a/arch/arm64/kernel/smp.c
> +++ b/arch/arm64/kernel/smp.c
> @@ -322,7 +322,7 @@ void __init smp_prepare_boot_cpu(void)
>   * cpu logical map array containing MPIDR values related to logical
>   * cpus. Assumes that cpu_logical_map(0) has already been initialized.
>   */
> -void __init smp_init_cpus(void)
> +void __init of_smp_init_cpus(void)
>  {
>  	struct device_node *dn = NULL;
>  	unsigned int i, cpu = 1;
> -- 
> 1.9.1
> 


^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 14/21] ACPI / processor: Make it possible to get CPU hardware ID via GICC
  2015-02-25  8:39 ` [PATCH v9 14/21] ACPI / processor: Make it possible to get CPU hardware ID via GICC Hanjun Guo
  2015-03-04 22:46   ` Rafael J. Wysocki
@ 2015-03-07 22:52   ` Grant Likely
  1 sibling, 0 replies; 106+ messages in thread
From: Grant Likely @ 2015-03-07 22:52 UTC (permalink / raw)
  To: Hanjun Guo, Catalin Marinas, Rafael J. Wysocki, Will Deacon,
	Olof Johansson
  Cc: Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi, Hanjun Guo

On Wed, 25 Feb 2015 16:39:54 +0800
, Hanjun Guo <hanjun.guo@linaro.org>
 wrote:
> Introduce a new function map_gicc_mpidr() to allow MPIDRs to be obtained
> from the GICC Structure introduced by ACPI 5.1.
> 
> The ARM architecture defines the MPIDR register as the CPU hardware
> identifier. This patch adds the code infrastructure to retrieve the MPIDR
> values from the ARM ACPI GICC structure in order to look-up the kernel CPU
> hardware ids required by the ACPI core code to identify CPUs.
> 
> CC: Rafael J. Wysocki <rjw@rjwysocki.net>
> CC: Catalin Marinas <catalin.marinas@arm.com>
> CC: Will Deacon <will.deacon@arm.com>
> Tested-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
> Tested-by: Yijing Wang <wangyijing@huawei.com>
> Tested-by: Mark Langsdorf <mlangsdo@redhat.com>
> Tested-by: Jon Masters <jcm@redhat.com>
> Tested-by: Timur Tabi <timur@codeaurora.org>
> Tested-by: Robert Richter <rrichter@cavium.com>
> Acked-by: Robert Richter <rrichter@cavium.com>
> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>

Reviewed-by: Grant Likely <grant.likely@linaro.org>

> ---
>  arch/arm64/include/asm/acpi.h | 12 ++++++++++++
>  drivers/acpi/processor_core.c | 30 ++++++++++++++++++++++++++++++
>  2 files changed, 42 insertions(+)
> 
> diff --git a/arch/arm64/include/asm/acpi.h b/arch/arm64/include/asm/acpi.h
> index 9719921..9a23369 100644
> --- a/arch/arm64/include/asm/acpi.h
> +++ b/arch/arm64/include/asm/acpi.h
> @@ -13,6 +13,8 @@
>  #define _ASM_ACPI_H
>  
>  #include <linux/mm.h>
> +#include <asm/cputype.h>
> +#include <asm/smp_plat.h>
>  
>  /* Basic configuration for ACPI */
>  #ifdef	CONFIG_ACPI
> @@ -27,6 +29,9 @@ static inline void __iomem *acpi_os_ioremap(acpi_physical_address phys,
>  }
>  #define acpi_os_ioremap acpi_os_ioremap
>  
> +typedef u64 phys_cpuid_t;
> +#define CPU_PHYS_ID_INVALID INVALID_HWID
> +
>  #define acpi_strict 1	/* No out-of-spec workarounds on ARM64 */
>  extern int acpi_disabled;
>  extern int acpi_noirq;
> @@ -59,6 +64,13 @@ static inline void enable_acpi(void)
>  }
>  
>  /*
> + * The ACPI processor driver for ACPI core code needs this macro
> + * to find out this cpu was already mapped (mapping from CPU hardware
> + * ID to CPU logical ID) or not.
> + */
> +#define cpu_physical_id(cpu) cpu_logical_map(cpu)
> +
> +/*
>   * It's used from ACPI core in kdump to boot UP system with SMP kernel,
>   * with this check the ACPI core will not override the CPU index
>   * obtained from GICC with 0 and not print some error message as well.
> diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c
> index a5547dc..8654adb 100644
> --- a/drivers/acpi/processor_core.c
> +++ b/drivers/acpi/processor_core.c
> @@ -83,6 +83,31 @@ static int map_lsapic_id(struct acpi_subtable_header *entry,
>  	return 0;
>  }
>  
> +/*
> + * Retrieve the ARM CPU physical identifier (MPIDR)
> + */
> +static int map_gicc_mpidr(struct acpi_subtable_header *entry,
> +		int device_declaration, u32 acpi_id, phys_cpuid_t *mpidr)
> +{
> +	struct acpi_madt_generic_interrupt *gicc =
> +	    container_of(entry, struct acpi_madt_generic_interrupt, header);
> +
> +	if (!(gicc->flags & ACPI_MADT_ENABLED))
> +		return -ENODEV;
> +
> +	/* device_declaration means Device object in DSDT, In the
> +	 * GIC interrupt model, logical processors are required to
> +	 * have a Processor Device object in the DSDT, so we should
> +	 * check device_declaration here
> +	 */
> +	if (device_declaration && (gicc->uid == acpi_id)) {
> +		*mpidr = gicc->arm_mpidr;
> +		return 0;
> +	}
> +
> +	return -EINVAL;
> +}
> +
>  static phys_cpuid_t map_madt_entry(int type, u32 acpi_id)
>  {
>  	unsigned long madt_end, entry;
> @@ -111,6 +136,9 @@ static phys_cpuid_t map_madt_entry(int type, u32 acpi_id)
>  		} else if (header->type == ACPI_MADT_TYPE_LOCAL_SAPIC) {
>  			if (!map_lsapic_id(header, type, acpi_id, &phys_id))
>  				break;
> +		} else if (header->type == ACPI_MADT_TYPE_GENERIC_INTERRUPT) {
> +			if (!map_gicc_mpidr(header, type, acpi_id, &phys_id))
> +				break;
>  		}
>  		entry += header->length;
>  	}
> @@ -143,6 +171,8 @@ static phys_cpuid_t map_mat_entry(acpi_handle handle, int type, u32 acpi_id)
>  		map_lsapic_id(header, type, acpi_id, &phys_id);
>  	else if (header->type == ACPI_MADT_TYPE_LOCAL_X2APIC)
>  		map_x2apic_id(header, type, acpi_id, &phys_id);
> +	else if (header->type == ACPI_MADT_TYPE_GENERIC_INTERRUPT)
> +		map_gicc_mpidr(header, type, acpi_id, &phys_id);
>  
>  exit:
>  	kfree(buffer.pointer);
> -- 
> 1.9.1
> 


^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 15/21] ARM64 / ACPI: Introduce ACPI_IRQ_MODEL_GIC and register device's gsi
  2015-02-25  8:39 ` [PATCH v9 15/21] ARM64 / ACPI: Introduce ACPI_IRQ_MODEL_GIC and register device's gsi Hanjun Guo
  2015-03-04 22:47   ` Rafael J. Wysocki
@ 2015-03-07 23:05   ` Grant Likely
  1 sibling, 0 replies; 106+ messages in thread
From: Grant Likely @ 2015-03-07 23:05 UTC (permalink / raw)
  To: Hanjun Guo, Catalin Marinas, Rafael J. Wysocki, Will Deacon,
	Olof Johansson
  Cc: Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi, Hanjun Guo

On Wed, 25 Feb 2015 16:39:55 +0800
, Hanjun Guo <hanjun.guo@linaro.org>
 wrote:
> Introduce ACPI_IRQ_MODEL_GIC which is needed for ARM64 as GIC is
> used, and then register device's gsi with the core IRQ subsystem.
> 
> acpi_register_gsi() is similar to DT based irq_of_parse_and_map(),
> since gsi is unique in the system, so use hwirq number directly
> for the mapping.
> 
> We are going to implement stacked domains when GICv2m, GICv3, ITS
> support are added.
> 
> CC: Marc Zyngier <marc.zyngier@arm.com>
> Originally-by: Amit Daniel Kachhap <amit.daniel@samsung.com>
> Tested-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
> Tested-by: Yijing Wang <wangyijing@huawei.com>
> Tested-by: Mark Langsdorf <mlangsdo@redhat.com>
> Tested-by: Jon Masters <jcm@redhat.com>
> Tested-by: Timur Tabi <timur@codeaurora.org>
> Tested-by: Robert Richter <rrichter@cavium.com>
> Acked-by: Robert Richter <rrichter@cavium.com>
> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>

Reviewed-by: Grant Likely <grant.likely@linaro.org>

> ---
>  arch/arm64/kernel/acpi.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++++
>  drivers/acpi/bus.c       |  3 ++
>  include/linux/acpi.h     |  1 +
>  3 files changed, 77 insertions(+)
> 
> diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c
> index 0f35d87..31f080e 100644
> --- a/arch/arm64/kernel/acpi.c
> +++ b/arch/arm64/kernel/acpi.c
> @@ -76,6 +76,12 @@ static int __init dt_scan_depth1_nodes(unsigned long node,
>  }
>  
>  /*
> + * Since we're on ARM, the default interrupt routing model
> + * clearly has to be GIC.
> + */
> +enum acpi_irq_model_id acpi_irq_model = ACPI_IRQ_MODEL_GIC;
> +
> +/*
>   * __acpi_map_table() will be called before page_init(), so early_ioremap()
>   * or early_memremap() should be called here to for ACPI table mapping.
>   */
> @@ -218,6 +224,73 @@ void __init acpi_init_cpus(void)
>  	pr_info("%d CPUs enabled, %d CPUs total\n", enabled_cpus, total_cpus);
>  }
>  
> +int acpi_gsi_to_irq(u32 gsi, unsigned int *irq)
> +{
> +	*irq = irq_find_mapping(NULL, gsi);
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL_GPL(acpi_gsi_to_irq);
> +
> +/*
> + * success: return IRQ number (>0)
> + * failure: return =< 0
> + */
> +int acpi_register_gsi(struct device *dev, u32 gsi, int trigger, int polarity)
> +{
> +	unsigned int irq;
> +	unsigned int irq_type;
> +
> +	/*
> +	 * ACPI have no bindings to indicate SPI or PPI, so we
> +	 * use different mappings from DT in ACPI.
> +	 *
> +	 * For FDT
> +	 * PPI interrupt: in the range [0, 15];
> +	 * SPI interrupt: in the range [0, 987];
> +	 *
> +	 * For ACPI, GSI should be unique so using
> +	 * the hwirq directly for the mapping:
> +	 * PPI interrupt: in the range [16, 31];
> +	 * SPI interrupt: in the range [32, 1019];
> +	 */
> +
> +	if (trigger == ACPI_EDGE_SENSITIVE &&
> +				polarity == ACPI_ACTIVE_LOW)
> +		irq_type = IRQ_TYPE_EDGE_FALLING;
> +	else if (trigger == ACPI_EDGE_SENSITIVE &&
> +				polarity == ACPI_ACTIVE_HIGH)
> +		irq_type = IRQ_TYPE_EDGE_RISING;
> +	else if (trigger == ACPI_LEVEL_SENSITIVE &&
> +				polarity == ACPI_ACTIVE_LOW)
> +		irq_type = IRQ_TYPE_LEVEL_LOW;
> +	else if (trigger == ACPI_LEVEL_SENSITIVE &&
> +				polarity == ACPI_ACTIVE_HIGH)
> +		irq_type = IRQ_TYPE_LEVEL_HIGH;
> +	else
> +		irq_type = IRQ_TYPE_NONE;
> +
> +	/*
> +	 * Since only one GIC is supported in ACPI 5.0, we can
> +	 * create mapping refer to the default domain
> +	 */
> +	irq = irq_create_mapping(NULL, gsi);
> +	if (!irq)
> +		return irq;
> +
> +	/* Set irq type if specified and different than the current one */
> +	if (irq_type != IRQ_TYPE_NONE &&
> +		irq_type != irq_get_trigger_type(irq))
> +		irq_set_irq_type(irq, irq_type);
> +	return irq;
> +}
> +EXPORT_SYMBOL_GPL(acpi_register_gsi);
> +
> +void acpi_unregister_gsi(u32 gsi)
> +{
> +}
> +EXPORT_SYMBOL_GPL(acpi_unregister_gsi);
> +
>  static int __init acpi_parse_fadt(struct acpi_table_header *table)
>  {
>  	struct acpi_table_fadt *fadt = (struct acpi_table_fadt *)table;
> diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
> index 8b67bd0..c412fdb 100644
> --- a/drivers/acpi/bus.c
> +++ b/drivers/acpi/bus.c
> @@ -448,6 +448,9 @@ static int __init acpi_bus_init_irq(void)
>  	case ACPI_IRQ_MODEL_IOSAPIC:
>  		message = "IOSAPIC";
>  		break;
> +	case ACPI_IRQ_MODEL_GIC:
> +		message = "GIC";
> +		break;
>  	case ACPI_IRQ_MODEL_PLATFORM:
>  		message = "platform specific model";
>  		break;
> diff --git a/include/linux/acpi.h b/include/linux/acpi.h
> index 0eabd15..c03d8d1 100644
> --- a/include/linux/acpi.h
> +++ b/include/linux/acpi.h
> @@ -73,6 +73,7 @@ enum acpi_irq_model_id {
>  	ACPI_IRQ_MODEL_IOAPIC,
>  	ACPI_IRQ_MODEL_IOSAPIC,
>  	ACPI_IRQ_MODEL_PLATFORM,
> +	ACPI_IRQ_MODEL_GIC,
>  	ACPI_IRQ_MODEL_COUNT
>  };
>  
> -- 
> 1.9.1
> 


^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 16/21] irqchip: Add GICv2 specific ACPI boot support
  2015-02-25  8:39 ` [PATCH v9 16/21] irqchip: Add GICv2 specific ACPI boot support Hanjun Guo
  2015-03-04 22:50   ` Rafael J. Wysocki
  2015-03-05  8:21   ` Hanjun Guo
@ 2015-03-07 23:14   ` Grant Likely
  2 siblings, 0 replies; 106+ messages in thread
From: Grant Likely @ 2015-03-07 23:14 UTC (permalink / raw)
  To: Hanjun Guo, Catalin Marinas, Rafael J. Wysocki, Will Deacon,
	Olof Johansson
  Cc: Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi, Tomasz Nowicki, Jason Cooper,
	Thomas Gleixner, Hanjun Guo

On Wed, 25 Feb 2015 16:39:56 +0800
, Hanjun Guo <hanjun.guo@linaro.org>
 wrote:
> From: Tomasz Nowicki <tomasz.nowicki@linaro.org>
> 
> ACPI kernel uses MADT table for proper GIC initialization. It needs to
> parse GIC related subtables, collect CPU interface and distributor
> addresses and call driver initialization function (which is hardware
> abstraction agnostic). In a similar way, FDT initialize GICv1/2.
> 
> NOTE: This commit allow to initialize GICv1/2 basic functionality.
> While now simple GICv2 init call is used, any further GIC features
> require generic infrastructure for proper ACPI irqchip initialization.
> That mechanism and stacked irqdomains to support GICv2 MSI/virtualization
> extension, GICv3/4 and its ITS are considered as next steps.
> 
> CC: Jason Cooper <jason@lakedaemon.net>
> CC: Marc Zyngier <marc.zyngier@arm.com>
> CC: Thomas Gleixner <tglx@linutronix.de>
> Tested-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
> Tested-by: Yijing Wang <wangyijing@huawei.com>
> Tested-by: Mark Langsdorf <mlangsdo@redhat.com>
> Tested-by: Jon Masters <jcm@redhat.com>
> Tested-by: Timur Tabi <timur@codeaurora.org>
> Tested-by: Robert Richter <rrichter@cavium.com>
> Acked-by: Robert Richter <rrichter@cavium.com>
> Signed-off-by: Tomasz Nowicki <tomasz.nowicki@linaro.org>
> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>

Reviewed-by: Grant Likely <grant.likely@linaro.org>

> ---
>  arch/arm64/include/asm/acpi.h        |   2 +
>  arch/arm64/kernel/acpi.c             |  25 +++++++++
>  drivers/irqchip/irq-gic.c            | 102 +++++++++++++++++++++++++++++++++++
>  drivers/irqchip/irqchip.c            |   3 ++
>  include/linux/acpi.h                 |  14 +++++
>  include/linux/irqchip/arm-gic-acpi.h |  29 ++++++++++
>  6 files changed, 175 insertions(+)
>  create mode 100644 include/linux/irqchip/arm-gic-acpi.h
> 
> diff --git a/arch/arm64/include/asm/acpi.h b/arch/arm64/include/asm/acpi.h
> index 9a23369..a720a61 100644
> --- a/arch/arm64/include/asm/acpi.h
> +++ b/arch/arm64/include/asm/acpi.h
> @@ -13,6 +13,8 @@
>  #define _ASM_ACPI_H
>  
>  #include <linux/mm.h>
> +#include <linux/irqchip/arm-gic-acpi.h>
> +
>  #include <asm/cputype.h>
>  #include <asm/smp_plat.h>
>  
> diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c
> index 31f080e..af308c3 100644
> --- a/arch/arm64/kernel/acpi.c
> +++ b/arch/arm64/kernel/acpi.c
> @@ -359,3 +359,28 @@ void __init acpi_boot_table_init(void)
>  		pr_err("Can't find FADT\n");
>  	}
>  }
> +
> +void __init acpi_gic_init(void)
> +{
> +	struct acpi_table_header *table;
> +	acpi_status status;
> +	acpi_size tbl_size;
> +	int err;
> +
> +	if (acpi_disabled)
> +		return;
> +
> +	status = acpi_get_table_with_size(ACPI_SIG_MADT, 0, &table, &tbl_size);
> +	if (ACPI_FAILURE(status)) {
> +		const char *msg = acpi_format_exception(status);
> +
> +		pr_err("Failed to get MADT table, %s\n", msg);
> +		return;
> +	}
> +
> +	err = gic_v2_acpi_init(table);
> +	if (err)
> +		pr_err("Failed to initialize GIC IRQ controller");
> +
> +	early_acpi_os_unmap_memory((char *)table, tbl_size);
> +}
> diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
> index 4634cf7..929d668 100644
> --- a/drivers/irqchip/irq-gic.c
> +++ b/drivers/irqchip/irq-gic.c
> @@ -33,12 +33,14 @@
>  #include <linux/of.h>
>  #include <linux/of_address.h>
>  #include <linux/of_irq.h>
> +#include <linux/acpi.h>
>  #include <linux/irqdomain.h>
>  #include <linux/interrupt.h>
>  #include <linux/percpu.h>
>  #include <linux/slab.h>
>  #include <linux/irqchip/chained_irq.h>
>  #include <linux/irqchip/arm-gic.h>
> +#include <linux/irqchip/arm-gic-acpi.h>
>  
>  #include <asm/cputype.h>
>  #include <asm/irq.h>
> @@ -1086,3 +1088,103 @@ IRQCHIP_DECLARE(msm_8660_qgic, "qcom,msm-8660-qgic", gic_of_init);
>  IRQCHIP_DECLARE(msm_qgic2, "qcom,msm-qgic2", gic_of_init);
>  
>  #endif
> +
> +#ifdef CONFIG_ACPI
> +static phys_addr_t dist_phy_base, cpu_phy_base __initdata;
> +
> +static int __init
> +gic_acpi_parse_madt_cpu(struct acpi_subtable_header *header,
> +			const unsigned long end)
> +{
> +	struct acpi_madt_generic_interrupt *processor;
> +	phys_addr_t gic_cpu_base;
> +	static int cpu_base_assigned;
> +
> +	processor = (struct acpi_madt_generic_interrupt *)header;
> +
> +	if (BAD_MADT_ENTRY(processor, end))
> +		return -EINVAL;
> +
> +	/*
> +	 * There is no support for non-banked GICv1/2 register in ACPI spec.
> +	 * All CPU interface addresses have to be the same.
> +	 */
> +	gic_cpu_base = processor->base_address;
> +	if (cpu_base_assigned && gic_cpu_base != cpu_phy_base)
> +		return -EINVAL;
> +
> +	cpu_phy_base = gic_cpu_base;
> +	cpu_base_assigned = 1;
> +	return 0;
> +}
> +
> +static int __init
> +gic_acpi_parse_madt_distributor(struct acpi_subtable_header *header,
> +				const unsigned long end)
> +{
> +	struct acpi_madt_generic_distributor *dist;
> +
> +	dist = (struct acpi_madt_generic_distributor *)header;
> +
> +	if (BAD_MADT_ENTRY(dist, end))
> +		return -EINVAL;
> +
> +	dist_phy_base = dist->base_address;
> +	return 0;
> +}
> +
> +int __init
> +gic_v2_acpi_init(struct acpi_table_header *table)
> +{
> +	void __iomem *cpu_base, *dist_base;
> +	int count;
> +
> +	/* Collect CPU base addresses */
> +	count = acpi_parse_entries(ACPI_SIG_MADT,
> +				   sizeof(struct acpi_table_madt),
> +				   gic_acpi_parse_madt_cpu, table,
> +				   ACPI_MADT_TYPE_GENERIC_INTERRUPT, 0);
> +	if (count <= 0) {
> +		pr_err("No valid GICC entries exist\n");
> +		return -EINVAL;
> +	}
> +
> +	/*
> +	 * Find distributor base address. We expect one distributor entry since
> +	 * ACPI 5.1 spec neither support multi-GIC instances nor GIC cascade.
> +	 */
> +	count = acpi_parse_entries(ACPI_SIG_MADT,
> +				   sizeof(struct acpi_table_madt),
> +				   gic_acpi_parse_madt_distributor, table,
> +				   ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR, 0);
> +	if (count <= 0) {
> +		pr_err("No valid GICD entries exist\n");
> +		return -EINVAL;
> +	} else if (count > 1) {
> +		pr_err("More than one GICD entry detected\n");
> +		return -EINVAL;
> +	}
> +
> +	cpu_base = ioremap(cpu_phy_base, ACPI_GIC_CPU_IF_MEM_SIZE);
> +	if (!cpu_base) {
> +		pr_err("Unable to map GICC registers\n");
> +		return -ENOMEM;
> +	}
> +
> +	dist_base = ioremap(dist_phy_base, ACPI_GICV2_DIST_MEM_SIZE);
> +	if (!dist_base) {
> +		pr_err("Unable to map GICD registers\n");
> +		iounmap(cpu_base);
> +		return -ENOMEM;
> +	}
> +
> +	/*
> +	 * Initialize zero GIC instance (no multi-GIC support). Also, set GIC
> +	 * as default IRQ domain to allow for GSI registration and GSI to IRQ
> +	 * number translation (see acpi_register_gsi() and acpi_gsi_to_irq()).
> +	 */
> +	gic_init_bases(0, -1, dist_base, cpu_base, 0, NULL);
> +	irq_set_default_host(gic_data[0].domain);
> +	return 0;
> +}
> +#endif
> diff --git a/drivers/irqchip/irqchip.c b/drivers/irqchip/irqchip.c
> index 0fe2f71..5855240 100644
> --- a/drivers/irqchip/irqchip.c
> +++ b/drivers/irqchip/irqchip.c
> @@ -8,6 +8,7 @@
>   * warranty of any kind, whether express or implied.
>   */
>  
> +#include <linux/acpi.h>
>  #include <linux/init.h>
>  #include <linux/of_irq.h>
>  #include <linux/irqchip.h>
> @@ -26,4 +27,6 @@ extern struct of_device_id __irqchip_of_table[];
>  void __init irqchip_init(void)
>  {
>  	of_irq_init(__irqchip_of_table);
> +
> +	acpi_irq_init();
>  }
> diff --git a/include/linux/acpi.h b/include/linux/acpi.h
> index c03d8d1..e27117a 100644
> --- a/include/linux/acpi.h
> +++ b/include/linux/acpi.h
> @@ -557,6 +557,20 @@ static inline int acpi_device_modalias(struct device *dev,
>  
>  #endif	/* !CONFIG_ACPI */
>  
> +#if defined(CONFIG_ACPI) && defined(CONFIG_ARM64)
> +static inline void acpi_irq_init(void)
> +{
> +	/*
> +	 * Hardcode ACPI IRQ chip initialization to GICv2 for now.
> +	 * Proper irqchip infrastructure will be implemented along with
> +	 * incoming  GICv2m|GICv3|ITS bits.
> +	 */
> +	acpi_gic_init();
> +}
> +#else
> +static inline void acpi_irq_init(void) { }
> +#endif
> +
>  #ifdef CONFIG_ACPI
>  void acpi_os_set_prepare_sleep(int (*func)(u8 sleep_state,
>  			       u32 pm1a_ctrl,  u32 pm1b_ctrl));
> diff --git a/include/linux/irqchip/arm-gic-acpi.h b/include/linux/irqchip/arm-gic-acpi.h
> new file mode 100644
> index 0000000..d5b2c79
> --- /dev/null
> +++ b/include/linux/irqchip/arm-gic-acpi.h
> @@ -0,0 +1,29 @@
> +/*
> + * Copyright (C) 2014, Linaro Ltd.
> + *	Author: Tomasz Nowicki <tomasz.nowicki@linaro.org>
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + */
> +
> +#ifndef ARM_GIC_ACPI_H_
> +#define ARM_GIC_ACPI_H_
> +
> +#ifdef CONFIG_ACPI
> +
> +/*
> + * Hard code here, we can not get memory size from MADT (but FDT does),
> + * Actually no need to do that, because this size can be inferred
> + * from GIC spec.
> + */
> +#define ACPI_GICV2_DIST_MEM_SIZE	(SZ_4K)
> +#define ACPI_GIC_CPU_IF_MEM_SIZE	(SZ_8K)
> +
> +struct acpi_table_header;
> +
> +int gic_v2_acpi_init(struct acpi_table_header *table);
> +void acpi_gic_init(void);
> +#endif
> +
> +#endif /* ARM_GIC_ACPI_H_ */
> -- 
> 1.9.1
> 


^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 17/21] clocksource / arch_timer: Parse GTDT to initialize arch timer
  2015-02-25  8:39 ` [PATCH v9 17/21] clocksource / arch_timer: Parse GTDT to initialize arch timer Hanjun Guo
@ 2015-03-07 23:16   ` Grant Likely
  0 siblings, 0 replies; 106+ messages in thread
From: Grant Likely @ 2015-03-07 23:16 UTC (permalink / raw)
  To: Hanjun Guo, Catalin Marinas, Rafael J. Wysocki, Will Deacon,
	Olof Johansson
  Cc: Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi, Hanjun Guo, Daniel Lezcano,
	Thomas Gleixner

On Wed, 25 Feb 2015 16:39:57 +0800
, Hanjun Guo <hanjun.guo@linaro.org>
 wrote:
> Using the information presented by GTDT (Generic Timer Description Table)
> to initialize the arch timer (not memory-mapped).
> 
> CC: Daniel Lezcano <daniel.lezcano@linaro.org>
> CC: Thomas Gleixner <tglx@linutronix.de>
> Originally-by: Amit Daniel Kachhap <amit.daniel@samsung.com>
> Tested-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
> Tested-by: Yijing Wang <wangyijing@huawei.com>
> Tested-by: Mark Langsdorf <mlangsdo@redhat.com>
> Tested-by: Jon Masters <jcm@redhat.com>
> Tested-by: Timur Tabi <timur@codeaurora.org>
> Tested-by: Robert Richter <rrichter@cavium.com>
> Acked-by: Robert Richter <rrichter@cavium.com>
> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>

Reviewed-by: Grant Likely <grant.likely@linaro.org>

> ---
>  arch/arm64/kernel/time.c             |   7 ++
>  drivers/clocksource/arm_arch_timer.c | 132 ++++++++++++++++++++++++++++-------
>  include/linux/clocksource.h          |   6 ++
>  3 files changed, 118 insertions(+), 27 deletions(-)
> 
> diff --git a/arch/arm64/kernel/time.c b/arch/arm64/kernel/time.c
> index 1a7125c..42f9195 100644
> --- a/arch/arm64/kernel/time.c
> +++ b/arch/arm64/kernel/time.c
> @@ -35,6 +35,7 @@
>  #include <linux/delay.h>
>  #include <linux/clocksource.h>
>  #include <linux/clk-provider.h>
> +#include <linux/acpi.h>
>  
>  #include <clocksource/arm_arch_timer.h>
>  
> @@ -72,6 +73,12 @@ void __init time_init(void)
>  
>  	tick_setup_hrtimer_broadcast();
>  
> +	/*
> +	 * Since ACPI or FDT will only one be available in the system,
> +	 * we can use acpi_generic_timer_init() here safely
> +	 */
> +	acpi_generic_timer_init();
> +
>  	arch_timer_rate = arch_timer_get_rate();
>  	if (!arch_timer_rate)
>  		panic("Unable to initialise architected timer.\n");
> diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
> index a3025e7..ea62fc7 100644
> --- a/drivers/clocksource/arm_arch_timer.c
> +++ b/drivers/clocksource/arm_arch_timer.c
> @@ -22,6 +22,7 @@
>  #include <linux/io.h>
>  #include <linux/slab.h>
>  #include <linux/sched_clock.h>
> +#include <linux/acpi.h>
>  
>  #include <asm/arch_timer.h>
>  #include <asm/virt.h>
> @@ -371,8 +372,12 @@ arch_timer_detect_rate(void __iomem *cntbase, struct device_node *np)
>  	if (arch_timer_rate)
>  		return;
>  
> -	/* Try to determine the frequency from the device tree or CNTFRQ */
> -	if (of_property_read_u32(np, "clock-frequency", &arch_timer_rate)) {
> +	/*
> +	 * Try to determine the frequency from the device tree or CNTFRQ,
> +	 * if ACPI is enabled, get the frequency from CNTFRQ ONLY.
> +	 */
> +	if (!acpi_disabled ||
> +	    of_property_read_u32(np, "clock-frequency", &arch_timer_rate)) {
>  		if (cntbase)
>  			arch_timer_rate = readl_relaxed(cntbase + CNTFRQ);
>  		else
> @@ -691,28 +696,8 @@ static void __init arch_timer_common_init(void)
>  	arch_timer_arch_init();
>  }
>  
> -static void __init arch_timer_init(struct device_node *np)
> +static void __init arch_timer_init(void)
>  {
> -	int i;
> -
> -	if (arch_timers_present & ARCH_CP15_TIMER) {
> -		pr_warn("arch_timer: multiple nodes in dt, skipping\n");
> -		return;
> -	}
> -
> -	arch_timers_present |= ARCH_CP15_TIMER;
> -	for (i = PHYS_SECURE_PPI; i < MAX_TIMER_PPI; i++)
> -		arch_timer_ppi[i] = irq_of_parse_and_map(np, i);
> -	arch_timer_detect_rate(NULL, np);
> -
> -	/*
> -	 * If we cannot rely on firmware initializing the timer registers then
> -	 * we should use the physical timers instead.
> -	 */
> -	if (IS_ENABLED(CONFIG_ARM) &&
> -	    of_property_read_bool(np, "arm,cpu-registers-not-fw-configured"))
> -			arch_timer_use_virtual = false;
> -
>  	/*
>  	 * If HYP mode is available, we know that the physical timer
>  	 * has been configured to be accessible from PL1. Use it, so
> @@ -731,13 +716,39 @@ static void __init arch_timer_init(struct device_node *np)
>  		}
>  	}
>  
> -	arch_timer_c3stop = !of_property_read_bool(np, "always-on");
> -
>  	arch_timer_register();
>  	arch_timer_common_init();
>  }
> -CLOCKSOURCE_OF_DECLARE(armv7_arch_timer, "arm,armv7-timer", arch_timer_init);
> -CLOCKSOURCE_OF_DECLARE(armv8_arch_timer, "arm,armv8-timer", arch_timer_init);
> +
> +static void __init arch_timer_of_init(struct device_node *np)
> +{
> +	int i;
> +
> +	if (arch_timers_present & ARCH_CP15_TIMER) {
> +		pr_warn("arch_timer: multiple nodes in dt, skipping\n");
> +		return;
> +	}
> +
> +	arch_timers_present |= ARCH_CP15_TIMER;
> +	for (i = PHYS_SECURE_PPI; i < MAX_TIMER_PPI; i++)
> +		arch_timer_ppi[i] = irq_of_parse_and_map(np, i);
> +
> +	arch_timer_detect_rate(NULL, np);
> +
> +	arch_timer_c3stop = !of_property_read_bool(np, "always-on");
> +
> +	/*
> +	 * If we cannot rely on firmware initializing the timer registers then
> +	 * we should use the physical timers instead.
> +	 */
> +	if (IS_ENABLED(CONFIG_ARM) &&
> +	    of_property_read_bool(np, "arm,cpu-registers-not-fw-configured"))
> +			arch_timer_use_virtual = false;
> +
> +	arch_timer_init();
> +}
> +CLOCKSOURCE_OF_DECLARE(armv7_arch_timer, "arm,armv7-timer", arch_timer_of_init);
> +CLOCKSOURCE_OF_DECLARE(armv8_arch_timer, "arm,armv8-timer", arch_timer_of_init);
>  
>  static void __init arch_timer_mem_init(struct device_node *np)
>  {
> @@ -804,3 +815,70 @@ static void __init arch_timer_mem_init(struct device_node *np)
>  }
>  CLOCKSOURCE_OF_DECLARE(armv7_arch_timer_mem, "arm,armv7-timer-mem",
>  		       arch_timer_mem_init);
> +
> +#ifdef CONFIG_ACPI
> +static int __init map_generic_timer_interrupt(u32 interrupt, u32 flags)
> +{
> +	int trigger, polarity;
> +
> +	if (!interrupt)
> +		return 0;
> +
> +	trigger = (flags & ACPI_GTDT_INTERRUPT_MODE) ? ACPI_EDGE_SENSITIVE
> +			: ACPI_LEVEL_SENSITIVE;
> +
> +	polarity = (flags & ACPI_GTDT_INTERRUPT_POLARITY) ? ACPI_ACTIVE_LOW
> +			: ACPI_ACTIVE_HIGH;
> +
> +	return acpi_register_gsi(NULL, interrupt, trigger, polarity);
> +}
> +
> +/* Initialize per-processor generic timer */
> +static int __init arch_timer_acpi_init(struct acpi_table_header *table)
> +{
> +	struct acpi_table_gtdt *gtdt;
> +
> +	if (arch_timers_present & ARCH_CP15_TIMER) {
> +		pr_warn("arch_timer: already initialized, skipping\n");
> +		return -EINVAL;
> +	}
> +
> +	gtdt = container_of(table, struct acpi_table_gtdt, header);
> +
> +	arch_timers_present |= ARCH_CP15_TIMER;
> +
> +	arch_timer_ppi[PHYS_SECURE_PPI] =
> +		map_generic_timer_interrupt(gtdt->secure_el1_interrupt,
> +		gtdt->secure_el1_flags);
> +
> +	arch_timer_ppi[PHYS_NONSECURE_PPI] =
> +		map_generic_timer_interrupt(gtdt->non_secure_el1_interrupt,
> +		gtdt->non_secure_el1_flags);
> +
> +	arch_timer_ppi[VIRT_PPI] =
> +		map_generic_timer_interrupt(gtdt->virtual_timer_interrupt,
> +		gtdt->virtual_timer_flags);
> +
> +	arch_timer_ppi[HYP_PPI] =
> +		map_generic_timer_interrupt(gtdt->non_secure_el2_interrupt,
> +		gtdt->non_secure_el2_flags);
> +
> +	/* Get the frequency from CNTFRQ */
> +	arch_timer_detect_rate(NULL, NULL);
> +
> +	/* Always-on capability */
> +	arch_timer_c3stop = !(gtdt->non_secure_el1_flags & ACPI_GTDT_ALWAYS_ON);
> +
> +	arch_timer_init();
> +	return 0;
> +}
> +
> +/* Initialize all the generic timers presented in GTDT */
> +void __init acpi_generic_timer_init(void)
> +{
> +	if (acpi_disabled)
> +		return;
> +
> +	acpi_table_parse(ACPI_SIG_GTDT, arch_timer_acpi_init);
> +}
> +#endif
> diff --git a/include/linux/clocksource.h b/include/linux/clocksource.h
> index 9c78d15..2b2e1f8 100644
> --- a/include/linux/clocksource.h
> +++ b/include/linux/clocksource.h
> @@ -244,4 +244,10 @@ extern void clocksource_of_init(void);
>  static inline void clocksource_of_init(void) {}
>  #endif
>  
> +#ifdef CONFIG_ACPI
> +void acpi_generic_timer_init(void);
> +#else
> +static inline void acpi_generic_timer_init(void) { }
> +#endif
> +
>  #endif /* _LINUX_CLOCKSOURCE_H */
> -- 
> 1.9.1
> 


^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 18/21] ARM64 / ACPI: Select ACPI_REDUCED_HARDWARE_ONLY if ACPI is enabled on ARM64
  2015-02-25  8:39 ` [PATCH v9 18/21] ARM64 / ACPI: Select ACPI_REDUCED_HARDWARE_ONLY if ACPI is enabled on ARM64 Hanjun Guo
  2015-03-06 17:47   ` Lorenzo Pieralisi
@ 2015-03-07 23:16   ` Grant Likely
  1 sibling, 0 replies; 106+ messages in thread
From: Grant Likely @ 2015-03-07 23:16 UTC (permalink / raw)
  To: Hanjun Guo, Catalin Marinas, Rafael J. Wysocki, Will Deacon,
	Olof Johansson
  Cc: Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi, Al Stone, Hanjun Guo

On Wed, 25 Feb 2015 16:39:58 +0800
, Hanjun Guo <hanjun.guo@linaro.org>
 wrote:
> From: Al Stone <al.stone@linaro.org>
> 
> ACPI reduced hardware mode is disabled by default, but ARM64
> can only run properly in ACPI hardware reduced mode, so select
> ACPI_REDUCED_HARDWARE_ONLY if ACPI is enabled on ARM64.
> 
> CC: Catalin Marinas <catalin.marinas@arm.com>
> CC: Will Deacon <will.deacon@arm.com>
> Reviewed-by: Grant Likely <grant.likely@linaro.org>
> Tested-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
> Tested-by: Yijing Wang <wangyijing@huawei.com>
> Tested-by: Mark Langsdorf <mlangsdo@redhat.com>
> Tested-by: Jon Masters <jcm@redhat.com>
> Tested-by: Timur Tabi <timur@codeaurora.org>
> Tested-by: Robert Richter <rrichter@cavium.com>
> Acked-by: Robert Richter <rrichter@cavium.com>
> Signed-off-by: Al Stone <al.stone@linaro.org>
> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>

Acked-by: Grant Likely <grant.likely@linaro.org>

> ---
>  arch/arm64/Kconfig | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
> index 1b8e973..d00ab9a 100644
> --- a/arch/arm64/Kconfig
> +++ b/arch/arm64/Kconfig
> @@ -1,5 +1,6 @@
>  config ARM64
>  	def_bool y
> +	select ACPI_REDUCED_HARDWARE_ONLY if ACPI
>  	select ARCH_BINFMT_ELF_RANDOMIZE_PIE
>  	select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE
>  	select ARCH_HAS_GCOV_PROFILE_ALL
> -- 
> 1.9.1
> 


^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 19/21] ARM64 / ACPI: Enable ARM64 in Kconfig
  2015-02-25  8:39 ` [PATCH v9 19/21] ARM64 / ACPI: Enable ARM64 in Kconfig Hanjun Guo
  2015-03-04 22:52   ` Rafael J. Wysocki
@ 2015-03-07 23:17   ` Grant Likely
  1 sibling, 0 replies; 106+ messages in thread
From: Grant Likely @ 2015-03-07 23:17 UTC (permalink / raw)
  To: Hanjun Guo, Catalin Marinas, Rafael J. Wysocki, Will Deacon,
	Olof Johansson
  Cc: Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi, Al Stone, Hanjun Guo

On Wed, 25 Feb 2015 16:39:59 +0800
, Hanjun Guo <hanjun.guo@linaro.org>
 wrote:
> From: Graeme Gregory <graeme.gregory@linaro.org>
> 
> Add Kconfigs to build ACPI on ARM64, and make ACPI available on ARM64.
> 
> acpi_idle driver is x86/IA64 dependent now, so make CONFIG_ACPI_PROCESSOR
> depend on X86 || IA64, and implement it on ARM64 in the future.
> 
> CC: Rafael J. Wysocki <rjw@rjwysocki.net>
> CC: Catalin Marinas <catalin.marinas@arm.com>
> CC: Will Deacon <will.deacon@arm.com>
> Reviewed-by: Grant Likely <grant.likely@linaro.org>
> Tested-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
> Tested-by: Yijing Wang <wangyijing@huawei.com>
> Tested-by: Mark Langsdorf <mlangsdo@redhat.com>
> Tested-by: Jon Masters <jcm@redhat.com>
> Tested-by: Timur Tabi <timur@codeaurora.org>
> Tested-by: Robert Richter <rrichter@cavium.com>
> Acked-by: Robert Richter <rrichter@cavium.com>
> Signed-off-by: Graeme Gregory <graeme.gregory@linaro.org>
> Signed-off-by: Al Stone <al.stone@linaro.org>
> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>

Acked-by: Grant Likely <grant.likely@linaro.org>

> ---
>  arch/arm64/Kconfig   | 2 ++
>  drivers/acpi/Kconfig | 3 ++-
>  2 files changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
> index d00ab9a..e5aa081 100644
> --- a/arch/arm64/Kconfig
> +++ b/arch/arm64/Kconfig
> @@ -713,6 +713,8 @@ source "drivers/Kconfig"
>  
>  source "drivers/firmware/Kconfig"
>  
> +source "drivers/acpi/Kconfig"
> +
>  source "fs/Kconfig"
>  
>  source "arch/arm64/kvm/Kconfig"
> diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
> index e6c3ddd..7aa3288 100644
> --- a/drivers/acpi/Kconfig
> +++ b/drivers/acpi/Kconfig
> @@ -5,7 +5,7 @@
>  menuconfig ACPI
>  	bool "ACPI (Advanced Configuration and Power Interface) Support"
>  	depends on !IA64_HP_SIM
> -	depends on IA64 || X86
> +	depends on IA64 || X86 || (ARM64 && EXPERT)
>  	depends on PCI
>  	select PNP
>  	default y
> @@ -163,6 +163,7 @@ config ACPI_PROCESSOR
>  	tristate "Processor"
>  	select THERMAL
>  	select CPU_IDLE
> +	depends on X86 || IA64
>  	default y
>  	help
>  	  This driver installs ACPI as the idle handler for Linux and uses
> -- 
> 1.9.1
> 


^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 08/21] ARM64 / ACPI: Introduce PCI stub functions for ACPI
  2015-02-25  8:39 ` [PATCH v9 08/21] ARM64 / ACPI: Introduce PCI stub functions for ACPI Hanjun Guo
  2015-03-06 18:31   ` Lorenzo Pieralisi
  2015-03-06 20:36   ` Grant Likely
@ 2015-03-09 15:01   ` Liviu Dudau
  2015-03-10  9:34     ` Hanjun Guo
  2 siblings, 1 reply; 106+ messages in thread
From: Liviu Dudau @ 2015-03-09 15:01 UTC (permalink / raw)
  To: Hanjun Guo
  Cc: Catalin Marinas, Rafael J. Wysocki, Will Deacon, Olof Johansson,
	grant.likely, Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland,
	graeme.gregory, Sudeep Holla, jcm, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi

On Wed, Feb 25, 2015 at 08:39:48AM +0000, Hanjun Guo wrote:
> CONFIG_ACPI depends CONFIG_PCI on x86 and ia64, in ARM64 server
> world we will have PCIe in most cases, but some of them may not,
> make CONFIG_ACPI depend CONFIG_PCI on ARM64 will satisfy both.
> 
> With that case, we need some arch dependent PCI functions to
> access the config space before the PCI root bridge is created, and
> pci_acpi_scan_root() to create the PCI root bus. So introduce
> some stub function here to make ACPI core compile and revisit
> them later when implemented on ARM64.
> 
> CC: Liviu Dudau <Liviu.Dudau@arm.com>
> CC: Catalin Marinas <catalin.marinas@arm.com>
> CC: Will Deacon <will.deacon@arm.com>
> Tested-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
> Tested-by: Yijing Wang <wangyijing@huawei.com>
> Tested-by: Mark Langsdorf <mlangsdo@redhat.com>
> Tested-by: Jon Masters <jcm@redhat.com>
> Tested-by: Timur Tabi <timur@codeaurora.org>
> Tested-by: Robert Richter <rrichter@cavium.com>
> Acked-by: Robert Richter <rrichter@cavium.com>
> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
> ---
>  arch/arm64/include/asm/pci.h |  6 ++++++
>  arch/arm64/kernel/pci.c      | 25 +++++++++++++++++++++++++
>  2 files changed, 31 insertions(+)
> 
> diff --git a/arch/arm64/include/asm/pci.h b/arch/arm64/include/asm/pci.h
> index 872ba93..fded096 100644
> --- a/arch/arm64/include/asm/pci.h
> +++ b/arch/arm64/include/asm/pci.h
> @@ -24,6 +24,12 @@
>   */
>  #define PCI_DMA_BUS_IS_PHYS	(0)

Hanjun,

>  
> +static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
> +{
> +	/* no legacy IRQ on arm64 */
> +	return -ENODEV;
> +}
> +

Could you explain to me what situation you encountered where you needed
to define this? I'm trying to figure out when this would be needed and the
only thing I can come up with would be for drivers/pnp/resource.c, but that
is guarded by #ifdef CONFIG_PCI, which would mean that you should move this
a bit further down in the file, but also contradicts the last comment on
this patch (i.e. PCI on ACPI is not really implemented, so presumably
CONFIG_PCI is not enabled?)

Best regards,
Liviu


>  extern int isa_dma_bridge_buggy;
>  
>  #ifdef CONFIG_PCI
> diff --git a/arch/arm64/kernel/pci.c b/arch/arm64/kernel/pci.c
> index 6f93c24..4095379 100644
> --- a/arch/arm64/kernel/pci.c
> +++ b/arch/arm64/kernel/pci.c
> @@ -10,6 +10,7 @@
>   *
>   */
>  
> +#include <linux/acpi.h>
>  #include <linux/init.h>
>  #include <linux/io.h>
>  #include <linux/kernel.h>
> @@ -46,3 +47,27 @@ int pcibios_add_device(struct pci_dev *dev)
>  
>  	return 0;
>  }
> +
> +/*
> + * raw_pci_read/write - Platform-specific PCI config space access.
> + */
> +int raw_pci_read(unsigned int domain, unsigned int bus,
> +		  unsigned int devfn, int reg, int len, u32 *val)
> +{
> +	return -ENXIO;
> +}
> +
> +int raw_pci_write(unsigned int domain, unsigned int bus,
> +		unsigned int devfn, int reg, int len, u32 val)
> +{
> +	return -ENXIO;
> +}
> +
> +#ifdef CONFIG_ACPI
> +/* Root bridge scanning */
> +struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
> +{
> +	/* TODO: Should be revisited when implementing PCI on ACPI */
> +	return NULL;
> +}
> +#endif
> -- 
> 1.9.1
> 
> 

-- 
====================
| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
 \ source code!  /
  ---------------
    ¯\_(ツ)_/¯


^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 01/21] ACPI / table: Use pr_debug() instead of pr_info() for MADT table scanning
  2015-03-06 20:31     ` Joe Perches
@ 2015-03-10  2:35       ` Hanjun Guo
  0 siblings, 0 replies; 106+ messages in thread
From: Hanjun Guo @ 2015-03-10  2:35 UTC (permalink / raw)
  To: Joe Perches, Grant Likely
  Cc: Catalin Marinas, Rafael J. Wysocki, Will Deacon, Olof Johansson,
	Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi

On 2015年03月07日 04:31, Joe Perches wrote:
> On Fri, 2015-03-06 at 20:17 +0000, Grant Likely wrote:
>> On Wed, 25 Feb 2015 16:39:41 +0800 Hanjun Guo <hanjun.guo@linaro.org> wrote:
>>> This patch just use pr_debug() instead of pr_info() for ioapic/iosapic,
>>> local apic/x2apic/sapic structures when scanning the MADT table to remove
>>> those verbose information, but leave other structures unchanged.
> []
>> One nitpick below, but don't respin over this, and don't do a fixup.
> []
>>> diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c
> []
>>> @@ -61,9 +63,9 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header)
>>>   		{
>>>   			struct acpi_madt_local_apic *p =
>>>   			    (struct acpi_madt_local_apic *)header;
>>> -			pr_info("LAPIC (acpi_id[0x%02x] lapic_id[0x%02x] %s)\n",
>>> -				p->processor_id, p->id,
>>> -				(p->lapic_flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled");
>>> +			pr_debug("LAPIC (acpi_id[0x%02x] lapic_id[0x%02x] %s)\n",
>>> +				 p->processor_id, p->id,
>>> +				 (p->lapic_flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled");
>>
>> The whitespace changes makes each 1 line change into 3 line changes. In
>> these situations, I would chose to leave the whitespace alone to keep
>> the diffstat as small as possible. It makes it less likely to conflict
>> with other patches and easier to find context.
>
> I think it's mostly better to use a consistent indentation style
> regardless of the number in whitespace changes surrounding the change.

I think both would be fine. Since this patch only touches acpi core
code and ACPI maintainer Rafael already acked it, I will keep it as
it is.

Thanks
Hanjun

^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 05/21] ARM64 / ACPI: Get RSDP and ACPI boot-time tables
  2015-03-05 18:51   ` Lorenzo Pieralisi
@ 2015-03-10  8:01     ` Hanjun Guo
  2015-03-10  9:32       ` Lorenzo Pieralisi
  2015-03-10 11:19       ` Leif Lindholm
  0 siblings, 2 replies; 106+ messages in thread
From: Hanjun Guo @ 2015-03-10  8:01 UTC (permalink / raw)
  To: Lorenzo Pieralisi
  Cc: Catalin Marinas, Rafael J. Wysocki, Will Deacon, Olof Johansson,
	grant.likely, Arnd Bergmann, Mark Rutland, graeme.gregory,
	Sudeep Holla, jcm, Marc Zyngier, Mark Brown, Robert Richter,
	Timur Tabi, Ashwin Chaugule, suravee.suthikulpanit, linux-acpi,
	linux-arm-kernel, linux-kernel, linaro-acpi, Al Stone,
	Tomasz Nowicki, Leif Lindholm

On 2015年03月06日 02:51, Lorenzo Pieralisi wrote:
> On Wed, Feb 25, 2015 at 08:39:45AM +0000, Hanjun Guo wrote:
>> From: Al Stone <al.stone@linaro.org>
>>
>> As we want to get ACPI tables to parse and then use the information
>> for system initialization, we should get the RSDP (Root System
>> Description Pointer) first, it then locates Extended Root Description
>> Table (XSDT) which contains all the 64-bit physical address that
>> pointer to other boot-time tables.
>>
>> Introduce acpi.c and its related head file in this patch to provide
>> fundamental needs of extern variables and functions for ACPI core,
>> and then get boot-time tables as needed.
>>    - asm/acenv.h for arch specific ACPICA environments and
>>      implementation, It is needed unconditionally by ACPI core;
>
> I am not sure we will ever need it since the global lock is not
> needed on HW reduced ACPI (ie ACPI on arm64), and instructions to
> flush the caches are not needed either on arm64.
>
> Anyway, I will have a look if it is worth writing optimized div/shift,
> to give it a purpose to exist.
>
> [...]
>
>> diff --git a/arch/arm64/include/asm/acpi.h b/arch/arm64/include/asm/acpi.h
>> new file mode 100644
>> index 0000000..8b837ab
>> --- /dev/null
>> +++ b/arch/arm64/include/asm/acpi.h
>> @@ -0,0 +1,45 @@
>> +/*
>> + *  Copyright (C) 2013-2014, Linaro Ltd.
>> + *	Author: Al Stone <al.stone@linaro.org>
>> + *	Author: Graeme Gregory <graeme.gregory@linaro.org>
>> + *	Author: Hanjun Guo <hanjun.guo@linaro.org>
>> + *
>> + *  This program is free software; you can redistribute it and/or modify
>> + *  it under the terms of the GNU General Public License version 2 as
>> + *  published by the Free Software Foundation;
>> + */
>> +
>> +#ifndef _ASM_ACPI_H
>> +#define _ASM_ACPI_H
>> +
>> +/* Basic configuration for ACPI */
>> +#ifdef	CONFIG_ACPI
>> +#define acpi_strict 1	/* No out-of-spec workarounds on ARM64 */
>> +extern int acpi_disabled;
>> +extern int acpi_noirq;
>> +extern int acpi_pci_disabled;
>> +
>> +static inline void disable_acpi(void)
>> +{
>> +	acpi_disabled = 1;
>> +	acpi_pci_disabled = 1;
>> +	acpi_noirq = 1;
>> +}
>> +
>> +/*
>> + * It's used from ACPI core in kdump to boot UP system with SMP kernel,
>> + * with this check the ACPI core will not override the CPU index
>> + * obtained from GICC with 0 and not print some error message as well.
>> + * Since MADT must provide at least one GICC structure for GIC
>> + * initialization, CPU will be always available in MADT on ARM64.
>> + */
>> +static inline bool acpi_has_cpu_in_madt(void)
>> +{
>> +	return true;
>> +}
>
> I am still trying to make sense of what's this is used for, to me
> it looks like a legacy hack in acpi_processor.c. It is a shame that we need
> to define functions to paper over legacy hacks that make no sense
> whatsoever on arm64.

I'm sorry that I'm confused, why call this as a "hack"? If I remember
correctly, this is a bugfix for x86 from Redhat folks to test kdump
on UP system but without CPU entries in MADT table [1], and we make it
arch independent to introduce acpi_has_cpu_in_madt().

[1]: commit c401eb8ee37, ACPI / processor: Check if LAPIC is present
during initialization

>
>> +static inline void arch_fix_phys_package_id(int num, u32 slot) { }
>
> This is only used on ia64 to pass the _SUN value to arch code to fix up
> the socket id. See above.
>
> You could define last two functions in generic code, and let the
> arch code that needs them override them.
>
> Whether we do it in this series or later, this stuff needs cleaning up.
>
>> +
>> +#endif /* CONFIG_ACPI */
>> +
>> +#endif /*_ASM_ACPI_H*/
>> diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile
>> index bef04af..218eb7e 100644
>> --- a/arch/arm64/kernel/Makefile
>> +++ b/arch/arm64/kernel/Makefile
>> @@ -34,6 +34,7 @@ arm64-obj-$(CONFIG_KGDB)		+= kgdb.o
>>   arm64-obj-$(CONFIG_EFI)			+= efi.o efi-stub.o efi-entry.o
>>   arm64-obj-$(CONFIG_PCI)			+= pci.o
>>   arm64-obj-$(CONFIG_ARMV8_DEPRECATED)	+= armv8_deprecated.o
>> +arm64-obj-$(CONFIG_ACPI)		+= acpi.o
>>
>>   obj-y					+= $(arm64-obj-y) vdso/
>>   obj-m					+= $(arm64-obj-m)
>> diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c
>> new file mode 100644
>> index 0000000..f052e7a
>> --- /dev/null
>> +++ b/arch/arm64/kernel/acpi.c
>> @@ -0,0 +1,101 @@
>> +/*
>> + *  ARM64 Specific Low-Level ACPI Boot Support
>> + *
>> + *  Copyright (C) 2013-2014, Linaro Ltd.
>> + *	Author: Al Stone <al.stone@linaro.org>
>> + *	Author: Graeme Gregory <graeme.gregory@linaro.org>
>> + *	Author: Hanjun Guo <hanjun.guo@linaro.org>
>> + *	Author: Tomasz Nowicki <tomasz.nowicki@linaro.org>
>> + *	Author: Naresh Bhat <naresh.bhat@linaro.org>
>> + *
>> + *  This program is free software; you can redistribute it and/or modify
>> + *  it under the terms of the GNU General Public License version 2 as
>> + *  published by the Free Software Foundation.
>> + */
>> +
>> +#define pr_fmt(fmt) "ACPI: " fmt
>> +
>> +#include <linux/acpi.h>
>> +#include <linux/bootmem.h>
>> +#include <linux/cpumask.h>
>> +#include <linux/init.h>
>> +#include <linux/irq.h>
>> +#include <linux/irqdomain.h>
>> +#include <linux/memblock.h>
>> +#include <linux/smp.h>
>> +
>> +int acpi_noirq;			/* skip ACPI IRQ initialization */
>> +int acpi_disabled;
>> +EXPORT_SYMBOL(acpi_disabled);
>> +
>> +int acpi_pci_disabled;		/* skip ACPI PCI scan and IRQ initialization */
>> +EXPORT_SYMBOL(acpi_pci_disabled);
>> +
>> +/*
>> + * __acpi_map_table() will be called before page_init(), so early_ioremap()
>> + * or early_memremap() should be called here to for ACPI table mapping.
>> + */
>> +char *__init __acpi_map_table(unsigned long phys, unsigned long size)
>> +{
>> +	if (!phys || !size)
>
> Is there a reason to rule out physical address 0x0 ?

No particular reasons, unless some arch/firmware limits, I'm
not sure if we need this check (x86 needs it), I'm CC Leif
to confirm.

Thanks
Hanjun

^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 08/21] ARM64 / ACPI: Introduce PCI stub functions for ACPI
  2015-03-06 18:31   ` Lorenzo Pieralisi
@ 2015-03-10  9:21     ` Hanjun Guo
  0 siblings, 0 replies; 106+ messages in thread
From: Hanjun Guo @ 2015-03-10  9:21 UTC (permalink / raw)
  To: Lorenzo Pieralisi
  Cc: Catalin Marinas, Rafael J. Wysocki, Will Deacon, Olof Johansson,
	grant.likely, Arnd Bergmann, Mark Rutland, graeme.gregory,
	Sudeep Holla, jcm, Marc Zyngier, Mark Brown, Robert Richter,
	Timur Tabi, Ashwin Chaugule, suravee.suthikulpanit, linux-acpi,
	linux-arm-kernel, linux-kernel, linaro-acpi, Liviu Dudau

On 2015年03月07日 02:31, Lorenzo Pieralisi wrote:
> On Wed, Feb 25, 2015 at 08:39:48AM +0000, Hanjun Guo wrote:
>
> [...]
>
>> diff --git a/arch/arm64/kernel/pci.c b/arch/arm64/kernel/pci.c
>> index 6f93c24..4095379 100644
>> --- a/arch/arm64/kernel/pci.c
>> +++ b/arch/arm64/kernel/pci.c
>> @@ -10,6 +10,7 @@
>>    *
>>    */
>>
>> +#include <linux/acpi.h>
>>   #include <linux/init.h>
>>   #include <linux/io.h>
>>   #include <linux/kernel.h>
>> @@ -46,3 +47,27 @@ int pcibios_add_device(struct pci_dev *dev)
>>
>>   	return 0;
>>   }
>> +
>> +/*
>> + * raw_pci_read/write - Platform-specific PCI config space access.
>> + */
>> +int raw_pci_read(unsigned int domain, unsigned int bus,
>> +		  unsigned int devfn, int reg, int len, u32 *val)
>> +{
>> +	return -ENXIO;
>> +}
>> +
>> +int raw_pci_write(unsigned int domain, unsigned int bus,
>> +		unsigned int devfn, int reg, int len, u32 val)
>> +{
>> +	return -ENXIO;
>> +}
>> +
>
> It would be nice to see:
>
> https://lkml.org/lkml/2015/2/27/264
>
> merged at the same time, so that the two functions above disappear :)

I hope so, but MMCONFIG patches are being taken care of by Bjorn, it
would be nice to merge them through different tree (and it no harms),
and remove those two function when introducing the implementation
of pci_acpi_scan_root() in later patches.

Thanks
Hanjun

^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 05/21] ARM64 / ACPI: Get RSDP and ACPI boot-time tables
  2015-03-10  8:01     ` Hanjun Guo
@ 2015-03-10  9:32       ` Lorenzo Pieralisi
  2015-03-10 11:19       ` Leif Lindholm
  1 sibling, 0 replies; 106+ messages in thread
From: Lorenzo Pieralisi @ 2015-03-10  9:32 UTC (permalink / raw)
  To: Hanjun Guo
  Cc: Catalin Marinas, Rafael J. Wysocki, Will Deacon, Olof Johansson,
	grant.likely, Arnd Bergmann, Mark Rutland, graeme.gregory,
	Sudeep Holla, jcm, Marc Zyngier, Mark Brown, Robert Richter,
	Timur Tabi, Ashwin Chaugule, suravee.suthikulpanit, linux-acpi,
	linux-arm-kernel, linux-kernel, linaro-acpi, Al Stone,
	Tomasz Nowicki, Leif Lindholm

On Tue, Mar 10, 2015 at 08:01:16AM +0000, Hanjun Guo wrote:

[...]

> >> diff --git a/arch/arm64/include/asm/acpi.h b/arch/arm64/include/asm/acpi.h
> >> new file mode 100644
> >> index 0000000..8b837ab
> >> --- /dev/null
> >> +++ b/arch/arm64/include/asm/acpi.h
> >> @@ -0,0 +1,45 @@
> >> +/*
> >> + *  Copyright (C) 2013-2014, Linaro Ltd.
> >> + *	Author: Al Stone <al.stone@linaro.org>
> >> + *	Author: Graeme Gregory <graeme.gregory@linaro.org>
> >> + *	Author: Hanjun Guo <hanjun.guo@linaro.org>
> >> + *
> >> + *  This program is free software; you can redistribute it and/or modify
> >> + *  it under the terms of the GNU General Public License version 2 as
> >> + *  published by the Free Software Foundation;
> >> + */
> >> +
> >> +#ifndef _ASM_ACPI_H
> >> +#define _ASM_ACPI_H
> >> +
> >> +/* Basic configuration for ACPI */
> >> +#ifdef	CONFIG_ACPI
> >> +#define acpi_strict 1	/* No out-of-spec workarounds on ARM64 */
> >> +extern int acpi_disabled;
> >> +extern int acpi_noirq;
> >> +extern int acpi_pci_disabled;
> >> +
> >> +static inline void disable_acpi(void)
> >> +{
> >> +	acpi_disabled = 1;
> >> +	acpi_pci_disabled = 1;
> >> +	acpi_noirq = 1;
> >> +}
> >> +
> >> +/*
> >> + * It's used from ACPI core in kdump to boot UP system with SMP kernel,
> >> + * with this check the ACPI core will not override the CPU index
> >> + * obtained from GICC with 0 and not print some error message as well.
> >> + * Since MADT must provide at least one GICC structure for GIC
> >> + * initialization, CPU will be always available in MADT on ARM64.
> >> + */
> >> +static inline bool acpi_has_cpu_in_madt(void)
> >> +{
> >> +	return true;
> >> +}
> >
> > I am still trying to make sense of what's this is used for, to me
> > it looks like a legacy hack in acpi_processor.c. It is a shame that we need
> > to define functions to paper over legacy hacks that make no sense
> > whatsoever on arm64.
> 
> I'm sorry that I'm confused, why call this as a "hack"? If I remember
> correctly, this is a bugfix for x86 from Redhat folks to test kdump
> on UP system but without CPU entries in MADT table [1], and we make it
> arch independent to introduce acpi_has_cpu_in_madt().

I gathered that, do not tell me it is nice please. ACPI core code
is chock full of things like this that force you to define functions
in arch arm64 since they are called from "generic" code, and I do not
like that, at all.

It can be cleaned up later.

> [1]: commit c401eb8ee37, ACPI / processor: Check if LAPIC is present
> during initialization
> 
> >
> >> +static inline void arch_fix_phys_package_id(int num, u32 slot) { }
> >
> > This is only used on ia64 to pass the _SUN value to arch code to fix up
> > the socket id. See above.
> >
> > You could define last two functions in generic code, and let the
> > arch code that needs them override them.
> >
> > Whether we do it in this series or later, this stuff needs cleaning up.
> >
> >> +
> >> +#endif /* CONFIG_ACPI */
> >> +
> >> +#endif /*_ASM_ACPI_H*/
> >> diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile
> >> index bef04af..218eb7e 100644
> >> --- a/arch/arm64/kernel/Makefile
> >> +++ b/arch/arm64/kernel/Makefile
> >> @@ -34,6 +34,7 @@ arm64-obj-$(CONFIG_KGDB)		+= kgdb.o
> >>   arm64-obj-$(CONFIG_EFI)			+= efi.o efi-stub.o efi-entry.o
> >>   arm64-obj-$(CONFIG_PCI)			+= pci.o
> >>   arm64-obj-$(CONFIG_ARMV8_DEPRECATED)	+= armv8_deprecated.o
> >> +arm64-obj-$(CONFIG_ACPI)		+= acpi.o
> >>
> >>   obj-y					+= $(arm64-obj-y) vdso/
> >>   obj-m					+= $(arm64-obj-m)
> >> diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c
> >> new file mode 100644
> >> index 0000000..f052e7a
> >> --- /dev/null
> >> +++ b/arch/arm64/kernel/acpi.c
> >> @@ -0,0 +1,101 @@
> >> +/*
> >> + *  ARM64 Specific Low-Level ACPI Boot Support
> >> + *
> >> + *  Copyright (C) 2013-2014, Linaro Ltd.
> >> + *	Author: Al Stone <al.stone@linaro.org>
> >> + *	Author: Graeme Gregory <graeme.gregory@linaro.org>
> >> + *	Author: Hanjun Guo <hanjun.guo@linaro.org>
> >> + *	Author: Tomasz Nowicki <tomasz.nowicki@linaro.org>
> >> + *	Author: Naresh Bhat <naresh.bhat@linaro.org>
> >> + *
> >> + *  This program is free software; you can redistribute it and/or modify
> >> + *  it under the terms of the GNU General Public License version 2 as
> >> + *  published by the Free Software Foundation.
> >> + */
> >> +
> >> +#define pr_fmt(fmt) "ACPI: " fmt
> >> +
> >> +#include <linux/acpi.h>
> >> +#include <linux/bootmem.h>
> >> +#include <linux/cpumask.h>
> >> +#include <linux/init.h>
> >> +#include <linux/irq.h>
> >> +#include <linux/irqdomain.h>
> >> +#include <linux/memblock.h>
> >> +#include <linux/smp.h>
> >> +
> >> +int acpi_noirq;			/* skip ACPI IRQ initialization */
> >> +int acpi_disabled;
> >> +EXPORT_SYMBOL(acpi_disabled);
> >> +
> >> +int acpi_pci_disabled;		/* skip ACPI PCI scan and IRQ initialization */
> >> +EXPORT_SYMBOL(acpi_pci_disabled);
> >> +
> >> +/*
> >> + * __acpi_map_table() will be called before page_init(), so early_ioremap()
> >> + * or early_memremap() should be called here to for ACPI table mapping.
> >> + */
> >> +char *__init __acpi_map_table(unsigned long phys, unsigned long size)
> >> +{
> >> +	if (!phys || !size)
> >
> > Is there a reason to rule out physical address 0x0 ?
> 
> No particular reasons, unless some arch/firmware limits, I'm
> not sure if we need this check (x86 needs it), I'm CC Leif
> to confirm.

If there is no particular reason the check should not be there, "x86
needs it" is not a good reason, there is arch specific code for that
in x86 directories.

Ok, let's wait for Leif to confirm that.

Thanks,
Lorenzo

^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 08/21] ARM64 / ACPI: Introduce PCI stub functions for ACPI
  2015-03-09 15:01   ` Liviu Dudau
@ 2015-03-10  9:34     ` Hanjun Guo
  0 siblings, 0 replies; 106+ messages in thread
From: Hanjun Guo @ 2015-03-10  9:34 UTC (permalink / raw)
  To: Liviu Dudau
  Cc: Catalin Marinas, Rafael J. Wysocki, Will Deacon, Olof Johansson,
	grant.likely, Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland,
	graeme.gregory, Sudeep Holla, jcm, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi

On 2015年03月09日 23:01, Liviu Dudau wrote:
> On Wed, Feb 25, 2015 at 08:39:48AM +0000, Hanjun Guo wrote:
>> CONFIG_ACPI depends CONFIG_PCI on x86 and ia64, in ARM64 server
>> world we will have PCIe in most cases, but some of them may not,
>> make CONFIG_ACPI depend CONFIG_PCI on ARM64 will satisfy both.
>>
>> With that case, we need some arch dependent PCI functions to
>> access the config space before the PCI root bridge is created, and
>> pci_acpi_scan_root() to create the PCI root bus. So introduce
>> some stub function here to make ACPI core compile and revisit
>> them later when implemented on ARM64.
>>
>> CC: Liviu Dudau <Liviu.Dudau@arm.com>
>> CC: Catalin Marinas <catalin.marinas@arm.com>
>> CC: Will Deacon <will.deacon@arm.com>
>> Tested-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
>> Tested-by: Yijing Wang <wangyijing@huawei.com>
>> Tested-by: Mark Langsdorf <mlangsdo@redhat.com>
>> Tested-by: Jon Masters <jcm@redhat.com>
>> Tested-by: Timur Tabi <timur@codeaurora.org>
>> Tested-by: Robert Richter <rrichter@cavium.com>
>> Acked-by: Robert Richter <rrichter@cavium.com>
>> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
>> ---
>>   arch/arm64/include/asm/pci.h |  6 ++++++
>>   arch/arm64/kernel/pci.c      | 25 +++++++++++++++++++++++++
>>   2 files changed, 31 insertions(+)
>>
>> diff --git a/arch/arm64/include/asm/pci.h b/arch/arm64/include/asm/pci.h
>> index 872ba93..fded096 100644
>> --- a/arch/arm64/include/asm/pci.h
>> +++ b/arch/arm64/include/asm/pci.h
>> @@ -24,6 +24,12 @@
>>    */
>>   #define PCI_DMA_BUS_IS_PHYS	(0)
>
> Hanjun,

Hi Liviu,

>
>>
>> +static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
>> +{
>> +	/* no legacy IRQ on arm64 */
>> +	return -ENODEV;
>> +}
>> +
>
> Could you explain to me what situation you encountered where you needed
> to define this? I'm trying to figure out when this would be needed and the
> only thing I can come up with would be for drivers/pnp/resource.c, but that
> is guarded by #ifdef CONFIG_PCI, which would mean that you should move this
> a bit further down in the file,

Agreed, will move it to #ifdef CONFIG_PCI .. #endif.

> but also contradicts the last comment on
> this patch (i.e. PCI on ACPI is not really implemented, so presumably
> CONFIG_PCI is not enabled?)

CONFIG_ACPI depends on CONFIG_PCI in the Kconfig, so CONFIG_PCI will be
enabled even PCI on ACPI is not really implemented now, did I
understand your question correctly?

Thanks
Hanjun

^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 05/21] ARM64 / ACPI: Get RSDP and ACPI boot-time tables
  2015-03-10  8:01     ` Hanjun Guo
  2015-03-10  9:32       ` Lorenzo Pieralisi
@ 2015-03-10 11:19       ` Leif Lindholm
  2015-03-10 11:36         ` Hanjun Guo
  1 sibling, 1 reply; 106+ messages in thread
From: Leif Lindholm @ 2015-03-10 11:19 UTC (permalink / raw)
  To: Hanjun Guo
  Cc: Lorenzo Pieralisi, Catalin Marinas, Rafael J. Wysocki,
	Will Deacon, Olof Johansson, grant.likely, Arnd Bergmann,
	Mark Rutland, graeme.gregory, Sudeep Holla, jcm, Marc Zyngier,
	Mark Brown, Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi, Al Stone, Tomasz Nowicki

On Tue, Mar 10, 2015 at 04:01:16PM +0800, Hanjun Guo wrote:
> >>index 0000000..f052e7a
> >>--- /dev/null
> >>+++ b/arch/arm64/kernel/acpi.c
> >>@@ -0,0 +1,101 @@
> >>+/*
> >>+ *  ARM64 Specific Low-Level ACPI Boot Support
> >>+ *
> >>+ *  Copyright (C) 2013-2014, Linaro Ltd.
> >>+ *	Author: Al Stone <al.stone@linaro.org>
> >>+ *	Author: Graeme Gregory <graeme.gregory@linaro.org>
> >>+ *	Author: Hanjun Guo <hanjun.guo@linaro.org>
> >>+ *	Author: Tomasz Nowicki <tomasz.nowicki@linaro.org>
> >>+ *	Author: Naresh Bhat <naresh.bhat@linaro.org>
> >>+ *
> >>+ *  This program is free software; you can redistribute it and/or modify
> >>+ *  it under the terms of the GNU General Public License version 2 as
> >>+ *  published by the Free Software Foundation.
> >>+ */
> >>+
> >>+#define pr_fmt(fmt) "ACPI: " fmt
> >>+
> >>+#include <linux/acpi.h>
> >>+#include <linux/bootmem.h>
> >>+#include <linux/cpumask.h>
> >>+#include <linux/init.h>
> >>+#include <linux/irq.h>
> >>+#include <linux/irqdomain.h>
> >>+#include <linux/memblock.h>
> >>+#include <linux/smp.h>
> >>+
> >>+int acpi_noirq;			/* skip ACPI IRQ initialization */
> >>+int acpi_disabled;
> >>+EXPORT_SYMBOL(acpi_disabled);
> >>+
> >>+int acpi_pci_disabled;		/* skip ACPI PCI scan and IRQ initialization */
> >>+EXPORT_SYMBOL(acpi_pci_disabled);
> >>+
> >>+/*
> >>+ * __acpi_map_table() will be called before page_init(), so early_ioremap()
> >>+ * or early_memremap() should be called here to for ACPI table mapping.
> >>+ */
> >>+char *__init __acpi_map_table(unsigned long phys, unsigned long size)
> >>+{
> >>+	if (!phys || !size)
> >
> >Is there a reason to rule out physical address 0x0 ?
> 
> No particular reasons, unless some arch/firmware limits, I'm
> not sure if we need this check (x86 needs it), I'm CC Leif
> to confirm.

Nothing in UEFI explicitly bans using physical address 0 for anything,
and nothing in the architecture reserves it. So I don't think this
check is necessary.

/
    Leif

^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 13/21] ARM64 / ACPI: Parse MADT for SMP initialization
  2015-03-05 18:49   ` Olof Johansson
@ 2015-03-10 11:33     ` Hanjun Guo
  0 siblings, 0 replies; 106+ messages in thread
From: Hanjun Guo @ 2015-03-10 11:33 UTC (permalink / raw)
  To: Olof Johansson
  Cc: Catalin Marinas, Rafael J. Wysocki, Will Deacon, Grant Likely,
	Lorenzo Pieralisi, Arnd Bergmann, Mark Rutland, Graeme Gregory,
	Sudeep Holla, Jon Masters, Marc Zyngier, Mark Brown,
	Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi, Tomasz Nowicki

Hi Olof,

On 2015年03月06日 02:49, Olof Johansson wrote:
> Hi,
>
> On Wed, Feb 25, 2015 at 04:39:53PM +0800, Hanjun Guo wrote:
>> MADT contains the information for MPIDR which is essential for
>> SMP initialization, parse the GIC cpu interface structures to
>> get the MPIDR value and map it to cpu_logical_map(), and add
>> enabled cpu with valid MPIDR into cpu_possible_map.
>>
>> ACPI 5.1 only has two explicit methods to boot up SMP, PSCI and
>> Parking protocol, but the Parking protocol is only specified for
>> ARMv7 now, so make PSCI as the only way for the SMP boot protocol
>> before some updates for the ACPI spec or the Parking protocol spec.
>>
>> Parking protocol patches for SMP boot will be sent to upstream when
>> the new version of Parking protocol is ready.
>>
>> CC: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
>> CC: Catalin Marinas <catalin.marinas@arm.com>
>> CC: Will Deacon <will.deacon@arm.com>
>> CC: Mark Rutland <mark.rutland@arm.com>
>> Tested-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
>> Tested-by: Yijing Wang <wangyijing@huawei.com>
>> Tested-by: Mark Langsdorf <mlangsdo@redhat.com>
>> Tested-by: Jon Masters <jcm@redhat.com>
>> Tested-by: Timur Tabi <timur@codeaurora.org>
>> Tested-by: Robert Richter <rrichter@cavium.com>
>> Acked-by: Robert Richter <rrichter@cavium.com>
>> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
>> Signed-off-by: Tomasz Nowicki <tomasz.nowicki@linaro.org>
>
> Some nits below. Up to you if you fix incrementally or respin, but I'd like to
> see them fixed for consistency's sake.
>
> Acked-by: Olof Johansson <olof@lixom.net>
>
>> diff --git a/arch/arm64/include/asm/smp.h b/arch/arm64/include/asm/smp.h
>> index 780f82c..bf22650 100644
>> --- a/arch/arm64/include/asm/smp.h
>> +++ b/arch/arm64/include/asm/smp.h
>> @@ -39,9 +39,10 @@ extern void show_ipi_list(struct seq_file *p, int prec);
>>   extern void handle_IPI(int ipinr, struct pt_regs *regs);
>>
>>   /*
>> - * Setup the set of possible CPUs (via set_cpu_possible)
>> + * Discover the set of possible CPUs and determine their
>> + * SMP operations.
>>    */
>> -extern void smp_init_cpus(void);
>> +extern void of_smp_init_cpus(void);
>
> This is inconsistent naming, we use dt some places, of elsewhere.

Do you mean dt_smp_init_cpus() here?

>
>> diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c
>> index bdcc9fc..0f35d87 100644
>> --- a/arch/arm64/kernel/acpi.c
>> +++ b/arch/arm64/kernel/acpi.c
>> @@ -25,6 +25,10 @@
>>   #include <linux/of_fdt.h>
>>   #include <linux/smp.h>
>>
>> +#include <asm/cputype.h>
>> +#include <asm/cpu_ops.h>
>> +#include <asm/smp_plat.h>
>> +
>>   int acpi_noirq = 1;		/* skip ACPI IRQ initialization */
>>   int acpi_disabled = 1;
>>   EXPORT_SYMBOL(acpi_disabled);
>> @@ -32,6 +36,12 @@ EXPORT_SYMBOL(acpi_disabled);
>>   int acpi_pci_disabled = 1;	/* skip ACPI PCI scan and IRQ initialization */
>>   EXPORT_SYMBOL(acpi_pci_disabled);
>>
[...]
>> diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
>> index 97fa7f3..b278311 100644
>> --- a/arch/arm64/kernel/setup.c
>> +++ b/arch/arm64/kernel/setup.c
>> @@ -393,13 +393,16 @@ void __init setup_arch(char **cmdline_p)
>>   	if (acpi_disabled) {
>>   		unflatten_device_tree();
>>   		psci_dt_init();
>> +		cpu_read_bootcpu_ops();
>> +#ifdef CONFIG_SMP
>> +		of_smp_init_cpus();
>> +#endif
>>   	} else {
>>   		psci_acpi_init();
>> +		acpi_init_cpus();
>>   	}
>>
>> -	cpu_read_bootcpu_ops();
>>   #ifdef CONFIG_SMP
>> -	smp_init_cpus();
>>   	smp_build_mpidr_hash();
>>   #endif
>
> I'd rather do without another ifdef above and provide a stub for that function,
> but again it might make sense to just keep a small smp_init_cpus() just as with
> the psci setup.
>
> The cpu_read_bootcpu_ops() should be pushed down to the dt implementation to
> keep the paths more common between acpi and dt.

the declaration of of_smp_init_cpus() is in asm/smp.h, unfortunately
the way asm/smp.h is handled is generally a mess, it only be compiled
in SMP build:

#ifndef CONFIG_SMP
# error "<asm/smp.h> included in non-SMP build"
#endif

so I think we need more cleanup before provide a stub function.

Thanks
Hanjun

^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 05/21] ARM64 / ACPI: Get RSDP and ACPI boot-time tables
  2015-03-10 11:19       ` Leif Lindholm
@ 2015-03-10 11:36         ` Hanjun Guo
  0 siblings, 0 replies; 106+ messages in thread
From: Hanjun Guo @ 2015-03-10 11:36 UTC (permalink / raw)
  To: Leif Lindholm
  Cc: Lorenzo Pieralisi, Catalin Marinas, Rafael J. Wysocki,
	Will Deacon, Olof Johansson, grant.likely, Arnd Bergmann,
	Mark Rutland, graeme.gregory, Sudeep Holla, jcm, Marc Zyngier,
	Mark Brown, Robert Richter, Timur Tabi, Ashwin Chaugule,
	suravee.suthikulpanit, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi, Al Stone, Tomasz Nowicki

On 2015年03月10日 19:19, Leif Lindholm wrote:
> On Tue, Mar 10, 2015 at 04:01:16PM +0800, Hanjun Guo wrote:
>>>> index 0000000..f052e7a
>>>> --- /dev/null
>>>> +++ b/arch/arm64/kernel/acpi.c
>>>> @@ -0,0 +1,101 @@
>>>> +/*
>>>> + *  ARM64 Specific Low-Level ACPI Boot Support
>>>> + *
>>>> + *  Copyright (C) 2013-2014, Linaro Ltd.
>>>> + *	Author: Al Stone <al.stone@linaro.org>
>>>> + *	Author: Graeme Gregory <graeme.gregory@linaro.org>
>>>> + *	Author: Hanjun Guo <hanjun.guo@linaro.org>
>>>> + *	Author: Tomasz Nowicki <tomasz.nowicki@linaro.org>
>>>> + *	Author: Naresh Bhat <naresh.bhat@linaro.org>
>>>> + *
>>>> + *  This program is free software; you can redistribute it and/or modify
>>>> + *  it under the terms of the GNU General Public License version 2 as
>>>> + *  published by the Free Software Foundation.
>>>> + */
>>>> +
>>>> +#define pr_fmt(fmt) "ACPI: " fmt
>>>> +
>>>> +#include <linux/acpi.h>
>>>> +#include <linux/bootmem.h>
>>>> +#include <linux/cpumask.h>
>>>> +#include <linux/init.h>
>>>> +#include <linux/irq.h>
>>>> +#include <linux/irqdomain.h>
>>>> +#include <linux/memblock.h>
>>>> +#include <linux/smp.h>
>>>> +
>>>> +int acpi_noirq;			/* skip ACPI IRQ initialization */
>>>> +int acpi_disabled;
>>>> +EXPORT_SYMBOL(acpi_disabled);
>>>> +
>>>> +int acpi_pci_disabled;		/* skip ACPI PCI scan and IRQ initialization */
>>>> +EXPORT_SYMBOL(acpi_pci_disabled);
>>>> +
>>>> +/*
>>>> + * __acpi_map_table() will be called before page_init(), so early_ioremap()
>>>> + * or early_memremap() should be called here to for ACPI table mapping.
>>>> + */
>>>> +char *__init __acpi_map_table(unsigned long phys, unsigned long size)
>>>> +{
>>>> +	if (!phys || !size)
>>>
>>> Is there a reason to rule out physical address 0x0 ?
>>
>> No particular reasons, unless some arch/firmware limits, I'm
>> not sure if we need this check (x86 needs it), I'm CC Leif
>> to confirm.
>
> Nothing in UEFI explicitly bans using physical address 0 for anything,
> and nothing in the architecture reserves it. So I don't think this
> check is necessary.

Thanks for the confirmation, will remove the !phys check.

Hanjun

^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 18/21] ARM64 / ACPI: Select ACPI_REDUCED_HARDWARE_ONLY if ACPI is enabled on ARM64
  2015-03-06 17:47   ` Lorenzo Pieralisi
@ 2015-03-10 12:23     ` Hanjun Guo
  2015-03-10 14:16       ` Lorenzo Pieralisi
  0 siblings, 1 reply; 106+ messages in thread
From: Hanjun Guo @ 2015-03-10 12:23 UTC (permalink / raw)
  To: Lorenzo Pieralisi
  Cc: Catalin Marinas, Rafael J. Wysocki, Will Deacon, Olof Johansson,
	grant.likely, Arnd Bergmann, Mark Rutland, graeme.gregory,
	Sudeep Holla, jcm, Marc Zyngier, Mark Brown, Robert Richter,
	Timur Tabi, Ashwin Chaugule, suravee.suthikulpanit, linux-acpi,
	linux-arm-kernel, linux-kernel, linaro-acpi, Al Stone

On 2015年03月07日 01:47, Lorenzo Pieralisi wrote:
> On Wed, Feb 25, 2015 at 08:39:58AM +0000, Hanjun Guo wrote:
>> From: Al Stone <al.stone@linaro.org>
>>
>> ACPI reduced hardware mode is disabled by default, but ARM64
>> can only run properly in ACPI hardware reduced mode, so select
>> ACPI_REDUCED_HARDWARE_ONLY if ACPI is enabled on ARM64.
>
> Agreed. This will remove unneeded acpica code. I think though,
> you should also check the FADT flag HW_REDUCED_ACPI at boot to
> make sure that the tables are HW reduced compliant. I am flagging

Agreed, I will add that check on top of this patch set. We explicitly
stated that we are using hardware reduced mode on ARM64 in the doc, so, 
how about print some warning message and go on with the boot if we
got the wrong flag HW_REDUCED_ACPI at boot?

> this up because I noticed code in core code (not guarded by
> ifdef) that checks:
>
> acpi_gbl_reduced_hardware
>
> and if it is not set it goes on instantiating fixed HW devices.
>
> drivers/acpi/scan.c:2567
>
> It is just a heads up, I think it is harmless, but one thing is
> removing acpica code on ACPI HW reduced only, the other is to make
> sure the kernel does not try to use ACPI HW features that acpica
> can't support.

I agree, need some cleanups for the ACPICA code I think, and this
was raised about 1 and half years ago and Intel folks need more
consideration on that [1].

[1]: http://comments.gmane.org/gmane.linux.acpi.devel/63844

Thanks
Hanjun

^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v9 18/21] ARM64 / ACPI: Select ACPI_REDUCED_HARDWARE_ONLY if ACPI is enabled on ARM64
  2015-03-10 12:23     ` Hanjun Guo
@ 2015-03-10 14:16       ` Lorenzo Pieralisi
  0 siblings, 0 replies; 106+ messages in thread
From: Lorenzo Pieralisi @ 2015-03-10 14:16 UTC (permalink / raw)
  To: Hanjun Guo
  Cc: Catalin Marinas, Rafael J. Wysocki, Will Deacon, Olof Johansson,
	grant.likely, Arnd Bergmann, Mark Rutland, graeme.gregory,
	Sudeep Holla, jcm, Marc Zyngier, Mark Brown, Robert Richter,
	Timur Tabi, Ashwin Chaugule, suravee.suthikulpanit, linux-acpi,
	linux-arm-kernel, linux-kernel, linaro-acpi, Al Stone

On Tue, Mar 10, 2015 at 12:23:03PM +0000, Hanjun Guo wrote:
> On 2015年03月07日 01:47, Lorenzo Pieralisi wrote:
> > On Wed, Feb 25, 2015 at 08:39:58AM +0000, Hanjun Guo wrote:
> >> From: Al Stone <al.stone@linaro.org>
> >>
> >> ACPI reduced hardware mode is disabled by default, but ARM64
> >> can only run properly in ACPI hardware reduced mode, so select
> >> ACPI_REDUCED_HARDWARE_ONLY if ACPI is enabled on ARM64.
> >
> > Agreed. This will remove unneeded acpica code. I think though,
> > you should also check the FADT flag HW_REDUCED_ACPI at boot to
> > make sure that the tables are HW reduced compliant. I am flagging
> 
> Agreed, I will add that check on top of this patch set. We explicitly
> stated that we are using hardware reduced mode on ARM64 in the doc, so, 
> how about print some warning message and go on with the boot if we
> got the wrong flag HW_REDUCED_ACPI at boot?

Why would be boot if the ACPI tables are not HW_REDUCED_ACPI compliant ?

To look for trouble :) ? arm64 does not support any other ACPI model,
the missing flag should disable ACPI IMO on arm64.

You could add a check in this patch same place where you check
the FADT version and be done with this.

Thank you !
Lorenzo

> > this up because I noticed code in core code (not guarded by
> > ifdef) that checks:
> >
> > acpi_gbl_reduced_hardware
> >
> > and if it is not set it goes on instantiating fixed HW devices.
> >
> > drivers/acpi/scan.c:2567
> >
> > It is just a heads up, I think it is harmless, but one thing is
> > removing acpica code on ACPI HW reduced only, the other is to make
> > sure the kernel does not try to use ACPI HW features that acpica
> > can't support.
> 
> I agree, need some cleanups for the ACPICA code I think, and this
> was raised about 1 and half years ago and Intel folks need more
> consideration on that [1].
> 
> [1]: http://comments.gmane.org/gmane.linux.acpi.devel/63844
> 
> Thanks
> Hanjun
> 

^ permalink raw reply	[flat|nested] 106+ messages in thread

end of thread, other threads:[~2015-03-10 14:16 UTC | newest]

Thread overview: 106+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-25  8:39 [PATCH v9 00/21] Introduce ACPI for ARM64 based on ACPI 5.1 Hanjun Guo
2015-02-25  8:39 ` [PATCH v9 01/21] ACPI / table: Use pr_debug() instead of pr_info() for MADT table scanning Hanjun Guo
2015-03-04 22:33   ` Rafael J. Wysocki
2015-03-05 17:55   ` Olof Johansson
2015-03-06 20:17   ` Grant Likely
2015-03-06 20:31     ` Joe Perches
2015-03-10  2:35       ` Hanjun Guo
2015-02-25  8:39 ` [PATCH v9 02/21] ACPI / processor: Introduce phys_cpuid_t for CPU hardware ID Hanjun Guo
2015-03-04 22:29   ` Rafael J. Wysocki
2015-03-05  7:44     ` Hanjun Guo
2015-03-05 13:23       ` Rafael J. Wysocki
2015-03-06  6:48         ` Hanjun Guo
2015-03-06 20:19   ` Grant Likely
2015-02-25  8:39 ` [PATCH v9 03/21] ACPI: add arm64 to the platforms that use ioremap Hanjun Guo
2015-03-04 22:33   ` Rafael J. Wysocki
2015-03-06 20:20   ` Grant Likely
2015-02-25  8:39 ` [PATCH v9 04/21] ARM64: allow late use of early_ioremap Hanjun Guo
2015-03-06 20:24   ` Grant Likely
2015-02-25  8:39 ` [PATCH v9 05/21] ARM64 / ACPI: Get RSDP and ACPI boot-time tables Hanjun Guo
2015-03-05 18:10   ` Olof Johansson
2015-03-05 18:51   ` Lorenzo Pieralisi
2015-03-10  8:01     ` Hanjun Guo
2015-03-10  9:32       ` Lorenzo Pieralisi
2015-03-10 11:19       ` Leif Lindholm
2015-03-10 11:36         ` Hanjun Guo
2015-03-06 20:28   ` Grant Likely
2015-02-25  8:39 ` [PATCH v9 06/21] ACPI: fix acpi_os_ioremap for arm64 Hanjun Guo
2015-03-04 22:36   ` Rafael J. Wysocki
2015-03-06 20:30   ` Grant Likely
2015-02-25  8:39 ` [PATCH v9 07/21] ACPI / sleep: Introduce arm64 specific acpi_sleep.c Hanjun Guo
2015-03-04 22:38   ` Rafael J. Wysocki
2015-03-04 22:49     ` G Gregory
2015-03-04 23:25       ` Rafael J. Wysocki
2015-03-05  0:16         ` Rafael J. Wysocki
2015-03-06 12:36           ` Lorenzo Pieralisi
2015-03-06 20:34   ` Grant Likely
2015-02-25  8:39 ` [PATCH v9 08/21] ARM64 / ACPI: Introduce PCI stub functions for ACPI Hanjun Guo
2015-03-06 18:31   ` Lorenzo Pieralisi
2015-03-10  9:21     ` Hanjun Guo
2015-03-06 20:36   ` Grant Likely
2015-03-09 15:01   ` Liviu Dudau
2015-03-10  9:34     ` Hanjun Guo
2015-02-25  8:39 ` [PATCH v9 09/21] ARM64 / ACPI: Introduce early_param "acpi=" to enable/disable ACPI Hanjun Guo
2015-03-05 18:11   ` Olof Johansson
2015-03-06 20:37   ` Grant Likely
2015-02-25  8:39 ` [PATCH v9 10/21] ARM64 / ACPI: If we chose to boot from acpi then disable FDT Hanjun Guo
2015-03-05 18:12   ` Olof Johansson
2015-03-06 20:38   ` Grant Likely
2015-02-25  8:39 ` [PATCH v9 11/21] ARM64 / ACPI: Get PSCI flags in FADT for PSCI init Hanjun Guo
2015-03-05 18:19   ` Olof Johansson
2015-03-06 20:40   ` Grant Likely
2015-02-25  8:39 ` [PATCH v9 12/21] ACPI / table: Print GIC information when MADT is parsed Hanjun Guo
2015-03-04 22:40   ` Rafael J. Wysocki
2015-03-06 18:06   ` Lorenzo Pieralisi
2015-03-06 20:40   ` Grant Likely
2015-02-25  8:39 ` [PATCH v9 13/21] ARM64 / ACPI: Parse MADT for SMP initialization Hanjun Guo
2015-03-05 18:49   ` Olof Johansson
2015-03-10 11:33     ` Hanjun Guo
2015-03-07 22:49   ` Grant Likely
2015-02-25  8:39 ` [PATCH v9 14/21] ACPI / processor: Make it possible to get CPU hardware ID via GICC Hanjun Guo
2015-03-04 22:46   ` Rafael J. Wysocki
2015-03-05  8:03     ` Hanjun Guo
2015-03-05 11:27       ` Catalin Marinas
2015-03-05 13:13         ` Rafael J. Wysocki
2015-03-05 15:19           ` Catalin Marinas
2015-03-06  6:51             ` Hanjun Guo
2015-03-07 22:52   ` Grant Likely
2015-02-25  8:39 ` [PATCH v9 15/21] ARM64 / ACPI: Introduce ACPI_IRQ_MODEL_GIC and register device's gsi Hanjun Guo
2015-03-04 22:47   ` Rafael J. Wysocki
2015-03-07 23:05   ` Grant Likely
2015-02-25  8:39 ` [PATCH v9 16/21] irqchip: Add GICv2 specific ACPI boot support Hanjun Guo
2015-03-04 22:50   ` Rafael J. Wysocki
2015-03-05  9:06     ` Hanjun Guo
2015-03-05 11:53     ` Catalin Marinas
2015-03-06  0:42       ` Rafael J. Wysocki
2015-03-05  8:21   ` Hanjun Guo
2015-03-07 23:14   ` Grant Likely
2015-02-25  8:39 ` [PATCH v9 17/21] clocksource / arch_timer: Parse GTDT to initialize arch timer Hanjun Guo
2015-03-07 23:16   ` Grant Likely
2015-02-25  8:39 ` [PATCH v9 18/21] ARM64 / ACPI: Select ACPI_REDUCED_HARDWARE_ONLY if ACPI is enabled on ARM64 Hanjun Guo
2015-03-06 17:47   ` Lorenzo Pieralisi
2015-03-10 12:23     ` Hanjun Guo
2015-03-10 14:16       ` Lorenzo Pieralisi
2015-03-07 23:16   ` Grant Likely
2015-02-25  8:39 ` [PATCH v9 19/21] ARM64 / ACPI: Enable ARM64 in Kconfig Hanjun Guo
2015-03-04 22:52   ` Rafael J. Wysocki
2015-03-07 23:17   ` Grant Likely
2015-02-25  8:40 ` [PATCH v9 20/21] Documentation: ACPI for ARM64 Hanjun Guo
2015-02-27 10:53   ` Shannon Zhao
2015-02-27 11:13     ` Shannon Zhao
2015-02-27 11:20   ` Shannon Zhao
2015-02-25  8:40 ` [PATCH v9 21/21] ARM64 / ACPI: additions of ACPI documentation for arm64 Hanjun Guo
2015-02-27 11:22   ` Shannon Zhao
2015-02-27 14:19     ` Hanjun Guo
2015-03-05 18:54   ` Olof Johansson
2015-02-27  3:20 ` [PATCH v9 00/21] Introduce ACPI for ARM64 based on ACPI 5.1 Timur Tabi
2015-02-27  8:37   ` Hanjun Guo
2015-02-27 10:51     ` Shannon Zhao
2015-02-27  8:50   ` Ard Biesheuvel
2015-02-27 10:36     ` Mark Rutland
2015-02-27 21:05     ` Timur Tabi
2015-03-04 23:18     ` Timur Tabi
2015-03-04 22:56 ` Rafael J. Wysocki
2015-03-05  7:03   ` Hanjun Guo
2015-03-05 18:57 ` Olof Johansson
2015-03-06  4:26   ` Hanjun Guo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).