From: hanjun.guo@linaro.org (Hanjun Guo)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC part2 PATCH 4/9] ARM64 / ACPI: Use Parked Address in GIC structure for spin table SMP initialisation
Date: Wed, 4 Dec 2013 00:39:08 +0800 [thread overview]
Message-ID: <1386088753-2850-5-git-send-email-hanjun.guo@linaro.org> (raw)
In-Reply-To: <1386088753-2850-1-git-send-email-hanjun.guo@linaro.org>
Parked Address in GIC structure can be used as cpu release address
for spin table SMP initialisation.
This patch gets parked address from MADT and use it for SMP
initialisation when DT is not available.
Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
---
arch/arm64/include/asm/acpi.h | 3 +++
arch/arm64/kernel/smp_spin_table.c | 16 +++++++++---
drivers/acpi/plat/arm-core.c | 50 ++++++++++++++++++++++++++++++++++++
3 files changed, 66 insertions(+), 3 deletions(-)
diff --git a/arch/arm64/include/asm/acpi.h b/arch/arm64/include/asm/acpi.h
index 423a32c..180de4a 100644
--- a/arch/arm64/include/asm/acpi.h
+++ b/arch/arm64/include/asm/acpi.h
@@ -90,6 +90,9 @@ extern int boot_cpu_apic_id;
extern void prefill_possible_map(void);
+extern int acpi_get_parked_address_with_gic_id(u32 gic_id,
+ u64 *parked_address);
+
#else /* !CONFIG_ACPI */
#define acpi_disabled 1 /* ACPI sometimes enabled on ARM */
#define acpi_noirq 1 /* ACPI sometimes enabled on ARM */
diff --git a/arch/arm64/kernel/smp_spin_table.c b/arch/arm64/kernel/smp_spin_table.c
index 44c2280..7997873 100644
--- a/arch/arm64/kernel/smp_spin_table.c
+++ b/arch/arm64/kernel/smp_spin_table.c
@@ -25,6 +25,7 @@
#include <asm/cpu_ops.h>
#include <asm/cputype.h>
#include <asm/smp_plat.h>
+#include <asm/acpi.h>
extern void secondary_holding_pen(void);
volatile unsigned long secondary_holding_pen_release = INVALID_HWID;
@@ -47,6 +48,11 @@ static void write_pen_release(u64 val)
__flush_dcache_area(start, size);
}
+static int get_cpu_release_addr_acpi(unsigned int cpu, u64 *parked_address)
+{
+ return acpi_get_parked_address_with_gic_id(arm_cpu_to_apicid[cpu],
+ parked_address);
+}
static int smp_spin_table_cpu_init(struct device_node *dn, unsigned int cpu)
{
@@ -55,10 +61,14 @@ static int smp_spin_table_cpu_init(struct device_node *dn, unsigned int cpu)
*/
if (of_property_read_u64(dn, "cpu-release-addr",
&cpu_release_addr[cpu])) {
- pr_err("CPU %d: missing or invalid cpu-release-addr property\n",
- cpu);
- return -1;
+ /* try ACPI way */
+ if (get_cpu_release_addr_acpi(cpu, &cpu_release_addr[cpu])) {
+ pr_err("CPU %d: missing or invalid cpu-release-addr property\n",
+ cpu);
+
+ return -1;
+ }
}
return 0;
diff --git a/drivers/acpi/plat/arm-core.c b/drivers/acpi/plat/arm-core.c
index 8527ecc..c4c8c68 100644
--- a/drivers/acpi/plat/arm-core.c
+++ b/drivers/acpi/plat/arm-core.c
@@ -262,6 +262,56 @@ static int __init acpi_parse_madt_gic_entries(void)
return 0;
}
+/* Parked Address in ACPI GIC structure can be used as cpu release addr */
+int acpi_get_parked_address_with_gic_id(u32 gic_id, u64 *parked_address)
+{
+ struct acpi_table_header *table_header = NULL;
+ struct acpi_subtable_header *entry;
+ int err = 0;
+ unsigned long table_end;
+ acpi_size tbl_size;
+ struct acpi_madt_generic_interrupt *processor = NULL;
+
+ if (!parked_address)
+ return -EINVAL;
+
+ acpi_get_table_with_size(ACPI_SIG_MADT, 0, &table_header, &tbl_size);
+ if (!table_header) {
+ pr_warn(PREFIX "MADT table not present\n");
+ return -ENODEV;
+ }
+
+ table_end = (unsigned long)table_header + table_header->length;
+
+ /* Parse all entries looking for a match. */
+ entry = (struct acpi_subtable_header *)
+ ((unsigned long)table_header + sizeof(struct acpi_table_madt));
+
+ while (((unsigned long)entry) + sizeof(struct acpi_subtable_header) <
+ table_end) {
+ if (entry->type != ACPI_MADT_TYPE_GENERIC_INTERRUPT
+ || BAD_MADT_ENTRY(entry, table_end))
+ continue;
+
+ processor = (struct acpi_madt_generic_interrupt *)entry;
+
+ if (processor->gic_id == gic_id) {
+ *parked_address = processor->parked_address;
+ goto out;
+ }
+
+ entry = (struct acpi_subtable_header *)
+ ((unsigned long)entry + entry->length);
+ }
+
+ err = -ENODEV;
+out:
+ if (!acpi_gbl_permanent_mmap)
+ __acpi_unmap_table((char *)table_header, tbl_size);
+
+ return err;
+}
+
/*
* Parse GIC distributor related entries in MADT
* returns 0 on success, < 0 on error
--
1.7.9.5
next prev parent reply other threads:[~2013-12-03 16:39 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-03 16:39 [RFC part2 PATCH 0/9] Using ACPI MADT table to initialise SMP and GIC Hanjun Guo
2013-12-03 16:39 ` [RFC part2 PATCH 1/9] ARM64 / ACPI: Implement core functions for parsing MADT table Hanjun Guo
2013-12-03 16:39 ` [RFC part2 PATCH 2/9] ARM64 / ACPI: Prefill cpu possible/present maps and map logical cpu id to APIC id Hanjun Guo
2013-12-03 16:57 ` One Thousand Gnomes
2013-12-04 14:21 ` Hanjun Guo
2013-12-04 15:40 ` Rob Herring
2013-12-04 15:47 ` Rob Herring
2013-12-05 13:24 ` Mark Brown
2013-12-05 13:34 ` Hanjun Guo
2013-12-05 23:09 ` Arnd Bergmann
2013-12-09 8:06 ` Hanjun Guo
2013-12-03 16:39 ` [RFC part2 PATCH 3/9] ARM64 / ACPI: Introduce map_gic_id() to get apic id from MADT or _MAT method Hanjun Guo
2013-12-03 16:39 ` Hanjun Guo [this message]
2013-12-03 16:39 ` [RFC part2 PATCH 5/9] ACPI: Define ACPI_IRQ_MODEL_GIC needed for arm Hanjun Guo
2013-12-03 16:39 ` [RFC part2 PATCH 6/9] Irqchip / gic: Set as default domain so we can access from ACPI Hanjun Guo
2013-12-03 16:39 ` [RFC part2 PATCH 7/9] irqdomain: Add a new API irq_create_acpi_mapping() Hanjun Guo
2013-12-03 17:25 ` Rob Herring
2013-12-04 15:38 ` Hanjun Guo
2013-12-10 10:06 ` Linus Walleij
2013-12-03 16:39 ` [RFC part2 PATCH 8/9] ACPI / ARM64: Update acpi_register_gsi to register with the core IRQ subsystem Hanjun Guo
2013-12-05 3:48 ` Arnd Bergmann
2013-12-05 14:01 ` Hanjun Guo
2013-12-03 16:39 ` [RFC part2 PATCH 9/9] ACPI / GIC: Initialize GIC using the information in MADT Hanjun Guo
2013-12-03 17:09 ` Rob Herring
2013-12-04 14:58 ` Hanjun Guo
2013-12-03 17:26 ` Marc Zyngier
2013-12-04 15:32 ` Hanjun Guo
2013-12-04 15:50 ` Marc Zyngier
2013-12-05 13:41 ` Hanjun Guo
2013-12-09 18:54 ` Olof Johansson
[not found] <1385999094-3152-1-git-send-email-hanjun.guo@linaro.org>
[not found] ` < 1385999094-3152-5-git-send-email-hanjun.guo@linaro.org>
[not found] ` <1385999094-3152-5-git-send-email-hanjun.guo@linaro.org>
2013-12-10 13:03 ` [RFC part2 PATCH 4/9] ARM64 / ACPI: Use Parked Address in GIC structure for spin table SMP initialisation Grant Likely
2013-12-11 7:02 ` Hanjun Guo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1386088753-2850-5-git-send-email-hanjun.guo@linaro.org \
--to=hanjun.guo@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).