From nobody Wed Sep 10 11:03:50 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5108BC77B73 for ; Tue, 25 Apr 2023 14:37:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234184AbjDYOhX (ORCPT ); Tue, 25 Apr 2023 10:37:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233910AbjDYOgm (ORCPT ); Tue, 25 Apr 2023 10:36:42 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 42A60B463 for ; Tue, 25 Apr 2023 07:36:35 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 02887FEC; Tue, 25 Apr 2023 07:37:19 -0700 (PDT) Received: from localhost.localdomain (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 714E83F587; Tue, 25 Apr 2023 07:36:33 -0700 (PDT) From: James Clark To: coresight@lists.linaro.org, quic_jinlmao@quicinc.com, mike.leach@linaro.org, suzuki.poulose@arm.com Cc: James Clark , Leo Yan , Alexander Shishkin , Mathieu Poirier , Greg Kroah-Hartman , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 05/13] coresight: Rename connection members to make the direction explicit Date: Tue, 25 Apr 2023 15:35:32 +0100 Message-Id: <20230425143542.2305069-6-james.clark@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230425143542.2305069-1-james.clark@arm.com> References: <20230425143542.2305069-1-james.clark@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" When input connections are added they will use the same connection object as the output so parent and child could be misinterpreted. Making the direction unambiguous in the names should improve readability. Reviewed-by: Mike Leach Signed-off-by: James Clark --- drivers/hwtracing/coresight/coresight-core.c | 51 +++++++++---------- .../hwtracing/coresight/coresight-platform.c | 30 +++++------ drivers/hwtracing/coresight/coresight-sysfs.c | 10 ++-- .../hwtracing/coresight/coresight-tmc-etr.c | 2 +- include/linux/coresight.h | 18 +++---- 5 files changed, 55 insertions(+), 56 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtraci= ng/coresight/coresight-core.c index 0f6712a6fba3..f3dc320b374c 100644 --- a/drivers/hwtracing/coresight/coresight-core.c +++ b/drivers/hwtracing/coresight/coresight-core.c @@ -120,8 +120,8 @@ static int coresight_find_link_inport(struct coresight_= device *csdev, =20 for (i =3D 0; i < parent->pdata->nr_outconns; i++) { conn =3D &parent->pdata->out_conns[i]; - if (conn->child_dev =3D=3D csdev) - return conn->child_port; + if (conn->dest_dev =3D=3D csdev) + return conn->dest_port; } =20 dev_err(&csdev->dev, "couldn't find inport, parent: %s, child: %s\n", @@ -138,8 +138,8 @@ static int coresight_find_link_outport(struct coresight= _device *csdev, =20 for (i =3D 0; i < csdev->pdata->nr_outconns; i++) { conn =3D &csdev->pdata->out_conns[i]; - if (conn->child_dev =3D=3D child) - return conn->outport; + if (conn->dest_dev =3D=3D child) + return conn->src_port; } =20 dev_err(&csdev->dev, "couldn't find outport, parent: %s, child: %s\n", @@ -606,7 +606,7 @@ coresight_find_enabled_sink(struct coresight_device *cs= dev) for (i =3D 0; i < csdev->pdata->nr_outconns; i++) { struct coresight_device *child_dev; =20 - child_dev =3D csdev->pdata->out_conns[i].child_dev; + child_dev =3D csdev->pdata->out_conns[i].dest_dev; if (child_dev) sink =3D coresight_find_enabled_sink(child_dev); if (sink) @@ -722,7 +722,7 @@ static int coresight_grab_device(struct coresight_devic= e *csdev) for (i =3D 0; i < csdev->pdata->nr_outconns; i++) { struct coresight_device *child; =20 - child =3D csdev->pdata->out_conns[i].child_dev; + child =3D csdev->pdata->out_conns[i].dest_dev; if (child && child->type =3D=3D CORESIGHT_DEV_TYPE_HELPER) if (!coresight_get_ref(child)) goto err; @@ -733,7 +733,7 @@ static int coresight_grab_device(struct coresight_devic= e *csdev) for (i--; i >=3D 0; i--) { struct coresight_device *child; =20 - child =3D csdev->pdata->out_conns[i].child_dev; + child =3D csdev->pdata->out_conns[i].dest_dev; if (child && child->type =3D=3D CORESIGHT_DEV_TYPE_HELPER) coresight_put_ref(child); } @@ -752,7 +752,7 @@ static void coresight_drop_device(struct coresight_devi= ce *csdev) for (i =3D 0; i < csdev->pdata->nr_outconns; i++) { struct coresight_device *child; =20 - child =3D csdev->pdata->out_conns[i].child_dev; + child =3D csdev->pdata->out_conns[i].dest_dev; if (child && child->type =3D=3D CORESIGHT_DEV_TYPE_HELPER) coresight_put_ref(child); } @@ -794,7 +794,7 @@ static int _coresight_build_path(struct coresight_devic= e *csdev, for (i =3D 0; i < csdev->pdata->nr_outconns; i++) { struct coresight_device *child_dev; =20 - child_dev =3D csdev->pdata->out_conns[i].child_dev; + child_dev =3D csdev->pdata->out_conns[i].dest_dev; if (child_dev && _coresight_build_path(child_dev, sink, path) =3D=3D 0) { found =3D true; @@ -964,7 +964,7 @@ coresight_find_sink(struct coresight_device *csdev, int= *depth) struct coresight_device *child_dev, *sink =3D NULL; int child_depth =3D curr_depth; =20 - child_dev =3D csdev->pdata->out_conns[i].child_dev; + child_dev =3D csdev->pdata->out_conns[i].dest_dev; if (child_dev) sink =3D coresight_find_sink(child_dev, &child_depth); =20 @@ -1337,12 +1337,12 @@ static int coresight_orphan_match(struct device *de= v, void *data) conn =3D &i_csdev->pdata->out_conns[i]; =20 /* Skip the port if FW doesn't describe it */ - if (!conn->child_fwnode) + if (!conn->dest_fwnode) continue; /* We have found at least one orphan connection */ - if (conn->child_dev =3D=3D NULL) { + if (conn->dest_dev =3D=3D NULL) { /* Does it match this newly added device? */ - if (conn->child_fwnode =3D=3D csdev->dev.fwnode) { + if (conn->dest_fwnode =3D=3D csdev->dev.fwnode) { ret =3D coresight_make_links(i_csdev, conn, csdev); if (ret) @@ -1377,13 +1377,12 @@ static int coresight_fixup_device_conns(struct core= sight_device *csdev) for (i =3D 0; i < csdev->pdata->nr_outconns; i++) { struct coresight_connection *conn =3D &csdev->pdata->out_conns[i]; =20 - if (!conn->child_fwnode) + if (!conn->dest_fwnode) continue; - conn->child_dev =3D - coresight_find_csdev_by_fwnode(conn->child_fwnode); - if (conn->child_dev && conn->child_dev->has_conns_grp) { - ret =3D coresight_make_links(csdev, conn, - conn->child_dev); + conn->dest_dev =3D + coresight_find_csdev_by_fwnode(conn->dest_fwnode); + if (conn->dest_dev && conn->dest_dev->has_conns_grp) { + ret =3D coresight_make_links(csdev, conn, conn->dest_dev); if (ret) break; } else { @@ -1414,14 +1413,14 @@ static int coresight_remove_match(struct device *de= v, void *data) for (i =3D 0; i < iterator->pdata->nr_outconns; i++) { conn =3D &iterator->pdata->out_conns[i]; =20 - if (conn->child_dev =3D=3D NULL || conn->child_fwnode =3D=3D NULL) + if (conn->dest_dev =3D=3D NULL || conn->dest_fwnode =3D=3D NULL) continue; =20 - if (csdev->dev.fwnode =3D=3D conn->child_fwnode) { + if (csdev->dev.fwnode =3D=3D conn->dest_fwnode) { iterator->orphan =3D true; coresight_remove_links(iterator, conn); =20 - conn->child_dev =3D NULL; + conn->dest_dev =3D NULL; /* No need to continue */ break; } @@ -1547,15 +1546,15 @@ void coresight_release_platform_data(struct coresig= ht_device *csdev, =20 for (i =3D 0; i < pdata->nr_outconns; i++) { /* If we have made the links, remove them now */ - if (csdev && conns[i].child_dev) + if (csdev && conns[i].dest_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); - conns[i].child_fwnode =3D NULL; + if (conns[i].dest_fwnode) { + fwnode_handle_put(conns[i].dest_fwnode); + conns[i].dest_fwnode =3D NULL; } } if (csdev) diff --git a/drivers/hwtracing/coresight/coresight-platform.c b/drivers/hwt= racing/coresight/coresight-platform.c index ed865e0621a9..566cc99a2c34 100644 --- a/drivers/hwtracing/coresight/coresight-platform.c +++ b/drivers/hwtracing/coresight/coresight-platform.c @@ -252,13 +252,13 @@ static int of_coresight_parse_endpoint(struct device = *dev, } =20 conn =3D &pdata->out_conns[endpoint.port]; - if (conn->child_fwnode) { + if (conn->dest_fwnode) { dev_warn(dev, "Duplicate output port %d\n", endpoint.port); ret =3D -EINVAL; break; } - conn->outport =3D endpoint.port; + conn->src_port =3D endpoint.port; /* * Hold the refcount to the target device. This could be * released via: @@ -267,8 +267,8 @@ static int of_coresight_parse_endpoint(struct device *d= ev, * 2) While removing the target device via * coresight_remove_match() */ - conn->child_fwnode =3D fwnode_handle_get(rdev_fwnode); - conn->child_port =3D rendpoint.port; + conn->dest_fwnode =3D fwnode_handle_get(rdev_fwnode); + conn->dest_port =3D rendpoint.port; /* Connection record updated */ } while (0); =20 @@ -649,8 +649,8 @@ static int acpi_coresight_parse_link(struct acpi_device= *adev, =20 dir =3D fields[3].integer.value; if (dir =3D=3D ACPI_CORESIGHT_LINK_MASTER) { - conn->outport =3D fields[0].integer.value; - conn->child_port =3D fields[1].integer.value; + conn->src_port =3D fields[0].integer.value; + conn->dest_port =3D fields[1].integer.value; rdev =3D coresight_find_device_by_fwnode(&r_adev->fwnode); if (!rdev) return -EPROBE_DEFER; @@ -662,14 +662,14 @@ static int acpi_coresight_parse_link(struct acpi_devi= ce *adev, * 2) While removing the target device via * coresight_remove_match(). */ - conn->child_fwnode =3D fwnode_handle_get(&r_adev->fwnode); + conn->dest_fwnode =3D fwnode_handle_get(&r_adev->fwnode); } else if (dir =3D=3D ACPI_CORESIGHT_LINK_SLAVE) { /* * We are only interested in the port number * for the input ports at this component. * Store the port number in child_port. */ - conn->child_port =3D fields[0].integer.value; + conn->dest_port =3D fields[0].integer.value; } else { /* Invalid direction */ return -EINVAL; @@ -718,11 +718,11 @@ static int acpi_coresight_parse_graph(struct acpi_dev= ice *adev, return dir; =20 if (dir =3D=3D ACPI_CORESIGHT_LINK_MASTER) { - if (ptr->outport >=3D pdata->nr_outconns) - pdata->nr_outconns =3D ptr->outport + 1; + if (ptr->src_port >=3D pdata->nr_outconns) + pdata->nr_outconns =3D ptr->src_port + 1; ptr++; } else { - WARN_ON(pdata->nr_inconns =3D=3D ptr->child_port + 1); + WARN_ON(pdata->nr_inconns =3D=3D ptr->dest_port + 1); /* * We do not track input port connections for a device. * However we need the highest port number described, @@ -730,8 +730,8 @@ static int acpi_coresight_parse_graph(struct acpi_devic= e *adev, * record for an output connection. Hence, do not move * the ptr for input connections */ - if (ptr->child_port >=3D pdata->nr_inconns) - pdata->nr_inconns =3D ptr->child_port + 1; + if (ptr->dest_port >=3D pdata->nr_inconns) + pdata->nr_inconns =3D ptr->dest_port + 1; } } =20 @@ -741,10 +741,10 @@ static int acpi_coresight_parse_graph(struct acpi_dev= ice *adev, =20 /* Copy the connection information to the final location */ for (i =3D 0; conns + i < ptr; i++) { - int port =3D conns[i].outport; + int port =3D conns[i].src_port; =20 /* Duplicate output port */ - WARN_ON(pdata->out_conns[port].child_fwnode); + WARN_ON(pdata->out_conns[port].dest_fwnode); pdata->out_conns[port] =3D conns[i]; } =20 diff --git a/drivers/hwtracing/coresight/coresight-sysfs.c b/drivers/hwtrac= ing/coresight/coresight-sysfs.c index 34d2a2d31d00..a4a8e8e642e8 100644 --- a/drivers/hwtracing/coresight/coresight-sysfs.c +++ b/drivers/hwtracing/coresight/coresight-sysfs.c @@ -150,11 +150,11 @@ int coresight_make_links(struct coresight_device *ori= g, =20 do { outs =3D devm_kasprintf(&orig->dev, GFP_KERNEL, - "out:%d", conn->outport); + "out:%d", conn->src_port); if (!outs) break; ins =3D devm_kasprintf(&target->dev, GFP_KERNEL, - "in:%d", conn->child_port); + "in:%d", conn->dest_port); if (!ins) break; link =3D devm_kzalloc(&orig->dev, @@ -178,7 +178,7 @@ int coresight_make_links(struct coresight_device *orig, * Install the device connection. This also indicates that * the links are operational on both ends. */ - conn->child_dev =3D target; + conn->dest_dev =3D target; return 0; } while (0); =20 @@ -198,9 +198,9 @@ void coresight_remove_links(struct coresight_device *or= ig, =20 coresight_remove_sysfs_link(conn->link); =20 - devm_kfree(&conn->child_dev->dev, conn->link->target_name); + devm_kfree(&conn->dest_dev->dev, conn->link->target_name); devm_kfree(&orig->dev, conn->link->orig_name); devm_kfree(&orig->dev, conn->link); conn->link =3D NULL; - conn->child_dev =3D NULL; + conn->dest_dev =3D NULL; } diff --git a/drivers/hwtracing/coresight/coresight-tmc-etr.c b/drivers/hwtr= acing/coresight/coresight-tmc-etr.c index 4711dfa7418c..61234cb8052a 100644 --- a/drivers/hwtracing/coresight/coresight-tmc-etr.c +++ b/drivers/hwtracing/coresight/coresight-tmc-etr.c @@ -782,7 +782,7 @@ tmc_etr_get_catu_device(struct tmc_drvdata *drvdata) return NULL; =20 for (i =3D 0; i < etr->pdata->nr_outconns; i++) { - tmp =3D etr->pdata->out_conns[i].child_dev; + tmp =3D etr->pdata->out_conns[i].dest_dev; if (tmp && coresight_is_catu_device(tmp)) return tmp; } diff --git a/include/linux/coresight.h b/include/linux/coresight.h index daf392fcb67a..b6f444804bf3 100644 --- a/include/linux/coresight.h +++ b/include/linux/coresight.h @@ -164,18 +164,18 @@ struct coresight_desc { =20 /** * struct coresight_connection - representation of a single connection - * @outport: a connection's output port number. - * @child_port: remote component's port number @output is connected to. - * @chid_fwnode: remote component's fwnode handle. - * @child_dev: a @coresight_device representation of the component - connected to @outport. + * @src_port: a connection's output port number. + * @dest_port: destination's input port number @src_port is connected to. + * @dest_fwnode: destination component's fwnode handle. + * @dest_dev: a @coresight_device representation of the component + connected to @src_port. NULL until the device is created * @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; + int src_port; + int dest_port; + struct fwnode_handle *dest_fwnode; + struct coresight_device *dest_dev; struct coresight_sysfs_link *link; }; =20 --=20 2.34.1