drivers/hwtracing/coresight/coresight-etm3x-sysfs.c
Source file repositories/reference/linux-study-clean/drivers/hwtracing/coresight/coresight-etm3x-sysfs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hwtracing/coresight/coresight-etm3x-sysfs.c- Extension
.c- Size
- 32298 bytes
- Lines
- 1269
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/pid_namespace.hlinux/pm_runtime.hlinux/sysfs.hcoresight-etm.hcoresight-priv.h
Detected Declarations
function Copyrightfunction nr_cntr_showfunction nr_ctxid_cmp_showfunction etmsr_showfunction reset_storefunction mode_showfunction mode_storefunction trigger_event_showfunction trigger_event_storefunction enable_event_showfunction enable_event_storefunction fifofull_level_showfunction fifofull_level_storefunction addr_idx_showfunction addr_idx_storefunction addr_single_showfunction addr_single_storefunction addr_range_showfunction addr_range_storefunction addr_start_showfunction addr_start_storefunction addr_stop_showfunction addr_stop_storefunction addr_acctype_showfunction addr_acctype_storefunction cntr_idx_showfunction cntr_idx_storefunction cntr_rld_val_showfunction cntr_rld_val_storefunction cntr_event_showfunction cntr_event_storefunction cntr_rld_event_showfunction cntr_rld_event_storefunction cntr_val_showfunction cntr_val_storefunction seq_12_event_showfunction seq_12_event_storefunction seq_21_event_showfunction seq_21_event_storefunction seq_23_event_showfunction seq_23_event_storefunction seq_31_event_showfunction seq_31_event_storefunction seq_32_event_showfunction seq_32_event_storefunction seq_13_event_showfunction seq_13_event_storefunction seq_curr_state_show
Annotated Snippet
if (!(drvdata->etmccr & ETMCCR_FIFOFULL)) {
dev_warn(dev, "stall mode not supported\n");
ret = -EINVAL;
goto err_unlock;
}
config->ctrl |= ETMCR_STALL_MODE;
} else
config->ctrl &= ~ETMCR_STALL_MODE;
if (config->mode & ETM_MODE_TIMESTAMP) {
if (!(drvdata->etmccer & ETMCCER_TIMESTAMP)) {
dev_warn(dev, "timestamp not supported\n");
ret = -EINVAL;
goto err_unlock;
}
config->ctrl |= ETMCR_TIMESTAMP_EN;
} else
config->ctrl &= ~ETMCR_TIMESTAMP_EN;
if (config->mode & ETM_MODE_CTXID)
config->ctrl |= ETMCR_CTXID_SIZE;
else
config->ctrl &= ~ETMCR_CTXID_SIZE;
if (config->mode & ETM_MODE_BBROAD)
config->ctrl |= ETMCR_BRANCH_BROADCAST;
else
config->ctrl &= ~ETMCR_BRANCH_BROADCAST;
if (config->mode & ETM_MODE_RET_STACK)
config->ctrl |= ETMCR_RETURN_STACK;
else
config->ctrl &= ~ETMCR_RETURN_STACK;
if (config->mode & (ETM_MODE_EXCL_KERN | ETM_MODE_EXCL_USER))
etm_config_trace_mode(config);
spin_unlock(&drvdata->spinlock);
return size;
err_unlock:
spin_unlock(&drvdata->spinlock);
return ret;
}
static DEVICE_ATTR_RW(mode);
static ssize_t trigger_event_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
unsigned long val;
struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent);
struct etm_config *config = &drvdata->config;
val = config->trigger_event;
return sprintf(buf, "%#lx\n", val);
}
static ssize_t trigger_event_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t size)
{
int ret;
unsigned long val;
struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent);
struct etm_config *config = &drvdata->config;
ret = kstrtoul(buf, 16, &val);
if (ret)
return ret;
config->trigger_event = val & ETM_EVENT_MASK;
return size;
}
static DEVICE_ATTR_RW(trigger_event);
static ssize_t enable_event_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
unsigned long val;
struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent);
struct etm_config *config = &drvdata->config;
val = config->enable_event;
return sprintf(buf, "%#lx\n", val);
}
static ssize_t enable_event_store(struct device *dev,
struct device_attribute *attr,
Annotation
- Immediate include surface: `linux/pid_namespace.h`, `linux/pm_runtime.h`, `linux/sysfs.h`, `coresight-etm.h`, `coresight-priv.h`.
- Detected declarations: `function Copyright`, `function nr_cntr_show`, `function nr_ctxid_cmp_show`, `function etmsr_show`, `function reset_store`, `function mode_show`, `function mode_store`, `function trigger_event_show`, `function trigger_event_store`, `function enable_event_show`.
- 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.