From patchwork Wed Feb 4 14:01:49 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Parth Dixit X-Patchwork-Id: 44337 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f199.google.com (mail-lb0-f199.google.com [209.85.217.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 14BDB2029F for ; Wed, 4 Feb 2015 14:04:31 +0000 (UTC) Received: by mail-lb0-f199.google.com with SMTP id f15sf1479524lbj.2 for ; Wed, 04 Feb 2015 06:04:30 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:cc:subject:precedence:list-id:list-unsubscribe:list-post :list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:sender:errors-to:x-original-sender :x-original-authentication-results:mailing-list:list-archive; bh=KC5jmIn35pKr96S9r4gPS4HlR/YAvy/YIJngLub3hCo=; b=fVgOag91OGZkZsnfFQFYNBhhWMa/EX/EDdIZknLi10WfHwG2OeyJhnpQg10ICESYZQ +2tHSSSF+1oL7vKPWIothkm+1Bso5Vd2ZHla6TrUYNXx1jakMCwhZqyKkwY4G6W3WdQq eDSgrVl63TwlLW7ET03xiH7fLQBepxRqbKp3hPDvBNN8xbyD2/Ye0gkldgGv19a1Kger N7Xy84ijJEkCS+4YQhXg0rPSpVsL7nnBIt2DwteaMYG8rZwzwSMNOLdm+im/cS+vVRNL IC5KAYfl9NrSHVLlpKBCvDBbfl3vEO0lPEb0bXfoUBiSSJ4wwHJIgPlJYtnL9Ie/rD3E 2mRQ== X-Gm-Message-State: ALoCoQkKqNZL1tqwtT8A1L0DnkFPljQgRkIl/r7TP6WqDqVT+I8BYlfHYzPGM2w5ifQKyaLzoOfZ X-Received: by 10.180.13.83 with SMTP id f19mr367184wic.7.1423058670029; Wed, 04 Feb 2015 06:04:30 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.7.42 with SMTP id g10ls37775laa.51.gmail; Wed, 04 Feb 2015 06:04:29 -0800 (PST) X-Received: by 10.152.10.238 with SMTP id l14mr29361124lab.68.1423058669784; Wed, 04 Feb 2015 06:04:29 -0800 (PST) Received: from mail-lb0-f178.google.com (mail-lb0-f178.google.com. [209.85.217.178]) by mx.google.com with ESMTPS id x4si1437333lbm.37.2015.02.04.06.04.29 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Feb 2015 06:04:29 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.178 as permitted sender) client-ip=209.85.217.178; Received: by mail-lb0-f178.google.com with SMTP id u10so1627709lbd.9 for ; Wed, 04 Feb 2015 06:04:29 -0800 (PST) X-Received: by 10.152.3.70 with SMTP id a6mr30766580laa.71.1423058669677; Wed, 04 Feb 2015 06:04:29 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.35.133 with SMTP id h5csp506283lbj; Wed, 4 Feb 2015 06:04:28 -0800 (PST) X-Received: by 10.220.50.70 with SMTP id y6mr205940vcf.44.1423058668004; Wed, 04 Feb 2015 06:04:28 -0800 (PST) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id ut3si711873vcb.73.2015.02.04.06.04.25 (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 04 Feb 2015 06:04:27 -0800 (PST) Received-SPF: none (google.com: xen-devel-bounces@lists.xen.org does not designate permitted sender hosts) client-ip=50.57.142.19; Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YJ0YH-0006X7-HA; Wed, 04 Feb 2015 14:03:33 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YJ0YF-0006W3-Qd for xen-devel@lists.xen.org; Wed, 04 Feb 2015 14:03:32 +0000 Received: from [85.158.137.68] by server-1.bemta-3.messagelabs.com id A9/6D-02999-3B622D45; Wed, 04 Feb 2015 14:03:31 +0000 X-Env-Sender: parth.dixit@linaro.org X-Msg-Ref: server-12.tower-31.messagelabs.com!1423058608!11928673!1 X-Originating-IP: [209.85.220.51] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 6.12.5; banners=-,-,- X-VirusChecked: Checked Received: (qmail 2918 invoked from network); 4 Feb 2015 14:03:30 -0000 Received: from mail-pa0-f51.google.com (HELO mail-pa0-f51.google.com) (209.85.220.51) by server-12.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 4 Feb 2015 14:03:30 -0000 Received: by mail-pa0-f51.google.com with SMTP id fb1so2897946pad.10 for ; Wed, 04 Feb 2015 06:03:28 -0800 (PST) X-Received: by 10.67.1.132 with SMTP id bg4mr45416631pad.151.1423058608394; Wed, 04 Feb 2015 06:03:28 -0800 (PST) Received: from parthd-ubunutu.qualcomm.com ([202.46.23.62]) by mx.google.com with ESMTPSA id kg12sm2161881pbb.44.2015.02.04.06.03.23 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 04 Feb 2015 06:03:27 -0800 (PST) From: parth.dixit@linaro.org To: xen-devel@lists.xen.org Date: Wed, 4 Feb 2015 19:31:49 +0530 Message-Id: <1423058539-26403-6-git-send-email-parth.dixit@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1423058539-26403-1-git-send-email-parth.dixit@linaro.org> References: <1423058539-26403-1-git-send-email-parth.dixit@linaro.org> Cc: ian.campbell@citrix.com, Naresh Bhat , julien.grall@linaro.org, tim@xen.org, stefano.stabellini@citrix.com, Hanjun Guo , jbeulich@suse.com, christoffer.dall@linaro.org Subject: [Xen-devel] [PATCH RFC 05/35] ARM64 / ACPI: Parse FADT table to get PSCI flags X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: parth.dixit@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.178 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Archive: From: Naresh Bhat There are two flags: PSCI_COMPLIANT and PSCI_USE_HVC. When set, the former signals to the OS that the hardware is PSCI compliant. The latter selects the appropriate conduit for PSCI calls by toggling between Hypervisor Calls (HVC) and Secure Monitor Calls (SMC). FADT table contains such information, parse FADT to get the flags for furture usage. 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, so disable ACPI if we get an FADT table with version less that 5.1. Signed-off-by: Hanjun Guo Signed-off-by: Naresh Bhat --- xen/arch/arm/arm64/acpi/arm-core.c | 54 +++++++++++++++++++++++++++++++++++--- xen/arch/arm/setup.c | 1 + xen/include/asm-arm/acpi.h | 2 ++ 3 files changed, 54 insertions(+), 3 deletions(-) diff --git a/xen/arch/arm/arm64/acpi/arm-core.c b/xen/arch/arm/arm64/acpi/arm-core.c index 50a83d6..2b7e2ef 100644 --- a/xen/arch/arm/arm64/acpi/arm-core.c +++ b/xen/arch/arm/arm64/acpi/arm-core.c @@ -25,6 +25,7 @@ #if defined(CONFIG_ARM_64) && defined(CONFIG_ACPI) #include #include +#include #include @@ -42,6 +43,12 @@ EXPORT_SYMBOL(acpi_disabled); int acpi_pci_disabled; /* skip ACPI PCI scan and IRQ initialization */ EXPORT_SYMBOL(acpi_pci_disabled); +/* 1 to indicate PSCI is implemented */ +int acpi_psci_present; + +/* 1 to indicate HVC must be used instead of SMC as the PSCI conduit */ +int acpi_psci_use_hvc; + enum acpi_irq_model_id acpi_irq_model = ACPI_IRQ_MODEL_PLATFORM; struct acpi_arm_root acpi_arm_rsdp_info; /* info about RSDP from FDT */ @@ -58,7 +65,7 @@ EXPORT_SYMBOL_GPL(acpi_gsi_to_irq); * failure: return =< 0 */ //int acpi_register_gsi(struct device *dev, u32 gsi, int trigger, int polarity) -unsigned int acpi_register_gsi (u32 gsi, int edge_level, int active_high_low) +unsigned int acpi_register_gsi(u32 gsi, int edge_level, int active_high_low) { return -1; } @@ -69,6 +76,33 @@ 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; + + /* + * Revision in table header is the FADT Major version, + * and there is a minor version of FADT which was introduced + * by ACPI 5.1, we only deal with ACPI 5.1 or higher version + * to get arm boot flags, or we will disable ACPI. + */ + if ( table->revision < 5 || fadt->minor_version < 1 ) { + printk("FADT version is %d.%d, no PSCI support, should be 5.1 or higher\n", + table->revision, fadt->minor_version); + acpi_psci_present = 0; + disable_acpi(); + return -EINVAL; + } + + if ( acpi_gbl_FADT.arm_boot_flags & ACPI_FADT_PSCI_COMPLIANT ) + acpi_psci_present = 1; + + if ( acpi_gbl_FADT.arm_boot_flags & ACPI_FADT_PSCI_USE_HVC ) + acpi_psci_use_hvc = 1; + + return 0; +} + /* * acpi_boot_table_init() called from setup_arch(), always. * 1. find RSDP and get its address, and then find XSDT @@ -81,12 +115,12 @@ int __init acpi_boot_table_init(void) { int error; /* If acpi_disabled, bail out */ - if (acpi_disabled) + if ( acpi_disabled ) return 1; /* Initialize the ACPI boot-time table parser. */ error = acpi_table_init(); - if (error) + if ( error ) { disable_acpi(); return error; @@ -94,4 +128,18 @@ int __init acpi_boot_table_init(void) return 0; } + +int __init acpi_boot_init(void) +{ + int err = 0; + /* If acpi_disabled, bail out */ + if (acpi_disabled) + return -ENODEV; + + err = acpi_table_parse(ACPI_SIG_FADT, acpi_parse_fadt); + if ( err ) + printk("Can't find FADT\n"); + + return err; +} #endif diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c index 7ae126b..3531d47 100644 --- a/xen/arch/arm/setup.c +++ b/xen/arch/arm/setup.c @@ -749,6 +749,7 @@ void __init start_xen(unsigned long boot_phys_offset, #if defined(CONFIG_ACPI) && defined(CONFIG_ARM_64) acpi_boot_table_init(); + acpi_boot_init(); #endif dt_unflatten_host_device_tree(); diff --git a/xen/include/asm-arm/acpi.h b/xen/include/asm-arm/acpi.h index f6284b5..03051ef 100644 --- a/xen/include/asm-arm/acpi.h +++ b/xen/include/asm-arm/acpi.h @@ -60,6 +60,8 @@ extern int acpi_disabled; extern int acpi_noirq; extern int acpi_pci_disabled; extern int acpi_strict; +extern int acpi_psci_present; +extern int acpi_psci_use_hvc; /* map logic cpu id to physical APIC id * APIC = GIC cpu interface on ARM