From patchwork Thu Feb 27 15:14:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Leach X-Patchwork-Id: 11408799 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 BFECE930 for ; Thu, 27 Feb 2020 15:14:45 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9D0A424688 for ; Thu, 27 Feb 2020 15:14:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Sle44k0A"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="khdIi3v/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9D0A424688 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=Sle44k0AxyoWLcP9FtZaetW6Aa frces/5onOS20546fW9GrTPb8dU9pWOIG+FJZX6Oc5Sqwvz6lGJeG0mHVgytA21mLKksuZAiu/qo0 9ZMyl5JZUqWfrozIL3TgCKPZlIYcxXfPftOeo7rkD7TH3ZR8UMbRO9JAJ+p2P1QLTBSuE9xKSUDAG 9GztyiKQS9/le6UbwbkPJaA8bepJ39uHvYCKWlyG3cuLynbVxPUOVnR8o270NG3I75xOxPPz7PlGL Es0JdlP5VSqZx3BCpsJ1+fpSxmFk/q478yBN5w2vIQ6yS4ZPTqCAP5WK21sn3iT8TTSglCsGhnkpb TAUTTIsw==; 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 1j7Ks8-0000HL-Ox; Thu, 27 Feb 2020 15:14:44 +0000 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1j7Krq-0008TC-6r for linux-arm-kernel@lists.infradead.org; Thu, 27 Feb 2020 15:14:27 +0000 Received: by mail-wr1-x443.google.com with SMTP id j7so3752234wrp.13 for ; Thu, 27 Feb 2020 07:14:25 -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=khdIi3v/WjWtTLD5Gano2VoTVsWvfrsrViJoqnSP7ucDvWWlvJfPVTdsh6WzjW/67Y FMhrsAtmF//Jtd4nZiPfZ1XGAauf3b9lftjE4rrN5zpU1ZJpFpVQExVTExi0e/kkHyZK hIZv98mNye2Xef5K6Dxdy1zrCGjz2FhGK/okh1oUBizbUXBLqLQ8o4okxtjLIQWAGdKK wkgHo+zLHv8gj494YvjJLNEjolfDrv0If/EENA/lnihKJ1fuoe8c6rXfNQQhqckqsdF8 V45rEEg+r+4nVfBktesRE7LDXBU60Od3QmY97wrun3Nk5X7xuoO/zfKM94v4bx2Y65ix fmqg== 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=TsNcz+Nt6AmWsbr8OHa7eoRJZOmoOllKJUTbtFLKDznlEYSmAjeINMFCzTqQ+KXZ5o HYuEx4h+fjKrdeE4IWvij6zbLH9OJx8mZ5wOSND2sW7Plvp7nx/mhBh381rsdi4vjPHf keAekYjXn7zc3tVdt00+xNqWyOy8q24zo9LBZEGNSh76mwfPOBvgIErhPysHn3QQ6hWS ySCtJ+iZn0S7YNz9R6XfUInUDVEMjLPpDaWNAHjP2mUbtFTohdXsmyfMNnCaJ7JMjnRR TFWLyx9FEmtPp75Ax0Pq5cqEQPiVQKtKwQT9XmImPCTh/mkFVTbMTNvUt9eQ31lwKlIv gdfg== X-Gm-Message-State: APjAAAVHGuSYkldFwQOE+5uXYtTTyH5g4K4nh2tRG7zRK31DX3TaTZuL I7bAODyybzEAw1Mas9ExKttrap3QODA= X-Google-Smtp-Source: APXvYqw7G49lXA2P4gxjfJf21ybocdc6APkNBAj0GT3OLB8Eq60JRqJWPL/PhU0SAkkIgTe2i/coYA== X-Received: by 2002:a5d:628e:: with SMTP id k14mr5095633wru.425.1582816464072; Thu, 27 Feb 2020 07:14:24 -0800 (PST) Received: from linaro.org ([2a00:23c5:6801:1801:2dc1:e60d:4b1c:70e0]) by smtp.gmail.com with ESMTPSA id q12sm8973079wrg.71.2020.02.27.07.14.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Feb 2020 07:14:22 -0800 (PST) From: Mike Leach To: linux-arm-kernel@lists.infradead.org, coresight@lists.linaro.org, linux-doc@vger.kernel.org Subject: [PATCH v5 1/6] coresight: Pass coresight_device for coresight_release_platform_data Date: Thu, 27 Feb 2020 15:14:11 +0000 Message-Id: <20200227151416.14271-2-mike.leach@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200227151416.14271-1-mike.leach@linaro.org> References: <20200227151416.14271-1-mike.leach@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200227_071426_249017_BA358401 X-CRM114-Status: GOOD ( 14.30 ) 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:443 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_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 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 Thu Feb 27 15:14:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Leach X-Patchwork-Id: 11408801 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 4F1BA14D5 for ; Thu, 27 Feb 2020 15:15: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 2B956246A0 for ; Thu, 27 Feb 2020 15:15:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="YDG9IIG4"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="lGOGYjWv" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2B956246A0 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=YDG9IIG4nLNaxfAO+I+v0oXTHu UWlkFLyNr/KjvgQZTvJydIQu/KwcFsFCzWbhsRiiFzd66zUSk4PEcDgGRLdBA694MpNvDM2aTcnja HY2bmTbqMRsfY9VL9KPveYioZX8XvYv6ButsvmMLyLZnFGtuJ/fdonVJs8diCA7jxmiNEsyZDahCs ezM/xHY9qELMhrAgkpNMemiL7fRDNI6PacxoaWmiyVhLdiLWF5vvQQ22eJW2FDQmG1Aa1NmF9sTVA 7kfvCYLqyWg++iao4QEJYTmJLoWk2sTzKGAIrn0b7UStQsFF5xvytTkutYXu17QgZ7ZBDMEEnZ3sY mQmA6vQQ==; 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 1j7KsN-0000UW-So; Thu, 27 Feb 2020 15:14:59 +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 1j7Krs-0008Tz-FJ for linux-arm-kernel@lists.infradead.org; Thu, 27 Feb 2020 15:14:30 +0000 Received: by mail-wm1-x342.google.com with SMTP id a5so4009235wmb.0 for ; Thu, 27 Feb 2020 07:14:28 -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=lGOGYjWvFOg5M7k/ms9JmHqQgpQVC7X0oYBJEB//CU9OsCJN4upV5cCx1JyNlYNmoK +2/VWclnq2fLHGSksfR/kk1si2RuNqpN4MSlKHY+S3YGG6Wtt7wBOHoGz4x+sV0+peNA 68IkLY9eVo9OO72IpECg5g7C3kgB2suzsDZj3W7m8z40sLrqEnQt3Heg5dnhRznvyDYf ZE3v2GJcrfkvvcLLbG++nDePiS0GN3NuRMuCReW0IkYSWaY0diAP1t6bYCjOcR+HC/4n lHwRagy9/WbFVYPRJZ3Y7D1zMqayfIscWQ94wsZdbSog2vGFoc6CXQPt7waz1OVeVL6Q SmDw== 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=hZxshl4GQW8MNMXJrzotj3ekrDHACb2EJKeE7FF6/HzLtKZOhrm+fnTWbzCu9apEB/ W+2bZog2ldBg6tFofbq2GVTODn0eW8ZM//VM8870TfIoJCT4lOkN0IrLgSNdpHC4uroN XkyR7mrVP8E8uEDKkMeZu4eqaa9LIl2tAnX2NpM2avQueA6Ad2PUcL6HPd4k6nmLoxg0 0Imbq+HB36frJppg0WlGqYnqPPUy+1En7dnCYkl1qFOUKF+QH9QLXNgYPKOUbbesJcSa akbmmrIfcB2mYvzj0ZfCJP2UiSVn4vKiGvfaXDu6c6rANrVMaXANFRqBw/zquIQNK5iW YvPQ== X-Gm-Message-State: APjAAAVMM3Q8ZPgC0eWEZdAwMcZfvnwXAQ2gSdGwGehJPs7BW5fMgiwl rumK1kwsKK6TzQESb+kFfA2K94kti9s= X-Google-Smtp-Source: APXvYqwYNvy4x4HObXIRykQWd9hrfXmoR5SHd1J2lIy8mUwfXFz0d5C40E8G9rnmVv6gED5f0qfCzA== X-Received: by 2002:a1c:dd87:: with SMTP id u129mr5846805wmg.111.1582816465696; Thu, 27 Feb 2020 07:14:25 -0800 (PST) Received: from linaro.org ([2a00:23c5:6801:1801:2dc1:e60d:4b1c:70e0]) by smtp.gmail.com with ESMTPSA id q12sm8973079wrg.71.2020.02.27.07.14.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Feb 2020 07:14:24 -0800 (PST) From: Mike Leach To: linux-arm-kernel@lists.infradead.org, coresight@lists.linaro.org, linux-doc@vger.kernel.org Subject: [PATCH v5 2/6] coresight: add return value for fixup connections Date: Thu, 27 Feb 2020 15:14:12 +0000 Message-Id: <20200227151416.14271-3-mike.leach@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200227151416.14271-1-mike.leach@linaro.org> References: <20200227151416.14271-1-mike.leach@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200227_071428_547948_2557B841 X-CRM114-Status: GOOD ( 14.00 ) 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_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_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 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 Thu Feb 27 15:14:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Leach X-Patchwork-Id: 11408803 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 B040014D5 for ; Thu, 27 Feb 2020 15:15:29 +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 8A40324688 for ; Thu, 27 Feb 2020 15:15:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="r+iF5g5I"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="yUhrzFw2" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8A40324688 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=gpMZHGjI8JgjVOR25caR5wbowemrKz1GmyNcsh12sZ8=; b=r+iF5g5I36nuR3zzIV1go0itn/ 4gcJsI7vh+5EdTN41BLhxMNKN6FeqX+WY0kXBbUUs2n9D473HzRO5tRDVKHI5Ip2GNW9a0xU6qktz 3UX/8m/+P77/Iq0MZsPFJUnNSCNLuqfV3YZt2Hu7rPIjLaa+3iZBXPQBqrS5bj6NeUcebEKRFM5AV LfiE4+UnTW7dZVF2/4EX17Bb0HlsNm9Xwqh2m4imU7RmxY+Oi1uVQU1RHO3h20rD6JXpHLdsRjPDI j/ZPUFsC/glpBQ722y0HhPAnkCw/i8hoHtU+EwuQGiX00rkcXwWNA+4bNmx4Ywj1p0XWQEKJIVApx vOo2XeyA==; 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 1j7Kso-00021b-TO; Thu, 27 Feb 2020 15:15:26 +0000 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1j7Kru-0008VT-GN for linux-arm-kernel@lists.infradead.org; Thu, 27 Feb 2020 15:14:32 +0000 Received: by mail-wm1-x344.google.com with SMTP id a5so4009345wmb.0 for ; Thu, 27 Feb 2020 07:14:29 -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=aTDBzI1XIx/lCwvz5NfAj4LMnLcoxC6x80PetPnO3r0=; b=yUhrzFw2SPQAAyNL6r+o0pfXf+cP/0hDZG5rLfDyMhYX5BtxfzM1BxRO2mgF2q7/QN Kasf0zMc7pfGMMB/Q7nLq+4S9oav0Wp3dpRF9QjOxAuHIgvNEY1EcT7XVL/ZRSD61qKU gW0C/zxCsylA2t4SuSzO0gGPuUrDg2e7x/6qs9SpxZWA2QejAkogv0VFoydNNKeGV1cn k69/XCc5Al46kb4S4B3UIydwLGYYjmfJ1YOHKf/fzjZh6eFZaaX5bXSk8mhOskLddaya SXjLct5SXgpMg1wdVOLg6gAohDMJvW5qX9YcQZlsajKG2UUKkdN4tvO3z66D1iR0CBYz vU3A== 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=aTDBzI1XIx/lCwvz5NfAj4LMnLcoxC6x80PetPnO3r0=; b=t7StI48zHl8/YppqKKw+6SJmZb2N2cYLwS7bU2X7YxzG1R6eYgQMk3+IBjpL2IZomU aoHVeNeSX3H4MhhpZ13tycbSgVnLdE5EHgvFDSdpyP/zM/pxZ/CcDiKrhHMjUHbyNUe7 By4rbbNeGKAPNNmKKmBiy9BGjMK6Ze/63RpXGHxbe8Pjpb7PWs4Ejv9RAiskE0tFsHeA miSeGYrPwgR9QRI+oN0t/hGzWR5OzpkFstqIV5Ikkm6BSUGd/RzzKy867k83jssPzDC7 XFG4Ij12eg9GDTUNUU7jS+h3uWaDFaCOp1moc3KkOOPjcQOX/xF3KBhwUQp4gr1mZFpP 21dQ== X-Gm-Message-State: APjAAAU1JdiDrOzyI75IbNzOdF4uaW3YeGfaT1h0rzkYr/9siLMHtuKm bY/ttOotPCBRGJIjK+a5GZIVnV5QWZI= X-Google-Smtp-Source: APXvYqwif1iRQrupH6jmi5KHHZRUMYrZW46xuTCHun48dnOu77CziodNXre5xSQXbN61jclIulFqZg== X-Received: by 2002:a1c:f71a:: with SMTP id v26mr5858539wmh.85.1582816467932; Thu, 27 Feb 2020 07:14:27 -0800 (PST) Received: from linaro.org ([2a00:23c5:6801:1801:2dc1:e60d:4b1c:70e0]) by smtp.gmail.com with ESMTPSA id q12sm8973079wrg.71.2020.02.27.07.14.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Feb 2020 07:14:26 -0800 (PST) From: Mike Leach To: linux-arm-kernel@lists.infradead.org, coresight@lists.linaro.org, linux-doc@vger.kernel.org Subject: [PATCH v5 3/6] coresight: Add generic sysfs link creation functions Date: Thu, 27 Feb 2020 15:14:13 +0000 Message-Id: <20200227151416.14271-4-mike.leach@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200227151416.14271-1-mike.leach@linaro.org> References: <20200227151416.14271-1-mike.leach@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200227_071430_573643_0CA772D6 X-CRM114-Status: GOOD ( 19.46 ) 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:344 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_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 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 Thu Feb 27 15:14:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Leach X-Patchwork-Id: 11408805 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 73B941805 for ; Thu, 27 Feb 2020 15:15:40 +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 3826924688 for ; Thu, 27 Feb 2020 15:15:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Yj5I+uF0"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="YMPyLRAG" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3826924688 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=icaHb2xzguf/KTW1l7Fy8lwdMIvI7cFtcbeSOD1PL64=; b=Yj5I+uF0LU5uGiYpbBdsywmSbD DaM7bfnl1sQZx132+pJkNEbiwl6dQprfEjH4kPHVCaLzRK7U73r9ILQkcwzuerpoQ0O6xTIttcWQP By5N+kKqdEf33nyh6NZQ42rxCTsJFWfhOLx//eHn+oZ3h1oBU8qdutOG74GZ6W7mB1kunkRNe14fB TvBu5gAK22Wk61M75tJAR/+LPfLwq21M/R+75j7xUp+/95y/4phDIL8m1ibICZKDotzpo83onTnnd 0vnVCur5Pv0/ywlkX+PpGmBzv5E7ko4ocDEI/Qhv4PnPTnzlbMq4L23NT7NbTA3SbAsUhqaRPQtUO tU6pcscA==; 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 1j7Kt1-0002E3-0m; Thu, 27 Feb 2020 15:15:39 +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 1j7Krw-00006A-Pg for linux-arm-kernel@lists.infradead.org; Thu, 27 Feb 2020 15:14:34 +0000 Received: by mail-wm1-x341.google.com with SMTP id p9so4000584wmc.2 for ; Thu, 27 Feb 2020 07:14:32 -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=Rt0xhGGUlUAKc3IBeyv6F9CRc9Aupi/oWjn2J6IKFo4=; b=YMPyLRAGDb2HhIwGvLU+EBQ7vhzdxm4xWeiszH65LkvnrmQ//Xsija93Kyt2T8dO8L esqbHbpczx23UaI00JWYMkBdfKCMjuSZ+DUDY+tHvmwaauWJlJr0NWv4SkjvCnZtb6Ns m6uATIadIDOv7YhoXl2vvFxbGYZdxdQhLYp4OHS+ScSnlIllJPJgtJYWbOd+MYnNgUWe Ud8YkDy3fpzkYLfEPIchfrkCi5ysm4bI9xfoTGY661F5vJPHOEetNvP49VBObQvRHbVT diimQOZ4SIvgz6RZv1N7TZ+mqlD0S+yFcEHYtZG+yvCK7kW+NNUV8ptancc+wnXWvfNS Z1IQ== 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=Rt0xhGGUlUAKc3IBeyv6F9CRc9Aupi/oWjn2J6IKFo4=; b=Me/sAhWGkboEq5DODVVjbhSC8tEZNY4jsfq9b3PKpqsF+xanBLNIF2OWhePmmD4LTg V4bVb2peqPMz5DW6gYQgJOMtJAEgLW+1YNjeEkci9bUzS2yfV+b1+/QsFcrVO0ZAGcq3 MzMnd82KWaFfLE+lRDcYX1uf8RfXLrImXMRrencBTSJ7VJ042OGkZbNWmgqsSoFBPoPf AaM1Wb3jGUY3auXWqRZbRvLLJ1g3E8pL63qrgO2LudAUJUT2AUX29Y0rInbr1bc0kgOn VNg89qSB7nkODiYLznvY0FO40/EfPeAAXl3C8OsdyCNQ4rKU9mABtoAKxHnO+qlY0Pad kcoA== X-Gm-Message-State: APjAAAXXOisulISFHy7hheb7PLR6C3gtIgktNIRlEQBwYdUAO6zQ+bpw l7/nq3Qql1egjMQizZwECaBIAxH54og= X-Google-Smtp-Source: APXvYqz6tzX6TzVBLCA2VFnY/RJSCjdAT8KtR1tom8r4KyPlkbCXtkdYWLNDSMime7iWPJIgnDfk+g== X-Received: by 2002:a7b:c119:: with SMTP id w25mr16187wmi.112.1582816470077; Thu, 27 Feb 2020 07:14:30 -0800 (PST) Received: from linaro.org ([2a00:23c5:6801:1801:2dc1:e60d:4b1c:70e0]) by smtp.gmail.com with ESMTPSA id q12sm8973079wrg.71.2020.02.27.07.14.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Feb 2020 07:14:28 -0800 (PST) From: Mike Leach To: linux-arm-kernel@lists.infradead.org, coresight@lists.linaro.org, linux-doc@vger.kernel.org Subject: [PATCH v5 4/6] coresight: Expose device connections via sysfs Date: Thu, 27 Feb 2020 15:14:14 +0000 Message-Id: <20200227151416.14271-5-mike.leach@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200227151416.14271-1-mike.leach@linaro.org> References: <20200227151416.14271-1-mike.leach@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200227_071432_904977_9A55FCC6 X-CRM114-Status: GOOD ( 24.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:341 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_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 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 in each device to hold the links. Co-developed-by: Mike Leach Signed-off-by: Mike Leach Reviewed-by: Mathieu Poirier --- 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 Thu Feb 27 15:14:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Leach X-Patchwork-Id: 11408807 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 2EB5592A for ; Thu, 27 Feb 2020 15:15:52 +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 F1FE424688 for ; Thu, 27 Feb 2020 15:15:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="t/IPBV3d"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="wBIa5+lk" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F1FE424688 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=+urIkUnZXlyn6tPMkxWre+4O4jXHOfCuzHXyDgip+d0=; b=t/IPBV3dXGggIcD4BtSAXDttQk sLcVKuY+qKW1y+amK85UJNzybzniYF74a006HKngCStRM/whcgLDaENRTBNzKPyC5lVbIPYZgW58r PsRsNv8aJkxejf++nP2UPRRdZc1Iormd87lsLAcW1XpsJ9R9VLxA2LKTwozrWSpoCgtAUfzBWAl9j kV3OcBDT8G1uuGgeR0VAs8JyW9FnE1xkRU2iZbMN2N9dmTIvvIEKXNEhvriit2lA4pvh2AhYYb/Gw 8SNg1TPJksgc+V2P5HF0oE3nx3R6UpWViu+KPLjw9WIHCEx4CzSl77qe5ehVbpQ915HIkBOWxwdZR WweMRmYA==; 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 1j7KtD-0002T8-0z; Thu, 27 Feb 2020 15:15:51 +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 1j7Kry-00007n-Io for linux-arm-kernel@lists.infradead.org; Thu, 27 Feb 2020 15:14:36 +0000 Received: by mail-wm1-x343.google.com with SMTP id f19so1707075wmh.1 for ; Thu, 27 Feb 2020 07:14:34 -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=vhTfl79n9jE2DgXDY2nDtsHQSi/ayZitWxYC2DEPQGI=; b=wBIa5+lk9iIYCjNMcn6f1N3lnW5EuWlHDIRvMpMHapeoN57BZdvLS2Mxfb10vIvANx T73l3ZhrAiOhld5eWb9sG5hZKFSXiG7QYTsFbj6lyKfUFzPYlcqKrRnG4PvTUkrXK0gV yGM7mMaqSbK87Hs+w3/1AqWZsLXLdfEQ0hQ5Tqrd3SVsb9yJF9ay0F0P+ySqpFEbuLfZ h4ve1qjTiZ1cJqgYKxM6pz7140+ZimtERut9mX2prXYklr3tY/tL5mQ5HK/HhYulNVxo iFQcHAXCiTxFE/sDHYsHYf+ZO2wEQhFRtBybM3Xtve23Q+o3W21UlNR/FoybtJEiVHzV W8mg== 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=vhTfl79n9jE2DgXDY2nDtsHQSi/ayZitWxYC2DEPQGI=; b=b/JLhrvcp/xwZm0RtzxCowvBrfnIwGkT8CoBiWSgAI8yZEoo00Tkz7Afc/S224QhtY FQAzDXjftJXMFpHcgGtR0xMeofhnfnlVZXWR/S7eV0jhF/sfzq6SEVGqMxcAr8LTJ+kE a/W8R+ztWdgiyAvJiWX6qzL+RIzghWDid2OZc5WFTe77w/7lt6yQI/IFZAqZlPdulJ9+ AMVnbQrCXqFAN7mcKtp/JAGdF3MRVmXZauGAiR+VTcgY8HogIQ2APezPCgQ0Zx0JiYoH U0XPzHHPlp2rSzC+QkvTRgnERmbE04caLDf34Tdddww3/SvxLVQJyttRMSJHW0Ob2Nkl fEoA== X-Gm-Message-State: APjAAAUQFPChhLuKH64WYb8RQ18u+DBjd6j47bB47oNMxx5SE/zl+FX9 ZYsDmQGh7cPpvd327QXmC6eNf9OwuHQ= X-Google-Smtp-Source: APXvYqw4jKtA+AOitpttxRTf2Q5Jgjrntsjt2hAMESAge0Jsw/yJx1debLxfpyIIEKpiX7mDYkYfTQ== X-Received: by 2002:a7b:cd14:: with SMTP id f20mr5634452wmj.43.1582816472373; Thu, 27 Feb 2020 07:14:32 -0800 (PST) Received: from linaro.org ([2a00:23c5:6801:1801:2dc1:e60d:4b1c:70e0]) by smtp.gmail.com with ESMTPSA id q12sm8973079wrg.71.2020.02.27.07.14.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Feb 2020 07:14:30 -0800 (PST) From: Mike Leach To: linux-arm-kernel@lists.infradead.org, coresight@lists.linaro.org, linux-doc@vger.kernel.org Subject: [PATCH v5 5/6] coresight: cti: Add in sysfs links to other coresight devices Date: Thu, 27 Feb 2020 15:14:15 +0000 Message-Id: <20200227151416.14271-6-mike.leach@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200227151416.14271-1-mike.leach@linaro.org> References: <20200227151416.14271-1-mike.leach@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200227_071434_632977_D9AACEDA X-CRM114-Status: GOOD ( 15.95 ) 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: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_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 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 --- drivers/hwtracing/coresight/coresight-cti.c | 52 +++++++++++++++++++-- 1 file changed, 48 insertions(+), 4 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-cti.c b/drivers/hwtracing/coresight/coresight-cti.c index aa6e0249bd70..9e262f5a85e3 100644 --- a/drivers/hwtracing/coresight/coresight-cti.c +++ b/drivers/hwtracing/coresight/coresight-cti.c @@ -442,6 +442,34 @@ int cti_channel_setop(struct device *dev, enum cti_chan_set_op op, return err; } +static bool cti_add_sysfs_link(struct cti_drvdata *drvdata, + struct cti_trig_con *tc) +{ + struct coresight_sysfs_link link_info; + int link_err = 0; + + 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); + + link_err = coresight_add_sysfs_link(&link_info); + if (link_err) + dev_warn(&drvdata->csdev->dev, + "Failed to set CTI sysfs link %s<=>%s\n", + link_info.orig_name, link_info.target_name); + return !link_err; +} + +static void cti_remove_sysfs_link(struct cti_trig_con *tc) +{ + struct coresight_sysfs_link link_info; + + link_info.orig_name = tc->con_dev_name; + link_info.target = tc->con_dev; + 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 +480,8 @@ cti_match_fixup_csdev(struct cti_device *ctidev, const char *node_name, struct coresight_device *csdev) { struct cti_trig_con *tc; + 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) { @@ -459,7 +489,12 @@ cti_match_fixup_csdev(struct cti_device *ctidev, const char *node_name, /* match: so swap in csdev name & dev */ tc->con_dev_name = dev_name(&csdev->dev); tc->con_dev = csdev; - return true; + /* try to set sysfs link */ + if (cti_add_sysfs_link(drvdata, tc)) + return true; + /* link failed - remove CTI reference */ + tc->con_dev = NULL; + break; } } } @@ -522,6 +557,7 @@ void cti_remove_assoc_from_csdev(struct coresight_device *csdev) ctidev = &ctidrv->ctidev; list_for_each_entry(tc, &ctidev->trig_cons, node) { if (tc->con_dev == csdev->ect_dev) { + cti_remove_sysfs_link(tc); tc->con_dev = NULL; break; } @@ -543,10 +579,16 @@ 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) - /* set tc->con_dev->ect_dev */ - coresight_set_assoc_ectdev_mutex(tc->con_dev, + if (tc->con_dev) { + /* if we can set the sysfs link */ + if (cti_add_sysfs_link(drvdata, tc)) + /* set the CTI/csdev association */ + coresight_set_assoc_ectdev_mutex(tc->con_dev, drvdata->csdev); + else + /* otherwise remove reference from CTI */ + tc->con_dev = NULL; + } } } @@ -559,6 +601,8 @@ static void cti_remove_conn_xrefs(struct cti_drvdata *drvdata) if (tc->con_dev) { coresight_set_assoc_ectdev_mutex(tc->con_dev, NULL); + cti_remove_sysfs_link(tc); + tc->con_dev = NULL; } } } From patchwork Thu Feb 27 15:14:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Leach X-Patchwork-Id: 11408809 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 0C72692A for ; Thu, 27 Feb 2020 15:16:13 +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 DE5AF24688 for ; Thu, 27 Feb 2020 15:16:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Xtd65H7/"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="n3dfJoV3" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DE5AF24688 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=XPcfNoJ5XiFFgT1kSHuZxm8OHc7I5z4vRKqD2OxQfME=; b=Xtd65H7/FolFkqahQT5tgM9s5X 3BPzldKpkaJhFw3JuKegWrcEMOZY4Ziwpiy4SKjwbNUzYiGPEB80Xk6V6p45BPdl8irfm0UOreLq6 ybt7kw0LhTnipnIgVt2DJeokhs9/ICbC3am5O9T1HI+iFHgEH5+aikm6kx6ScHxiiblxOTixh1mSr K+6c8BQhx9VhC09k5yqhDoQ5pWYD+pB2NIcww9rN0P0fOetnv5pAD8Cchhi6x3qHnxc+Teh122Inm jh5ONDF0v6BiyOONa6KwFoQjwmLEH41Q1rIhGT5O5lCRCuw71ZDmwimK4Hm8zGLoqZSOHeVzatGOy O4XZCG/g==; 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 1j7KtX-0002lb-Hg; Thu, 27 Feb 2020 15:16:11 +0000 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1j7Ks0-00008q-IX for linux-arm-kernel@lists.infradead.org; Thu, 27 Feb 2020 15:14:38 +0000 Received: by mail-wm1-x333.google.com with SMTP id a5so4009723wmb.0 for ; Thu, 27 Feb 2020 07:14:35 -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=0dvq0TIvLIhYW6FRHb2k6j4t1FaEUBN90K81y+vKrss=; b=n3dfJoV3D6qtoScNIKFTLoXkidqgBL9BgtF6Y4SweATy7nHjRMGikNNWjPH/JLrt2g 5hWx1D+DIFycvH62F1+p8Ie8w8AfTz821Uzb0TAbtnFxUJw+q4URbDYjG84wx8Ue32iE 0jb5//mN0QFp334ZGFkDA2WJnMNoHOwcelt+NLw5t55RbTzKMNIkin2cFMv6b5JzWzr0 rwbII38y+SkKSK7a/KiX6l882RelEgCAAHH/7LEWEW2K1A2Ni90sUAbwmrIOrlswEP0b A8fpW1MzM+diCyT4l5bhEdp9Q04oS9OUWKS1Ue0/uW8FVdpDrLp9hLcw0443S9oWLpaX Be9A== 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=0dvq0TIvLIhYW6FRHb2k6j4t1FaEUBN90K81y+vKrss=; b=UgamWFrB8hFpTzmsxDiM4/y7dwmb97VviMeJUKMSw23pNDVXobs/tQm3dDnoJGW3uP 3od5Lak7QJNVEhpvtUle0Ga2nQQtlHkmdZ7BmHElQ9ZY+HIM1KLrCGi5EYudM1MLbcms 76u5R48rPiJtGG46sQHVTDfDMu+iHOhdWKHXQlMJmrGGax1PhUOdifnmKEbc07bGU0J3 glejTDbCxv7OnPJj0pegyZii48T5NguxawipaejLaSDWcO+04F7+RKi9RVkvSqZ9lQER XXr85OD5BDRbRZFZRsvq8y4hsxGpIXZvRLTByKC+XS/PXi1mMHZ9hnDkBtRMGDi22zWT bxow== X-Gm-Message-State: APjAAAWTNZmVr7G3MoNxjPk/XwzFSsJGiTYQx47kih5g2vrAZEYhj4si sMnO1btazHl0YW5uGdeXgbyNSSlQMFg= X-Google-Smtp-Source: APXvYqzyZ0jyt4lFW5kshD8LLCN+heer9j/vnrZt0b0UOmMwmVFlpTvo+3iTRCXmNrQPH0rFQ8WXmg== X-Received: by 2002:a05:600c:149:: with SMTP id w9mr10823wmm.132.1582816473630; Thu, 27 Feb 2020 07:14:33 -0800 (PST) Received: from linaro.org ([2a00:23c5:6801:1801:2dc1:e60d:4b1c:70e0]) by smtp.gmail.com with ESMTPSA id q12sm8973079wrg.71.2020.02.27.07.14.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Feb 2020 07:14:32 -0800 (PST) From: Mike Leach To: linux-arm-kernel@lists.infradead.org, coresight@lists.linaro.org, linux-doc@vger.kernel.org Subject: [PATCH v5 6/6] coresight: docs: Add information about the topology representations Date: Thu, 27 Feb 2020 15:14:16 +0000 Message-Id: <20200227151416.14271-7-mike.leach@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200227151416.14271-1-mike.leach@linaro.org> References: <20200227151416.14271-1-mike.leach@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200227_071436_634868_6B9DF351 X-CRM114-Status: GOOD ( 15.76 ) 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:333 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_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 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 -----------------------------