From patchwork Tue Feb 11 10:58: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: 11375189 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 59C5714B4 for ; Tue, 11 Feb 2020 10:58:38 +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 261F320842 for ; Tue, 11 Feb 2020 10:58:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="iOEaiWOW"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="RLLCq1mS" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 261F320842 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=48rMaWS/c6Oudw+0oxJwr8ZxxD0jYXLfoVPo64csQWM=; b=iOEaiWOWGOQuPvUzCP3bmw3ul0 5IVurCp/FvsP3KXBucedcGoTiOis4cugnu0TUkhqM+UrsiEUNJIzHt67EocfmfZ5giENQ2Bg6ra7u WdR2lhlZNJANpjaykUqy1r90COQt15JjcEw2zBnAcpdJ8pn+Buiy2Ac55UNORRDmaS0wVZCA9WwYS 5/l8O1/WJGTI8FutR2DScSE5/obsM6wBTyVHkxOrD4U1Ofc7QuGW6RTgErcmQ0DuMJUhJAhIjyFDW faLWo6e7XTjTjEf2ac8BjcW1Q3TwH7A8z8IsbNQJHLjgnK4h3sVhu2LPMgs4dtspfH615zZJJA9ZQ TqNlQtdA==; 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 1j1TFO-0001Tm-20; Tue, 11 Feb 2020 10:58:30 +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 1j1TFD-0001IN-0m for linux-arm-kernel@lists.infradead.org; Tue, 11 Feb 2020 10:58:20 +0000 Received: by mail-wm1-x342.google.com with SMTP id s10so2887395wmh.3 for ; Tue, 11 Feb 2020 02:58:18 -0800 (PST) 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=CBZqYhjGCYlEVl1hQyBcSruJxPzTWglj+OLo8vtBQ4s=; b=RLLCq1mSrfgnKsO81lzrre53LWaEKOBe8rxJhLoMjI1859JUEAsQIDLeKYRE7qG4YW ETAMXpnvb7HGMNh7s3c7ZzC+AcOpYnezRABvTmn84mQor2gpFp9QAZgwdtqcGI8XKEgD fTloWnjpn5RtxHaBb0Zf2fefFRw3j1PmLr7g1m7tirkWslBW0PqVBPNVupY4eTnFndKK xuxk6hT5hCOKQ9avKC/qs+3Hh+8Lm7sZaSBEuPFy683EQ7aVI7QA4XuhRCwZc9pnyq/p /3PkFVRVfQwvW/C44eAAenKIQ0q66vA5eOYLZLgr8z+8emeNKUYzw9vIAUYYIyXl02h8 wIsA== 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=CBZqYhjGCYlEVl1hQyBcSruJxPzTWglj+OLo8vtBQ4s=; b=LfErcw2Z2FxJoeD6nl96+0ISvHGO545UtlDfYzHtqWg/8zP136pbDxr+rN1YdSvufJ Es2ZOn8yI4DdUYHMgq/z85fhWSCe1pGM8Yv9G7A68+tDdKh16Nrwi0cDQY7VXsSAQnYu x8YzSNi8/9K2/F4kP11USyeEsnjK/TPvxWZy3wCnnqb+y5njHaDn0YOcRDDsj8ehMoYr lYeYP6eFEtTOpFPiG3VZ2ZP9oVWPrW/9239Zx2mq1zT0VG/1v/kfLujjofjm3/FMKNPZ CRCrcG9DZ92BeFzoKSLvc1yljdXwNUWkeRxd3pDPE1J7at8bFPbyzzWtzQ0rVdewbfpL Ezqg== X-Gm-Message-State: APjAAAXJsKiLxatZfSCkBZ6+reg3/HdanNsxTT8XPg1GKkH1bdLmdgab Ai1j9QaTSaDPGyhNunL1EPPvsUVLPUg= X-Google-Smtp-Source: APXvYqwF6Z1MQGBMp/cv9I8o/B835/lRMiwSMvhMpXTc6WBkbl3mu2ydwjsUIpp5SIZ0T1en65oY6g== X-Received: by 2002:a05:600c:2c53:: with SMTP id r19mr5008569wmg.39.1581418697095; Tue, 11 Feb 2020 02:58:17 -0800 (PST) Received: from linaro.org ([2a00:23c5:6815:3901:a1cf:b00b:5683:ed40]) by smtp.gmail.com with ESMTPSA id g21sm3171291wmh.17.2020.02.11.02.58.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Feb 2020 02:58:16 -0800 (PST) From: Mike Leach To: linux-arm-kernel@lists.infradead.org, coresight@lists.linaro.org, linux-doc@vger.kernel.org Subject: [PATCH v4 1/6] coresight: Pass coresight_device for coresight_release_platform_data Date: Tue, 11 Feb 2020 10:58:03 +0000 Message-Id: <20200211105808.27884-2-mike.leach@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200211105808.27884-1-mike.leach@linaro.org> References: <20200211105808.27884-1-mike.leach@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200211_025819_060380_9673D7BD X-CRM114-Status: GOOD ( 14.04 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.3 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_SIGNED Message has a DKIM or DK signature, not necessarily valid -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_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 , mathieu.poirier@linaro.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 From: Suzuki K Poulose As we prepare to expose the links between the devices in sysfs, pass the coresight_device instance to the coresight_release_platform_data in order to free up the connections when the device is removed. No functional changes as such in this patch. Reviewed-by: Mathieu Poirier Signed-off-by: Suzuki K Poulose Signed-off-by: Mike Leach --- drivers/hwtracing/coresight/coresight-platform.c | 2 +- drivers/hwtracing/coresight/coresight-priv.h | 3 ++- drivers/hwtracing/coresight/coresight.c | 7 ++++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-platform.c b/drivers/hwtracing/coresight/coresight-platform.c index 43418a2126ff..4b78e1ac5285 100644 --- a/drivers/hwtracing/coresight/coresight-platform.c +++ b/drivers/hwtracing/coresight/coresight-platform.c @@ -822,7 +822,7 @@ coresight_get_platform_data(struct device *dev) error: if (!IS_ERR_OR_NULL(pdata)) /* Cleanup the connection information */ - coresight_release_platform_data(pdata); + coresight_release_platform_data(NULL, pdata); return ERR_PTR(ret); } EXPORT_SYMBOL_GPL(coresight_get_platform_data); diff --git a/drivers/hwtracing/coresight/coresight-priv.h b/drivers/hwtracing/coresight/coresight-priv.h index 890f9a5c97c6..1cad642f27aa 100644 --- a/drivers/hwtracing/coresight/coresight-priv.h +++ b/drivers/hwtracing/coresight/coresight-priv.h @@ -211,7 +211,8 @@ static inline void *coresight_get_uci_data(const struct amba_id *id) return 0; } -void coresight_release_platform_data(struct coresight_platform_data *pdata); +void coresight_release_platform_data(struct coresight_device *csdev, + struct coresight_platform_data *pdata); struct coresight_device * coresight_find_csdev_by_fwnode(struct fwnode_handle *r_fwnode); void coresight_set_assoc_ectdev_mutex(struct coresight_device *csdev, diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c index c71553c09f8e..10e756410d3c 100644 --- a/drivers/hwtracing/coresight/coresight.c +++ b/drivers/hwtracing/coresight/coresight.c @@ -1213,7 +1213,8 @@ postcore_initcall(coresight_init); * coresight_release_platform_data: Release references to the devices connected * to the output port of this device. */ -void coresight_release_platform_data(struct coresight_platform_data *pdata) +void coresight_release_platform_data(struct coresight_device *csdev, + struct coresight_platform_data *pdata) { int i; @@ -1316,7 +1317,7 @@ struct coresight_device *coresight_register(struct coresight_desc *desc) kfree(csdev); err_out: /* Cleanup the connection information */ - coresight_release_platform_data(desc->pdata); + coresight_release_platform_data(NULL, desc->pdata); return ERR_PTR(ret); } EXPORT_SYMBOL_GPL(coresight_register); @@ -1326,7 +1327,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_release_platform_data(csdev->pdata); + coresight_release_platform_data(csdev, csdev->pdata); device_unregister(&csdev->dev); } EXPORT_SYMBOL_GPL(coresight_unregister); From patchwork Tue Feb 11 10:58: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: 11375191 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 222C314B4 for ; Tue, 11 Feb 2020 10:58:43 +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 0068B20842 for ; Tue, 11 Feb 2020 10:58:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="cfPF4xyu"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Ti4NKkbk" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0068B20842 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=hhyxQdQTOvn+Fqxphst/gTI0CwTlBPl01Vf6Z0ksgDM=; b=cfPF4xyuEq9R+a+VytrEpMcW27 H9HV2YvieJ6XqPSDCQ+sP45BGkrfp9hiKMQAp6txnS/imEpH5Hn3uAEVdjo5uQONDU59bEVya5ESI mylgG8aKooTNhV9lEn3OqAet+0kFQjdFQ8buEXZy9EzuahwO1tw7N6aCZoazl2V9SNIUTS4IQGk7O nVyn104F+qbBsvm5AujWIQc0tnYas9cmQN9m/3pPQjaxzh75EZv+i3FzlvYQgohJLWVAtJBh+gqCX k9l88CG2jfmIsRa5r7kj/7u1hiV6QODfMNeC6NCdnO/dBT9L7fq8BbzYq0EKRlPdxHYOrQp45RaeU y/kHI6cg==; 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 1j1TFa-0001h6-Hq; Tue, 11 Feb 2020 10:58:42 +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 1j1TFD-0001Ib-U3 for linux-arm-kernel@lists.infradead.org; Tue, 11 Feb 2020 10:58:21 +0000 Received: by mail-wr1-x442.google.com with SMTP id t2so11765785wrr.1 for ; Tue, 11 Feb 2020 02:58:19 -0800 (PST) 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=mcjy2CEkG4vUV/6rKn0LaYo72M9aNFWzBHIkohtYboo=; b=Ti4NKkbkjAgYVP72llVKREnT/9iq3do5dLrmCumt+TOI+SGt9hfEaAZgn5Ew0AzAwV gwzbzeOhbor1ivtJLviXBrZ5vfC3P6SiwVn/0gf4JWCZDygh69+AJgmGT7B/DvqDc7Dn VpoDFz6rMuSFFpeQxm6aH+BSAiLyUp1e91X1Huiw6f3RUp2RHfjzDBfDlnrvBBrKqiya 4cDXzmbSGe9Ohed78ODEM+2ZivdqetXAHsuvVLJs12MAA7FF58MUPzmsLT7K+lBr9lYn z45dm/tNFKi1gaMsNBCHs7oIXpY5jWVSm2TJ9d2BAjhKyMuo0HFkWEy5f6G1zWssc1G9 0B0Q== 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=mcjy2CEkG4vUV/6rKn0LaYo72M9aNFWzBHIkohtYboo=; b=fXtRwi0jOmB4E8OQnKku0i/E4QsGvoTD8mOsqYNkH6A2Tpd8CbJRXgWKrTozZbGnS1 CFGq0b5XCCZxQPbzE4iWqzx8bkIk+WLqHog3xbmHRhHrVv1z/ODrEMPCTjV+sDkTnzGp mXAJatKCQDOfwJ7+M+PsfqWkrI6kaQYGJPNUukJfv/xXbUt/7/YOYse5soifhaimqjhR z4bxH8tDR2M3WhpZvIYqhHUbAF11km3w8/LeEA6rEb1l1rchAZ/XF3+BstaNHUMMdhuR sB2f1GqpFNL4s0TBrpW0wNpO+2L0+d/dRvcdhlQoifSTDIrL8IWqXLQc+lrQ0lE1dTd5 Vvaw== X-Gm-Message-State: APjAAAXYKhEQxZb7SLk1rNSSxBoDVV1/73MiZHwuLJcnH2wu2M4a8WjU JPPtpr+tm8XfQhnp2frDvg4NORgjYGQ= X-Google-Smtp-Source: APXvYqzot50fmcFXwimsQuijTt/kJOpNnHi0OoneA0dxGEX6mY5s1phjJSPIWu0s4zJMIXEsqz3BAw== X-Received: by 2002:a5d:6646:: with SMTP id f6mr8543403wrw.276.1581418698013; Tue, 11 Feb 2020 02:58:18 -0800 (PST) Received: from linaro.org ([2a00:23c5:6815:3901:a1cf:b00b:5683:ed40]) by smtp.gmail.com with ESMTPSA id g21sm3171291wmh.17.2020.02.11.02.58.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Feb 2020 02:58:17 -0800 (PST) From: Mike Leach To: linux-arm-kernel@lists.infradead.org, coresight@lists.linaro.org, linux-doc@vger.kernel.org Subject: [PATCH v4 2/6] coresight: add return value for fixup connections Date: Tue, 11 Feb 2020 10:58:04 +0000 Message-Id: <20200211105808.27884-3-mike.leach@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200211105808.27884-1-mike.leach@linaro.org> References: <20200211105808.27884-1-mike.leach@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200211_025819_967611_AF6E2EA3 X-CRM114-Status: GOOD ( 13.63 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.3 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_SIGNED Message has a DKIM or DK signature, not necessarily valid -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_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 , mathieu.poirier@linaro.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 From: Suzuki K Poulose Handle failures in fixing up connections for a newly registered device. This will be useful to handle cases where we fail to expose the links via sysfs for the connections. Reviewed-by: Mathieu Poirier Signed-off-by: Suzuki K Poulose Signed-off-by: Mike Leach --- drivers/hwtracing/coresight/coresight.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c index 10e756410d3c..07f66a3968f1 100644 --- a/drivers/hwtracing/coresight/coresight.c +++ b/drivers/hwtracing/coresight/coresight.c @@ -1073,18 +1073,14 @@ static int coresight_orphan_match(struct device *dev, void *data) return 0; } -static void coresight_fixup_orphan_conns(struct coresight_device *csdev) +static int coresight_fixup_orphan_conns(struct coresight_device *csdev) { - /* - * No need to check for a return value as orphan connection(s) - * are hooked-up with each newly added component. - */ - bus_for_each_dev(&coresight_bustype, NULL, + return bus_for_each_dev(&coresight_bustype, NULL, csdev, coresight_orphan_match); } -static void coresight_fixup_device_conns(struct coresight_device *csdev) +static int coresight_fixup_device_conns(struct coresight_device *csdev) { int i; @@ -1096,6 +1092,8 @@ static void coresight_fixup_device_conns(struct coresight_device *csdev) if (!conn->child_dev) csdev->orphan = true; } + + return 0; } static int coresight_remove_match(struct device *dev, void *data) @@ -1305,11 +1303,17 @@ struct coresight_device *coresight_register(struct coresight_desc *desc) mutex_lock(&coresight_mutex); - coresight_fixup_device_conns(csdev); - coresight_fixup_orphan_conns(csdev); - cti_add_assoc_to_csdev(csdev); + ret = coresight_fixup_device_conns(csdev); + if (!ret) + ret = coresight_fixup_orphan_conns(csdev); + if (!ret) + cti_add_assoc_to_csdev(csdev); mutex_unlock(&coresight_mutex); + if (ret) { + coresight_unregister(csdev); + return ERR_PTR(ret); + } return csdev; From patchwork Tue Feb 11 10:58: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: 11375193 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 0F84814B4 for ; Tue, 11 Feb 2020 10:59:01 +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 E172820842 for ; Tue, 11 Feb 2020 10:59:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="VdqbxBQ9"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="s1h1AznN" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E172820842 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=UUt806BLP7Df0TP92/EuJ64cTzMnRtramFnbY0zHGmc=; b=VdqbxBQ925jk0drMH6T2m5L1IX AE7/5tao/4mxty+zgAoUTpOsg8lpP2qj//1ARmz05RAz9pb8bKrm9QIXEg6f3jQzdz/PxZtrbK8Pu qS9C+71iyXk48qdllDJH1FV3X81sCrMx1Cg6OUDT1mjPax0fJKr8du7TG6bfmm6Sty3zIDW9rrOIQ 0zucT24tdmuMj5+JKgOtEtFJrLSrRtJjEz+sFCvImcg5F/PV30zyuiPN88kqjQtwQtriUMgaiDg1y 3qP+0ORY9zV/AcRUZikNLgbHD9Wyr75PuueoiWe5s5smZYhAYNoBQyzNJiRAD3jtdMZJCTNGHblHO cMifFdXw==; 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 1j1TFn-0001wk-MC; Tue, 11 Feb 2020 10:58:55 +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 1j1TFF-0001J2-6k for linux-arm-kernel@lists.infradead.org; Tue, 11 Feb 2020 10:58:23 +0000 Received: by mail-wr1-x444.google.com with SMTP id m16so11695050wrx.11 for ; Tue, 11 Feb 2020 02:58:20 -0800 (PST) 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=T27IXVbXguFSrcc6QT4764F4SifO2NNzK2+depwL7hM=; b=s1h1AznN3YphyL6qV3l5zymZ8s4g36UwohuMRxg/neGL5PEee1gMAIPVroIYL0OJKd egqwlsq1v1RvXmrMxfS3jWl+cNXhprW2eF+k38jADMqTqGnlxpobDkeE5TjrsW6I2th7 +7OQPytQxWzUw5mYtolqx8h3mamucMpLq704I6iilr4DQqRs7J7qodsqhvw4PuWRCEiZ J7p/M331HkvdnJ00TQE0aBbvJcqodxm44RdhjDAaVSBbOw1KP15ei7QLqFDefI0OVqn/ MfLKpLZ1IVI/0IyTCEjfwcEJ8OZe5g3he4J8zZv6gCc6pMFRJsWMzUIQgg2GDXedPGZw t+zQ== 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=T27IXVbXguFSrcc6QT4764F4SifO2NNzK2+depwL7hM=; b=nUVzxiLKbbeodWFmNXD0T6TekMy1vZk1aEYwbreik/7m7VqjBMjrYceKbBoh+N3/lT Bly22tTTm6uKHu8y0BoAhIn5hwzzFGGquvxHCWxJBYSFw92qXaTYFm67FGWLa15eHJM0 yBli2UsEXRoqpds5EPSAf9LlnocFxUVGrSDxYRvWYMbLnovGbD0N/MFU5C+0m2BMMRfu MJ+mlrFHjIDNQQGCp9h/zsV6GHtn2iI8+2M5J8V1izflyZqc1aiWIySBCmpHJ0lGPfHA 5im305jAw6Lfd43jFX53x+PpQH5gaAeqa1Yv1gvlr2rTfK17vnPqxE1J0QGFIwME6DQw ugxQ== X-Gm-Message-State: APjAAAWUJFViod7VFilccrTVFvQY04wT+TrJND2UOQVNH2xUgBfmmn+c 5iFtVWvFiEXutYieSWGLSHiPcOFOMtk= X-Google-Smtp-Source: APXvYqyT6MMjWNJF0bZewyihn9zK6/85Uws1PWOQ0ZXXFdvgmiHt9lZAySjngP1VLbqp+HEtyoPznQ== X-Received: by 2002:a5d:4204:: with SMTP id n4mr7867764wrq.123.1581418699079; Tue, 11 Feb 2020 02:58:19 -0800 (PST) Received: from linaro.org ([2a00:23c5:6815:3901:a1cf:b00b:5683:ed40]) by smtp.gmail.com with ESMTPSA id g21sm3171291wmh.17.2020.02.11.02.58.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Feb 2020 02:58:18 -0800 (PST) From: Mike Leach To: linux-arm-kernel@lists.infradead.org, coresight@lists.linaro.org, linux-doc@vger.kernel.org Subject: [PATCH v4 3/6] coresight: Add generic sysfs link creation functions. Date: Tue, 11 Feb 2020 10:58:05 +0000 Message-Id: <20200211105808.27884-4-mike.leach@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200211105808.27884-1-mike.leach@linaro.org> References: <20200211105808.27884-1-mike.leach@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200211_025821_264146_BC6125C4 X-CRM114-Status: GOOD ( 19.10 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.3 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_SIGNED Message has a DKIM or DK signature, not necessarily valid -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_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 , mathieu.poirier@linaro.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 To allow the connections between coresight components to be represented in sysfs, generic methods for creating sysfs links between two coresight devices are added. Signed-off-by: Mike Leach Reviewed-by: Suzuki K Poulose Reviewed-by: Mathieu Poirier --- drivers/hwtracing/coresight/Makefile | 3 +- drivers/hwtracing/coresight/coresight-priv.h | 4 + drivers/hwtracing/coresight/coresight-sysfs.c | 124 ++++++++++++++++++ include/linux/coresight.h | 20 +++ 4 files changed, 150 insertions(+), 1 deletion(-) create mode 100644 drivers/hwtracing/coresight/coresight-sysfs.c diff --git a/drivers/hwtracing/coresight/Makefile b/drivers/hwtracing/coresight/Makefile index 0e3e72f0f510..19497d1d92bf 100644 --- a/drivers/hwtracing/coresight/Makefile +++ b/drivers/hwtracing/coresight/Makefile @@ -2,7 +2,8 @@ # # Makefile for CoreSight drivers. # -obj-$(CONFIG_CORESIGHT) += coresight.o coresight-etm-perf.o coresight-platform.o +obj-$(CONFIG_CORESIGHT) += coresight.o coresight-etm-perf.o \ + coresight-platform.o coresight-sysfs.o obj-$(CONFIG_CORESIGHT_LINK_AND_SINK_TMC) += coresight-tmc.o \ coresight-tmc-etf.o \ coresight-tmc-etr.o diff --git a/drivers/hwtracing/coresight/coresight-priv.h b/drivers/hwtracing/coresight/coresight-priv.h index 1cad642f27aa..a4a658d46045 100644 --- a/drivers/hwtracing/coresight/coresight-priv.h +++ b/drivers/hwtracing/coresight/coresight-priv.h @@ -153,6 +153,10 @@ struct coresight_device *coresight_get_sink_by_id(u32 id); struct list_head *coresight_build_path(struct coresight_device *csdev, struct coresight_device *sink); void coresight_release_path(struct list_head *path); +int coresight_add_sysfs_link(struct coresight_sysfs_link *info); +void coresight_remove_sysfs_link(struct coresight_sysfs_link *info); +int coresight_create_conns_sysfs_group(struct coresight_device *csdev); +void coresight_remove_conns_sysfs_group(struct coresight_device *csdev); #ifdef CONFIG_CORESIGHT_SOURCE_ETM3X extern int etm_readl_cp14(u32 off, unsigned int *val); diff --git a/drivers/hwtracing/coresight/coresight-sysfs.c b/drivers/hwtracing/coresight/coresight-sysfs.c new file mode 100644 index 000000000000..17d565941e5e --- /dev/null +++ b/drivers/hwtracing/coresight/coresight-sysfs.c @@ -0,0 +1,124 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2019, Linaro Limited, All rights reserved. + * Author: Mike Leach + */ + +#include +#include + +#include "coresight-priv.h" + +/* + * Connections group - links attribute. + * Count of created links between coresight components in the group. + */ +static ssize_t nr_links_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct coresight_device *csdev = to_coresight_device(dev); + + return scnprintf(buf, PAGE_SIZE, "%d\n", csdev->nr_links); +} +static DEVICE_ATTR_RO(nr_links); + +static struct attribute *coresight_conns_attrs[] = { + &dev_attr_nr_links.attr, + NULL, +}; + +static struct attribute_group coresight_conns_group = { + .attrs = coresight_conns_attrs, + .name = "connections", +}; + +/* + * Create connections group for CoreSight devices. + * This group will then be used to collate the sysfs links between + * devices. + */ +int coresight_create_conns_sysfs_group(struct coresight_device *csdev) +{ + int ret = 0; + + if (!csdev) + return -EINVAL; + + ret = sysfs_create_group(&csdev->dev.kobj, &coresight_conns_group); + if (ret) + return ret; + + csdev->has_conns_grp = true; + return ret; +} + +void coresight_remove_conns_sysfs_group(struct coresight_device *csdev) +{ + if (!csdev) + return; + + if (csdev->has_conns_grp) { + sysfs_remove_group(&csdev->dev.kobj, &coresight_conns_group); + csdev->has_conns_grp = false; + } +} + +int coresight_add_sysfs_link(struct coresight_sysfs_link *info) +{ + int ret = 0; + + if (!info) + return -EINVAL; + if (!info->orig || !info->target || + !info->orig_name || !info->target_name) + return -EINVAL; + if (!info->orig->has_conns_grp || !info->target->has_conns_grp) + return -EINVAL; + + /* first link orig->target */ + ret = sysfs_add_link_to_group(&info->orig->dev.kobj, + coresight_conns_group.name, + &info->target->dev.kobj, + info->orig_name); + if (ret) + return ret; + + /* second link target->orig */ + ret = sysfs_add_link_to_group(&info->target->dev.kobj, + coresight_conns_group.name, + &info->orig->dev.kobj, + info->target_name); + + /* error in second link - remove first - otherwise inc counts */ + if (ret) { + sysfs_remove_link_from_group(&info->orig->dev.kobj, + coresight_conns_group.name, + info->orig_name); + } else { + info->orig->nr_links++; + info->target->nr_links++; + } + + return ret; +} + +void coresight_remove_sysfs_link(struct coresight_sysfs_link *info) +{ + if (!info) + return; + if (!info->orig || !info->target || + !info->orig_name || !info->target_name) + return; + + sysfs_remove_link_from_group(&info->orig->dev.kobj, + coresight_conns_group.name, + info->orig_name); + + sysfs_remove_link_from_group(&info->target->dev.kobj, + coresight_conns_group.name, + info->target_name); + + info->orig->nr_links--; + info->target->nr_links--; +} diff --git a/include/linux/coresight.h b/include/linux/coresight.h index 193cc9dbf448..a2ec25e02ca9 100644 --- a/include/linux/coresight.h +++ b/include/linux/coresight.h @@ -148,6 +148,20 @@ struct coresight_connection { struct coresight_device *child_dev; }; +/** + * struct coresight_sysfs_link - representation of a connection in sysfs. + * @orig: Originating (master) coresight device for the link. + * @orig_name: Name to use for the link orig->target. + * @target: Target (slave) coresight device for the link. + * @target_name: Name to use for the link target->orig. + */ +struct coresight_sysfs_link { + struct coresight_device *orig; + const char *orig_name; + struct coresight_device *target; + const char *target_name; +}; + /** * struct coresight_device - representation of a device as used by the framework * @pdata: Platform data with device connections associated to this device. @@ -165,6 +179,9 @@ struct coresight_connection { * @ea: Device attribute for sink representation under PMU directory. * @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 + * device. These will appear in the "connections" group. + * @has_conns_grp: Have added a "connections" group for sysfs links. */ struct coresight_device { struct coresight_platform_data *pdata; @@ -180,6 +197,9 @@ struct coresight_device { struct dev_ext_attribute *ea; /* cross trigger handling */ struct coresight_device *ect_dev; + /* sysfs links between components */ + int nr_links; + bool has_conns_grp; }; /* From patchwork Tue Feb 11 10:58: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: 11375195 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 1B33D109A for ; Tue, 11 Feb 2020 10:59:17 +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 EA34C2086A for ; Tue, 11 Feb 2020 10:59:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="mnir+Clg"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="yRYM43LS" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EA34C2086A 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=ov8gl1ILR8kq+MVRneg/UjlgPszPjAJ3rS0NA/M5G6M=; b=mnir+ClgQAtVhxWlbe+tjft3IU WwWZOeq+1f/2sfGbCAe/Aozd6S44KscXX/nKxGT+utOMTWycwfv7gx7rreSkQjrrTgRZXtxvp+JZQ LN1u21M52WWCiLW37pbUM+Q8JJis0Lpo7BcyD8fC7styQr7cKGWY7Skc6CBm/EUqMA8ksjbsK5HOO OioqP1hFr4JLcMM3WRldQ3vaIN05JPu7UzWgBsrQGSr54k0ksc6rnhOQ/N5WMpNMZeWyLAXiGMMGj taoIW5nWR4SXX/hgpadi3pVpd0lIqlhaTBUQsiUWwqG2rHemzMf390WCzEfX1Y69o0nzHB7snMnyT VpL1bWNA==; 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 1j1TG1-0002Du-UG; Tue, 11 Feb 2020 10:59:09 +0000 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1j1TFG-0001Je-0j for linux-arm-kernel@lists.infradead.org; Tue, 11 Feb 2020 10:58:24 +0000 Received: by mail-wm1-x341.google.com with SMTP id a5so2904326wmb.0 for ; Tue, 11 Feb 2020 02:58:21 -0800 (PST) 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=UkHXs/ICS0ww6vJx9GuPCceCRLMrxlhwu4y3PLs/7GU=; b=yRYM43LSAycuxJrfC5cTq5YBSX6AZjfvG2jgbbxjDMbCwUOMHB4zyjvPPvsgr5qe/R 4rLz1s7yWr7gYqK9IPrpn0KZsgr3IZY/SPadjdOL3VmiHryz9qmA9FfXStAVFIBJhddo 3Q5s8dFxnBbYx28WM2hkFlB/dgW+Zp+47cFjySbZaxX4QbmuwejaUMvHeMcjnXWWyKU6 SK3BFjNRzPchybBOS9t+QPvziEtR5m4xux4fShfBaFsG86FpgurfX4CDCDyoZYavXruV A5DerIWs01s73o7oSJR7vgrMtpqKq5OeB1lKJOseoJvALxeZfA5lxC9nSHA14SOqAWBq 7lXg== 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=UkHXs/ICS0ww6vJx9GuPCceCRLMrxlhwu4y3PLs/7GU=; b=lfK+MGUX6Wfk/QdyIVZVIj4rU13l8yPJVK8QmKOJ8HUkAeVn7rcEXGSEaktnYMZanl c8suE7ZptKAiIEYmrSscUv9R9KTCnILzLArjFoCLgNCo9YqeH96afJ+Yybn4pYiPb3FS k4XLqukipkzwdfEDOccQTtqhPJtqsQsK+VL1yie9VouAyLFitiCKs6ucm9/xiohv56ay gXEAvVnkBhINaGWXGWtoCG3UkgOjMTX5+XYcNbxfiGxQZWzH9QUB6qNG3jH+VZEJ8t61 F1FAHhfqjDi02MY15zoodnzSe0CGOKlI5lVoZwjt4DE5YRcndJ8sLniViJno6cZ6BQiK Epkw== X-Gm-Message-State: APjAAAUtryNbP0nDkvTlB2S6iA/4xJeMhyPKScn4WxhaYJR5J2MsLnUh l+h/DZv+Q/XcXpLEQx7oTEsEOonfbOM= X-Google-Smtp-Source: APXvYqyTZhv1S+MPefPL40yOfPVnW6Yb9Bx5Tq56W1naiXcztiYBO/i4hRsX14guiz8C2MfmlBAeEA== X-Received: by 2002:a05:600c:2383:: with SMTP id m3mr5212122wma.32.1581418700024; Tue, 11 Feb 2020 02:58:20 -0800 (PST) Received: from linaro.org ([2a00:23c5:6815:3901:a1cf:b00b:5683:ed40]) by smtp.gmail.com with ESMTPSA id g21sm3171291wmh.17.2020.02.11.02.58.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Feb 2020 02:58:19 -0800 (PST) From: Mike Leach To: linux-arm-kernel@lists.infradead.org, coresight@lists.linaro.org, linux-doc@vger.kernel.org Subject: [PATCH v4 4/6] coresight: Expose device connections via sysfs Date: Tue, 11 Feb 2020 10:58:06 +0000 Message-Id: <20200211105808.27884-5-mike.leach@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200211105808.27884-1-mike.leach@linaro.org> References: <20200211105808.27884-1-mike.leach@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200211_025822_160544_C243E430 X-CRM114-Status: GOOD ( 24.07 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.3 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:341 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_SIGNED Message has a DKIM or DK signature, not necessarily valid -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_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 , mathieu.poirier@linaro.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 From: Suzuki K Poulose Coresight device connections are a bit complicated and is not exposed currently to the user. One has to look at the platform descriptions (DT bindings or ACPI bindings) to make an understanding. Given the new naming scheme, it will be helpful to have this information to choose the appropriate devices for tracing. This patch exposes the device connections via links in the sysfs directories. e.g, for a connection devA[OutputPort_X] -> devB[InputPort_Y] is represented as two symlinks: /sys/bus/coresight/.../devA/out:X -> /sys/bus/coresight/.../devB /sys/bus/coresight/.../devB/in:Y -> /sys/bus/coresight/.../devA Cc: Mathieu Poirier Signed-off-by: Suzuki K Poulose Revised to use the generic sysfs links functions & link structures. Provides a connections sysfs group to hold the links. Co-developed-by: Mike Leach Signed-off-by: Mike Leach Signed-off-by: Mike Leach Reviewed-by: Mathieu Poirier Signed-off-by: Mike Leach --- drivers/hwtracing/coresight/coresight-priv.h | 5 ++ drivers/hwtracing/coresight/coresight-sysfs.c | 80 +++++++++++++++++++ drivers/hwtracing/coresight/coresight.c | 46 ++++++++--- include/linux/coresight.h | 2 + 4 files changed, 121 insertions(+), 12 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-priv.h b/drivers/hwtracing/coresight/coresight-priv.h index a4a658d46045..5a36f0f50899 100644 --- a/drivers/hwtracing/coresight/coresight-priv.h +++ b/drivers/hwtracing/coresight/coresight-priv.h @@ -157,6 +157,11 @@ int coresight_add_sysfs_link(struct coresight_sysfs_link *info); void coresight_remove_sysfs_link(struct coresight_sysfs_link *info); int coresight_create_conns_sysfs_group(struct coresight_device *csdev); void coresight_remove_conns_sysfs_group(struct coresight_device *csdev); +int coresight_make_links(struct coresight_device *orig, + struct coresight_connection *conn, + struct coresight_device *target); +void coresight_remove_links(struct coresight_device *orig, + struct coresight_connection *conn); #ifdef CONFIG_CORESIGHT_SOURCE_ETM3X extern int etm_readl_cp14(u32 off, unsigned int *val); diff --git a/drivers/hwtracing/coresight/coresight-sysfs.c b/drivers/hwtracing/coresight/coresight-sysfs.c index 17d565941e5e..0f18332b9f19 100644 --- a/drivers/hwtracing/coresight/coresight-sysfs.c +++ b/drivers/hwtracing/coresight/coresight-sysfs.c @@ -122,3 +122,83 @@ void coresight_remove_sysfs_link(struct coresight_sysfs_link *info) info->orig->nr_links--; info->target->nr_links--; } + +/* + * coresight_make_links: Make a link for a connection from a @orig + * device to @target, represented by @conn. + * + * e.g, for devOrig[output_X] -> devTarget[input_Y] is represented + * as two symbolic links : + * + * /sys/.../devOrig/out:X -> /sys/.../devTarget/ + * /sys/.../devTarget/in:Y -> /sys/.../devOrig/ + * + * The link names are allocated for a device where it appears. i.e, the + * "out" link on the master and "in" link on the slave device. + * The link info is stored in the connection record for avoiding + * the reconstruction of names for removal. + */ +int coresight_make_links(struct coresight_device *orig, + struct coresight_connection *conn, + struct coresight_device *target) +{ + int ret = -ENOMEM; + char *outs = NULL, *ins = NULL; + struct coresight_sysfs_link *link = NULL; + + do { + outs = devm_kasprintf(&orig->dev, GFP_KERNEL, + "out:%d", conn->outport); + if (!outs) + break; + ins = devm_kasprintf(&target->dev, GFP_KERNEL, + "in:%d", conn->child_port); + if (!ins) + break; + link = devm_kzalloc(&orig->dev, + sizeof(struct coresight_sysfs_link), + GFP_KERNEL); + if (!link) + break; + + link->orig = orig; + link->target = target; + link->orig_name = outs; + link->target_name = ins; + + ret = coresight_add_sysfs_link(link); + if (ret) + break; + + conn->link = link; + + /* + * Install the device connection. This also indicates that + * the links are operational on both ends. + */ + conn->child_dev = target; + return 0; + } while (0); + + return ret; +} + +/* + * coresight_remove_links: Remove the sysfs links for a given connection @conn, + * from @orig device to @target device. See coresight_make_links() for more + * details. + */ +void coresight_remove_links(struct coresight_device *orig, + struct coresight_connection *conn) +{ + if (!orig || !conn->link) + return; + + coresight_remove_sysfs_link(conn->link); + + devm_kfree(&conn->child_dev->dev, conn->link->target_name); + devm_kfree(&orig->dev, conn->link->orig_name); + devm_kfree(&orig->dev, conn->link); + conn->link = NULL; + conn->child_dev = NULL; +} diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c index 07f66a3968f1..4f10cfa9dc18 100644 --- a/drivers/hwtracing/coresight/coresight.c +++ b/drivers/hwtracing/coresight/coresight.c @@ -1031,7 +1031,7 @@ static void coresight_device_release(struct device *dev) static int coresight_orphan_match(struct device *dev, void *data) { - int i; + int i, ret = 0; bool still_orphan = false; struct coresight_device *csdev, *i_csdev; struct coresight_connection *conn; @@ -1056,19 +1056,23 @@ static int coresight_orphan_match(struct device *dev, void *data) /* We have found at least one orphan connection */ if (conn->child_dev == NULL) { /* Does it match this newly added device? */ - if (conn->child_fwnode == csdev->dev.fwnode) - conn->child_dev = csdev; - else + if (conn->child_fwnode == csdev->dev.fwnode) { + ret = coresight_make_links(i_csdev, + conn, csdev); + if (ret) + return ret; + } else { /* This component still has an orphan */ still_orphan = true; + } } } i_csdev->orphan = still_orphan; /* - * Returning '0' ensures that all known component on the - * bus will be checked. + * Returning '0' in case we didn't encounter any error, + * ensures that all known component on the bus will be checked. */ return 0; } @@ -1082,15 +1086,21 @@ static int coresight_fixup_orphan_conns(struct coresight_device *csdev) static int coresight_fixup_device_conns(struct coresight_device *csdev) { - int i; + int i, ret = 0; for (i = 0; i < csdev->pdata->nr_outport; i++) { struct coresight_connection *conn = &csdev->pdata->conns[i]; conn->child_dev = coresight_find_csdev_by_fwnode(conn->child_fwnode); - if (!conn->child_dev) + if (conn->child_dev) { + ret = coresight_make_links(csdev, conn, + conn->child_dev); + if (ret) + break; + } else { csdev->orphan = true; + } } return 0; @@ -1121,7 +1131,7 @@ static int coresight_remove_match(struct device *dev, void *data) if (csdev->dev.fwnode == conn->child_fwnode) { iterator->orphan = true; - conn->child_dev = NULL; + coresight_remove_links(iterator, conn); /* * Drop the reference to the handle for the remote * device acquired in parsing the connections from @@ -1215,13 +1225,23 @@ void coresight_release_platform_data(struct coresight_device *csdev, struct coresight_platform_data *pdata) { int i; + struct coresight_connection *conns = pdata->conns; for (i = 0; i < pdata->nr_outport; i++) { - if (pdata->conns[i].child_fwnode) { - fwnode_handle_put(pdata->conns[i].child_fwnode); + /* If we have made the links, remove them now */ + if (csdev && conns[i].child_dev) + coresight_remove_links(csdev, &conns[i]); + /* + * Drop the refcount and clear the handle as this device + * is going away + */ + if (conns[i].child_fwnode) { + fwnode_handle_put(conns[i].child_fwnode); pdata->conns[i].child_fwnode = NULL; } } + if (csdev) + coresight_remove_conns_sysfs_group(csdev); } struct coresight_device *coresight_register(struct coresight_desc *desc) @@ -1303,7 +1323,9 @@ struct coresight_device *coresight_register(struct coresight_desc *desc) mutex_lock(&coresight_mutex); - ret = coresight_fixup_device_conns(csdev); + ret = coresight_create_conns_sysfs_group(csdev); + if (!ret) + ret = coresight_fixup_device_conns(csdev); if (!ret) ret = coresight_fixup_orphan_conns(csdev); if (!ret) diff --git a/include/linux/coresight.h b/include/linux/coresight.h index a2ec25e02ca9..ccd17304d7bd 100644 --- a/include/linux/coresight.h +++ b/include/linux/coresight.h @@ -140,12 +140,14 @@ struct coresight_desc { * @chid_fwnode: remote component's fwnode handle. * @child_dev: a @coresight_device representation of the component connected to @outport. + * @link: Representation of the connection as a sysfs link. */ struct coresight_connection { int outport; int child_port; struct fwnode_handle *child_fwnode; struct coresight_device *child_dev; + struct coresight_sysfs_link *link; }; /** From patchwork Tue Feb 11 10:58:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Leach X-Patchwork-Id: 11375197 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 628F3109A for ; Tue, 11 Feb 2020 10:59: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 3FFEF20842 for ; Tue, 11 Feb 2020 10:59: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="BPkf8fh4"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="ZDgv/t7s" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3FFEF20842 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=2pkO4amQM2jOKyzLj+boLh39DDh0PpARcDIBDYbjPY4=; b=BPkf8fh4GLCFvEZzl04tC4n4ZD HGDa4ylFEPjTFfPvnmsdlsRl/CRrSDnr14npzd/pJ72lfoIP6Y6L89MuHtQ+6CApQzTb8v7pDa5p3 g0ITGXaJkiyYQ/ltw80TMqdHvPd8hObYroqdr6vAjfT7eAc5gJlLKpbAMDHo+TWDbQ0A2PuDkS/2t RnLcobUV/YtiW+1tvh13Cj1RS0BQYjyY8Xzll5gkusr5qtCgBTPV97UIBZdrJXJqcb47SVjBFkEcH H7Wk1WjfY7pKwuaz7kcMkFonkGFxGhxA9+D8A2hS7kH28vZhA9sdx55oTfXX72/xOSj52ARUUVJch coDlthWA==; 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 1j1TGD-0002R7-LG; Tue, 11 Feb 2020 10:59:21 +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 1j1TFH-0001Kj-A2 for linux-arm-kernel@lists.infradead.org; Tue, 11 Feb 2020 10:58:24 +0000 Received: by mail-wr1-x441.google.com with SMTP id z7so11684136wrl.13 for ; Tue, 11 Feb 2020 02:58:22 -0800 (PST) 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=vNm6E41dD+3EcT2K0DKbvrPIUP9PYyF/XxhSVh53CX0=; b=ZDgv/t7sP+1uEALXpOkZpnoz/ADtsfUQwiF774ux9bqMBNrEWL7M97gwvi2sQLez2u U+GlZ39laxiS/Tu69JKhSRjgzOyMz7bf1p4ReTCQp9RRGB3ocKimww6VufV+oV4Jj6mU jyWeu4+K89JcKCeCrJdcDMr3stiK838D1Mh9iNmRu/faef2dU60D/6yeIKfRxkaxkx/E y0IwUc2urI63kdHNPEySEgZvnDjm4xKLfm6Fv5kNvYcycTmWz13BITMgn9tIBbUWI/G5 CIOak1SljGxKjKx5r0QTyudlwJf8mMm2fRIjH+aXljiKj4YwJt40GJl8QTW0fkNUeu9c +Yqw== 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=vNm6E41dD+3EcT2K0DKbvrPIUP9PYyF/XxhSVh53CX0=; b=sMZ4fTXAXGPOm35RSpK/P86ajxdvpHBkysO+YJlUy5GFnmuvyOfAOTO3DjxcBbpWnc IfZskTvLrDxOxCSSCXHguDTVvaun3R5NsjKDOPVeEnZwFzpESkTepHFqvroulsJYzjiX 8u89d4qv9I10yoyBXspLCsbkTvzf/FUh4hlo/TxWRa1Pe5dO6kWBkZS89AlAJ5PxVWxW 0vi2zi1FMl54xqgHUqpkL5c/vE2j8MIJWHpaUfWjpUBlEUTzuEFXZPtKdW75u2XRlG7Q pjvnkOZCq9Lw03Vch+ylY3sVRzix5rWsnxnxmED1GiB+jizCo1E37ET5pPgg0XHU6yJ9 yMeg== X-Gm-Message-State: APjAAAVjZndQLeJZ3/fSGL2kFUseeERSZnIKoKHUentcVpQDq+9me5uJ x2avieE7AN/LD6cDD3zqhk2POMg7n3E= X-Google-Smtp-Source: APXvYqzFlqJJqrPjFPpJYQFGxy5nia87NDWRjTSgfCOvhptfDM8hkWrlFc5afOgryjY0L3tap5GyRw== X-Received: by 2002:a5d:54c1:: with SMTP id x1mr7717644wrv.240.1581418701161; Tue, 11 Feb 2020 02:58:21 -0800 (PST) Received: from linaro.org ([2a00:23c5:6815:3901:a1cf:b00b:5683:ed40]) by smtp.gmail.com with ESMTPSA id g21sm3171291wmh.17.2020.02.11.02.58.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Feb 2020 02:58:20 -0800 (PST) From: Mike Leach To: linux-arm-kernel@lists.infradead.org, coresight@lists.linaro.org, linux-doc@vger.kernel.org Subject: [PATCH v4 5/6] coresight: cti: Add in sysfs links to other coresight devices. Date: Tue, 11 Feb 2020 10:58:07 +0000 Message-Id: <20200211105808.27884-6-mike.leach@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200211105808.27884-1-mike.leach@linaro.org> References: <20200211105808.27884-1-mike.leach@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200211_025823_357361_32BD1F7D X-CRM114-Status: GOOD ( 14.17 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.3 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_SIGNED Message has a DKIM or DK signature, not necessarily valid -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_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 , mathieu.poirier@linaro.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 in sysfs links for connections where the connected device is another coresight device. This allows examination of the coresight topology. Non-coresight connections remain just as a reference name. Signed-off-by: Mike Leach Reviewed-by: Mathieu Poirier --- drivers/hwtracing/coresight/coresight-cti.c | 41 ++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/drivers/hwtracing/coresight/coresight-cti.c b/drivers/hwtracing/coresight/coresight-cti.c index 9e18e176831c..f620e9460e7d 100644 --- a/drivers/hwtracing/coresight/coresight-cti.c +++ b/drivers/hwtracing/coresight/coresight-cti.c @@ -441,6 +441,37 @@ int cti_channel_setop(struct device *dev, enum cti_chan_set_op op, return err; } +static void cti_add_sysfs_link(struct cti_drvdata *drvdata, + struct cti_trig_con *tc) +{ + struct coresight_sysfs_link link_info; + + link_info.orig = drvdata->csdev; + link_info.orig_name = tc->con_dev_name; + link_info.target = tc->con_dev; + link_info.target_name = dev_name(&drvdata->csdev->dev); + coresight_add_sysfs_link(&link_info); +} + +static void cti_remove_all_sysfs_links(struct cti_drvdata *drvdata) +{ + struct cti_trig_con *tc; + struct cti_device *ctidev = &drvdata->ctidev; + struct coresight_sysfs_link link_info; + + /* origin device and target link name constant for this cti */ + link_info.orig = drvdata->csdev; + link_info.target_name = dev_name(&drvdata->csdev->dev); + + list_for_each_entry(tc, &ctidev->trig_cons, node) { + if (tc->con_dev) { + link_info.target = tc->con_dev; + link_info.orig_name = tc->con_dev_name; + coresight_remove_sysfs_link(&link_info); + } + } +} + /* * Look for a matching connection device name in the list of connections. * If found then swap in the csdev name, set trig con association pointer @@ -452,6 +483,8 @@ cti_match_fixup_csdev(struct cti_device *ctidev, const char *node_name, { struct cti_trig_con *tc; const char *csdev_name; + struct cti_drvdata *drvdata = container_of(ctidev, struct cti_drvdata, + ctidev); list_for_each_entry(tc, &ctidev->trig_cons, node) { if (tc->con_dev_name) { @@ -462,6 +495,7 @@ cti_match_fixup_csdev(struct cti_device *ctidev, const char *node_name, devm_kstrdup(&csdev->dev, csdev_name, GFP_KERNEL); tc->con_dev = csdev; + cti_add_sysfs_link(drvdata, tc); return true; } } @@ -546,10 +580,12 @@ static void cti_update_conn_xrefs(struct cti_drvdata *drvdata) struct cti_device *ctidev = &drvdata->ctidev; list_for_each_entry(tc, &ctidev->trig_cons, node) { - if (tc->con_dev) + if (tc->con_dev) { /* set tc->con_dev->ect_dev */ coresight_set_assoc_ectdev_mutex(tc->con_dev, drvdata->csdev); + cti_add_sysfs_link(drvdata, tc); + } } } @@ -602,6 +638,9 @@ static void cti_device_release(struct device *dev) mutex_lock(&ect_mutex); cti_remove_conn_xrefs(drvdata); + /* clear the dynamic sysfs associate with connections */ + cti_remove_all_sysfs_links(drvdata); + /* remove from the list */ list_for_each_entry_safe(ect_item, ect_tmp, &ect_net, node) { if (ect_item == drvdata) { From patchwork Tue Feb 11 10:58:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Leach X-Patchwork-Id: 11375199 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 98C7814B4 for ; Tue, 11 Feb 2020 10:59:38 +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 775AC20842 for ; Tue, 11 Feb 2020 10:59:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Hq0+YrqE"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="o9REiGwv" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 775AC20842 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=Awk6zJHoG56eMzkl4eD7nwXX4g2iZ1nUj8qDq1WQ3O4=; b=Hq0+YrqEe8J2R84yHiyKjJeB4K /+GYs7WfkfBByUVVM7567t2fDLhRmlMLEq2Bz5gF019QuOMVdfQrER3fS4A4vVvWrJQXOXzGUrDoL /6kmj/Rd6lXsRtzs1gnPTEcS4F+yMrOQHjSvgQIUjnYoNI5nG4L0yT4ce0JN9F4fUP1/09KfBuSCO MLcy6CvfnAETngw3rXD4a2gSdeGZhJQisDhJClnC1Yyv1JPD8GNnYyN+K+XgkyoaV2B79NBS7J9Xh zisxbCd3rEYTUv5ciEkEF19lVwT5eXfWZfDl1042gr+XA1pt/MFGg4VZmD8fZ83PC/OD+gTQ8UHqF TdYCAX8Q==; 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 1j1TGQ-0002fo-1K; Tue, 11 Feb 2020 10:59:34 +0000 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1j1TFI-0001M3-7d for linux-arm-kernel@lists.infradead.org; Tue, 11 Feb 2020 10:58:26 +0000 Received: by mail-wr1-x42d.google.com with SMTP id y11so11745625wrt.6 for ; Tue, 11 Feb 2020 02:58:23 -0800 (PST) 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=M6xq/OxJSWfSTPvEoweukyF8MINoDGNxuW+L6ZQztPM=; b=o9REiGwvSPNR/g1Cq5hByCtYy8T9Rnf88hnGfwRNoSJKpw+DmpGOLV1vWzpSsPuWED GaHauWwmfpvL7QKBT2AG/NxVhxpzIQ6H5rtfp/RZScgYYJfV9lq0BtRQgJzMEgjiCkHO z61N6wQZ6jN9ewWiMyIkvg6kCv/2rOJnqL7DdBr7v5CXQBtTGEJ+FjkR1WpZ4pdLaJ6C Ou2ILlM0zKRPLuaJxuMnyM7lg0EtBZgnxVQAF24tUOsAFJE85a/GB/ceVjjEVU50fmTJ AH5vYkHvGyQSBrtzyz/mkYAG2aQuToPcsj0QBOZTVxHr1Urvqwmwt8BxYRff9kbd+QNR oBCQ== 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=M6xq/OxJSWfSTPvEoweukyF8MINoDGNxuW+L6ZQztPM=; b=tM5z4xJpF7Hb2wtitUm8IjXBgikHV0gEFKi+DhZgV8DR4UKIwUAKlC812q+Y9/A6Jp 6D4C8X0qyqmlfmCuXPKXPTpAViqMCTYVjAOYNICY0tXZQn0bSvKa+GjGBli8tUUtlO0F +rp8F7Yn7A5KyC1467W7b5e1XpJYJYel7ssLzOUAjdvcFOb2NS2QHKQkfYPfLvRFuaY1 m7waf1e/TOLvbo/GnzhG7gJibZEwn77m9cI9NPHFUORwW5dSiq53c+ga9E2fDxKwYow5 oWut9S9pwmSdd9SNzJcPF6DzvJPfFO3CC/iAh5SyGZDjWo5L39m9I4SUYPpxcAt/PG3g x7yw== X-Gm-Message-State: APjAAAXzFsZcrwITMYnliS74YPpbeHcjINpvShyuBEXcCbjqBK1x1xjc 7tmCKr8HfDYEWbEnWckbcUr5CzDVQXs= X-Google-Smtp-Source: APXvYqxZhJedOIVtgpr6JvsCzPcDmeNJnY75P/JUMOwUUZ2QqThZYaJLjAdCNuPyV0wLn2/l3jy/Eg== X-Received: by 2002:a5d:4446:: with SMTP id x6mr7838462wrr.312.1581418702081; Tue, 11 Feb 2020 02:58:22 -0800 (PST) Received: from linaro.org ([2a00:23c5:6815:3901:a1cf:b00b:5683:ed40]) by smtp.gmail.com with ESMTPSA id g21sm3171291wmh.17.2020.02.11.02.58.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Feb 2020 02:58:21 -0800 (PST) From: Mike Leach To: linux-arm-kernel@lists.infradead.org, coresight@lists.linaro.org, linux-doc@vger.kernel.org Subject: [PATCH v4 6/6] coresight: docs: Add information about the topology representations. Date: Tue, 11 Feb 2020 10:58:08 +0000 Message-Id: <20200211105808.27884-7-mike.leach@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200211105808.27884-1-mike.leach@linaro.org> References: <20200211105808.27884-1-mike.leach@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200211_025824_283208_0A9995F6 X-CRM114-Status: GOOD ( 15.51 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.3 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:42d 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_SIGNED Message has a DKIM or DK signature, not necessarily valid -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_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 , mathieu.poirier@linaro.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 Update the CoreSight documents to describe the new connections directory and the links between CoreSight devices in this directory. Signed-off-by: Mike Leach Reviewed-by: Mathieu Poirier --- .../trace/coresight/coresight-ect.rst | 5 +- Documentation/trace/coresight/coresight.rst | 85 +++++++++++++++++++ 2 files changed, 89 insertions(+), 1 deletion(-) diff --git a/Documentation/trace/coresight/coresight-ect.rst b/Documentation/trace/coresight/coresight-ect.rst index 067cee91c857..3539af895832 100644 --- a/Documentation/trace/coresight/coresight-ect.rst +++ b/Documentation/trace/coresight/coresight-ect.rst @@ -71,7 +71,7 @@ capable of generating or using trigger signals.:: >$ ls /sys/bus/coresight/devices/etm0/cti_cpu0 channels ctmid enable nr_trigger_cons mgmt power regs subsystem - triggers0 triggers1 uevent + connections triggers0 triggers1 uevent *Key file items are:-* * ``enable``: enables/disables the CTI. @@ -84,6 +84,9 @@ capable of generating or using trigger signals.:: * ``channels``: Contains the channel API - CTI main programming interface. * ``regs``: Gives access to the raw programmable CTI regs. * ``mgmt``: the standard CoreSight management registers. + * ``connections``: Links to connected *CoreSight* devices. The number of + links can be 0 to ``nr_trigger_cons``. Actual number given by ``nr_links`` + in this directory. triggers directories diff --git a/Documentation/trace/coresight/coresight.rst b/Documentation/trace/coresight/coresight.rst index 108600ee1e12..0b73acb44efa 100644 --- a/Documentation/trace/coresight/coresight.rst +++ b/Documentation/trace/coresight/coresight.rst @@ -241,6 +241,91 @@ to the newer scheme, to give a confirmation that what you see on your system is not unexpected. One must use the "names" as they appear on the system under specified locations. +Topology Representation +----------------------- + +Each CoreSight component has a ``connections`` directory which will contain +links to other CoreSight components. This allows the user to explore the trace +topology and for larger systems, determine the most appropriate sink for a +given source. The connection information can also be used to establish +which CTI devices are connected to a given component. This directory contains a +``nr_links`` attribute detailing the number of links in the directory. + +For an ETM source, in this case ``etm0`` on a Juno platform, a typical +arrangement will be:: + + linaro-developer:~# ls - l /sys/bus/coresight/devices/etm0/connections + cti_cpu0 -> ../../../23020000.cti/cti_cpu0 + nr_links + out:0 -> ../../../230c0000.funnel/funnel2 + +Following the out port to ``funnel2``:: + + linaro-developer:~# ls -l /sys/bus/coresight/devices/funnel2/connections + in:0 -> ../../../23040000.etm/etm0 + in:1 -> ../../../23140000.etm/etm3 + in:2 -> ../../../23240000.etm/etm4 + in:3 -> ../../../23340000.etm/etm5 + nr_links + out:0 -> ../../../20040000.funnel/funnel0 + +And again to ``funnel0``:: + + linaro-developer:~# ls -l /sys/bus/coresight/devices/funnel0/connections + in:0 -> ../../../220c0000.funnel/funnel1 + in:1 -> ../../../230c0000.funnel/funnel2 + nr_links + out:0 -> ../../../20010000.etf/tmc_etf0 + +Finding the first sink ``tmc_etf0``. This can be used to collect data +as a sink, or as a link to propagate further along the chain:: + + linaro-developer:~# ls -l /sys/bus/coresight/devices/tmc_etf0/connections + cti_sys0 -> ../../../20020000.cti/cti_sys0 + in:0 -> ../../../20040000.funnel/funnel0 + nr_links + out:0 -> ../../../20150000.funnel/funnel4 + +via ``funnel4``:: + + linaro-developer:~# ls -l /sys/bus/coresight/devices/funnel4/connections + in:0 -> ../../../20010000.etf/tmc_etf0 + in:1 -> ../../../20140000.etf/tmc_etf1 + nr_links + out:0 -> ../../../20120000.replicator/replicator0 + +and a ``replicator0``:: + + linaro-developer:~# ls -l /sys/bus/coresight/devices/replicator0/connections + in:0 -> ../../../20150000.funnel/funnel4 + nr_links + out:0 -> ../../../20030000.tpiu/tpiu0 + out:1 -> ../../../20070000.etr/tmc_etr0 + +Arriving at the final sink in the chain, ``tmc_etr0``:: + + linaro-developer:~# ls -l /sys/bus/coresight/devices/tmc_etr0/connections + cti_sys0 -> ../../../20020000.cti/cti_sys0 + in:0 -> ../../../20120000.replicator/replicator0 + nr_links + +As described below, when using sysfs it is sufficient to enable a sink and +a source for successful trace. The framework will correctly enable all +intermediate links as required. + +Note: ``cti_sys0`` appears in two of the connections lists above. +CTIs can connect to multiple devices and are arranged in a star topology +via the CTM. See (:doc:`coresight-ect`) [#fourth]_ for further details. +Looking at this device we see 4 connections:: + + linaro-developer:~# ls -l /sys/bus/coresight/devices/cti_sys0/connections + nr_links + stm0 -> ../../../20100000.stm/stm0 + tmc_etf0 -> ../../../20010000.etf/tmc_etf0 + tmc_etr0 -> ../../../20070000.etr/tmc_etr0 + tpiu0 -> ../../../20030000.tpiu/tpiu0 + + How to use the tracer modules -----------------------------