From patchwork Fri Mar 30 03:15:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 132581 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp2530831ljb; Thu, 29 Mar 2018 20:16:20 -0700 (PDT) X-Google-Smtp-Source: AIpwx49171FWWYchC3ycSrAT6yXJlRk2ntm7exQT16lvNKGoXQ0O/EJ/UAknfWZyEDt2pyulDz9P X-Received: by 10.98.87.7 with SMTP id l7mr8451342pfb.148.1522379780265; Thu, 29 Mar 2018 20:16:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522379780; cv=none; d=google.com; s=arc-20160816; b=wG1neu7KpUKZFYaHf9n08jWvKpHbsczdv75yx9H2/vMlGnNDsusiSkZ7IJJVJ52PMq R1E3vt3gRHM3Cq5tJ3SyQ7t4VFkoInFIIctYrGVUjaynJivuYC8LIjOQqftZ18oMXNZ5 UKXqX5lpLO71qGKR6w+4DfZ63tP/6rkzHDhEOHmQyU28369/7MoLHGYRHM+Mr5BVJrF2 2rEWUflnWBWbDl+2kwkUgktZPeTDVhy+gjf+9/yzGxCOj+/fxpWL3yOw5wvHAksFB+r6 OXbFgyV1jjpbdbU1Ze77ysUIZ5tyJD7QLs4ozX1CpkNEEk9bJT+zG50Qr4y2R5X0lJ+8 JlwQ== 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=gsayClFC98iYx6/DqOyvc4Nh2Po2oTAyjfQNyaF63bo=; b=mSZioiLHxPG1KuobkI8+pdUxZh9Id/IiN5dc5s8myeKIsIkiSsOoALbHjulM7VC/99 1fk5VU/+JLjjfEnPxu/tYoVRYPPzTXJgz2GSirFUXHBSHczklmDPWMoGbEf7Lo9kjzZV PcG1L+4m+IjHGCZcIN4TX7SoqrktZuMgdgtk/TPDWPhXjQwLLld2XLjnK70isOc6P+t/ UnNyHeFeWzwLF4CmpIdSbjiPo6p62fBCt50fBNLudGpojn46i+DW7RLo0Jd4FJcdn46F 66W9h4M49aFhXnC/TtjhRVhoGNQ2PSCcwHJ/WH/T1E8NSMUVmEPUSuFz6k8nIlBdyeRI cPuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jVhtZPFl; 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 c15si4912599pgu.312.2018.03.29.20.16.19; Thu, 29 Mar 2018 20:16:20 -0700 (PDT) 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=jVhtZPFl; 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 S1752864AbeC3DQS (ORCPT + 29 others); Thu, 29 Mar 2018 23:16:18 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:51780 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752840AbeC3DQP (ORCPT ); Thu, 29 Mar 2018 23:16:15 -0400 Received: by mail-wm0-f68.google.com with SMTP id v21so13788930wmc.1 for ; Thu, 29 Mar 2018 20:16:14 -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; bh=gsayClFC98iYx6/DqOyvc4Nh2Po2oTAyjfQNyaF63bo=; b=jVhtZPFl0kII/TF4P7WL6AmIIxkdny77kI8hs5UvnFEoEv8j0OrCQrRhTqWmS1kenX ug6VnsEmhNmQ/JDkFE2jWN1pvEYYGyF8qewsZyRpqbwVGT97KDDw+7oGbQK1VoZCdkem mwuTvS+YdUG8foCTCujbnSuYzJ8NkQUCtnIC0= 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=gsayClFC98iYx6/DqOyvc4Nh2Po2oTAyjfQNyaF63bo=; b=O8/ggYqAlfXU8y+Ib/j11R55iJODrpMlMwzS1EqFBEPszzARQu+Newm+BJmEZMJDo4 ei1H6vQdaMEs0tPA0qr3/Jc53RAMG3C/TCofuUMYzKY5YhTuPzur/0i4BF19plXdfUC+ O0jUw6IC7e3daVcp1bgaVyy5HZOu6W/Z258suf/lOjw4R3WyhujnznIx7hc7obX49HKj IEnJQqU3e5k4622ElhytiidFCq9eYBdq52zLzg/McO6SdZICN7edcN0UlKSoeLxcCOy1 RvtXohS488y0RNYuIDRquXJSAapLrCr/+f7O6rOFLv+yzkBLBlS9/52ueSq9/VN3tcI2 Hgug== X-Gm-Message-State: AElRT7FGtWUbGRYDPYski+qzxdu4CPugIvy5kqbQCglwexzamxl0cguT 2xmoQosrS1kQmS41lNOqUDX+cK6fbdM= X-Received: by 10.28.1.197 with SMTP id 188mr920701wmb.49.1522379773967; Thu, 29 Mar 2018 20:16:13 -0700 (PDT) Received: from localhost.localdomain (li622-172.members.linode.com. [212.71.249.172]) by smtp.gmail.com with ESMTPSA id z9sm12798903wrz.4.2018.03.29.20.16.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 29 Mar 2018 20:16:13 -0700 (PDT) From: Leo Yan To: Jonathan Corbet , Mathieu Poirier , Greg Kroah-Hartman , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, coresight@lists.linaro.org, Kim Phillips , Mike Leach Cc: Leo Yan Subject: [PATCH v4 6/6] coresight: etm4x: Support panic kdump Date: Fri, 30 Mar 2018 11:15:24 +0800 Message-Id: <1522379724-30648-7-git-send-email-leo.yan@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1522379724-30648-1-git-send-email-leo.yan@linaro.org> References: <1522379724-30648-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 ETMv4 hardware information and configuration needs to be saved as metadata; the metadata format should be compatible with 'perf' tool and finally is used by tracing data decoder. ETMv4 works as tracer per CPU, we cannot wait for gathering ETM info after CPU panic has happened in case there have CPU is locked up and can't response inter-processor interrupt for execution dump operations; so it's more reliable to gather tracer metadata when all of the CPUs are alive. This patch saves ETMv4 metadata but with the different method for different registers. Since values in TRCIDR{0, 1, 2, 8} and TRCAUTHSTATUS are read-only and won't change afterward, thus those registers values are filled into metadata structure when tracers are instantiated. The configuration and control registers TRCCONFIGR and TRCTRACEIDR are dynamically configured, their values are recorded during tracer enabling phase. To avoid unnecessary overload introduced by set/clear operations for updating kdump node, we only set ETMv4 metadata info for the corresponding kdump node at initialization and won't be cleared anymore. Suggested-by: Mathieu Poirier Signed-off-by: Leo Yan --- drivers/hwtracing/coresight/coresight-etm4x.c | 27 +++++++++++++++++++++++++++ drivers/hwtracing/coresight/coresight-etm4x.h | 15 +++++++++++++++ 2 files changed, 42 insertions(+) -- 2.7.4 diff --git a/drivers/hwtracing/coresight/coresight-etm4x.c b/drivers/hwtracing/coresight/coresight-etm4x.c index cf364a5..88b1e19 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x.c +++ b/drivers/hwtracing/coresight/coresight-etm4x.c @@ -288,6 +288,8 @@ static int etm4_enable(struct coresight_device *csdev, int ret; u32 val; struct etmv4_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); + struct etmv4_config *config = &drvdata->config; + struct etmv4_metadata *metadata = &drvdata->metadata; val = local_cmpxchg(&drvdata->mode, CS_MODE_DISABLED, mode); @@ -306,6 +308,10 @@ static int etm4_enable(struct coresight_device *csdev, ret = -EINVAL; } + /* Update tracer meta data after tracer configuration */ + metadata->trcconfigr = config->cfg; + metadata->trctraceidr = drvdata->trcid; + /* The tracer didn't start */ if (ret) local_set(&drvdata->mode, CS_MODE_DISABLED); @@ -438,6 +444,7 @@ static void etm4_init_arch_data(void *info) u32 etmidr4; u32 etmidr5; struct etmv4_drvdata *drvdata = info; + struct etmv4_metadata *metadata = &drvdata->metadata; /* Make sure all registers are accessible */ etm4_os_unlock(drvdata); @@ -590,6 +597,16 @@ static void etm4_init_arch_data(void *info) drvdata->nrseqstate = BMVAL(etmidr5, 25, 27); /* NUMCNTR, bits[30:28] number of counters available for tracing */ drvdata->nr_cntr = BMVAL(etmidr5, 28, 30); + + /* Update metadata */ + metadata->magic = ETM4_METADATA_MAGIC; + metadata->cpu = drvdata->cpu; + metadata->trcidr0 = readl_relaxed(drvdata->base + TRCIDR0); + metadata->trcidr1 = readl_relaxed(drvdata->base + TRCIDR1); + metadata->trcidr2 = readl_relaxed(drvdata->base + TRCIDR2); + metadata->trcidr8 = readl_relaxed(drvdata->base + TRCIDR8); + metadata->trcauthstatus = readl_relaxed(drvdata->base + TRCAUTHSTATUS); + CS_LOCK(drvdata->base); } @@ -957,6 +974,7 @@ static int etm4_probe(struct amba_device *adev, const struct amba_id *id) struct device *dev = &adev->dev; struct coresight_platform_data *pdata = NULL; struct etmv4_drvdata *drvdata; + struct etmv4_metadata *metadata; struct resource *res = &adev->res; struct coresight_desc desc = { 0 }; struct device_node *np = adev->dev.of_node; @@ -1027,6 +1045,15 @@ static int etm4_probe(struct amba_device *adev, const struct amba_id *id) goto err_arch_supported; } + /* Set source device handler and metadata into kdump node */ + metadata = &drvdata->metadata; + ret = coresight_kdump_source(drvdata->cpu, drvdata->csdev, + (char *)metadata, sizeof(*metadata)); + if (ret) { + coresight_unregister(drvdata->csdev); + goto err_arch_supported; + } + ret = etm_perf_symlink(drvdata->csdev, true); if (ret) { coresight_unregister(drvdata->csdev); diff --git a/drivers/hwtracing/coresight/coresight-etm4x.h b/drivers/hwtracing/coresight/coresight-etm4x.h index b3b5ea7..08dc8b7 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x.h +++ b/drivers/hwtracing/coresight/coresight-etm4x.h @@ -198,6 +198,20 @@ #define ETM_EXLEVEL_NS_HYP BIT(14) #define ETM_EXLEVEL_NS_NA BIT(15) +#define ETM4_METADATA_MAGIC 0x4040404040404040ULL + +struct etmv4_metadata { + u64 magic; + u64 cpu; + u64 trcconfigr; + u64 trctraceidr; + u64 trcidr0; + u64 trcidr1; + u64 trcidr2; + u64 trcidr8; + u64 trcauthstatus; +}; + /** * struct etmv4_config - configuration information related to an ETMv4 * @mode: Controls various modes supported by this ETM. @@ -393,6 +407,7 @@ struct etmv4_drvdata { bool atbtrig; bool lpoverride; struct etmv4_config config; + struct etmv4_metadata metadata; }; /* Address comparator access types */