Loading drivers/hwtracing/coresight/coresight.c +54 −13 Original line number Diff line number Diff line Loading @@ -21,6 +21,9 @@ #include "coresight-priv.h" static int coresight_source_filter(struct list_head *path, struct coresight_connection *conn); static DEFINE_MUTEX(coresight_mutex); /** Loading Loading @@ -109,13 +112,16 @@ static void coresight_reset_all_sink(void) } static int coresight_find_link_inport(struct coresight_device *csdev, struct coresight_device *parent) struct coresight_device *parent, struct list_head *path) { int i; struct coresight_connection *conn; for (i = 0; i < parent->nr_outport; i++) { conn = &parent->conns[i]; if (coresight_source_filter(path, conn)) continue; if (conn->child_dev == csdev) return conn->child_port; } Loading @@ -127,13 +133,16 @@ static int coresight_find_link_inport(struct coresight_device *csdev, } static int coresight_find_link_outport(struct coresight_device *csdev, struct coresight_device *child) struct coresight_device *child, struct list_head *path) { int i; struct coresight_connection *conn; for (i = 0; i < csdev->nr_outport; i++) { conn = &csdev->conns[i]; if (coresight_source_filter(path, conn)) continue; if (conn->child_dev == child) return conn->outport; } Loading Loading @@ -175,7 +184,8 @@ static void coresight_disable_sink(struct coresight_device *csdev) static int coresight_enable_link(struct coresight_device *csdev, struct coresight_device *parent, struct coresight_device *child) struct coresight_device *child, struct list_head *path) { int ret; int link_subtype; Loading @@ -184,8 +194,8 @@ static int coresight_enable_link(struct coresight_device *csdev, if (!parent || !child) return -EINVAL; inport = coresight_find_link_inport(csdev, parent); outport = coresight_find_link_outport(csdev, child); inport = coresight_find_link_inport(csdev, parent, path); outport = coresight_find_link_outport(csdev, child, path); link_subtype = csdev->subtype.link_subtype; if (link_subtype == CORESIGHT_DEV_SUBTYPE_LINK_MERG) Loading Loading @@ -213,7 +223,8 @@ static int coresight_enable_link(struct coresight_device *csdev, static void coresight_disable_link(struct coresight_device *csdev, struct coresight_device *parent, struct coresight_device *child) struct coresight_device *child, struct list_head *path) { int i, nr_conns; int link_subtype; Loading @@ -222,8 +233,8 @@ static void coresight_disable_link(struct coresight_device *csdev, if (!parent || !child) return; inport = coresight_find_link_inport(csdev, parent); outport = coresight_find_link_outport(csdev, child); inport = coresight_find_link_inport(csdev, parent, path); outport = coresight_find_link_outport(csdev, child, path); link_subtype = csdev->subtype.link_subtype; if (link_subtype == CORESIGHT_DEV_SUBTYPE_LINK_MERG) { Loading Loading @@ -322,7 +333,7 @@ void coresight_disable_path(struct list_head *path) case CORESIGHT_DEV_TYPE_LINK: parent = list_prev_entry(nd, link)->csdev; child = list_next_entry(nd, link)->csdev; coresight_disable_link(csdev, parent, child); coresight_disable_link(csdev, parent, child, path); break; default: break; Loading Loading @@ -365,7 +376,7 @@ int coresight_enable_path(struct list_head *path, u32 mode) case CORESIGHT_DEV_TYPE_LINK: parent = list_prev_entry(nd, link)->csdev; child = list_next_entry(nd, link)->csdev; ret = coresight_enable_link(csdev, parent, child); ret = coresight_enable_link(csdev, parent, child, path); if (ret) goto err; break; Loading Loading @@ -492,6 +503,31 @@ static void coresight_drop_device(struct coresight_device *csdev) } } /** * coresight_source_filter - checks whether the connection matches the source * of path if connection is binded to specific source. * @path: The list of devices * @conn: The connection of one outport * * Return zero if the connection doesn't have a source binded or source of the * path matches the source binds to connection. */ static int coresight_source_filter(struct list_head *path, struct coresight_connection *conn) { int ret = 0; struct coresight_device *source = NULL; if (conn->source_name == NULL) return ret; source = coresight_get_source(path); if (source == NULL) return ret; return strcmp(conn->source_name, dev_name(&source->dev)); } /** * _coresight_build_path - recursively build a path from a @csdev to a sink. * @csdev: The device to start from. Loading @@ -505,7 +541,8 @@ static void coresight_drop_device(struct coresight_device *csdev) */ static int _coresight_build_path(struct coresight_device *csdev, struct coresight_device *sink, struct list_head *path) struct list_head *path, struct coresight_device *source) { int i; bool found = false; Loading @@ -519,8 +556,12 @@ static int _coresight_build_path(struct coresight_device *csdev, for (i = 0; i < csdev->nr_outport; i++) { struct coresight_device *child_dev = csdev->conns[i].child_dev; if (csdev->conns[i].source_name && strcmp(csdev->conns[i].source_name, dev_name(&source->dev))) continue; if (child_dev && _coresight_build_path(child_dev, sink, path) == 0) { _coresight_build_path(child_dev, sink, path, source) == 0) { found = true; break; } Loading Loading @@ -562,7 +603,7 @@ struct list_head *coresight_build_path(struct coresight_device *source, INIT_LIST_HEAD(path); rc = _coresight_build_path(source, sink, path); rc = _coresight_build_path(source, sink, path, source); if (rc) { kfree(path); return ERR_PTR(rc); Loading drivers/hwtracing/coresight/of_coresight.c +16 −1 Original line number Diff line number Diff line // SPDX-License-Identifier: GPL-2.0 /* * Copyright (c) 2012,2017, The Linux Foundation. All rights reserved. * Copyright (c) 2012,2017-2018 The Linux Foundation. All rights reserved. */ #include <linux/types.h> Loading Loading @@ -78,6 +78,12 @@ static int of_coresight_alloc_memory(struct device *dev, if (!pdata->outports) return -ENOMEM; pdata->source_names = devm_kzalloc(dev, pdata->nr_outport * sizeof(*pdata->source_names), GFP_KERNEL); if (!pdata->source_names) return -ENOMEM; /* Children connected to this component via @outports */ pdata->child_names = devm_kcalloc(dev, pdata->nr_outport, Loading Loading @@ -127,6 +133,7 @@ of_get_coresight_platform_data(struct device *dev, struct device_node *ep = NULL; struct device_node *rparent = NULL; struct device_node *rport = NULL; struct device_node *sn = NULL; pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); if (!pdata) Loading Loading @@ -191,6 +198,14 @@ of_get_coresight_platform_data(struct device *dev, pdata->child_names[i] = dev_name(rdev); pdata->child_ports[i] = rendpoint.id; pdata->source_names[i] = NULL; sn = of_parse_phandle(ep, "source", 0); if (sn) { ret = of_property_read_string(sn, "coresight-name", &pdata->source_names[i]); of_node_put(sn); } i++; } while (ep); } Loading include/linux/coresight.h +5 −1 Original line number Diff line number Diff line /* SPDX-License-Identifier: GPL-2.0 */ /* * Copyright (c) 2012,2017, The Linux Foundation. All rights reserved. * Copyright (c) 2012,2017-2018 The Linux Foundation. All rights reserved. */ #ifndef _LINUX_CORESIGHT_H Loading Loading @@ -95,6 +95,7 @@ union coresight_dev_subtype { * @name: name of the component as shown under sysfs. * @nr_inport: number of input ports for this component. * @outports: list of remote endpoint port number. * @source_names:name of all source components connected to this device. * @child_names:name of all child components connected to this device. * @child_ports:child component port number the current component is connected to. Loading @@ -105,6 +106,7 @@ struct coresight_platform_data { const char *name; int nr_inport; int *outports; const char **source_names; const char **child_names; int *child_ports; int nr_outport; Loading Loading @@ -133,6 +135,7 @@ struct coresight_desc { /** * struct coresight_connection - representation of a single connection * @outport: a connection's output port number. * @source_name:source component's name. * @chid_name: remote component's name. * @child_port: remote component's port number @output is connected to. * @child_dev: a @coresight_device representation of the component Loading @@ -140,6 +143,7 @@ struct coresight_desc { */ struct coresight_connection { int outport; const char *source_name; const char *child_name; int child_port; struct coresight_device *child_dev; Loading Loading
drivers/hwtracing/coresight/coresight.c +54 −13 Original line number Diff line number Diff line Loading @@ -21,6 +21,9 @@ #include "coresight-priv.h" static int coresight_source_filter(struct list_head *path, struct coresight_connection *conn); static DEFINE_MUTEX(coresight_mutex); /** Loading Loading @@ -109,13 +112,16 @@ static void coresight_reset_all_sink(void) } static int coresight_find_link_inport(struct coresight_device *csdev, struct coresight_device *parent) struct coresight_device *parent, struct list_head *path) { int i; struct coresight_connection *conn; for (i = 0; i < parent->nr_outport; i++) { conn = &parent->conns[i]; if (coresight_source_filter(path, conn)) continue; if (conn->child_dev == csdev) return conn->child_port; } Loading @@ -127,13 +133,16 @@ static int coresight_find_link_inport(struct coresight_device *csdev, } static int coresight_find_link_outport(struct coresight_device *csdev, struct coresight_device *child) struct coresight_device *child, struct list_head *path) { int i; struct coresight_connection *conn; for (i = 0; i < csdev->nr_outport; i++) { conn = &csdev->conns[i]; if (coresight_source_filter(path, conn)) continue; if (conn->child_dev == child) return conn->outport; } Loading Loading @@ -175,7 +184,8 @@ static void coresight_disable_sink(struct coresight_device *csdev) static int coresight_enable_link(struct coresight_device *csdev, struct coresight_device *parent, struct coresight_device *child) struct coresight_device *child, struct list_head *path) { int ret; int link_subtype; Loading @@ -184,8 +194,8 @@ static int coresight_enable_link(struct coresight_device *csdev, if (!parent || !child) return -EINVAL; inport = coresight_find_link_inport(csdev, parent); outport = coresight_find_link_outport(csdev, child); inport = coresight_find_link_inport(csdev, parent, path); outport = coresight_find_link_outport(csdev, child, path); link_subtype = csdev->subtype.link_subtype; if (link_subtype == CORESIGHT_DEV_SUBTYPE_LINK_MERG) Loading Loading @@ -213,7 +223,8 @@ static int coresight_enable_link(struct coresight_device *csdev, static void coresight_disable_link(struct coresight_device *csdev, struct coresight_device *parent, struct coresight_device *child) struct coresight_device *child, struct list_head *path) { int i, nr_conns; int link_subtype; Loading @@ -222,8 +233,8 @@ static void coresight_disable_link(struct coresight_device *csdev, if (!parent || !child) return; inport = coresight_find_link_inport(csdev, parent); outport = coresight_find_link_outport(csdev, child); inport = coresight_find_link_inport(csdev, parent, path); outport = coresight_find_link_outport(csdev, child, path); link_subtype = csdev->subtype.link_subtype; if (link_subtype == CORESIGHT_DEV_SUBTYPE_LINK_MERG) { Loading Loading @@ -322,7 +333,7 @@ void coresight_disable_path(struct list_head *path) case CORESIGHT_DEV_TYPE_LINK: parent = list_prev_entry(nd, link)->csdev; child = list_next_entry(nd, link)->csdev; coresight_disable_link(csdev, parent, child); coresight_disable_link(csdev, parent, child, path); break; default: break; Loading Loading @@ -365,7 +376,7 @@ int coresight_enable_path(struct list_head *path, u32 mode) case CORESIGHT_DEV_TYPE_LINK: parent = list_prev_entry(nd, link)->csdev; child = list_next_entry(nd, link)->csdev; ret = coresight_enable_link(csdev, parent, child); ret = coresight_enable_link(csdev, parent, child, path); if (ret) goto err; break; Loading Loading @@ -492,6 +503,31 @@ static void coresight_drop_device(struct coresight_device *csdev) } } /** * coresight_source_filter - checks whether the connection matches the source * of path if connection is binded to specific source. * @path: The list of devices * @conn: The connection of one outport * * Return zero if the connection doesn't have a source binded or source of the * path matches the source binds to connection. */ static int coresight_source_filter(struct list_head *path, struct coresight_connection *conn) { int ret = 0; struct coresight_device *source = NULL; if (conn->source_name == NULL) return ret; source = coresight_get_source(path); if (source == NULL) return ret; return strcmp(conn->source_name, dev_name(&source->dev)); } /** * _coresight_build_path - recursively build a path from a @csdev to a sink. * @csdev: The device to start from. Loading @@ -505,7 +541,8 @@ static void coresight_drop_device(struct coresight_device *csdev) */ static int _coresight_build_path(struct coresight_device *csdev, struct coresight_device *sink, struct list_head *path) struct list_head *path, struct coresight_device *source) { int i; bool found = false; Loading @@ -519,8 +556,12 @@ static int _coresight_build_path(struct coresight_device *csdev, for (i = 0; i < csdev->nr_outport; i++) { struct coresight_device *child_dev = csdev->conns[i].child_dev; if (csdev->conns[i].source_name && strcmp(csdev->conns[i].source_name, dev_name(&source->dev))) continue; if (child_dev && _coresight_build_path(child_dev, sink, path) == 0) { _coresight_build_path(child_dev, sink, path, source) == 0) { found = true; break; } Loading Loading @@ -562,7 +603,7 @@ struct list_head *coresight_build_path(struct coresight_device *source, INIT_LIST_HEAD(path); rc = _coresight_build_path(source, sink, path); rc = _coresight_build_path(source, sink, path, source); if (rc) { kfree(path); return ERR_PTR(rc); Loading
drivers/hwtracing/coresight/of_coresight.c +16 −1 Original line number Diff line number Diff line // SPDX-License-Identifier: GPL-2.0 /* * Copyright (c) 2012,2017, The Linux Foundation. All rights reserved. * Copyright (c) 2012,2017-2018 The Linux Foundation. All rights reserved. */ #include <linux/types.h> Loading Loading @@ -78,6 +78,12 @@ static int of_coresight_alloc_memory(struct device *dev, if (!pdata->outports) return -ENOMEM; pdata->source_names = devm_kzalloc(dev, pdata->nr_outport * sizeof(*pdata->source_names), GFP_KERNEL); if (!pdata->source_names) return -ENOMEM; /* Children connected to this component via @outports */ pdata->child_names = devm_kcalloc(dev, pdata->nr_outport, Loading Loading @@ -127,6 +133,7 @@ of_get_coresight_platform_data(struct device *dev, struct device_node *ep = NULL; struct device_node *rparent = NULL; struct device_node *rport = NULL; struct device_node *sn = NULL; pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); if (!pdata) Loading Loading @@ -191,6 +198,14 @@ of_get_coresight_platform_data(struct device *dev, pdata->child_names[i] = dev_name(rdev); pdata->child_ports[i] = rendpoint.id; pdata->source_names[i] = NULL; sn = of_parse_phandle(ep, "source", 0); if (sn) { ret = of_property_read_string(sn, "coresight-name", &pdata->source_names[i]); of_node_put(sn); } i++; } while (ep); } Loading
include/linux/coresight.h +5 −1 Original line number Diff line number Diff line /* SPDX-License-Identifier: GPL-2.0 */ /* * Copyright (c) 2012,2017, The Linux Foundation. All rights reserved. * Copyright (c) 2012,2017-2018 The Linux Foundation. All rights reserved. */ #ifndef _LINUX_CORESIGHT_H Loading Loading @@ -95,6 +95,7 @@ union coresight_dev_subtype { * @name: name of the component as shown under sysfs. * @nr_inport: number of input ports for this component. * @outports: list of remote endpoint port number. * @source_names:name of all source components connected to this device. * @child_names:name of all child components connected to this device. * @child_ports:child component port number the current component is connected to. Loading @@ -105,6 +106,7 @@ struct coresight_platform_data { const char *name; int nr_inport; int *outports; const char **source_names; const char **child_names; int *child_ports; int nr_outport; Loading Loading @@ -133,6 +135,7 @@ struct coresight_desc { /** * struct coresight_connection - representation of a single connection * @outport: a connection's output port number. * @source_name:source component's name. * @chid_name: remote component's name. * @child_port: remote component's port number @output is connected to. * @child_dev: a @coresight_device representation of the component Loading @@ -140,6 +143,7 @@ struct coresight_desc { */ struct coresight_connection { int outport; const char *source_name; const char *child_name; int child_port; struct coresight_device *child_dev; Loading