drivers/hwtracing/coresight/coresight-tmc-etf.c
Source file repositories/reference/linux-study-clean/drivers/hwtracing/coresight/coresight-tmc-etf.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hwtracing/coresight/coresight-tmc-etf.c- Extension
.c- Size
- 20066 bytes
- Lines
- 811
- Domain
- Driver Families
- Bucket
- drivers/hwtracing
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/atomic.hlinux/circ_buf.hlinux/coresight.hlinux/perf_event.hlinux/slab.hcoresight-priv.hcoresight-tmc.hcoresight-etm-perf.h
Detected Declarations
function __tmc_etb_enable_hwfunction tmc_etb_enable_hwfunction tmc_etb_dump_hwfunction __tmc_etb_disable_hwfunction tmc_etb_disable_hwfunction __tmc_etf_enable_hwfunction tmc_etf_enable_hwfunction tmc_etf_disable_hwfunction tmc_etb_get_sysfs_tracefunction tmc_enable_etf_sink_sysfsfunction tmc_enable_etf_sink_perffunction tmc_enable_etf_sinkfunction tmc_disable_etf_sinkfunction tmc_enable_etf_linkfunction tmc_disable_etf_linkfunction tmc_free_etf_bufferfunction tmc_set_etf_bufferfunction tmc_update_etf_bufferfunction bufferfunction tmc_panic_sync_etffunction tmc_read_prepare_etbfunction tmc_read_unprepare_etb
Annotated Snippet
if (coresight_get_mode(csdev) == CS_MODE_SYSFS) {
ret = -EBUSY;
break;
}
/* Get a handle on the pid of the process to monitor */
pid = buf->pid;
if (drvdata->pid != -1 && drvdata->pid != pid) {
ret = -EBUSY;
break;
}
ret = tmc_set_etf_buffer(csdev, handle);
if (ret)
break;
/*
* No HW configuration is needed if the sink is already in
* use for this session.
*/
if (drvdata->pid == pid) {
csdev->refcnt++;
break;
}
ret = tmc_etb_enable_hw(drvdata);
if (!ret) {
/* Associate with monitored process. */
drvdata->pid = pid;
coresight_set_mode(csdev, CS_MODE_PERF);
csdev->refcnt++;
}
} while (0);
raw_spin_unlock_irqrestore(&drvdata->spinlock, flags);
return ret;
}
static int tmc_enable_etf_sink(struct coresight_device *csdev,
enum cs_mode mode,
struct coresight_path *path)
{
int ret;
switch (mode) {
case CS_MODE_SYSFS:
ret = tmc_enable_etf_sink_sysfs(csdev);
break;
case CS_MODE_PERF:
ret = tmc_enable_etf_sink_perf(csdev, path);
break;
/* We shouldn't be here */
default:
ret = -EINVAL;
break;
}
if (ret)
return ret;
dev_dbg(&csdev->dev, "TMC-ETB/ETF enabled\n");
return 0;
}
static int tmc_disable_etf_sink(struct coresight_device *csdev)
{
unsigned long flags;
struct tmc_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
raw_spin_lock_irqsave(&drvdata->spinlock, flags);
if (drvdata->reading) {
raw_spin_unlock_irqrestore(&drvdata->spinlock, flags);
return -EBUSY;
}
csdev->refcnt--;
if (csdev->refcnt) {
raw_spin_unlock_irqrestore(&drvdata->spinlock, flags);
return -EBUSY;
}
/* Complain if we (somehow) got out of sync */
WARN_ON_ONCE(coresight_get_mode(csdev) == CS_MODE_DISABLED);
tmc_etb_disable_hw(drvdata);
/* Dissociate from monitored process. */
drvdata->pid = -1;
coresight_set_mode(csdev, CS_MODE_DISABLED);
Annotation
- Immediate include surface: `linux/atomic.h`, `linux/circ_buf.h`, `linux/coresight.h`, `linux/perf_event.h`, `linux/slab.h`, `coresight-priv.h`, `coresight-tmc.h`, `coresight-etm-perf.h`.
- Detected declarations: `function __tmc_etb_enable_hw`, `function tmc_etb_enable_hw`, `function tmc_etb_dump_hw`, `function __tmc_etb_disable_hw`, `function tmc_etb_disable_hw`, `function __tmc_etf_enable_hw`, `function tmc_etf_enable_hw`, `function tmc_etf_disable_hw`, `function tmc_etb_get_sysfs_trace`, `function tmc_enable_etf_sink_sysfs`.
- Atlas domain: Driver Families / drivers/hwtracing.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.