From patchwork Thu Dec 21 08:20:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 122519 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp581039qgn; Thu, 21 Dec 2017 00:21:46 -0800 (PST) X-Google-Smtp-Source: ACJfBovHXegkVODnAmZ43GbYDbUVYa9QDynyDrZX5iXo++siwFujiX7xqee4fnPZNeXIawxZVW3n X-Received: by 10.84.235.2 with SMTP id o2mr9656182plk.64.1513844506095; Thu, 21 Dec 2017 00:21:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513844506; cv=none; d=google.com; s=arc-20160816; b=H1sV8xMcBrsck33cCdVtQyJ5XFxSxAHdck9vSO1Z0R1QnXipRM//RDh5cboBhTLp5d yV3nShlqbJeptCJr8tr8uW8NBbSjs6j8vwg7GrH9O5EeYINfRhY/hO9JAX3fyyjwra29 mkkZk34zzH8zSDQ+drTQGH7bvBEyqbH7ZLd8sSh7jp9vBbdIx5rEjWsEA5luZTuD6REw XyRYmm99meK4B2g2eavMZksiCjNiFWqqhmToNT7ordxzzIGC819daFzk3unMbQgqJvTC oD0nwGS8PPpO7TM3DmnEsvg9m7iV/CARwavKA+Yg1rDtfqg1Q3PBsY+MfSFeNCkHUVO7 8VyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=/eTpv8iA5Al+T360+/ZTh3hwOR46+gjkKrw3OpJ/WGI=; b=F6eTv0wnYPRQMgKFRytrq1NEadmfZSaoFCApIlWN2bPPsvvzXWlaX6fzw61XG7hb8R JbDakCM2rro1x35vcI7uWavegxnMepXJfveejms2oKf+tr0MajxLlWcmmmN1wblF636q Yj7wbzyMvnzcfWEytbSNWg40k3mtbmpecKXUdtvnnL1qWWcFRnDIyzXmRTcjQxiR30T/ 0sgz7L8Wk9fuqIGwu/fCUpi5ItkjH5Ki+3m7RrA9SMD7imoKZu8cpqECSTMbcCNwsvTB Ru+fpf3L4tC3nAr8M0jktCxTdmwxOlONjh0xuRScDWOyyiopFPD2IMT4+xx+NdwK91YL VvLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DU5RMvGs; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p7si15113413pll.96.2017.12.21.00.21.45; Thu, 21 Dec 2017 00:21:46 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DU5RMvGs; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751976AbdLUIVl (ORCPT + 28 others); Thu, 21 Dec 2017 03:21:41 -0500 Received: from mail-pg0-f67.google.com ([74.125.83.67]:43989 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751781AbdLUIU6 (ORCPT ); Thu, 21 Dec 2017 03:20:58 -0500 Received: by mail-pg0-f67.google.com with SMTP id b18so12975642pgv.10 for ; Thu, 21 Dec 2017 00:20:58 -0800 (PST) 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; bh=/eTpv8iA5Al+T360+/ZTh3hwOR46+gjkKrw3OpJ/WGI=; b=DU5RMvGs/cms3WgP3IKWfxsyXumEnJ5e+osvE/TBSWjb8gWFpC4IlBjQX+zLlJN6q0 DSs1rRRxQ7jdCotYwn2+iO6Rzl72YFyDyUU+8sUj4Ted9/dN4YKBYM87nxi5dMKAsJeH uT2XUmUDSVgFmXT6w7AFv5RhFGFntOU2vFL+M= 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; bh=/eTpv8iA5Al+T360+/ZTh3hwOR46+gjkKrw3OpJ/WGI=; b=VlmKq+gAiTEYjS77bh4e6Ze5VlYVudx/ROaj2lpy1uq5EApsUclUaMa6RFMtju1430 1+p1mJQNxjvxWspIx+z9vapjEXDi/RXSWcLk0JS5gpS1sbN4frSMoKLihjsVnGkQ5sFr CB+Im3GBMMX0QHwXYEJrZXz0RZ+dmFseRJB+PhaehfwZi8+ycwiiQyS7zFTBLoxAPRfG 9ZWVduPjqF7Ud3ElMpHkJDYjje5KG65VgtNjFpFVSC60YjIeZu2PgMur6x/zToakKj98 G6z8njkuMJG8OxyCTliXJdUYswfS5IVsXi/mJtbiu0ZBvypCk7nmw8VWnqy3KD5s0HyU fjQg== X-Gm-Message-State: AKGB3mIZi/LbTsoPdDC2s0XTDpRbn++CXFnyQuojbqEg2PxybZsA+nV0 jkDFeYu7JVd0n8TgH5iukvZklw== X-Received: by 10.99.121.72 with SMTP id u69mr8936876pgc.419.1513844458094; Thu, 21 Dec 2017 00:20:58 -0800 (PST) Received: from localhost.localdomain (li159-223.members.linode.com. [173.230.149.223]) by smtp.gmail.com with ESMTPSA id r86sm43699720pfk.114.2017.12.21.00.20.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 21 Dec 2017 00:20:56 -0800 (PST) From: Leo Yan To: Jonathan Corbet , Mathieu Poirier , Greg Kroah-Hartman , Will Deacon , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, coresight@lists.linaro.org Cc: Leo Yan Subject: [PATCH v3 4/6] coresight: tmc: Hook callback for panic kdump Date: Thu, 21 Dec 2017 16:20:13 +0800 Message-Id: <1513844415-11427-5-git-send-email-leo.yan@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1513844415-11427-1-git-send-email-leo.yan@linaro.org> References: <1513844415-11427-1-git-send-email-leo.yan@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since the panic kdump functionality has been ready, this patch is to hook panic callback function for ETB/ETF. Since the driver data structure has allocated buffer when the session started, so simply save ETB/ETF trace data into the buffer when panic happens and update related info into dump node. Signed-off-by: Leo Yan --- drivers/hwtracing/coresight/coresight-tmc-etf.c | 29 +++++++++++++++++++++++++ 1 file changed, 29 insertions(+) -- 2.7.4 diff --git a/drivers/hwtracing/coresight/coresight-tmc-etf.c b/drivers/hwtracing/coresight/coresight-tmc-etf.c index e2513b7..f823464 100644 --- a/drivers/hwtracing/coresight/coresight-tmc-etf.c +++ b/drivers/hwtracing/coresight/coresight-tmc-etf.c @@ -504,6 +504,34 @@ static void tmc_update_etf_buffer(struct coresight_device *csdev, CS_LOCK(drvdata->base); } +static void tmc_panic_cb(void *data) +{ + struct coresight_device *csdev = (struct coresight_device *)data; + struct tmc_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); + unsigned long flags; + + if (WARN_ON_ONCE(drvdata->config_type != TMC_CONFIG_TYPE_ETB && + drvdata->config_type != TMC_CONFIG_TYPE_ETF)) + return; + + if (drvdata->mode == CS_MODE_DISABLED) + return; + + spin_lock_irqsave(&drvdata->spinlock, flags); + + CS_UNLOCK(drvdata->base); + + tmc_flush_and_stop(drvdata); + tmc_etb_dump_hw(drvdata); + + CS_LOCK(drvdata->base); + + /* Update buffer info for panic dump */ + coresight_kdump_update(csdev, drvdata->buf, drvdata->len); + + spin_unlock_irqrestore(&drvdata->spinlock, flags); +} + static const struct coresight_ops_sink tmc_etf_sink_ops = { .enable = tmc_enable_etf_sink, .disable = tmc_disable_etf_sink, @@ -512,6 +540,7 @@ static const struct coresight_ops_sink tmc_etf_sink_ops = { .set_buffer = tmc_set_etf_buffer, .reset_buffer = tmc_reset_etf_buffer, .update_buffer = tmc_update_etf_buffer, + .panic_cb = tmc_panic_cb, }; static const struct coresight_ops_link tmc_etf_link_ops = {