From patchwork Tue Dec 3 16:39:08 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanjun Guo X-Patchwork-Id: 21985 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qa0-f70.google.com (mail-qa0-f70.google.com [209.85.216.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 14FDE202AE for ; Tue, 3 Dec 2013 16:40:25 +0000 (UTC) Received: by mail-qa0-f70.google.com with SMTP id j5sf14332536qaq.1 for ; Tue, 03 Dec 2013 08:40:24 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=RnACNKDUPgfuiG70ALJNaNhhJ9/wIujfWwSlTZLIioM=; b=aYuv04dwb5n7cv8Oc0Pnr+HfBBCwZ0rGvwBbJVj8+nRWaEQF4lZZuwb4MfeSMBLxLE wi+3QXA147HlzZ92D+PkkZVhGoLxAEEV1miDbrv0Vpw95bH7yLfyafkCS9BspHXs9lI0 Kz755mWX2Dmo2xN3ink3Azc1C/4u8uWrJo4/RFyhyiJADoRdB29ve8ygfsJnBRhPx8Lg QKZYb97GjkvsEq8mMZrKyVOIJxkGLei+jZ1JE4X/bBv760DfvJk0chXsG0UJ4h9/m8AR wqdnkcOJrcsUwk+VpVyAbYwgkrz1OGVmlPBO0Nl9Qv4FerDBGVMgqgFjNzaNg9Ui4ij5 RMPg== X-Gm-Message-State: ALoCoQnkfjCC1iram/HnzfNEsQq6b6C/oEFpNQrNhUoy0aSxS6xQbxGebG5spT+ft+xX1MRwWIlA X-Received: by 10.236.119.180 with SMTP id n40mr22781635yhh.2.1386088824917; Tue, 03 Dec 2013 08:40:24 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.62.199 with SMTP id a7ls5399398qes.87.gmail; Tue, 03 Dec 2013 08:40:24 -0800 (PST) X-Received: by 10.58.50.194 with SMTP id e2mr111126veo.54.1386088824681; Tue, 03 Dec 2013 08:40:24 -0800 (PST) Received: from mail-ve0-f182.google.com (mail-ve0-f182.google.com [209.85.128.182]) by mx.google.com with ESMTPS id sl9si16723090vdc.151.2013.12.03.08.40.24 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 03 Dec 2013 08:40:24 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.182 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.182; Received: by mail-ve0-f182.google.com with SMTP id jy13so10377955veb.41 for ; Tue, 03 Dec 2013 08:40:24 -0800 (PST) X-Received: by 10.52.76.36 with SMTP id h4mr1683039vdw.46.1386088824482; Tue, 03 Dec 2013 08:40:24 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp222585vcz; Tue, 3 Dec 2013 08:40:24 -0800 (PST) X-Received: by 10.67.1.101 with SMTP id bf5mr75048331pad.50.1386088823443; Tue, 03 Dec 2013 08:40:23 -0800 (PST) Received: from mail-pd0-f171.google.com (mail-pd0-f171.google.com [209.85.192.171]) by mx.google.com with ESMTPS id wm3si2326383pab.49.2013.12.03.08.40.23 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 03 Dec 2013 08:40:23 -0800 (PST) Received-SPF: neutral (google.com: 209.85.192.171 is neither permitted nor denied by best guess record for domain of hanjun.guo@linaro.org) client-ip=209.85.192.171; Received: by mail-pd0-f171.google.com with SMTP id z10so20415242pdj.30 for ; Tue, 03 Dec 2013 08:40:23 -0800 (PST) X-Received: by 10.68.172.65 with SMTP id ba1mr39771766pbc.18.1386088822955; Tue, 03 Dec 2013 08:40:22 -0800 (PST) Received: from localhost ([61.148.199.138]) by mx.google.com with ESMTPSA id gh3sm131192037pbb.2.2013.12.03.08.40.16 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 03 Dec 2013 08:40:22 -0800 (PST) From: Hanjun Guo To: "Rafael J. Wysocki" , Catalin Marinas , Will Deacon , Russell King - ARM Linux , Daniel Lezcano Cc: linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Grant Likely , Matthew Garrett , Olof Johansson , Linus Walleij , Bjorn Helgaas , Rob Herring , Mark Rutland , Jon Masters , patches@linaro.org, linux-kernel@vger.kernel.org, linaro-kernel@lists.linaro.org, linaro-acpi@lists.linaro.org, Hanjun Guo 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 Message-Id: <1386088753-2850-5-git-send-email-hanjun.guo@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1386088753-2850-1-git-send-email-hanjun.guo@linaro.org> References: <1386088753-2850-1-git-send-email-hanjun.guo@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: hanjun.guo@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.182 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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 --- 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 #include #include +#include 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