LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH v10 00/21] Introduce ACPI for ARM64 based on ACPI 5.1
@ 2015-03-11 12:39 Hanjun Guo
  2015-03-11 12:39 ` [PATCH v10 01/21] ACPI / table: Use pr_debug() instead of pr_info() for MADT table scanning Hanjun Guo
                   ` (23 more replies)
  0 siblings, 24 replies; 89+ messages in thread
From: Hanjun Guo @ 2015-03-11 12: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

This patch set already tested on multi platforms:
 - AMD Seattle board;
 - Cavium Thunder board;
 - Huawei D02 board;
 - Qualcomm ARM64 platform

This version 10 patch set address some minor comments and collect ACKs and
Reviewed-bys for v9:

 - new Acks from Rafael, Olof, Grant, Lorenzo
 - new way to handle typdef phys_cpuid_t which suggested by Rafael,
   but no functional change
 - Remove if(!phys) for early ioremappings
 - Rework sleep function for ARM64
 - Introduce linux/acpi_irq.h to hold acpi_irq_init()
 - Disable ACPI if not HW_REDUCED_ACPI compliant
 - Remove the doc of why ACPI on ARM

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 CONFIG_ACPI_GENERIC_SLEEP
  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
  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: Introduce phys_cpuid_t for CPU hardware ID
  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 | 593 ++++++++++++++++++++++++++++++
 Documentation/arm64/arm-acpi.txt          | 505 +++++++++++++++++++++++++
 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/irq.h              |  13 +
 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                  | 392 ++++++++++++++++++++
 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/Kconfig                         |   1 +
 arch/ia64/kernel/acpi.c                   |   2 +-
 arch/x86/Kconfig                          |   1 +
 arch/x86/kernel/acpi/boot.c               |   2 +-
 drivers/acpi/Kconfig                      |   7 +-
 drivers/acpi/Makefile                     |   2 +-
 drivers/acpi/acpi_processor.c             |   7 +-
 drivers/acpi/bus.c                        |   3 +
 drivers/acpi/internal.h                   |   4 +
 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                      |   8 +-
 include/linux/acpi_irq.h                  |  10 +
 include/linux/clocksource.h               |   6 +
 include/linux/irqchip/arm-gic-acpi.h      |  31 ++
 41 files changed, 2121 insertions(+), 105 deletions(-)
 create mode 100644 Documentation/arm64/acpi_object_usage.txt
 create mode 100644 Documentation/arm64/arm-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 include/linux/acpi_irq.h
 create mode 100644 include/linux/irqchip/arm-gic-acpi.h

-- 
1.9.1


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

* [PATCH v10 01/21] ACPI / table: Use pr_debug() instead of pr_info() for MADT table scanning
  2015-03-11 12:39 [PATCH v10 00/21] Introduce ACPI for ARM64 based on ACPI 5.1 Hanjun Guo
@ 2015-03-11 12:39 ` Hanjun Guo
  2015-03-11 12:39 ` [PATCH v10 02/21] ACPI: add arm64 to the platforms that use ioremap Hanjun Guo
                   ` (22 subsequent siblings)
  23 siblings, 0 replies; 89+ messages in thread
From: Hanjun Guo @ 2015-03-11 12: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>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Olof Johansson <olof@lixom.net>
Acked-by: Grant Likely <grant.likely@linaro.org>
Tested-by: Timur Tabi <timur@codeaurora.org>
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	[flat|nested] 89+ messages in thread

* [PATCH v10 02/21] ACPI: add arm64 to the platforms that use ioremap
  2015-03-11 12:39 [PATCH v10 00/21] Introduce ACPI for ARM64 based on ACPI 5.1 Hanjun Guo
  2015-03-11 12:39 ` [PATCH v10 01/21] ACPI / table: Use pr_debug() instead of pr_info() for MADT table scanning Hanjun Guo
@ 2015-03-11 12:39 ` Hanjun Guo
  2015-03-11 12:39 ` [PATCH v10 03/21] ARM64: allow late use of early_ioremap Hanjun Guo
                   ` (21 subsequent siblings)
  23 siblings, 0 replies; 89+ messages in thread
From: Hanjun Guo @ 2015-03-11 12: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>
Tested-by: Timur Tabi <timur@codeaurora.org>
Acked-by: Robert Richter <rrichter@cavium.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Grant Likely <grant.likely@linaro.org>
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	[flat|nested] 89+ messages in thread

* [PATCH v10 03/21] ARM64: allow late use of early_ioremap
  2015-03-11 12:39 [PATCH v10 00/21] Introduce ACPI for ARM64 based on ACPI 5.1 Hanjun Guo
  2015-03-11 12:39 ` [PATCH v10 01/21] ACPI / table: Use pr_debug() instead of pr_info() for MADT table scanning Hanjun Guo
  2015-03-11 12:39 ` [PATCH v10 02/21] ACPI: add arm64 to the platforms that use ioremap Hanjun Guo
@ 2015-03-11 12:39 ` Hanjun Guo
  2015-03-11 12:39 ` [PATCH v10 04/21] ARM64 / ACPI: Get RSDP and ACPI boot-time tables Hanjun Guo
                   ` (20 subsequent siblings)
  23 siblings, 0 replies; 89+ messages in thread
From: Hanjun Guo @ 2015-03-11 12: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>
Tested-by: Timur Tabi <timur@codeaurora.org>
Acked-by: Robert Richter <rrichter@cavium.com>
Reviewed-by: Grant Likely <grant.likely@linaro.org>
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	[flat|nested] 89+ messages in thread

* [PATCH v10 04/21] ARM64 / ACPI: Get RSDP and ACPI boot-time tables
  2015-03-11 12:39 [PATCH v10 00/21] Introduce ACPI for ARM64 based on ACPI 5.1 Hanjun Guo
                   ` (2 preceding siblings ...)
  2015-03-11 12:39 ` [PATCH v10 03/21] ARM64: allow late use of early_ioremap Hanjun Guo
@ 2015-03-11 12:39 ` Hanjun Guo
  2015-03-11 12:39 ` [PATCH v10 05/21] ACPI: fix acpi_os_ioremap for arm64 Hanjun Guo
                   ` (19 subsequent siblings)
  23 siblings, 0 replies; 89+ messages in thread
From: Hanjun Guo @ 2015-03-11 12: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>
Acked-by: Olof Johansson <olof@lixom.net>
Acked-by: Grant Likely <grant.likely@linaro.org>
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 5ee07ee..fdc7877 100644
--- a/arch/arm64/kernel/Makefile
+++ b/arch/arm64/kernel/Makefile
@@ -35,6 +35,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..7abac24
--- /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 (!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] 89+ messages in thread

* [PATCH v10 05/21] ACPI: fix acpi_os_ioremap for arm64
  2015-03-11 12:39 [PATCH v10 00/21] Introduce ACPI for ARM64 based on ACPI 5.1 Hanjun Guo
                   ` (3 preceding siblings ...)
  2015-03-11 12:39 ` [PATCH v10 04/21] ARM64 / ACPI: Get RSDP and ACPI boot-time tables Hanjun Guo
@ 2015-03-11 12:39 ` Hanjun Guo
  2015-03-11 12:39 ` [PATCH v10 06/21] ACPI / sleep: Introduce CONFIG_ACPI_GENERIC_SLEEP Hanjun Guo
                   ` (18 subsequent siblings)
  23 siblings, 0 replies; 89+ messages in thread
From: Hanjun Guo @ 2015-03-11 12: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>
Tested-by: Timur Tabi <timur@codeaurora.org>
Acked-by: Robert Richter <rrichter@cavium.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Grant Likely <grant.likely@linaro.org>
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	[flat|nested] 89+ messages in thread

* [PATCH v10 06/21] ACPI / sleep: Introduce CONFIG_ACPI_GENERIC_SLEEP
  2015-03-11 12:39 [PATCH v10 00/21] Introduce ACPI for ARM64 based on ACPI 5.1 Hanjun Guo
                   ` (4 preceding siblings ...)
  2015-03-11 12:39 ` [PATCH v10 05/21] ACPI: fix acpi_os_ioremap for arm64 Hanjun Guo
@ 2015-03-11 12:39 ` Hanjun Guo
  2015-03-12  9:32   ` Lorenzo Pieralisi
  2015-03-12 22:57   ` Rafael J. Wysocki
  2015-03-11 12:39 ` [PATCH v10 07/21] ARM64 / ACPI: Introduce PCI stub functions for ACPI Hanjun Guo
                   ` (17 subsequent siblings)
  23 siblings, 2 replies; 89+ messages in thread
From: Hanjun Guo @ 2015-03-11 12: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() and acpi_sleep_init()
for device power management, so introduce CONFIG_ACPI_GENERIC_SLEEP
and select it for x86 and ia64 only to make sleep functions available,
and also introduce stub function to allow other drivers to function
until S states are defined for ARM64.

It will be no functional change for x86 and IA64.

CC: Rafael J. Wysocki <rjw@rjwysocki.net>
Suggested-by: Rafael J. Wysocki <rafael.j.wysocki@intel.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/ia64/Kconfig       | 1 +
 arch/x86/Kconfig        | 1 +
 drivers/acpi/Kconfig    | 4 ++++
 drivers/acpi/Makefile   | 2 +-
 drivers/acpi/internal.h | 4 ++++
 5 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
index 074e52b..e8728d7 100644
--- a/arch/ia64/Kconfig
+++ b/arch/ia64/Kconfig
@@ -10,6 +10,7 @@ config IA64
 	select ARCH_MIGHT_HAVE_PC_SERIO
 	select PCI if (!IA64_HP_SIM)
 	select ACPI if (!IA64_HP_SIM)
+	select ACPI_GENERIC_SLEEP if ACPI
 	select ARCH_MIGHT_HAVE_ACPI_PDC if ACPI
 	select HAVE_UNSTABLE_SCHED_CLOCK
 	select HAVE_IDE
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index b7d31ca..9804431 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -22,6 +22,7 @@ config X86_64
 ### Arch settings
 config X86
 	def_bool y
+	select ACPI_GENERIC_SLEEP if ACPI
 	select ARCH_MIGHT_HAVE_ACPI_PDC if ACPI
 	select ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
 	select ARCH_HAS_FAST_MULTIPLIER
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index e6c3ddd..a7b9120 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -48,9 +48,13 @@ config ACPI_LEGACY_TABLES_LOOKUP
 config ARCH_MIGHT_HAVE_ACPI_PDC
 	bool
 
+config ACPI_GENERIC_SLEEP
+	bool
+
 config ACPI_SLEEP
 	bool
 	depends on SUSPEND || HIBERNATION
+	depends on ACPI_GENERIC_SLEEP
 	default y
 
 config ACPI_PROCFS_POWER
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
index 623b117..2397822 100644
--- a/drivers/acpi/Makefile
+++ b/drivers/acpi/Makefile
@@ -23,7 +23,7 @@ acpi-y				+= nvs.o
 
 # Power management related files
 acpi-y				+= wakeup.o
-acpi-y				+= sleep.o
+acpi-$(CONFIG_ACPI_GENERIC_SLEEP) += sleep.o
 acpi-y				+= device_pm.o
 acpi-$(CONFIG_ACPI_SLEEP)	+= proc.o
 
diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h
index 56b321a..b5eef4c 100644
--- a/drivers/acpi/internal.h
+++ b/drivers/acpi/internal.h
@@ -161,7 +161,11 @@ void acpi_ec_remove_query_handler(struct acpi_ec *ec, u8 query_bit);
 /*--------------------------------------------------------------------------
                                   Suspend/Resume
   -------------------------------------------------------------------------- */
+#ifdef CONFIG_ACPI_GENERIC_SLEEP
 extern int acpi_sleep_init(void);
+#else
+static inline int acpi_sleep_init(void) { return -ENOSYS; }
+#endif
 
 #ifdef CONFIG_ACPI_SLEEP
 int acpi_sleep_proc_init(void);
-- 
1.9.1


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

* [PATCH v10 07/21] ARM64 / ACPI: Introduce PCI stub functions for ACPI
  2015-03-11 12:39 [PATCH v10 00/21] Introduce ACPI for ARM64 based on ACPI 5.1 Hanjun Guo
                   ` (5 preceding siblings ...)
  2015-03-11 12:39 ` [PATCH v10 06/21] ACPI / sleep: Introduce CONFIG_ACPI_GENERIC_SLEEP Hanjun Guo
@ 2015-03-11 12:39 ` Hanjun Guo
  2015-03-11 12:39 ` [PATCH v10 08/21] ARM64 / ACPI: Introduce early_param "acpi=" to enable/disable ACPI Hanjun Guo
                   ` (16 subsequent siblings)
  23 siblings, 0 replies; 89+ messages in thread
From: Hanjun Guo @ 2015-03-11 12: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>
Reviewed-by: Grant Likely <grant.likely@linaro.org>
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..b008a72 100644
--- a/arch/arm64/include/asm/pci.h
+++ b/arch/arm64/include/asm/pci.h
@@ -27,6 +27,12 @@
 extern int isa_dma_bridge_buggy;
 
 #ifdef CONFIG_PCI
+static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
+{
+	/* no legacy IRQ on arm64 */
+	return -ENODEV;
+}
+
 static inline int pci_proc_domain(struct pci_bus *bus)
 {
 	return 1;
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] 89+ messages in thread

* [PATCH v10 08/21] ARM64 / ACPI: Introduce early_param "acpi=" to enable/disable ACPI
  2015-03-11 12:39 [PATCH v10 00/21] Introduce ACPI for ARM64 based on ACPI 5.1 Hanjun Guo
                   ` (6 preceding siblings ...)
  2015-03-11 12:39 ` [PATCH v10 07/21] ARM64 / ACPI: Introduce PCI stub functions for ACPI Hanjun Guo
@ 2015-03-11 12:39 ` Hanjun Guo
  2015-03-18 11:35   ` Lorenzo Pieralisi
  2015-03-11 12:39 ` [PATCH v10 09/21] ARM64 / ACPI: If we chose to boot from acpi then disable FDT Hanjun Guo
                   ` (15 subsequent siblings)
  23 siblings, 1 reply; 89+ messages in thread
From: Hanjun Guo @ 2015-03-11 12: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>
Acked-by: Olof Johansson <olof@lixom.net>
Acked-by: Grant Likely <grant.likely@linaro.org>
Tested-by: Timur Tabi <timur@codeaurora.org>
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 7abac24..2269e30 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 param_acpi_off __initdata;
+static bool param_acpi_force __initdata;
+
+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] 89+ messages in thread

* [PATCH v10 09/21] ARM64 / ACPI: If we chose to boot from acpi then disable FDT
  2015-03-11 12:39 [PATCH v10 00/21] Introduce ACPI for ARM64 based on ACPI 5.1 Hanjun Guo
                   ` (7 preceding siblings ...)
  2015-03-11 12:39 ` [PATCH v10 08/21] ARM64 / ACPI: Introduce early_param "acpi=" to enable/disable ACPI Hanjun Guo
@ 2015-03-11 12:39 ` Hanjun Guo
  2015-03-18 16:52   ` Catalin Marinas
  2015-03-11 12:39 ` [PATCH v10 10/21] ARM64 / ACPI: Get PSCI flags in FADT for PSCI init Hanjun Guo
                   ` (14 subsequent siblings)
  23 siblings, 1 reply; 89+ messages in thread
From: Hanjun Guo @ 2015-03-11 12: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>
Acked-by: Olof Johansson <olof@lixom.net>
Acked-by: Grant Likely <grant.likely@linaro.org>
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	[flat|nested] 89+ messages in thread

* [PATCH v10 10/21] ARM64 / ACPI: Get PSCI flags in FADT for PSCI init
  2015-03-11 12:39 [PATCH v10 00/21] Introduce ACPI for ARM64 based on ACPI 5.1 Hanjun Guo
                   ` (8 preceding siblings ...)
  2015-03-11 12:39 ` [PATCH v10 09/21] ARM64 / ACPI: If we chose to boot from acpi then disable FDT Hanjun Guo
@ 2015-03-11 12:39 ` Hanjun Guo
  2015-03-13 14:51   ` Lorenzo Pieralisi
  2015-03-11 12:39 ` [PATCH v10 11/21] ACPI / table: Print GIC information when MADT is parsed Hanjun Guo
                   ` (13 subsequent siblings)
  23 siblings, 1 reply; 89+ messages in thread
From: Hanjun Guo @ 2015-03-11 12: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>
Acked-by: Olof Johansson <olof@lixom.net>
Acked-by: Grant Likely <grant.likely@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/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 9b8a70a..d3c52ce 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>
@@ -273,6 +275,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.
@@ -306,29 +335,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);
@@ -381,7 +388,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;
@@ -396,6 +403,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] 89+ messages in thread

* [PATCH v10 11/21] ACPI / table: Print GIC information when MADT is parsed
  2015-03-11 12:39 [PATCH v10 00/21] Introduce ACPI for ARM64 based on ACPI 5.1 Hanjun Guo
                   ` (9 preceding siblings ...)
  2015-03-11 12:39 ` [PATCH v10 10/21] ARM64 / ACPI: Get PSCI flags in FADT for PSCI init Hanjun Guo
@ 2015-03-11 12:39 ` Hanjun Guo
  2015-03-11 12:39 ` [PATCH v10 12/21] ARM64 / ACPI: Parse MADT for SMP initialization Hanjun Guo
                   ` (12 subsequent siblings)
  23 siblings, 0 replies; 89+ messages in thread
From: Hanjun Guo @ 2015-03-11 12: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)

This 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>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Acked-by: Grant Likely <grant.likely@linaro.org>
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	[flat|nested] 89+ messages in thread

* [PATCH v10 12/21] ARM64 / ACPI: Parse MADT for SMP initialization
  2015-03-11 12:39 [PATCH v10 00/21] Introduce ACPI for ARM64 based on ACPI 5.1 Hanjun Guo
                   ` (10 preceding siblings ...)
  2015-03-11 12:39 ` [PATCH v10 11/21] ACPI / table: Print GIC information when MADT is parsed Hanjun Guo
@ 2015-03-11 12:39 ` Hanjun Guo
  2015-03-11 12:39 ` [PATCH v10 13/21] ACPI / processor: Introduce phys_cpuid_t for CPU hardware ID Hanjun Guo
                   ` (11 subsequent siblings)
  23 siblings, 0 replies; 89+ messages in thread
From: Hanjun Guo @ 2015-03-11 12: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>
Acked-by: Olof Johansson <olof@lixom.net>
Reviewed-by: Grant Likely <grant.likely@linaro.org>
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 2269e30..c9203c0 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 bootcpu_valid  __initdata;
+
 static bool param_acpi_off __initdata;
 static bool param_acpi_force __initdata;
 
@@ -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] 89+ messages in thread

* [PATCH v10 13/21] ACPI / processor: Introduce phys_cpuid_t for CPU hardware ID
  2015-03-11 12:39 [PATCH v10 00/21] Introduce ACPI for ARM64 based on ACPI 5.1 Hanjun Guo
                   ` (11 preceding siblings ...)
  2015-03-11 12:39 ` [PATCH v10 12/21] ARM64 / ACPI: Parse MADT for SMP initialization Hanjun Guo
@ 2015-03-11 12:39 ` Hanjun Guo
  2015-03-12  9:51   ` Lorenzo Pieralisi
  2015-03-11 12:39 ` [PATCH v10 14/21] ACPI / processor: Make it possible to get CPU hardware ID via GICC Hanjun Guo
                   ` (10 subsequent siblings)
  23 siblings, 1 reply; 89+ messages in thread
From: Hanjun Guo @ 2015-03-11 12: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 for the 64 bit CPU hardware ID
in the following patch.

CC: Rafael J Wysocki <rjw@rjwysocki.net>
Suggested-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: Grant Likely <grant.likely@linaro.org>
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/kernel/acpi.c       |  2 +-
 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          |  7 ++++++-
 6 files changed, 30 insertions(+), 24 deletions(-)

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/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..58f335c 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 == PHYS_CPUID_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 == PHYS_CPUID_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..51cc299 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 = PHYS_CPUID_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 = PHYS_CPUID_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 == PHYS_CPUID_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 == PHYS_CPUID_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 PHYS_CPUID_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..6ec33c5 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -146,9 +146,14 @@ void acpi_numa_x2apic_affinity_init(struct acpi_srat_x2apic_cpu_affinity *pa);
 int acpi_numa_memory_affinity_init (struct acpi_srat_mem_affinity *ma);
 void acpi_numa_arch_fixup(void);
 
+#ifndef PHYS_CPUID_INVALID
+typedef u32 phys_cpuid_t;
+#define PHYS_CPUID_INVALID (phys_cpuid_t)(-1)
+#endif
+
 #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] 89+ messages in thread

* [PATCH v10 14/21] ACPI / processor: Make it possible to get CPU hardware ID via GICC
  2015-03-11 12:39 [PATCH v10 00/21] Introduce ACPI for ARM64 based on ACPI 5.1 Hanjun Guo
                   ` (12 preceding siblings ...)
  2015-03-11 12:39 ` [PATCH v10 13/21] ACPI / processor: Introduce phys_cpuid_t for CPU hardware ID Hanjun Guo
@ 2015-03-11 12:39 ` Hanjun Guo
  2015-03-12 15:41   ` Lorenzo Pieralisi
  2015-03-12 23:02   ` Rafael J. Wysocki
  2015-03-11 12:39 ` [PATCH v10 15/21] ARM64 / ACPI: Introduce ACPI_IRQ_MODEL_GIC and register device's gsi Hanjun Guo
                   ` (9 subsequent siblings)
  23 siblings, 2 replies; 89+ messages in thread
From: Hanjun Guo @ 2015-03-11 12: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, since MPIDR for ARM64 is
64-bit, so typedef u64 for phys_cpuid_t.

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>
Reviewed-by: Grant Likely <grant.likely@linaro.org>
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..eea0bc3 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 PHYS_CPUID_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 51cc299..b1ec78b 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] 89+ messages in thread

* [PATCH v10 15/21] ARM64 / ACPI: Introduce ACPI_IRQ_MODEL_GIC and register device's gsi
  2015-03-11 12:39 [PATCH v10 00/21] Introduce ACPI for ARM64 based on ACPI 5.1 Hanjun Guo
                   ` (13 preceding siblings ...)
  2015-03-11 12:39 ` [PATCH v10 14/21] ACPI / processor: Make it possible to get CPU hardware ID via GICC Hanjun Guo
@ 2015-03-11 12:39 ` Hanjun Guo
  2015-03-18 18:41   ` Will Deacon
  2015-03-11 12:39 ` [PATCH v10 16/21] irqchip: Add GICv2 specific ACPI boot support Hanjun Guo
                   ` (8 subsequent siblings)
  23 siblings, 1 reply; 89+ messages in thread
From: Hanjun Guo @ 2015-03-11 12: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>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Grant Likely <grant.likely@linaro.org>
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 c9203c0..dec6f8a 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 6ec33c5..de4e86f 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] 89+ messages in thread

* [PATCH v10 16/21] irqchip: Add GICv2 specific ACPI boot support
  2015-03-11 12:39 [PATCH v10 00/21] Introduce ACPI for ARM64 based on ACPI 5.1 Hanjun Guo
                   ` (14 preceding siblings ...)
  2015-03-11 12:39 ` [PATCH v10 15/21] ARM64 / ACPI: Introduce ACPI_IRQ_MODEL_GIC and register device's gsi Hanjun Guo
@ 2015-03-11 12:39 ` Hanjun Guo
       [not found]   ` <CACxGe6uWwts6X=Yc2ioBdQizXkF1_YgoNNOsREWirk2MFBVDHg@mail.gmail.com>
  2015-03-14 18:44   ` Jason Cooper
  2015-03-11 12:39 ` [PATCH v10 17/21] clocksource / arch_timer: Parse GTDT to initialize arch timer Hanjun Guo
                   ` (7 subsequent siblings)
  23 siblings, 2 replies; 89+ messages in thread
From: Hanjun Guo @ 2015-03-11 12: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>
Reviewed-by: Grant Likely <grant.likely@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        |   2 +
 arch/arm64/include/asm/irq.h         |  13 +++++
 arch/arm64/kernel/acpi.c             |  25 +++++++++
 drivers/irqchip/irq-gic.c            | 102 +++++++++++++++++++++++++++++++++++
 drivers/irqchip/irqchip.c            |   3 ++
 include/linux/acpi_irq.h             |  10 ++++
 include/linux/irqchip/arm-gic-acpi.h |  31 +++++++++++
 7 files changed, 186 insertions(+)
 create mode 100644 include/linux/acpi_irq.h
 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 eea0bc3..59c05d8 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/include/asm/irq.h b/arch/arm64/include/asm/irq.h
index 94c5367..bbb251b 100644
--- a/arch/arm64/include/asm/irq.h
+++ b/arch/arm64/include/asm/irq.h
@@ -1,6 +1,8 @@
 #ifndef __ASM_IRQ_H
 #define __ASM_IRQ_H
 
+#include <linux/irqchip/arm-gic-acpi.h>
+
 #include <asm-generic/irq.h>
 
 struct pt_regs;
@@ -8,4 +10,15 @@ struct pt_regs;
 extern void migrate_irqs(void);
 extern void set_handle_irq(void (*handle_irq)(struct pt_regs *));
 
+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
+
 #endif
diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c
index dec6f8a..6468f88 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..afd1af3 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_irq.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_irq.h b/include/linux/acpi_irq.h
new file mode 100644
index 0000000..e4e8a81
--- /dev/null
+++ b/include/linux/acpi_irq.h
@@ -0,0 +1,10 @@
+#ifndef _LINUX_ACPI_IRQ_H
+#define _LINUX_ACPI_IRQ_H
+
+#include <asm/irq.h>
+
+#ifndef acpi_irq_init
+static inline void acpi_irq_init(void) { }
+#endif
+
+#endif /* _LINUX_ACPI_IRQ_H */
diff --git a/include/linux/irqchip/arm-gic-acpi.h b/include/linux/irqchip/arm-gic-acpi.h
new file mode 100644
index 0000000..de3419e
--- /dev/null
+++ b/include/linux/irqchip/arm-gic-acpi.h
@@ -0,0 +1,31 @@
+/*
+ * 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);
+#else
+static inline void acpi_gic_init(void) { }
+#endif
+
+#endif /* ARM_GIC_ACPI_H_ */
-- 
1.9.1


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

* [PATCH v10 17/21] clocksource / arch_timer: Parse GTDT to initialize arch timer
  2015-03-11 12:39 [PATCH v10 00/21] Introduce ACPI for ARM64 based on ACPI 5.1 Hanjun Guo
                   ` (15 preceding siblings ...)
  2015-03-11 12:39 ` [PATCH v10 16/21] irqchip: Add GICv2 specific ACPI boot support Hanjun Guo
@ 2015-03-11 12:39 ` Hanjun Guo
  2015-03-18 18:34   ` Will Deacon
  2015-03-20 13:49   ` Daniel Lezcano
  2015-03-11 12:39 ` [PATCH v10 18/21] ARM64 / ACPI: Select ACPI_REDUCED_HARDWARE_ONLY if ACPI is enabled on ARM64 Hanjun Guo
                   ` (6 subsequent siblings)
  23 siblings, 2 replies; 89+ messages in thread
From: Hanjun Guo @ 2015-03-11 12: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>
Reviewed-by: Grant Likely <grant.likely@linaro.org>
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	[flat|nested] 89+ messages in thread

* [PATCH v10 18/21] ARM64 / ACPI: Select ACPI_REDUCED_HARDWARE_ONLY if ACPI is enabled on ARM64
  2015-03-11 12:39 [PATCH v10 00/21] Introduce ACPI for ARM64 based on ACPI 5.1 Hanjun Guo
                   ` (16 preceding siblings ...)
  2015-03-11 12:39 ` [PATCH v10 17/21] clocksource / arch_timer: Parse GTDT to initialize arch timer Hanjun Guo
@ 2015-03-11 12:39 ` Hanjun Guo
  2015-03-12 18:21   ` Lorenzo Pieralisi
  2015-03-11 12:39 ` [PATCH v10 19/21] ARM64 / ACPI: Enable ARM64 in Kconfig Hanjun Guo
                   ` (5 subsequent siblings)
  23 siblings, 1 reply; 89+ messages in thread
From: Hanjun Guo @ 2015-03-11 12: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.

If the firmware is not using hardware reduced ACPI mode, we
will disable ACPI to avoid nightmare such as accessing some
registers which are not available 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 +
 arch/arm64/kernel/acpi.c | 8 +++++++-
 2 files changed, 8 insertions(+), 1 deletion(-)

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
diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c
index 6468f88..5819ef7 100644
--- a/arch/arm64/kernel/acpi.c
+++ b/arch/arm64/kernel/acpi.c
@@ -303,6 +303,11 @@ static int __init acpi_parse_fadt(struct acpi_table_header *table)
 	 */
 	if (table->revision > 5 ||
 	    (table->revision == 5 && fadt->minor_revision >= 1)) {
+		if (!acpi_gbl_reduced_hardware) {
+			pr_err("Not hardware reduced ACPI mode, will not be supported\n");
+			goto disable_acpi;
+		}
+
 		/*
 		 * ACPI 5.1 only has two explicit methods to boot up SMP,
 		 * PSCI and Parking protocol, but the Parking protocol is
@@ -319,8 +324,9 @@ static int __init acpi_parse_fadt(struct acpi_table_header *table)
 
 	pr_warn("Unsupported FADT revision %d.%d, should be 5.1+, will disable ACPI\n",
 		table->revision, fadt->minor_revision);
-	disable_acpi();
 
+disable_acpi:
+	disable_acpi();
 	return -EINVAL;
 }
 
-- 
1.9.1


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

* [PATCH v10 19/21] ARM64 / ACPI: Enable ARM64 in Kconfig
  2015-03-11 12:39 [PATCH v10 00/21] Introduce ACPI for ARM64 based on ACPI 5.1 Hanjun Guo
                   ` (17 preceding siblings ...)
  2015-03-11 12:39 ` [PATCH v10 18/21] ARM64 / ACPI: Select ACPI_REDUCED_HARDWARE_ONLY if ACPI is enabled on ARM64 Hanjun Guo
@ 2015-03-11 12:39 ` Hanjun Guo
  2015-03-11 12:39 ` [PATCH v10 20/21] Documentation: ACPI for ARM64 Hanjun Guo
                   ` (4 subsequent siblings)
  23 siblings, 0 replies; 89+ messages in thread
