Re: [PATCH v9 05/21] ARM64 / ACPI: Get RSDP and ACPI boot-time tables

2015-03-10 Thread Hanjun Guo

On 2015年03月10日 19:19, Leif Lindholm wrote:

On Tue, Mar 10, 2015 at 04:01:16PM +0800, Hanjun Guo wrote:

index 000..f052e7a
--- /dev/null
+++ b/arch/arm64/kernel/acpi.c
@@ -0,0 +1,101 @@
+/*
+ *  ARM64 Specific Low-Level ACPI Boot Support
+ *
+ *  Copyright (C) 2013-2014, Linaro Ltd.
+ * Author: Al Stone 
+ * Author: Graeme Gregory 
+ * Author: Hanjun Guo 
+ * Author: Tomasz Nowicki 
+ * Author: Naresh Bhat 
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ */
+
+#define pr_fmt(fmt) "ACPI: " fmt
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+int acpi_noirq;/* skip ACPI IRQ initialization */
+int acpi_disabled;
+EXPORT_SYMBOL(acpi_disabled);
+
+int acpi_pci_disabled; /* skip ACPI PCI scan and IRQ initialization */
+EXPORT_SYMBOL(acpi_pci_disabled);
+
+/*
+ * __acpi_map_table() will be called before page_init(), so early_ioremap()
+ * or early_memremap() should be called here to for ACPI table mapping.
+ */
+char *__init __acpi_map_table(unsigned long phys, unsigned long size)
+{
+   if (!phys || !size)


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


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


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


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

Hanjun
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v9 05/21] ARM64 / ACPI: Get RSDP and ACPI boot-time tables

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

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

/
Leif
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v9 05/21] ARM64 / ACPI: Get RSDP and ACPI boot-time tables

2015-03-10 Thread Lorenzo Pieralisi
On Tue, Mar 10, 2015 at 08:01:16AM +, Hanjun Guo wrote:

[...]

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

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

It can be cleaned up later.

> [1]: commit c401eb8ee37, ACPI / processor: Check if LAPIC is present
> during initialization
> 
> >
> >> +static inline void arch_fix_phys_package_id(int num, u32 slot) { }
> >
> > This is only used on ia64 to pass the _SUN value to arch code to fix up
> > the socket id. See above.
> >
> > You could define last two functions in generic code, and let the
> > arch code that needs them override them.
> >
> > Whether we do it in this series or later, this stuff needs cleaning up.
> >
> >> +
> >> +#endif /* CONFIG_ACPI */
> >> +
> >> +#endif /*_ASM_ACPI_H*/
> >> diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile
> >> index bef04af..218eb7e 100644
> >> --- a/arch/arm64/kernel/Makefile
> >> +++ b/arch/arm64/kernel/Makefile
> >> @@ -34,6 +34,7 @@ arm64-obj-$(CONFIG_KGDB) += kgdb.o
> >>   arm64-obj-$(CONFIG_EFI)  += efi.o efi-stub.o efi-entry.o
> >>   arm64-obj-$(CONFIG_PCI)  += pci.o
> >>   arm64-obj-$(CONFIG_ARMV8_DEPRECATED) += armv8_deprecated.o
> >> +arm64-obj-$(CONFIG_ACPI)  += acpi.o
> >>
> >>   obj-y+= $(arm64-obj-y) vdso/
> >>   obj-m+= $(arm64-obj-m)
> >> diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c
> >> new file mode 100644
> >> index 000..f052e7a
> >> --- /dev/null
> >> +++ b/arch/arm64/kernel/acpi.c
> >> @@ -0,0 +1,101 @@
> >> +/*
> >> + *  ARM64 Specific Low-Level ACPI Boot Support
> >> + *
> >> + *  Copyright (C) 2013-2014, Linaro Ltd.
> >> + *Author: Al Stone 
> >> + *Author: Graeme Gregory 
> >> + *Author: Hanjun Guo 
> >> + *Author: Tomasz Nowicki 
> >> + *Author: Naresh Bhat 
> >> + *
> >> + *  This program is free software; you can redistribute it and/or modify
> >> + *  it under the terms of the GNU General Public License version 2 as
> >> + *  published by the Free Software Foundation.
> >> + */
> >> +
> >> +#define pr_fmt(fmt) "ACPI: " fmt
> >> +
> >> +#include 
> >> +#include 
> >> +#include 
> >> +#include 
> >> +#include 
> >> +#include 
> >> +#include 
> >> +#include 
> >> +
> >> +int acpi_noirq;   /* skip ACPI IRQ initialization */
> >> +int acpi_disabled;
> >> +EXPORT_SYMBOL(acpi_disabled);
> >> +
> >> +int acpi_pci_disabled;/* skip ACPI PCI scan and IRQ 
> >> initialization */
> >> +EXPORT_SYMBOL(acpi_pci_disabled);
> >> +
> >> +/*
> >> + * __acpi_map_table() will be called before page_init(), so 
> >> early_ioremap()
> >> + * or early_memremap() should be called here to for ACPI table mapping.
> >> + */
> 

