Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp55784pxx; Wed, 28 Oct 2020 18:01:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwodk7qV7IlYv8G2v6tQRP7Dle7zKJweM/uJFvQPTcqfamrMTopjQIMSETraorbZLsrfWuy X-Received: by 2002:a05:6402:1bc9:: with SMTP id ch9mr1637014edb.386.1603933279915; Wed, 28 Oct 2020 18:01:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603933279; cv=none; d=google.com; s=arc-20160816; b=yJ59aRufFasUIjfDAF3R1MIH29nz+9BSS1daaSHZUXoiKvEV56ZtGUBUor2TuutXFO oEzOsfM8QSr6M2NNHUXafDNDiyL/9qjMmbamSGZpa9DjW47fatefpKbM33hnPdtD86rq QsLsj9OYDx3TLzevgsw6TDvu57PF3iQgEWk/ybe1oR4I1xHywjVY6RDfROLaSz3gfbka udInjTZXwrHR1emq787sHuVD1y2cUx+l+M2trhCV3ovKvugKKK+0/XNhSEXy/CMbCXXo /MKef3ss3x8BncZF91bpyzNB12xmfk5GyNK2MreznoDKgRMRCQymJ055yhAc8eIdgr4l Ju3A== 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=LczuT0uUdtN/ILnqjNox0i9Mb3wWD4UBFrEycXsoHIA=; b=zopzBdLhBA8qC0jh2Lppf91IaTD+mV34EvRn5YBRQofPa8r2fqmWrBMmwiOdtboKbl zPcfPAOkuJL+AasJK12LgCG+hrpfbiyvkxuujX7cHXQfZN3ktg1x2yUzcb67JNF11jeY pL+iup0iZWtUGnv0IkU7tWjdOI+SMmiUlgWLcpP6ya+ntBg2PC87IaVniffiAcXdKdD7 leVrmwK0D04pOrH0g541+x5h+XqFiVWV/HqCYNP3VtGMxFNsAzazqA+GrB4IY6MFffUe iiiYUuQRRgrb7Yus0UKv8W6njSZ/5sR5yhUChjIG/BI8Uug7zvEDCqx3rk3+/L+MwmCT im7A== 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 b7si749116ejj.658.2020.10.28.18.00.57; Wed, 28 Oct 2020 18:01:19 -0700 (PDT) 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 S1730636AbgJ1WLP (ORCPT + 99 others); Wed, 28 Oct 2020 18:11:15 -0400 Received: from foss.arm.com ([217.140.110.172]:39206 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730522AbgJ1WKZ (ORCPT ); Wed, 28 Oct 2020 18:10:25 -0400 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 5F8721AC1; Wed, 28 Oct 2020 15:10:25 -0700 (PDT) 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 7A3273F68F; Wed, 28 Oct 2020 15:10:24 -0700 (PDT) From: Suzuki K Poulose To: linux-arm-kernel@lists.infradead.org Cc: mathieu.poirier@linaro.org, mike.leach@linaro.org, coresight@lists.linaro.org, linux-kernel@vger.kernel.org, Suzuki K Poulose Subject: [PATCH v3 22/26] coresight: etm4x: Add necessary synchronization for sysreg access Date: Wed, 28 Oct 2020 22:09:41 +0000 Message-Id: <20201028220945.3826358-24-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20201028220945.3826358-1-suzuki.poulose@arm.com> References: <20201028220945.3826358-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 Cc: 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 e36bc1c722c7..4bc2f15b6332 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x-core.c +++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c @@ -178,6 +178,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, @@ -256,6 +265,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