From: Hanjun Guo @ 2015-03-11 12: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>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.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 a7b9120..a716965 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
@@ -167,6 +167,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] 89+ messages in thread

* [PATCH v10 20/21] Documentation: ACPI for ARM64
  2015-03-11 12:39 [PATCH v10 00/21] Introduce ACPI for ARM64 based on ACPI 5.1 Hanjun Guo
                   ` (18 preceding siblings ...)
  2015-03-11 12:39 ` [PATCH v10 19/21] ARM64 / ACPI: Enable ARM64 in Kconfig Hanjun Guo
@ 2015-03-11 12:39 ` Hanjun Guo
  2015-03-11 12:39 ` [PATCH v10 21/21] ARM64 / ACPI: additions of ACPI documentation for arm64 Hanjun Guo
                   ` (3 subsequent siblings)
  23 siblings, 0 replies; 89+ messages in thread
From: Hanjun Guo @ 2015-03-11 12: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 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 | 505 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 505 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..7d6e636
--- /dev/null
+++ b/Documentation/arm64/arm-acpi.txt
@@ -0,0 +1,505 @@
+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	[flat|nested] 89+ messages in thread

* [PATCH v10 21/21] ARM64 / ACPI: additions of ACPI documentation for arm64
  2015-03-11 12:39 [PATCH v10 00/21] Introduce ACPI for ARM64 based on ACPI 5.1 Hanjun Guo
                   ` (19 preceding siblings ...)
  2015-03-11 12:39 ` [PATCH v10 20/21] Documentation: ACPI for ARM64 Hanjun Guo
@ 2015-03-11 12:39 ` Hanjun Guo
  2015-03-12 13:26 ` [PATCH v10 00/21] Introduce ACPI for ARM64 based on ACPI 5.1 Timur Tabi
                   ` (2 subsequent siblings)
  23 siblings, 0 replies; 89+ messages in thread
From: Hanjun Guo @ 2015-03-11 12: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, Suravee Suthikulpanit,
	Yi Li, Mark Langsdorf, Hanjun Guo

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

One more documentation file are also being added:

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 | 593 ++++++++++++++++++++++++++++++
 1 file changed, 593 insertions(+)
 create mode 100644 Documentation/arm64/acpi_object_usage.txt

diff --git a/Documentation/arm64/acpi_object_usage.txt b/Documentation/arm64/acpi_object_usage.txt
new file mode 100644
index 0000000..96e2273
--- /dev/null
+++ b/Documentation/arm64/acpi_object_usage.txt
@@ -0,0 +1,593 @@
+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)
-- 
1.9.1


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

* Re: [PATCH v10 16/21] irqchip: Add GICv2 specific ACPI boot support
       [not found]   ` <CACxGe6uWwts6X=Yc2ioBdQizXkF1_YgoNNOsREWirk2MFBVDHg@mail.gmail.com>
@ 2015-03-11 23:11     ` Jason Cooper
  2015-03-12  1:46       ` Hanjun Guo
  2015-03-12 10:14       ` Marc Zyngier
  0 siblings, 2 replies; 89+ messages in thread
From: Jason Cooper @ 2015-03-11 23:11 UTC (permalink / raw)
  To: Grant Likely
  Cc: Hanjun Guo, Thomas Gleixner, Sudeep Holla, Graeme Gregory,
	Suravee Suthikulanit, linaro-acpi, Jon Masters,
	Lorenzo Pieralisi, Rafael J. Wysocki, Will Deacon, Mark Rutland,
	Marc Zyngier, Linux Kernel Mailing List, Mark Brown,
	Tomasz Nowicki, ACPI Devel Mailing List, Ashwin Chaugule,
	Timur Tabi, Arnd Bergmann, Robert Richter, Olof Johansson,
	linux-arm-kernel, Catalin Marinas

Hey Grant,

On Wed, Mar 11, 2015 at 06:04:50PM +0000, Grant Likely wrote:
> On 11 Mar 2015 12:42, "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>
> 
> BTW, Thomas is taking a bit of a break, do he is unlikely to give an ack
> here in a timely manner. I've not heard from Jason. Personally, I think we
> can proceed without their ack if everything else is in order (heck, I used
> to help with the irq subsystem, use me as an ack of you want). The patch is
> low impact and only had effect for ARM ACPI builds.

I'm not talking much, but I am tracking and collecting everything for irqchip.
We do have some other changes in this driver this time around.  So it'd be nice
if I could take this.

I had reached out to Olof for his thoughts on this and he hasn't had enough
cycles to look at it.  iirc, Marc reviewed a previous version and was happy with
the changes.  My only question I had for Olof I'll put below:

> > diff --git a/drivers/irqchip/irqchip.c b/drivers/irqchip/irqchip.c
> > index 0fe2f71..afd1af3 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_irq.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();
> >  }

Is this in line with Olof's idea that providing a dtb would override ACPI?

I have no strong opinion on the matter personally.  I haven't been able to
follow the ACPI discussion as closely as I would have liked, what with the new
job and all.

Just let me know and I can pull it in with other GIC changes for this cycle.
I'll do a topic branch in case other branches need to depend on this.

thx,

Jason.

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

* Re: [PATCH v10 16/21] irqchip: Add GICv2 specific ACPI boot support
  2015-03-11 23:11     ` Jason Cooper
@ 2015-03-12  1:46       ` Hanjun Guo
  2015-03-12  5:12         ` Jason Cooper
  2015-03-12 10:14       ` Marc Zyngier
  1 sibling, 1 reply; 89+ messages in thread
From: Hanjun Guo @ 2015-03-12  1:46 UTC (permalink / raw)
  To: Jason Cooper, Grant Likely
  Cc: Mark Rutland, linaro-acpi, Catalin Marinas, Will Deacon,
	Lorenzo Pieralisi, Timur Tabi, ACPI Devel Mailing List,
	Robert Richter, Arnd Bergmann, Marc Zyngier, Jon Masters,
	Tomasz Nowicki, Mark Brown, Thomas Gleixner, linux-arm-kernel,
	Graeme Gregory, Ashwin Chaugule, Rafael J. Wysocki,
	Linux Kernel Mailing List, Hanjun Guo, Suravee Suthikulanit,
	Sudeep Holla, Olof Johansson

On 2015/3/12 7:11, Jason Cooper wrote:
> Hey Grant,
>
> On Wed, Mar 11, 2015 at 06:04:50PM +0000, Grant Likely wrote:
>> On 11 Mar 2015 12:42, "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>
>> BTW, Thomas is taking a bit of a break, do he is unlikely to give an ack
>> here in a timely manner. I've not heard from Jason. Personally, I think we
>> can proceed without their ack if everything else is in order (heck, I used
>> to help with the irq subsystem, use me as an ack of you want). The patch is
>> low impact and only had effect for ARM ACPI builds.
> I'm not talking much, but I am tracking and collecting everything for irqchip.
> We do have some other changes in this driver this time around.  So it'd be nice
> if I could take this.
>
> I had reached out to Olof for his thoughts on this and he hasn't had enough
> cycles to look at it.  iirc, Marc reviewed a previous version and was happy with
> the changes.  My only question I had for Olof I'll put below:

Please allow me to explain a little bit before Olof's confirmation, please don't mind if
any offended.

>
>>> diff --git a/drivers/irqchip/irqchip.c b/drivers/irqchip/irqchip.c
>>> index 0fe2f71..afd1af3 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_irq.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();
>>>  }
> Is this in line with Olof's idea that providing a dtb would override ACPI?

Yes, it will. Since ACPI is default OFF (disabled), if a dtb provided, and no acpi=force
passed in the early command line, dtb will be used as system configuration for
boot (dtb is always the prior one for now) [1]. In acpi_gic_init() which called by
acpi_irq_init(), it will return immediately if acpi disabled, so it will not parse
any ACPI table for device configuration.

[1]: [patch 08/21] ARM64 / ACPI: Introduce early_param "acpi=" to enable/disable ACPI

Thanks
Hanjun


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

* Re: [PATCH v10 16/21] irqchip: Add GICv2 specific ACPI boot support
  2015-03-12  1:46       ` Hanjun Guo
@ 2015-03-12  5:12         ` Jason Cooper
  2015-03-12  7:31           ` Hanjun Guo
  0 siblings, 1 reply; 89+ messages in thread
From: Jason Cooper @ 2015-03-12  5:12 UTC (permalink / raw)
  To: Hanjun Guo
  Cc: Grant Likely, Mark Rutland, linaro-acpi, Catalin Marinas,
	Will Deacon, Lorenzo Pieralisi, Timur Tabi,
	ACPI Devel Mailing List, Robert Richter, Arnd Bergmann,
	Marc Zyngier, Jon Masters, Tomasz Nowicki, Mark Brown,
	Thomas Gleixner, linux-arm-kernel, Graeme Gregory,
	Ashwin Chaugule, Rafael J. Wysocki, Linux Kernel Mailing List,
	Hanjun Guo, Suravee Suthikulanit, Sudeep Holla, Olof Johansson

On Thu, Mar 12, 2015 at 09:46:39AM +0800, Hanjun Guo wrote:
> On 2015/3/12 7:11, Jason Cooper wrote:
> > Hey Grant,
> >
> > On Wed, Mar 11, 2015 at 06:04:50PM +0000, Grant Likely wrote:
> >> On 11 Mar 2015 12:42, "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>
> >> BTW, Thomas is taking a bit of a break, do he is unlikely to give an ack
> >> here in a timely manner. I've not heard from Jason. Personally, I think we
> >> can proceed without their ack if everything else is in order (heck, I used
> >> to help with the irq subsystem, use me as an ack of you want). The patch is
> >> low impact and only had effect for ARM ACPI builds.
> > I'm not talking much, but I am tracking and collecting everything for irqchip.
> > We do have some other changes in this driver this time around.  So it'd be nice
> > if I could take this.
> >
> > I had reached out to Olof for his thoughts on this and he hasn't had enough
> > cycles to look at it.  iirc, Marc reviewed a previous version and was happy with
> > the changes.  My only question I had for Olof I'll put below:
> 
> Please allow me to explain a little bit before Olof's confirmation, please don't mind if
> any offended.

I'm not sure I parse this correctly, but fwiw, I'm not easily offended.  :-)

> >>> diff --git a/drivers/irqchip/irqchip.c b/drivers/irqchip/irqchip.c
> >>> index 0fe2f71..afd1af3 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_irq.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();
> >>>  }
> > Is this in line with Olof's idea that providing a dtb would override ACPI?
> 
> Yes, it will. Since ACPI is default OFF (disabled), if a dtb provided, and no acpi=force
> passed in the early command line, dtb will be used as system configuration for
> boot (dtb is always the prior one for now) [1]. In acpi_gic_init() which called by
> acpi_irq_init(), it will return immediately if acpi disabled, so it will not parse
> any ACPI table for device configuration.

Ok, that matches my recollection.  Thanks for refreshing my memory.  I'll apply
this on a topic branch for irqchip/gic when I return from travel.  Most likely
Friday or over the weekend.

thx,

Jason.

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

* Re: [PATCH v10 16/21] irqchip: Add GICv2 specific ACPI boot support
  2015-03-12  5:12         ` Jason Cooper
@ 2015-03-12  7:31           ` Hanjun Guo
  2015-03-13 17:15             ` Jason Cooper
  0 siblings, 1 reply; 89+ messages in thread
From: Hanjun Guo @ 2015-03-12  7:31 UTC (permalink / raw)
  To: Jason Cooper
  Cc: Grant Likely, Mark Rutland, linaro-acpi, Catalin Marinas,
	Will Deacon, Lorenzo Pieralisi, Timur Tabi,
	ACPI Devel Mailing List, Robert Richter, Arnd Bergmann,
	Marc Zyngier, Jon Masters, Tomasz Nowicki, Mark Brown,
	Thomas Gleixner, linux-arm-kernel, Graeme Gregory,
	Ashwin Chaugule, Rafael J. Wysocki, Linux Kernel Mailing List,
	Hanjun Guo, Suravee Suthikulanit, Sudeep Holla, Olof Johansson

On 2015/3/12 13:12, Jason Cooper wrote:
> On Thu, Mar 12, 2015 at 09:46:39AM +0800, Hanjun Guo wrote:
>> On 2015/3/12 7:11, Jason Cooper wrote:
>>> Hey Grant,
>>>
>>> On Wed, Mar 11, 2015 at 06:04:50PM +0000, Grant Likely wrote:
>>>> On 11 Mar 2015 12:42, "Hanjun Guo" <hanjun.guo@linaro.org> wrote:
[...]
>>>>> diff --git a/drivers/irqchip/irqchip.c b/drivers/irqchip/irqchip.c
>>>>> index 0fe2f71..afd1af3 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_irq.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();
>>>>>  }
>>> Is this in line with Olof's idea that providing a dtb would override ACPI?
>> Yes, it will. Since ACPI is default OFF (disabled), if a dtb provided, and no acpi=force
>> passed in the early command line, dtb will be used as system configuration for
>> boot (dtb is always the prior one for now) [1]. In acpi_gic_init() which called by
>> acpi_irq_init(), it will return immediately if acpi disabled, so it will not parse
>> any ACPI table for device configuration.
> Ok, that matches my recollection.  Thanks for refreshing my memory.  I'll apply
> this on a topic branch for irqchip/gic when I return from travel.  Most likely
> Friday or over the weekend.

Thank you very much! But this patch can't be applied without previous ones in this
patch set, how about you ack this patch and Catalin takes it via ARM64 tree? I'm
not sure for this, it depends on your decision.

Thanks
Hanjun


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

* Re: [PATCH v10 06/21] ACPI / sleep: Introduce CONFIG_ACPI_GENERIC_SLEEP
  2015-03-11 12:39 ` [PATCH v10 06/21] ACPI / sleep: Introduce CONFIG_ACPI_GENERIC_SLEEP Hanjun Guo
@ 2015-03-12  9:32   ` Lorenzo Pieralisi
  2015-03-12 22:57   ` Rafael J. Wysocki
  1 sibling, 0 replies; 89+ messages in thread
From: Lorenzo Pieralisi @ 2015-03-12  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, Tomasz Nowicki

On Wed, Mar 11, 2015 at 12:39:32PM +0000, 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() and acpi_sleep_init()
> for device power management, so introduce CONFIG_ACPI_GENERIC_SLEEP
> and select it for x86 and ia64 only to make sleep functions available,
> and also introduce stub function to allow other drivers to function
> until S states are defined for ARM64.
> 
> It will be no functional change for x86 and IA64.
> 
> CC: Rafael J. Wysocki <rjw@rjwysocki.net>
> Suggested-by: Rafael J. Wysocki <rafael.j.wysocki@intel.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>

It looks ok to me:

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

> ---
>  arch/ia64/Kconfig       | 1 +
>  arch/x86/Kconfig        | 1 +
>  drivers/acpi/Kconfig    | 4 ++++
>  drivers/acpi/Makefile   | 2 +-
>  drivers/acpi/internal.h | 4 ++++
>  5 files changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
> index 074e52b..e8728d7 100644
> --- a/arch/ia64/Kconfig
> +++ b/arch/ia64/Kconfig
> @@ -10,6 +10,7 @@ config IA64
>  	select ARCH_MIGHT_HAVE_PC_SERIO
>  	select PCI if (!IA64_HP_SIM)
>  	select ACPI if (!IA64_HP_SIM)
> +	select ACPI_GENERIC_SLEEP if ACPI
>  	select ARCH_MIGHT_HAVE_ACPI_PDC if ACPI
>  	select HAVE_UNSTABLE_SCHED_CLOCK
>  	select HAVE_IDE
> diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
> index b7d31ca..9804431 100644
> --- a/arch/x86/Kconfig
> +++ b/arch/x86/Kconfig
> @@ -22,6 +22,7 @@ config X86_64
>  ### Arch settings
>  config X86
>  	def_bool y
> +	select ACPI_GENERIC_SLEEP if ACPI
>  	select ARCH_MIGHT_HAVE_ACPI_PDC if ACPI
>  	select ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
>  	select ARCH_HAS_FAST_MULTIPLIER
> diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
> index e6c3ddd..a7b9120 100644
> --- a/drivers/acpi/Kconfig
> +++ b/drivers/acpi/Kconfig
> @@ -48,9 +48,13 @@ config ACPI_LEGACY_TABLES_LOOKUP
>  config ARCH_MIGHT_HAVE_ACPI_PDC
>  	bool
>  
> +config ACPI_GENERIC_SLEEP
> +	bool
> +
>  config ACPI_SLEEP
>  	bool
>  	depends on SUSPEND || HIBERNATION
> +	depends on ACPI_GENERIC_SLEEP
>  	default y
>  
>  config ACPI_PROCFS_POWER
> diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
> index 623b117..2397822 100644
> --- a/drivers/acpi/Makefile
> +++ b/drivers/acpi/Makefile
> @@ -23,7 +23,7 @@ acpi-y				+= nvs.o
>  
>  # Power management related files
>  acpi-y				+= wakeup.o
> -acpi-y				+= sleep.o
> +acpi-$(CONFIG_ACPI_GENERIC_SLEEP) += sleep.o
>  acpi-y				+= device_pm.o
>  acpi-$(CONFIG_ACPI_SLEEP)	+= proc.o
>  
> diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h
> index 56b321a..b5eef4c 100644
> --- a/drivers/acpi/internal.h
> +++ b/drivers/acpi/internal.h
> @@ -161,7 +161,11 @@ void acpi_ec_remove_query_handler(struct acpi_ec *ec, u8 query_bit);
>  /*--------------------------------------------------------------------------
>                                    Suspend/Resume
>    -------------------------------------------------------------------------- */
> +#ifdef CONFIG_ACPI_GENERIC_SLEEP
>  extern int acpi_sleep_init(void);
> +#else
> +static inline int acpi_sleep_init(void) { return -ENOSYS; }
> +#endif
>  
>  #ifdef CONFIG_ACPI_SLEEP
>  int acpi_sleep_proc_init(void);
> -- 
> 1.9.1
> 
> 

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

* Re: [PATCH v10 13/21] ACPI / processor: Introduce phys_cpuid_t for CPU hardware ID
  2015-03-11 12:39 ` [PATCH v10 13/21] ACPI / processor: Introduce phys_cpuid_t for CPU hardware ID Hanjun Guo
@ 2015-03-12  9:51   ` Lorenzo Pieralisi
  2015-03-12 10:16     ` Hanjun Guo
  0 siblings, 1 reply; 89+ messages in thread
From: Lorenzo Pieralisi @ 2015-03-12  9: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

On Wed, Mar 11, 2015 at 12:39:39PM +0000, 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 for the 64 bit CPU hardware ID
> in the following patch.

Nit: Commit log above is stale (since you moved the phys_cpuid_t to
common declaration for all archs that do not define PHYS_CPUID_INVALID
and the macro name itself changed) so you should rewrite it before
asking to merge it. Furthermore you should not describe how you implemented
the change, you should describe why.

Other than that:

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

> CC: Rafael J Wysocki <rjw@rjwysocki.net>
> Suggested-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
> Reviewed-by: Grant Likely <grant.likely@linaro.org>
> 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/kernel/acpi.c       |  2 +-
>  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          |  7 ++++++-
>  6 files changed, 30 insertions(+), 24 deletions(-)
> 
> 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/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..58f335c 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 == PHYS_CPUID_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 == PHYS_CPUID_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..51cc299 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 = PHYS_CPUID_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 = PHYS_CPUID_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 == PHYS_CPUID_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 == PHYS_CPUID_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 PHYS_CPUID_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..6ec33c5 100644
> --- a/include/linux/acpi.h
> +++ b/include/linux/acpi.h
> @@ -146,9 +146,14 @@ void acpi_numa_x2apic_affinity_init(struct acpi_srat_x2apic_cpu_affinity *pa);
>  int acpi_numa_memory_affinity_init (struct acpi_srat_mem_affinity *ma);
>  void acpi_numa_arch_fixup(void);
>  
> +#ifndef PHYS_CPUID_INVALID
> +typedef u32 phys_cpuid_t;
> +#define PHYS_CPUID_INVALID (phys_cpuid_t)(-1)
> +#endif
> +
>  #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] 89+ messages in thread

* Re: [PATCH v10 16/21] irqchip: Add GICv2 specific ACPI boot support
  2015-03-11 23:11     ` Jason Cooper
  2015-03-12  1:46       ` Hanjun Guo
@ 2015-03-12 10:14       ` Marc Zyngier
  1 sibling, 0 replies; 89+ messages in thread
From: Marc Zyngier @ 2015-03-12 10:14 UTC (permalink / raw)
  To: Jason Cooper, grant.likely
  Cc: hanjun.guo, Thomas Gleixner, Sudeep Holla, graeme.gregory,
	suravee.suthikulpanit, linaro-acpi, jcm, Lorenzo Pieralisi,
	Rafael J. Wysocki, Will Deacon, Mark Rutland,
	Linux Kernel Mailing List, Mark Brown, Tomasz Nowicki,
	ACPI Devel Mailing List, Ashwin Chaugule, Timur Tabi,
	Arnd Bergmann, Robert Richter, Olof Johansson, linux-arm-kernel,
	Catalin Marinas

On 11/03/15 23:11, Jason Cooper wrote:
> Hey Grant,
> 
> On Wed, Mar 11, 2015 at 06:04:50PM +0000, Grant Likely wrote:
>> On 11 Mar 2015 12:42, "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>
>>
>> BTW, Thomas is taking a bit of a break, do he is unlikely to give an ack
>> here in a timely manner. I've not heard from Jason. Personally, I think we
>> can proceed without their ack if everything else is in order (heck, I used
>> to help with the irq subsystem, use me as an ack of you want). The patch is
>> low impact and only had effect for ARM ACPI builds.
> 
> I'm not talking much, but I am tracking and collecting everything for irqchip.
> We do have some other changes in this driver this time around.  So it'd be nice
> if I could take this.
> 
> I had reached out to Olof for his thoughts on this and he hasn't had enough
> cycles to look at it.  iirc, Marc reviewed a previous version and was happy with
> the changes.

FWIW, and given the prominent "NOTE" in the commit message, please have my:

Acked-by: Marc Zyngier <marc.zyngier@arm.com>

Thanks,

	M.
-- 
Jazz is not dead. It just smells funny...

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

* Re: [PATCH v10 13/21] ACPI / processor: Introduce phys_cpuid_t for CPU hardware ID
  2015-03-12  9:51   ` Lorenzo Pieralisi
@ 2015-03-12 10:16     ` Hanjun Guo
  0 siblings, 0 replies; 89+ messages in thread
From: Hanjun Guo @ 2015-03-12 10:16 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

On 2015年03月12日 17:51, Lorenzo Pieralisi wrote:
> On Wed, Mar 11, 2015 at 12:39:39PM +0000, 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 for the 64 bit CPU hardware ID
>> in the following patch.
>
> Nit: Commit log above is stale (since you moved the phys_cpuid_t to
> common declaration for all archs that do not define PHYS_CPUID_INVALID
> and the macro name itself changed) so you should rewrite it before

Oops, I will send a updated patch only for this one, good catch.

> asking to merge it. Furthermore you should not describe how you implemented
> the change, you should describe why.

I'm prefer writing the commit log as following way (not always) :)
  - why the patch is needed
  - what the patch implements
  - How the patch is implemented

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

Thanks!

Hanjun

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

* Re: [PATCH v10 00/21] Introduce ACPI for ARM64 based on ACPI 5.1
  2015-03-11 12:39 [PATCH v10 00/21] Introduce ACPI for ARM64 based on ACPI 5.1 Hanjun Guo
                   ` (20 preceding siblings ...)
  2015-03-11 12:39 ` [PATCH v10 21/21] ARM64 / ACPI: additions of ACPI documentation for arm64 Hanjun Guo
@ 2015-03-12 13:26 ` Timur Tabi
  2015-03-16  5:07   ` Suthikulpanit, Suravee
  2015-03-18 19:05 ` Will Deacon
  2015-03-20 13:18 ` Mark Salter
  23 siblings, 1 reply; 89+ messages in thread
From: Timur Tabi @ 2015-03-12 13:26 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

Hanjun Guo wrote:
> This patch set already tested on multi platforms:
>   - AMD Seattle board;
>   - Cavium Thunder board;
>   - Huawei D02 board;
>   - Qualcomm ARM64 platform
>
> This version 10 patch set address some minor comments and collect ACKs and
> Reviewed-bys for v9:
>
>   - new Acks from Rafael, Olof, Grant, Lorenzo
>   - new way to handle typdef phys_cpuid_t which suggested by Rafael,
>     but no functional change
>   - Remove if(!phys) for early ioremappings
>   - Rework sleep function for ARM64
>   - Introduce linux/acpi_irq.h to hold acpi_irq_init()
>   - Disable ACPI if not HW_REDUCED_ACPI compliant
>   - Remove the doc of why ACPI on ARM

v10 retested and working as before, so ...

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

for the whole patchset.

-- 
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] 89+ messages in thread

* Re: [PATCH v10 14/21] ACPI / processor: Make it possible to get CPU hardware ID via GICC
  2015-03-11 12:39 ` [PATCH v10 14/21] ACPI / processor: Make it possible to get CPU hardware ID via GICC Hanjun Guo
@ 2015-03-12 15:41   ` Lorenzo Pieralisi
  2015-03-12 23:02   ` Rafael J. Wysocki
  1 sibling, 0 replies; 89+ messages in thread
From: Lorenzo Pieralisi @ 2015-03-12 15:41 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

On Wed, Mar 11, 2015 at 12:39:40PM +0000, 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, since MPIDR for ARM64 is
> 64-bit, so typedef u64 for phys_cpuid_t.
> 
> 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.

Nit: To me the two paragraphs above should be swapped, current log
sounds odd; first you define what an MPIDR is, then define what the patch
does with it, no need to respin.

I still have some reservations related to ACPI core code mapping
of physical to logical CPUs, in particular I loathe the multiple parsing
of MADT to get the same values twice - create cpu_logical_map and map
processor objects to logical cpu ids - but given the current state of
affairs, this patch looks fine:

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

> 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>
> Reviewed-by: Grant Likely <grant.likely@linaro.org>
> 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..eea0bc3 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 PHYS_CPUID_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 51cc299..b1ec78b 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] 89+ messages in thread

