Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966260AbbBDNGq (ORCPT ); Wed, 4 Feb 2015 08:06:46 -0500 Received: from foss-mx-na.foss.arm.com ([217.140.108.86]:41127 "EHLO foss-mx-na.foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965280AbbBDNGk (ORCPT ); Wed, 4 Feb 2015 08:06:40 -0500 Date: Wed, 4 Feb 2015 13:06:26 +0000 From: Lorenzo Pieralisi To: Hanjun Guo Cc: Catalin Marinas , "Rafael J. Wysocki" , Olof Johansson , Arnd Bergmann , Mark Rutland , "grant.likely@linaro.org" , Will Deacon , "graeme.gregory@linaro.org" , Sudeep Holla , "jcm@redhat.com" , Jason Cooper , Marc Zyngier , Bjorn Helgaas , Daniel Lezcano , Mark Brown , Rob Herring , Robert Richter , Randy Dunlap , Charles Garcia-Tobin , "phoenix.liyi@huawei.com" , Timur Tabi , Ashwin Chaugule , "suravee.suthikulpanit@amd.com" , Mark Langsdorf , "wangyijing@huawei.com" , "linux-acpi@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" , "linaro-acpi@lists.linaro.org" Subject: Re: [PATCH v8 09/21] ARM64 / ACPI: Disable ACPI if FADT revision is less than 5.1 Message-ID: <20150204130626.GE22035@red-moon> References: <1422881149-8177-1-git-send-email-hanjun.guo@linaro.org> <1422881149-8177-10-git-send-email-hanjun.guo@linaro.org> <20150203172047.GA13339@e104818-lin.cambridge.arm.com> <54D1E891.80405@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <54D1E891.80405@linaro.org> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3995 Lines: 107 On Wed, Feb 04, 2015 at 09:38:25AM +0000, Hanjun Guo wrote: > On 2015年02月04日 01:20, Catalin Marinas wrote: > > On Mon, Feb 02, 2015 at 12:45:37PM +0000, Hanjun Guo wrote: > >> diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c > >> index afe10b4..b9f64ec 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 > >> #include > >> #include > >> @@ -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 GIC and SMP > >> + * boot protocol configuration data, 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 revision > >> * > >> * We can parse ACPI boot-time tables such as MADT after > >> * this function is called. > >> @@ -64,8 +88,16 @@ 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)) { > >> + /* disable ACPI if no FADT is found */ > >> disable_acpi(); > >> + pr_err("Can't find FADT\n"); > >> + } > >> } > > > > It looks fine to call disable_acpi() here but a bit weird to call it > > again in acpi_parse_fadt(). I guess that's because acpi_table_parse() > > ignores the return value of the handler() call. I think it's better to > > fix the core code (can be an additional patch on top of this series). > > I checked all the code calling acpi_table_parse() and I found that it > will be no functional change if we return the value of handler(), but > I need Rafael's confirm on it. Are you sure ? All calls to acpi_table_parse() that checks the return value are affected. I guess that depends on what an error return from the handler means, from acpi_table_parse(): * Return 0 if table found, -errno if not. So, if table is found but parsing fails that acpi_table_parse() signature should be changed if the handler barfs with an error and it is propagated. Still, I share Catalin's comment. Have you thought about getting the FADT through: acpi_get_table_with_size() and check the revision there instead of going through acpi_table_parse() for that ? I wonder if the revision information is not already available without needing to retrieve the FADT again. On top of that, this patch should be squashed, I have a feeling that between patch 4 and 9, there is a window where ACPI versions predating 5.1 are ok on arm64, which is not the case. I do not think that's a bisectable issue, but keep this in mind please. Thanks, Lorenzo -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/