drivers/hwtracing/coresight/coresight-etb10.c
Source file repositories/reference/linux-study-clean/drivers/hwtracing/coresight/coresight-etb10.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hwtracing/coresight/coresight-etb10.c- Extension
.c- Size
- 21655 bytes
- Lines
- 855
- 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/atomic.hlinux/kernel.hlinux/init.hlinux/types.hlinux/device.hlinux/io.hlinux/err.hlinux/fs.hlinux/miscdevice.hlinux/uaccess.hlinux/slab.hlinux/spinlock.hlinux/pm_runtime.hlinux/seq_file.hlinux/coresight.hlinux/amba/bus.hlinux/clk.hlinux/circ_buf.hlinux/mm.hlinux/perf_event.hcoresight-priv.hcoresight-etm-perf.h
Detected Declarations
struct etb_drvdatafunction etb_get_buffer_depthfunction __etb_enable_hwfunction etb_enable_hwfunction etb_enable_sysfsfunction etb_enable_perffunction etb_enablefunction __etb_disable_hwfunction etb_dump_hwfunction etb_disable_hwfunction etb_disablefunction etb_free_bufferfunction etb_set_bufferfunction etb_update_bufferfunction etb_dumpfunction etb_openfunction etb_readfunction etb_releasefunction trigger_cntr_showfunction trigger_cntr_storefunction etb_probefunction etb_removefunction etb_runtime_suspendfunction etb_runtime_resume
Annotated Snippet
static const struct file_operations etb_fops = {
.owner = THIS_MODULE,
.open = etb_open,
.read = etb_read,
.release = etb_release,
};
static struct attribute *coresight_etb_mgmt_attrs[] = {
coresight_simple_reg32(rdp, ETB_RAM_DEPTH_REG),
coresight_simple_reg32(sts, ETB_STATUS_REG),
coresight_simple_reg32(rrp, ETB_RAM_READ_POINTER),
coresight_simple_reg32(rwp, ETB_RAM_WRITE_POINTER),
coresight_simple_reg32(trg, ETB_TRG),
coresight_simple_reg32(ctl, ETB_CTL_REG),
coresight_simple_reg32(ffsr, ETB_FFSR),
coresight_simple_reg32(ffcr, ETB_FFCR),
NULL,
};
static ssize_t trigger_cntr_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct etb_drvdata *drvdata = dev_get_drvdata(dev->parent);
unsigned long val = drvdata->trigger_cntr;
return sprintf(buf, "%#lx\n", val);
}
static ssize_t trigger_cntr_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t size)
{
int ret;
unsigned long val;
struct etb_drvdata *drvdata = dev_get_drvdata(dev->parent);
ret = kstrtoul(buf, 16, &val);
if (ret)
return ret;
drvdata->trigger_cntr = val;
return size;
}
static DEVICE_ATTR_RW(trigger_cntr);
static struct attribute *coresight_etb_attrs[] = {
&dev_attr_trigger_cntr.attr,
NULL,
};
static const struct attribute_group coresight_etb_group = {
.attrs = coresight_etb_attrs,
};
static const struct attribute_group coresight_etb_mgmt_group = {
.attrs = coresight_etb_mgmt_attrs,
.name = "mgmt",
};
static const struct attribute_group *coresight_etb_groups[] = {
&coresight_etb_group,
&coresight_etb_mgmt_group,
NULL,
};
static int etb_probe(struct amba_device *adev, const struct amba_id *id)
{
int ret;
void __iomem *base;
struct device *dev = &adev->dev;
struct coresight_platform_data *pdata = NULL;
struct etb_drvdata *drvdata;
struct resource *res = &adev->res;
struct coresight_desc desc = { 0 };
desc.name = coresight_alloc_device_name("etb", dev);
if (!desc.name)
return -ENOMEM;
drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
if (!drvdata)
return -ENOMEM;
drvdata->atclk = devm_clk_get_optional_enabled(dev, "atclk");
if (IS_ERR(drvdata->atclk))
return PTR_ERR(drvdata->atclk);
dev_set_drvdata(dev, drvdata);
/* validity for the resource is already checked by the AMBA core */
Annotation
- Immediate include surface: `linux/atomic.h`, `linux/kernel.h`, `linux/init.h`, `linux/types.h`, `linux/device.h`, `linux/io.h`, `linux/err.h`, `linux/fs.h`.
- Detected declarations: `struct etb_drvdata`, `function etb_get_buffer_depth`, `function __etb_enable_hw`, `function etb_enable_hw`, `function etb_enable_sysfs`, `function etb_enable_perf`, `function etb_enable`, `function __etb_disable_hw`, `function etb_dump_hw`, `function etb_disable_hw`.
- 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.