All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 00/21] Add ACPI support for Xen itself on ARM64
@ 2016-01-23  9:19 Shannon Zhao
  2016-01-23  9:19 ` [PATCH v4 01/21] arm/acpi: Emulate io ports for arm Shannon Zhao
                   ` (20 more replies)
  0 siblings, 21 replies; 62+ messages in thread
From: Shannon Zhao @ 2016-01-23  9:19 UTC (permalink / raw)
  To: xen-devel
  Cc: ian.campbell, stefano.stabellini, peter.huangpeng, julien.grall,
	stefano.stabellini, shannon.zhao

From: Shannon Zhao <shannon.zhao@linaro.org>

These patches are Part 3 of the previous patch set I sent which adds
ACPI support for arm64 on Xen[1]. Split them as an individual set for
convenient reviewing.

These patches mostly add ACPI support for Xen itself(not yet for Dom0)
on ARM64. It makes Xen could parse physical ACPI tables and initialize
hardwares it uses. But so far it doesn't enable ACPI since it doesn't
add support for Dom0.

See individual patch for changes.

Thanks,
Shannon
[1] http://lists.xenproject.org/archives/html/xen-devel/2015-11/msg01831.html

Parth Dixit (4):
  arm/acpi: Parse MADT to map logical cpu to MPIDR and get
    cpu_possible_map
  arm: Introduce a generic way to use a device from acpi
  arm/gic-v2: Add ACPI boot support for GICv2
  arm/irq: Add helper function for setting interrupt type

Shannon Zhao (17):
  arm/acpi: Emulate io ports for arm
  arm/acpi: Add arm specific acpi header file
  arm/acpi: Add __acpi_map_table function for ARM
  arm/acpi: Move end_boot_allocator after acpi_boot_table_init
  arm/acpi: Add basic ACPI initialization
  arm/acpi: Parse FADT table and get PSCI flags
  arm/acpi: Print GIC information when MADT is parsed
  arm/acpi: Add ACPI support for SMP initialization
  acpi/table: Introduce acpi_table_get_entry_madt to get specified entry
  arm/irq: Drop the DT prefix of the irq line type
  arm/gic-v3: Add ACPI boot support for GICv3
  arm/gic: Add ACPI support for GIC preinit
  arm/acpi: Parse GTDT to initialize timer
  arm/acpi: Add a new ACPI initialized function for UART
  arm/acpi: Initialize serial port from ACPI SPCR table
  arm/fdt: Export device_tree_for_each_node
  arm/acpi: Add acpi parameter to enable/disable acpi

 xen/arch/arm/Makefile          |   1 +
 xen/arch/arm/acpi/Makefile     |   2 +
 xen/arch/arm/acpi/boot.c       | 269 +++++++++++++++++++++++++++++++++++++++++
 xen/arch/arm/acpi/lib.c        |  64 ++++++++++
 xen/arch/arm/arm64/smpboot.c   |   7 +-
 xen/arch/arm/bootfdt.c         |   6 +-
 xen/arch/arm/device.c          |  18 +++
 xen/arch/arm/domain_build.c    |  10 +-
 xen/arch/arm/gic-hip04.c       |  10 +-
 xen/arch/arm/gic-v2.c          | 130 +++++++++++++++++++-
 xen/arch/arm/gic-v3.c          | 182 +++++++++++++++++++++++++++-
 xen/arch/arm/gic.c             |  41 ++++++-
 xen/arch/arm/irq.c             |  35 +++---
 xen/arch/arm/psci.c            |  35 ++++--
 xen/arch/arm/setup.c           |  15 ++-
 xen/arch/arm/smpboot.c         |   7 +-
 xen/arch/arm/time.c            |  84 ++++++++++---
 xen/arch/arm/xen.lds.S         |   7 ++
 xen/arch/x86/acpi/boot.c       |   4 -
 xen/drivers/acpi/tables.c      |  81 +++++++++++++
 xen/drivers/char/arm-uart.c    |  33 ++++-
 xen/drivers/char/pl011.c       |  37 ++++++
 xen/include/acpi/actbl2.h      |   9 ++
 xen/include/asm-arm/acpi.h     |  55 +++++++++
 xen/include/asm-arm/arm64/io.h |  18 +++
 xen/include/asm-arm/config.h   |   2 +
 xen/include/asm-arm/device.h   |  30 +++++
 xen/include/asm-arm/irq.h      |   2 +
 xen/include/xen/acpi.h         |   6 +
 xen/include/xen/device_tree.h  |  54 +++++----
 xen/include/xen/serial.h       |   2 +-
 31 files changed, 1150 insertions(+), 106 deletions(-)
 create mode 100644 xen/arch/arm/acpi/Makefile
 create mode 100644 xen/arch/arm/acpi/boot.c
 create mode 100644 xen/arch/arm/acpi/lib.c
 create mode 100644 xen/include/asm-arm/acpi.h

-- 
2.0.4

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

* [PATCH v4 01/21] arm/acpi: Emulate io ports for arm
  2016-01-23  9:19 [PATCH v4 00/21] Add ACPI support for Xen itself on ARM64 Shannon Zhao
@ 2016-01-23  9:19 ` Shannon Zhao
  2016-01-27 12:52   ` Stefano Stabellini
  2016-01-23  9:19 ` [PATCH v4 02/21] arm/acpi: Add arm specific acpi header file Shannon Zhao
                   ` (19 subsequent siblings)
  20 siblings, 1 reply; 62+ messages in thread
From: Shannon Zhao @ 2016-01-23  9:19 UTC (permalink / raw)
  To: xen-devel
  Cc: ian.campbell, stefano.stabellini, peter.huangpeng, julien.grall,
	stefano.stabellini, shannon.zhao

From: Shannon Zhao <shannon.zhao@linaro.org>

Add macros to emulate x86 style ports for arm. This avoids modification in
common code for acpi. Here just print a warning on ARM.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
V4: print warning
---
 xen/include/asm-arm/arm64/io.h | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/xen/include/asm-arm/arm64/io.h b/xen/include/asm-arm/arm64/io.h
index 37abc47..ec5815d 100644
--- a/xen/include/asm-arm/arm64/io.h
+++ b/xen/include/asm-arm/arm64/io.h
@@ -20,6 +20,7 @@
 #ifndef _ARM_ARM64_IO_H
 #define _ARM_ARM64_IO_H
 
+#include <asm/system.h>
 #include <asm/byteorder.h>
 
 /*
@@ -109,4 +110,21 @@ static inline u64 __raw_readq(const volatile void __iomem *addr)
 #define writel(v,c)             ({ __iowmb(); writel_relaxed((v),(c)); })
 #define writeq(v,c)             ({ __iowmb(); writeq_relaxed((v),(c)); })
 
+/*
+ * Emulate x86 io ports for ARM.
+ */
+static inline void __iomem * __armio(u64 addr)
+{
+    printk(XENLOG_G_WARNING "Can't access IO %lx\n", addr);
+    return (void __iomem *)addr;
+}
+
+#define inb(c) ( readb( __armio(c) ) )
+#define inw(c) ( readw( __armio(c) ) )
+#define inl(c) ( readl( __armio(c) ) )
+
+#define outb(v, c) ( writeb(v, __armio(c) ) )
+#define outw(v, c) ( writew(v, __armio(c) ) )
+#define outl(v, c) ( writel(v, __armio(c) ) )
+
 #endif /* _ARM_ARM64_IO_H */
-- 
2.0.4

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

* [PATCH v4 02/21] arm/acpi: Add arm specific acpi header file
  2016-01-23  9:19 [PATCH v4 00/21] Add ACPI support for Xen itself on ARM64 Shannon Zhao
  2016-01-23  9:19 ` [PATCH v4 01/21] arm/acpi: Emulate io ports for arm Shannon Zhao
@ 2016-01-23  9:19 ` Shannon Zhao
  2016-01-23  9:19 ` [PATCH v4 03/21] arm/acpi: Add __acpi_map_table function for ARM Shannon Zhao
                   ` (18 subsequent siblings)
  20 siblings, 0 replies; 62+ messages in thread
From: Shannon Zhao @ 2016-01-23  9:19 UTC (permalink / raw)
  To: xen-devel
  Cc: ian.campbell, stefano.stabellini, peter.huangpeng, julien.grall,
	stefano.stabellini, shannon.zhao

From: Shannon Zhao <shannon.zhao@linaro.org>

Add architecture specific definitions and calls required for acpi in new
header file.

Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
 xen/arch/arm/setup.c       |  3 +++
 xen/include/asm-arm/acpi.h | 44 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 47 insertions(+)
 create mode 100644 xen/include/asm-arm/acpi.h

diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
index e95759d..3b29904 100644
--- a/xen/arch/arm/setup.c
+++ b/xen/arch/arm/setup.c
@@ -45,11 +45,14 @@
 #include <asm/procinfo.h>
 #include <asm/setup.h>
 #include <xsm/xsm.h>
+#include <asm/acpi.h>
 
 struct bootinfo __initdata bootinfo;
 
 struct cpuinfo_arm __read_mostly boot_cpu_data;
 
+bool_t __read_mostly acpi_disabled;
+
 #ifdef CONFIG_ARM_32
 static unsigned long opt_xenheap_megabytes __initdata;
 integer_param("xenheap_megabytes", opt_xenheap_megabytes);
diff --git a/xen/include/asm-arm/acpi.h b/xen/include/asm-arm/acpi.h
new file mode 100644
index 0000000..6a037c9
--- /dev/null
+++ b/xen/include/asm-arm/acpi.h
@@ -0,0 +1,44 @@
+/*
+ *  Copyright (C) 2015, Shannon Zhao <shannon.zhao@linaro.org>
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+#ifndef _ASM_ARM_ACPI_H
+#define _ASM_ARM_ACPI_H
+
+#include <xen/init.h>
+#include <asm/page.h>
+
+#define COMPILER_DEPENDENT_INT64   long long
+#define COMPILER_DEPENDENT_UINT64  unsigned long long
+#define ACPI_MAP_MEM_ATTR          PAGE_HYPERVISOR
+
+extern bool_t acpi_disabled;
+/* Basic configuration for ACPI */
+static inline void disable_acpi(void)
+{
+    acpi_disabled = 1;
+}
+
+static inline void enable_acpi(void)
+{
+    acpi_disabled = 0;
+}
+#endif /*_ASM_ARM_ACPI_H*/
-- 
2.0.4

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

* [PATCH v4 03/21] arm/acpi: Add __acpi_map_table function for ARM
  2016-01-23  9:19 [PATCH v4 00/21] Add ACPI support for Xen itself on ARM64 Shannon Zhao
  2016-01-23  9:19 ` [PATCH v4 01/21] arm/acpi: Emulate io ports for arm Shannon Zhao
  2016-01-23  9:19 ` [PATCH v4 02/21] arm/acpi: Add arm specific acpi header file Shannon Zhao
@ 2016-01-23  9:19 ` Shannon Zhao
  2016-01-23  9:19 ` [PATCH v4 04/21] arm/acpi: Move end_boot_allocator after acpi_boot_table_init Shannon Zhao
                   ` (17 subsequent siblings)
  20 siblings, 0 replies; 62+ messages in thread
From: Shannon Zhao @ 2016-01-23  9:19 UTC (permalink / raw)
  To: xen-devel
  Cc: ian.campbell, stefano.stabellini, peter.huangpeng, julien.grall,
	stefano.stabellini, shannon.zhao

From: Shannon Zhao <shannon.zhao@linaro.org>

Implement __acpi_map_table function for ARM.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
V4: add __acpi_map_table function
---
 xen/arch/arm/Makefile        |  1 +
 xen/arch/arm/acpi/Makefile   |  1 +
 xen/arch/arm/acpi/lib.c      | 52 ++++++++++++++++++++++++++++++++++++++++++++
 xen/include/asm-arm/config.h |  2 ++
 4 files changed, 56 insertions(+)
 create mode 100644 xen/arch/arm/acpi/Makefile
 create mode 100644 xen/arch/arm/acpi/lib.c

diff --git a/xen/arch/arm/Makefile b/xen/arch/arm/Makefile
index 2f050f5..21f74ac 100644
--- a/xen/arch/arm/Makefile
+++ b/xen/arch/arm/Makefile
@@ -2,6 +2,7 @@ subdir-$(arm32) += arm32
 subdir-$(arm64) += arm64
 subdir-y += platforms
 subdir-$(arm64) += efi
+subdir-$(CONFIG_HAS_ACPI) += acpi
 
 obj-$(EARLY_PRINTK) += early_printk.o
 obj-y += cpu.o
diff --git a/xen/arch/arm/acpi/Makefile b/xen/arch/arm/acpi/Makefile
new file mode 100644
index 0000000..b5be22d
--- /dev/null
+++ b/xen/arch/arm/acpi/Makefile
@@ -0,0 +1 @@
+obj-y += lib.o
diff --git a/xen/arch/arm/acpi/lib.c b/xen/arch/arm/acpi/lib.c
new file mode 100644
index 0000000..f817fe6
--- /dev/null
+++ b/xen/arch/arm/acpi/lib.c
@@ -0,0 +1,52 @@
+/*
+ *  lib.c - Architecture-Specific Low-Level ACPI Support
+ *
+ *  Copyright (C) 2015, Shannon Zhao <shannon.zhao@linaro.org>
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+#include <xen/acpi.h>
+#include <xen/mm.h>
+#include <asm/config.h>
+
+char *__acpi_map_table(paddr_t phys, unsigned long size)
+{
+	unsigned long base, offset, mapped_size;
+	int idx;
+
+	offset = phys & (PAGE_SIZE - 1);
+	mapped_size = PAGE_SIZE - offset;
+	set_fixmap(FIX_ACPI_BEGIN, phys >> PAGE_SHIFT, PAGE_HYPERVISOR);
+	base = FIXMAP_ADDR(FIX_ACPI_BEGIN);
+
+	/*
+	 * Most cases can be covered by the below.
+	 */
+	idx = FIX_ACPI_BEGIN;
+	while (mapped_size < size) {
+		if (++idx > FIX_ACPI_END)
+			return NULL;	/* cannot handle this */
+		phys += PAGE_SIZE;
+		set_fixmap(idx, phys >> PAGE_SHIFT, PAGE_HYPERVISOR);
+		mapped_size += PAGE_SIZE;
+	}
+
+	return ((char *) base + offset);
+}
diff --git a/xen/include/asm-arm/config.h b/xen/include/asm-arm/config.h
index 1520b41..a7798cb 100644
--- a/xen/include/asm-arm/config.h
+++ b/xen/include/asm-arm/config.h
@@ -183,6 +183,8 @@
 #define FIXMAP_GICC1    4  /* Interrupt controller: CPU registers (first page) */
 #define FIXMAP_GICC2    5  /* Interrupt controller: CPU registers (second page) */
 #define FIXMAP_GICH     6  /* Interrupt controller: virtual interface control registers */
+#define FIX_ACPI_BEGIN  7  /* Start mappings of ACPI tables */
+#define FIX_ACPI_END    10 /* End mappings of ACPI tables */
 
 #define PAGE_SHIFT              12
 
-- 
2.0.4

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

* [PATCH v4 04/21] arm/acpi: Move end_boot_allocator after acpi_boot_table_init
  2016-01-23  9:19 [PATCH v4 00/21] Add ACPI support for Xen itself on ARM64 Shannon Zhao
                   ` (2 preceding siblings ...)
  2016-01-23  9:19 ` [PATCH v4 03/21] arm/acpi: Add __acpi_map_table function for ARM Shannon Zhao
@ 2016-01-23  9:19 ` Shannon Zhao
  2016-01-27 14:53   ` Stefano Stabellini
  2016-01-23  9:19 ` [PATCH v4 05/21] arm/acpi: Add basic ACPI initialization Shannon Zhao
                   ` (16 subsequent siblings)
  20 siblings, 1 reply; 62+ messages in thread
From: Shannon Zhao @ 2016-01-23  9:19 UTC (permalink / raw)
  To: xen-devel
  Cc: ian.campbell, stefano.stabellini, peter.huangpeng, julien.grall,
	stefano.stabellini, shannon.zhao

From: Shannon Zhao <shannon.zhao@linaro.org>

If ACPI is initialized after the boot allocator has ended(the system
state is not early boot), assert happens in acpi_os_zalloc_memory and
acpi_boot_table_init will fail. So it needs to move end_boot_allocator
after acpi_boot_table_init.

Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/arch/arm/setup.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
index 3b29904..0ba601e 100644
--- a/xen/arch/arm/setup.c
+++ b/xen/arch/arm/setup.c
@@ -612,8 +612,6 @@ static void __init setup_mm(unsigned long dtb_paddr, size_t dtb_size)
        allocator. */
     init_xenheap_pages(pfn_to_paddr(xenheap_mfn_start),
                        pfn_to_paddr(boot_mfn_start));
-
-    end_boot_allocator();
 }
 #else /* CONFIG_ARM_64 */
 static void __init setup_mm(unsigned long dtb_paddr, size_t dtb_size)
@@ -681,8 +679,6 @@ static void __init setup_mm(unsigned long dtb_paddr, size_t dtb_size)
 
     setup_frametable_mappings(ram_start, ram_end);
     max_page = PFN_DOWN(ram_end);
-
-    end_boot_allocator();
 }
 #endif
 
@@ -753,6 +749,8 @@ void __init start_xen(unsigned long boot_phys_offset,
 
     setup_mm(fdt_paddr, fdt_size);
 
+    end_boot_allocator();
+
     vm_init();
     dt_unflatten_host_device_tree();
 
-- 
2.0.4

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

* [PATCH v4 05/21] arm/acpi: Add basic ACPI initialization
  2016-01-23  9:19 [PATCH v4 00/21] Add ACPI support for Xen itself on ARM64 Shannon Zhao
                   ` (3 preceding siblings ...)
  2016-01-23  9:19 ` [PATCH v4 04/21] arm/acpi: Move end_boot_allocator after acpi_boot_table_init Shannon Zhao
@ 2016-01-23  9:19 ` Shannon Zhao
  2016-01-27 14:54   ` Stefano Stabellini
  2016-01-23  9:19 ` [PATCH v4 06/21] arm/acpi: Parse FADT table and get PSCI flags Shannon Zhao
                   ` (15 subsequent siblings)
  20 siblings, 1 reply; 62+ messages in thread
From: Shannon Zhao @ 2016-01-23  9:19 UTC (permalink / raw)
  To: xen-devel
  Cc: ian.campbell, stefano.stabellini, peter.huangpeng, julien.grall,
	stefano.stabellini, shannon.zhao

From: Shannon Zhao <shannon.zhao@linaro.org>

acpi_boot_table_init() will be called in start_xen to get the RSDP and
all the table pointers. With this patch, we can get ACPI boot-time
tables from firmware on ARM64.

Signed-off-by: Naresh Bhat <naresh.bhat@linaro.org>
Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/arch/arm/acpi/Makefile |  1 +
 xen/arch/arm/acpi/boot.c   | 58 ++++++++++++++++++++++++++++++++++++++++++++++
 xen/arch/arm/setup.c       |  4 ++++
 3 files changed, 63 insertions(+)
 create mode 100644 xen/arch/arm/acpi/boot.c

diff --git a/xen/arch/arm/acpi/Makefile b/xen/arch/arm/acpi/Makefile
index b5be22d..196c40a 100644
--- a/xen/arch/arm/acpi/Makefile
+++ b/xen/arch/arm/acpi/Makefile
@@ -1 +1,2 @@
 obj-y += lib.o
+obj-y += boot.o
diff --git a/xen/arch/arm/acpi/boot.c b/xen/arch/arm/acpi/boot.c
new file mode 100644
index 0000000..1570f7e
--- /dev/null
+++ b/xen/arch/arm/acpi/boot.c
@@ -0,0 +1,58 @@
+/*
+ *  ARM Specific Low-Level ACPI Boot Support
+ *
+ *  Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
+ *  Copyright (C) 2001 Jun Nakajima <jun.nakajima@intel.com>
+ *  Copyright (C) 2014, Naresh Bhat <naresh.bhat@linaro.org>
+ *  Copyright (C) 2015, Shannon Zhao <shannon.zhao@linaro.org>
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+#include <xen/init.h>
+#include <xen/acpi.h>
+
+#include <asm/acpi.h>
+
+/*
+ * 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
+ *
+ * return value: (currently ignored)
+ *	0: success
+ *	!0: failure
+ *
+ * We can parse ACPI boot-time tables such as FADT, MADT after
+ * this function is called.
+ */
+int __init acpi_boot_table_init(void)
+{
+    int error;
+
+    /* Initialize the ACPI boot-time table parser. */
+    error = acpi_table_init();
+    if ( error )
+    {
+        disable_acpi();
+        return error;
+    }
+
+    return 0;
+}
diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
index 0ba601e..c15a09d 100644
--- a/xen/arch/arm/setup.c
+++ b/xen/arch/arm/setup.c
@@ -36,6 +36,7 @@
 #include <xen/pfn.h>
 #include <xen/vmap.h>
 #include <xen/libfdt/libfdt.h>
+#include <xen/acpi.h>
 #include <asm/page.h>
 #include <asm/current.h>
 #include <asm/setup.h>
@@ -749,6 +750,9 @@ void __init start_xen(unsigned long boot_phys_offset,
 
     setup_mm(fdt_paddr, fdt_size);
 
+    /* Parse the ACPI tables for possible boot-time configuration */
+    acpi_boot_table_init();
+
     end_boot_allocator();
 
     vm_init();
-- 
2.0.4

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

* [PATCH v4 06/21] arm/acpi: Parse FADT table and get PSCI flags
  2016-01-23  9:19 [PATCH v4 00/21] Add ACPI support for Xen itself on ARM64 Shannon Zhao
                   ` (4 preceding siblings ...)
  2016-01-23  9:19 ` [PATCH v4 05/21] arm/acpi: Add basic ACPI initialization Shannon Zhao
@ 2016-01-23  9:19 ` Shannon Zhao
  2016-01-27 15:41   ` Stefano Stabellini
  2016-01-23  9:19 ` [PATCH v4 07/21] arm/acpi: Print GIC information when MADT is parsed Shannon Zhao
                   ` (14 subsequent siblings)
  20 siblings, 1 reply; 62+ messages in thread
From: Shannon Zhao @ 2016-01-23  9:19 UTC (permalink / raw)
  To: xen-devel
  Cc: ian.campbell, stefano.stabellini, peter.huangpeng, julien.grall,
	stefano.stabellini, shannon.zhao

From: Shannon Zhao <shannon.zhao@linaro.org>

There are two flags: PSCI_COMPLIANT and PSCI_USE_HVC. When set, the
former signals to the OS that the hardware 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, parse FADT to get the flags for furture
usage.

Since STAO table and the GIC version are introduced by ACPI 6.0, we will
check the version and only parse FADT table with version >= 6.0. If
firmware provides ACPI tables with ACPI version less than 6.0, OS will
be messed up with those information, so disable ACPI if we get an FADT
table with version less than 6.0.

Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
Signed-off-by: Naresh Bhat <naresh.bhat@linaro.org>
Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
V4: drop disable_acpi in acpi_parse_fadt
---
 xen/arch/arm/acpi/boot.c   | 30 ++++++++++++++++++++++++++++++
 xen/arch/arm/acpi/lib.c    | 12 ++++++++++++
 xen/include/asm-arm/acpi.h |  9 +++++++++
 3 files changed, 51 insertions(+)

diff --git a/xen/arch/arm/acpi/boot.c b/xen/arch/arm/acpi/boot.c
index 1570f7e..6b33fbe 100644
--- a/xen/arch/arm/acpi/boot.c
+++ b/xen/arch/arm/acpi/boot.c
@@ -27,9 +27,32 @@
 
 #include <xen/init.h>
 #include <xen/acpi.h>
+#include <xen/errno.h>
+#include <acpi/actables.h>
+#include <xen/mm.h>
 
 #include <asm/acpi.h>
 
+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 6.0,
+     * we only deal with ACPI 6.0 or newer revision to get GIC and SMP
+     * boot protocol configuration data, or we will disable ACPI.
+     */
+    if ( table->revision > 6
+         || (table->revision == 6 && fadt->minor_revision >= 0) )
+        return 0;
+
+    printk("Unsupported FADT revision %d.%d, should be 6.0+, will disable ACPI\n",
+            table->revision, fadt->minor_revision);
+
+    return -EINVAL;
+}
+
 /*
  * acpi_boot_table_init() called from setup_arch(), always.
  *      1. find RSDP and get its address, and then find XSDT
@@ -54,5 +77,12 @@ int __init acpi_boot_table_init(void)
         return error;
     }
 
+    if ( acpi_table_parse(ACPI_SIG_FADT, acpi_parse_fadt) )
+    {
+        /* disable ACPI if no FADT is found */
+        disable_acpi();
+        printk("Can't find FADT\n");
+    }
+
     return 0;
 }
diff --git a/xen/arch/arm/acpi/lib.c b/xen/arch/arm/acpi/lib.c
index f817fe6..a30e4e6 100644
--- a/xen/arch/arm/acpi/lib.c
+++ b/xen/arch/arm/acpi/lib.c
@@ -50,3 +50,15 @@ char *__acpi_map_table(paddr_t phys, unsigned long size)
 
 	return ((char *) base + offset);
 }
+
+/* 1 to indicate PSCI 0.2+ is implemented */
+bool_t __init acpi_psci_present(void)
+{
+    return acpi_gbl_FADT.arm_boot_flags & ACPI_FADT_PSCI_COMPLIANT;
+}
+
+/* 1 to indicate HVC is present instead of SMC as the PSCI conduit */
+bool_t __init acpi_psci_hvc_present(void)
+{
+    return acpi_gbl_FADT.arm_boot_flags & ACPI_FADT_PSCI_USE_HVC;
+}
diff --git a/xen/include/asm-arm/acpi.h b/xen/include/asm-arm/acpi.h
index 6a037c9..1ce88f8 100644
--- a/xen/include/asm-arm/acpi.h
+++ b/xen/include/asm-arm/acpi.h
@@ -31,6 +31,15 @@
 #define ACPI_MAP_MEM_ATTR          PAGE_HYPERVISOR
 
 extern bool_t acpi_disabled;
+
+#ifdef CONFIG_ACPI
+bool_t __init acpi_psci_present(void);
+bool_t __init acpi_psci_hvc_present(void);
+#else
+static inline bool_t acpi_psci_present(void) { return false; }
+static inline bool_t acpi_psci_hvc_present(void) {return false; }
+#endif /* CONFIG_ACPI */
+
 /* Basic configuration for ACPI */
 static inline void disable_acpi(void)
 {
-- 
2.0.4

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

* [PATCH v4 07/21] arm/acpi: Print GIC information when MADT is parsed
  2016-01-23  9:19 [PATCH v4 00/21] Add ACPI support for Xen itself on ARM64 Shannon Zhao
                   ` (5 preceding siblings ...)
  2016-01-23  9:19 ` [PATCH v4 06/21] arm/acpi: Parse FADT table and get PSCI flags Shannon Zhao
@ 2016-01-23  9:19 ` Shannon Zhao
  2016-01-25 14:49   ` Jan Beulich
  2016-01-27 16:50   ` Stefano Stabellini
  2016-01-23  9:20 ` [PATCH v4 08/21] arm/acpi: Parse MADT to map logical cpu to MPIDR and get cpu_possible_map Shannon Zhao
                   ` (13 subsequent siblings)
  20 siblings, 2 replies; 62+ messages in thread
From: Shannon Zhao @ 2016-01-23  9:19 UTC (permalink / raw)
  To: xen-devel
  Cc: ian.campbell, stefano.stabellini, peter.huangpeng, julien.grall,
	stefano.stabellini, shannon.zhao

From: Shannon Zhao <shannon.zhao@linaro.org>

When MADT is parsed, print GIC information to make the boot log look
pretty.

Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
Signed-off-by: Tomasz Nowicki <tomasz.nowicki@linaro.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
V4: use PRIx64 instead of %llx
---
 xen/drivers/acpi/tables.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/xen/drivers/acpi/tables.c b/xen/drivers/acpi/tables.c
index 4e590de..84a290f 100644
--- a/xen/drivers/acpi/tables.c
+++ b/xen/drivers/acpi/tables.c
@@ -189,6 +189,28 @@ void __init 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;
+			printk(KERN_INFO PREFIX
+			       "GICC (acpi_id[0x%04x] address[0x%"PRIx64"] MPIDR[0x%"PRIx64"] %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;
+			printk(KERN_INFO PREFIX
+			       "GIC Distributor (gic_id[0x%04x] address[0x%"PRIx64"] gsi_base[%d])\n",
+			       p->gic_id, p->base_address, p->global_irq_base);
+		}
+		break;
+
 	default:
 		printk(KERN_WARNING PREFIX
 		       "Found unsupported MADT entry (type = %#x)\n",
-- 
2.0.4

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

* [PATCH v4 08/21] arm/acpi: Parse MADT to map logical cpu to MPIDR and get cpu_possible_map
  2016-01-23  9:19 [PATCH v4 00/21] Add ACPI support for Xen itself on ARM64 Shannon Zhao
                   ` (6 preceding siblings ...)
  2016-01-23  9:19 ` [PATCH v4 07/21] arm/acpi: Print GIC information when MADT is parsed Shannon Zhao
@ 2016-01-23  9:20 ` Shannon Zhao
  2016-01-25 14:53   ` Jan Beulich
  2016-01-28 10:40   ` Stefano Stabellini
  2016-01-23  9:20 ` [PATCH v4 09/21] arm/acpi: Add ACPI support for SMP initialization Shannon Zhao
                   ` (12 subsequent siblings)
  20 siblings, 2 replies; 62+ messages in thread
From: Shannon Zhao @ 2016-01-23  9:20 UTC (permalink / raw)
  To: xen-devel
  Cc: ian.campbell, stefano.stabellini, peter.huangpeng, julien.grall,
	stefano.stabellini, shannon.zhao, Jan Beulich

From: Parth Dixit <parth.dixit@linaro.org>

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.

Move BAD_MADT_ENTRY to common place.

Cc: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
Signed-off-by: Tomasz Nowicki <tomasz.nowicki@linaro.org>
Signed-off-by: Naresh Bhat <naresh.bhat@linaro.org>
Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
V4: fix coding style and address some comments
---
 xen/arch/arm/acpi/boot.c   | 129 +++++++++++++++++++++++++++++++++++++++++++++
 xen/arch/x86/acpi/boot.c   |   4 --
 xen/include/asm-arm/acpi.h |   2 +
 xen/include/xen/acpi.h     |   4 ++
 4 files changed, 135 insertions(+), 4 deletions(-)

diff --git a/xen/arch/arm/acpi/boot.c b/xen/arch/arm/acpi/boot.c
index 6b33fbe..c9135f2 100644
--- a/xen/arch/arm/acpi/boot.c
+++ b/xen/arch/arm/acpi/boot.c
@@ -32,6 +32,135 @@
 #include <xen/mm.h>
 
 #include <asm/acpi.h>
+#include <asm/smp.h>
+
+/* Processors with enabled flag and sane MPIDR */
+static unsigned int enabled_cpus;
+
+/* Boot CPU is valid or not in MADT */
+static bool_t __initdata bootcpu_valid;
+
+/* total number of cpus in this system */
+static unsigned int __initdata total_cpus;
+
+/*
+ * acpi_map_gic_cpu_interface - generates a logical cpu number
+ * and map to MPIDR represented by GICC structure
+ */
+static void __init
+acpi_map_gic_cpu_interface(struct acpi_madt_generic_interrupt *processor)
+{
+    int i;
+    u64 mpidr = processor->arm_mpidr & MPIDR_HWID_MASK;
+    bool_t enabled = !!(processor->flags & ACPI_MADT_ENABLED);
+
+    if ( mpidr == MPIDR_INVALID )
+    {
+        printk("Skip MADT cpu entry with invalid MPIDR\n");
+        return;
+    }
+
+    total_cpus++;
+    if ( !enabled )
+        return;
+
+    if ( enabled_cpus >=  NR_CPUS )
+    {
+        printk("NR_CPUS limit of %d reached, Processor %d/0x%"PRIx64" ignored.\n",
+               NR_CPUS, total_cpus, mpidr);
+        return;
+    }
+
+    /* Check if GICC structure of boot CPU is available in the MADT */
+    if ( cpu_logical_map(0) == mpidr )
+    {
+        if ( bootcpu_valid )
+        {
+            printk("Firmware bug, duplicate CPU MPIDR: 0x%"PRIx64" in MADT\n",
+                   mpidr);
+            return;
+        }
+
+        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 )
+        {
+            printk("Firmware bug, duplicate CPU MPIDR: 0x%"PRIx64" in MADT\n",
+                   mpidr);
+            return;
+        }
+    }
+
+    if ( !acpi_psci_present() )
+        return;
+
+    /* CPU 0 was already initialized */
+    if ( enabled_cpus )
+    {
+        if ( arch_cpu_init(enabled_cpus, NULL) < 0 )
+            return;
+
+        /* map the logical cpu id to cpu MPIDR */
+        cpu_logical_map(enabled_cpus) = mpidr;
+    }
+
+    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 =
+               container_of(header, 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);
+    return 0;
+}
+
+/* Parse GIC cpu interface entries in MADT for SMP init */
+void __init acpi_smp_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 <= 0 )
+    {
+        printk("Error parsing GIC CPU interface entry\n");
+        return;
+    }
+
+    if ( !bootcpu_valid )
+    {
+        printk("MADT missing boot CPU MPIDR, not enabling secondaries\n");
+        return;
+    }
+
+    for ( i = 0; i < enabled_cpus; i++ )
+        cpumask_set_cpu(i, &cpu_possible_map);
+
+    /* Make boot-up look pretty */
+    printk("%d CPUs enabled, %d CPUs total\n", enabled_cpus, total_cpus);
+}
 
 static int __init acpi_parse_fadt(struct acpi_table_header *table)
 {
diff --git a/xen/arch/x86/acpi/boot.c b/xen/arch/x86/acpi/boot.c
index fac36c6..385c0be 100644
--- a/xen/arch/x86/acpi/boot.c
+++ b/xen/arch/x86/acpi/boot.c
@@ -43,10 +43,6 @@
 #include <mach_apic.h>
 #include <mach_mpparse.h>
 
-#define BAD_MADT_ENTRY(entry, end) (					    \
-		(!entry) || (unsigned long)entry + sizeof(*entry) > end ||  \
-		((struct acpi_subtable_header *)entry)->length != sizeof(*entry))
-
 #define PREFIX			"ACPI: "
 
 bool_t __initdata acpi_noirq;	/* skip ACPI IRQ initialization */
diff --git a/xen/include/asm-arm/acpi.h b/xen/include/asm-arm/acpi.h
index 1ce88f8..89d17e8 100644
--- a/xen/include/asm-arm/acpi.h
+++ b/xen/include/asm-arm/acpi.h
@@ -35,9 +35,11 @@ extern bool_t acpi_disabled;
 #ifdef CONFIG_ACPI
 bool_t __init acpi_psci_present(void);
 bool_t __init acpi_psci_hvc_present(void);
+void __init acpi_smp_init_cpus(void);
 #else
 static inline bool_t acpi_psci_present(void) { return false; }
 static inline bool_t acpi_psci_hvc_present(void) {return false; }
+static inline void acpi_smp_init_cpus(void) { }
 #endif /* CONFIG_ACPI */
 
 /* Basic configuration for ACPI */
diff --git a/xen/include/xen/acpi.h b/xen/include/xen/acpi.h
index 65e53a6..bc73310 100644
--- a/xen/include/xen/acpi.h
+++ b/xen/include/xen/acpi.h
@@ -39,6 +39,10 @@
 #define ACPI_MADT_GET_POLARITY(inti)	ACPI_MADT_GET_(POLARITY, inti)
 #define ACPI_MADT_GET_TRIGGER(inti)	ACPI_MADT_GET_(TRIGGER, inti)
 
+#define BAD_MADT_ENTRY(entry, end) (                                        \
+                (!entry) || (unsigned long)entry + sizeof(*entry) > end ||  \
+                ((struct acpi_subtable_header *)entry)->length < sizeof(*entry))
+
 #ifdef CONFIG_ACPI_BOOT
 
 enum acpi_interrupt_id {
-- 
2.0.4

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

* [PATCH v4 09/21] arm/acpi: Add ACPI support for SMP initialization
  2016-01-23  9:19 [PATCH v4 00/21] Add ACPI support for Xen itself on ARM64 Shannon Zhao
                   ` (7 preceding siblings ...)
  2016-01-23  9:20 ` [PATCH v4 08/21] arm/acpi: Parse MADT to map logical cpu to MPIDR and get cpu_possible_map Shannon Zhao
@ 2016-01-23  9:20 ` Shannon Zhao
  2016-01-28 10:56   ` Stefano Stabellini
  2016-01-23  9:20 ` [PATCH v4 10/21] acpi/table: Introduce acpi_table_get_entry_madt to get specified entry Shannon Zhao
                   ` (11 subsequent siblings)
  20 siblings, 1 reply; 62+ messages in thread
From: Shannon Zhao @ 2016-01-23  9:20 UTC (permalink / raw)
  To: xen-devel
  Cc: ian.campbell, stefano.stabellini, peter.huangpeng, julien.grall,
	stefano.stabellini, shannon.zhao

From: Shannon Zhao <shannon.zhao@linaro.org>

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.

ACPI only supports PSCI 0.2+, since prior to PSCI 0.2 function IDs are
not well-defined.

Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
V4: explain why only support PSCI 0.2+ and print an error message for
    PSCI 0.1 and SMC not present
---

 xen/arch/arm/arm64/smpboot.c |  7 ++++++-
 xen/arch/arm/psci.c          | 35 ++++++++++++++++++++++++++++-------
 xen/arch/arm/smpboot.c       |  7 ++++++-
 3 files changed, 40 insertions(+), 9 deletions(-)

diff --git a/xen/arch/arm/arm64/smpboot.c b/xen/arch/arm/arm64/smpboot.c
index 7928f69..4fd0ac6 100644
--- a/xen/arch/arm/arm64/smpboot.c
+++ b/xen/arch/arm/arm64/smpboot.c
@@ -7,6 +7,7 @@
 #include <xen/vmap.h>
 #include <asm/io.h>
 #include <asm/psci.h>
+#include <asm/acpi.h>
 
 struct smp_enable_ops {
         int             (*prepare_cpu)(int);
@@ -96,7 +97,11 @@ static int __init dt_arch_cpu_init(int cpu, struct dt_device_node *dn)
 
 int __init arch_cpu_init(int cpu, struct dt_device_node *dn)
 {
-    return dt_arch_cpu_init(cpu, dn);
+    if ( acpi_disabled )
+        return dt_arch_cpu_init(cpu, dn);
+    else
+        /* acpi only supports psci at present */
+        return smp_psci_init(cpu);
 }
 
 int __init arch_cpu_up(int cpu)
diff --git a/xen/arch/arm/psci.c b/xen/arch/arm/psci.c
index d800cb6..7966b5e 100644
--- a/xen/arch/arm/psci.c
+++ b/xen/arch/arm/psci.c
@@ -22,6 +22,7 @@
 #include <xen/mm.h>
 #include <xen/smp.h>
 #include <asm/psci.h>
+#include <asm/acpi.h>
 
 /*
  * While a 64-bit OS can make calls with SMC32 calling conventions, for
@@ -86,6 +87,12 @@ int __init psci_init_0_1(void)
     int ret;
     const struct dt_device_node *psci;
 
+    if ( !acpi_disabled )
+    {
+        printk("PSCI 0.1 is not supported when using ACPI\n");
+        return -EINVAL;
+    }
+
     psci = dt_find_compatible_node(NULL, NULL, "arm,psci");
     if ( !psci )
         return -EOPNOTSUPP;
@@ -116,15 +123,26 @@ int __init psci_init_0_2(void)
         { /* sentinel */ },
     };
     int ret;
-    const struct dt_device_node *psci;
 
-    psci = dt_find_matching_node(NULL, psci_ids);
-    if ( !psci )
-        return -EOPNOTSUPP;
+    if ( acpi_disabled )
+    {
+        const struct dt_device_node *psci;
 
-    ret = psci_is_smc_method(psci);
-    if ( ret )
-        return -EINVAL;
+        psci = dt_find_matching_node(NULL, psci_ids);
+        if ( !psci )
+            return -EOPNOTSUPP;
+
+        ret = psci_is_smc_method(psci);
+        if ( ret )
+            return -EINVAL;
+    }
+    else
+    {
+        if ( acpi_psci_hvc_present() ) {
+            printk("PSCI conduit must be SMC, but is HVC\n");
+            return -EINVAL;
+        }
+    }
 
     psci_ver = call_smc(PSCI_0_2_FN_PSCI_VERSION, 0, 0, 0);
 
@@ -148,6 +166,9 @@ int __init psci_init(void)
 {
     int ret;
 
+    if ( !acpi_disabled && !acpi_psci_present() )
+        return -EOPNOTSUPP;
+
     ret = psci_init_0_2();
     if ( ret )
         ret = psci_init_0_1();
diff --git a/xen/arch/arm/smpboot.c b/xen/arch/arm/smpboot.c
index b6119d1..c5109bf 100644
--- a/xen/arch/arm/smpboot.c
+++ b/xen/arch/arm/smpboot.c
@@ -31,6 +31,7 @@
 #include <xen/console.h>
 #include <asm/gic.h>
 #include <asm/psci.h>
+#include <asm/acpi.h>
 
 cpumask_t cpu_online_map;
 cpumask_t cpu_present_map;
@@ -247,7 +248,11 @@ void __init smp_init_cpus(void)
         return;
     }
 
-    dt_smp_init_cpus();
+    if ( acpi_disabled )
+        dt_smp_init_cpus();
+    else
+        acpi_smp_init_cpus();
+
 }
 
 int __init
-- 
2.0.4

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

* [PATCH v4 10/21] acpi/table: Introduce acpi_table_get_entry_madt to get specified entry
  2016-01-23  9:19 [PATCH v4 00/21] Add ACPI support for Xen itself on ARM64 Shannon Zhao
                   ` (8 preceding siblings ...)
  2016-01-23  9:20 ` [PATCH v4 09/21] arm/acpi: Add ACPI support for SMP initialization Shannon Zhao
@ 2016-01-23  9:20 ` Shannon Zhao
  2016-01-25 15:02   ` Jan Beulich
  2016-01-23  9:20 ` [PATCH v4 11/21] arm: Introduce a generic way to use a device from acpi Shannon Zhao
                   ` (10 subsequent siblings)
  20 siblings, 1 reply; 62+ messages in thread
From: Shannon Zhao @ 2016-01-23  9:20 UTC (permalink / raw)
  To: xen-devel
  Cc: ian.campbell, stefano.stabellini, peter.huangpeng, julien.grall,
	stefano.stabellini, shannon.zhao, Jan Beulich

From: Shannon Zhao <shannon.zhao@linaro.org>

This function could get the specified index entry of MADT table. This
would be useful when it needs to get the contens of the entry.

Cc: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
V4: Fix coding style and make the function only for MADT table
---
 xen/drivers/acpi/tables.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++
 xen/include/xen/acpi.h    |  2 ++
 2 files changed, 61 insertions(+)

diff --git a/xen/drivers/acpi/tables.c b/xen/drivers/acpi/tables.c
index 84a290f..c50bae4 100644
--- a/xen/drivers/acpi/tables.c
+++ b/xen/drivers/acpi/tables.c
@@ -219,6 +219,65 @@ void __init acpi_table_print_madt_entry(struct acpi_subtable_header *header)
 	}
 }
 
+static struct acpi_subtable_header * __init
+acpi_get_entry(char *id, unsigned long table_size,
+	       struct acpi_table_header *table_header, int entry_id,
+	       unsigned int entry_index)
+{
+	struct acpi_subtable_header *entry;
+	int count = 0;
+	unsigned long table_end;
+
+	if (!table_size)
+		return NULL;
+
+	if (!table_header) {
+		printk(KERN_WARNING PREFIX "%4.4s not present\n", id);
+		return NULL;
+	}
+
+	table_end = (unsigned long)table_header + table_header->length;
+
+	/* Parse all entries looking for a match. */
+	entry = (struct acpi_subtable_header *)
+	    ((unsigned long)table_header + table_size);
+
+	while (((unsigned long)entry) + sizeof(struct acpi_subtable_header) <
+	       table_end) {
+		if (entry->length < sizeof(*entry)) {
+			printk(KERN_ERR PREFIX "[%4.4s:%#x] Invalid length\n",
+			       id, entry_id);
+			return NULL;
+		}
+
+		if (entry->type == entry_id) {
+			if (count == entry_index)
+				return entry;
+			count++;
+		}
+
+		entry = (struct acpi_subtable_header *)
+		    ((unsigned long)entry + entry->length);
+	}
+
+	return NULL;
+}
+
+struct acpi_subtable_header * __init
+acpi_table_get_entry_madt(enum acpi_madt_type id, unsigned int entry_index)
+{
+	struct acpi_table_header *table_header = NULL;
+
+	acpi_get_table(ACPI_SIG_MADT, acpi_apic_instance, &table_header);
+	if (!table_header) {
+		printk(KERN_WARNING PREFIX "%4.4s not present\n",
+		       ACPI_SIG_MADT);
+		return NULL;
+	}
+
+	return acpi_get_entry(ACPI_SIG_MADT, sizeof(struct acpi_table_madt),
+			      table_header, id, entry_index);
+}
 
 int __init
 acpi_parse_entries(char *id, unsigned long table_size,
diff --git a/xen/include/xen/acpi.h b/xen/include/xen/acpi.h
index bc73310..32d7a4f 100644
--- a/xen/include/xen/acpi.h
+++ b/xen/include/xen/acpi.h
@@ -74,6 +74,8 @@ int acpi_parse_entries(char *id, unsigned long table_size,
 		       int entry_id, unsigned int max_entries);
 int acpi_table_parse_entries(char *id, unsigned long table_size,
 	int entry_id, acpi_table_entry_handler handler, unsigned int max_entries);
+struct acpi_subtable_header *acpi_table_get_entry_madt(enum acpi_madt_type id,
+						      unsigned int entry_index);
 int acpi_table_parse_madt(enum acpi_madt_type id, acpi_table_entry_handler handler, unsigned int max_entries);
 int acpi_table_parse_srat(int id, acpi_madt_entry_handler handler,
 	unsigned int max_entries);
-- 
2.0.4

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

* [PATCH v4 11/21] arm: Introduce a generic way to use a device from acpi
  2016-01-23  9:19 [PATCH v4 00/21] Add ACPI support for Xen itself on ARM64 Shannon Zhao
                   ` (9 preceding siblings ...)
  2016-01-23  9:20 ` [PATCH v4 10/21] acpi/table: Introduce acpi_table_get_entry_madt to get specified entry Shannon Zhao
@ 2016-01-23  9:20 ` Shannon Zhao
  2016-01-28 12:45   ` Stefano Stabellini
  2016-01-23  9:20 ` [PATCH v4 12/21] arm/irq: Drop the DT prefix of the irq line type Shannon Zhao
                   ` (9 subsequent siblings)
  20 siblings, 1 reply; 62+ messages in thread
From: Shannon Zhao @ 2016-01-23  9:20 UTC (permalink / raw)
  To: xen-devel
  Cc: ian.campbell, stefano.stabellini, peter.huangpeng, julien.grall,
	stefano.stabellini, shannon.zhao

From: Parth Dixit <parth.dixit@linaro.org>

Add generic way to use device from acpi similar to the way it is
supported in device tree.

Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
V4: drop __attribute__ 
---
 xen/arch/arm/device.c        | 18 ++++++++++++++++++
 xen/arch/arm/xen.lds.S       |  7 +++++++
 xen/include/asm-arm/device.h | 30 ++++++++++++++++++++++++++++++
 3 files changed, 55 insertions(+)

diff --git a/xen/arch/arm/device.c b/xen/arch/arm/device.c
index 0b53f6a..a0072c1 100644
--- a/xen/arch/arm/device.c
+++ b/xen/arch/arm/device.c
@@ -22,6 +22,7 @@
 #include <xen/lib.h>
 
 extern const struct device_desc _sdevice[], _edevice[];
+extern const struct acpi_device_desc _asdevice[], _aedevice[];
 
 int __init device_init(struct dt_device_node *dev, enum device_class class,
                        const void *data)
@@ -50,6 +51,23 @@ int __init device_init(struct dt_device_node *dev, enum device_class class,
     return -EBADF;
 }
 
+int __init acpi_device_init(enum device_class class, const void *data, int class_type)
+{
+    const struct acpi_device_desc *desc;
+
+    for ( desc = _asdevice; desc != _aedevice; desc++ )
+    {
+        if ( ( desc->class != class ) || ( desc->class_type != class_type ) )
+            continue;
+
+        ASSERT(desc->init != NULL);
+
+        return desc->init(data);
+    }
+
+    return -EBADF;
+}
+
 enum device_class device_get_class(const struct dt_device_node *dev)
 {
     const struct device_desc *desc;
diff --git a/xen/arch/arm/xen.lds.S b/xen/arch/arm/xen.lds.S
index 0488f37..60802f6 100644
--- a/xen/arch/arm/xen.lds.S
+++ b/xen/arch/arm/xen.lds.S
@@ -100,6 +100,13 @@ SECTIONS
       _edevice = .;
   } :text
 
+  . = ALIGN(8);
+  .adev.info : {
+      _asdevice = .;
+      *(.adev.info)
+      _aedevice = .;
+  } :text
+
   . = ALIGN(PAGE_SIZE);             /* Init code and data */
   __init_begin = .;
   .init.text : {
diff --git a/xen/include/asm-arm/device.h b/xen/include/asm-arm/device.h
index b455bdf..6734ae8 100644
--- a/xen/include/asm-arm/device.h
+++ b/xen/include/asm-arm/device.h
@@ -50,6 +50,27 @@ struct device_desc {
     int (*init)(struct dt_device_node *dev, const void *data);
 };
 
+struct acpi_device_desc {
+    /* Device name */
+    const char *name;
+    /* Device class */
+    enum device_class class;
+    /* type of device supported by the driver */
+    const int class_type;
+    /* Device initialization */
+    int (*init)(const void *data);
+};
+
+/**
+ *  acpi_device_init - Initialize a device
+ *  @class: class of the device (serial, network...)
+ *  @data: specific data for initializing the device
+ *
+ *  Return 0 on success.
+ */
+int __init acpi_device_init(enum device_class class,
+                            const void *data, int class_type);
+
 /**
  *  device_init - Initialize a device
  *  @dev: device to initialize
@@ -78,6 +99,15 @@ __section(".dev.info") = {                                          \
 #define DT_DEVICE_END                                               \
 };
 
+#define ACPI_DEVICE_START(_name, _namestr, _class)                    \
+static const struct acpi_device_desc __dev_desc_##_name __used           \
+__section(".adev.info") = {                       \
+    .name = _namestr,                                               \
+    .class = _class,                                                \
+
+#define ACPI_DEVICE_END                                               \
+};
+
 #endif /* __ASM_ARM_DEVICE_H */
 
 /*
-- 
2.0.4

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

* [PATCH v4 12/21] arm/irq: Drop the DT prefix of the irq line type
  2016-01-23  9:19 [PATCH v4 00/21] Add ACPI support for Xen itself on ARM64 Shannon Zhao
                   ` (10 preceding siblings ...)
  2016-01-23  9:20 ` [PATCH v4 11/21] arm: Introduce a generic way to use a device from acpi Shannon Zhao
@ 2016-01-23  9:20 ` Shannon Zhao
  2016-01-28 12:48   ` Stefano Stabellini
  2016-01-23  9:20 ` [PATCH v4 13/21] arm/gic-v2: Add ACPI boot support for GICv2 Shannon Zhao
                   ` (8 subsequent siblings)
  20 siblings, 1 reply; 62+ messages in thread
From: Shannon Zhao @ 2016-01-23  9:20 UTC (permalink / raw)
  To: xen-devel
  Cc: ian.campbell, stefano.stabellini, peter.huangpeng, julien.grall,
	stefano.stabellini, shannon.zhao

From: Shannon Zhao <shannon.zhao@linaro.org>

Make these types generic to DT and ACPI. So they are can be used in ACPI
codes.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/arch/arm/domain_build.c   | 10 ++++-----
 xen/arch/arm/gic-hip04.c      | 10 ++++-----
 xen/arch/arm/gic-v2.c         | 10 ++++-----
 xen/arch/arm/gic-v3.c         |  8 +++----
 xen/arch/arm/gic.c            |  4 ++--
 xen/arch/arm/irq.c            |  8 +++----
 xen/arch/arm/time.c           |  2 +-
 xen/include/xen/device_tree.h | 50 +++++++++++++++++++++----------------------
 8 files changed, 51 insertions(+), 51 deletions(-)

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 0f0f53e..83676e4 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -650,7 +650,7 @@ static int make_hypervisor_node(const struct kernel_info *kinfo,
      * Placeholder for the event channel interrupt.  The values will be
      * replaced later.
      */
-    set_interrupt_ppi(intr, ~0, 0xf, DT_IRQ_TYPE_INVALID);
+    set_interrupt_ppi(intr, ~0, 0xf, IRQ_TYPE_INVALID);
     res = fdt_property_interrupts(fdt, &intr, 1);
     if ( res )
         return res;
@@ -923,15 +923,15 @@ static int make_timer_node(const struct domain *d, void *fdt,
 
     irq = timer_get_irq(TIMER_PHYS_SECURE_PPI);
     DPRINT("  Secure interrupt %u\n", irq);
-    set_interrupt_ppi(intrs[0], irq, 0xf, DT_IRQ_TYPE_LEVEL_LOW);
+    set_interrupt_ppi(intrs[0], irq, 0xf, IRQ_TYPE_LEVEL_LOW);
 
     irq = timer_get_irq(TIMER_PHYS_NONSECURE_PPI);
     DPRINT("  Non secure interrupt %u\n", irq);
-    set_interrupt_ppi(intrs[1], irq, 0xf, DT_IRQ_TYPE_LEVEL_LOW);
+    set_interrupt_ppi(intrs[1], irq, 0xf, IRQ_TYPE_LEVEL_LOW);
 
     irq = timer_get_irq(TIMER_VIRT_PPI);
     DPRINT("  Virt interrupt %u\n", irq);
-    set_interrupt_ppi(intrs[2], irq, 0xf, DT_IRQ_TYPE_LEVEL_LOW);
+    set_interrupt_ppi(intrs[2], irq, 0xf, IRQ_TYPE_LEVEL_LOW);
 
     res = fdt_property_interrupts(fdt, intrs, 3);
     if ( res )
@@ -1463,7 +1463,7 @@ static void evtchn_fixup(struct domain *d, struct kernel_info *kinfo)
      *  TODO: Handle properly the cpumask
      */
     set_interrupt_ppi(intr, d->arch.evtchn_irq, 0xf,
-                      DT_IRQ_TYPE_LEVEL_LOW);
+                      IRQ_TYPE_LEVEL_LOW);
     res = fdt_setprop_inplace(kinfo->fdt, node, "interrupts",
                               &intr, sizeof(intr));
     if ( res )
diff --git a/xen/arch/arm/gic-hip04.c b/xen/arch/arm/gic-hip04.c
index a42cf24..395360b 100644
--- a/xen/arch/arm/gic-hip04.c
+++ b/xen/arch/arm/gic-hip04.c
@@ -224,16 +224,16 @@ static void hip04gic_set_irq_properties(struct irq_desc *desc,
     unsigned int irq = desc->irq;
     unsigned int type = desc->arch.type;
 
-    ASSERT(type != DT_IRQ_TYPE_INVALID);
+    ASSERT(type != IRQ_TYPE_INVALID);
     ASSERT(spin_is_locked(&desc->lock));
 
     spin_lock(&gicv2.lock);
     /* Set edge / level */
     cfg = readl_gicd(GICD_ICFGR + (irq / 16) * 4);
     edgebit = 2u << (2 * (irq % 16));
-    if ( type & DT_IRQ_TYPE_LEVEL_MASK )
+    if ( type & IRQ_TYPE_LEVEL_MASK )
         cfg &= ~edgebit;
-    else if ( type & DT_IRQ_TYPE_EDGE_BOTH )
+    else if ( type & IRQ_TYPE_EDGE_BOTH )
         cfg |= edgebit;
     writel_gicd(cfg, GICD_ICFGR + (irq / 16) * 4);
 
@@ -247,8 +247,8 @@ static void hip04gic_set_irq_properties(struct irq_desc *desc,
                cfg & edgebit ? "Edge" : "Level",
                actual & edgebit ? "Edge" : "Level");
         desc->arch.type = actual & edgebit ?
-            DT_IRQ_TYPE_EDGE_RISING :
-            DT_IRQ_TYPE_LEVEL_HIGH;
+            IRQ_TYPE_EDGE_RISING :
+            IRQ_TYPE_LEVEL_HIGH;
     }
 
     /* Set target CPU mask (RAZ/WI on uniprocessor) */
diff --git a/xen/arch/arm/gic-v2.c b/xen/arch/arm/gic-v2.c
index 3fb5823..668b863 100644
--- a/xen/arch/arm/gic-v2.c
+++ b/xen/arch/arm/gic-v2.c
@@ -209,16 +209,16 @@ static void gicv2_set_irq_properties(struct irq_desc *desc,
     unsigned int irq = desc->irq;
     unsigned int type = desc->arch.type;
 
-    ASSERT(type != DT_IRQ_TYPE_INVALID);
+    ASSERT(type != IRQ_TYPE_INVALID);
     ASSERT(spin_is_locked(&desc->lock));
 
     spin_lock(&gicv2.lock);
     /* Set edge / level */
     cfg = readl_gicd(GICD_ICFGR + (irq / 16) * 4);
     edgebit = 2u << (2 * (irq % 16));
-    if ( type & DT_IRQ_TYPE_LEVEL_MASK )
+    if ( type & IRQ_TYPE_LEVEL_MASK )
         cfg &= ~edgebit;
-    else if ( type & DT_IRQ_TYPE_EDGE_BOTH )
+    else if ( type & IRQ_TYPE_EDGE_BOTH )
         cfg |= edgebit;
     writel_gicd(cfg, GICD_ICFGR + (irq / 16) * 4);
 
@@ -232,8 +232,8 @@ static void gicv2_set_irq_properties(struct irq_desc *desc,
                cfg & edgebit ? "Edge" : "Level",
                actual & edgebit ? "Edge" : "Level");
         desc->arch.type = actual & edgebit ?
-            DT_IRQ_TYPE_EDGE_RISING :
-            DT_IRQ_TYPE_LEVEL_HIGH;
+            IRQ_TYPE_EDGE_RISING :
+            IRQ_TYPE_LEVEL_HIGH;
     }
 
     /* Set target CPU mask (RAZ/WI on uniprocessor) */
diff --git a/xen/arch/arm/gic-v3.c b/xen/arch/arm/gic-v3.c
index 65a4de6..c79b0b4 100644
--- a/xen/arch/arm/gic-v3.c
+++ b/xen/arch/arm/gic-v3.c
@@ -491,9 +491,9 @@ static void gicv3_set_irq_properties(struct irq_desc *desc,
     cfg = readl_relaxed(base);
 
     edgebit = 2u << (2 * (irq % 16));
-    if ( type & DT_IRQ_TYPE_LEVEL_MASK )
+    if ( type & IRQ_TYPE_LEVEL_MASK )
         cfg &= ~edgebit;
-    else if ( type & DT_IRQ_TYPE_EDGE_BOTH )
+    else if ( type & IRQ_TYPE_EDGE_BOTH )
         cfg |= edgebit;
 
     writel_relaxed(cfg, base);
@@ -508,8 +508,8 @@ static void gicv3_set_irq_properties(struct irq_desc *desc,
                cfg & edgebit ? "Edge" : "Level",
                actual & edgebit ? "Edge" : "Level");
         desc->arch.type = actual & edgebit ?
-            DT_IRQ_TYPE_EDGE_RISING :
-            DT_IRQ_TYPE_LEVEL_HIGH;
+            IRQ_TYPE_EDGE_RISING :
+            IRQ_TYPE_LEVEL_HIGH;
     }
 
     affinity = gicv3_mpidr_to_affinity(cpu);
diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c
index 0b3f634..43e6fa2 100644
--- a/xen/arch/arm/gic.c
+++ b/xen/arch/arm/gic.c
@@ -98,7 +98,7 @@ void gic_restore_state(struct vcpu *v)
  * needs to be called with a valid cpu_mask, ie each cpu in the mask has
  * already called gic_cpu_init
  * - desc.lock must be held
- * - arch.type must be valid (i.e != DT_IRQ_TYPE_INVALID)
+ * - arch.type must be valid (i.e != IRQ_TYPE_INVALID)
  */
 static void gic_set_irq_properties(struct irq_desc *desc,
                                    const cpumask_t *cpu_mask,
@@ -223,7 +223,7 @@ int gic_irq_xlate(const u32 *intspec, unsigned int intsize,
         *out_hwirq += 16;
 
     if ( out_type )
-        *out_type = intspec[2] & DT_IRQ_TYPE_SENSE_MASK;
+        *out_type = intspec[2] & IRQ_TYPE_SENSE_MASK;
 
     return 0;
 }
diff --git a/xen/arch/arm/irq.c b/xen/arch/arm/irq.c
index d409abb..0ff5cbc 100644
--- a/xen/arch/arm/irq.c
+++ b/xen/arch/arm/irq.c
@@ -66,7 +66,7 @@ irq_desc_t *__irq_to_desc(int irq)
 
 int __init arch_init_one_irq_desc(struct irq_desc *desc)
 {
-    desc->arch.type = DT_IRQ_TYPE_INVALID;
+    desc->arch.type = IRQ_TYPE_INVALID;
     return 0;
 }
 
@@ -117,7 +117,7 @@ void __init init_IRQ(void)
 
     spin_lock(&local_irqs_type_lock);
     for ( irq = 0; irq < NR_LOCAL_IRQS; irq++ )
-        local_irqs_type[irq] = DT_IRQ_TYPE_INVALID;
+        local_irqs_type[irq] = IRQ_TYPE_INVALID;
     spin_unlock(&local_irqs_type_lock);
 
     BUG_ON(init_local_irq_data() < 0);
@@ -449,7 +449,7 @@ int route_irq_to_guest(struct domain *d, unsigned int virq,
 
     spin_lock_irqsave(&desc->lock, flags);
 
-    if ( desc->arch.type == DT_IRQ_TYPE_INVALID )
+    if ( desc->arch.type == IRQ_TYPE_INVALID )
     {
         printk(XENLOG_G_ERR "IRQ %u has not been configured\n", irq);
         retval = -EIO;
@@ -591,7 +591,7 @@ void pirq_set_affinity(struct domain *d, int pirq, const cpumask_t *mask)
 
 static bool_t irq_validate_new_type(unsigned int curr, unsigned new)
 {
-    return (curr == DT_IRQ_TYPE_INVALID || curr == new );
+    return (curr == IRQ_TYPE_INVALID || curr == new );
 }
 
 int irq_set_spi_type(unsigned int spi, unsigned int type)
diff --git a/xen/arch/arm/time.c b/xen/arch/arm/time.c
index 40f4758..73a1a3e 100644
--- a/xen/arch/arm/time.c
+++ b/xen/arch/arm/time.c
@@ -222,7 +222,7 @@ static void check_timer_irq_cfg(unsigned int irq, const char *which)
      * The interrupt controller driver will update desc->arch.type with
      * the actual type which ended up configured in the hardware.
      */
-    if ( desc->arch.type & DT_IRQ_TYPE_LEVEL_MASK )
+    if ( desc->arch.type & IRQ_TYPE_LEVEL_MASK )
         return;
 
     printk(XENLOG_WARNING
diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h
index 5c03f40..cf31e50 100644
--- a/xen/include/xen/device_tree.h
+++ b/xen/include/xen/device_tree.h
@@ -105,33 +105,33 @@ struct dt_phandle_args {
 /**
  * IRQ line type.
  *
- * DT_IRQ_TYPE_NONE            - default, unspecified type
- * DT_IRQ_TYPE_EDGE_RISING     - rising edge triggered
- * DT_IRQ_TYPE_EDGE_FALLING    - falling edge triggered
- * DT_IRQ_TYPE_EDGE_BOTH       - rising and falling edge triggered
- * DT_IRQ_TYPE_LEVEL_HIGH      - high level triggered
- * DT_IRQ_TYPE_LEVEL_LOW       - low level triggered
- * DT_IRQ_TYPE_LEVEL_MASK      - Mask to filter out the level bits
- * DT_IRQ_TYPE_SENSE_MASK      - Mask for all the above bits
- * DT_IRQ_TYPE_INVALID         - Use to initialize the type
- */
-#define DT_IRQ_TYPE_NONE           0x00000000
-#define DT_IRQ_TYPE_EDGE_RISING    0x00000001
-#define DT_IRQ_TYPE_EDGE_FALLING   0x00000002
-#define DT_IRQ_TYPE_EDGE_BOTH                           \
-    (DT_IRQ_TYPE_EDGE_FALLING | DT_IRQ_TYPE_EDGE_RISING)
-#define DT_IRQ_TYPE_LEVEL_HIGH     0x00000004
-#define DT_IRQ_TYPE_LEVEL_LOW      0x00000008
-#define DT_IRQ_TYPE_LEVEL_MASK                          \
-    (DT_IRQ_TYPE_LEVEL_LOW | DT_IRQ_TYPE_LEVEL_HIGH)
-#define DT_IRQ_TYPE_SENSE_MASK     0x0000000f
-
-#define DT_IRQ_TYPE_INVALID        0x00000010
+ * IRQ_TYPE_NONE            - default, unspecified type
+ * IRQ_TYPE_EDGE_RISING     - rising edge triggered
+ * IRQ_TYPE_EDGE_FALLING    - falling edge triggered
+ * IRQ_TYPE_EDGE_BOTH       - rising and falling edge triggered
+ * IRQ_TYPE_LEVEL_HIGH      - high level triggered
+ * IRQ_TYPE_LEVEL_LOW       - low level triggered
+ * IRQ_TYPE_LEVEL_MASK      - Mask to filter out the level bits
+ * IRQ_TYPE_SENSE_MASK      - Mask for all the above bits
+ * IRQ_TYPE_INVALID         - Use to initialize the type
+ */
+#define IRQ_TYPE_NONE           0x00000000
+#define IRQ_TYPE_EDGE_RISING    0x00000001
+#define IRQ_TYPE_EDGE_FALLING   0x00000002
+#define IRQ_TYPE_EDGE_BOTH                           \
+    (IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING)
+#define IRQ_TYPE_LEVEL_HIGH     0x00000004
+#define IRQ_TYPE_LEVEL_LOW      0x00000008
+#define IRQ_TYPE_LEVEL_MASK                          \
+    (IRQ_TYPE_LEVEL_LOW | IRQ_TYPE_LEVEL_HIGH)
+#define IRQ_TYPE_SENSE_MASK     0x0000000f
+
+#define IRQ_TYPE_INVALID        0x00000010
 
 /**
  * dt_irq - describe an IRQ in the device tree
  * @irq: IRQ number
- * @type: IRQ type (see DT_IRQ_TYPE_*)
+ * @type: IRQ type (see IRQ_TYPE_*)
  *
  * This structure is returned when an interrupt is mapped.
  */
@@ -140,12 +140,12 @@ struct dt_irq {
     unsigned int type;
 };
 
-/* If type == DT_IRQ_TYPE_NONE, assume we use level triggered */
+/* If type == IRQ_TYPE_NONE, assume we use level triggered */
 static inline bool_t dt_irq_is_level_triggered(const struct dt_irq *irq)
 {
     unsigned int type = irq->type;
 
-    return (type & DT_IRQ_TYPE_LEVEL_MASK) || (type == DT_IRQ_TYPE_NONE);
+    return (type & IRQ_TYPE_LEVEL_MASK) || (type == IRQ_TYPE_NONE);
 }
 
 /**
-- 
2.0.4

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

* [PATCH v4 13/21] arm/gic-v2: Add ACPI boot support for GICv2
  2016-01-23  9:19 [PATCH v4 00/21] Add ACPI support for Xen itself on ARM64 Shannon Zhao
                   ` (11 preceding siblings ...)
  2016-01-23  9:20 ` [PATCH v4 12/21] arm/irq: Drop the DT prefix of the irq line type Shannon Zhao
@ 2016-01-23  9:20 ` Shannon Zhao
  2016-01-28 12:56   ` Stefano Stabellini
  2016-01-23  9:20 ` [PATCH v4 14/21] arm/gic-v3: Add ACPI boot support for GICv3 Shannon Zhao
                   ` (7 subsequent siblings)
  20 siblings, 1 reply; 62+ messages in thread
From: Shannon Zhao @ 2016-01-23  9:20 UTC (permalink / raw)
  To: xen-devel
  Cc: ian.campbell, stefano.stabellini, peter.huangpeng, julien.grall,
	stefano.stabellini, shannon.zhao

From: Parth Dixit <parth.dixit@linaro.org>

ACPI on Xen hypervisor uses MADT table for proper GIC initialization.
First get the GIC version from GIC Distributor. Then 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 GICv2.

Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
V4: use container_of and fix coding style
---
 xen/arch/arm/gic-v2.c | 120 +++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 119 insertions(+), 1 deletion(-)

diff --git a/xen/arch/arm/gic-v2.c b/xen/arch/arm/gic-v2.c
index 668b863..7e46ee9 100644
--- a/xen/arch/arm/gic-v2.c
+++ b/xen/arch/arm/gic-v2.c
@@ -29,6 +29,8 @@
 #include <xen/device_tree.h>
 #include <xen/libfdt/libfdt.h>
 #include <xen/sizes.h>
+#include <xen/acpi.h>
+#include <acpi/actables.h>
 #include <asm/p2m.h>
 #include <asm/domain.h>
 #include <asm/platform.h>
@@ -36,6 +38,7 @@
 
 #include <asm/io.h>
 #include <asm/gic.h>
+#include <asm/acpi.h>
 
 /*
  * LR register definitions are GIC v2 specific.
@@ -681,11 +684,111 @@ static void __init gicv2_dt_init(void)
                csize, vsize);
 }
 
+#ifdef CONFIG_ACPI
+static int __init
+gic_acpi_parse_madt_cpu(struct acpi_subtable_header *header,
+                        const unsigned long end)
+{
+    static int cpu_base_assigned = 0;
+    struct acpi_madt_generic_interrupt *processor =
+               container_of(header, struct acpi_madt_generic_interrupt, header);
+
+    if ( BAD_MADT_ENTRY(processor, end) )
+        return -EINVAL;
+
+    /* Read from APIC table and fill up the GIC variables */
+    if ( cpu_base_assigned == 0 )
+    {
+        cbase = processor->base_address;
+        csize = SZ_8K;
+        hbase = processor->gich_base_address;
+        vbase = processor->gicv_base_address;
+        gicv2_info.maintenance_irq = processor->vgic_interrupt;
+
+        if( processor->flags & ACPI_MADT_VGIC_IRQ_MODE )
+            irq_set_type(gicv2_info.maintenance_irq, IRQ_TYPE_EDGE_BOTH);
+        else
+            irq_set_type(gicv2_info.maintenance_irq, IRQ_TYPE_LEVEL_MASK);
+
+        cpu_base_assigned = 1;
+    }
+    else
+    {
+        if ( cbase != processor->base_address
+             || hbase != processor->gich_base_address
+             || vbase != processor->gicv_base_address
+             || gicv2_info.maintenance_irq != processor->vgic_interrupt )
+        {
+            printk("GICv2: GICC entries are not same in MADT table\n");
+            return -EINVAL;
+        }
+    }
+
+    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 =
+             container_of(header, struct acpi_madt_generic_distributor, header);
+
+    if ( BAD_MADT_ENTRY(dist, end) )
+        return -EINVAL;
+
+    dbase = dist->base_address;
+
+    return 0;
+}
+
+static void __init gicv2_acpi_init(void)
+{
+    acpi_status status;
+    struct acpi_table_header *table;
+    int count;
+
+    status = acpi_get_table(ACPI_SIG_MADT, 0, &table);
+
+    if ( ACPI_FAILURE(status) )
+    {
+        const char *msg = acpi_format_exception(status);
+
+        panic("GICv2: Failed to get MADT table, %s", msg);
+    }
+
+    /* 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 )
+        panic("GICv2: No valid GICC entries exists");
+
+    /*
+     * Find distributor base address. We expect one distributor entry since
+     * ACPI 5.0 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 )
+        panic("GICv2: No valid GICD entries exists");
+}
+#else
+static void __init gicv2_acpi_init(void)
+{
+/* Should never reach here */
+}
+#endif
+
 static int __init gicv2_init(void)
 {
     uint32_t aliased_offset = 0;
 
-    gicv2_dt_init();
+    if ( acpi_disabled )
+        gicv2_dt_init();
+    else
+        gicv2_acpi_init();
 
     printk("GICv2 initialization:\n"
               "        gic_dist_addr=%"PRIpaddr"\n"
@@ -793,6 +896,21 @@ DT_DEVICE_START(gicv2, "GICv2", DEVICE_GIC)
         .init = gicv2_dt_preinit,
 DT_DEVICE_END
 
+#ifdef CONFIG_ACPI
+/* Set up the GIC */
+static int __init gicv2_acpi_preinit(const void *data)
+{
+    gicv2_info.hw_version = GIC_V2;
+    register_gic_ops(&gicv2_ops);
+
+    return 0;
+}
+
+ACPI_DEVICE_START(agicv2, "GICv2", DEVICE_GIC)
+        .class_type = ACPI_MADT_GIC_VERSION_V2,
+        .init = gicv2_acpi_preinit,
+ACPI_DEVICE_END
+#endif
 /*
  * Local variables:
  * mode: C
-- 
2.0.4

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

* [PATCH v4 14/21] arm/gic-v3: Add ACPI boot support for GICv3
  2016-01-23  9:19 [PATCH v4 00/21] Add ACPI support for Xen itself on ARM64 Shannon Zhao
                   ` (12 preceding siblings ...)
  2016-01-23  9:20 ` [PATCH v4 13/21] arm/gic-v2: Add ACPI boot support for GICv2 Shannon Zhao
@ 2016-01-23  9:20 ` Shannon Zhao
  2016-02-02 17:31   ` Stefano Stabellini
  2016-01-23  9:20 ` [PATCH v4 15/21] arm/gic: Add ACPI support for GIC preinit Shannon Zhao
                   ` (6 subsequent siblings)
  20 siblings, 1 reply; 62+ messages in thread
From: Shannon Zhao @ 2016-01-23  9:20 UTC (permalink / raw)
  To: xen-devel
  Cc: ian.campbell, stefano.stabellini, peter.huangpeng, julien.grall,
	stefano.stabellini, shannon.zhao

From: Shannon Zhao <shannon.zhao@linaro.org>

Like GICv2, ACPI on Xen hypervisor uses MADT table for proper GICv3
initialization. Parse GIC distributor subtable, redistributor subtable
and interrupt subtable.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
V4: move ioremap to common init function and fix coding style
---
 xen/arch/arm/gic-v3.c | 174 +++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 173 insertions(+), 1 deletion(-)

diff --git a/xen/arch/arm/gic-v3.c b/xen/arch/arm/gic-v3.c
index c79b0b4..5ac0b1c 100644
--- a/xen/arch/arm/gic-v3.c
+++ b/xen/arch/arm/gic-v3.c
@@ -34,6 +34,8 @@
 #include <xen/sizes.h>
 #include <xen/libfdt/libfdt.h>
 #include <xen/sort.h>
+#include <xen/acpi.h>
+#include <acpi/actables.h>
 #include <asm/p2m.h>
 #include <asm/domain.h>
 #include <asm/io.h>
@@ -41,6 +43,7 @@
 #include <asm/gic.h>
 #include <asm/gic_v3_defs.h>
 #include <asm/cpufeature.h>
+#include <asm/acpi.h>
 
 /* Global state */
 static struct {
@@ -1234,6 +1237,156 @@ static void __init gicv3_dt_init(void)
     }
 }
 
+#ifdef CONFIG_ACPI
+static int __init
+gic_acpi_parse_madt_cpu(struct acpi_subtable_header *header,
+                        const unsigned long end)
+{
+    static bool cpu_base_assigned = false;
+    struct acpi_madt_generic_interrupt *processor =
+               container_of(header, struct acpi_madt_generic_interrupt, header);
+
+    if ( BAD_MADT_ENTRY(processor, end) )
+        return -EINVAL;
+
+    /* Read from APIC table and fill up the GIC variables */
+    if ( !cpu_base_assigned )
+    {
+        cbase = processor->base_address;
+        csize = SZ_8K;
+        vbase = processor->gicv_base_address;
+        gicv3_info.maintenance_irq = processor->vgic_interrupt;
+
+        if( processor->flags & ACPI_MADT_VGIC_IRQ_MODE )
+            irq_set_type(gicv3_info.maintenance_irq, IRQ_TYPE_EDGE_BOTH);
+        else
+            irq_set_type(gicv3_info.maintenance_irq, IRQ_TYPE_LEVEL_MASK);
+
+        cpu_base_assigned = true;
+    }
+    else
+    {
+        if ( cbase != processor->base_address
+             || vbase != processor->gicv_base_address
+             || gicv3_info.maintenance_irq != processor->vgic_interrupt )
+        {
+            printk("GICv3: GICC entries are not same in MADT table\n");
+            return -EINVAL;
+        }
+    }
+
+    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 =
+             container_of(header, struct acpi_madt_generic_distributor, header);
+
+    if ( BAD_MADT_ENTRY(dist, end) )
+        return -EINVAL;
+
+    dbase = dist->base_address;
+
+    return 0;
+}
+static int __init
+gic_acpi_get_madt_redistributor_num(struct acpi_subtable_header *header,
+                                    const unsigned long end)
+{
+    /* Nothing to do here since it only wants to get the number of GIC
+     * redistributors.
+     */
+    return 0;
+}
+
+static void __init gicv3_acpi_init(void)
+{
+    struct acpi_table_header *table;
+    struct rdist_region *rdist_regs;
+    acpi_status status;
+    int count, i;
+
+    status = acpi_get_table(ACPI_SIG_MADT, 0, &table);
+
+    if ( ACPI_FAILURE(status) )
+    {
+        const char *msg = acpi_format_exception(status);
+
+        panic("GICv3: Failed to get MADT table, %s", msg);
+    }
+
+    /*
+     * Find distributor base address. We expect one distributor entry since
+     * ACPI 5.0 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 )
+        panic("GICv3: No valid GICD entries exists");
+
+    if ( (dbase & ~PAGE_MASK) )
+        panic("GICv3: Found unaligned distributor address %"PRIpaddr"",
+              dbase);
+
+    /* Get number of redistributor */
+    count = acpi_parse_entries(ACPI_SIG_MADT, sizeof(struct acpi_table_madt),
+                               gic_acpi_get_madt_redistributor_num, table,
+                               ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR, 0);
+    if ( count <= 0 )
+        panic("GICv3: No valid GICR entries exists");
+
+    gicv3.rdist_count = count;
+
+    if ( gicv3.rdist_count > MAX_RDIST_COUNT )
+        panic("GICv3: Number of redistributor regions is more than"
+              "%d (Increase MAX_RDIST_COUNT!!)\n", MAX_RDIST_COUNT);
+
+    rdist_regs = xzalloc_array(struct rdist_region, gicv3.rdist_count);
+    if ( !rdist_regs )
+        panic("GICv3: Failed to allocate memory for rdist regions\n");
+
+    for ( i = 0; i < gicv3.rdist_count; i++ )
+    {
+        struct acpi_subtable_header *header;
+        struct acpi_madt_generic_redistributor *gic_rdist;
+
+        header = acpi_table_get_entry_madt(ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR,
+                                           i);
+        if ( !header )
+            panic("GICv3: Can't get GICR entry");
+
+        gic_rdist =
+           container_of(header, struct acpi_madt_generic_redistributor, header);
+        rdist_regs[i].base = gic_rdist->base_address;
+        rdist_regs[i].size = gic_rdist->length;
+    }
+
+    /* The vGIC code requires the region to be sorted */
+    sort(rdist_regs, gicv3.rdist_count, sizeof(*rdist_regs), cmp_rdist, NULL);
+
+    gicv3.rdist_regions= rdist_regs;
+
+    /* 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 )
+        panic("GICv3: No valid GICC entries exists");
+
+    gicv3.rdist_stride = 0;
+}
+#else
+static void __init gicv3_acpi_init(void)
+{
+/* Should never reach here */
+}
+#endif
+
 /* Set up the GIC */
 static int __init gicv3_init(void)
 {
@@ -1246,7 +1399,10 @@ static int __init gicv3_init(void)
         return -ENODEV;
     }
 
-    gicv3_dt_init();
+    if ( acpi_disabled )
+        gicv3_dt_init();
+    else
+        gicv3_acpi_init();
 
     gicv3.map_dbase = ioremap_nocache(dbase, SZ_64K);
     if ( !gicv3.map_dbase )
@@ -1346,6 +1502,22 @@ DT_DEVICE_START(gicv3, "GICv3", DEVICE_GIC)
         .init = gicv3_dt_preinit,
 DT_DEVICE_END
 
+#ifdef CONFIG_ACPI
+/* Set up the GIC */
+static int __init gicv3_acpi_preinit(const void *data)
+{
+    gicv3_info.hw_version = GIC_V3;
+    register_gic_ops(&gicv3_ops);
+
+    return 0;
+}
+
+ACPI_DEVICE_START(agicv3, "GICv3", DEVICE_GIC)
+        .class_type = ACPI_MADT_GIC_VERSION_V3,
+        .init = gicv3_acpi_preinit,
+ACPI_DEVICE_END
+#endif
+
 /*
  * Local variables:
  * mode: C
-- 
2.0.4

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

* [PATCH v4 15/21] arm/gic: Add ACPI support for GIC preinit
  2016-01-23  9:19 [PATCH v4 00/21] Add ACPI support for Xen itself on ARM64 Shannon Zhao
                   ` (13 preceding siblings ...)
  2016-01-23  9:20 ` [PATCH v4 14/21] arm/gic-v3: Add ACPI boot support for GICv3 Shannon Zhao
@ 2016-01-23  9:20 ` Shannon Zhao
  2016-02-02 17:36   ` Stefano Stabellini
  2016-01-23  9:20 ` [PATCH v4 16/21] arm/irq: Add helper function for setting interrupt type Shannon Zhao
                   ` (5 subsequent siblings)
  20 siblings, 1 reply; 62+ messages in thread
From: Shannon Zhao @ 2016-01-23  9:20 UTC (permalink / raw)
  To: xen-devel
  Cc: ian.campbell, stefano.stabellini, peter.huangpeng, julien.grall,
	stefano.stabellini, shannon.zhao

From: Shannon Zhao <shannon.zhao@linaro.org>

Since ACPI 6.0 defines that GIC Distributor Structure contains the GIC
version filed, it could get GIC version from that. Then call acpi device
initializing function to preinit GIC device.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
V4: use ACPI_MADT_GIC_VERSION_V* instead of GICv*
---
 xen/arch/arm/gic.c | 37 +++++++++++++++++++++++++++++++++----
 1 file changed, 33 insertions(+), 4 deletions(-)

diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c
index 43e6fa2..840075f 100644
--- a/xen/arch/arm/gic.c
+++ b/xen/arch/arm/gic.c
@@ -27,6 +27,7 @@
 #include <xen/softirq.h>
 #include <xen/list.h>
 #include <xen/device_tree.h>
+#include <xen/acpi.h>
 #include <asm/p2m.h>
 #include <asm/domain.h>
 #include <asm/platform.h>
@@ -34,6 +35,7 @@
 #include <asm/io.h>
 #include <asm/gic.h>
 #include <asm/vgic.h>
+#include <asm/acpi.h>
 
 static void gic_restore_pending_irqs(struct vcpu *v);
 
@@ -228,10 +230,7 @@ int gic_irq_xlate(const u32 *intspec, unsigned int intsize,
     return 0;
 }
 
-/* Find the interrupt controller and set up the callback to translate
- * device tree IRQ.
- */
-void __init gic_preinit(void)
+static void __init gic_dt_preinit(void)
 {
     int rc;
     struct dt_device_node *node;
@@ -261,6 +260,36 @@ void __init gic_preinit(void)
     dt_device_set_used_by(node, DOMID_XEN);
 }
 
+#ifdef CONFIG_ACPI
+static void __init gic_acpi_preinit(void)
+{
+    struct acpi_subtable_header *header;
+    struct acpi_madt_generic_distributor *dist;
+
+    header = acpi_table_get_entry_madt(ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR, 0);
+    if ( !header )
+        panic("No valid GICD entries exists");
+
+    dist = container_of(header, struct acpi_madt_generic_distributor, header);
+
+    if ( acpi_device_init(DEVICE_GIC, NULL, dist->version) )
+        panic("Unable to find compatible GIC in the ACPI table");
+}
+#else
+static void __init gic_acpi_preinit(void) {}
+#endif
+
+/* Find the interrupt controller and set up the callback to translate
+ * device tree or ACPI IRQ.
+ */
+void __init gic_preinit(void)
+{
+    if ( acpi_disabled )
+        gic_dt_preinit();
+    else
+        gic_acpi_preinit();
+}
+
 /* Set up the GIC */
 void __init gic_init(void)
 {
-- 
2.0.4

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

* [PATCH v4 16/21] arm/irq: Add helper function for setting interrupt type
  2016-01-23  9:19 [PATCH v4 00/21] Add ACPI support for Xen itself on ARM64 Shannon Zhao
                   ` (14 preceding siblings ...)
  2016-01-23  9:20 ` [PATCH v4 15/21] arm/gic: Add ACPI support for GIC preinit Shannon Zhao
@ 2016-01-23  9:20 ` Shannon Zhao
  2016-01-23  9:20 ` [PATCH v4 17/21] arm/acpi: Parse GTDT to initialize timer Shannon Zhao
                   ` (4 subsequent siblings)
  20 siblings, 0 replies; 62+ messages in thread
From: Shannon Zhao @ 2016-01-23  9:20 UTC (permalink / raw)
  To: xen-devel
  Cc: ian.campbell, stefano.stabellini, peter.huangpeng, julien.grall,
	stefano.stabellini, shannon.zhao

From: Parth Dixit <parth.dixit@linaro.org>

Add a helper function to set edge/level type information for an
interrupt.

Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
 xen/arch/arm/irq.c        | 27 ++++++++++++++++-----------
 xen/include/asm-arm/irq.h |  2 ++
 2 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/xen/arch/arm/irq.c b/xen/arch/arm/irq.c
index 0ff5cbc..2f8af72 100644
--- a/xen/arch/arm/irq.c
+++ b/xen/arch/arm/irq.c
@@ -655,27 +655,32 @@ unlock:
     return ret;
 }
 
+int irq_set_type(unsigned int irq, unsigned int type)
+{
+    int res;
+
+    /* Setup the IRQ type */
+    if ( irq < NR_LOCAL_IRQS )
+        res = irq_local_set_type(irq, type);
+    else
+        res = irq_set_spi_type(irq, type);
+
+    return res;
+}
+
 int platform_get_irq(const struct dt_device_node *device, int index)
 {
     struct dt_irq dt_irq;
     unsigned int type, irq;
-    int res;
 
-    res = dt_device_get_irq(device, index, &dt_irq);
-    if ( res )
+    if ( dt_device_get_irq(device, index, &dt_irq) )
         return -1;
 
     irq = dt_irq.irq;
     type = dt_irq.type;
 
-    /* Setup the IRQ type */
-    if ( irq < NR_LOCAL_IRQS )
-        res = irq_local_set_type(irq, type);
-    else
-        res = irq_set_spi_type(irq, type);
-
-    if ( res )
-            return -1;
+    if ( irq_set_type(irq, type) )
+        return -1;
 
     return irq;
 }
diff --git a/xen/include/asm-arm/irq.h b/xen/include/asm-arm/irq.h
index f33c331..493773c 100644
--- a/xen/include/asm-arm/irq.h
+++ b/xen/include/asm-arm/irq.h
@@ -52,6 +52,8 @@ void arch_move_irqs(struct vcpu *v);
 /* Set IRQ type for an SPI */
 int irq_set_spi_type(unsigned int spi, unsigned int type);
 
+int irq_set_type(unsigned int irq, unsigned int type);
+
 int platform_get_irq(const struct dt_device_node *device, int index);
 
 void irq_set_affinity(struct irq_desc *desc, const cpumask_t *cpu_mask);
-- 
2.0.4

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

* [PATCH v4 17/21] arm/acpi: Parse GTDT to initialize timer
  2016-01-23  9:19 [PATCH v4 00/21] Add ACPI support for Xen itself on ARM64 Shannon Zhao
                   ` (15 preceding siblings ...)
  2016-01-23  9:20 ` [PATCH v4 16/21] arm/irq: Add helper function for setting interrupt type Shannon Zhao
@ 2016-01-23  9:20 ` Shannon Zhao
  2016-02-02 17:45   ` Stefano Stabellini
  2016-01-23  9:20 ` [PATCH v4 18/21] arm/acpi: Add a new ACPI initialized function for UART Shannon Zhao
                   ` (3 subsequent siblings)
  20 siblings, 1 reply; 62+ messages in thread
From: Shannon Zhao @ 2016-01-23  9:20 UTC (permalink / raw)
  To: xen-devel
  Cc: ian.campbell, stefano.stabellini, peter.huangpeng, julien.grall,
	stefano.stabellini, shannon.zhao

From: Shannon Zhao <shannon.zhao@linaro.org>

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

Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
V4: Factor dt parts
---
 xen/arch/arm/time.c | 82 ++++++++++++++++++++++++++++++++++++++++++++---------
 1 file changed, 68 insertions(+), 14 deletions(-)

diff --git a/xen/arch/arm/time.c b/xen/arch/arm/time.c
index 73a1a3e..4261207 100644
--- a/xen/arch/arm/time.c
+++ b/xen/arch/arm/time.c
@@ -29,6 +29,7 @@
 #include <xen/time.h>
 #include <xen/sched.h>
 #include <xen/event.h>
+#include <xen/acpi.h>
 #include <asm/system.h>
 #include <asm/time.h>
 #include <asm/gic.h>
@@ -65,8 +66,52 @@ unsigned int timer_get_irq(enum timer_ppi ppi)
 
 static __initdata struct dt_device_node *timer;
 
+#ifdef CONFIG_ACPI
+static u32 __init acpi_get_timer_irq_type(u32 flags)
+{
+    return (flags & ACPI_GTDT_INTERRUPT_MODE) ? IRQ_TYPE_EDGE_BOTH
+                                              : IRQ_TYPE_LEVEL_MASK;
+}
+
+/* Initialize per-processor generic timer */
+static int __init arch_timer_acpi_init(struct acpi_table_header *header)
+{
+    u32 irq_type;
+    struct acpi_table_gtdt *gtdt;
+
+    gtdt = container_of(header, struct acpi_table_gtdt, header);
+
+    /* Initialize all the generic timer IRQ variable from GTDT table */
+    irq_type = acpi_get_timer_irq_type(gtdt->non_secure_el1_flags);
+    irq_set_type(gtdt->non_secure_el1_interrupt, irq_type);
+    timer_irq[TIMER_PHYS_NONSECURE_PPI] = gtdt->non_secure_el1_interrupt;
+
+    irq_type = acpi_get_timer_irq_type(gtdt->secure_el1_flags);
+    irq_set_type(gtdt->secure_el1_interrupt, irq_type);
+    timer_irq[TIMER_PHYS_SECURE_PPI] = gtdt->secure_el1_interrupt;
+
+    irq_type = acpi_get_timer_irq_type(gtdt->virtual_timer_flags);
+    irq_set_type(gtdt->virtual_timer_interrupt, irq_type);
+    timer_irq[TIMER_VIRT_PPI] = gtdt->virtual_timer_interrupt;
+
+    irq_type = acpi_get_timer_irq_type(gtdt->non_secure_el2_flags);
+    irq_set_type(gtdt->non_secure_el2_interrupt, irq_type);
+    timer_irq[TIMER_HYP_PPI] = gtdt->non_secure_el2_interrupt;
+
+    return 0;
+}
+
+static void __init preinit_acpi_xen_time(void)
+{
+    acpi_table_parse(ACPI_SIG_GTDT, arch_timer_acpi_init);
+    cpu_khz = READ_SYSREG32(CNTFRQ_EL0) / 1000;
+}
+#else
+static inline void preinit_acpi_xen_time(void) { }
+#endif
+
 /* Set up the timer on the boot CPU (early init function) */
-void __init preinit_xen_time(void)
+static void __init preinit_dt_xen_time(void)
 {
     static const struct dt_device_match timer_ids[] __initconst =
     {
@@ -75,6 +120,7 @@ void __init preinit_xen_time(void)
     };
     int res;
     u32 rate;
+    unsigned int i;
 
     timer = dt_find_matching_node(NULL, timer_ids);
     if ( !timer )
@@ -82,10 +128,6 @@ void __init preinit_xen_time(void)
 
     dt_device_set_used_by(timer, DOMID_XEN);
 
-    res = platform_init_time();
-    if ( res )
-        panic("Timer: Cannot initialize platform timer");
-
     res = dt_property_read_u32(timer, "clock-frequency", &rate);
     if ( res )
     {
@@ -95,15 +137,6 @@ void __init preinit_xen_time(void)
     else
         cpu_khz = READ_SYSREG32(CNTFRQ_EL0) / 1000;
 
-    boot_count = READ_SYSREG64(CNTPCT_EL0);
-}
-
-/* Set up the timer on the boot CPU (late init function) */
-int __init init_xen_time(void)
-{
-    int res;
-    unsigned int i;
-
     /* Retrieve all IRQs for the timer */
     for ( i = TIMER_PHYS_SECURE_PPI; i < MAX_TIMER_PPI; i++ )
     {
@@ -113,7 +146,28 @@ int __init init_xen_time(void)
             panic("Timer: Unable to retrieve IRQ %u from the device tree", i);
         timer_irq[i] = res;
     }
+}
+
+void __init preinit_xen_time(void)
+{
+    int res;
 
+    /* Initialize all the generic timers presented in GTDT */
+    if ( acpi_disabled )
+        preinit_dt_xen_time();
+    else
+        preinit_acpi_xen_time();
+
+    res = platform_init_time();
+    if ( res )
+        panic("Timer: Cannot initialize platform timer");
+
+    boot_count = READ_SYSREG64(CNTPCT_EL0);
+}
+
+/* Set up the timer on the boot CPU (late init function) */
+int __init init_xen_time(void)
+{
     /* Check that this CPU supports the Generic Timer interface */
     if ( !cpu_has_gentimer )
         panic("CPU does not support the Generic Timer v1 interface");
-- 
2.0.4

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

* [PATCH v4 18/21] arm/acpi: Add a new ACPI initialized function for UART
  2016-01-23  9:19 [PATCH v4 00/21] Add ACPI support for Xen itself on ARM64 Shannon Zhao
                   ` (16 preceding siblings ...)
  2016-01-23  9:20 ` [PATCH v4 17/21] arm/acpi: Parse GTDT to initialize timer Shannon Zhao
@ 2016-01-23  9:20 ` Shannon Zhao
  2016-01-25 15:04   ` Jan Beulich
  2016-02-02 17:48   ` Stefano Stabellini
  2016-01-23  9:20 ` [PATCH v4 19/21] arm/acpi: Initialize serial port from ACPI SPCR table Shannon Zhao
                   ` (2 subsequent siblings)
  20 siblings, 2 replies; 62+ messages in thread
From: Shannon Zhao @ 2016-01-23  9:20 UTC (permalink / raw)
  To: xen-devel
  Cc: ian.campbell, stefano.stabellini, peter.huangpeng, julien.grall,
	stefano.stabellini, shannon.zhao

From: Shannon Zhao <shannon.zhao@linaro.org>

This adds a new function to initialize UART for ACPI on ARM.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/arch/arm/setup.c        |  2 +-
 xen/drivers/char/arm-uart.c | 33 +++++++++++++++++++++++++++++++--
 xen/include/xen/serial.h    |  2 +-
 3 files changed, 33 insertions(+), 4 deletions(-)

diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
index c15a09d..63feadf 100644
--- a/xen/arch/arm/setup.c
+++ b/xen/arch/arm/setup.c
@@ -766,7 +766,7 @@ void __init start_xen(unsigned long boot_phys_offset,
 
     gic_preinit();
 
-    dt_uart_init();
+    arm_uart_init();
     console_init_preirq();
     console_init_ring();
 
diff --git a/xen/drivers/char/arm-uart.c b/xen/drivers/char/arm-uart.c
index 883e615..a68959b 100644
--- a/xen/drivers/char/arm-uart.c
+++ b/xen/drivers/char/arm-uart.c
@@ -1,7 +1,7 @@
 /*
  * xen/drivers/char/arm-uart.c
  *
- * Generic uart retrieved via the device tree
+ * Generic uart retrieved via the device tree or ACPI
  *
  * Julien Grall <julien.grall@linaro.org>
  * Copyright (c) 2013 Linaro Limited.
@@ -23,6 +23,7 @@
 #include <xen/device_tree.h>
 #include <xen/serial.h>
 #include <xen/errno.h>
+#include <xen/acpi.h>
 
 /*
  * Configure UART port with a string:
@@ -35,7 +36,7 @@
 static char __initdata opt_dtuart[256] = "";
 string_param("dtuart", opt_dtuart);
 
-void __init dt_uart_init(void)
+static void __init dt_uart_init(void)
 {
     struct dt_device_node *dev;
     int ret;
@@ -96,6 +97,34 @@ void __init dt_uart_init(void)
         printk("Unable to initialize dtuart: %d\n", ret);
 }
 
+static void __init acpi_uart_init(void)
+{
+#ifdef CONFIG_ACPI
+    struct acpi_table_spcr *spcr=NULL;
+    int ret;
+
+    acpi_get_table(ACPI_SIG_SPCR, 0,(struct acpi_table_header **)&spcr);
+
+    if ( spcr == NULL )
+        printk("Unable to get spcr table\n");
+    else
+    {
+        ret = acpi_device_init(DEVICE_SERIAL, NULL, spcr->interface_type);
+
+        if ( ret )
+            printk("Unable to initialize acpi uart: %d\n", ret);
+    }
+#endif
+}
+
+void __init arm_uart_init(void)
+{
+    if ( acpi_disabled )
+        dt_uart_init();
+    else
+        acpi_uart_init();
+}
+
 /*
  * Local variables:
  * mode: C
diff --git a/xen/include/xen/serial.h b/xen/include/xen/serial.h
index 71e6ade..5e1a536 100644
--- a/xen/include/xen/serial.h
+++ b/xen/include/xen/serial.h
@@ -170,7 +170,7 @@ struct ns16550_defaults {
 void ns16550_init(int index, struct ns16550_defaults *defaults);
 void ehci_dbgp_init(void);
 
-void __init dt_uart_init(void);
+void __init arm_uart_init(void);
 
 struct physdev_dbgp_op;
 int dbgp_op(const struct physdev_dbgp_op *);
-- 
2.0.4

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

* [PATCH v4 19/21] arm/acpi: Initialize serial port from ACPI SPCR table
  2016-01-23  9:19 [PATCH v4 00/21] Add ACPI support for Xen itself on ARM64 Shannon Zhao
                   ` (17 preceding siblings ...)
  2016-01-23  9:20 ` [PATCH v4 18/21] arm/acpi: Add a new ACPI initialized function for UART Shannon Zhao
@ 2016-01-23  9:20 ` Shannon Zhao
  2016-01-25 15:05   ` Jan Beulich
  2016-02-02 17:51   ` Stefano Stabellini
  2016-01-23  9:20 ` [PATCH v4 20/21] arm/fdt: Export device_tree_for_each_node Shannon Zhao
  2016-01-23  9:20 ` [PATCH v4 21/21] arm/acpi: Add acpi parameter to enable/disable acpi Shannon Zhao
  20 siblings, 2 replies; 62+ messages in thread
From: Shannon Zhao @ 2016-01-23  9:20 UTC (permalink / raw)
  To: xen-devel
  Cc: ian.campbell, stefano.stabellini, peter.huangpeng, julien.grall,
	stefano.stabellini, shannon.zhao

From: Shannon Zhao <shannon.zhao@linaro.org>

Parse ACPI SPCR (Serial Port Console Redirection table) table and
initialize the serial port pl011.

Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
V4: Add other fields of SPCR Interface type
---
 xen/drivers/char/pl011.c  | 37 +++++++++++++++++++++++++++++++++++++
 xen/include/acpi/actbl2.h |  9 +++++++++
 2 files changed, 46 insertions(+)

diff --git a/xen/drivers/char/pl011.c b/xen/drivers/char/pl011.c
index 7e16294..9d47299 100644
--- a/xen/drivers/char/pl011.c
+++ b/xen/drivers/char/pl011.c
@@ -27,6 +27,7 @@
 #include <asm/device.h>
 #include <xen/mm.h>
 #include <xen/vmap.h>
+#include <xen/acpi.h>
 #include <asm/pl011-uart.h>
 #include <asm/io.h>
 
@@ -308,6 +309,42 @@ DT_DEVICE_START(pl011, "PL011 UART", DEVICE_SERIAL)
         .init = pl011_dt_uart_init,
 DT_DEVICE_END
 
+#ifdef CONFIG_ACPI
+static int __init pl011_acpi_uart_init(const void *data)
+{
+    acpi_status status;
+    struct acpi_table_spcr *spcr = NULL;
+    int res;
+
+    status = acpi_get_table(ACPI_SIG_SPCR, 0,
+                            (struct acpi_table_header **)&spcr);
+
+    if ( ACPI_FAILURE(status) )
+    {
+        printk("pl011: Failed to get SPCR table\n");
+        return -EINVAL;
+    }
+
+    /* trigger/polarity information is not available in spcr */
+    irq_set_type(spcr->interrupt, IRQ_TYPE_EDGE_BOTH);
+
+    res = pl011_uart_init(spcr->interrupt, spcr->serial_port.address,
+                          PAGE_SIZE);
+    if ( res < 0 )
+    {
+        printk("pl011: Unable to initialize\n");
+        return res;
+    }
+
+    return 0;
+}
+
+ACPI_DEVICE_START(apl011, "PL011 UART", DEVICE_SERIAL)
+        .class_type = ACPI_SPCR_TYPE_PL011,
+        .init = pl011_acpi_uart_init,
+ACPI_DEVICE_END
+#endif
+
 /*
  * Local variables:
  * mode: C
diff --git a/xen/include/acpi/actbl2.h b/xen/include/acpi/actbl2.h
index 87bc6b3..d0508be 100644
--- a/xen/include/acpi/actbl2.h
+++ b/xen/include/acpi/actbl2.h
@@ -815,6 +815,15 @@ struct acpi_table_spcr {
 
 #define ACPI_SPCR_DO_NOT_DISABLE    (1)
 
+/* SPCR Interface type */
+#define ACPI_SPCR_TYPE_16550		0
+#define ACPI_SPCR_TYPE_16550_SUB	0x1
+#define ACPI_SPCR_TYPE_PL011		0x3
+#define ACPI_SPCR_TYPE_SBSA_32		0xd
+#define ACPI_SPCR_TYPE_SBSA		0xe
+#define ACPI_SPCR_TYPE_DCC		0xf
+#define ACPI_SPCR_TYPE_BCM2835		0x10
+
 /*******************************************************************************
  *
  * SPMI - Server Platform Management Interface table
-- 
2.0.4

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

* [PATCH v4 20/21] arm/fdt: Export device_tree_for_each_node
  2016-01-23  9:19 [PATCH v4 00/21] Add ACPI support for Xen itself on ARM64 Shannon Zhao
                   ` (18 preceding siblings ...)
  2016-01-23  9:20 ` [PATCH v4 19/21] arm/acpi: Initialize serial port from ACPI SPCR table Shannon Zhao
@ 2016-01-23  9:20 ` Shannon Zhao
  2016-02-02 18:01   ` Stefano Stabellini
  2016-01-23  9:20 ` [PATCH v4 21/21] arm/acpi: Add acpi parameter to enable/disable acpi Shannon Zhao
  20 siblings, 1 reply; 62+ messages in thread
From: Shannon Zhao @ 2016-01-23  9:20 UTC (permalink / raw)
  To: xen-devel
  Cc: ian.campbell, stefano.stabellini, peter.huangpeng, julien.grall,
	stefano.stabellini, shannon.zhao

From: Shannon Zhao <shannon.zhao@linaro.org>

This function will be used by ACPI booting. Export it so that it can be
used by other files.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/arch/arm/bootfdt.c        | 6 +++---
 xen/include/xen/device_tree.h | 4 ++++
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/xen/arch/arm/bootfdt.c b/xen/arch/arm/bootfdt.c
index 74d208b..8a14015 100644
--- a/xen/arch/arm/bootfdt.c
+++ b/xen/arch/arm/bootfdt.c
@@ -85,9 +85,9 @@ static u32 __init device_tree_get_u32(const void *fdt, int node,
  * Returns 0 if all nodes were iterated over successfully.  If @func
  * returns a value different from 0, that value is returned immediately.
  */
-static int __init device_tree_for_each_node(const void *fdt,
-                                            device_tree_node_func func,
-                                            void *data)
+int __init device_tree_for_each_node(const void *fdt,
+                                     device_tree_node_func func,
+                                     void *data)
 {
     int node;
     int depth;
diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h
index cf31e50..12942cf 100644
--- a/xen/include/xen/device_tree.h
+++ b/xen/include/xen/device_tree.h
@@ -173,6 +173,10 @@ typedef int (*device_tree_node_func)(const void *fdt,
 
 extern const void *device_tree_flattened;
 
+int __init device_tree_for_each_node(const void *fdt,
+                                     device_tree_node_func func,
+                                     void *data);
+
 /**
  * dt_unflatten_host_device_tree - Unflatten the host device tree
  *
-- 
2.0.4

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

* [PATCH v4 21/21] arm/acpi: Add acpi parameter to enable/disable acpi
  2016-01-23  9:19 [PATCH v4 00/21] Add ACPI support for Xen itself on ARM64 Shannon Zhao
                   ` (19 preceding siblings ...)
  2016-01-23  9:20 ` [PATCH v4 20/21] arm/fdt: Export device_tree_for_each_node Shannon Zhao
@ 2016-01-23  9:20 ` Shannon Zhao
  2016-02-02 17:58   ` Stefano Stabellini
  20 siblings, 1 reply; 62+ messages in thread
From: Shannon Zhao @ 2016-01-23  9:20 UTC (permalink / raw)
  To: xen-devel
  Cc: ian.campbell, stefano.stabellini, peter.huangpeng, julien.grall,
	stefano.stabellini, shannon.zhao

From: Shannon Zhao <shannon.zhao@linaro.org>

Define new command line parameter "acpi" to enable/disable acpi.
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

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
V4: be consistent with Linux
---
 xen/arch/arm/acpi/boot.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)

diff --git a/xen/arch/arm/acpi/boot.c b/xen/arch/arm/acpi/boot.c
index c9135f2..8eb6c37 100644
--- a/xen/arch/arm/acpi/boot.c
+++ b/xen/arch/arm/acpi/boot.c
@@ -30,9 +30,11 @@
 #include <xen/errno.h>
 #include <acpi/actables.h>
 #include <xen/mm.h>
+#include <xen/device_tree.h>
 
 #include <asm/acpi.h>
 #include <asm/smp.h>
+#include <asm/setup.h>
 
 /* Processors with enabled flag and sane MPIDR */
 static unsigned int enabled_cpus;
@@ -182,6 +184,36 @@ static int __init acpi_parse_fadt(struct acpi_table_header *table)
     return -EINVAL;
 }
 
+static bool_t __initdata param_acpi_off;
+static bool_t __initdata param_acpi_force;
+
+static void __init parse_acpi_param(char *arg)
+{
+    if ( !arg )
+        return;
+
+    /* Interpret the parameter for use within Xen. */
+    if ( !parse_bool(arg) )
+        param_acpi_off = true;
+    else if ( !strcmp(arg, "force") ) /* force ACPI to be enabled */
+        param_acpi_force = true;
+}
+custom_param("acpi", parse_acpi_param);
+
+static int __init dt_scan_depth1_nodes(const void *fdt, int node,
+                                       const char *uname, int depth,
+                                       u32 address_cells, u32 size_cells,
+                                       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_boot_table_init() called from setup_arch(), always.
  *      1. find RSDP and get its address, and then find XSDT
@@ -198,6 +230,26 @@ int __init acpi_boot_table_init(void)
 {
     int error;
 
+    /*
+     * 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
+                             && device_tree_for_each_node(device_tree_flattened,
+                                                   dt_scan_depth1_nodes, NULL)))
+    {
+        disable_acpi();
+        return 0;
+    }
+
+    /*
+     * ACPI is disabled at this point. Enable it in order to parse
+     * the ACPI tables.
+     */
+    enable_acpi();
+
     /* Initialize the ACPI boot-time table parser. */
     error = acpi_table_init();
     if ( error )
-- 
2.0.4

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

* Re: [PATCH v4 07/21] arm/acpi: Print GIC information when MADT is parsed
  2016-01-23  9:19 ` [PATCH v4 07/21] arm/acpi: Print GIC information when MADT is parsed Shannon Zhao
@ 2016-01-25 14:49   ` Jan Beulich
  2016-01-27 16:50   ` Stefano Stabellini
  1 sibling, 0 replies; 62+ messages in thread
From: Jan Beulich @ 2016-01-25 14:49 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: ian.campbell, stefano.stabellini, peter.huangpeng, xen-devel,
	julien.grall, stefano.stabellini, shannon.zhao

>>> On 23.01.16 at 10:19, <zhaoshenglong@huawei.com> wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> When MADT is parsed, print GIC information to make the boot log look
> pretty.
> 
> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
> Signed-off-by: Tomasz Nowicki <tomasz.nowicki@linaro.org>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>

Is this the equivalent of a Linux side commit? If so please name it.
If not, ...

> --- a/xen/drivers/acpi/tables.c
> +++ b/xen/drivers/acpi/tables.c
> @@ -189,6 +189,28 @@ void __init 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;

... no matter that other cases here have been coded in a similarly
bad manner, please do better than them and use container_of()
instead of a cast here. (Cleaning up the others is [fairly low] on my
todo list.)

Jan

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

* Re: [PATCH v4 08/21] arm/acpi: Parse MADT to map logical cpu to MPIDR and get cpu_possible_map
  2016-01-23  9:20 ` [PATCH v4 08/21] arm/acpi: Parse MADT to map logical cpu to MPIDR and get cpu_possible_map Shannon Zhao
@ 2016-01-25 14:53   ` Jan Beulich
  2016-01-28 10:40   ` Stefano Stabellini
  1 sibling, 0 replies; 62+ messages in thread
From: Jan Beulich @ 2016-01-25 14:53 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: ian.campbell, stefano.stabellini, peter.huangpeng, xen-devel,
	julien.grall, stefano.stabellini, shannon.zhao

>>> On 23.01.16 at 10:20, <zhaoshenglong@huawei.com> wrote:
> --- a/xen/include/xen/acpi.h
> +++ b/xen/include/xen/acpi.h
> @@ -39,6 +39,10 @@
>  #define ACPI_MADT_GET_POLARITY(inti)	ACPI_MADT_GET_(POLARITY, inti)
>  #define ACPI_MADT_GET_TRIGGER(inti)	ACPI_MADT_GET_(TRIGGER, inti)
>  
> +#define BAD_MADT_ENTRY(entry, end) (                                        \
> +                (!entry) || (unsigned long)entry + sizeof(*entry) > end ||  \
> +                ((struct acpi_subtable_header *)entry)->length < sizeof(*entry))

If you move or otherwise anyway touch existing code, please
always take a critical look at it and at least fix obvious problems.
Read, here: Properly parenthesize all uses of the macro's
parameters. While not desirable, failing to do so may be
acceptable when the scope of such definitions is very limited (as
it was before you moving it), but once globally exposed it needs
to be made safe.

Jan

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

* Re: [PATCH v4 10/21] acpi/table: Introduce acpi_table_get_entry_madt to get specified entry
  2016-01-23  9:20 ` [PATCH v4 10/21] acpi/table: Introduce acpi_table_get_entry_madt to get specified entry Shannon Zhao
@ 2016-01-25 15:02   ` Jan Beulich
  2016-01-29  7:49     ` Shannon Zhao
  0 siblings, 1 reply; 62+ messages in thread
From: Jan Beulich @ 2016-01-25 15:02 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: ian.campbell, stefano.stabellini, peter.huangpeng, xen-devel,
	julien.grall, stefano.stabellini, shannon.zhao

>>> On 23.01.16 at 10:20, <zhaoshenglong@huawei.com> wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> This function could get the specified index entry of MADT table. This
> would be useful when it needs to get the contens of the entry.
> 
> Cc: Jan Beulich <jbeulich@suse.com>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>

Again - if this is the counterpart to a Linux side change, please name
that change. If it isn't, besides needing a better explanation of why
you need it whether neither Linux nor x86 Xen does is needed, and
a few code issues would need to be addressed too: Pointer type
function parameters should be constified as much as possible, use of
plain int should be avoided unless you truly need a signed type, and
...

> +struct acpi_subtable_header * __init
> +acpi_table_get_entry_madt(enum acpi_madt_type id, unsigned int entry_index)
> +{
> +	struct acpi_table_header *table_header = NULL;
> +
> +	acpi_get_table(ACPI_SIG_MADT, acpi_apic_instance, &table_header);
> +	if (!table_header) {

... you should use the return value of the function instead of pre-
setting table_header to NULL and then checking whether it changed.

Jan

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

* Re: [PATCH v4 18/21] arm/acpi: Add a new ACPI initialized function for UART
  2016-01-23  9:20 ` [PATCH v4 18/21] arm/acpi: Add a new ACPI initialized function for UART Shannon Zhao
@ 2016-01-25 15:04   ` Jan Beulich
  2016-02-02 17:48   ` Stefano Stabellini
  1 sibling, 0 replies; 62+ messages in thread
From: Jan Beulich @ 2016-01-25 15:04 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: ian.campbell, stefano.stabellini, peter.huangpeng, xen-devel,
	julien.grall, stefano.stabellini, shannon.zhao

>>> On 23.01.16 at 10:20, <zhaoshenglong@huawei.com> wrote:
> --- a/xen/include/xen/serial.h
> +++ b/xen/include/xen/serial.h
> @@ -170,7 +170,7 @@ struct ns16550_defaults {
>  void ns16550_init(int index, struct ns16550_defaults *defaults);
>  void ehci_dbgp_init(void);
>  
> -void __init dt_uart_init(void);
> +void __init arm_uart_init(void);

As mentioned before - if you already have to touch this, please
take the opportunity to drop the stray __init here (section
placement annotations belong only on definitions, never on
declarations).

Jan

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

* Re: [PATCH v4 19/21] arm/acpi: Initialize serial port from ACPI SPCR table
  2016-01-23  9:20 ` [PATCH v4 19/21] arm/acpi: Initialize serial port from ACPI SPCR table Shannon Zhao
@ 2016-01-25 15:05   ` Jan Beulich
  2016-01-28 12:33     ` Shannon Zhao
  2016-02-02 17:51   ` Stefano Stabellini
  1 sibling, 1 reply; 62+ messages in thread
From: Jan Beulich @ 2016-01-25 15:05 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: ian.campbell, stefano.stabellini, peter.huangpeng, xen-devel,
	julien.grall, stefano.stabellini, shannon.zhao

>>> On 23.01.16 at 10:20, <zhaoshenglong@huawei.com> wrote:
> --- a/xen/include/acpi/actbl2.h
> +++ b/xen/include/acpi/actbl2.h
> @@ -815,6 +815,15 @@ struct acpi_table_spcr {
>  
>  #define ACPI_SPCR_DO_NOT_DISABLE    (1)
>  
> +/* SPCR Interface type */
> +#define ACPI_SPCR_TYPE_16550		0
> +#define ACPI_SPCR_TYPE_16550_SUB	0x1
> +#define ACPI_SPCR_TYPE_PL011		0x3
> +#define ACPI_SPCR_TYPE_SBSA_32		0xd
> +#define ACPI_SPCR_TYPE_SBSA		0xe
> +#define ACPI_SPCR_TYPE_DCC		0xf
> +#define ACPI_SPCR_TYPE_BCM2835		0x10

It seems very likely to me that this part of the change actually would
have a Linux counterpart, in which case it should be submitted as such.

Jan

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

* Re: [PATCH v4 01/21] arm/acpi: Emulate io ports for arm
  2016-01-23  9:19 ` [PATCH v4 01/21] arm/acpi: Emulate io ports for arm Shannon Zhao
@ 2016-01-27 12:52   ` Stefano Stabellini
  2016-01-28 12:13     ` Shannon Zhao
  0 siblings, 1 reply; 62+ messages in thread
From: Stefano Stabellini @ 2016-01-27 12:52 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: ian.campbell, stefano.stabellini, peter.huangpeng, xen-devel,
	julien.grall, stefano.stabellini, shannon.zhao

On Sat, 23 Jan 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Add macros to emulate x86 style ports for arm. This avoids modification in
> common code for acpi. Here just print a warning on ARM.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
> V4: print warning
> ---
>  xen/include/asm-arm/arm64/io.h | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
> 
> diff --git a/xen/include/asm-arm/arm64/io.h b/xen/include/asm-arm/arm64/io.h
> index 37abc47..ec5815d 100644
> --- a/xen/include/asm-arm/arm64/io.h
> +++ b/xen/include/asm-arm/arm64/io.h
> @@ -20,6 +20,7 @@
>  #ifndef _ARM_ARM64_IO_H
>  #define _ARM_ARM64_IO_H
>  
> +#include <asm/system.h>
>  #include <asm/byteorder.h>
>  
>  /*
> @@ -109,4 +110,21 @@ static inline u64 __raw_readq(const volatile void __iomem *addr)
>  #define writel(v,c)             ({ __iowmb(); writel_relaxed((v),(c)); })
>  #define writeq(v,c)             ({ __iowmb(); writeq_relaxed((v),(c)); })
>  
> +/*
> + * Emulate x86 io ports for ARM.
> + */
> +static inline void __iomem * __armio(u64 addr)
> +{
> +    printk(XENLOG_G_WARNING "Can't access IO %lx\n", addr);
> +    return (void __iomem *)addr;
> +}
> +
> +#define inb(c) ( readb( __armio(c) ) )
> +#define inw(c) ( readw( __armio(c) ) )
> +#define inl(c) ( readl( __armio(c) ) )
> +
> +#define outb(v, c) ( writeb(v, __armio(c) ) )
> +#define outw(v, c) ( writew(v, __armio(c) ) )
> +#define outl(v, c) ( writel(v, __armio(c) ) )

This is better than before, but it would still end up causing a write to
happen on outb, outw and outl. I would define them in a way so that
only the warning gets printed when they are called and nothing else.

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

* Re: [PATCH v4 04/21] arm/acpi: Move end_boot_allocator after acpi_boot_table_init
  2016-01-23  9:19 ` [PATCH v4 04/21] arm/acpi: Move end_boot_allocator after acpi_boot_table_init Shannon Zhao
@ 2016-01-27 14:53   ` Stefano Stabellini
  0 siblings, 0 replies; 62+ messages in thread
From: Stefano Stabellini @ 2016-01-27 14:53 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: ian.campbell, stefano.stabellini, peter.huangpeng, xen-devel,
	julien.grall, stefano.stabellini, shannon.zhao

On Sat, 23 Jan 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> If ACPI is initialized after the boot allocator has ended(the system
> state is not early boot), assert happens in acpi_os_zalloc_memory and
> acpi_boot_table_init will fail. So it needs to move end_boot_allocator
> after acpi_boot_table_init.

The commit message is wrong: on arm64 system_state is set to
SYS_STATE_boot from start_xen few lines after the vm_init() call,
end_boot_allocator() doesn't change it.

Why do we need to move end_boot_allocator() exactly?


> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  xen/arch/arm/setup.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
> index 3b29904..0ba601e 100644
> --- a/xen/arch/arm/setup.c
> +++ b/xen/arch/arm/setup.c
> @@ -612,8 +612,6 @@ static void __init setup_mm(unsigned long dtb_paddr, size_t dtb_size)
>         allocator. */
>      init_xenheap_pages(pfn_to_paddr(xenheap_mfn_start),
>                         pfn_to_paddr(boot_mfn_start));
> -
> -    end_boot_allocator();
>  }
>  #else /* CONFIG_ARM_64 */
>  static void __init setup_mm(unsigned long dtb_paddr, size_t dtb_size)
> @@ -681,8 +679,6 @@ static void __init setup_mm(unsigned long dtb_paddr, size_t dtb_size)
>  
>      setup_frametable_mappings(ram_start, ram_end);
>      max_page = PFN_DOWN(ram_end);
> -
> -    end_boot_allocator();
>  }
>  #endif
>  
> @@ -753,6 +749,8 @@ void __init start_xen(unsigned long boot_phys_offset,
>  
>      setup_mm(fdt_paddr, fdt_size);
>  
> +    end_boot_allocator();
> +
>      vm_init();
>      dt_unflatten_host_device_tree();
>  
> -- 
> 2.0.4
> 
> 

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

* Re: [PATCH v4 05/21] arm/acpi: Add basic ACPI initialization
  2016-01-23  9:19 ` [PATCH v4 05/21] arm/acpi: Add basic ACPI initialization Shannon Zhao
@ 2016-01-27 14:54   ` Stefano Stabellini
  2016-01-28 10:33     ` Shannon Zhao
  0 siblings, 1 reply; 62+ messages in thread
From: Stefano Stabellini @ 2016-01-27 14:54 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: ian.campbell, stefano.stabellini, peter.huangpeng, xen-devel,
	julien.grall, stefano.stabellini, shannon.zhao

On Sat, 23 Jan 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> acpi_boot_table_init() will be called in start_xen to get the RSDP and
> all the table pointers. With this patch, we can get ACPI boot-time
> tables from firmware on ARM64.
> 
> Signed-off-by: Naresh Bhat <naresh.bhat@linaro.org>
> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  xen/arch/arm/acpi/Makefile |  1 +
>  xen/arch/arm/acpi/boot.c   | 58 ++++++++++++++++++++++++++++++++++++++++++++++
>  xen/arch/arm/setup.c       |  4 ++++
>  3 files changed, 63 insertions(+)
>  create mode 100644 xen/arch/arm/acpi/boot.c
> 
> diff --git a/xen/arch/arm/acpi/Makefile b/xen/arch/arm/acpi/Makefile
> index b5be22d..196c40a 100644
> --- a/xen/arch/arm/acpi/Makefile
> +++ b/xen/arch/arm/acpi/Makefile
> @@ -1 +1,2 @@
>  obj-y += lib.o
> +obj-y += boot.o
> diff --git a/xen/arch/arm/acpi/boot.c b/xen/arch/arm/acpi/boot.c
> new file mode 100644
> index 0000000..1570f7e
> --- /dev/null
> +++ b/xen/arch/arm/acpi/boot.c
> @@ -0,0 +1,58 @@
> +/*
> + *  ARM Specific Low-Level ACPI Boot Support
> + *
> + *  Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
> + *  Copyright (C) 2001 Jun Nakajima <jun.nakajima@intel.com>
> + *  Copyright (C) 2014, Naresh Bhat <naresh.bhat@linaro.org>
> + *  Copyright (C) 2015, Shannon Zhao <shannon.zhao@linaro.org>
> + *
> + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> + *
> + *  This program is free software; you can redistribute it and/or modify
> + *  it under the terms of the GNU General Public License as published by
> + *  the Free Software Foundation; either version 2 of the License, or
> + *  (at your option) any later version.
> + *
> + *  This program is distributed in the hope that it will be useful,
> + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
> + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + *  GNU General Public License for more details.
> + *
> + *  You should have received a copy of the GNU General Public License
> + *  along with this program; if not, write to the Free Software
> + *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
> + *
> + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> + */
> +
> +#include <xen/init.h>
> +#include <xen/acpi.h>
> +
> +#include <asm/acpi.h>
> +
> +/*
> + * 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
> + *
> + * return value: (currently ignored)
> + *	0: success
> + *	!0: failure
> + *
> + * We can parse ACPI boot-time tables such as FADT, MADT after
> + * this function is called.
> + */
> +int __init acpi_boot_table_init(void)
> +{
> +    int error;
> +
> +    /* Initialize the ACPI boot-time table parser. */
> +    error = acpi_table_init();
> +    if ( error )
> +    {
> +        disable_acpi();
> +        return error;
> +    }
> +
> +    return 0;
> +}
> diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
> index 0ba601e..c15a09d 100644
> --- a/xen/arch/arm/setup.c
> +++ b/xen/arch/arm/setup.c
> @@ -36,6 +36,7 @@
>  #include <xen/pfn.h>
>  #include <xen/vmap.h>
>  #include <xen/libfdt/libfdt.h>
> +#include <xen/acpi.h>
>  #include <asm/page.h>
>  #include <asm/current.h>
>  #include <asm/setup.h>
> @@ -749,6 +750,9 @@ void __init start_xen(unsigned long boot_phys_offset,
>  
>      setup_mm(fdt_paddr, fdt_size);
>  
> +    /* Parse the ACPI tables for possible boot-time configuration */
> +    acpi_boot_table_init();

As I asked before, why do you need to call acpi_boot_table_init() before
vm_init?  If you called acpi_boot_table_init() after vm_init(), you
could implement __acpi_map_table with vmap, which would be better.



>      end_boot_allocator();
>  
>      vm_init();
> -- 
> 2.0.4
> 
> 

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

* Re: [PATCH v4 06/21] arm/acpi: Parse FADT table and get PSCI flags
  2016-01-23  9:19 ` [PATCH v4 06/21] arm/acpi: Parse FADT table and get PSCI flags Shannon Zhao
@ 2016-01-27 15:41   ` Stefano Stabellini
  2016-02-23 12:13     ` Shannon Zhao
  0 siblings, 1 reply; 62+ messages in thread
From: Stefano Stabellini @ 2016-01-27 15:41 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: ian.campbell, stefano.stabellini, peter.huangpeng, xen-devel,
	julien.grall, stefano.stabellini, shannon.zhao

On Sat, 23 Jan 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> There are two flags: PSCI_COMPLIANT and PSCI_USE_HVC. When set, the
> former signals to the OS that the hardware 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, parse FADT to get the flags for furture
> usage.
> 
> Since STAO table and the GIC version are introduced by ACPI 6.0, we will
> check the version and only parse FADT table with version >= 6.0. If
> firmware provides ACPI tables with ACPI version less than 6.0, OS will
> be messed up with those information, so disable ACPI if we get an FADT
> table with version less than 6.0.
> 
> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
> Signed-off-by: Naresh Bhat <naresh.bhat@linaro.org>
> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
> V4: drop disable_acpi in acpi_parse_fadt
> ---
>  xen/arch/arm/acpi/boot.c   | 30 ++++++++++++++++++++++++++++++
>  xen/arch/arm/acpi/lib.c    | 12 ++++++++++++
>  xen/include/asm-arm/acpi.h |  9 +++++++++
>  3 files changed, 51 insertions(+)
> 
> diff --git a/xen/arch/arm/acpi/boot.c b/xen/arch/arm/acpi/boot.c
> index 1570f7e..6b33fbe 100644
> --- a/xen/arch/arm/acpi/boot.c
> +++ b/xen/arch/arm/acpi/boot.c
> @@ -27,9 +27,32 @@
>  
>  #include <xen/init.h>
>  #include <xen/acpi.h>
> +#include <xen/errno.h>
> +#include <acpi/actables.h>
> +#include <xen/mm.h>
>  
>  #include <asm/acpi.h>
>  
> +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 6.0,
> +     * we only deal with ACPI 6.0 or newer revision to get GIC and SMP
> +     * boot protocol configuration data, or we will disable ACPI.
> +     */
> +    if ( table->revision > 6
> +         || (table->revision == 6 && fadt->minor_revision >= 0) )
> +        return 0;
> +
> +    printk("Unsupported FADT revision %d.%d, should be 6.0+, will disable ACPI\n",
> +            table->revision, fadt->minor_revision);
> +
> +    return -EINVAL;
> +}
> +
>  /*
>   * acpi_boot_table_init() called from setup_arch(), always.
>   *      1. find RSDP and get its address, and then find XSDT
> @@ -54,5 +77,12 @@ int __init acpi_boot_table_init(void)
>          return error;
>      }
>  
> +    if ( acpi_table_parse(ACPI_SIG_FADT, acpi_parse_fadt) )
> +    {
> +        /* disable ACPI if no FADT is found */
> +        disable_acpi();
> +        printk("Can't find FADT\n");
> +    }
> +
>      return 0;
>  }
> diff --git a/xen/arch/arm/acpi/lib.c b/xen/arch/arm/acpi/lib.c
> index f817fe6..a30e4e6 100644
> --- a/xen/arch/arm/acpi/lib.c
> +++ b/xen/arch/arm/acpi/lib.c
> @@ -50,3 +50,15 @@ char *__acpi_map_table(paddr_t phys, unsigned long size)
>  
>  	return ((char *) base + offset);
>  }
> +
> +/* 1 to indicate PSCI 0.2+ is implemented */
> +bool_t __init acpi_psci_present(void)
> +{
> +    return acpi_gbl_FADT.arm_boot_flags & ACPI_FADT_PSCI_COMPLIANT;
> +}
> +
> +/* 1 to indicate HVC is present instead of SMC as the PSCI conduit */
> +bool_t __init acpi_psci_hvc_present(void)
> +{
> +    return acpi_gbl_FADT.arm_boot_flags & ACPI_FADT_PSCI_USE_HVC;
> +}

So far so good.


> diff --git a/xen/include/asm-arm/acpi.h b/xen/include/asm-arm/acpi.h
> index 6a037c9..1ce88f8 100644
> --- a/xen/include/asm-arm/acpi.h
> +++ b/xen/include/asm-arm/acpi.h
> @@ -31,6 +31,15 @@
>  #define ACPI_MAP_MEM_ATTR          PAGE_HYPERVISOR
>  
>  extern bool_t acpi_disabled;
> +
> +#ifdef CONFIG_ACPI
> +bool_t __init acpi_psci_present(void);
> +bool_t __init acpi_psci_hvc_present(void);
> +#else
> +static inline bool_t acpi_psci_present(void) { return false; }
> +static inline bool_t acpi_psci_hvc_present(void) {return false; }
> +#endif /* CONFIG_ACPI */
> +
>  /* Basic configuration for ACPI */
>  static inline void disable_acpi(void)
>  {

I would prefer if we only defined each function once, outside the ifdef
(no static inline needed). Then we could

#ifdef CONFIG_ACPI
extern bool_t acpi_disabled;
#else
#define acpi_disabled (1)
#endif

Which would solve the problem for !CONFIG_ACPI cases. But you need to be
careful to move bool_t acpi_disabled, enable_acpi and disable_acpi
inside an ifdef.

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

* Re: [PATCH v4 07/21] arm/acpi: Print GIC information when MADT is parsed
  2016-01-23  9:19 ` [PATCH v4 07/21] arm/acpi: Print GIC information when MADT is parsed Shannon Zhao
  2016-01-25 14:49   ` Jan Beulich
@ 2016-01-27 16:50   ` Stefano Stabellini
  1 sibling, 0 replies; 62+ messages in thread
From: Stefano Stabellini @ 2016-01-27 16:50 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: ian.campbell, stefano.stabellini, peter.huangpeng, xen-devel,
	julien.grall, stefano.stabellini, shannon.zhao

On Sat, 23 Jan 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> When MADT is parsed, print GIC information to make the boot log look
> pretty.
> 
> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
> Signed-off-by: Tomasz Nowicki <tomasz.nowicki@linaro.org>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>

Reviewed-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>


> V4: use PRIx64 instead of %llx
> ---
>  xen/drivers/acpi/tables.c | 22 ++++++++++++++++++++++
>  1 file changed, 22 insertions(+)
> 
> diff --git a/xen/drivers/acpi/tables.c b/xen/drivers/acpi/tables.c
> index 4e590de..84a290f 100644
> --- a/xen/drivers/acpi/tables.c
> +++ b/xen/drivers/acpi/tables.c
> @@ -189,6 +189,28 @@ void __init 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;
> +			printk(KERN_INFO PREFIX
> +			       "GICC (acpi_id[0x%04x] address[0x%"PRIx64"] MPIDR[0x%"PRIx64"] %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;
> +			printk(KERN_INFO PREFIX
> +			       "GIC Distributor (gic_id[0x%04x] address[0x%"PRIx64"] gsi_base[%d])\n",
> +			       p->gic_id, p->base_address, p->global_irq_base);
> +		}
> +		break;
> +
>  	default:
>  		printk(KERN_WARNING PREFIX
>  		       "Found unsupported MADT entry (type = %#x)\n",
> -- 
> 2.0.4
> 
> 

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

* Re: [PATCH v4 05/21] arm/acpi: Add basic ACPI initialization
  2016-01-27 14:54   ` Stefano Stabellini
@ 2016-01-28 10:33     ` Shannon Zhao
  2016-01-28 10:44       ` Stefano Stabellini
  0 siblings, 1 reply; 62+ messages in thread
From: Shannon Zhao @ 2016-01-28 10:33 UTC (permalink / raw)
  To: Stefano Stabellini
  Cc: ian.campbell, peter.huangpeng, xen-devel, julien.grall,
	stefano.stabellini, shannon.zhao



On 2016/1/27 22:54, Stefano Stabellini wrote:
> On Sat, 23 Jan 2016, Shannon Zhao wrote:
>> > From: Shannon Zhao <shannon.zhao@linaro.org>
>> > 
>> > acpi_boot_table_init() will be called in start_xen to get the RSDP and
>> > all the table pointers. With this patch, we can get ACPI boot-time
>> > tables from firmware on ARM64.
>> > 
>> > Signed-off-by: Naresh Bhat <naresh.bhat@linaro.org>
>> > Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
>> > Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
>> > ---
>> >  xen/arch/arm/acpi/Makefile |  1 +
>> >  xen/arch/arm/acpi/boot.c   | 58 ++++++++++++++++++++++++++++++++++++++++++++++
>> >  xen/arch/arm/setup.c       |  4 ++++
>> >  3 files changed, 63 insertions(+)
>> >  create mode 100644 xen/arch/arm/acpi/boot.c
>> > 
>> > diff --git a/xen/arch/arm/acpi/Makefile b/xen/arch/arm/acpi/Makefile
>> > index b5be22d..196c40a 100644
>> > --- a/xen/arch/arm/acpi/Makefile
>> > +++ b/xen/arch/arm/acpi/Makefile
>> > @@ -1 +1,2 @@
>> >  obj-y += lib.o
>> > +obj-y += boot.o
>> > diff --git a/xen/arch/arm/acpi/boot.c b/xen/arch/arm/acpi/boot.c
>> > new file mode 100644
>> > index 0000000..1570f7e
>> > --- /dev/null
>> > +++ b/xen/arch/arm/acpi/boot.c
>> > @@ -0,0 +1,58 @@
>> > +/*
>> > + *  ARM Specific Low-Level ACPI Boot Support
>> > + *
>> > + *  Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
>> > + *  Copyright (C) 2001 Jun Nakajima <jun.nakajima@intel.com>
>> > + *  Copyright (C) 2014, Naresh Bhat <naresh.bhat@linaro.org>
>> > + *  Copyright (C) 2015, Shannon Zhao <shannon.zhao@linaro.org>
>> > + *
>> > + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> > + *
>> > + *  This program is free software; you can redistribute it and/or modify
>> > + *  it under the terms of the GNU General Public License as published by
>> > + *  the Free Software Foundation; either version 2 of the License, or
>> > + *  (at your option) any later version.
>> > + *
>> > + *  This program is distributed in the hope that it will be useful,
>> > + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
>> > + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>> > + *  GNU General Public License for more details.
>> > + *
>> > + *  You should have received a copy of the GNU General Public License
>> > + *  along with this program; if not, write to the Free Software
>> > + *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
>> > + *
>> > + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> > + */
>> > +
>> > +#include <xen/init.h>
>> > +#include <xen/acpi.h>
>> > +
>> > +#include <asm/acpi.h>
>> > +
>> > +/*
>> > + * 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
>> > + *
>> > + * return value: (currently ignored)
>> > + *	0: success
>> > + *	!0: failure
>> > + *
>> > + * We can parse ACPI boot-time tables such as FADT, MADT after
>> > + * this function is called.
>> > + */
>> > +int __init acpi_boot_table_init(void)
>> > +{
>> > +    int error;
>> > +
>> > +    /* Initialize the ACPI boot-time table parser. */
>> > +    error = acpi_table_init();
>> > +    if ( error )
>> > +    {
>> > +        disable_acpi();
>> > +        return error;
>> > +    }
>> > +
>> > +    return 0;
>> > +}
>> > diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
>> > index 0ba601e..c15a09d 100644
>> > --- a/xen/arch/arm/setup.c
>> > +++ b/xen/arch/arm/setup.c
>> > @@ -36,6 +36,7 @@
>> >  #include <xen/pfn.h>
>> >  #include <xen/vmap.h>
>> >  #include <xen/libfdt/libfdt.h>
>> > +#include <xen/acpi.h>
>> >  #include <asm/page.h>
>> >  #include <asm/current.h>
>> >  #include <asm/setup.h>
>> > @@ -749,6 +750,9 @@ void __init start_xen(unsigned long boot_phys_offset,
>> >  
>> >      setup_mm(fdt_paddr, fdt_size);
>> >  
>> > +    /* Parse the ACPI tables for possible boot-time configuration */
>> > +    acpi_boot_table_init();
> As I asked before, why do you need to call acpi_boot_table_init() before
> vm_init?  If you called acpi_boot_table_init() after vm_init(), you
> could implement __acpi_map_table with vmap, which would be better.
> 
Yes, if we call acpi_boot_table_init() before vm_init, it needs to move
end_boot_allocator after acpi_boot_table_init because it will assert in
acpi_os_zalloc_memory.
TBH, I'm not sure where acpi_boot_table_init should be called. The
current way refers to x86.

Thanks,
-- 
Shannon

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

* Re: [PATCH v4 08/21] arm/acpi: Parse MADT to map logical cpu to MPIDR and get cpu_possible_map
  2016-01-23  9:20 ` [PATCH v4 08/21] arm/acpi: Parse MADT to map logical cpu to MPIDR and get cpu_possible_map Shannon Zhao
  2016-01-25 14:53   ` Jan Beulich
@ 2016-01-28 10:40   ` Stefano Stabellini
  1 sibling, 0 replies; 62+ messages in thread
From: Stefano Stabellini @ 2016-01-28 10:40 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: ian.campbell, stefano.stabellini, peter.huangpeng, xen-devel,
	julien.grall, stefano.stabellini, shannon.zhao, Jan Beulich

On Sat, 23 Jan 2016, Shannon Zhao wrote:
> From: Parth Dixit <parth.dixit@linaro.org>
> 
> 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.
> 
> Move BAD_MADT_ENTRY to common place.
> 
> Cc: Jan Beulich <jbeulich@suse.com>
> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
> Signed-off-by: Tomasz Nowicki <tomasz.nowicki@linaro.org>
> Signed-off-by: Naresh Bhat <naresh.bhat@linaro.org>
> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
> V4: fix coding style and address some comments
> ---
>  xen/arch/arm/acpi/boot.c   | 129 +++++++++++++++++++++++++++++++++++++++++++++
>  xen/arch/x86/acpi/boot.c   |   4 --
>  xen/include/asm-arm/acpi.h |   2 +
>  xen/include/xen/acpi.h     |   4 ++
>  4 files changed, 135 insertions(+), 4 deletions(-)
> 
> diff --git a/xen/arch/arm/acpi/boot.c b/xen/arch/arm/acpi/boot.c
> index 6b33fbe..c9135f2 100644
> --- a/xen/arch/arm/acpi/boot.c
> +++ b/xen/arch/arm/acpi/boot.c
> @@ -32,6 +32,135 @@
>  #include <xen/mm.h>
>  
>  #include <asm/acpi.h>
> +#include <asm/smp.h>
> +
> +/* Processors with enabled flag and sane MPIDR */
> +static unsigned int enabled_cpus;
> +
> +/* Boot CPU is valid or not in MADT */
> +static bool_t __initdata bootcpu_valid;
> +
> +/* total number of cpus in this system */
> +static unsigned int __initdata total_cpus;
> +
> +/*
> + * acpi_map_gic_cpu_interface - generates a logical cpu number
> + * and map to MPIDR represented by GICC structure
> + */
> +static void __init
> +acpi_map_gic_cpu_interface(struct acpi_madt_generic_interrupt *processor)
> +{
> +    int i;
> +    u64 mpidr = processor->arm_mpidr & MPIDR_HWID_MASK;
> +    bool_t enabled = !!(processor->flags & ACPI_MADT_ENABLED);
> +
> +    if ( mpidr == MPIDR_INVALID )
> +    {
> +        printk("Skip MADT cpu entry with invalid MPIDR\n");
> +        return;
> +    }
> +
> +    total_cpus++;
> +    if ( !enabled )
> +        return;
> +
> +    if ( enabled_cpus >=  NR_CPUS )
> +    {
> +        printk("NR_CPUS limit of %d reached, Processor %d/0x%"PRIx64" ignored.\n",
> +               NR_CPUS, total_cpus, mpidr);
> +        return;
> +    }
> +
> +    /* Check if GICC structure of boot CPU is available in the MADT */
> +    if ( cpu_logical_map(0) == mpidr )
> +    {
> +        if ( bootcpu_valid )
> +        {
> +            printk("Firmware bug, duplicate CPU MPIDR: 0x%"PRIx64" in MADT\n",
> +                   mpidr);
> +            return;
> +        }
> +
> +        bootcpu_valid = true;
> +    }

cpu0 is always initialized first, right? In that case I think we should
remove bootcpu_valid and turn this into a more explicit check, such as:

    if ( (enabled_cpus == 0) && (cpu_logical_map(0) != mpidr) )
    {
        printk("Firmware bug, invalid CPU MPIDR for cpu0: 0x%"PRIx64" in MADT\n",
                mpidr);
        return;
    }


> +    /*
> +     * 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 )
> +        {
> +            printk("Firmware bug, duplicate CPU MPIDR: 0x%"PRIx64" in MADT\n",
> +                   mpidr);
> +            return;
> +        }
> +    }

Please remove bootcpu_valid and merge this loop with the previous if
statement, like this:

for ( i = 0; i < enabled_cpus; i++ )
{
    if ( cpu_logical_map(i) == mpidr )
    {
        printk("Firmware bug...
        return;
    }
}



> +    if ( !acpi_psci_present() )
> +        return;
> +
> +    /* CPU 0 was already initialized */
> +    if ( enabled_cpus )
> +    {
> +        if ( arch_cpu_init(enabled_cpus, NULL) < 0 )
> +            return;
> +
> +        /* map the logical cpu id to cpu MPIDR */
> +        cpu_logical_map(enabled_cpus) = mpidr;
> +    }
> +
> +    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 =
> +               container_of(header, 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);
> +    return 0;
> +}
> +
> +/* Parse GIC cpu interface entries in MADT for SMP init */
> +void __init acpi_smp_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 <= 0 )
> +    {
> +        printk("Error parsing GIC CPU interface entry\n");
> +        return;
> +    }
> +
> +    if ( !bootcpu_valid )
> +    {
> +        printk("MADT missing boot CPU MPIDR, not enabling secondaries\n");
> +        return;
> +    }
> +
> +    for ( i = 0; i < enabled_cpus; i++ )
> +        cpumask_set_cpu(i, &cpu_possible_map);
> +
> +    /* Make boot-up look pretty */
> +    printk("%d CPUs enabled, %d CPUs total\n", enabled_cpus, total_cpus);
> +}
>  
>  static int __init acpi_parse_fadt(struct acpi_table_header *table)
>  {
> diff --git a/xen/arch/x86/acpi/boot.c b/xen/arch/x86/acpi/boot.c
> index fac36c6..385c0be 100644
> --- a/xen/arch/x86/acpi/boot.c
> +++ b/xen/arch/x86/acpi/boot.c
> @@ -43,10 +43,6 @@
>  #include <mach_apic.h>
>  #include <mach_mpparse.h>
>  
> -#define BAD_MADT_ENTRY(entry, end) (					    \
> -		(!entry) || (unsigned long)entry + sizeof(*entry) > end ||  \
> -		((struct acpi_subtable_header *)entry)->length != sizeof(*entry))
> -
>  #define PREFIX			"ACPI: "
>  
>  bool_t __initdata acpi_noirq;	/* skip ACPI IRQ initialization */
> diff --git a/xen/include/asm-arm/acpi.h b/xen/include/asm-arm/acpi.h
> index 1ce88f8..89d17e8 100644
> --- a/xen/include/asm-arm/acpi.h
> +++ b/xen/include/asm-arm/acpi.h
> @@ -35,9 +35,11 @@ extern bool_t acpi_disabled;
>  #ifdef CONFIG_ACPI
>  bool_t __init acpi_psci_present(void);
>  bool_t __init acpi_psci_hvc_present(void);
> +void __init acpi_smp_init_cpus(void);
>  #else
>  static inline bool_t acpi_psci_present(void) { return false; }
>  static inline bool_t acpi_psci_hvc_present(void) {return false; }
> +static inline void acpi_smp_init_cpus(void) { }
>  #endif /* CONFIG_ACPI */
>  
>  /* Basic configuration for ACPI */
> diff --git a/xen/include/xen/acpi.h b/xen/include/xen/acpi.h
> index 65e53a6..bc73310 100644
> --- a/xen/include/xen/acpi.h
> +++ b/xen/include/xen/acpi.h
> @@ -39,6 +39,10 @@
>  #define ACPI_MADT_GET_POLARITY(inti)	ACPI_MADT_GET_(POLARITY, inti)
>  #define ACPI_MADT_GET_TRIGGER(inti)	ACPI_MADT_GET_(TRIGGER, inti)
>  
> +#define BAD_MADT_ENTRY(entry, end) (                                        \
> +                (!entry) || (unsigned long)entry + sizeof(*entry) > end ||  \
> +                ((struct acpi_subtable_header *)entry)->length < sizeof(*entry))
> +
>  #ifdef CONFIG_ACPI_BOOT
>  
>  enum acpi_interrupt_id {
> -- 
> 2.0.4
> 
> 

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

* Re: [PATCH v4 05/21] arm/acpi: Add basic ACPI initialization
  2016-01-28 10:33     ` Shannon Zhao
@ 2016-01-28 10:44       ` Stefano Stabellini
  2016-01-28 11:18         ` Shannon Zhao
  0 siblings, 1 reply; 62+ messages in thread
From: Stefano Stabellini @ 2016-01-28 10:44 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: ian.campbell, Stefano Stabellini, peter.huangpeng, xen-devel,
	julien.grall, stefano.stabellini, shannon.zhao

On Thu, 28 Jan 2016, Shannon Zhao wrote:
> On 2016/1/27 22:54, Stefano Stabellini wrote:
> > On Sat, 23 Jan 2016, Shannon Zhao wrote:
> >> > From: Shannon Zhao <shannon.zhao@linaro.org>
> >> > 
> >> > acpi_boot_table_init() will be called in start_xen to get the RSDP and
> >> > all the table pointers. With this patch, we can get ACPI boot-time
> >> > tables from firmware on ARM64.
> >> > 
> >> > Signed-off-by: Naresh Bhat <naresh.bhat@linaro.org>
> >> > Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
> >> > Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> >> > ---
> >> >  xen/arch/arm/acpi/Makefile |  1 +
> >> >  xen/arch/arm/acpi/boot.c   | 58 ++++++++++++++++++++++++++++++++++++++++++++++
> >> >  xen/arch/arm/setup.c       |  4 ++++
> >> >  3 files changed, 63 insertions(+)
> >> >  create mode 100644 xen/arch/arm/acpi/boot.c
> >> > 
> >> > diff --git a/xen/arch/arm/acpi/Makefile b/xen/arch/arm/acpi/Makefile
> >> > index b5be22d..196c40a 100644
> >> > --- a/xen/arch/arm/acpi/Makefile
> >> > +++ b/xen/arch/arm/acpi/Makefile
> >> > @@ -1 +1,2 @@
> >> >  obj-y += lib.o
> >> > +obj-y += boot.o
> >> > diff --git a/xen/arch/arm/acpi/boot.c b/xen/arch/arm/acpi/boot.c
> >> > new file mode 100644
> >> > index 0000000..1570f7e
> >> > --- /dev/null
> >> > +++ b/xen/arch/arm/acpi/boot.c
> >> > @@ -0,0 +1,58 @@
> >> > +/*
> >> > + *  ARM Specific Low-Level ACPI Boot Support
> >> > + *
> >> > + *  Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
> >> > + *  Copyright (C) 2001 Jun Nakajima <jun.nakajima@intel.com>
> >> > + *  Copyright (C) 2014, Naresh Bhat <naresh.bhat@linaro.org>
> >> > + *  Copyright (C) 2015, Shannon Zhao <shannon.zhao@linaro.org>
> >> > + *
> >> > + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >> > + *
> >> > + *  This program is free software; you can redistribute it and/or modify
> >> > + *  it under the terms of the GNU General Public License as published by
> >> > + *  the Free Software Foundation; either version 2 of the License, or
> >> > + *  (at your option) any later version.
> >> > + *
> >> > + *  This program is distributed in the hope that it will be useful,
> >> > + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
> >> > + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> >> > + *  GNU General Public License for more details.
> >> > + *
> >> > + *  You should have received a copy of the GNU General Public License
> >> > + *  along with this program; if not, write to the Free Software
> >> > + *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
> >> > + *
> >> > + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >> > + */
> >> > +
> >> > +#include <xen/init.h>
> >> > +#include <xen/acpi.h>
> >> > +
> >> > +#include <asm/acpi.h>
> >> > +
> >> > +/*
> >> > + * 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
> >> > + *
> >> > + * return value: (currently ignored)
> >> > + *	0: success
> >> > + *	!0: failure
> >> > + *
> >> > + * We can parse ACPI boot-time tables such as FADT, MADT after
> >> > + * this function is called.
> >> > + */
> >> > +int __init acpi_boot_table_init(void)
> >> > +{
> >> > +    int error;
> >> > +
> >> > +    /* Initialize the ACPI boot-time table parser. */
> >> > +    error = acpi_table_init();
> >> > +    if ( error )
> >> > +    {
> >> > +        disable_acpi();
> >> > +        return error;
> >> > +    }
> >> > +
> >> > +    return 0;
> >> > +}
> >> > diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
> >> > index 0ba601e..c15a09d 100644
> >> > --- a/xen/arch/arm/setup.c
> >> > +++ b/xen/arch/arm/setup.c
> >> > @@ -36,6 +36,7 @@
> >> >  #include <xen/pfn.h>
> >> >  #include <xen/vmap.h>
> >> >  #include <xen/libfdt/libfdt.h>
> >> > +#include <xen/acpi.h>
> >> >  #include <asm/page.h>
> >> >  #include <asm/current.h>
> >> >  #include <asm/setup.h>
> >> > @@ -749,6 +750,9 @@ void __init start_xen(unsigned long boot_phys_offset,
> >> >  
> >> >      setup_mm(fdt_paddr, fdt_size);
> >> >  
> >> > +    /* Parse the ACPI tables for possible boot-time configuration */
> >> > +    acpi_boot_table_init();
> > As I asked before, why do you need to call acpi_boot_table_init() before
> > vm_init?  If you called acpi_boot_table_init() after vm_init(), you
> > could implement __acpi_map_table with vmap, which would be better.
> > 
> Yes, if we call acpi_boot_table_init() before vm_init, it needs to move
> end_boot_allocator after acpi_boot_table_init because it will assert in
> acpi_os_zalloc_memory.

Why does acpi_os_zalloc_memory assert exactly?


> TBH, I'm not sure where acpi_boot_table_init should be called. The
> current way refers to x86.

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

* Re: [PATCH v4 09/21] arm/acpi: Add ACPI support for SMP initialization
  2016-01-23  9:20 ` [PATCH v4 09/21] arm/acpi: Add ACPI support for SMP initialization Shannon Zhao
@ 2016-01-28 10:56   ` Stefano Stabellini
  0 siblings, 0 replies; 62+ messages in thread
From: Stefano Stabellini @ 2016-01-28 10:56 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: ian.campbell, stefano.stabellini, peter.huangpeng, xen-devel,
	julien.grall, stefano.stabellini, shannon.zhao

On Sat, 23 Jan 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> 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.
> 
> ACPI only supports PSCI 0.2+, since prior to PSCI 0.2 function IDs are
> not well-defined.
> 
> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>

Reviewed-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>


> V4: explain why only support PSCI 0.2+ and print an error message for
>     PSCI 0.1 and SMC not present
> ---
> 
>  xen/arch/arm/arm64/smpboot.c |  7 ++++++-
>  xen/arch/arm/psci.c          | 35 ++++++++++++++++++++++++++++-------
>  xen/arch/arm/smpboot.c       |  7 ++++++-
>  3 files changed, 40 insertions(+), 9 deletions(-)
> 
> diff --git a/xen/arch/arm/arm64/smpboot.c b/xen/arch/arm/arm64/smpboot.c
> index 7928f69..4fd0ac6 100644
> --- a/xen/arch/arm/arm64/smpboot.c
> +++ b/xen/arch/arm/arm64/smpboot.c
> @@ -7,6 +7,7 @@
>  #include <xen/vmap.h>
>  #include <asm/io.h>
>  #include <asm/psci.h>
> +#include <asm/acpi.h>
>  
>  struct smp_enable_ops {
>          int             (*prepare_cpu)(int);
> @@ -96,7 +97,11 @@ static int __init dt_arch_cpu_init(int cpu, struct dt_device_node *dn)
>  
>  int __init arch_cpu_init(int cpu, struct dt_device_node *dn)
>  {
> -    return dt_arch_cpu_init(cpu, dn);
> +    if ( acpi_disabled )
> +        return dt_arch_cpu_init(cpu, dn);
> +    else
> +        /* acpi only supports psci at present */
> +        return smp_psci_init(cpu);
>  }
>  
>  int __init arch_cpu_up(int cpu)
> diff --git a/xen/arch/arm/psci.c b/xen/arch/arm/psci.c
> index d800cb6..7966b5e 100644
> --- a/xen/arch/arm/psci.c
> +++ b/xen/arch/arm/psci.c
> @@ -22,6 +22,7 @@
>  #include <xen/mm.h>
>  #include <xen/smp.h>
>  #include <asm/psci.h>
> +#include <asm/acpi.h>
>  
>  /*
>   * While a 64-bit OS can make calls with SMC32 calling conventions, for
> @@ -86,6 +87,12 @@ int __init psci_init_0_1(void)
>      int ret;
>      const struct dt_device_node *psci;
>  
> +    if ( !acpi_disabled )
> +    {
> +        printk("PSCI 0.1 is not supported when using ACPI\n");
> +        return -EINVAL;
> +    }
> +
>      psci = dt_find_compatible_node(NULL, NULL, "arm,psci");
>      if ( !psci )
>          return -EOPNOTSUPP;
> @@ -116,15 +123,26 @@ int __init psci_init_0_2(void)
>          { /* sentinel */ },
>      };
>      int ret;
> -    const struct dt_device_node *psci;
>  
> -    psci = dt_find_matching_node(NULL, psci_ids);
> -    if ( !psci )
> -        return -EOPNOTSUPP;
> +    if ( acpi_disabled )
> +    {
> +        const struct dt_device_node *psci;
>  
> -    ret = psci_is_smc_method(psci);
> -    if ( ret )
> -        return -EINVAL;
> +        psci = dt_find_matching_node(NULL, psci_ids);
> +        if ( !psci )
> +            return -EOPNOTSUPP;
> +
> +        ret = psci_is_smc_method(psci);
> +        if ( ret )
> +            return -EINVAL;
> +    }
> +    else
> +    {
> +        if ( acpi_psci_hvc_present() ) {
> +            printk("PSCI conduit must be SMC, but is HVC\n");
> +            return -EINVAL;
> +        }
> +    }
>  
>      psci_ver = call_smc(PSCI_0_2_FN_PSCI_VERSION, 0, 0, 0);
>  
> @@ -148,6 +166,9 @@ int __init psci_init(void)
>  {
>      int ret;
>  
> +    if ( !acpi_disabled && !acpi_psci_present() )
> +        return -EOPNOTSUPP;
> +
>      ret = psci_init_0_2();
>      if ( ret )
>          ret = psci_init_0_1();
> diff --git a/xen/arch/arm/smpboot.c b/xen/arch/arm/smpboot.c
> index b6119d1..c5109bf 100644
> --- a/xen/arch/arm/smpboot.c
> +++ b/xen/arch/arm/smpboot.c
> @@ -31,6 +31,7 @@
>  #include <xen/console.h>
>  #include <asm/gic.h>
>  #include <asm/psci.h>
> +#include <asm/acpi.h>
>  
>  cpumask_t cpu_online_map;
>  cpumask_t cpu_present_map;
> @@ -247,7 +248,11 @@ void __init smp_init_cpus(void)
>          return;
>      }
>  
> -    dt_smp_init_cpus();
> +    if ( acpi_disabled )
> +        dt_smp_init_cpus();
> +    else
> +        acpi_smp_init_cpus();
> +
>  }
>  
>  int __init
> -- 
> 2.0.4
> 
> 

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

* Re: [PATCH v4 05/21] arm/acpi: Add basic ACPI initialization
  2016-01-28 10:44       ` Stefano Stabellini
@ 2016-01-28 11:18         ` Shannon Zhao
  2016-01-28 11:27           ` Stefano Stabellini
  0 siblings, 1 reply; 62+ messages in thread
From: Shannon Zhao @ 2016-01-28 11:18 UTC (permalink / raw)
  To: Stefano Stabellini
  Cc: ian.campbell, peter.huangpeng, xen-devel, julien.grall,
	stefano.stabellini, shannon.zhao



On 2016/1/28 18:44, Stefano Stabellini wrote:
> On Thu, 28 Jan 2016, Shannon Zhao wrote:
>> > On 2016/1/27 22:54, Stefano Stabellini wrote:
>>> > > On Sat, 23 Jan 2016, Shannon Zhao wrote:
>>>>> > >> > From: Shannon Zhao <shannon.zhao@linaro.org>
>>>>> > >> > 
>>>>> > >> > acpi_boot_table_init() will be called in start_xen to get the RSDP and
>>>>> > >> > all the table pointers. With this patch, we can get ACPI boot-time
>>>>> > >> > tables from firmware on ARM64.
>>>>> > >> > 
>>>>> > >> > Signed-off-by: Naresh Bhat <naresh.bhat@linaro.org>
>>>>> > >> > Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
>>>>> > >> > Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
>>>>> > >> > ---
>>>>> > >> >  xen/arch/arm/acpi/Makefile |  1 +
>>>>> > >> >  xen/arch/arm/acpi/boot.c   | 58 ++++++++++++++++++++++++++++++++++++++++++++++
>>>>> > >> >  xen/arch/arm/setup.c       |  4 ++++
>>>>> > >> >  3 files changed, 63 insertions(+)
>>>>> > >> >  create mode 100644 xen/arch/arm/acpi/boot.c
>>>>> > >> > 
>>>>> > >> > diff --git a/xen/arch/arm/acpi/Makefile b/xen/arch/arm/acpi/Makefile
>>>>> > >> > index b5be22d..196c40a 100644
>>>>> > >> > --- a/xen/arch/arm/acpi/Makefile
>>>>> > >> > +++ b/xen/arch/arm/acpi/Makefile
>>>>> > >> > @@ -1 +1,2 @@
>>>>> > >> >  obj-y += lib.o
>>>>> > >> > +obj-y += boot.o
>>>>> > >> > diff --git a/xen/arch/arm/acpi/boot.c b/xen/arch/arm/acpi/boot.c
>>>>> > >> > new file mode 100644
>>>>> > >> > index 0000000..1570f7e
>>>>> > >> > --- /dev/null
>>>>> > >> > +++ b/xen/arch/arm/acpi/boot.c
>>>>> > >> > @@ -0,0 +1,58 @@
>>>>> > >> > +/*
>>>>> > >> > + *  ARM Specific Low-Level ACPI Boot Support
>>>>> > >> > + *
>>>>> > >> > + *  Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
>>>>> > >> > + *  Copyright (C) 2001 Jun Nakajima <jun.nakajima@intel.com>
>>>>> > >> > + *  Copyright (C) 2014, Naresh Bhat <naresh.bhat@linaro.org>
>>>>> > >> > + *  Copyright (C) 2015, Shannon Zhao <shannon.zhao@linaro.org>
>>>>> > >> > + *
>>>>> > >> > + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>>>> > >> > + *
>>>>> > >> > + *  This program is free software; you can redistribute it and/or modify
>>>>> > >> > + *  it under the terms of the GNU General Public License as published by
>>>>> > >> > + *  the Free Software Foundation; either version 2 of the License, or
>>>>> > >> > + *  (at your option) any later version.
>>>>> > >> > + *
>>>>> > >> > + *  This program is distributed in the hope that it will be useful,
>>>>> > >> > + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
>>>>> > >> > + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>>>>> > >> > + *  GNU General Public License for more details.
>>>>> > >> > + *
>>>>> > >> > + *  You should have received a copy of the GNU General Public License
>>>>> > >> > + *  along with this program; if not, write to the Free Software
>>>>> > >> > + *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
>>>>> > >> > + *
>>>>> > >> > + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>>>> > >> > + */
>>>>> > >> > +
>>>>> > >> > +#include <xen/init.h>
>>>>> > >> > +#include <xen/acpi.h>
>>>>> > >> > +
>>>>> > >> > +#include <asm/acpi.h>
>>>>> > >> > +
>>>>> > >> > +/*
>>>>> > >> > + * 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
>>>>> > >> > + *
>>>>> > >> > + * return value: (currently ignored)
>>>>> > >> > + *	0: success
>>>>> > >> > + *	!0: failure
>>>>> > >> > + *
>>>>> > >> > + * We can parse ACPI boot-time tables such as FADT, MADT after
>>>>> > >> > + * this function is called.
>>>>> > >> > + */
>>>>> > >> > +int __init acpi_boot_table_init(void)
>>>>> > >> > +{
>>>>> > >> > +    int error;
>>>>> > >> > +
>>>>> > >> > +    /* Initialize the ACPI boot-time table parser. */
>>>>> > >> > +    error = acpi_table_init();
>>>>> > >> > +    if ( error )
>>>>> > >> > +    {
>>>>> > >> > +        disable_acpi();
>>>>> > >> > +        return error;
>>>>> > >> > +    }
>>>>> > >> > +
>>>>> > >> > +    return 0;
>>>>> > >> > +}
>>>>> > >> > diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
>>>>> > >> > index 0ba601e..c15a09d 100644
>>>>> > >> > --- a/xen/arch/arm/setup.c
>>>>> > >> > +++ b/xen/arch/arm/setup.c
>>>>> > >> > @@ -36,6 +36,7 @@
>>>>> > >> >  #include <xen/pfn.h>
>>>>> > >> >  #include <xen/vmap.h>
>>>>> > >> >  #include <xen/libfdt/libfdt.h>
>>>>> > >> > +#include <xen/acpi.h>
>>>>> > >> >  #include <asm/page.h>
>>>>> > >> >  #include <asm/current.h>
>>>>> > >> >  #include <asm/setup.h>
>>>>> > >> > @@ -749,6 +750,9 @@ void __init start_xen(unsigned long boot_phys_offset,
>>>>> > >> >  
>>>>> > >> >      setup_mm(fdt_paddr, fdt_size);
>>>>> > >> >  
>>>>> > >> > +    /* Parse the ACPI tables for possible boot-time configuration */
>>>>> > >> > +    acpi_boot_table_init();
>>> > > As I asked before, why do you need to call acpi_boot_table_init() before
>>> > > vm_init?  If you called acpi_boot_table_init() after vm_init(), you
>>> > > could implement __acpi_map_table with vmap, which would be better.
>>> > > 
>> > Yes, if we call acpi_boot_table_init() before vm_init, it needs to move
>> > end_boot_allocator after acpi_boot_table_init because it will assert in
>> > acpi_os_zalloc_memory.
> Why does acpi_os_zalloc_memory assert exactly?
> 

If call acpi_boot_table_init after end_boot_allocator, system_state !=
SYS_STATE_early_boot, acpi_os_zalloc_memory will call xzalloc_bytes to
malloc memory but vm_init is not called, so the ASSERT(!ptr ||
is_xmalloc_memory(ptr)) will occurs.

void *__init acpi_os_zalloc_memory(size_t sz)
{
	void *ptr;

	if (system_state != SYS_STATE_early_boot) {
		ptr = xzalloc_bytes(sz);
		ASSERT(!ptr || is_xmalloc_memory(ptr));
		return ptr;
	}
	ptr = acpi_os_alloc_memory(sz);
	return ptr ? memset(ptr, 0, sz) : NULL;
}

-- 
Shannon

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

* Re: [PATCH v4 05/21] arm/acpi: Add basic ACPI initialization
  2016-01-28 11:18         ` Shannon Zhao
@ 2016-01-28 11:27           ` Stefano Stabellini
  2016-01-28 11:53             ` Shannon Zhao
  0 siblings, 1 reply; 62+ messages in thread
From: Stefano Stabellini @ 2016-01-28 11:27 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: ian.campbell, Stefano Stabellini, peter.huangpeng, xen-devel,
	julien.grall, stefano.stabellini, shannon.zhao

On Thu, 28 Jan 2016, Shannon Zhao wrote:
> On 2016/1/28 18:44, Stefano Stabellini wrote:
> > On Thu, 28 Jan 2016, Shannon Zhao wrote:
> >> > On 2016/1/27 22:54, Stefano Stabellini wrote:
> >>> > > On Sat, 23 Jan 2016, Shannon Zhao wrote:
> >>>>> > >> > From: Shannon Zhao <shannon.zhao@linaro.org>
> >>>>> > >> > 
> >>>>> > >> > acpi_boot_table_init() will be called in start_xen to get the RSDP and
> >>>>> > >> > all the table pointers. With this patch, we can get ACPI boot-time
> >>>>> > >> > tables from firmware on ARM64.
> >>>>> > >> > 
> >>>>> > >> > Signed-off-by: Naresh Bhat <naresh.bhat@linaro.org>
> >>>>> > >> > Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
> >>>>> > >> > Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> >>>>> > >> > ---
> >>>>> > >> >  xen/arch/arm/acpi/Makefile |  1 +
> >>>>> > >> >  xen/arch/arm/acpi/boot.c   | 58 ++++++++++++++++++++++++++++++++++++++++++++++
> >>>>> > >> >  xen/arch/arm/setup.c       |  4 ++++
> >>>>> > >> >  3 files changed, 63 insertions(+)
> >>>>> > >> >  create mode 100644 xen/arch/arm/acpi/boot.c
> >>>>> > >> > 
> >>>>> > >> > diff --git a/xen/arch/arm/acpi/Makefile b/xen/arch/arm/acpi/Makefile
> >>>>> > >> > index b5be22d..196c40a 100644
> >>>>> > >> > --- a/xen/arch/arm/acpi/Makefile
> >>>>> > >> > +++ b/xen/arch/arm/acpi/Makefile
> >>>>> > >> > @@ -1 +1,2 @@
> >>>>> > >> >  obj-y += lib.o
> >>>>> > >> > +obj-y += boot.o
> >>>>> > >> > diff --git a/xen/arch/arm/acpi/boot.c b/xen/arch/arm/acpi/boot.c
> >>>>> > >> > new file mode 100644
> >>>>> > >> > index 0000000..1570f7e
> >>>>> > >> > --- /dev/null
> >>>>> > >> > +++ b/xen/arch/arm/acpi/boot.c
> >>>>> > >> > @@ -0,0 +1,58 @@
> >>>>> > >> > +/*
> >>>>> > >> > + *  ARM Specific Low-Level ACPI Boot Support
> >>>>> > >> > + *
> >>>>> > >> > + *  Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
> >>>>> > >> > + *  Copyright (C) 2001 Jun Nakajima <jun.nakajima@intel.com>
> >>>>> > >> > + *  Copyright (C) 2014, Naresh Bhat <naresh.bhat@linaro.org>
> >>>>> > >> > + *  Copyright (C) 2015, Shannon Zhao <shannon.zhao@linaro.org>
> >>>>> > >> > + *
> >>>>> > >> > + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >>>>> > >> > + *
> >>>>> > >> > + *  This program is free software; you can redistribute it and/or modify
> >>>>> > >> > + *  it under the terms of the GNU General Public License as published by
> >>>>> > >> > + *  the Free Software Foundation; either version 2 of the License, or
> >>>>> > >> > + *  (at your option) any later version.
> >>>>> > >> > + *
> >>>>> > >> > + *  This program is distributed in the hope that it will be useful,
> >>>>> > >> > + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
> >>>>> > >> > + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> >>>>> > >> > + *  GNU General Public License for more details.
> >>>>> > >> > + *
> >>>>> > >> > + *  You should have received a copy of the GNU General Public License
> >>>>> > >> > + *  along with this program; if not, write to the Free Software
> >>>>> > >> > + *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
> >>>>> > >> > + *
> >>>>> > >> > + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >>>>> > >> > + */
> >>>>> > >> > +
> >>>>> > >> > +#include <xen/init.h>
> >>>>> > >> > +#include <xen/acpi.h>
> >>>>> > >> > +
> >>>>> > >> > +#include <asm/acpi.h>
> >>>>> > >> > +
> >>>>> > >> > +/*
> >>>>> > >> > + * 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
> >>>>> > >> > + *
> >>>>> > >> > + * return value: (currently ignored)
> >>>>> > >> > + *	0: success
> >>>>> > >> > + *	!0: failure
> >>>>> > >> > + *
> >>>>> > >> > + * We can parse ACPI boot-time tables such as FADT, MADT after
> >>>>> > >> > + * this function is called.
> >>>>> > >> > + */
> >>>>> > >> > +int __init acpi_boot_table_init(void)
> >>>>> > >> > +{
> >>>>> > >> > +    int error;
> >>>>> > >> > +
> >>>>> > >> > +    /* Initialize the ACPI boot-time table parser. */
> >>>>> > >> > +    error = acpi_table_init();
> >>>>> > >> > +    if ( error )
> >>>>> > >> > +    {
> >>>>> > >> > +        disable_acpi();
> >>>>> > >> > +        return error;
> >>>>> > >> > +    }
> >>>>> > >> > +
> >>>>> > >> > +    return 0;
> >>>>> > >> > +}
> >>>>> > >> > diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
> >>>>> > >> > index 0ba601e..c15a09d 100644
> >>>>> > >> > --- a/xen/arch/arm/setup.c
> >>>>> > >> > +++ b/xen/arch/arm/setup.c
> >>>>> > >> > @@ -36,6 +36,7 @@
> >>>>> > >> >  #include <xen/pfn.h>
> >>>>> > >> >  #include <xen/vmap.h>
> >>>>> > >> >  #include <xen/libfdt/libfdt.h>
> >>>>> > >> > +#include <xen/acpi.h>
> >>>>> > >> >  #include <asm/page.h>
> >>>>> > >> >  #include <asm/current.h>
> >>>>> > >> >  #include <asm/setup.h>
> >>>>> > >> > @@ -749,6 +750,9 @@ void __init start_xen(unsigned long boot_phys_offset,
> >>>>> > >> >  
> >>>>> > >> >      setup_mm(fdt_paddr, fdt_size);
> >>>>> > >> >  
> >>>>> > >> > +    /* Parse the ACPI tables for possible boot-time configuration */
> >>>>> > >> > +    acpi_boot_table_init();
> >>> > > As I asked before, why do you need to call acpi_boot_table_init() before
> >>> > > vm_init?  If you called acpi_boot_table_init() after vm_init(), you
> >>> > > could implement __acpi_map_table with vmap, which would be better.
> >>> > > 
> >> > Yes, if we call acpi_boot_table_init() before vm_init, it needs to move
> >> > end_boot_allocator after acpi_boot_table_init because it will assert in
> >> > acpi_os_zalloc_memory.
> > Why does acpi_os_zalloc_memory assert exactly?
> > 
> 
> If call acpi_boot_table_init after end_boot_allocator, system_state !=
> SYS_STATE_early_boot,

Could you please point out where end_boot_allocator changes
system_state?


> acpi_os_zalloc_memory will call xzalloc_bytes to
> malloc memory but vm_init is not called, so the ASSERT(!ptr ||
> is_xmalloc_memory(ptr)) will occurs.
> 
> void *__init acpi_os_zalloc_memory(size_t sz)
> {
> 	void *ptr;
> 
> 	if (system_state != SYS_STATE_early_boot) {
> 		ptr = xzalloc_bytes(sz);
> 		ASSERT(!ptr || is_xmalloc_memory(ptr));
> 		return ptr;
> 	}
> 	ptr = acpi_os_alloc_memory(sz);
> 	return ptr ? memset(ptr, 0, sz) : NULL;
> }

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

* Re: [PATCH v4 05/21] arm/acpi: Add basic ACPI initialization
  2016-01-28 11:27           ` Stefano Stabellini
@ 2016-01-28 11:53             ` Shannon Zhao
  2016-01-28 12:38               ` Stefano Stabellini
  0 siblings, 1 reply; 62+ messages in thread
From: Shannon Zhao @ 2016-01-28 11:53 UTC (permalink / raw)
  To: Stefano Stabellini
  Cc: ian.campbell, peter.huangpeng, xen-devel, julien.grall,
	stefano.stabellini, shannon.zhao



On 2016/1/28 19:27, Stefano Stabellini wrote:
> On Thu, 28 Jan 2016, Shannon Zhao wrote:
>> On 2016/1/28 18:44, Stefano Stabellini wrote:
>>> On Thu, 28 Jan 2016, Shannon Zhao wrote:
>>>>> On 2016/1/27 22:54, Stefano Stabellini wrote:
>>>>>>> On Sat, 23 Jan 2016, Shannon Zhao wrote:
>>>>>>>>>>> From: Shannon Zhao <shannon.zhao@linaro.org>
>>>>>>>>>>>
>>>>>>>>>>> acpi_boot_table_init() will be called in start_xen to get the RSDP and
>>>>>>>>>>> all the table pointers. With this patch, we can get ACPI boot-time
>>>>>>>>>>> tables from firmware on ARM64.
>>>>>>>>>>>
>>>>>>>>>>> Signed-off-by: Naresh Bhat <naresh.bhat@linaro.org>
>>>>>>>>>>> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
>>>>>>>>>>> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
>>>>>>>>>>> ---
>>>>>>>>>>>  xen/arch/arm/acpi/Makefile |  1 +
>>>>>>>>>>>  xen/arch/arm/acpi/boot.c   | 58 ++++++++++++++++++++++++++++++++++++++++++++++
>>>>>>>>>>>  xen/arch/arm/setup.c       |  4 ++++
>>>>>>>>>>>  3 files changed, 63 insertions(+)
>>>>>>>>>>>  create mode 100644 xen/arch/arm/acpi/boot.c
>>>>>>>>>>>
>>>>>>>>>>> diff --git a/xen/arch/arm/acpi/Makefile b/xen/arch/arm/acpi/Makefile
>>>>>>>>>>> index b5be22d..196c40a 100644
>>>>>>>>>>> --- a/xen/arch/arm/acpi/Makefile
>>>>>>>>>>> +++ b/xen/arch/arm/acpi/Makefile
>>>>>>>>>>> @@ -1 +1,2 @@
>>>>>>>>>>>  obj-y += lib.o
>>>>>>>>>>> +obj-y += boot.o
>>>>>>>>>>> diff --git a/xen/arch/arm/acpi/boot.c b/xen/arch/arm/acpi/boot.c
>>>>>>>>>>> new file mode 100644
>>>>>>>>>>> index 0000000..1570f7e
>>>>>>>>>>> --- /dev/null
>>>>>>>>>>> +++ b/xen/arch/arm/acpi/boot.c
>>>>>>>>>>> @@ -0,0 +1,58 @@
>>>>>>>>>>> +/*
>>>>>>>>>>> + *  ARM Specific Low-Level ACPI Boot Support
>>>>>>>>>>> + *
>>>>>>>>>>> + *  Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
>>>>>>>>>>> + *  Copyright (C) 2001 Jun Nakajima <jun.nakajima@intel.com>
>>>>>>>>>>> + *  Copyright (C) 2014, Naresh Bhat <naresh.bhat@linaro.org>
>>>>>>>>>>> + *  Copyright (C) 2015, Shannon Zhao <shannon.zhao@linaro.org>
>>>>>>>>>>> + *
>>>>>>>>>>> + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>>>>>>>>>> + *
>>>>>>>>>>> + *  This program is free software; you can redistribute it and/or modify
>>>>>>>>>>> + *  it under the terms of the GNU General Public License as published by
>>>>>>>>>>> + *  the Free Software Foundation; either version 2 of the License, or
>>>>>>>>>>> + *  (at your option) any later version.
>>>>>>>>>>> + *
>>>>>>>>>>> + *  This program is distributed in the hope that it will be useful,
>>>>>>>>>>> + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
>>>>>>>>>>> + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>>>>>>>>>>> + *  GNU General Public License for more details.
>>>>>>>>>>> + *
>>>>>>>>>>> + *  You should have received a copy of the GNU General Public License
>>>>>>>>>>> + *  along with this program; if not, write to the Free Software
>>>>>>>>>>> + *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
>>>>>>>>>>> + *
>>>>>>>>>>> + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>>>>>>>>>> + */
>>>>>>>>>>> +
>>>>>>>>>>> +#include <xen/init.h>
>>>>>>>>>>> +#include <xen/acpi.h>
>>>>>>>>>>> +
>>>>>>>>>>> +#include <asm/acpi.h>
>>>>>>>>>>> +
>>>>>>>>>>> +/*
>>>>>>>>>>> + * 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
>>>>>>>>>>> + *
>>>>>>>>>>> + * return value: (currently ignored)
>>>>>>>>>>> + *	0: success
>>>>>>>>>>> + *	!0: failure
>>>>>>>>>>> + *
>>>>>>>>>>> + * We can parse ACPI boot-time tables such as FADT, MADT after
>>>>>>>>>>> + * this function is called.
>>>>>>>>>>> + */
>>>>>>>>>>> +int __init acpi_boot_table_init(void)
>>>>>>>>>>> +{
>>>>>>>>>>> +    int error;
>>>>>>>>>>> +
>>>>>>>>>>> +    /* Initialize the ACPI boot-time table parser. */
>>>>>>>>>>> +    error = acpi_table_init();
>>>>>>>>>>> +    if ( error )
>>>>>>>>>>> +    {
>>>>>>>>>>> +        disable_acpi();
>>>>>>>>>>> +        return error;
>>>>>>>>>>> +    }
>>>>>>>>>>> +
>>>>>>>>>>> +    return 0;
>>>>>>>>>>> +}
>>>>>>>>>>> diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
>>>>>>>>>>> index 0ba601e..c15a09d 100644
>>>>>>>>>>> --- a/xen/arch/arm/setup.c
>>>>>>>>>>> +++ b/xen/arch/arm/setup.c
>>>>>>>>>>> @@ -36,6 +36,7 @@
>>>>>>>>>>>  #include <xen/pfn.h>
>>>>>>>>>>>  #include <xen/vmap.h>
>>>>>>>>>>>  #include <xen/libfdt/libfdt.h>
>>>>>>>>>>> +#include <xen/acpi.h>
>>>>>>>>>>>  #include <asm/page.h>
>>>>>>>>>>>  #include <asm/current.h>
>>>>>>>>>>>  #include <asm/setup.h>
>>>>>>>>>>> @@ -749,6 +750,9 @@ void __init start_xen(unsigned long boot_phys_offset,
>>>>>>>>>>>  
>>>>>>>>>>>      setup_mm(fdt_paddr, fdt_size);
>>>>>>>>>>>  
>>>>>>>>>>> +    /* Parse the ACPI tables for possible boot-time configuration */
>>>>>>>>>>> +    acpi_boot_table_init();
>>>>>>> As I asked before, why do you need to call acpi_boot_table_init() before
>>>>>>> vm_init?  If you called acpi_boot_table_init() after vm_init(), you
>>>>>>> could implement __acpi_map_table with vmap, which would be better.
>>>>>>>
>>>>> Yes, if we call acpi_boot_table_init() before vm_init, it needs to move
>>>>> end_boot_allocator after acpi_boot_table_init because it will assert in
>>>>> acpi_os_zalloc_memory.
>>> Why does acpi_os_zalloc_memory assert exactly?
>>>
>>
>> If call acpi_boot_table_init after end_boot_allocator, system_state !=
>> SYS_STATE_early_boot,
> 
> Could you please point out where end_boot_allocator changes
> system_state?
> 
Oh, sorry, I see. It doesn't change the system_state. I mixed this with
the patch[1] which change the system_state to SYS_STATE_boot, then will
cause assert.

+    system_state = SYS_STATE_boot;
+
     vm_init();
+
+/*
+ * Parse the ACPI tables for possible boot-time configuration
+ */
+
+#if defined(CONFIG_ACPI) && defined(CONFIG_ARM_64)
+    acpi_boot_table_init();
+#endif

But current implementation doesn't do that so it won't cause assert.

While the true reason to move acpi_boot_table_init before
end_boot_allocator is NUMA support. There is a discussion about it, see [2].

[1]http://lists.xenproject.org/archives/html/xen-devel/2015-02/msg00491.html
[2]http://lists.xenproject.org/archives/html/xen-devel/2015-02/msg01157.html

-- 
Shannon

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

* Re: [PATCH v4 01/21] arm/acpi: Emulate io ports for arm
  2016-01-27 12:52   ` Stefano Stabellini
@ 2016-01-28 12:13     ` Shannon Zhao
  2016-01-28 12:35       ` Stefano Stabellini
  0 siblings, 1 reply; 62+ messages in thread
From: Shannon Zhao @ 2016-01-28 12:13 UTC (permalink / raw)
  To: Stefano Stabellini
  Cc: ian.campbell, peter.huangpeng, xen-devel, julien.grall,
	stefano.stabellini, shannon.zhao



On 2016/1/27 20:52, Stefano Stabellini wrote:
> On Sat, 23 Jan 2016, Shannon Zhao wrote:
>> From: Shannon Zhao <shannon.zhao@linaro.org>
>>
>> Add macros to emulate x86 style ports for arm. This avoids modification in
>> common code for acpi. Here just print a warning on ARM.
>>
>> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
>> ---
>> V4: print warning
>> ---
>>  xen/include/asm-arm/arm64/io.h | 18 ++++++++++++++++++
>>  1 file changed, 18 insertions(+)
>>
>> diff --git a/xen/include/asm-arm/arm64/io.h b/xen/include/asm-arm/arm64/io.h
>> index 37abc47..ec5815d 100644
>> --- a/xen/include/asm-arm/arm64/io.h
>> +++ b/xen/include/asm-arm/arm64/io.h
>> @@ -20,6 +20,7 @@
>>  #ifndef _ARM_ARM64_IO_H
>>  #define _ARM_ARM64_IO_H
>>  
>> +#include <asm/system.h>
>>  #include <asm/byteorder.h>
>>  
>>  /*
>> @@ -109,4 +110,21 @@ static inline u64 __raw_readq(const volatile void __iomem *addr)
>>  #define writel(v,c)             ({ __iowmb(); writel_relaxed((v),(c)); })
>>  #define writeq(v,c)             ({ __iowmb(); writeq_relaxed((v),(c)); })
>>  
>> +/*
>> + * Emulate x86 io ports for ARM.
>> + */
>> +static inline void __iomem * __armio(u64 addr)
>> +{
>> +    printk(XENLOG_G_WARNING "Can't access IO %lx\n", addr);
>> +    return (void __iomem *)addr;
>> +}
>> +
>> +#define inb(c) ( readb( __armio(c) ) )
>> +#define inw(c) ( readw( __armio(c) ) )
>> +#define inl(c) ( readl( __armio(c) ) )
>> +
>> +#define outb(v, c) ( writeb(v, __armio(c) ) )
>> +#define outw(v, c) ( writew(v, __armio(c) ) )
>> +#define outl(v, c) ( writel(v, __armio(c) ) )
> 
> This is better than before, but it would still end up causing a write to
> happen on outb, outw and outl. I would define them in a way so that
> only the warning gets printed when they are called and nothing else.
> 

How about this?

+/*
+ * Emulate x86 io ports for ARM.
+ */
+static inline int emulate_read(u64 addr)
+{
+    printk(XENLOG_G_WARNING "Can't access IO %lx\n", addr);
+    return 0;
+}
+
+static inline void emulate_write(u64 addr)
+{
+    printk(XENLOG_G_WARNING "Can't access IO %lx\n", addr);
+}
+
+#define inb(c) ( emulate_read(c) )
+#define inw(c) ( emulate_read(c) )
+#define inl(c) ( emulate_read(c) )
+
+#define outb(v, c) ( emulate_write(c) )
+#define outw(v, c) ( emulate_write(c) )
+#define outl(v, c) ( emulate_write(c) )

Thanks,
-- 
Shannon

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

* Re: [PATCH v4 19/21] arm/acpi: Initialize serial port from ACPI SPCR table
  2016-01-25 15:05   ` Jan Beulich
@ 2016-01-28 12:33     ` Shannon Zhao
  2016-01-28 12:59       ` Jan Beulich
  0 siblings, 1 reply; 62+ messages in thread
From: Shannon Zhao @ 2016-01-28 12:33 UTC (permalink / raw)
  To: Jan Beulich
  Cc: ian.campbell, stefano.stabellini, peter.huangpeng, xen-devel,
	julien.grall, stefano.stabellini, shannon.zhao



On 2016/1/25 23:05, Jan Beulich wrote:
>>>> On 23.01.16 at 10:20, <zhaoshenglong@huawei.com> wrote:
>> --- a/xen/include/acpi/actbl2.h
>> +++ b/xen/include/acpi/actbl2.h
>> @@ -815,6 +815,15 @@ struct acpi_table_spcr {
>>  
>>  #define ACPI_SPCR_DO_NOT_DISABLE    (1)
>>  
>> +/* SPCR Interface type */
>> +#define ACPI_SPCR_TYPE_16550		0
>> +#define ACPI_SPCR_TYPE_16550_SUB	0x1
>> +#define ACPI_SPCR_TYPE_PL011		0x3
>> +#define ACPI_SPCR_TYPE_SBSA_32		0xd
>> +#define ACPI_SPCR_TYPE_SBSA		0xe
>> +#define ACPI_SPCR_TYPE_DCC		0xf
>> +#define ACPI_SPCR_TYPE_BCM2835		0x10
> 
> It seems very likely to me that this part of the change actually would
> have a Linux counterpart, in which case it should be submitted as such.
> 

I checked it with Linux master. Those interface types are shared with
DGB2 table. But Linux master only adds ACPI_DBG2_16550_COMPATIBLE and
ACPI_DBG2_16550_SUBSET, doesn't have other types. And actually we only
need the interface type not the DBG2 table. Yes, it could port commit
[1] first then add other types. Is that fine?

[1]4e2f9c278ad84196991fcf6f6646a3e15967fe90

Thanks,
-- 
Shannon

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

* Re: [PATCH v4 01/21] arm/acpi: Emulate io ports for arm
  2016-01-28 12:13     ` Shannon Zhao
@ 2016-01-28 12:35       ` Stefano Stabellini
  0 siblings, 0 replies; 62+ messages in thread
From: Stefano Stabellini @ 2016-01-28 12:35 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: ian.campbell, Stefano Stabellini, peter.huangpeng, xen-devel,
	julien.grall, stefano.stabellini, shannon.zhao

On Thu, 28 Jan 2016, Shannon Zhao wrote:
> On 2016/1/27 20:52, Stefano Stabellini wrote:
> > On Sat, 23 Jan 2016, Shannon Zhao wrote:
> >> From: Shannon Zhao <shannon.zhao@linaro.org>
> >>
> >> Add macros to emulate x86 style ports for arm. This avoids modification in
> >> common code for acpi. Here just print a warning on ARM.
> >>
> >> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> >> ---
> >> V4: print warning
> >> ---
> >>  xen/include/asm-arm/arm64/io.h | 18 ++++++++++++++++++
> >>  1 file changed, 18 insertions(+)
> >>
> >> diff --git a/xen/include/asm-arm/arm64/io.h b/xen/include/asm-arm/arm64/io.h
> >> index 37abc47..ec5815d 100644
> >> --- a/xen/include/asm-arm/arm64/io.h
> >> +++ b/xen/include/asm-arm/arm64/io.h
> >> @@ -20,6 +20,7 @@
> >>  #ifndef _ARM_ARM64_IO_H
> >>  #define _ARM_ARM64_IO_H
> >>  
> >> +#include <asm/system.h>
> >>  #include <asm/byteorder.h>
> >>  
> >>  /*
> >> @@ -109,4 +110,21 @@ static inline u64 __raw_readq(const volatile void __iomem *addr)
> >>  #define writel(v,c)             ({ __iowmb(); writel_relaxed((v),(c)); })
> >>  #define writeq(v,c)             ({ __iowmb(); writeq_relaxed((v),(c)); })
> >>  
> >> +/*
> >> + * Emulate x86 io ports for ARM.
> >> + */
> >> +static inline void __iomem * __armio(u64 addr)
> >> +{
> >> +    printk(XENLOG_G_WARNING "Can't access IO %lx\n", addr);
> >> +    return (void __iomem *)addr;
> >> +}
> >> +
> >> +#define inb(c) ( readb( __armio(c) ) )
> >> +#define inw(c) ( readw( __armio(c) ) )
> >> +#define inl(c) ( readl( __armio(c) ) )
> >> +
> >> +#define outb(v, c) ( writeb(v, __armio(c) ) )
> >> +#define outw(v, c) ( writew(v, __armio(c) ) )
> >> +#define outl(v, c) ( writel(v, __armio(c) ) )
> > 
> > This is better than before, but it would still end up causing a write to
> > happen on outb, outw and outl. I would define them in a way so that
> > only the warning gets printed when they are called and nothing else.
> > 
> 
> How about this?

That's good


> +/*
> + * Emulate x86 io ports for ARM.
> + */
> +static inline int emulate_read(u64 addr)
> +{
> +    printk(XENLOG_G_WARNING "Can't access IO %lx\n", addr);
> +    return 0;
> +}
> +
> +static inline void emulate_write(u64 addr)
> +{
> +    printk(XENLOG_G_WARNING "Can't access IO %lx\n", addr);
> +}
> +
> +#define inb(c) ( emulate_read(c) )
> +#define inw(c) ( emulate_read(c) )
> +#define inl(c) ( emulate_read(c) )
> +
> +#define outb(v, c) ( emulate_write(c) )
> +#define outw(v, c) ( emulate_write(c) )
> +#define outl(v, c) ( emulate_write(c) )
> 
> Thanks,
> -- 
> Shannon
> 

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

* Re: [PATCH v4 05/21] arm/acpi: Add basic ACPI initialization
  2016-01-28 11:53             ` Shannon Zhao
@ 2016-01-28 12:38               ` Stefano Stabellini
  0 siblings, 0 replies; 62+ messages in thread
From: Stefano Stabellini @ 2016-01-28 12:38 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: ian.campbell, Stefano Stabellini, peter.huangpeng, xen-devel,
	julien.grall, stefano.stabellini, shannon.zhao

On Thu, 28 Jan 2016, Shannon Zhao wrote:
> On 2016/1/28 19:27, Stefano Stabellini wrote:
> > On Thu, 28 Jan 2016, Shannon Zhao wrote:
> >> On 2016/1/28 18:44, Stefano Stabellini wrote:
> >>> On Thu, 28 Jan 2016, Shannon Zhao wrote:
> >>>>> On 2016/1/27 22:54, Stefano Stabellini wrote:
> >>>>>>> On Sat, 23 Jan 2016, Shannon Zhao wrote:
> >>>>>>>>>>> From: Shannon Zhao <shannon.zhao@linaro.org>
> >>>>>>>>>>>
> >>>>>>>>>>> acpi_boot_table_init() will be called in start_xen to get the RSDP and
> >>>>>>>>>>> all the table pointers. With this patch, we can get ACPI boot-time
> >>>>>>>>>>> tables from firmware on ARM64.
> >>>>>>>>>>>
> >>>>>>>>>>> Signed-off-by: Naresh Bhat <naresh.bhat@linaro.org>
> >>>>>>>>>>> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
> >>>>>>>>>>> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> >>>>>>>>>>> ---
> >>>>>>>>>>>  xen/arch/arm/acpi/Makefile |  1 +
> >>>>>>>>>>>  xen/arch/arm/acpi/boot.c   | 58 ++++++++++++++++++++++++++++++++++++++++++++++
> >>>>>>>>>>>  xen/arch/arm/setup.c       |  4 ++++
> >>>>>>>>>>>  3 files changed, 63 insertions(+)
> >>>>>>>>>>>  create mode 100644 xen/arch/arm/acpi/boot.c
> >>>>>>>>>>>
> >>>>>>>>>>> diff --git a/xen/arch/arm/acpi/Makefile b/xen/arch/arm/acpi/Makefile
> >>>>>>>>>>> index b5be22d..196c40a 100644
> >>>>>>>>>>> --- a/xen/arch/arm/acpi/Makefile
> >>>>>>>>>>> +++ b/xen/arch/arm/acpi/Makefile
> >>>>>>>>>>> @@ -1 +1,2 @@
> >>>>>>>>>>>  obj-y += lib.o
> >>>>>>>>>>> +obj-y += boot.o
> >>>>>>>>>>> diff --git a/xen/arch/arm/acpi/boot.c b/xen/arch/arm/acpi/boot.c
> >>>>>>>>>>> new file mode 100644
> >>>>>>>>>>> index 0000000..1570f7e
> >>>>>>>>>>> --- /dev/null
> >>>>>>>>>>> +++ b/xen/arch/arm/acpi/boot.c
> >>>>>>>>>>> @@ -0,0 +1,58 @@
> >>>>>>>>>>> +/*
> >>>>>>>>>>> + *  ARM Specific Low-Level ACPI Boot Support
> >>>>>>>>>>> + *
> >>>>>>>>>>> + *  Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
> >>>>>>>>>>> + *  Copyright (C) 2001 Jun Nakajima <jun.nakajima@intel.com>
> >>>>>>>>>>> + *  Copyright (C) 2014, Naresh Bhat <naresh.bhat@linaro.org>
> >>>>>>>>>>> + *  Copyright (C) 2015, Shannon Zhao <shannon.zhao@linaro.org>
> >>>>>>>>>>> + *
> >>>>>>>>>>> + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >>>>>>>>>>> + *
> >>>>>>>>>>> + *  This program is free software; you can redistribute it and/or modify
> >>>>>>>>>>> + *  it under the terms of the GNU General Public License as published by
> >>>>>>>>>>> + *  the Free Software Foundation; either version 2 of the License, or
> >>>>>>>>>>> + *  (at your option) any later version.
> >>>>>>>>>>> + *
> >>>>>>>>>>> + *  This program is distributed in the hope that it will be useful,
> >>>>>>>>>>> + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
> >>>>>>>>>>> + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> >>>>>>>>>>> + *  GNU General Public License for more details.
> >>>>>>>>>>> + *
> >>>>>>>>>>> + *  You should have received a copy of the GNU General Public License
> >>>>>>>>>>> + *  along with this program; if not, write to the Free Software
> >>>>>>>>>>> + *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
> >>>>>>>>>>> + *
> >>>>>>>>>>> + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >>>>>>>>>>> + */
> >>>>>>>>>>> +
> >>>>>>>>>>> +#include <xen/init.h>
> >>>>>>>>>>> +#include <xen/acpi.h>
> >>>>>>>>>>> +
> >>>>>>>>>>> +#include <asm/acpi.h>
> >>>>>>>>>>> +
> >>>>>>>>>>> +/*
> >>>>>>>>>>> + * 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
> >>>>>>>>>>> + *
> >>>>>>>>>>> + * return value: (currently ignored)
> >>>>>>>>>>> + *	0: success
> >>>>>>>>>>> + *	!0: failure
> >>>>>>>>>>> + *
> >>>>>>>>>>> + * We can parse ACPI boot-time tables such as FADT, MADT after
> >>>>>>>>>>> + * this function is called.
> >>>>>>>>>>> + */
> >>>>>>>>>>> +int __init acpi_boot_table_init(void)
> >>>>>>>>>>> +{
> >>>>>>>>>>> +    int error;
> >>>>>>>>>>> +
> >>>>>>>>>>> +    /* Initialize the ACPI boot-time table parser. */
> >>>>>>>>>>> +    error = acpi_table_init();
> >>>>>>>>>>> +    if ( error )
> >>>>>>>>>>> +    {
> >>>>>>>>>>> +        disable_acpi();
> >>>>>>>>>>> +        return error;
> >>>>>>>>>>> +    }
> >>>>>>>>>>> +
> >>>>>>>>>>> +    return 0;
> >>>>>>>>>>> +}
> >>>>>>>>>>> diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
> >>>>>>>>>>> index 0ba601e..c15a09d 100644
> >>>>>>>>>>> --- a/xen/arch/arm/setup.c
> >>>>>>>>>>> +++ b/xen/arch/arm/setup.c
> >>>>>>>>>>> @@ -36,6 +36,7 @@
> >>>>>>>>>>>  #include <xen/pfn.h>
> >>>>>>>>>>>  #include <xen/vmap.h>
> >>>>>>>>>>>  #include <xen/libfdt/libfdt.h>
> >>>>>>>>>>> +#include <xen/acpi.h>
> >>>>>>>>>>>  #include <asm/page.h>
> >>>>>>>>>>>  #include <asm/current.h>
> >>>>>>>>>>>  #include <asm/setup.h>
> >>>>>>>>>>> @@ -749,6 +750,9 @@ void __init start_xen(unsigned long boot_phys_offset,
> >>>>>>>>>>>  
> >>>>>>>>>>>      setup_mm(fdt_paddr, fdt_size);
> >>>>>>>>>>>  
> >>>>>>>>>>> +    /* Parse the ACPI tables for possible boot-time configuration */
> >>>>>>>>>>> +    acpi_boot_table_init();
> >>>>>>> As I asked before, why do you need to call acpi_boot_table_init() before
> >>>>>>> vm_init?  If you called acpi_boot_table_init() after vm_init(), you
> >>>>>>> could implement __acpi_map_table with vmap, which would be better.
> >>>>>>>
> >>>>> Yes, if we call acpi_boot_table_init() before vm_init, it needs to move
> >>>>> end_boot_allocator after acpi_boot_table_init because it will assert in
> >>>>> acpi_os_zalloc_memory.
> >>> Why does acpi_os_zalloc_memory assert exactly?
> >>>
> >>
> >> If call acpi_boot_table_init after end_boot_allocator, system_state !=
> >> SYS_STATE_early_boot,
> > 
> > Could you please point out where end_boot_allocator changes
> > system_state?
> > 
> Oh, sorry, I see. It doesn't change the system_state. I mixed this with
> the patch[1] which change the system_state to SYS_STATE_boot, then will
> cause assert.
> 
> +    system_state = SYS_STATE_boot;
> +
>      vm_init();
> +
> +/*
> + * Parse the ACPI tables for possible boot-time configuration
> + */
> +
> +#if defined(CONFIG_ACPI) && defined(CONFIG_ARM_64)
> +    acpi_boot_table_init();
> +#endif
> 
> But current implementation doesn't do that so it won't cause assert.
> 
> While the true reason to move acpi_boot_table_init before
> end_boot_allocator is NUMA support. There is a discussion about it, see [2].
> 
> [1]http://lists.xenproject.org/archives/html/xen-devel/2015-02/msg00491.html
> [2]http://lists.xenproject.org/archives/html/xen-devel/2015-02/msg01157.html
 
All right, that's a good reason. Please fix the commit message of the
patch that moves end_boot_allocator. Also mention that it's done this
way on x86 too.

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

* Re: [PATCH v4 11/21] arm: Introduce a generic way to use a device from acpi
  2016-01-23  9:20 ` [PATCH v4 11/21] arm: Introduce a generic way to use a device from acpi Shannon Zhao
@ 2016-01-28 12:45   ` Stefano Stabellini
  0 siblings, 0 replies; 62+ messages in thread
From: Stefano Stabellini @ 2016-01-28 12:45 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: ian.campbell, stefano.stabellini, peter.huangpeng, xen-devel,
	julien.grall, stefano.stabellini, shannon.zhao

On Sat, 23 Jan 2016, Shannon Zhao wrote:
> From: Parth Dixit <parth.dixit@linaro.org>
> 
> Add generic way to use device from acpi similar to the way it is
> supported in device tree.
> 
> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>

Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>


> V4: drop __attribute__ 
> ---
>  xen/arch/arm/device.c        | 18 ++++++++++++++++++
>  xen/arch/arm/xen.lds.S       |  7 +++++++
>  xen/include/asm-arm/device.h | 30 ++++++++++++++++++++++++++++++
>  3 files changed, 55 insertions(+)
> 
> diff --git a/xen/arch/arm/device.c b/xen/arch/arm/device.c
> index 0b53f6a..a0072c1 100644
> --- a/xen/arch/arm/device.c
> +++ b/xen/arch/arm/device.c
> @@ -22,6 +22,7 @@
>  #include <xen/lib.h>
>  
>  extern const struct device_desc _sdevice[], _edevice[];
> +extern const struct acpi_device_desc _asdevice[], _aedevice[];
>  
>  int __init device_init(struct dt_device_node *dev, enum device_class class,
>                         const void *data)
> @@ -50,6 +51,23 @@ int __init device_init(struct dt_device_node *dev, enum device_class class,
>      return -EBADF;
>  }
>  
> +int __init acpi_device_init(enum device_class class, const void *data, int class_type)
> +{
> +    const struct acpi_device_desc *desc;
> +
> +    for ( desc = _asdevice; desc != _aedevice; desc++ )
> +    {
> +        if ( ( desc->class != class ) || ( desc->class_type != class_type ) )
> +            continue;
> +
> +        ASSERT(desc->init != NULL);
> +
> +        return desc->init(data);
> +    }
> +
> +    return -EBADF;
> +}
> +
>  enum device_class device_get_class(const struct dt_device_node *dev)
>  {
>      const struct device_desc *desc;
> diff --git a/xen/arch/arm/xen.lds.S b/xen/arch/arm/xen.lds.S
> index 0488f37..60802f6 100644
> --- a/xen/arch/arm/xen.lds.S
> +++ b/xen/arch/arm/xen.lds.S
> @@ -100,6 +100,13 @@ SECTIONS
>        _edevice = .;
>    } :text
>  
> +  . = ALIGN(8);
> +  .adev.info : {
> +      _asdevice = .;
> +      *(.adev.info)
> +      _aedevice = .;
> +  } :text
> +
>    . = ALIGN(PAGE_SIZE);             /* Init code and data */
>    __init_begin = .;
>    .init.text : {
> diff --git a/xen/include/asm-arm/device.h b/xen/include/asm-arm/device.h
> index b455bdf..6734ae8 100644
> --- a/xen/include/asm-arm/device.h
> +++ b/xen/include/asm-arm/device.h
> @@ -50,6 +50,27 @@ struct device_desc {
>      int (*init)(struct dt_device_node *dev, const void *data);
>  };
>  
> +struct acpi_device_desc {
> +    /* Device name */
> +    const char *name;
> +    /* Device class */
> +    enum device_class class;
> +    /* type of device supported by the driver */
> +    const int class_type;
> +    /* Device initialization */
> +    int (*init)(const void *data);
> +};
> +
> +/**
> + *  acpi_device_init - Initialize a device
> + *  @class: class of the device (serial, network...)
> + *  @data: specific data for initializing the device
> + *
> + *  Return 0 on success.
> + */
> +int __init acpi_device_init(enum device_class class,
> +                            const void *data, int class_type);
> +
>  /**
>   *  device_init - Initialize a device
>   *  @dev: device to initialize
> @@ -78,6 +99,15 @@ __section(".dev.info") = {                                          \
>  #define DT_DEVICE_END                                               \
>  };
>  
> +#define ACPI_DEVICE_START(_name, _namestr, _class)                    \
> +static const struct acpi_device_desc __dev_desc_##_name __used           \
> +__section(".adev.info") = {                       \
> +    .name = _namestr,                                               \
> +    .class = _class,                                                \
> +
> +#define ACPI_DEVICE_END                                               \
> +};
> +
>  #endif /* __ASM_ARM_DEVICE_H */
>  
>  /*
> -- 
> 2.0.4
> 
> 

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

* Re: [PATCH v4 12/21] arm/irq: Drop the DT prefix of the irq line type
  2016-01-23  9:20 ` [PATCH v4 12/21] arm/irq: Drop the DT prefix of the irq line type Shannon Zhao
@ 2016-01-28 12:48   ` Stefano Stabellini
  0 siblings, 0 replies; 62+ messages in thread
From: Stefano Stabellini @ 2016-01-28 12:48 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: ian.campbell, stefano.stabellini, peter.huangpeng, xen-devel,
	julien.grall, stefano.stabellini, shannon.zhao

On Sat, 23 Jan 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Make these types generic to DT and ACPI. So they are can be used in ACPI
> codes.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>

Reviewed-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>


>  xen/arch/arm/domain_build.c   | 10 ++++-----
>  xen/arch/arm/gic-hip04.c      | 10 ++++-----
>  xen/arch/arm/gic-v2.c         | 10 ++++-----
>  xen/arch/arm/gic-v3.c         |  8 +++----
>  xen/arch/arm/gic.c            |  4 ++--
>  xen/arch/arm/irq.c            |  8 +++----
>  xen/arch/arm/time.c           |  2 +-
>  xen/include/xen/device_tree.h | 50 +++++++++++++++++++++----------------------
>  8 files changed, 51 insertions(+), 51 deletions(-)
> 
> diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
> index 0f0f53e..83676e4 100644
> --- a/xen/arch/arm/domain_build.c
> +++ b/xen/arch/arm/domain_build.c
> @@ -650,7 +650,7 @@ static int make_hypervisor_node(const struct kernel_info *kinfo,
>       * Placeholder for the event channel interrupt.  The values will be
>       * replaced later.
>       */
> -    set_interrupt_ppi(intr, ~0, 0xf, DT_IRQ_TYPE_INVALID);
> +    set_interrupt_ppi(intr, ~0, 0xf, IRQ_TYPE_INVALID);
>      res = fdt_property_interrupts(fdt, &intr, 1);
>      if ( res )
>          return res;
> @@ -923,15 +923,15 @@ static int make_timer_node(const struct domain *d, void *fdt,
>  
>      irq = timer_get_irq(TIMER_PHYS_SECURE_PPI);
>      DPRINT("  Secure interrupt %u\n", irq);
> -    set_interrupt_ppi(intrs[0], irq, 0xf, DT_IRQ_TYPE_LEVEL_LOW);
> +    set_interrupt_ppi(intrs[0], irq, 0xf, IRQ_TYPE_LEVEL_LOW);
>  
>      irq = timer_get_irq(TIMER_PHYS_NONSECURE_PPI);
>      DPRINT("  Non secure interrupt %u\n", irq);
> -    set_interrupt_ppi(intrs[1], irq, 0xf, DT_IRQ_TYPE_LEVEL_LOW);
> +    set_interrupt_ppi(intrs[1], irq, 0xf, IRQ_TYPE_LEVEL_LOW);
>  
>      irq = timer_get_irq(TIMER_VIRT_PPI);
>      DPRINT("  Virt interrupt %u\n", irq);
> -    set_interrupt_ppi(intrs[2], irq, 0xf, DT_IRQ_TYPE_LEVEL_LOW);
> +    set_interrupt_ppi(intrs[2], irq, 0xf, IRQ_TYPE_LEVEL_LOW);
>  
>      res = fdt_property_interrupts(fdt, intrs, 3);
>      if ( res )
> @@ -1463,7 +1463,7 @@ static void evtchn_fixup(struct domain *d, struct kernel_info *kinfo)
>       *  TODO: Handle properly the cpumask
>       */
>      set_interrupt_ppi(intr, d->arch.evtchn_irq, 0xf,
> -                      DT_IRQ_TYPE_LEVEL_LOW);
> +                      IRQ_TYPE_LEVEL_LOW);
>      res = fdt_setprop_inplace(kinfo->fdt, node, "interrupts",
>                                &intr, sizeof(intr));
>      if ( res )
> diff --git a/xen/arch/arm/gic-hip04.c b/xen/arch/arm/gic-hip04.c
> index a42cf24..395360b 100644
> --- a/xen/arch/arm/gic-hip04.c
> +++ b/xen/arch/arm/gic-hip04.c
> @@ -224,16 +224,16 @@ static void hip04gic_set_irq_properties(struct irq_desc *desc,
>      unsigned int irq = desc->irq;
>      unsigned int type = desc->arch.type;
>  
> -    ASSERT(type != DT_IRQ_TYPE_INVALID);
> +    ASSERT(type != IRQ_TYPE_INVALID);
>      ASSERT(spin_is_locked(&desc->lock));
>  
>      spin_lock(&gicv2.lock);
>      /* Set edge / level */
>      cfg = readl_gicd(GICD_ICFGR + (irq / 16) * 4);
>      edgebit = 2u << (2 * (irq % 16));
> -    if ( type & DT_IRQ_TYPE_LEVEL_MASK )
> +    if ( type & IRQ_TYPE_LEVEL_MASK )
>          cfg &= ~edgebit;
> -    else if ( type & DT_IRQ_TYPE_EDGE_BOTH )
> +    else if ( type & IRQ_TYPE_EDGE_BOTH )
>          cfg |= edgebit;
>      writel_gicd(cfg, GICD_ICFGR + (irq / 16) * 4);
>  
> @@ -247,8 +247,8 @@ static void hip04gic_set_irq_properties(struct irq_desc *desc,
>                 cfg & edgebit ? "Edge" : "Level",
>                 actual & edgebit ? "Edge" : "Level");
>          desc->arch.type = actual & edgebit ?
> -            DT_IRQ_TYPE_EDGE_RISING :
> -            DT_IRQ_TYPE_LEVEL_HIGH;
> +            IRQ_TYPE_EDGE_RISING :
> +            IRQ_TYPE_LEVEL_HIGH;
>      }
>  
>      /* Set target CPU mask (RAZ/WI on uniprocessor) */
> diff --git a/xen/arch/arm/gic-v2.c b/xen/arch/arm/gic-v2.c
> index 3fb5823..668b863 100644
> --- a/xen/arch/arm/gic-v2.c
> +++ b/xen/arch/arm/gic-v2.c
> @@ -209,16 +209,16 @@ static void gicv2_set_irq_properties(struct irq_desc *desc,
>      unsigned int irq = desc->irq;
>      unsigned int type = desc->arch.type;
>  
> -    ASSERT(type != DT_IRQ_TYPE_INVALID);
> +    ASSERT(type != IRQ_TYPE_INVALID);
>      ASSERT(spin_is_locked(&desc->lock));
>  
>      spin_lock(&gicv2.lock);
>      /* Set edge / level */
>      cfg = readl_gicd(GICD_ICFGR + (irq / 16) * 4);
>      edgebit = 2u << (2 * (irq % 16));
> -    if ( type & DT_IRQ_TYPE_LEVEL_MASK )
> +    if ( type & IRQ_TYPE_LEVEL_MASK )
>          cfg &= ~edgebit;
> -    else if ( type & DT_IRQ_TYPE_EDGE_BOTH )
> +    else if ( type & IRQ_TYPE_EDGE_BOTH )
>          cfg |= edgebit;
>      writel_gicd(cfg, GICD_ICFGR + (irq / 16) * 4);
>  
> @@ -232,8 +232,8 @@ static void gicv2_set_irq_properties(struct irq_desc *desc,
>                 cfg & edgebit ? "Edge" : "Level",
>                 actual & edgebit ? "Edge" : "Level");
>          desc->arch.type = actual & edgebit ?
> -            DT_IRQ_TYPE_EDGE_RISING :
> -            DT_IRQ_TYPE_LEVEL_HIGH;
> +            IRQ_TYPE_EDGE_RISING :
> +            IRQ_TYPE_LEVEL_HIGH;
>      }
>  
>      /* Set target CPU mask (RAZ/WI on uniprocessor) */
> diff --git a/xen/arch/arm/gic-v3.c b/xen/arch/arm/gic-v3.c
> index 65a4de6..c79b0b4 100644
> --- a/xen/arch/arm/gic-v3.c
> +++ b/xen/arch/arm/gic-v3.c
> @@ -491,9 +491,9 @@ static void gicv3_set_irq_properties(struct irq_desc *desc,
>      cfg = readl_relaxed(base);
>  
>      edgebit = 2u << (2 * (irq % 16));
> -    if ( type & DT_IRQ_TYPE_LEVEL_MASK )
> +    if ( type & IRQ_TYPE_LEVEL_MASK )
>          cfg &= ~edgebit;
> -    else if ( type & DT_IRQ_TYPE_EDGE_BOTH )
> +    else if ( type & IRQ_TYPE_EDGE_BOTH )
>          cfg |= edgebit;
>  
>      writel_relaxed(cfg, base);
> @@ -508,8 +508,8 @@ static void gicv3_set_irq_properties(struct irq_desc *desc,
>                 cfg & edgebit ? "Edge" : "Level",
>                 actual & edgebit ? "Edge" : "Level");
>          desc->arch.type = actual & edgebit ?
> -            DT_IRQ_TYPE_EDGE_RISING :
> -            DT_IRQ_TYPE_LEVEL_HIGH;
> +            IRQ_TYPE_EDGE_RISING :
> +            IRQ_TYPE_LEVEL_HIGH;
>      }
>  
>      affinity = gicv3_mpidr_to_affinity(cpu);
> diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c
> index 0b3f634..43e6fa2 100644
> --- a/xen/arch/arm/gic.c
> +++ b/xen/arch/arm/gic.c
> @@ -98,7 +98,7 @@ void gic_restore_state(struct vcpu *v)
>   * needs to be called with a valid cpu_mask, ie each cpu in the mask has
>   * already called gic_cpu_init
>   * - desc.lock must be held
> - * - arch.type must be valid (i.e != DT_IRQ_TYPE_INVALID)
> + * - arch.type must be valid (i.e != IRQ_TYPE_INVALID)
>   */
>  static void gic_set_irq_properties(struct irq_desc *desc,
>                                     const cpumask_t *cpu_mask,
> @@ -223,7 +223,7 @@ int gic_irq_xlate(const u32 *intspec, unsigned int intsize,
>          *out_hwirq += 16;
>  
>      if ( out_type )
> -        *out_type = intspec[2] & DT_IRQ_TYPE_SENSE_MASK;
> +        *out_type = intspec[2] & IRQ_TYPE_SENSE_MASK;
>  
>      return 0;
>  }
> diff --git a/xen/arch/arm/irq.c b/xen/arch/arm/irq.c
> index d409abb..0ff5cbc 100644
> --- a/xen/arch/arm/irq.c
> +++ b/xen/arch/arm/irq.c
> @@ -66,7 +66,7 @@ irq_desc_t *__irq_to_desc(int irq)
>  
>  int __init arch_init_one_irq_desc(struct irq_desc *desc)
>  {
> -    desc->arch.type = DT_IRQ_TYPE_INVALID;
> +    desc->arch.type = IRQ_TYPE_INVALID;
>      return 0;
>  }
>  
> @@ -117,7 +117,7 @@ void __init init_IRQ(void)
>  
>      spin_lock(&local_irqs_type_lock);
>      for ( irq = 0; irq < NR_LOCAL_IRQS; irq++ )
> -        local_irqs_type[irq] = DT_IRQ_TYPE_INVALID;
> +        local_irqs_type[irq] = IRQ_TYPE_INVALID;
>      spin_unlock(&local_irqs_type_lock);
>  
>      BUG_ON(init_local_irq_data() < 0);
> @@ -449,7 +449,7 @@ int route_irq_to_guest(struct domain *d, unsigned int virq,
>  
>      spin_lock_irqsave(&desc->lock, flags);
>  
> -    if ( desc->arch.type == DT_IRQ_TYPE_INVALID )
> +    if ( desc->arch.type == IRQ_TYPE_INVALID )
>      {
>          printk(XENLOG_G_ERR "IRQ %u has not been configured\n", irq);
>          retval = -EIO;
> @@ -591,7 +591,7 @@ void pirq_set_affinity(struct domain *d, int pirq, const cpumask_t *mask)
>  
>  static bool_t irq_validate_new_type(unsigned int curr, unsigned new)
>  {
> -    return (curr == DT_IRQ_TYPE_INVALID || curr == new );
> +    return (curr == IRQ_TYPE_INVALID || curr == new );
>  }
>  
>  int irq_set_spi_type(unsigned int spi, unsigned int type)
> diff --git a/xen/arch/arm/time.c b/xen/arch/arm/time.c
> index 40f4758..73a1a3e 100644
> --- a/xen/arch/arm/time.c
> +++ b/xen/arch/arm/time.c
> @@ -222,7 +222,7 @@ static void check_timer_irq_cfg(unsigned int irq, const char *which)
>       * The interrupt controller driver will update desc->arch.type with
>       * the actual type which ended up configured in the hardware.
>       */
> -    if ( desc->arch.type & DT_IRQ_TYPE_LEVEL_MASK )
> +    if ( desc->arch.type & IRQ_TYPE_LEVEL_MASK )
>          return;
>  
>      printk(XENLOG_WARNING
> diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h
> index 5c03f40..cf31e50 100644
> --- a/xen/include/xen/device_tree.h
> +++ b/xen/include/xen/device_tree.h
> @@ -105,33 +105,33 @@ struct dt_phandle_args {
>  /**
>   * IRQ line type.
>   *
> - * DT_IRQ_TYPE_NONE            - default, unspecified type
> - * DT_IRQ_TYPE_EDGE_RISING     - rising edge triggered
> - * DT_IRQ_TYPE_EDGE_FALLING    - falling edge triggered
> - * DT_IRQ_TYPE_EDGE_BOTH       - rising and falling edge triggered
> - * DT_IRQ_TYPE_LEVEL_HIGH      - high level triggered
> - * DT_IRQ_TYPE_LEVEL_LOW       - low level triggered
> - * DT_IRQ_TYPE_LEVEL_MASK      - Mask to filter out the level bits
> - * DT_IRQ_TYPE_SENSE_MASK      - Mask for all the above bits
> - * DT_IRQ_TYPE_INVALID         - Use to initialize the type
> - */
> -#define DT_IRQ_TYPE_NONE           0x00000000
> -#define DT_IRQ_TYPE_EDGE_RISING    0x00000001
> -#define DT_IRQ_TYPE_EDGE_FALLING   0x00000002
> -#define DT_IRQ_TYPE_EDGE_BOTH                           \
> -    (DT_IRQ_TYPE_EDGE_FALLING | DT_IRQ_TYPE_EDGE_RISING)
> -#define DT_IRQ_TYPE_LEVEL_HIGH     0x00000004
> -#define DT_IRQ_TYPE_LEVEL_LOW      0x00000008
> -#define DT_IRQ_TYPE_LEVEL_MASK                          \
> -    (DT_IRQ_TYPE_LEVEL_LOW | DT_IRQ_TYPE_LEVEL_HIGH)
> -#define DT_IRQ_TYPE_SENSE_MASK     0x0000000f
> -
> -#define DT_IRQ_TYPE_INVALID        0x00000010
> + * IRQ_TYPE_NONE            - default, unspecified type
> + * IRQ_TYPE_EDGE_RISING     - rising edge triggered
> + * IRQ_TYPE_EDGE_FALLING    - falling edge triggered
> + * IRQ_TYPE_EDGE_BOTH       - rising and falling edge triggered
> + * IRQ_TYPE_LEVEL_HIGH      - high level triggered
> + * IRQ_TYPE_LEVEL_LOW       - low level triggered
> + * IRQ_TYPE_LEVEL_MASK      - Mask to filter out the level bits
> + * IRQ_TYPE_SENSE_MASK      - Mask for all the above bits
> + * IRQ_TYPE_INVALID         - Use to initialize the type
> + */
> +#define IRQ_TYPE_NONE           0x00000000
> +#define IRQ_TYPE_EDGE_RISING    0x00000001
> +#define IRQ_TYPE_EDGE_FALLING   0x00000002
> +#define IRQ_TYPE_EDGE_BOTH                           \
> +    (IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING)
> +#define IRQ_TYPE_LEVEL_HIGH     0x00000004
> +#define IRQ_TYPE_LEVEL_LOW      0x00000008
> +#define IRQ_TYPE_LEVEL_MASK                          \
> +    (IRQ_TYPE_LEVEL_LOW | IRQ_TYPE_LEVEL_HIGH)
> +#define IRQ_TYPE_SENSE_MASK     0x0000000f
> +
> +#define IRQ_TYPE_INVALID        0x00000010
>  
>  /**
>   * dt_irq - describe an IRQ in the device tree
>   * @irq: IRQ number
> - * @type: IRQ type (see DT_IRQ_TYPE_*)
> + * @type: IRQ type (see IRQ_TYPE_*)
>   *
>   * This structure is returned when an interrupt is mapped.
>   */
> @@ -140,12 +140,12 @@ struct dt_irq {
>      unsigned int type;
>  };
>  
> -/* If type == DT_IRQ_TYPE_NONE, assume we use level triggered */
> +/* If type == IRQ_TYPE_NONE, assume we use level triggered */
>  static inline bool_t dt_irq_is_level_triggered(const struct dt_irq *irq)
>  {
>      unsigned int type = irq->type;
>  
> -    return (type & DT_IRQ_TYPE_LEVEL_MASK) || (type == DT_IRQ_TYPE_NONE);
> +    return (type & IRQ_TYPE_LEVEL_MASK) || (type == IRQ_TYPE_NONE);
>  }
>  
>  /**
> -- 
> 2.0.4
> 
> 

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

* Re: [PATCH v4 13/21] arm/gic-v2: Add ACPI boot support for GICv2
  2016-01-23  9:20 ` [PATCH v4 13/21] arm/gic-v2: Add ACPI boot support for GICv2 Shannon Zhao
@ 2016-01-28 12:56   ` Stefano Stabellini
  2016-02-25  8:32     ` Shannon Zhao
  0 siblings, 1 reply; 62+ messages in thread
From: Stefano Stabellini @ 2016-01-28 12:56 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: ian.campbell, stefano.stabellini, peter.huangpeng, xen-devel,
	julien.grall, stefano.stabellini, shannon.zhao

On Sat, 23 Jan 2016, Shannon Zhao wrote:
> From: Parth Dixit <parth.dixit@linaro.org>
> 
> ACPI on Xen hypervisor uses MADT table for proper GIC initialization.
> First get the GIC version from GIC Distributor. Then 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 GICv2.
> 
> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
>
> V4: use container_of and fix coding style
> ---
>  xen/arch/arm/gic-v2.c | 120 +++++++++++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 119 insertions(+), 1 deletion(-)
> 
> diff --git a/xen/arch/arm/gic-v2.c b/xen/arch/arm/gic-v2.c
> index 668b863..7e46ee9 100644
> --- a/xen/arch/arm/gic-v2.c
> +++ b/xen/arch/arm/gic-v2.c
> @@ -29,6 +29,8 @@
>  #include <xen/device_tree.h>
>  #include <xen/libfdt/libfdt.h>
>  #include <xen/sizes.h>
> +#include <xen/acpi.h>
> +#include <acpi/actables.h>
>  #include <asm/p2m.h>
>  #include <asm/domain.h>
>  #include <asm/platform.h>
> @@ -36,6 +38,7 @@
>  
>  #include <asm/io.h>
>  #include <asm/gic.h>
> +#include <asm/acpi.h>
>  
>  /*
>   * LR register definitions are GIC v2 specific.
> @@ -681,11 +684,111 @@ static void __init gicv2_dt_init(void)
>                 csize, vsize);
>  }
>  
> +#ifdef CONFIG_ACPI
> +static int __init
> +gic_acpi_parse_madt_cpu(struct acpi_subtable_header *header,
> +                        const unsigned long end)
> +{
> +    static int cpu_base_assigned = 0;
> +    struct acpi_madt_generic_interrupt *processor =
> +               container_of(header, struct acpi_madt_generic_interrupt, header);
> +
> +    if ( BAD_MADT_ENTRY(processor, end) )
> +        return -EINVAL;
> +
> +    /* Read from APIC table and fill up the GIC variables */
> +    if ( cpu_base_assigned == 0 )
> +    {
> +        cbase = processor->base_address;
> +        csize = SZ_8K;
> +        hbase = processor->gich_base_address;
> +        vbase = processor->gicv_base_address;
> +        gicv2_info.maintenance_irq = processor->vgic_interrupt;
> +
> +        if( processor->flags & ACPI_MADT_VGIC_IRQ_MODE )

            ^ if ( 


> +            irq_set_type(gicv2_info.maintenance_irq, IRQ_TYPE_EDGE_BOTH);
> +        else
> +            irq_set_type(gicv2_info.maintenance_irq, IRQ_TYPE_LEVEL_MASK);
> +
> +        cpu_base_assigned = 1;
> +    }
> +    else
> +    {
> +        if ( cbase != processor->base_address
> +             || hbase != processor->gich_base_address
> +             || vbase != processor->gicv_base_address
> +             || gicv2_info.maintenance_irq != processor->vgic_interrupt )
> +        {
> +            printk("GICv2: GICC entries are not same in MADT table\n");
> +            return -EINVAL;
> +        }
> +    }
> +
> +    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 =
> +             container_of(header, struct acpi_madt_generic_distributor, header);
> +
> +    if ( BAD_MADT_ENTRY(dist, end) )
> +        return -EINVAL;
> +
> +    dbase = dist->base_address;
> +
> +    return 0;
> +}
> +
> +static void __init gicv2_acpi_init(void)
> +{
> +    acpi_status status;
> +    struct acpi_table_header *table;
> +    int count;
> +
> +    status = acpi_get_table(ACPI_SIG_MADT, 0, &table);
> +
> +    if ( ACPI_FAILURE(status) )
> +    {
> +        const char *msg = acpi_format_exception(status);
> +
> +        panic("GICv2: Failed to get MADT table, %s", msg);
> +    }
> +
> +    /* 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 )
> +        panic("GICv2: No valid GICC entries exists");
> +
> +    /*
> +     * Find distributor base address. We expect one distributor entry since
> +     * ACPI 5.0 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 )
> +        panic("GICv2: No valid GICD entries exists");
> +}
> +#else
> +static void __init gicv2_acpi_init(void)
> +{
> +/* Should never reach here */
> +}
> +#endif

With acpi_disabled becoming an #define constant, this #else should not
be needed.

Provided that you make these 2 changes, you can add my Reviewed-by.


>  static int __init gicv2_init(void)
>  {
>      uint32_t aliased_offset = 0;
>  
> -    gicv2_dt_init();
> +    if ( acpi_disabled )
> +        gicv2_dt_init();
> +    else
> +        gicv2_acpi_init();
>  
>      printk("GICv2 initialization:\n"
>                "        gic_dist_addr=%"PRIpaddr"\n"
> @@ -793,6 +896,21 @@ DT_DEVICE_START(gicv2, "GICv2", DEVICE_GIC)
>          .init = gicv2_dt_preinit,
>  DT_DEVICE_END
>  
> +#ifdef CONFIG_ACPI
> +/* Set up the GIC */
> +static int __init gicv2_acpi_preinit(const void *data)
> +{
> +    gicv2_info.hw_version = GIC_V2;
> +    register_gic_ops(&gicv2_ops);
> +
> +    return 0;
> +}
> +
> +ACPI_DEVICE_START(agicv2, "GICv2", DEVICE_GIC)
> +        .class_type = ACPI_MADT_GIC_VERSION_V2,
> +        .init = gicv2_acpi_preinit,
> +ACPI_DEVICE_END
> +#endif
>  /*
>   * Local variables:
>   * mode: C
> -- 
> 2.0.4
> 
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel
> 

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

* Re: [PATCH v4 19/21] arm/acpi: Initialize serial port from ACPI SPCR table
  2016-01-28 12:33     ` Shannon Zhao
@ 2016-01-28 12:59       ` Jan Beulich
  0 siblings, 0 replies; 62+ messages in thread
From: Jan Beulich @ 2016-01-28 12:59 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: ian.campbell, stefano.stabellini, peter.huangpeng, xen-devel,
	julien.grall, stefano.stabellini, shannon.zhao

>>> On 28.01.16 at 13:33, <zhaoshenglong@huawei.com> wrote:
> On 2016/1/25 23:05, Jan Beulich wrote:
>>>>> On 23.01.16 at 10:20, <zhaoshenglong@huawei.com> wrote:
>>> --- a/xen/include/acpi/actbl2.h
>>> +++ b/xen/include/acpi/actbl2.h
>>> @@ -815,6 +815,15 @@ struct acpi_table_spcr {
>>>  
>>>  #define ACPI_SPCR_DO_NOT_DISABLE    (1)
>>>  
>>> +/* SPCR Interface type */
>>> +#define ACPI_SPCR_TYPE_16550		0
>>> +#define ACPI_SPCR_TYPE_16550_SUB	0x1
>>> +#define ACPI_SPCR_TYPE_PL011		0x3
>>> +#define ACPI_SPCR_TYPE_SBSA_32		0xd
>>> +#define ACPI_SPCR_TYPE_SBSA		0xe
>>> +#define ACPI_SPCR_TYPE_DCC		0xf
>>> +#define ACPI_SPCR_TYPE_BCM2835		0x10
>> 
>> It seems very likely to me that this part of the change actually would
>> have a Linux counterpart, in which case it should be submitted as such.
>> 
> 
> I checked it with Linux master. Those interface types are shared with
> DGB2 table. But Linux master only adds ACPI_DBG2_16550_COMPATIBLE and
> ACPI_DBG2_16550_SUBSET, doesn't have other types. And actually we only
> need the interface type not the DBG2 table. Yes, it could port commit
> [1] first then add other types. Is that fine?

Yes please.

Jan

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

* Re: [PATCH v4 10/21] acpi/table: Introduce acpi_table_get_entry_madt to get specified entry
  2016-01-25 15:02   ` Jan Beulich
@ 2016-01-29  7:49     ` Shannon Zhao
  0 siblings, 0 replies; 62+ messages in thread
From: Shannon Zhao @ 2016-01-29  7:49 UTC (permalink / raw)
  To: Jan Beulich
  Cc: ian.campbell, stefano.stabellini, peter.huangpeng, xen-devel,
	julien.grall, stefano.stabellini, shannon.zhao



On 2016/1/25 23:02, Jan Beulich wrote:
>>>> On 23.01.16 at 10:20, <zhaoshenglong@huawei.com> wrote:
>> > From: Shannon Zhao <shannon.zhao@linaro.org>
>> > 
>> > This function could get the specified index entry of MADT table. This
>> > would be useful when it needs to get the contens of the entry.
>> > 
>> > Cc: Jan Beulich <jbeulich@suse.com>
>> > Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> Again - if this is the counterpart to a Linux side change, please name
> that change. If it isn't, besides needing a better explanation of why
> you need it whether neither Linux nor x86 Xen does is needed,

This is not a Linux commit. The reason is that on ARM Xen must create
MADT table for Dom0 and it needs to get the contents of the physical
MADT entry to make up that for Dom0.

> a few code issues would need to be addressed too: Pointer type
> function parameters should be constified as much as possible, use of
> plain int should be avoided unless you truly need a signed type, and
> ...
> 
>> > +struct acpi_subtable_header * __init
>> > +acpi_table_get_entry_madt(enum acpi_madt_type id, unsigned int entry_index)
>> > +{
>> > +	struct acpi_table_header *table_header = NULL;
>> > +
>> > +	acpi_get_table(ACPI_SIG_MADT, acpi_apic_instance, &table_header);
>> > +	if (!table_header) {
> ... you should use the return value of the function instead of pre-
> setting table_header to NULL and then checking whether it changed.
Ok, will update. But looking the codes in this file, there are some
places using this way.

-- 
Shannon

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

* Re: [PATCH v4 14/21] arm/gic-v3: Add ACPI boot support for GICv3
  2016-01-23  9:20 ` [PATCH v4 14/21] arm/gic-v3: Add ACPI boot support for GICv3 Shannon Zhao
@ 2016-02-02 17:31   ` Stefano Stabellini
  0 siblings, 0 replies; 62+ messages in thread
From: Stefano Stabellini @ 2016-02-02 17:31 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: ian.campbell, stefano.stabellini, peter.huangpeng, xen-devel,
	julien.grall, stefano.stabellini, shannon.zhao

On Sat, 23 Jan 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Like GICv2, ACPI on Xen hypervisor uses MADT table for proper GICv3
> initialization. Parse GIC distributor subtable, redistributor subtable
> and interrupt subtable.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
> V4: move ioremap to common init function and fix coding style
> ---
>  xen/arch/arm/gic-v3.c | 174 +++++++++++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 173 insertions(+), 1 deletion(-)
> 
> diff --git a/xen/arch/arm/gic-v3.c b/xen/arch/arm/gic-v3.c
> index c79b0b4..5ac0b1c 100644
> --- a/xen/arch/arm/gic-v3.c
> +++ b/xen/arch/arm/gic-v3.c
> @@ -34,6 +34,8 @@
>  #include <xen/sizes.h>
>  #include <xen/libfdt/libfdt.h>
>  #include <xen/sort.h>
> +#include <xen/acpi.h>
> +#include <acpi/actables.h>
>  #include <asm/p2m.h>
>  #include <asm/domain.h>
>  #include <asm/io.h>
> @@ -41,6 +43,7 @@
>  #include <asm/gic.h>
>  #include <asm/gic_v3_defs.h>
>  #include <asm/cpufeature.h>
> +#include <asm/acpi.h>
>  
>  /* Global state */
>  static struct {
> @@ -1234,6 +1237,156 @@ static void __init gicv3_dt_init(void)
>      }
>  }
>  
> +#ifdef CONFIG_ACPI
> +static int __init
> +gic_acpi_parse_madt_cpu(struct acpi_subtable_header *header,
> +                        const unsigned long end)
> +{
> +    static bool cpu_base_assigned = false;
> +    struct acpi_madt_generic_interrupt *processor =
> +               container_of(header, struct acpi_madt_generic_interrupt, header);
> +
> +    if ( BAD_MADT_ENTRY(processor, end) )
> +        return -EINVAL;
> +
> +    /* Read from APIC table and fill up the GIC variables */
> +    if ( !cpu_base_assigned )
> +    {
> +        cbase = processor->base_address;
> +        csize = SZ_8K;
> +        vbase = processor->gicv_base_address;
> +        gicv3_info.maintenance_irq = processor->vgic_interrupt;
> +
> +        if( processor->flags & ACPI_MADT_VGIC_IRQ_MODE )
> +            irq_set_type(gicv3_info.maintenance_irq, IRQ_TYPE_EDGE_BOTH);
> +        else
> +            irq_set_type(gicv3_info.maintenance_irq, IRQ_TYPE_LEVEL_MASK);
> +
> +        cpu_base_assigned = true;

It might make sense to be coheremt with the gicv2 code and use "= 1"


> +    }
> +    else
> +    {
> +        if ( cbase != processor->base_address
> +             || vbase != processor->gicv_base_address
> +             || gicv3_info.maintenance_irq != processor->vgic_interrupt )
> +        {
> +            printk("GICv3: GICC entries are not same in MADT table\n");
> +            return -EINVAL;
> +        }
> +    }
> +
> +    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 =
> +             container_of(header, struct acpi_madt_generic_distributor, header);
> +
> +    if ( BAD_MADT_ENTRY(dist, end) )
> +        return -EINVAL;
> +
> +    dbase = dist->base_address;
> +
> +    return 0;
> +}
> +static int __init
> +gic_acpi_get_madt_redistributor_num(struct acpi_subtable_header *header,
> +                                    const unsigned long end)
> +{
> +    /* Nothing to do here since it only wants to get the number of GIC
> +     * redistributors.
> +     */
> +    return 0;
> +}
> +
> +static void __init gicv3_acpi_init(void)
> +{
> +    struct acpi_table_header *table;
> +    struct rdist_region *rdist_regs;
> +    acpi_status status;
> +    int count, i;
> +
> +    status = acpi_get_table(ACPI_SIG_MADT, 0, &table);
> +
> +    if ( ACPI_FAILURE(status) )
> +    {
> +        const char *msg = acpi_format_exception(status);
> +
> +        panic("GICv3: Failed to get MADT table, %s", msg);
> +    }
> +
> +    /*
> +     * Find distributor base address. We expect one distributor entry since
> +     * ACPI 5.0 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 )
> +        panic("GICv3: No valid GICD entries exists");
> +
> +    if ( (dbase & ~PAGE_MASK) )
> +        panic("GICv3: Found unaligned distributor address %"PRIpaddr"",
> +              dbase);
> +
> +    /* Get number of redistributor */
> +    count = acpi_parse_entries(ACPI_SIG_MADT, sizeof(struct acpi_table_madt),
> +                               gic_acpi_get_madt_redistributor_num, table,
> +                               ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR, 0);
> +    if ( count <= 0 )
> +        panic("GICv3: No valid GICR entries exists");
> +
> +    gicv3.rdist_count = count;
> +
> +    if ( gicv3.rdist_count > MAX_RDIST_COUNT )
> +        panic("GICv3: Number of redistributor regions is more than"
> +              "%d (Increase MAX_RDIST_COUNT!!)\n", MAX_RDIST_COUNT);
> +
> +    rdist_regs = xzalloc_array(struct rdist_region, gicv3.rdist_count);
> +    if ( !rdist_regs )
> +        panic("GICv3: Failed to allocate memory for rdist regions\n");
> +
> +    for ( i = 0; i < gicv3.rdist_count; i++ )
> +    {
> +        struct acpi_subtable_header *header;
> +        struct acpi_madt_generic_redistributor *gic_rdist;
> +
> +        header = acpi_table_get_entry_madt(ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR,
> +                                           i);
> +        if ( !header )
> +            panic("GICv3: Can't get GICR entry");
> +
> +        gic_rdist =
> +           container_of(header, struct acpi_madt_generic_redistributor, header);
> +        rdist_regs[i].base = gic_rdist->base_address;
> +        rdist_regs[i].size = gic_rdist->length;
> +    }
> +
> +    /* The vGIC code requires the region to be sorted */
> +    sort(rdist_regs, gicv3.rdist_count, sizeof(*rdist_regs), cmp_rdist, NULL);
> +
> +    gicv3.rdist_regions= rdist_regs;
> +
> +    /* 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 )
> +        panic("GICv3: No valid GICC entries exists");
> +
> +    gicv3.rdist_stride = 0;
> +}
> +#else
> +static void __init gicv3_acpi_init(void)
> +{
> +/* Should never reach here */
> +}
> +#endif

Same comment as for the previous patch, regarding this empty function
going away.


>  /* Set up the GIC */
>  static int __init gicv3_init(void)
>  {
> @@ -1246,7 +1399,10 @@ static int __init gicv3_init(void)
>          return -ENODEV;
>      }
>  
> -    gicv3_dt_init();
> +    if ( acpi_disabled )
> +        gicv3_dt_init();
> +    else
> +        gicv3_acpi_init();
>  
>      gicv3.map_dbase = ioremap_nocache(dbase, SZ_64K);
>      if ( !gicv3.map_dbase )
> @@ -1346,6 +1502,22 @@ DT_DEVICE_START(gicv3, "GICv3", DEVICE_GIC)
>          .init = gicv3_dt_preinit,
>  DT_DEVICE_END
>  
> +#ifdef CONFIG_ACPI
> +/* Set up the GIC */
> +static int __init gicv3_acpi_preinit(const void *data)
> +{
> +    gicv3_info.hw_version = GIC_V3;
> +    register_gic_ops(&gicv3_ops);
> +
> +    return 0;
> +}
> +
> +ACPI_DEVICE_START(agicv3, "GICv3", DEVICE_GIC)
> +        .class_type = ACPI_MADT_GIC_VERSION_V3,
> +        .init = gicv3_acpi_preinit,
> +ACPI_DEVICE_END
> +#endif
> +
>  /*
>   * Local variables:
>   * mode: C
> -- 
> 2.0.4
> 
> 

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

* Re: [PATCH v4 15/21] arm/gic: Add ACPI support for GIC preinit
  2016-01-23  9:20 ` [PATCH v4 15/21] arm/gic: Add ACPI support for GIC preinit Shannon Zhao
@ 2016-02-02 17:36   ` Stefano Stabellini
  0 siblings, 0 replies; 62+ messages in thread
From: Stefano Stabellini @ 2016-02-02 17:36 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: ian.campbell, stefano.stabellini, peter.huangpeng, xen-devel,
	julien.grall, stefano.stabellini, shannon.zhao

On Sat, 23 Jan 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Since ACPI 6.0 defines that GIC Distributor Structure contains the GIC
> version filed, it could get GIC version from that. Then call acpi device
> initializing function to preinit GIC device.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
> V4: use ACPI_MADT_GIC_VERSION_V* instead of GICv*
> ---
>  xen/arch/arm/gic.c | 37 +++++++++++++++++++++++++++++++++----
>  1 file changed, 33 insertions(+), 4 deletions(-)
> 
> diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c
> index 43e6fa2..840075f 100644
> --- a/xen/arch/arm/gic.c
> +++ b/xen/arch/arm/gic.c
> @@ -27,6 +27,7 @@
>  #include <xen/softirq.h>
>  #include <xen/list.h>
>  #include <xen/device_tree.h>
> +#include <xen/acpi.h>
>  #include <asm/p2m.h>
>  #include <asm/domain.h>
>  #include <asm/platform.h>
> @@ -34,6 +35,7 @@
>  #include <asm/io.h>
>  #include <asm/gic.h>
>  #include <asm/vgic.h>
> +#include <asm/acpi.h>
>  
>  static void gic_restore_pending_irqs(struct vcpu *v);
>  
> @@ -228,10 +230,7 @@ int gic_irq_xlate(const u32 *intspec, unsigned int intsize,
>      return 0;
>  }
>  
> -/* Find the interrupt controller and set up the callback to translate
> - * device tree IRQ.
> - */
> -void __init gic_preinit(void)
> +static void __init gic_dt_preinit(void)
>  {
>      int rc;
>      struct dt_device_node *node;
> @@ -261,6 +260,36 @@ void __init gic_preinit(void)
>      dt_device_set_used_by(node, DOMID_XEN);
>  }
>  
> +#ifdef CONFIG_ACPI
> +static void __init gic_acpi_preinit(void)
> +{
> +    struct acpi_subtable_header *header;
> +    struct acpi_madt_generic_distributor *dist;
> +
> +    header = acpi_table_get_entry_madt(ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR, 0);
> +    if ( !header )
> +        panic("No valid GICD entries exists");
> +
> +    dist = container_of(header, struct acpi_madt_generic_distributor, header);
> +
> +    if ( acpi_device_init(DEVICE_GIC, NULL, dist->version) )
> +        panic("Unable to find compatible GIC in the ACPI table");
> +}
> +#else
> +static void __init gic_acpi_preinit(void) {}
> +#endif

Again if acpi_disabled were an #define constant, this #else would
not be needed. Provided that you remove it, you can add my Reviewed-by.


> +/* Find the interrupt controller and set up the callback to translate
> + * device tree or ACPI IRQ.
> + */
> +void __init gic_preinit(void)
> +{
> +    if ( acpi_disabled )
> +        gic_dt_preinit();
> +    else
> +        gic_acpi_preinit();
> +}
> +
>  /* Set up the GIC */
>  void __init gic_init(void)
>  {

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

* Re: [PATCH v4 17/21] arm/acpi: Parse GTDT to initialize timer
  2016-01-23  9:20 ` [PATCH v4 17/21] arm/acpi: Parse GTDT to initialize timer Shannon Zhao
@ 2016-02-02 17:45   ` Stefano Stabellini
  0 siblings, 0 replies; 62+ messages in thread
From: Stefano Stabellini @ 2016-02-02 17:45 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: ian.campbell, stefano.stabellini, peter.huangpeng, xen-devel,
	julien.grall, stefano.stabellini, shannon.zhao

On Sat, 23 Jan 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Parse GTDT (Generic Timer Descriptor Table) to initialize timer. Using
> the information presented by GTDT to initialize the arch timer (not
> memory-mapped).
> 
> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
> V4: Factor dt parts
> ---
>  xen/arch/arm/time.c | 82 ++++++++++++++++++++++++++++++++++++++++++++---------
>  1 file changed, 68 insertions(+), 14 deletions(-)
> 
> diff --git a/xen/arch/arm/time.c b/xen/arch/arm/time.c
> index 73a1a3e..4261207 100644
> --- a/xen/arch/arm/time.c
> +++ b/xen/arch/arm/time.c
> @@ -29,6 +29,7 @@
>  #include <xen/time.h>
>  #include <xen/sched.h>
>  #include <xen/event.h>
> +#include <xen/acpi.h>
>  #include <asm/system.h>
>  #include <asm/time.h>
>  #include <asm/gic.h>
> @@ -65,8 +66,52 @@ unsigned int timer_get_irq(enum timer_ppi ppi)
>  
>  static __initdata struct dt_device_node *timer;
>  
> +#ifdef CONFIG_ACPI
> +static u32 __init acpi_get_timer_irq_type(u32 flags)
> +{
> +    return (flags & ACPI_GTDT_INTERRUPT_MODE) ? IRQ_TYPE_EDGE_BOTH
> +                                              : IRQ_TYPE_LEVEL_MASK;
> +}
> +
> +/* Initialize per-processor generic timer */
> +static int __init arch_timer_acpi_init(struct acpi_table_header *header)
> +{
> +    u32 irq_type;
> +    struct acpi_table_gtdt *gtdt;
> +
> +    gtdt = container_of(header, struct acpi_table_gtdt, header);
> +
> +    /* Initialize all the generic timer IRQ variable from GTDT table */
> +    irq_type = acpi_get_timer_irq_type(gtdt->non_secure_el1_flags);
> +    irq_set_type(gtdt->non_secure_el1_interrupt, irq_type);
> +    timer_irq[TIMER_PHYS_NONSECURE_PPI] = gtdt->non_secure_el1_interrupt;
> +
> +    irq_type = acpi_get_timer_irq_type(gtdt->secure_el1_flags);
> +    irq_set_type(gtdt->secure_el1_interrupt, irq_type);
> +    timer_irq[TIMER_PHYS_SECURE_PPI] = gtdt->secure_el1_interrupt;
> +
> +    irq_type = acpi_get_timer_irq_type(gtdt->virtual_timer_flags);
> +    irq_set_type(gtdt->virtual_timer_interrupt, irq_type);
> +    timer_irq[TIMER_VIRT_PPI] = gtdt->virtual_timer_interrupt;
> +
> +    irq_type = acpi_get_timer_irq_type(gtdt->non_secure_el2_flags);
> +    irq_set_type(gtdt->non_secure_el2_interrupt, irq_type);
> +    timer_irq[TIMER_HYP_PPI] = gtdt->non_secure_el2_interrupt;
> +
> +    return 0;
> +}
> +
> +static void __init preinit_acpi_xen_time(void)
> +{
> +    acpi_table_parse(ACPI_SIG_GTDT, arch_timer_acpi_init);
> +    cpu_khz = READ_SYSREG32(CNTFRQ_EL0) / 1000;

I would move this and the other line like this in preinit_dt_xen_time to
preinit_xen_time, with a if (!cpu_khz) check.


> +}
> +#else
> +static inline void preinit_acpi_xen_time(void) { }
> +#endif

As usual, this can go away.

Everything else is good.


>  /* Set up the timer on the boot CPU (early init function) */
> -void __init preinit_xen_time(void)
> +static void __init preinit_dt_xen_time(void)
>  {
>      static const struct dt_device_match timer_ids[] __initconst =
>      {
> @@ -75,6 +120,7 @@ void __init preinit_xen_time(void)
>      };
>      int res;
>      u32 rate;
> +    unsigned int i;
>  
>      timer = dt_find_matching_node(NULL, timer_ids);
>      if ( !timer )
> @@ -82,10 +128,6 @@ void __init preinit_xen_time(void)
>  
>      dt_device_set_used_by(timer, DOMID_XEN);
>  
> -    res = platform_init_time();
> -    if ( res )
> -        panic("Timer: Cannot initialize platform timer");
> -
>      res = dt_property_read_u32(timer, "clock-frequency", &rate);
>      if ( res )
>      {
> @@ -95,15 +137,6 @@ void __init preinit_xen_time(void)
>      else
>          cpu_khz = READ_SYSREG32(CNTFRQ_EL0) / 1000;
>  
> -    boot_count = READ_SYSREG64(CNTPCT_EL0);
> -}
> -
> -/* Set up the timer on the boot CPU (late init function) */
> -int __init init_xen_time(void)
> -{
> -    int res;
> -    unsigned int i;
> -
>      /* Retrieve all IRQs for the timer */
>      for ( i = TIMER_PHYS_SECURE_PPI; i < MAX_TIMER_PPI; i++ )
>      {
> @@ -113,7 +146,28 @@ int __init init_xen_time(void)
>              panic("Timer: Unable to retrieve IRQ %u from the device tree", i);
>          timer_irq[i] = res;
>      }
> +}
> +
> +void __init preinit_xen_time(void)
> +{
> +    int res;
>  
> +    /* Initialize all the generic timers presented in GTDT */
> +    if ( acpi_disabled )
> +        preinit_dt_xen_time();
> +    else
> +        preinit_acpi_xen_time();
> +
> +    res = platform_init_time();
> +    if ( res )
> +        panic("Timer: Cannot initialize platform timer");
> +
> +    boot_count = READ_SYSREG64(CNTPCT_EL0);
> +}
> +
> +/* Set up the timer on the boot CPU (late init function) */
> +int __init init_xen_time(void)
> +{
>      /* Check that this CPU supports the Generic Timer interface */
>      if ( !cpu_has_gentimer )
>          panic("CPU does not support the Generic Timer v1 interface");
> -- 
> 2.0.4
> 
> 

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

* Re: [PATCH v4 18/21] arm/acpi: Add a new ACPI initialized function for UART
  2016-01-23  9:20 ` [PATCH v4 18/21] arm/acpi: Add a new ACPI initialized function for UART Shannon Zhao
  2016-01-25 15:04   ` Jan Beulich
@ 2016-02-02 17:48   ` Stefano Stabellini
  1 sibling, 0 replies; 62+ messages in thread
From: Stefano Stabellini @ 2016-02-02 17:48 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: ian.campbell, stefano.stabellini, peter.huangpeng, xen-devel,
	julien.grall, stefano.stabellini, shannon.zhao

On Sat, 23 Jan 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> This adds a new function to initialize UART for ACPI on ARM.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  xen/arch/arm/setup.c        |  2 +-
>  xen/drivers/char/arm-uart.c | 33 +++++++++++++++++++++++++++++++--
>  xen/include/xen/serial.h    |  2 +-
>  3 files changed, 33 insertions(+), 4 deletions(-)
> 
> diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
> index c15a09d..63feadf 100644
> --- a/xen/arch/arm/setup.c
> +++ b/xen/arch/arm/setup.c
> @@ -766,7 +766,7 @@ void __init start_xen(unsigned long boot_phys_offset,
>  
>      gic_preinit();
>  
> -    dt_uart_init();
> +    arm_uart_init();
>      console_init_preirq();
>      console_init_ring();
>  
> diff --git a/xen/drivers/char/arm-uart.c b/xen/drivers/char/arm-uart.c
> index 883e615..a68959b 100644
> --- a/xen/drivers/char/arm-uart.c
> +++ b/xen/drivers/char/arm-uart.c
> @@ -1,7 +1,7 @@
>  /*
>   * xen/drivers/char/arm-uart.c
>   *
> - * Generic uart retrieved via the device tree
> + * Generic uart retrieved via the device tree or ACPI
>   *
>   * Julien Grall <julien.grall@linaro.org>
>   * Copyright (c) 2013 Linaro Limited.
> @@ -23,6 +23,7 @@
>  #include <xen/device_tree.h>
>  #include <xen/serial.h>
>  #include <xen/errno.h>
> +#include <xen/acpi.h>
>  
>  /*
>   * Configure UART port with a string:
> @@ -35,7 +36,7 @@
>  static char __initdata opt_dtuart[256] = "";
>  string_param("dtuart", opt_dtuart);
>  
> -void __init dt_uart_init(void)
> +static void __init dt_uart_init(void)
>  {
>      struct dt_device_node *dev;
>      int ret;
> @@ -96,6 +97,34 @@ void __init dt_uart_init(void)
>          printk("Unable to initialize dtuart: %d\n", ret);
>  }
>  
> +static void __init acpi_uart_init(void)
> +{
> +#ifdef CONFIG_ACPI

With acpi_disabled as an #define, you can ifdef the whole function.


> +    struct acpi_table_spcr *spcr=NULL;
                                  ^ code style


> +    int ret;
> +
> +    acpi_get_table(ACPI_SIG_SPCR, 0,(struct acpi_table_header **)&spcr);
                                       ^ code style

> +    if ( spcr == NULL )
> +        printk("Unable to get spcr table\n");
> +    else
> +    {
> +        ret = acpi_device_init(DEVICE_SERIAL, NULL, spcr->interface_type);
> +
> +        if ( ret )
> +            printk("Unable to initialize acpi uart: %d\n", ret);
> +    }
> +#endif
> +}
> +
> +void __init arm_uart_init(void)
> +{
> +    if ( acpi_disabled )
> +        dt_uart_init();
> +    else
> +        acpi_uart_init();
> +}
> +
>  /*
>   * Local variables:
>   * mode: C
> diff --git a/xen/include/xen/serial.h b/xen/include/xen/serial.h
> index 71e6ade..5e1a536 100644
> --- a/xen/include/xen/serial.h
> +++ b/xen/include/xen/serial.h
> @@ -170,7 +170,7 @@ struct ns16550_defaults {
>  void ns16550_init(int index, struct ns16550_defaults *defaults);
>  void ehci_dbgp_init(void);
>  
> -void __init dt_uart_init(void);
> +void __init arm_uart_init(void);
>  
>  struct physdev_dbgp_op;
>  int dbgp_op(const struct physdev_dbgp_op *);
> -- 
> 2.0.4
> 
> 

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

* Re: [PATCH v4 19/21] arm/acpi: Initialize serial port from ACPI SPCR table
  2016-01-23  9:20 ` [PATCH v4 19/21] arm/acpi: Initialize serial port from ACPI SPCR table Shannon Zhao
  2016-01-25 15:05   ` Jan Beulich
@ 2016-02-02 17:51   ` Stefano Stabellini
  1 sibling, 0 replies; 62+ messages in thread
From: Stefano Stabellini @ 2016-02-02 17:51 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: ian.campbell, stefano.stabellini, peter.huangpeng, xen-devel,
	julien.grall, stefano.stabellini, shannon.zhao

On Sat, 23 Jan 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Parse ACPI SPCR (Serial Port Console Redirection table) table and
> initialize the serial port pl011.
> 
> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
> V4: Add other fields of SPCR Interface type

Reviewed-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>


>  xen/drivers/char/pl011.c  | 37 +++++++++++++++++++++++++++++++++++++
>  xen/include/acpi/actbl2.h |  9 +++++++++
>  2 files changed, 46 insertions(+)
> 
> diff --git a/xen/drivers/char/pl011.c b/xen/drivers/char/pl011.c
> index 7e16294..9d47299 100644
> --- a/xen/drivers/char/pl011.c
> +++ b/xen/drivers/char/pl011.c
> @@ -27,6 +27,7 @@
>  #include <asm/device.h>
>  #include <xen/mm.h>
>  #include <xen/vmap.h>
> +#include <xen/acpi.h>
>  #include <asm/pl011-uart.h>
>  #include <asm/io.h>
>  
> @@ -308,6 +309,42 @@ DT_DEVICE_START(pl011, "PL011 UART", DEVICE_SERIAL)
>          .init = pl011_dt_uart_init,
>  DT_DEVICE_END
>  
> +#ifdef CONFIG_ACPI
> +static int __init pl011_acpi_uart_init(const void *data)
> +{
> +    acpi_status status;
> +    struct acpi_table_spcr *spcr = NULL;
> +    int res;
> +
> +    status = acpi_get_table(ACPI_SIG_SPCR, 0,
> +                            (struct acpi_table_header **)&spcr);
> +
> +    if ( ACPI_FAILURE(status) )
> +    {
> +        printk("pl011: Failed to get SPCR table\n");
> +        return -EINVAL;
> +    }
> +
> +    /* trigger/polarity information is not available in spcr */
> +    irq_set_type(spcr->interrupt, IRQ_TYPE_EDGE_BOTH);
> +
> +    res = pl011_uart_init(spcr->interrupt, spcr->serial_port.address,
> +                          PAGE_SIZE);
> +    if ( res < 0 )
> +    {
> +        printk("pl011: Unable to initialize\n");
> +        return res;
> +    }
> +
> +    return 0;
> +}
> +
> +ACPI_DEVICE_START(apl011, "PL011 UART", DEVICE_SERIAL)
> +        .class_type = ACPI_SPCR_TYPE_PL011,
> +        .init = pl011_acpi_uart_init,
> +ACPI_DEVICE_END
> +#endif
> +
>  /*
>   * Local variables:
>   * mode: C
> diff --git a/xen/include/acpi/actbl2.h b/xen/include/acpi/actbl2.h
> index 87bc6b3..d0508be 100644
> --- a/xen/include/acpi/actbl2.h
> +++ b/xen/include/acpi/actbl2.h
> @@ -815,6 +815,15 @@ struct acpi_table_spcr {
>  
>  #define ACPI_SPCR_DO_NOT_DISABLE    (1)
>  
> +/* SPCR Interface type */
> +#define ACPI_SPCR_TYPE_16550		0
> +#define ACPI_SPCR_TYPE_16550_SUB	0x1
> +#define ACPI_SPCR_TYPE_PL011		0x3
> +#define ACPI_SPCR_TYPE_SBSA_32		0xd
> +#define ACPI_SPCR_TYPE_SBSA		0xe
> +#define ACPI_SPCR_TYPE_DCC		0xf
> +#define ACPI_SPCR_TYPE_BCM2835		0x10
> +
>  /*******************************************************************************
>   *
>   * SPMI - Server Platform Management Interface table
> -- 
> 2.0.4
> 
> 

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

* Re: [PATCH v4 21/21] arm/acpi: Add acpi parameter to enable/disable acpi
  2016-01-23  9:20 ` [PATCH v4 21/21] arm/acpi: Add acpi parameter to enable/disable acpi Shannon Zhao
@ 2016-02-02 17:58   ` Stefano Stabellini
  0 siblings, 0 replies; 62+ messages in thread
From: Stefano Stabellini @ 2016-02-02 17:58 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: ian.campbell, stefano.stabellini, peter.huangpeng, xen-devel,
	julien.grall, stefano.stabellini, shannon.zhao

On Sat, 23 Jan 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Define new command line parameter "acpi" to enable/disable acpi.
> 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
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
> V4: be consistent with Linux

Reviewed-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>


>  xen/arch/arm/acpi/boot.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 52 insertions(+)
> 
> diff --git a/xen/arch/arm/acpi/boot.c b/xen/arch/arm/acpi/boot.c
> index c9135f2..8eb6c37 100644
> --- a/xen/arch/arm/acpi/boot.c
> +++ b/xen/arch/arm/acpi/boot.c
> @@ -30,9 +30,11 @@
>  #include <xen/errno.h>
>  #include <acpi/actables.h>
>  #include <xen/mm.h>
> +#include <xen/device_tree.h>
>  
>  #include <asm/acpi.h>
>  #include <asm/smp.h>
> +#include <asm/setup.h>
>  
>  /* Processors with enabled flag and sane MPIDR */
>  static unsigned int enabled_cpus;
> @@ -182,6 +184,36 @@ static int __init acpi_parse_fadt(struct acpi_table_header *table)
>      return -EINVAL;
>  }
>  
> +static bool_t __initdata param_acpi_off;
> +static bool_t __initdata param_acpi_force;
> +
> +static void __init parse_acpi_param(char *arg)
> +{
> +    if ( !arg )
> +        return;
> +
> +    /* Interpret the parameter for use within Xen. */
> +    if ( !parse_bool(arg) )
> +        param_acpi_off = true;
> +    else if ( !strcmp(arg, "force") ) /* force ACPI to be enabled */
> +        param_acpi_force = true;
> +}
> +custom_param("acpi", parse_acpi_param);
> +
> +static int __init dt_scan_depth1_nodes(const void *fdt, int node,
> +                                       const char *uname, int depth,
> +                                       u32 address_cells, u32 size_cells,
> +                                       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_boot_table_init() called from setup_arch(), always.
>   *      1. find RSDP and get its address, and then find XSDT
> @@ -198,6 +230,26 @@ int __init acpi_boot_table_init(void)
>  {
>      int error;
>  
> +    /*
> +     * 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
> +                             && device_tree_for_each_node(device_tree_flattened,
> +                                                   dt_scan_depth1_nodes, NULL)))
> +    {
> +        disable_acpi();
> +        return 0;
> +    }
> +
> +    /*
> +     * ACPI is disabled at this point. Enable it in order to parse
> +     * the ACPI tables.
> +     */
> +    enable_acpi();
> +
>      /* Initialize the ACPI boot-time table parser. */
>      error = acpi_table_init();
>      if ( error )
> -- 
> 2.0.4
> 
> 

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

* Re: [PATCH v4 20/21] arm/fdt: Export device_tree_for_each_node
  2016-01-23  9:20 ` [PATCH v4 20/21] arm/fdt: Export device_tree_for_each_node Shannon Zhao
@ 2016-02-02 18:01   ` Stefano Stabellini
  0 siblings, 0 replies; 62+ messages in thread
From: Stefano Stabellini @ 2016-02-02 18:01 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: ian.campbell, stefano.stabellini, peter.huangpeng, xen-devel,
	julien.grall, stefano.stabellini, shannon.zhao

On Sat, 23 Jan 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> This function will be used by ACPI booting. Export it so that it can be
> used by other files.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>

Please remove __init from the declaration.

Reviewed-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>


>  xen/arch/arm/bootfdt.c        | 6 +++---
>  xen/include/xen/device_tree.h | 4 ++++
>  2 files changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/xen/arch/arm/bootfdt.c b/xen/arch/arm/bootfdt.c
> index 74d208b..8a14015 100644
> --- a/xen/arch/arm/bootfdt.c
> +++ b/xen/arch/arm/bootfdt.c
> @@ -85,9 +85,9 @@ static u32 __init device_tree_get_u32(const void *fdt, int node,
>   * Returns 0 if all nodes were iterated over successfully.  If @func
>   * returns a value different from 0, that value is returned immediately.
>   */
> -static int __init device_tree_for_each_node(const void *fdt,
> -                                            device_tree_node_func func,
> -                                            void *data)
> +int __init device_tree_for_each_node(const void *fdt,
> +                                     device_tree_node_func func,
> +                                     void *data)
>  {
>      int node;
>      int depth;
> diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h
> index cf31e50..12942cf 100644
> --- a/xen/include/xen/device_tree.h
> +++ b/xen/include/xen/device_tree.h
> @@ -173,6 +173,10 @@ typedef int (*device_tree_node_func)(const void *fdt,
>  
>  extern const void *device_tree_flattened;
>  
> +int __init device_tree_for_each_node(const void *fdt,
> +                                     device_tree_node_func func,
> +                                     void *data);
> +
>  /**
>   * dt_unflatten_host_device_tree - Unflatten the host device tree
>   *
> -- 
> 2.0.4
> 
> 

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

* Re: [PATCH v4 06/21] arm/acpi: Parse FADT table and get PSCI flags
  2016-01-27 15:41   ` Stefano Stabellini
@ 2016-02-23 12:13     ` Shannon Zhao
  2016-02-23 14:37       ` Stefano Stabellini
  0 siblings, 1 reply; 62+ messages in thread
From: Shannon Zhao @ 2016-02-23 12:13 UTC (permalink / raw)
  To: Stefano Stabellini
  Cc: ian.campbell, peter.huangpeng, xen-devel, julien.grall,
	stefano.stabellini, shannon.zhao



On 2016/1/27 23:41, Stefano Stabellini wrote:
> On Sat, 23 Jan 2016, Shannon Zhao wrote:
>> From: Shannon Zhao <shannon.zhao@linaro.org>
>>
>> There are two flags: PSCI_COMPLIANT and PSCI_USE_HVC. When set, the
>> former signals to the OS that the hardware 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, parse FADT to get the flags for furture
>> usage.
>>
>> Since STAO table and the GIC version are introduced by ACPI 6.0, we will
>> check the version and only parse FADT table with version >= 6.0. If
>> firmware provides ACPI tables with ACPI version less than 6.0, OS will
>> be messed up with those information, so disable ACPI if we get an FADT
>> table with version less than 6.0.
>>
>> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
>> Signed-off-by: Naresh Bhat <naresh.bhat@linaro.org>
>> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
>> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
>> ---
>> V4: drop disable_acpi in acpi_parse_fadt
>> ---
>>  xen/arch/arm/acpi/boot.c   | 30 ++++++++++++++++++++++++++++++
>>  xen/arch/arm/acpi/lib.c    | 12 ++++++++++++
>>  xen/include/asm-arm/acpi.h |  9 +++++++++
>>  3 files changed, 51 insertions(+)
>>
>> diff --git a/xen/arch/arm/acpi/boot.c b/xen/arch/arm/acpi/boot.c
>> index 1570f7e..6b33fbe 100644
>> --- a/xen/arch/arm/acpi/boot.c
>> +++ b/xen/arch/arm/acpi/boot.c
>> @@ -27,9 +27,32 @@
>>  
>>  #include <xen/init.h>
>>  #include <xen/acpi.h>
>> +#include <xen/errno.h>
>> +#include <acpi/actables.h>
>> +#include <xen/mm.h>
>>  
>>  #include <asm/acpi.h>
>>  
>> +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 6.0,
>> +     * we only deal with ACPI 6.0 or newer revision to get GIC and SMP
>> +     * boot protocol configuration data, or we will disable ACPI.
>> +     */
>> +    if ( table->revision > 6
>> +         || (table->revision == 6 && fadt->minor_revision >= 0) )
>> +        return 0;
>> +
>> +    printk("Unsupported FADT revision %d.%d, should be 6.0+, will disable ACPI\n",
>> +            table->revision, fadt->minor_revision);
>> +
>> +    return -EINVAL;
>> +}
>> +
>>  /*
>>   * acpi_boot_table_init() called from setup_arch(), always.
>>   *      1. find RSDP and get its address, and then find XSDT
>> @@ -54,5 +77,12 @@ int __init acpi_boot_table_init(void)
>>          return error;
>>      }
>>  
>> +    if ( acpi_table_parse(ACPI_SIG_FADT, acpi_parse_fadt) )
>> +    {
>> +        /* disable ACPI if no FADT is found */
>> +        disable_acpi();
>> +        printk("Can't find FADT\n");
>> +    }
>> +
>>      return 0;
>>  }
>> diff --git a/xen/arch/arm/acpi/lib.c b/xen/arch/arm/acpi/lib.c
>> index f817fe6..a30e4e6 100644
>> --- a/xen/arch/arm/acpi/lib.c
>> +++ b/xen/arch/arm/acpi/lib.c
>> @@ -50,3 +50,15 @@ char *__acpi_map_table(paddr_t phys, unsigned long size)
>>  
>>  	return ((char *) base + offset);
>>  }
>> +
>> +/* 1 to indicate PSCI 0.2+ is implemented */
>> +bool_t __init acpi_psci_present(void)
>> +{
>> +    return acpi_gbl_FADT.arm_boot_flags & ACPI_FADT_PSCI_COMPLIANT;
>> +}
>> +
>> +/* 1 to indicate HVC is present instead of SMC as the PSCI conduit */
>> +bool_t __init acpi_psci_hvc_present(void)
>> +{
>> +    return acpi_gbl_FADT.arm_boot_flags & ACPI_FADT_PSCI_USE_HVC;
>> +}
> 
> So far so good.
> 
> 
>> diff --git a/xen/include/asm-arm/acpi.h b/xen/include/asm-arm/acpi.h
>> index 6a037c9..1ce88f8 100644
>> --- a/xen/include/asm-arm/acpi.h
>> +++ b/xen/include/asm-arm/acpi.h
>> @@ -31,6 +31,15 @@
>>  #define ACPI_MAP_MEM_ATTR          PAGE_HYPERVISOR
>>  
>>  extern bool_t acpi_disabled;
>> +
>> +#ifdef CONFIG_ACPI
>> +bool_t __init acpi_psci_present(void);
>> +bool_t __init acpi_psci_hvc_present(void);
>> +#else
>> +static inline bool_t acpi_psci_present(void) { return false; }
>> +static inline bool_t acpi_psci_hvc_present(void) {return false; }
>> +#endif /* CONFIG_ACPI */
>> +
>>  /* Basic configuration for ACPI */
>>  static inline void disable_acpi(void)
>>  {
> 
> I would prefer if we only defined each function once, outside the ifdef
> (no static inline needed). Then we could
> 
> #ifdef CONFIG_ACPI
> extern bool_t acpi_disabled;
> #else
> #define acpi_disabled (1)
> #endif
> 
Yes, we could do this to drop the #else (CONFIG_ACPI) case in some
places. But I think it still needs to stub out acpi_psci_present and
acpi_psci_hvc_present because they are used in some codes which are not
covered by #ifdef CONFIG_ACPI, see[1]. The file psci.c will be compiled
whether ACPI is enabled or not.

[1] [PATCH v4 09/21] arm/acpi: Add ACPI support for SMP initialization

> Which would solve the problem for !CONFIG_ACPI cases. But you need to be
> careful to move bool_t acpi_disabled, enable_acpi and disable_acpi
> inside an ifdef.
> 
> .
> 

-- 
Shannon

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

* Re: [PATCH v4 06/21] arm/acpi: Parse FADT table and get PSCI flags
  2016-02-23 12:13     ` Shannon Zhao
@ 2016-02-23 14:37       ` Stefano Stabellini
  0 siblings, 0 replies; 62+ messages in thread
From: Stefano Stabellini @ 2016-02-23 14:37 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: ian.campbell, Stefano Stabellini, peter.huangpeng, xen-devel,
	julien.grall, stefano.stabellini, shannon.zhao

On Tue, 23 Feb 2016, Shannon Zhao wrote:
> On 2016/1/27 23:41, Stefano Stabellini wrote:
> > On Sat, 23 Jan 2016, Shannon Zhao wrote:
> >> From: Shannon Zhao <shannon.zhao@linaro.org>
> >>
> >> There are two flags: PSCI_COMPLIANT and PSCI_USE_HVC. When set, the
> >> former signals to the OS that the hardware 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, parse FADT to get the flags for furture
> >> usage.
> >>
> >> Since STAO table and the GIC version are introduced by ACPI 6.0, we will
> >> check the version and only parse FADT table with version >= 6.0. If
> >> firmware provides ACPI tables with ACPI version less than 6.0, OS will
> >> be messed up with those information, so disable ACPI if we get an FADT
> >> table with version less than 6.0.
> >>
> >> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
> >> Signed-off-by: Naresh Bhat <naresh.bhat@linaro.org>
> >> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
> >> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> >> ---
> >> V4: drop disable_acpi in acpi_parse_fadt
> >> ---
> >>  xen/arch/arm/acpi/boot.c   | 30 ++++++++++++++++++++++++++++++
> >>  xen/arch/arm/acpi/lib.c    | 12 ++++++++++++
> >>  xen/include/asm-arm/acpi.h |  9 +++++++++
> >>  3 files changed, 51 insertions(+)
> >>
> >> diff --git a/xen/arch/arm/acpi/boot.c b/xen/arch/arm/acpi/boot.c
> >> index 1570f7e..6b33fbe 100644
> >> --- a/xen/arch/arm/acpi/boot.c
> >> +++ b/xen/arch/arm/acpi/boot.c
> >> @@ -27,9 +27,32 @@
> >>  
> >>  #include <xen/init.h>
> >>  #include <xen/acpi.h>
> >> +#include <xen/errno.h>
> >> +#include <acpi/actables.h>
> >> +#include <xen/mm.h>
> >>  
> >>  #include <asm/acpi.h>
> >>  
> >> +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 6.0,
> >> +     * we only deal with ACPI 6.0 or newer revision to get GIC and SMP
> >> +     * boot protocol configuration data, or we will disable ACPI.
> >> +     */
> >> +    if ( table->revision > 6
> >> +         || (table->revision == 6 && fadt->minor_revision >= 0) )
> >> +        return 0;
> >> +
> >> +    printk("Unsupported FADT revision %d.%d, should be 6.0+, will disable ACPI\n",
> >> +            table->revision, fadt->minor_revision);
> >> +
> >> +    return -EINVAL;
> >> +}
> >> +
> >>  /*
> >>   * acpi_boot_table_init() called from setup_arch(), always.
> >>   *      1. find RSDP and get its address, and then find XSDT
> >> @@ -54,5 +77,12 @@ int __init acpi_boot_table_init(void)
> >>          return error;
> >>      }
> >>  
> >> +    if ( acpi_table_parse(ACPI_SIG_FADT, acpi_parse_fadt) )
> >> +    {
> >> +        /* disable ACPI if no FADT is found */
> >> +        disable_acpi();
> >> +        printk("Can't find FADT\n");
> >> +    }
> >> +
> >>      return 0;
> >>  }
> >> diff --git a/xen/arch/arm/acpi/lib.c b/xen/arch/arm/acpi/lib.c
> >> index f817fe6..a30e4e6 100644
> >> --- a/xen/arch/arm/acpi/lib.c
> >> +++ b/xen/arch/arm/acpi/lib.c
> >> @@ -50,3 +50,15 @@ char *__acpi_map_table(paddr_t phys, unsigned long size)
> >>  
> >>  	return ((char *) base + offset);
> >>  }
> >> +
> >> +/* 1 to indicate PSCI 0.2+ is implemented */
> >> +bool_t __init acpi_psci_present(void)
> >> +{
> >> +    return acpi_gbl_FADT.arm_boot_flags & ACPI_FADT_PSCI_COMPLIANT;
> >> +}
> >> +
> >> +/* 1 to indicate HVC is present instead of SMC as the PSCI conduit */
> >> +bool_t __init acpi_psci_hvc_present(void)
> >> +{
> >> +    return acpi_gbl_FADT.arm_boot_flags & ACPI_FADT_PSCI_USE_HVC;
> >> +}
> > 
> > So far so good.
> > 
> > 
> >> diff --git a/xen/include/asm-arm/acpi.h b/xen/include/asm-arm/acpi.h
> >> index 6a037c9..1ce88f8 100644
> >> --- a/xen/include/asm-arm/acpi.h
> >> +++ b/xen/include/asm-arm/acpi.h
> >> @@ -31,6 +31,15 @@
> >>  #define ACPI_MAP_MEM_ATTR          PAGE_HYPERVISOR
> >>  
> >>  extern bool_t acpi_disabled;
> >> +
> >> +#ifdef CONFIG_ACPI
> >> +bool_t __init acpi_psci_present(void);
> >> +bool_t __init acpi_psci_hvc_present(void);
> >> +#else
> >> +static inline bool_t acpi_psci_present(void) { return false; }
> >> +static inline bool_t acpi_psci_hvc_present(void) {return false; }
> >> +#endif /* CONFIG_ACPI */
> >> +
> >>  /* Basic configuration for ACPI */
> >>  static inline void disable_acpi(void)
> >>  {
> > 
> > I would prefer if we only defined each function once, outside the ifdef
> > (no static inline needed). Then we could
> > 
> > #ifdef CONFIG_ACPI
> > extern bool_t acpi_disabled;
> > #else
> > #define acpi_disabled (1)
> > #endif
> > 
> Yes, we could do this to drop the #else (CONFIG_ACPI) case in some
> places. But I think it still needs to stub out acpi_psci_present and
> acpi_psci_hvc_present because they are used in some codes which are not
> covered by #ifdef CONFIG_ACPI, see[1]. The file psci.c will be compiled
> whether ACPI is enabled or not.
> 
> [1] [PATCH v4 09/21] arm/acpi: Add ACPI support for SMP initialization

Just to clarify, see the appended patch, generated on top of
ACPI_XEN_ARM_V3. With that I can compile Xen both arm64 (ACPI) and
arm32 (non-ACPI).

diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
index 1a40323..0a2b64e 100644
--- a/xen/arch/arm/setup.c
+++ b/xen/arch/arm/setup.c
@@ -52,7 +52,9 @@ struct bootinfo __initdata bootinfo;
 
 struct cpuinfo_arm __read_mostly boot_cpu_data;
 
+#ifdef CONFIG_ACPI
 bool_t __read_mostly acpi_disabled;
+#endif
 
 #ifdef CONFIG_ARM_32
 static unsigned long opt_xenheap_megabytes __initdata;
@@ -101,7 +103,7 @@ static void __init parse_acpi_param(char *s)
     }
     else if ( !strcmp(s, "force") )
     {
-        acpi_disabled = 0;
+        enable_acpi();
     }
 }
 
diff --git a/xen/include/asm-arm/acpi.h b/xen/include/asm-arm/acpi.h
index 628f3c8..5fe5a1d 100644
--- a/xen/include/asm-arm/acpi.h
+++ b/xen/include/asm-arm/acpi.h
@@ -29,7 +29,6 @@
 #define COMPILER_DEPENDENT_INT64   long long
 #define COMPILER_DEPENDENT_UINT64  unsigned long long
 
-extern bool_t acpi_disabled;
 
 /* Tables marked as reserved in efi table */
 typedef enum {
@@ -43,22 +42,14 @@ typedef enum {
     TBL_MMAX,
 } EFI_MEM_RES;
 
-#ifdef CONFIG_ACPI
 bool_t __init acpi_psci_present(void);
 bool_t __init acpi_psci_hvc_present(void);
 void __init acpi_smp_init_cpus(void);
 unsigned int acpi_get_irq_type(u32 flags);
 unsigned int acpi_get_table_offset(struct membank tbl_add[], EFI_MEM_RES index);
-#else
-static inline bool_t acpi_psci_present(void) { return false; }
-static inline bool_t acpi_psci_hvc_present(void) {return false; }
-static inline void acpi_smp_init_cpus(void) { }
-static inline unsigned int acpi_get_irq_type(u32 flags) { return 0; }
-unsigned int acpi_get_table_offset(struct membank tbl_add[], EFI_MEM_RES index)
-{
-    return 0;
-}
-#endif /* CONFIG_ACPI */
+
+#ifdef CONFIG_ACPI
+extern bool_t acpi_disabled;
 
 /* Basic configuration for ACPI */
 static inline void disable_acpi(void)
@@ -66,6 +57,18 @@ static inline void disable_acpi(void)
     acpi_disabled = 1;
 }
 
+static inline void enable_acpi(void)
+{
+    acpi_disabled = 0;
+}
+#else
+
+#define acpi_disabled (1)
+#define disable_acpi(x)
+#define enable_acpi(x)
+
+#endif /* CONFIG_ACPI */
+
 #define ACPI_GTDT_INTR_MASK ( ACPI_GTDT_INTERRUPT_MODE | ACPI_GTDT_INTERRUPT_POLARITY )
 
 /* Triggering */

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

* Re: [PATCH v4 13/21] arm/gic-v2: Add ACPI boot support for GICv2
  2016-01-28 12:56   ` Stefano Stabellini
@ 2016-02-25  8:32     ` Shannon Zhao
  2016-02-25 10:42       ` Stefano Stabellini
  0 siblings, 1 reply; 62+ messages in thread
From: Shannon Zhao @ 2016-02-25  8:32 UTC (permalink / raw)
  To: Stefano Stabellini
  Cc: ian.campbell, peter.huangpeng, xen-devel, julien.grall,
	stefano.stabellini, shannon.zhao



On 2016/1/28 20:56, Stefano Stabellini wrote:
> On Sat, 23 Jan 2016, Shannon Zhao wrote:
>> From: Parth Dixit <parth.dixit@linaro.org>
>>
>> ACPI on Xen hypervisor uses MADT table for proper GIC initialization.
>> First get the GIC version from GIC Distributor. Then 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 GICv2.
>>
>> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
>> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
>>
>> V4: use container_of and fix coding style
>> ---
>>  xen/arch/arm/gic-v2.c | 120 +++++++++++++++++++++++++++++++++++++++++++++++++-
>>  1 file changed, 119 insertions(+), 1 deletion(-)
>>
>> diff --git a/xen/arch/arm/gic-v2.c b/xen/arch/arm/gic-v2.c
>> index 668b863..7e46ee9 100644
>> --- a/xen/arch/arm/gic-v2.c
>> +++ b/xen/arch/arm/gic-v2.c
>> @@ -29,6 +29,8 @@
>>  #include <xen/device_tree.h>
>>  #include <xen/libfdt/libfdt.h>
>>  #include <xen/sizes.h>
>> +#include <xen/acpi.h>
>> +#include <acpi/actables.h>
>>  #include <asm/p2m.h>
>>  #include <asm/domain.h>
>>  #include <asm/platform.h>
>> @@ -36,6 +38,7 @@
>>  
>>  #include <asm/io.h>
>>  #include <asm/gic.h>
>> +#include <asm/acpi.h>
>>  
>>  /*
>>   * LR register definitions are GIC v2 specific.
>> @@ -681,11 +684,111 @@ static void __init gicv2_dt_init(void)
>>                 csize, vsize);
>>  }
>>  
>> +#ifdef CONFIG_ACPI
>> +static int __init
>> +gic_acpi_parse_madt_cpu(struct acpi_subtable_header *header,
>> +                        const unsigned long end)
>> +{
>> +    static int cpu_base_assigned = 0;
>> +    struct acpi_madt_generic_interrupt *processor =
>> +               container_of(header, struct acpi_madt_generic_interrupt, header);
>> +
>> +    if ( BAD_MADT_ENTRY(processor, end) )
>> +        return -EINVAL;
>> +
>> +    /* Read from APIC table and fill up the GIC variables */
>> +    if ( cpu_base_assigned == 0 )
>> +    {
>> +        cbase = processor->base_address;
>> +        csize = SZ_8K;
>> +        hbase = processor->gich_base_address;
>> +        vbase = processor->gicv_base_address;
>> +        gicv2_info.maintenance_irq = processor->vgic_interrupt;
>> +
>> +        if( processor->flags & ACPI_MADT_VGIC_IRQ_MODE )
> 
>             ^ if ( 
> 
> 
>> +            irq_set_type(gicv2_info.maintenance_irq, IRQ_TYPE_EDGE_BOTH);
>> +        else
>> +            irq_set_type(gicv2_info.maintenance_irq, IRQ_TYPE_LEVEL_MASK);
>> +
>> +        cpu_base_assigned = 1;
>> +    }
>> +    else
>> +    {
>> +        if ( cbase != processor->base_address
>> +             || hbase != processor->gich_base_address
>> +             || vbase != processor->gicv_base_address
>> +             || gicv2_info.maintenance_irq != processor->vgic_interrupt )
>> +        {
>> +            printk("GICv2: GICC entries are not same in MADT table\n");
>> +            return -EINVAL;
>> +        }
>> +    }
>> +
>> +    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 =
>> +             container_of(header, struct acpi_madt_generic_distributor, header);
>> +
>> +    if ( BAD_MADT_ENTRY(dist, end) )
>> +        return -EINVAL;
>> +
>> +    dbase = dist->base_address;
>> +
>> +    return 0;
>> +}
>> +
>> +static void __init gicv2_acpi_init(void)
>> +{
>> +    acpi_status status;
>> +    struct acpi_table_header *table;
>> +    int count;
>> +
>> +    status = acpi_get_table(ACPI_SIG_MADT, 0, &table);
>> +
>> +    if ( ACPI_FAILURE(status) )
>> +    {
>> +        const char *msg = acpi_format_exception(status);
>> +
>> +        panic("GICv2: Failed to get MADT table, %s", msg);
>> +    }
>> +
>> +    /* 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 )
>> +        panic("GICv2: No valid GICC entries exists");
>> +
>> +    /*
>> +     * Find distributor base address. We expect one distributor entry since
>> +     * ACPI 5.0 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 )
>> +        panic("GICv2: No valid GICD entries exists");
>> +}
>> +#else
>> +static void __init gicv2_acpi_init(void)
>> +{
>> +/* Should never reach here */
>> +}
>> +#endif
> 
> With acpi_disabled becoming an #define constant, this #else should not
> be needed.
> 
If I remove #else and define acpi_disabled as a constant as you
suggested, it has below compiling error on arm32.

diff --git a/xen/arch/arm/gic-v2.c b/xen/arch/arm/gic-v2.c
index 9a9fcd5..28ec064 100644
--- a/xen/arch/arm/gic-v2.c
+++ b/xen/arch/arm/gic-v2.c
@@ -776,11 +776,6 @@ static void __init acpi_gicv2_init(void)
     if ( count <= 0 )
         panic("GICv2: No valid GICD entries exists");
 }
-#else
-static void __init acpi_gicv2_init(void)
-{
-/* Should never reach here */
-}
 #endif

gic-v2.c: In function 'gicv2_init':
gic-v2.c:793:9: error: implicit declaration of function
'acpi_gicv2_init' [-Werror=implicit-function-declaration]
gic-v2.c:793:9: error: nested extern declaration of 'acpi_gicv2_init'
[-Werror=nested-externs]
cc1: all warnings being treated as errors


> Provided that you make these 2 changes, you can add my Reviewed-by.
> 
> 
>>  static int __init gicv2_init(void)
>>  {
>>      uint32_t aliased_offset = 0;
>>  
>> -    gicv2_dt_init();
>> +    if ( acpi_disabled )
>> +        gicv2_dt_init();
>> +    else
>> +        gicv2_acpi_init();
>>  
>>      printk("GICv2 initialization:\n"
>>                "        gic_dist_addr=%"PRIpaddr"\n"
>> @@ -793,6 +896,21 @@ DT_DEVICE_START(gicv2, "GICv2", DEVICE_GIC)
>>          .init = gicv2_dt_preinit,
>>  DT_DEVICE_END
>>  
>> +#ifdef CONFIG_ACPI
>> +/* Set up the GIC */
>> +static int __init gicv2_acpi_preinit(const void *data)
>> +{
>> +    gicv2_info.hw_version = GIC_V2;
>> +    register_gic_ops(&gicv2_ops);
>> +
>> +    return 0;
>> +}
>> +
>> +ACPI_DEVICE_START(agicv2, "GICv2", DEVICE_GIC)
>> +        .class_type = ACPI_MADT_GIC_VERSION_V2,
>> +        .init = gicv2_acpi_preinit,
>> +ACPI_DEVICE_END
>> +#endif
>>  /*
>>   * Local variables:
>>   * mode: C
>> -- 
>> 2.0.4
>>
>>
>>
>> _______________________________________________
>> Xen-devel mailing list
>> Xen-devel@lists.xen.org
>> http://lists.xen.org/xen-devel
>>
> 
> .
> 

-- 
Shannon


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

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

* Re: [PATCH v4 13/21] arm/gic-v2: Add ACPI boot support for GICv2
  2016-02-25  8:32     ` Shannon Zhao
@ 2016-02-25 10:42       ` Stefano Stabellini
  2016-02-25 14:06         ` Shannon Zhao
  0 siblings, 1 reply; 62+ messages in thread
From: Stefano Stabellini @ 2016-02-25 10:42 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: ian.campbell, Stefano Stabellini, peter.huangpeng, xen-devel,
	julien.grall, stefano.stabellini, shannon.zhao

On Thu, 25 Feb 2016, Shannon Zhao wrote:
> On 2016/1/28 20:56, Stefano Stabellini wrote:
> > On Sat, 23 Jan 2016, Shannon Zhao wrote:
> >> From: Parth Dixit <parth.dixit@linaro.org>
> >>
> >> ACPI on Xen hypervisor uses MADT table for proper GIC initialization.
> >> First get the GIC version from GIC Distributor. Then 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 GICv2.
> >>
> >> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
> >> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> >>
> >> V4: use container_of and fix coding style
> >> ---
> >>  xen/arch/arm/gic-v2.c | 120 +++++++++++++++++++++++++++++++++++++++++++++++++-
> >>  1 file changed, 119 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/xen/arch/arm/gic-v2.c b/xen/arch/arm/gic-v2.c
> >> index 668b863..7e46ee9 100644
> >> --- a/xen/arch/arm/gic-v2.c
> >> +++ b/xen/arch/arm/gic-v2.c
> >> @@ -29,6 +29,8 @@
> >>  #include <xen/device_tree.h>
> >>  #include <xen/libfdt/libfdt.h>
> >>  #include <xen/sizes.h>
> >> +#include <xen/acpi.h>
> >> +#include <acpi/actables.h>
> >>  #include <asm/p2m.h>
> >>  #include <asm/domain.h>
> >>  #include <asm/platform.h>
> >> @@ -36,6 +38,7 @@
> >>  
> >>  #include <asm/io.h>
> >>  #include <asm/gic.h>
> >> +#include <asm/acpi.h>
> >>  
> >>  /*
> >>   * LR register definitions are GIC v2 specific.
> >> @@ -681,11 +684,111 @@ static void __init gicv2_dt_init(void)
> >>                 csize, vsize);
> >>  }
> >>  
> >> +#ifdef CONFIG_ACPI
> >> +static int __init
> >> +gic_acpi_parse_madt_cpu(struct acpi_subtable_header *header,
> >> +                        const unsigned long end)
> >> +{
> >> +    static int cpu_base_assigned = 0;
> >> +    struct acpi_madt_generic_interrupt *processor =
> >> +               container_of(header, struct acpi_madt_generic_interrupt, header);
> >> +
> >> +    if ( BAD_MADT_ENTRY(processor, end) )
> >> +        return -EINVAL;
> >> +
> >> +    /* Read from APIC table and fill up the GIC variables */
> >> +    if ( cpu_base_assigned == 0 )
> >> +    {
> >> +        cbase = processor->base_address;
> >> +        csize = SZ_8K;
> >> +        hbase = processor->gich_base_address;
> >> +        vbase = processor->gicv_base_address;
> >> +        gicv2_info.maintenance_irq = processor->vgic_interrupt;
> >> +
> >> +        if( processor->flags & ACPI_MADT_VGIC_IRQ_MODE )
> > 
> >             ^ if ( 
> > 
> > 
> >> +            irq_set_type(gicv2_info.maintenance_irq, IRQ_TYPE_EDGE_BOTH);
> >> +        else
> >> +            irq_set_type(gicv2_info.maintenance_irq, IRQ_TYPE_LEVEL_MASK);
> >> +
> >> +        cpu_base_assigned = 1;
> >> +    }
> >> +    else
> >> +    {
> >> +        if ( cbase != processor->base_address
> >> +             || hbase != processor->gich_base_address
> >> +             || vbase != processor->gicv_base_address
> >> +             || gicv2_info.maintenance_irq != processor->vgic_interrupt )
> >> +        {
> >> +            printk("GICv2: GICC entries are not same in MADT table\n");
> >> +            return -EINVAL;
> >> +        }
> >> +    }
> >> +
> >> +    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 =
> >> +             container_of(header, struct acpi_madt_generic_distributor, header);
> >> +
> >> +    if ( BAD_MADT_ENTRY(dist, end) )
> >> +        return -EINVAL;
> >> +
> >> +    dbase = dist->base_address;
> >> +
> >> +    return 0;
> >> +}
> >> +
> >> +static void __init gicv2_acpi_init(void)
> >> +{
> >> +    acpi_status status;
> >> +    struct acpi_table_header *table;
> >> +    int count;
> >> +
> >> +    status = acpi_get_table(ACPI_SIG_MADT, 0, &table);
> >> +
> >> +    if ( ACPI_FAILURE(status) )
> >> +    {
> >> +        const char *msg = acpi_format_exception(status);
> >> +
> >> +        panic("GICv2: Failed to get MADT table, %s", msg);
> >> +    }
> >> +
> >> +    /* 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 )
> >> +        panic("GICv2: No valid GICC entries exists");
> >> +
> >> +    /*
> >> +     * Find distributor base address. We expect one distributor entry since
> >> +     * ACPI 5.0 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 )
> >> +        panic("GICv2: No valid GICD entries exists");
> >> +}
> >> +#else
> >> +static void __init gicv2_acpi_init(void)
> >> +{
> >> +/* Should never reach here */
> >> +}
> >> +#endif
> > 
> > With acpi_disabled becoming an #define constant, this #else should not
> > be needed.
> > 
> If I remove #else and define acpi_disabled as a constant as you
> suggested, it has below compiling error on arm32.
> 
> diff --git a/xen/arch/arm/gic-v2.c b/xen/arch/arm/gic-v2.c
> index 9a9fcd5..28ec064 100644
> --- a/xen/arch/arm/gic-v2.c
> +++ b/xen/arch/arm/gic-v2.c
> @@ -776,11 +776,6 @@ static void __init acpi_gicv2_init(void)
>      if ( count <= 0 )
>          panic("GICv2: No valid GICD entries exists");
>  }
> -#else
> -static void __init acpi_gicv2_init(void)
> -{
> -/* Should never reach here */
> -}
>  #endif
> 
> gic-v2.c: In function 'gicv2_init':
> gic-v2.c:793:9: error: implicit declaration of function
> 'acpi_gicv2_init' [-Werror=implicit-function-declaration]
> gic-v2.c:793:9: error: nested extern declaration of 'acpi_gicv2_init'
> [-Werror=nested-externs]
> cc1: all warnings being treated as errors

Sorry, I should have been clearer. You still need to have a declaration
of the function outside the #ifdef. Something like the following should
work:

  static void acpi_gicv2_init(void);

  [...]

  #ifdef CONFIG_ACPI
  static void __init acpi_gicv2_init(void)
  {
      /* do something */
  }
  #endif

  [...]

  if ( acpi_disabled )
      gicv2_dt_init();
  else
      gicv2_acpi_init();

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

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

* Re: [PATCH v4 13/21] arm/gic-v2: Add ACPI boot support for GICv2
  2016-02-25 10:42       ` Stefano Stabellini
@ 2016-02-25 14:06         ` Shannon Zhao
  2016-02-25 14:56           ` Stefano Stabellini
  0 siblings, 1 reply; 62+ messages in thread
From: Shannon Zhao @ 2016-02-25 14:06 UTC (permalink / raw)
  To: Stefano Stabellini
  Cc: ian.campbell, peter.huangpeng, xen-devel, julien.grall,
	stefano.stabellini, shannon.zhao



On 2016/2/25 18:42, Stefano Stabellini wrote:
> On Thu, 25 Feb 2016, Shannon Zhao wrote:
>> On 2016/1/28 20:56, Stefano Stabellini wrote:
>>> On Sat, 23 Jan 2016, Shannon Zhao wrote:
>>>> From: Parth Dixit <parth.dixit@linaro.org>
>>>>
>>>> ACPI on Xen hypervisor uses MADT table for proper GIC initialization.
>>>> First get the GIC version from GIC Distributor. Then 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 GICv2.
>>>>
>>>> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
>>>> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
>>>>
>>>> V4: use container_of and fix coding style
>>>> ---
>>>>  xen/arch/arm/gic-v2.c | 120 +++++++++++++++++++++++++++++++++++++++++++++++++-
>>>>  1 file changed, 119 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/xen/arch/arm/gic-v2.c b/xen/arch/arm/gic-v2.c
>>>> index 668b863..7e46ee9 100644
>>>> --- a/xen/arch/arm/gic-v2.c
>>>> +++ b/xen/arch/arm/gic-v2.c
>>>> @@ -29,6 +29,8 @@
>>>>  #include <xen/device_tree.h>
>>>>  #include <xen/libfdt/libfdt.h>
>>>>  #include <xen/sizes.h>
>>>> +#include <xen/acpi.h>
>>>> +#include <acpi/actables.h>
>>>>  #include <asm/p2m.h>
>>>>  #include <asm/domain.h>
>>>>  #include <asm/platform.h>
>>>> @@ -36,6 +38,7 @@
>>>>  
>>>>  #include <asm/io.h>
>>>>  #include <asm/gic.h>
>>>> +#include <asm/acpi.h>
>>>>  
>>>>  /*
>>>>   * LR register definitions are GIC v2 specific.
>>>> @@ -681,11 +684,111 @@ static void __init gicv2_dt_init(void)
>>>>                 csize, vsize);
>>>>  }
>>>>  
>>>> +#ifdef CONFIG_ACPI
>>>> +static int __init
>>>> +gic_acpi_parse_madt_cpu(struct acpi_subtable_header *header,
>>>> +                        const unsigned long end)
>>>> +{
>>>> +    static int cpu_base_assigned = 0;
>>>> +    struct acpi_madt_generic_interrupt *processor =
>>>> +               container_of(header, struct acpi_madt_generic_interrupt, header);
>>>> +
>>>> +    if ( BAD_MADT_ENTRY(processor, end) )
>>>> +        return -EINVAL;
>>>> +
>>>> +    /* Read from APIC table and fill up the GIC variables */
>>>> +    if ( cpu_base_assigned == 0 )
>>>> +    {
>>>> +        cbase = processor->base_address;
>>>> +        csize = SZ_8K;
>>>> +        hbase = processor->gich_base_address;
>>>> +        vbase = processor->gicv_base_address;
>>>> +        gicv2_info.maintenance_irq = processor->vgic_interrupt;
>>>> +
>>>> +        if( processor->flags & ACPI_MADT_VGIC_IRQ_MODE )
>>>
>>>             ^ if ( 
>>>
>>>
>>>> +            irq_set_type(gicv2_info.maintenance_irq, IRQ_TYPE_EDGE_BOTH);
>>>> +        else
>>>> +            irq_set_type(gicv2_info.maintenance_irq, IRQ_TYPE_LEVEL_MASK);
>>>> +
>>>> +        cpu_base_assigned = 1;
>>>> +    }
>>>> +    else
>>>> +    {
>>>> +        if ( cbase != processor->base_address
>>>> +             || hbase != processor->gich_base_address
>>>> +             || vbase != processor->gicv_base_address
>>>> +             || gicv2_info.maintenance_irq != processor->vgic_interrupt )
>>>> +        {
>>>> +            printk("GICv2: GICC entries are not same in MADT table\n");
>>>> +            return -EINVAL;
>>>> +        }
>>>> +    }
>>>> +
>>>> +    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 =
>>>> +             container_of(header, struct acpi_madt_generic_distributor, header);
>>>> +
>>>> +    if ( BAD_MADT_ENTRY(dist, end) )
>>>> +        return -EINVAL;
>>>> +
>>>> +    dbase = dist->base_address;
>>>> +
>>>> +    return 0;
>>>> +}
>>>> +
>>>> +static void __init gicv2_acpi_init(void)
>>>> +{
>>>> +    acpi_status status;
>>>> +    struct acpi_table_header *table;
>>>> +    int count;
>>>> +
>>>> +    status = acpi_get_table(ACPI_SIG_MADT, 0, &table);
>>>> +
>>>> +    if ( ACPI_FAILURE(status) )
>>>> +    {
>>>> +        const char *msg = acpi_format_exception(status);
>>>> +
>>>> +        panic("GICv2: Failed to get MADT table, %s", msg);
>>>> +    }
>>>> +
>>>> +    /* 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 )
>>>> +        panic("GICv2: No valid GICC entries exists");
>>>> +
>>>> +    /*
>>>> +     * Find distributor base address. We expect one distributor entry since
>>>> +     * ACPI 5.0 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 )
>>>> +        panic("GICv2: No valid GICD entries exists");
>>>> +}
>>>> +#else
>>>> +static void __init gicv2_acpi_init(void)
>>>> +{
>>>> +/* Should never reach here */
>>>> +}
>>>> +#endif
>>>
>>> With acpi_disabled becoming an #define constant, this #else should not
>>> be needed.
>>>
>> If I remove #else and define acpi_disabled as a constant as you
>> suggested, it has below compiling error on arm32.
>>
>> diff --git a/xen/arch/arm/gic-v2.c b/xen/arch/arm/gic-v2.c
>> index 9a9fcd5..28ec064 100644
>> --- a/xen/arch/arm/gic-v2.c
>> +++ b/xen/arch/arm/gic-v2.c
>> @@ -776,11 +776,6 @@ static void __init acpi_gicv2_init(void)
>>      if ( count <= 0 )
>>          panic("GICv2: No valid GICD entries exists");
>>  }
>> -#else
>> -static void __init acpi_gicv2_init(void)
>> -{
>> -/* Should never reach here */
>> -}
>>  #endif
>>
>> gic-v2.c: In function 'gicv2_init':
>> gic-v2.c:793:9: error: implicit declaration of function
>> 'acpi_gicv2_init' [-Werror=implicit-function-declaration]
>> gic-v2.c:793:9: error: nested extern declaration of 'acpi_gicv2_init'
>> [-Werror=nested-externs]
>> cc1: all warnings being treated as errors
> 
> Sorry, I should have been clearer. You still need to have a declaration
> of the function outside the #ifdef. Something like the following should
> work:
> 
>   static void acpi_gicv2_init(void);
> 
>   [...]
> 
>   #ifdef CONFIG_ACPI
>   static void __init acpi_gicv2_init(void)
>   {
>       /* do something */
>   }
>   #endif
> 
>   [...]
> 
>   if ( acpi_disabled )
>       gicv2_dt_init();
>   else
>       gicv2_acpi_init();
> 
> .
> 
I'm afraid it doesn't work. Still has below errors with the declaration:

gic-v2.c:687:13: error: 'gicv2_acpi_init' used but never defined [-Werror]
cc1: all warnings being treated as errors

diff --git a/xen/arch/arm/gic-v2.c b/xen/arch/arm/gic-v2.c
index 4b6c4c0..7b7e094 100644
--- a/xen/arch/arm/gic-v2.c
+++ b/xen/arch/arm/gic-v2.c
@@ -684,6 +684,8 @@ static void __init gicv2_dt_init(void)
                csize, vsize);
 }

+static void gicv2_acpi_init(void);
+
 #ifdef CONFIG_ACPI
 static int __init
 gic_acpi_parse_madt_cpu(struct acpi_subtable_header *header,
@@ -774,11 +776,6 @@ static void __init gicv2_acpi_init(void)
     if ( count <= 0 )
         panic("GICv2: No valid GICD entries exists");
 }
-#else
-static void __init gicv2_acpi_init(void)
-{
-/* Should never reach here */
-}
 #endif

 static int __init gicv2_init(void)

-- 
Shannon


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

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

* Re: [PATCH v4 13/21] arm/gic-v2: Add ACPI boot support for GICv2
  2016-02-25 14:06         ` Shannon Zhao
@ 2016-02-25 14:56           ` Stefano Stabellini
  2016-02-25 14:59             ` Stefano Stabellini
  0 siblings, 1 reply; 62+ messages in thread
From: Stefano Stabellini @ 2016-02-25 14:56 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: ian.campbell, Stefano Stabellini, peter.huangpeng, xen-devel,
	julien.grall, stefano.stabellini, shannon.zhao

On Thu, 25 Feb 2016, Shannon Zhao wrote:
> On 2016/2/25 18:42, Stefano Stabellini wrote:
> > On Thu, 25 Feb 2016, Shannon Zhao wrote:
> >> On 2016/1/28 20:56, Stefano Stabellini wrote:
> >>> On Sat, 23 Jan 2016, Shannon Zhao wrote:
> >>>> From: Parth Dixit <parth.dixit@linaro.org>
> >>>>
> >>>> ACPI on Xen hypervisor uses MADT table for proper GIC initialization.
> >>>> First get the GIC version from GIC Distributor. Then 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 GICv2.
> >>>>
> >>>> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
> >>>> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> >>>>
> >>>> V4: use container_of and fix coding style
> >>>> ---
> >>>>  xen/arch/arm/gic-v2.c | 120 +++++++++++++++++++++++++++++++++++++++++++++++++-
> >>>>  1 file changed, 119 insertions(+), 1 deletion(-)
> >>>>
> >>>> diff --git a/xen/arch/arm/gic-v2.c b/xen/arch/arm/gic-v2.c
> >>>> index 668b863..7e46ee9 100644
> >>>> --- a/xen/arch/arm/gic-v2.c
> >>>> +++ b/xen/arch/arm/gic-v2.c
> >>>> @@ -29,6 +29,8 @@
> >>>>  #include <xen/device_tree.h>
> >>>>  #include <xen/libfdt/libfdt.h>
> >>>>  #include <xen/sizes.h>
> >>>> +#include <xen/acpi.h>
> >>>> +#include <acpi/actables.h>
> >>>>  #include <asm/p2m.h>
> >>>>  #include <asm/domain.h>
> >>>>  #include <asm/platform.h>
> >>>> @@ -36,6 +38,7 @@
> >>>>  
> >>>>  #include <asm/io.h>
> >>>>  #include <asm/gic.h>
> >>>> +#include <asm/acpi.h>
> >>>>  
> >>>>  /*
> >>>>   * LR register definitions are GIC v2 specific.
> >>>> @@ -681,11 +684,111 @@ static void __init gicv2_dt_init(void)
> >>>>                 csize, vsize);
> >>>>  }
> >>>>  
> >>>> +#ifdef CONFIG_ACPI
> >>>> +static int __init
> >>>> +gic_acpi_parse_madt_cpu(struct acpi_subtable_header *header,
> >>>> +                        const unsigned long end)
> >>>> +{
> >>>> +    static int cpu_base_assigned = 0;
> >>>> +    struct acpi_madt_generic_interrupt *processor =
> >>>> +               container_of(header, struct acpi_madt_generic_interrupt, header);
> >>>> +
> >>>> +    if ( BAD_MADT_ENTRY(processor, end) )
> >>>> +        return -EINVAL;
> >>>> +
> >>>> +    /* Read from APIC table and fill up the GIC variables */
> >>>> +    if ( cpu_base_assigned == 0 )
> >>>> +    {
> >>>> +        cbase = processor->base_address;
> >>>> +        csize = SZ_8K;
> >>>> +        hbase = processor->gich_base_address;
> >>>> +        vbase = processor->gicv_base_address;
> >>>> +        gicv2_info.maintenance_irq = processor->vgic_interrupt;
> >>>> +
> >>>> +        if( processor->flags & ACPI_MADT_VGIC_IRQ_MODE )
> >>>
> >>>             ^ if ( 
> >>>
> >>>
> >>>> +            irq_set_type(gicv2_info.maintenance_irq, IRQ_TYPE_EDGE_BOTH);
> >>>> +        else
> >>>> +            irq_set_type(gicv2_info.maintenance_irq, IRQ_TYPE_LEVEL_MASK);
> >>>> +
> >>>> +        cpu_base_assigned = 1;
> >>>> +    }
> >>>> +    else
> >>>> +    {
> >>>> +        if ( cbase != processor->base_address
> >>>> +             || hbase != processor->gich_base_address
> >>>> +             || vbase != processor->gicv_base_address
> >>>> +             || gicv2_info.maintenance_irq != processor->vgic_interrupt )
> >>>> +        {
> >>>> +            printk("GICv2: GICC entries are not same in MADT table\n");
> >>>> +            return -EINVAL;
> >>>> +        }
> >>>> +    }
> >>>> +
> >>>> +    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 =
> >>>> +             container_of(header, struct acpi_madt_generic_distributor, header);
> >>>> +
> >>>> +    if ( BAD_MADT_ENTRY(dist, end) )
> >>>> +        return -EINVAL;
> >>>> +
> >>>> +    dbase = dist->base_address;
> >>>> +
> >>>> +    return 0;
> >>>> +}
> >>>> +
> >>>> +static void __init gicv2_acpi_init(void)
> >>>> +{
> >>>> +    acpi_status status;
> >>>> +    struct acpi_table_header *table;
> >>>> +    int count;
> >>>> +
> >>>> +    status = acpi_get_table(ACPI_SIG_MADT, 0, &table);
> >>>> +
> >>>> +    if ( ACPI_FAILURE(status) )
> >>>> +    {
> >>>> +        const char *msg = acpi_format_exception(status);
> >>>> +
> >>>> +        panic("GICv2: Failed to get MADT table, %s", msg);
> >>>> +    }
> >>>> +
> >>>> +    /* 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 )
> >>>> +        panic("GICv2: No valid GICC entries exists");
> >>>> +
> >>>> +    /*
> >>>> +     * Find distributor base address. We expect one distributor entry since
> >>>> +     * ACPI 5.0 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 )
> >>>> +        panic("GICv2: No valid GICD entries exists");
> >>>> +}
> >>>> +#else
> >>>> +static void __init gicv2_acpi_init(void)
> >>>> +{
> >>>> +/* Should never reach here */
> >>>> +}
> >>>> +#endif
> >>>
> >>> With acpi_disabled becoming an #define constant, this #else should not
> >>> be needed.
> >>>
> >> If I remove #else and define acpi_disabled as a constant as you
> >> suggested, it has below compiling error on arm32.
> >>
> >> diff --git a/xen/arch/arm/gic-v2.c b/xen/arch/arm/gic-v2.c
> >> index 9a9fcd5..28ec064 100644
> >> --- a/xen/arch/arm/gic-v2.c
> >> +++ b/xen/arch/arm/gic-v2.c
> >> @@ -776,11 +776,6 @@ static void __init acpi_gicv2_init(void)
> >>      if ( count <= 0 )
> >>          panic("GICv2: No valid GICD entries exists");
> >>  }
> >> -#else
> >> -static void __init acpi_gicv2_init(void)
> >> -{
> >> -/* Should never reach here */
> >> -}
> >>  #endif
> >>
> >> gic-v2.c: In function 'gicv2_init':
> >> gic-v2.c:793:9: error: implicit declaration of function
> >> 'acpi_gicv2_init' [-Werror=implicit-function-declaration]
> >> gic-v2.c:793:9: error: nested extern declaration of 'acpi_gicv2_init'
> >> [-Werror=nested-externs]
> >> cc1: all warnings being treated as errors
> > 
> > Sorry, I should have been clearer. You still need to have a declaration
> > of the function outside the #ifdef. Something like the following should
> > work:
> > 
> >   static void acpi_gicv2_init(void);
> > 
> >   [...]
> > 
> >   #ifdef CONFIG_ACPI
> >   static void __init acpi_gicv2_init(void)
> >   {
> >       /* do something */
> >   }
> >   #endif
> > 
> >   [...]
> > 
> >   if ( acpi_disabled )
> >       gicv2_dt_init();
> >   else
> >       gicv2_acpi_init();
> > 
> > .
> > 
> I'm afraid it doesn't work. Still has below errors with the declaration:
> 
> gic-v2.c:687:13: error: 'gicv2_acpi_init' used but never defined [-Werror]
> cc1: all warnings being treated as errors
>
> diff --git a/xen/arch/arm/gic-v2.c b/xen/arch/arm/gic-v2.c
> index 4b6c4c0..7b7e094 100644
> --- a/xen/arch/arm/gic-v2.c
> +++ b/xen/arch/arm/gic-v2.c
> @@ -684,6 +684,8 @@ static void __init gicv2_dt_init(void)
>                 csize, vsize);
>  }
> 
> +static void gicv2_acpi_init(void);

It should be

   void gicv2_acpi_init(void);

without "static".



>  #ifdef CONFIG_ACPI
>  static int __init
>  gic_acpi_parse_madt_cpu(struct acpi_subtable_header *header,
> @@ -774,11 +776,6 @@ static void __init gicv2_acpi_init(void)
>      if ( count <= 0 )
>          panic("GICv2: No valid GICD entries exists");
>  }
> -#else
> -static void __init gicv2_acpi_init(void)
> -{
> -/* Should never reach here */
> -}
>  #endif
> 
>  static int __init gicv2_init(void)
> 
> -- 
> Shannon
> 

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

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

* Re: [PATCH v4 13/21] arm/gic-v2: Add ACPI boot support for GICv2
  2016-02-25 14:56           ` Stefano Stabellini
@ 2016-02-25 14:59             ` Stefano Stabellini
  0 siblings, 0 replies; 62+ messages in thread
From: Stefano Stabellini @ 2016-02-25 14:59 UTC (permalink / raw)
  To: Stefano Stabellini
  Cc: ian.campbell, peter.huangpeng, xen-devel, julien.grall,
	stefano.stabellini, shannon.zhao, Shannon Zhao

On Thu, 25 Feb 2016, Stefano Stabellini wrote:
> On Thu, 25 Feb 2016, Shannon Zhao wrote:
> > On 2016/2/25 18:42, Stefano Stabellini wrote:
> > > On Thu, 25 Feb 2016, Shannon Zhao wrote:
> > >> On 2016/1/28 20:56, Stefano Stabellini wrote:
> > >>> On Sat, 23 Jan 2016, Shannon Zhao wrote:
> > >>>> From: Parth Dixit <parth.dixit@linaro.org>
> > >>>>
> > >>>> ACPI on Xen hypervisor uses MADT table for proper GIC initialization.
> > >>>> First get the GIC version from GIC Distributor. Then 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 GICv2.
> > >>>>
> > >>>> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
> > >>>> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> > >>>>
> > >>>> V4: use container_of and fix coding style
> > >>>> ---
> > >>>>  xen/arch/arm/gic-v2.c | 120 +++++++++++++++++++++++++++++++++++++++++++++++++-
> > >>>>  1 file changed, 119 insertions(+), 1 deletion(-)
> > >>>>
> > >>>> diff --git a/xen/arch/arm/gic-v2.c b/xen/arch/arm/gic-v2.c
> > >>>> index 668b863..7e46ee9 100644
> > >>>> --- a/xen/arch/arm/gic-v2.c
> > >>>> +++ b/xen/arch/arm/gic-v2.c
> > >>>> @@ -29,6 +29,8 @@
> > >>>>  #include <xen/device_tree.h>
> > >>>>  #include <xen/libfdt/libfdt.h>
> > >>>>  #include <xen/sizes.h>
> > >>>> +#include <xen/acpi.h>
> > >>>> +#include <acpi/actables.h>
> > >>>>  #include <asm/p2m.h>
> > >>>>  #include <asm/domain.h>
> > >>>>  #include <asm/platform.h>
> > >>>> @@ -36,6 +38,7 @@
> > >>>>  
> > >>>>  #include <asm/io.h>
> > >>>>  #include <asm/gic.h>
> > >>>> +#include <asm/acpi.h>
> > >>>>  
> > >>>>  /*
> > >>>>   * LR register definitions are GIC v2 specific.
> > >>>> @@ -681,11 +684,111 @@ static void __init gicv2_dt_init(void)
> > >>>>                 csize, vsize);
> > >>>>  }
> > >>>>  
> > >>>> +#ifdef CONFIG_ACPI
> > >>>> +static int __init
> > >>>> +gic_acpi_parse_madt_cpu(struct acpi_subtable_header *header,
> > >>>> +                        const unsigned long end)
> > >>>> +{
> > >>>> +    static int cpu_base_assigned = 0;
> > >>>> +    struct acpi_madt_generic_interrupt *processor =
> > >>>> +               container_of(header, struct acpi_madt_generic_interrupt, header);
> > >>>> +
> > >>>> +    if ( BAD_MADT_ENTRY(processor, end) )
> > >>>> +        return -EINVAL;
> > >>>> +
> > >>>> +    /* Read from APIC table and fill up the GIC variables */
> > >>>> +    if ( cpu_base_assigned == 0 )
> > >>>> +    {
> > >>>> +        cbase = processor->base_address;
> > >>>> +        csize = SZ_8K;
> > >>>> +        hbase = processor->gich_base_address;
> > >>>> +        vbase = processor->gicv_base_address;
> > >>>> +        gicv2_info.maintenance_irq = processor->vgic_interrupt;
> > >>>> +
> > >>>> +        if( processor->flags & ACPI_MADT_VGIC_IRQ_MODE )
> > >>>
> > >>>             ^ if ( 
> > >>>
> > >>>
> > >>>> +            irq_set_type(gicv2_info.maintenance_irq, IRQ_TYPE_EDGE_BOTH);
> > >>>> +        else
> > >>>> +            irq_set_type(gicv2_info.maintenance_irq, IRQ_TYPE_LEVEL_MASK);
> > >>>> +
> > >>>> +        cpu_base_assigned = 1;
> > >>>> +    }
> > >>>> +    else
> > >>>> +    {
> > >>>> +        if ( cbase != processor->base_address
> > >>>> +             || hbase != processor->gich_base_address
> > >>>> +             || vbase != processor->gicv_base_address
> > >>>> +             || gicv2_info.maintenance_irq != processor->vgic_interrupt )
> > >>>> +        {
> > >>>> +            printk("GICv2: GICC entries are not same in MADT table\n");
> > >>>> +            return -EINVAL;
> > >>>> +        }
> > >>>> +    }
> > >>>> +
> > >>>> +    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 =
> > >>>> +             container_of(header, struct acpi_madt_generic_distributor, header);
> > >>>> +
> > >>>> +    if ( BAD_MADT_ENTRY(dist, end) )
> > >>>> +        return -EINVAL;
> > >>>> +
> > >>>> +    dbase = dist->base_address;
> > >>>> +
> > >>>> +    return 0;
> > >>>> +}
> > >>>> +
> > >>>> +static void __init gicv2_acpi_init(void)
> > >>>> +{
> > >>>> +    acpi_status status;
> > >>>> +    struct acpi_table_header *table;
> > >>>> +    int count;
> > >>>> +
> > >>>> +    status = acpi_get_table(ACPI_SIG_MADT, 0, &table);
> > >>>> +
> > >>>> +    if ( ACPI_FAILURE(status) )
> > >>>> +    {
> > >>>> +        const char *msg = acpi_format_exception(status);
> > >>>> +
> > >>>> +        panic("GICv2: Failed to get MADT table, %s", msg);
> > >>>> +    }
> > >>>> +
> > >>>> +    /* 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 )
> > >>>> +        panic("GICv2: No valid GICC entries exists");
> > >>>> +
> > >>>> +    /*
> > >>>> +     * Find distributor base address. We expect one distributor entry since
> > >>>> +     * ACPI 5.0 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 )
> > >>>> +        panic("GICv2: No valid GICD entries exists");
> > >>>> +}
> > >>>> +#else
> > >>>> +static void __init gicv2_acpi_init(void)
> > >>>> +{
> > >>>> +/* Should never reach here */
> > >>>> +}
> > >>>> +#endif
> > >>>
> > >>> With acpi_disabled becoming an #define constant, this #else should not
> > >>> be needed.
> > >>>
> > >> If I remove #else and define acpi_disabled as a constant as you
> > >> suggested, it has below compiling error on arm32.
> > >>
> > >> diff --git a/xen/arch/arm/gic-v2.c b/xen/arch/arm/gic-v2.c
> > >> index 9a9fcd5..28ec064 100644
> > >> --- a/xen/arch/arm/gic-v2.c
> > >> +++ b/xen/arch/arm/gic-v2.c
> > >> @@ -776,11 +776,6 @@ static void __init acpi_gicv2_init(void)
> > >>      if ( count <= 0 )
> > >>          panic("GICv2: No valid GICD entries exists");
> > >>  }
> > >> -#else
> > >> -static void __init acpi_gicv2_init(void)
> > >> -{
> > >> -/* Should never reach here */
> > >> -}
> > >>  #endif
> > >>
> > >> gic-v2.c: In function 'gicv2_init':
> > >> gic-v2.c:793:9: error: implicit declaration of function
> > >> 'acpi_gicv2_init' [-Werror=implicit-function-declaration]
> > >> gic-v2.c:793:9: error: nested extern declaration of 'acpi_gicv2_init'
> > >> [-Werror=nested-externs]
> > >> cc1: all warnings being treated as errors
> > > 
> > > Sorry, I should have been clearer. You still need to have a declaration
> > > of the function outside the #ifdef. Something like the following should
> > > work:
> > > 
> > >   static void acpi_gicv2_init(void);
> > > 
> > >   [...]
> > > 
> > >   #ifdef CONFIG_ACPI
> > >   static void __init acpi_gicv2_init(void)
> > >   {
> > >       /* do something */
> > >   }
> > >   #endif
> > > 
> > >   [...]
> > > 
> > >   if ( acpi_disabled )
> > >       gicv2_dt_init();
> > >   else
> > >       gicv2_acpi_init();
> > > 
> > > .
> > > 
> > I'm afraid it doesn't work. Still has below errors with the declaration:
> > 
> > gic-v2.c:687:13: error: 'gicv2_acpi_init' used but never defined [-Werror]
> > cc1: all warnings being treated as errors
> >
> > diff --git a/xen/arch/arm/gic-v2.c b/xen/arch/arm/gic-v2.c
> > index 4b6c4c0..7b7e094 100644
> > --- a/xen/arch/arm/gic-v2.c
> > +++ b/xen/arch/arm/gic-v2.c
> > @@ -684,6 +684,8 @@ static void __init gicv2_dt_init(void)
> >                 csize, vsize);
> >  }
> > 
> > +static void gicv2_acpi_init(void);
> 
> It should be
> 
>    void gicv2_acpi_init(void);
> 
> without "static".

However I am starting to doubt that this is actually an good improvement
in terms of code quality. So I would be also OK with keeping things are
they are.

 
> >  #ifdef CONFIG_ACPI
> >  static int __init
> >  gic_acpi_parse_madt_cpu(struct acpi_subtable_header *header,
> > @@ -774,11 +776,6 @@ static void __init gicv2_acpi_init(void)
> >      if ( count <= 0 )
> >          panic("GICv2: No valid GICD entries exists");
> >  }
> > -#else
> > -static void __init gicv2_acpi_init(void)
> > -{
> > -/* Should never reach here */
> > -}

but if you do that please make the stub function a single line:

  static void __init gicv2_acpi_init(void) { }


> >  #endif
> > 
> >  static int __init gicv2_init(void)

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

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

end of thread, other threads:[~2016-02-25 14:59 UTC | newest]

Thread overview: 62+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-23  9:19 [PATCH v4 00/21] Add ACPI support for Xen itself on ARM64 Shannon Zhao
2016-01-23  9:19 ` [PATCH v4 01/21] arm/acpi: Emulate io ports for arm Shannon Zhao
2016-01-27 12:52   ` Stefano Stabellini
2016-01-28 12:13     ` Shannon Zhao
2016-01-28 12:35       ` Stefano Stabellini
2016-01-23  9:19 ` [PATCH v4 02/21] arm/acpi: Add arm specific acpi header file Shannon Zhao
2016-01-23  9:19 ` [PATCH v4 03/21] arm/acpi: Add __acpi_map_table function for ARM Shannon Zhao
2016-01-23  9:19 ` [PATCH v4 04/21] arm/acpi: Move end_boot_allocator after acpi_boot_table_init Shannon Zhao
2016-01-27 14:53   ` Stefano Stabellini
2016-01-23  9:19 ` [PATCH v4 05/21] arm/acpi: Add basic ACPI initialization Shannon Zhao
2016-01-27 14:54   ` Stefano Stabellini
2016-01-28 10:33     ` Shannon Zhao
2016-01-28 10:44       ` Stefano Stabellini
2016-01-28 11:18         ` Shannon Zhao
2016-01-28 11:27           ` Stefano Stabellini
2016-01-28 11:53             ` Shannon Zhao
2016-01-28 12:38               ` Stefano Stabellini
2016-01-23  9:19 ` [PATCH v4 06/21] arm/acpi: Parse FADT table and get PSCI flags Shannon Zhao
2016-01-27 15:41   ` Stefano Stabellini
2016-02-23 12:13     ` Shannon Zhao
2016-02-23 14:37       ` Stefano Stabellini
2016-01-23  9:19 ` [PATCH v4 07/21] arm/acpi: Print GIC information when MADT is parsed Shannon Zhao
2016-01-25 14:49   ` Jan Beulich
2016-01-27 16:50   ` Stefano Stabellini
2016-01-23  9:20 ` [PATCH v4 08/21] arm/acpi: Parse MADT to map logical cpu to MPIDR and get cpu_possible_map Shannon Zhao
2016-01-25 14:53   ` Jan Beulich
2016-01-28 10:40   ` Stefano Stabellini
2016-01-23  9:20 ` [PATCH v4 09/21] arm/acpi: Add ACPI support for SMP initialization Shannon Zhao
2016-01-28 10:56   ` Stefano Stabellini
2016-01-23  9:20 ` [PATCH v4 10/21] acpi/table: Introduce acpi_table_get_entry_madt to get specified entry Shannon Zhao
2016-01-25 15:02   ` Jan Beulich
2016-01-29  7:49     ` Shannon Zhao
2016-01-23  9:20 ` [PATCH v4 11/21] arm: Introduce a generic way to use a device from acpi Shannon Zhao
2016-01-28 12:45   ` Stefano Stabellini
2016-01-23  9:20 ` [PATCH v4 12/21] arm/irq: Drop the DT prefix of the irq line type Shannon Zhao
2016-01-28 12:48   ` Stefano Stabellini
2016-01-23  9:20 ` [PATCH v4 13/21] arm/gic-v2: Add ACPI boot support for GICv2 Shannon Zhao
2016-01-28 12:56   ` Stefano Stabellini
2016-02-25  8:32     ` Shannon Zhao
2016-02-25 10:42       ` Stefano Stabellini
2016-02-25 14:06         ` Shannon Zhao
2016-02-25 14:56           ` Stefano Stabellini
2016-02-25 14:59             ` Stefano Stabellini
2016-01-23  9:20 ` [PATCH v4 14/21] arm/gic-v3: Add ACPI boot support for GICv3 Shannon Zhao
2016-02-02 17:31   ` Stefano Stabellini
2016-01-23  9:20 ` [PATCH v4 15/21] arm/gic: Add ACPI support for GIC preinit Shannon Zhao
2016-02-02 17:36   ` Stefano Stabellini
2016-01-23  9:20 ` [PATCH v4 16/21] arm/irq: Add helper function for setting interrupt type Shannon Zhao
2016-01-23  9:20 ` [PATCH v4 17/21] arm/acpi: Parse GTDT to initialize timer Shannon Zhao
2016-02-02 17:45   ` Stefano Stabellini
2016-01-23  9:20 ` [PATCH v4 18/21] arm/acpi: Add a new ACPI initialized function for UART Shannon Zhao
2016-01-25 15:04   ` Jan Beulich
2016-02-02 17:48   ` Stefano Stabellini
2016-01-23  9:20 ` [PATCH v4 19/21] arm/acpi: Initialize serial port from ACPI SPCR table Shannon Zhao
2016-01-25 15:05   ` Jan Beulich
2016-01-28 12:33     ` Shannon Zhao
2016-01-28 12:59       ` Jan Beulich
2016-02-02 17:51   ` Stefano Stabellini
2016-01-23  9:20 ` [PATCH v4 20/21] arm/fdt: Export device_tree_for_each_node Shannon Zhao
2016-02-02 18:01   ` Stefano Stabellini
2016-01-23  9:20 ` [PATCH v4 21/21] arm/acpi: Add acpi parameter to enable/disable acpi Shannon Zhao
2016-02-02 17:58   ` Stefano Stabellini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.