Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp1879486pxb; Sun, 10 Jan 2021 14:54:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJx3qnPwt0T7M02veSOswAcnvzvdO3cWNtnkJEIhEUfRBFoWKjLEt2ZevBufJe9r9ys981G7 X-Received: by 2002:a17:907:40f0:: with SMTP id nn24mr8764091ejb.233.1610319253729; Sun, 10 Jan 2021 14:54:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610319253; cv=none; d=google.com; s=arc-20160816; b=OU7WM1EOLYY0V/oYda0F7nCX37F9pYc16Ha5poCXdl+bEMXotnbnElOjVHphlQ56bh GGsy0UVaVbrrXB2UVqRYo5irOige3YNHx/aukZQBXnkyEIVOlk9puCmLCr9ad6DjhyGb zudv5KmqzTYHHMxi3QD77OnunuWaIilofvDTgLtHRAk99YOmV7xl1tvX5N295f1r2DgH 7mxonI6IPhjWjFz9RdeIDf5mNYKJt1fBTxyHEUkKfmXW9qzX36pVn8iavqbZUw1jUFa8 /LAKVKLkpnrh/xGWUJeDwKsw3zdWDirSjTiY9ovohHW8SZpi5vuWf4aqlX159xM5b+kJ GxcA== 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=t/f0SbKUT+UsEzOBD9CKXQX2dpVHJ0rECtvyts7u5xk=; b=XP+KG1R5DwyvRh/b+bw8pqal4nJ9bkPLZmufnMTL19DIoTQikTh1z6FRpubEE4jbmu QePNKlcAkttxCiIn7Ceone1+DI6cNLT327VlHjPpf8WF/6E8F9ZTW8R6OZkSI2qi6rMH 3Hb0KIDazSq2hEq6cjYCl/66MFxKfOLCV45UtI1BoFpLwMQyLy3NGyjzfOkpHgjKhbu9 rOl22ocfpw4XXpf6IolqivEkXZbikM5U/apgqVOTgKKdMnk6sQUFLGSGlcVrtOTGF+xn vytlpxCg7p8E+z1Bs2a0qiooE3rgy7cVTTgDOuDLk4ov3Nb9kX5ZXjBhmOivOqF5O7Mt oUMA== 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 d8si5772292ejw.38.2021.01.10.14.53.50; Sun, 10 Jan 2021 14:54:13 -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 S1727464AbhAJWvZ (ORCPT + 99 others); Sun, 10 Jan 2021 17:51:25 -0500 Received: from foss.arm.com ([217.140.110.172]:39106 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727430AbhAJWvW (ORCPT ); Sun, 10 Jan 2021 17:51:22 -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 0230A152D; Sun, 10 Jan 2021 14:49:35 -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 A77C23F719; Sun, 10 Jan 2021 14:49:33 -0800 (PST) From: Suzuki K Poulose To: linux-arm-kernel@lists.infradead.org Cc: coresight@lists.linaro.org, mathieu.poirier@linaro.org, anshuman.khandual@arm.com, mike.leach@linaro.org, leo.yan@linaro.org, linux-kernel@vger.kernel.org, jonathan.zhouwen@huawei.com, catalin.marinas@arm.com, Suzuki K Poulose Subject: [PATCH v7 21/28] coresight: etm4x: Add necessary synchronization for sysreg access Date: Sun, 10 Jan 2021 22:48:43 +0000 Message-Id: <20210110224850.1880240-22-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20210110224850.1880240-1-suzuki.poulose@arm.com> References: <20210110224850.1880240-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 5d3041eccc14..3b17feb86d8a 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