Re: [PATCH v9 05/21] ARM64 / ACPI: Get RSDP and ACPI boot-time tables

2015-03-10 Thread Hanjun Guo

On 2015年03月06日 02:51, Lorenzo Pieralisi wrote:

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

From: Al Stone 

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

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


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

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

[...]


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


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


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

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




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


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

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

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


+
+#endif /* CONFIG_ACPI */
+
+#endif /*_ASM_ACPI_H*/
diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile
index bef04af..218eb7e 100644
--- a/arch/arm64/kernel/Makefile
+++ b/arch/arm64/kernel/Makefile
@@ -34,6 +34,7 @@ arm64-obj-$(CONFIG_KGDB)  += kgdb.o
  arm64-obj-$(CONFIG_EFI)   += efi.o efi-stub.o efi-entry.o
  arm64-obj-$(CONFIG_PCI)   += pci.o
  arm64-obj-$(CONFIG_ARMV8_DEPRECATED)  += armv8_deprecated.o
+arm64-obj-$(CONFIG_ACPI)   += acpi.o

  obj-y += $(arm64-obj-y) vdso/
  obj-m += $(arm64-obj-m)
diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c
new file mode 100644
index 000..f052e7a
--- /dev/null
+++ b/arch/arm64/kernel/acpi.c
@@ -0,0 +1,101 @@
+/*
+ *  ARM64 Specific Low-Level ACPI Boot Support
+ *
+ *  Copyright (C) 2013-2014, Linaro Ltd.
+ * Author: Al Stone 
+ * Author: Graeme Gregory 
+ * Author: Hanjun Guo 
+ * Author: Tomasz Nowicki 
+ * Author: Naresh Bhat 
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ */
+
+#define pr_fmt(fmt) "ACPI: " fmt
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+int acpi_noirq;/* skip ACPI IRQ initialization */
+int acpi_disabled;
+EXPORT_SYMBOL(acpi_disabled);
+
+int acpi_pci_disabled; /* skip ACPI PCI scan and IRQ initialization */
+EXPORT_SYMBOL(acpi_pci_disabled);
+
+/*
+ * __acpi_map_table() will be called before 

Re: [PATCH v9 05/21] ARM64 / ACPI: Get RSDP and ACPI boot-time tables

2015-03-10 Thread Lorenzo Pieralisi
On Tue, Mar 10, 2015 at 08:01:16AM +, Hanjun Guo wrote:

[...]

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

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

It can be cleaned up later.

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

Re: [PATCH v9 05/21] ARM64 / ACPI: Get RSDP and ACPI boot-time tables

2015-03-10 Thread Hanjun Guo

On 2015年03月10日 19:19, Leif Lindholm wrote:

On Tue, Mar 10, 2015 at 04:01:16PM +0800, Hanjun Guo wrote:

index 000..f052e7a
--- /dev/null
+++ b/arch/arm64/kernel/acpi.c
@@ -0,0 +1,101 @@
+/*
+ *  ARM64 Specific Low-Level ACPI Boot Support
+ *
+ *  Copyright (C) 2013-2014, Linaro Ltd.
+ * Author: Al Stone al.st...@linaro.org
+ * Author: Graeme Gregory graeme.greg...@linaro.org
+ * Author: Hanjun Guo hanjun@linaro.org
+ * Author: Tomasz Nowicki tomasz.nowi...@linaro.org
+ * Author: Naresh Bhat naresh.b...@linaro.org
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ */
+
+#define pr_fmt(fmt) ACPI:  fmt
+
+#include linux/acpi.h
+#include linux/bootmem.h
+#include linux/cpumask.h
+#include linux/init.h
+#include linux/irq.h
+#include linux/irqdomain.h
+#include linux/memblock.h
+#include linux/smp.h
+
+int acpi_noirq;/* skip ACPI IRQ initialization */
+int acpi_disabled;
+EXPORT_SYMBOL(acpi_disabled);
+
+int acpi_pci_disabled; /* skip ACPI PCI scan and IRQ initialization */
+EXPORT_SYMBOL(acpi_pci_disabled);
+
+/*
+ * __acpi_map_table() will be called before page_init(), so early_ioremap()
+ * or early_memremap() should be called here to for ACPI table mapping.
+ */
+char *__init __acpi_map_table(unsigned long phys, unsigned long size)
+{
+   if (!phys || !size)


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


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


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


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

Hanjun
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v9 05/21] ARM64 / ACPI: Get RSDP and ACPI boot-time tables

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

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

