--- zzzz-none-000/linux-5.4.213/drivers/hwtracing/coresight/coresight-replicator.c 2022-09-15 10:04:56.000000000 +0000 +++ alder-5690pro-762/linux-5.4.213/drivers/hwtracing/coresight/coresight-replicator.c 2024-08-14 09:01:58.000000000 +0000 @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 /* - * Copyright (c) 2011-2015, The Linux Foundation. All rights reserved. + * Copyright (c) 2011-2015, 2020, The Linux Foundation. All rights reserved. * * Description: CoreSight Replicator driver */ @@ -94,6 +94,18 @@ return rc; } +static bool is_replicator_disabled(struct coresight_device *csdev) +{ + int i; + + for (i = 0; i < csdev->pdata->nr_outport; i++) { + if (atomic_read(&csdev->refcnt[i]) > 0) + return false; + } + + return true; +} + static int replicator_enable(struct coresight_device *csdev, int inport, int outport) { @@ -103,6 +115,10 @@ bool first_enable = false; spin_lock_irqsave(&drvdata->spinlock, flags); + + if (is_replicator_disabled(csdev)) + dynamic_replicator_reset(drvdata); + if (atomic_read(&csdev->refcnt[outport]) == 0) { if (drvdata->base) rc = dynamic_replicator_enable(drvdata, inport, @@ -210,7 +226,8 @@ dev_warn_once(dev, "Uses OBSOLETE CoreSight replicator binding\n"); - desc.name = coresight_alloc_device_name(&replicator_devs, dev); + if (of_property_read_string(dev->of_node, "coresight-name", &desc.name)) + desc.name = coresight_alloc_device_name(&replicator_devs, dev); if (!desc.name) return -ENOMEM; @@ -241,6 +258,8 @@ dev_set_drvdata(dev, drvdata); + spin_lock_init(&drvdata->spinlock); + pdata = coresight_get_platform_data(dev); if (IS_ERR(pdata)) { ret = PTR_ERR(pdata);