Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp402808rwb; Sat, 14 Jan 2023 02:20:04 -0800 (PST) X-Google-Smtp-Source: AMrXdXuypZA0e9dRPjW0Wffd/ZRO7zXHOT2XmCIXdNTCJiXFm9kouA1bpr4cCIcyRKlL5dSjNaRW X-Received: by 2002:a17:906:1410:b0:7c0:dfb7:4476 with SMTP id p16-20020a170906141000b007c0dfb74476mr70371733ejc.57.1673691604405; Sat, 14 Jan 2023 02:20:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673691604; cv=none; d=google.com; s=arc-20160816; b=up6YV0JNM/VRiLVZirGBmTVdUbv6O0FzwOE6fUpBEsM/5tSwgwQtA/s7Jv2Ps2T+C6 Mflc1dxzflXnH4jk7X5BBxaFAsuDXDqDzbUsGYr6DDoV8+X2nAcIM5XgTmmzYrzV62PM 4qFEi92hcZjKnuzUc9JBIbFWgcGS3Vyl9XOfYWXOxnOp3eCwwhmWWz7d6USltlHoxF5/ h9Bb9ZX9lj/v688JDISc8YpktwdiXdgq6tJn7YwSKnP78zANtRzB23sFv598OK+9n2rE 9L2A9RUGLcm8Fo7vrsvsH2fctqSGoO9ezmsdhQJeE7b/B7hDUuzdi5vX7yump413RvTl 0Mag== 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 :message-id:date:subject:cc:to:from; bh=0zQlz83BRhVMsjgJJ6538H50XGaEQS7fmRnIp+JpuBs=; b=vGhkm9fZjmtvOcThW/XkAX6T6PbzKvnDAXTzPWDuoX35rsWD3MyIHqFO5ocrlJOXua MKCh+zu/ycWz0KwqY+Y7T0oDJm5r2a/ooeueofW3NazgIOO/VNYnH5fAOI9xaSIB4wMu otO4IrphLt0GziR3FUHf2ojZCpoSwg2hik7KCZ2/iS7f6paG/VEN/qdo3z/hsY6XQPRJ B11VeM1SzQRZys8z68jQxcFq/WKFRmewRoLmXij7oDsfdG0ZIP7aK/sJxoRD5c4GK1Eo J3Em/rhbgZ7qv/CexpeLbSnATjEHlvlWT/tS8r96HQgWewoPoVsOVB6EkIrvYoVfH2gG 5xgg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bb2-20020a1709070a0200b00864aa239277si8586466ejc.896.2023.01.14.02.19.51; Sat, 14 Jan 2023 02:20:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229489AbjANJRE (ORCPT + 51 others); Sat, 14 Jan 2023 04:17:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48788 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229875AbjANJQ6 (ORCPT ); Sat, 14 Jan 2023 04:16:58 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8ED8F5BA2 for ; Sat, 14 Jan 2023 01:16:52 -0800 (PST) Received: from dggpeml500002.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4NvCGR6VRYzqV6d; Sat, 14 Jan 2023 17:11:59 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by dggpeml500002.china.huawei.com (7.185.36.158) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Sat, 14 Jan 2023 17:16:49 +0800 From: Junhao He To: , , , CC: , , , , , , , Subject: [PATCH v2] coresight: etm4x: Fix accesses to TRCSEQRSTEVR and TRCSEQSTR Date: Sat, 14 Jan 2023 17:16:32 +0800 Message-ID: <20230114091632.60095-1-hejunhao3@huawei.com> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.69.192.56] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpeml500002.china.huawei.com (7.185.36.158) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The TRCSEQRSTEVR and TRCSEQSTR registers are not implemented if the TRCIDR5.NUMSEQSTATE == 0. Skip accessing the registers in such cases. Fixes: 2e1cdfe184b5 ("coresight-etm4x: Adding CoreSight ETM4x driver") Signed-off-by: Junhao He Reviewed-by: Mike Leach Reviewed-by: Anshuman Khandual --- .../hwtracing/coresight/coresight-etm4x-core.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/hwtracing/coresight/coresight-etm4x-core.c index 1cc052979e01..77bca6932f01 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x-core.c +++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c @@ -427,8 +427,10 @@ static int etm4_enable_hw(struct etmv4_drvdata *drvdata) etm4x_relaxed_write32(csa, config->vipcssctlr, TRCVIPCSSCTLR); for (i = 0; i < drvdata->nrseqstate - 1; i++) etm4x_relaxed_write32(csa, config->seq_ctrl[i], TRCSEQEVRn(i)); - etm4x_relaxed_write32(csa, config->seq_rst, TRCSEQRSTEVR); - etm4x_relaxed_write32(csa, config->seq_state, TRCSEQSTR); + if (drvdata->nrseqstate) { + etm4x_relaxed_write32(csa, config->seq_rst, TRCSEQRSTEVR); + etm4x_relaxed_write32(csa, config->seq_state, TRCSEQSTR); + } etm4x_relaxed_write32(csa, config->ext_inp, TRCEXTINSELR); for (i = 0; i < drvdata->nr_cntr; i++) { etm4x_relaxed_write32(csa, config->cntrldvr[i], TRCCNTRLDVRn(i)); @@ -1634,8 +1636,10 @@ static int __etm4_cpu_save(struct etmv4_drvdata *drvdata) for (i = 0; i < drvdata->nrseqstate - 1; i++) state->trcseqevr[i] = etm4x_read32(csa, TRCSEQEVRn(i)); - state->trcseqrstevr = etm4x_read32(csa, TRCSEQRSTEVR); - state->trcseqstr = etm4x_read32(csa, TRCSEQSTR); + if (drvdata->nrseqstate) { + state->trcseqrstevr = etm4x_read32(csa, TRCSEQRSTEVR); + state->trcseqstr = etm4x_read32(csa, TRCSEQSTR); + } state->trcextinselr = etm4x_read32(csa, TRCEXTINSELR); for (i = 0; i < drvdata->nr_cntr; i++) { @@ -1763,8 +1767,10 @@ static void __etm4_cpu_restore(struct etmv4_drvdata *drvdata) for (i = 0; i < drvdata->nrseqstate - 1; i++) etm4x_relaxed_write32(csa, state->trcseqevr[i], TRCSEQEVRn(i)); - etm4x_relaxed_write32(csa, state->trcseqrstevr, TRCSEQRSTEVR); - etm4x_relaxed_write32(csa, state->trcseqstr, TRCSEQSTR); + if (drvdata->nrseqstate) { + etm4x_relaxed_write32(csa, state->trcseqrstevr, TRCSEQRSTEVR); + etm4x_relaxed_write32(csa, state->trcseqstr, TRCSEQSTR); + } etm4x_relaxed_write32(csa, state->trcextinselr, TRCEXTINSELR); for (i = 0; i < drvdata->nr_cntr; i++) { -- 2.33.0