Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp270305pxu; Thu, 7 Jan 2021 04:44:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJxwwrPieHj2vzEJPXg82NdGS/75MRcMBYXerd8MGxqYiHrdth9t0op1dk2fhsGpKUh9c698 X-Received: by 2002:a17:906:408f:: with SMTP id u15mr6372541ejj.84.1610023470915; Thu, 07 Jan 2021 04:44:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610023470; cv=none; d=google.com; s=arc-20160816; b=CE3jYfts2xLIBq4mGX1qAW3W+aAZz15Syavgy+J25zM96K2yktk+EEVQtVPus1j3fD CY/GuQDIIDNknEHxj/7RZq4u0UiqgxymBj2wonGIuc4/fkfZq43PmnYy9BVBslifxyou UjYydXzv82nJi6dD8Ba+Llbnhq18h3a3fY0tPn4rAlU/jUDozjERM4omAsIHDsViLGBF rba61KMVdO7BdrS7t11A2pmSkyZlpIozffhCXoKXoMW5H2UWt06qopOFVm9TshhMxh9p cimbnQ6CTwxyDFzA/Pp+RGEb3uCa8rFPe9cZkvhJ0/ioPj4UMPJb5coaautNjhurgNfI zkUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=6KcL2INPFmEieHPe089UDTPPOaHhjVJQJCKfhJ3js0o=; b=B5taSL5efTex3gSPBHwUpgPU5gY4h3LrjPnhKEzKkVotpPBeBxxr4yzjTc0xslw75l pqrDr2DmZgbKR3ruioNWFEvIR3eIoaLLNHR5Jh4V7mRcz+8IYOr4ChntY8ETEnlk6lp7 PSc1Yfsf7u4HGDWSwJCh/dx4GDJIwZmqZsdFFEDYBudgdz5vKcXXOY3wg9g1swABJZ6M Zz4SFTvB8FseiMo7NjnoH4+73tp4XNW7J+Iam3TuVZFYoh4n9+hpyvvBQRvHYTNnacC6 b0m7At8jCHb/YhJymgxk7t1rLcbjehXJUxKkYzVYF+GYkxmYYcy3QOgvwsRZ0a89Je/p O+Wg== 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 x9si2342664eje.109.2021.01.07.04.44.05; Thu, 07 Jan 2021 04:44:30 -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 S1728606AbhAGMlq (ORCPT + 99 others); Thu, 7 Jan 2021 07:41:46 -0500 Received: from foss.arm.com ([217.140.110.172]:59934 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728474AbhAGMlI (ORCPT ); Thu, 7 Jan 2021 07:41:08 -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 2381F1509; Thu, 7 Jan 2021 04:39:40 -0800 (PST) Received: from ewhatever.cambridge.arm.com (ewhatever.cambridge.arm.com [10.1.197.1]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 096723F719; Thu, 7 Jan 2021 04:39:38 -0800 (PST) From: Suzuki K Poulose To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, coresight@lists.linaro.org, mathieu.poirier@linaro.org, leo.yan@linaro.org, mike.leach@linaro.org, anshuman.khandual@arm.com, Suzuki K Poulose Subject: [PATCH v6 19/26] coresight: etm4x: Add necessary synchronization for sysreg access Date: Thu, 7 Jan 2021 12:38:52 +0000 Message-Id: <20210107123859.674252-20-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20210107123859.674252-1-suzuki.poulose@arm.com> References: <20210107123859.674252-1-suzuki.poulose@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As per the specification any update to the TRCPRGCTLR must be synchronized by a context synchronization event (in our case an explicist ISB) before the TRCSTATR is checked. Cc: Mike Leach Reviewed-by: Mathieu Poirier Signed-off-by: Suzuki K Poulose --- drivers/hwtracing/coresight/coresight-etm4x-core.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/hwtracing/coresight/coresight-etm4x-core.c index 84af2c7b7f86..9b00720e7a02 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x-core.c +++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c @@ -284,6 +284,15 @@ static int etm4_enable_hw(struct etmv4_drvdata *drvdata) /* Disable the trace unit before programming trace registers */ etm4x_relaxed_write32(csa, 0, TRCPRGCTLR); + /* + * If we use system instructions, we need to synchronize the + * write to the TRCPRGCTLR, before accessing the TRCSTATR. + * See ARM IHI0064F, section + * "4.3.7 Synchronization of register updates" + */ + if (!csa->io_mem) + isb(); + /* wait for TRCSTATR.IDLE to go up */ if (coresight_timeout(csa, TRCSTATR, TRCSTATR_IDLE_BIT, 1)) dev_err(etm_dev, @@ -362,6 +371,10 @@ static int etm4_enable_hw(struct etmv4_drvdata *drvdata) /* Enable the trace unit */ etm4x_relaxed_write32(csa, 1, TRCPRGCTLR); + /* Synchronize the register updates for sysreg access */ + if (!csa->io_mem) + isb(); + /* wait for TRCSTATR.IDLE to go back down to '0' */ if (coresight_timeout(csa, TRCSTATR, TRCSTATR_IDLE_BIT, 0)) dev_err(etm_dev, -- 2.24.1