ACPI 5.1 has some major changes for ARM platform and the following tables which are essential for ARM platforms: 1) MADT table updates for GIC v2/v3. 2) FADT updates for PSCI 3) GTDT for arch timer
This patch set is the ARM64 ACPI core patches covered MADT, FADT and GTDT, platform board specific drivers are not covered by this patch set.
We first introduce acpi.c and its related head file which are needed by ACPI core, and then get RSDP to extract all the ACPI boot-time tables. When all the boot-time tables (FADT, MADT, GTDT) are ready, then parse them to init the sytem when booted. Specifically, a) we use FADT to init PSCI and use PSCI to boot SMP; b) Use MADT for GIC init and SMP init; c) GTDT for arch timer init.
This patch set is based on 3.17-rc4 and was tested by Graeme on Juno and FVP base model boot with ACPI only OK, if you want to test them, you can pull from acpi-5.1-v5 branch in leg/acpi repo: git://git.linaro.org/leg/acpi/acpi.git
Updates since v4: - ACPI uasge doc for ARM64 was updated a lot by Al - Collect some ACKs from Grant, Olof, Mark - address some comments from Olof and Catalin since last version
Updates since v3: - Compile out sleep.c on ARM64 when ACPI enabled - refactor the GIC init code to address the comments from Marc and Arnd - refactor the SMP init code to fix some logic problem when PSCI is not present, also address some of Grant and Lorenzo's comments - reorder the patch series and move ACPI table changes to the front of patch set - rebase on top of 3.17-rc4
Updates since v2: - Refactor the code to make SMP/PSCI init with less sperated init path by Tomasz - make ACPI depend on EXPERT - Address lots of comments from Catalin, Sudeep, Geoff - Add Juno device ACPI driver patches for review
Updates since v1: - Set ACPI default off on ARM64 suggested by Olof; - Rebase the patch set on top of linux-next branch/linux-pm tree which includes the ACPICA for full ACPI 5.1 support. - Update the document as suggested; - Adress lots of comments from Mark, Sudeep, Randy, Naresh, Olof, Geoff and more...
Al Stone (3): ARM64 / ACPI: Get RSDP and ACPI boot-time tables ARM64 / ACPI: Introduce early_param for "acpi" and pass acpi=force to enable ACPI ARM64 / ACPI: Select ACPI_REDUCED_HARDWARE_ONLY if ACPI is enabled on ARM64
Ashwin Chaugule (1): ACPI / table: Add new function to get table entries
Graeme Gregory (4): ARM64 / ACPI: Introduce sleep-arm.c ARM64 / ACPI: If we chose to boot from acpi then disable FDT ARM64 / ACPI: Enable ARM64 in Kconfig Documentation: ACPI for ARM64
Hanjun Guo (8): ARM64: Move the init of cpu_logical_map(0) before unflatten_device_tree() ARM64 / ACPI: Make PCI optional for ACPI on ARM64 ARM64 / ACPI: Parse FADT table to get PSCI flags for PSCI init ACPI / table: Print GIC information when MADT is parsed ARM64 / ACPI: Parse MADT for SMP initialization ACPI / processor: Make it possible to get CPU hardware ID via GICC ARM64 / ACPI: Introduce ACPI_IRQ_MODEL_GIC and register device's gsi ARM64 / ACPI: Parse GTDT to initialize arch timer
Tomasz Nowicki (2): ACPI / table: Count matched and successfully parsed entries without specifying max entries ARM64 / ACPI: Add GICv2 specific ACPI boot support
Documentation/arm64/arm-acpi.txt | 323 ++++++++++++++++++++++++++++++ Documentation/kernel-parameters.txt | 3 +- arch/arm64/Kconfig | 3 + arch/arm64/include/asm/acenv.h | 18 ++ arch/arm64/include/asm/acpi.h | 99 ++++++++++ arch/arm64/include/asm/cpu_ops.h | 1 + arch/arm64/include/asm/pci.h | 11 ++ arch/arm64/include/asm/psci.h | 3 +- arch/arm64/include/asm/smp.h | 5 +- arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/acpi.c | 356 ++++++++++++++++++++++++++++++++++ arch/arm64/kernel/cpu_ops.c | 4 +- arch/arm64/kernel/psci.c | 78 +++++--- arch/arm64/kernel/setup.c | 25 ++- arch/arm64/kernel/smp.c | 2 +- arch/arm64/kernel/time.c | 7 + drivers/acpi/Kconfig | 6 +- drivers/acpi/Makefile | 6 +- drivers/acpi/bus.c | 3 + drivers/acpi/internal.h | 5 + drivers/acpi/processor_core.c | 37 ++++ drivers/acpi/sleep-arm.c | 28 +++ drivers/acpi/tables.c | 115 +++++++++-- drivers/clocksource/arm_arch_timer.c | 117 +++++++++-- drivers/irqchip/irq-gic.c | 106 ++++++++++ drivers/irqchip/irqchip.c | 3 + include/linux/acpi.h | 5 + include/linux/clocksource.h | 6 + include/linux/irqchip/arm-gic-acpi.h | 31 +++ include/linux/pci.h | 37 +++- 30 files changed, 1353 insertions(+), 91 deletions(-) create mode 100644 Documentation/arm64/arm-acpi.txt create mode 100644 arch/arm64/include/asm/acenv.h create mode 100644 arch/arm64/include/asm/acpi.h create mode 100644 arch/arm64/include/asm/pci.h create mode 100644 arch/arm64/kernel/acpi.c create mode 100644 drivers/acpi/sleep-arm.c create mode 100644 include/linux/irqchip/arm-gic-acpi.h
It always make sense to initialize CPU0's logical map entry from the hardware values, so move the initialization of cpu_logical_map(0) before unflatten_device_tree() which is needed by ACPI code later.
Acked-by: Olof Johansson olof@lixom.net Acked-by: Mark Rutland mark.rutland@arm.com Signed-off-by: Hanjun Guo hanjun.guo@linaro.org --- arch/arm64/kernel/setup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c index edb146d..8f33f72 100644 --- a/arch/arm64/kernel/setup.c +++ b/arch/arm64/kernel/setup.c @@ -393,11 +393,11 @@ void __init setup_arch(char **cmdline_p)
efi_idmap_init();
+ cpu_logical_map(0) = read_cpuid_mpidr() & MPIDR_HWID_BITMASK; unflatten_device_tree();
psci_init();
- cpu_logical_map(0) = read_cpuid_mpidr() & MPIDR_HWID_BITMASK; cpu_read_bootcpu_ops(); #ifdef CONFIG_SMP smp_init_cpus();
Hi Catalin,
On 2014年10月17日 21:36, Hanjun Guo wrote:
It always make sense to initialize CPU0's logical map entry from the hardware values, so move the initialization of cpu_logical_map(0) before unflatten_device_tree() which is needed by ACPI code later.
Acked-by: Olof Johansson olof@lixom.net Acked-by: Mark Rutland mark.rutland@arm.com Signed-off-by: Hanjun Guo hanjun.guo@linaro.org
Could you merge this patch first in 3.19? It was acked by Olof and Mark, and it will make sense without ACPI too.
Thanks Hanjun
arch/arm64/kernel/setup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c index edb146d..8f33f72 100644 --- a/arch/arm64/kernel/setup.c +++ b/arch/arm64/kernel/setup.c @@ -393,11 +393,11 @@ void __init setup_arch(char **cmdline_p)
efi_idmap_init();
cpu_logical_map(0) = read_cpuid_mpidr() & MPIDR_HWID_BITMASK; unflatten_device_tree();
psci_init();
- cpu_logical_map(0) = read_cpuid_mpidr() & MPIDR_HWID_BITMASK; cpu_read_bootcpu_ops(); #ifdef CONFIG_SMP smp_init_cpus();
On Tue, Nov 18, 2014 at 01:45:49PM +0000, Hanjun Guo wrote:
On 2014年10月17日 21:36, Hanjun Guo wrote:
It always make sense to initialize CPU0's logical map entry from the hardware values, so move the initialization of cpu_logical_map(0) before unflatten_device_tree() which is needed by ACPI code later.
Acked-by: Olof Johansson olof@lixom.net Acked-by: Mark Rutland mark.rutland@arm.com Signed-off-by: Hanjun Guo hanjun.guo@linaro.org
Could you merge this patch first in 3.19? It was acked by Olof and Mark, and it will make sense without ACPI too.
I think it can go in for 3.19 (it's Will's turn this time ;)).
FWIW:
Acked-by: Catalin Marinas catalin.marinas@arm.com
On Tue, Nov 18, 2014 at 04:43:13PM +0000, Catalin Marinas wrote:
On Tue, Nov 18, 2014 at 01:45:49PM +0000, Hanjun Guo wrote:
On 2014年10月17日 21:36, Hanjun Guo wrote:
It always make sense to initialize CPU0's logical map entry from the hardware values, so move the initialization of cpu_logical_map(0) before unflatten_device_tree() which is needed by ACPI code later.
Acked-by: Olof Johansson olof@lixom.net Acked-by: Mark Rutland mark.rutland@arm.com Signed-off-by: Hanjun Guo hanjun.guo@linaro.org
Could you merge this patch first in 3.19? It was acked by Olof and Mark, and it will make sense without ACPI too.
I think it can go in for 3.19 (it's Will's turn this time ;)).
This patch doesn't apply on for-next/core, as it conflicts with some of Rutland's rework ("arm64: log physical ID of boot CPU").
Will
Hi Will,
I was writing to reply to Catalin's mail :)
On 18/11/14 16:57, Will Deacon wrote:
On Tue, Nov 18, 2014 at 04:43:13PM +0000, Catalin Marinas wrote:
On Tue, Nov 18, 2014 at 01:45:49PM +0000, Hanjun Guo wrote:
On 2014年10月17日 21:36, Hanjun Guo wrote:
It always make sense to initialize CPU0's logical map entry from the hardware values, so move the initialization of cpu_logical_map(0) before unflatten_device_tree() which is needed by ACPI code later.
Acked-by: Olof Johansson olof@lixom.net Acked-by: Mark Rutland mark.rutland@arm.com Signed-off-by: Hanjun Guo hanjun.guo@linaro.org
Could you merge this patch first in 3.19? It was acked by Olof and Mark, and it will make sense without ACPI too.
I think it can go in for 3.19 (it's Will's turn this time ;)).
This patch doesn't apply on for-next/core, as it conflicts with some of Rutland's rework ("arm64: log physical ID of boot CPU").
It's actually not required anymore, as "arm64: log physical ID of boot CPU" move it quite early in the sequence from setup_arch to smp_setup_processor_id while this patch just moves it up in setup_arch.
Regards, Sudeep
On Tue, Nov 18, 2014 at 05:02:05PM +0000, Sudeep Holla wrote:
On 18/11/14 16:57, Will Deacon wrote:
On Tue, Nov 18, 2014 at 04:43:13PM +0000, Catalin Marinas wrote:
On Tue, Nov 18, 2014 at 01:45:49PM +0000, Hanjun Guo wrote:
On 2014年10月17日 21:36, Hanjun Guo wrote:
It always make sense to initialize CPU0's logical map entry from the hardware values, so move the initialization of cpu_logical_map(0) before unflatten_device_tree() which is needed by ACPI code later.
Acked-by: Olof Johansson olof@lixom.net Acked-by: Mark Rutland mark.rutland@arm.com Signed-off-by: Hanjun Guo hanjun.guo@linaro.org
Could you merge this patch first in 3.19? It was acked by Olof and Mark, and it will make sense without ACPI too.
I think it can go in for 3.19 (it's Will's turn this time ;)).
This patch doesn't apply on for-next/core, as it conflicts with some of Rutland's rework ("arm64: log physical ID of boot CPU").
It's actually not required anymore, as "arm64: log physical ID of boot CPU" move it quite early in the sequence from setup_arch to smp_setup_processor_id while this patch just moves it up in setup_arch.
Thanks Sudeep, I'd guessed as much :)
Will
On 2014-11-19 1:03, Will Deacon wrote:
On Tue, Nov 18, 2014 at 05:02:05PM +0000, Sudeep Holla wrote:
On 18/11/14 16:57, Will Deacon wrote:
On Tue, Nov 18, 2014 at 04:43:13PM +0000, Catalin Marinas wrote:
On Tue, Nov 18, 2014 at 01:45:49PM +0000, Hanjun Guo wrote:
On 2014年10月17日 21:36, Hanjun Guo wrote:
It always make sense to initialize CPU0's logical map entry from the hardware values, so move the initialization of cpu_logical_map(0) before unflatten_device_tree() which is needed by ACPI code later.
Acked-by: Olof Johansson olof@lixom.net Acked-by: Mark Rutland mark.rutland@arm.com Signed-off-by: Hanjun Guo hanjun.guo@linaro.org
Could you merge this patch first in 3.19? It was acked by Olof and Mark, and it will make sense without ACPI too.
I think it can go in for 3.19 (it's Will's turn this time ;)).
This patch doesn't apply on for-next/core, as it conflicts with some of Rutland's rework ("arm64: log physical ID of boot CPU").
It's actually not required anymore, as "arm64: log physical ID of boot CPU" move it quite early in the sequence from setup_arch to smp_setup_processor_id while this patch just moves it up in setup_arch.
Thanks Sudeep, I'd guessed as much :)
That's great, thanks for the reminding, I will drop this one.
Best regards Hanjun
From: Ashwin Chaugule ashwin.chaugule@linaro.org
The acpi_table_parse() function has a callback that passes a pointer to a table_header. Add a new function which takes this pointer and parses its entries. This eliminates the need to re-traverse all the tables for each call. e.g. as in acpi_table_parse_madt() which is normally called after acpi_table_parse().
Acked-by: Grant Likely grant.likely@linaro.org Signed-off-by: Ashwin Chaugule ashwin.chaugule@linaro.org Signed-off-by: Tomasz Nowicki tomasz.nowicki@linaro.org Signed-off-by: Hanjun Guo hanjun.guo@linaro.org --- drivers/acpi/tables.c | 67 ++++++++++++++++++++++++++++++++++--------------- include/linux/acpi.h | 4 +++ 2 files changed, 51 insertions(+), 20 deletions(-)
diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c index 6d5a6cd..21ae521 100644 --- a/drivers/acpi/tables.c +++ b/drivers/acpi/tables.c @@ -192,17 +192,14 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header)
int __init -acpi_table_parse_entries(char *id, - unsigned long table_size, - int entry_id, - acpi_tbl_entry_handler handler, - unsigned int max_entries) +acpi_parse_entries(unsigned long table_size, + acpi_tbl_entry_handler handler, + struct acpi_table_header *table_header, + int entry_id, unsigned int max_entries) { - struct acpi_table_header *table_header = NULL; struct acpi_subtable_header *entry; - unsigned int count = 0; + int count = 0; unsigned long table_end; - acpi_size tbl_size;
if (acpi_disabled) return -ENODEV; @@ -210,13 +207,11 @@ acpi_table_parse_entries(char *id, if (!handler) return -EINVAL;
- if (strncmp(id, ACPI_SIG_MADT, 4) == 0) - acpi_get_table_with_size(id, acpi_apic_instance, &table_header, &tbl_size); - else - acpi_get_table_with_size(id, 0, &table_header, &tbl_size); + if (!table_size) + return -EINVAL;
if (!table_header) { - pr_warn("%4.4s not present\n", id); + pr_warn("Table header not present\n"); return -ENODEV; }
@@ -232,30 +227,62 @@ acpi_table_parse_entries(char *id, if (entry->type == entry_id && (!max_entries || count++ < max_entries)) if (handler(entry, table_end)) - goto err; + return -EINVAL;
/* * If entry->length is 0, break from this loop to avoid * infinite loop. */ if (entry->length == 0) { - pr_err("[%4.4s:0x%02x] Invalid zero length\n", id, entry_id); - goto err; + pr_err("[0x%02x] Invalid zero length\n", entry_id); + return -EINVAL; }
entry = (struct acpi_subtable_header *) ((unsigned long)entry + entry->length); } + if (max_entries && count > max_entries) { pr_warn("[%4.4s:0x%02x] ignored %i entries of %i found\n", - id, entry_id, count - max_entries, count); + table_header->signature, entry_id, count - max_entries, + count); }
- early_acpi_os_unmap_memory((char *)table_header, tbl_size); return count; -err: +} + +int __init +acpi_table_parse_entries(char *id, + unsigned long table_size, + int entry_id, + acpi_tbl_entry_handler handler, + unsigned int max_entries) +{ + struct acpi_table_header *table_header = NULL; + acpi_size tbl_size; + int count; + + if (acpi_disabled) + return -ENODEV; + + if (!handler) + return -EINVAL; + + if (strncmp(id, ACPI_SIG_MADT, 4) == 0) + acpi_get_table_with_size(id, acpi_apic_instance, &table_header, &tbl_size); + else + acpi_get_table_with_size(id, 0, &table_header, &tbl_size); + + if (!table_header) { + pr_warn("%4.4s not present\n", id); + return -ENODEV; + } + + count = acpi_parse_entries(table_size, handler, table_header, + entry_id, max_entries); + early_acpi_os_unmap_memory((char *)table_header, tbl_size); - return -EINVAL; + return count; }
int __init diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 807cbc4..36d5012 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -123,6 +123,10 @@ int acpi_numa_init (void);
int acpi_table_init (void); int acpi_table_parse(char *id, acpi_tbl_table_handler handler); +int __init acpi_parse_entries(unsigned long table_size, + acpi_tbl_entry_handler handler, + struct acpi_table_header *table_header, + int entry_id, unsigned int max_entries); int __init acpi_table_parse_entries(char *id, unsigned long table_size, int entry_id, acpi_tbl_entry_handler handler,
On Friday, October 17, 2014 09:36:58 PM Hanjun Guo wrote:
From: Ashwin Chaugule ashwin.chaugule@linaro.org
The acpi_table_parse() function has a callback that passes a pointer to a table_header. Add a new function which takes this pointer and parses its entries. This eliminates the need to re-traverse all the tables for each call. e.g. as in acpi_table_parse_madt() which is normally called after acpi_table_parse().
Acked-by: Grant Likely grant.likely@linaro.org Signed-off-by: Ashwin Chaugule ashwin.chaugule@linaro.org Signed-off-by: Tomasz Nowicki tomasz.nowicki@linaro.org Signed-off-by: Hanjun Guo hanjun.guo@linaro.org
drivers/acpi/tables.c | 67 ++++++++++++++++++++++++++++++++++--------------- include/linux/acpi.h | 4 +++ 2 files changed, 51 insertions(+), 20 deletions(-)
diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c index 6d5a6cd..21ae521 100644 --- a/drivers/acpi/tables.c +++ b/drivers/acpi/tables.c @@ -192,17 +192,14 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header) int __init -acpi_table_parse_entries(char *id,
unsigned long table_size,
int entry_id,
acpi_tbl_entry_handler handler,
unsigned int max_entries)
+acpi_parse_entries(unsigned long table_size,
acpi_tbl_entry_handler handler,
struct acpi_table_header *table_header,
int entry_id, unsigned int max_entries)
{
- struct acpi_table_header *table_header = NULL; struct acpi_subtable_header *entry;
- unsigned int count = 0;
- int count = 0; unsigned long table_end;
- acpi_size tbl_size;
if (acpi_disabled) return -ENODEV; @@ -210,13 +207,11 @@ acpi_table_parse_entries(char *id, if (!handler) return -EINVAL;
- if (strncmp(id, ACPI_SIG_MADT, 4) == 0)
acpi_get_table_with_size(id, acpi_apic_instance, &table_header, &tbl_size);
- else
acpi_get_table_with_size(id, 0, &table_header, &tbl_size);
- if (!table_size)
return -EINVAL;
if (!table_header) {
pr_warn("%4.4s not present\n", id);
pr_warn("Table header not present\n");
The message doesn't make sense any more if the table signature is not printed.
return -ENODEV;
} @@ -232,30 +227,62 @@ acpi_table_parse_entries(char *id, if (entry->type == entry_id && (!max_entries || count++ < max_entries)) if (handler(entry, table_end))
goto err;
return -EINVAL;
/* * If entry->length is 0, break from this loop to avoid * infinite loop. */ if (entry->length == 0) {
pr_err("[%4.4s:0x%02x] Invalid zero length\n", id, entry_id);
goto err;
pr_err("[0x%02x] Invalid zero length\n", entry_id);
Same here.
}return -EINVAL;
entry = (struct acpi_subtable_header *) ((unsigned long)entry + entry->length); }
- if (max_entries && count > max_entries) { pr_warn("[%4.4s:0x%02x] ignored %i entries of %i found\n",
id, entry_id, count - max_entries, count);
table_header->signature, entry_id, count - max_entries,
}count);
- early_acpi_os_unmap_memory((char *)table_header, tbl_size); return count;
-err: +}
+int __init +acpi_table_parse_entries(char *id,
unsigned long table_size,
int entry_id,
acpi_tbl_entry_handler handler,
unsigned int max_entries)
+{
- struct acpi_table_header *table_header = NULL;
- acpi_size tbl_size;
- int count;
- if (acpi_disabled)
return -ENODEV;
- if (!handler)
return -EINVAL;
- if (strncmp(id, ACPI_SIG_MADT, 4) == 0)
acpi_get_table_with_size(id, acpi_apic_instance, &table_header, &tbl_size);
- else
acpi_get_table_with_size(id, 0, &table_header, &tbl_size);
u32 instance = 0;
if (!strncmp(id, ACPI_SIG_MADT, 4)) instance = acpi_apic_instance;
acpi_get_table_with_size(id, instance, &table_header, &tbl_size);
Pretty please.
- if (!table_header) {
pr_warn("%4.4s not present\n", id);
return -ENODEV;
- }
- count = acpi_parse_entries(table_size, handler, table_header,
entry_id, max_entries);
- early_acpi_os_unmap_memory((char *)table_header, tbl_size);
- return -EINVAL;
- return count;
} int __init diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 807cbc4..36d5012 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -123,6 +123,10 @@ int acpi_numa_init (void); int acpi_table_init (void); int acpi_table_parse(char *id, acpi_tbl_table_handler handler); +int __init acpi_parse_entries(unsigned long table_size,
acpi_tbl_entry_handler handler,
struct acpi_table_header *table_header,
int entry_id, unsigned int max_entries);
int __init acpi_table_parse_entries(char *id, unsigned long table_size, int entry_id, acpi_tbl_entry_handler handler,
On 2014-11-24 9:27, Rafael J. Wysocki wrote:
On Friday, October 17, 2014 09:36:58 PM Hanjun Guo wrote:
From: Ashwin Chaugule ashwin.chaugule@linaro.org
The acpi_table_parse() function has a callback that passes a pointer to a table_header. Add a new function which takes this pointer and parses its entries. This eliminates the need to re-traverse all the tables for each call. e.g. as in acpi_table_parse_madt() which is normally called after acpi_table_parse().
Acked-by: Grant Likely grant.likely@linaro.org Signed-off-by: Ashwin Chaugule ashwin.chaugule@linaro.org Signed-off-by: Tomasz Nowicki tomasz.nowicki@linaro.org Signed-off-by: Hanjun Guo hanjun.guo@linaro.org
drivers/acpi/tables.c | 67 ++++++++++++++++++++++++++++++++++--------------- include/linux/acpi.h | 4 +++ 2 files changed, 51 insertions(+), 20 deletions(-)
diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c index 6d5a6cd..21ae521 100644 --- a/drivers/acpi/tables.c +++ b/drivers/acpi/tables.c @@ -192,17 +192,14 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header) int __init -acpi_table_parse_entries(char *id,
unsigned long table_size,
int entry_id,
acpi_tbl_entry_handler handler,
unsigned int max_entries)
+acpi_parse_entries(unsigned long table_size,
acpi_tbl_entry_handler handler,
struct acpi_table_header *table_header,
int entry_id, unsigned int max_entries)
{
- struct acpi_table_header *table_header = NULL; struct acpi_subtable_header *entry;
- unsigned int count = 0;
- int count = 0; unsigned long table_end;
- acpi_size tbl_size;
if (acpi_disabled) return -ENODEV; @@ -210,13 +207,11 @@ acpi_table_parse_entries(char *id, if (!handler) return -EINVAL;
- if (strncmp(id, ACPI_SIG_MADT, 4) == 0)
acpi_get_table_with_size(id, acpi_apic_instance, &table_header, &tbl_size);
- else
acpi_get_table_with_size(id, 0, &table_header, &tbl_size);
- if (!table_size)
return -EINVAL;
if (!table_header) {
pr_warn("%4.4s not present\n", id);
pr_warn("Table header not present\n");
The message doesn't make sense any more if the table signature is not printed.
return -ENODEV;
} @@ -232,30 +227,62 @@ acpi_table_parse_entries(char *id, if (entry->type == entry_id && (!max_entries || count++ < max_entries)) if (handler(entry, table_end))
goto err;
return -EINVAL;
/* * If entry->length is 0, break from this loop to avoid * infinite loop. */ if (entry->length == 0) {
pr_err("[%4.4s:0x%02x] Invalid zero length\n", id, entry_id);
goto err;
pr_err("[0x%02x] Invalid zero length\n", entry_id);
Same here.
How about remove the message and return directly?
}return -EINVAL;
entry = (struct acpi_subtable_header *) ((unsigned long)entry + entry->length); }
- if (max_entries && count > max_entries) { pr_warn("[%4.4s:0x%02x] ignored %i entries of %i found\n",
id, entry_id, count - max_entries, count);
table_header->signature, entry_id, count - max_entries,
}count);
- early_acpi_os_unmap_memory((char *)table_header, tbl_size); return count;
-err: +}
+int __init +acpi_table_parse_entries(char *id,
unsigned long table_size,
int entry_id,
acpi_tbl_entry_handler handler,
unsigned int max_entries)
+{
- struct acpi_table_header *table_header = NULL;
- acpi_size tbl_size;
- int count;
- if (acpi_disabled)
return -ENODEV;
- if (!handler)
return -EINVAL;
- if (strncmp(id, ACPI_SIG_MADT, 4) == 0)
acpi_get_table_with_size(id, acpi_apic_instance, &table_header, &tbl_size);
- else
acpi_get_table_with_size(id, 0, &table_header, &tbl_size);
u32 instance = 0;
if (!strncmp(id, ACPI_SIG_MADT, 4)) instance = acpi_apic_instance;
acpi_get_table_with_size(id, instance, &table_header, &tbl_size);
Pretty please.
Yes, much better! I will update the patch.
Thanks Hanjun
On Monday, November 24, 2014 07:03:54 PM Hanjun Guo wrote:
On 2014-11-24 9:27, Rafael J. Wysocki wrote:
On Friday, October 17, 2014 09:36:58 PM Hanjun Guo wrote:
From: Ashwin Chaugule ashwin.chaugule@linaro.org
The acpi_table_parse() function has a callback that passes a pointer to a table_header. Add a new function which takes this pointer and parses its entries. This eliminates the need to re-traverse all the tables for each call. e.g. as in acpi_table_parse_madt() which is normally called after acpi_table_parse().
Acked-by: Grant Likely grant.likely@linaro.org Signed-off-by: Ashwin Chaugule ashwin.chaugule@linaro.org Signed-off-by: Tomasz Nowicki tomasz.nowicki@linaro.org Signed-off-by: Hanjun Guo hanjun.guo@linaro.org
drivers/acpi/tables.c | 67 ++++++++++++++++++++++++++++++++++--------------- include/linux/acpi.h | 4 +++ 2 files changed, 51 insertions(+), 20 deletions(-)
diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c index 6d5a6cd..21ae521 100644 --- a/drivers/acpi/tables.c +++ b/drivers/acpi/tables.c @@ -192,17 +192,14 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header) int __init -acpi_table_parse_entries(char *id,
unsigned long table_size,
int entry_id,
acpi_tbl_entry_handler handler,
unsigned int max_entries)
+acpi_parse_entries(unsigned long table_size,
acpi_tbl_entry_handler handler,
struct acpi_table_header *table_header,
int entry_id, unsigned int max_entries)
{
- struct acpi_table_header *table_header = NULL; struct acpi_subtable_header *entry;
- unsigned int count = 0;
- int count = 0; unsigned long table_end;
- acpi_size tbl_size;
if (acpi_disabled) return -ENODEV; @@ -210,13 +207,11 @@ acpi_table_parse_entries(char *id, if (!handler) return -EINVAL;
- if (strncmp(id, ACPI_SIG_MADT, 4) == 0)
acpi_get_table_with_size(id, acpi_apic_instance, &table_header, &tbl_size);
- else
acpi_get_table_with_size(id, 0, &table_header, &tbl_size);
- if (!table_size)
return -EINVAL;
if (!table_header) {
pr_warn("%4.4s not present\n", id);
pr_warn("Table header not present\n");
The message doesn't make sense any more if the table signature is not printed.
return -ENODEV;
} @@ -232,30 +227,62 @@ acpi_table_parse_entries(char *id, if (entry->type == entry_id && (!max_entries || count++ < max_entries)) if (handler(entry, table_end))
goto err;
return -EINVAL;
/* * If entry->length is 0, break from this loop to avoid * infinite loop. */ if (entry->length == 0) {
pr_err("[%4.4s:0x%02x] Invalid zero length\n", id, entry_id);
goto err;
pr_err("[0x%02x] Invalid zero length\n", entry_id);
Same here.
How about remove the message and return directly?
We could do that, but for what reason? Is the message not useful?
On 2014/11/24 22:51, Rafael J. Wysocki wrote:
On Monday, November 24, 2014 07:03:54 PM Hanjun Guo wrote:
On 2014-11-24 9:27, Rafael J. Wysocki wrote:
On Friday, October 17, 2014 09:36:58 PM Hanjun Guo wrote:
From: Ashwin Chaugule ashwin.chaugule@linaro.org
The acpi_table_parse() function has a callback that passes a pointer to a table_header. Add a new function which takes this pointer and parses its entries. This eliminates the need to re-traverse all the tables for each call. e.g. as in acpi_table_parse_madt() which is normally called after acpi_table_parse().
Acked-by: Grant Likely grant.likely@linaro.org Signed-off-by: Ashwin Chaugule ashwin.chaugule@linaro.org Signed-off-by: Tomasz Nowicki tomasz.nowicki@linaro.org Signed-off-by: Hanjun Guo hanjun.guo@linaro.org
drivers/acpi/tables.c | 67 ++++++++++++++++++++++++++++++++++--------------- include/linux/acpi.h | 4 +++ 2 files changed, 51 insertions(+), 20 deletions(-)
diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c index 6d5a6cd..21ae521 100644 --- a/drivers/acpi/tables.c +++ b/drivers/acpi/tables.c @@ -192,17 +192,14 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header) int __init -acpi_table_parse_entries(char *id,
unsigned long table_size,
int entry_id,
acpi_tbl_entry_handler handler,
unsigned int max_entries)
+acpi_parse_entries(unsigned long table_size,
acpi_tbl_entry_handler handler,
struct acpi_table_header *table_header,
int entry_id, unsigned int max_entries)
{
- struct acpi_table_header *table_header = NULL; struct acpi_subtable_header *entry;
- unsigned int count = 0;
- int count = 0; unsigned long table_end;
- acpi_size tbl_size;
if (acpi_disabled) return -ENODEV; @@ -210,13 +207,11 @@ acpi_table_parse_entries(char *id, if (!handler) return -EINVAL;
- if (strncmp(id, ACPI_SIG_MADT, 4) == 0)
acpi_get_table_with_size(id, acpi_apic_instance, &table_header, &tbl_size);
- else
acpi_get_table_with_size(id, 0, &table_header, &tbl_size);
- if (!table_size)
return -EINVAL;
if (!table_header) {
pr_warn("%4.4s not present\n", id);
pr_warn("Table header not present\n");
The message doesn't make sense any more if the table signature is not printed.
For this message, since no table id is passed, and this message is printed in acpi_table_parse_entries() before this function is called, I think we can check the table_header before call this function and remove the printed message here.
return -ENODEV;
} @@ -232,30 +227,62 @@ acpi_table_parse_entries(char *id, if (entry->type == entry_id && (!max_entries || count++ < max_entries)) if (handler(entry, table_end))
goto err;
return -EINVAL;
/* * If entry->length is 0, break from this loop to avoid * infinite loop. */ if (entry->length == 0) {
pr_err("[%4.4s:0x%02x] Invalid zero length\n", id, entry_id);
goto err;
pr_err("[0x%02x] Invalid zero length\n", entry_id);
For this one, since the table_header is valid now, we can keep it with:
- pr_err("[%4.4s:0x%02x] Invalid zero length\n", id, entry_id); + pr_err("[%4.4s:0x%02x] Invalid zero length\n", table_header->signature, entry_id);
Same here.
How about remove the message and return directly?
We could do that, but for what reason? Is the message not useful?
I agree with you, the message is useful I think, how about the comments above?
Thanks Hanjun
On Tuesday, November 25, 2014 11:38:05 AM Hanjun Guo wrote:
On 2014/11/24 22:51, Rafael J. Wysocki wrote:
On Monday, November 24, 2014 07:03:54 PM Hanjun Guo wrote:
On 2014-11-24 9:27, Rafael J. Wysocki wrote:
On Friday, October 17, 2014 09:36:58 PM Hanjun Guo wrote:
From: Ashwin Chaugule ashwin.chaugule@linaro.org
The acpi_table_parse() function has a callback that passes a pointer to a table_header. Add a new function which takes this pointer and parses its entries. This eliminates the need to re-traverse all the tables for each call. e.g. as in acpi_table_parse_madt() which is normally called after acpi_table_parse().
Acked-by: Grant Likely grant.likely@linaro.org Signed-off-by: Ashwin Chaugule ashwin.chaugule@linaro.org Signed-off-by: Tomasz Nowicki tomasz.nowicki@linaro.org Signed-off-by: Hanjun Guo hanjun.guo@linaro.org
drivers/acpi/tables.c | 67 ++++++++++++++++++++++++++++++++++--------------- include/linux/acpi.h | 4 +++ 2 files changed, 51 insertions(+), 20 deletions(-)
diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c index 6d5a6cd..21ae521 100644 --- a/drivers/acpi/tables.c +++ b/drivers/acpi/tables.c @@ -192,17 +192,14 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header) int __init -acpi_table_parse_entries(char *id,
unsigned long table_size,
int entry_id,
acpi_tbl_entry_handler handler,
unsigned int max_entries)
+acpi_parse_entries(unsigned long table_size,
acpi_tbl_entry_handler handler,
struct acpi_table_header *table_header,
int entry_id, unsigned int max_entries)
{
- struct acpi_table_header *table_header = NULL; struct acpi_subtable_header *entry;
- unsigned int count = 0;
- int count = 0; unsigned long table_end;
- acpi_size tbl_size;
if (acpi_disabled) return -ENODEV; @@ -210,13 +207,11 @@ acpi_table_parse_entries(char *id, if (!handler) return -EINVAL;
- if (strncmp(id, ACPI_SIG_MADT, 4) == 0)
acpi_get_table_with_size(id, acpi_apic_instance, &table_header, &tbl_size);
- else
acpi_get_table_with_size(id, 0, &table_header, &tbl_size);
- if (!table_size)
return -EINVAL;
if (!table_header) {
pr_warn("%4.4s not present\n", id);
pr_warn("Table header not present\n");
The message doesn't make sense any more if the table signature is not printed.
For this message, since no table id is passed, and this message is printed in acpi_table_parse_entries() before this function is called, I think we can check the table_header before call this function and remove the printed message here.
table_header needs to be checked against NULL in the caller and the message printed from there to my eyes.
return -ENODEV;
} @@ -232,30 +227,62 @@ acpi_table_parse_entries(char *id, if (entry->type == entry_id && (!max_entries || count++ < max_entries)) if (handler(entry, table_end))
goto err;
return -EINVAL;
/* * If entry->length is 0, break from this loop to avoid * infinite loop. */ if (entry->length == 0) {
pr_err("[%4.4s:0x%02x] Invalid zero length\n", id, entry_id);
goto err;
pr_err("[0x%02x] Invalid zero length\n", entry_id);
For this one, since the table_header is valid now, we can keep it with:
Fine by me.
- pr_err("[%4.4s:0x%02x] Invalid zero length\n", id, entry_id);
- pr_err("[%4.4s:0x%02x] Invalid zero length\n", table_header->signature, entry_id);
Same here.
How about remove the message and return directly?
We could do that, but for what reason? Is the message not useful?
I agree with you, the message is useful I think, how about the comments above?
Please see above.
On 2014/11/26 5:20, Rafael J. Wysocki wrote:
On Tuesday, November 25, 2014 11:38:05 AM Hanjun Guo wrote:
On 2014/11/24 22:51, Rafael J. Wysocki wrote:
On Monday, November 24, 2014 07:03:54 PM Hanjun Guo wrote:
On 2014-11-24 9:27, Rafael J. Wysocki wrote:
On Friday, October 17, 2014 09:36:58 PM Hanjun Guo wrote:
From: Ashwin Chaugule ashwin.chaugule@linaro.org
The acpi_table_parse() function has a callback that passes a pointer to a table_header. Add a new function which takes this pointer and parses its entries. This eliminates the need to re-traverse all the tables for each call. e.g. as in acpi_table_parse_madt() which is normally called after acpi_table_parse().
Acked-by: Grant Likely grant.likely@linaro.org Signed-off-by: Ashwin Chaugule ashwin.chaugule@linaro.org Signed-off-by: Tomasz Nowicki tomasz.nowicki@linaro.org Signed-off-by: Hanjun Guo hanjun.guo@linaro.org
drivers/acpi/tables.c | 67 ++++++++++++++++++++++++++++++++++--------------- include/linux/acpi.h | 4 +++ 2 files changed, 51 insertions(+), 20 deletions(-)
diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c index 6d5a6cd..21ae521 100644 --- a/drivers/acpi/tables.c +++ b/drivers/acpi/tables.c @@ -192,17 +192,14 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header) int __init -acpi_table_parse_entries(char *id,
unsigned long table_size,
int entry_id,
acpi_tbl_entry_handler handler,
unsigned int max_entries)
+acpi_parse_entries(unsigned long table_size,
acpi_tbl_entry_handler handler,
struct acpi_table_header *table_header,
int entry_id, unsigned int max_entries)
{
- struct acpi_table_header *table_header = NULL; struct acpi_subtable_header *entry;
- unsigned int count = 0;
- int count = 0; unsigned long table_end;
- acpi_size tbl_size;
if (acpi_disabled) return -ENODEV; @@ -210,13 +207,11 @@ acpi_table_parse_entries(char *id, if (!handler) return -EINVAL;
- if (strncmp(id, ACPI_SIG_MADT, 4) == 0)
acpi_get_table_with_size(id, acpi_apic_instance, &table_header, &tbl_size);
- else
acpi_get_table_with_size(id, 0, &table_header, &tbl_size);
- if (!table_size)
return -EINVAL;
if (!table_header) {
pr_warn("%4.4s not present\n", id);
pr_warn("Table header not present\n");
The message doesn't make sense any more if the table signature is not printed.
For this message, since no table id is passed, and this message is printed in acpi_table_parse_entries() before this function is called, I think we can check the table_header before call this function and remove the printed message here.
table_header needs to be checked against NULL in the caller and the message printed from there to my eyes.
ok, I think table id should pass to this function, I will rework this patch and resend.
Thanks Hanjun
From: Tomasz Nowicki tomasz.nowicki@linaro.org
It is very useful to traverse all available table entries without max number of expected entries type. Current acpi_parse_entries() implementation gives that feature but it does not count those entries, it returns 0 instead, so fix it to count matched and successfully entries and return it.
NOTE: This change has no impact to x86 and ia64 archs since existing code checks for error occurrence only (acpi_parse_entries(...,0) < 0).
Acked-by: Grant Likely grant.likely@linaro.org Signed-off-by: Tomasz Nowicki tomasz.nowicki@linaro.org Signed-off-by: Hanjun Guo hanjun.guo@linaro.org --- drivers/acpi/tables.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c index 21ae521..b18e45e 100644 --- a/drivers/acpi/tables.c +++ b/drivers/acpi/tables.c @@ -225,10 +225,13 @@ acpi_parse_entries(unsigned long table_size, while (((unsigned long)entry) + sizeof(struct acpi_subtable_header) < table_end) { if (entry->type == entry_id - && (!max_entries || count++ < max_entries)) + && (!max_entries || count < max_entries)) { if (handler(entry, table_end)) return -EINVAL;
+ count++; + } + /* * If entry->length is 0, break from this loop to avoid * infinite loop.
Hi Rafael,
On 2014年10月17日 21:36, Hanjun Guo wrote:
From: Tomasz Nowicki tomasz.nowicki@linaro.org
It is very useful to traverse all available table entries without max number of expected entries type. Current acpi_parse_entries() implementation gives that feature but it does not count those entries, it returns 0 instead, so fix it to count matched and successfully entries and return it.
NOTE: This change has no impact to x86 and ia64 archs since existing code checks for error occurrence only (acpi_parse_entries(...,0) < 0).
Acked-by: Grant Likely grant.likely@linaro.org Signed-off-by: Tomasz Nowicki tomasz.nowicki@linaro.org Signed-off-by: Hanjun Guo hanjun.guo@linaro.org
Patch 2 and patch 3 are only for ACPI cores, and have no harm to x86 and IA64, could you merge first in 3.19?
Thanks Hanjun
drivers/acpi/tables.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c index 21ae521..b18e45e 100644 --- a/drivers/acpi/tables.c +++ b/drivers/acpi/tables.c @@ -225,10 +225,13 @@ acpi_parse_entries(unsigned long table_size, while (((unsigned long)entry) + sizeof(struct acpi_subtable_header) < table_end) { if (entry->type == entry_id
&& (!max_entries || count++ < max_entries))
&& (!max_entries || count < max_entries)) { if (handler(entry, table_end)) return -EINVAL;
count++;
}
/*
- If entry->length is 0, break from this loop to avoid
- infinite loop.
On Tuesday, November 18, 2014 09:51:25 PM Hanjun Guo wrote:
Hi Rafael,
On 2014年10月17日 21:36, Hanjun Guo wrote:
From: Tomasz Nowicki tomasz.nowicki@linaro.org
It is very useful to traverse all available table entries without max number of expected entries type. Current acpi_parse_entries() implementation gives that feature but it does not count those entries, it returns 0 instead, so fix it to count matched and successfully entries and return it.
NOTE: This change has no impact to x86 and ia64 archs since existing code checks for error occurrence only (acpi_parse_entries(...,0) < 0).
Acked-by: Grant Likely grant.likely@linaro.org Signed-off-by: Tomasz Nowicki tomasz.nowicki@linaro.org Signed-off-by: Hanjun Guo hanjun.guo@linaro.org
Patch 2 and patch 3 are only for ACPI cores, and have no harm to x86 and IA64, could you merge first in 3.19?
I can do that if that helps.
On 2014-11-19 4:15, Rafael J. Wysocki wrote:
On Tuesday, November 18, 2014 09:51:25 PM Hanjun Guo wrote:
Hi Rafael,
On 2014年10月17日 21:36, Hanjun Guo wrote:
From: Tomasz Nowicki tomasz.nowicki@linaro.org
It is very useful to traverse all available table entries without max number of expected entries type. Current acpi_parse_entries() implementation gives that feature but it does not count those entries, it returns 0 instead, so fix it to count matched and successfully entries and return it.
NOTE: This change has no impact to x86 and ia64 archs since existing code checks for error occurrence only (acpi_parse_entries(...,0) < 0).
Acked-by: Grant Likely grant.likely@linaro.org Signed-off-by: Tomasz Nowicki tomasz.nowicki@linaro.org Signed-off-by: Hanjun Guo hanjun.guo@linaro.org
Patch 2 and patch 3 are only for ACPI cores, and have no harm to x86 and IA64, could you merge first in 3.19?
I can do that if that helps.
Yes, it helps to keep the next version of ARM64 ACPI patch set smaller and easy for review. If any rebase work needed, please let me know.
Thanks Hanjun
On Friday, October 17, 2014 09:36:59 PM Hanjun Guo wrote:
From: Tomasz Nowicki tomasz.nowicki@linaro.org
It is very useful to traverse all available table entries without max number of expected entries type. Current acpi_parse_entries() implementation gives that feature but it does not count those entries, it returns 0 instead, so fix it to count matched and successfully entries and return it.
Hmm. I guess that the goal is for count to only be incremented when the condition is satisfied entirely, while without the patch it may be incremented even if that isn't the case.
I'm not sure how that is related to the above paragraph, however.
NOTE: This change has no impact to x86 and ia64 archs since existing code checks for error occurrence only (acpi_parse_entries(...,0) < 0).
Acked-by: Grant Likely grant.likely@linaro.org Signed-off-by: Tomasz Nowicki tomasz.nowicki@linaro.org Signed-off-by: Hanjun Guo hanjun.guo@linaro.org
drivers/acpi/tables.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c index 21ae521..b18e45e 100644 --- a/drivers/acpi/tables.c +++ b/drivers/acpi/tables.c @@ -225,10 +225,13 @@ acpi_parse_entries(unsigned long table_size, while (((unsigned long)entry) + sizeof(struct acpi_subtable_header) < table_end) { if (entry->type == entry_id
&& (!max_entries || count++ < max_entries))
&& (!max_entries || count < max_entries)) { if (handler(entry, table_end)) return -EINVAL;
count++;
}
- /*
- If entry->length is 0, break from this loop to avoid
- infinite loop.
On 24.11.2014 02:45, Rafael J. Wysocki wrote:
On Friday, October 17, 2014 09:36:59 PM Hanjun Guo wrote:
From: Tomasz Nowicki tomasz.nowicki@linaro.org
It is very useful to traverse all available table entries without max number of expected entries type. Current acpi_parse_entries() implementation gives that feature but it does not count those entries, it returns 0 instead, so fix it to count matched and successfully entries and return it.
Hmm. I guess that the goal is for count to only be incremented when the condition is satisfied entirely, while without the patch it may be incremented even if that isn't the case.
That would be our goal if patch would look like: - && (!max_entries || count++ < max_entries)) + && (!max_entries && count++ < max_entries)) { but then we can not walk through all available entries (with max_entries==0)
I'm not sure how that is related to the above paragraph, however.
Previous changelog is not clear, let me rewrite it:
acpi_parse_entries() allows to traverse all available table entries (aka subtables) by passing max_entries parameter equal to 0. But for that use case acpi_parse_entries() does not inform caller how many entries were matched and for how many entries handler was run against. That patch is going to fix it.
Regards, Tomasz
NOTE: This change has no impact to x86 and ia64 archs since existing code checks for error occurrence only (acpi_parse_entries(...,0) < 0).
Acked-by: Grant Likely grant.likely@linaro.org Signed-off-by: Tomasz Nowicki tomasz.nowicki@linaro.org Signed-off-by: Hanjun Guo hanjun.guo@linaro.org
drivers/acpi/tables.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c index 21ae521..b18e45e 100644 --- a/drivers/acpi/tables.c +++ b/drivers/acpi/tables.c @@ -225,10 +225,13 @@ acpi_parse_entries(unsigned long table_size, while (((unsigned long)entry) + sizeof(struct acpi_subtable_header) < table_end) { if (entry->type == entry_id
&& (!max_entries || count++ < max_entries))
&& (!max_entries || count < max_entries)) { if (handler(entry, table_end)) return -EINVAL;
count++;
}
/*
- If entry->length is 0, break from this loop to avoid
- infinite loop.
On Monday, November 24, 2014 09:34:24 AM Tomasz Nowicki wrote:
On 24.11.2014 02:45, Rafael J. Wysocki wrote:
On Friday, October 17, 2014 09:36:59 PM Hanjun Guo wrote:
From: Tomasz Nowicki tomasz.nowicki@linaro.org
It is very useful to traverse all available table entries without max number of expected entries type. Current acpi_parse_entries() implementation gives that feature but it does not count those entries, it returns 0 instead, so fix it to count matched and successfully entries and return it.
Hmm. I guess that the goal is for count to only be incremented when the condition is satisfied entirely, while without the patch it may be incremented even if that isn't the case.
That would be our goal if patch would look like:
&& (!max_entries || count++ < max_entries))
&& (!max_entries && count++ < max_entries)) {
but then we can not walk through all available entries (with max_entries==0)
No, that's not what I was trying to say. :-)
I'm not sure how that is related to the above paragraph, however.
Previous changelog is not clear, let me rewrite it:
acpi_parse_entries() allows to traverse all available table entries (aka subtables) by passing max_entries parameter equal to 0. But for that use case acpi_parse_entries() does not inform caller how many entries were matched and for how many entries handler was run against. That patch is going to fix it.
Do I understand correctly that count is only ever incremented by current code if max_entries is different from 0?
NOTE: This change has no impact to x86 and ia64 archs since existing code checks for error occurrence only (acpi_parse_entries(...,0) < 0).
Acked-by: Grant Likely grant.likely@linaro.org Signed-off-by: Tomasz Nowicki tomasz.nowicki@linaro.org Signed-off-by: Hanjun Guo hanjun.guo@linaro.org
drivers/acpi/tables.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c index 21ae521..b18e45e 100644 --- a/drivers/acpi/tables.c +++ b/drivers/acpi/tables.c @@ -225,10 +225,13 @@ acpi_parse_entries(unsigned long table_size, while (((unsigned long)entry) + sizeof(struct acpi_subtable_header) < table_end) { if (entry->type == entry_id
&& (!max_entries || count++ < max_entries))
&& (!max_entries || count < max_entries)) { if (handler(entry, table_end)) return -EINVAL;
count++;
}
/*
- If entry->length is 0, break from this loop to avoid
- infinite loop.
-- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 24.11.2014 16:16, Rafael J. Wysocki wrote:
On Monday, November 24, 2014 09:34:24 AM Tomasz Nowicki wrote:
On 24.11.2014 02:45, Rafael J. Wysocki wrote:
On Friday, October 17, 2014 09:36:59 PM Hanjun Guo wrote:
From: Tomasz Nowicki tomasz.nowicki@linaro.org
It is very useful to traverse all available table entries without max number of expected entries type. Current acpi_parse_entries() implementation gives that feature but it does not count those entries, it returns 0 instead, so fix it to count matched and successfully entries and return it.
Hmm. I guess that the goal is for count to only be incremented when the condition is satisfied entirely, while without the patch it may be incremented even if that isn't the case.
That would be our goal if patch would look like:
&& (!max_entries || count++ < max_entries))
&& (!max_entries && count++ < max_entries)) {
but then we can not walk through all available entries (with max_entries==0)
No, that's not what I was trying to say. :-)
I'm not sure how that is related to the above paragraph, however.
Previous changelog is not clear, let me rewrite it:
acpi_parse_entries() allows to traverse all available table entries (aka subtables) by passing max_entries parameter equal to 0. But for that use case acpi_parse_entries() does not inform caller how many entries were matched and for how many entries handler was run against. That patch is going to fix it.
Do I understand correctly that count is only ever incremented by current code if max_entries is different from 0?
Right. Currently "count" is incremented only if max_entries > 0.
Tomasz
NOTE: This change has no impact to x86 and ia64 archs since existing code checks for error occurrence only (acpi_parse_entries(...,0) < 0).
Acked-by: Grant Likely grant.likely@linaro.org Signed-off-by: Tomasz Nowicki tomasz.nowicki@linaro.org Signed-off-by: Hanjun Guo hanjun.guo@linaro.org
drivers/acpi/tables.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c index 21ae521..b18e45e 100644 --- a/drivers/acpi/tables.c +++ b/drivers/acpi/tables.c @@ -225,10 +225,13 @@ acpi_parse_entries(unsigned long table_size, while (((unsigned long)entry) + sizeof(struct acpi_subtable_header) < table_end) { if (entry->type == entry_id
&& (!max_entries || count++ < max_entries))
&& (!max_entries || count < max_entries)) { if (handler(entry, table_end)) return -EINVAL;
count++;
}
/* * If entry->length is 0, break from this loop to avoid * infinite loop.
-- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Monday, November 24, 2014 04:01:24 PM Tomasz Nowicki wrote:
On 24.11.2014 16:16, Rafael J. Wysocki wrote:
On Monday, November 24, 2014 09:34:24 AM Tomasz Nowicki wrote:
On 24.11.2014 02:45, Rafael J. Wysocki wrote:
On Friday, October 17, 2014 09:36:59 PM Hanjun Guo wrote:
From: Tomasz Nowicki tomasz.nowicki@linaro.org
It is very useful to traverse all available table entries without max number of expected entries type. Current acpi_parse_entries() implementation gives that feature but it does not count those entries, it returns 0 instead, so fix it to count matched and successfully entries and return it.
Hmm. I guess that the goal is for count to only be incremented when the condition is satisfied entirely, while without the patch it may be incremented even if that isn't the case.
That would be our goal if patch would look like:
&& (!max_entries || count++ < max_entries))
&& (!max_entries && count++ < max_entries)) {
but then we can not walk through all available entries (with max_entries==0)
No, that's not what I was trying to say. :-)
I'm not sure how that is related to the above paragraph, however.
Previous changelog is not clear, let me rewrite it:
acpi_parse_entries() allows to traverse all available table entries (aka subtables) by passing max_entries parameter equal to 0. But for that use case acpi_parse_entries() does not inform caller how many entries were matched and for how many entries handler was run against. That patch is going to fix it.
Do I understand correctly that count is only ever incremented by current code if max_entries is different from 0?
Right. Currently "count" is incremented only if max_entries > 0.
So can you say that in the changelog, please?
Something like:
"acpi_parse_entries() allows to traverse all available table entries (aka subtables) by passing max_entries parameter equal to 0, but since its count variable is only incremented if max_entries is not 0, the function always returns 0 for max_entries equal to 0. It would be more useful if it returned the number of entries matched instead, so make it increment count in that case too".
On 24.11.2014 16:37, Rafael J. Wysocki wrote:
On Monday, November 24, 2014 04:01:24 PM Tomasz Nowicki wrote:
On 24.11.2014 16:16, Rafael J. Wysocki wrote:
On Monday, November 24, 2014 09:34:24 AM Tomasz Nowicki wrote:
On 24.11.2014 02:45, Rafael J. Wysocki wrote:
On Friday, October 17, 2014 09:36:59 PM Hanjun Guo wrote:
From: Tomasz Nowicki tomasz.nowicki@linaro.org
It is very useful to traverse all available table entries without max number of expected entries type. Current acpi_parse_entries() implementation gives that feature but it does not count those entries, it returns 0 instead, so fix it to count matched and successfully entries and return it.
Hmm. I guess that the goal is for count to only be incremented when the condition is satisfied entirely, while without the patch it may be incremented even if that isn't the case.
That would be our goal if patch would look like:
&& (!max_entries || count++ < max_entries))
&& (!max_entries && count++ < max_entries)) {
but then we can not walk through all available entries (with max_entries==0)
No, that's not what I was trying to say. :-)
I'm not sure how that is related to the above paragraph, however.
Previous changelog is not clear, let me rewrite it:
acpi_parse_entries() allows to traverse all available table entries (aka subtables) by passing max_entries parameter equal to 0. But for that use case acpi_parse_entries() does not inform caller how many entries were matched and for how many entries handler was run against. That patch is going to fix it.
Do I understand correctly that count is only ever incremented by current code if max_entries is different from 0?
Right. Currently "count" is incremented only if max_entries > 0.
So can you say that in the changelog, please?
Something like:
"acpi_parse_entries() allows to traverse all available table entries (aka subtables) by passing max_entries parameter equal to 0, but since its count variable is only incremented if max_entries is not 0, the function always returns 0 for max_entries equal to 0. It would be more useful if it returned the number of entries matched instead, so make it increment count in that case too".
Sure, thanks.
Tomasz
From: Al Stone al.stone@linaro.org
As we want to get ACPI tables to parse and then use the information for system initialization, we should get the RSDP (Root System Description Pointer) first, it then locates Extended Root Description Table (XSDT) which contains all the 64-bit physical address that pointer to other boot-time tables.
Introduce acpi.c and its related head file in this patch to provide fundamental needs of extern variables and functions for ACPI core, and then get boot-time tables as needed. - asm/acenv.h for arch specific ACPICA environments and implementation, It is needed unconditionally by ACPI core; - asm/acpi.h for arch specific variables and functions needed by ACPI driver core; - acpi.c for ARM64 related ACPI implementation for ACPI driver core;
acpi_boot_table_init() is introduced to get RSDP and boot-time tables, it will be called in setup_arch() before paging_init(), so we should use eary_memremap() mechanism here to get the RSDP and all the table pointers.
Signed-off-by: Al Stone al.stone@linaro.org Signed-off-by: Graeme Gregory graeme.gregory@linaro.org Signed-off-by: Tomasz Nowicki tomasz.nowicki@linaro.org Signed-off-by: Hanjun Guo hanjun.guo@linaro.org --- arch/arm64/include/asm/acenv.h | 18 +++++++++++ arch/arm64/include/asm/acpi.h | 45 ++++++++++++++++++++++++++ arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/acpi.c | 69 ++++++++++++++++++++++++++++++++++++++++ arch/arm64/kernel/setup.c | 4 +++ 5 files changed, 137 insertions(+) create mode 100644 arch/arm64/include/asm/acenv.h create mode 100644 arch/arm64/include/asm/acpi.h create mode 100644 arch/arm64/kernel/acpi.c
diff --git a/arch/arm64/include/asm/acenv.h b/arch/arm64/include/asm/acenv.h new file mode 100644 index 0000000..b49166f --- /dev/null +++ b/arch/arm64/include/asm/acenv.h @@ -0,0 +1,18 @@ +/* + * ARM64 specific ACPICA environments and implementation + * + * Copyright (C) 2014, Linaro Ltd. + * Author: Hanjun Guo hanjun.guo@linaro.org + * Author: Graeme Gregory graeme.gregory@linaro.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#ifndef _ASM_ACENV_H +#define _ASM_ACENV_H + +/* It is required unconditionally by ACPI core, update it when needed. */ + +#endif /* _ASM_ACENV_H */ diff --git a/arch/arm64/include/asm/acpi.h b/arch/arm64/include/asm/acpi.h new file mode 100644 index 0000000..8b837ab --- /dev/null +++ b/arch/arm64/include/asm/acpi.h @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2013-2014, Linaro Ltd. + * Author: Al Stone al.stone@linaro.org + * Author: Graeme Gregory graeme.gregory@linaro.org + * Author: Hanjun Guo hanjun.guo@linaro.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + */ + +#ifndef _ASM_ACPI_H +#define _ASM_ACPI_H + +/* Basic configuration for ACPI */ +#ifdef CONFIG_ACPI +#define acpi_strict 1 /* No out-of-spec workarounds on ARM64 */ +extern int acpi_disabled; +extern int acpi_noirq; +extern int acpi_pci_disabled; + +static inline void disable_acpi(void) +{ + acpi_disabled = 1; + acpi_pci_disabled = 1; + acpi_noirq = 1; +} + +/* + * It's used from ACPI core in kdump to boot UP system with SMP kernel, + * with this check the ACPI core will not override the CPU index + * obtained from GICC with 0 and not print some error message as well. + * Since MADT must provide at least one GICC structure for GIC + * initialization, CPU will be always available in MADT on ARM64. + */ +static inline bool acpi_has_cpu_in_madt(void) +{ + return true; +} + +static inline void arch_fix_phys_package_id(int num, u32 slot) { } + +#endif /* CONFIG_ACPI */ + +#endif /*_ASM_ACPI_H*/ diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile index df7ef87..29ea7d6 100644 --- a/arch/arm64/kernel/Makefile +++ b/arch/arm64/kernel/Makefile @@ -29,6 +29,7 @@ arm64-obj-$(CONFIG_ARM64_CPU_SUSPEND) += sleep.o suspend.o arm64-obj-$(CONFIG_JUMP_LABEL) += jump_label.o arm64-obj-$(CONFIG_KGDB) += kgdb.o arm64-obj-$(CONFIG_EFI) += efi.o efi-stub.o efi-entry.o +arm64-obj-$(CONFIG_ACPI) += acpi.o
obj-y += $(arm64-obj-y) vdso/ obj-m += $(arm64-obj-m) diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c new file mode 100644 index 0000000..9252f72 --- /dev/null +++ b/arch/arm64/kernel/acpi.c @@ -0,0 +1,69 @@ +/* + * ARM64 Specific Low-Level ACPI Boot Support + * + * Copyright (C) 2013-2014, Linaro Ltd. + * Author: Al Stone al.stone@linaro.org + * Author: Graeme Gregory graeme.gregory@linaro.org + * Author: Hanjun Guo hanjun.guo@linaro.org + * Author: Tomasz Nowicki tomasz.nowicki@linaro.org + * Author: Naresh Bhat naresh.bhat@linaro.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include <linux/init.h> +#include <linux/acpi.h> +#include <linux/cpumask.h> +#include <linux/memblock.h> +#include <linux/irq.h> +#include <linux/irqdomain.h> +#include <linux/bootmem.h> +#include <linux/smp.h> + +int acpi_noirq; /* skip ACPI IRQ initialization */ +int acpi_disabled; +EXPORT_SYMBOL(acpi_disabled); + +int acpi_pci_disabled; /* skip ACPI PCI scan and IRQ initialization */ +EXPORT_SYMBOL(acpi_pci_disabled); + +/* + * __acpi_map_table() will be called before page_init(), so early_ioremap() + * or early_memremap() should be called here to for ACPI table mapping. + */ +char *__init __acpi_map_table(unsigned long phys, unsigned long size) +{ + if (!phys || !size) + return NULL; + + return early_memremap(phys, size); +} + +void __init __acpi_unmap_table(char *map, unsigned long size) +{ + if (!map || !size) + return; + + early_memunmap(map, size); +} + +/* + * 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 + * + * We can parse ACPI boot-time tables such as MADT after + * this function is called. + */ +void __init acpi_boot_table_init(void) +{ + /* If acpi_disabled, bail out */ + if (acpi_disabled) + return; + + /* Initialize the ACPI boot-time table parser. */ + if (acpi_table_init()) + disable_acpi(); +} diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c index 8f33f72..5b05227 100644 --- a/arch/arm64/kernel/setup.c +++ b/arch/arm64/kernel/setup.c @@ -43,6 +43,7 @@ #include <linux/of_fdt.h> #include <linux/of_platform.h> #include <linux/efi.h> +#include <linux/acpi.h>
#include <asm/fixmap.h> #include <asm/cpu.h> @@ -388,6 +389,9 @@ void __init setup_arch(char **cmdline_p) efi_init(); arm64_memblock_init();
+ /* Parse the ACPI tables for possible boot-time configuration */ + acpi_boot_table_init(); + paging_init(); request_standard_resources();
From: Graeme Gregory graeme.gregory@linaro.org
ACPI 5.1 does not currently support S states for ARM64 hardware but ACPI code will call acpi_target_system_state() for device power managment, so introduce sleep-arm.c to allow other drivers to function until S states are defined.
Signed-off-by: Graeme Gregory graeme.gregory@linaro.org Signed-off-by: Tomasz Nowicki tomasz.nowicki@linaro.org Signed-off-by: Hanjun Guo hanjun.guo@linaro.org --- drivers/acpi/Makefile | 4 ++++ drivers/acpi/sleep-arm.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 drivers/acpi/sleep-arm.c
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile index 505d4d7..89837f8 100644 --- a/drivers/acpi/Makefile +++ b/drivers/acpi/Makefile @@ -23,7 +23,11 @@ acpi-y += nvs.o
# Power management related files acpi-y += wakeup.o +ifeq ($(ARCH), arm64) +acpi-y += sleep-arm.o +else # X86, IA64 acpi-y += sleep.o +endif acpi-y += device_pm.o acpi-$(CONFIG_ACPI_SLEEP) += proc.o
diff --git a/drivers/acpi/sleep-arm.c b/drivers/acpi/sleep-arm.c new file mode 100644 index 0000000..54578ef --- /dev/null +++ b/drivers/acpi/sleep-arm.c @@ -0,0 +1,28 @@ +/* + * ARM64 Specific Sleep Functionality + * + * Copyright (C) 2013-2014, Linaro Ltd. + * Author: Graeme Gregory graeme.gregory@linaro.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include <linux/acpi.h> + +/* + * Currently the ACPI 5.1 standard does not define S states in a + * manner which is usable for ARM64. These two stubs are sufficient + * that system initialises and device PM works. + */ +u32 acpi_target_system_state(void) +{ + return ACPI_STATE_S0; +} +EXPORT_SYMBOL_GPL(acpi_target_system_state); + +int __init acpi_sleep_init(void) +{ + return -ENOSYS; +}
From: Al Stone al.stone@linaro.org
Introduce one early parameters "off" and "force" for "acpi", acpi=off will be the default behavior for ARM64, so introduce acpi=force to enable ACPI on ARM64.
Disable ACPI before early parameters parsed, and enable it to pass "acpi=force" if people want use ACPI on ARM64. This ensures DT be the prefer one if ACPI table and DT both are provided at this moment.
Signed-off-by: Al Stone al.stone@linaro.org Signed-off-by: Graeme Gregory graeme.gregory@linaro.org Signed-off-by: Hanjun Guo hanjun.guo@linaro.org --- Documentation/kernel-parameters.txt | 3 ++- arch/arm64/include/asm/acpi.h | 9 +++++++++ arch/arm64/kernel/acpi.c | 17 +++++++++++++++++ arch/arm64/kernel/setup.c | 3 +++ 4 files changed, 31 insertions(+), 1 deletion(-)
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt index 5ae8608..2af0948 100644 --- a/Documentation/kernel-parameters.txt +++ b/Documentation/kernel-parameters.txt @@ -165,7 +165,7 @@ multipliers 'Kilo', 'Mega', and 'Giga', equalling 2^10, 2^20, and 2^30 bytes respectively. Such letter suffixes can also be entirely omitted.
- acpi= [HW,ACPI,X86] + acpi= [HW,ACPI,X86,ARM64] Advanced Configuration and Power Interface Format: { force | off | strict | noirq | rsdt } force -- enable ACPI if default was off @@ -175,6 +175,7 @@ bytes respectively. Such letter suffixes can also be entirely omitted. strictly ACPI specification compliant. rsdt -- prefer RSDT over (default) XSDT copy_dsdt -- copy DSDT to memory + For ARM64, ONLY "acpi=off" or "acpi=force" are available
See also Documentation/power/runtime_pm.txt, pci=noacpi
diff --git a/arch/arm64/include/asm/acpi.h b/arch/arm64/include/asm/acpi.h index 8b837ab..496c33b 100644 --- a/arch/arm64/include/asm/acpi.h +++ b/arch/arm64/include/asm/acpi.h @@ -26,6 +26,13 @@ static inline void disable_acpi(void) acpi_noirq = 1; }
+static inline void enable_acpi(void) +{ + acpi_disabled = 0; + acpi_pci_disabled = 0; + acpi_noirq = 0; +} + /* * It's used from ACPI core in kdump to boot UP system with SMP kernel, * with this check the ACPI core will not override the CPU index @@ -40,6 +47,8 @@ static inline bool acpi_has_cpu_in_madt(void)
static inline void arch_fix_phys_package_id(int num, u32 slot) { }
+#else +static inline void disable_acpi(void) { } #endif /* CONFIG_ACPI */
#endif /*_ASM_ACPI_H*/ diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c index 9252f72..39a1655 100644 --- a/arch/arm64/kernel/acpi.c +++ b/arch/arm64/kernel/acpi.c @@ -67,3 +67,20 @@ void __init acpi_boot_table_init(void) if (acpi_table_init()) disable_acpi(); } + +static int __init parse_acpi(char *arg) +{ + if (!arg) + return -EINVAL; + + /* "acpi=off" disables both ACPI table parsing and interpreter */ + if (strcmp(arg, "off") == 0) + disable_acpi(); + else if (strcmp(arg, "force") == 0) /* force ACPI to be enabled */ + enable_acpi(); + else + return -EINVAL; /* Core will print when we return error */ + + return 0; +} +early_param("acpi", parse_acpi); diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c index 5b05227..15621b9 100644 --- a/arch/arm64/kernel/setup.c +++ b/arch/arm64/kernel/setup.c @@ -60,6 +60,7 @@ #include <asm/memblock.h> #include <asm/psci.h> #include <asm/efi.h> +#include <asm/acpi.h>
unsigned int processor_id; EXPORT_SYMBOL(processor_id); @@ -384,6 +385,8 @@ void __init setup_arch(char **cmdline_p)
early_ioremap_init();
+ disable_acpi(); + parse_early_param();
efi_init();
From: Graeme Gregory graeme.gregory@linaro.org
If the early boot methods of acpi are happy that we have valid ACPI tables and acpi=force has been passed, then do not unflat devicetree effectively disabling further hardware probing from DT.
Signed-off-by: Graeme Gregory graeme.gregory@linaro.org Signed-off-by: Hanjun Guo hanjun.guo@linaro.org --- arch/arm64/kernel/setup.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c index 15621b9..e4f2576 100644 --- a/arch/arm64/kernel/setup.c +++ b/arch/arm64/kernel/setup.c @@ -401,7 +401,8 @@ void __init setup_arch(char **cmdline_p) efi_idmap_init();
cpu_logical_map(0) = read_cpuid_mpidr() & MPIDR_HWID_BITMASK; - unflatten_device_tree(); + if (acpi_disabled) + unflatten_device_tree();
psci_init();
As PCI for ARM64 is not ready, so introduce some stub functions to make PCI optional for ACPI, and make ACPI core run without CONFIG_PCI on ARM64.
Since ACPI on X86 and IA64 depends on PCI and this patch only makes PCI optional for ARM64, it will not break anything on X86 and IA64.
Signed-off-by: Hanjun Guo hanjun.guo@linaro.org --- arch/arm64/include/asm/pci.h | 11 +++++++++++ drivers/acpi/Makefile | 2 +- drivers/acpi/internal.h | 5 +++++ include/linux/pci.h | 37 +++++++++++++++++++++++++++---------- 4 files changed, 44 insertions(+), 11 deletions(-) create mode 100644 arch/arm64/include/asm/pci.h
diff --git a/arch/arm64/include/asm/pci.h b/arch/arm64/include/asm/pci.h new file mode 100644 index 0000000..250cd24 --- /dev/null +++ b/arch/arm64/include/asm/pci.h @@ -0,0 +1,11 @@ +#ifndef __ASM_PCI_H +#define __ASM_PCI_H +#ifdef __KERNEL__ + +/* + * PCI address space differs from physical memory address space + */ +#define PCI_DMA_BUS_IS_PHYS (0) + +#endif /* __KERNEL__ */ +#endif /* __ASM_PCI_H */ diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile index 89837f8..6f3a74d 100644 --- a/drivers/acpi/Makefile +++ b/drivers/acpi/Makefile @@ -43,7 +43,7 @@ acpi-y += processor_core.o acpi-$(CONFIG_ARCH_MIGHT_HAVE_ACPI_PDC) += processor_pdc.o acpi-y += ec.o acpi-$(CONFIG_ACPI_DOCK) += dock.o -acpi-y += pci_root.o pci_link.o pci_irq.o +acpi-$(CONFIG_PCI) += pci_root.o pci_link.o pci_irq.o acpi-y += acpi_lpss.o acpi-y += acpi_platform.o acpi-y += acpi_pnp.o diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h index 4c5cf77..e1e6487 100644 --- a/drivers/acpi/internal.h +++ b/drivers/acpi/internal.h @@ -26,8 +26,13 @@ acpi_status acpi_os_initialize1(void); int init_acpi_device_notify(void); int acpi_scan_init(void); +#ifdef CONFIG_PCI void acpi_pci_root_init(void); void acpi_pci_link_init(void); +#else +static inline void acpi_pci_root_init(void) {} +static inline void acpi_pci_link_init(void) {} +#endif void acpi_processor_init(void); void acpi_platform_init(void); void acpi_pnp_init(void); diff --git a/include/linux/pci.h b/include/linux/pci.h index 61978a4..50fa750 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -558,15 +558,6 @@ struct pci_ops { int (*write)(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 val); };
-/* - * ACPI needs to be able to access PCI config space before we've done a - * PCI bus scan and created pci_bus structures. - */ -int raw_pci_read(unsigned int domain, unsigned int bus, unsigned int devfn, - int reg, int len, u32 *val); -int raw_pci_write(unsigned int domain, unsigned int bus, unsigned int devfn, - int reg, int len, u32 val); - struct pci_bus_region { dma_addr_t start; dma_addr_t end; @@ -1293,6 +1284,16 @@ typedef int (*arch_set_vga_state_t)(struct pci_dev *pdev, bool decode, unsigned int command_bits, u32 flags); void pci_register_set_vga_state(arch_set_vga_state_t func);
+/* + * ACPI needs to be able to access PCI config space before we've done a + * PCI bus scan and created pci_bus structures. + */ +int raw_pci_read(unsigned int domain, unsigned int bus, unsigned int devfn, + int reg, int len, u32 *val); +int raw_pci_write(unsigned int domain, unsigned int bus, unsigned int devfn, + int reg, int len, u32 val); +void pcibios_penalize_isa_irq(int irq, int active); + #else /* CONFIG_PCI is not enabled */
/* @@ -1394,6 +1395,23 @@ static inline struct pci_dev *pci_get_bus_and_slot(unsigned int bus, unsigned int devfn) { return NULL; }
+static inline struct pci_bus *pci_find_bus(int domain, int busnr) +{ return NULL; } + +static inline int pci_bus_write_config_byte(struct pci_bus *bus, + unsigned int devfn, int where, u8 val) +{ return -ENOSYS; } + +static inline int raw_pci_read(unsigned int domain, unsigned int bus, + unsigned int devfn, int reg, int len, u32 *val) +{ return -ENOSYS; } + +static inline int raw_pci_write(unsigned int domain, unsigned int bus, + unsigned int devfn, int reg, int len, u32 val) +{ return -ENOSYS; } + +static inline void pcibios_penalize_isa_irq(int irq, int active) { } + static inline int pci_domain_nr(struct pci_bus *bus) { return 0; } static inline struct pci_dev *pci_dev_get(struct pci_dev *dev) { return NULL; }
@@ -1607,7 +1625,6 @@ int pcibios_set_pcie_reset_state(struct pci_dev *dev, enum pcie_reset_state state); int pcibios_add_device(struct pci_dev *dev); void pcibios_release_device(struct pci_dev *dev); -void pcibios_penalize_isa_irq(int irq, int active);
#ifdef CONFIG_HIBERNATE_CALLBACKS extern struct dev_pm_ops pcibios_pm_ops;
There are two flags: PSCI_COMPLIANT and PSCI_USE_HVC. When set, the former signals to the OS that the firmware is PSCI compliant. The latter selects the appropriate conduit for PSCI calls by toggling between Hypervisor Calls (HVC) and Secure Monitor Calls (SMC).
FADT table contains such information, parse FADT to get the flags for PSCI init. Since ACPI 5.1 doesn't support self defined PSCI function IDs, which means that only PSCI 0.2+ is supported in ACPI.
At the same time, only ACPI 5.1 or higher verison supports PSCI, and FADT Major.Minor version was introduced in ACPI 5.1, so we will check the version and only parse FADT table with version >= 5.1.
If firmware provides ACPI tables with ACPI version less than 5.1, OS will be messed up with those information and have no way to init smp and GIC, so disable ACPI if we get an FADT table with version less that 5.1.
Signed-off-by: Hanjun Guo hanjun.guo@linaro.org Signed-off-by: Graeme Gregory graeme.gregory@linaro.org Signed-off-by: Tomasz Nowicki tomasz.nowicki@linaro.org --- arch/arm64/include/asm/acpi.h | 14 ++++++++ arch/arm64/include/asm/psci.h | 3 +- arch/arm64/kernel/acpi.c | 31 +++++++++++++++- arch/arm64/kernel/psci.c | 78 ++++++++++++++++++++++++++++------------- arch/arm64/kernel/setup.c | 8 +++-- 5 files changed, 105 insertions(+), 29 deletions(-)
diff --git a/arch/arm64/include/asm/acpi.h b/arch/arm64/include/asm/acpi.h index 496c33b..221ff15 100644 --- a/arch/arm64/include/asm/acpi.h +++ b/arch/arm64/include/asm/acpi.h @@ -19,6 +19,18 @@ extern int acpi_disabled; extern int acpi_noirq; extern int acpi_pci_disabled;
+/* 1 to indicate PSCI 0.2+ is implemented */ +static inline bool acpi_psci_present(void) +{ + return acpi_gbl_FADT.arm_boot_flags & ACPI_FADT_PSCI_COMPLIANT; +} + +/* 1 to indicate HVC must be used instead of SMC as the PSCI conduit */ +static inline bool acpi_psci_use_hvc(void) +{ + return acpi_gbl_FADT.arm_boot_flags & ACPI_FADT_PSCI_USE_HVC; +} + static inline void disable_acpi(void) { acpi_disabled = 1; @@ -49,6 +61,8 @@ static inline void arch_fix_phys_package_id(int num, u32 slot) { }
#else static inline void disable_acpi(void) { } +static inline bool acpi_psci_present(void) { return false; } +static inline bool acpi_psci_use_hvc(void) { return false; } #endif /* CONFIG_ACPI */
#endif /*_ASM_ACPI_H*/ diff --git a/arch/arm64/include/asm/psci.h b/arch/arm64/include/asm/psci.h index e5312ea..2454bc5 100644 --- a/arch/arm64/include/asm/psci.h +++ b/arch/arm64/include/asm/psci.h @@ -14,6 +14,7 @@ #ifndef __ASM_PSCI_H #define __ASM_PSCI_H
-int psci_init(void); +int psci_dt_init(void); +int psci_acpi_init(void);
#endif /* __ASM_PSCI_H */ diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c index 39a1655..e713236 100644 --- a/arch/arm64/kernel/acpi.c +++ b/arch/arm64/kernel/acpi.c @@ -13,6 +13,8 @@ * published by the Free Software Foundation. */
+#define pr_fmt(fmt) "ACPI: " fmt + #include <linux/init.h> #include <linux/acpi.h> #include <linux/cpumask.h> @@ -49,10 +51,32 @@ void __init __acpi_unmap_table(char *map, unsigned long size) early_memunmap(map, size); }
+static int __init acpi_parse_fadt(struct acpi_table_header *table) +{ + struct acpi_table_fadt *fadt = (struct acpi_table_fadt *)table; + + /* + * Revision in table header is the FADT Major revision, + * and there is a minor revision of FADT which was introduced + * by ACPI 5.1, we only deal with ACPI 5.1 or newer revision + * to get arm boot flags, or we will disable ACPI. + */ + if (table->revision > 5 || + (table->revision == 5 && fadt->minor_revision >= 1)) + return 0; + + pr_warn("Unsupported FADT revision %d.%d, should be 5.1+, will disable ACPI\n", + table->revision, fadt->minor_revision); + disable_acpi(); + + return -EINVAL; +} + /* * acpi_boot_table_init() called from setup_arch(), always. * 1. find RSDP and get its address, and then find XSDT * 2. extract all tables and checksums them all + * 3. check ACPI FADT revisoin * * We can parse ACPI boot-time tables such as MADT after * this function is called. @@ -64,8 +88,13 @@ void __init acpi_boot_table_init(void) return;
/* Initialize the ACPI boot-time table parser. */ - if (acpi_table_init()) + if (acpi_table_init()) { disable_acpi(); + return; + } + + if (acpi_table_parse(ACPI_SIG_FADT, acpi_parse_fadt)) + pr_err("Can't find FADT or error happened during parsing FADT\n"); }
static int __init parse_acpi(char *arg) diff --git a/arch/arm64/kernel/psci.c b/arch/arm64/kernel/psci.c index 5539547..15ba470 100644 --- a/arch/arm64/kernel/psci.c +++ b/arch/arm64/kernel/psci.c @@ -15,6 +15,7 @@
#define pr_fmt(fmt) "psci: " fmt
+#include <linux/acpi.h> #include <linux/init.h> #include <linux/of.h> #include <linux/smp.h> @@ -23,6 +24,7 @@ #include <linux/delay.h> #include <uapi/linux/psci.h>
+#include <asm/acpi.h> #include <asm/compiler.h> #include <asm/cpu_ops.h> #include <asm/errno.h> @@ -231,6 +233,33 @@ static void psci_sys_poweroff(void) invoke_psci_fn(PSCI_0_2_FN_SYSTEM_OFF, 0, 0, 0); }
+static void psci_0_2_set_functions(void) +{ + pr_info("Using standard PSCI v0.2 function IDs\n"); + psci_function_id[PSCI_FN_CPU_SUSPEND] = PSCI_0_2_FN64_CPU_SUSPEND; + psci_ops.cpu_suspend = psci_cpu_suspend; + + psci_function_id[PSCI_FN_CPU_OFF] = PSCI_0_2_FN_CPU_OFF; + psci_ops.cpu_off = psci_cpu_off; + + psci_function_id[PSCI_FN_CPU_ON] = PSCI_0_2_FN64_CPU_ON; + psci_ops.cpu_on = psci_cpu_on; + + psci_function_id[PSCI_FN_MIGRATE] = PSCI_0_2_FN64_MIGRATE; + psci_ops.migrate = psci_migrate; + + psci_function_id[PSCI_FN_AFFINITY_INFO] = PSCI_0_2_FN64_AFFINITY_INFO; + psci_ops.affinity_info = psci_affinity_info; + + psci_function_id[PSCI_FN_MIGRATE_INFO_TYPE] = + PSCI_0_2_FN_MIGRATE_INFO_TYPE; + psci_ops.migrate_info_type = psci_migrate_info_type; + + arm_pm_restart = psci_sys_reset; + + pm_power_off = psci_sys_poweroff; +} + /* * PSCI Function IDs for v0.2+ are well defined so use * standard values. @@ -264,29 +293,7 @@ static int __init psci_0_2_init(struct device_node *np) } }
- pr_info("Using standard PSCI v0.2 function IDs\n"); - psci_function_id[PSCI_FN_CPU_SUSPEND] = PSCI_0_2_FN64_CPU_SUSPEND; - psci_ops.cpu_suspend = psci_cpu_suspend; - - psci_function_id[PSCI_FN_CPU_OFF] = PSCI_0_2_FN_CPU_OFF; - psci_ops.cpu_off = psci_cpu_off; - - psci_function_id[PSCI_FN_CPU_ON] = PSCI_0_2_FN64_CPU_ON; - psci_ops.cpu_on = psci_cpu_on; - - psci_function_id[PSCI_FN_MIGRATE] = PSCI_0_2_FN64_MIGRATE; - psci_ops.migrate = psci_migrate; - - psci_function_id[PSCI_FN_AFFINITY_INFO] = PSCI_0_2_FN64_AFFINITY_INFO; - psci_ops.affinity_info = psci_affinity_info; - - psci_function_id[PSCI_FN_MIGRATE_INFO_TYPE] = - PSCI_0_2_FN_MIGRATE_INFO_TYPE; - psci_ops.migrate_info_type = psci_migrate_info_type; - - arm_pm_restart = psci_sys_reset; - - pm_power_off = psci_sys_poweroff; + psci_0_2_set_functions();
out_put_node: of_node_put(np); @@ -339,7 +346,7 @@ static const struct of_device_id psci_of_match[] __initconst = { {}, };
-int __init psci_init(void) +int __init psci_dt_init(void) { struct device_node *np; const struct of_device_id *matched_np; @@ -354,6 +361,29 @@ int __init psci_init(void) return init_fn(np); }
+/* + * We use PSCI 0.2+ when ACPI is deployed on ARM64 and it's + * explicitly clarified in SBBR + */ +int __init psci_acpi_init(void) +{ + if (!acpi_psci_present()) { + pr_info("is not implemented in ACPI.\n"); + return -EOPNOTSUPP; + } + + pr_info("probing for conduit method from ACPI.\n"); + + if (acpi_psci_use_hvc()) + invoke_psci_fn = __invoke_psci_fn_hvc; + else + invoke_psci_fn = __invoke_psci_fn_smc; + + psci_0_2_set_functions(); + + return 0; +} + #ifdef CONFIG_SMP
static int __init cpu_psci_cpu_init(struct device_node *dn, unsigned int cpu) diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c index e4f2576..d448d6a 100644 --- a/arch/arm64/kernel/setup.c +++ b/arch/arm64/kernel/setup.c @@ -401,10 +401,12 @@ void __init setup_arch(char **cmdline_p) efi_idmap_init();
cpu_logical_map(0) = read_cpuid_mpidr() & MPIDR_HWID_BITMASK; - if (acpi_disabled) + if (acpi_disabled) { unflatten_device_tree(); - - psci_init(); + psci_dt_init(); + } else { + psci_acpi_init(); + }
cpu_read_bootcpu_ops(); #ifdef CONFIG_SMP
When MADT is parsed, print GIC information to make the boot log look pretty:
ACPI: GICC (acpi_id[0x0000] address[00000000e112f000] MPDIR[0x0] enabled) ACPI: GICC (acpi_id[0x0001] address[00000000e112f000] MPDIR[0x1] enabled) ... ACPI: GICC (acpi_id[0x0201] address[00000000e112f000] MPDIR[0x201] enabled)
These information will be very helpful to bring up early systems to see if acpi_id and MPIDR are matched or not as spec defined.
Signed-off-by: Hanjun Guo hanjun.guo@linaro.org Signed-off-by: Tomasz Nowicki tomasz.nowicki@linaro.org --- drivers/acpi/tables.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+)
diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c index b18e45e..47f36d4 100644 --- a/drivers/acpi/tables.c +++ b/drivers/acpi/tables.c @@ -183,6 +183,49 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header) } break;
+ case ACPI_MADT_TYPE_GENERIC_INTERRUPT: + { + struct acpi_madt_generic_interrupt *p = + (struct acpi_madt_generic_interrupt *)header; + pr_info("GICC (acpi_id[0x%04x] address[%p] MPDIR[0x%llx] %s)\n", + p->uid, (void *)(unsigned long)p->base_address, + p->arm_mpidr, + (p->flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled"); + + } + break; + + case ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR: + { + struct acpi_madt_generic_distributor *p = + (struct acpi_madt_generic_distributor *)header; + pr_info("GIC Distributor (gic_id[0x%04x] address[%p] gsi_base[%d])\n", + p->gic_id, + (void *)(unsigned long)p->base_address, + p->global_irq_base); + } + break; + + case ACPI_MADT_TYPE_GENERIC_MSI_FRAME: + { + struct acpi_madt_generic_msi_frame *p = + (struct acpi_madt_generic_msi_frame *)header; + pr_info("GIC MSI Frame (msi_fame_id[%d] address[%p])\n", + p->msi_frame_id, + (void *)(unsigned long)p->base_address); + } + break; + + case ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR: + { + struct acpi_madt_generic_redistributor *p = + (struct acpi_madt_generic_redistributor *)header; + pr_info("GIC Redistributor (address[%p] region_size[0x%x])\n", + (void *)(unsigned long)p->base_address, + p->length); + } + break; + default: pr_warn("Found unsupported MADT entry (type = 0x%x)\n", header->type);
MADT contains the information for MPIDR which is essential for SMP initialization, parse the GIC cpu interface structures to get the MPIDR value and map it to cpu_logical_map(), and add enabled cpu with valid MPIDR into cpu_possible_map.
ACPI 5.1 only has two explicit methods to boot up SMP, PSCI and Parking protocol, but the Parking protocol is only specified for ARMv7 now, so make PSCI as the only way for the SMP boot protocol before some updates for the ACPI spec or the Parking protocol spec.
Signed-off-by: Hanjun Guo hanjun.guo@linaro.org Signed-off-by: Tomasz Nowicki tomasz.nowicki@linaro.org --- arch/arm64/include/asm/acpi.h | 2 + arch/arm64/include/asm/cpu_ops.h | 1 + arch/arm64/include/asm/smp.h | 5 +- arch/arm64/kernel/acpi.c | 150 +++++++++++++++++++++++++++++++++++++- arch/arm64/kernel/cpu_ops.c | 4 +- arch/arm64/kernel/setup.c | 7 +- arch/arm64/kernel/smp.c | 2 +- 7 files changed, 162 insertions(+), 9 deletions(-)
diff --git a/arch/arm64/include/asm/acpi.h b/arch/arm64/include/asm/acpi.h index 221ff15..c82d4a1 100644 --- a/arch/arm64/include/asm/acpi.h +++ b/arch/arm64/include/asm/acpi.h @@ -58,11 +58,13 @@ static inline bool acpi_has_cpu_in_madt(void) }
static inline void arch_fix_phys_package_id(int num, u32 slot) { } +void __init acpi_smp_init_cpus(void);
#else static inline void disable_acpi(void) { } static inline bool acpi_psci_present(void) { return false; } static inline bool acpi_psci_use_hvc(void) { return false; } +static inline void acpi_smp_init_cpus(void) { } #endif /* CONFIG_ACPI */
#endif /*_ASM_ACPI_H*/ diff --git a/arch/arm64/include/asm/cpu_ops.h b/arch/arm64/include/asm/cpu_ops.h index d7b4b38..d149580 100644 --- a/arch/arm64/include/asm/cpu_ops.h +++ b/arch/arm64/include/asm/cpu_ops.h @@ -61,6 +61,7 @@ struct cpu_operations { };
extern const struct cpu_operations *cpu_ops[NR_CPUS]; +const struct cpu_operations *cpu_get_ops(const char *name); extern int __init cpu_read_ops(struct device_node *dn, int cpu); extern void __init cpu_read_bootcpu_ops(void);
diff --git a/arch/arm64/include/asm/smp.h b/arch/arm64/include/asm/smp.h index a498f2c..c877adc 100644 --- a/arch/arm64/include/asm/smp.h +++ b/arch/arm64/include/asm/smp.h @@ -39,9 +39,10 @@ extern void show_ipi_list(struct seq_file *p, int prec); extern void handle_IPI(int ipinr, struct pt_regs *regs);
/* - * Setup the set of possible CPUs (via set_cpu_possible) + * Discover the set of possible CPUs and determine their + * SMP operations. */ -extern void smp_init_cpus(void); +extern void of_smp_init_cpus(void);
/* * Provide a function to raise an IPI cross call on CPUs in callmap. diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c index e713236..34837e0 100644 --- a/arch/arm64/kernel/acpi.c +++ b/arch/arm64/kernel/acpi.c @@ -24,6 +24,10 @@ #include <linux/bootmem.h> #include <linux/smp.h>
+#include <asm/smp_plat.h> +#include <asm/cputype.h> +#include <asm/cpu_ops.h> + int acpi_noirq; /* skip ACPI IRQ initialization */ int acpi_disabled; EXPORT_SYMBOL(acpi_disabled); @@ -31,6 +35,8 @@ EXPORT_SYMBOL(acpi_disabled); int acpi_pci_disabled; /* skip ACPI PCI scan and IRQ initialization */ EXPORT_SYMBOL(acpi_pci_disabled);
+static int enabled_cpus; /* Processors (GICC) with enabled flag in MADT */ + /* * __acpi_map_table() will be called before page_init(), so early_ioremap() * or early_memremap() should be called here to for ACPI table mapping. @@ -51,6 +57,134 @@ void __init __acpi_unmap_table(char *map, unsigned long size) early_memunmap(map, size); }
+/** + * acpi_map_gic_cpu_interface - generates a logical cpu number + * and map to MPIDR represented by GICC structure + * @mpidr: CPU's hardware id to register, MPIDR represented in MADT + * @enabled: this cpu is enabled or not + * + * Returns the logical cpu number which maps to MPIDR + */ +static int acpi_map_gic_cpu_interface(u64 mpidr, u8 enabled) +{ + int cpu; + + if (mpidr == INVALID_HWID) { + pr_info("Skip MADT cpu entry with invalid MPIDR\n"); + return -EINVAL; + } + + total_cpus++; + if (!enabled) + return -EINVAL; + + if (enabled_cpus >= NR_CPUS) { + pr_warn("NR_CPUS limit of %d reached, Processor %d/0x%llx ignored.\n", + NR_CPUS, total_cpus, mpidr); + return -EINVAL; + } + + /* No need to check duplicate MPIDRs for the first CPU */ + if (enabled_cpus) { + /* + * Duplicate MPIDRs are a recipe for disaster. Scan + * all initialized entries and check for + * duplicates. If any is found just ignore the CPU. + */ + for_each_possible_cpu(cpu) { + if (cpu_logical_map(cpu) == mpidr) { + pr_err("Firmware bug, duplicate CPU MPIDR: 0x%llx in MADT\n", + mpidr); + return -EINVAL; + } + } + + /* allocate a logical cpu id for the new comer */ + cpu = cpumask_next_zero(-1, cpu_possible_mask); + } else { + /* + * First GICC entry must be BSP as ACPI spec said + * in section 5.2.12.15 + */ + if (cpu_logical_map(0) != mpidr) { + pr_err("First GICC entry with MPIDR 0x%llx is not BSP\n", + mpidr); + return -EINVAL; + } + + /* + * boot_cpu_init() already hold bit 0 in cpu_present_mask + * for BSP, no need to allocate again. + */ + cpu = 0; + } + + /* CPU 0 was already initialized */ + if (cpu) { + cpu_ops[cpu] = cpu_get_ops(acpi_psci_present() ? "psci" : NULL); + if (!cpu_ops[cpu]) + return -EINVAL; + + if (cpu_ops[cpu]->cpu_init(NULL, cpu)) + return -EOPNOTSUPP; + + /* map the logical cpu id to cpu MPIDR */ + cpu_logical_map(cpu) = mpidr; + + set_cpu_possible(cpu, true); + } else { + /* get cpu0's ops, no need to return if ops is null */ + cpu_ops[0] = cpu_get_ops(acpi_psci_present() ? "psci" : NULL); + } + + enabled_cpus++; + return cpu; +} + +static int __init +acpi_parse_gic_cpu_interface(struct acpi_subtable_header *header, + const unsigned long end) +{ + struct acpi_madt_generic_interrupt *processor; + + processor = (struct acpi_madt_generic_interrupt *)header; + + if (BAD_MADT_ENTRY(processor, end)) + return -EINVAL; + + acpi_table_print_madt_entry(header); + + acpi_map_gic_cpu_interface(processor->arm_mpidr & MPIDR_HWID_BITMASK, + processor->flags & ACPI_MADT_ENABLED); + + return 0; +} + +/* Parse GIC cpu interface entries in MADT for SMP init */ +void __init acpi_smp_init_cpus(void) +{ + int count; + + /* + * do a partial walk of MADT to determine how many CPUs + * we have including disabled CPUs, and get information + * we need for SMP init + */ + count = acpi_table_parse_madt(ACPI_MADT_TYPE_GENERIC_INTERRUPT, + acpi_parse_gic_cpu_interface, 0); + + if (!count) { + pr_err("No GIC CPU interface entries present\n"); + return; + } else if (count < 0) { + pr_err("Error parsing GIC CPU interface entry\n"); + return; + } + + /* Make boot-up look pretty */ + pr_info("%d CPUs enabled, %d CPUs total\n", enabled_cpus, total_cpus); +} + static int __init acpi_parse_fadt(struct acpi_table_header *table) { struct acpi_table_fadt *fadt = (struct acpi_table_fadt *)table; @@ -62,8 +196,20 @@ static int __init acpi_parse_fadt(struct acpi_table_header *table) * to get arm boot flags, or we will disable ACPI. */ if (table->revision > 5 || - (table->revision == 5 && fadt->minor_revision >= 1)) - return 0; + (table->revision == 5 && fadt->minor_revision >= 1)) { + /* + * ACPI 5.1 only has two explicit methods to boot up SMP, + * PSCI and Parking protocol, but the Parking protocol is + * only specified for ARMv7 now, so make PSCI as the only + * way for the SMP boot protocol before some updates for + * the ACPI spec or the Parking protocol spec. + */ + if (acpi_psci_present()) + return 0; + + pr_warn("No PSCI support, will not bring up secondary CPUs\n"); + return -EOPNOTSUPP; + }
pr_warn("Unsupported FADT revision %d.%d, should be 5.1+, will disable ACPI\n", table->revision, fadt->minor_revision); diff --git a/arch/arm64/kernel/cpu_ops.c b/arch/arm64/kernel/cpu_ops.c index cce9524..1a04deb 100644 --- a/arch/arm64/kernel/cpu_ops.c +++ b/arch/arm64/kernel/cpu_ops.c @@ -27,7 +27,7 @@ extern const struct cpu_operations cpu_psci_ops;
const struct cpu_operations *cpu_ops[NR_CPUS];
-static const struct cpu_operations *supported_cpu_ops[] __initconst = { +static const struct cpu_operations *supported_cpu_ops[] = { #ifdef CONFIG_SMP &smp_spin_table_ops, #endif @@ -35,7 +35,7 @@ static const struct cpu_operations *supported_cpu_ops[] __initconst = { NULL, };
-static const struct cpu_operations * __init cpu_get_ops(const char *name) +const struct cpu_operations *cpu_get_ops(const char *name) { const struct cpu_operations **ops = supported_cpu_ops;
diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c index d448d6a..eb00f01 100644 --- a/arch/arm64/kernel/setup.c +++ b/arch/arm64/kernel/setup.c @@ -404,13 +404,16 @@ void __init setup_arch(char **cmdline_p) if (acpi_disabled) { unflatten_device_tree(); psci_dt_init(); + cpu_read_bootcpu_ops(); +#ifdef CONFIG_SMP + of_smp_init_cpus(); +#endif } else { psci_acpi_init(); + acpi_smp_init_cpus(); }
- cpu_read_bootcpu_ops(); #ifdef CONFIG_SMP - smp_init_cpus(); smp_build_mpidr_hash(); #endif
diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index 4743397..4e390ac 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c @@ -321,7 +321,7 @@ void __init smp_prepare_boot_cpu(void) * cpu logical map array containing MPIDR values related to logical * cpus. Assumes that cpu_logical_map(0) has already been initialized. */ -void __init smp_init_cpus(void) +void __init of_smp_init_cpus(void) { struct device_node *dn = NULL; unsigned int i, cpu = 1;
Introduce a new function map_gicc_mpidr() to allow MPIDRs to be obtained from the GICC Structure introduced by ACPI 5.1.
MPIDR is the CPU hardware ID as local APIC ID on x86 platform, so we use MPIDR not the GIC CPU interface ID to identify CPUs.
Signed-off-by: Hanjun Guo hanjun.guo@linaro.org --- arch/arm64/include/asm/acpi.h | 29 +++++++++++++++++++++++++++++ arch/arm64/kernel/acpi.c | 1 - drivers/acpi/processor_core.c | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+), 1 deletion(-)
diff --git a/arch/arm64/include/asm/acpi.h b/arch/arm64/include/asm/acpi.h index c82d4a1..483ff45 100644 --- a/arch/arm64/include/asm/acpi.h +++ b/arch/arm64/include/asm/acpi.h @@ -12,6 +12,8 @@ #ifndef _ASM_ACPI_H #define _ASM_ACPI_H
+#include <asm/smp_plat.h> + /* Basic configuration for ACPI */ #ifdef CONFIG_ACPI #define acpi_strict 1 /* No out-of-spec workarounds on ARM64 */ @@ -45,6 +47,33 @@ static inline void enable_acpi(void) acpi_noirq = 0; }
+/* MPIDR value provided in GICC structure is 64 bits, but the + * existing apic_id (CPU hardware ID) using in acpi processor + * driver is 32-bit, to conform to the same datatype we need + * to repack the GICC structure MPIDR. + * + * Only 32 bits of MPIDR are used: + * + * Bits [0:7] Aff0; + * Bits [8:15] Aff1; + * Bits [16:23] Aff2; + * Bits [32:39] Aff3; + */ +static inline u32 pack_mpidr(u64 mpidr) +{ + return (u32) ((mpidr & 0xff00000000) >> 8) | mpidr; +} + +/* + * The ACPI processor driver for ACPI core code needs this macro + * to find out this cpu was already mapped (mapping from CPU hardware + * ID to CPU logical ID) or not. + * + * cpu_logical_map(cpu) is the mapping of MPIDR and the logical cpu, + * and MPIDR is the cpu hardware ID we needed to pack. + */ +#define cpu_physical_id(cpu) pack_mpidr(cpu_logical_map(cpu)) + /* * It's used from ACPI core in kdump to boot UP system with SMP kernel, * with this check the ACPI core will not override the CPU index diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c index 34837e0..e91ec76 100644 --- a/arch/arm64/kernel/acpi.c +++ b/arch/arm64/kernel/acpi.c @@ -24,7 +24,6 @@ #include <linux/bootmem.h> #include <linux/smp.h>
-#include <asm/smp_plat.h> #include <asm/cputype.h> #include <asm/cpu_ops.h>
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c index e32321c..4007313 100644 --- a/drivers/acpi/processor_core.c +++ b/drivers/acpi/processor_core.c @@ -64,6 +64,38 @@ static int map_lsapic_id(struct acpi_subtable_header *entry, return 0; }
+/* + * On ARM platform, MPIDR value is the hardware ID as apic ID + * on Intel platforms + */ +static int map_gicc_mpidr(struct acpi_subtable_header *entry, + int device_declaration, u32 acpi_id, int *mpidr) +{ + struct acpi_madt_generic_interrupt *gicc = + container_of(entry, struct acpi_madt_generic_interrupt, header); + + if (!(gicc->flags & ACPI_MADT_ENABLED)) + return -ENODEV; + + /* In the GIC interrupt model, logical processors are + * required to have a Processor Device object in the DSDT, + * so we should check device_declaration here + */ + if (device_declaration && (gicc->uid == acpi_id)) { + /* + * Only bits [0:7] Aff0, bits [8:15] Aff1, bits [16:23] Aff2 + * and bits [32:39] Aff3 are meaningful, so pack the Affx + * fields into a single 32 bit identifier to accommodate the + * acpi processor drivers. + */ + *mpidr = ((gicc->arm_mpidr & 0xff00000000) >> 8) + | gicc->arm_mpidr; + return 0; + } + + return -EINVAL; +} + static int map_madt_entry(int type, u32 acpi_id) { unsigned long madt_end, entry; @@ -99,6 +131,9 @@ static int map_madt_entry(int type, u32 acpi_id) } else if (header->type == ACPI_MADT_TYPE_LOCAL_SAPIC) { if (!map_lsapic_id(header, type, acpi_id, &apic_id)) break; + } else if (header->type == ACPI_MADT_TYPE_GENERIC_INTERRUPT) { + if (!map_gicc_mpidr(header, type, acpi_id, &apic_id)) + break; } entry += header->length; } @@ -131,6 +166,8 @@ static int map_mat_entry(acpi_handle handle, int type, u32 acpi_id) map_lsapic_id(header, type, acpi_id, &apic_id); } else if (header->type == ACPI_MADT_TYPE_LOCAL_X2APIC) { map_x2apic_id(header, type, acpi_id, &apic_id); + } else if (header->type == ACPI_MADT_TYPE_GENERIC_INTERRUPT) { + map_gicc_mpidr(header, type, acpi_id, &apic_id); }
exit:
On Fri, Oct 17, 2014 at 02:37:08PM +0100, Hanjun Guo wrote:
Introduce a new function map_gicc_mpidr() to allow MPIDRs to be obtained from the GICC Structure introduced by ACPI 5.1.
MPIDR is the CPU hardware ID as local APIC ID on x86 platform, so we use MPIDR not the GIC CPU interface ID to identify CPUs.
Signed-off-by: Hanjun Guo hanjun.guo@linaro.org
arch/arm64/include/asm/acpi.h | 29 +++++++++++++++++++++++++++++ arch/arm64/kernel/acpi.c | 1 - drivers/acpi/processor_core.c | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+), 1 deletion(-)
diff --git a/arch/arm64/include/asm/acpi.h b/arch/arm64/include/asm/acpi.h index c82d4a1..483ff45 100644 --- a/arch/arm64/include/asm/acpi.h +++ b/arch/arm64/include/asm/acpi.h @@ -12,6 +12,8 @@ #ifndef _ASM_ACPI_H #define _ASM_ACPI_H +#include <asm/smp_plat.h>
/* Basic configuration for ACPI */ #ifdef CONFIG_ACPI #define acpi_strict 1 /* No out-of-spec workarounds on ARM64 */ @@ -45,6 +47,33 @@ static inline void enable_acpi(void) acpi_noirq = 0; } +/* MPIDR value provided in GICC structure is 64 bits, but the
- existing apic_id (CPU hardware ID) using in acpi processor
- driver is 32-bit, to conform to the same datatype we need
- to repack the GICC structure MPIDR.
- Only 32 bits of MPIDR are used:
- Bits [0:7] Aff0;
- Bits [8:15] Aff1;
- Bits [16:23] Aff2;
- Bits [32:39] Aff3;
- */
+static inline u32 pack_mpidr(u64 mpidr) +{
- return (u32) ((mpidr & 0xff00000000) >> 8) | mpidr;
+}
+/*
- The ACPI processor driver for ACPI core code needs this macro
- to find out this cpu was already mapped (mapping from CPU hardware
- ID to CPU logical ID) or not.
- cpu_logical_map(cpu) is the mapping of MPIDR and the logical cpu,
- and MPIDR is the cpu hardware ID we needed to pack.
- */
+#define cpu_physical_id(cpu) pack_mpidr(cpu_logical_map(cpu))
/*
- It's used from ACPI core in kdump to boot UP system with SMP kernel,
- with this check the ACPI core will not override the CPU index
diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c index 34837e0..e91ec76 100644 --- a/arch/arm64/kernel/acpi.c +++ b/arch/arm64/kernel/acpi.c @@ -24,7 +24,6 @@ #include <linux/bootmem.h> #include <linux/smp.h> -#include <asm/smp_plat.h> #include <asm/cputype.h> #include <asm/cpu_ops.h> diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c index e32321c..4007313 100644 --- a/drivers/acpi/processor_core.c +++ b/drivers/acpi/processor_core.c @@ -64,6 +64,38 @@ static int map_lsapic_id(struct acpi_subtable_header *entry, return 0; } +/*
- On ARM platform, MPIDR value is the hardware ID as apic ID
- on Intel platforms
- */
+static int map_gicc_mpidr(struct acpi_subtable_header *entry,
int device_declaration, u32 acpi_id, int *mpidr)
+{
- struct acpi_madt_generic_interrupt *gicc =
container_of(entry, struct acpi_madt_generic_interrupt, header);
- if (!(gicc->flags & ACPI_MADT_ENABLED))
return -ENODEV;
- /* In the GIC interrupt model, logical processors are
* required to have a Processor Device object in the DSDT,
* so we should check device_declaration here
*/
- if (device_declaration && (gicc->uid == acpi_id)) {
/*
* Only bits [0:7] Aff0, bits [8:15] Aff1, bits [16:23] Aff2
* and bits [32:39] Aff3 are meaningful, so pack the Affx
* fields into a single 32 bit identifier to accommodate the
* acpi processor drivers.
*/
*mpidr = ((gicc->arm_mpidr & 0xff00000000) >> 8)
| gicc->arm_mpidr;
The simple fact that you define a function to pack the mpidr value and you can't use it here because this is *generic* code is telling, and a very bad omen. At the cost of sounding like a broken record, I do not like this mpidr->apic->logical_cpu song and dance at all. ACPI is peppered with code (eg hotplug is another example, CPUidle driver even worse) that is supposed to be generic but contains x86 code to carry out this cpuid conversion, I really think that in order to start an ARM64 ACPI port properly we should at least try to factor out this physical to logical cpu id conversion, and it is not the first time that I mention this on the lists.
I will also talk to Rafael about this at the earliest opportunity, I guess that x86 code relies on apic-id because some ACPI versions could not rely on the acpi-id or some other reasons I have to investigate.
Thanks, Lorenzo
return 0;
- }
- return -EINVAL;
+}
static int map_madt_entry(int type, u32 acpi_id) { unsigned long madt_end, entry; @@ -99,6 +131,9 @@ static int map_madt_entry(int type, u32 acpi_id) } else if (header->type == ACPI_MADT_TYPE_LOCAL_SAPIC) { if (!map_lsapic_id(header, type, acpi_id, &apic_id)) break;
} else if (header->type == ACPI_MADT_TYPE_GENERIC_INTERRUPT) {
if (!map_gicc_mpidr(header, type, acpi_id, &apic_id))
} entry += header->length; }break;
@@ -131,6 +166,8 @@ static int map_mat_entry(acpi_handle handle, int type, u32 acpi_id) map_lsapic_id(header, type, acpi_id, &apic_id); } else if (header->type == ACPI_MADT_TYPE_LOCAL_X2APIC) { map_x2apic_id(header, type, acpi_id, &apic_id);
- } else if (header->type == ACPI_MADT_TYPE_GENERIC_INTERRUPT) {
}map_gicc_mpidr(header, type, acpi_id, &apic_id);
exit: -- 1.7.9.5
On 2014-10-25 1:39, Lorenzo Pieralisi wrote:
On Fri, Oct 17, 2014 at 02:37:08PM +0100, Hanjun Guo wrote:
Introduce a new function map_gicc_mpidr() to allow MPIDRs to be obtained from the GICC Structure introduced by ACPI 5.1.
MPIDR is the CPU hardware ID as local APIC ID on x86 platform, so we use MPIDR not the GIC CPU interface ID to identify CPUs.
Signed-off-by: Hanjun Guo hanjun.guo@linaro.org
arch/arm64/include/asm/acpi.h | 29 +++++++++++++++++++++++++++++ arch/arm64/kernel/acpi.c | 1 - drivers/acpi/processor_core.c | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+), 1 deletion(-)
diff --git a/arch/arm64/include/asm/acpi.h b/arch/arm64/include/asm/acpi.h index c82d4a1..483ff45 100644 --- a/arch/arm64/include/asm/acpi.h +++ b/arch/arm64/include/asm/acpi.h @@ -12,6 +12,8 @@ #ifndef _ASM_ACPI_H #define _ASM_ACPI_H +#include <asm/smp_plat.h>
/* Basic configuration for ACPI */ #ifdef CONFIG_ACPI #define acpi_strict 1 /* No out-of-spec workarounds on ARM64 */ @@ -45,6 +47,33 @@ static inline void enable_acpi(void) acpi_noirq = 0; } +/* MPIDR value provided in GICC structure is 64 bits, but the
- existing apic_id (CPU hardware ID) using in acpi processor
- driver is 32-bit, to conform to the same datatype we need
- to repack the GICC structure MPIDR.
- Only 32 bits of MPIDR are used:
- Bits [0:7] Aff0;
- Bits [8:15] Aff1;
- Bits [16:23] Aff2;
- Bits [32:39] Aff3;
- */
+static inline u32 pack_mpidr(u64 mpidr) +{
- return (u32) ((mpidr & 0xff00000000) >> 8) | mpidr;
+}
+/*
- The ACPI processor driver for ACPI core code needs this macro
- to find out this cpu was already mapped (mapping from CPU hardware
- ID to CPU logical ID) or not.
- cpu_logical_map(cpu) is the mapping of MPIDR and the logical cpu,
- and MPIDR is the cpu hardware ID we needed to pack.
- */
+#define cpu_physical_id(cpu) pack_mpidr(cpu_logical_map(cpu))
/*
- It's used from ACPI core in kdump to boot UP system with SMP kernel,
- with this check the ACPI core will not override the CPU index
diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c index 34837e0..e91ec76 100644 --- a/arch/arm64/kernel/acpi.c +++ b/arch/arm64/kernel/acpi.c @@ -24,7 +24,6 @@ #include <linux/bootmem.h> #include <linux/smp.h> -#include <asm/smp_plat.h> #include <asm/cputype.h> #include <asm/cpu_ops.h> diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c index e32321c..4007313 100644 --- a/drivers/acpi/processor_core.c +++ b/drivers/acpi/processor_core.c @@ -64,6 +64,38 @@ static int map_lsapic_id(struct acpi_subtable_header *entry, return 0; } +/*
- On ARM platform, MPIDR value is the hardware ID as apic ID
- on Intel platforms
- */
+static int map_gicc_mpidr(struct acpi_subtable_header *entry,
int device_declaration, u32 acpi_id, int *mpidr)
+{
- struct acpi_madt_generic_interrupt *gicc =
container_of(entry, struct acpi_madt_generic_interrupt, header);
- if (!(gicc->flags & ACPI_MADT_ENABLED))
return -ENODEV;
- /* In the GIC interrupt model, logical processors are
* required to have a Processor Device object in the DSDT,
* so we should check device_declaration here
*/
- if (device_declaration && (gicc->uid == acpi_id)) {
/*
* Only bits [0:7] Aff0, bits [8:15] Aff1, bits [16:23] Aff2
* and bits [32:39] Aff3 are meaningful, so pack the Affx
* fields into a single 32 bit identifier to accommodate the
* acpi processor drivers.
*/
*mpidr = ((gicc->arm_mpidr & 0xff00000000) >> 8)
| gicc->arm_mpidr;
The simple fact that you define a function to pack the mpidr value and you can't use it here because this is *generic* code is telling, and a very bad omen. At the cost of sounding like a broken record, I do not like this mpidr->apic->logical_cpu song and dance at all. ACPI is peppered with code (eg hotplug is another example, CPUidle driver even worse) that is supposed to be generic but contains x86 code to carry out this cpuid conversion, I really think that in order to start an ARM64 ACPI port properly we should at least try to factor out this physical to logical cpu id conversion, and it is not the first time that I mention this on the lists.
I know, thanks for pointing this out. As I replied in previous version of this patch set, apic_id is x86/ia64 specific, but the meaning behind it is not. It means the CPU hardware id to identify itself in the system, it just like MPIDR on ARM.
I will send out a patch for RFC to convert apic_id to physid which is generic for all platforms.
I will also talk to Rafael about this at the earliest opportunity, I guess that x86 code relies on apic-id because some ACPI versions could not rely on the acpi-id or some other reasons I have to investigate.
As ACPI spec (section 8.4, Declaring Processors) said, Each processor in the system must be declared in the ACPI namespace, so each cpu will have acpi_id in all ACPI versions, and in theory we can map acpi_id to logical cpu id if we want to.
But things are complicated, apic_id is connected to many tables, MADT for smp init, DSDT for device driver, and SRAT for NUMA (there is no acpi_id in it, ONLY has apic_id in the table for x86/ia64), so if we want to factor the code to map acpi_id to logical cpu id, we need to modify:
- ACPI drivers; - SMP init for x86 and ia64 - the mappings for NUMA init for x86 and ia64 that will be lots of work I think.
I'm willing to discuss this further and come out a solution, please comment on what I said and share your ideas :)
Thanks Hanjun
On Mon, Oct 27, 2014 at 09:58:10AM +0000, Hanjun Guo wrote:
[...]
+static int map_gicc_mpidr(struct acpi_subtable_header *entry,
int device_declaration, u32 acpi_id, int *mpidr)
+{
- struct acpi_madt_generic_interrupt *gicc =
container_of(entry, struct acpi_madt_generic_interrupt, header);
- if (!(gicc->flags & ACPI_MADT_ENABLED))
return -ENODEV;
- /* In the GIC interrupt model, logical processors are
* required to have a Processor Device object in the DSDT,
* so we should check device_declaration here
*/
- if (device_declaration && (gicc->uid == acpi_id)) {
/*
* Only bits [0:7] Aff0, bits [8:15] Aff1, bits [16:23] Aff2
* and bits [32:39] Aff3 are meaningful, so pack the Affx
* fields into a single 32 bit identifier to accommodate the
* acpi processor drivers.
*/
*mpidr = ((gicc->arm_mpidr & 0xff00000000) >> 8)
| gicc->arm_mpidr;
The simple fact that you define a function to pack the mpidr value and you can't use it here because this is *generic* code is telling, and a very bad omen. At the cost of sounding like a broken record, I do not like this mpidr->apic->logical_cpu song and dance at all. ACPI is peppered with code (eg hotplug is another example, CPUidle driver even worse) that is supposed to be generic but contains x86 code to carry out this cpuid conversion, I really think that in order to start an ARM64 ACPI port properly we should at least try to factor out this physical to logical cpu id conversion, and it is not the first time that I mention this on the lists.
I know, thanks for pointing this out. As I replied in previous version of this patch set, apic_id is x86/ia64 specific, but the meaning behind it is not. It means the CPU hardware id to identify itself in the system, it just like MPIDR on ARM.
Yes, except that it is called apic_id.
I will send out a patch for RFC to convert apic_id to physid which is generic for all platforms.
That seems a good idea to sound out if I am the only one having an issue with the current approach.
I will also talk to Rafael about this at the earliest opportunity, I guess that x86 code relies on apic-id because some ACPI versions could not rely on the acpi-id or some other reasons I have to investigate.
As ACPI spec (section 8.4, Declaring Processors) said, Each processor in the system must be declared in the ACPI namespace, so each cpu will have acpi_id in all ACPI versions, and in theory we can map acpi_id to logical cpu id if we want to.
But things are complicated, apic_id is connected to many tables, MADT for smp init, DSDT for device driver, and SRAT for NUMA (there is no acpi_id in it, ONLY has apic_id in the table for x86/ia64), so if we want to factor the code to map acpi_id to logical cpu id, we need to modify:
- ACPI drivers;
- SMP init for x86 and ia64
- the mappings for NUMA init for x86 and ia64
that will be lots of work I think.
I'm willing to discuss this further and come out a solution, please comment on what I said and share your ideas :)
Factoring out apic_id to a common cpu_physical_id is ok to me, because basically that's what you are doing except for the naming. I do not have any particular preference for the acpi_id, I mentioned that only as a means to implement a generic cpu_physical_id, arch agnostic.
Drop the RFC you mentioned above please on the list, we will restart debating from there.
Thanks, Lorenzo
On 2014-10-29 18:43, Lorenzo Pieralisi wrote:
On Mon, Oct 27, 2014 at 09:58:10AM +0000, Hanjun Guo wrote:
[...]
+static int map_gicc_mpidr(struct acpi_subtable_header *entry,
int device_declaration, u32 acpi_id, int *mpidr)
+{
- struct acpi_madt_generic_interrupt *gicc =
container_of(entry, struct acpi_madt_generic_interrupt, header);
- if (!(gicc->flags & ACPI_MADT_ENABLED))
return -ENODEV;
- /* In the GIC interrupt model, logical processors are
* required to have a Processor Device object in the DSDT,
* so we should check device_declaration here
*/
- if (device_declaration && (gicc->uid == acpi_id)) {
/*
* Only bits [0:7] Aff0, bits [8:15] Aff1, bits [16:23] Aff2
* and bits [32:39] Aff3 are meaningful, so pack the Affx
* fields into a single 32 bit identifier to accommodate the
* acpi processor drivers.
*/
*mpidr = ((gicc->arm_mpidr & 0xff00000000) >> 8)
| gicc->arm_mpidr;
The simple fact that you define a function to pack the mpidr value and you can't use it here because this is *generic* code is telling, and a very bad omen. At the cost of sounding like a broken record, I do not like this mpidr->apic->logical_cpu song and dance at all. ACPI is peppered with code (eg hotplug is another example, CPUidle driver even worse) that is supposed to be generic but contains x86 code to carry out this cpuid conversion, I really think that in order to start an ARM64 ACPI port properly we should at least try to factor out this physical to logical cpu id conversion, and it is not the first time that I mention this on the lists.
I know, thanks for pointing this out. As I replied in previous version of this patch set, apic_id is x86/ia64 specific, but the meaning behind it is not. It means the CPU hardware id to identify itself in the system, it just like MPIDR on ARM.
Yes, except that it is called apic_id.
I will send out a patch for RFC to convert apic_id to physid which is generic for all platforms.
That seems a good idea to sound out if I am the only one having an issue with the current approach.
I will also talk to Rafael about this at the earliest opportunity, I guess that x86 code relies on apic-id because some ACPI versions could not rely on the acpi-id or some other reasons I have to investigate.
As ACPI spec (section 8.4, Declaring Processors) said, Each processor in the system must be declared in the ACPI namespace, so each cpu will have acpi_id in all ACPI versions, and in theory we can map acpi_id to logical cpu id if we want to.
But things are complicated, apic_id is connected to many tables, MADT for smp init, DSDT for device driver, and SRAT for NUMA (there is no acpi_id in it, ONLY has apic_id in the table for x86/ia64), so if we want to factor the code to map acpi_id to logical cpu id, we need to modify:
- ACPI drivers;
- SMP init for x86 and ia64
- the mappings for NUMA init for x86 and ia64
that will be lots of work I think.
I'm willing to discuss this further and come out a solution, please comment on what I said and share your ideas :)
Factoring out apic_id to a common cpu_physical_id is ok to me, because basically that's what you are doing except for the naming. I do not have any particular preference for the acpi_id, I mentioned that only as a means to implement a generic cpu_physical_id, arch agnostic.
Drop the RFC you mentioned above please on the list, we will restart debating from there.
Ok, will send out the patch soon.
Thanks Hanjun
On Monday, October 27, 2014 05:58:10 PM Hanjun Guo wrote:
On 2014-10-25 1:39, Lorenzo Pieralisi wrote:
On Fri, Oct 17, 2014 at 02:37:08PM +0100, Hanjun Guo wrote:
Introduce a new function map_gicc_mpidr() to allow MPIDRs to be obtained from the GICC Structure introduced by ACPI 5.1.
MPIDR is the CPU hardware ID as local APIC ID on x86 platform, so we use MPIDR not the GIC CPU interface ID to identify CPUs.
Signed-off-by: Hanjun Guo hanjun.guo@linaro.org
arch/arm64/include/asm/acpi.h | 29 +++++++++++++++++++++++++++++ arch/arm64/kernel/acpi.c | 1 - drivers/acpi/processor_core.c | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+), 1 deletion(-)
diff --git a/arch/arm64/include/asm/acpi.h b/arch/arm64/include/asm/acpi.h index c82d4a1..483ff45 100644 --- a/arch/arm64/include/asm/acpi.h +++ b/arch/arm64/include/asm/acpi.h @@ -12,6 +12,8 @@ #ifndef _ASM_ACPI_H #define _ASM_ACPI_H +#include <asm/smp_plat.h>
/* Basic configuration for ACPI */ #ifdef CONFIG_ACPI #define acpi_strict 1 /* No out-of-spec workarounds on ARM64 */ @@ -45,6 +47,33 @@ static inline void enable_acpi(void) acpi_noirq = 0; } +/* MPIDR value provided in GICC structure is 64 bits, but the
- existing apic_id (CPU hardware ID) using in acpi processor
- driver is 32-bit, to conform to the same datatype we need
- to repack the GICC structure MPIDR.
- Only 32 bits of MPIDR are used:
- Bits [0:7] Aff0;
- Bits [8:15] Aff1;
- Bits [16:23] Aff2;
- Bits [32:39] Aff3;
- */
+static inline u32 pack_mpidr(u64 mpidr) +{
- return (u32) ((mpidr & 0xff00000000) >> 8) | mpidr;
+}
+/*
- The ACPI processor driver for ACPI core code needs this macro
- to find out this cpu was already mapped (mapping from CPU hardware
- ID to CPU logical ID) or not.
- cpu_logical_map(cpu) is the mapping of MPIDR and the logical cpu,
- and MPIDR is the cpu hardware ID we needed to pack.
- */
+#define cpu_physical_id(cpu) pack_mpidr(cpu_logical_map(cpu))
/*
- It's used from ACPI core in kdump to boot UP system with SMP kernel,
- with this check the ACPI core will not override the CPU index
diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c index 34837e0..e91ec76 100644 --- a/arch/arm64/kernel/acpi.c +++ b/arch/arm64/kernel/acpi.c @@ -24,7 +24,6 @@ #include <linux/bootmem.h> #include <linux/smp.h> -#include <asm/smp_plat.h> #include <asm/cputype.h> #include <asm/cpu_ops.h> diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c index e32321c..4007313 100644 --- a/drivers/acpi/processor_core.c +++ b/drivers/acpi/processor_core.c @@ -64,6 +64,38 @@ static int map_lsapic_id(struct acpi_subtable_header *entry, return 0; } +/*
- On ARM platform, MPIDR value is the hardware ID as apic ID
- on Intel platforms
- */
+static int map_gicc_mpidr(struct acpi_subtable_header *entry,
int device_declaration, u32 acpi_id, int *mpidr)
+{
- struct acpi_madt_generic_interrupt *gicc =
container_of(entry, struct acpi_madt_generic_interrupt, header);
- if (!(gicc->flags & ACPI_MADT_ENABLED))
return -ENODEV;
- /* In the GIC interrupt model, logical processors are
* required to have a Processor Device object in the DSDT,
* so we should check device_declaration here
*/
- if (device_declaration && (gicc->uid == acpi_id)) {
/*
* Only bits [0:7] Aff0, bits [8:15] Aff1, bits [16:23] Aff2
* and bits [32:39] Aff3 are meaningful, so pack the Affx
* fields into a single 32 bit identifier to accommodate the
* acpi processor drivers.
*/
*mpidr = ((gicc->arm_mpidr & 0xff00000000) >> 8)
| gicc->arm_mpidr;
The simple fact that you define a function to pack the mpidr value and you can't use it here because this is *generic* code is telling, and a very bad omen. At the cost of sounding like a broken record, I do not like this mpidr->apic->logical_cpu song and dance at all. ACPI is peppered with code (eg hotplug is another example, CPUidle driver even worse) that is supposed to be generic but contains x86 code to carry out this cpuid conversion, I really think that in order to start an ARM64 ACPI port properly we should at least try to factor out this physical to logical cpu id conversion, and it is not the first time that I mention this on the lists.
I know, thanks for pointing this out. As I replied in previous version of this patch set, apic_id is x86/ia64 specific, but the meaning behind it is not. It means the CPU hardware id to identify itself in the system, it just like MPIDR on ARM.
I will send out a patch for RFC to convert apic_id to physid which is generic for all platforms.
I will also talk to Rafael about this at the earliest opportunity, I guess that x86 code relies on apic-id because some ACPI versions could not rely on the acpi-id or some other reasons I have to investigate.
As ACPI spec (section 8.4, Declaring Processors) said, Each processor in the system must be declared in the ACPI namespace, so each cpu will have acpi_id in all ACPI versions, and in theory we can map acpi_id to logical cpu id if we want to.
But things are complicated, apic_id is connected to many tables, MADT for smp init, DSDT for device driver, and SRAT for NUMA (there is no acpi_id in it, ONLY has apic_id in the table for x86/ia64), so if we want to factor the code to map acpi_id to logical cpu id, we need to modify:
- ACPI drivers;
- SMP init for x86 and ia64
- the mappings for NUMA init for x86 and ia64
that will be lots of work I think.
And error prone for that matter.
On 2014-10-30 5:33, Rafael J. Wysocki wrote:
On Monday, October 27, 2014 05:58:10 PM Hanjun Guo wrote:
On 2014-10-25 1:39, Lorenzo Pieralisi wrote:
On Fri, Oct 17, 2014 at 02:37:08PM +0100, Hanjun Guo wrote:
Introduce a new function map_gicc_mpidr() to allow MPIDRs to be obtained from the GICC Structure introduced by ACPI 5.1.
MPIDR is the CPU hardware ID as local APIC ID on x86 platform, so we use MPIDR not the GIC CPU interface ID to identify CPUs.
Signed-off-by: Hanjun Guo hanjun.guo@linaro.org
arch/arm64/include/asm/acpi.h | 29 +++++++++++++++++++++++++++++ arch/arm64/kernel/acpi.c | 1 - drivers/acpi/processor_core.c | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+), 1 deletion(-)
diff --git a/arch/arm64/include/asm/acpi.h b/arch/arm64/include/asm/acpi.h index c82d4a1..483ff45 100644 --- a/arch/arm64/include/asm/acpi.h +++ b/arch/arm64/include/asm/acpi.h @@ -12,6 +12,8 @@ #ifndef _ASM_ACPI_H #define _ASM_ACPI_H +#include <asm/smp_plat.h>
/* Basic configuration for ACPI */ #ifdef CONFIG_ACPI #define acpi_strict 1 /* No out-of-spec workarounds on ARM64 */ @@ -45,6 +47,33 @@ static inline void enable_acpi(void) acpi_noirq = 0; } +/* MPIDR value provided in GICC structure is 64 bits, but the
- existing apic_id (CPU hardware ID) using in acpi processor
- driver is 32-bit, to conform to the same datatype we need
- to repack the GICC structure MPIDR.
- Only 32 bits of MPIDR are used:
- Bits [0:7] Aff0;
- Bits [8:15] Aff1;
- Bits [16:23] Aff2;
- Bits [32:39] Aff3;
- */
+static inline u32 pack_mpidr(u64 mpidr) +{
- return (u32) ((mpidr & 0xff00000000) >> 8) | mpidr;
+}
+/*
- The ACPI processor driver for ACPI core code needs this macro
- to find out this cpu was already mapped (mapping from CPU hardware
- ID to CPU logical ID) or not.
- cpu_logical_map(cpu) is the mapping of MPIDR and the logical cpu,
- and MPIDR is the cpu hardware ID we needed to pack.
- */
+#define cpu_physical_id(cpu) pack_mpidr(cpu_logical_map(cpu))
/*
- It's used from ACPI core in kdump to boot UP system with SMP kernel,
- with this check the ACPI core will not override the CPU index
diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c index 34837e0..e91ec76 100644 --- a/arch/arm64/kernel/acpi.c +++ b/arch/arm64/kernel/acpi.c @@ -24,7 +24,6 @@ #include <linux/bootmem.h> #include <linux/smp.h> -#include <asm/smp_plat.h> #include <asm/cputype.h> #include <asm/cpu_ops.h> diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c index e32321c..4007313 100644 --- a/drivers/acpi/processor_core.c +++ b/drivers/acpi/processor_core.c @@ -64,6 +64,38 @@ static int map_lsapic_id(struct acpi_subtable_header *entry, return 0; } +/*
- On ARM platform, MPIDR value is the hardware ID as apic ID
- on Intel platforms
- */
+static int map_gicc_mpidr(struct acpi_subtable_header *entry,
int device_declaration, u32 acpi_id, int *mpidr)
+{
- struct acpi_madt_generic_interrupt *gicc =
container_of(entry, struct acpi_madt_generic_interrupt, header);
- if (!(gicc->flags & ACPI_MADT_ENABLED))
return -ENODEV;
- /* In the GIC interrupt model, logical processors are
* required to have a Processor Device object in the DSDT,
* so we should check device_declaration here
*/
- if (device_declaration && (gicc->uid == acpi_id)) {
/*
* Only bits [0:7] Aff0, bits [8:15] Aff1, bits [16:23] Aff2
* and bits [32:39] Aff3 are meaningful, so pack the Affx
* fields into a single 32 bit identifier to accommodate the
* acpi processor drivers.
*/
*mpidr = ((gicc->arm_mpidr & 0xff00000000) >> 8)
| gicc->arm_mpidr;
The simple fact that you define a function to pack the mpidr value and you can't use it here because this is *generic* code is telling, and a very bad omen. At the cost of sounding like a broken record, I do not like this mpidr->apic->logical_cpu song and dance at all. ACPI is peppered with code (eg hotplug is another example, CPUidle driver even worse) that is supposed to be generic but contains x86 code to carry out this cpuid conversion, I really think that in order to start an ARM64 ACPI port properly we should at least try to factor out this physical to logical cpu id conversion, and it is not the first time that I mention this on the lists.
I know, thanks for pointing this out. As I replied in previous version of this patch set, apic_id is x86/ia64 specific, but the meaning behind it is not. It means the CPU hardware id to identify itself in the system, it just like MPIDR on ARM.
I will send out a patch for RFC to convert apic_id to physid which is generic for all platforms.
I will also talk to Rafael about this at the earliest opportunity, I guess that x86 code relies on apic-id because some ACPI versions could not rely on the acpi-id or some other reasons I have to investigate.
As ACPI spec (section 8.4, Declaring Processors) said, Each processor in the system must be declared in the ACPI namespace, so each cpu will have acpi_id in all ACPI versions, and in theory we can map acpi_id to logical cpu id if we want to.
But things are complicated, apic_id is connected to many tables, MADT for smp init, DSDT for device driver, and SRAT for NUMA (there is no acpi_id in it, ONLY has apic_id in the table for x86/ia64), so if we want to factor the code to map acpi_id to logical cpu id, we need to modify:
- ACPI drivers;
- SMP init for x86 and ia64
- the mappings for NUMA init for x86 and ia64
that will be lots of work I think.
And error prone for that matter.
Thanks for the clarify, I will send out a patch set to convert apic_id to phys_id in ACPI processor driver soon, then we don't need to map acpi_id to logical cpu number.
Thanks Hanjun
Introduce ACPI_IRQ_MODEL_GIC which is needed for ARM64 as GIC is used, and then register device's gsi with the core IRQ subsystem.
acpi_register_gsi() is similar to DT based irq_of_parse_and_map(), since gsi is unique in the system, so use hwirq number directly for the mapping.
Originally-by: Amit Daniel Kachhap amit.daniel@samsung.com Signed-off-by: Hanjun Guo hanjun.guo@linaro.org --- arch/arm64/kernel/acpi.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++ drivers/acpi/bus.c | 3 ++ include/linux/acpi.h | 1 + 3 files changed, 77 insertions(+)
diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c index e91ec76..8526569 100644 --- a/arch/arm64/kernel/acpi.c +++ b/arch/arm64/kernel/acpi.c @@ -37,6 +37,12 @@ EXPORT_SYMBOL(acpi_pci_disabled); static int enabled_cpus; /* Processors (GICC) with enabled flag in MADT */
/* + * Since we're on ARM, the default interrupt routing model + * clearly has to be GIC. + */ +enum acpi_irq_model_id acpi_irq_model = ACPI_IRQ_MODEL_GIC; + +/* * __acpi_map_table() will be called before page_init(), so early_ioremap() * or early_memremap() should be called here to for ACPI table mapping. */ @@ -184,6 +190,73 @@ void __init acpi_smp_init_cpus(void) pr_info("%d CPUs enabled, %d CPUs total\n", enabled_cpus, total_cpus); }
+int acpi_gsi_to_irq(u32 gsi, unsigned int *irq) +{ + *irq = irq_find_mapping(NULL, gsi); + + return 0; +} +EXPORT_SYMBOL_GPL(acpi_gsi_to_irq); + +/* + * success: return IRQ number (>0) + * failure: return =< 0 + */ +int acpi_register_gsi(struct device *dev, u32 gsi, int trigger, int polarity) +{ + unsigned int irq; + unsigned int irq_type; + + /* + * ACPI have no bindings to indicate SPI or PPI, so we + * use different mappings from DT in ACPI. + * + * For FDT + * PPI interrupt: in the range [0, 15]; + * SPI interrupt: in the range [0, 987]; + * + * For ACPI, GSI should be unique so using + * the hwirq directly for the mapping: + * PPI interrupt: in the range [16, 31]; + * SPI interrupt: in the range [32, 1019]; + */ + + if (trigger == ACPI_EDGE_SENSITIVE && + polarity == ACPI_ACTIVE_LOW) + irq_type = IRQ_TYPE_EDGE_FALLING; + else if (trigger == ACPI_EDGE_SENSITIVE && + polarity == ACPI_ACTIVE_HIGH) + irq_type = IRQ_TYPE_EDGE_RISING; + else if (trigger == ACPI_LEVEL_SENSITIVE && + polarity == ACPI_ACTIVE_LOW) + irq_type = IRQ_TYPE_LEVEL_LOW; + else if (trigger == ACPI_LEVEL_SENSITIVE && + polarity == ACPI_ACTIVE_HIGH) + irq_type = IRQ_TYPE_LEVEL_HIGH; + else + irq_type = IRQ_TYPE_NONE; + + /* + * Since only one GIC is supported in ACPI 5.0, we can + * create mapping refer to the default domain + */ + irq = irq_create_mapping(NULL, gsi); + if (!irq) + return irq; + + /* Set irq type if specified and different than the current one */ + if (irq_type != IRQ_TYPE_NONE && + irq_type != irq_get_trigger_type(irq)) + irq_set_irq_type(irq, irq_type); + return irq; +} +EXPORT_SYMBOL_GPL(acpi_register_gsi); + +void acpi_unregister_gsi(u32 gsi) +{ +} +EXPORT_SYMBOL_GPL(acpi_unregister_gsi); + static int __init acpi_parse_fadt(struct acpi_table_header *table) { struct acpi_table_fadt *fadt = (struct acpi_table_fadt *)table; diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index 8581f5b..d132c1b 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c @@ -458,6 +458,9 @@ static int __init acpi_bus_init_irq(void) case ACPI_IRQ_MODEL_IOSAPIC: message = "IOSAPIC"; break; + case ACPI_IRQ_MODEL_GIC: + message = "GIC"; + break; case ACPI_IRQ_MODEL_PLATFORM: message = "platform specific model"; break; diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 36d5012..4615eb1 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -71,6 +71,7 @@ enum acpi_irq_model_id { ACPI_IRQ_MODEL_IOAPIC, ACPI_IRQ_MODEL_IOSAPIC, ACPI_IRQ_MODEL_PLATFORM, + ACPI_IRQ_MODEL_GIC, ACPI_IRQ_MODEL_COUNT };
From: Tomasz Nowicki tomasz.nowicki@linaro.org
ACPI kernel uses MADT table for proper GIC initialization. It needs to parse GIC related subtables, collect CPU interface and distributor addresses and call driver initialization function (which is hardware abstraction agnostic). In a similar way, FDT initialize GICv1/2.
NOTE: This commit allow to initialize GICv1/2 basic functionality. GICv2 vitalization extension, GICv3/4 and ITS are considered as next steps.
Signed-off-by: Tomasz Nowicki tomasz.nowicki@linaro.org Signed-off-by: Hanjun Guo hanjun.guo@linaro.org --- arch/arm64/kernel/acpi.c | 23 ++++++++ drivers/irqchip/irq-gic.c | 106 ++++++++++++++++++++++++++++++++++ drivers/irqchip/irqchip.c | 3 + include/linux/irqchip/arm-gic-acpi.h | 31 ++++++++++ 4 files changed, 163 insertions(+) create mode 100644 include/linux/irqchip/arm-gic-acpi.h
diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c index 8526569..2c8afe8 100644 --- a/arch/arm64/kernel/acpi.c +++ b/arch/arm64/kernel/acpi.c @@ -23,6 +23,7 @@ #include <linux/irqdomain.h> #include <linux/bootmem.h> #include <linux/smp.h> +#include <linux/irqchip/arm-gic-acpi.h>
#include <asm/cputype.h> #include <asm/cpu_ops.h> @@ -315,6 +316,28 @@ void __init acpi_boot_table_init(void) pr_err("Can't find FADT or error happened during parsing FADT\n"); }
+void __init acpi_gic_init(void) +{ + struct acpi_table_header *table; + acpi_status status; + acpi_size tbl_size; + int err; + + status = acpi_get_table_with_size(ACPI_SIG_MADT, 0, &table, &tbl_size); + if (ACPI_FAILURE(status)) { + const char *msg = acpi_format_exception(status); + + pr_err("Failed to get MADT table, %s\n", msg); + return; + } + + err = gic_v2_acpi_init(table); + if (err) + pr_err("Failed to initialize GIC IRQ controller"); + + early_acpi_os_unmap_memory((char *)table, tbl_size); +} + static int __init parse_acpi(char *arg) { if (!arg) diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c index 4b959e6..8aba096 100644 --- a/drivers/irqchip/irq-gic.c +++ b/drivers/irqchip/irq-gic.c @@ -33,12 +33,14 @@ #include <linux/of.h> #include <linux/of_address.h> #include <linux/of_irq.h> +#include <linux/acpi.h> #include <linux/irqdomain.h> #include <linux/interrupt.h> #include <linux/percpu.h> #include <linux/slab.h> #include <linux/irqchip/chained_irq.h> #include <linux/irqchip/arm-gic.h> +#include <linux/irqchip/arm-gic-acpi.h>
#include <asm/cputype.h> #include <asm/irq.h> @@ -1029,3 +1031,107 @@ IRQCHIP_DECLARE(msm_8660_qgic, "qcom,msm-8660-qgic", gic_of_init); IRQCHIP_DECLARE(msm_qgic2, "qcom,msm-qgic2", gic_of_init);
#endif + +#ifdef CONFIG_ACPI +static phys_addr_t dist_phy_base, cpu_phy_base; +static int cpu_base_assigned; + +static int __init +gic_acpi_parse_madt_cpu(struct acpi_subtable_header *header, + const unsigned long end) +{ + struct acpi_madt_generic_interrupt *processor; + phys_addr_t gic_cpu_base; + + processor = (struct acpi_madt_generic_interrupt *)header; + + if (BAD_MADT_ENTRY(processor, end)) + return -EINVAL; + + /* + * There is no support for non-banked GICv1/2 register in ACPI spec. + * All CPU interface addresses have to be the same. + */ + gic_cpu_base = processor->base_address; + if (cpu_base_assigned && gic_cpu_base != cpu_phy_base) + return -EFAULT; + + cpu_phy_base = gic_cpu_base; + cpu_base_assigned = 1; + return 0; +} + +static int __init +gic_acpi_parse_madt_distributor(struct acpi_subtable_header *header, + const unsigned long end) +{ + struct acpi_madt_generic_distributor *dist; + + dist = (struct acpi_madt_generic_distributor *)header; + + if (BAD_MADT_ENTRY(dist, end)) + return -EINVAL; + + dist_phy_base = dist->base_address; + return 0; +} + +int __init +gic_v2_acpi_init(struct acpi_table_header *table) +{ + void __iomem *cpu_base, *dist_base; + int count; + + /* Collect CPU base addresses */ + count = acpi_parse_entries(sizeof(struct acpi_table_madt), + gic_acpi_parse_madt_cpu, table, + ACPI_MADT_TYPE_GENERIC_INTERRUPT, 0); + if (count < 0) { + pr_err("Error during GICC entries parsing\n"); + return -EFAULT; + } else if (!count) { + pr_err("No valid GICC entries exist\n"); + return -EINVAL; + } + + /* + * Find distributor base address. We expect one distributor entry since + * ACPI 5.1 spec neither support multi-GIC instances nor GIC cascade. + */ + count = acpi_parse_entries(sizeof(struct acpi_table_madt), + gic_acpi_parse_madt_distributor, table, + ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR, 0); + if (count <= 0) { + pr_err("Error during GICD entries parsing\n"); + return -EFAULT; + } else if (!count) { + pr_err("No valid GICD entries exist\n"); + return -EINVAL; + } else if (count > 1) { + pr_err("More than one GICD entry detected\n"); + return -EINVAL; + } + + cpu_base = ioremap(cpu_phy_base, ACPI_GIC_CPU_IF_MEM_SIZE); + if (!cpu_base) { + pr_err("Unable to map GICC registers\n"); + return -ENOMEM; + } + + dist_base = ioremap(dist_phy_base, ACPI_GICV2_DIST_MEM_SIZE); + if (!dist_base) { + pr_err("Unable to map GICD registers\n"); + iounmap(cpu_base); + return -ENOMEM; + } + + /* + * Initialize zero GIC instance (no multi-GIC support). Also, set GIC + * as default IRQ domain to allow for GSI registration and GSI to IRQ + * number translation (see acpi_register_gsi() and acpi_gsi_to_irq()). + */ + gic_init_bases(0, -1, dist_base, cpu_base, 0, NULL); + irq_set_default_host(gic_data[0].domain); + return 0; +} +#endif diff --git a/drivers/irqchip/irqchip.c b/drivers/irqchip/irqchip.c index 0fe2f71..9106c6d 100644 --- a/drivers/irqchip/irqchip.c +++ b/drivers/irqchip/irqchip.c @@ -11,6 +11,7 @@ #include <linux/init.h> #include <linux/of_irq.h> #include <linux/irqchip.h> +#include <linux/irqchip/arm-gic-acpi.h>
/* * This special of_device_id is the sentinel at the end of the @@ -26,4 +27,6 @@ extern struct of_device_id __irqchip_of_table[]; void __init irqchip_init(void) { of_irq_init(__irqchip_of_table); + + acpi_gic_init(); } diff --git a/include/linux/irqchip/arm-gic-acpi.h b/include/linux/irqchip/arm-gic-acpi.h new file mode 100644 index 0000000..ad5b577 --- /dev/null +++ b/include/linux/irqchip/arm-gic-acpi.h @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2014, Linaro Ltd. + * Author: Tomasz Nowicki tomasz.nowicki@linaro.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#ifndef ARM_GIC_ACPI_H_ +#define ARM_GIC_ACPI_H_ + +#ifdef CONFIG_ACPI + +/* + * Hard code here, we can not get memory size from MADT (but FDT does), + * Actually no need to do that, because this size can be inferred + * from GIC spec. + */ +#define ACPI_GICV2_DIST_MEM_SIZE (SZ_4K) +#define ACPI_GIC_CPU_IF_MEM_SIZE (SZ_8K) + +struct acpi_table_header; + +void acpi_gic_init(void); +int gic_v2_acpi_init(struct acpi_table_header *table); +#else +static inline void acpi_gic_init(void) { } +#endif + +#endif /* ARM_GIC_ACPI_H_ */
Using the information presented by GTDT to initialize the arch timer (not memory-mapped).
Originally-by: Amit Daniel Kachhap amit.daniel@samsung.com Signed-off-by: Hanjun Guo hanjun.guo@linaro.org --- arch/arm64/kernel/time.c | 7 ++ drivers/clocksource/arm_arch_timer.c | 117 ++++++++++++++++++++++++++++------ include/linux/clocksource.h | 6 ++ 3 files changed, 111 insertions(+), 19 deletions(-)
diff --git a/arch/arm64/kernel/time.c b/arch/arm64/kernel/time.c index 1a7125c..42f9195 100644 --- a/arch/arm64/kernel/time.c +++ b/arch/arm64/kernel/time.c @@ -35,6 +35,7 @@ #include <linux/delay.h> #include <linux/clocksource.h> #include <linux/clk-provider.h> +#include <linux/acpi.h>
#include <clocksource/arm_arch_timer.h>
@@ -72,6 +73,12 @@ void __init time_init(void)
tick_setup_hrtimer_broadcast();
+ /* + * Since ACPI or FDT will only one be available in the system, + * we can use acpi_generic_timer_init() here safely + */ + acpi_generic_timer_init(); + arch_timer_rate = arch_timer_get_rate(); if (!arch_timer_rate) panic("Unable to initialise architected timer.\n"); diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c index 5163ec1..397783f 100644 --- a/drivers/clocksource/arm_arch_timer.c +++ b/drivers/clocksource/arm_arch_timer.c @@ -21,6 +21,7 @@ #include <linux/io.h> #include <linux/slab.h> #include <linux/sched_clock.h> +#include <linux/acpi.h>
#include <asm/arch_timer.h> #include <asm/virt.h> @@ -338,8 +339,12 @@ arch_timer_detect_rate(void __iomem *cntbase, struct device_node *np) if (arch_timer_rate) return;
- /* Try to determine the frequency from the device tree or CNTFRQ */ - if (of_property_read_u32(np, "clock-frequency", &arch_timer_rate)) { + /* + * Try to determine the frequency from the device tree or CNTFRQ, + * if ACPI is enabled, get the frequency from CNTFRQ ONLY. + */ + if (!acpi_disabled || + of_property_read_u32(np, "clock-frequency", &arch_timer_rate)) { if (cntbase) arch_timer_rate = readl_relaxed(cntbase + CNTFRQ); else @@ -635,20 +640,8 @@ static void __init arch_timer_common_init(void) arch_timer_arch_init(); }
-static void __init arch_timer_init(struct device_node *np) +static void __init arch_timer_init(void) { - int i; - - if (arch_timers_present & ARCH_CP15_TIMER) { - pr_warn("arch_timer: multiple nodes in dt, skipping\n"); - return; - } - - arch_timers_present |= ARCH_CP15_TIMER; - for (i = PHYS_SECURE_PPI; i < MAX_TIMER_PPI; i++) - arch_timer_ppi[i] = irq_of_parse_and_map(np, i); - arch_timer_detect_rate(NULL, np); - /* * If HYP mode is available, we know that the physical timer * has been configured to be accessible from PL1. Use it, so @@ -667,13 +660,31 @@ static void __init arch_timer_init(struct device_node *np) } }
- arch_timer_c3stop = !of_property_read_bool(np, "always-on"); - arch_timer_register(); arch_timer_common_init(); } -CLOCKSOURCE_OF_DECLARE(armv7_arch_timer, "arm,armv7-timer", arch_timer_init); -CLOCKSOURCE_OF_DECLARE(armv8_arch_timer, "arm,armv8-timer", arch_timer_init); + +static void __init arch_timer_of_init(struct device_node *np) +{ + int i; + + if (arch_timers_present & ARCH_CP15_TIMER) { + pr_warn("arch_timer: multiple nodes in dt, skipping\n"); + return; + } + + arch_timers_present |= ARCH_CP15_TIMER; + for (i = PHYS_SECURE_PPI; i < MAX_TIMER_PPI; i++) + arch_timer_ppi[i] = irq_of_parse_and_map(np, i); + + arch_timer_detect_rate(NULL, np); + + arch_timer_c3stop = !of_property_read_bool(np, "always-on"); + + arch_timer_init(); +} +CLOCKSOURCE_OF_DECLARE(armv7_arch_timer, "arm,armv7-timer", arch_timer_of_init); +CLOCKSOURCE_OF_DECLARE(armv8_arch_timer, "arm,armv8-timer", arch_timer_of_init);
static void __init arch_timer_mem_init(struct device_node *np) { @@ -740,3 +751,71 @@ static void __init arch_timer_mem_init(struct device_node *np) } CLOCKSOURCE_OF_DECLARE(armv7_arch_timer_mem, "arm,armv7-timer-mem", arch_timer_mem_init); + +#ifdef CONFIG_ACPI +static int __init +map_generic_timer_interrupt(u32 interrupt, u32 flags) +{ + int trigger, polarity; + + if (!interrupt) + return 0; + + trigger = (flags & ACPI_GTDT_INTERRUPT_MODE) ? ACPI_EDGE_SENSITIVE + : ACPI_LEVEL_SENSITIVE; + + polarity = (flags & ACPI_GTDT_INTERRUPT_POLARITY) ? ACPI_ACTIVE_LOW + : ACPI_ACTIVE_HIGH; + + return acpi_register_gsi(NULL, interrupt, trigger, polarity); +} + +/* Initialize per-processor generic timer */ +static int __init arch_timer_acpi_init(struct acpi_table_header *table) +{ + struct acpi_table_gtdt *gtdt; + + if (arch_timers_present & ARCH_CP15_TIMER) { + pr_warn("arch_timer: already initialized, skipping\n"); + return -EINVAL; + } + + gtdt = container_of(table, struct acpi_table_gtdt, header); + + arch_timers_present |= ARCH_CP15_TIMER; + + arch_timer_ppi[PHYS_SECURE_PPI] = + map_generic_timer_interrupt(gtdt->secure_el1_interrupt, + gtdt->secure_el1_flags); + + arch_timer_ppi[PHYS_NONSECURE_PPI] = + map_generic_timer_interrupt(gtdt->non_secure_el1_interrupt, + gtdt->non_secure_el1_flags); + + arch_timer_ppi[VIRT_PPI] = + map_generic_timer_interrupt(gtdt->virtual_timer_interrupt, + gtdt->virtual_timer_flags); + + arch_timer_ppi[HYP_PPI] = + map_generic_timer_interrupt(gtdt->non_secure_el2_interrupt, + gtdt->non_secure_el2_flags); + + /* Get the frequency from CNTFRQ */ + arch_timer_detect_rate(NULL, NULL); + + /* Always-on capability */ + arch_timer_c3stop = !(gtdt->non_secure_el1_flags & ACPI_GTDT_ALWAYS_ON); + + arch_timer_init(); + return 0; +} + +/* Initialize all the generic timers presented in GTDT */ +void __init acpi_generic_timer_init(void) +{ + if (acpi_disabled) + return; + + acpi_table_parse(ACPI_SIG_GTDT, arch_timer_acpi_init); +} +#endif diff --git a/include/linux/clocksource.h b/include/linux/clocksource.h index 653f0e2..5839f98 100644 --- a/include/linux/clocksource.h +++ b/include/linux/clocksource.h @@ -346,4 +346,10 @@ extern void clocksource_of_init(void); static inline void clocksource_of_init(void) {} #endif
+#ifdef CONFIG_ACPI +void acpi_generic_timer_init(void); +#else +static inline void acpi_generic_timer_init(void) {} +#endif + #endif /* _LINUX_CLOCKSOURCE_H */
From: Al Stone al.stone@linaro.org
ACPI reduced hardware mode is disabled by default, but ARM64 can only run properly in ACPI hardware reduced mode, so select ACPI_REDUCED_HARDWARE_ONLY if ACPI is enabled on ARM64.
Reviewed-by: Grant Likely grant.likely@linaro.org Signed-off-by: Al Stone al.stone@linaro.org Signed-off-by: Hanjun Guo hanjun.guo@linaro.org --- arch/arm64/Kconfig | 1 + 1 file changed, 1 insertion(+)
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index fd4e81a..065438c 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -1,5 +1,6 @@ config ARM64 def_bool y + select ACPI_REDUCED_HARDWARE_ONLY if ACPI select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE select ARCH_HAS_SG_CHAIN select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
From: Graeme Gregory graeme.gregory@linaro.org
Add Kconfigs to build ACPI on ARM64, and make ACPI available on ARM64.
acpi_idle driver is x86/IA64 dependent now, so make CONFIG_ACPI_PROCESSOR depend on X86 || IA64, and implement it on ARM64 in the future.
Reviewed-by: Grant Likely grant.likely@linaro.org Signed-off-by: Graeme Gregory graeme.gregory@linaro.org Signed-off-by: Al Stone al.stone@linaro.org Signed-off-by: Hanjun Guo hanjun.guo@linaro.org --- arch/arm64/Kconfig | 2 ++ drivers/acpi/Kconfig | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 065438c..8dabaeb 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -422,6 +422,8 @@ source "drivers/Kconfig"
source "drivers/firmware/Kconfig"
+source "drivers/acpi/Kconfig" + source "fs/Kconfig"
source "arch/arm64/kvm/Kconfig" diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index d0f3265..f935d2e 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig @@ -5,8 +5,7 @@ menuconfig ACPI bool "ACPI (Advanced Configuration and Power Interface) Support" depends on !IA64_HP_SIM - depends on IA64 || X86 - depends on PCI + depends on ((IA64 || X86) && PCI) || (ARM64 && EXPERT) select PNP default y help @@ -163,6 +162,7 @@ config ACPI_PROCESSOR tristate "Processor" select THERMAL select CPU_IDLE + depends on X86 || IA64 default y help This driver installs ACPI as the idle handler for Linux and uses @@ -263,7 +263,7 @@ config ACPI_DEBUG
config ACPI_PCI_SLOT bool "PCI slot detection driver" - depends on SYSFS + depends on SYSFS && PCI default n help This driver creates entries in /sys/bus/pci/slots/ for all PCI
From: Graeme Gregory graeme.gregory@linaro.org
Add documentation for the guidelines of how to use ACPI on ARM64.
Signed-off-by: Graeme Gregory graeme.gregory@linaro.org Signed-off-by: Al Stone al.stone@linaro.org Signed-off-by: Hanjun Guo hanjun.guo@linaro.org --- Documentation/arm64/arm-acpi.txt | 323 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 323 insertions(+) create mode 100644 Documentation/arm64/arm-acpi.txt
diff --git a/Documentation/arm64/arm-acpi.txt b/Documentation/arm64/arm-acpi.txt new file mode 100644 index 0000000..17cf96d --- /dev/null +++ b/Documentation/arm64/arm-acpi.txt @@ -0,0 +1,323 @@ +ACPI on ARMv8 Servers +--------------------- +ACPI can be used for ARMv8 general purpose servers designed to follow +the ARM SBSA (Server Base System Architecture) specification, currently +available to those with an ARM login at http://silver.arm.com. + +The ARMv8 kernel implements the reduced hardware model of ACPI version +5.1 and its corresponding errata. Links to the specification and all +external documents it refers to are managed by the UEFI Forum. The +specification is available at http://www.uefi.org/specifications and +external documents can be found via http://www.uefi.org/acpi. + +If an ARMv8 system does not meet the requirements of the SBSA, or cannot +be described using the mechanisms defined in the required ACPI specifications, +then it is likely that Device Tree (DT) is more suitable than ACPI for the +hardware. + + +Relationship with Device Tree +----------------------------- +ACPI support in drivers and subsystems for ARMv8 should never be mutually +exclusive with DT support at compile time. + +At boot time the kernel will only use one description method depending on +parameters passed from the bootloader (including kernel bootargs). + +Regardless of whether DT or ACPI is used, the kernel must always be capable +of booting with either scheme (in kernels with both schemes enabled at compile +time). + +When booting using ACPI tables, the /chosen node in DT will still be parsed +to extract the kernel command line and initrd path. No other section of the +DT will be used. + + +Booting using ACPI tables +------------------------- +The only defined method for passing ACPI tables to the kernel on ARMv8 +is via the UEFI system configuration table. + +Processing of ACPI tables may be disabled by passing acpi=off on the kernel +command line; this is the default behavior. If acpi=force is used, the kernel +will ONLY use device configuration information contained in the ACPI tables. + +In order for the kernel to load and use ACPI tables, the UEFI implementation +MUST set the ACPI_20_TABLE_GUID to point to the RSDP table (the table with +the ACPI signature "RSD PTR "). If this pointer is incorrect and acpi=force +is used, the kernel will disable ACPI and try to use DT to boot. + +If the pointer to the RSDP table is correct, the table will be mapped into +the kernel by the ACPI core, using the address provided by UEFI. + +The ACPI core will then locate and map in all other ACPI tables provided by +using the addresses in the RSDP table to find the XSDT (eXtended System +Description Table). The XSDT in turn provides the addresses to all other +ACPI tables provided by the system firmware; the ACPI core will then traverse +this table and map in the tables listed. + +The ACPI core will ignore any provided RSDT (Root System Description Table). +RSDTs have been deprecated and are ignored on arm64 since they only allow +for 32-bit addresses. + +Further, the ACPI core will only use the 64-bit address fields in the FADT +(Fixed ACPI Description Table). Any 32-bit address fields in the FADT will +be ignored on arm64. + +Hardware reduced mode (see Section 4.1 of the ACPI 5.1 specification) will +be enforced by the ACPI core on arm64. Doing so allows the ACPI core to +run less complex code since it no longer has to provide support for legacy +hardware from other architectures. + +For the ACPI core to operate properly, and in turn provide the information +the kernel needs to configure devices, it expects to find the following +tables (all section numbers refer to the ACPI 5.1 specfication): + + -- RSDP (Root System Description Pointer), section 5.2.5 + + -- XSDT (eXtended System Description Table), section 5.2.8 + + -- FACS (Firmware ACPI Control Structure), section 5.2.10 + + -- FADT (Fixed ACPI Description Table), section 5.2.9 + + -- DSDT (Differentiated System Description Table), section + 5.2.11.1 + + -- MADT (Multiple APIC Description Table), section 5.2.12 + + -- GTDT (Generic Timer Description Table), section 5.2.24 + + -- If PCI is supported, the MCFG (Memory mapped ConFiGuration + Table), section 5.2.6, specifically Table 5-31. + +If the above tables are not all present, the kernel may or may not be +able to boot properly since it may not be able to configure all of the +devices available. + + +ACPI Detection +-------------- +Drivers should determine their probe() type by checking for a null +value for ACPI_HANDLE, or checking .of_node, or other information in +the device structure. This is detailed further in the "Driver +Recommendations" section. + +In non-driver code, if the presence of ACPI needs to be detected at +runtime, then check the value of acpi_disabled. If CONFIG_ACPI is not +set, acpi_disabled will always be 1. + + +Device Enumeration +------------------ +Device descriptions in ACPI should use standard recognized ACPI interfaces. +These can contain less information than is typically provided via a Device +Tree description for the same device. This is also one of the reasons that +ACPI can be useful -- the driver takes into account that it may have less +detailed information about the device and uses sensible defaults instead. +If done properly in the driver, the hardware can change and improve over +time without the driver having to change at all. + +Clocks provide an excellent example. In DT, clocks need to be specified +and the drivers need to take them into account. In ACPI, the assumption +is that UEFI will leave the device in a reasonable default state, including +any clock settings. If for some reason the driver needs to change a clock +value, this can be done in an ACPI method; all the driver needs to do is +invoke the method and not concern itself with what the method needs to do +to change the clock. Changing the hardware can then take place over time +by changing what the ACPI method does, and not the driver. + +ACPI drivers should only look at one specific ASL object -- the _DSD object +-- for device driver parameters (known in DT as "bindings", or "Device +Properties" in ACPI). Not all DT bindings will be recognized. The UEFI +Forum provides a mechanism for registering such bindings [URL TBD by ASWG] +so that they may be used on any operating system supporting ACPI. Device +properties that have not been registered with the UEFI Forum should not be +used. + +Drivers should look for device properties in the _DSD object ONLY; the _DSD +object is described in the ACPI specification section 6.2.5, but more +specifically, use the _DSD Device Properties UUID: + + -- UUID: daffd814-6eba-4d8c-8a91-bc9bbf4aa301 + + -- http://www.uefi.org/sites/default/files/resources/_DSD-device-properties-UUI...) + +The kernel has an interface for looking up device properties in a manner +independent of whether DT or ACPI is being used and that interface should +be used; it can eliminate some duplication of code paths in driver probing +functions and discourage divergence between DT bindings and ACPI device +properties. + +ACPI tables are described with a formal language called ASL, the ACPI +Source Language (section 19 of the specification). This means that there +are always multiple ways to describe the same thing -- including device +properties. For example, device properties could use an ASL construct +that looks like this: Name(KEY0, "value0"). An ACPI device driver would +then retrieve the value of the property by evaluating the KEY0 object. +However, using Name() this way has multiple problems: (1) ACPI limits +names ("KEY0") to four characters unlike DT; (2) there is no industry +wide registry that maintains a list of names, minimzing re-use; (3) +there is also no registry for the definition of property values ("value0"), +again making re-use difficult; and (4) how does one maintain backward +compatibility as new hardware comes out? The _DSD method was created +to solve precisely these sorts of problems; Linux drivers should ALWAYS +use the _DSD method for device properties and nothing else. + +The _DSM object (ACPI Section 9.14.1) could also be used for conveying +device properties to a driver. Linux drivers should only expect it to +be used if _DSD cannot represent the data required, and there is no way +to create a new UUID for the _DSD object. Note that there is even less +regulation of the use of _DSM than there is of _DSD. Drivers that depend +on the contents of _DSM objects will be more difficult to maintain over +time because of this. + +The _DSD object is a very flexible mechanism in ACPI, as are the registered +Device Properties. This flexibility allows _DSD to cover more than just the +generic server case and care should be taken in device drivers not to expect +it to replicate highly specific embedded behaviour from DT. + +Both DT bindings and ACPI device properties for device drivers have review +processes. Use them. And, before creating new device properties, check to +be sure that they have not been defined before and either registered in the +Linux kernel documentation or the UEFI Forum. If the device drivers supports +ACPI and DT, please make sure the device properties are consistent in both +places. + + +Programmable Power Control Resources +------------------------------------ +Programmable power control resources include such resources as voltage/current +providers (regulators) and clock sources. + +The kernel assumes that power control of these resources is represented with +Power Resource Objects (ACPI section 7.1). The ACPI core will then handle +correctly enabling and disabling resources as they are needed. In order to +get that to work, ACPI assumes each device has defined D-states and that these +can be controlled through the optional ACPI methods _PS0, _PS1, _PS2, and _PS3; +in ACPI, _PS0 is the method to invoke to turn a device full on, and _PS3 is for +turning a device full off. + +The kernel ACPI code will also assume that the _PS? methods follow the normal +ACPI rules for such methods: + + -- If either _PS0 or _PS3 is implemented, then the other method must also + be implemented. + + -- If a device requires usage or setup of a power resource when on, the ASL + should organize that it is allocated/enabled using the _PS0 method. + + -- Resources allocated or enabled in the _PS0 method should be disabled + or de-allocated in the _PS3 method. + + -- Firmware will leave the resources in a reasonable state before handing + over control to the kernel. + +Such code in _PS? methods will of course be very platform specific. But, +this allows the driver to abstract out the interface for operating the device +and avoid having to read special non-standard values from ACPI tables. Further, +abstracting the use of these resources allows the hardware to change over time +without requiring updates to the driver. + + +Clocks +------ +ACPI makes the assumption that clocks are initialized by the firmware -- +UEFI, in this case -- to some working value before control is handed over +to the kernel. This has implications for devices such as UARTs, or SoC +driven LCD displays, for example. + +When the kernel boots, the clock is assumed to be set to reasonable +working value. If for some reason the frequency needs to change -- e.g., +throttling for power management -- the device driver should expect that +process to be abstracted out into some ACPI method that can be invoked +(please see the ACPI specification for further recommendations on standard +methods to be expected). If is not, there is no direct way for ACPI to +control the clocks. + + +Driver Recommendations +---------------------- +DO NOT remove any DT handling when adding ACPI support for a driver. The +same device may be used on many different systems. + +DO try to structure the driver so that it is data driven. That is, set up +a struct containing internal per-device state based on defaults and whatever +else must be discovered by the driver probe function. Then, have the rest +of the driver operate off of the contents of that struct. Doing so should +allow most divergence between ACPI and DT functionality to be kept local to +the probe function instead of being scattered throughout the driver. For +example: + +static int device_probe_dt(struct platform_device *pdev) +{ + /* DT specific functionality */ + ... +} + +static int device_probe_acpi(struct platform_device *pdev) +{ + /* ACPI specific functionality */ + ... +} + +static int device_probe(stuct platform_device *pdev) +{ + ... + struct device_node node = pdev->dev.of_node; + ... + + if (node) + ret = device_probe_dt(pdev); + else if (ACPI_HANDLE(&pdev->dev)) + ret = device_probe_acpi(pdev); + else + /* other initialization */ + ... + /* Continue with any generic probe operations */ + ... +} + +DO keep the MODULE_DEVICE_TABLE entries together in the driver to make it +clear the different names the driver is probed for, both from DT and from +ACPI: + +static struct of_device_id virtio_mmio_match[] = { + { .compatible = "virtio,mmio", }, + { } +}; +MODULE_DEVICE_TABLE(of, virtio_mmio_match); + +static const struct acpi_device_id virtio_mmio_acpi_match[] = { + { "LNRO0005", }, + { } +}; +MODULE_DEVICE_TABLE(acpi, virtio_mmio_acpi_match); + + +ASWG +---- +The following areas are not yet fully defined for ARM in the 5.1 version +of the ACPI specification and are expected to be worked through in the +UEFI ACPI Specification Working Group (ASWG): + + -- ACPI based CPU topology + -- ACPI based Power management + -- CPU idle control based on PSCI + -- CPU performance control (CPPC) + -- ACPI based SMMU + -- ITS support for GIC in MADT + +Participation in this group is open to all UEFI members. Please see +http://www.uefi.org/workinggroup for details on group membership. + +It is the intent of the ARMv8 ACPI kernel code to follow the ACPI specification +as closely as possible, and to only implement functionality that complies with +the released standards from UEFI ASWG. As a practical matter, there will be +vendors that provide bad ACPI tables or violate the standards in some way. +If this is because of errors, quirks and fixups may be necessary, but will +be avoided if possible. If there are features missing from ACPI that preclude +it from being used on a platform, ECRs (Engineering Change Requests) should be +submitted to ASWG and go through the normal approval process; for those that +are not UEFI members, many other members of the Linux community are and would +likely be willing to assist in submitting ECRs.
On 10/17/2014 8:37 AM, Hanjun Guo wrote:
From: Graeme Gregory graeme.gregory@linaro.org
Add documentation for the guidelines of how to use ACPI on ARM64.
Signed-off-by: Graeme Gregory graeme.gregory@linaro.org Signed-off-by: Al Stone al.stone@linaro.org Signed-off-by: Hanjun Guo hanjun.guo@linaro.org
Documentation/arm64/arm-acpi.txt | 323 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 323 insertions(+) create mode 100644 Documentation/arm64/arm-acpi.txt [...]
AMD has reviewed this document, and currently implements ACPI table in the firmware for AMD Seattle platform based on the documentation published here:
http://amd-dev.wpengine.netdna-cdn.com/wordpress/media/2012/10/Seattle_ACPI_...
Reviewed-by: Suravee Suthikulpanit Suravee.Suthikulpanit@amd.com
Thank you,
Suravee
On 2014年12月19日 04:01, Suravee Suthikulanit wrote:
On 10/17/2014 8:37 AM, Hanjun Guo wrote:
From: Graeme Gregory graeme.gregory@linaro.org
Add documentation for the guidelines of how to use ACPI on ARM64.
Signed-off-by: Graeme Gregory graeme.gregory@linaro.org Signed-off-by: Al Stone al.stone@linaro.org Signed-off-by: Hanjun Guo hanjun.guo@linaro.org
Documentation/arm64/arm-acpi.txt | 323 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 323 insertions(+) create mode 100644 Documentation/arm64/arm-acpi.txt [...]
AMD has reviewed this document, and currently implements ACPI table in the firmware for AMD Seattle platform based on the documentation published here:
http://amd-dev.wpengine.netdna-cdn.com/wordpress/media/2012/10/Seattle_ACPI_...
Reviewed-by: Suravee Suthikulpanit Suravee.Suthikulpanit@amd.com
Thank you very much, Suravee.
Hanjun
On Fri, Oct 17, 2014 at 8:37 AM, Hanjun Guo hanjun.guo@linaro.org wrote:
If acpi=force is used, the kernel +will ONLY use device configuration information contained in the ACPI tables.
Based on this statement, ...
+In order for the kernel to load and use ACPI tables, the UEFI implementation +MUST set the ACPI_20_TABLE_GUID to point to the RSDP table (the table with +the ACPI signature "RSD PTR "). If this pointer is incorrect and acpi=force +is used, the kernel will disable ACPI and try to use DT to boot.
wouldn't it be more correct to say "If this pointer is incorrect OR acpi=force is used"?
+Forum provides a mechanism for registering such bindings [URL TBD by ASWG]
Did you intend to replace the text in []?
+so that they may be used on any operating system supporting ACPI. Device +properties that have not been registered with the UEFI Forum should not be +used.
Blech. I guess it's necessary, but the information needs to be documented here.
+Drivers should look for device properties in the _DSD object ONLY; the _DSD +object is described in the ACPI specification section 6.2.5, but more +specifically, use the _DSD Device Properties UUID:
- -- UUID: daffd814-6eba-4d8c-8a91-bc9bbf4aa301
- -- http://www.uefi.org/sites/default/files/resources/_DSD-device-properties-UUI...)
Extra ) here.
+The kernel has an interface for looking up device properties in a manner +independent of whether DT or ACPI is being used and that interface should +be used; it can eliminate some duplication of code paths in driver probing +functions and discourage divergence between DT bindings and ACPI device +properties.
How about a pointer to the documentation for this method?
+Such code in _PS? methods will of course be very platform specific. But,
I would use _PSx instead of _PS? here.
+this allows the driver to abstract out the interface for operating the device +and avoid having to read special non-standard values from ACPI tables. Further, +abstracting the use of these resources allows the hardware to change over time +without requiring updates to the driver.
+Clocks +------ +ACPI makes the assumption that clocks are initialized by the firmware -- +UEFI, in this case -- to some working value before control is handed over +to the kernel. This has implications for devices such as UARTs, or SoC +driven LCD displays, for example.
SOC-driven should be hyphenated.
+When the kernel boots, the clock is assumed to be set to reasonable
to A reasonable
+working value. If for some reason the frequency needs to change -- e.g., +throttling for power management -- the device driver should expect that +process to be abstracted out into some ACPI method that can be invoked +(please see the ACPI specification for further recommendations on standard +methods to be expected). If is not, there is no direct way for ACPI to
If IT is not
+control the clocks.
+Driver Recommendations +---------------------- +DO NOT remove any DT handling when adding ACPI support for a driver. The +same device may be used on many different systems.
+DO try to structure the driver so that it is data driven. That is, set up
data-driven
Hi Timur,
On 2014年12月19日 04:04, Timur Tabi wrote:
On Fri, Oct 17, 2014 at 8:37 AM, Hanjun Guo hanjun.guo@linaro.org wrote:
If acpi=force is used, the kernel +will ONLY use device configuration information contained in the ACPI tables.
Based on this statement, ...
+In order for the kernel to load and use ACPI tables, the UEFI implementation +MUST set the ACPI_20_TABLE_GUID to point to the RSDP table (the table with +the ACPI signature "RSD PTR "). If this pointer is incorrect and acpi=force +is used, the kernel will disable ACPI and try to use DT to boot.
wouldn't it be more correct to say "If this pointer is incorrect OR acpi=force is used"?
Good catch, some inconsistency here. Actually it means if the pointer to RSDP is incorrect, the ACPI code will catch that error, then ACPI will be disabled and tries to boot with DT even if acpi=force is passed, I think that makes sense.
I will fix the inconsistency anyway in next version.
+Forum provides a mechanism for registering such bindings [URL TBD by ASWG]
Did you intend to replace the text in []?
Yes, it is TBD by ASWG, and we already agreed that the bindings will be reviewed by ASWG which proposed by Al. the URL will be ready when next version of ACPI spec is released.
+so that they may be used on any operating system supporting ACPI. Device +properties that have not been registered with the UEFI Forum should not be +used.
Blech. I guess it's necessary, but the information needs to be documented here.
+Drivers should look for device properties in the _DSD object ONLY; the _DSD +object is described in the ACPI specification section 6.2.5, but more +specifically, use the _DSD Device Properties UUID:
- -- UUID: daffd814-6eba-4d8c-8a91-bc9bbf4aa301
- -- http://www.uefi.org/sites/default/files/resources/_DSD-device-properties-UUI...)
Extra ) here.
Good catch :)
+The kernel has an interface for looking up device properties in a manner +independent of whether DT or ACPI is being used and that interface should +be used; it can eliminate some duplication of code paths in driver probing +functions and discourage divergence between DT bindings and ACPI device +properties.
How about a pointer to the documentation for this method?
This is a patch set posted by Rafael and goes into 3.19: https://lkml.org/lkml/2014/10/21/762
No documentation as far as I know.
+Such code in _PS? methods will of course be very platform specific. But,
I would use _PSx instead of _PS? here.
I will update it.
+this allows the driver to abstract out the interface for operating the device +and avoid having to read special non-standard values from ACPI tables. Further, +abstracting the use of these resources allows the hardware to change over time +without requiring updates to the driver.
+Clocks +------ +ACPI makes the assumption that clocks are initialized by the firmware -- +UEFI, in this case -- to some working value before control is handed over +to the kernel. This has implications for devices such as UARTs, or SoC +driven LCD displays, for example.
SOC-driven should be hyphenated.
+When the kernel boots, the clock is assumed to be set to reasonable
to A reasonable
+working value. If for some reason the frequency needs to change -- e.g., +throttling for power management -- the device driver should expect that +process to be abstracted out into some ACPI method that can be invoked +(please see the ACPI specification for further recommendations on standard +methods to be expected). If is not, there is no direct way for ACPI to
If IT is not
+control the clocks.
+Driver Recommendations +---------------------- +DO NOT remove any DT handling when adding ACPI support for a driver. The +same device may be used on many different systems.
+DO try to structure the driver so that it is data driven. That is, set up
data-driven
I will update them.
Thanks a lot for your review!
Hanjun
Hi,
Some thoughts before the end of the year. I won't be able to follow up until around 5th of January though.
On Fri, Oct 17, 2014 at 02:37:14PM +0100, Hanjun Guo wrote:
--- /dev/null +++ b/Documentation/arm64/arm-acpi.txt @@ -0,0 +1,323 @@ +ACPI on ARMv8 Servers +--------------------- +ACPI can be used for ARMv8 general purpose servers designed to follow +the ARM SBSA (Server Base System Architecture) specification, currently +available to those with an ARM login at http://silver.arm.com.
You should mention SBBR (Server Base Boot Requirements) here as well. The arm-acpi.txt is complementary to arm-acpi.txt and longer term we should aim to move parts of the Linux document into the more OS-agonstic SBBR.
+The ARMv8 kernel implements the reduced hardware model of ACPI version +5.1 and its corresponding errata.
I would say 5.1 or later to avoid updating this document every time we get a new ACPI release.
+If an ARMv8 system does not meet the requirements of the SBSA, or cannot +be described using the mechanisms defined in the required ACPI specifications, +then it is likely that Device Tree (DT) is more suitable than ACPI for the +hardware.
Based on some private discussions, I think we could drop some of the references to DT in this document. It should specify the requirements for ACPI support and, if not met, the alternative SoC support is automatically DT for Linux. That's just to make it easier to move parts of this doc into SBBR.
+Relationship with Device Tree +-----------------------------
This section is fine, Linux specific and it will stay in this document.
+ACPI support in drivers and subsystems for ARMv8 should never be mutually +exclusive with DT support at compile time.
+At boot time the kernel will only use one description method depending on +parameters passed from the bootloader (including kernel bootargs).
+Regardless of whether DT or ACPI is used, the kernel must always be capable +of booting with either scheme (in kernels with both schemes enabled at compile +time).
+When booting using ACPI tables, the /chosen node in DT will still be parsed +to extract the kernel command line and initrd path. No other section of the +DT will be used.
I don't think this paragraph is needed. That's a kernel detail when how the EFI_STUB passes the information to the rest of the kernel. We mandate UEFI booting for ACPI support, so I wouldn't expect an ACPI-aware U-Boot.
+Booting using ACPI tables +------------------------- +The only defined method for passing ACPI tables to the kernel on ARMv8 +is via the UEFI system configuration table.
+Processing of ACPI tables may be disabled by passing acpi=off on the kernel +command line; this is the default behavior. If acpi=force is used, the kernel +will ONLY use device configuration information contained in the ACPI tables.
See my comments to Al around the defaults. I think if only ACPI tables are present, we shouldn't panic the kernel if acpi=force is missing but continue with ACPI. If both DT and ACPI tables are present, DT will be the default. You could say "this is the default behaviour if both ACPI and DT tables are present".
+Device Enumeration +------------------ +Device descriptions in ACPI should use standard recognized ACPI interfaces. +These can contain less information than is typically provided via a Device
s/can/may/ ? Not sure, it just sounds better to me (not a native English speaker).
+Tree description for the same device. This is also one of the reasons that +ACPI can be useful -- the driver takes into account that it may have less +detailed information about the device and uses sensible defaults instead. +If done properly in the driver, the hardware can change and improve over +time without the driver having to change at all.
+Clocks provide an excellent example. In DT, clocks need to be specified +and the drivers need to take them into account. In ACPI, the assumption +is that UEFI will leave the device in a reasonable default state, including +any clock settings. If for some reason the driver needs to change a clock +value, this can be done in an ACPI method; all the driver needs to do is +invoke the method and not concern itself with what the method needs to do +to change the clock. Changing the hardware can then take place over time +by changing what the ACPI method does, and not the driver.
+ACPI drivers should only look at one specific ASL object -- the _DSD object +-- for device driver parameters (known in DT as "bindings", or "Device +Properties" in ACPI). Not all DT bindings will be recognized.
This last sentence kind of implies that many of the DT bindings will be recognised. While it is useful to have some commonalities, I think this gives the wrong message that _DSD is a copy of DT. We should avoid this.
The UEFI +Forum provides a mechanism for registering such bindings [URL TBD by ASWG]
s/bindings/properties/ if we talk in the ACPI context.
+so that they may be used on any operating system supporting ACPI. Device +properties that have not been registered with the UEFI Forum should not be +used.
More about this further down.
+Drivers should look for device properties in the _DSD object ONLY; the _DSD +object is described in the ACPI specification section 6.2.5, but more +specifically, use the _DSD Device Properties UUID:
- -- UUID: daffd814-6eba-4d8c-8a91-bc9bbf4aa301
- -- http://www.uefi.org/sites/default/files/resources/_DSD-device-properties-UUI...)
+The kernel has an interface for looking up device properties in a manner +independent of whether DT or ACPI is being used and that interface should +be used;
I haven't followed the _DSD kernel support but does it provide a common API to be shared with DT? I'm not entirely convinced it's a good idea.
it can eliminate some duplication of code paths in driver probing +functions and discourage divergence between DT bindings and ACPI device +properties.
Given the current different mechanism of reviewing/approving bindings between DT and ACPI (kernel community vs UEFI forum), I don't see how we encourage convergence (unless we state that _DSD are Linux-only, Windows should use a different mechanism like .inf files).
+ACPI tables are described with a formal language called ASL, the ACPI +Source Language (section 19 of the specification). This means that there +are always multiple ways to describe the same thing -- including device +properties. For example, device properties could use an ASL construct +that looks like this: Name(KEY0, "value0"). An ACPI device driver would +then retrieve the value of the property by evaluating the KEY0 object. +However, using Name() this way has multiple problems: (1) ACPI limits +names ("KEY0") to four characters unlike DT; (2) there is no industry +wide registry that maintains a list of names, minimzing re-use; (3) +there is also no registry for the definition of property values ("value0"), +again making re-use difficult; and (4) how does one maintain backward +compatibility as new hardware comes out? The _DSD method was created +to solve precisely these sorts of problems; Linux drivers should ALWAYS +use the _DSD method for device properties and nothing else.
+The _DSM object (ACPI Section 9.14.1) could also be used for conveying +device properties to a driver. Linux drivers should only expect it to +be used if _DSD cannot represent the data required, and there is no way +to create a new UUID for the _DSD object. Note that there is even less +regulation of the use of _DSM than there is of _DSD. Drivers that depend +on the contents of _DSM objects will be more difficult to maintain over +time because of this.
+The _DSD object is a very flexible mechanism in ACPI, as are the registered +Device Properties. This flexibility allows _DSD to cover more than just the +generic server case and care should be taken in device drivers not to expect +it to replicate highly specific embedded behaviour from DT.
While this is all good, we need to be more specific on what "embedded behaviour" means. Maybe not for this document but the UEFI approval process for new properties doesn't give any hint on what is and is not sane (and I already disagree with some of the examples on uefi.org).
+Both DT bindings and ACPI device properties for device drivers have review +processes. Use them. And, before creating new device properties, check to +be sure that they have not been defined before and either registered in the +Linux kernel documentation or the UEFI Forum. If the device drivers supports +ACPI and DT, please make sure the device properties are consistent in both +places.
In the interest of progress, I think we need to *temporarily* ban the use of _DSD on ARM platforms aimed at ACPI and state it clearly in this document. Once we are happy with the UEFI forum review process, we'll adjust the document accordingly.
My problems with _DSD:
a) no clear guidance on what a good property means, whether it covers just device specific information or it may include Linux behaviour (like "linux,default-trigger", I don't think it should) b) the Linux kernel community does not seem to be involved in the UEFI forum _DSD review process. This means that we'll be faced with patches against drivers to support UEFI-published _DSD properties. I want to avoid such arguments, rejecting kernel code is too late after _DSD properties have been published
The alternative to _DSD would be to program the hardware to some sane state. For example, I'm sure a MAC address can be written by firmware to some register and the driver can read and store it locally (I'm not even sure why we need MAC address in ACPI tables, this is not really a property of the hardware but a configuration that could be done in firmware).
+Clocks +------ +ACPI makes the assumption that clocks are initialized by the firmware -- +UEFI, in this case -- to some working value before control is handed over +to the kernel. This has implications for devices such as UARTs, or SoC +driven LCD displays, for example.
+When the kernel boots, the clock is assumed to be set to reasonable +working value. If for some reason the frequency needs to change -- e.g., +throttling for power management -- the device driver should expect that +process to be abstracted out into some ACPI method that can be invoked +(please see the ACPI specification for further recommendations on standard +methods to be expected). If is not, there is no direct way for ACPI to +control the clocks.
I would emphasize that there is no way for _Linux_ to directly control the clocks on an ACPI-enabled platform.
+ASWG +---- +The following areas are not yet fully defined for ARM in the 5.1 version +of the ACPI specification and are expected to be worked through in the +UEFI ACPI Specification Working Group (ASWG):
- -- ACPI based CPU topology
- -- ACPI based Power management
- -- CPU idle control based on PSCI
- -- CPU performance control (CPPC)
- -- ACPI based SMMU
- -- ITS support for GIC in MADT
In addition to the above and _DSD requirements/banning, I would also add some clear statements around:
_OSC: only global/published capabilities are allowed. For device-specific _OSC we need a process or maybe we can ban them entirely and rely on _DSD once we clarify the process.
_OSI: firmware must not check for certain _OSI strings. Here I'm not sure what we would have to do for ARM Linux. Reporting "Windows" does not make any sense but not reporting anything can, as Matthew Garrett pointed out, can be interpreted by firmware as "Linux". In addition to any statements in this document, I suggest you patch drivers/acpi/acpica/utosi.c accordingly, maybe report "Linux" for ARM and print a kernel warning so that we notice earlier.
ACPI_OS_NAME: this is globally defined as "Microsoft Windows NT". It doesn't make much sense in the ARM context. Could we change it to "Linux" when CONFIG_ARM64?
Compatibility with older kernels: ACPI firmware must work, even though not fully optimal, with the earliest kernel version implementing the targeted ACPI spec. There may be a need for new drivers but otherwise adding things like CPU power management should not break older kernel versions. In addition, the ACPI firmware must also work with the latest kernel version.
I strongly consider that we need to be very strict with the Linux ACPI firmware and hardware requirements to avoid the need for supporting non-standard implementations as much as possible. This is, however, a live document, so we can relax it as we see fit (e.g. _DSD process clarified).
In the meantime, Merry Christmas ;). I'll follow up in January.
Hi Catalin,
Good feedback. In particular, though we have only one example of _DSD (network parameters because the hardware might be reset post boot and some of it is not sophisticated enough to preserve programmed MAC and parameters such as PHy type that will require reloading, both because drivers might be reprobed or because we might reboot or kexec) it is reasonable not to pull support for that into upstream on a short term basis while some of the process is codified. Generally with _DSD I know nobody is implementing anything else in the medium term and have ensured the vendors concerned have had private conversations to ensure existing _DSD entries in DSDTs out there conform to those proposed and are all self consistent (and are supported in certain other kernels so far). But for now that can suffice until the process is codified to a level everyone is comfortable with - certainly we would not expect growth there in the short term and would absolutely not expect DT entries to be arbitrarily carried over.
Also, I agree with the sentiments around codifying into the SBBR. Upstream kernel docs should pertain to Linux, but ideally non OS specifics will live in the SBBR. As one of the original coauthors of the SBBR I know our intention is to grow that document into a more complete platform doc. With that in mind, I will be donating Red Hat's commercial hardware requirements (shared with vendors in separate discussions) as input into that process in 2015.
Jon.
On Wed, Dec 24, 2014 at 05:18:15PM +0000, Catalin Marinas wrote:
On Fri, Oct 17, 2014 at 02:37:14PM +0100, Hanjun Guo wrote:
+ACPI drivers should only look at one specific ASL object -- the _DSD object +-- for device driver parameters (known in DT as "bindings", or "Device +Properties" in ACPI). Not all DT bindings will be recognized.
This last sentence kind of implies that many of the DT bindings will be recognised. While it is useful to have some commonalities, I think this gives the wrong message that _DSD is a copy of DT. We should avoid this.
+so that they may be used on any operating system supporting ACPI. Device +properties that have not been registered with the UEFI Forum should not be +used.
More about this further down.
Indeed...
+Drivers should look for device properties in the _DSD object ONLY; the _DSD +object is described in the ACPI specification section 6.2.5, but more +specifically, use the _DSD Device Properties UUID:
- -- UUID: daffd814-6eba-4d8c-8a91-bc9bbf4aa301
+The kernel has an interface for looking up device properties in a manner +independent of whether DT or ACPI is being used and that interface should +be used;
I haven't followed the _DSD kernel support but does it provide a common API to be shared with DT? I'm not entirely convinced it's a good idea.
Yes, it does. I'm not entirely convinced about that either but it really meets the goals of some of the users. Right now I'm seeing several user communities:
- x86 server - x86 laptop - x86 embedded - ARM server
The _DSD/DT abstraction API is intended to meet the needs of the x86 embedded community, they are really only interested in Linux and just want to be able to pick up Linux drivers that have been developed with DT in mind and use them with the minimum fuss. They are, to a good approximation, not really interested in UEFI and ACPI per se.
it can eliminate some duplication of code paths in driver probing +functions and discourage divergence between DT bindings and ACPI device +properties.
Given the current different mechanism of reviewing/approving bindings between DT and ACPI (kernel community vs UEFI forum), I don't see how we
Right now there is no real way of reviewing and approving bindings for _DSD.
encourage convergence (unless we state that _DSD are Linux-only, Windows should use a different mechanism like .inf files).
No, I don't think we want to encourage that. It's what's happening right now for the x86 laptop case and it's making things miserable for people working with audio, what we end up with on the Linux side is needing to have per-machine quirk tables which means that Linux has little chance of working out of the box with unknown hardware. It's bad for users and not a lot of fun for developers. What you're saying is fine for the x86 embedded people but as soon as we want to run both Windows and Linux on the same system we want to try to make sure that the firmware itself describes the hardware.
Note also that there are already some non-_DSD ways of passing platform data to ACPI devices (you can read at least integer properties easily) so it's not just _DSD we have to consider here.
+The _DSD object is a very flexible mechanism in ACPI, as are the registered +Device Properties. This flexibility allows _DSD to cover more than just the +generic server case and care should be taken in device drivers not to expect +it to replicate highly specific embedded behaviour from DT.
While this is all good, we need to be more specific on what "embedded behaviour" means. Maybe not for this document but the UEFI approval process for new properties doesn't give any hint on what is and is not sane (and I already disagree with some of the examples on uefi.org).
Right, though we also don't want the UEFI approval process to set down standards that are too heavily tied to a specific view for ARM servers since ARM servers are not the only users.
My problems with _DSD:
a) no clear guidance on what a good property means, whether it covers just device specific information or it may include Linux behaviour (like "linux,default-trigger", I don't think it should)
Right, though some people are going to want to do that.
b) the Linux kernel community does not seem to be involved in the UEFI forum _DSD review process. This means that we'll be faced with patches against drivers to support UEFI-published _DSD properties. I want to avoid such arguments, rejecting kernel code is too late after _DSD properties have been published
I've been very concerned about this and chasing it up myself. As far as I have been able to tell there essentially is no UEFI forum _DSD review process at this point, the brief bits that are there are essentially placeholders rather than actual practical things which people expect to be viable long term and were placed there in the interests of getting the actual stuff that goes into the tables approved. There was some indication that there was an intention to have some discussion early next year about doing it properly.
It'd certainly be good to get wider involvement from the kernel community in that discussion, right now I'm a bit concerned that the standardisation isn't going to be terribly effective in reaching everyone it needs to or relevant to them.
Personally I'm mainly interested in making sure we can ideally facilitate conversation with the Windows driver people and at worst can set good practice standards for them which make life easier for Linux when followed even if there's a degree of reverse engineerinng involved.
The alternative to _DSD would be to program the hardware to some sane state. For example, I'm sure a MAC address can be written by firmware to some register and the driver can read and store it locally (I'm not even sure why we need MAC address in ACPI tables, this is not really a property of the hardware but a configuration that could be done in firmware).
On the other hand something like a MAC address is a useful placeholder for discussion since there's no real debate about the technical aspects of representing it allowing everyone to focus on the process.
+ASWG +---- +The following areas are not yet fully defined for ARM in the 5.1 version +of the ACPI specification and are expected to be worked through in the +UEFI ACPI Specification Working Group (ASWG):
- -- ACPI based CPU topology
- -- ACPI based Power management
- -- CPU idle control based on PSCI
- -- CPU performance control (CPPC)
- -- ACPI based SMMU
- -- ITS support for GIC in MADT
In addition to the above and _DSD requirements/banning, I would also add some clear statements around:
I'd not go that far with _DSD, I am unhappy with the current state of the world but I'm not sure how relevant the process is going to be and that anything more than a very strong disrecommendation is going to make sense.
Compatibility with older kernels: ACPI firmware must work, even though not fully optimal, with the earliest kernel version implementing the targeted ACPI spec. There may be a need for new drivers but otherwise adding things like CPU power management should not break older kernel versions. In addition, the ACPI firmware must also work with the latest kernel version.
The backwards compatibility thing sounds a bit strongly worded - I think that's something the customers would probably sort out anyway to the extent it's important. It's obviously good to recommend that people keep as much backwards compatibility as they can since if nothing else it makes it easier for people to use their hardware but it doesn't seem unreasonable to decide that supporting older kernels (or more to the point older distro releases) isn't that interesting for whatever reason.
I strongly consider that we need to be very strict with the Linux ACPI firmware and hardware requirements to avoid the need for supporting non-standard implementations as much as possible. This is, however, a live document, so we can relax it as we see fit (e.g. _DSD process clarified).
To the extent that it is specific to ARM server that should be fine, however when it comes to actually enforcing standards for how the kernel behaves then that's a different story - there are other communities with different goals and interests. This in turn means that there will be things that actually practically work and that have become an ABI for another community. Once that happens I'm not sure it's constructive to try to enforce not using them on ARM, and if people manage to ship systems we care about it's game over anyway.
I don't know that it's reasonable to expect people to enforce this from the kernel side - with my subsystem maintainer hat on I really don't know that I care if some ACPI thing is being done for the benefit of an ARM server or if it's being done for the benefit of an x86 embedded box and I'm actually interested.
Hi,
On 2014年12月25日 01:18, Catalin Marinas wrote:
Hi,
Some thoughts before the end of the year. I won't be able to follow up until around 5th of January though.
On Fri, Oct 17, 2014 at 02:37:14PM +0100, Hanjun Guo wrote:
--- /dev/null +++ b/Documentation/arm64/arm-acpi.txt @@ -0,0 +1,323 @@ +ACPI on ARMv8 Servers +--------------------- +ACPI can be used for ARMv8 general purpose servers designed to follow +the ARM SBSA (Server Base System Architecture) specification, currently +available to those with an ARM login at http://silver.arm.com.
You should mention SBBR (Server Base Boot Requirements) here as well. The arm-acpi.txt is complementary to arm-acpi.txt and longer term we should aim to move parts of the Linux document into the more OS-agonstic SBBR.
ok, I will update the doc. and I agree that moving parts of this doc into SBBR, actually part of the content is coming from SBBR, especially section "Booting using ACPI tables" (not include the command line part). please refer to section 4.2 ACPI Tables in SBBR.
+The ARMv8 kernel implements the reduced hardware model of ACPI version +5.1 and its corresponding errata.
I would say 5.1 or later to avoid updating this document every time we get a new ACPI release.
sure, will update it.
+If an ARMv8 system does not meet the requirements of the SBSA, or cannot +be described using the mechanisms defined in the required ACPI specifications, +then it is likely that Device Tree (DT) is more suitable than ACPI for the +hardware.
Based on some private discussions, I think we could drop some of the references to DT in this document. It should specify the requirements for ACPI support and, if not met, the alternative SoC support is automatically DT for Linux. That's just to make it easier to move parts of this doc into SBBR.
+Relationship with Device Tree +-----------------------------
This section is fine, Linux specific and it will stay in this document.
+ACPI support in drivers and subsystems for ARMv8 should never be mutually +exclusive with DT support at compile time.
+At boot time the kernel will only use one description method depending on +parameters passed from the bootloader (including kernel bootargs).
+Regardless of whether DT or ACPI is used, the kernel must always be capable +of booting with either scheme (in kernels with both schemes enabled at compile +time).
+When booting using ACPI tables, the /chosen node in DT will still be parsed +to extract the kernel command line and initrd path. No other section of the +DT will be used.
I don't think this paragraph is needed. That's a kernel detail when how the EFI_STUB passes the information to the rest of the kernel. We mandate UEFI booting for ACPI support, so I wouldn't expect an ACPI-aware U-Boot.
Agree, we can boot kernel ok without passing the dtb to kernel in the command line if ACPI presents.
+Booting using ACPI tables +------------------------- +The only defined method for passing ACPI tables to the kernel on ARMv8 +is via the UEFI system configuration table.
+Processing of ACPI tables may be disabled by passing acpi=off on the kernel +command line; this is the default behavior. If acpi=force is used, the kernel +will ONLY use device configuration information contained in the ACPI tables.
See my comments to Al around the defaults. I think if only ACPI tables are present, we shouldn't panic the kernel if acpi=force is missing but continue with ACPI.
I think we need another patch to implement it, for this patch set,kernel will panic if no dtb and acpi=off. since passing no DT tables to OS but acpi=force is missing is a corner case, we can do a follow up patch to fix that, does it make sense?
If both DT and ACPI tables are present, DT will be the default. You could say "this is the default behaviour if both ACPI and DT tables are present".
+Device Enumeration +------------------ +Device descriptions in ACPI should use standard recognized ACPI interfaces. +These can contain less information than is typically provided via a Device
s/can/may/ ? Not sure, it just sounds better to me (not a native English speaker).
+Tree description for the same device. This is also one of the reasons that +ACPI can be useful -- the driver takes into account that it may have less +detailed information about the device and uses sensible defaults instead. +If done properly in the driver, the hardware can change and improve over +time without the driver having to change at all.
+Clocks provide an excellent example. In DT, clocks need to be specified +and the drivers need to take them into account. In ACPI, the assumption +is that UEFI will leave the device in a reasonable default state, including +any clock settings. If for some reason the driver needs to change a clock +value, this can be done in an ACPI method; all the driver needs to do is +invoke the method and not concern itself with what the method needs to do +to change the clock. Changing the hardware can then take place over time +by changing what the ACPI method does, and not the driver.
+ACPI drivers should only look at one specific ASL object -- the _DSD object +-- for device driver parameters (known in DT as "bindings", or "Device +Properties" in ACPI). Not all DT bindings will be recognized.
This last sentence kind of implies that many of the DT bindings will be recognised. While it is useful to have some commonalities, I think this gives the wrong message that _DSD is a copy of DT. We should avoid this.
The UEFI +Forum provides a mechanism for registering such bindings [URL TBD by ASWG]
s/bindings/properties/ if we talk in the ACPI context.
+so that they may be used on any operating system supporting ACPI. Device +properties that have not been registered with the UEFI Forum should not be +used.
More about this further down.
+Drivers should look for device properties in the _DSD object ONLY; the _DSD +object is described in the ACPI specification section 6.2.5, but more +specifically, use the _DSD Device Properties UUID:
- -- UUID: daffd814-6eba-4d8c-8a91-bc9bbf4aa301
- -- http://www.uefi.org/sites/default/files/resources/_DSD-device-properties-UUI...)
+The kernel has an interface for looking up device properties in a manner +independent of whether DT or ACPI is being used and that interface should +be used;
I haven't followed the _DSD kernel support but does it provide a common API to be shared with DT? I'm not entirely convinced it's a good idea.
it can eliminate some duplication of code paths in driver probing +functions and discourage divergence between DT bindings and ACPI device +properties.
Given the current different mechanism of reviewing/approving bindings between DT and ACPI (kernel community vs UEFI forum), I don't see how we encourage convergence (unless we state that _DSD are Linux-only, Windows should use a different mechanism like .inf files).
+ACPI tables are described with a formal language called ASL, the ACPI +Source Language (section 19 of the specification). This means that there +are always multiple ways to describe the same thing -- including device +properties. For example, device properties could use an ASL construct +that looks like this: Name(KEY0, "value0"). An ACPI device driver would +then retrieve the value of the property by evaluating the KEY0 object. +However, using Name() this way has multiple problems: (1) ACPI limits +names ("KEY0") to four characters unlike DT; (2) there is no industry +wide registry that maintains a list of names, minimzing re-use; (3) +there is also no registry for the definition of property values ("value0"), +again making re-use difficult; and (4) how does one maintain backward +compatibility as new hardware comes out? The _DSD method was created +to solve precisely these sorts of problems; Linux drivers should ALWAYS +use the _DSD method for device properties and nothing else.
+The _DSM object (ACPI Section 9.14.1) could also be used for conveying +device properties to a driver. Linux drivers should only expect it to +be used if _DSD cannot represent the data required, and there is no way +to create a new UUID for the _DSD object. Note that there is even less +regulation of the use of _DSM than there is of _DSD. Drivers that depend +on the contents of _DSM objects will be more difficult to maintain over +time because of this.
+The _DSD object is a very flexible mechanism in ACPI, as are the registered +Device Properties. This flexibility allows _DSD to cover more than just the +generic server case and care should be taken in device drivers not to expect +it to replicate highly specific embedded behaviour from DT.
While this is all good, we need to be more specific on what "embedded behaviour" means. Maybe not for this document but the UEFI approval process for new properties doesn't give any hint on what is and is not sane (and I already disagree with some of the examples on uefi.org).
+Both DT bindings and ACPI device properties for device drivers have review +processes. Use them. And, before creating new device properties, check to +be sure that they have not been defined before and either registered in the +Linux kernel documentation or the UEFI Forum. If the device drivers supports +ACPI and DT, please make sure the device properties are consistent in both +places.
In the interest of progress, I think we need to *temporarily* ban the use of _DSD on ARM platforms aimed at ACPI and state it clearly in this document. Once we are happy with the UEFI forum review process, we'll adjust the document accordingly.
My problems with _DSD:
a) no clear guidance on what a good property means, whether it covers just device specific information or it may include Linux behaviour (like "linux,default-trigger", I don't think it should) b) the Linux kernel community does not seem to be involved in the UEFI forum _DSD review process. This means that we'll be faced with patches against drivers to support UEFI-published _DSD properties. I want to avoid such arguments, rejecting kernel code is too late after _DSD properties have been published
The alternative to _DSD would be to program the hardware to some sane state. For example, I'm sure a MAC address can be written by firmware to some register and the driver can read and store it locally (I'm not even sure why we need MAC address in ACPI tables, this is not really a property of the hardware but a configuration that could be done in firmware).
+Clocks +------ +ACPI makes the assumption that clocks are initialized by the firmware -- +UEFI, in this case -- to some working value before control is handed over +to the kernel. This has implications for devices such as UARTs, or SoC +driven LCD displays, for example.
+When the kernel boots, the clock is assumed to be set to reasonable +working value. If for some reason the frequency needs to change -- e.g., +throttling for power management -- the device driver should expect that +process to be abstracted out into some ACPI method that can be invoked +(please see the ACPI specification for further recommendations on standard +methods to be expected). If is not, there is no direct way for ACPI to +control the clocks.
I would emphasize that there is no way for _Linux_ to directly control the clocks on an ACPI-enabled platform.
+ASWG +---- +The following areas are not yet fully defined for ARM in the 5.1 version +of the ACPI specification and are expected to be worked through in the +UEFI ACPI Specification Working Group (ASWG):
- -- ACPI based CPU topology
- -- ACPI based Power management
- -- CPU idle control based on PSCI
- -- CPU performance control (CPPC)
- -- ACPI based SMMU
- -- ITS support for GIC in MADT
In addition to the above and _DSD requirements/banning, I would also add some clear statements around:
_OSC: only global/published capabilities are allowed. For device-specific _OSC we need a process or maybe we can ban them entirely and rely on _DSD once we clarify the process.
_OSI: firmware must not check for certain _OSI strings. Here I'm not sure what we would have to do for ARM Linux. Reporting "Windows" does not make any sense but not reporting anything can, as Matthew Garrett pointed out, can be interpreted by firmware as "Linux". In addition to any statements in this document, I suggest you patch drivers/acpi/acpica/utosi.c accordingly, maybe report "Linux" for ARM and print a kernel warning so that we notice earlier.
ACPI_OS_NAME: this is globally defined as "Microsoft Windows NT". It doesn't make much sense in the ARM context. Could we change it to "Linux" when CONFIG_ARM64?
Compatibility with older kernels: ACPI firmware must work, even though not fully optimal, with the earliest kernel version implementing the targeted ACPI spec. There may be a need for new drivers but otherwise adding things like CPU power management should not break older kernel versions. In addition, the ACPI firmware must also work with the latest kernel version.
I strongly consider that we need to be very strict with the Linux ACPI firmware and hardware requirements to avoid the need for supporting non-standard implementations as much as possible. This is, however, a live document, so we can relax it as we see fit (e.g. _DSD process clarified).
In the meantime, Merry Christmas ;). I'll follow up in January.
I will send another version of patches based on 3.19-rc2, and I will address some comments in that patch set, we can continue our discussion here about doc for ACPI on ARM64.
Thanks Hanjun
On Tue, Dec 30, 2014 at 11:23:14AM +0000, Hanjun Guo wrote:
On 2014年12月25日 01:18, Catalin Marinas wrote:
On Fri, Oct 17, 2014 at 02:37:14PM +0100, Hanjun Guo wrote:
+Booting using ACPI tables +------------------------- +The only defined method for passing ACPI tables to the kernel on ARMv8 +is via the UEFI system configuration table.
+Processing of ACPI tables may be disabled by passing acpi=off on the kernel +command line; this is the default behavior. If acpi=force is used, the kernel +will ONLY use device configuration information contained in the ACPI tables.
See my comments to Al around the defaults. I think if only ACPI tables are present, we shouldn't panic the kernel if acpi=force is missing but continue with ACPI.
I think we need another patch to implement it, for this patch set,kernel will panic if no dtb and acpi=off.
If no dtb and acpi=off on the kernel command line, I agree that the kernel should panic as it doesn't have any way to get the platform description.
since passing no DT tables to OS but acpi=force is missing is a corner case, we can do a follow up patch to fix that, does it make sense?
Not entirely. Why would no dtb and no acpi=force be a corner case? I thought this should be the default when only ACPI tables are passed, no need for an additional acpi=force argument.
On Monday 05 January 2015 13:13:02 Catalin Marinas wrote:
since passing no DT tables to OS but acpi=force is missing is a corner case, we can do a follow up patch to fix that, does it make sense?
Not entirely. Why would no dtb and no acpi=force be a corner case? I thought this should be the default when only ACPI tables are passed, no need for an additional acpi=force argument.
We don't really support the case of only ACPI tables for now. The expectation is that you always have working DT support, at least for the next few years as ACPI features are ramping up, and without acpi=force it should not try to use ACPI at all.
Arnd
On Mon, Jan 05, 2015 at 08:16:30PM +0000, Arnd Bergmann wrote:
On Monday 05 January 2015 13:13:02 Catalin Marinas wrote:
since passing no DT tables to OS but acpi=force is missing is a corner case, we can do a follow up patch to fix that, does it make sense?
Not entirely. Why would no dtb and no acpi=force be a corner case? I thought this should be the default when only ACPI tables are passed, no need for an additional acpi=force argument.
We don't really support the case of only ACPI tables for now. The expectation is that you always have working DT support, at least for the next few years as ACPI features are ramping up, and without acpi=force it should not try to use ACPI at all.
So if both DT and ACPI are present, just use DT unless acpi=force is passed. So far I think we agree but what I want to avoid is always mandating acpi=force even when the DT tables are missing (in the long run).
Now, what's preventing a vendor firmware from providing only ACPI tables? Do we enforce it in some way (arm-acpi.txt, kernel warning etc.) that both DT and ACPI are supported, or at least that dts files are merged in the kernel first?
On 6 January 2015 at 11:20, Catalin Marinas catalin.marinas@arm.com wrote:
On Mon, Jan 05, 2015 at 08:16:30PM +0000, Arnd Bergmann wrote:
On Monday 05 January 2015 13:13:02 Catalin Marinas wrote:
since passing no DT tables to OS but acpi=force is missing is a corner case, we can do a follow up patch to fix that, does it make sense?
Not entirely. Why would no dtb and no acpi=force be a corner case? I thought this should be the default when only ACPI tables are passed, no need for an additional acpi=force argument.
We don't really support the case of only ACPI tables for now. The expectation is that you always have working DT support, at least for the next few years as ACPI features are ramping up, and without acpi=force it should not try to use ACPI at all.
So if both DT and ACPI are present, just use DT unless acpi=force is passed. So far I think we agree but what I want to avoid is always mandating acpi=force even when the DT tables are missing (in the long run).
Now, what's preventing a vendor firmware from providing only ACPI tables? Do we enforce it in some way (arm-acpi.txt, kernel warning etc.) that both DT and ACPI are supported, or at least that dts files are merged in the kernel first?
How do we tell the difference between a DT passed purely for booting purposes ie a skeleton DT. And one which actually has hardware description as this needs to be done before unpacking the DT.
Graeme
On Tue, Jan 06, 2015 at 01:51:27PM +0000, G Gregory wrote:
On 6 January 2015 at 11:20, Catalin Marinas catalin.marinas@arm.com wrote:
On Mon, Jan 05, 2015 at 08:16:30PM +0000, Arnd Bergmann wrote:
On Monday 05 January 2015 13:13:02 Catalin Marinas wrote:
since passing no DT tables to OS but acpi=force is missing is a corner case, we can do a follow up patch to fix that, does it make sense?
Not entirely. Why would no dtb and no acpi=force be a corner case? I thought this should be the default when only ACPI tables are passed, no need for an additional acpi=force argument.
We don't really support the case of only ACPI tables for now. The expectation is that you always have working DT support, at least for the next few years as ACPI features are ramping up, and without acpi=force it should not try to use ACPI at all.
So if both DT and ACPI are present, just use DT unless acpi=force is passed. So far I think we agree but what I want to avoid is always mandating acpi=force even when the DT tables are missing (in the long run).
Now, what's preventing a vendor firmware from providing only ACPI tables? Do we enforce it in some way (arm-acpi.txt, kernel warning etc.) that both DT and ACPI are supported, or at least that dts files are merged in the kernel first?
How do we tell the difference between a DT passed purely for booting purposes ie a skeleton DT. And one which actually has hardware description as this needs to be done before unpacking the DT.
You do the check in EFI_STUB (part of the kernel). An ACPI-only firmware should never pass a DT to the kernel, not even for booting purposes (EFI_STUB builds one on the fly to pass parameters to the kernel but that's purely an internal kernel decision).
There are other ways as well, but if we decide to enforce this, I think EFI_STUB is the best option.
On Tuesday 06 January 2015 11:20:01 Catalin Marinas wrote:
On Mon, Jan 05, 2015 at 08:16:30PM +0000, Arnd Bergmann wrote:
On Monday 05 January 2015 13:13:02 Catalin Marinas wrote:
since passing no DT tables to OS but acpi=force is missing is a corner case, we can do a follow up patch to fix that, does it make sense?
Not entirely. Why would no dtb and no acpi=force be a corner case? I thought this should be the default when only ACPI tables are passed, no need for an additional acpi=force argument.
We don't really support the case of only ACPI tables for now. The expectation is that you always have working DT support, at least for the next few years as ACPI features are ramping up, and without acpi=force it should not try to use ACPI at all.
So if both DT and ACPI are present, just use DT unless acpi=force is passed. So far I think we agree but what I want to avoid is always mandating acpi=force even when the DT tables are missing (in the long run).
Now, what's preventing a vendor firmware from providing only ACPI tables? Do we enforce it in some way (arm-acpi.txt, kernel warning etc.) that both DT and ACPI are supported, or at least that dts files are merged in the kernel first?
We have no way of enforcing what a board vendor ships, so if they want to have ACPI-only machines for MS Windows, they just won't work by default on Linux. Once ACPI support is mature enough, we can also have a whitelist or a different default for using it automatically when no DT is present.
For drivers merged upstream, I would insist that every driver merged for an ARM64 platform has a documented DT binding that is used in the driver.
Arnd
On Tue, Jan 06, 2015 at 01:59:27PM +0000, Arnd Bergmann wrote:
On Tuesday 06 January 2015 11:20:01 Catalin Marinas wrote:
On Mon, Jan 05, 2015 at 08:16:30PM +0000, Arnd Bergmann wrote:
On Monday 05 January 2015 13:13:02 Catalin Marinas wrote:
since passing no DT tables to OS but acpi=force is missing is a corner case, we can do a follow up patch to fix that, does it make sense?
Not entirely. Why would no dtb and no acpi=force be a corner case? I thought this should be the default when only ACPI tables are passed, no need for an additional acpi=force argument.
We don't really support the case of only ACPI tables for now. The expectation is that you always have working DT support, at least for the next few years as ACPI features are ramping up, and without acpi=force it should not try to use ACPI at all.
So if both DT and ACPI are present, just use DT unless acpi=force is passed. So far I think we agree but what I want to avoid is always mandating acpi=force even when the DT tables are missing (in the long run).
Now, what's preventing a vendor firmware from providing only ACPI tables? Do we enforce it in some way (arm-acpi.txt, kernel warning etc.) that both DT and ACPI are supported, or at least that dts files are merged in the kernel first?
We have no way of enforcing what a board vendor ships, so if they want to have ACPI-only machines for MS Windows, they just won't work by default on Linux.
What do you mean by "won't work by default on Linux"? Assuming no additional drivers are needed (i.e. a few devices mentioned in SBSA and the rest on a PCIe bus, using existing drivers without further modifications), do you still want mainline to fail to boot on such ACPI-only systems?
Once ACPI support is mature enough, we can also have a whitelist or a different default for using it automatically when no DT is present.
Having a white-list requires some for of SoC identification. Does ACPI provide such thing (like "model" or "compatible" strings in the top DT node)?
For drivers merged upstream, I would insist that every driver merged for an ARM64 platform has a documented DT binding that is used in the driver.
That's fine by me. I just hope that for hardware aimed at ACPI we won't need many non-PCIe drivers.
On Tuesday 06 January 2015 14:11:33 Catalin Marinas wrote:
On Tue, Jan 06, 2015 at 01:59:27PM +0000, Arnd Bergmann wrote:
On Tuesday 06 January 2015 11:20:01 Catalin Marinas wrote:
On Mon, Jan 05, 2015 at 08:16:30PM +0000, Arnd Bergmann wrote:
On Monday 05 January 2015 13:13:02 Catalin Marinas wrote:
since passing no DT tables to OS but acpi=force is missing is a corner case, we can do a follow up patch to fix that, does it make sense?
Not entirely. Why would no dtb and no acpi=force be a corner case? I thought this should be the default when only ACPI tables are passed, no need for an additional acpi=force argument.
We don't really support the case of only ACPI tables for now. The expectation is that you always have working DT support, at least for the next few years as ACPI features are ramping up, and without acpi=force it should not try to use ACPI at all.
So if both DT and ACPI are present, just use DT unless acpi=force is passed. So far I think we agree but what I want to avoid is always mandating acpi=force even when the DT tables are missing (in the long run).
Now, what's preventing a vendor firmware from providing only ACPI tables? Do we enforce it in some way (arm-acpi.txt, kernel warning etc.) that both DT and ACPI are supported, or at least that dts files are merged in the kernel first?
We have no way of enforcing what a board vendor ships, so if they want to have ACPI-only machines for MS Windows, they just won't work by default on Linux.
What do you mean by "won't work by default on Linux"? Assuming no additional drivers are needed (i.e. a few devices mentioned in SBSA and the rest on a PCIe bus, using existing drivers without further modifications), do you still want mainline to fail to boot on such ACPI-only systems?
I mean it won't work without acpi=force on the command line.
Once ACPI support is mature enough, we can also have a whitelist or a different default for using it automatically when no DT is present.
Having a white-list requires some for of SoC identification. Does ACPI provide such thing (like "model" or "compatible" strings in the top DT node)?
This is independent of the SoC: All SoCs we support have DT drivers, so machines like this would be board whose vendor doesn't care about Linux, but happens to use a SoC that we support. What we would need here is a whitelist of boards.
For drivers merged upstream, I would insist that every driver merged for an ARM64 platform has a documented DT binding that is used in the driver.
That's fine by me. I just hope that for hardware aimed at ACPI we won't need many non-PCIe drivers.
Yes, that is a reasonable assumption. Looking at the AMD patches that were posted already, there are however a few devices that are not on the PCI bus:
- pl011 uart - pl022 spi - pl061 gpio - pl330 dma - designware i2c - custom 10gbit ethernet - probably some I forgot
Most of these will likely just not be needed on servers (pl330) or handled by AML (spi, i2c, gpio) transparently without needing a driver, but we do need to support the ethernet port and the uart. I expect that other SoCs come with different ethernet implementations that are also not discoverable through PCI.
Arnd
On Tue, Jan 6, 2015 at 1:59 PM, Arnd Bergmann arnd@arndb.de wrote:
On Tuesday 06 January 2015 11:20:01 Catalin Marinas wrote:
On Mon, Jan 05, 2015 at 08:16:30PM +0000, Arnd Bergmann wrote:
On Monday 05 January 2015 13:13:02 Catalin Marinas wrote:
since passing no DT tables to OS but acpi=force is missing is a corner case, we can do a follow up patch to fix that, does it make sense?
Not entirely. Why would no dtb and no acpi=force be a corner case? I thought this should be the default when only ACPI tables are passed, no need for an additional acpi=force argument.
We don't really support the case of only ACPI tables for now. The expectation is that you always have working DT support, at least for the next few years as ACPI features are ramping up, and without acpi=force it should not try to use ACPI at all.
So if both DT and ACPI are present, just use DT unless acpi=force is passed. So far I think we agree but what I want to avoid is always mandating acpi=force even when the DT tables are missing (in the long run).
Now, what's preventing a vendor firmware from providing only ACPI tables? Do we enforce it in some way (arm-acpi.txt, kernel warning etc.) that both DT and ACPI are supported, or at least that dts files are merged in the kernel first?
We have no way of enforcing what a board vendor ships, so if they want to have ACPI-only machines for MS Windows, they just won't work by default on Linux. Once ACPI support is mature enough, we can also have a whitelist or a different default for using it automatically when no DT is present.
For drivers merged upstream, I would insist that every driver merged for an ARM64 platform has a documented DT binding that is used in the driver.
That's a dumb rule. It will result in untested DT code paths being thrown into drivers just too meet the rules rather than on whether or not they will actually be used. It's fine to allow driver authors to only implement the ACPI code path if that is what they are working with. We can *always* add a DT path to the driver when it is needed.
As you say, wecannot insist that vendors implement DT as well as ACPI. The most we can do is offer the recommendation that DT works now, but ACPI is immature for ARM. If they choose to do ACPI only, that is absolutely fine and they do so with the understanding that it will take time to stabilize to the point that we're comfortable guaranteeing support in mainline. However, that doesn't even remotely block getting each of their drivers merged as they become ready.
g.
On 01/15/2015 09:10 AM, Grant Likely wrote:
On Tue, Jan 6, 2015 at 1:59 PM, Arnd Bergmann arnd@arndb.de wrote:
On Tuesday 06 January 2015 11:20:01 Catalin Marinas wrote:
On Mon, Jan 05, 2015 at 08:16:30PM +0000, Arnd Bergmann wrote:
On Monday 05 January 2015 13:13:02 Catalin Marinas wrote:
since passing no DT tables to OS but acpi=force is missing is a corner case, we can do a follow up patch to fix that, does it make sense?
Not entirely. Why would no dtb and no acpi=force be a corner case? I thought this should be the default when only ACPI tables are passed, no need for an additional acpi=force argument.
We don't really support the case of only ACPI tables for now. The expectation is that you always have working DT support, at least for the next few years as ACPI features are ramping up, and without acpi=force it should not try to use ACPI at all.
So if both DT and ACPI are present, just use DT unless acpi=force is passed. So far I think we agree but what I want to avoid is always mandating acpi=force even when the DT tables are missing (in the long run).
Now, what's preventing a vendor firmware from providing only ACPI tables? Do we enforce it in some way (arm-acpi.txt, kernel warning etc.) that both DT and ACPI are supported, or at least that dts files are merged in the kernel first?
We have no way of enforcing what a board vendor ships, so if they want to have ACPI-only machines for MS Windows, they just won't work by default on Linux. Once ACPI support is mature enough, we can also have a whitelist or a different default for using it automatically when no DT is present.
For drivers merged upstream, I would insist that every driver merged for an ARM64 platform has a documented DT binding that is used in the driver.
That's a dumb rule. It will result in untested DT code paths being thrown into drivers just too meet the rules rather than on whether or not they will actually be used. It's fine to allow driver authors to only implement the ACPI code path if that is what they are working with. We can *always* add a DT path to the driver when it is needed.
It gets worse. There *will* be large numbers of ACPI only ARM servers landing over the coming year. Not only would DT code be untested, but insisting on keeping e.g. a DSDT and DT in sync is never going to work anyway. Already we have early stage servers that contain a DT used for bringup that is subsequently not being updated as often as the ACPI tables (those systems are now booting exclusively in labs with ACPI). Eventually, I am going to push for the DT data to be removed from these systems rather than have out of date unmaintained DT data in firmware.
Jon.
On Thursday 15 January 2015 10:51:58 Jon Masters wrote:
On 01/15/2015 09:10 AM, Grant Likely wrote:
On Tue, Jan 6, 2015 at 1:59 PM, Arnd Bergmann arnd@arndb.de wrote:
For drivers merged upstream, I would insist that every driver merged for an ARM64 platform has a documented DT binding that is used in the driver.
That's a dumb rule. It will result in untested DT code paths being thrown into drivers just too meet the rules rather than on whether or not they will actually be used. It's fine to allow driver authors to only implement the ACPI code path if that is what they are working with. We can *always* add a DT path to the driver when it is needed.
It gets worse. There *will* be large numbers of ACPI only ARM servers landing over the coming year. Not only would DT code be untested, but insisting on keeping e.g. a DSDT and DT in sync is never going to work anyway. Already we have early stage servers that contain a DT used for bringup that is subsequently not being updated as often as the ACPI tables (those systems are now booting exclusively in labs with ACPI). Eventually, I am going to push for the DT data to be removed from these systems rather than have out of date unmaintained DT data in firmware.
We will of course be able to relax the rule once ACPI has stabilized on ARM64. At the moment, we haven't even agreed on how to represent basic devices, so things are in flux and there is no way for a BIOS writer to ship an image that we will guarantee to support in the long run.
At some point after we are reasonably sure we are able to keep supporting all existing systems that are working with that kernel, we can take support for new systems without having DT by default, and also support booting those without acpi=force, which is related to this question.
Arnd
On 01/15/2015 09:52 AM, Arnd Bergmann wrote:
On Thursday 15 January 2015 10:51:58 Jon Masters wrote:
On 01/15/2015 09:10 AM, Grant Likely wrote:
On Tue, Jan 6, 2015 at 1:59 PM, Arnd Bergmann arnd@arndb.de wrote:
For drivers merged upstream, I would insist that every driver merged for an ARM64 platform has a documented DT binding that is used in the driver.
That's a dumb rule. It will result in untested DT code paths being thrown into drivers just too meet the rules rather than on whether or not they will actually be used. It's fine to allow driver authors to only implement the ACPI code path if that is what they are working with. We can *always* add a DT path to the driver when it is needed.
It gets worse. There *will* be large numbers of ACPI only ARM servers landing over the coming year. Not only would DT code be untested, but insisting on keeping e.g. a DSDT and DT in sync is never going to work anyway. Already we have early stage servers that contain a DT used for bringup that is subsequently not being updated as often as the ACPI tables (those systems are now booting exclusively in labs with ACPI). Eventually, I am going to push for the DT data to be removed from these systems rather than have out of date unmaintained DT data in firmware.
We will of course be able to relax the rule once ACPI has stabilized on ARM64. At the moment, we haven't even agreed on how to represent basic devices, so things are in flux and there is no way for a BIOS writer to ship an image that we will guarantee to support in the long run.
At some point after we are reasonably sure we are able to keep supporting all existing systems that are working with that kernel, we can take support for new systems without having DT by default, and also support booting those without acpi=force, which is related to this question.
Arnd
Can I restate the position as I hear it, then? I want to make sure I'm understanding what's being said.
What I'm reading seems to say: if an ARMv8 vendor wants Linux support in the upstream kernel, regardless of whether or not it is a mobile or server product, they must submit DT-based patches until such time as ACPI on arm64 is deemed "mature." Do I have that correct?
That implies to me that if I want to build an ACPI-only product, there is no way to predict when or if I can get Linux support. And, that if I do want Linux support, and need ACPI for my end-users, I have to maintain both sets of firmware for some unknown time into the future. Is that what was meant?
I'm not really trying to judge the position right this second, but I am trying to make sure I understand it. English is not really the most precise of languages and I would prefer not to misinterpret.
On Thursday 15 January 2015 10:22:47 Al Stone wrote:
Can I restate the position as I hear it, then? I want to make sure I'm understanding what's being said.
What I'm reading seems to say: if an ARMv8 vendor wants Linux support in the upstream kernel, regardless of whether or not it is a mobile or server product, they must submit DT-based patches until such time as ACPI on arm64 is deemed "mature." Do I have that correct?
I was specifically referring to SoC specific device drivers here. It's a bit unclear what a 'vendor' is in this context, but I'd hope that as long as we have basic support for a SoC, other people can build DT blobs for these machines and have them run Linux out of the box.
That implies to me that if I want to build an ACPI-only product, there is no way to predict when or if I can get Linux support. And, that if I do want Linux support, and need ACPI for my end-users, I have to maintain both sets of firmware for some unknown time into the future. Is that what was meant?
The firmware is normally not written by the people that do the SoC, and we have very little control over what someone puts in their firmware. Shipping an ACPI-only firmware would still work, but has the danger of breaking if we ever have to make incompatible changes to the way we interpret the ACPI tables and we have to support users that can't upgrade their firmware.
Hopefully we can quickly get to the point where we don't have to make incompatible changes, but I don't think that is realistic from the day we first merge ACPI support.
Arnd
On Thu, Jan 15, 2015 at 05:52:31PM +0100, Arnd Bergmann wrote:
On Thursday 15 January 2015 10:51:58 Jon Masters wrote:
It gets worse. There *will* be large numbers of ACPI only ARM servers landing over the coming year. Not only would DT code be untested, but insisting on keeping e.g. a DSDT and DT in sync is never going to work anyway. Already we have early stage servers that contain a DT used for bringup that is subsequently not being updated as often as the ACPI tables (those systems are now booting exclusively in labs with ACPI). Eventually, I am going to push for the DT data to be removed from these systems rather than have out of date unmaintained DT data in firmware.
We will of course be able to relax the rule once ACPI has stabilized on ARM64. At the moment, we haven't even agreed on how to represent basic devices, so things are in flux and there is no way for a BIOS writer to ship an image that we will guarantee to support in the long run.
At some point after we are reasonably sure we are able to keep supporting all existing systems that are working with that kernel, we can take support for new systems without having DT by default, and also support booting those without acpi=force, which is related to this question.
Speaking with my subsystem maintainer hat on (admittedly not subsystems affected too much by ARM servers so take this with a pinch of salt) this just sounds like it's making more work for me - it means having to force people to write DT code and bindings which I'm then going to have to review and none of us really care about. Realistically I'm just going to take the code if a lack of a DT binding is the only option, I suspect others will be similar.
On 01/06/2015 06:20 AM, Catalin Marinas wrote:
Now, what's preventing a vendor firmware from providing only ACPI tables? Do we enforce it in some way (arm-acpi.txt, kernel warning etc.) that both DT and ACPI are supported, or at least that dts files are merged in the kernel first?
I know of some (server) firmware that will only provide ACPI in the medium term, so this is coming.
Jon.
On Tuesday 06 January 2015 11:24:43 Jon Masters wrote:
On 01/06/2015 06:20 AM, Catalin Marinas wrote:
Now, what's preventing a vendor firmware from providing only ACPI tables? Do we enforce it in some way (arm-acpi.txt, kernel warning etc.) that both DT and ACPI are supported, or at least that dts files are merged in the kernel first?
I know of some (server) firmware that will only provide ACPI in the medium term, so this is coming.
Medium term is fine, as long as they are not expecting their hardware to be supported by Linux before ACPI support is stable enough for general consumption. I have no idea how long that will take, but my guess is that we shouldn't plan on supporting ACPI-only platforms in Linux for the next couple of years and just demand that all drivers have DT support to let users add a valid DTB that can describe the hardware.
That should always be possible using something like grub2 as an intermediate that boots using the UEFI interfaces and loads the kernel and DT from disk.
Arnd
Hi Arnd,
Happy New Year!
On 01/06/2015 02:21 PM, Arnd Bergmann wrote:
On Tuesday 06 January 2015 11:24:43 Jon Masters wrote:
On 01/06/2015 06:20 AM, Catalin Marinas wrote:
Now, what's preventing a vendor firmware from providing only ACPI tables? Do we enforce it in some way (arm-acpi.txt, kernel warning etc.) that both DT and ACPI are supported, or at least that dts files are merged in the kernel first?
I know of some (server) firmware that will only provide ACPI in the medium term, so this is coming.
Medium term is fine, as long as they are not expecting their hardware to be supported by Linux before ACPI support is stable enough for general consumption.
To be clear, I think that's reasonable for upstream. I may love ACPI, but vendors can always ship kernels with a config supporting ACPI only platforms in the interim period if they have a commercial justification and that doesn't have to be supported in terms of the upstream default.
But, perhaps there's a way to have it both ways, you could consider also a CONFIG_EXPERT option that would allow you to build a kernel with ACPI only support in the medium term. That way, if someone is running a vendor kernel, but wants to track upstream development more closely, they can do so on such hardware by enabling the expert config bit.
I have no idea how long that will take, but my guess is that we shouldn't plan on supporting ACPI-only platforms in Linux for the next couple of years and just demand that all drivers have DT support to let users add a valid DTB that can describe the hardware.
I'm not opposed. It was particularly useful in the early days of ACPI to be able to boot our internal systems (which now all default to ACPI on by default) with acpi=off when there were glitches that needed to be isolated to whether they were ACPI related. One reason I was very keen for a DT UUID in UEFI early on was so that there was a clean way to specify both sets of tables on a UEFI platform. Keeping them in sync is not something we can rely on in the longer term, but during bringup timeframe I suspect you'll continue to see many platforms with both sets of tables. This is especially true for early silicon that might be supporting both embedded and server environments - hence a platform that appears to be a server might have a DT posted upstream anyway if such a platform is also being used for unrelated embedded work.
That should always be possible using something like grub2 as an intermediate that boots using the UEFI interfaces and loads the kernel and DT from disk.
This is another reason (but it's up to you, I understand your position) why it may not be a huge problem if there are ACPI only systems, since the "devicetree" directive in GRUB2 configs is always possible.
Jon.
On 01/06/2015 05:06 PM, Jon Masters wrote:
Hi Arnd,
Happy New Year!
On 01/06/2015 02:21 PM, Arnd Bergmann wrote:
On Tuesday 06 January 2015 11:24:43 Jon Masters wrote:
On 01/06/2015 06:20 AM, Catalin Marinas wrote:
Now, what's preventing a vendor firmware from providing only ACPI tables? Do we enforce it in some way (arm-acpi.txt, kernel warning etc.) that both DT and ACPI are supported, or at least that dts files are merged in the kernel first?
I know of some (server) firmware that will only provide ACPI in the medium term, so this is coming.
Medium term is fine, as long as they are not expecting their hardware to be supported by Linux before ACPI support is stable enough for general consumption.
To be clear, I think that's reasonable for upstream. I may love ACPI, but vendors can always ship kernels with a config supporting ACPI only platforms in the interim period if they have a commercial justification and that doesn't have to be supported in terms of the upstream default.
But, perhaps there's a way to have it both ways, you could consider also a CONFIG_EXPERT option that would allow you to build a kernel with ACPI only support in the medium term. That way, if someone is running a vendor kernel, but wants to track upstream development more closely, they can do so on such hardware by enabling the expert config bit.
Clarification: I'm suggesting that in the medium term the dependency upon CONFIG_EXPERT either goes away or is replaced with requiring ACPI and DTB in the non "expert" case and requiring "expert" selected to allow a kernel that will boot with ACPI only. But only a suggestion.
Jon.
On Tuesday 06 January 2015 23:55:58 Jon Masters wrote:
On 01/06/2015 05:06 PM, Jon Masters wrote:
Hi Arnd,
Happy New Year!
On 01/06/2015 02:21 PM, Arnd Bergmann wrote:
On Tuesday 06 January 2015 11:24:43 Jon Masters wrote:
On 01/06/2015 06:20 AM, Catalin Marinas wrote:
Now, what's preventing a vendor firmware from providing only ACPI tables? Do we enforce it in some way (arm-acpi.txt, kernel warning etc.) that both DT and ACPI are supported, or at least that dts files are merged in the kernel first?
I know of some (server) firmware that will only provide ACPI in the medium term, so this is coming.
Medium term is fine, as long as they are not expecting their hardware to be supported by Linux before ACPI support is stable enough for general consumption.
To be clear, I think that's reasonable for upstream. I may love ACPI, but vendors can always ship kernels with a config supporting ACPI only platforms in the interim period if they have a commercial justification and that doesn't have to be supported in terms of the upstream default.
I would hope that none of the ACPI-only machines are meant to run Linux as a primary operating system, that would be very sad.
Vendors that are interested in Linux support should instead work on getting their hardware supported upstream so they don't need a private kernel to match their private firmware.
But, perhaps there's a way to have it both ways, you could consider also a CONFIG_EXPERT option that would allow you to build a kernel with ACPI only support in the medium term. That way, if someone is running a vendor kernel, but wants to track upstream development more closely, they can do so on such hardware by enabling the expert config bit.
I don't see how this helps. The main point of requiring users to add the option is to ensure that everyone understands the support is experimental and not guaranteed to work across firmware releases or kernel versions, until we have stopped making incompatible changes.
If someone is tracking the upstream kernel, they should know that they have to get working DT support in first, and test both ways with the same kernel anyway.
Clarification: I'm suggesting that in the medium term the dependency upon CONFIG_EXPERT either goes away or is replaced with requiring ACPI and DTB in the non "expert" case
Sure, no debate on that.
and requiring "expert" selected to allow a kernel that will boot with ACPI only. But only a suggestion.
This is a separate issue. I personally think we shouldn't bother with this, as such a configuration would just break a lot of assumptions we make today and removes hardware support, but it's something we can discuss after we get to the point of having ACPI enabled by default.
Arnd
On Wed, Jan 07, 2015 at 10:36:13AM +0000, Arnd Bergmann wrote:
On Tuesday 06 January 2015 23:55:58 Jon Masters wrote:
On 01/06/2015 05:06 PM, Jon Masters wrote:
On 01/06/2015 02:21 PM, Arnd Bergmann wrote:
On Tuesday 06 January 2015 11:24:43 Jon Masters wrote:
On 01/06/2015 06:20 AM, Catalin Marinas wrote:
Now, what's preventing a vendor firmware from providing only ACPI tables? Do we enforce it in some way (arm-acpi.txt, kernel warning etc.) that both DT and ACPI are supported, or at least that dts files are merged in the kernel first?
I know of some (server) firmware that will only provide ACPI in the medium term, so this is coming.
Medium term is fine, as long as they are not expecting their hardware to be supported by Linux before ACPI support is stable enough for general consumption.
To be clear, I think that's reasonable for upstream. I may love ACPI, but vendors can always ship kernels with a config supporting ACPI only platforms in the interim period if they have a commercial justification and that doesn't have to be supported in terms of the upstream default.
I would hope that none of the ACPI-only machines are meant to run Linux as a primary operating system, that would be very sad.
I keep hearing different stories around this. I think this goes back to the last point on Al's to-do list, the reason _why_ vendors need ACPI. As you mentioned some time ago, I would also like to see a summary of such reasons included in the cover letter for the arm64 ACPI patches. In the meantime, we can assume that DT is required.
From what I gathered so far, the main reason for _some_ vendors is not
support for "other" OS but actually features that ACPI has and DT doesn't (like AML; I deliberately ignore statements like "industry standard"). _If_ such reasons are sound, maybe they have a case for ACPI-only machines targeted primarily at Linux.
In theory, it may be beneficial to the kernel maintainers as such ACPI-only machine would potentially require less kernel driver code compared to DT. For example, no need for pin control, clocks or voltage regulator drivers as they are handled in AML. Of course, the counter argument is that it's harder to debug when problems appear but I would expect on such ACPI-only machines that the hardware vendor is very active on solving them (I'm more thinking for machines that sit in some data centre and are actively maintained rather than some board I keep in my house; for the latter, I definitely prefer DT and full control).
Vendors that are interested in Linux support should instead work on getting their hardware supported upstream so they don't need a private kernel to match their private firmware.
I agree, irrespective of whether they target ACPI longer term or not.
As I said yesterday, at some point in the future, ACPI-only SoC support may not require any new kernel code, just usual PCIe drivers that may already be there. If we ever get to that stage (it's not a kernel problem, it's more about SoC standardisation), vendors would be able to run mainline kernels without additional driver code with a few SoC differences handled by AML (e.g. clocks). At that point, I don't see any incentive for them to upstream additional driver code (e.g. clocks) just to support a DT-only kernel. We are probably still a long way, nothing to worry about just yet ;).
On Wednesday 07 January 2015 11:50:39 Catalin Marinas wrote:
On Wed, Jan 07, 2015 at 10:36:13AM +0000, Arnd Bergmann wrote:
On Tuesday 06 January 2015 23:55:58 Jon Masters wrote:
On 01/06/2015 05:06 PM, Jon Masters wrote:
On 01/06/2015 02:21 PM, Arnd Bergmann wrote:
On Tuesday 06 January 2015 11:24:43 Jon Masters wrote:
On 01/06/2015 06:20 AM, Catalin Marinas wrote:
> Now, what's preventing a vendor firmware from providing only ACPI > tables? Do we enforce it in some way (arm-acpi.txt, kernel warning etc.) > that both DT and ACPI are supported, or at least that dts files are > merged in the kernel first?
I know of some (server) firmware that will only provide ACPI in the medium term, so this is coming.
Medium term is fine, as long as they are not expecting their hardware to be supported by Linux before ACPI support is stable enough for general consumption.
To be clear, I think that's reasonable for upstream. I may love ACPI, but vendors can always ship kernels with a config supporting ACPI only platforms in the interim period if they have a commercial justification and that doesn't have to be supported in terms of the upstream default.
I would hope that none of the ACPI-only machines are meant to run Linux as a primary operating system, that would be very sad.
I keep hearing different stories around this. I think this goes back to the last point on Al's to-do list, the reason _why_ vendors need ACPI. As you mentioned some time ago, I would also like to see a summary of such reasons included in the cover letter for the arm64 ACPI patches. In the meantime, we can assume that DT is required.
Right, if we can finish the discussion about the reason for having ACPI, we can skip a lot of pointless back-and-forth on the other issues.
From what I gathered so far, the main reason for _some_ vendors is not support for "other" OS but actually features that ACPI has and DT doesn't (like AML; I deliberately ignore statements like "industry standard"). _If_ such reasons are sound, maybe they have a case for ACPI-only machines targeted primarily at Linux.
What I got from the replies from HP, Huawei and from earlier discussions with Jon is that they all hope to get to the point of relying on AML alone to bridge the differences between SoC families. However, I don't see that happening with the limited hardware compatibility that the existing SBSA provides:
In theory, it may be beneficial to the kernel maintainers as such ACPI-only machine would potentially require less kernel driver code compared to DT. For example, no need for pin control, clocks or voltage regulator drivers as they are handled in AML. Of course, the counter argument is that it's harder to debug when problems appear but I would expect on such ACPI-only machines that the hardware vendor is very active on solving them (I'm more thinking for machines that sit in some data centre and are actively maintained rather than some board I keep in my house; for the latter, I definitely prefer DT and full control).
The main problem here is that can AML only cover part of the problem: it can talk to a clock controller e.g. over I2C, SPI, GPIO, UART or IPMI, but you still need a device driver in the kernel to talk to those, and SBSA doesn't mandate a specific implementation so you can expect every other SoC that is coming out to have a different one.
Similarly, SBSA is rather vague about some peripherals it mandates, and if a new SoC has a slightly different AHCI variation, there is nothing you can do about it in AML.
x86 gets around this problem by having an extreme level of hardware backwards compatibility, so you don't even need AML for this and can generally boot a (almost) full-featured Linux kernel with acpi=off on the command line.
Vendors that are interested in Linux support should instead work on getting their hardware supported upstream so they don't need a private kernel to match their private firmware.
I agree, irrespective of whether they target ACPI longer term or not.
As I said yesterday, at some point in the future, ACPI-only SoC support may not require any new kernel code, just usual PCIe drivers that may already be there. If we ever get to that stage (it's not a kernel problem, it's more about SoC standardisation), vendors would be able to run mainline kernels without additional driver code with a few SoC differences handled by AML (e.g. clocks). At that point, I don't see any incentive for them to upstream additional driver code (e.g. clocks) just to support a DT-only kernel. We are probably still a long way, nothing to worry about just yet ;).
Agreed on all points, yes.
Arnd
On Wed, Jan 07, 2015 at 02:06:28PM +0100, Arnd Bergmann wrote:
On Wednesday 07 January 2015 11:50:39 Catalin Marinas wrote:
From what I gathered so far, the main reason for _some_ vendors is not support for "other" OS but actually features that ACPI has and DT doesn't (like AML; I deliberately ignore statements like "industry standard"). _If_ such reasons are sound, maybe they have a case for ACPI-only machines targeted primarily at Linux.
What I got from the replies from HP, Huawei and from earlier discussions with Jon is that they all hope to get to the point of relying on AML alone to bridge the differences between SoC families. However, I don't see that happening with the limited hardware compatibility that the existing SBSA provides:
I tend to agree with you that it's an overreach to think that this is going to completely abstract away the differences between SoCs from different vendors without substantial further standardization work. However it does seem reasonable to expect that features like AML are going to be more successful in handling board differences and incremental revisions of SoCs - things like interactions with system power controllers for example. That seems like a useful win in and of itself, and one that's worth supporting.
The main problem here is that can AML only cover part of the problem: it can talk to a clock controller e.g. over I2C, SPI, GPIO, UART or IPMI, but you still need a device driver in the kernel to talk to those, and SBSA doesn't mandate a specific implementation so you can expect every other SoC that is coming out to have a different one.
Similarly, SBSA is rather vague about some peripherals it mandates, and if a new SoC has a slightly different AHCI variation, there is nothing you can do about it in AML.
x86 gets around this problem by having an extreme level of hardware backwards compatibility, so you don't even need AML for this and can generally boot a (almost) full-featured Linux kernel with acpi=off on the command line.
That level of hardware compatibility does partly come from the need to run existing software. I'd expect that similar effects will start to come into play with ARMv8 ACPI systems if they become successful; people will do things like ensure compatibility with common IPs that have existing Linux drivers that distros tend to include as standard.
On 01/07/2015 12:27 PM, Mark Brown wrote:
On Wed, Jan 07, 2015 at 02:06:28PM +0100, Arnd Bergmann wrote:
On Wednesday 07 January 2015 11:50:39 Catalin Marinas wrote:
From what I gathered so far, the main reason for _some_ vendors is not support for "other" OS but actually features that ACPI has and DT doesn't (like AML; I deliberately ignore statements like "industry standard"). _If_ such reasons are sound, maybe they have a case for ACPI-only machines targeted primarily at Linux.
What I got from the replies from HP, Huawei and from earlier discussions with Jon is that they all hope to get to the point of relying on AML alone to bridge the differences between SoC families.
I'm expecting to need new drivers for SoC IP blocks that are net new, but generational differences between iterations of the same SoC should be abstracted behind the firmware (and we are already seeing this with at least one platform). Platform wise, it's nice to already see e.g. mmconfig working to handle the specific ways a platform wires PCI.
I tend to agree with you that it's an overreach to think that this is going to completely abstract away the differences between SoCs from different vendors without substantial further standardization work.
(which we plan to do - I intend ultimately for us to have an answer to the Windows Hardware Qualification guides for ARM server systems)
However it does seem reasonable to expect that features like AML are going to be more successful in handling board differences and incremental revisions of SoCs - things like interactions with system power controllers for example. That seems like a useful win in and of itself, and one that's worth supporting.
Indeed.
The main problem here is that can AML only cover part of the problem: it can talk to a clock controller e.g. over I2C, SPI, GPIO, UART or IPMI, but you still need a device driver in the kernel to talk to those, and SBSA doesn't mandate a specific implementation so you can expect every other SoC that is coming out to have a different one.
Similarly, SBSA is rather vague about some peripherals it mandates, and if a new SoC has a slightly different AHCI variation, there is nothing you can do about it in AML.
x86 gets around this problem by having an extreme level of hardware backwards compatibility, so you don't even need AML for this and can generally boot a (almost) full-featured Linux kernel with acpi=off on the command line.
That level of hardware compatibility does partly come from the need to run existing software. I'd expect that similar effects will start to come into play with ARMv8 ACPI systems if they become successful; people will do things like ensure compatibility with common IPs that have existing Linux drivers that distros tend to include as standard.
Agreed.
Jon.
On Wednesday 07 January 2015 12:44:56 Jon Masters wrote:
On 01/07/2015 12:27 PM, Mark Brown wrote:
On Wed, Jan 07, 2015 at 02:06:28PM +0100, Arnd Bergmann wrote:
On Wednesday 07 January 2015 11:50:39 Catalin Marinas wrote:
From what I gathered so far, the main reason for _some_ vendors is not support for "other" OS but actually features that ACPI has and DT doesn't (like AML; I deliberately ignore statements like "industry standard"). _If_ such reasons are sound, maybe they have a case for ACPI-only machines targeted primarily at Linux.
What I got from the replies from HP, Huawei and from earlier discussions with Jon is that they all hope to get to the point of relying on AML alone to bridge the differences between SoC families.
I'm expecting to need new drivers for SoC IP blocks that are net new, but generational differences between iterations of the same SoC should be abstracted behind the firmware (and we are already seeing this with at least one platform). Platform wise, it's nice to already see e.g. mmconfig working to handle the specific ways a platform wires PCI.
Yes, the parts that are mandated by SBSA, like the way that PCI needs to be done are generally good. Unfortunately a lot of the hardware that I've seen has a rather lax interpretation of the spec, so just because something is mandated doesn't mean it's done that way ;-)
In other cases that's actually a good thing. One such example is the "Principles of ARM Memory Maps" document that tells hardware implementers to do a rather complex mapping "To support 36-bit x86 PAE compatible operating systems, such as Linux." but makes life much harder in the process than any of the random mappings we have seen in the wild.
I tend to agree with you that it's an overreach to think that this is going to completely abstract away the differences between SoCs from different vendors without substantial further standardization work.
(which we plan to do - I intend ultimately for us to have an answer to the Windows Hardware Qualification guides for ARM server systems)
Ok, good.
The main problem here is that can AML only cover part of the problem: it can talk to a clock controller e.g. over I2C, SPI, GPIO, UART or IPMI, but you still need a device driver in the kernel to talk to those, and SBSA doesn't mandate a specific implementation so you can expect every other SoC that is coming out to have a different one.
Similarly, SBSA is rather vague about some peripherals it mandates, and if a new SoC has a slightly different AHCI variation, there is nothing you can do about it in AML.
x86 gets around this problem by having an extreme level of hardware backwards compatibility, so you don't even need AML for this and can generally boot a (almost) full-featured Linux kernel with acpi=off on the command line.
That level of hardware compatibility does partly come from the need to run existing software. I'd expect that similar effects will start to come into play with ARMv8 ACPI systems if they become successful; people will do things like ensure compatibility with common IPs that have existing Linux drivers that distros tend to include as standard.
Agreed.
There are two problems I see in trying to do the same thing on ARM:
* we don't have a single vendor that makes de-facto standards that everyone else has to copy in the way that the few remaining x86 vendors copy everything that Intel does. In fact, we prefer to have a large number of independent vendors.
* There is a general mindset about deprecating unwanted features early. ARMv8 aarch32 bit mode removes support for older instructions or makes them optional. Even the virtualization mode doesn't allow to trap on architecture version specific differences, so you can't completely emulate an older architecture level. This is nice for implementers but not so much for users that rely on old (mis-)features. It's also not just the CPU core, other components also get easily replaced, like a GICv3 that is not a strict superset of GICv2.
Arnd
On Wed, Jan 07, 2015 at 08:48:48PM +0100, Arnd Bergmann wrote:
On Wednesday 07 January 2015 12:44:56 Jon Masters wrote:
On 01/07/2015 12:27 PM, Mark Brown wrote:
That level of hardware compatibility does partly come from the need to run existing software. I'd expect that similar effects will start to come into play with ARMv8 ACPI systems if they become successful; people will do things like ensure compatibility with common IPs that have existing Linux drivers that distros tend to include as standard.
Agreed.
There are two problems I see in trying to do the same thing on ARM:
- we don't have a single vendor that makes de-facto standards that everyone else has to copy in the way that the few remaining x86 vendors copy everything that Intel does. In fact, we prefer to have a large number of independent vendors.
Right, I'd guess that (modulo any standards being defined and becoming successful) it'll more be a case of vendors keeping compatibility with their own stuff. We *are* seeing greater reliance on off the shelf IPs for more boring things like DMA and basic bus controllers but there's plenty of other areas that still affect servers.
- There is a general mindset about deprecating unwanted features early. ARMv8 aarch32 bit mode removes support for older instructions or makes them optional. Even the virtualization mode doesn't allow to trap on architecture version specific differences, so you can't completely emulate an older architecture level. This is nice for implementers but not so much for users that rely on old (mis-)features. It's also not just the CPU core, other components also get easily replaced, like a GICv3 that is not a strict superset of GICv2.
This is indeed worrying, though hopefully the fact that we're already seeing negative impacts in the app ecosystem for Android will have focused some minds - once you're talking about full system images it gets even more fun.
On 01/07/2015 03:05 PM, Mark Brown wrote:
On Wed, Jan 07, 2015 at 08:48:48PM +0100, Arnd Bergmann wrote:
On Wednesday 07 January 2015 12:44:56 Jon Masters wrote:
On 01/07/2015 12:27 PM, Mark Brown wrote:
That level of hardware compatibility does partly come from the need to run existing software. I'd expect that similar effects will start to come into play with ARMv8 ACPI systems if they become successful; people will do things like ensure compatibility with common IPs that have existing Linux drivers that distros tend to include as standard.
Agreed.
There are two problems I see in trying to do the same thing on ARM:
- we don't have a single vendor that makes de-facto standards that everyone else has to copy in the way that the few remaining x86 vendors copy everything that Intel does. In fact, we prefer to have a large number of independent vendors.
Right, I'd guess that (modulo any standards being defined and becoming successful) it'll more be a case of vendors keeping compatibility with their own stuff. We *are* seeing greater reliance on off the shelf IPs for more boring things like DMA and basic bus controllers but there's plenty of other areas that still affect servers.
I expect to see a greater level of standardization. SBBR is the beginning, but it is far from the end. There will be a lot more as the vendors come together and agree on common platform components. I've spent a lot of time over the past few years with a large number of vendors going over lots of these issues in lieu of more of a Windows Hardware Qualification style guide. I intend to have one this year that captures what Red Hat think an ARM server looks like, and to circulate that among the broader ecosystem of vendors to feed into SBBR++.
- There is a general mindset about deprecating unwanted features early. ARMv8 aarch32 bit mode removes support for older instructions or makes them optional. Even the virtualization mode doesn't allow to trap on architecture version specific differences, so you can't completely emulate an older architecture level. This is nice for implementers but not so much for users that rely on old (mis-)features. It's also not just the CPU core, other components also get easily replaced, like a GICv3 that is not a strict superset of GICv2.
This is indeed worrying, though hopefully the fact that we're already seeing negative impacts in the app ecosystem for Android will have focused some minds - once you're talking about full system images it gets even more fun.
GICv2/3 was something a bunch of us discussed years ago. At the time we debated whether there was a need to compel the superset option. It was deemed early enough not to be a critical issue. But there have already been other cases where we've pushed to ensure backward compatibility for all time. And there will be more of those as the ecosystem develops out into a world of existing Operating System images and apps that need to run on these emerging platforms. Deprecating instructions and formalizing other behaviors is an area where it's ephemeral - what made sense in the past might not make sense in the future, and ARM know that. Their architecture team features some of the smartest minds.
(on architecture revisions, Red Hat has stated in the past that we only care about AArch64, not even running 32-bit code on 64-bit processors, which is one reason I have pushed for some silicon designs not to implement the 32-bit compatibility when it comes to servers)
Jon.
On Wed, Jan 07, 2015 at 07:48:48PM +0000, Arnd Bergmann wrote:
On Wednesday 07 January 2015 12:44:56 Jon Masters wrote:
I'm expecting to need new drivers for SoC IP blocks that are net new, but generational differences between iterations of the same SoC should be abstracted behind the firmware (and we are already seeing this with at least one platform). Platform wise, it's nice to already see e.g. mmconfig working to handle the specific ways a platform wires PCI.
Yes, the parts that are mandated by SBSA, like the way that PCI needs to be done are generally good. Unfortunately a lot of the hardware that I've seen has a rather lax interpretation of the spec, so just because something is mandated doesn't mean it's done that way ;-)
In other cases that's actually a good thing. One such example is the "Principles of ARM Memory Maps" document that tells hardware implementers to do a rather complex mapping "To support 36-bit x86 PAE compatible operating systems, such as Linux." but makes life much harder in the process than any of the random mappings we have seen in the wild.
Unfortunately, with any significant amount of RAM (say 16GB), this document becomes pretty useless. It basically forces you to have a very sparse physical address map from 0 to over 40-bit. I wouldn't apply the ARM memory maps doc to server systems.
- There is a general mindset about deprecating unwanted features early. ARMv8 aarch32 bit mode removes support for older instructions or makes them optional. Even the virtualization mode doesn't allow to trap on architecture version specific differences, so you can't completely emulate an older architecture level. This is nice for implementers but not so much for users that rely on old (mis-)features.
This mindset is (slowly) changing. There are, of course, instructions like SWP that just can't always be implemented at the SoC level (not necessarily CPU level; requiring bus locks) but others like CP15 barriers, I don't see why they should go away, it's just a decoder problem.
It's also not just the CPU core, other components also get easily replaced, like a GICv3 that is not a strict superset of GICv2.
That's not a problem for Linux, we can describe them in DT or ACPI and have drivers. GICv3 has an optional GICv2 compatible mode, though vendors may decide not to implement it.
On Friday 09 January 2015 10:33:07 Catalin Marinas wrote:
On Wed, Jan 07, 2015 at 07:48:48PM +0000, Arnd Bergmann wrote:
In other cases that's actually a good thing. One such example is the "Principles of ARM Memory Maps" document that tells hardware implementers to do a rather complex mapping "To support 36-bit x86 PAE compatible operating systems, such as Linux." but makes life much harder in the process than any of the random mappings we have seen in the wild.
Unfortunately, with any significant amount of RAM (say 16GB), this document becomes pretty useless. It basically forces you to have a very sparse physical address map from 0 to over 40-bit. I wouldn't apply the ARM memory maps doc to server systems.
Are you sure? I was under the impression that this document was targetted specifically at servers.
It's also not just the CPU core, other components also get easily replaced, like a GICv3 that is not a strict superset of GICv2.
That's not a problem for Linux, we can describe them in DT or ACPI and have drivers. GICv3 has an optional GICv2 compatible mode, though vendors may decide not to implement it.
I'm aware that we can deal with it after we have the drivers. My point was that we are unable to deal with this problem in general if we want to run existing kernels on new hardware that contains e.g. a GICv4/5/6 that requires a new driver which has to first be written and then backported into distro kernels.
Arnd
On Fri, Jan 09, 2015 at 10:55:51AM +0000, Arnd Bergmann wrote:
On Friday 09 January 2015 10:33:07 Catalin Marinas wrote:
On Wed, Jan 07, 2015 at 07:48:48PM +0000, Arnd Bergmann wrote:
In other cases that's actually a good thing. One such example is the "Principles of ARM Memory Maps" document that tells hardware implementers to do a rather complex mapping "To support 36-bit x86 PAE compatible operating systems, such as Linux." but makes life much harder in the process than any of the random mappings we have seen in the wild.
Unfortunately, with any significant amount of RAM (say 16GB), this document becomes pretty useless. It basically forces you to have a very sparse physical address map from 0 to over 40-bit. I wouldn't apply the ARM memory maps doc to server systems.
Are you sure? I was under the impression that this document was targetted specifically at servers.
Ah, sorry for the confusion, I haven't read the latest (apparently from 2012) update which covers 44 and 48-bit memory maps.
The only downside is that for more than 32GB of RAM (up to 512GB) it requires a 40-bit memory map. Given the sparseness, we can't use 3-levels of page table with 4KB pages which can only cover 39-bit. Anyway, not a major issue.
On Wed, Jan 07, 2015 at 05:27:41PM +0000, Mark Brown wrote:
On Wed, Jan 07, 2015 at 02:06:28PM +0100, Arnd Bergmann wrote:
On Wednesday 07 January 2015 11:50:39 Catalin Marinas wrote:
From what I gathered so far, the main reason for _some_ vendors is not support for "other" OS but actually features that ACPI has and DT doesn't (like AML; I deliberately ignore statements like "industry standard"). _If_ such reasons are sound, maybe they have a case for ACPI-only machines targeted primarily at Linux.
What I got from the replies from HP, Huawei and from earlier discussions with Jon is that they all hope to get to the point of relying on AML alone to bridge the differences between SoC families. However, I don't see that happening with the limited hardware compatibility that the existing SBSA provides:
I tend to agree with you that it's an overreach to think that this is going to completely abstract away the differences between SoCs from different vendors without substantial further standardization work. However it does seem reasonable to expect that features like AML are going to be more successful in handling board differences and incremental revisions of SoCs - things like interactions with system power controllers for example. That seems like a useful win in and of itself, and one that's worth supporting.
This piqued my interest, so I did a little research and found the following to describe AML (second para under "What does this mean?")
http://community.arm.com/groups/processors/blog/2014/05/01/let-s-talk-acpi-f...
iiuc, AML are basically drivers for some low-level functions provided as binary blobs via the ACPI tables. How does this work in a trusted boot scenario? Can the ACPI tables, and these binary blobs with it, be updated from userspace? If so, is there an authentication mechanism (including for non-secure boot scenarios)?
One of the reasons I've really enjoyed working with ARM platforms and DT is the absence of this type of 'feature'. I honestly don't care whether the kernel gets the board configuration info from DT or ACPI or FOO, as long as we can avoid the security mistakes of the past:
http://www.spiegel.de/international/world/catalog-reveals-nsa-has-back-doors...
""" ... The ANT developers have a clear preference for planting their malicious code in so-called BIOS, software located on a computer's motherboard that is the first thing to load when a computer is turned on.
This has a number of valuable advantages: an infected PC or server appears to be functioning normally, so the infection remains invisible to virus protection and other security programs. And even if the hard drive of an infected computer has been completely erased and a new operating system is installed, the ANT malware can continue to function and ensures that new spyware can once again be loaded onto what is presumed to be a clean computer. ... """
I'm not advocating "throw out AML and ACPI with it!", rather I'd like to see a serious, open, discussion about the security implications of a convenience feature such as AML.
And wrt the kernel, we should ensure we can always provide a fallback for users who prefer not to trust the binary blobs. Which shouldn't be too difficult as we aren't dependent on AML or similar atm.
thx,
Jason.
On 01/07/2015 01:41 PM, Jason Cooper wrote:
On Wed, Jan 07, 2015 at 05:27:41PM +0000, Mark Brown wrote:
On Wed, Jan 07, 2015 at 02:06:28PM +0100, Arnd Bergmann wrote:
On Wednesday 07 January 2015 11:50:39 Catalin Marinas wrote:
From what I gathered so far, the main reason for _some_ vendors is not support for "other" OS but actually features that ACPI has and DT doesn't (like AML; I deliberately ignore statements like "industry standard"). _If_ such reasons are sound, maybe they have a case for ACPI-only machines targeted primarily at Linux.
What I got from the replies from HP, Huawei and from earlier discussions with Jon is that they all hope to get to the point of relying on AML alone to bridge the differences between SoC families. However, I don't see that happening with the limited hardware compatibility that the existing SBSA provides:
I tend to agree with you that it's an overreach to think that this is going to completely abstract away the differences between SoCs from different vendors without substantial further standardization work. However it does seem reasonable to expect that features like AML are going to be more successful in handling board differences and incremental revisions of SoCs - things like interactions with system power controllers for example. That seems like a useful win in and of itself, and one that's worth supporting.
This piqued my interest, so I did a little research and found the following to describe AML (second para under "What does this mean?")
http://community.arm.com/groups/processors/blog/2014/05/01/let-s-talk-acpi-f...
iiuc, AML are basically drivers for some low-level functions provided as binary blobs via the ACPI tables.
AML isn't a "driver" per se. Think of it as providing a couple of methods for doing things like turning on a device, where the interpreted code might cause e.g. a memory address to be written with a value that causes a side effect (e.g. talking with a system configuration co-processor hidden inside the SoC the adjusts the clocking, enables power, configures PHY parameters, etc.). Most of the "AML" that you see on servers is actually just informational, or methods that return data describing the hardware installed.
How does this work in a trusted boot scenario?
No different than on x86.
Can the ACPI tables, and these binary blobs with it, be updated from userspace?
Tables are baked into the firmware and are updated as a result of normal firmware updates (which already has a defined process). There are secondary tables that can augment things like the primary DSDT but those are also provided by the platform. There are only two ways the "OS" might provide a DSDT, but only including here for pedantry:
1). If you compile a kernel specially with an embedded DSDT within the image itself (nobody does this one any more AFAIK).
2). If you attach a special update test DSDT into your initramfs in a particular way, in which case I believe secure boot already is disabled.
But these are all developer/debug things, not intended for users running in a secure boot environment.
If so, is there an authentication mechanism (including for non-secure boot scenarios)?
It's no different than scenarios on x86, which are well covered.
One of the reasons I've really enjoyed working with ARM platforms and DT is the absence of this type of 'feature'. I honestly don't care whether the kernel gets the board configuration info from DT or ACPI or FOO, as long as we can avoid the security mistakes of the past:
http://www.spiegel.de/international/world/catalog-reveals-nsa-has-back-doors...
ACPI is not the great satan. I'm aware certain others in the community have written missinformed blog posts and G+ rants equating ACPI with SMI and even with various other system firmware. I can't force someone to become informed on a topic, especially if it's politically useful to them to hate on ACPI and use the security paranoia handwavy argument.
I'm not advocating "throw out AML and ACPI with it!", rather I'd like to see a serious, open, discussion about the security implications of a convenience feature such as AML.
AML is in (almost) every server you're using today. What you want to be worried about is hidden firmware, especially what might be running inside a Trusted environment or inside an SMI context, or the radio firmware on your phone that the NSA have backdoored. Once we've solved every other issue, we can come back to whether the extremely limited capabilities of AML are what the evil bad guys are using to infiltrate our minds and make us think that we all want to use ACPI.
Jon.
On 01/07/2015 02:58 PM, Jon Masters wrote:
On 01/07/2015 01:41 PM, Jason Cooper wrote:
One of the reasons I've really enjoyed working with ARM platforms and DT is the absence of this type of 'feature'. I honestly don't care whether the kernel gets the board configuration info from DT or ACPI or FOO, as long as we can avoid the security mistakes of the past:
http://www.spiegel.de/international/world/catalog-reveals-nsa-has-back-doors...
ACPI is not the great satan. I'm aware certain others in the community have written missinformed blog posts and G+ rants equating ACPI with SMI and even with various other system firmware. I can't force someone to become informed on a topic, especially if it's politically useful to them to hate on ACPI and use the security paranoia handwavy argument.
To clarify, and this is not directed at you Jason, it is politically useful to some who have written rants those business models are built upon being paid to enable platforms. For those folks, standardized platforms which allow a common OS approach are seen as threatening.
In the previous rants (which were really instigated as a result of the above) ACPI was equated with SMM (System Management Mode), which is a bit like the Secure/Trusted world on AArch64 in which you might run another "Trusted" OS. These are the places where you want to watch out to malware of the kind cited in your link, not in ACPI tables.
Jon.
On Wed, Jan 07, 2015 at 03:05:14PM -0500, Jon Masters wrote:
On 01/07/2015 02:58 PM, Jon Masters wrote:
On 01/07/2015 01:41 PM, Jason Cooper wrote:
One of the reasons I've really enjoyed working with ARM platforms and DT is the absence of this type of 'feature'. I honestly don't care whether the kernel gets the board configuration info from DT or ACPI or FOO, as long as we can avoid the security mistakes of the past:
http://www.spiegel.de/international/world/catalog-reveals-nsa-has-back-doors...
ACPI is not the great satan. I'm aware certain others in the community have written missinformed blog posts and G+ rants equating ACPI with SMI and even with various other system firmware. I can't force someone to become informed on a topic, especially if it's politically useful to them to hate on ACPI and use the security paranoia handwavy argument.
To clarify, and this is not directed at you Jason, it is politically useful to some who have written rants those business models are built upon being paid to enable platforms. For those folks, standardized platforms which allow a common OS approach are seen as threatening.
Ahh, thanks for clarifying.
In the previous rants (which were really instigated as a result of the above) ACPI was equated with SMM (System Management Mode), which is a bit like the Secure/Trusted world on AArch64 in which you might run another "Trusted" OS. These are the places where you want to watch out to malware of the kind cited in your link, not in ACPI tables.
fwiw, I *am* concerned about those spaces. It seems we agree on their vulnerability to attack (plus being meaty targets).
To more concisely state my other reply to you, wrt to AML, I'm primarily concerned about a malicious update to the ACPI tables. The ACPI tables in the update would be otherwise normal, except for the AML blob that contains some extra code. The malicious payload. Then, a routine call into an AML (for pinctrl, say) executes the malicious code.
The plausibility and preventability of that style of attack is what I'm hoping to nail down with this discussion.
thx,
Jason.
On Wednesday 07 January 2015 17:59:04 Jason Cooper wrote:
On Wed, Jan 07, 2015 at 03:05:14PM -0500, Jon Masters wrote:
On 01/07/2015 02:58 PM, Jon Masters wrote:
On 01/07/2015 01:41 PM, Jason Cooper wrote:
One of the reasons I've really enjoyed working with ARM platforms and DT is the absence of this type of 'feature'. I honestly don't care whether the kernel gets the board configuration info from DT or ACPI or FOO, as long as we can avoid the security mistakes of the past:
http://www.spiegel.de/international/world/catalog-reveals-nsa-has-back-doors...
ACPI is not the great satan. I'm aware certain others in the community have written missinformed blog posts and G+ rants equating ACPI with SMI and even with various other system firmware. I can't force someone to become informed on a topic, especially if it's politically useful to them to hate on ACPI and use the security paranoia handwavy argument.
To clarify, and this is not directed at you Jason, it is politically useful to some who have written rants those business models are built upon being paid to enable platforms. For those folks, standardized platforms which allow a common OS approach are seen as threatening.
Ahh, thanks for clarifying.
In the previous rants (which were really instigated as a result of the above) ACPI was equated with SMM (System Management Mode), which is a bit like the Secure/Trusted world on AArch64 in which you might run another "Trusted" OS. These are the places where you want to watch out to malware of the kind cited in your link, not in ACPI tables.
fwiw, I *am* concerned about those spaces. It seems we agree on their vulnerability to attack (plus being meaty targets).
To more concisely state my other reply to you, wrt to AML, I'm primarily concerned about a malicious update to the ACPI tables. The ACPI tables in the update would be otherwise normal, except for the AML blob that contains some extra code. The malicious payload. Then, a routine call into an AML (for pinctrl, say) executes the malicious code.
The plausibility and preventability of that style of attack is what I'm hoping to nail down with this discussion.
If you want to run hidden code through the firmware, then doing an attack on Intel SMM or ARM TrustZone would be much harder to detect and as easy to get in, as long as you have the ability to flash arbitrary firmware. I think this has been shown to happen in the wild. That code could go and manipulate the running kernel image to do something else.
Running code inside of the AML interpreter is fairly limited for the purpose of an attack [*], but there might be bugs in the interpreter that allow arbitrary code execution from malicious firmware. I think this case would be similar to constructing a malicious DT blob that exploits a bug in the DT parser for arbitrary code execution. The AML interpreter is a relatively large chunk of code, but it's self-contained. In comparison, the DT parser is much smaller, but has the additional (theoretical) problem of potential buffer overflows in any drivers that use it incorrectly (e.g. format string attacks on string properties). Another difference is that the AML code is intended to not be user-upgradable without a full firmware upgrade, while a DT blob is meant to be easily replaced if necessary without flashing the firmware, using the same permissions you need for updating the OS.
I'm deliberately not trying to draw conclusions regarding whether AML is more or less secure than DT, but the above is my understanding of the fundamental differences.
Arnd
[*] I would assume you can get AML code to write to arbitrary physical memory locations without much effort, but it has rather limited arithmetical capabilities which makes it hard to know where to write to.
Security is a much big scale issue. The industry has all kind of solutions to deal with firmware security. In ARM system, the Firmware has been designed with higher privilege/security than OS. I will suggest we trust firmware security and focus on Linux itself.
-----Original Message----- From: linaro-acpi-bounces@lists.linaro.org [mailto:linaro-acpi-bounces@lists.linaro.org] On Behalf Of Arnd Bergmann Sent: Thursday, January 08, 2015 3:27 AM To: Jason Cooper Cc: Rob Herring; Daniel Lezcano; Robert Richter; linaro-acpi@lists.linaro.org; Marc Zyngier; Jon Masters; Randy Dunlap; Liviu Dudau; Robert Moore; Will Deacon; linux-kernel@vger.kernel.org; linux-acpi@vger.kernel.org; Mark Brown; Rafael J. Wysocki; Lv Zheng; Catalin Marinas; Bjorn Helgaas; linux-arm-kernel@lists.infradead.org; Olof Johansson Subject: Re: [Linaro-acpi] [PATCH v5 18/18] Documentation: ACPI for ARM64
On Wednesday 07 January 2015 17:59:04 Jason Cooper wrote:
On Wed, Jan 07, 2015 at 03:05:14PM -0500, Jon Masters wrote:
On 01/07/2015 02:58 PM, Jon Masters wrote:
On 01/07/2015 01:41 PM, Jason Cooper wrote:
One of the reasons I've really enjoyed working with ARM platforms and DT is the absence of this type of 'feature'. I honestly don't care whether the kernel gets the board configuration info from DT or ACPI or FOO, as long as we can avoid the security mistakes of the past:
http://www.spiegel.de/international/world/catalog-reveals-nsa-has -back-doors-for-numerous-devices-a-940994.html
ACPI is not the great satan. I'm aware certain others in the community have written missinformed blog posts and G+ rants equating ACPI with SMI and even with various other system firmware. I can't force someone to become informed on a topic, especially if it's politically useful to them to hate on ACPI and use the security paranoia handwavy argument.
To clarify, and this is not directed at you Jason, it is politically useful to some who have written rants those business models are built upon being paid to enable platforms. For those folks, standardized platforms which allow a common OS approach are seen as threatening.
Ahh, thanks for clarifying.
In the previous rants (which were really instigated as a result of the above) ACPI was equated with SMM (System Management Mode), which is a bit like the Secure/Trusted world on AArch64 in which you might run another "Trusted" OS. These are the places where you want to watch out to malware of the kind cited in your link, not in ACPI tables.
fwiw, I *am* concerned about those spaces. It seems we agree on their vulnerability to attack (plus being meaty targets).
To more concisely state my other reply to you, wrt to AML, I'm primarily concerned about a malicious update to the ACPI tables. The ACPI tables in the update would be otherwise normal, except for the AML blob that contains some extra code. The malicious payload. Then, a routine call into an AML (for pinctrl, say) executes the malicious code.
The plausibility and preventability of that style of attack is what I'm hoping to nail down with this discussion.
If you want to run hidden code through the firmware, then doing an attack on Intel SMM or ARM TrustZone would be much harder to detect and as easy to get in, as long as you have the ability to flash arbitrary firmware. I think this has been shown to happen in the wild. That code could go and manipulate the running kernel image to do something else.
Running code inside of the AML interpreter is fairly limited for the purpose of an attack [*], but there might be bugs in the interpreter that allow arbitrary code execution from malicious firmware. I think this case would be similar to constructing a malicious DT blob that exploits a bug in the DT parser for arbitrary code execution. The AML interpreter is a relatively large chunk of code, but it's self-contained. In comparison, the DT parser is much smaller, but has the additional (theoretical) problem of potential buffer overflows in any drivers that use it incorrectly (e.g. format string attacks on string properties). Another difference is that the AML code is intended to not be user-upgradable without a full firmware upgrade, while a DT blob is meant to be easily replaced if necessary without flashing the firmware, using the same permissions you need for updating the OS.
I'm deliberately not trying to draw conclusions regarding whether AML is more or less secure than DT, but the above is my understanding of the fundamental differences.
Arnd
[*] I would assume you can get AML code to write to arbitrary physical memory locations without much effort, but it has rather limited arithmetical capabilities which makes it hard to know where to write to.
_______________________________________________ Linaro-acpi mailing list Linaro-acpi@lists.linaro.org http://lists.linaro.org/mailman/listinfo/linaro-acpi
On Thu, 8 Jan 2015 19:59:23 +0000 Kangkang Shen Kangkang.Shen@huawei.com wrote:
Security is a much big scale issue. The industry has all kind of solutions to deal with firmware security. In ARM system, the Firmware has been designed with higher privilege/security than OS. I will suggest we trust firmware security and focus on Linux itself.
Security works by trusting nothing, by questioning every assumption. I'm sure there are a lot of governments would prefer everyone just carried on trusting them as they have a higher privilege/security level....
My point here is we should focus on ACPI support for Linux OS and leave the security topics to UEFI secure boot, trusted firmware groups. In US, we have NIST publications 800-147, 800-147b and 800-155 to address BIOS security issues. As compared with the widely used x86 serves, the firmware in AArch64 is more secure because of the 4 exception level architecture. Up to today, I do not aware any security attack incidents through AML.
-----Original Message----- From: One Thousand Gnomes [mailto:gnomes@lxorguk.ukuu.org.uk] Sent: Thursday, January 08, 2015 2:20 PM To: Kangkang Shen Cc: Arnd Bergmann; Jason Cooper; Rob Herring; Daniel Lezcano; Robert Richter; linaro-acpi@lists.linaro.org; Marc Zyngier; Jon Masters; Randy Dunlap; Liviu Dudau; Robert Moore; Will Deacon; linux-kernel@vger.kernel.org; linux-acpi@vger.kernel.org; Mark Brown; Rafael J. Wysocki; Lv Zheng; Catalin Marinas; Bjorn Helgaas; "linux-arm-kernel@lists.infradead.org" linux-arm-kernel@lists.infradead.org, Olof Johansson olof@lixom.net"@lxorguk.ukuu.org.uk Subject: Re: [Linaro-acpi] [PATCH v5 18/18] Documentation: ACPI for ARM64
On Thu, 8 Jan 2015 19:59:23 +0000 Kangkang Shen Kangkang.Shen@huawei.com wrote:
Security is a much big scale issue. The industry has all kind of solutions to deal with firmware security. In ARM system, the Firmware has been designed with higher privilege/security than OS. I will suggest we trust firmware security and focus on Linux itself.
Security works by trusting nothing, by questioning every assumption. I'm sure there are a lot of governments would prefer everyone just carried on trusting them as they have a higher privilege/security level....
On Wed, Jan 07, 2015 at 02:58:42PM -0500, Jon Masters wrote:
On 01/07/2015 01:41 PM, Jason Cooper wrote:
On Wed, Jan 07, 2015 at 05:27:41PM +0000, Mark Brown wrote:
On Wed, Jan 07, 2015 at 02:06:28PM +0100, Arnd Bergmann wrote:
On Wednesday 07 January 2015 11:50:39 Catalin Marinas wrote:
From what I gathered so far, the main reason for _some_ vendors is not support for "other" OS but actually features that ACPI has and DT doesn't (like AML; I deliberately ignore statements like "industry standard"). _If_ such reasons are sound, maybe they have a case for ACPI-only machines targeted primarily at Linux.
What I got from the replies from HP, Huawei and from earlier discussions with Jon is that they all hope to get to the point of relying on AML alone to bridge the differences between SoC families. However, I don't see that happening with the limited hardware compatibility that the existing SBSA provides:
I tend to agree with you that it's an overreach to think that this is going to completely abstract away the differences between SoCs from different vendors without substantial further standardization work. However it does seem reasonable to expect that features like AML are going to be more successful in handling board differences and incremental revisions of SoCs - things like interactions with system power controllers for example. That seems like a useful win in and of itself, and one that's worth supporting.
This piqued my interest, so I did a little research and found the following to describe AML (second para under "What does this mean?")
http://community.arm.com/groups/processors/blog/2014/05/01/let-s-talk-acpi-f...
iiuc, AML are basically drivers for some low-level functions provided as binary blobs via the ACPI tables.
AML isn't a "driver" per se. Think of it as providing a couple of methods for doing things like turning on a device, where the interpreted code might cause e.g. a memory address to be written with a value that causes a side effect (e.g. talking with a system configuration co-processor hidden inside the SoC the adjusts the clocking, enables power, configures PHY parameters, etc.). Most of the "AML" that you see on servers is actually just informational, or methods that return data describing the hardware installed.
So, similar in scope to an irqchip driver? Because that's what I was thinking when I said "driver", not alsa or drm... Thanks for great description.
How does this work in a trusted boot scenario?
No different than on x86.
Suprisingly, I don't do much with x86 development-wise. The x86 boxes are just tools to me. So I'm not very familiar with the intricacies there. Do you have a pointer to ACPI update security standards/protocols?
Can the ACPI tables, and these binary blobs with it, be updated from userspace?
Tables are baked into the firmware and are updated as a result of normal firmware updates (which already has a defined process). There are secondary tables that can augment things like the primary DSDT but those are also provided by the platform. There are only two ways the "OS" might provide a DSDT, but only including here for pedantry:
1). If you compile a kernel specially with an embedded DSDT within the image itself (nobody does this one any more AFAIK).
2). If you attach a special update test DSDT into your initramfs in a particular way, in which case I believe secure boot already is disabled.
But these are all developer/debug things, not intended for users running in a secure boot environment.
Right, I'm more concerned about the update process being the vector to inject bad code.
If so, is there an authentication mechanism (including for non-secure boot scenarios)?
It's no different than scenarios on x86, which are well covered.
One of the reasons I've really enjoyed working with ARM platforms and DT is the absence of this type of 'feature'. I honestly don't care whether the kernel gets the board configuration info from DT or ACPI or FOO, as long as we can avoid the security mistakes of the past:
http://www.spiegel.de/international/world/catalog-reveals-nsa-has-back-doors...
ACPI is not the great satan.
Relax, I'm not saying, nor implying that. :) I *am* saying that upgradeable executable code not loaded from traditional OS storage (harddisk, flash) is a valid security concern.
I'm aware certain others in the community have written missinformed blog posts and G+ rants equating ACPI with SMI and even with various other system firmware.
You're in luck, I don't blog or do social media. :-P
I can't force someone to become informed on a topic, especially if it's politically useful to them to hate on ACPI and use the security paranoia handwavy argument.
I'm not sure where you got that from. I said very specifically, since trimmed, that I don't care where the board configuration data comes from, DT, ACPI, or FOO.
If ACPI works, is stable, and integrates with the community, I'd use it. Right now, DT is the closest to that goal, so it's what I prefer.
I'm not advocating "throw out AML and ACPI with it!", rather I'd like to see a serious, open, discussion about the security implications of a convenience feature such as AML.
AML is in (almost) every server you're using today.
"It's already everywhere" is not a valid reason to dismiss a security discussion. It's *not* on ARM today, so AML on ARM is a significant change to ecosystem. I'd hope I'm not the only person who was taking advantage of fewer firmware hiding spots that ARM provides. :)
What you want to be worried about is hidden firmware, especially what might be running inside a Trusted environment or inside an SMI context, or the radio firmware on your phone that the NSA have backdoored.
These are all valid security concerns, but this thread was about ACPI/AML on ARM, so I didn't mention them. Just because there are three other holes doesn't mean we should throw up our hands and not address the one in front of us.
Once we've solved every other issue, we can come back to whether the extremely limited capabilities of AML are what the evil bad guys are using to infiltrate our minds and make us think that we all want to use ACPI.
Umm, wow. I was not implying that a malicious piece of code would call AML in a bad way to do something nefarious. I *am* concerned about a malicious update to the ACPI tables hooking an innocent AML call so that *any* malicious code could be run at boot time, or suspend/resume, shutdown, etc.
Sorry to have plucked a nerve, but I am sincerely interested in having a *rational* discussion about how this changes the ARM ecosystem. fwiw, if I didn't think this was going to hit mainline, I wouldn't've bothered bringing it up. ;-)
thx,
Jason.
Jason,
Will followup more later...was being a little sarcastic before...no raw nerve ;) but sarcasm translates badly so apologies. Will send a better reply when back online :) Good points!
Jon.
On 2014年12月25日 01:18, Catalin Marinas wrote: [...]
In addition to the above and _DSD requirements/banning, I would also add some clear statements around:
_OSC: only global/published capabilities are allowed. For device-specific _OSC we need a process or maybe we can ban them entirely and rely on _DSD once we clarify the process.
_OSI: firmware must not check for certain _OSI strings. Here I'm not sure what we would have to do for ARM Linux. Reporting "Windows" does not make any sense but not reporting anything can, as Matthew Garrett pointed out, can be interpreted by firmware as "Linux". In addition to any statements in this document, I suggest you patch drivers/acpi/acpica/utosi.c accordingly, maybe report "Linux" for ARM and print a kernel warning so that we notice earlier.
ACPI_OS_NAME: this is globally defined as "Microsoft Windows NT". It doesn't make much sense in the ARM context. Could we change it to "Linux" when CONFIG_ARM64?
We will work on this both on ASWG and linux ACPI driver side, as Dong and Charles pointed out, _OSI things can be solved in ACPI spec, when that is done, we can modify the kernel driver to fix the problems above.
Compatibility with older kernels: ACPI firmware must work, even though not fully optimal, with the earliest kernel version implementing the targeted ACPI spec. There may be a need for new drivers but otherwise adding things like CPU power management should not break older kernel versions. In addition, the ACPI firmware must also work with the latest kernel version.
It should be, and I think that's why we need ACPI (or DT) here :)
Thanks Hanjun
On Sun, Jan 04, 2015 at 09:39:24AM +0000, Hanjun Guo wrote:
On 2014年12月25日 01:18, Catalin Marinas wrote: [...]
In addition to the above and _DSD requirements/banning, I would also add some clear statements around:
_OSC: only global/published capabilities are allowed. For device-specific _OSC we need a process or maybe we can ban them entirely and rely on _DSD once we clarify the process.
_OSI: firmware must not check for certain _OSI strings. Here I'm not sure what we would have to do for ARM Linux. Reporting "Windows" does not make any sense but not reporting anything can, as Matthew Garrett pointed out, can be interpreted by firmware as "Linux". In addition to any statements in this document, I suggest you patch drivers/acpi/acpica/utosi.c accordingly, maybe report "Linux" for ARM and print a kernel warning so that we notice earlier.
ACPI_OS_NAME: this is globally defined as "Microsoft Windows NT". It doesn't make much sense in the ARM context. Could we change it to "Linux" when CONFIG_ARM64?
We will work on this both on ASWG and linux ACPI driver side, as Dong and Charles pointed out, _OSI things can be solved in ACPI spec, when that is done, we can modify the kernel driver to fix the problems above.
Which driver?
What about ACPI_OS_NAME? Would you suggest it is fine to report "Microsoft Windows NT" on an ARM system? That _OS_ not _OSI.
On 2015年01月05日 19:05, Catalin Marinas wrote:
On Sun, Jan 04, 2015 at 09:39:24AM +0000, Hanjun Guo wrote:
On 2014年12月25日 01:18, Catalin Marinas wrote: [...]
In addition to the above and _DSD requirements/banning, I would also add some clear statements around:
_OSC: only global/published capabilities are allowed. For device-specific _OSC we need a process or maybe we can ban them entirely and rely on _DSD once we clarify the process.
_OSI: firmware must not check for certain _OSI strings. Here I'm not sure what we would have to do for ARM Linux. Reporting "Windows" does not make any sense but not reporting anything can, as Matthew Garrett pointed out, can be interpreted by firmware as "Linux". In addition to any statements in this document, I suggest you patch drivers/acpi/acpica/utosi.c accordingly, maybe report "Linux" for ARM and print a kernel warning so that we notice earlier.
ACPI_OS_NAME: this is globally defined as "Microsoft Windows NT". It doesn't make much sense in the ARM context. Could we change it to "Linux" when CONFIG_ARM64?
I think we can introduce a Kconfig such as CONFIG_ACPI_OS_NAME_LINUX, selected by ARM64 and change ACPI_OS_NAME to "Linux" when CONFIG_ACPI_OS_NAME_LINUX defined. (we can not add CONFIG_ARM64 in ACPICA code directly since it will be used by windows too)
some code like below:
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index b1f9a20..de567a3 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -1,5 +1,6 @@ config ARM64 def_bool y + select ACPI_OS_NAME_LINUX if ACPI select ARCH_BINFMT_ELF_RANDOMIZE_PIE select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE select ARCH_HAS_GCOV_PROFILE_ALL diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index 8951cef..11a10ac 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig @@ -369,6 +369,10 @@ config ACPI_REDUCED_HARDWARE_ONLY
If you are unsure what to do, do not enable this option.
+config ACPI_OS_NAME_LINUX + bool "Using Linux for _OS method" if EXPERT + def_bool n + source "drivers/acpi/apei/Kconfig"
config ACPI_EXTLOG diff --git a/include/acpi/acconfig.h b/include/acpi/acconfig.h index 5a0a3e5..db5e13e 100644 --- a/include/acpi/acconfig.h +++ b/include/acpi/acconfig.h @@ -69,7 +69,11 @@ * code that will not execute the _OSI method unless _OS matches the string * below. Therefore, change this string at your own risk. */ +#ifndef ACPI_OS_NAME_USING_LINUX #define ACPI_OS_NAME "Microsoft Windows NT" +#else +#define ACPI_OS_NAME "Linux" +#endif
/* Maximum objects in the various object caches */
diff --git a/include/acpi/platform/aclinux.h b/include/acpi/platform/aclinux.h index 1ba7c19..45d51d2 100644 --- a/include/acpi/platform/aclinux.h +++ b/include/acpi/platform/aclinux.h @@ -69,6 +69,10 @@ #define ACPI_REDUCED_HARDWARE 1 #endif
+#ifdef CONFIG_ACPI_OS_NAME_LINUX +#define ACPI_OS_NAME_USING_LINUX 1 +#endif + #include <linux/string.h> #include <linux/kernel.h> #include <linux/ctype.h>
We will work on this both on ASWG and linux ACPI driver side, as Dong and Charles pointed out, _OSI things can be solved in ACPI spec, when that is done, we can modify the kernel driver to fix the problems above.
Which driver?
the ACPICA core driver as you suggested, sorry for the confusion.
What about ACPI_OS_NAME? Would you suggest it is fine to report "Microsoft Windows NT" on an ARM system? That _OS_ not _OSI.
No, not at all. I prefer "Linux" In include/acpi/acconfig.h, when ACPI_OS_NAME defined, it says: "OS name, used for the _OS object. The _OS object is essentially obsolete,..." for some legacy reasons, we needed "Microsoft Windows NT", but ACPI for ARM64 on linux is totally new, I think we can change it to "Linux" when CONFIG_ARM64 as you suggested.
Thanks Hanjun
On Tue, Jan 06, 2015 at 11:11:07AM +0000, Hanjun Guo wrote:
On 2015年01月05日 19:05, Catalin Marinas wrote:
On Sun, Jan 04, 2015 at 09:39:24AM +0000, Hanjun Guo wrote:
On 2014年12月25日 01:18, Catalin Marinas wrote: [...]
In addition to the above and _DSD requirements/banning, I would also add some clear statements around:
_OSC: only global/published capabilities are allowed. For device-specific _OSC we need a process or maybe we can ban them entirely and rely on _DSD once we clarify the process.
_OSI: firmware must not check for certain _OSI strings. Here I'm not sure what we would have to do for ARM Linux. Reporting "Windows" does not make any sense but not reporting anything can, as Matthew Garrett pointed out, can be interpreted by firmware as "Linux". In addition to any statements in this document, I suggest you patch drivers/acpi/acpica/utosi.c accordingly, maybe report "Linux" for ARM and print a kernel warning so that we notice earlier.
ACPI_OS_NAME: this is globally defined as "Microsoft Windows NT". It doesn't make much sense in the ARM context. Could we change it to "Linux" when CONFIG_ARM64?
I think we can introduce a Kconfig such as CONFIG_ACPI_OS_NAME_LINUX, selected by ARM64 and change ACPI_OS_NAME to "Linux" when CONFIG_ACPI_OS_NAME_LINUX defined. (we can not add CONFIG_ARM64 in ACPICA code directly since it will be used by windows too)
some code like below:
This looks fine for me (with some minor comments below) but I'm not an ACPI expert to say there wouldn't be any issues.
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index b1f9a20..de567a3 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -1,5 +1,6 @@ config ARM64 def_bool y
select ACPI_OS_NAME_LINUX if ACPI select ARCH_BINFMT_ELF_RANDOMIZE_PIE select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE select ARCH_HAS_GCOV_PROFILE_ALL
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index 8951cef..11a10ac 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig @@ -369,6 +369,10 @@ config ACPI_REDUCED_HARDWARE_ONLY
If you are unsure what to do, do not enable this option.
+config ACPI_OS_NAME_LINUX
bool "Using Linux for _OS method" if EXPERT
def_bool n
No need for a default n, it is off by default. Alternatively you could say:
default y if ARM64
source "drivers/acpi/apei/Kconfig"
config ACPI_EXTLOG
diff --git a/include/acpi/acconfig.h b/include/acpi/acconfig.h index 5a0a3e5..db5e13e 100644 --- a/include/acpi/acconfig.h +++ b/include/acpi/acconfig.h @@ -69,7 +69,11 @@
- code that will not execute the _OSI method unless _OS matches the
string
- below. Therefore, change this string at your own risk.
*/ +#ifndef ACPI_OS_NAME_USING_LINUX #define ACPI_OS_NAME "Microsoft Windows NT" +#else +#define ACPI_OS_NAME "Linux" +#endif
Can you not use CONFIG_ACPI_OS_NAME_LINUX directly here without introducing another macro?
We will work on this both on ASWG and linux ACPI driver side, as Dong and Charles pointed out, _OSI things can be solved in ACPI spec, when that is done, we can modify the kernel driver to fix the problems above.
Which driver?
the ACPICA core driver as you suggested, sorry for the confusion.
What about ACPI_OS_NAME? Would you suggest it is fine to report "Microsoft Windows NT" on an ARM system? That _OS_ not _OSI.
No, not at all. I prefer "Linux" In include/acpi/acconfig.h, when ACPI_OS_NAME defined, it says: "OS name, used for the _OS object. The _OS object is essentially obsolete,..." for some legacy reasons, we needed "Microsoft Windows NT", but ACPI for ARM64 on linux is totally new, I think we can change it to "Linux" when CONFIG_ARM64 as you suggested.
We could ignore this change for now if we don't expect the _OS object to be used at all. But do we have any other way to check the AML code for this? Would FWTS catch such obsolete cases?
On 2015年01月06日 19:29, Catalin Marinas wrote:
On Tue, Jan 06, 2015 at 11:11:07AM +0000, Hanjun Guo wrote:
On 2015年01月05日 19:05, Catalin Marinas wrote:
On Sun, Jan 04, 2015 at 09:39:24AM +0000, Hanjun Guo wrote:
On 2014年12月25日 01:18, Catalin Marinas wrote: [...]
In addition to the above and _DSD requirements/banning, I would also add some clear statements around:
_OSC: only global/published capabilities are allowed. For device-specific _OSC we need a process or maybe we can ban them entirely and rely on _DSD once we clarify the process.
_OSI: firmware must not check for certain _OSI strings. Here I'm not sure what we would have to do for ARM Linux. Reporting "Windows" does not make any sense but not reporting anything can, as Matthew Garrett pointed out, can be interpreted by firmware as "Linux". In addition to any statements in this document, I suggest you patch drivers/acpi/acpica/utosi.c accordingly, maybe report "Linux" for ARM and print a kernel warning so that we notice earlier.
ACPI_OS_NAME: this is globally defined as "Microsoft Windows NT". It doesn't make much sense in the ARM context. Could we change it to "Linux" when CONFIG_ARM64?
I think we can introduce a Kconfig such as CONFIG_ACPI_OS_NAME_LINUX, selected by ARM64 and change ACPI_OS_NAME to "Linux" when CONFIG_ACPI_OS_NAME_LINUX defined. (we can not add CONFIG_ARM64 in ACPICA code directly since it will be used by windows too)
some code like below:
This looks fine for me (with some minor comments below) but I'm not an ACPI expert to say there wouldn't be any issues.
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index b1f9a20..de567a3 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -1,5 +1,6 @@ config ARM64 def_bool y
select ACPI_OS_NAME_LINUX if ACPI select ARCH_BINFMT_ELF_RANDOMIZE_PIE select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE select ARCH_HAS_GCOV_PROFILE_ALL
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index 8951cef..11a10ac 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig @@ -369,6 +369,10 @@ config ACPI_REDUCED_HARDWARE_ONLY
If you are unsure what to do, do not enable this option.
+config ACPI_OS_NAME_LINUX
bool "Using Linux for _OS method" if EXPERT
def_bool n
No need for a default n, it is off by default. Alternatively you could say:
default y if ARM64
ok.
source "drivers/acpi/apei/Kconfig"
config ACPI_EXTLOG
diff --git a/include/acpi/acconfig.h b/include/acpi/acconfig.h index 5a0a3e5..db5e13e 100644 --- a/include/acpi/acconfig.h +++ b/include/acpi/acconfig.h @@ -69,7 +69,11 @@ * code that will not execute the _OSI method unless _OS matches the string * below. Therefore, change this string at your own risk. */ +#ifndef ACPI_OS_NAME_USING_LINUX #define ACPI_OS_NAME "Microsoft Windows NT" +#else +#define ACPI_OS_NAME "Linux" +#endif
Can you not use CONFIG_ACPI_OS_NAME_LINUX directly here without introducing another macro?
acconfig.h is part of ACPICA core and will be shared by windows and other OS, so use CONFIG from Linux in this file is not allowed I think.
We will work on this both on ASWG and linux ACPI driver side, as Dong and Charles pointed out, _OSI things can be solved in ACPI spec, when that is done, we can modify the kernel driver to fix the problems above.
Which driver?
the ACPICA core driver as you suggested, sorry for the confusion.
What about ACPI_OS_NAME? Would you suggest it is fine to report "Microsoft Windows NT" on an ARM system? That _OS_ not _OSI.
No, not at all. I prefer "Linux" In include/acpi/acconfig.h, when ACPI_OS_NAME defined, it says: "OS name, used for the _OS object. The _OS object is essentially obsolete,..." for some legacy reasons, we needed "Microsoft Windows NT", but ACPI for ARM64 on linux is totally new, I think we can change it to "Linux" when CONFIG_ARM64 as you suggested.
We could ignore this change for now if we don't expect the _OS object to be used at all. But do we have any other way to check the AML code for this? Would FWTS catch such obsolete cases?
I'm not sure, I will check it and get back when I have the answer.
Thanks Hanjun
On 6 January 2015 at 13:50, Hanjun Guo hanjun.guo@linaro.org wrote:
On 2015年01月06日 19:29, Catalin Marinas wrote:
On Tue, Jan 06, 2015 at 11:11:07AM +0000, Hanjun Guo wrote:
On 2015年01月05日 19:05, Catalin Marinas wrote:
On Sun, Jan 04, 2015 at 09:39:24AM +0000, Hanjun Guo wrote:
On 2014年12月25日 01:18, Catalin Marinas wrote: [...]
In addition to the above and _DSD requirements/banning, I would also add some clear statements around:
_OSC: only global/published capabilities are allowed. For device-specific _OSC we need a process or maybe we can ban them entirely and rely on _DSD once we clarify the process.
_OSI: firmware must not check for certain _OSI strings. Here I'm not sure what we would have to do for ARM Linux. Reporting "Windows" does not make any sense but not reporting anything can, as Matthew Garrett pointed out, can be interpreted by firmware as "Linux". In addition to any statements in this document, I suggest you patch drivers/acpi/acpica/utosi.c accordingly, maybe report "Linux" for ARM and print a kernel warning so that we notice earlier.
ACPI_OS_NAME: this is globally defined as "Microsoft Windows NT". It doesn't make much sense in the ARM context. Could we change it to "Linux" when CONFIG_ARM64?
I think we can introduce a Kconfig such as CONFIG_ACPI_OS_NAME_LINUX, selected by ARM64 and change ACPI_OS_NAME to "Linux" when CONFIG_ACPI_OS_NAME_LINUX defined. (we can not add CONFIG_ARM64 in ACPICA code directly since it will be used by windows too)
some code like below:
This looks fine for me (with some minor comments below) but I'm not an ACPI expert to say there wouldn't be any issues.
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index b1f9a20..de567a3 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -1,5 +1,6 @@ config ARM64 def_bool y
select ACPI_OS_NAME_LINUX if ACPI select ARCH_BINFMT_ELF_RANDOMIZE_PIE select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE select ARCH_HAS_GCOV_PROFILE_ALL
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index 8951cef..11a10ac 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig @@ -369,6 +369,10 @@ config ACPI_REDUCED_HARDWARE_ONLY
If you are unsure what to do, do not enable this option.
+config ACPI_OS_NAME_LINUX
bool "Using Linux for _OS method" if EXPERT
def_bool n
No need for a default n, it is off by default. Alternatively you could say:
default y if ARM64
ok.
source "drivers/acpi/apei/Kconfig"
config ACPI_EXTLOG
diff --git a/include/acpi/acconfig.h b/include/acpi/acconfig.h index 5a0a3e5..db5e13e 100644 --- a/include/acpi/acconfig.h +++ b/include/acpi/acconfig.h @@ -69,7 +69,11 @@ * code that will not execute the _OSI method unless _OS matches the string * below. Therefore, change this string at your own risk. */ +#ifndef ACPI_OS_NAME_USING_LINUX #define ACPI_OS_NAME "Microsoft Windows NT" +#else +#define ACPI_OS_NAME "Linux" +#endif
Can you not use CONFIG_ACPI_OS_NAME_LINUX directly here without introducing another macro?
acconfig.h is part of ACPICA core and will be shared by windows and other OS, so use CONFIG from Linux in this file is not allowed I think.
We could just propse #ifndef ACPI_OS_NAME #define ACPI_OS_NAME "Microsoft Windows NT" #endif
to acpica maintainers. This will not alter Windows or other software usage but we can then override it in Linux when/if we want to.
Graeme
On 2015年01月06日 21:54, G Gregory wrote:
On 6 January 2015 at 13:50, Hanjun Guo hanjun.guo@linaro.org wrote:
On 2015年01月06日 19:29, Catalin Marinas wrote:
On Tue, Jan 06, 2015 at 11:11:07AM +0000, Hanjun Guo wrote:
On 2015年01月05日 19:05, Catalin Marinas wrote:
On Sun, Jan 04, 2015 at 09:39:24AM +0000, Hanjun Guo wrote:
On 2014年12月25日 01:18, Catalin Marinas wrote: [...] > > > In addition to the above and _DSD requirements/banning, I would also > add > some clear statements around: > > _OSC: only global/published capabilities are allowed. For > device-specific _OSC we need a process or maybe we can ban them > entirely > and rely on _DSD once we clarify the process. > > _OSI: firmware must not check for certain _OSI strings. Here I'm not > sure what we would have to do for ARM Linux. Reporting "Windows" does > not make any sense but not reporting anything can, as Matthew Garrett > pointed out, can be interpreted by firmware as "Linux". In addition to > any statements in this document, I suggest you patch > drivers/acpi/acpica/utosi.c accordingly, maybe report "Linux" for ARM > and print a kernel warning so that we notice earlier. > > ACPI_OS_NAME: this is globally defined as "Microsoft Windows NT". It > doesn't make much sense in the ARM context. Could we change it to > "Linux" when CONFIG_ARM64?
I think we can introduce a Kconfig such as CONFIG_ACPI_OS_NAME_LINUX, selected by ARM64 and change ACPI_OS_NAME to "Linux" when CONFIG_ACPI_OS_NAME_LINUX defined. (we can not add CONFIG_ARM64 in ACPICA code directly since it will be used by windows too)
some code like below:
This looks fine for me (with some minor comments below) but I'm not an ACPI expert to say there wouldn't be any issues.
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index b1f9a20..de567a3 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -1,5 +1,6 @@ config ARM64 def_bool y
select ACPI_OS_NAME_LINUX if ACPI select ARCH_BINFMT_ELF_RANDOMIZE_PIE select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE select ARCH_HAS_GCOV_PROFILE_ALL
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index 8951cef..11a10ac 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig @@ -369,6 +369,10 @@ config ACPI_REDUCED_HARDWARE_ONLY
If you are unsure what to do, do not enable this option.
+config ACPI_OS_NAME_LINUX
bool "Using Linux for _OS method" if EXPERT
def_bool n
No need for a default n, it is off by default. Alternatively you could say:
default y if ARM64
ok.
source "drivers/acpi/apei/Kconfig"
config ACPI_EXTLOG
diff --git a/include/acpi/acconfig.h b/include/acpi/acconfig.h index 5a0a3e5..db5e13e 100644 --- a/include/acpi/acconfig.h +++ b/include/acpi/acconfig.h @@ -69,7 +69,11 @@ * code that will not execute the _OSI method unless _OS matches the string * below. Therefore, change this string at your own risk. */ +#ifndef ACPI_OS_NAME_USING_LINUX #define ACPI_OS_NAME "Microsoft Windows NT" +#else +#define ACPI_OS_NAME "Linux" +#endif
Can you not use CONFIG_ACPI_OS_NAME_LINUX directly here without introducing another macro?
acconfig.h is part of ACPICA core and will be shared by windows and other OS, so use CONFIG from Linux in this file is not allowed I think.
We could just propse #ifndef ACPI_OS_NAME #define ACPI_OS_NAME "Microsoft Windows NT" #endif
to acpica maintainers. This will not alter Windows or other software usage but we can then override it in Linux when/if we want to.
this is better and looks great to me :)
Thanks Hanjun
On Tuesday 06 January 2015 11:29:29 Catalin Marinas wrote:
We will work on this both on ASWG and linux ACPI driver side, as Dong and Charles pointed out, _OSI things can be solved in ACPI spec, when that is done, we can modify the kernel driver to fix the problems above.
Which driver?
the ACPICA core driver as you suggested, sorry for the confusion.
What about ACPI_OS_NAME? Would you suggest it is fine to report "Microsoft Windows NT" on an ARM system? That _OS_ not _OSI.
No, not at all. I prefer "Linux" In include/acpi/acconfig.h, when ACPI_OS_NAME defined, it says: "OS name, used for the _OS object. The _OS object is essentially obsolete,..." for some legacy reasons, we needed "Microsoft Windows NT", but ACPI for ARM64 on linux is totally new, I think we can change it to "Linux" when CONFIG_ARM64 as you suggested.
We could ignore this change for now if we don't expect the _OS object to be used at all. But do we have any other way to check the AML code for this? Would FWTS catch such obsolete cases?
How about just leaving it out? It's clearly not used for anything good, so I don't see the point in passing either Linux or "Microsoft Windows NT" here.
Arnd
On Tue, Jan 06, 2015 at 02:05:12PM +0000, Arnd Bergmann wrote:
On Tuesday 06 January 2015 11:29:29 Catalin Marinas wrote:
We will work on this both on ASWG and linux ACPI driver side, as Dong and Charles pointed out, _OSI things can be solved in ACPI spec, when that is done, we can modify the kernel driver to fix the problems above.
Which driver?
the ACPICA core driver as you suggested, sorry for the confusion.
What about ACPI_OS_NAME? Would you suggest it is fine to report "Microsoft Windows NT" on an ARM system? That _OS_ not _OSI.
No, not at all. I prefer "Linux" In include/acpi/acconfig.h, when ACPI_OS_NAME defined, it says: "OS name, used for the _OS object. The _OS object is essentially obsolete,..." for some legacy reasons, we needed "Microsoft Windows NT", but ACPI for ARM64 on linux is totally new, I think we can change it to "Linux" when CONFIG_ARM64 as you suggested.
We could ignore this change for now if we don't expect the _OS object to be used at all. But do we have any other way to check the AML code for this? Would FWTS catch such obsolete cases?
How about just leaving it out? It's clearly not used for anything good, so I don't see the point in passing either Linux or "Microsoft Windows NT" here.
Do you mean defining it to NULL (so it ends up as NULL in acpi_gbl_pre_defined_names) or removing "_OS_" entirely from that array? I really can't tell what the implications are.
-----Original Message----- From: Catalin Marinas [mailto:catalin.marinas@arm.com] Sent: 06 January 2015 14:17 To: Arnd Bergmann Cc: linux-arm-kernel@lists.infradead.org; hanjun.guo@linaro.org; Mark Rutland; linaro-acpi@lists.linaro.org; Will Deacon; Lv Zheng; Rob Herring; Lorenzo Pieralisi; Al Stone; Daniel Lezcano; Robert Moore; linux-acpi@vger.kernel.org; jcm@redhat.com; grant.likely@linaro.org; Charles Garcia-Tobin; Robert Richter; Jason Cooper; Marc Zyngier; Liviu Dudau; Mark Brown; Bjorn Helgaas; graeme.gregory@linaro.org; Kangkang.Shen@huawei.com; Randy Dunlap; Rafael J. Wysocki; linux- kernel@vger.kernel.org; Sudeep Holla; Olof Johansson Subject: Re: [PATCH v5 18/18] Documentation: ACPI for ARM64
On Tue, Jan 06, 2015 at 02:05:12PM +0000, Arnd Bergmann wrote:
On Tuesday 06 January 2015 11:29:29 Catalin Marinas wrote:
We will work on this both on ASWG and linux ACPI driver side,
as Dong
and Charles pointed out, _OSI things can be solved in ACPI
spec, when
that is done, we can modify the kernel driver to fix the
problems above.
Which driver?
the ACPICA core driver as you suggested, sorry for the confusion.
What about ACPI_OS_NAME? Would you suggest it is fine to report "Microsoft Windows NT" on an ARM system? That _OS_ not _OSI.
No, not at all. I prefer "Linux" In include/acpi/acconfig.h, when ACPI_OS_NAME defined, it says: "OS name, used for the _OS object. The _OS object is essentially obsolete,..." for some legacy reasons, we needed "Microsoft Windows NT", but
ACPI
for ARM64 on linux is totally new, I think we can change it to "Linux" when CONFIG_ARM64 as you suggested.
We could ignore this change for now if we don't expect the _OS
object to
be used at all. But do we have any other way to check the AML code
for
this? Would FWTS catch such obsolete cases?
How about just leaving it out? It's clearly not used for anything good, so I don't see the point in passing either Linux or "Microsoft Windows NT" here.
Do you mean defining it to NULL (so it ends up as NULL in acpi_gbl_pre_defined_names) or removing "_OS_" entirely from that array? I really can't tell what the implications are.
To me, given that we don't want to use it in ARM64, it would make sense to have some method to configurably: 0. Leave as is 1. Warn for usage 2. Panic With a configurability method that allows FWTS to make use of it, and therefore catch usages of the method.
Cheers
Charles
-- Catalin
On 01/06/2015 09:16 AM, Catalin Marinas wrote:
On Tue, Jan 06, 2015 at 02:05:12PM +0000, Arnd Bergmann wrote:
On Tuesday 06 January 2015 11:29:29 Catalin Marinas wrote:
We will work on this both on ASWG and linux ACPI driver side, as Dong and Charles pointed out, _OSI things can be solved in ACPI spec, when that is done, we can modify the kernel driver to fix the problems above.
Which driver?
the ACPICA core driver as you suggested, sorry for the confusion.
What about ACPI_OS_NAME? Would you suggest it is fine to report "Microsoft Windows NT" on an ARM system? That _OS_ not _OSI.
No, not at all. I prefer "Linux" In include/acpi/acconfig.h, when ACPI_OS_NAME defined, it says: "OS name, used for the _OS object. The _OS object is essentially obsolete,..." for some legacy reasons, we needed "Microsoft Windows NT", but ACPI for ARM64 on linux is totally new, I think we can change it to "Linux" when CONFIG_ARM64 as you suggested.
We could ignore this change for now if we don't expect the _OS object to be used at all. But do we have any other way to check the AML code for this? Would FWTS catch such obsolete cases?
How about just leaving it out? It's clearly not used for anything good, so I don't see the point in passing either Linux or "Microsoft Windows NT" here.
Do you mean defining it to NULL (so it ends up as NULL in acpi_gbl_pre_defined_names) or removing "_OS_" entirely from that array? I really can't tell what the implications are.
Setting it to NULL is almost certainly (99%+ likely IMO) going to result in some firmware crashing nastily somewhere.
I think I've mentioned before that we're using the ACPI patches in an early access program for partners that we announced last year. I've pinged the team internally and asked that we swiftly change to use whatever name is agreed in this thread so that we can get a lot of other folks to begin testing with a correctly reported OS name.
Jon.
On Tuesday 06 January 2015 11:37:08 Jon Masters wrote:
On 01/06/2015 09:16 AM, Catalin Marinas wrote:
On Tue, Jan 06, 2015 at 02:05:12PM +0000, Arnd Bergmann wrote:
On Tuesday 06 January 2015 11:29:29 Catalin Marinas wrote:
> We will work on this both on ASWG and linux ACPI driver side, as Dong > and Charles pointed out, _OSI things can be solved in ACPI spec, when > that is done, we can modify the kernel driver to fix the problems above.
Which driver?
the ACPICA core driver as you suggested, sorry for the confusion.
What about ACPI_OS_NAME? Would you suggest it is fine to report "Microsoft Windows NT" on an ARM system? That _OS_ not _OSI.
No, not at all. I prefer "Linux" In include/acpi/acconfig.h, when ACPI_OS_NAME defined, it says: "OS name, used for the _OS object. The _OS object is essentially obsolete,..." for some legacy reasons, we needed "Microsoft Windows NT", but ACPI for ARM64 on linux is totally new, I think we can change it to "Linux" when CONFIG_ARM64 as you suggested.
We could ignore this change for now if we don't expect the _OS object to be used at all. But do we have any other way to check the AML code for this? Would FWTS catch such obsolete cases?
How about just leaving it out? It's clearly not used for anything good, so I don't see the point in passing either Linux or "Microsoft Windows NT" here.
Do you mean defining it to NULL (so it ends up as NULL in acpi_gbl_pre_defined_names) or removing "_OS_" entirely from that array? I really can't tell what the implications are.
Setting it to NULL is almost certainly (99%+ likely IMO) going to result in some firmware crashing nastily somewhere.
I think I've mentioned before that we're using the ACPI patches in an early access program for partners that we announced last year. I've pinged the team internally and asked that we swiftly change to use whatever name is agreed in this thread so that we can get a lot of other folks to begin testing with a correctly reported OS name.
If we have to put something in there, I'd vote for keeping the current string. It's not clear whether Microsoft would follow the change to use "Linux" as the _OS_ string, and we probably don't want them to use incompatible IDs here.
Arnd