From patchwork Sun Apr 16 20:27:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 97484 Delivered-To: patch@linaro.org Received: by 10.140.109.52 with SMTP id k49csp1087654qgf; Sun, 16 Apr 2017 13:32:06 -0700 (PDT) X-Received: by 10.84.174.197 with SMTP id r63mr11292916plb.67.1492374726693; Sun, 16 Apr 2017 13:32:06 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b69si8929614pfl.158.2017.04.16.13.32.06; Sun, 16 Apr 2017 13:32:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757260AbdDPUcB (ORCPT + 15 others); Sun, 16 Apr 2017 16:32:01 -0400 Received: from mail-wr0-f171.google.com ([209.85.128.171]:36047 "EHLO mail-wr0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756858AbdDPU20 (ORCPT ); Sun, 16 Apr 2017 16:28:26 -0400 Received: by mail-wr0-f171.google.com with SMTP id c55so74459209wrc.3 for ; Sun, 16 Apr 2017 13:28:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=XA+0IhCCeFxY7EM/HK4RahNMUmg+1b9HeIV/WbbfgoM=; b=Upd+Yo+0ucwYfyuEVFMFTSBc0Lm/ZsrKbzMWoLilkq/eLt82XJpNrF0D2zGYERh/LP BIHZzhtFM539BTwyQl6Rc87FCLQz+YSPFYPc1rcvMkUgk2GWse3FSrAjPkIIDC+c64aY QnYZTsU1LpRe0+s+Qk/jem5N5ScTt3rq0qSEA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=XA+0IhCCeFxY7EM/HK4RahNMUmg+1b9HeIV/WbbfgoM=; b=lHyQygHB4U1LLl9jWdhXxg42gdzrmPYRM/m9Ck+ocOkIAe8ahe4zUGkYZs8ahU4xth YnDXlHla0tL7X4Vju8TYpSE9Gx/e9/kvAZjpdYkUSiw2pilTXzYoy/zXz7uCcmDtPfVI DwY6v2iac0D8mih7AM13yzk8RF/mDmpKGuZSFWRy3VMIljLbVdyG/No9LqbXR5cpkzKo c7yBI9CoQIoTVRBaQ0UIpkE/QDC12FlstFFS6GudSTox/Ql+EVE6XP4fRT3XPrAul44/ iPAjm1nhAcTkWNsfgHN5/BqI8M9fhZ6S1JYK7mzFyiMMPNwrOfRqOZ5p1/oEKoGe73mD XAOw== X-Gm-Message-State: AN3rC/7KzS6SuhkIE3rar0HAl3Uaxp1i/JT7hFkol2pJOE+NVNU08sQ+ vv9lcI6J4MEpoAp4 X-Received: by 10.223.157.23 with SMTP id k23mr15656028wre.28.1492374505096; Sun, 16 Apr 2017 13:28:25 -0700 (PDT) Received: from mai.lan ([2001:41d0:fe90:b800:20c0:6248:a385:db35]) by smtp.gmail.com with ESMTPSA id 81sm7732196wmj.9.2017.04.16.13.28.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 16 Apr 2017 13:28:24 -0700 (PDT) From: Daniel Lezcano To: tglx@linutronix.de Cc: linux-kernel@vger.kernel.org, Marc Zyngier , dann frazier , Hanjun Guo , Mark Rutland , Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org (moderated list:ARM ARCHITECTED TIMER DRIVER) Subject: [PATCH 17/29] arm64: arch_timer: Allow erratum matching with ACPI OEM information Date: Sun, 16 Apr 2017 22:27:07 +0200 Message-Id: <1492374441-23336-17-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1492374441-23336-1-git-send-email-daniel.lezcano@linaro.org> References: <20170416202542.GV2078@mai> <1492374441-23336-1-git-send-email-daniel.lezcano@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Marc Zyngier Just as we're able to identify a broken platform using some DT information, let's enable a way to spot the offenders with ACPI. The difference is that we can only match on some OEM info instead of implementation-specific properties. So in order to avoid the insane multiplication of errata structures, we allow an array of OEM descriptions to be attached to an erratum structure. Acked-by: Thomas Gleixner Tested-by: dann frazier Tested-by: Hanjun Guo Reviewed-by: Hanjun Guo Signed-off-by: Marc Zyngier --- arch/arm64/include/asm/arch_timer.h | 1 + drivers/clocksource/arm_arch_timer.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) -- 2.7.4 diff --git a/arch/arm64/include/asm/arch_timer.h b/arch/arm64/include/asm/arch_timer.h index 6bd1a9a..74d08e4 100644 --- a/arch/arm64/include/asm/arch_timer.h +++ b/arch/arm64/include/asm/arch_timer.h @@ -41,6 +41,7 @@ extern struct static_key_false arch_timer_read_ool_enabled; enum arch_timer_erratum_match_type { ate_match_dt, ate_match_local_cap_id, + ate_match_acpi_oem_info, }; struct clock_event_device; diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c index 8459d19..887f6d0 100644 --- a/drivers/clocksource/arm_arch_timer.c +++ b/drivers/clocksource/arm_arch_timer.c @@ -190,6 +190,12 @@ static struct cyclecounter cyclecounter __ro_after_init = { .mask = CLOCKSOURCE_MASK(56), }; +struct ate_acpi_oem_info { + char oem_id[ACPI_OEM_ID_SIZE + 1]; + char oem_table_id[ACPI_OEM_TABLE_ID_SIZE + 1]; + u32 oem_revision; +}; + #ifdef CONFIG_FSL_ERRATUM_A008585 /* * The number of retries is an arbitrary value well beyond the highest number @@ -371,6 +377,28 @@ bool arch_timer_check_local_cap_erratum(const struct arch_timer_erratum_workarou return this_cpu_has_cap((uintptr_t)wa->id); } + +static +bool arch_timer_check_acpi_oem_erratum(const struct arch_timer_erratum_workaround *wa, + const void *arg) +{ + static const struct ate_acpi_oem_info empty_oem_info = {}; + const struct ate_acpi_oem_info *info = wa->id; + const struct acpi_table_header *table = arg; + + /* Iterate over the ACPI OEM info array, looking for a match */ + while (memcmp(info, &empty_oem_info, sizeof(*info))) { + if (!memcmp(info->oem_id, table->oem_id, ACPI_OEM_ID_SIZE) && + !memcmp(info->oem_table_id, table->oem_table_id, ACPI_OEM_TABLE_ID_SIZE) && + info->oem_revision == table->oem_revision) + return true; + + info++; + } + + return false; +} + static const struct arch_timer_erratum_workaround * arch_timer_iterate_errata(enum arch_timer_erratum_match_type type, ate_match_fn_t match_fn, @@ -431,6 +459,9 @@ static void arch_timer_check_ool_workaround(enum arch_timer_erratum_match_type t match_fn = arch_timer_check_local_cap_erratum; local = true; break; + case ate_match_acpi_oem_info: + match_fn = arch_timer_check_acpi_oem_erratum; + break; default: WARN_ON(1); return; @@ -1277,6 +1308,9 @@ static int __init arch_timer_acpi_init(struct acpi_table_header *table) /* Always-on capability */ arch_timer_c3stop = !(gtdt->non_secure_el1_flags & ACPI_GTDT_ALWAYS_ON); + /* Check for globally applicable workarounds */ + arch_timer_check_ool_workaround(ate_match_acpi_oem_info, table); + arch_timer_init(); return 0; }