From patchwork Tue Jul 19 22:53:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 72374 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp322255qga; Tue, 19 Jul 2016 15:54:56 -0700 (PDT) X-Received: by 10.98.98.193 with SMTP id w184mr59387627pfb.162.1468968896392; Tue, 19 Jul 2016 15:54:56 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id wy7si35007274pab.3.2016.07.19.15.54.55; Tue, 19 Jul 2016 15:54:56 -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; 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 dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752466AbcGSWyP (ORCPT + 29 others); Tue, 19 Jul 2016 18:54:15 -0400 Received: from mail-it0-f49.google.com ([209.85.214.49]:36368 "EHLO mail-it0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752354AbcGSWyG (ORCPT ); Tue, 19 Jul 2016 18:54:06 -0400 Received: by mail-it0-f49.google.com with SMTP id f6so102809189ith.1 for ; Tue, 19 Jul 2016 15:54:06 -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=KBRW0CkFaZEYLiQG80AByJN3uksWSKjneUhDDpPuluE=; b=hpmZIto4x6/SQ4evQBqmlbasLdPTC9aCWN0qWZBgB2ViYfyGPs6b+kNVFEqEfn7KRY /ZzcGCBXJzRqJ4zNI5TDJGV2ViLa6huFHLJsOB8CwOK9MaznYoFS0XhjoCMVQ7MUnuUm 5o0y30fVMJROTI01+op8q0w3wwaLpc7w5htyY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=KBRW0CkFaZEYLiQG80AByJN3uksWSKjneUhDDpPuluE=; b=cV1q0V8PKQ+RWQtq73KTY2+iUuPvHbn5jikzghurqFJE3HZ47gxbwAFPASH8HABv79 HZA3pIT68qWFDP+8okQ63rNhK4HGEMEu8KV6TbIuHtFUt4say6t9uzTJmGj7oNSALa3A S0k4Ci2ALeB8Wixs1WYqQzb45N7Antv0xh8dg640Imi6WUkUHZwLHzXiKfH5CokYLU2a KxgWltyzOWBQJAZAjgVQjEiBWbIRVj97vIpk+5kPYy7XjEjDJ0dHRFt4duI1Y5kLkzO9 etS4AGKB4B1m2kgvqS+DnYJ+GO5NNZtBb2gNf4pGuP2knJz84Wpu+gyoYFfQduCMzbXZ Qd7Q== X-Gm-Message-State: ALyK8tLrw8qeS4NFttcDx/m1O2rGxocNLtLqSzSeR1Cedhe72O0OoT/eYGmNC7XqyXJYBDok X-Received: by 10.36.28.149 with SMTP id c143mr6882110itc.55.1468968845853; Tue, 19 Jul 2016 15:54:05 -0700 (PDT) Received: from t430.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id x96sm71499ita.20.2016.07.19.15.54.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 19 Jul 2016 15:54:05 -0700 (PDT) From: Mathieu Poirier To: peterz@infradead.org, mingo@redhat.com, acme@kernel.org, alexander.shishkin@linux.intel.com, jolsa@kernel.org Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 5/6] coresight: adding sink parameter to function coresight_build_path() Date: Tue, 19 Jul 2016 16:53:55 -0600 Message-Id: <1468968836-12695-6-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1468968836-12695-1-git-send-email-mathieu.poirier@linaro.org> References: <1468968836-12695-1-git-send-email-mathieu.poirier@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Up to now function coresight_build_path() was counting on a sink to have been selected (from sysFS) prior to being called. This patch adds a string argument so that a sink matching the argument can be selected. Signed-off-by: Mathieu Poirier --- drivers/hwtracing/coresight/coresight-etm-perf.c | 2 +- drivers/hwtracing/coresight/coresight-priv.h | 3 +- drivers/hwtracing/coresight/coresight.c | 40 +++++++++++++++--------- 3 files changed, 29 insertions(+), 16 deletions(-) -- 2.7.4 diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c index f4174f36c5a0..f8c7a8733b23 100644 --- a/drivers/hwtracing/coresight/coresight-etm-perf.c +++ b/drivers/hwtracing/coresight/coresight-etm-perf.c @@ -184,7 +184,7 @@ static void *etm_setup_aux(struct perf_event *event, void **pages, * list of devices from source to sink that can be * referenced later when the path is actually needed. */ - event_data->path[cpu] = coresight_build_path(csdev); + event_data->path[cpu] = coresight_build_path(csdev, NULL); if (!event_data->path[cpu]) goto err; } diff --git a/drivers/hwtracing/coresight/coresight-priv.h b/drivers/hwtracing/coresight/coresight-priv.h index decfd52b5dc3..31d248819377 100644 --- a/drivers/hwtracing/coresight/coresight-priv.h +++ b/drivers/hwtracing/coresight/coresight-priv.h @@ -98,7 +98,8 @@ static inline void CS_UNLOCK(void __iomem *addr) void coresight_disable_path(struct list_head *path); int coresight_enable_path(struct list_head *path, u32 mode); struct coresight_device *coresight_get_sink(struct list_head *path); -struct list_head *coresight_build_path(struct coresight_device *csdev); +struct list_head *coresight_build_path(struct coresight_device *csdev, + const char *sink); void coresight_release_path(struct list_head *path); #ifdef CONFIG_CORESIGHT_SOURCE_ETM3X diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c index bb20ee9747e1..f4b960f48ca4 100644 --- a/drivers/hwtracing/coresight/coresight.c +++ b/drivers/hwtracing/coresight/coresight.c @@ -372,30 +372,41 @@ struct coresight_device *coresight_get_sink(struct list_head *path) * _coresight_build_path - recursively build a path from a @csdev to a sink. * @csdev: The device to start from. * @path: The list to add devices to. + * @sink: The name of the sink this path should connect with. * - * The tree of Coresight device is traversed until an activated sink is - * found. From there the sink is added to the list along with all the - * devices that led to that point - the end result is a list from source - * to sink. In that list the source is the first device and the sink the - * last one. + * The tree of Coresight device is traversed until an activated sink or + * the one specified by @sink is found. + * From there the sink is added to the list along with all the devices that + * led to that point - the end result is a list from source to sink. In that + * list the source is the first device and the sink the last one. */ static int _coresight_build_path(struct coresight_device *csdev, - struct list_head *path) + struct list_head *path, const char *sink) { int i; bool found = false; struct coresight_node *node; - /* An activated sink has been found. Enqueue the element */ - if ((csdev->type == CORESIGHT_DEV_TYPE_SINK || - csdev->type == CORESIGHT_DEV_TYPE_LINKSINK) && csdev->activated) - goto out; + /* + * First see if we are dealing with a sink. If we have one check if + * it was selected via sysFS or the perf cmd line. + */ + if (csdev->type == CORESIGHT_DEV_TYPE_SINK || + csdev->type == CORESIGHT_DEV_TYPE_LINKSINK) { + /* Activated via perf cmd line */ + if (sink && !strcmp(dev_name(&csdev->dev), sink)) + goto out; + /* Activated via sysFS */ + if (csdev->activated) + goto out; + } /* Not a sink - recursively explore each port found on this element */ for (i = 0; i < csdev->nr_outport; i++) { struct coresight_device *child_dev = csdev->conns[i].child_dev; - if (child_dev && _coresight_build_path(child_dev, path) == 0) { + if (child_dev && + _coresight_build_path(child_dev, path, sink) == 0) { found = true; break; } @@ -422,7 +433,8 @@ out: return 0; } -struct list_head *coresight_build_path(struct coresight_device *csdev) +struct list_head *coresight_build_path(struct coresight_device *csdev, + const char *sink) { struct list_head *path; int rc; @@ -433,7 +445,7 @@ struct list_head *coresight_build_path(struct coresight_device *csdev) INIT_LIST_HEAD(path); - rc = _coresight_build_path(csdev, path); + rc = _coresight_build_path(csdev, path, sink); if (rc) { kfree(path); return ERR_PTR(rc); @@ -508,7 +520,7 @@ int coresight_enable(struct coresight_device *csdev) if (csdev->enable) goto out; - path = coresight_build_path(csdev); + path = coresight_build_path(csdev, NULL); if (IS_ERR(path)) { pr_err("building path(s) failed\n"); ret = PTR_ERR(path);