--- zzzz-none-000/linux-5.4.213/drivers/hwtracing/coresight/coresight-tmc-etf.c 2022-09-15 10:04:56.000000000 +0000 +++ alder-5690pro-762/linux-5.4.213/drivers/hwtracing/coresight/coresight-tmc-etf.c 2024-08-14 09:01:58.000000000 +0000 @@ -217,6 +217,12 @@ if (!used) kfree(buf); + if (!ret) { + coresight_cti_map_trigin(drvdata->cti_reset, 0, 0); + coresight_cti_map_trigout(drvdata->cti_flush, 1, 0); + dev_info(&csdev->dev, "TMC-ETB/ETF enabled\n"); + } + return ret; } @@ -328,6 +334,8 @@ spin_unlock_irqrestore(&drvdata->spinlock, flags); + coresight_cti_unmap_trigin(drvdata->cti_reset, 0, 0); + coresight_cti_unmap_trigout(drvdata->cti_flush, 1, 0); dev_dbg(&csdev->dev, "TMC-ETB/ETF disabled\n"); return 0; } @@ -558,12 +566,43 @@ return to_read; } +static void tmc_abort_etf_sink(struct coresight_device *csdev) +{ + struct tmc_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); + unsigned long flags; + enum tmc_mode mode; + + spin_lock_irqsave(&drvdata->spinlock, flags); + if (drvdata->reading) + goto out0; + + if (drvdata->config_type == TMC_CONFIG_TYPE_ETB) { + tmc_etb_disable_hw(drvdata); + } else { + mode = readl_relaxed(drvdata->base + TMC_MODE); + if (mode == TMC_MODE_CIRCULAR_BUFFER) + tmc_etb_disable_hw(drvdata); + else + goto out1; + } +out0: + drvdata->enable = false; + spin_unlock_irqrestore(&drvdata->spinlock, flags); + + dev_info(&drvdata->csdev->dev, "TMC aborted\n"); + return; +out1: + spin_unlock_irqrestore(&drvdata->spinlock, flags); +} + + static const struct coresight_ops_sink tmc_etf_sink_ops = { .enable = tmc_enable_etf_sink, .disable = tmc_disable_etf_sink, .alloc_buffer = tmc_alloc_etf_buffer, .free_buffer = tmc_free_etf_buffer, .update_buffer = tmc_update_etf_buffer, + .abort = tmc_abort_etf_sink, }; static const struct coresight_ops_link tmc_etf_link_ops = {