From patchwork Thu Jul 16 17:57:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11668241 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8BD2C1392 for ; Thu, 16 Jul 2020 18:01:35 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5E32D20578 for ; Thu, 16 Jul 2020 18:01:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="nSBKF7dc"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="OpzV4NaE" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5E32D20578 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=5Gjs2f+ljvCWcjOJy18vM3fzcK8rQLtbGTY9sdQ9OsM=; b=nSBKF7dcvKD32Uto3J6FDcMPW XEt68rD6N9aXvHlsbh+m6x7+uBje3bGXUvIKPFMe+2PMAM0bVBrnh6xhOHHQIgFY3Wsg99l/6dxD0 Oe2u8bThWuVOjmSDxRWebZLb3b7Oj00D1fAZIxCp5YT8LkDVz99goXTPiR9AA0hVNFg7HVbfPLoKu o/E38Fkc9l8PIsH+ulmld0e2KA50UbLwqzURlg1aa6WL4Ff0YjHsE8ffKLmg2iAhjM3SqP4NrV5sV uj+1LM4YvVOtjXInor5dS16c0W4wPOtms3W29WnJQAxZqn1PNdCWSMNYoiYkSwbx0Zi/ASILfmqaz ctvOa+MbQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jw8Ah-00043l-C8; Thu, 16 Jul 2020 17:59:51 +0000 Received: from mail-pj1-x1042.google.com ([2607:f8b0:4864:20::1042]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jw88z-0003Gu-C9 for linux-arm-kernel@lists.infradead.org; Thu, 16 Jul 2020 17:58:09 +0000 Received: by mail-pj1-x1042.google.com with SMTP id gc9so5183739pjb.2 for ; Thu, 16 Jul 2020 10:58:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=x3lU9ESZHuY6IEHfi+MuYyjVp7DZTndB82CCyaqDX50=; b=OpzV4NaEaleDpzdmRuAlQoctrlccSk50yNj/iHO6/e30lFopQzd8JfMxVZYLX5/LsW uWa0DxkuRN52CblDPJCSlP5aVkxySbnxOjTjnT2ebW1wvbB3RqTKZTt47QMcV4zGg3Ue YfMEX1H2DTX7MJHtTGc5DuyF9g6v29VB0IDJYqTwyeRW6tbl0bIW7ETXLKoDeRmsXzAS 9X+ShfCtSD/2/Fot9vyO1405SKZz9mqXoFyE1YFgw0JdOn6/BaDP/z89C+R1ut6Jrwyb 9VmXw9ux5L2Sb1lB2peR8E2QtmzQIbnoWs/zZ/FXkgrDep6HpKmMGM/u9rZhFETgKWTd Rwgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=x3lU9ESZHuY6IEHfi+MuYyjVp7DZTndB82CCyaqDX50=; b=QZkH89+Mcyp50XfPjnlKbtL8Q0S2LC2joP89FCmE09jMR/A3QPIqx6IM4C60eb1RaH 92qZ4WHGB3hsLwALyKf2ynCeU+IXjNg2WtxzrcuJqaazrA6jzluu9r1vIFd+ifjkhqZj kwU5mfRzQ/Auk70ySdClJcXTh6lEWr/WKqMAloLBK0y1Yct8CxmQ7YpPSysfjkmFfF6I GKKo8nA5e9V9/rualh/KCJsLs47NvFlsosSdamvmCUao+FxOXP0mtPR55qkOyF6mSzXM y6QX2oxnsb5zaGmtIgGW9F2YM9/63b4dX2qiypZU9Mmxn4zLgeOGhHv55R7SFHBImWRu wuaA== X-Gm-Message-State: AOAM533JkjvnvdpRwmzGHRk2KPdMrOONxtEPUoc3lzHbBmc3HcoC4xeV +bwdUXysbguinux0VaoYanzNKqe9zh0= X-Google-Smtp-Source: ABdhPJyrf32tbmnyjqzXiZO51+mdup0SSwcihqJ7sJL0YzYpFeCipl+8isBV5TqypB0/A6ZAZQNBBQ== X-Received: by 2002:a17:90b:4c8b:: with SMTP id my11mr6093377pjb.153.1594922283580; Thu, 16 Jul 2020 10:58:03 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id 83sm5473253pfu.60.2020.07.16.10.58.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jul 2020 10:58:03 -0700 (PDT) From: Mathieu Poirier To: gregkh@linuxfoundation.org Subject: [PATCH 13/17] coresight: tmc: Fix TMC mode read in tmc_read_unprepare_etb() Date: Thu, 16 Jul 2020 11:57:42 -0600 Message-Id: <20200716175746.3338735-14-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200716175746.3338735-1-mathieu.poirier@linaro.org> References: <20200716175746.3338735-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200716_135805_924505_FAB41F84 X-CRM114-Status: GOOD ( 12.83 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:1042 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: saiprakash.ranjan@codeaurora.org, suzuki.poulose@arm.com, vulab@iscas.ac.cn, tingwei@codeaurora.org, andriy.shevchenko@linux.intel.com, linux-arm-kernel@lists.infradead.org, mike.leach@linaro.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Sai Prakash Ranjan Reading TMC mode register without proper coresight power management can lead to exceptions like the one in the call trace below in tmc_read_unprepare_etb() when the trace data is read after the sink is disabled. So fix this by having a check for coresight sysfs mode before reading TMC mode management register in tmc_read_unprepare_etb() similar to tmc_read_prepare_etb(). SError Interrupt on CPU6, code 0xbe000411 -- SError pstate: 80400089 (Nzcv daIf +PAN -UAO) pc : tmc_read_unprepare_etb+0x74/0x108 lr : tmc_read_unprepare_etb+0x54/0x108 sp : ffffff80d9507c30 x29: ffffff80d9507c30 x28: ffffff80b3569a0c x27: 0000000000000000 x26: 00000000000a0001 x25: ffffff80cbae9550 x24: 0000000000000010 x23: ffffffd07296b0f0 x22: ffffffd0109ee028 x21: 0000000000000000 x20: ffffff80d19e70e0 x19: ffffff80d19e7080 x18: 0000000000000000 x17: 0000000000000000 x16: 0000000000000000 x15: 0000000000000000 x14: 0000000000000000 x13: 0000000000000000 x12: 0000000000000000 x11: 0000000000000000 x10: dfffffd000000001 x9 : 0000000000000000 x8 : 0000000000000002 x7 : ffffffd071d0fe78 x6 : 0000000000000000 x5 : 0000000000000080 x4 : 0000000000000001 x3 : ffffffd071d0fe98 x2 : 0000000000000000 x1 : 0000000000000004 x0 : 0000000000000001 Kernel panic - not syncing: Asynchronous SError Interrupt Fixes: 4525412a5046 ("coresight: tmc: making prepare/unprepare functions generic") Reported-by: Mike Leach Signed-off-by: Sai Prakash Ranjan Tested-by: Mike Leach Signed-off-by: Mathieu Poirier --- drivers/hwtracing/coresight/coresight-tmc-etf.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-tmc-etf.c b/drivers/hwtracing/coresight/coresight-tmc-etf.c index 36cce2bfb744..6375504ba8b0 100644 --- a/drivers/hwtracing/coresight/coresight-tmc-etf.c +++ b/drivers/hwtracing/coresight/coresight-tmc-etf.c @@ -639,15 +639,14 @@ int tmc_read_unprepare_etb(struct tmc_drvdata *drvdata) spin_lock_irqsave(&drvdata->spinlock, flags); - /* There is no point in reading a TMC in HW FIFO mode */ - mode = readl_relaxed(drvdata->base + TMC_MODE); - if (mode != TMC_MODE_CIRCULAR_BUFFER) { - spin_unlock_irqrestore(&drvdata->spinlock, flags); - return -EINVAL; - } - /* Re-enable the TMC if need be */ if (drvdata->mode == CS_MODE_SYSFS) { + /* There is no point in reading a TMC in HW FIFO mode */ + mode = readl_relaxed(drvdata->base + TMC_MODE); + if (mode != TMC_MODE_CIRCULAR_BUFFER) { + spin_unlock_irqrestore(&drvdata->spinlock, flags); + return -EINVAL; + } /* * The trace run will continue with the same allocated trace * buffer. As such zero-out the buffer so that we don't end