From patchwork Thu Dec 21 08:20:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 122518 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp580736qgn; Thu, 21 Dec 2017 00:21:24 -0800 (PST) X-Google-Smtp-Source: ACJfBotxK1sht8J7BsapCXI0O60HrnrnqSMHohHepEDSH9+RftK25+xjh8gN9jKriSpr9KZjsgD+ X-Received: by 10.101.82.137 with SMTP id y9mr4063096pgp.325.1513844484432; Thu, 21 Dec 2017 00:21:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513844484; cv=none; d=google.com; s=arc-20160816; b=OkWull8xO620i1F5ebuv2il16mzzfpI+IcVqteAPcsP3zapE0m6T/xEyT3F8OorpUb PhDdcS6SB1PsRAg4mJoqJ3ucN0D8fI29OBkfMau6KqyjrBOfsuu2Z8vLgThNxIT/HZ0t 68KPIFyTMwxNsy8SAo7nsj3+oBLGHYyIB7moIY/ZW9ULJB2CNgI164BdYeQn7qsbOqo2 4XMs5ANGEOYjBmYpPlHZ0gH7dORaysuto9dMsBf8b15hu1iqLn/HdJEu8X7klYrCaiHA Mb/CQD5VZDgka3S5FYe0TVNyiLEP8VuexDg7+LAC0bTyO7rYHrUEWKhQMZWf68/8aEHg 7+Iw== 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=hVcw3xdLS6WeFuwfw5o1/9kGrkGHKX+BEls7BbqyzX0=; b=M+lDhJfRt16zkJ0ZEMQFU9wt0FxbwBj6rYgFJnqG4ZTayiUi0+Qk8NZI6SWa7p/3p4 QoduccM+g27Hi4oD+/xg4cIeQMRzZSyfY3fVNpI1KmZrkmit1/xUpyV7RMaduOkcI1JT t4A+KdxdNFlyt963DXNoxOvQwMov1CLy4szvYhwRm8qSaHje95zFcHNQLtm9r42Lcmun gHne18YgnN9eW3svXrErCEDSPd1iUElIkVAfHh21bLoEupDXRy4mrUx/V/7OfvPwXkWY QImJk04Mv8rJKrOnneVbQqEX27GRMGgofgDjXSeBlSQ+Vn2ABxo5Y8/EdgHXgyCrAMjJ baxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ElIyeibX; 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 k6si13211470pgt.332.2017.12.21.00.21.24; Thu, 21 Dec 2017 00:21:24 -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=ElIyeibX; 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 S1751973AbdLUIVT (ORCPT + 28 others); Thu, 21 Dec 2017 03:21:19 -0500 Received: from mail-pg0-f67.google.com ([74.125.83.67]:38181 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751868AbdLUIVJ (ORCPT ); Thu, 21 Dec 2017 03:21:09 -0500 Received: by mail-pg0-f67.google.com with SMTP id f12so12984361pgo.5 for ; Thu, 21 Dec 2017 00:21:08 -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=hVcw3xdLS6WeFuwfw5o1/9kGrkGHKX+BEls7BbqyzX0=; b=ElIyeibXgKizq9nJocqY9T9N+wa89tyvBSe4KbllXvZXgfvELn+UX1TEFfEFPSJmsG LP1UCcC4DWG5/vrGgjOtJ1AAQ6jx+D4IOmWh/35TPbMXt5eNVKdiaomx/jhxqqOPnVzV 9xYGVDlUiNt2CelGjWg9jLVbVET/MC1gVXixo= 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=hVcw3xdLS6WeFuwfw5o1/9kGrkGHKX+BEls7BbqyzX0=; b=aO9hgRyyyP9y9aIJEtb5u6iziU2d5bu2sMUcmhPDwQH6BykYn/ATDu0tA4cuefZCCj Vywr/CQ3UQnjgEmODbc57M499e5Ssjwmh6s4V4VNfokr1rulaFkPtHA5sPK6d5FcUP9V JkIBjEUs2b6i5R5qUK3DnLYMqCJUmaPxzePDHcArvFVuTBpz09i/l/QHOpaW5X1M7May xQHEbLpAF/1tfpp8LteZAbDgt+NeZHvhQ0KaBWvIQ9y+OG/zReTzQROEY6auK37oyWde n5VNhASk4mUR1RdfXUzxKgqe4jfMMKgYyt3vn+4qToRt0/YBd9KTFcnFykHEvDqCfs+v p2mQ== X-Gm-Message-State: AKGB3mIVSKS1YC4rpWnqeq9evrnxG1wE9FDX3Yfgbmb4rZeNbNmdM2U7 5NHi39J4BZ1kxD6b7RE304QjNw== X-Received: by 10.98.138.17 with SMTP id y17mr9775299pfd.122.1513844468283; Thu, 21 Dec 2017 00:21:08 -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.21.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 21 Dec 2017 00:21:07 -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 6/6] coresight: etm4x: Support panic kdump Date: Thu, 21 Dec 2017 16:20:15 +0800 Message-Id: <1513844415-11427-7-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 ETMv4 hardware information and configuration needs to be saved as metadata; these metadata should be compatible with tool 'perf' and can be used for tracing data analysis. ETMv4 usually works as tracer per CPU, we cannot wait to gather ETM info after the CPU has been panic and cannot execute dump operations for itself; so should gather metadata when the corresponding CPU is alive. Since values in TRCIDR{0, 1, 2, 8} and TRCAUTHSTATUS are read-only and won't change at the runtime. Those registers value are filled when tracers are instantiated. The configuration and control registers TRCCONFIGR and TRCTRACEIDR are dynamically configured, we record their value when enabling coresight path. When operating from sysFS tracer these two registers are recorded in etm4_enable_sysfs() and add kdump node into list, and remove the kdump node in etm4_disable_sysfs(). When operating from perf, etm_setup_aux() adds all tracers to the dump list and etm4_enable_perf() is used to record configuration registers and update dump buffer info, this can avoid unnecessary list addition and deletion operations. Removal of the tracers from the dump list is done in function free_event_data(). Suggested-by: Mathieu Poirier Signed-off-by: Leo Yan --- drivers/hwtracing/coresight/coresight-etm-perf.c | 12 +++++++++++- drivers/hwtracing/coresight/coresight-etm4x.c | 23 +++++++++++++++++++++++ drivers/hwtracing/coresight/coresight-etm4x.h | 15 +++++++++++++++ 3 files changed, 49 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c index 8a0ad77..fec779b 100644 --- a/drivers/hwtracing/coresight/coresight-etm-perf.c +++ b/drivers/hwtracing/coresight/coresight-etm-perf.c @@ -137,6 +137,12 @@ static void free_event_data(struct work_struct *work) } for_each_cpu(cpu, mask) { + struct coresight_device *csdev; + + csdev = per_cpu(csdev_src, cpu); + if (csdev) + coresight_kdump_del(csdev); + if (!(IS_ERR_OR_NULL(event_data->path[cpu]))) coresight_release_path(event_data->path[cpu]); } @@ -195,7 +201,7 @@ static void etm_free_aux(void *data) static void *etm_setup_aux(int event_cpu, void **pages, int nr_pages, bool overwrite) { - int cpu; + int cpu, ret; cpumask_t *mask; struct coresight_device *sink; struct etm_event_data *event_data = NULL; @@ -238,6 +244,10 @@ static void *etm_setup_aux(int event_cpu, void **pages, event_data->path[cpu] = coresight_build_path(csdev, sink); if (IS_ERR(event_data->path[cpu])) goto err; + + ret = coresight_kdump_add(csdev, cpu); + if (ret) + goto err; } if (!sink_ops(sink)->alloc_buffer) diff --git a/drivers/hwtracing/coresight/coresight-etm4x.c b/drivers/hwtracing/coresight/coresight-etm4x.c index cf364a5..cbde398 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x.c +++ b/drivers/hwtracing/coresight/coresight-etm4x.c @@ -258,10 +258,19 @@ static int etm4_enable_perf(struct coresight_device *csdev, static int etm4_enable_sysfs(struct coresight_device *csdev) { struct etmv4_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); + struct etmv4_config *config = &drvdata->config; + struct etmv4_metadata *metadata = &drvdata->metadata; int ret; spin_lock(&drvdata->spinlock); + /* Update meta data and add into kdump list */ + metadata->trcconfigr = config->cfg; + metadata->trctraceidr = drvdata->trcid; + + coresight_kdump_add(csdev, drvdata->cpu); + coresight_kdump_update(csdev, (char *)metadata, sizeof(*metadata)); + /* * Executing etm4_enable_hw on the cpu whose ETM is being enabled * ensures that register writes occur when cpu is powered. @@ -384,6 +393,9 @@ static void etm4_disable_sysfs(struct coresight_device *csdev) */ smp_call_function_single(drvdata->cpu, etm4_disable_hw, drvdata, 1); + /* Delete from kdump list */ + coresight_kdump_del(csdev); + spin_unlock(&drvdata->spinlock); cpus_read_unlock(); @@ -438,6 +450,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 +603,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); } 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 */