From patchwork Tue May 26 10:46:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Leach X-Patchwork-Id: 11570267 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 DB65360D for ; Tue, 26 May 2020 10:47:10 +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 79B2B2073B for ; Tue, 26 May 2020 10:47:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="tiyK0Gha"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Jj93FwV5" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 79B2B2073B 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=r0MlAOa6KS047CLw2mrST82/KDIWsaAGySMHye8hoVc=; b=tiyK0GhaS9sXXNgXWiu5uTKXUZ B+JedF4ywwd04/Yq/PK3BsoBywBAnLqeVaK9ZAR4ez3gt87Z2SPGYBzJ/CAsg5neEiadJ6J3LTWV5 zh6f2FsQC26aJi/i42O5k1+6uF4hDBXDiVPrAWDKoKM6KhdoI7NQNLTneacyUotDH9V+inhClTL/6 8Wb0XdbZKFIQFE8ITnsOFKPDvW0UPiXQRrjK70ISt1kjMxb159cwiOAT/zPDTEBpVt9Vw4plI2f7j q6eKokFnKR7xHyoU0+wfkaM+i2hs/5aYNZrbfeDoJ1sKuugU/1xoFDSL4iWZw9kCmUMpp8NW4pvHh eqwo3h1w==; 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 1jdX6v-00021R-4G; Tue, 26 May 2020 10:47:05 +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 1jdX6i-0001q0-AP for linux-arm-kernel@lists.infradead.org; Tue, 26 May 2020 10:46:53 +0000 Received: by mail-wr1-x442.google.com with SMTP id r7so3226324wro.1 for ; Tue, 26 May 2020 03:46:51 -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=FgO6AdP43Um2PGzv5S5Pfi8oIKzNumXYXeRwuAF9in4=; b=Jj93FwV5ywea0S8lQEL+hiTtDlb/eLep4niAG6flvp89Zuw/bp2jcQFCbE+QLYTMrG q/XsCFXN3LNdwe9EAQ5VP+glqqrce+cjcS2cQO2R2zP++cJsudNO/CC9gVRWT868A1hf KEBfyAY6VdxyQgAWicuOMx8RlJl5oApMFP0zVLelCfAfXOV9cc02UZoXlLxTLmUSsxfK YzMAGJ4lGm1gFzuKQKeCX4r/S+wyDpgzqfS1u0VcLdcfH+AG3fkz4Uu5VCbHjpxhPHe/ nG1GV6IansVFQKhj+i/z0/nhtNTgd7Jqp7dM8+PhK6RpYXNB4RQ31JJxQp1W1KlocfEa cM/w== 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=FgO6AdP43Um2PGzv5S5Pfi8oIKzNumXYXeRwuAF9in4=; b=He6MjYNivOgo1knTgoJ+KAb8ki//goTiJoIZSi0Pwqrt/F3XoF1l3ZIYunn6MYBqgx rSHWh3aq8Wfl8S5SGriU/ad6GR8FdRnhkps7hcLi0Y11M0NTrPrg+dRYzgu6Q/NqAI2H cwzuuVzx2O15O+612w0acJeUmyBX7pX0csWahtJ6a8++5gTIRvTKO3Aerkka5pMOx1oq 18zB93K7LfIGjw12o1BOw0PaRkgikRR4KTqLuxhi1yiGRRnOx/vie9zlhNdcxSaJYNrq h7uJHK9nHy6SWnwEHn+fRUr5s7gu7O7bConm18phgTmM3p91qPc8YmN+wiSLko3QFIJF QtRg== X-Gm-Message-State: AOAM532Z1N2wTXHx0hyurQdEDcKsTu6LNxW1pteXG7ywT8ZFerkvG/Yi IKPGRLQyOCmbD2kZZbtLr9+h+MHwsTo= X-Google-Smtp-Source: ABdhPJyT6zCbwVCsSmwHdU12WYd+YqWO8s90+X8f3a2fGotcE1+8vWQLTvnoXXVD4YwXsrfUR23KRg== X-Received: by 2002:adf:eb47:: with SMTP id u7mr19363635wrn.14.1590490010085; Tue, 26 May 2020 03:46:50 -0700 (PDT) Received: from linaro.org ([2a00:23c5:6801:1801:8bee:312:6092:58f2]) by smtp.gmail.com with ESMTPSA id u3sm393441wmg.38.2020.05.26.03.46.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 May 2020 03:46:49 -0700 (PDT) From: Mike Leach To: linux-arm-kernel@lists.infradead.org, coresight@lists.linaro.org, mathieu.poirier@linaro.org Subject: [PATCH v4 1/5] coresight: Fix comment in main header file. Date: Tue, 26 May 2020 11:46:38 +0100 Message-Id: <20200526104642.9526-2-mike.leach@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200526104642.9526-1-mike.leach@linaro.org> References: <20200526104642.9526-1-mike.leach@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200526_034652_427823_F3E249F2 X-CRM114-Status: GOOD ( 12.81 ) 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_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 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: Mike Leach , acme@kernel.org, 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 Comment for an elemnt in the coresight_device structure appears to have been corrupted & makes no sense. Fix this before making further changes. Signed-off-by: Mike Leach Reviewed-by: Suzuki K Poulose Reviewed-by: Mathieu Poirier --- include/linux/coresight.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/linux/coresight.h b/include/linux/coresight.h index e3e9f0e3a878..84dc695e87d4 100644 --- a/include/linux/coresight.h +++ b/include/linux/coresight.h @@ -179,7 +179,8 @@ struct coresight_sysfs_link { * @enable: 'true' if component is currently part of an active path. * @activated: 'true' only if a _sink_ has been activated. A sink can be * activated but not yet enabled. Enabling for a _sink_ - * appens when a source has been selected for that it. + * 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. * @ect_dev: Associated cross trigger device. Not part of the trace data * path or connections. From patchwork Tue May 26 10:46:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Leach X-Patchwork-Id: 11570269 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 16B7960D for ; Tue, 26 May 2020 10:47:37 +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 E92492073B for ; Tue, 26 May 2020 10:47:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="jZ+ORqC1"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Bbz22miS" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E92492073B 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=j5NXU7tP6pMFvKIotEA19Ix82PQtuNs8ovc/rmgxYbQ=; b=jZ+ORqC1beXqWj0hayo/GMS9Hw OOIJELdCk7b2q1BSYrQLrvAHP5R6ff1usiThKhF9d4iNy2BCbCj8i4taeTnPK8WmY1FV5mihCz1XZ OUPQsBpkc0KnvMv9lJj1FMoaZuha6PO6L/RddFN5fYZ/HJkGaroNcy4WlLtrCwhspAGDYrp7GZHua FPQkaxozHfv2b1k4OQaWNmsp5dD+ChbirhhQsunJcEt/bM233ycBCHA5W+wf52YoxU5bakmyU1Wr0 +KhgOmpmYde7hr9bxxOJmBvIXm23a9YNCBrHKWXXqNvk/Ird0+8fph+V4QfgIhrMYXldOawIlLY+B utzyDtiw==; 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 1jdX7I-0002I5-Lz; Tue, 26 May 2020 10:47:28 +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 1jdX6j-0001q5-4Q for linux-arm-kernel@lists.infradead.org; Tue, 26 May 2020 10:46:55 +0000 Received: by mail-wr1-x444.google.com with SMTP id j16so7473377wrb.7 for ; Tue, 26 May 2020 03:46:52 -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=+TVW4UTODkyLfpaijWt7O8XwAy1JuMHhVBNCKJcCujs=; b=Bbz22miS+FU+DVOh5U7ryFYf5KRB9Hk5+yLGCWChkMx+8UR+r+0A6ZjzGxVED2AP7G whxkV4xQtop4NJOI/6hDllARrG2P6HFOO5gm18jndJhdTVApsss+sjURSfKmjan8I2vy tK/A/vyGo1bdlZmvE2hjPJZqiAdUtHiGJrYAvtMRCuYt4GZjgCkAsYZPoglOBlRCuYoM S7CgIvW5a2wW3sGDxh+3S2UHd3GnSGyqsRv3rYD9x/ntZ5jkdWvNMWq+KmVwla0+/OaI /dLpNewdQCwPyN2bf2h4rAR5qS6XV31NOI+DLhpRFhdCCtcwnenEAaELBNV2WsQyUepl sQQg== 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=+TVW4UTODkyLfpaijWt7O8XwAy1JuMHhVBNCKJcCujs=; b=aeiMQt9ZXsW+W39c+aNMzu8SzUa/uoeGHXcTwwMl7hza6jqdmCF6j32i/G4yHKbnDm WznjoSUliUn0K8ElMweGWCMXPzv1O5tcy2RFVeIil/lGaVDmYOfaNhnjlawwzRJyjUGs mHKOylhsENRJ/G4lzRq49MSeo6/bygYNFroRZMDn5Qq1wtBNL3nq58dRAOPOY8IByre3 6eQA6CbNcGR+AuKEwDjpn+7RcjqdmfewhbP1zhydLRqyyxepvC5hFE/9Cv7tOsGB6Hxf s7xqAH8N2EgTw2igDhy3Qp6w0eJziq0v7A+udooElEwPSJtw52tN999M/WSSXJyeLcov pbgw== X-Gm-Message-State: AOAM533ArnaIrZk8N+11QdSND/7Mf8x2Q1eiPyRWlsjOSMIbZyQXISdn WM96dIR7yc0ezj95WUGxFZk8zinTP+w= X-Google-Smtp-Source: ABdhPJyk8cay6MD2Zb4nQRgFTf3xlFk7IpSAh/OrBoQliPQzZwEz1PEB41XSXt8AztSttEjcX8e/gg== X-Received: by 2002:a5d:694a:: with SMTP id r10mr10002483wrw.266.1590490011232; Tue, 26 May 2020 03:46:51 -0700 (PDT) Received: from linaro.org ([2a00:23c5:6801:1801:8bee:312:6092:58f2]) by smtp.gmail.com with ESMTPSA id u3sm393441wmg.38.2020.05.26.03.46.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 May 2020 03:46:50 -0700 (PDT) From: Mike Leach To: linux-arm-kernel@lists.infradead.org, coresight@lists.linaro.org, mathieu.poirier@linaro.org Subject: [PATCH v4 2/5] coresight: Add default sink selection to CoreSight base Date: Tue, 26 May 2020 11:46:39 +0100 Message-Id: <20200526104642.9526-3-mike.leach@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200526104642.9526-1-mike.leach@linaro.org> References: <20200526104642.9526-1-mike.leach@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200526_034653_169948_01F4C56C X-CRM114-Status: GOOD ( 26.77 ) 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_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 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: Mike Leach , acme@kernel.org, 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 Reviewed-by: Mathieu Poirier --- drivers/hwtracing/coresight/coresight-priv.h | 2 + drivers/hwtracing/coresight/coresight.c | 136 +++++++++++++++++++ include/linux/coresight.h | 3 + 3 files changed, 141 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..7632d060e25d 100644 --- a/drivers/hwtracing/coresight/coresight.c +++ b/drivers/hwtracing/coresight/coresight.c @@ -769,6 +769,142 @@ 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; +} + /** 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. 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 May 26 10:46:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Leach X-Patchwork-Id: 11570271 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 4205260D for ; Tue, 26 May 2020 10:47:49 +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 1FFC32086A for ; Tue, 26 May 2020 10:47:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="C4+LLMOP"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="p6eLXYON" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1FFC32086A 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=fMM/U7+USSzfSIeOg/nP7J+Re6kSfoRzHI8mx1ukJ3k=; b=C4+LLMOPF72GHkjLFQD4AHRGEb 2JZ9Km84RIx3HYHb4mwll/vz7Tj47Zc9H0b5C6tgjJJvBwRBvGlfrZPhtv51IfY+YgsIzW6SmSIvV kzkE5VqnhcaJzW/cRy+hCVekT34/u9a2pP3KfL0gqt4/1Wj75sY8LLddCRtDS5mGrYceyyrrbM937 scfqm2lrqTGHj+dn0OPWijFticAR++iZ4tyItX7uHxcijXDRWh9TYyIGmW546XdZ82GOUu8GM6i76 I0urcniLWIjKcpYUOv4eD2RjH3Ia61QY3wzSGmE3a+SILl06HgIpQFyezggwNJ7LK+qFIQyVrTmoC jXwauSXA==; 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 1jdX7W-0002UW-KM; Tue, 26 May 2020 10:47:42 +0000 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jdX6k-0001ql-M7 for linux-arm-kernel@lists.infradead.org; Tue, 26 May 2020 10:46:56 +0000 Received: by mail-wm1-x343.google.com with SMTP id r9so2667709wmh.2 for ; Tue, 26 May 2020 03:46:54 -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=S8tDeesSr+uuVmJ6yQJIHMVfeP/kah2VmSj3nFDadlk=; b=p6eLXYON/6T/sWFV6XdTTwUZloqGHo3rQp6AewYv3gOWABlVG70uvn6antmf2MhoY7 8BeTdcD7CovXskWGKbBpdkaLbY5v5Zth2HLf8tVWR8P1+p6g9o+OizF0qJq7SVJri5tE ff1UEVL6p0oFYeI3YYCgKLMVy9Zx9iIhT9vgjcu/U3M4sOc0wXmmSa2Pc0YNmXiMNA9g zeQzZV7pncjRHhQ2o6/7lxbCkS9qGgu3dOxpiSgZwzbUVrz3APn/qvumVibaOFvxfe1f XLVc/zx5y+yXYPaEyRlWaih0pegX5AZxd3cgLDVUv0Ch/7TMncYzTa+RuJr2+7TX1nEv 6USQ== 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=S8tDeesSr+uuVmJ6yQJIHMVfeP/kah2VmSj3nFDadlk=; b=GcYuWpASgwLKekkoaEqhG+XMkaAK8oJ24sv1p3uwP/KaGptLGF8Mo4CAnM781ILpE8 Pt8mYlysZ9CUQjNGGwDEbFS/ZM9A/WtTuLBpYf131TsLN3WFz4StEM2rREMaZQvBJ8vk NqwEfz9XmIt5ELyMuzbBmnaKm8EQ1qD/iVm9hcl61NqMd+Jb82z+1FIhUpIrll3eDrzG O0Mcq51Mxg2SxlN2bQ3CDZb98Eo2ET+T46tL4Yqn/1tARAfhqRVfYLCrzuIdSaQabF8s LkA21zSpg61aXf38dDebKx7hevEmXjpC8PGwsWgO6agIkjeCvjwypXSKzp6OBpdQyg8K GIDQ== X-Gm-Message-State: AOAM531XfK28dLtwe4zM6eJQAAS+pxzeEpPwzMQi60wbvz73sT/hyA7q cMuVyTtJNs9Ho3BYdD0qC83882I07gc= X-Google-Smtp-Source: ABdhPJwv1MGOoITv+7ofKKiuJwTneVDafichxemKQ+GxjRMrx3/socYW0ZDFnBy1ffs/3IbUWys/Qg== X-Received: by 2002:a05:600c:2183:: with SMTP id e3mr889969wme.0.1590490012802; Tue, 26 May 2020 03:46:52 -0700 (PDT) Received: from linaro.org ([2a00:23c5:6801:1801:8bee:312:6092:58f2]) by smtp.gmail.com with ESMTPSA id u3sm393441wmg.38.2020.05.26.03.46.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 May 2020 03:46:51 -0700 (PDT) From: Mike Leach To: linux-arm-kernel@lists.infradead.org, coresight@lists.linaro.org, mathieu.poirier@linaro.org Subject: [PATCH v4 3/5] coresight: tmc: Update sink types for default selection. Date: Tue, 26 May 2020 11:46:40 +0100 Message-Id: <20200526104642.9526-4-mike.leach@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200526104642.9526-1-mike.leach@linaro.org> References: <20200526104642.9526-1-mike.leach@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200526_034654_725148_35552BD4 X-CRM114-Status: GOOD ( 11.59 ) 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:343 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 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: Mike Leach , acme@kernel.org, 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 May 26 10:46:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Leach X-Patchwork-Id: 11570277 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 08B6C1391 for ; Tue, 26 May 2020 10:48:20 +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 DABDC20776 for ; Tue, 26 May 2020 10:48:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="I86huM7m"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="pzU02rQN" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DABDC20776 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=aSAY+/5P2I83xwEXJLCJ3wXtMqgEhTYFsPTMg5bQOBI=; b=I86huM7moKqqrAsPT6U+kD2Zgy /viGINruvk7Gm1uOcwNGYBzA6x6tQtSHQ+Dtz8QDKOFdGOpnBw/rBiOD2mvqLM8Anspth2/9Y567X FmAhmXIWpF8ZU4BvghD43w0MRAQB4Y7up8ltHIkwMGCO8q2oYjQ+/KIQckoeoobAlULQ3ZA5ni9YJ jM0K2QBLhgUU1iBF44OH605J20mbpqL9L1XnoznMfz2FySoWWZ5iAfDHQcWNqSuuDN0ociMZkwMKE elgqrp+OiDytYBV5vt4m0EqVmr+fz2eWADdX7ZBNQmctZNGpq9TO9Izcb/Tly+d49LnFgWdhS9gxM c5u3LAzA==; 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 1jdX80-0002yF-Qo; Tue, 26 May 2020 10:48:12 +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 1jdX6m-0001rA-1C for linux-arm-kernel@lists.infradead.org; Tue, 26 May 2020 10:46:57 +0000 Received: by mail-wr1-x441.google.com with SMTP id l11so19965128wru.0 for ; Tue, 26 May 2020 03:46:55 -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=mmS/Kfd2EQnn9ZGp0wgAdxQdekn/AsbBvLcBNRhMhmM=; b=pzU02rQNixMgpUcc43uwZWab4tTCqlviOUyJsPje1ZXkDZ+67bbtFcDSpFNgTW+ylx 4/fZe4/9aJ4l8txOT6oisgPPo6xdN2gpHDcedmkrepGP12O/hmsx+3+DO3vuZxcNcp+D 8U7GdbKdxIQTsUruaTW+G/Xm04QtEnVas4IPfKxOo5J9sJpfLbVUZD5z4Ug9j3EXwya2 /u8sQl3hPVo+WNzk2ejJf9vBSw5EsVohl/EDjyLE/F3Ds6T7QoXWAXvgn0FF3R2g0xbX sfQgb8hpaBtRQWzXpYvDghOHarhNbReqFAIEKZdVm9TDrhO6V27mUAztVM/la14TQK3i pTCA== 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=mmS/Kfd2EQnn9ZGp0wgAdxQdekn/AsbBvLcBNRhMhmM=; b=gRVutIVFdXsKbmvMKj74Zn4XevnaZ/WvVn21T1icD0D54+VgqjoVdS4V2up8CQJNpe hhykejIGoQqOE5k01NSSRjUBEA4c4rgZ+lp+NAxCr5lv8JuGL0LA9M+U7jTK6cIwvWQ/ w9AEik1Q4i8EE+DSAkRTVDwch3zE3q9kWE2t0pEPp92G/FxeMhLcI0aen60sa0oSOT1j 7Zlj2lzpzAmnxCMWCnd4+Xv43JxoSOooNDWK4nQhcso8Ngy92l7itZXIrh9j4RmaVTxa JYKr1NS4vMHFOKYBGL0Am05DfEazMPyNBUh87NTPIvXC9oZZ0MCIDIdhe8KFKNVw708R GNdw== X-Gm-Message-State: AOAM532/O7HqJpJQlWFW1aNpU6RpshkEX6BCRkzy9ivtNttre3ODSU+r Erwosgx3ug8G/DwskEyFSrZNcy33vZg= X-Google-Smtp-Source: ABdhPJyRmhZlmbGQxT6RmRWRAGJJnx2ni3iKOLpizBaK/1YzfH8G67kUmo/5/b07JA2N1pB8kru+tg== X-Received: by 2002:adf:f4c6:: with SMTP id h6mr19977271wrp.398.1590490014116; Tue, 26 May 2020 03:46:54 -0700 (PDT) Received: from linaro.org ([2a00:23c5:6801:1801:8bee:312:6092:58f2]) by smtp.gmail.com with ESMTPSA id u3sm393441wmg.38.2020.05.26.03.46.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 May 2020 03:46:53 -0700 (PDT) From: Mike Leach To: linux-arm-kernel@lists.infradead.org, coresight@lists.linaro.org, mathieu.poirier@linaro.org Subject: [PATCH v4 4/5] coresight: etm: perf: Add default sink selection to etm perf Date: Tue, 26 May 2020 11:46:41 +0100 Message-Id: <20200526104642.9526-5-mike.leach@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200526104642.9526-1-mike.leach@linaro.org> References: <20200526104642.9526-1-mike.leach@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200526_034656_098087_2D2C2FE3 X-CRM114-Status: GOOD ( 15.96 ) 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_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 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: Mike Leach , acme@kernel.org, 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 --- .../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 May 26 10:46:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Leach X-Patchwork-Id: 11570273 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 163A060D for ; Tue, 26 May 2020 10:47:59 +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 E676F2073B for ; Tue, 26 May 2020 10:47:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="TgbZexVj"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="sM0kt9ND" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E676F2073B 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=qp+412bigDZuAH0U+dQ9xgRlsCCdvQM1Pd8RE2gCXAI=; b=TgbZexVjLVyadXvoHpGaXUWBrp N4r9uIoeudYC3OkErSabXF4vaTJo1Ht0NzlAQHEN5fh/rfEsDTn46CjjQH/F7sUPjQOIDBiUuf7Qm 7uIzHm66nIN65nvex9xUNjglGuOt+N+bWFa6ZVJxzZ2eQZTaFLqVyp5DFfTbL8C6TS57FKjTl/8XF 3WzDaOz421PqVXrpVsKmr1quIDVI8iXXLL7vuBKwaZca52ppM1gmNQzq5q33X3Y+wZkzZrx55Bx6p rAKy37H/ncWHx1J/oUqMvfbkVNtni9mET7soaKHzaPBh7MT7TZR30tBV8UFfvI8f68nZ1ELZPVdHD oYaIosdw==; 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 1jdX7h-0002h1-Sf; Tue, 26 May 2020 10:47:53 +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 1jdX6m-0001sQ-KW for linux-arm-kernel@lists.infradead.org; Tue, 26 May 2020 10:46:57 +0000 Received: by mail-wr1-x444.google.com with SMTP id x13so5268079wrv.4 for ; Tue, 26 May 2020 03:46:56 -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=UdzCrND5d4vIGkAZe5IuRiv30DT38TsEw6Df0v8lcJ0=; b=sM0kt9NDAP8x4M0oJG9WWmlCALHA0cDi8/rQQrsdRfbo5OZtvz1thd8AWvsnMK74zM YyoF8xJtBucfjo7g2kVt7Y3Tfs1F1WEI5VWBtVnjTov1inZaZQvK2TxHBhzmnUAwLlfq spV6lZ/oeIwPLiALfHaMHwUlUGhgM77cReZrVO025hjfjiiIlecp7HFM11zkaXz15tXi FAidp0PJzB9PcvT5FRROeInhcAL3NgSw+Hd/aNaCjkR15qDHRv2BFGYlQ470NcXqecM8 +lNi/Ep5hIhviEa7KZC2/7qFrpH/rr2GC8a7iGrXm9Y0OnnVK1eitCJeUh6meitJHBUE jsQQ== 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=UdzCrND5d4vIGkAZe5IuRiv30DT38TsEw6Df0v8lcJ0=; b=A+Dd6WjmbqwXOk7tRnffZIxRvjmOVkxJE/MiJYNmf+19O4SnZctkv4O6cuY1/cmf5R LCn1V3N5MPLfsFD3BqkJ5TSBKqW3LobHehN5CAPBuQgh3ncSg6TGzyJgXg49vkk+hhZ9 9pzLfvtMkEQc+z4JJAbTYWoJGxki5VUNokS0qCiRglOcqbvnc0P+SvYTfXlJ+DXFg9JE 095a58T0Q8V/8uJiBqjbWEcGxnduj0bw8FT6nA1WdooEOkC+nm/UErKKAl3/OEyUKnMR rAESJjYUR+iyaBIuWDhWmVATarQmfz9UkzKravRfegBBTvaaPfqcbSeJxK8YxbttZevQ H0Ug== X-Gm-Message-State: AOAM530P0IJFBvFASZtj0vj093Br2SLfOBep4RS3T8ykFYYpMNaHhRrD Pj7V0vCqMmCYsGVE3UAaX9rV8paMr7c= X-Google-Smtp-Source: ABdhPJz0YBPMbs5gRnXwNOnU+oTjS+wNAeO3eca4ejMvYN9Yxi4mLLiIgMIctffh7EG6coCxszqeCw== X-Received: by 2002:a05:6000:1184:: with SMTP id g4mr4434108wrx.46.1590490015243; Tue, 26 May 2020 03:46:55 -0700 (PDT) Received: from linaro.org ([2a00:23c5:6801:1801:8bee:312:6092:58f2]) by smtp.gmail.com with ESMTPSA id u3sm393441wmg.38.2020.05.26.03.46.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 May 2020 03:46:54 -0700 (PDT) From: Mike Leach To: linux-arm-kernel@lists.infradead.org, coresight@lists.linaro.org, mathieu.poirier@linaro.org Subject: [PATCH v4 5/5] coresight: sysfs: Allow select default sink on source enable. Date: Tue, 26 May 2020 11:46:42 +0100 Message-Id: <20200526104642.9526-6-mike.leach@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200526104642.9526-1-mike.leach@linaro.org> References: <20200526104642.9526-1-mike.leach@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200526_034656_696105_62BD3926 X-CRM114-Status: GOOD ( 14.02 ) 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_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 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: Mike Leach , acme@kernel.org, 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. Signed-off-by: Mike Leach --- drivers/hwtracing/coresight/coresight.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c index 7632d060e25d..bd1a52a65d00 100644 --- a/drivers/hwtracing/coresight/coresight.c +++ b/drivers/hwtracing/coresight/coresight.c @@ -965,8 +965,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);