* Re: [PATCH v10 18/21] ARM64 / ACPI: Select ACPI_REDUCED_HARDWARE_ONLY if ACPI is enabled on ARM64
  2015-03-11 12:39 ` [PATCH v10 18/21] ARM64 / ACPI: Select ACPI_REDUCED_HARDWARE_ONLY if ACPI is enabled on ARM64 Hanjun Guo
@ 2015-03-12 18:21   ` Lorenzo Pieralisi
  2015-03-13  3:28     ` Hanjun Guo
  0 siblings, 1 reply; 89+ messages in thread
From: Lorenzo Pieralisi @ 2015-03-12 18:21 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, Mar 11, 2015 at 12:39:44PM +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.
> 
> If the firmware is not using hardware reduced ACPI mode, we
> will disable ACPI to avoid nightmare such as accessing some
> registers which are not available 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 +
>  arch/arm64/kernel/acpi.c | 8 +++++++-
>  2 files changed, 8 insertions(+), 1 deletion(-)
> 
> 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
> diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c
> index 6468f88..5819ef7 100644
> --- a/arch/arm64/kernel/acpi.c
> +++ b/arch/arm64/kernel/acpi.c
> @@ -303,6 +303,11 @@ static int __init acpi_parse_fadt(struct acpi_table_header *table)
>  	 */
>  	if (table->revision > 5 ||
>  	    (table->revision == 5 && fadt->minor_revision >= 1)) {
> +		if (!acpi_gbl_reduced_hardware) {
> +			pr_err("Not hardware reduced ACPI mode, will not be supported\n");
> +			goto disable_acpi;
> +		}
> +

I reviewed the code and found that acpi_parse_fadt has become very
complex to read and understand. On top of that, I still do not understand
why you check PSCI presence in there (to print a warning ?) and as it
was raised before disable_acpi() is scattered all over the place.
I do not understand why we enable ACPI to disable it again if
one of the checks fails, IMHO it is better to leave it disabled,
carry out the checks and enable ACPI if all of them pass.

I came up with the patch attached on top of your series, which should be
split, tested on Juno, please test, let me know your opinion and shout if
you spot something wrong, it should simplify things a lot.

I wonder if acpi_get_table_with_size() usage is frowned upon, but you
use it anyway and it helps us remove the FADT parsing function that
in my opinion is useless, since its return value is dumped by ACPI
core.

Thanks,
Lorenzo

---
 arch/arm64/kernel/acpi.c | 92 ++++++++++++++++++++++++------------------------
 1 file changed, 46 insertions(+), 46 deletions(-)

diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c
index 5819ef7..b7497fa 100644
--- a/arch/arm64/kernel/acpi.c
+++ b/arch/arm64/kernel/acpi.c
@@ -291,56 +291,23 @@ 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;
-
-	/*
-	 * 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)) {
-		if (!acpi_gbl_reduced_hardware) {
-			pr_err("Not hardware reduced ACPI mode, will not be supported\n");
-			goto disable_acpi;
-		}
-
-		/*
-		 * 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);
-
-disable_acpi:
-	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
+ *	4. check ACPI FADT HW reduced flag
  *
  * We can parse ACPI boot-time tables such as MADT after
  * this function is called.
  */
 void __init acpi_boot_table_init(void)
 {
+	struct acpi_table_header *table;
+	struct acpi_table_fadt *fadt;
+	acpi_status status;
+	acpi_size tbl_size;
+
 	/*
 	 * Enable ACPI instead of device tree unless
 	 * - ACPI has been disabled explicitly (acpi=off), or
@@ -351,19 +318,52 @@ void __init acpi_boot_table_init(void)
 	    (!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();
+		pr_err("Failed to init ACPI tables\n");
 		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");
+	/*
+	 * FADT is required on arm64; retrieve it to check its presence
+	 * and carry out revision and ACPI HW reduced compliancy tests
+	 */
+	status = acpi_get_table_with_size(ACPI_SIG_FADT, 0, &table, &tbl_size);
+	if (ACPI_FAILURE(status)) {
+		const char *msg = acpi_format_exception(status);
+
+		pr_err("Failed to get FADT table, %s\n", msg);
+		return;
 	}
+
+	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.
+	 */
+	if (table->revision < 5 ||
+	   (table->revision == 5 && fadt->minor_revision < 1)) {
+		pr_err("Unsupported FADT revision %d.%d, should be 5.1+\n",
+		       table->revision, fadt->minor_revision);
+		goto out_unmap;
+	}
+
+	if (!(fadt->flags & ACPI_FADT_HW_REDUCED)) {
+		pr_err("FADT not ACPI hardware reduced compliant\n");
+		goto out_unmap;
+	}
+
+	enable_acpi();
+
+	/*
+	 * acpi_get_table_with_size() creates FADT table mapping that
+	 * should be released after parsing and before resuming boot
+	 */
+out_unmap:
+	early_acpi_os_unmap_memory((char *)table, tbl_size);
 }
 
 void __init acpi_gic_init(void)
-- 
2.2.1


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

* Re: [PATCH v10 06/21] ACPI / sleep: Introduce CONFIG_ACPI_GENERIC_SLEEP
  2015-03-11 12:39 ` [PATCH v10 06/21] ACPI / sleep: Introduce CONFIG_ACPI_GENERIC_SLEEP Hanjun Guo
  2015-03-12  9:32   ` Lorenzo Pieralisi
@ 2015-03-12 22:57   ` Rafael J. Wysocki
  2015-03-13  3:31     ` Hanjun Guo
  1 sibling, 1 reply; 89+ messages in thread
From: Rafael J. Wysocki @ 2015-03-12 22:57 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, March 11, 2015 08:39:32 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() and acpi_sleep_init()
> for device power management, so introduce CONFIG_ACPI_GENERIC_SLEEP
> and select it for x86 and ia64 only to make sleep functions available,
> and also introduce stub function to allow other drivers to function
> until S states are defined for ARM64.
> 
> It will be no functional change for x86 and IA64.
> 
> CC: Rafael J. Wysocki <rjw@rjwysocki.net>
> Suggested-by: Rafael J. Wysocki <rafael.j.wysocki@intel.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/ia64/Kconfig       | 1 +
>  arch/x86/Kconfig        | 1 +
>  drivers/acpi/Kconfig    | 4 ++++
>  drivers/acpi/Makefile   | 2 +-
>  drivers/acpi/internal.h | 4 ++++
>  5 files changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
> index 074e52b..e8728d7 100644
> --- a/arch/ia64/Kconfig
> +++ b/arch/ia64/Kconfig
> @@ -10,6 +10,7 @@ config IA64
>  	select ARCH_MIGHT_HAVE_PC_SERIO
>  	select PCI if (!IA64_HP_SIM)
>  	select ACPI if (!IA64_HP_SIM)
> +	select ACPI_GENERIC_SLEEP if ACPI
>  	select ARCH_MIGHT_HAVE_ACPI_PDC if ACPI
>  	select HAVE_UNSTABLE_SCHED_CLOCK
>  	select HAVE_IDE
> diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
> index b7d31ca..9804431 100644
> --- a/arch/x86/Kconfig
> +++ b/arch/x86/Kconfig
> @@ -22,6 +22,7 @@ config X86_64
>  ### Arch settings
>  config X86
>  	def_bool y
> +	select ACPI_GENERIC_SLEEP if ACPI
>  	select ARCH_MIGHT_HAVE_ACPI_PDC if ACPI
>  	select ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
>  	select ARCH_HAS_FAST_MULTIPLIER
> diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
> index e6c3ddd..a7b9120 100644
> --- a/drivers/acpi/Kconfig
> +++ b/drivers/acpi/Kconfig
> @@ -48,9 +48,13 @@ config ACPI_LEGACY_TABLES_LOOKUP
>  config ARCH_MIGHT_HAVE_ACPI_PDC
>  	bool
>  
> +config ACPI_GENERIC_SLEEP
> +	bool
> +
>  config ACPI_SLEEP
>  	bool
>  	depends on SUSPEND || HIBERNATION
> +	depends on ACPI_GENERIC_SLEEP
>  	default y
>  
>  config ACPI_PROCFS_POWER
> diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
> index 623b117..2397822 100644
> --- a/drivers/acpi/Makefile
> +++ b/drivers/acpi/Makefile
> @@ -23,7 +23,7 @@ acpi-y				+= nvs.o
>  
>  # Power management related files
>  acpi-y				+= wakeup.o
> -acpi-y				+= sleep.o
> +acpi-$(CONFIG_ACPI_GENERIC_SLEEP) += sleep.o
>  acpi-y				+= device_pm.o
>  acpi-$(CONFIG_ACPI_SLEEP)	+= proc.o
>  
> diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h
> index 56b321a..b5eef4c 100644
> --- a/drivers/acpi/internal.h
> +++ b/drivers/acpi/internal.h
> @@ -161,7 +161,11 @@ void acpi_ec_remove_query_handler(struct acpi_ec *ec, u8 query_bit);
>  /*--------------------------------------------------------------------------
>                                    Suspend/Resume
>    -------------------------------------------------------------------------- */
> +#ifdef CONFIG_ACPI_GENERIC_SLEEP
>  extern int acpi_sleep_init(void);
> +#else
> +static inline int acpi_sleep_init(void) { return -ENOSYS; }

Please change the return value here, preferably to -ENXIO.

-ENOSYS *specifically* means "system call not implemented" and should only be
used to indicate this particular condition.

> +#endif
>  
>  #ifdef CONFIG_ACPI_SLEEP
>  int acpi_sleep_proc_init(void);
> 

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

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

* Re: [PATCH v10 14/21] ACPI / processor: Make it possible to get CPU hardware ID via GICC
  2015-03-11 12:39 ` [PATCH v10 14/21] ACPI / processor: Make it possible to get CPU hardware ID via GICC Hanjun Guo
  2015-03-12 15:41   ` Lorenzo Pieralisi
@ 2015-03-12 23:02   ` Rafael J. Wysocki
  1 sibling, 0 replies; 89+ messages in thread
From: Rafael J. Wysocki @ 2015-03-12 23:02 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, March 11, 2015 08:39:40 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, since MPIDR for ARM64 is
> 64-bit, so typedef u64 for phys_cpuid_t.
> 
> 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>
> Reviewed-by: Grant Likely <grant.likely@linaro.org>
> 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 | 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..eea0bc3 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 PHYS_CPUID_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 51cc299..b1ec78b 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] 89+ messages in thread

* Re: [PATCH v10 18/21] ARM64 / ACPI: Select ACPI_REDUCED_HARDWARE_ONLY if ACPI is enabled on ARM64
  2015-03-12 18:21   ` Lorenzo Pieralisi
@ 2015-03-13  3:28     ` Hanjun Guo
  2015-03-13 11:04       ` Lorenzo Pieralisi
  0 siblings, 1 reply; 89+ messages in thread
From: Hanjun Guo @ 2015-03-13  3:28 UTC (permalink / raw)
  To: Lorenzo Pieralisi, 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 2015/3/13 2:21, Lorenzo Pieralisi wrote:
> On Wed, Mar 11, 2015 at 12:39:44PM +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.
>>
>> If the firmware is not using hardware reduced ACPI mode, we
>> will disable ACPI to avoid nightmare such as accessing some
>> registers which are not available on ARM64.
>>
[...]
>> diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c
>> index 6468f88..5819ef7 100644
>> --- a/arch/arm64/kernel/acpi.c
>> +++ b/arch/arm64/kernel/acpi.c
>> @@ -303,6 +303,11 @@ static int __init acpi_parse_fadt(struct acpi_table_header *table)
>>  	 */
>>  	if (table->revision > 5 ||
>>  	    (table->revision == 5 && fadt->minor_revision >= 1)) {
>> +		if (!acpi_gbl_reduced_hardware) {
>> +			pr_err("Not hardware reduced ACPI mode, will not be supported\n");
>> +			goto disable_acpi;
>> +		}
>> +
> I reviewed the code and found that acpi_parse_fadt has become very
> complex to read and understand. On top of that, I still do not understand
> why you check PSCI presence in there (to print a warning ?) and as it

Since Parking protocol for bringing up secondary CPUs will be upstreamed,
it is ok to me to print no message for not supporting PSCI.

> was raised before disable_acpi() is scattered all over the place.
> I do not understand why we enable ACPI to disable it again if
> one of the checks fails, IMHO it is better to leave it disabled,
> carry out the checks and enable ACPI if all of them pass.
>
> I came up with the patch attached on top of your series, which should be
> split, tested on Juno, please test, let me know your opinion and shout if
> you spot something wrong, it should simplify things a lot.

Thanks, I have some minor comments below.

>
> I wonder if acpi_get_table_with_size() usage is frowned upon, but you
> use it anyway and it helps us remove the FADT parsing function that
> in my opinion is useless, since its return value is dumped by ACPI
> core.
>
> Thanks,
> Lorenzo
>
> ---
>  arch/arm64/kernel/acpi.c | 92 ++++++++++++++++++++++++------------------------
>  1 file changed, 46 insertions(+), 46 deletions(-)
>
> diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c
> index 5819ef7..b7497fa 100644
> --- a/arch/arm64/kernel/acpi.c
> +++ b/arch/arm64/kernel/acpi.c
> @@ -291,56 +291,23 @@ 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;
> -
> -	/*
> -	 * 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)) {
> -		if (!acpi_gbl_reduced_hardware) {
> -			pr_err("Not hardware reduced ACPI mode, will not be supported\n");
> -			goto disable_acpi;
> -		}
> -
> -		/*
> -		 * 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);
> -
> -disable_acpi:
> -	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
> + *	4. check ACPI FADT HW reduced flag
>   *
>   * We can parse ACPI boot-time tables such as MADT after
>   * this function is called.
>   */
>  void __init acpi_boot_table_init(void)
>  {
> +	struct acpi_table_header *table;
> +	struct acpi_table_fadt *fadt;
> +	acpi_status status;
> +	acpi_size tbl_size;
> +
>  	/*
>  	 * Enable ACPI instead of device tree unless
>  	 * - ACPI has been disabled explicitly (acpi=off), or
> @@ -351,19 +318,52 @@ void __init acpi_boot_table_init(void)
>  	    (!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()) {

Since we disable ACPI in default, it is a bit strange for me to init all
the ACPI tables and parse FADT when ACPI is disabled, could you
put some comments here to clarify the purpose? other than that, it is looks
good to me.

Thanks
Hanjun


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

* Re: [PATCH v10 06/21] ACPI / sleep: Introduce CONFIG_ACPI_GENERIC_SLEEP
  2015-03-12 22:57   ` Rafael J. Wysocki
@ 2015-03-13  3:31     ` Hanjun Guo
  0 siblings, 0 replies; 89+ messages in thread
From: Hanjun Guo @ 2015-03-13  3:31 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, Zhangdianfang

On 2015/3/13 6:57, Rafael J. Wysocki wrote:
> On Wednesday, March 11, 2015 08:39:32 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() and acpi_sleep_init()
>> for device power management, so introduce CONFIG_ACPI_GENERIC_SLEEP
>> and select it for x86 and ia64 only to make sleep functions available,
>> and also introduce stub function to allow other drivers to function
>> until S states are defined for ARM64.
>>
>> It will be no functional change for x86 and IA64.
>>
>> CC: Rafael J. Wysocki <rjw@rjwysocki.net>
>> Suggested-by: Rafael J. Wysocki <rafael.j.wysocki@intel.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/ia64/Kconfig       | 1 +
>>  arch/x86/Kconfig        | 1 +
>>  drivers/acpi/Kconfig    | 4 ++++
>>  drivers/acpi/Makefile   | 2 +-
>>  drivers/acpi/internal.h | 4 ++++
>>  5 files changed, 11 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
>> index 074e52b..e8728d7 100644
>> --- a/arch/ia64/Kconfig
>> +++ b/arch/ia64/Kconfig
>> @@ -10,6 +10,7 @@ config IA64
>>  	select ARCH_MIGHT_HAVE_PC_SERIO
>>  	select PCI if (!IA64_HP_SIM)
>>  	select ACPI if (!IA64_HP_SIM)
>> +	select ACPI_GENERIC_SLEEP if ACPI
>>  	select ARCH_MIGHT_HAVE_ACPI_PDC if ACPI
>>  	select HAVE_UNSTABLE_SCHED_CLOCK
>>  	select HAVE_IDE
>> diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
>> index b7d31ca..9804431 100644
>> --- a/arch/x86/Kconfig
>> +++ b/arch/x86/Kconfig
>> @@ -22,6 +22,7 @@ config X86_64
>>  ### Arch settings
>>  config X86
>>  	def_bool y
>> +	select ACPI_GENERIC_SLEEP if ACPI
>>  	select ARCH_MIGHT_HAVE_ACPI_PDC if ACPI
>>  	select ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
>>  	select ARCH_HAS_FAST_MULTIPLIER
>> diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
>> index e6c3ddd..a7b9120 100644
>> --- a/drivers/acpi/Kconfig
>> +++ b/drivers/acpi/Kconfig
>> @@ -48,9 +48,13 @@ config ACPI_LEGACY_TABLES_LOOKUP
>>  config ARCH_MIGHT_HAVE_ACPI_PDC
>>  	bool
>>  
>> +config ACPI_GENERIC_SLEEP
>> +	bool
>> +
>>  config ACPI_SLEEP
>>  	bool
>>  	depends on SUSPEND || HIBERNATION
>> +	depends on ACPI_GENERIC_SLEEP
>>  	default y
>>  
>>  config ACPI_PROCFS_POWER
>> diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
>> index 623b117..2397822 100644
>> --- a/drivers/acpi/Makefile
>> +++ b/drivers/acpi/Makefile
>> @@ -23,7 +23,7 @@ acpi-y				+= nvs.o
>>  
>>  # Power management related files
>>  acpi-y				+= wakeup.o
>> -acpi-y				+= sleep.o
>> +acpi-$(CONFIG_ACPI_GENERIC_SLEEP) += sleep.o
>>  acpi-y				+= device_pm.o
>>  acpi-$(CONFIG_ACPI_SLEEP)	+= proc.o
>>  
>> diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h
>> index 56b321a..b5eef4c 100644
>> --- a/drivers/acpi/internal.h
>> +++ b/drivers/acpi/internal.h
>> @@ -161,7 +161,11 @@ void acpi_ec_remove_query_handler(struct acpi_ec *ec, u8 query_bit);
>>  /*--------------------------------------------------------------------------
>>                                    Suspend/Resume
>>    -------------------------------------------------------------------------- */
>> +#ifdef CONFIG_ACPI_GENERIC_SLEEP
>>  extern int acpi_sleep_init(void);
>> +#else
>> +static inline int acpi_sleep_init(void) { return -ENOSYS; }
> Please change the return value here, preferably to -ENXIO.
>
> -ENOSYS *specifically* means "system call not implemented" and should only be
> used to indicate this particular condition.

Oops, you mentioned this for another patch, I will send a updated patch for this one.

Thanks
Hanjun


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

* Re: [PATCH v10 18/21] ARM64 / ACPI: Select ACPI_REDUCED_HARDWARE_ONLY if ACPI is enabled on ARM64
  2015-03-13  3:28     ` Hanjun Guo
@ 2015-03-13 11:04       ` Lorenzo Pieralisi
  2015-03-16 11:33         ` Hanjun Guo
  0 siblings, 1 reply; 89+ messages in thread
From: Lorenzo Pieralisi @ 2015-03-13 11:04 UTC (permalink / raw)
  To: Hanjun Guo
  Cc: hanjun.guo, 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 Fri, Mar 13, 2015 at 03:28:45AM +0000, Hanjun Guo wrote:

[...]

> >  /*
> >   * 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
> > + *	4. check ACPI FADT HW reduced flag
> >   *
> >   * We can parse ACPI boot-time tables such as MADT after
> >   * this function is called.
> >   */
> >  void __init acpi_boot_table_init(void)
> >  {
> > +	struct acpi_table_header *table;
> > +	struct acpi_table_fadt *fadt;
> > +	acpi_status status;
> > +	acpi_size tbl_size;
> > +
> >  	/*
> >  	 * Enable ACPI instead of device tree unless
> >  	 * - ACPI has been disabled explicitly (acpi=off), or
> > @@ -351,19 +318,52 @@ void __init acpi_boot_table_init(void)
> >  	    (!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()) {
> 
> Since we disable ACPI in default, it is a bit strange for me to init all
> the ACPI tables and parse FADT when ACPI is disabled, could you
> put some comments here to clarify the purpose? other than that, it is looks
> good to me.

Ok, the purpose was to make things simpler, but I think that given
current code it is not 100% safe to init ACPI tables with
acpi_disabled == 1.

To me having to enable ACPI to parse the tables and check *if* ACPI tables
are there is a bit crazy, but I agree with you that given current code
it is safer.

Patch rewritten, here below, please have a look, test it and rework
bits as needed, I added comments where I thought they were needed but
please add to that if you feel it is worth it.

It should be easy to split, let me know if you want an incremental
version.

Thanks !
Lorenzo

---
 arch/arm64/kernel/acpi.c | 103 +++++++++++++++++++++++++++++++----------------
 1 file changed, 69 insertions(+), 34 deletions(-)

diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c
index 5819ef7..e5ee4d4 100644
--- a/arch/arm64/kernel/acpi.c
+++ b/arch/arm64/kernel/acpi.c
@@ -291,43 +291,60 @@ void acpi_unregister_gsi(u32 gsi)
 }
 EXPORT_SYMBOL_GPL(acpi_unregister_gsi);
 
-static int __init acpi_parse_fadt(struct acpi_table_header *table)
+/*
+ * acpi_fadt_sanity_check() - Check FADT presence and carry out sanity
+ *			      checks on it
+ *
+ * Return 0 on success,  <0 on failure
+ */
+static int __init acpi_fadt_sanity_check(void)
 {
-	struct acpi_table_fadt *fadt = (struct acpi_table_fadt *)table;
+	struct acpi_table_header *table;
+	struct acpi_table_fadt *fadt;
+	acpi_status status;
+	acpi_size tbl_size;
+	int ret = 0;
+
+	/*
+	 * FADT is required on arm64; retrieve it to check its presence
+	 * and carry out revision and ACPI HW reduced compliancy tests
+	 */
+	status = acpi_get_table_with_size(ACPI_SIG_FADT, 0, &table, &tbl_size);
+	if (ACPI_FAILURE(status)) {
+		const char *msg = acpi_format_exception(status);
+
+		pr_err("Failed to get FADT table, %s\n", msg);
+		return -ENODEV;
+	}
+
+	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.
+	 * boot protocol configuration data.
 	 */
-	if (table->revision > 5 ||
-	    (table->revision == 5 && fadt->minor_revision >= 1)) {
-		if (!acpi_gbl_reduced_hardware) {
-			pr_err("Not hardware reduced ACPI mode, will not be supported\n");
-			goto disable_acpi;
-		}
-
-		/*
-		 * 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;
+	if (table->revision < 5 ||
+	   (table->revision == 5 && fadt->minor_revision < 1)) {
+		pr_err("Unsupported FADT revision %d.%d, should be 5.1+\n",
+		       table->revision, fadt->minor_revision);
+		ret = -EINVAL;
+		goto out;
 	}
 
-	pr_warn("Unsupported FADT revision %d.%d, should be 5.1+, will disable ACPI\n",
-		table->revision, fadt->minor_revision);
+	if (!(fadt->flags & ACPI_FADT_HW_REDUCED)) {
+		pr_err("FADT not ACPI hardware reduced compliant\n");
+		ret = -EINVAL;
+	}
 
-disable_acpi:
-	disable_acpi();
-	return -EINVAL;
+out:
+	/*
+	 * acpi_get_table_with_size() creates FADT table mapping that
+	 * should be released after parsing and before resuming boot
+	 */
+	early_acpi_os_unmap_memory((char *)table, tbl_size);
+	return ret;
 }
 
 /*
@@ -335,12 +352,17 @@ disable_acpi:
  *	1. find RSDP and get its address, and then find XSDT
  *	2. extract all tables and checksums them all
  *	3. check ACPI FADT revision
+ *	4. check ACPI FADT HW reduced flag
  *
  * We can parse ACPI boot-time tables such as MADT after
  * this function is called.
+ *
+ * ACPI is enabled on return if ACPI tables initialized and sanity checks
+ * passed, disabled otherwise
  */
 void __init acpi_boot_table_init(void)
 {
+
 	/*
 	 * Enable ACPI instead of device tree unless
 	 * - ACPI has been disabled explicitly (acpi=off), or
@@ -351,19 +373,32 @@ void __init acpi_boot_table_init(void)
 	    (!param_acpi_force && of_scan_flat_dt(dt_scan_depth1_nodes, NULL)))
 		return;
 
+	/*
+	 * ACPI is disabled at this point. Enable it in order to parse
+	 * the ACPI tables and carry out sanity checks
+	 */
 	enable_acpi();
 
 	/* Initialize the ACPI boot-time table parser. */
 	if (acpi_table_init()) {
-		disable_acpi();
-		return;
+		pr_err("Failed to init ACPI tables\n");
+		goto init_failed;
 	}
 
-	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");
-	}
+	/*
+	 * Check FADT presence and carry out FADT sanity checks
+	 */
+	if (acpi_fadt_sanity_check() < 0)
+		goto init_failed;
+
+	/*
+	 * ACPI tables initialized and FADT sanity checks passed, leave
+	 * ACPI enabled and carry on booting
+	 */
+	return;
+
+init_failed:
+	disable_acpi();
 }
 
 void __init acpi_gic_init(void)
-- 
1.9.1


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

* Re: [PATCH v10 10/21] ARM64 / ACPI: Get PSCI flags in FADT for PSCI init
  2015-03-11 12:39 ` [PATCH v10 10/21] ARM64 / ACPI: Get PSCI flags in FADT for PSCI init Hanjun Guo
@ 2015-03-13 14:51   ` Lorenzo Pieralisi
  2015-03-16 11:45     ` Hanjun Guo
  0 siblings, 1 reply; 89+ messages in thread
From: Lorenzo Pieralisi @ 2015-03-13 14: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, Tomasz Nowicki

On Wed, Mar 11, 2015 at 12:39:36PM +0000, Hanjun Guo wrote:

[...]

> +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.
> @@ -306,29 +335,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();

You should have factored out the firmware version probing too, that's
the only way we can detect the PSCI firmware version when booting through
ACPI. You can end up initializing pointers for v0.2+ with a mismatching
version implemented in PSCI firmware, eg 0.1.

We should do that incrementally, I will put together a patch to
factor out the FW version probing first, you can rebase on top of it.

>  out_put_node:
>  	of_node_put(np);
> @@ -381,7 +388,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;
> @@ -396,6 +403,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;
> +	}

If PSCI is not present, that's a problem related to SMP init, right ?
That's where a warning should be printed if any, not here, the SBBR
mandates PSCI as secondaries bring up method, warn otherwise.

Lorenzo

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

* Re: [PATCH v10 16/21] irqchip: Add GICv2 specific ACPI boot support
  2015-03-12  7:31           ` Hanjun Guo
@ 2015-03-13 17:15             ` Jason Cooper
  2015-03-14  8:47               ` Grant Likely
  0 siblings, 1 reply; 89+ messages in thread
From: Jason Cooper @ 2015-03-13 17:15 UTC (permalink / raw)
  To: Hanjun Guo
  Cc: Grant Likely, Mark Rutland, linaro-acpi, Catalin Marinas,
	Will Deacon, Lorenzo Pieralisi, Timur Tabi,
	ACPI Devel Mailing List, Robert Richter, Arnd Bergmann,
	Marc Zyngier, Jon Masters, Tomasz Nowicki, Mark Brown,
	Thomas Gleixner, linux-arm-kernel, Graeme Gregory,
	Ashwin Chaugule, Rafael J. Wysocki, Linux Kernel Mailing List,
	Hanjun Guo, Suravee Suthikulanit, Sudeep Holla, Olof Johansson

Hanjun, Catalin,

On Thu, Mar 12, 2015 at 03:31:57PM +0800, Hanjun Guo wrote:
> On 2015/3/12 13:12, Jason Cooper wrote:
> > On Thu, Mar 12, 2015 at 09:46:39AM +0800, Hanjun Guo wrote:
> >> On 2015/3/12 7:11, Jason Cooper wrote:
> >>> Hey Grant,
> >>>
> >>> On Wed, Mar 11, 2015 at 06:04:50PM +0000, Grant Likely wrote:
> >>>> On 11 Mar 2015 12:42, "Hanjun Guo" <hanjun.guo@linaro.org> wrote:
> [...]
> >>>>> diff --git a/drivers/irqchip/irqchip.c b/drivers/irqchip/irqchip.c
> >>>>> index 0fe2f71..afd1af3 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_irq.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();
> >>>>>  }
> >>> Is this in line with Olof's idea that providing a dtb would override ACPI?
> >> Yes, it will. Since ACPI is default OFF (disabled), if a dtb provided, and no acpi=force
> >> passed in the early command line, dtb will be used as system configuration for
> >> boot (dtb is always the prior one for now) [1]. In acpi_gic_init() which called by
> >> acpi_irq_init(), it will return immediately if acpi disabled, so it will not parse
> >> any ACPI table for device configuration.
> > Ok, that matches my recollection.  Thanks for refreshing my memory.  I'll apply
> > this on a topic branch for irqchip/gic when I return from travel.  Most likely
> > Friday or over the weekend.
> 
> Thank you very much! But this patch can't be applied without previous ones in this
> patch set, how about you ack this patch and Catalin takes it via ARM64 tree? I'm
> not sure for this, it depends on your decision.

Is this a build dependency or a boot dependency?  I only received this patch in
the series and I apologize, I'm a bit swamped atm.  Catalin, would an immutable
irqchip/gic topic branch with this in it work for you?

thx,

Jason.

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

