drivers/hwtracing/coresight/coresight-tmc-core.c
Source file repositories/reference/linux-study-clean/drivers/hwtracing/coresight/coresight-tmc-core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hwtracing/coresight/coresight-tmc-core.c- Extension
.c- Size
- 26057 bytes
- Lines
- 1062
- Domain
- Driver Families
- Bucket
- drivers/hwtracing
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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/acpi.hlinux/kernel.hlinux/init.hlinux/types.hlinux/device.hlinux/idr.hlinux/io.hlinux/iommu.hlinux/err.hlinux/fs.hlinux/miscdevice.hlinux/mutex.hlinux/property.hlinux/uaccess.hlinux/slab.hlinux/dma-mapping.hlinux/spinlock.hlinux/pm_runtime.hlinux/of.hlinux/of_address.hlinux/of_reserved_mem.hlinux/coresight.hlinux/amba/bus.hlinux/platform_device.hcoresight-priv.hcoresight-tmc.h
Detected Declarations
function tmc_wait_for_tmcreadyfunction tmc_flush_and_stopfunction tmc_enable_hwfunction tmc_disable_hwfunction tmc_get_memwidth_maskfunction boundaryfunction is_tmc_crashdata_validfunction tmc_get_resvbuf_tracefunction tmc_prepare_crashdatafunction tmc_read_preparefunction tmc_read_unpreparefunction tmc_openfunction tmc_get_sysfs_tracefunction tmc_readfunction tmc_releasefunction tmc_crashdata_openfunction tmc_crashdata_readfunction tmc_crashdata_releasefunction tmc_get_memwidthfunction trigger_cntr_showfunction trigger_cntr_storefunction buffer_size_showfunction buffer_size_storefunction stop_on_flush_showfunction stop_on_flush_storefunction tmc_etr_can_use_sgfunction tmc_etr_has_non_secure_accessfunction of_tmc_get_reserved_resource_by_namefunction tmc_get_reserved_regionfunction tmc_etr_setup_capsfunction tmc_etr_get_default_buffer_sizefunction tmc_etr_get_max_burst_sizefunction register_crash_dev_interfacefunction __tmc_probefunction tmc_probefunction tmc_shutdownfunction __tmc_removefunction tmc_removefunction tmc_platform_probefunction tmc_platform_removefunction tmc_runtime_suspendfunction tmc_runtime_resumefunction tmc_initfunction tmc_exitmodule init tmc_init
Annotated Snippet
static const struct file_operations tmc_fops = {
.owner = THIS_MODULE,
.open = tmc_open,
.read = tmc_read,
.release = tmc_release,
};
static int tmc_crashdata_open(struct inode *inode, struct file *file)
{
int err = 0;
unsigned long flags;
struct tmc_resrv_buf *rbuf;
struct tmc_crash_metadata *mdata;
struct tmc_drvdata *drvdata = container_of(file->private_data,
struct tmc_drvdata,
crashdev);
mdata = drvdata->crash_mdata.vaddr;
rbuf = &drvdata->resrv_buf;
raw_spin_lock_irqsave(&drvdata->spinlock, flags);
if (mdata->valid)
rbuf->reading = true;
else
err = -ENOENT;
raw_spin_unlock_irqrestore(&drvdata->spinlock, flags);
if (err)
goto exit;
nonseekable_open(inode, file);
dev_dbg(&drvdata->csdev->dev, "%s: successfully opened\n", __func__);
exit:
return err;
}
static ssize_t tmc_crashdata_read(struct file *file, char __user *data,
size_t len, loff_t *ppos)
{
char *bufp;
ssize_t actual;
struct tmc_drvdata *drvdata = container_of(file->private_data,
struct tmc_drvdata,
crashdev);
actual = tmc_get_resvbuf_trace(drvdata, *ppos, len, &bufp);
if (actual <= 0)
return 0;
if (copy_to_user(data, bufp, actual)) {
dev_dbg(&drvdata->csdev->dev,
"%s: copy_to_user failed\n", __func__);
return -EFAULT;
}
*ppos += actual;
dev_dbg(&drvdata->csdev->dev, "%zu bytes copied\n", actual);
return actual;
}
static int tmc_crashdata_release(struct inode *inode, struct file *file)
{
unsigned long flags;
struct tmc_resrv_buf *rbuf;
struct tmc_drvdata *drvdata = container_of(file->private_data,
struct tmc_drvdata,
crashdev);
rbuf = &drvdata->resrv_buf;
raw_spin_lock_irqsave(&drvdata->spinlock, flags);
rbuf->reading = false;
raw_spin_unlock_irqrestore(&drvdata->spinlock, flags);
dev_dbg(&drvdata->csdev->dev, "%s: released\n", __func__);
return 0;
}
static const struct file_operations tmc_crashdata_fops = {
.owner = THIS_MODULE,
.open = tmc_crashdata_open,
.read = tmc_crashdata_read,
.release = tmc_crashdata_release,
};
static enum tmc_mem_intf_width tmc_get_memwidth(u32 devid)
{
enum tmc_mem_intf_width memwidth;
/*
* Excerpt from the TRM:
Annotation
- Immediate include surface: `linux/acpi.h`, `linux/kernel.h`, `linux/init.h`, `linux/types.h`, `linux/device.h`, `linux/idr.h`, `linux/io.h`, `linux/iommu.h`.
- Detected declarations: `function tmc_wait_for_tmcready`, `function tmc_flush_and_stop`, `function tmc_enable_hw`, `function tmc_disable_hw`, `function tmc_get_memwidth_mask`, `function boundary`, `function is_tmc_crashdata_valid`, `function tmc_get_resvbuf_trace`, `function tmc_prepare_crashdata`, `function tmc_read_prepare`.
- Atlas domain: Driver Families / drivers/hwtracing.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.