From patchwork Thu Jul 28 21:42:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 9251753 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B31EF60757 for ; Thu, 28 Jul 2016 21:45:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A572827EED for ; Thu, 28 Jul 2016 21:45:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 97FBC27F17; Thu, 28 Jul 2016 21:45:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2912B27EED for ; Thu, 28 Jul 2016 21:45:20 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bSt5y-0005Rc-QH; Thu, 28 Jul 2016 21:43:58 +0000 Received: from mail-io0-x231.google.com ([2607:f8b0:4001:c06::231]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bSt4z-0004pN-7f for linux-arm-kernel@lists.infradead.org; Thu, 28 Jul 2016 21:42:58 +0000 Received: by mail-io0-x231.google.com with SMTP id m101so112072970ioi.2 for ; Thu, 28 Jul 2016 14:42:36 -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=nVeXFXZoqyLyV4O9YiXBF02GhrQnLh36GlA6xO8ccXU=; b=iKVLgjQowFTSzwtA8pp24qkN2uxKZVYbxHIryC77FCd6WpV28eU5eOGFJ6EHUwjZFJ 0ZjRyDFvakDbyfb4T+lGemKa2IVmW4IAId5ohH9bUchqjDWxQHNa3qkdqxVRHYIRIBDa rAny5rn3z2nb6CCaeBz7OlTMlDRrbT1pzQCb0= 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=nVeXFXZoqyLyV4O9YiXBF02GhrQnLh36GlA6xO8ccXU=; b=iE4WzLqkqSmNK4Ed7FI2KxXn1TObp+AY4FHuw5IVpRm+VdSfQHQMAnFj8rlbO05G3d e3T4A9ekDI36Vstf4/MtfQ/lyZcNEjDhCSI4RddUex5a/A06Qs6YZpToYaq6kqZK1zPY vfb7EFJ1yscAE806ay8CsMSyxK8NDBFN3e7cKEHDruMkC4m99imaRUw73GUkE4U3KXpB 6kuinpHQQ+9MuFomn/LMTwVYt4HXZWaGmlFXIe8Zv6BhrRpfPEV1sZNVPU7McEIxaKM/ zjEQCRJDxhigrLWSt0DMVDgq9ISsEIXrfJxpilGB95HnzKuomsf+Pd18XjQieA7JQJQ1 LoMg== X-Gm-Message-State: AEkoouu/i4dnzDXMuwtFFLWfHl2BJnsBJSMcJDI17xIsJvNEhydEUmQW1bcLIw4nL4KT1Cmt X-Received: by 10.107.29.67 with SMTP id d64mr39355206iod.138.1469742156341; Thu, 28 Jul 2016 14:42:36 -0700 (PDT) Received: from t430.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id h99sm5808499iod.9.2016.07.28.14.42.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 28 Jul 2016 14:42:35 -0700 (PDT) From: Mathieu Poirier To: acme@kernel.org, jolsa@kernel.org Subject: [PATCH V3 5/6] coresight: adding sink parameter to function coresight_build_path() Date: Thu, 28 Jul 2016 15:42:22 -0600 Message-Id: <1469742143-22245-6-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1469742143-22245-1-git-send-email-mathieu.poirier@linaro.org> References: <1469742143-22245-1-git-send-email-mathieu.poirier@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160728_144257_424296_2575F4E9 X-CRM114-Status: GOOD ( 22.10 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peterz@infradead.org, Mathieu Poirier , mingo@redhat.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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 | 43 ++++++++++++++++-------- 3 files changed, 32 insertions(+), 16 deletions(-) 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 ad975c58080d..3cb574b3cdd9 100644 --- a/drivers/hwtracing/coresight/coresight-priv.h +++ b/drivers/hwtracing/coresight/coresight-priv.h @@ -94,7 +94,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 d08d1ab9bba5..2b7196aa54c3 100644 --- a/drivers/hwtracing/coresight/coresight.c +++ b/drivers/hwtracing/coresight/coresight.c @@ -372,30 +372,44 @@ 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) { + /* Discourage meddling in sysFS if using the perf interface */ + if (sink && csdev->activated) + return -EINVAL; + /* 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 +436,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 +448,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 +523,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);