From patchwork Tue Jun 16 16:40:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Leach X-Patchwork-Id: 11608287 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 00BCD90 for ; Tue, 16 Jun 2020 16:40:34 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C41E420679 for ; Tue, 16 Jun 2020 16:40:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="bemZG4RW"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="iXLSMGTM" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C41E420679 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=KjTwrfeZwxmADQurC81VyW6LYRvreYGA+fNfwp5o7a0=; b=bemZG4RW9bS0Stn97mgTcJLYko lj4Wg5hJzYeA4+rgaTfweq8zvcAkZDuxk5BX2OS72F7ChvuSPqn9rD4gTPMSPy/Fd0FhKL/2asYSn mEpvfUbLknAz57La4i0G3suoxt1/SXxUeonIUCXUuYdF/i4dJJbAYmY2Ol4KuJud1kGXqRywuBjvN 99DqeWrm7HgxUPxKZE168/CALkmNQPeC7lARXVHWhTuHKhBO400czbGtVOe6v0AlQOmi/8P4+f3W6 XkID6MKMmhRTmUERPK1rxS2U4OgJKeiiKcecs5nOFKXt/Yi7uAr8xzOdPqObhJebvVNnaUXSiuIBP FgfPo+UA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jlEdL-00006N-HK; Tue, 16 Jun 2020 16:40:23 +0000 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jlEdA-00088H-72 for linux-arm-kernel@lists.infradead.org; Tue, 16 Jun 2020 16:40:14 +0000 Received: by mail-wr1-x442.google.com with SMTP id j10so21463377wrw.8 for ; Tue, 16 Jun 2020 09:40:11 -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=JvNhFPgAekuOh98eM7QIE6yiEIZ2rGlQ4CDaGTYjSLY=; b=iXLSMGTMAMcpGOJzbRoQjT/sKbFJ/0Tk+PrBtjhSvvSD3aFuu8JUwnpYo+qOEfGyQm Qp7tZnkqPi5mP+DJ5MdEqUQJL+1zk6csiRQnFT8HBUfCg7o2uPhtexcLRhM9HC0BzKgM Kv/ZREQagHWdbdVG3saAe9l+KekzRZ+J9SRAIzMD9l62cybThc18ulRQcvOUH2EKDe1Y i3p4aVSmip2ULHoRsElkW4GuL4C7OzMNcBTq8F7vHIOgX1Jex74cqKo3mtq94GN/g/Ol tCCgDt1WTg+jlI7M+lu6ycRfjuV3+gGq0Yj2qr6JDr0KC6EvP9cjOE/tb73GX2YGV74f VrYg== 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=JvNhFPgAekuOh98eM7QIE6yiEIZ2rGlQ4CDaGTYjSLY=; b=SVw5BilTnzFExSDWSzuqmPYy4ktOsuNIfRRTfHYlaQraVoVP0RCPZJMXl6nH3qcf+1 BSiEPF3iMwTnbocklb1kXDiISSyI2GGncK2ld5lK49wLout66i6W5TY73tSUnszvhHmN jSwpYA3VhhUbFDKvMcL+Yvv5kjiAwW0uavTr8lOP1T2EtdGLAs2a8MJzar2v04uK+ZN2 p7pT9S8zjDVScBA1PdkIsBzyDWMToNs/cMhUzTypNWQPSD+k+VEIwPQ3E47ED6E7utyI LOXIwwUanBJRXcPpGETI2vlLIfcYBIalUkMKOJzQvWVk6yPLW617KlX3KOIHdG6bPygo IANg== X-Gm-Message-State: AOAM533fK6w3/BryQ10KdU6+IZBqz2ns2Nc33chytqEKAxPSlp9cOOKa LOgvnSKKE08hTYrCOSdfW+H48VDUR3Q= X-Google-Smtp-Source: ABdhPJwddWC6tT5XMJlG5DztkmNAEg5w+rvwoDqKakRGTHObzKvjpep3f/GVlfAsPbSThzoQodvg7w== X-Received: by 2002:adf:f6ce:: with SMTP id y14mr4138185wrp.90.1592325610126; Tue, 16 Jun 2020 09:40:10 -0700 (PDT) Received: from linaro.org ([2a00:23c5:6801:1801:dc9e:c297:59e5:dbd9]) by smtp.gmail.com with ESMTPSA id g82sm4843866wmf.1.2020.06.16.09.40.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jun 2020 09:40:09 -0700 (PDT) From: Mike Leach To: linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, coresight@lists.linaro.org, mathieu.poirier@linaro.org Subject: [PATCH v5 1/5] coresight: Add default sink selection to CoreSight base. Date: Tue, 16 Jun 2020 17:40:02 +0100 Message-Id: <20200616164006.15309-2-mike.leach@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200616164006.15309-1-mike.leach@linaro.org> References: <20200616164006.15309-1-mike.leach@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200616_094012_269129_BF51E98B X-CRM114-Status: GOOD ( 26.76 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:442 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: corbet@lwn.net, Mike Leach , suzuki.poulose@arm.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Adds a method to select a suitable sink connected to a given source. In cases where no sink is defined, the coresight_find_default_sink routine can search from a given source, through the child connections until a suitable sink is found. The suitability is defined in by the sink coresight_dev_subtype on the CoreSight device, and the distance from the source by counting connections. Higher value subtype is preferred - where these are equal, shorter distance from source is used as a tie-break. This allows for default sink to be discovered were none is specified (e.g. perf command line) Signed-off-by: Mike Leach Suggested-by: Suzuki K Poulose Reviewed-by: Leo Yan Reviewed-by: Mathieu Poirier Reviewed-by: Suzuki K Poulose --- drivers/hwtracing/coresight/coresight-priv.h | 2 + drivers/hwtracing/coresight/coresight.c | 166 +++++++++++++++++++ include/linux/coresight.h | 3 + 3 files changed, 171 insertions(+) diff --git a/drivers/hwtracing/coresight/coresight-priv.h b/drivers/hwtracing/coresight/coresight-priv.h index 36c943ae94d5..f2dc625ea585 100644 --- a/drivers/hwtracing/coresight/coresight-priv.h +++ b/drivers/hwtracing/coresight/coresight-priv.h @@ -150,6 +150,8 @@ int coresight_enable_path(struct list_head *path, u32 mode, void *sink_data); struct coresight_device *coresight_get_sink(struct list_head *path); struct coresight_device *coresight_get_enabled_sink(bool reset); struct coresight_device *coresight_get_sink_by_id(u32 id); +struct coresight_device * +coresight_find_default_sink(struct coresight_device *csdev); struct list_head *coresight_build_path(struct coresight_device *csdev, struct coresight_device *sink); void coresight_release_path(struct list_head *path); diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c index f3efbb3b2b4d..e9c90f2de34a 100644 --- a/drivers/hwtracing/coresight/coresight.c +++ b/drivers/hwtracing/coresight/coresight.c @@ -769,6 +769,171 @@ void coresight_release_path(struct list_head *path) path = NULL; } +/* return true if the device is a suitable type for a default sink */ +static inline bool coresight_is_def_sink_type(struct coresight_device *csdev) +{ + /* sink & correct subtype */ + if (((csdev->type == CORESIGHT_DEV_TYPE_SINK) || + (csdev->type == CORESIGHT_DEV_TYPE_LINKSINK)) && + (csdev->subtype.sink_subtype >= CORESIGHT_DEV_SUBTYPE_SINK_BUFFER)) + return true; + return false; +} + +/** + * coresight_select_best_sink - return the best sink for use as default from + * the two provided. + * + * @sink: current best sink. + * @depth: search depth where current sink was found. + * @new_sink: new sink for comparison with current sink. + * @new_depth: search depth where new sink was found. + * + * Sinks prioritised according to coresight_dev_subtype_sink, with only + * subtypes CORESIGHT_DEV_SUBTYPE_SINK_BUFFER or higher being used. + * + * Where two sinks of equal priority are found, the sink closest to the + * source is used (smallest search depth). + * + * return @new_sink & update @depth if better than @sink, else return @sink. + */ +static struct coresight_device * +coresight_select_best_sink(struct coresight_device *sink, int *depth, + struct coresight_device *new_sink, int new_depth) +{ + bool update = false; + + if (!sink) { + /* first found at this level */ + update = true; + } else if (new_sink->subtype.sink_subtype > + sink->subtype.sink_subtype) { + /* found better sink */ + update = true; + } else if ((new_sink->subtype.sink_subtype == + sink->subtype.sink_subtype) && + (*depth > new_depth)) { + /* found same but closer sink */ + update = true; + } + + if (update) + *depth = new_depth; + return update ? new_sink : sink; +} + +/** + * coresight_find_sink - recursive function to walk trace connections from + * source to find a suitable default sink. + * + * @csdev: source / current device to check. + * @depth: [in] search depth of calling dev, [out] depth of found sink. + * + * This will walk the connection path from a source (ETM) till a suitable + * sink is encountered and return that sink to the original caller. + * + * If current device is a plain sink return that & depth, otherwise recursively + * call child connections looking for a sink. Select best possible using + * coresight_select_best_sink. + * + * return best sink found, or NULL if not found at this node or child nodes. + */ +static struct coresight_device * +coresight_find_sink(struct coresight_device *csdev, int *depth) +{ + int i, curr_depth = *depth + 1, found_depth = 0; + struct coresight_device *found_sink = NULL; + + if (coresight_is_def_sink_type(csdev)) { + found_depth = curr_depth; + found_sink = csdev; + if (csdev->type == CORESIGHT_DEV_TYPE_SINK) + goto return_def_sink; + /* look past LINKSINK for something better */ + } + + /* + * Not a sink we want - or possible child sink may be better. + * recursively explore each port found on this element. + */ + for (i = 0; i < csdev->pdata->nr_outport; i++) { + struct coresight_device *child_dev, *sink = NULL; + int child_depth = curr_depth; + + child_dev = csdev->pdata->conns[i].child_dev; + if (child_dev) + sink = coresight_find_sink(child_dev, &child_depth); + + if (sink) + found_sink = coresight_select_best_sink(found_sink, + &found_depth, + sink, + child_depth); + } + +return_def_sink: + /* return found sink and depth */ + if (found_sink) + *depth = found_depth; + return found_sink; +} + +/** + * coresight_find_default_sink: Find a sink suitable for use as a + * default sink. + * + * @csdev: starting source to find a connected sink. + * + * Walks connections graph looking for a suitable sink to enable for the + * supplied source. Uses CoreSight device subtypes and distance from source + * to select the best sink. + * + * If a sink is found, then the default sink for this device is set and + * will be automatically used in future. + * + * Used in cases where the CoreSight user (perf / sysfs) has not selected a + * sink. + */ +struct coresight_device * +coresight_find_default_sink(struct coresight_device *csdev) +{ + int depth = 0; + + /* look for a default sink if we have not found for this device */ + if (!csdev->def_sink) + csdev->def_sink = coresight_find_sink(csdev, &depth); + return csdev->def_sink; +} + +static int coresight_remove_sink_ref(struct device *dev, void *data) +{ + struct coresight_device *sink = data; + struct coresight_device *source = to_coresight_device(dev); + + if (source->def_sink == sink) + source->def_sink = NULL; + return 0; +} + +/** + * coresight_clear_default_sink: Remove all default sink references to the + * supplied sink. + * + * If supplied device is a sink, then check all the bus devices and clear + * out all the references to this sink from the coresight_device def_sink + * parameter. + * + * @csdev: coresight sink - remove references to this from all sources. + */ +static void coresight_clear_default_sink(struct coresight_device *csdev) +{ + if ((csdev->type == CORESIGHT_DEV_TYPE_SINK) || + (csdev->type == CORESIGHT_DEV_TYPE_LINKSINK)) { + bus_for_each_dev(&coresight_bustype, NULL, csdev, + coresight_remove_sink_ref); + } +} + /** coresight_validate_source - make sure a source has the right credentials * @csdev: the device structure for a source. * @function: the function this was called from. @@ -1358,6 +1523,7 @@ void coresight_unregister(struct coresight_device *csdev) etm_perf_del_symlink_sink(csdev); /* Remove references of that device in the topology */ coresight_remove_conns(csdev); + coresight_clear_default_sink(csdev); coresight_release_platform_data(csdev, csdev->pdata); device_unregister(&csdev->dev); } diff --git a/include/linux/coresight.h b/include/linux/coresight.h index 84dc695e87d4..58fffdecdbfd 100644 --- a/include/linux/coresight.h +++ b/include/linux/coresight.h @@ -48,6 +48,7 @@ enum coresight_dev_subtype_sink { CORESIGHT_DEV_SUBTYPE_SINK_NONE, CORESIGHT_DEV_SUBTYPE_SINK_PORT, CORESIGHT_DEV_SUBTYPE_SINK_BUFFER, + CORESIGHT_DEV_SUBTYPE_SINK_SYSMEM, }; enum coresight_dev_subtype_link { @@ -182,6 +183,7 @@ struct coresight_sysfs_link { * happens when a source has been selected and a path is enabled * from source to that sink. * @ea: Device attribute for sink representation under PMU directory. + * @def_sink: cached reference to default sink found for this device. * @ect_dev: Associated cross trigger device. Not part of the trace data * path or connections. * @nr_links: number of sysfs links created to other components from this @@ -200,6 +202,7 @@ struct coresight_device { /* sink specific fields */ bool activated; /* true only if a sink is part of a path */ struct dev_ext_attribute *ea; + struct coresight_device *def_sink; /* cross trigger handling */ struct coresight_device *ect_dev; /* sysfs links between components */ From patchwork Tue Jun 16 16:40:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Leach X-Patchwork-Id: 11608289 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 999D590 for ; Tue, 16 Jun 2020 16:40:45 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3392820679 for ; Tue, 16 Jun 2020 16:40:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="BtSCDAjh"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="UYpcHQH/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3392820679 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=MtOvJLwM0kzIxYZUOT/HVZ1YiBHWAdjnOl3mxe5tYg0=; b=BtSCDAjhRclySC8eGo9ihm9OHv sapUA6Q5P8Au7BIw1Xw2mP9Z/XkbPg87RrrRNqu4S7dbplEaVWPnHDxXfIU9sRQ7JQ4h3qef06ysP YMIasbV7w4xd89UzxZEUq3c2dqJJ8hffQCjo99IRIKesHA8rZNpgsBuIgqvki4C0LXXExpc3M5nDi bp41sjlAYrzJWL9pZl9Okx1JMzfGtCVfz5PIYxciYEWR6hR9KIMtNUt4RVrU9DH8fZeBrasltno/Q rUeHjV6rKaVjLgXWoSJX8x101f72+trzXbwRk3ULk7CtTT3XgMl0KuVulOcLa/dhLWzH1Q1DeK3eV lXquXZMw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jlEde-0000NT-RT; Tue, 16 Jun 2020 16:40:42 +0000 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jlEdB-0008JK-11 for linux-arm-kernel@lists.infradead.org; Tue, 16 Jun 2020 16:40:14 +0000 Received: by mail-wm1-x342.google.com with SMTP id q25so3810311wmj.0 for ; Tue, 16 Jun 2020 09:40:12 -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=aqErEkGc0G89wKtmIHGbgBfE4aZbj87KIVLTsmxB2XY=; b=UYpcHQH/yKkhdBn9ulPpq77f+Agl0AsbvPJ30d343fb0xZWL5dSqnT6bJyahJrFYTB ApDTcq1Yu8TzkiBQyOsPROiIFfnChdNzLKpFfQEZ83JDaFBgagzmzoDZ7a2gaQTz99rn KoKwEfttLLSQ+ZX5pFCuI0YNoy/H9Ii543Yesck5edN+BglTc5tA5MaCuPzcNTzQyL9P LuENtduUyj5liKDExdOG8So9DIfrWk3GZyLFfFahBgifxxElow1Id9M8tYXM0AhMTZX2 jIw//r8x8ASflsOZmo2bWYH7LD/SygrpMb9ni+uOME/o3Tv444GpBCRZZvbg5UMitBsW ZxBg== 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=aqErEkGc0G89wKtmIHGbgBfE4aZbj87KIVLTsmxB2XY=; b=s69pTMmVknqf3WG9+imbtJ6+F6WjblCg66J/XQP7uEmyD9f+HYZ3mDsxUXoRc+IT+p jVfU9q7uXyExUYNFHM+M3by6raEBj6WDu83zFmZZ/VRGvnj43ycxrPlqncfhjNwgukKo 3HsKZ089PLsoawpOn9Qb72bLtLT2MEln0Ath9VKZzfaIDS9O9JR5FjGZr2DEjxdBdM0L 3dXXIXwNvGTQjHH8Q1170bbXL0J29Gkn6ADZKt67WjiXYlsQ0laREj8Tj2Trb3xu3Le4 4Haa59mL8szrTnDi/yHruu2GjAln0Kl1NhMeBh5MTXNyz8EHLkWNOdEjZCc+u0x/NbLc rJug== X-Gm-Message-State: AOAM531cUSytsYvsD07qo8ZixxVjb53aMqkn0rcXLmydvxitP5syitIu YkodLrbUFaZyZZowReJKugsIcxFlLN0= X-Google-Smtp-Source: ABdhPJwdx3JS+7B8OiPrbMZzyeHAkleLtl8T1QaUpWQuvObRxe6fB4GLU5k0nnNG3CxPtBufYPAAqQ== X-Received: by 2002:a1c:bbd6:: with SMTP id l205mr4253963wmf.147.1592325611191; Tue, 16 Jun 2020 09:40:11 -0700 (PDT) Received: from linaro.org ([2a00:23c5:6801:1801:dc9e:c297:59e5:dbd9]) by smtp.gmail.com with ESMTPSA id g82sm4843866wmf.1.2020.06.16.09.40.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jun 2020 09:40:10 -0700 (PDT) From: Mike Leach To: linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, coresight@lists.linaro.org, mathieu.poirier@linaro.org Subject: [PATCH v5 2/5] coresight: tmc: Update sink types for default selection. Date: Tue, 16 Jun 2020 17:40:03 +0100 Message-Id: <20200616164006.15309-3-mike.leach@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200616164006.15309-1-mike.leach@linaro.org> References: <20200616164006.15309-1-mike.leach@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200616_094013_065061_E2306CB6 X-CRM114-Status: GOOD ( 10.71 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:342 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: corbet@lwn.net, Mike Leach , suzuki.poulose@arm.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org An additional sink subtype is added to differentiate ETB/ETF buffer sinks and ETR type system memory sinks. This allows the prioritised selection of default sinks. Signed-off-by: Mike Leach Reviewed-by: Suzuki K Poulose Reviewed-by: Mathieu Poirier --- drivers/hwtracing/coresight/coresight-tmc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/hwtracing/coresight/coresight-tmc.c b/drivers/hwtracing/coresight/coresight-tmc.c index 39fba1d16e6e..0d2eb7e0e1bb 100644 --- a/drivers/hwtracing/coresight/coresight-tmc.c +++ b/drivers/hwtracing/coresight/coresight-tmc.c @@ -484,7 +484,7 @@ static int tmc_probe(struct amba_device *adev, const struct amba_id *id) break; case TMC_CONFIG_TYPE_ETR: desc.type = CORESIGHT_DEV_TYPE_SINK; - desc.subtype.sink_subtype = CORESIGHT_DEV_SUBTYPE_SINK_BUFFER; + desc.subtype.sink_subtype = CORESIGHT_DEV_SUBTYPE_SINK_SYSMEM; desc.ops = &tmc_etr_cs_ops; ret = tmc_etr_setup_caps(dev, devid, coresight_get_uci_data(id)); @@ -496,6 +496,7 @@ static int tmc_probe(struct amba_device *adev, const struct amba_id *id) break; case TMC_CONFIG_TYPE_ETF: desc.type = CORESIGHT_DEV_TYPE_LINKSINK; + desc.subtype.sink_subtype = CORESIGHT_DEV_SUBTYPE_SINK_BUFFER; desc.subtype.link_subtype = CORESIGHT_DEV_SUBTYPE_LINK_FIFO; desc.ops = &tmc_etf_cs_ops; dev_list = &etf_devs; From patchwork Tue Jun 16 16:40:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Leach X-Patchwork-Id: 11608291 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AD82B90 for ; Tue, 16 Jun 2020 16:41:15 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8908C20679 for ; Tue, 16 Jun 2020 16:41:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="mJdzapWy"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="F0rebMc3" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8908C20679 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=2bMF4cr5WF7Y27qiDmOAT5n9t4dBHHEP4hUU/nPmHns=; b=mJdzapWyCBT/bqQN7xgy8OSgaZ 1MiHjRe/2fHA5IqPwopkuBjkR2bnk1mBBowXVpfqcjLWmuvFxQ3NBF6ujwgh+FwQ5OyQpGLZjRLHd jDxKwSocyBVhIOmpgDPtbkCM1qt6nd2YgRCd0Cs9TF6DHv8ZufzlICUT3Yb6p45Pp+ucOakYNBHPf nbE9OqVmNF43P0EC5bvIQnU2MhFOyF3Y1vioszkG+0+kTYXb/jgZLNczJDR65BF7Ja6jBIIGfSQua 7gOGyeat3wDDvQNMidoVTE4ec0Y0cXBAswVRblFXlMNcvUP/p4mNNwKZn9rInYxR60dC+NygmkuFd vEUwJARA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jlEe3-0000fN-5R; Tue, 16 Jun 2020 16:41:07 +0000 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jlEdC-0008OZ-8x for linux-arm-kernel@lists.infradead.org; Tue, 16 Jun 2020 16:40:15 +0000 Received: by mail-wr1-x444.google.com with SMTP id x14so21482636wrp.2 for ; Tue, 16 Jun 2020 09:40:13 -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=0oSmh9OEc1CJ9Wkcu4JKPKk4wvUEYD5z+Ymo2CQ2Vt4=; b=F0rebMc3rOizhdJuI8CgmWTQ3eAJkyz5CmJOOYVkQ3DnZBRCJYzp2lHMpJ/AU5ork9 ltIPLTxAXldQHZQbkELam6jVX6pYOVn1JEEZhyGBpcFbKoGAFAg3LAN4x6Dhorbs2mo1 pB2XH/Su4Kqntmi5QO722jEneBWNi30iZKo7TfeZP2a8dFrT2yJYgwFixM4r7jGpyQFx r2SzqZs43CRr8Wv1cn0ArNrZws+udWNtBrXwSFxnRJMleAv9gTsYPsQNCE+T7nQo7Ev2 4be+khpE6TnqjUd+8vC5NFjwuGWUNCLQRa3E+3tOIDdfOVRNflk5R7/i7bcvHNjmSA8W F1uQ== 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=0oSmh9OEc1CJ9Wkcu4JKPKk4wvUEYD5z+Ymo2CQ2Vt4=; b=uBFC8XTrwcJ3U0g7T3VmZBdl5P2rq/oq6rAresMArkV7UZyuCpmX6X1fpoG93g4Ni+ Nb19xXz5Jl5UeESTD1KGFDVonVYdMW0iw5sbJxgiVzq0VilwwGWaTP+yj6bowZV/TsBX 7GE+b5b7Cn3M+RbhQ2fpjGiMMohlG/OEwjV1ytm9F+wMityqV1myuXHYN5vRDfaR6fQp bFQNUyTw1N1JOaftLoWoJQ6WES+FdGTKtQ34UdSjRTOwbZKc1TmpADMK7W8/j8nTwBe+ DbjHk3PnrOkkkRfuTxtbQS4RPbC9PUIljIDNwGenALB6K3N3n0ZRMJbcbovN5UIhENOE GQrA== X-Gm-Message-State: AOAM532OIX6LVD6wxNfk+RHoqrAFhwIpOMKwW5TfmBkygE8uDpgfY1BJ E0NP5eL8wgQ9p0AKtUsEIOJEMAOl2nk= X-Google-Smtp-Source: ABdhPJxl5HlrXeboRVSj/nKHxJBCP6/rO3oFed/D0Vjmmhe0Mj3mXCjfA93JBbvEMF4LwI4rDDexjA== X-Received: by 2002:a5d:4e45:: with SMTP id r5mr3014189wrt.92.1592325612513; Tue, 16 Jun 2020 09:40:12 -0700 (PDT) Received: from linaro.org ([2a00:23c5:6801:1801:dc9e:c297:59e5:dbd9]) by smtp.gmail.com with ESMTPSA id g82sm4843866wmf.1.2020.06.16.09.40.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jun 2020 09:40:11 -0700 (PDT) From: Mike Leach To: linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, coresight@lists.linaro.org, mathieu.poirier@linaro.org Subject: [PATCH v5 3/5] coresight: etm: perf: Add default sink selection to etm perf. Date: Tue, 16 Jun 2020 17:40:04 +0100 Message-Id: <20200616164006.15309-4-mike.leach@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200616164006.15309-1-mike.leach@linaro.org> References: <20200616164006.15309-1-mike.leach@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200616_094014_316211_C9D05673 X-CRM114-Status: GOOD ( 14.97 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:444 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: corbet@lwn.net, Mike Leach , suzuki.poulose@arm.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Add default sink selection to the perf trace handling in the etm driver. Uses the select default sink infrastructure to select a sink for the perf session, if no other sink is specified. Signed-off-by: Mike Leach Reviewed-by: Mathieu Poirier Reviewed-by: Suzuki K Poulose --- .../hwtracing/coresight/coresight-etm-perf.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c index 84f1dcb69827..1a3169e69bb1 100644 --- a/drivers/hwtracing/coresight/coresight-etm-perf.c +++ b/drivers/hwtracing/coresight/coresight-etm-perf.c @@ -226,9 +226,6 @@ static void *etm_setup_aux(struct perf_event *event, void **pages, sink = coresight_get_enabled_sink(true); } - if (!sink) - goto err; - mask = &event_data->mask; /* @@ -253,6 +250,16 @@ static void *etm_setup_aux(struct perf_event *event, void **pages, continue; } + /* + * No sink provided - look for a default sink for one of the + * devices. At present we only support topology where all CPUs + * use the same sink [N:1], so only need to find one sink. The + * coresight_build_path later will remove any CPU that does not + * attach to the sink, or if we have not found a sink. + */ + if (!sink) + sink = coresight_find_default_sink(csdev); + /* * Building a path doesn't enable it, it simply builds a * list of devices from source to sink that can be @@ -267,6 +274,10 @@ static void *etm_setup_aux(struct perf_event *event, void **pages, *etm_event_cpu_path_ptr(event_data, cpu) = path; } + /* no sink found for any CPU - cannot trace */ + if (!sink) + goto err; + /* If we don't have any CPUs ready for tracing, abort */ cpu = cpumask_first(mask); if (cpu >= nr_cpu_ids) From patchwork Tue Jun 16 16:40:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Leach X-Patchwork-Id: 11608293 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CEC4D138C for ; Tue, 16 Jun 2020 16:41:22 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AE6C220679 for ; Tue, 16 Jun 2020 16:41:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="cdhvuy4A"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="aEKX/YBz" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AE6C220679 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=XsO6TIbt8ZLpX/wdb60/9qkYQPj2tlgXvrwKgnuB1zY=; b=cdhvuy4AJwQKiwn8L8engVUxWy FTxHB0WCxAKgf5/yobxElCd14pqOCxfSRSzdw0kITDtR5WD8O7Gmz1oqAXPlaB/loxN1r4IFDTBqs d6Zr+XCa0Yf4pRQYFT+Wa7dqvHg2KTdNp8tcjitx76zhR+zTZuspqksLKl6n8eQpuihn8ygjRlbbL ZNvkNOIIcWlTkoO9VhYv3qmBUpfDjhI/fL6TrgNvUphxxt5RAkn6gM0vgVun4QKZI/WTfO15OAITZ FGq9KSIPXTOI95vWkN5wxNsmzMHdCbFHxrXtNP4+ZLeZY4PGsY5XZgXmlq6/C8QK73N2lB+NyOUyR lWpiw9Fw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jlEeE-0000t9-1G; Tue, 16 Jun 2020 16:41:18 +0000 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jlEdD-0008PA-4W for linux-arm-kernel@lists.infradead.org; Tue, 16 Jun 2020 16:40:16 +0000 Received: by mail-wr1-x444.google.com with SMTP id b6so2327886wrs.11 for ; Tue, 16 Jun 2020 09:40:15 -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=I2TjwT9IfqG2nrgLrAevDzKvNXE/MwXIyJwS2KSXhng=; b=aEKX/YBz/O7iZpusiQTX/Mfj/o7PxCrCNcL7fuhDR9UcBUu1zdQoZscsG0S87lFcKI HkGMn847nDsLMmtKxOJCSqWh52IUV0RgT6gTk7lcVF3U9Pryu5WrPuEHk54R2Ac3lgFC OWxQcK/NNsYArwODM6+6YHkP7mXzIHOkaEuOt4zjX6pZhbV3JiTmNV5Z5LSOQSorWShZ iDujvjQaHOhRxJcQn1B8c5mMyLwExWoHRP55bqR8fU0tUue/4uSaNC5lPcWcoFRI2vrB NucUtM81uA9byWutCZLia7qn1/f5kYxFphkBGxj+WjTVhNEuA6BJuHoPrOHvnnew8/ut PGFg== 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=I2TjwT9IfqG2nrgLrAevDzKvNXE/MwXIyJwS2KSXhng=; b=lgj1RB3wIfj4m09o3AWgM9qDhwUSg8zL25bbWmmfiAqD7tX5kKb70Gcf3pw5wt25ix ghFA1CUxldKZBFEwChFe1TqbTp4xbQ43vNZf/lQce12CzdJ5Yz06SlrPSmel9CLpqKYB RZvCxXZ1W+i5/93Iqkh9aaEziVIeVab5PRYc5LN2eOOgOuH8W0IBb0WFTpOtKNWAKPnK 3V8rvNQI/gzGGRO1twXuBdp8d33TyABDX4csbYSMmokWggyVyePy/cipa+ZbUx5vPem4 fLmufOOxmXknTJxhRc5bbfI9Q4GTsgVREbw0ki3dfxPaqztE0qUssrmI8wrA3sIx3M71 efiQ== X-Gm-Message-State: AOAM5311Yi1CTDBVYfMwABwwehD6g/48VlanyeMIgWG3XCZnEQhSOik7 ht/LefK0HTPpQosIEI30asobebdVW+w= X-Google-Smtp-Source: ABdhPJzHXgNQpyErZftibK2loj/26aph0mEVisQ1m9b+ntxshr40za6D0ixAlFRe02NcPwKuz2mMXg== X-Received: by 2002:adf:ef47:: with SMTP id c7mr4232461wrp.57.1592325613602; Tue, 16 Jun 2020 09:40:13 -0700 (PDT) Received: from linaro.org ([2a00:23c5:6801:1801:dc9e:c297:59e5:dbd9]) by smtp.gmail.com with ESMTPSA id g82sm4843866wmf.1.2020.06.16.09.40.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jun 2020 09:40:12 -0700 (PDT) From: Mike Leach To: linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, coresight@lists.linaro.org, mathieu.poirier@linaro.org Subject: [PATCH v5 4/5] coresight: sysfs: Allow select default sink on source enable. Date: Tue, 16 Jun 2020 17:40:05 +0100 Message-Id: <20200616164006.15309-5-mike.leach@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200616164006.15309-1-mike.leach@linaro.org> References: <20200616164006.15309-1-mike.leach@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200616_094015_196966_43FB1DBD X-CRM114-Status: GOOD ( 20.89 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:444 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: corbet@lwn.net, Mike Leach , suzuki.poulose@arm.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org When enabling a trace source using sysfs, allow the CoreSight system to auto-select a default sink if none has been enabled by the user. Uses the sink select algorithm that uses the default select priorities set when sinks are registered with the system. At present this will prefer ETR over ETB / ETF. Adds a new attribute 'last_sink' to source CoreSight devices. This is set when a source is enabled using sysfs, to the sink that the device will trace into. This applies for both user enabled and default enabled sinks. Signed-off-by: Mike Leach --- drivers/hwtracing/coresight/coresight.c | 39 +++++++++++++++++++++++-- include/linux/coresight.h | 3 ++ 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c index e9c90f2de34a..db39e0b56994 100644 --- a/drivers/hwtracing/coresight/coresight.c +++ b/drivers/hwtracing/coresight/coresight.c @@ -934,6 +934,16 @@ static void coresight_clear_default_sink(struct coresight_device *csdev) } } +static void coresight_set_last_sink_name(struct coresight_device *source, + struct coresight_device *sink) +{ + /* remove current value and set new one if *sink not NULL */ + kfree(source->last_sink); + source->last_sink = NULL; + if (sink) + source->last_sink = kstrdup(dev_name(&sink->dev), GFP_KERNEL); +} + /** coresight_validate_source - make sure a source has the right credentials * @csdev: the device structure for a source. * @function: the function this was called from. @@ -994,8 +1004,15 @@ int coresight_enable(struct coresight_device *csdev) */ sink = coresight_get_enabled_sink(false); if (!sink) { - ret = -EINVAL; - goto out; + /* look for a default sink if nothing enabled */ + sink = coresight_find_default_sink(csdev); + if (!sink) { + ret = -EINVAL; + goto out; + } + /* mark the default as enabled */ + sink->activated = true; + dev_info(&sink->dev, "Enabled default sink."); } path = coresight_build_path(csdev, sink); @@ -1033,6 +1050,9 @@ int coresight_enable(struct coresight_device *csdev) break; } + /* record name of sink used for this session */ + coresight_set_last_sink_name(csdev, sink); + out: mutex_unlock(&coresight_mutex); return ret; @@ -1145,6 +1165,19 @@ static ssize_t enable_source_store(struct device *dev, } static DEVICE_ATTR_RW(enable_source); +static ssize_t last_sink_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct coresight_device *csdev = to_coresight_device(dev); + ssize_t size = 0; + + if (csdev->last_sink) + size = scnprintf(buf, PAGE_SIZE, "%s\n", csdev->last_sink); + return size; +} +static DEVICE_ATTR_RO(last_sink); + + static struct attribute *coresight_sink_attrs[] = { &dev_attr_enable_sink.attr, NULL, @@ -1153,6 +1186,7 @@ ATTRIBUTE_GROUPS(coresight_sink); static struct attribute *coresight_source_attrs[] = { &dev_attr_enable_source.attr, + &dev_attr_last_sink.attr, NULL, }; ATTRIBUTE_GROUPS(coresight_source); @@ -1524,6 +1558,7 @@ void coresight_unregister(struct coresight_device *csdev) /* Remove references of that device in the topology */ coresight_remove_conns(csdev); coresight_clear_default_sink(csdev); + coresight_set_last_sink_name(csdev, NULL); coresight_release_platform_data(csdev, csdev->pdata); device_unregister(&csdev->dev); } diff --git a/include/linux/coresight.h b/include/linux/coresight.h index 58fffdecdbfd..fc320dd2cedc 100644 --- a/include/linux/coresight.h +++ b/include/linux/coresight.h @@ -184,6 +184,8 @@ struct coresight_sysfs_link { * from source to that sink. * @ea: Device attribute for sink representation under PMU directory. * @def_sink: cached reference to default sink found for this device. + * @last_sink: Name of last sink used for this source to trace into. Set when + * enabling a source using sysfs - only set on a source device. * @ect_dev: Associated cross trigger device. Not part of the trace data * path or connections. * @nr_links: number of sysfs links created to other components from this @@ -203,6 +205,7 @@ struct coresight_device { bool activated; /* true only if a sink is part of a path */ struct dev_ext_attribute *ea; struct coresight_device *def_sink; + const char *last_sink; /* cross trigger handling */ struct coresight_device *ect_dev; /* sysfs links between components */ From patchwork Tue Jun 16 16:40:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Leach X-Patchwork-Id: 11608295 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E297290 for ; Tue, 16 Jun 2020 16:41:44 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C0D3120679 for ; Tue, 16 Jun 2020 16:41:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="SINv51Wa"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Go2w4WPC" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C0D3120679 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=LRUndVbje4SsxNUMMCgJakeoI78DURxQNujKamnp22o=; b=SINv51WaT7kx5gnd9IyAsh/VGO fhlw/78gZ12JhFVR7uHfxH8y+DSkcY6ICfgWxbMpNV3N5L/jBKyVRhWYQhc2ElGO6re8Kk1GwkBPh IYal5pgKzQbEVuxkNuVln7C/649AVthdK7tn6CB5WQz6r8xSBMGMAYtEKmzo7vQdZjgEpkB/wGLgf WpOz8bhyjLT1dpnXjyqF7RYIX9ZhwAzqjcRvA7qAOLXOZNNM+JVrQcZTQ47a2RoGwKmN9sx886Ci1 3kTenh/twWVGt2hseiZxq0aJ7L2XLf60SyBLnNLUN+SjNH8JzIcCx/Kc5arXKpybTsLkCNJbf9O20 ejZbE4zQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jlEeW-0001Bc-FB; Tue, 16 Jun 2020 16:41:36 +0000 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jlEdE-0008QG-Oy for linux-arm-kernel@lists.infradead.org; Tue, 16 Jun 2020 16:40:18 +0000 Received: by mail-wr1-x441.google.com with SMTP id c3so21437581wru.12 for ; Tue, 16 Jun 2020 09:40:16 -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=n2NHRnVJc5C6MADoxTFzUsgSIOdIPkV7GWDKSuh8LYo=; b=Go2w4WPCylLmbALMzBQK1S5p5HIA2UF8kUfalYYZuEi+oM8rpfFnsJWEw9REsNwibv ZFNa1a1qi5kn/kzvFwXrUl5nN8iZEgAgkj+s0U5Q8dgGy+tn4EOvSVJ2YKOGc8MTkl+G FzpUdQO5X9c/zsT5qswdlBlyZsLJMPwd7laysY30SxuisShVk/v8SPNsh+IOVrbmIUIV 2R58yyZ9S7I7EmiLTwKi+dW72oXk/0DHZtegD+MIs6dYiRQNhFILxcs5DWkqZFS5BL9o FQ460OG9NYzDbdQ2Xaog7ylhkTQ12yRTaDK8/zmsMknI6DKKKjZ9M9w6VO9lRl2syIqZ Swqg== 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=n2NHRnVJc5C6MADoxTFzUsgSIOdIPkV7GWDKSuh8LYo=; b=btRHELWOI72aNkYC2oCx8kPPFtAe3Xl0Od75BJsVtyN2MZZaO0tHizRLtsYkaSSXaq TkAadv3r8FrsG1ZTdyE3NJDGczRicLG6Umqn7uEiGWjVNNGgQicVFXQR8/nH+drrRrlF WMPuR1dRzuvNmwILIrN3Kl39Enb1lfy8L2sUZfMUJoUtTNpMSZcPeqTEJl2+Pwkva+i3 oOAsIOJdm8BHWW03TA47ZUWm0wS5EKcj4sWE+dT+wuUtqDfj3ws3rnaNbbwpNIEboW3y r/42cwlNuAjnP1QaGSYbtMutlw61d0OvGi7pLVjRSiKrDRSUhz6u+ENwilmvPM+aKDYl 45Sg== X-Gm-Message-State: AOAM532cgEwE4x3TxqludqsDneBZAukJeTyjZ0SQSMmwMLB76uCX0OUF 8nvl9HWtWq8NN8/yUl8JMoZ3ZtqdacM= X-Google-Smtp-Source: ABdhPJwWreG7Y7CLeVlSpKGbSAIZCOj/MG40rFIWNn8jJLxll8XJOve70JeA1trsCvcLLdg4q03IkA== X-Received: by 2002:a05:6000:18c:: with SMTP id p12mr4249039wrx.66.1592325614772; Tue, 16 Jun 2020 09:40:14 -0700 (PDT) Received: from linaro.org ([2a00:23c5:6801:1801:dc9e:c297:59e5:dbd9]) by smtp.gmail.com with ESMTPSA id g82sm4843866wmf.1.2020.06.16.09.40.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jun 2020 09:40:13 -0700 (PDT) From: Mike Leach To: linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, coresight@lists.linaro.org, mathieu.poirier@linaro.org Subject: [PATCH v5 5/5] documentation: coresight: Update CoreSight document for default sink. Date: Tue, 16 Jun 2020 17:40:06 +0100 Message-Id: <20200616164006.15309-6-mike.leach@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200616164006.15309-1-mike.leach@linaro.org> References: <20200616164006.15309-1-mike.leach@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200616_094016_844835_A64EEF68 X-CRM114-Status: GOOD ( 13.91 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:441 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: corbet@lwn.net, Mike Leach , suzuki.poulose@arm.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Updates the CoreSight documentation to cover the use of default sinks for both perf and sysfs operations. Signed-off-by: Mike Leach --- Documentation/trace/coresight/coresight.rst | 48 +++++++++++++++------ 1 file changed, 34 insertions(+), 14 deletions(-) diff --git a/Documentation/trace/coresight/coresight.rst b/Documentation/trace/coresight/coresight.rst index 0b73acb44efa..917d89f74c2e 100644 --- a/Documentation/trace/coresight/coresight.rst +++ b/Documentation/trace/coresight/coresight.rst @@ -341,17 +341,18 @@ provide details on using both methods. 1) Using the sysFS interface: Before trace collection can start, a coresight sink needs to be identified. -There is no limit on the amount of sinks (nor sources) that can be enabled at -any given moment. As a generic operation, all device pertaining to the sink -class will have an "active" entry in sysfs:: +There is no limit on the amount of sources and sinks that can be enabled at +any given moment. However, any source will only trace into a single sink. +As a generic operation, all device pertaining to the sink class will have an +"active" entry in sysfs:: root:/sys/bus/coresight/devices# ls - replicator 20030000.tpiu 2201c000.ptm 2203c000.etm 2203e000.etm - 20010000.etb 20040000.funnel 2201d000.ptm 2203d000.etm - root:/sys/bus/coresight/devices# ls 20010000.etb + replicator0 tpiu0 ptm0 etm2 etm3 + etb0 funnel0 ptm1 etm4 + root:/sys/bus/coresight/devices# ls etb0 enable_sink status trigger_cntr - root:/sys/bus/coresight/devices# echo 1 > 20010000.etb/enable_sink - root:/sys/bus/coresight/devices# cat 20010000.etb/enable_sink + root:/sys/bus/coresight/devices# echo 1 > etb0/enable_sink + root:/sys/bus/coresight/devices# cat etb0/enable_sink 1 root:/sys/bus/coresight/devices# @@ -360,10 +361,10 @@ comparator with "_stext" and "_etext", essentially tracing any instruction that falls within that range. As such "enabling" a source will immediately trigger a trace capture:: - root:/sys/bus/coresight/devices# echo 1 > 2201c000.ptm/enable_source - root:/sys/bus/coresight/devices# cat 2201c000.ptm/enable_source + root:/sys/bus/coresight/devices# echo 1 > ptm0/enable_source + root:/sys/bus/coresight/devices# cat ptm0/enable_source 1 - root:/sys/bus/coresight/devices# cat 20010000.etb/status + root:/sys/bus/coresight/devices# cat etb0/status Depth: 0x2000 Status: 0x1 RAM read ptr: 0x0 @@ -376,13 +377,22 @@ trigger a trace capture:: Trace collection is stopped the same way:: - root:/sys/bus/coresight/devices# echo 0 > 2201c000.ptm/enable_source + root:/sys/bus/coresight/devices# echo 0 > ptm0/enable_source root:/sys/bus/coresight/devices# +If no sink is enabled before the source is enabled, then a default sink will +be selected and enabled automatically. Once the source is disabled, then the +sink used can be read from /last_sink.:: + + root:/sys/bus/coresight/devices# echo 1 > ptm0/enable_source + root:/sys/bus/coresight/devices# echo 0 > ptm0/enable_source + root:/sys/bus/coresight/devices# cat ptm0/last_sink + etb0 + root:/sys/bus/coresight/devices# echo 0 > etb0/enable_sink + The content of the ETB buffer can be harvested directly from /dev:: - root:/sys/bus/coresight/devices# dd if=/dev/20010000.etb \ - of=~/cstrace.bin + root:/sys/bus/coresight/devices# dd if=/dev/etb0 of=~/cstrace.bin 64+0 records in 64+0 records out 32768 bytes (33 kB) copied, 0.00125258 s, 26.2 MB/s @@ -490,6 +500,16 @@ The syntax within the forward slashes '/' is important. The '@' character tells the parser that a sink is about to be specified and that this is the sink to use for the trace session. +Alternatively, if no sink name is given between the //, then the CoreSight +system will select a default sink:: + + root@linaro-nano:~# perf record -e cs_etm//u --per-thread program + +The system selects a sink by searching connection path from the source ETM to +any sink that is on the path.The system will prefer ETR devices over ETB/ETF, +and where two of the same type are found, the closest to the ETM, in terms of +connection links. + More information on the above and other example on how to use Coresight with the perf tools can be found in the "HOWTO.md" file of the openCSD gitHub repository [#third]_.