From patchwork Fri Mar 30 03:15:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 132580 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp2530798ljb; Thu, 29 Mar 2018 20:16:16 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/eeH3/x8WOVPOvI7ajAzkyOORN1Pt9ZHZMAre+uA9KwAGRkFQb1INFPilJqTDAbfY+J24n X-Received: by 2002:a17:902:1006:: with SMTP id b6-v6mr11175951pla.252.1522379776838; Thu, 29 Mar 2018 20:16:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522379776; cv=none; d=google.com; s=arc-20160816; b=fpeWxA76Letp5eJFz/qm3hcvdGyzEakPUsVh/GGSF9i5oejRy96rdddM2Eeb7VjnNH 69skgeL2iJ6rfnfX0KvHVz1pWe9D1tglq5konYgw64QVTb0HJ5gTrNK6CVA1F2BMIejY A8GHCP5St+f1lJHC0/SUGPsAX2Zfz06L6JQU6UvPQ8zHGYLGLZy5cL3YWtijWmO8s8GN AO6zj1eWNdcvYblCFjZVbvKPVObV9NdQMCXdSl+CEPmkNnWwTTKhMuQwMWZB0dRVesOn 7o9V4r50zUpgRuyYqoQpmV+ND4EyvaSSZyjdcaqoD4p/T1bVKznRM+Rw8rYz35WdyWv9 HepA== 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=Q2kDM5YY0TwXhvJ2W20sii7DcFnE2eb+0roImoIBLhE=; b=YzxVgKL/uF7zoZasRFhhVpUTzQIy2E5ghciPMQDlmINp42+o+oNVhXs3nGCmn+zPlT X4l/zsdTMRi/F6B/RhP2V17gB1r+kSYKuLE/+dWHR56Y7ZujZ5R3TsjTrP/vMdqc0/81 viPK5TtbeHrpSn8BCWTFGsU5vPAh4ZeqHanUySO/iwl5etF02YHdP11VhHJ0o3syyO4a w5Q5ph4CDPKirprSNelSqyGfZ3a8y3XuhbtyQ/a5aUSC5lIPqQep9c6UUXJ7Sek7gSJn ZF2rhHTYSNgHEdBYVD/ABTu01w1XHHUBoumoe6aajpGjO3mzYxE/C3pC94+pUJQXyQ9/ vzzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GMNqn4QN; 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.16; Thu, 29 Mar 2018 20:16:16 -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=GMNqn4QN; 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 S1752838AbeC3DQN (ORCPT + 29 others); Thu, 29 Mar 2018 23:16:13 -0400 Received: from mail-wr0-f193.google.com ([209.85.128.193]:43106 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752800AbeC3DQK (ORCPT ); Thu, 29 Mar 2018 23:16:10 -0400 Received: by mail-wr0-f193.google.com with SMTP id p53so6965400wrc.10 for ; Thu, 29 Mar 2018 20:16:10 -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=Q2kDM5YY0TwXhvJ2W20sii7DcFnE2eb+0roImoIBLhE=; b=GMNqn4QNPZXZgme8ePFR/DJMWeGcXC9pfBLGKxc8Mz3yfap/sCbEP1P+fm/TwPFf98 PSE/aUa17YScshfBnO9QWfqbmV1jsMnGuT62Tl7kKpNFrMfZgRiMAnudRwju5ZGj222D 1xpXEnyk2ICSOukguQsmIDSdGrzsQbIhGEZKo= 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=Q2kDM5YY0TwXhvJ2W20sii7DcFnE2eb+0roImoIBLhE=; b=EcDa1DYLhmgL6EHhbs+JgbV9X1HL3fPDeu1jPscFuAcx9/elIVUAZ4YngBLM3Kj/jJ xZdcWwtWq4kCz792xZlrVkkPfNYzDQG4Pd8a+0JgLNbwywuPPnKhllRBKbDc+5Xhu0L1 lS+2qeWLc0W5TYATDhGxBe2DbtVj9ZqVu7v4qPcMSJ0cBN/OWL0a/fLshFz/nFDyF8id gybs2VwZXOZ/sbB682wMqKlZSOqtB0f+PtrkMajQhc3wnu7d6D0lab+tiJHbyWCrrNDj YYyRmouUQzvuKxVAvriGUEpvGrhk0Jk+QoXDRCB5aoE6FL1oe4oIYNpVuebt5ZFqkyJ2 4wtw== X-Gm-Message-State: AElRT7GiXdKzMDKzivL6/eq/QQJMvIjcyAlHUWeTAurA2qPNP9VIv0um OgX23xURI6P6cv+1OTIumhbDsQ== X-Received: by 10.223.227.73 with SMTP id n9mr8011978wrj.134.1522379769345; Thu, 29 Mar 2018 20:16:09 -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.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 29 Mar 2018 20:16:08 -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 5/6] coresight: Set and clear sink device handler for kdump node Date: Fri, 30 Mar 2018 11:15:23 +0800 Message-Id: <1522379724-30648-6-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 If Coresight path is enabled for specific CPU, the sink device handler need to be set to kdump node; on the other hand we also need to clear sink device handler when path is disabled. This patch sets sink devices handler for kdump node for two separate Coresight enabling modes: CS_MODE_SYSFS and CS_MODE_PERF; and clear the handler when Coresight is disabled. Signed-off-by: Leo Yan --- drivers/hwtracing/coresight/coresight-etm-perf.c | 5 +++++ drivers/hwtracing/coresight/coresight.c | 16 ++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) -- 2.7.4 diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c index 8a0ad77..f8b159c 100644 --- a/drivers/hwtracing/coresight/coresight-etm-perf.c +++ b/drivers/hwtracing/coresight/coresight-etm-perf.c @@ -139,6 +139,8 @@ static void free_event_data(struct work_struct *work) for_each_cpu(cpu, mask) { if (!(IS_ERR_OR_NULL(event_data->path[cpu]))) coresight_release_path(event_data->path[cpu]); + + coresight_kdump_sink(cpu, NULL); } kfree(event_data->path); @@ -238,6 +240,9 @@ 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; + + if (coresight_kdump_sink(cpu, sink)) + goto err; } if (!sink_ops(sink)->alloc_buffer) diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c index 389c4ba..483a1f7 100644 --- a/drivers/hwtracing/coresight/coresight.c +++ b/drivers/hwtracing/coresight/coresight.c @@ -272,6 +272,7 @@ static int coresight_enable_source(struct coresight_device *csdev, u32 mode) static bool coresight_disable_source(struct coresight_device *csdev) { if (atomic_dec_return(csdev->refcnt) == 0) { + if (source_ops(csdev)->disable) source_ops(csdev)->disable(csdev, NULL); csdev->enable = false; @@ -612,6 +613,13 @@ int coresight_enable(struct coresight_device *csdev) if (ret) goto err_source; + cpu = source_ops(csdev)->cpu_id(csdev); + + /* Set sink device handler into kdump node */ + ret = coresight_kdump_sink(cpu, sink); + if (ret) + goto err_kdump; + switch (subtype) { case CORESIGHT_DEV_SUBTYPE_SOURCE_PROC: /* @@ -621,7 +629,6 @@ int coresight_enable(struct coresight_device *csdev) * be a single session per tracer (when working from sysFS) * a per-cpu variable will do just fine. */ - cpu = source_ops(csdev)->cpu_id(csdev); per_cpu(tracer_path, cpu) = path; break; case CORESIGHT_DEV_SUBTYPE_SOURCE_SOFTWARE: @@ -636,6 +643,9 @@ int coresight_enable(struct coresight_device *csdev) mutex_unlock(&coresight_mutex); return ret; +err_kdump: + coresight_disable_source(csdev); + err_source: coresight_disable_path(path); @@ -659,9 +669,10 @@ void coresight_disable(struct coresight_device *csdev) if (!csdev->enable || !coresight_disable_source(csdev)) goto out; + cpu = source_ops(csdev)->cpu_id(csdev); + switch (csdev->subtype.source_subtype) { case CORESIGHT_DEV_SUBTYPE_SOURCE_PROC: - cpu = source_ops(csdev)->cpu_id(csdev); path = per_cpu(tracer_path, cpu); per_cpu(tracer_path, cpu) = NULL; break; @@ -674,6 +685,7 @@ void coresight_disable(struct coresight_device *csdev) break; } + coresight_kdump_sink(cpu, NULL); coresight_disable_path(path); coresight_release_path(path);