From patchwork Tue Jun 5 21:43:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 925648 Return-Path: X-Original-To: incoming-dt@patchwork.ozlabs.org Delivered-To: patchwork-incoming-dt@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=devicetree-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arm.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 410lmV5qzqz9ry1 for ; Wed, 6 Jun 2018 07:48:26 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752636AbeFEVpF (ORCPT ); Tue, 5 Jun 2018 17:45:05 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:34500 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751780AbeFEVpE (ORCPT ); Tue, 5 Jun 2018 17:45:04 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id CF08680D; Tue, 5 Jun 2018 14:45:03 -0700 (PDT) Received: from en101.cambridge.arm.com (en101.cambridge.arm.com [10.1.206.73]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 54F0E3F59D; Tue, 5 Jun 2018 14:45:01 -0700 (PDT) From: Suzuki K Poulose To: linux-arm-kernel@lists.infradead.org Cc: mathieu.poirier@linaro.org, robh@kernel.org, frowand.list@gmail.com, mark.rutland@arm.com, sudeep.holla@arm.com, arm@kernel.org, linux-kernel@vger.kernel.org, matt.sealey@arm.com, john.horley@arm.com, charles.garcia-tobin@arm.com, coresight@lists.linaro.org, devicetree@vger.kernel.org, mike.leach@linaro.org, Suzuki K Poulose Subject: [PATCH 07/20] coresight: dts: Document usage of graph bindings Date: Tue, 5 Jun 2018 22:43:18 +0100 Message-Id: <1528235011-30691-8-git-send-email-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1528235011-30691-1-git-send-email-suzuki.poulose@arm.com> References: <1528235011-30691-1-git-send-email-suzuki.poulose@arm.com> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Before we update the bindings, document the current graph bindings and usage of additional properties. Cc: Mathieu Poirier Signed-off-by: Suzuki K Poulose Reviewed-by: Mathieu Poirier --- .../devicetree/bindings/arm/coresight.txt | 31 +++++++++++++++++++--- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/Documentation/devicetree/bindings/arm/coresight.txt b/Documentation/devicetree/bindings/arm/coresight.txt index 9aa30a1..ed6b555 100644 --- a/Documentation/devicetree/bindings/arm/coresight.txt +++ b/Documentation/devicetree/bindings/arm/coresight.txt @@ -52,9 +52,7 @@ its hardware characteristcs. clocks the core of that coresight component. The latter clock is optional. - * port or ports: The representation of the component's port - layout using the generic DT graph presentation found in - "bindings/graph.txt". + * port or ports: see "Graph bindings for Coresight" below. * Additional required properties for System Trace Macrocells (STM): * reg: along with the physical base address and length of the register @@ -71,7 +69,7 @@ its hardware characteristcs. AMBA markee): - "arm,coresight-replicator" - * port or ports: same as above. + * port or ports: see "Graph bindings for Coresight" below. * Optional properties for ETM/PTMs: @@ -90,6 +88,31 @@ its hardware characteristcs. * arm,scatter-gather: boolean. Indicates that the TMC-ETR can safely use the SG mode on this system. +Graph bindings for Coresight +------------------------------- + +Coresight components are interconnected to create a data path for the flow of +trace data generated from the "sources" to their collection points "sink". +Each coresight component must describe the "input" and "output" connections. +The connections must be described via generic DT graph bindings as described +by the "bindings/graph.txt", where each "port" along with an "endpoint" +component represents a hardware port and the connection. + +Since it is possible to have multiple connections for any coresight component +with a specific direction of data flow, each connection must define the +following properties to uniquely identify the connection details. + + * Direction of the data flow w.r.t the component : + Each input port must have the following property defined at the "endpoint" + for the port. + "slave-mode" + + * Hardware Port number at the component: + - The hardware port number is assumed to be the address of the "port" + component. + + + Example: 1. Sinks From patchwork Tue Jun 5 21:43:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 925647 Return-Path: X-Original-To: incoming-dt@patchwork.ozlabs.org Delivered-To: patchwork-incoming-dt@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=devicetree-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arm.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 410lmK5f9Dz9s15 for ; Wed, 6 Jun 2018 07:48:17 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752783AbeFEVpI (ORCPT ); Tue, 5 Jun 2018 17:45:08 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:34512 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751780AbeFEVpG (ORCPT ); Tue, 5 Jun 2018 17:45:06 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9287A1596; Tue, 5 Jun 2018 14:45:06 -0700 (PDT) Received: from en101.cambridge.arm.com (en101.cambridge.arm.com [10.1.206.73]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 1895D3F59D; Tue, 5 Jun 2018 14:45:03 -0700 (PDT) From: Suzuki K Poulose To: linux-arm-kernel@lists.infradead.org Cc: mathieu.poirier@linaro.org, robh@kernel.org, frowand.list@gmail.com, mark.rutland@arm.com, sudeep.holla@arm.com, arm@kernel.org, linux-kernel@vger.kernel.org, matt.sealey@arm.com, john.horley@arm.com, charles.garcia-tobin@arm.com, coresight@lists.linaro.org, devicetree@vger.kernel.org, mike.leach@linaro.org, Suzuki K Poulose Subject: [PATCH 08/20] coresight: dts: Cleanup device tree graph bindings Date: Tue, 5 Jun 2018 22:43:19 +0100 Message-Id: <1528235011-30691-9-git-send-email-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1528235011-30691-1-git-send-email-suzuki.poulose@arm.com> References: <1528235011-30691-1-git-send-email-suzuki.poulose@arm.com> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org The coresight drivers relied on default bindings for graph in DT, while reusing the "reg" field of the "ports" to indicate the actual hardware port number for the connections. However, with the rules getting stricter w.r.t to the address mismatch with the label, it is no longer possible to use the port address field for the hardware port number. Hence, we add an explicit property to denote the hardware port number, "coresight,hwid" which must be specified for each "endpoint". Cc: Mathieu Poirier Cc: Sudeep Holla Cc: Rob Herring Signed-off-by: Suzuki K Poulose Reviewed-by: Mathieu Poirier --- .../devicetree/bindings/arm/coresight.txt | 29 ++++++++++--- drivers/hwtracing/coresight/of_coresight.c | 49 +++++++++++++++++----- 2 files changed, 62 insertions(+), 16 deletions(-) diff --git a/Documentation/devicetree/bindings/arm/coresight.txt b/Documentation/devicetree/bindings/arm/coresight.txt index ed6b555..bf75ab3 100644 --- a/Documentation/devicetree/bindings/arm/coresight.txt +++ b/Documentation/devicetree/bindings/arm/coresight.txt @@ -108,8 +108,13 @@ following properties to uniquely identify the connection details. "slave-mode" * Hardware Port number at the component: - - The hardware port number is assumed to be the address of the "port" - component. + - Each "endpoint" must define the hardware port of the local end of the + connection using the following property : + + "coresight,hwid" - 32bit integer, local hardware port. + + - [ ** Obsolete ** ] The hardware port number is assumed to be the address + of the "port" component. @@ -126,6 +131,7 @@ Example: etb_in_port: endpoint@0 { slave-mode; remote-endpoint = <&replicator_out_port0>; + coresight,hwid = <0>; }; }; }; @@ -140,6 +146,7 @@ Example: tpiu_in_port: endpoint@0 { slave-mode; remote-endpoint = <&replicator_out_port1>; + coresight,hwid = <0>; }; }; }; @@ -160,6 +167,7 @@ Example: reg = <0>; replicator_out_port0: endpoint { remote-endpoint = <&etb_in_port>; + coresight,hwid = <0>; }; }; @@ -167,15 +175,17 @@ Example: reg = <1>; replicator_out_port1: endpoint { remote-endpoint = <&tpiu_in_port>; + coresight,hwid = <1>; }; }; /* replicator input port */ port@2 { - reg = <0>; + reg = <1>; replicator_in_port0: endpoint { slave-mode; remote-endpoint = <&funnel_out_port0>; + coresight,hwid = <0>; }; }; }; @@ -197,31 +207,35 @@ Example: funnel_out_port0: endpoint { remote-endpoint = <&replicator_in_port0>; + coresight,hwid = <0>; }; }; /* funnel input ports */ port@1 { - reg = <0>; + reg = <1>; funnel_in_port0: endpoint { slave-mode; remote-endpoint = <&ptm0_out_port>; + coresight,hwid = <0>; }; }; port@2 { - reg = <1>; + reg = <2>; funnel_in_port1: endpoint { slave-mode; remote-endpoint = <&ptm1_out_port>; + coresight,hwid = <1>; }; }; port@3 { - reg = <2>; + reg = <3>; funnel_in_port2: endpoint { slave-mode; remote-endpoint = <&etm0_out_port>; + coresight,hwid = <2>; }; }; @@ -239,6 +253,7 @@ Example: port { ptm0_out_port: endpoint { remote-endpoint = <&funnel_in_port0>; + coresight,hwid = <0>; }; }; }; @@ -253,6 +268,7 @@ Example: port { ptm1_out_port: endpoint { remote-endpoint = <&funnel_in_port1>; + coresight,hwid = <0>; }; }; }; @@ -269,6 +285,7 @@ Example: port { stm_out_port: endpoint { remote-endpoint = <&main_funnel_in_port2>; + coresight,hwid = <0>; }; }; }; diff --git a/drivers/hwtracing/coresight/of_coresight.c b/drivers/hwtracing/coresight/of_coresight.c index d01a9ce..d23d7dd 100644 --- a/drivers/hwtracing/coresight/of_coresight.c +++ b/drivers/hwtracing/coresight/of_coresight.c @@ -99,6 +99,31 @@ int of_coresight_get_cpu(const struct device_node *node) EXPORT_SYMBOL_GPL(of_coresight_get_cpu); /* + * of_coresight_endpoint_get_port_id : Get the hardware port number for the + * given endpoint device node. Prefer the explicit "coresight,hwid" property + * over the endpoint register id (obsolete bindings). + */ +static int of_coresight_endpoint_get_port_id(struct device *dev, + struct device_node *ep_node) +{ + struct of_endpoint ep; + int rc, port_id; + + + if (!of_property_read_u32(ep_node, "coresight,hwid", &port_id)) + return port_id; + + rc = of_graph_parse_endpoint(ep_node, &ep); + if (rc) + return rc; + dev_warn_once(dev, + "ep%d: Mandatory \"coresight,hwid\" property missing.\n", + ep.port); + dev_warn_once(dev, "DT uses obsolete coresight bindings\n"); + return ep.port; +} + +/* * of_coresight_parse_endpoint : Parse the given output endpoint @ep * and fill the connection information in *@pconn. * @@ -109,11 +134,11 @@ EXPORT_SYMBOL_GPL(of_coresight_get_cpu); * 0 - If the parsing completed without any fatal errors. * -Errno - Fatal error, abort the scanning. */ -static int of_coresight_parse_endpoint(struct device_node *ep, +static int of_coresight_parse_endpoint(struct device *dev, + struct device_node *ep, struct coresight_connection **pconn) { - int ret = 0; - struct of_endpoint endpoint, rendpoint; + int ret = 0, local_port, child_port; struct device_node *rparent = NULL; struct device_node *rep = NULL; struct device *rdev = NULL; @@ -128,7 +153,8 @@ static int of_coresight_parse_endpoint(struct device_node *ep, break; /* Parse the local port details */ - if (of_graph_parse_endpoint(ep, &endpoint)) + local_port = of_coresight_endpoint_get_port_id(dev, ep); + if (local_port < 0) break; /* * Get a handle on the remote endpoint and the device it is @@ -140,9 +166,6 @@ static int of_coresight_parse_endpoint(struct device_node *ep, rparent = of_graph_get_port_parent(rep); if (!rparent) break; - if (of_graph_parse_endpoint(rep, &rendpoint)) - break; - /* If the remote device is not available, defer probing */ rdev = of_coresight_get_endpoint_device(rparent); if (!rdev) { @@ -150,9 +173,15 @@ static int of_coresight_parse_endpoint(struct device_node *ep, break; } - conn->outport = endpoint.port; + child_port = of_coresight_endpoint_get_port_id(rdev, rep); + if (child_port < 0) { + ret = 0; + break; + } + + conn->outport = local_port; conn->child_name = dev_name(rdev); - conn->child_port = rendpoint.port; + conn->child_port = child_port; /* Move the connection record */ (*pconn)++; } while (0); @@ -200,7 +229,7 @@ of_get_coresight_platform_data(struct device *dev, ep = of_graph_get_next_endpoint(node, ep); if (!ep) break; - ret = of_coresight_parse_endpoint(ep, &conn); + ret = of_coresight_parse_endpoint(dev, ep, &conn); if (ret) return ERR_PTR(ret); } while (ep); From patchwork Tue Jun 5 21:43:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 925646 Return-Path: X-Original-To: incoming-dt@patchwork.ozlabs.org Delivered-To: patchwork-incoming-dt@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=devicetree-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arm.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 410lmD0Rh6z9s0W for ; Wed, 6 Jun 2018 07:48:12 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753084AbeFEVrp (ORCPT ); Tue, 5 Jun 2018 17:47:45 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:34530 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752800AbeFEVpJ (ORCPT ); Tue, 5 Jun 2018 17:45:09 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 5621515AB; Tue, 5 Jun 2018 14:45:09 -0700 (PDT) Received: from en101.cambridge.arm.com (en101.cambridge.arm.com [10.1.206.73]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id D03E63F59D; Tue, 5 Jun 2018 14:45:06 -0700 (PDT) From: Suzuki K Poulose To: linux-arm-kernel@lists.infradead.org Cc: mathieu.poirier@linaro.org, robh@kernel.org, frowand.list@gmail.com, mark.rutland@arm.com, sudeep.holla@arm.com, arm@kernel.org, linux-kernel@vger.kernel.org, matt.sealey@arm.com, john.horley@arm.com, charles.garcia-tobin@arm.com, coresight@lists.linaro.org, devicetree@vger.kernel.org, mike.leach@linaro.org, Suzuki K Poulose Subject: [PATCH 09/20] coresight: dts: Define new bindings for direction of data flow Date: Tue, 5 Jun 2018 22:43:20 +0100 Message-Id: <1528235011-30691-10-git-send-email-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1528235011-30691-1-git-send-email-suzuki.poulose@arm.com> References: <1528235011-30691-1-git-send-email-suzuki.poulose@arm.com> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org So far we have relied on an undocumented property "slave-mode", to indicate if the given port is input or not. Since we are redefining the coresight bindings, define new property for the "direction" of data flow for a given connection endpoint in the device. Each endpoint must define the following property. - "direction" : 0 => Port is input 1 => Port is output Cc: Sudeep Holla Cc: Rob Herring Cc: Mathieu Poirier Signed-off-by: Suzuki K Poulose Reviewed-by: Mathieu Poirier --- .../devicetree/bindings/arm/coresight.txt | 24 ++++++++++++++-------- drivers/hwtracing/coresight/of_coresight.c | 22 ++++++++++++++++---- 2 files changed, 34 insertions(+), 12 deletions(-) diff --git a/Documentation/devicetree/bindings/arm/coresight.txt b/Documentation/devicetree/bindings/arm/coresight.txt index bf75ab3..ff382bc 100644 --- a/Documentation/devicetree/bindings/arm/coresight.txt +++ b/Documentation/devicetree/bindings/arm/coresight.txt @@ -103,9 +103,11 @@ with a specific direction of data flow, each connection must define the following properties to uniquely identify the connection details. * Direction of the data flow w.r.t the component : - Each input port must have the following property defined at the "endpoint" + Each hardware port must have the following property defined at the "endpoint" for the port. - "slave-mode" + "direction" - 32bit integer, whose values are defined as follows : + 0 => the endpoint is an Input port + 1 => the endpoint is an Output port. * Hardware Port number at the component: - Each "endpoint" must define the hardware port of the local end of the @@ -129,7 +131,7 @@ Example: clock-names = "apb_pclk"; port { etb_in_port: endpoint@0 { - slave-mode; + direction = <0>; remote-endpoint = <&replicator_out_port0>; coresight,hwid = <0>; }; @@ -144,7 +146,7 @@ Example: clock-names = "apb_pclk"; port { tpiu_in_port: endpoint@0 { - slave-mode; + direction = <0>; remote-endpoint = <&replicator_out_port1>; coresight,hwid = <0>; }; @@ -166,6 +168,7 @@ Example: port@0 { reg = <0>; replicator_out_port0: endpoint { + direction = <1>; remote-endpoint = <&etb_in_port>; coresight,hwid = <0>; }; @@ -174,6 +177,7 @@ Example: port@1 { reg = <1>; replicator_out_port1: endpoint { + direction = <1>; remote-endpoint = <&tpiu_in_port>; coresight,hwid = <1>; }; @@ -183,7 +187,7 @@ Example: port@2 { reg = <1>; replicator_in_port0: endpoint { - slave-mode; + direction = <0>; remote-endpoint = <&funnel_out_port0>; coresight,hwid = <0>; }; @@ -205,6 +209,7 @@ Example: port@0 { reg = <0>; funnel_out_port0: endpoint { + direction = <1>; remote-endpoint = <&replicator_in_port0>; coresight,hwid = <0>; @@ -215,7 +220,7 @@ Example: port@1 { reg = <1>; funnel_in_port0: endpoint { - slave-mode; + direction = <0>; remote-endpoint = <&ptm0_out_port>; coresight,hwid = <0>; }; @@ -224,7 +229,7 @@ Example: port@2 { reg = <2>; funnel_in_port1: endpoint { - slave-mode; + direction = <0>; remote-endpoint = <&ptm1_out_port>; coresight,hwid = <1>; }; @@ -233,7 +238,7 @@ Example: port@3 { reg = <3>; funnel_in_port2: endpoint { - slave-mode; + direction = <0>; remote-endpoint = <&etm0_out_port>; coresight,hwid = <2>; }; @@ -252,6 +257,7 @@ Example: clock-names = "apb_pclk"; port { ptm0_out_port: endpoint { + direction = <1>; remote-endpoint = <&funnel_in_port0>; coresight,hwid = <0>; }; @@ -267,6 +273,7 @@ Example: clock-names = "apb_pclk"; port { ptm1_out_port: endpoint { + direction = <1>; remote-endpoint = <&funnel_in_port1>; coresight,hwid = <0>; }; @@ -284,6 +291,7 @@ Example: clock-names = "apb_pclk"; port { stm_out_port: endpoint { + direction = <1>; remote-endpoint = <&main_funnel_in_port2>; coresight,hwid = <0>; }; diff --git a/drivers/hwtracing/coresight/of_coresight.c b/drivers/hwtracing/coresight/of_coresight.c index d23d7dd..0d6e6a9 100644 --- a/drivers/hwtracing/coresight/of_coresight.c +++ b/drivers/hwtracing/coresight/of_coresight.c @@ -45,7 +45,20 @@ of_coresight_get_endpoint_device(struct device_node *endpoint) endpoint, of_dev_node_match); } -static void of_coresight_get_ports(const struct device_node *node, +static bool of_coresight_endpoint_is_input(struct device *dev, + struct device_node *ep_node) +{ + u32 dir; + + if (!of_property_read_u32(ep_node, "direction", &dir)) + return dir == 0; + + dev_warn_once(dev, "Missing mandatory \"direction\" property!\n"); + return of_property_read_bool(ep_node, "slave-mode"); +} + +static void of_coresight_get_ports(struct device *dev, + const struct device_node *node, int *nr_inport, int *nr_outport) { struct device_node *ep = NULL; @@ -56,7 +69,7 @@ static void of_coresight_get_ports(const struct device_node *node, if (!ep) break; - if (of_property_read_bool(ep, "slave-mode")) + if (of_coresight_endpoint_is_input(dev, ep)) in++; else out++; @@ -149,7 +162,7 @@ static int of_coresight_parse_endpoint(struct device *dev, * No need to deal with input ports, processing for as * processing for output ports will deal with them. */ - if (of_find_property(ep, "slave-mode", NULL)) + if (of_coresight_endpoint_is_input(dev, ep)) break; /* Parse the local port details */ @@ -212,7 +225,8 @@ of_get_coresight_platform_data(struct device *dev, pdata->cpu = of_coresight_get_cpu(node); /* Get the number of input and output port for this component */ - of_coresight_get_ports(node, &pdata->nr_inport, &pdata->nr_outport); + of_coresight_get_ports(dev, node, + &pdata->nr_inport, &pdata->nr_outport); /* If there are not output connections, we are done */ if (!pdata->nr_outport)