Merge "coresight: add node to reset all coresight devices"

This commit is contained in:
qctecmdr 2022-08-19 05:21:28 -07:00 committed by Gerrit - the friendly Code Review server
commit 3002dfd5aa

View File

@ -122,6 +122,23 @@ static int coresight_source_is_unique(struct coresight_device *csdev)
csdev, coresight_id_match);
}
static int coresight_reset_sink(struct device *dev, void *data)
{
struct coresight_device *csdev = to_coresight_device(dev);
if ((csdev->type == CORESIGHT_DEV_TYPE_SINK ||
csdev->type == CORESIGHT_DEV_TYPE_LINKSINK) &&
csdev->activated)
csdev->activated = false;
return 0;
}
static void coresight_reset_all_sink(void)
{
bus_for_each_dev(&coresight_bustype, NULL, NULL, coresight_reset_sink);
}
static int coresight_find_link_inport(struct coresight_device *csdev,
struct coresight_device *parent)
{
@ -1177,7 +1194,7 @@ int coresight_enable(struct coresight_device *csdev)
}
EXPORT_SYMBOL_GPL(coresight_enable);
void coresight_disable(struct coresight_device *csdev)
static void __coresight_disable(struct coresight_device *csdev)
{
int ret;
struct list_head *path = NULL;
@ -1185,14 +1202,12 @@ void coresight_disable(struct coresight_device *csdev)
struct coresight_path *cspath_next = NULL;
struct coresight_device *src_csdev = NULL;
mutex_lock(&coresight_mutex);
ret = coresight_validate_source(csdev, __func__);
if (ret)
goto out;
return;
if (!csdev->enable || !coresight_disable_source(csdev))
goto out;
return;
list_for_each_entry_safe(cspath, cspath_next, &cs_active_paths, link) {
src_csdev = coresight_get_source(cspath->path);
@ -1206,12 +1221,17 @@ void coresight_disable(struct coresight_device *csdev)
}
if (path == NULL)
goto out;
return;
coresight_disable_path(path);
coresight_release_path(path);
out:
}
void coresight_disable(struct coresight_device *csdev)
{
mutex_lock(&coresight_mutex);
__coresight_disable(csdev);
mutex_unlock(&coresight_mutex);
}
EXPORT_SYMBOL_GPL(coresight_disable);
@ -1771,8 +1791,46 @@ char *coresight_alloc_device_name(struct coresight_dev_list *dict,
}
EXPORT_SYMBOL_GPL(coresight_alloc_device_name);
static ssize_t reset_source_sink_store(struct bus_type *bus,
const char *buf, size_t size)
{
int ret = 0;
unsigned long val;
struct coresight_path *cspath = NULL;
struct coresight_path *cspath_next = NULL;
struct coresight_device *csdev;
ret = kstrtoul(buf, 10, &val);
if (ret)
return ret;
mutex_lock(&coresight_mutex);
list_for_each_entry_safe(cspath, cspath_next, &cs_active_paths, link) {
csdev = coresight_get_source(cspath->path);
if (!csdev)
continue;
atomic_set(csdev->refcnt, 1);
__coresight_disable(csdev);
}
/* Reset all activated sinks */
coresight_reset_all_sink();
mutex_unlock(&coresight_mutex);
return size;
}
static BUS_ATTR_WO(reset_source_sink);
static struct attribute *coresight_reset_source_sink_attrs[] = {
&bus_attr_reset_source_sink.attr,
NULL,
};
ATTRIBUTE_GROUPS(coresight_reset_source_sink);
struct bus_type coresight_bustype = {
.name = "coresight",
.name = "coresight",
.bus_groups = coresight_reset_source_sink_groups,
};
static int __init coresight_init(void)