/
Leif
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v9 05/21] ARM64 / ACPI: Get RSDP and ACPI boot-time tables

2015-03-10 Thread Hanjun Guo

On 2015年03月06日 02:51, Lorenzo Pieralisi wrote:

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

From: Al Stone al.st...@linaro.org

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

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


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

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

[...]


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


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


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

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




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


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

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

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


+
+#endif /* CONFIG_ACPI */
+
+#endif /*_ASM_ACPI_H*/
diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile
index bef04af..218eb7e 100644
--- a/arch/arm64/kernel/Makefile
+++ b/arch/arm64/kernel/Makefile
@@ -34,6 +34,7 @@ arm64-obj-$(CONFIG_KGDB)  += kgdb.o
  arm64-obj-$(CONFIG_EFI)   += efi.o efi-stub.o efi-entry.o
  arm64-obj-$(CONFIG_PCI)   += pci.o
  arm64-obj-$(CONFIG_ARMV8_DEPRECATED)  += armv8_deprecated.o
+arm64-obj-$(CONFIG_ACPI)   += acpi.o

  obj-y += $(arm64-obj-y) vdso/
  obj-m += $(arm64-obj-m)
diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c
new file mode 100644
index 000..f052e7a
--- /dev/null
+++ b/arch/arm64/kernel/acpi.c
@@ -0,0 +1,101 @@
+/*
+ *  ARM64 Specific Low-Level ACPI Boot Support
+ *
+ *  Copyright (C) 2013-2014, Linaro Ltd.
+ * Author: Al Stone al.st...@linaro.org
+ * Author: Graeme Gregory graeme.greg...@linaro.org
+ * Author: Hanjun Guo hanjun@linaro.org
+ * Author: Tomasz Nowicki tomasz.nowi...@linaro.org
+ * Author: Naresh Bhat naresh.b...@linaro.org
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ */
+
+#define pr_fmt(fmt) ACPI:  fmt
+
+#include linux/acpi.h
+#include linux/bootmem.h
+#include linux/cpumask.h
+#include linux/init.h
+#include linux/irq.h
+#include linux/irqdomain.h
+#include linux/memblock.h
+#include linux/smp.h
+
+int 

Re: [PATCH v9 05/21] ARM64 / ACPI: Get RSDP and ACPI boot-time tables

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

Acked-by: Grant Likely 

> ---
>  arch/arm64/include/asm/acenv.h |  18 
>  arch/arm64/include/asm/acpi.h  |  45 ++
>  arch/arm64/kernel/Makefile |   1 +
>  arch/arm64/kernel/acpi.c   | 101 
> +
>  arch/arm64/kernel/setup.c  |   5 ++
>  5 files changed, 170 insertions(+)
>  create mode 100644 arch/arm64/include/asm/acenv.h
>  create mode 100644 arch/arm64/include/asm/acpi.h
>  create mode 100644 arch/arm64/kernel/acpi.c
> 
> diff --git a/arch/arm64/include/asm/acenv.h b/arch/arm64/include/asm/acenv.h
> new file mode 100644
> index 000..b49166f
> --- /dev/null
> +++ b/arch/arm64/include/asm/acenv.h
> @@ -0,0 +1,18 @@
> +/*
> + * ARM64 specific ACPICA environments and implementation
> + *
> + * Copyright (C) 2014, Linaro Ltd.
> + *   Author: Hanjun Guo 
> + *   Author: Graeme Gregory 
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + */
> +
> +#ifndef _ASM_ACENV_H
> +#define _ASM_ACENV_H
> +
> +/* It is required unconditionally by ACPI core, update it when needed. */
> +
> +#endif /* _ASM_ACENV_H */
> diff --git a/arch/arm64/include/asm/acpi.h b/arch/arm64/include/asm/acpi.h
> new file mode 100644
> index 000..8b837ab
> --- /dev/null
> +++ b/arch/arm64/include/asm/acpi.h
> @@ -0,0 +1,45 @@
> +/*
> + *  Copyright (C) 2013-2014, Linaro Ltd.
> + *   Author: Al Stone 
> + *   Author: Graeme Gregory 
> + *   Author: Hanjun Guo 
> + *
> + *  This program is free software; you can redistribute it and/or modify
> + *  it under the terms of the GNU General Public License version 2 as
> + *  published by the Free Software Foundation;
> + */
> +
> +#ifndef _ASM_ACPI_H
> +#define _ASM_ACPI_H
> +
> +/* Basic configuration for ACPI */
> +#ifdef   CONFIG_ACPI
> +#define acpi_strict 1/* No out-of-spec workarounds on ARM64 */
> +extern int acpi_disabled;
> +extern int acpi_noirq;
> +extern int acpi_pci_disabled;
> +
> +static inline void disable_acpi(void)
> +{
> + acpi_disabled = 1;
> + acpi_pci_disabled = 1;
> + acpi_noirq = 1;
> +}
> +
> +/*
> + * It's used from ACPI core in kdump to boot UP system with SMP kernel,
> + * with this check the ACPI core will not override the CPU index
> + * obtained from GICC with 0 and not print some error message as well.
> + * Since MADT must provide at least one GICC structure for GIC
> + * initialization, CPU will be always available in MADT on ARM64.
> + */
> +static inline bool acpi_has_cpu_in_madt(void)
> +{
> + return true;
> +}
> +
> +static inline void arch_fix_phys_package_id(int num, u32 slot) { }
> +
> +#endif /* CONFIG_ACPI */
> +
> +#endif /*_ASM_ACPI_H*/
> diff --git 