* Re: [PATCH v10 16/21] irqchip: Add GICv2 specific ACPI boot support
  2015-03-13 17:15             ` Jason Cooper
@ 2015-03-14  8:47               ` Grant Likely
  2015-03-14 11:43                 ` Catalin Marinas
  0 siblings, 1 reply; 89+ messages in thread
From: Grant Likely @ 2015-03-14  8:47 UTC (permalink / raw)
  To: Jason Cooper
  Cc: Hanjun Guo, Mark Rutland, linaro-acpi, Catalin Marinas,
	Will Deacon, Lorenzo Pieralisi, Timur Tabi,
	ACPI Devel Mailing List, Robert Richter, Arnd Bergmann,
	Marc Zyngier, Jon Masters, Tomasz Nowicki, Mark Brown,
	Thomas Gleixner, linux-arm-kernel, Graeme Gregory,
	Ashwin Chaugule, Rafael J. Wysocki, Linux Kernel Mailing List,
	Hanjun Guo, Suravee Suthikulanit, Sudeep Holla, Olof Johansson

On Fri, Mar 13, 2015 at 5:15 PM, Jason Cooper <jason@lakedaemon.net> wrote:
> Hanjun, Catalin,
>
> On Thu, Mar 12, 2015 at 03:31:57PM +0800, Hanjun Guo wrote:
>> On 2015/3/12 13:12, Jason Cooper wrote:
>> > On Thu, Mar 12, 2015 at 09:46:39AM +0800, Hanjun Guo wrote:
>> >> On 2015/3/12 7:11, Jason Cooper wrote:
>> >>> Hey Grant,
>> >>>
>> >>> On Wed, Mar 11, 2015 at 06:04:50PM +0000, Grant Likely wrote:
>> >>>> On 11 Mar 2015 12:42, "Hanjun Guo" <hanjun.guo@linaro.org> wrote:
>> [...]
>> >>>>> diff --git a/drivers/irqchip/irqchip.c b/drivers/irqchip/irqchip.c
>> >>>>> index 0fe2f71..afd1af3 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_irq.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();
>> >>>>>  }
>> >>> Is this in line with Olof's idea that providing a dtb would override ACPI?
>> >> Yes, it will. Since ACPI is default OFF (disabled), if a dtb provided, and no acpi=force
>> >> passed in the early command line, dtb will be used as system configuration for
>> >> boot (dtb is always the prior one for now) [1]. In acpi_gic_init() which called by
>> >> acpi_irq_init(), it will return immediately if acpi disabled, so it will not parse
>> >> any ACPI table for device configuration.
>> > Ok, that matches my recollection.  Thanks for refreshing my memory.  I'll apply
>> > this on a topic branch for irqchip/gic when I return from travel.  Most likely
>> > Friday or over the weekend.
>>
>> Thank you very much! But this patch can't be applied without previous ones in this
>> patch set, how about you ack this patch and Catalin takes it via ARM64 tree? I'm
>> not sure for this, it depends on your decision.
>
> Is this a build dependency or a boot dependency?  I only received this patch in
> the series and I apologize, I'm a bit swamped atm.  Catalin, would an immutable
> irqchip/gic topic branch with this in it work for you?

Jason,

For a series like this I strongly recommend you provide an ack and let
the whole series go in via a single branch. Trying to split it up only
to reassemble it again creates more work for everyone. There is also
very little likelyhood that this will create a complex conflict with
your tree.

g.

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

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

On Sat, Mar 14, 2015 at 08:47:49AM +0000, Grant Likely wrote:
> On Fri, Mar 13, 2015 at 5:15 PM, Jason Cooper <jason@lakedaemon.net> wrote:
> > Hanjun, Catalin,
> >
> > On Thu, Mar 12, 2015 at 03:31:57PM +0800, Hanjun Guo wrote:
> >> On 2015/3/12 13:12, Jason Cooper wrote:
> >> > On Thu, Mar 12, 2015 at 09:46:39AM +0800, Hanjun Guo wrote:
> >> >> On 2015/3/12 7:11, Jason Cooper wrote:
> >> >>> Hey Grant,
> >> >>>
> >> >>> On Wed, Mar 11, 2015 at 06:04:50PM +0000, Grant Likely wrote:
> >> >>>> On 11 Mar 2015 12:42, "Hanjun Guo" <hanjun.guo@linaro.org> wrote:
> >> [...]
> >> >>>>> diff --git a/drivers/irqchip/irqchip.c b/drivers/irqchip/irqchip.c
> >> >>>>> index 0fe2f71..afd1af3 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_irq.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();
> >> >>>>>  }
> >> >>> Is this in line with Olof's idea that providing a dtb would override ACPI?
> >> >> Yes, it will. Since ACPI is default OFF (disabled), if a dtb provided, and no acpi=force
> >> >> passed in the early command line, dtb will be used as system configuration for
> >> >> boot (dtb is always the prior one for now) [1]. In acpi_gic_init() which called by
> >> >> acpi_irq_init(), it will return immediately if acpi disabled, so it will not parse
> >> >> any ACPI table for device configuration.
> >> > Ok, that matches my recollection.  Thanks for refreshing my memory.  I'll apply
> >> > this on a topic branch for irqchip/gic when I return from travel.  Most likely
> >> > Friday or over the weekend.
> >>
> >> Thank you very much! But this patch can't be applied without previous ones in this
> >> patch set, how about you ack this patch and Catalin takes it via ARM64 tree? I'm
> >> not sure for this, it depends on your decision.
> >
> > Is this a build dependency or a boot dependency?  I only received this patch in
> > the series and I apologize, I'm a bit swamped atm.  Catalin, would an immutable
> > irqchip/gic topic branch with this in it work for you?
> 
> Jason,
> 
> For a series like this I strongly recommend you provide an ack and let
> the whole series go in via a single branch. Trying to split it up only
> to reassemble it again creates more work for everyone. There is also
> very little likelyhood that this will create a complex conflict with
> your tree.

I would prefer this approach as well since we only enable ACPI on arm64
on patch 19. If we are to rework this, we probably end up with 3
branches: one for the base ACPI, another for irqchip and yet another to
enable ACPI on arm64 (that's unless we enable APCI on arm64 but without
any irqchip support which makes it pretty useless for testing).

-- 
Catalin

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

* Re: [PATCH v10 16/21] irqchip: Add GICv2 specific ACPI boot support
  2015-03-11 12:39 ` [PATCH v10 16/21] irqchip: Add GICv2 specific ACPI boot support Hanjun Guo
       [not found]   ` <CACxGe6uWwts6X=Yc2ioBdQizXkF1_YgoNNOsREWirk2MFBVDHg@mail.gmail.com>
@ 2015-03-14 18:44   ` Jason Cooper
  1 sibling, 0 replies; 89+ messages in thread
From: Jason Cooper @ 2015-03-14 18:44 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, 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, Thomas Gleixner

On Wed, Mar 11, 2015 at 08:39:42PM +0800, 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>
> Reviewed-by: Grant Likely <grant.likely@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        |   2 +
>  arch/arm64/include/asm/irq.h         |  13 +++++
>  arch/arm64/kernel/acpi.c             |  25 +++++++++
>  drivers/irqchip/irq-gic.c            | 102 +++++++++++++++++++++++++++++++++++
>  drivers/irqchip/irqchip.c            |   3 ++
>  include/linux/acpi_irq.h             |  10 ++++
>  include/linux/irqchip/arm-gic-acpi.h |  31 +++++++++++
>  7 files changed, 186 insertions(+)
>  create mode 100644 include/linux/acpi_irq.h
>  create mode 100644 include/linux/irqchip/arm-gic-acpi.h

Acked-by: Jason Cooper <jason@lakedaemon.net>

thx,

Jason.

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

* Re: [PATCH v10 00/21] Introduce ACPI for ARM64 based on ACPI 5.1
  2015-03-12 13:26 ` [PATCH v10 00/21] Introduce ACPI for ARM64 based on ACPI 5.1 Timur Tabi
@ 2015-03-16  5:07   ` Suthikulpanit, Suravee
  0 siblings, 0 replies; 89+ messages in thread
From: Suthikulpanit, Suravee @ 2015-03-16  5:07 UTC (permalink / raw)
  To: Timur Tabi, 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, linux-acpi, linux-arm-kernel,
	linux-kernel, linaro-acpi



On 3/12/15, 08:26, "Timur Tabi" <timur@codeaurora.org> wrote:

>Hanjun Guo wrote:
>> This patch set already tested on multi platforms:
>>   - AMD Seattle board;
>>   - Cavium Thunder board;
>>   - Huawei D02 board;
>>   - Qualcomm ARM64 platform
>>
>> This version 10 patch set address some minor comments and collect ACKs
>>and
>> Reviewed-bys for v9:
>>
>>   - new Acks from Rafael, Olof, Grant, Lorenzo
>>   - new way to handle typdef phys_cpuid_t which suggested by Rafael,
>>     but no functional change
>>   - Remove if(!phys) for early ioremappings
>>   - Rework sleep function for ARM64
>>   - Introduce linux/acpi_irq.h to hold acpi_irq_init()
>>   - Disable ACPI if not HW_REDUCED_ACPI compliant
>>   - Remove the doc of why ACPI on ARM
>
>v10 retested and working as before, so ...
>
>	Tested-by: Timur Tabi <timur@codeaurora.org>
>
>for the whole patchset.


Also retested on AMD Seattle.

Tested-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>

>
>-- 
>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] 89+ messages in thread

* Re: [PATCH v10 18/21] ARM64 / ACPI: Select ACPI_REDUCED_HARDWARE_ONLY if ACPI is enabled on ARM64
  2015-03-13 11:04       ` Lorenzo Pieralisi
@ 2015-03-16 11:33         ` Hanjun Guo
  2015-03-17 12:50           ` Lorenzo Pieralisi
  2015-03-18  9:18           ` Lorenzo Pieralisi
  0 siblings, 2 replies; 89+ messages in thread
From: Hanjun Guo @ 2015-03-16 11:33 UTC (permalink / raw)
  To: Lorenzo Pieralisi, 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 2015年03月13日 19:04, Lorenzo Pieralisi wrote:
> On Fri, Mar 13, 2015 at 03:28:45AM +0000, Hanjun Guo wrote:
>
> [...]
>
>>>   /*
>>>    * 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
>>> + *	4. check ACPI FADT HW reduced flag
>>>    *
>>>    * We can parse ACPI boot-time tables such as MADT after
>>>    * this function is called.
>>>    */
>>>   void __init acpi_boot_table_init(void)
>>>   {
>>> +	struct acpi_table_header *table;
>>> +	struct acpi_table_fadt *fadt;
>>> +	acpi_status status;
>>> +	acpi_size tbl_size;
>>> +
>>>   	/*
>>>   	 * Enable ACPI instead of device tree unless
>>>   	 * - ACPI has been disabled explicitly (acpi=off), or
>>> @@ -351,19 +318,52 @@ void __init acpi_boot_table_init(void)
>>>   	    (!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()) {
>>
>> Since we disable ACPI in default, it is a bit strange for me to init all
>> the ACPI tables and parse FADT when ACPI is disabled, could you
>> put some comments here to clarify the purpose? other than that, it is looks
>> good to me.
>
> Ok, the purpose was to make things simpler, but I think that given
> current code it is not 100% safe to init ACPI tables with
> acpi_disabled == 1.
>
> To me having to enable ACPI to parse the tables and check *if* ACPI tables
> are there is a bit crazy, but I agree with you that given current code
> it is safer.
>
> Patch rewritten, here below, please have a look, test it and rework
> bits as needed, I added comments where I thought they were needed but
> please add to that if you feel it is worth it.
>
> It should be easy to split, let me know if you want an incremental
> version.

This one is much better, pretty fine to me, thanks!

I assume that this patch is cleanup patch on top of ARM64 ACPI
core patches, right?

Thanks
Hanjun

>
> Thanks !
> Lorenzo
>
> ---
>   arch/arm64/kernel/acpi.c | 103 +++++++++++++++++++++++++++++++----------------
>   1 file changed, 69 insertions(+), 34 deletions(-)
>
> diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c
> index 5819ef7..e5ee4d4 100644
> --- a/arch/arm64/kernel/acpi.c
> +++ b/arch/arm64/kernel/acpi.c
> @@ -291,43 +291,60 @@ void acpi_unregister_gsi(u32 gsi)
>   }
>   EXPORT_SYMBOL_GPL(acpi_unregister_gsi);
>
> -static int __init acpi_parse_fadt(struct acpi_table_header *table)
> +/*
> + * acpi_fadt_sanity_check() - Check FADT presence and carry out sanity
> + *			      checks on it
> + *
> + * Return 0 on success,  <0 on failure
> + */
> +static int __init acpi_fadt_sanity_check(void)
>   {
> -	struct acpi_table_fadt *fadt = (struct acpi_table_fadt *)table;
> +	struct acpi_table_header *table;
> +	struct acpi_table_fadt *fadt;
> +	acpi_status status;
> +	acpi_size tbl_size;
> +	int ret = 0;
> +
> +	/*
> +	 * FADT is required on arm64; retrieve it to check its presence
> +	 * and carry out revision and ACPI HW reduced compliancy tests
> +	 */
> +	status = acpi_get_table_with_size(ACPI_SIG_FADT, 0, &table, &tbl_size);
> +	if (ACPI_FAILURE(status)) {
> +		const char *msg = acpi_format_exception(status);
> +
> +		pr_err("Failed to get FADT table, %s\n", msg);
> +		return -ENODEV;
> +	}
> +
> +	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.
> +	 * boot protocol configuration data.
>   	 */
> -	if (table->revision > 5 ||
> -	    (table->revision == 5 && fadt->minor_revision >= 1)) {
> -		if (!acpi_gbl_reduced_hardware) {
> -			pr_err("Not hardware reduced ACPI mode, will not be supported\n");
> -			goto disable_acpi;
> -		}
> -
> -		/*
> -		 * 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;
> +	if (table->revision < 5 ||
> +	   (table->revision == 5 && fadt->minor_revision < 1)) {
> +		pr_err("Unsupported FADT revision %d.%d, should be 5.1+\n",
> +		       table->revision, fadt->minor_revision);
> +		ret = -EINVAL;
> +		goto out;
>   	}
>
> -	pr_warn("Unsupported FADT revision %d.%d, should be 5.1+, will disable ACPI\n",
> -		table->revision, fadt->minor_revision);
> +	if (!(fadt->flags & ACPI_FADT_HW_REDUCED)) {
> +		pr_err("FADT not ACPI hardware reduced compliant\n");
> +		ret = -EINVAL;
> +	}
>
> -disable_acpi:
> -	disable_acpi();
> -	return -EINVAL;
> +out:
> +	/*
> +	 * acpi_get_table_with_size() creates FADT table mapping that
> +	 * should be released after parsing and before resuming boot
> +	 */
> +	early_acpi_os_unmap_memory((char *)table, tbl_size);
> +	return ret;
>   }
>
>   /*
> @@ -335,12 +352,17 @@ disable_acpi:
>    *	1. find RSDP and get its address, and then find XSDT
>    *	2. extract all tables and checksums them all
>    *	3. check ACPI FADT revision
> + *	4. check ACPI FADT HW reduced flag
>    *
>    * We can parse ACPI boot-time tables such as MADT after
>    * this function is called.
> + *
> + * ACPI is enabled on return if ACPI tables initialized and sanity checks
> + * passed, disabled otherwise
>    */
>   void __init acpi_boot_table_init(void)
>   {
> +
>   	/*
>   	 * Enable ACPI instead of device tree unless
>   	 * - ACPI has been disabled explicitly (acpi=off), or
> @@ -351,19 +373,32 @@ void __init acpi_boot_table_init(void)
>   	    (!param_acpi_force && of_scan_flat_dt(dt_scan_depth1_nodes, NULL)))
>   		return;
>
> +	/*
> +	 * ACPI is disabled at this point. Enable it in order to parse
> +	 * the ACPI tables and carry out sanity checks
> +	 */
>   	enable_acpi();
>
>   	/* Initialize the ACPI boot-time table parser. */
>   	if (acpi_table_init()) {
> -		disable_acpi();
> -		return;
> +		pr_err("Failed to init ACPI tables\n");
> +		goto init_failed;
>   	}
>
> -	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");
> -	}
> +	/*
> +	 * Check FADT presence and carry out FADT sanity checks
> +	 */
> +	if (acpi_fadt_sanity_check() < 0)
> +		goto init_failed;
> +
> +	/*
> +	 * ACPI tables initialized and FADT sanity checks passed, leave
> +	 * ACPI enabled and carry on booting
> +	 */
> +	return;
> +
> +init_failed:
> +	disable_acpi();
>   }
>
>   void __init acpi_gic_init(void)
>

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

* Re: [PATCH v10 10/21] ARM64 / ACPI: Get PSCI flags in FADT for PSCI init
  2015-03-13 14:51   ` Lorenzo Pieralisi
@ 2015-03-16 11:45     ` Hanjun Guo
  2015-03-16 18:41       ` Lorenzo Pieralisi
  0 siblings, 1 reply; 89+ messages in thread
From: Hanjun Guo @ 2015-03-16 11:45 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, Tomasz Nowicki

On 2015年03月13日 22:51, Lorenzo Pieralisi wrote:
> On Wed, Mar 11, 2015 at 12:39:36PM +0000, Hanjun Guo wrote:
>
> [...]
>
>> +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.
>> @@ -306,29 +335,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();
>
> You should have factored out the firmware version probing too, that's
> the only way we can detect the PSCI firmware version when booting through
> ACPI. You can end up initializing pointers for v0.2+ with a mismatching
> version implemented in PSCI firmware, eg 0.1.
>
> We should do that incrementally, I will put together a patch to
> factor out the FW version probing first, you can rebase on top of it.

Incrementally patches on top of this patch set? I think v10 of this
patch set is ready for merge, but I'm open for suggestions if we will
not miss the merge window for Catalin.

>
>>   out_put_node:
>>   	of_node_put(np);
>> @@ -381,7 +388,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;
>> @@ -396,6 +403,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;
>> +	}
>
> If PSCI is not present, that's a problem related to SMP init, right ?
> That's where a warning should be printed if any, not here, the SBBR
> mandates PSCI as secondaries bring up method, warn otherwise.

The SBBR is also said that if PSCI is not available, Parking protocol
will be used as secondaries bring up method, so I said that it is ok
to me that we don't print warn message for no PSCI support when parsing
FADT.

So maybe we can go back to the previous solution, print some warning
message if no PSCI when parsing FADT?

Thanks
Hanjun

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

* Re: [PATCH v10 10/21] ARM64 / ACPI: Get PSCI flags in FADT for PSCI init
  2015-03-16 11:45     ` Hanjun Guo
@ 2015-03-16 18:41       ` Lorenzo Pieralisi
  0 siblings, 0 replies; 89+ messages in thread
From: Lorenzo Pieralisi @ 2015-03-16 18:41 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 Mon, Mar 16, 2015 at 11:45:25AM +0000, Hanjun Guo wrote:
> On 2015年03月13日 22:51, Lorenzo Pieralisi wrote:
> > On Wed, Mar 11, 2015 at 12:39:36PM +0000, Hanjun Guo wrote:
> >
> > [...]
> >
> >> +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.
> >> @@ -306,29 +335,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();
> >
> > You should have factored out the firmware version probing too, that's
> > the only way we can detect the PSCI firmware version when booting through
> > ACPI. You can end up initializing pointers for v0.2+ with a mismatching
> > version implemented in PSCI firmware, eg 0.1.
> >
> > We should do that incrementally, I will put together a patch to
> > factor out the FW version probing first, you can rebase on top of it.
> 
> Incrementally patches on top of this patch set? I think v10 of this
> patch set is ready for merge, but I'm open for suggestions if we will
> not miss the merge window for Catalin.

I gave you my suggestion, I will try to get the prerequisite patch
queued asap, it is not a big deal but that's something that should be
fixed otherwise I would not have flagged this up.

I will post the patch asap, if we fail to get that in we will see what
to do, I do not expect this to be a blocking point.

> >
> >>   out_put_node:
> >>   	of_node_put(np);
> >> @@ -381,7 +388,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;
> >> @@ -396,6 +403,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;
> >> +	}
> >
> > If PSCI is not present, that's a problem related to SMP init, right ?
> > That's where a warning should be printed if any, not here, the SBBR
> > mandates PSCI as secondaries bring up method, warn otherwise.
> 
> The SBBR is also said that if PSCI is not available, Parking protocol
> will be used as secondaries bring up method, so I said that it is ok
> to me that we don't print warn message for no PSCI support when parsing
> FADT.
> 
> So maybe we can go back to the previous solution, print some warning
> message if no PSCI when parsing FADT?

You answered your own question. It is not what it is mandated, but if
a platform boots with parking protocol, do you think the information
you are printing in:

if (!acpi_psci_present()) {
	pr_info("is not implemented in ACPI.\n");
        ^^^

is useful to them ?

What should be flagged up is a missing boot method for secondaries,
a missing PSCI is not per-se an error, that's why I said it should
be done when preparing CPUs for SMP init.

No big deal at all, but I would remove the pr_info above.

Lorenzo

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

* Re: [PATCH v10 18/21] ARM64 / ACPI: Select ACPI_REDUCED_HARDWARE_ONLY if ACPI is enabled on ARM64
  2015-03-16 11:33         ` Hanjun Guo
@ 2015-03-17 12:50           ` Lorenzo Pieralisi
  2015-03-18  9:18           ` Lorenzo Pieralisi
  1 sibling, 0 replies; 89+ messages in thread
From: Lorenzo Pieralisi @ 2015-03-17 12:50 UTC (permalink / raw)
  To: Hanjun Guo
  Cc: guohanjun, 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 Mon, Mar 16, 2015 at 11:33:29AM +0000, Hanjun Guo wrote:

[...]

> > Patch rewritten, here below, please have a look, test it and rework
> > bits as needed, I added comments where I thought they were needed but
> > please add to that if you feel it is worth it.
> >
> > It should be easy to split, let me know if you want an incremental
> > version.
> 
> This one is much better, pretty fine to me, thanks!
> 
> I assume that this patch is cleanup patch on top of ARM64 ACPI
> core patches, right?

Well, it is a clean-up patch on top of your series, I can split it
in the respective patches and send you the patches in your series
updated with this code.

Thanks,
Lorenzo

> 
> Thanks
> Hanjun
> 
> >
> > Thanks !
> > Lorenzo
> >
> > ---
> >   arch/arm64/kernel/acpi.c | 103 +++++++++++++++++++++++++++++++----------------
> >   1 file changed, 69 insertions(+), 34 deletions(-)
> >
> > diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c
> > index 5819ef7..e5ee4d4 100644
> > --- a/arch/arm64/kernel/acpi.c
> > +++ b/arch/arm64/kernel/acpi.c
> > @@ -291,43 +291,60 @@ void acpi_unregister_gsi(u32 gsi)
> >   }
> >   EXPORT_SYMBOL_GPL(acpi_unregister_gsi);
> >
> > -static int __init acpi_parse_fadt(struct acpi_table_header *table)
> > +/*
> > + * acpi_fadt_sanity_check() - Check FADT presence and carry out sanity
> > + *			      checks on it
> > + *
> > + * Return 0 on success,  <0 on failure
> > + */
> > +static int __init acpi_fadt_sanity_check(void)
> >   {
> > -	struct acpi_table_fadt *fadt = (struct acpi_table_fadt *)table;
> > +	struct acpi_table_header *table;
> > +	struct acpi_table_fadt *fadt;
> > +	acpi_status status;
> > +	acpi_size tbl_size;
> > +	int ret = 0;
> > +
> > +	/*
> > +	 * FADT is required on arm64; retrieve it to check its presence
> > +	 * and carry out revision and ACPI HW reduced compliancy tests
> > +	 */
> > +	status = acpi_get_table_with_size(ACPI_SIG_FADT, 0, &table, &tbl_size);
> > +	if (ACPI_FAILURE(status)) {
> > +		const char *msg = acpi_format_exception(status);
> > +
> > +		pr_err("Failed to get FADT table, %s\n", msg);
> > +		return -ENODEV;
> > +	}
> > +
> > +	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.
> > +	 * boot protocol configuration data.
> >   	 */
> > -	if (table->revision > 5 ||
> > -	    (table->revision == 5 && fadt->minor_revision >= 1)) {
> > -		if (!acpi_gbl_reduced_hardware) {
> > -			pr_err("Not hardware reduced ACPI mode, will not be supported\n");
> > -			goto disable_acpi;
> > -		}
> > -
> > -		/*
> > -		 * 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;
> > +	if (table->revision < 5 ||
> > +	   (table->revision == 5 && fadt->minor_revision < 1)) {
> > +		pr_err("Unsupported FADT revision %d.%d, should be 5.1+\n",
> > +		       table->revision, fadt->minor_revision);
> > +		ret = -EINVAL;
> > +		goto out;
> >   	}
> >
> > -	pr_warn("Unsupported FADT revision %d.%d, should be 5.1+, will disable ACPI\n",
> > -		table->revision, fadt->minor_revision);
> > +	if (!(fadt->flags & ACPI_FADT_HW_REDUCED)) {
> > +		pr_err("FADT not ACPI hardware reduced compliant\n");
> > +		ret = -EINVAL;
> > +	}
> >
> > -disable_acpi:
> > -	disable_acpi();
> > -	return -EINVAL;
> > +out:
> > +	/*
> > +	 * acpi_get_table_with_size() creates FADT table mapping that
> > +	 * should be released after parsing and before resuming boot
> > +	 */
> > +	early_acpi_os_unmap_memory((char *)table, tbl_size);
> > +	return ret;
> >   }
> >
> >   /*
> > @@ -335,12 +352,17 @@ disable_acpi:
> >    *	1. find RSDP and get its address, and then find XSDT
> >    *	2. extract all tables and checksums them all
> >    *	3. check ACPI FADT revision
> > + *	4. check ACPI FADT HW reduced flag
> >    *
> >    * We can parse ACPI boot-time tables such as MADT after
> >    * this function is called.
> > + *
> > + * ACPI is enabled on return if ACPI tables initialized and sanity checks
> > + * passed, disabled otherwise
> >    */
> >   void __init acpi_boot_table_init(void)
> >   {
> > +
> >   	/*
> >   	 * Enable ACPI instead of device tree unless
> >   	 * - ACPI has been disabled explicitly (acpi=off), or
> > @@ -351,19 +373,32 @@ void __init acpi_boot_table_init(void)
> >   	    (!param_acpi_force && of_scan_flat_dt(dt_scan_depth1_nodes, NULL)))
> >   		return;
> >
> > +	/*
> > +	 * ACPI is disabled at this point. Enable it in order to parse
> > +	 * the ACPI tables and carry out sanity checks
> > +	 */
> >   	enable_acpi();
> >
> >   	/* Initialize the ACPI boot-time table parser. */
> >   	if (acpi_table_init()) {
> > -		disable_acpi();
> > -		return;
> > +		pr_err("Failed to init ACPI tables\n");
> > +		goto init_failed;
> >   	}
> >
> > -	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");
> > -	}
> > +	/*
> > +	 * Check FADT presence and carry out FADT sanity checks
> > +	 */
> > +	if (acpi_fadt_sanity_check() < 0)
> > +		goto init_failed;
> > +
> > +	/*
> > +	 * ACPI tables initialized and FADT sanity checks passed, leave
> > +	 * ACPI enabled and carry on booting
> > +	 */
> > +	return;
> > +
> > +init_failed:
> > +	disable_acpi();
> >   }
> >
> >   void __init acpi_gic_init(void)
> >
> 

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

* Re: [PATCH v10 18/21] ARM64 / ACPI: Select ACPI_REDUCED_HARDWARE_ONLY if ACPI is enabled on ARM64
  2015-03-16 11:33         ` Hanjun Guo
  2015-03-17 12:50           ` Lorenzo Pieralisi
@ 2015-03-18  9:18           ` Lorenzo Pieralisi
  2015-03-18 15:06             ` Rafael J. Wysocki
  1 sibling, 1 reply; 89+ messages in thread
From: Lorenzo Pieralisi @ 2015-03-18  9:18 UTC (permalink / raw)
  To: Hanjun Guo
  Cc: guohanjun, 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 Mon, Mar 16, 2015 at 11:33:29AM +0000, Hanjun Guo wrote:
