drivers/hwtracing/coresight/coresight-syscfg.c
Source file repositories/reference/linux-study-clean/drivers/hwtracing/coresight/coresight-syscfg.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hwtracing/coresight/coresight-syscfg.c- Extension
.c- Size
- 37397 bytes
- Lines
- 1320
- Domain
- Driver Families
- Bucket
- drivers/hwtracing
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/platform_device.hlinux/slab.hcoresight-config.hcoresight-etm-perf.hcoresight-syscfg.hcoresight-syscfg-configfs.h
Detected Declarations
function cscfg_get_feat_csdevfunction list_for_each_entryfunction cscfg_alloc_csdev_cfgfunction cscfg_add_csdev_cfgfunction cscfg_add_cfg_to_csdevsfunction list_for_each_entryfunction cscfg_alloc_csdev_featfunction cscfg_load_feat_csdevfunction cscfg_add_feat_to_csdevsfunction list_for_each_entryfunction cscfg_match_list_featfunction list_for_each_entryfunction cscfg_check_feat_for_cfgfunction cscfg_load_featfunction cscfg_load_configfunction list_for_each_entryfunction cscfg_csdev_get_feat_from_descfunction list_for_each_entryfunction cscfg_update_feat_param_valfunction cscfg_owner_getfunction cscfg_owner_putfunction cscfg_remove_owned_csdev_configsfunction list_for_each_entry_safefunction cscfg_remove_owned_csdev_featuresfunction list_for_each_entry_safefunction cscfg_fs_unregister_cfgs_featsfunction list_for_each_entryfunction cscfg_unload_owned_cfgs_featsfunction cscfg_load_owned_cfgs_featsfunction cscfg_set_configs_availablefunction cscfg_fs_register_cfgs_featsfunction cscfg_load_config_setsfunction cscfg_unload_config_setsfunction cscfg_add_cfgs_csdevfunction list_for_each_entryfunction cscfg_add_feats_csdevfunction list_for_each_entryfunction cscfg_list_add_csdevfunction cscfg_list_remove_csdevfunction list_for_each_entry_safefunction cscfg_register_csdevfunction cscfg_unregister_csdevfunction cscfg_csdev_reset_featsfunction cscfg_config_desc_getfunction cscfg_config_desc_putfunction _cscfg_activate_configfunction list_for_each_entryfunction _cscfg_deactivate_config
Annotated Snippet
if (feat_csdev) {
/*
* At least one feature on this device matches the config
* add a config instance to the device and a reference to the feature.
*/
if (!config_csdev) {
config_csdev = cscfg_alloc_csdev_cfg(csdev,
config_desc->nr_feat_refs);
if (!config_csdev)
return -ENOMEM;
config_csdev->config_desc = config_desc;
}
config_csdev->feats_csdev[config_csdev->nr_feat++] = feat_csdev;
}
}
/* if matched features, add config to device.*/
if (config_csdev) {
raw_spin_lock_irqsave(&csdev->cscfg_csdev_lock, flags);
list_add(&config_csdev->node, &csdev->config_csdev_list);
raw_spin_unlock_irqrestore(&csdev->cscfg_csdev_lock, flags);
}
return 0;
}
/*
* Add the config to the set of registered devices - call with mutex locked.
* Iterates through devices - any device that matches one or more of the
* configuration features will load it, the others will ignore it.
*/
static int cscfg_add_cfg_to_csdevs(struct cscfg_config_desc *config_desc)
{
struct cscfg_registered_csdev *csdev_item;
int err;
list_for_each_entry(csdev_item, &cscfg_mgr->csdev_desc_list, item) {
err = cscfg_add_csdev_cfg(csdev_item->csdev, config_desc);
if (err)
return err;
}
return 0;
}
/*
* Allocate a feature object for load into a csdev.
* memory allocated using the csdev->dev object using devm managed allocator.
*/
static struct cscfg_feature_csdev *
cscfg_alloc_csdev_feat(struct coresight_device *csdev, struct cscfg_feature_desc *feat_desc)
{
struct cscfg_feature_csdev *feat_csdev = NULL;
struct device *dev = csdev->dev.parent;
int i;
feat_csdev = devm_kzalloc(dev, sizeof(struct cscfg_feature_csdev), GFP_KERNEL);
if (!feat_csdev)
return NULL;
/* parameters are optional - could be 0 */
feat_csdev->nr_params = feat_desc->nr_params;
/*
* if we need parameters, zero alloc the space here, the load routine in
* the csdev device driver will fill out some information according to
* feature descriptor.
*/
if (feat_csdev->nr_params) {
feat_csdev->params_csdev = devm_kcalloc(dev, feat_csdev->nr_params,
sizeof(struct cscfg_parameter_csdev),
GFP_KERNEL);
if (!feat_csdev->params_csdev)
return NULL;
/*
* fill in the feature reference in the param - other fields
* handled by loader in csdev.
*/
for (i = 0; i < feat_csdev->nr_params; i++)
feat_csdev->params_csdev[i].feat_csdev = feat_csdev;
}
/*
* Always have registers to program - again the load routine in csdev device
* will fill out according to feature descriptor and device requirements.
*/
feat_csdev->nr_regs = feat_desc->nr_regs;
feat_csdev->regs_csdev = devm_kcalloc(dev, feat_csdev->nr_regs,
sizeof(struct cscfg_regval_csdev),
GFP_KERNEL);
if (!feat_csdev->regs_csdev)
Annotation
- Immediate include surface: `linux/platform_device.h`, `linux/slab.h`, `coresight-config.h`, `coresight-etm-perf.h`, `coresight-syscfg.h`, `coresight-syscfg-configfs.h`.
- Detected declarations: `function cscfg_get_feat_csdev`, `function list_for_each_entry`, `function cscfg_alloc_csdev_cfg`, `function cscfg_add_csdev_cfg`, `function cscfg_add_cfg_to_csdevs`, `function list_for_each_entry`, `function cscfg_alloc_csdev_feat`, `function cscfg_load_feat_csdev`, `function cscfg_add_feat_to_csdevs`, `function list_for_each_entry`.
- Atlas domain: Driver Families / drivers/hwtracing.
- Implementation status: integration 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.