Re: [PATCH v9 05/21] ARM64 / ACPI: Get RSDP and ACPI boot-time tables

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

Acked-by: Grant Likely grant.lik...@linaro.org

 ---
  arch/arm64/include/asm/acenv.h |  18 
  arch/arm64/include/asm/acpi.h  |  45 ++
  arch/arm64/kernel/Makefile |   1 +
  arch/arm64/kernel/acpi.c   | 101 
 +
  arch/arm64/kernel/setup.c  |   5 ++
  5 files changed, 170 insertions(+)
  create mode 100644 arch/arm64/include/asm/acenv.h
  create mode 100644 arch/arm64/include/asm/acpi.h
  create mode 100644 arch/arm64/kernel/acpi.c
 
 diff --git a/arch/arm64/include/asm/acenv.h b/arch/arm64/include/asm/acenv.h
 new file mode 100644
 index 000..b49166f
 --- /dev/null
 +++ b/arch/arm64/include/asm/acenv.h
 @@ -0,0 +1,18 @@
 +/*
 + * ARM64 specific ACPICA environments and implementation
 + *
 + * Copyright (C) 2014, Linaro Ltd.
 + *   Author: Hanjun Guo hanjun@linaro.org
 + *   Author: Graeme Gregory graeme.greg...@linaro.org
 + *
 + * This program is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License version 2 as
 + * published by the Free Software Foundation.
 + */
 +
 +#ifndef _ASM_ACENV_H
 +#define _ASM_ACENV_H
 +
 +/* It is required unconditionally by ACPI core, update it when needed. */
 +
 +#endif /* _ASM_ACENV_H */
 diff --git a/arch/arm64/include/asm/acpi.h b/arch/arm64/include/asm/acpi.h
 new file mode 100644
 index 000..8b837ab
 --- /dev/null
 +++ b/arch/arm64/include/asm/acpi.h
 @@ -0,0 +1,45 @@
 +/*
 + *  Copyright (C) 2013-2014, Linaro Ltd.
 + *   Author: Al Stone al.st...@linaro.org
 + *   Author: Graeme Gregory graeme.greg...@linaro.org
 + *   Author: Hanjun Guo hanjun@linaro.org
 + *
 + *  This program is free software; you can redistribute it and/or modify
 + *  it under the terms of the GNU General Public License version 2 as
 + *  published by the Free Software Foundation;
 + */
 +
 +#ifndef _ASM_ACPI_H
 +#define _ASM_ACPI_H
 +
 +/* Basic configuration for ACPI */
 +#ifdef   CONFIG_ACPI
 +#define acpi_strict 1/* No out-of-spec workarounds on ARM64 */
 +extern int acpi_disabled;
 +extern int acpi_noirq;
 +extern int acpi_pci_disabled;
 +
 +static inline void disable_acpi(void)
 +{
 + acpi_disabled = 1;
 + acpi_pci_disabled = 1;
 + acpi_noirq = 1;
 +}
 +
 +/*
 + * It's used from ACPI core in kdump to boot UP system with SMP kernel,
 + * with this check the ACPI core will not override the CPU index
 + * obtained from GICC with 0 and not print some error message as well.
 + * Since MADT must provide at least one 

Re: [PATCH v9 05/21] ARM64 / ACPI: Get RSDP and ACPI boot-time tables

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

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

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

[...]

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

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

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

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

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

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

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

Re: [PATCH v9 05/21] ARM64 / ACPI: Get RSDP and ACPI boot-time tables

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

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

Acked-by: Olof Johansson 


-Olof
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v9 05/21] ARM64 / ACPI: Get RSDP and ACPI boot-time tables

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

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

Acked-by: Olof Johansson o...@lixom.net


-Olof
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v9 05/21] ARM64 / ACPI: Get RSDP and ACPI boot-time tables

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

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

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

[...]

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

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

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

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

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

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

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