> On 2015年03月13日 19:04, Lorenzo Pieralisi wrote:
> > On Fri, Mar 13, 2015 at 03:28:45AM +0000, Hanjun Guo wrote:
> >
> > [...]
> >
> >>>   /*
> >>>    * 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
> >>> + *	4. check ACPI FADT HW reduced flag
> >>>    *
> >>>    * We can parse ACPI boot-time tables such as MADT after
> >>>    * this function is called.
> >>>    */
> >>>   void __init acpi_boot_table_init(void)
> >>>   {
> >>> +	struct acpi_table_header *table;
> >>> +	struct acpi_table_fadt *fadt;
> >>> +	acpi_status status;
> >>> +	acpi_size tbl_size;
> >>> +
> >>>   	/*
> >>>   	 * Enable ACPI instead of device tree unless
> >>>   	 * - ACPI has been disabled explicitly (acpi=off), or
> >>> @@ -351,19 +318,52 @@ void __init acpi_boot_table_init(void)
> >>>   	    (!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()) {
> >>
> >> Since we disable ACPI in default, it is a bit strange for me to init all
> >> the ACPI tables and parse FADT when ACPI is disabled, could you
> >> put some comments here to clarify the purpose? other than that, it is looks
> >> good to me.
> >
> > Ok, the purpose was to make things simpler, but I think that given
> > current code it is not 100% safe to init ACPI tables with
> > acpi_disabled == 1.
> >
> > To me having to enable ACPI to parse the tables and check *if* ACPI tables
> > are there is a bit crazy, but I agree with you that given current code
> > it is safer.
> >
> > Patch rewritten, here below, please have a look, test it and rework
> > bits as needed, I added comments where I thought they were needed but
> > please add to that if you feel it is worth it.
> >
> > It should be easy to split, let me know if you want an incremental
> > version.
> 
> This one is much better, pretty fine to me, thanks!
> 
> I assume that this patch is cleanup patch on top of ARM64 ACPI
> core patches, right?

For the records, I created a branch with my patch split over some
of your patches, even though I think to make things simpler it is best
to apply it as a single patch on top of your series, I will prepare the
commit log for the single patch version too.

Lorenzo

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

* Re: [PATCH v10 08/21] ARM64 / ACPI: Introduce early_param "acpi=" to enable/disable ACPI
  2015-03-11 12:39 ` [PATCH v10 08/21] ARM64 / ACPI: Introduce early_param "acpi=" to enable/disable ACPI Hanjun Guo
@ 2015-03-18 11:35   ` Lorenzo Pieralisi
  2015-03-18 20:07     ` Ard Biesheuvel
  0 siblings, 1 reply; 89+ messages in thread
From: Lorenzo Pieralisi @ 2015-03-18 11:35 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,
	Ard Biesheuvel

On Wed, Mar 11, 2015 at 12:39:34PM +0000, 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)

I think this comment is stale. acpi=force enables ACPI and tries to
init the ACPI tables without even checking DT, but it does fall back to
DT if ACPI table init fails (by disabling ACPI and unflattening the
FDT).

Am I wrong ?

Lorenzo

> - 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>
> Acked-by: Olof Johansson <olof@lixom.net>
> Acked-by: Grant Likely <grant.likely@linaro.org>
> Tested-by: Timur Tabi <timur@codeaurora.org>
> 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 7abac24..2269e30 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 param_acpi_off __initdata;
> +static bool param_acpi_force __initdata;
> +
> +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] 89+ messages in thread

* Re: [PATCH v10 18/21] ARM64 / ACPI: Select ACPI_REDUCED_HARDWARE_ONLY if ACPI is enabled on ARM64
  2015-03-18  9:18           ` Lorenzo Pieralisi
@ 2015-03-18 15:06             ` Rafael J. Wysocki
  2015-03-19  1:16               ` Hanjun Guo
  0 siblings, 1 reply; 89+ messages in thread
From: Rafael J. Wysocki @ 2015-03-18 15:06 UTC (permalink / raw)
  To: Lorenzo Pieralisi, Hanjun Guo
  Cc: guohanjun, Catalin Marinas, 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 Wednesday, March 18, 2015 09:18:20 AM Lorenzo Pieralisi wrote:
> On Mon, Mar 16, 2015 at 11:33:29AM +0000, Hanjun Guo wrote:
> > On 2015年03月13日 19:04, Lorenzo Pieralisi wrote:
> > > On Fri, Mar 13, 2015 at 03:28:45AM +0000, Hanjun Guo wrote:
> > >
> > > [...]
> > >
> > >>>   /*
> > >>>    * 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
> > >>> + *	4. check ACPI FADT HW reduced flag
> > >>>    *
> > >>>    * We can parse ACPI boot-time tables such as MADT after
> > >>>    * this function is called.
> > >>>    */
> > >>>   void __init acpi_boot_table_init(void)
> > >>>   {
> > >>> +	struct acpi_table_header *table;
> > >>> +	struct acpi_table_fadt *fadt;
> > >>> +	acpi_status status;
> > >>> +	acpi_size tbl_size;
> > >>> +
> > >>>   	/*
> > >>>   	 * Enable ACPI instead of device tree unless
> > >>>   	 * - ACPI has been disabled explicitly (acpi=off), or
> > >>> @@ -351,19 +318,52 @@ void __init acpi_boot_table_init(void)
> > >>>   	    (!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()) {
> > >>
> > >> Since we disable ACPI in default, it is a bit strange for me to init all
> > >> the ACPI tables and parse FADT when ACPI is disabled, could you
> > >> put some comments here to clarify the purpose? other than that, it is looks
> > >> good to me.
> > >
> > > Ok, the purpose was to make things simpler, but I think that given
> > > current code it is not 100% safe to init ACPI tables with
> > > acpi_disabled == 1.
> > >
> > > To me having to enable ACPI to parse the tables and check *if* ACPI tables
> > > are there is a bit crazy, but I agree with you that given current code
> > > it is safer.
> > >
> > > Patch rewritten, here below, please have a look, test it and rework
> > > bits as needed, I added comments where I thought they were needed but
> > > please add to that if you feel it is worth it.
> > >
> > > It should be easy to split, let me know if you want an incremental
> > > version.
> > 
> > This one is much better, pretty fine to me, thanks!
> > 
> > I assume that this patch is cleanup patch on top of ARM64 ACPI
> > core patches, right?
> 
> For the records, I created a branch with my patch split over some
> of your patches, even though I think to make things simpler it is best
> to apply it as a single patch on top of your series,

I agree.  In particular, the patches that have already been reviewed and
ACKed won't need to be reviewed again this way which seems to be crucially
important to me.

> I will prepare the commit log for the single patch version too.

Thanks!

Hanjun, please add this one to the series when ready.


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

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

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

On Wed, Mar 11, 2015 at 08:39:35PM +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>
> Acked-by: Olof Johansson <olof@lixom.net>
> Acked-by: Grant Likely <grant.likely@linaro.org>
> 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();

Lorenzo commented on the previous patch that acpi=force still allows the
fall back to DT. I guess you may want something like:

	if (acpi_disabled && !param_acpi_force)
		unflatten_device_tree();

-- 
Catalin

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

* Re: [PATCH v10 17/21] clocksource / arch_timer: Parse GTDT to initialize arch timer
  2015-03-11 12:39 ` [PATCH v10 17/21] clocksource / arch_timer: Parse GTDT to initialize arch timer Hanjun Guo
@ 2015-03-18 18:34   ` Will Deacon
  2015-03-20 13:49   ` Daniel Lezcano
  1 sibling, 0 replies; 89+ messages in thread
From: Will Deacon @ 2015-03-18 18:34 UTC (permalink / raw)
  To: Hanjun Guo
  Cc: Catalin Marinas, Rafael J. Wysocki, 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, Daniel Lezcano,
	Thomas Gleixner

On Wed, Mar 11, 2015 at 12:39:43PM +0000, Hanjun Guo 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>
> Reviewed-by: Grant Likely <grant.likely@linaro.org>
> 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(-)

Daniel, can we have your Ack on this patch please? The intention is to
merge the whole series via the arm64 tree.

Cheers.

Will

> 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] 89+ messages in thread

* Re: [PATCH v10 15/21] ARM64 / ACPI: Introduce ACPI_IRQ_MODEL_GIC and register device's gsi
  2015-03-11 12:39 ` [PATCH v10 15/21] ARM64 / ACPI: Introduce ACPI_IRQ_MODEL_GIC and register device's gsi Hanjun Guo
@ 2015-03-18 18:41   ` Will Deacon
  2015-03-19  3:45     ` Hanjun Guo
  0 siblings, 1 reply; 89+ messages in thread
From: Will Deacon @ 2015-03-18 18:41 UTC (permalink / raw)
  To: Hanjun Guo
  Cc: Catalin Marinas, Rafael J. Wysocki, 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, Mar 11, 2015 at 12:39:41PM +0000, 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>
> Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> Reviewed-by: Grant Likely <grant.likely@linaro.org>
> 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 c9203c0..dec6f8a 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);

I see you've still got this buried in the arch code. Is there any plan to
move it out, as I moaned about this in the last version of the series and
nothing seems to have changed?

Will

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

* Re: [PATCH v10 00/21] Introduce ACPI for ARM64 based on ACPI 5.1
  2015-03-11 12:39 [PATCH v10 00/21] Introduce ACPI for ARM64 based on ACPI 5.1 Hanjun Guo
                   ` (21 preceding siblings ...)
  2015-03-12 13:26 ` [PATCH v10 00/21] Introduce ACPI for ARM64 based on ACPI 5.1 Timur Tabi
@ 2015-03-18 19:05 ` Will Deacon
  2015-03-18 19:09   ` Will Deacon
  2015-03-19  4:09   ` Hanjun Guo
  2015-03-20 13:18 ` Mark Salter
  23 siblings, 2 replies; 89+ messages in thread
From: Will Deacon @ 2015-03-18 19:05 UTC (permalink / raw)
  To: Hanjun Guo
  Cc: Catalin Marinas, Rafael J. Wysocki, 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

Hanjun,

On Wed, Mar 11, 2015 at 12:39:26PM +0000, Hanjun Guo wrote:
> This patch set already tested on multi platforms:
>  - AMD Seattle board;
>  - Cavium Thunder board;
>  - Huawei D02 board;
>  - Qualcomm ARM64 platform
> 
> This version 10 patch set address some minor comments and collect ACKs and
> Reviewed-bys for v9:
> 
>  - new Acks from Rafael, Olof, Grant, Lorenzo
>  - new way to handle typdef phys_cpuid_t which suggested by Rafael,
>    but no functional change
>  - Remove if(!phys) for early ioremappings
>  - Rework sleep function for ARM64
>  - Introduce linux/acpi_irq.h to hold acpi_irq_init()
>  - Disable ACPI if not HW_REDUCED_ACPI compliant
>  - Remove the doc of why ACPI on ARM

So I've had a look at the current state of this series and I think there
are a few immediate things left to do:

  (1) Resolve the acpi=force cmdline issue highlighted by Lorenzo and
      Catalin

  (2) I believe Sudeep and Lorenzo have concerns about patch 13 (SMP init),
      so I'm assuming there will be additional patches from them that are
      required.

  (3) I have an open comment about moving the IRQ domain code into the
      core, which I'd like to see addressed.

  (4) We need an ack from Daniel on the arch-timer patch

If you can get that in place, I'm not opposed to putting this into
linux-next ahead of the firmware summit in San Jose next week. Note that
this is not a commitment for 4.1, since I'm keen to see the outcomes of
next week before setting anything in stone.

Also, there's no need to repost patches if you're just adding Acks. I
think I'm up to speed with those on my local branch and the Tested-by
party is starting to look a little silly.

Will

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

* Re: [PATCH v10 00/21] Introduce ACPI for ARM64 based on ACPI 5.1
  2015-03-18 19:05 ` Will Deacon
@ 2015-03-18 19:09   ` Will Deacon
  2015-03-19  4:09   ` Hanjun Guo
  1 sibling, 0 replies; 89+ messages in thread
From: Will Deacon @ 2015-03-18 19:09 UTC (permalink / raw)
  To: hanjun.guo
  Cc: Catalin Marinas, Rafael J. Wysocki, 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, Mar 18, 2015 at 07:05:09PM +0000, Will Deacon wrote:
>   (2) I believe Sudeep and Lorenzo have concerns about patch 13 (SMP init),
>       so I'm assuming there will be additional patches from them that are
>       required.

Bah, getting ahead of myself. This is in fact patch *12* of the series :)

Will

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

* Re: [PATCH v10 08/21] ARM64 / ACPI: Introduce early_param "acpi=" to enable/disable ACPI
  2015-03-18 11:35   ` Lorenzo Pieralisi
@ 2015-03-18 20:07     ` Ard Biesheuvel
  2015-03-19  2:30       ` Hanjun Guo
  2015-03-19 10:04       ` Lorenzo Pieralisi
  0 siblings, 2 replies; 89+ messages in thread
From: Ard Biesheuvel @ 2015-03-18 20:07 UTC (permalink / raw)
  To: Lorenzo Pieralisi
  Cc: Hanjun Guo, 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 18 March 2015 at 12:35, Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> wrote:
> On Wed, Mar 11, 2015 at 12:39:34PM +0000, 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)
>
> I think this comment is stale. acpi=force enables ACPI and tries to
> init the ACPI tables without even checking DT, but it does fall back to
> DT if ACPI table init fails (by disabling ACPI and unflattening the
> FDT).
>
> Am I wrong ?
>

No, you're right. But I would suggest that we fix the code, not the comment.

I think we are all in agreement on the policy, we only need to make
disable_acpi() conditional on whether acpi_param_force is set


>> - 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>
>> Acked-by: Olof Johansson <olof@lixom.net>
>> Acked-by: Grant Likely <grant.likely@linaro.org>
>> Tested-by: Timur Tabi <timur@codeaurora.org>
>> 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 7abac24..2269e30 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 param_acpi_off __initdata;
>> +static bool param_acpi_force __initdata;
>> +
>> +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] 89+ messages in thread

* Re: [PATCH v10 18/21] ARM64 / ACPI: Select ACPI_REDUCED_HARDWARE_ONLY if ACPI is enabled on ARM64
  2015-03-18 15:06             ` Rafael J. Wysocki
@ 2015-03-19  1:16               ` Hanjun Guo
  0 siblings, 0 replies; 89+ messages in thread
From: Hanjun Guo @ 2015-03-19  1:16 UTC (permalink / raw)
  To: Rafael J. Wysocki, Lorenzo Pieralisi, Hanjun Guo
  Cc: Catalin Marinas, 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/3/18 23:06, Rafael J. Wysocki wrote:
> On Wednesday, March 18, 2015 09:18:20 AM Lorenzo Pieralisi wrote:
>> On Mon, Mar 16, 2015 at 11:33:29AM +0000, Hanjun Guo wrote:
>>> On 2015年03月13日 19:04, Lorenzo Pieralisi wrote:
>>>> On Fri, Mar 13, 2015 at 03:28:45AM +0000, Hanjun Guo wrote:
>>>>
>>>> [...]
>>>>
>>>>>>   /*
>>>>>>    * 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
>>>>>> + *	4. check ACPI FADT HW reduced flag
>>>>>>    *
>>>>>>    * We can parse ACPI boot-time tables such as MADT after
>>>>>>    * this function is called.
>>>>>>    */
>>>>>>   void __init acpi_boot_table_init(void)
>>>>>>   {
>>>>>> +	struct acpi_table_header *table;
>>>>>> +	struct acpi_table_fadt *fadt;
>>>>>> +	acpi_status status;
>>>>>> +	acpi_size tbl_size;
>>>>>> +
>>>>>>   	/*
>>>>>>   	 * Enable ACPI instead of device tree unless
>>>>>>   	 * - ACPI has been disabled explicitly (acpi=off), or
>>>>>> @@ -351,19 +318,52 @@ void __init acpi_boot_table_init(void)
>>>>>>   	    (!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()) {
>>>>> Since we disable ACPI in default, it is a bit strange for me to init all
>>>>> the ACPI tables and parse FADT when ACPI is disabled, could you
>>>>> put some comments here to clarify the purpose? other than that, it is looks
>>>>> good to me.
>>>> Ok, the purpose was to make things simpler, but I think that given
>>>> current code it is not 100% safe to init ACPI tables with
>>>> acpi_disabled == 1.
>>>>
>>>> To me having to enable ACPI to parse the tables and check *if* ACPI tables
>>>> are there is a bit crazy, but I agree with you that given current code
>>>> it is safer.
>>>>
>>>> Patch rewritten, here below, please have a look, test it and rework
>>>> bits as needed, I added comments where I thought they were needed but
>>>> please add to that if you feel it is worth it.
>>>>
>>>> It should be easy to split, let me know if you want an incremental
>>>> version.
>>> This one is much better, pretty fine to me, thanks!
>>>
>>> I assume that this patch is cleanup patch on top of ARM64 ACPI
>>> core patches, right?
>> For the records, I created a branch with my patch split over some
>> of your patches, even though I think to make things simpler it is best
>> to apply it as a single patch on top of your series,
> I agree.  In particular, the patches that have already been reviewed and
> ACKed won't need to be reviewed again this way which seems to be crucially
> important to me.
>
>> I will prepare the commit log for the single patch version too.
> Thanks!
>
> Hanjun, please add this one to the series when ready.

Sure, I will.

Thanks
Hanjun


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

* Re: [PATCH v10 08/21] ARM64 / ACPI: Introduce early_param "acpi=" to enable/disable ACPI
  2015-03-18 20:07     ` Ard Biesheuvel
@ 2015-03-19  2:30       ` Hanjun Guo
  2015-03-19 10:04       ` Lorenzo Pieralisi
  1 sibling, 0 replies; 89+ messages in thread
From: Hanjun Guo @ 2015-03-19  2:30 UTC (permalink / raw)
  To: Ard Biesheuvel, Lorenzo Pieralisi
  Cc: Hanjun Guo, 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/3/19 4:07, Ard Biesheuvel wrote:
> On 18 March 2015 at 12:35, Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> wrote:
>> On Wed, Mar 11, 2015 at 12:39:34PM +0000, 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)
>> I think this comment is stale. acpi=force enables ACPI and tries to
>> init the ACPI tables without even checking DT, but it does fall back to
>> DT if ACPI table init fails (by disabling ACPI and unflattening the
>> FDT).
>>
>> Am I wrong ?
>>
> No, you're right. But I would suggest that we fix the code, not the comment.

I agree. If user pass "acpi=force", I think it means ACPI only, so if
ACPI fails, we can just not going to boot the system.

>
> I think we are all in agreement on the policy, we only need to make
> disable_acpi() conditional on whether acpi_param_force is set

I prefer Catalin's suggestion, just not to unflatten the device tree,
what do you think?

If it is ok, I will add a fix patch on top of this patch set.

Thanks
Hanjun

>
>
>>> - 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>
>>> Acked-by: Olof Johansson <olof@lixom.net>
>>> Acked-by: Grant Likely <grant.likely@linaro.org>
>>> Tested-by: Timur Tabi <timur@codeaurora.org>
>>> 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 7abac24..2269e30 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 param_acpi_off __initdata;
>>> +static bool param_acpi_force __initdata;
>>> +
>>> +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
>>>
>>>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
> .
>



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

* Re: [PATCH v10 15/21] ARM64 / ACPI: Introduce ACPI_IRQ_MODEL_GIC and register device's gsi
  2015-03-18 18:41   ` Will Deacon
@ 2015-03-19  3:45     ` Hanjun Guo
  2015-03-19 10:12       ` Lorenzo Pieralisi
  0 siblings, 1 reply; 89+ messages in thread
From: Hanjun Guo @ 2015-03-19  3:45 UTC (permalink / raw)
  To: Will Deacon, Hanjun Guo
  Cc: Catalin Marinas, Rafael J. Wysocki, 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

Hi Will,

On 2015/3/19 2:41, Will Deacon wrote:
> On Wed, Mar 11, 2015 at 12:39:41PM +0000, 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>
>> Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>> Reviewed-by: Grant Likely <grant.likely@linaro.org>
>> 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 c9203c0..dec6f8a 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);
> I see you've still got this buried in the arch code. Is there any plan to
> move it out, as I moaned about this in the last version of the series and
> nothing seems to have changed?

Ah, sorry. Last time when I was in Hongkong for LCA this Feb, I discussed with Lorenzo
and he had a look into that too, he also met some obstacles to do that, so Lorenzo
said that he will talk to you about this (Lorenzo, correct me if I'm wrong due to hearing
problems of much noise in that room where we were talking).

Anyway, if we move those functions to core code, such as irqdomain code, which will be
compiled for x86 too, we can only set those functions as _weak, or we guard with them
as #ifdef CONFIG_ARM64 ... #endif, so for me, it's really not a big deal to move those code
out of arch/arm64, but I'm still open for suggestions if you can do that in a proper way.

Thanks
Hanjun


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

* Re: [PATCH v10 00/21] Introduce ACPI for ARM64 based on ACPI 5.1
  2015-03-18 19:05 ` Will Deacon
  2015-03-18 19:09   ` Will Deacon
@ 2015-03-19  4:09   ` Hanjun Guo
  2015-03-19 10:17     ` Lorenzo Pieralisi
  2015-03-20 18:54     ` Will Deacon
  1 sibling, 2 replies; 89+ messages in thread
From: Hanjun Guo @ 2015-03-19  4:09 UTC (permalink / raw)
  To: Will Deacon, Hanjun Guo
  Cc: Catalin Marinas, Rafael J. Wysocki, 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/3/19 3:05, Will Deacon wrote:
> Hanjun,

Hi Will,

>
> On Wed, Mar 11, 2015 at 12:39:26PM +0000, Hanjun Guo wrote:
>> This patch set already tested on multi platforms:
>>  - AMD Seattle board;
>>  - Cavium Thunder board;
>>  - Huawei D02 board;
>>  - Qualcomm ARM64 platform
>>
>> This version 10 patch set address some minor comments and collect ACKs and
>> Reviewed-bys for v9:
>>
>>  - new Acks from Rafael, Olof, Grant, Lorenzo
>>  - new way to handle typdef phys_cpuid_t which suggested by Rafael,
>>    but no functional change
>>  - Remove if(!phys) for early ioremappings
>>  - Rework sleep function for ARM64
>>  - Introduce linux/acpi_irq.h to hold acpi_irq_init()
>>  - Disable ACPI if not HW_REDUCED_ACPI compliant
>>  - Remove the doc of why ACPI on ARM
> So I've had a look at the current state of this series and I think there
> are a few immediate things left to do:
>
>   (1) Resolve the acpi=force cmdline issue highlighted by Lorenzo and
>       Catalin

Sure, it will be done after the confirmation with Ard.

>
>   (2) I believe Sudeep and Lorenzo have concerns about patch 13 (SMP init),
>       so I'm assuming there will be additional patches from them that are
>       required.

Sorry, I assume that it is about the print information for PSCI absent for SMP init, right?

>
>   (3) I have an open comment about moving the IRQ domain code into the
>       core, which I'd like to see addressed.

I replied your email, please share your ideas for what I said.

>
>   (4) We need an ack from Daniel on the arch-timer patch

OK, thanks for your ping to Daniel :)

>
> If you can get that in place, I'm not opposed to putting this into
> linux-next ahead of the firmware summit in San Jose next week. Note that
> this is not a commitment for 4.1, since I'm keen to see the outcomes of
> next week before setting anything in stone.

OK, I will stick to this mailing list and respond as soon as I can.

>
> Also, there's no need to repost patches if you're just adding Acks. I
> think I'm up to speed with those on my local branch and the Tested-by
> party is starting to look a little silly.

Should I send another version, and add some incremental cleanup/fix patches
on top of that?

Thanks
Hanjun


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

* Re: [PATCH v10 08/21] ARM64 / ACPI: Introduce early_param "acpi=" to enable/disable ACPI
  2015-03-18 20:07     ` Ard Biesheuvel
  2015-03-19  2:30       ` Hanjun Guo
@ 2015-03-19 10:04       ` Lorenzo Pieralisi
  1 sibling, 0 replies; 89+ messages in thread
From: Lorenzo Pieralisi @ 2015-03-19 10:04 UTC (permalink / raw)
  To: Ard Biesheuvel
  Cc: hanjun.guo, 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, Mar 18, 2015 at 08:07:09PM +0000, Ard Biesheuvel wrote:
> On 18 March 2015 at 12:35, Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> wrote:
> > On Wed, Mar 11, 2015 at 12:39:34PM +0000, 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)
> >
> > I think this comment is stale. acpi=force enables ACPI and tries to
> > init the ACPI tables without even checking DT, but it does fall back to
> > DT if ACPI table init fails (by disabling ACPI and unflattening the
> > FDT).
> >
> > Am I wrong ?
> >
> 
> No, you're right. But I would suggest that we fix the code, not the comment.

So would I. I flagged this up on the comment since I was not able to follow
the thread on arm64 acpi=force and thought I was missing something.

> I think we are all in agreement on the policy, we only need to make
> disable_acpi() conditional on whether acpi_param_force is set

Either this or Catalin's fix, in actual terms the end result should be
the same on arm64, leaving acpi_disabled will save us some pointless
parsing IMO.

Nit: "acpi" kernel parameter description defines

"force -- enable ACPI if default was off"

which is not what we do on arm64 if we leave ACPI disabled when
acpi=force and ACPI fails to init.

I do not think we should care, if anyone disagrees manifest yourselves.

Lorenzo

> 
> 
> >> - 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>
> >> Acked-by: Olof Johansson <olof@lixom.net>
> >> Acked-by: Grant Likely <grant.likely@linaro.org>
> >> Tested-by: Timur Tabi <timur@codeaurora.org>
> >> 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 7abac24..2269e30 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 param_acpi_off __initdata;
> >> +static bool param_acpi_force __initdata;
> >> +
> >> +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] 89+ messages in thread

* Re: [PATCH v10 15/21] ARM64 / ACPI: Introduce ACPI_IRQ_MODEL_GIC and register device's gsi
  2015-03-19  3:45     ` Hanjun Guo
@ 2015-03-19 10:12       ` Lorenzo Pieralisi
  2015-03-19 19:37         ` Will Deacon
  0 siblings, 1 reply; 89+ messages in thread
From: Lorenzo Pieralisi @ 2015-03-19 10:12 UTC (permalink / raw)
  To: Hanjun Guo
  Cc: Will Deacon, hanjun.guo, Catalin Marinas, Rafael J. Wysocki,
	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

On Thu, Mar 19, 2015 at 03:45:35AM +0000, Hanjun Guo wrote:

[...]

> >> +/*
> >> + * 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);
> > I see you've still got this buried in the arch code. Is there any plan to
> > move it out, as I moaned about this in the last version of the series and
> > nothing seems to have changed?
> 
> Ah, sorry. Last time when I was in Hongkong for LCA this Feb, I discussed with Lorenzo
> and he had a look into that too, he also met some obstacles to do that, so Lorenzo
> said that he will talk to you about this (Lorenzo, correct me if I'm wrong due to hearing
> problems of much noise in that room where we were talking).
> 
> Anyway, if we move those functions to core code, such as irqdomain code, which will be
> compiled for x86 too, we can only set those functions as _weak, or we guard with them
> as #ifdef CONFIG_ARM64 ... #endif, so for me, it's really not a big deal to move those code
> out of arch/arm64, but I'm still open for suggestions if you can do that in a proper way.

You heard me clear and sound in HK, Will has a point and I looked into
this. Code is generic but not enough to be useful on other arches at
the moment, I need more time to look into this and see if we can move
this code to acpi core in a way that makes sense, to have, as you say,
a "default" implementation.

Lorenzo

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

* Re: [PATCH v10 00/21] Introduce ACPI for ARM64 based on ACPI 5.1
  2015-03-19  4:09   ` Hanjun Guo
@ 2015-03-19 10:17     ` Lorenzo Pieralisi
  2015-03-19 19:39       ` Will Deacon
  2015-03-20 18:54     ` Will Deacon
  1 sibling, 1 reply; 89+ messages in thread
From: Lorenzo Pieralisi @ 2015-03-19 10:17 UTC (permalink / raw)
  To: Hanjun Guo
  Cc: Will Deacon, hanjun.guo, Catalin Marinas, Rafael J. Wysocki,
	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

On Thu, Mar 19, 2015 at 04:09:33AM +0000, Hanjun Guo wrote:
> On 2015/3/19 3:05, Will Deacon wrote:
> > Hanjun,
> 
> Hi Will,
> 
> >
> > On Wed, Mar 11, 2015 at 12:39:26PM +0000, Hanjun Guo wrote:
> >> This patch set already tested on multi platforms:
> >>  - AMD Seattle board;
> >>  - Cavium Thunder board;
> >>  - Huawei D02 board;
> >>  - Qualcomm ARM64 platform
> >>
> >> This version 10 patch set address some minor comments and collect ACKs and
> >> Reviewed-bys for v9:
> >>
> >>  - new Acks from Rafael, Olof, Grant, Lorenzo
> >>  - new way to handle typdef phys_cpuid_t which suggested by Rafael,
> >>    but no functional change
> >>  - Remove if(!phys) for early ioremappings
> >>  - Rework sleep function for ARM64
> >>  - Introduce linux/acpi_irq.h to hold acpi_irq_init()
> >>  - Disable ACPI if not HW_REDUCED_ACPI compliant
> >>  - Remove the doc of why ACPI on ARM
> > So I've had a look at the current state of this series and I think there
> > are a few immediate things left to do:
> >
> >   (1) Resolve the acpi=force cmdline issue highlighted by Lorenzo and
> >       Catalin
> 
> Sure, it will be done after the confirmation with Ard.
> 
> >
> >   (2) I believe Sudeep and Lorenzo have concerns about patch 13 (SMP init),
> >       so I'm assuming there will be additional patches from them that are
> >       required.
> 
> Sorry, I assume that it is about the print information for PSCI absent for SMP init, right?

Not only that, Sudeep has a patch to consolidate DT and ACPI SMP code,
I am working on it, I do not think it should be a blocking point, patch
coming asap on top of your series.

Lorenzo

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

* Re: [PATCH v10 15/21] ARM64 / ACPI: Introduce ACPI_IRQ_MODEL_GIC and register device's gsi
  2015-03-19 10:12       ` Lorenzo Pieralisi
@ 2015-03-19 19:37         ` Will Deacon
  2015-03-20 13:07           ` Hanjun Guo
  2015-03-21 21:38           ` Lorenzo Pieralisi
  0 siblings, 2 replies; 89+ messages in thread
From: Will Deacon @ 2015-03-19 19:37 UTC (permalink / raw)
  To: Lorenzo Pieralisi
  Cc: guohanjun, hanjun.guo, Catalin Marinas, Rafael J. Wysocki,
	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

On Thu, Mar 19, 2015 at 10:12:05AM +0000, Lorenzo Pieralisi wrote:
> On Thu, Mar 19, 2015 at 03:45:35AM +0000, Hanjun Guo wrote:
> > >> +	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);
> > > I see you've still got this buried in the arch code. Is there any plan to
> > > move it out, as I moaned about this in the last version of the series and
> > > nothing seems to have changed?
> > 
> > Ah, sorry. Last time when I was in Hongkong for LCA this Feb, I
> > discussed with Lorenzo and he had a look into that too, he also met some
> > obstacles to do that, so Lorenzo said that he will talk to you about
> > this (Lorenzo, correct me if I'm wrong due to hearing problems of much
> > noise in that room where we were talking).
> > 
> > Anyway, if we move those functions to core code, such as irqdomain code,
> > which will be compiled for x86 too, we can only set those functions as
> > _weak, or we guard with them as #ifdef CONFIG_ARM64 ... #endif, so for
> > me, it's really not a big deal to move those code out of arch/arm64, but
> > I'm still open for suggestions if you can do that in a proper way.
> 
> You heard me clear and sound in HK, Will has a point and I looked into
> this. Code is generic but not enough to be useful on other arches at
> the moment, I need more time to look into this and see if we can move
> this code to acpi core in a way that makes sense, to have, as you say,
> a "default" implementation.

Yeah, just something guarded by a CONFIG option (probably not ARM64
though) would be enough, I think. Nothing too fancy.

Will

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

* Re: [PATCH v10 00/21] Introduce ACPI for ARM64 based on ACPI 5.1
  2015-03-19 10:17     ` Lorenzo Pieralisi
@ 2015-03-19 19:39       ` Will Deacon
  2015-03-24 22:02         ` Grant Likely
  0 siblings, 1 reply; 89+ messages in thread
From: Will Deacon @ 2015-03-19 19:39 UTC (permalink / raw)
  To: Lorenzo Pieralisi
  Cc: guohanjun, hanjun.guo, Catalin Marinas, Rafael J. Wysocki,
	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

On Thu, Mar 19, 2015 at 10:17:27AM +0000, Lorenzo Pieralisi wrote:
> On Thu, Mar 19, 2015 at 04:09:33AM +0000, Hanjun Guo wrote:
> > On 2015/3/19 3:05, Will Deacon wrote:
> > > On Wed, Mar 11, 2015 at 12:39:26PM +0000, Hanjun Guo wrote:
> > >> This patch set already tested on multi platforms:
> > >>  - AMD Seattle board;
> > >>  - Cavium Thunder board;
> > >>  - Huawei D02 board;
> > >>  - Qualcomm ARM64 platform
> > >>
> > >> This version 10 patch set address some minor comments and collect ACKs and
> > >> Reviewed-bys for v9:
> > >>
> > >>  - new Acks from Rafael, Olof, Grant, Lorenzo
> > >>  - new way to handle typdef phys_cpuid_t which suggested by Rafael,
> > >>    but no functional change
> > >>  - Remove if(!phys) for early ioremappings
> > >>  - Rework sleep function for ARM64
> > >>  - Introduce linux/acpi_irq.h to hold acpi_irq_init()
> > >>  - Disable ACPI if not HW_REDUCED_ACPI compliant
> > >>  - Remove the doc of why ACPI on ARM
> > > So I've had a look at the current state of this series and I think there
> > > are a few immediate things left to do:
> > >
> > >   (1) Resolve the acpi=force cmdline issue highlighted by Lorenzo and
> > >       Catalin
> > 
> > Sure, it will be done after the confirmation with Ard.
> > 
> > >
> > >   (2) I believe Sudeep and Lorenzo have concerns about patch 13 (SMP init),
> > >       so I'm assuming there will be additional patches from them that are
> > >       required.
> > 
> > Sorry, I assume that it is about the print information for PSCI absent for SMP init, right?
> 
> Not only that, Sudeep has a patch to consolidate DT and ACPI SMP code,
> I am working on it, I do not think it should be a blocking point, patch
> coming asap on top of your series.

Well, I don't really want to merge the series without those patches so I
do think it blocks the code from getting into mainline.

Will

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

* Re: [PATCH v10 15/21] ARM64 / ACPI: Introduce ACPI_IRQ_MODEL_GIC and register device's gsi
  2015-03-19 19:37         ` Will Deacon
@ 2015-03-20 13:07           ` Hanjun Guo
  2015-03-20 14:25             ` Lorenzo Pieralisi
  2015-03-21 21:38           ` Lorenzo Pieralisi
  1 sibling, 1 reply; 89+ messages in thread
From: Hanjun Guo @ 2015-03-20 13:07 UTC (permalink / raw)
  To: Will Deacon, Lorenzo Pieralisi
  Cc: hanjun.guo, Catalin Marinas, Rafael J. Wysocki, 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

On 2015/3/20 3:37, Will Deacon wrote:
> On Thu, Mar 19, 2015 at 10:12:05AM +0000, Lorenzo Pieralisi wrote:
>> On Thu, Mar 19, 2015 at 03:45:35AM +0000, Hanjun Guo wrote:
>>>>> +	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);
>>>> I see you've still got this buried in the arch code. Is there any plan to
>>>> move it out, as I moaned about this in the last version of the series and
>>>> nothing seems to have changed?
>>> Ah, sorry. Last time when I was in Hongkong for LCA this Feb, I
>>> discussed with Lorenzo and he had a look into that too, he also met some
>>> obstacles to do that, so Lorenzo said that he will talk to you about
>>> this (Lorenzo, correct me if I'm wrong due to hearing problems of much
>>> noise in that room where we were talking).
>>>
>>> Anyway, if we move those functions to core code, such as irqdomain code,
>>> which will be compiled for x86 too, we can only set those functions as
>>> _weak, or we guard with them as #ifdef CONFIG_ARM64 ... #endif, so for
>>> me, it's really not a big deal to move those code out of arch/arm64, but
>>> I'm still open for suggestions if you can do that in a proper way.
>> You heard me clear and sound in HK, Will has a point and I looked into
>> this. Code is generic but not enough to be useful on other arches at
>> the moment, I need more time to look into this and see if we can move
>> this code to acpi core in a way that makes sense, to have, as you say,
>> a "default" implementation.
> Yeah, just something guarded by a CONFIG option (probably not ARM64
> though) would be enough, I think. Nothing too fancy.
Hi Will,

It is ARM64 related code and ACPI specific, I can come up with following code:

 arch/arm64/kernel/acpi.c | 67 ---------------------------------------------
 kernel/irq/irqdomain.c   | 70 ++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 70 insertions(+), 67 deletions(-)

diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c
index 5819ef7..d207544 100644
--- a/arch/arm64/kernel/acpi.c
+++ b/arch/arm64/kernel/acpi.c
@@ -224,73 +224,6 @@ 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/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
index 7fac311..5a614bc 100644
--- a/kernel/irq/irqdomain.c
+++ b/kernel/irq/irqdomain.c
@@ -1,5 +1,6 @@
 #define pr_fmt(fmt)  "irq: " fmt
 
+#include <linux/acpi.h>
 #include <linux/debugfs.h>
 #include <linux/hardirq.h>
 #include <linux/interrupt.h>
@@ -568,6 +569,75 @@ unsigned int irq_find_mapping(struct irq_domain *domain,
 }
 EXPORT_SYMBOL_GPL(irq_find_mapping);
 
+#if defined(CONFIG_ARM64) && defined(CONFIG_ACPI)
+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.1, 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);
+#endif    /* CONFIG_ARM64 && CONFIG_ACPI */
+
 #ifdef CONFIG_IRQ_DOMAIN_DEBUG
 static int virq_debug_show(struct seq_file *m, void *private)
 {

is this the way you prefered?

Thanks
Hanjun


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

* Re: [PATCH v10 00/21] Introduce ACPI for ARM64 based on ACPI 5.1
  2015-03-11 12:39 [PATCH v10 00/21] Introduce ACPI for ARM64 based on ACPI 5.1 Hanjun Guo
                   ` (22 preceding siblings ...)
  2015-03-18 19:05 ` Will Deacon
@ 2015-03-20 13:18 ` Mark Salter
  23 siblings, 0 replies; 89+ messages in thread
From: Mark Salter @ 2015-03-20 13:18 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, 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, 2015-03-11 at 20:39 +0800, Hanjun Guo wrote:
> This patch set already tested on multi platforms:
>  - AMD Seattle board;
>  - Cavium Thunder board;
>  - Huawei D02 board;
>  - Qualcomm ARM64 platform

For the whole series:

Tested-by: Mark Salter <msalter@redhat.com>

on AMD Seattle and APM Mustang.



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

* Re: [PATCH v10 17/21] clocksource / arch_timer: Parse GTDT to initialize arch timer
  2015-03-11 12:39 ` [PATCH v10 17/21] clocksource / arch_timer: Parse GTDT to initialize arch timer Hanjun Guo
  2015-03-18 18:34   ` Will Deacon
@ 2015-03-20 13:49   ` Daniel Lezcano
  1 sibling, 0 replies; 89+ messages in thread
From: Daniel Lezcano @ 2015-03-20 13:49 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, Thomas Gleixner

On 03/11/2015 01:39 PM, Hanjun Guo 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>
> Reviewed-by: Grant Likely <grant.likely@linaro.org>
> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>

Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>


-- 
  <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog


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

* Re: [PATCH v10 15/21] ARM64 / ACPI: Introduce ACPI_IRQ_MODEL_GIC and register device's gsi
  2015-03-20 13:07           ` Hanjun Guo
@ 2015-03-20 14:25             ` Lorenzo Pieralisi
  0 siblings, 0 replies; 89+ messages in thread
From: Lorenzo Pieralisi @ 2015-03-20 14:25 UTC (permalink / raw)
  To: Hanjun Guo
  Cc: Will Deacon, hanjun.guo, Catalin Marinas, Rafael J. Wysocki,
	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

On Fri, Mar 20, 2015 at 01:07:12PM +0000, Hanjun Guo wrote:
> On 2015/3/20 3:37, Will Deacon wrote:
> > On Thu, Mar 19, 2015 at 10:12:05AM +0000, Lorenzo Pieralisi wrote:
> >> On Thu, Mar 19, 2015 at 03:45:35AM +0000, Hanjun Guo wrote:
> >>>>> +	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);
> >>>> I see you've still got this buried in the arch code. Is there any plan to
> >>>> move it out, as I moaned about this in the last version of the series and
> >>>> nothing seems to have changed?
> >>> Ah, sorry. Last time when I was in Hongkong for LCA this Feb, I
> >>> discussed with Lorenzo and he had a look into that too, he also met some
> >>> obstacles to do that, so Lorenzo said that he will talk to you about
> >>> this (Lorenzo, correct me if I'm wrong due to hearing problems of much
> >>> noise in that room where we were talking).
> >>>
> >>> Anyway, if we move those functions to core code, such as irqdomain code,
> >>> which will be compiled for x86 too, we can only set those functions as
> >>> _weak, or we guard with them as #ifdef CONFIG_ARM64 ... #endif, so for
> >>> me, it's really not a big deal to move those code out of arch/arm64, but
> >>> I'm still open for suggestions if you can do that in a proper way.
> >> You heard me clear and sound in HK, Will has a point and I looked into
> >> this. Code is generic but not enough to be useful on other arches at
> >> the moment, I need more time to look into this and see if we can move
> >> this code to acpi core in a way that makes sense, to have, as you say,
> >> a "default" implementation.
> > Yeah, just something guarded by a CONFIG option (probably not ARM64
> > though) would be enough, I think. Nothing too fancy.
> Hi Will,
> 
> It is ARM64 related code and ACPI specific, I can come up with following code:
No. It is ACPI code that can be made generic (if it is not already,
apart from GIC specific comments), so IMO it should live in drivers/acpi
and we can introduce a config option for that as we did for S-states and
select it on arm64.

Lorenzo

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

* Re: [PATCH v10 00/21] Introduce ACPI for ARM64 based on ACPI 5.1
  2015-03-19  4:09   ` Hanjun Guo
  2015-03-19 10:17     ` Lorenzo Pieralisi
@ 2015-03-20 18:54     ` Will Deacon
  2015-03-21  3:17       ` Hanjun Guo
  1 sibling, 1 reply; 89+ messages in thread
From: Will Deacon @ 2015-03-20 18:54 UTC (permalink / raw)
  To: Hanjun Guo
  Cc: hanjun.guo, Catalin Marinas, Rafael J. Wysocki, 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 Thu, Mar 19, 2015 at 04:09:33AM +0000, Hanjun Guo wrote:
> On 2015/3/19 3:05, Will Deacon wrote:
> > If you can get that in place, I'm not opposed to putting this into
> > linux-next ahead of the firmware summit in San Jose next week. Note that
> > this is not a commitment for 4.1, since I'm keen to see the outcomes of
> > next week before setting anything in stone.
> 
> OK, I will stick to this mailing list and respond as soon as I can.

This doesn't even build for me:


$ make ARCH=arm64 CROSS_COMPILE=aarch64-none-linux-gnu- allmodconfig
$ make ARCH=arm64 CROSS_COMPILE=aarch64-none-linux-gnu- Image

[...]

In file included from drivers/xen/acpi.c:33:0:
include/xen/acpi.h: In function ‘xen_acpi_sleep_register’:
include/xen/acpi.h:102:3: error: ‘acpi_suspend_lowlevel’ undeclared (first use in this function)
   acpi_suspend_lowlevel = xen_acpi_suspend_lowlevel;
   ^
include/xen/acpi.h:102:3: note: each undeclared identifier is reported only once for each function it appears in
drivers/xen/acpi.c: In function ‘xen_acpi_notify_hypervisor_state’:
drivers/xen/acpi.c:61:2: error: implicit declaration of function ‘HYPERVISOR_dom0_op’ [-Werror=implicit-function-declaration]
  HYPERVISOR_dom0_op(&op);
  ^
cc1: some warnings being treated as errors
make[2]: *** [drivers/xen/acpi.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [drivers/xen] Error 2
make[1]: *** Waiting for unfinished jobs....
make: *** [drivers] Error 2


Am I missing some other patches?

Will

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

* Re: [PATCH v10 00/21] Introduce ACPI for ARM64 based on ACPI 5.1
  2015-03-20 18:54     ` Will Deacon
@ 2015-03-21  3:17       ` Hanjun Guo
  2015-03-21  7:03         ` Hanjun Guo
  2015-03-23 18:32         ` Stefano Stabellini
  0 siblings, 2 replies; 89+ messages in thread
From: Hanjun Guo @ 2015-03-21  3:17 UTC (permalink / raw)
  To: Will Deacon, Hanjun Guo
  Cc: Catalin Marinas, Rafael J. Wysocki, 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, Parth Dixit,
	'Stefano Stabellini'

+CC Parth Dixit, Stefano Stabellini.

On 2015年03月21日 02:54, Will Deacon wrote:
> On Thu, Mar 19, 2015 at 04:09:33AM +0000, Hanjun Guo wrote:
>> On 2015/3/19 3:05, Will Deacon wrote:
>>> If you can get that in place, I'm not opposed to putting this into
>>> linux-next ahead of the firmware summit in San Jose next week. Note that
>>> this is not a commitment for 4.1, since I'm keen to see the outcomes of
>>> next week before setting anything in stone.
>>
>> OK, I will stick to this mailing list and respond as soon as I can.
>
> This doesn't even build for me:
>
>
> $ make ARCH=arm64 CROSS_COMPILE=aarch64-none-linux-gnu- allmodconfig
> $ make ARCH=arm64 CROSS_COMPILE=aarch64-none-linux-gnu- Image
>
> [...]
>
> In file included from drivers/xen/acpi.c:33:0:

Sorry, I didn't build ACPI with XEN enabled on ARM64.

> include/xen/acpi.h: In function ‘xen_acpi_sleep_register’:
> include/xen/acpi.h:102:3: error: ‘acpi_suspend_lowlevel’ undeclared (first use in this function)
>     acpi_suspend_lowlevel = xen_acpi_suspend_lowlevel;

acpi_suspend_lowlevel is defined only for X86 and IA64 for now.

>     ^
> include/xen/acpi.h:102:3: note: each undeclared identifier is reported only once for each function it appears in
> drivers/xen/acpi.c: In function ‘xen_acpi_notify_hypervisor_state’:
> drivers/xen/acpi.c:61:2: error: implicit declaration of function ‘HYPERVISOR_dom0_op’ [-Werror=implicit-function-declaration]
>    HYPERVISOR_dom0_op(&op);

And this is only for x86:
./arch/x86/include/asm/xen/hypercall.h:HYPERVISOR_dom0_op(struct 
xen_platform_op *platform_op)

>    ^
> cc1: some warnings being treated as errors
> make[2]: *** [drivers/xen/acpi.o] Error 1
> make[2]: *** Waiting for unfinished jobs....
> make[1]: *** [drivers/xen] Error 2
> make[1]: *** Waiting for unfinished jobs....
> make: *** [drivers] Error 2
>
>
> Am I missing some other patches?

No, you miss nothing. Parth Dixit is still working on XEN ACPI for
ARM64, before it's in full function, how about introduce a Kconfig
CONFIG_XEN_ACPI and let it depends on x86? when XEN ACPI for ARM64
comes, we can enable ARM64 for CONFIG_XEN_ACPI and fix the problems
above.

Stefano, Parth, what do you think?

Thanks
Hanjun

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

* Re: [PATCH v10 00/21] Introduce ACPI for ARM64 based on ACPI 5.1
  2015-03-21  3:17       ` Hanjun Guo
@ 2015-03-21  7:03         ` Hanjun Guo
       [not found]           ` <CAFoFrHatzS3MwGVeOPPjY1R1sfBRYnJjgbQjvfzi6xS+XYD14g@mail.gmail.com>
  2015-03-23 18:32         ` Stefano Stabellini
  1 sibling, 1 reply; 89+ messages in thread
From: Hanjun Guo @ 2015-03-21  7:03 UTC (permalink / raw)
  To: Hanjun Guo, Will Deacon, Parth Dixit, 'Stefano Stabellini'
  Cc: Catalin Marinas, Rafael J. Wysocki, 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/3/21 11:17, Hanjun Guo wrote:
> +CC Parth Dixit, Stefano Stabellini.
>
> On 2015年03月21日 02:54, Will Deacon wrote:
>> On Thu, Mar 19, 2015 at 04:09:33AM +0000, Hanjun Guo wrote:
>>> On 2015/3/19 3:05, Will Deacon wrote:
>>>> If you can get that in place, I'm not opposed to putting this into
>>>> linux-next ahead of the firmware summit in San Jose next week. Note that
>>>> this is not a commitment for 4.1, since I'm keen to see the outcomes of
>>>> next week before setting anything in stone.
>>>
>>> OK, I will stick to this mailing list and respond as soon as I can.
>>
>> This doesn't even build for me:
>>
>>
>> $ make ARCH=arm64 CROSS_COMPILE=aarch64-none-linux-gnu- allmodconfig
>> $ make ARCH=arm64 CROSS_COMPILE=aarch64-none-linux-gnu- Image
>>
>> [...]
>>
>> In file included from drivers/xen/acpi.c:33:0:
>
> Sorry, I didn't build ACPI with XEN enabled on ARM64.
>
>> include/xen/acpi.h: In function ‘xen_acpi_sleep_register’:
>> include/xen/acpi.h:102:3: error: ‘acpi_suspend_lowlevel’ undeclared (first use in this function)
>>     acpi_suspend_lowlevel = xen_acpi_suspend_lowlevel;
>
> acpi_suspend_lowlevel is defined only for X86 and IA64 for now.
>
>>     ^
>> include/xen/acpi.h:102:3: note: each undeclared identifier is reported only once for each function it appears in
>> drivers/xen/acpi.c: In function ‘xen_acpi_notify_hypervisor_state’:
>> drivers/xen/acpi.c:61:2: error: implicit declaration of function ‘HYPERVISOR_dom0_op’ [-Werror=implicit-function-declaration]
>>    HYPERVISOR_dom0_op(&op);
>
> And this is only for x86:
> ./arch/x86/include/asm/xen/hypercall.h:HYPERVISOR_dom0_op(struct xen_platform_op *platform_op)
>
>>    ^
>> cc1: some warnings being treated as errors
>> make[2]: *** [drivers/xen/acpi.o] Error 1
>> make[2]: *** Waiting for unfinished jobs....
>> make[1]: *** [drivers/xen] Error 2
>> make[1]: *** Waiting for unfinished jobs....
>> make: *** [drivers] Error 2
>>
>>
>> Am I missing some other patches?
>
> No, you miss nothing. Parth Dixit is still working on XEN ACPI for
> ARM64, before it's in full function, how about introduce a Kconfig
> CONFIG_XEN_ACPI and let it depends on x86? when XEN ACPI for ARM64
> comes, we can enable ARM64 for CONFIG_XEN_ACPI and fix the problems
> above.
>
> Stefano, Parth, what do you think?

I prepared a patch for further reference:

>From 268dcdafa34a690e2f99c0784ca33a6d2352ecf5 Mon Sep 17 00:00:00 2001
From: Hanjun Guo <hanjun.guo@linaro.org>
Date: Sat, 21 Mar 2015 14:43:54 +0800
Subject: [PATCH] XEN / ACPI: Make XEN ACPI depend on X86

When ACPI is enabled on ARM64, XEN ACPI will also compiled
into the kernel, but XEN ACPI is x86 dependent, so introduce
CONFIG_XEN_ACPI to make it depend on x86 before XEN ACPI is
functional on ARM64.

Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
---
 drivers/xen/Kconfig  | 4 ++++
 drivers/xen/Makefile | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/xen/Kconfig b/drivers/xen/Kconfig
index b812462..a31cd29 100644
--- a/drivers/xen/Kconfig
+++ b/drivers/xen/Kconfig
@@ -253,4 +253,8 @@ config XEN_EFI
     def_bool y
     depends on X86_64 && EFI
 
+config XEN_ACPI
+    def_bool y
+    depends on X86 && ACPI
+
 endmenu
diff --git a/drivers/xen/Makefile b/drivers/xen/Makefile
index 2ccd359..f4622ab 100644
--- a/drivers/xen/Makefile
+++ b/drivers/xen/Makefile
@@ -13,7 +13,7 @@ CFLAGS_efi.o                += -fshort-wchar
 
 dom0-$(CONFIG_PCI) += pci.o
 dom0-$(CONFIG_USB_SUPPORT) += dbgp.o
-dom0-$(CONFIG_ACPI) += acpi.o $(xen-pad-y)
+dom0-$(CONFIG_XEN_ACPI) += acpi.o $(xen-pad-y)
 xen-pad-$(CONFIG_X86) += xen-acpi-pad.o
 dom0-$(CONFIG_X86) += pcpu.o
 obj-$(CONFIG_XEN_DOM0)            += $(dom0-y)
-- 
1.7.12.4




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

* Re: [PATCH v10 15/21] ARM64 / ACPI: Introduce ACPI_IRQ_MODEL_GIC and register device's gsi
  2015-03-19 19:37         ` Will Deacon
  2015-03-20 13:07           ` Hanjun Guo
@ 2015-03-21 21:38           ` Lorenzo Pieralisi
  1 sibling, 0 replies; 89+ messages in thread
From: Lorenzo Pieralisi @ 2015-03-21 21:38 UTC (permalink / raw)
  To: Will Deacon
  Cc: guohanjun, hanjun.guo, Catalin Marinas, Rafael J. Wysocki,
	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

On Thu, Mar 19, 2015 at 07:37:24PM +0000, Will Deacon wrote:
> On Thu, Mar 19, 2015 at 10:12:05AM +0000, Lorenzo Pieralisi wrote:
> > On Thu, Mar 19, 2015 at 03:45:35AM +0000, Hanjun Guo wrote:
> > > >> +	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);
> > > > I see you've still got this buried in the arch code. Is there any plan to
> > > > move it out, as I moaned about this in the last version of the series and
> > > > nothing seems to have changed?
> > > 
> > > Ah, sorry. Last time when I was in Hongkong for LCA this Feb, I
> > > discussed with Lorenzo and he had a look into that too, he also met some
> > > obstacles to do that, so Lorenzo said that he will talk to you about
> > > this (Lorenzo, correct me if I'm wrong due to hearing problems of much
> > > noise in that room where we were talking).
> > > 
> > > Anyway, if we move those functions to core code, such as irqdomain code,
> > > which will be compiled for x86 too, we can only set those functions as
> > > _weak, or we guard with them as #ifdef CONFIG_ARM64 ... #endif, so for
> > > me, it's really not a big deal to move those code out of arch/arm64, but
> > > I'm still open for suggestions if you can do that in a proper way.
> > 
> > You heard me clear and sound in HK, Will has a point and I looked into
> > this. Code is generic but not enough to be useful on other arches at
> > the moment, I need more time to look into this and see if we can move
> > this code to acpi core in a way that makes sense, to have, as you say,
> > a "default" implementation.
> 
> Yeah, just something guarded by a CONFIG option (probably not ARM64
> though) would be enough, I think. Nothing too fancy.

I had a decent look and on x86/ia64 ACPI gsi mappings
(PIC/IOAPIC/IOSAPIC) are buried in arch code (not saying it is nice,
it is what it is at present).

We can try either to move this code to ACPI layer and make it
depend on CONFIG_ARM_GIC somehow, or move it to the GIC driver altogether.

I have to think about this, certainly it is not generic code at
present (or better it looks generic but can only work on ARM64 with
GIC IRQ model).

Lorenzo

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

* Re: [PATCH v10 00/21] Introduce ACPI for ARM64 based on ACPI 5.1
       [not found]           ` <CAFoFrHatzS3MwGVeOPPjY1R1sfBRYnJjgbQjvfzi6xS+XYD14g@mail.gmail.com>
@ 2015-03-22 21:05             ` Julien Grall
  2015-03-22 21:49               ` Rafael J. Wysocki
  0 siblings, 1 reply; 89+ messages in thread
From: Julien Grall @ 2015-03-22 21:05 UTC (permalink / raw)
  To: Naresh Bhat, Hanjun Guo
  Cc: Hanjun Guo, Jon Fraser, Parth Dixit, Stefano Stabellini,
	Catalin Marinas, Rafael J. Wysocki, 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, Ian Campbell

Hello,

On 21/03/2015 12:09, Naresh Bhat wrote:
>      From 268dcdafa34a690e2f99c0784ca33a6d2352ecf5 Mon Sep 17 00:00:00 2001
>     From: Hanjun Guo <hanjun.guo@linaro.org <mailto:hanjun.guo@linaro.org>>
>     Date: Sat, 21 Mar 2015 14:43:54 +0800
>     Subject: [PATCH] XEN / ACPI: Make XEN ACPI depend on X86
>
>     When ACPI is enabled on ARM64, XEN ACPI will also compiled
>     into the kernel, but XEN ACPI is x86 dependent, so introduce
>     CONFIG_XEN_ACPI to make it depend on x86 before XEN ACPI is
>     functional on ARM64.
>
>     Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org
>     <mailto:hanjun.guo@linaro.org>>
>     ---
>       drivers/xen/Kconfig  | 4 ++++
>       drivers/xen/Makefile | 2 +-
>       2 files changed, 5 insertions(+), 1 deletion(-)
>
>     diff --git a/drivers/xen/Kconfig b/drivers/xen/Kconfig
>     index b812462..a31cd29 100644
>     --- a/drivers/xen/Kconfig
>     +++ b/drivers/xen/Kconfig
>     @@ -253,4 +253,8 @@ config XEN_EFI
>           def_bool y
>           depends on X86_64 && EFI
>
>     +config XEN_ACPI
>     +    def_bool y
>     +    depends on X86 && ACPI
>     +
>       endmenu
>     diff --git a/drivers/xen/Makefile b/drivers/xen/Makefile
>     index 2ccd359..f4622ab 100644
>     --- a/drivers/xen/Makefile
>     +++ b/drivers/xen/Makefile
>     @@ -13,7 +13,7 @@ CFLAGS_efi.o                += -fshort-wchar
>
>       dom0-$(CONFIG_PCI) += pci.o
>       dom0-$(CONFIG_USB_SUPPORT) += dbgp.o
>     -dom0-$(CONFIG_ACPI) += acpi.o $(xen-pad-y)
>     +dom0-$(CONFIG_XEN_ACPI) += acpi.o $(xen-pad-y)
>       xen-pad-$(CONFIG_X86) += xen-acpi-pad.o
>       dom0-$(CONFIG_X86) += pcpu.o
>       obj-$(CONFIG_XEN_DOM0)            += $(dom0-y)

[..]

>
> AFAIK,  There is already a kernel patch exists to fix this issue.  I
> think  Julien or Parth is a right person to ask.  Hence I am CCed Julien
> Grall too.

The ACPI support for Xen is not ready. So I think avoiding to compile 
drivers/xen/acpi.c on ARM64/ARM seems the better solution for now.

Although, rather than introducing a new CONFIG option, I would use the 
same trick we use within the Makefile to avoid hotplug.c on ARM/ARM64.

ifeq ($(filter y, $(CONFIG_ARM) $(CONFIG_ARM64)), )
dom0-$(CONFIG_ACPI) += acpi.o $(xen-pad-y)
endif

Regards,

-- 
Julien Grall

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

* Re: [PATCH v10 00/21] Introduce ACPI for ARM64 based on ACPI 5.1
  2015-03-22 21:49               ` Rafael J. Wysocki
@ 2015-03-22 21:32                 ` Julien Grall
  2015-03-22 22:11                   ` Rafael J. Wysocki
  0 siblings, 1 reply; 89+ messages in thread
From: Julien Grall @ 2015-03-22 21:32 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Naresh Bhat, Hanjun Guo, Hanjun Guo, Jon Fraser, Parth Dixit,
	Stefano Stabellini, Catalin Marinas, 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, Ian Campbell



On 22/03/2015 21:49, Rafael J. Wysocki wrote:
> On Sunday, March 22, 2015 09:05:21 PM Julien Grall wrote:
>> Hello,
>>
>> On 21/03/2015 12:09, Naresh Bhat wrote:
>>>       From 268dcdafa34a690e2f99c0784ca33a6d2352ecf5 Mon Sep 17 00:00:00 2001
>>>      From: Hanjun Guo <hanjun.guo@linaro.org <mailto:hanjun.guo@linaro.org>>
>>>      Date: Sat, 21 Mar 2015 14:43:54 +0800
>>>      Subject: [PATCH] XEN / ACPI: Make XEN ACPI depend on X86
>>>
>>>      When ACPI is enabled on ARM64, XEN ACPI will also compiled
>>>      into the kernel, but XEN ACPI is x86 dependent, so introduce
>>>      CONFIG_XEN_ACPI to make it depend on x86 before XEN ACPI is
>>>      functional on ARM64.
>>>
>>>      Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org
>>>      <mailto:hanjun.guo@linaro.org>>
>>>      ---
>>>        drivers/xen/Kconfig  | 4 ++++
>>>        drivers/xen/Makefile | 2 +-
>>>        2 files changed, 5 insertions(+), 1 deletion(-)
>>>
>>>      diff --git a/drivers/xen/Kconfig b/drivers/xen/Kconfig
>>>      index b812462..a31cd29 100644
>>>      --- a/drivers/xen/Kconfig
>>>      +++ b/drivers/xen/Kconfig
>>>      @@ -253,4 +253,8 @@ config XEN_EFI
>>>            def_bool y
>>>            depends on X86_64 && EFI
>>>
>>>      +config XEN_ACPI
>>>      +    def_bool y
>>>      +    depends on X86 && ACPI
>>>      +
>>>        endmenu
>>>      diff --git a/drivers/xen/Makefile b/drivers/xen/Makefile
>>>      index 2ccd359..f4622ab 100644
>>>      --- a/drivers/xen/Makefile
>>>      +++ b/drivers/xen/Makefile
>>>      @@ -13,7 +13,7 @@ CFLAGS_efi.o                += -fshort-wchar
>>>
>>>        dom0-$(CONFIG_PCI) += pci.o
>>>        dom0-$(CONFIG_USB_SUPPORT) += dbgp.o
>>>      -dom0-$(CONFIG_ACPI) += acpi.o $(xen-pad-y)
>>>      +dom0-$(CONFIG_XEN_ACPI) += acpi.o $(xen-pad-y)
>>>        xen-pad-$(CONFIG_X86) += xen-acpi-pad.o
>>>        dom0-$(CONFIG_X86) += pcpu.o
>>>        obj-$(CONFIG_XEN_DOM0)            += $(dom0-y)
>>
>> [..]
>>
>>>
>>> AFAIK,  There is already a kernel patch exists to fix this issue.  I
>>> think  Julien or Parth is a right person to ask.  Hence I am CCed Julien
>>> Grall too.
>>
>> The ACPI support for Xen is not ready. So I think avoiding to compile
>> drivers/xen/acpi.c on ARM64/ARM seems the better solution for now.
>>
>> Although, rather than introducing a new CONFIG option, I would use the
>> same trick we use within the Makefile to avoid hotplug.c on ARM/ARM64.
>>
>> ifeq ($(filter y, $(CONFIG_ARM) $(CONFIG_ARM64)), )
>> dom0-$(CONFIG_ACPI) += acpi.o $(xen-pad-y)
>> endif
>
> Well, is avoiding an extra CONFIG_ option worth the ugliness of this?

When the support of ACPI for Xen will come, the CONFIG_ option will be 
an alias to CONFIG_XEN.

In this case the CONFIG_ option won't bring much improvement to the code 
and add an extra indirection.

The "ugliness" option has, at least, the advantage to be tiny and 
self-contained.

Regards,

-- 
Julien Grall

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

* Re: [PATCH v10 00/21] Introduce ACPI for ARM64 based on ACPI 5.1
  2015-03-22 21:05             ` Julien Grall
@ 2015-03-22 21:49               ` Rafael J. Wysocki
  2015-03-22 21:32                 ` Julien Grall
  0 siblings, 1 reply; 89+ messages in thread
From: Rafael J. Wysocki @ 2015-03-22 21:49 UTC (permalink / raw)
  To: Julien Grall
  Cc: Naresh Bhat, Hanjun Guo, Hanjun Guo, Jon Fraser, Parth Dixit,
	Stefano Stabellini, Catalin Marinas, 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, Ian Campbell

On Sunday, March 22, 2015 09:05:21 PM Julien Grall wrote:
> Hello,
> 
> On 21/03/2015 12:09, Naresh Bhat wrote:
> >      From 268dcdafa34a690e2f99c0784ca33a6d2352ecf5 Mon Sep 17 00:00:00 2001
> >     From: Hanjun Guo <hanjun.guo@linaro.org <mailto:hanjun.guo@linaro.org>>
> >     Date: Sat, 21 Mar 2015 14:43:54 +0800
> >     Subject: [PATCH] XEN / ACPI: Make XEN ACPI depend on X86
> >
> >     When ACPI is enabled on ARM64, XEN ACPI will also compiled
> >     into the kernel, but XEN ACPI is x86 dependent, so introduce
> >     CONFIG_XEN_ACPI to make it depend on x86 before XEN ACPI is
> >     functional on ARM64.
> >
> >     Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org
> >     <mailto:hanjun.guo@linaro.org>>
> >     ---
> >       drivers/xen/Kconfig  | 4 ++++
> >       drivers/xen/Makefile | 2 +-
> >       2 files changed, 5 insertions(+), 1 deletion(-)
> >
> >     diff --git a/drivers/xen/Kconfig b/drivers/xen/Kconfig
> >     index b812462..a31cd29 100644
> >     --- a/drivers/xen/Kconfig
> >     +++ b/drivers/xen/Kconfig
> >     @@ -253,4 +253,8 @@ config XEN_EFI
> >           def_bool y
> >           depends on X86_64 && EFI
> >
> >     +config XEN_ACPI
> >     +    def_bool y
> >     +    depends on X86 && ACPI
> >     +
> >       endmenu
> >     diff --git a/drivers/xen/Makefile b/drivers/xen/Makefile
> >     index 2ccd359..f4622ab 100644
> >     --- a/drivers/xen/Makefile
> >     +++ b/drivers/xen/Makefile
> >     @@ -13,7 +13,7 @@ CFLAGS_efi.o                += -fshort-wchar
> >
> >       dom0-$(CONFIG_PCI) += pci.o
> >       dom0-$(CONFIG_USB_SUPPORT) += dbgp.o
> >     -dom0-$(CONFIG_ACPI) += acpi.o $(xen-pad-y)
> >     +dom0-$(CONFIG_XEN_ACPI) += acpi.o $(xen-pad-y)
> >       xen-pad-$(CONFIG_X86) += xen-acpi-pad.o
> >       dom0-$(CONFIG_X86) += pcpu.o
> >       obj-$(CONFIG_XEN_DOM0)            += $(dom0-y)
> 
> [..]
> 
> >
> > AFAIK,  There is already a kernel patch exists to fix this issue.  I
> > think  Julien or Parth is a right person to ask.  Hence I am CCed Julien
> > Grall too.
> 
> The ACPI support for Xen is not ready. So I think avoiding to compile 
> drivers/xen/acpi.c on ARM64/ARM seems the better solution for now.
> 
> Although, rather than introducing a new CONFIG option, I would use the 
> same trick we use within the Makefile to avoid hotplug.c on ARM/ARM64.
> 
> ifeq ($(filter y, $(CONFIG_ARM) $(CONFIG_ARM64)), )
> dom0-$(CONFIG_ACPI) += acpi.o $(xen-pad-y)
> endif

Well, is avoiding an extra CONFIG_ option worth the ugliness of this?


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

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

* Re: [PATCH v10 00/21] Introduce ACPI for ARM64 based on ACPI 5.1
  2015-03-22 21:32                 ` Julien Grall
@ 2015-03-22 22:11                   ` Rafael J. Wysocki
  2015-03-23  1:37                     ` Hanjun Guo
  0 siblings, 1 reply; 89+ messages in thread
From: Rafael J. Wysocki @ 2015-03-22 22:11 UTC (permalink / raw)
  To: Julien Grall
  Cc: Naresh Bhat, Hanjun Guo, Hanjun Guo, Jon Fraser, Parth Dixit,
	Stefano Stabellini, Catalin Marinas, 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, Ian Campbell

On Sunday, March 22, 2015 09:32:48 PM Julien Grall wrote:
> 
> On 22/03/2015 21:49, Rafael J. Wysocki wrote:
> > On Sunday, March 22, 2015 09:05:21 PM Julien Grall wrote:
> >> Hello,
> >>
> >> On 21/03/2015 12:09, Naresh Bhat wrote:
> >>>       From 268dcdafa34a690e2f99c0784ca33a6d2352ecf5 Mon Sep 17 00:00:00 2001
> >>>      From: Hanjun Guo <hanjun.guo@linaro.org <mailto:hanjun.guo@linaro.org>>
> >>>      Date: Sat, 21 Mar 2015 14:43:54 +0800
> >>>      Subject: [PATCH] XEN / ACPI: Make XEN ACPI depend on X86
> >>>
> >>>      When ACPI is enabled on ARM64, XEN ACPI will also compiled
> >>>      into the kernel, but XEN ACPI is x86 dependent, so introduce
> >>>      CONFIG_XEN_ACPI to make it depend on x86 before XEN ACPI is
> >>>      functional on ARM64.
> >>>
> >>>      Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org
> >>>      <mailto:hanjun.guo@linaro.org>>
> >>>      ---
> >>>        drivers/xen/Kconfig  | 4 ++++
> >>>        drivers/xen/Makefile | 2 +-
> >>>        2 files changed, 5 insertions(+), 1 deletion(-)
> >>>
> >>>      diff --git a/drivers/xen/Kconfig b/drivers/xen/Kconfig
> >>>      index b812462..a31cd29 100644
> >>>      --- a/drivers/xen/Kconfig
> >>>      +++ b/drivers/xen/Kconfig
> >>>      @@ -253,4 +253,8 @@ config XEN_EFI
> >>>            def_bool y
> >>>            depends on X86_64 && EFI
> >>>
> >>>      +config XEN_ACPI
> >>>      +    def_bool y
> >>>      +    depends on X86 && ACPI
> >>>      +
> >>>        endmenu
> >>>      diff --git a/drivers/xen/Makefile b/drivers/xen/Makefile
> >>>      index 2ccd359..f4622ab 100644
> >>>      --- a/drivers/xen/Makefile
> >>>      +++ b/drivers/xen/Makefile
> >>>      @@ -13,7 +13,7 @@ CFLAGS_efi.o                += -fshort-wchar
> >>>
> >>>        dom0-$(CONFIG_PCI) += pci.o
> >>>        dom0-$(CONFIG_USB_SUPPORT) += dbgp.o
> >>>      -dom0-$(CONFIG_ACPI) += acpi.o $(xen-pad-y)
> >>>      +dom0-$(CONFIG_XEN_ACPI) += acpi.o $(xen-pad-y)
> >>>        xen-pad-$(CONFIG_X86) += xen-acpi-pad.o
> >>>        dom0-$(CONFIG_X86) += pcpu.o
> >>>        obj-$(CONFIG_XEN_DOM0)            += $(dom0-y)
> >>
> >> [..]
> >>
> >>>
> >>> AFAIK,  There is already a kernel patch exists to fix this issue.  I
> >>> think  Julien or Parth is a right person to ask.  Hence I am CCed Julien
> >>> Grall too.
> >>
> >> The ACPI support for Xen is not ready. So I think avoiding to compile
> >> drivers/xen/acpi.c on ARM64/ARM seems the better solution for now.
> >>
> >> Although, rather than introducing a new CONFIG option, I would use the
> >> same trick we use within the Makefile to avoid hotplug.c on ARM/ARM64.
> >>
> >> ifeq ($(filter y, $(CONFIG_ARM) $(CONFIG_ARM64)), )
> >> dom0-$(CONFIG_ACPI) += acpi.o $(xen-pad-y)
> >> endif
> >
> > Well, is avoiding an extra CONFIG_ option worth the ugliness of this?
> 
> When the support of ACPI for Xen will come, the CONFIG_ option will be 
> an alias to CONFIG_XEN.
> 
> In this case the CONFIG_ option won't bring much improvement to the code 
> and add an extra indirection.
> 
> The "ugliness" option has, at least, the advantage to be tiny and 
> self-contained.

Oh well, not really.  You're moving a config-time check to compile time
which means that it will be done every time this Makefile is executed
and for all architectures that execute it.  Not nice.

Also I think that ia64 is missing from the list, but I may be wrong.

Not to mention the fact that the dependency will be rather difficult to find
for tools like xconfig ...


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

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

* Re: [PATCH v10 00/21] Introduce ACPI for ARM64 based on ACPI 5.1
  2015-03-22 22:11                   ` Rafael J. Wysocki
@ 2015-03-23  1:37                     ` Hanjun Guo
  2015-03-23 18:39                       ` Stefano Stabellini
  0 siblings, 1 reply; 89+ messages in thread
From: Hanjun Guo @ 2015-03-23  1:37 UTC (permalink / raw)
  To: Rafael J. Wysocki, Julien Grall
  Cc: Naresh Bhat, Hanjun Guo, Jon Fraser, Parth Dixit,
	Stefano Stabellini, Catalin Marinas, 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@vger.kernelorg, linaro-acpi, Ian Campbell

On 2015/3/23 6:11, Rafael J. Wysocki wrote:
> On Sunday, March 22, 2015 09:32:48 PM Julien Grall wrote:
>> On 22/03/2015 21:49, Rafael J. Wysocki wrote:
>>> On Sunday, March 22, 2015 09:05:21 PM Julien Grall wrote:
>>>> Hello,
>>>>
>>>> On 21/03/2015 12:09, Naresh Bhat wrote:
>>>>>       From 268dcdafa34a690e2f99c0784ca33a6d2352ecf5 Mon Sep 17 00:00:00 2001
>>>>>      From: Hanjun Guo <hanjun.guo@linaro.org <mailto:hanjun.guo@linaro.org>>
>>>>>      Date: Sat, 21 Mar 2015 14:43:54 +0800
>>>>>      Subject: [PATCH] XEN / ACPI: Make XEN ACPI depend on X86
>>>>>
>>>>>      When ACPI is enabled on ARM64, XEN ACPI will also compiled
>>>>>      into the kernel, but XEN ACPI is x86 dependent, so introduce
>>>>>      CONFIG_XEN_ACPI to make it depend on x86 before XEN ACPI is
>>>>>      functional on ARM64.
>>>>>
>>>>>      Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org
>>>>>      <mailto:hanjun.guo@linaro.org>>
>>>>>      ---
>>>>>        drivers/xen/Kconfig  | 4 ++++
>>>>>        drivers/xen/Makefile | 2 +-
>>>>>        2 files changed, 5 insertions(+), 1 deletion(-)
>>>>>
>>>>>      diff --git a/drivers/xen/Kconfig b/drivers/xen/Kconfig
>>>>>      index b812462..a31cd29 100644
>>>>>      --- a/drivers/xen/Kconfig
>>>>>      +++ b/drivers/xen/Kconfig
>>>>>      @@ -253,4 +253,8 @@ config XEN_EFI
>>>>>            def_bool y
>>>>>            depends on X86_64 && EFI
>>>>>
>>>>>      +config XEN_ACPI
>>>>>      +    def_bool y
>>>>>      +    depends on X86 && ACPI
>>>>>      +
>>>>>        endmenu
>>>>>      diff --git a/drivers/xen/Makefile b/drivers/xen/Makefile
>>>>>      index 2ccd359..f4622ab 100644
>>>>>      --- a/drivers/xen/Makefile
>>>>>      +++ b/drivers/xen/Makefile
>>>>>      @@ -13,7 +13,7 @@ CFLAGS_efi.o                += -fshort-wchar
>>>>>
>>>>>        dom0-$(CONFIG_PCI) += pci.o
>>>>>        dom0-$(CONFIG_USB_SUPPORT) += dbgp.o
>>>>>      -dom0-$(CONFIG_ACPI) += acpi.o $(xen-pad-y)
>>>>>      +dom0-$(CONFIG_XEN_ACPI) += acpi.o $(xen-pad-y)
>>>>>        xen-pad-$(CONFIG_X86) += xen-acpi-pad.o
>>>>>        dom0-$(CONFIG_X86) += pcpu.o
>>>>>        obj-$(CONFIG_XEN_DOM0)            += $(dom0-y)
>>>> [..]
>>>>
>>>>> AFAIK,  There is already a kernel patch exists to fix this issue.  I
>>>>> think  Julien or Parth is a right person to ask.  Hence I am CCed Julien
>>>>> Grall too.
>>>> The ACPI support for Xen is not ready. So I think avoiding to compile
>>>> drivers/xen/acpi.c on ARM64/ARM seems the better solution for now.
>>>>
>>>> Although, rather than introducing a new CONFIG option, I would use the
>>>> same trick we use within the Makefile to avoid hotplug.c on ARM/ARM64.
>>>>
>>>> ifeq ($(filter y, $(CONFIG_ARM) $(CONFIG_ARM64)), )
>>>> dom0-$(CONFIG_ACPI) += acpi.o $(xen-pad-y)
>>>> endif
>>> Well, is avoiding an extra CONFIG_ option worth the ugliness of this?
>> When the support of ACPI for Xen will come, the CONFIG_ option will be 
>> an alias to CONFIG_XEN.
>>
>> In this case the CONFIG_ option won't bring much improvement to the code 
>> and add an extra indirection.
>>
>> The "ugliness" option has, at least, the advantage to be tiny and 
>> self-contained.
> Oh well, not really.  You're moving a config-time check to compile time
> which means that it will be done every time this Makefile is executed
> and for all architectures that execute it.  Not nice.
>
> Also I think that ia64 is missing from the list, but I may be wrong.

In commit d52eefb47d (ia64/xen: Remove Xen support for ia64), XEN is
not supported anymore on ia64 now.

>
> Not to mention the fact that the dependency will be rather difficult to find
> for tools like xconfig ...

I also think introducing a CONFIG_ option is a better idea.

Thanks
Hanjun


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

* Re: [PATCH v10 00/21] Introduce ACPI for ARM64 based on ACPI 5.1
  2015-03-21  3:17       ` Hanjun Guo
  2015-03-21  7:03         ` Hanjun Guo
@ 2015-03-23 18:32         ` Stefano Stabellini
  2015-03-24 13:46           ` Hanjun Guo
  1 sibling, 1 reply; 89+ messages in thread
From: Stefano Stabellini @ 2015-03-23 18:32 UTC (permalink / raw)
  To: Hanjun Guo
  Cc: Will Deacon, Hanjun Guo, Catalin Marinas, Rafael J. Wysocki,
	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, Parth Dixit,
	'Stefano Stabellini'

[-- Attachment #1: Type: text/plain, Size: 2917 bytes --]

On Sat, 21 Mar 2015, Hanjun Guo wrote:
> +CC Parth Dixit, Stefano Stabellini.
> 
> On 2015年03月21日 02:54, Will Deacon wrote:
> > On Thu, Mar 19, 2015 at 04:09:33AM +0000, Hanjun Guo wrote:
> > > On 2015/3/19 3:05, Will Deacon wrote:
> > > > If you can get that in place, I'm not opposed to putting this into
> > > > linux-next ahead of the firmware summit in San Jose next week. Note that
> > > > this is not a commitment for 4.1, since I'm keen to see the outcomes of
> > > > next week before setting anything in stone.
> > > 
> > > OK, I will stick to this mailing list and respond as soon as I can.
> > 
> > This doesn't even build for me:
> > 
> > 
> > $ make ARCH=arm64 CROSS_COMPILE=aarch64-none-linux-gnu- allmodconfig
> > $ make ARCH=arm64 CROSS_COMPILE=aarch64-none-linux-gnu- Image
> > 
> > [...]
> > 
> > In file included from drivers/xen/acpi.c:33:0:
> 
> Sorry, I didn't build ACPI with XEN enabled on ARM64.
> 
> > include/xen/acpi.h: In function ‘xen_acpi_sleep_register’:
> > include/xen/acpi.h:102:3: error: ‘acpi_suspend_lowlevel’ undeclared (first
> > use in this function)
> >     acpi_suspend_lowlevel = xen_acpi_suspend_lowlevel;
> 
> acpi_suspend_lowlevel is defined only for X86 and IA64 for now.
> 
> >     ^
> > include/xen/acpi.h:102:3: note: each undeclared identifier is reported only
> > once for each function it appears in
> > drivers/xen/acpi.c: In function ‘xen_acpi_notify_hypervisor_state’:
> > drivers/xen/acpi.c:61:2: error: implicit declaration of function
> > ‘HYPERVISOR_dom0_op’ [-Werror=implicit-function-declaration]
> >    HYPERVISOR_dom0_op(&op);
> 
> And this is only for x86:
> ./arch/x86/include/asm/xen/hypercall.h:HYPERVISOR_dom0_op(struct
> xen_platform_op *platform_op)
> 
> >    ^
> > cc1: some warnings being treated as errors
> > make[2]: *** [drivers/xen/acpi.o] Error 1
> > make[2]: *** Waiting for unfinished jobs....
> > make[1]: *** [drivers/xen] Error 2
> > make[1]: *** Waiting for unfinished jobs....
> > make: *** [drivers] Error 2
> > 
> > 
> > Am I missing some other patches?
> 
> No, you miss nothing. Parth Dixit is still working on XEN ACPI for
> ARM64, before it's in full function, how about introduce a Kconfig
> CONFIG_XEN_ACPI and let it depends on x86? when XEN ACPI for ARM64
> comes, we can enable ARM64 for CONFIG_XEN_ACPI and fix the problems
> above.
> 
> Stefano, Parth, what do you think?
 
To be precise, Parth is working on ACPI enablement for the Xen
hypervisor at the moment (on the Xen tree), I don't think he has any
patches for Linux (Dom0 is the key use case). The two works could be
carried on in parallel, even though you would obviously need Parth's Xen
patches to test the Linux side.

That said, I am OK with disabling ACPI for Xen on ARM and ARM64 for now
-- I wouldn't want to cause any significant delays to your patch series.

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

* Re: [PATCH v10 00/21] Introduce ACPI for ARM64 based on ACPI 5.1
  2015-03-23  1:37                     ` Hanjun Guo
@ 2015-03-23 18:39                       ` Stefano Stabellini
  0 siblings, 0 replies; 89+ messages in thread
From: Stefano Stabellini @ 2015-03-23 18:39 UTC (permalink / raw)
  To: Hanjun Guo
  Cc: Rafael J. Wysocki, Julien Grall, Naresh Bhat, Hanjun Guo,
	Jon Fraser, Parth Dixit, Stefano Stabellini, Catalin Marinas,
	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@vger.kernelorg, linaro-acpi, Ian Campbell

On Mon, 23 Mar 2015, Hanjun Guo wrote:
> On 2015/3/23 6:11, Rafael J. Wysocki wrote:
> > On Sunday, March 22, 2015 09:32:48 PM Julien Grall wrote:
> >> On 22/03/2015 21:49, Rafael J. Wysocki wrote:
> >>> On Sunday, March 22, 2015 09:05:21 PM Julien Grall wrote:
> >>>> Hello,
> >>>>
> >>>> On 21/03/2015 12:09, Naresh Bhat wrote:
> >>>>>       From 268dcdafa34a690e2f99c0784ca33a6d2352ecf5 Mon Sep 17 00:00:00 2001
> >>>>>      From: Hanjun Guo <hanjun.guo@linaro.org <mailto:hanjun.guo@linaro.org>>
> >>>>>      Date: Sat, 21 Mar 2015 14:43:54 +0800
> >>>>>      Subject: [PATCH] XEN / ACPI: Make XEN ACPI depend on X86
> >>>>>
> >>>>>      When ACPI is enabled on ARM64, XEN ACPI will also compiled
> >>>>>      into the kernel, but XEN ACPI is x86 dependent, so introduce
> >>>>>      CONFIG_XEN_ACPI to make it depend on x86 before XEN ACPI is
> >>>>>      functional on ARM64.
> >>>>>
> >>>>>      Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org
> >>>>>      <mailto:hanjun.guo@linaro.org>>
> >>>>>      ---
> >>>>>        drivers/xen/Kconfig  | 4 ++++
> >>>>>        drivers/xen/Makefile | 2 +-
> >>>>>        2 files changed, 5 insertions(+), 1 deletion(-)
> >>>>>
> >>>>>      diff --git a/drivers/xen/Kconfig b/drivers/xen/Kconfig
> >>>>>      index b812462..a31cd29 100644
> >>>>>      --- a/drivers/xen/Kconfig
> >>>>>      +++ b/drivers/xen/Kconfig
> >>>>>      @@ -253,4 +253,8 @@ config XEN_EFI
> >>>>>            def_bool y
> >>>>>            depends on X86_64 && EFI
> >>>>>
> >>>>>      +config XEN_ACPI
> >>>>>      +    def_bool y
> >>>>>      +    depends on X86 && ACPI
> >>>>>      +
> >>>>>        endmenu
> >>>>>      diff --git a/drivers/xen/Makefile b/drivers/xen/Makefile
> >>>>>      index 2ccd359..f4622ab 100644
> >>>>>      --- a/drivers/xen/Makefile
> >>>>>      +++ b/drivers/xen/Makefile
> >>>>>      @@ -13,7 +13,7 @@ CFLAGS_efi.o                += -fshort-wchar
> >>>>>
> >>>>>        dom0-$(CONFIG_PCI) += pci.o
> >>>>>        dom0-$(CONFIG_USB_SUPPORT) += dbgp.o
> >>>>>      -dom0-$(CONFIG_ACPI) += acpi.o $(xen-pad-y)
> >>>>>      +dom0-$(CONFIG_XEN_ACPI) += acpi.o $(xen-pad-y)
> >>>>>        xen-pad-$(CONFIG_X86) += xen-acpi-pad.o
> >>>>>        dom0-$(CONFIG_X86) += pcpu.o
> >>>>>        obj-$(CONFIG_XEN_DOM0)            += $(dom0-y)
> >>>> [..]
> >>>>
> >>>>> AFAIK,  There is already a kernel patch exists to fix this issue.  I
> >>>>> think  Julien or Parth is a right person to ask.  Hence I am CCed Julien
> >>>>> Grall too.
> >>>> The ACPI support for Xen is not ready. So I think avoiding to compile
> >>>> drivers/xen/acpi.c on ARM64/ARM seems the better solution for now.
> >>>>
> >>>> Although, rather than introducing a new CONFIG option, I would use the
> >>>> same trick we use within the Makefile to avoid hotplug.c on ARM/ARM64.
> >>>>
> >>>> ifeq ($(filter y, $(CONFIG_ARM) $(CONFIG_ARM64)), )
> >>>> dom0-$(CONFIG_ACPI) += acpi.o $(xen-pad-y)
> >>>> endif
> >>> Well, is avoiding an extra CONFIG_ option worth the ugliness of this?
> >> When the support of ACPI for Xen will come, the CONFIG_ option will be 
> >> an alias to CONFIG_XEN.
> >>
> >> In this case the CONFIG_ option won't bring much improvement to the code 
> >> and add an extra indirection.
> >>
> >> The "ugliness" option has, at least, the advantage to be tiny and 
> >> self-contained.
> > Oh well, not really.  You're moving a config-time check to compile time
> > which means that it will be done every time this Makefile is executed
> > and for all architectures that execute it.  Not nice.
> >
> > Also I think that ia64 is missing from the list, but I may be wrong.
> 
> In commit d52eefb47d (ia64/xen: Remove Xen support for ia64), XEN is
> not supported anymore on ia64 now.
> 
> >
> > Not to mention the fact that the dependency will be rather difficult to find
> > for tools like xconfig ...
> 
> I also think introducing a CONFIG_ option is a better idea.

Me too

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

* Re: [PATCH v10 00/21] Introduce ACPI for ARM64 based on ACPI 5.1
  2015-03-23 18:32         ` Stefano Stabellini
@ 2015-03-24 13:46           ` Hanjun Guo
  0 siblings, 0 replies; 89+ messages in thread
From: Hanjun Guo @ 2015-03-24 13:46 UTC (permalink / raw)
  To: Stefano Stabellini
  Cc: Will Deacon, Hanjun Guo, Catalin Marinas, Rafael J. Wysocki,
	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, Parth Dixit

On 2015年03月24日 02:32, Stefano Stabellini wrote:
> On Sat, 21 Mar 2015, Hanjun Guo wrote:
>> +CC Parth Dixit, Stefano Stabellini.
>>
>> On 2015年03月21日 02:54, Will Deacon wrote:
>>> On Thu, Mar 19, 2015 at 04:09:33AM +0000, Hanjun Guo wrote:
>>>> On 2015/3/19 3:05, Will Deacon wrote:
>>>>> If you can get that in place, I'm not opposed to putting this into
>>>>> linux-next ahead of the firmware summit in San Jose next week. Note that
>>>>> this is not a commitment for 4.1, since I'm keen to see the outcomes of
>>>>> next week before setting anything in stone.
>>>>
>>>> OK, I will stick to this mailing list and respond as soon as I can.
>>>
>>> This doesn't even build for me:
>>>
>>>
>>> $ make ARCH=arm64 CROSS_COMPILE=aarch64-none-linux-gnu- allmodconfig
>>> $ make ARCH=arm64 CROSS_COMPILE=aarch64-none-linux-gnu- Image
>>>
>>> [...]
>>>
>>> In file included from drivers/xen/acpi.c:33:0:
>>
>> Sorry, I didn't build ACPI with XEN enabled on ARM64.
>>
>>> include/xen/acpi.h: In function ‘xen_acpi_sleep_register’:
>>> include/xen/acpi.h:102:3: error: ‘acpi_suspend_lowlevel’ undeclared (first
>>> use in this function)
>>>      acpi_suspend_lowlevel = xen_acpi_suspend_lowlevel;
>>
>> acpi_suspend_lowlevel is defined only for X86 and IA64 for now.
>>
>>>      ^
>>> include/xen/acpi.h:102:3: note: each undeclared identifier is reported only
>>> once for each function it appears in
>>> drivers/xen/acpi.c: In function ‘xen_acpi_notify_hypervisor_state’:
>>> drivers/xen/acpi.c:61:2: error: implicit declaration of function
>>> ‘HYPERVISOR_dom0_op’ [-Werror=implicit-function-declaration]
>>>     HYPERVISOR_dom0_op(&op);
>>
>> And this is only for x86:
>> ./arch/x86/include/asm/xen/hypercall.h:HYPERVISOR_dom0_op(struct
>> xen_platform_op *platform_op)
>>
>>>     ^
>>> cc1: some warnings being treated as errors
>>> make[2]: *** [drivers/xen/acpi.o] Error 1
>>> make[2]: *** Waiting for unfinished jobs....
>>> make[1]: *** [drivers/xen] Error 2
>>> make[1]: *** Waiting for unfinished jobs....
>>> make: *** [drivers] Error 2
>>>
>>>
>>> Am I missing some other patches?
>>
>> No, you miss nothing. Parth Dixit is still working on XEN ACPI for
>> ARM64, before it's in full function, how about introduce a Kconfig
>> CONFIG_XEN_ACPI and let it depends on x86? when XEN ACPI for ARM64
>> comes, we can enable ARM64 for CONFIG_XEN_ACPI and fix the problems
>> above.
>>
>> Stefano, Parth, what do you think?
>
> To be precise, Parth is working on ACPI enablement for the Xen
> hypervisor at the moment (on the Xen tree), I don't think he has any
> patches for Linux (Dom0 is the key use case). The two works could be
> carried on in parallel, even though you would obviously need Parth's Xen
> patches to test the Linux side.

Sure, I saw a workaround patch for the Linux side, if Parth need
any help for the further development, I will be there.

>
> That said, I am OK with disabling ACPI for Xen on ARM and ARM64 for now
> -- I wouldn't want to cause any significant delays to your patch series.

Thanks!

Hanjun

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

* Re: [PATCH v10 00/21] Introduce ACPI for ARM64 based on ACPI 5.1
  2015-03-19 19:39       ` Will Deacon
@ 2015-03-24 22:02         ` Grant Likely
  2015-03-25 11:24           ` Will Deacon
  2015-03-26 10:24           ` Lorenzo Pieralisi
  0 siblings, 2 replies; 89+ messages in thread
From: Grant Likely @ 2015-03-24 22:02 UTC (permalink / raw)
  To: Will Deacon, Lorenzo Pieralisi
  Cc: guohanjun, hanjun.guo, Catalin Marinas, Rafael J. Wysocki,
	Olof Johansson, 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 Thu, 19 Mar 2015 19:39:27 +0000
, Will Deacon <will.deacon@arm.com>
 wrote:
> On Thu, Mar 19, 2015 at 10:17:27AM +0000, Lorenzo Pieralisi wrote:
> > On Thu, Mar 19, 2015 at 04:09:33AM +0000, Hanjun Guo wrote:
> > > On 2015/3/19 3:05, Will Deacon wrote:
> > > > On Wed, Mar 11, 2015 at 12:39:26PM +0000, Hanjun Guo wrote:
> > > >> This patch set already tested on multi platforms:
> > > >>  - AMD Seattle board;
> > > >>  - Cavium Thunder board;
> > > >>  - Huawei D02 board;
> > > >>  - Qualcomm ARM64 platform
> > > >>
> > > >> This version 10 patch set address some minor comments and collect ACKs and
> > > >> Reviewed-bys for v9:
> > > >>
> > > >>  - new Acks from Rafael, Olof, Grant, Lorenzo
> > > >>  - new way to handle typdef phys_cpuid_t which suggested by Rafael,
> > > >>    but no functional change
> > > >>  - Remove if(!phys) for early ioremappings
> > > >>  - Rework sleep function for ARM64
> > > >>  - Introduce linux/acpi_irq.h to hold acpi_irq_init()
> > > >>  - Disable ACPI if not HW_REDUCED_ACPI compliant
> > > >>  - Remove the doc of why ACPI on ARM
> > > > So I've had a look at the current state of this series and I think there
> > > > are a few immediate things left to do:
> > > >
> > > >   (1) Resolve the acpi=force cmdline issue highlighted by Lorenzo and
> > > >       Catalin
> > > 
> > > Sure, it will be done after the confirmation with Ard.
> > > 
> > > >
> > > >   (2) I believe Sudeep and Lorenzo have concerns about patch 13 (SMP init),
> > > >       so I'm assuming there will be additional patches from them that are
> > > >       required.
> > > 
> > > Sorry, I assume that it is about the print information for PSCI absent for SMP init, right?
> > 
> > Not only that, Sudeep has a patch to consolidate DT and ACPI SMP code,
> > I am working on it, I do not think it should be a blocking point, patch
> > coming asap on top of your series.
> 
> Well, I don't really want to merge the series without those patches so I
> do think it blocks the code from getting into mainline.

Really? It's a pretty minor duplication problem and it's been identified
as something requiring refactoring to both the ACPI and DT code. It
isn't at all dangerous. Why is this a blocking point?

g.


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

* Re: [PATCH v10 00/21] Introduce ACPI for ARM64 based on ACPI 5.1
  2015-03-24 22:02         ` Grant Likely
@ 2015-03-25 11:24           ` Will Deacon
  2015-03-25 11:54             ` Rafael J. Wysocki
  2015-03-26 10:24           ` Lorenzo Pieralisi
  1 sibling, 1 reply; 89+ messages in thread
From: Will Deacon @ 2015-03-25 11:24 UTC (permalink / raw)
  To: Grant Likely
  Cc: Lorenzo Pieralisi, guohanjun, hanjun.guo, Catalin Marinas,
	Rafael J. Wysocki, Olof Johansson, 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 Tue, Mar 24, 2015 at 10:02:53PM +0000, Grant Likely wrote:
> On Thu, 19 Mar 2015 19:39:27 +0000 , Will Deacon <will.deacon@arm.com>
> wrote:
> > On Thu, Mar 19, 2015 at 10:17:27AM +0000, Lorenzo Pieralisi wrote:
> > > Not only that, Sudeep has a patch to consolidate DT and ACPI SMP code,
> > > I am working on it, I do not think it should be a blocking point, patch
> > > coming asap on top of your series.
> > 
> > Well, I don't really want to merge the series without those patches so I
> > do think it blocks the code from getting into mainline.
> 
> Really? It's a pretty minor duplication problem and it's been identified
> as something requiring refactoring to both the ACPI and DT code. It
> isn't at all dangerous. Why is this a blocking point?

Because I don't really see a valid excuse not to get this right first time
around. Lorenzo already has patches on top, so we just need a co-ordinated
review effort.

I wouldn't accept another patch series that needed minor rework (which by
its very nature is easily addressed), so why should ACPI be treated any
differently?

Will

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

* Re: [PATCH v10 00/21] Introduce ACPI for ARM64 based on ACPI 5.1
  2015-03-25 11:54             ` Rafael J. Wysocki
@ 2015-03-25 11:38               ` Will Deacon
  2015-03-25 12:16                 ` Rafael J. Wysocki
  2015-03-28 12:34                 ` Grant Likely
  0 siblings, 2 replies; 89+ messages in thread
From: Will Deacon @ 2015-03-25 11:38 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: grant.likely, Lorenzo Pieralisi, guohanjun, hanjun.guo,
	Catalin Marinas, Olof Johansson, 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, Mar 25, 2015 at 11:54:25AM +0000, Rafael J. Wysocki wrote:
> On Wednesday, March 25, 2015 11:24:11 AM Will Deacon wrote:
> > On Tue, Mar 24, 2015 at 10:02:53PM +0000, Grant Likely wrote:
> > > On Thu, 19 Mar 2015 19:39:27 +0000 , Will Deacon <will.deacon@arm.com>
> > > wrote:
> > > > On Thu, Mar 19, 2015 at 10:17:27AM +0000, Lorenzo Pieralisi wrote:
> > > > > Not only that, Sudeep has a patch to consolidate DT and ACPI SMP code,
> > > > > I am working on it, I do not think it should be a blocking point, patch
> > > > > coming asap on top of your series.
> > > > 
> > > > Well, I don't really want to merge the series without those patches so I
> > > > do think it blocks the code from getting into mainline.
> > > 
> > > Really? It's a pretty minor duplication problem and it's been identified
> > > as something requiring refactoring to both the ACPI and DT code. It
> > > isn't at all dangerous. Why is this a blocking point?
> > 
> > Because I don't really see a valid excuse not to get this right first time
> > around. Lorenzo already has patches on top, so we just need a co-ordinated
> > review effort.
> > 
> > I wouldn't accept another patch series that needed minor rework (which by
> > its very nature is easily addressed), so why should ACPI be treated any
> > differently?
> 
> Not ACPI, but this particular patchset I think.  The problem is that it has
> already been reviewed and ACKed by multiple people and it would be a shame
> to require all of those people to do their reviews once again because of
> that minor rework (which arguably can be done on top of the patchset just
> fine).
> 
> Of course, if the minor rework in question would not involve the need to
> review things once again, then I agree that it'd be better to do it upfront,
> but otherwise there's a good reason not to.

Aha, I think this is just a misunderstanding -- I'm certainly not suggesting
that Hanjun rework the current set! What I *am* asking for is that they go
into mainline with Lorenzo's patches on top, which means that his series [1]
needs some review (and I plan to look at it later today).

> And, as a maintainer, you can always say "Well, I'm taking this conditional on
> doing this-and-that on top of it and I won't be taking any more patches from
> you in the future if that doesn't happen."

I can't really take that stance for a new feature like this.

Will

[1] http://lists.infradead.org/pipermail/linux-arm-kernel/2015-March/333257.html

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

* Re: [PATCH v10 00/21] Introduce ACPI for ARM64 based on ACPI 5.1
  2015-03-25 11:24           ` Will Deacon
@ 2015-03-25 11:54             ` Rafael J. Wysocki
  2015-03-25 11:38               ` Will Deacon
  0 siblings, 1 reply; 89+ messages in thread
From: Rafael J. Wysocki @ 2015-03-25 11:54 UTC (permalink / raw)
  To: Will Deacon
  Cc: Grant Likely, Lorenzo Pieralisi, guohanjun, hanjun.guo,
	Catalin Marinas, Olof Johansson, 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 Wednesday, March 25, 2015 11:24:11 AM Will Deacon wrote:
> On Tue, Mar 24, 2015 at 10:02:53PM +0000, Grant Likely wrote:
> > On Thu, 19 Mar 2015 19:39:27 +0000 , Will Deacon <will.deacon@arm.com>
> > wrote:
> > > On Thu, Mar 19, 2015 at 10:17:27AM +0000, Lorenzo Pieralisi wrote:
> > > > Not only that, Sudeep has a patch to consolidate DT and ACPI SMP code,
> > > > I am working on it, I do not think it should be a blocking point, patch
> > > > coming asap on top of your series.
> > > 
> > > Well, I don't really want to merge the series without those patches so I
> > > do think it blocks the code from getting into mainline.
> > 
> > Really? It's a pretty minor duplication problem and it's been identified
> > as something requiring refactoring to both the ACPI and DT code. It
> > isn't at all dangerous. Why is this a blocking point?
> 
> Because I don't really see a valid excuse not to get this right first time
> around. Lorenzo already has patches on top, so we just need a co-ordinated
> review effort.
> 
> I wouldn't accept another patch series that needed minor rework (which by
> its very nature is easily addressed), so why should ACPI be treated any
> differently?

Not ACPI, but this particular patchset I think.  The problem is that it has
already been reviewed and ACKed by multiple people and it would be a shame
to require all of those people to do their reviews once again because of
that minor rework (which arguably can be done on top of the patchset just
fine).

Of course, if the minor rework in question would not involve the need to
review things once again, then I agree that it'd be better to do it upfront,
but otherwise there's a good reason not to.

And, as a maintainer, you can always say "Well, I'm taking this conditional on
doing this-and-that on top of it and I won't be taking any more patches from
you in the future if that doesn't happen."


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

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

* Re: [PATCH v10 00/21] Introduce ACPI for ARM64 based on ACPI 5.1
  2015-03-25 11:38               ` Will Deacon
@ 2015-03-25 12:16                 ` Rafael J. Wysocki
  2015-03-28 12:34                 ` Grant Likely
  1 sibling, 0 replies; 89+ messages in thread
From: Rafael J. Wysocki @ 2015-03-25 12:16 UTC (permalink / raw)
  To: Will Deacon
  Cc: grant.likely, Lorenzo Pieralisi, guohanjun, hanjun.guo,
	Catalin Marinas, Olof Johansson, 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 Wednesday, March 25, 2015 11:38:43 AM Will Deacon wrote:
> On Wed, Mar 25, 2015 at 11:54:25AM +0000, Rafael J. Wysocki wrote:
> > On Wednesday, March 25, 2015 11:24:11 AM Will Deacon wrote:
> > > On Tue, Mar 24, 2015 at 10:02:53PM +0000, Grant Likely wrote:
> > > > On Thu, 19 Mar 2015 19:39:27 +0000 , Will Deacon <will.deacon@arm.com>
> > > > wrote:
> > > > > On Thu, Mar 19, 2015 at 10:17:27AM +0000, Lorenzo Pieralisi wrote:
> > > > > > Not only that, Sudeep has a patch to consolidate DT and ACPI SMP code,
> > > > > > I am working on it, I do not think it should be a blocking point, patch
> > > > > > coming asap on top of your series.
> > > > > 
> > > > > Well, I don't really want to merge the series without those patches so I
> > > > > do think it blocks the code from getting into mainline.
> > > > 
> > > > Really? It's a pretty minor duplication problem and it's been identified
> > > > as something requiring refactoring to both the ACPI and DT code. It
> > > > isn't at all dangerous. Why is this a blocking point?
> > > 
> > > Because I don't really see a valid excuse not to get this right first time
> > > around. Lorenzo already has patches on top, so we just need a co-ordinated
> > > review effort.
> > > 
> > > I wouldn't accept another patch series that needed minor rework (which by
> > > its very nature is easily addressed), so why should ACPI be treated any
> > > differently?
> > 
> > Not ACPI, but this particular patchset I think.  The problem is that it has
> > already been reviewed and ACKed by multiple people and it would be a shame
> > to require all of those people to do their reviews once again because of
> > that minor rework (which arguably can be done on top of the patchset just
> > fine).
> > 
> > Of course, if the minor rework in question would not involve the need to
> > review things once again, then I agree that it'd be better to do it upfront,
> > but otherwise there's a good reason not to.
> 
> Aha, I think this is just a misunderstanding -- I'm certainly not suggesting
> that Hanjun rework the current set! What I *am* asking for is that they go
> into mainline with Lorenzo's patches on top, which means that his series [1]
> needs some review (and I plan to look at it later today).

OK, that works for me, thanks for the clarification!

For the record, I've looked at the Lorenzo's series already and I don't see
anything particularly objectionable in it.

> [1] http://lists.infradead.org/pipermail/linux-arm-kernel/2015-March/333257.html


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

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

* Re: [PATCH v10 00/21] Introduce ACPI for ARM64 based on ACPI 5.1
  2015-03-24 22:02         ` Grant Likely
  2015-03-25 11:24           ` Will Deacon
@ 2015-03-26 10:24           ` Lorenzo Pieralisi
  1 sibling, 0 replies; 89+ messages in thread
From: Lorenzo Pieralisi @ 2015-03-26 10:24 UTC (permalink / raw)
  To: Grant Likely
  Cc: Will Deacon, guohanjun, hanjun.guo, Catalin Marinas,
	Rafael J. Wysocki, Olof Johansson, 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 Tue, Mar 24, 2015 at 10:02:53PM +0000, Grant Likely wrote:
> On Thu, 19 Mar 2015 19:39:27 +0000
> , Will Deacon <will.deacon@arm.com>
>  wrote:
> > On Thu, Mar 19, 2015 at 10:17:27AM +0000, Lorenzo Pieralisi wrote:
> > > On Thu, Mar 19, 2015 at 04:09:33AM +0000, Hanjun Guo wrote:
> > > > On 2015/3/19 3:05, Will Deacon wrote:
> > > > > On Wed, Mar 11, 2015 at 12:39:26PM +0000, Hanjun Guo wrote:
> > > > >> This patch set already tested on multi platforms:
> > > > >>  - AMD Seattle board;
> > > > >>  - Cavium Thunder board;
> > > > >>  - Huawei D02 board;
> > > > >>  - Qualcomm ARM64 platform
> > > > >>
> > > > >> This version 10 patch set address some minor comments and collect ACKs and
> > > > >> Reviewed-bys for v9:
> > > > >>
> > > > >>  - new Acks from Rafael, Olof, Grant, Lorenzo
> > > > >>  - new way to handle typdef phys_cpuid_t which suggested by Rafael,
> > > > >>    but no functional change
> > > > >>  - Remove if(!phys) for early ioremappings
> > > > >>  - Rework sleep function for ARM64
> > > > >>  - Introduce linux/acpi_irq.h to hold acpi_irq_init()
> > > > >>  - Disable ACPI if not HW_REDUCED_ACPI compliant
> > > > >>  - Remove the doc of why ACPI on ARM
> > > > > So I've had a look at the current state of this series and I think there
> > > > > are a few immediate things left to do:
> > > > >
> > > > >   (1) Resolve the acpi=force cmdline issue highlighted by Lorenzo and
> > > > >       Catalin
> > > > 
> > > > Sure, it will be done after the confirmation with Ard.
> > > > 
> > > > >
> > > > >   (2) I believe Sudeep and Lorenzo have concerns about patch 13 (SMP init),
> > > > >       so I'm assuming there will be additional patches from them that are
> > > > >       required.
> > > > 
> > > > Sorry, I assume that it is about the print information for PSCI absent for SMP init, right?
> > > 
> > > Not only that, Sudeep has a patch to consolidate DT and ACPI SMP code,
> > > I am working on it, I do not think it should be a blocking point, patch
> > > coming asap on top of your series.
> > 
> > Well, I don't really want to merge the series without those patches so I
> > do think it blocks the code from getting into mainline.
> 
> Really? It's a pretty minor duplication problem and it's been identified
> as something requiring refactoring to both the ACPI and DT code. It
> isn't at all dangerous. Why is this a blocking point?

The SMP init ACPI/DT consolidation, in particular in relation to cpu_ops may
not be a blocking point, but it is not a whim either and it deserves some
thought.

I will post a patch asap and the ACPI parking protocol support patches
strictly depend on this clean-up to be completed.

Lorenzo

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

* Re: [PATCH v10 00/21] Introduce ACPI for ARM64 based on ACPI 5.1
  2015-03-25 11:38               ` Will Deacon
  2015-03-25 12:16                 ` Rafael J. Wysocki
@ 2015-03-28 12:34                 ` Grant Likely
  1 sibling, 0 replies; 89+ messages in thread
From: Grant Likely @ 2015-03-28 12:34 UTC (permalink / raw)
  To: Will Deacon, Rafael J. Wysocki
  Cc: Lorenzo Pieralisi, guohanjun, hanjun.guo, Catalin Marinas,
	Olof Johansson, 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, 25 Mar 2015 11:38:43 +0000
, Will Deacon <will.deacon@arm.com>
 wrote:
> On Wed, Mar 25, 2015 at 11:54:25AM +0000, Rafael J. Wysocki wrote:
> > On Wednesday, March 25, 2015 11:24:11 AM Will Deacon wrote:
> > > On Tue, Mar 24, 2015 at 10:02:53PM +0000, Grant Likely wrote:
> > > > On Thu, 19 Mar 2015 19:39:27 +0000 , Will Deacon <will.deacon@arm.com>
> > > > wrote:
> > > > > On Thu, Mar 19, 2015 at 10:17:27AM +0000, Lorenzo Pieralisi wrote:
> > > > > > Not only that, Sudeep has a patch to consolidate DT and ACPI SMP code,
> > > > > > I am working on it, I do not think it should be a blocking point, patch
> > > > > > coming asap on top of your series.
> > > > > 
> > > > > Well, I don't really want to merge the series without those patches so I
> > > > > do think it blocks the code from getting into mainline.
> > > > 
> > > > Really? It's a pretty minor duplication problem and it's been identified
> > > > as something requiring refactoring to both the ACPI and DT code. It
> > > > isn't at all dangerous. Why is this a blocking point?
> > > 
> > > Because I don't really see a valid excuse not to get this right first time
> > > around. Lorenzo already has patches on top, so we just need a co-ordinated
> > > review effort.
> > > 
> > > I wouldn't accept another patch series that needed minor rework (which by
> > > its very nature is easily addressed), so why should ACPI be treated any
> > > differently?
> > 
> > Not ACPI, but this particular patchset I think.  The problem is that it has
> > already been reviewed and ACKed by multiple people and it would be a shame
> > to require all of those people to do their reviews once again because of
> > that minor rework (which arguably can be done on top of the patchset just
> > fine).
> > 
> > Of course, if the minor rework in question would not involve the need to
> > review things once again, then I agree that it'd be better to do it upfront,
> > but otherwise there's a good reason not to.
> 
> Aha, I think this is just a misunderstanding -- I'm certainly not suggesting
> that Hanjun rework the current set! What I *am* asking for is that they go
> into mainline with Lorenzo's patches on top, which means that his series [1]
> needs some review (and I plan to look at it later today).

Okay, thanks for the clarification.

g.


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

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

Thread overview: 89+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-11 12:39 [PATCH v10 00/21] Introduce ACPI for ARM64 based on ACPI 5.1 Hanjun Guo
2015-03-11 12:39 ` [PATCH v10 01/21] ACPI / table: Use pr_debug() instead of pr_info() for MADT table scanning Hanjun Guo
2015-03-11 12:39 ` [PATCH v10 02/21] ACPI: add arm64 to the platforms that use ioremap Hanjun Guo
2015-03-11 12:39 ` [PATCH v10 03/21] ARM64: allow late use of early_ioremap Hanjun Guo
2015-03-11 12:39 ` [PATCH v10 04/21] ARM64 / ACPI: Get RSDP and ACPI boot-time tables Hanjun Guo
2015-03-11 12:39 ` [PATCH v10 05/21] ACPI: fix acpi_os_ioremap for arm64 Hanjun Guo
2015-03-11 12:39 ` [PATCH v10 06/21] ACPI / sleep: Introduce CONFIG_ACPI_GENERIC_SLEEP Hanjun Guo
2015-03-12  9:32   ` Lorenzo Pieralisi
2015-03-12 22:57   ` Rafael J. Wysocki
2015-03-13  3:31     ` Hanjun Guo
2015-03-11 12:39 ` [PATCH v10 07/21] ARM64 / ACPI: Introduce PCI stub functions for ACPI Hanjun Guo
2015-03-11 12:39 ` [PATCH v10 08/21] ARM64 / ACPI: Introduce early_param "acpi=" to enable/disable ACPI Hanjun Guo
2015-03-18 11:35   ` Lorenzo Pieralisi
2015-03-18 20:07     ` Ard Biesheuvel
2015-03-19  2:30       ` Hanjun Guo
2015-03-19 10:04       ` Lorenzo Pieralisi
2015-03-11 12:39 ` [PATCH v10 09/21] ARM64 / ACPI: If we chose to boot from acpi then disable FDT Hanjun Guo
2015-03-18 16:52   ` Catalin Marinas
2015-03-11 12:39 ` [PATCH v10 10/21] ARM64 / ACPI: Get PSCI flags in FADT for PSCI init Hanjun Guo
2015-03-13 14:51   ` Lorenzo Pieralisi
2015-03-16 11:45     ` Hanjun Guo
2015-03-16 18:41       ` Lorenzo Pieralisi
2015-03-11 12:39 ` [PATCH v10 11/21] ACPI / table: Print GIC information when MADT is parsed Hanjun Guo
2015-03-11 12:39 ` [PATCH v10 12/21] ARM64 / ACPI: Parse MADT for SMP initialization Hanjun Guo
2015-03-11 12:39 ` [PATCH v10 13/21] ACPI / processor: Introduce phys_cpuid_t for CPU hardware ID Hanjun Guo
2015-03-12  9:51   ` Lorenzo Pieralisi
2015-03-12 10:16     ` Hanjun Guo
2015-03-11 12:39 ` [PATCH v10 14/21] ACPI / processor: Make it possible to get CPU hardware ID via GICC Hanjun Guo
2015-03-12 15:41   ` Lorenzo Pieralisi
2015-03-12 23:02   ` Rafael J. Wysocki
2015-03-11 12:39 ` [PATCH v10 15/21] ARM64 / ACPI: Introduce ACPI_IRQ_MODEL_GIC and register device's gsi Hanjun Guo
2015-03-18 18:41   ` Will Deacon
2015-03-19  3:45     ` Hanjun Guo
2015-03-19 10:12       ` Lorenzo Pieralisi
2015-03-19 19:37         ` Will Deacon
2015-03-20 13:07           ` Hanjun Guo
2015-03-20 14:25             ` Lorenzo Pieralisi
2015-03-21 21:38           ` Lorenzo Pieralisi
2015-03-11 12:39 ` [PATCH v10 16/21] irqchip: Add GICv2 specific ACPI boot support Hanjun Guo
     [not found]   ` <CACxGe6uWwts6X=Yc2ioBdQizXkF1_YgoNNOsREWirk2MFBVDHg@mail.gmail.com>
2015-03-11 23:11     ` Jason Cooper
2015-03-12  1:46       ` Hanjun Guo
2015-03-12  5:12         ` Jason Cooper
2015-03-12  7:31           ` Hanjun Guo
2015-03-13 17:15             ` Jason Cooper
2015-03-14  8:47               ` Grant Likely
2015-03-14 11:43                 ` Catalin Marinas
2015-03-12 10:14       ` Marc Zyngier
2015-03-14 18:44   ` Jason Cooper
2015-03-11 12:39 ` [PATCH v10 17/21] clocksource / arch_timer: Parse GTDT to initialize arch timer Hanjun Guo
2015-03-18 18:34   ` Will Deacon
2015-03-20 13:49   ` Daniel Lezcano
2015-03-11 12:39 ` [PATCH v10 18/21] ARM64 / ACPI: Select ACPI_REDUCED_HARDWARE_ONLY if ACPI is enabled on ARM64 Hanjun Guo
2015-03-12 18:21   ` Lorenzo Pieralisi
2015-03-13  3:28     ` Hanjun Guo
2015-03-13 11:04       ` Lorenzo Pieralisi
2015-03-16 11:33         ` Hanjun Guo
2015-03-17 12:50           ` Lorenzo Pieralisi
2015-03-18  9:18           ` Lorenzo Pieralisi
2015-03-18 15:06             ` Rafael J. Wysocki
2015-03-19  1:16               ` Hanjun Guo
2015-03-11 12:39 ` [PATCH v10 19/21] ARM64 / ACPI: Enable ARM64 in Kconfig Hanjun Guo
2015-03-11 12:39 ` [PATCH v10 20/21] Documentation: ACPI for ARM64 Hanjun Guo
2015-03-11 12:39 ` [PATCH v10 21/21] ARM64 / ACPI: additions of ACPI documentation for arm64 Hanjun Guo
2015-03-12 13:26 ` [PATCH v10 00/21] Introduce ACPI for ARM64 based on ACPI 5.1 Timur Tabi
2015-03-16  5:07   ` Suthikulpanit, Suravee
2015-03-18 19:05 ` Will Deacon
2015-03-18 19:09   ` Will Deacon
2015-03-19  4:09   ` Hanjun Guo
2015-03-19 10:17     ` Lorenzo Pieralisi
2015-03-19 19:39       ` Will Deacon
2015-03-24 22:02         ` Grant Likely
2015-03-25 11:24           ` Will Deacon
2015-03-25 11:54             ` Rafael J. Wysocki
2015-03-25 11:38               ` Will Deacon
2015-03-25 12:16                 ` Rafael J. Wysocki
2015-03-28 12:34                 ` Grant Likely
2015-03-26 10:24           ` Lorenzo Pieralisi
2015-03-20 18:54     ` Will Deacon
2015-03-21  3:17       ` Hanjun Guo
2015-03-21  7:03         ` Hanjun Guo
     [not found]           ` <CAFoFrHatzS3MwGVeOPPjY1R1sfBRYnJjgbQjvfzi6xS+XYD14g@mail.gmail.com>
2015-03-22 21:05             ` Julien Grall
2015-03-22 21:49               ` Rafael J. Wysocki
2015-03-22 21:32                 ` Julien Grall
2015-03-22 22:11                   ` Rafael J. Wysocki
2015-03-23  1:37                     ` Hanjun Guo
2015-03-23 18:39                       ` Stefano Stabellini
2015-03-23 18:32         ` Stefano Stabellini
2015-03-24 13:46           ` Hanjun Guo
2015-03-20 13:18 ` Mark Salter

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