Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp4524729pxb; Tue, 25 Jan 2022 12:14:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJxkbXq9m1O7dhJ6pOwHrF9BJ8T1GrNCP4reDQ4OU1yc42lw8cyHlJMSFeOmwQYwHnc97CEM X-Received: by 2002:a17:90a:b107:: with SMTP id z7mr5264694pjq.38.1643141699023; Tue, 25 Jan 2022 12:14:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643141699; cv=none; d=google.com; s=arc-20160816; b=AbMpIg3t2wkw8VGI0q0fRdY36n0F1Ns497JJCgvB9CcWxJZgRy7My4cL8Z0MX/Sj5u ZxmQM8w6mMPDBP5uZDpWWvkPX3ONNGmKH6itfkfTGVZVv+mRvkfYQxjrvc600kO3G2cB ce3nW1Y+8iv1nXIeC7Wfy+U0Kt1DIPOtWrd3uiKacL7lMCHzgt2I1wOr6cgWdZD7RHPW st9HKv1vuCLuEoNZFAVQFEGahdg8DFkEmf9K9KcxIvHv75ZGFj6Nb213T0OOI1f2c21D 4XOOnrkwKtWzpUrI/DOjCI2JuNrtxQvCebwUTLacXgH+5/RXbK8cRdrLML+YtMhXvXMu Lwgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=UXOm7ViVkSu/Fww3xPx/JyERXjFguXqKgLA69SSnmQU=; b=ezwsxY04lDesIHV1buCrcCsImDRfVdTeibBAg9prhkR1Dkr1sQIO+TQTUbzzBvz55A erIQolifhpX29M+psnaaqNgkv2P8u/VySVS0b7JUcCJxcWtWaf7GSIeJyRhWrtvDZWct Nk3rukGuV/lrE6HdvWdxq4GBFGGhFLR+C0rX8F/UiARxPSB1JVmfc1es3/HfOWc20YDM bW81M7cDCBiVV2ItljY6zYS4zLuJT5fT66kSlpIVqFhH2ioDEVHZ5ZRaLGs9IYf4jKNQ tGPO2SXlQGMGQjfhfqQcxqz0Fhtka/RVT4Zzwt7j8NRARlJ3FOnXhXe6fEZiYwF1lU/Z luXA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id mh12si1217006pjb.146.2022.01.25.12.14.47; Tue, 25 Jan 2022 12:14:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233699AbiAYOaC (ORCPT + 99 others); Tue, 25 Jan 2022 09:30:02 -0500 Received: from foss.arm.com ([217.140.110.172]:46652 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1579100AbiAYOXH (ORCPT ); Tue, 25 Jan 2022 09:23:07 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id BFED613D5; Tue, 25 Jan 2022 06:21:29 -0800 (PST) Received: from p8cg001049571a15.arm.com (unknown [10.163.42.158]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id B7FAA3F793; Tue, 25 Jan 2022 06:21:25 -0800 (PST) From: Anshuman Khandual To: linux-arm-kernel@lists.infradead.org Cc: Anshuman Khandual , Catalin Marinas , Will Deacon , Mathieu Poirier , Suzuki Poulose , coresight@lists.linaro.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH V3 RESEND 7/7] coresight: trbe: Work around the trace data corruption Date: Tue, 25 Jan 2022 19:50:37 +0530 Message-Id: <1643120437-14352-8-git-send-email-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1643120437-14352-1-git-send-email-anshuman.khandual@arm.com> References: <1643120437-14352-1-git-send-email-anshuman.khandual@arm.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org TRBE implementations affected by Arm erratum #1902691 might corrupt trace data or deadlock, when it's being written into the memory. Workaround this problem in the driver, by preventing TRBE initialization on affected cpus. The firmware must have disabled the access to TRBE for the kernel on such implementations. This will cover the kernel for any firmware that doesn't do this already. This just updates the TRBE driver as required. Cc: Catalin Marinas Cc: Will Deacon Cc: Mathieu Poirier Cc: Suzuki Poulose Cc: coresight@lists.linaro.org Cc: linux-doc@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org Reviewed-by: Suzuki K Poulose Signed-off-by: Anshuman Khandual --- arch/arm64/Kconfig | 2 +- drivers/hwtracing/coresight/coresight-trbe.c | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index f37c9d2d697d..ee0fe8a04b9b 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -821,7 +821,7 @@ config ARM64_ERRATUM_2038923 config ARM64_ERRATUM_1902691 bool "Cortex-A510: 1902691: workaround TRBE trace corruption" - depends on COMPILE_TEST # Until the CoreSight TRBE driver changes are in + depends on CORESIGHT_TRBE default y help This option adds the workaround for ARM Cortex-A510 erratum 1902691. diff --git a/drivers/hwtracing/coresight/coresight-trbe.c b/drivers/hwtracing/coresight/coresight-trbe.c index 6254ba598df2..75b608bc400b 100644 --- a/drivers/hwtracing/coresight/coresight-trbe.c +++ b/drivers/hwtracing/coresight/coresight-trbe.c @@ -93,12 +93,14 @@ struct trbe_buf { #define TRBE_WORKAROUND_WRITE_OUT_OF_RANGE 1 #define TRBE_NEEDS_DRAIN_AFTER_DISABLE 2 #define TRBE_NEEDS_CTXT_SYNC_AFTER_ENABLE 3 +#define TRBE_IS_BROKEN 4 static int trbe_errata_cpucaps[] = { [TRBE_WORKAROUND_OVERWRITE_FILL_MODE] = ARM64_WORKAROUND_TRBE_OVERWRITE_FILL_MODE, [TRBE_WORKAROUND_WRITE_OUT_OF_RANGE] = ARM64_WORKAROUND_TRBE_WRITE_OUT_OF_RANGE, [TRBE_NEEDS_DRAIN_AFTER_DISABLE] = ARM64_WORKAROUND_2064142, [TRBE_NEEDS_CTXT_SYNC_AFTER_ENABLE] = ARM64_WORKAROUND_2038923, + [TRBE_IS_BROKEN] = ARM64_WORKAROUND_1902691, -1, /* Sentinel, must be the last entry */ }; @@ -192,6 +194,11 @@ static inline bool trbe_needs_ctxt_sync_after_enable(struct trbe_cpudata *cpudat return trbe_has_erratum(cpudata, TRBE_NEEDS_CTXT_SYNC_AFTER_ENABLE); } +static inline bool trbe_is_broken(struct trbe_cpudata *cpudata) +{ + return trbe_has_erratum(cpudata, TRBE_IS_BROKEN); +} + static int trbe_alloc_node(struct perf_event *event) { if (event->cpu == -1) @@ -1288,6 +1295,11 @@ static void arm_trbe_probe_cpu(void *info) */ trbe_check_errata(cpudata); + if (trbe_is_broken(cpudata)) { + pr_err("Disabling TRBE on cpu%d due to erratum\n", cpu); + goto cpu_clear; + } + /* * If the TRBE is affected by erratum TRBE_WORKAROUND_OVERWRITE_FILL_MODE, * we must always program the TBRPTR_EL1, 256bytes from a page -- 2.25.1