drivers/accel/habanalabs/gaudi/gaudi_coresight.c
Source file repositories/reference/linux-study-clean/drivers/accel/habanalabs/gaudi/gaudi_coresight.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/accel/habanalabs/gaudi/gaudi_coresight.c- Extension
.c- Size
- 31301 bytes
- Lines
- 919
- Domain
- Driver Families
- Bucket
- drivers/accel
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
gaudiP.h../include/gaudi/gaudi_coresight.h../include/gaudi/asic_reg/gaudi_regs.h../include/gaudi/gaudi_masks.h../include/gaudi/gaudi_reg_map.huapi/drm/habanalabs_accel.h
Detected Declarations
function gaudi_coresight_timeoutfunction gaudi_config_stmfunction gaudi_config_etffunction gaudi_etr_validate_addressfunction hl_mem_area_inside_rangefunction gaudi_config_etrfunction gaudi_config_funnelfunction gaudi_config_bmonfunction gaudi_config_spmufunction gaudi_debug_coresightfunction gaudi_halt_coresight
Annotated Snippet
if (rc) {
dev_err(hdev->dev,
"Failed to disable STM on timeout, error %d\n",
rc);
return rc;
}
WREG32(base_reg + 0xE80, 4);
}
return 0;
}
static int gaudi_config_etf(struct hl_device *hdev,
struct hl_debug_params *params)
{
struct hl_debug_params_etf *input;
u64 base_reg;
u32 val;
int rc;
if (params->reg_idx >= ARRAY_SIZE(debug_etf_regs)) {
dev_err(hdev->dev, "Invalid register index in ETF\n");
return -EINVAL;
}
base_reg = debug_etf_regs[params->reg_idx] - CFG_BASE;
WREG32(base_reg + 0xFB0, CORESIGHT_UNLOCK);
val = RREG32(base_reg + 0x20);
if ((!params->enable && val == 0x0) || (params->enable && val != 0x0))
return 0;
val = RREG32(base_reg + 0x304);
val |= 0x1000;
WREG32(base_reg + 0x304, val);
val |= 0x40;
WREG32(base_reg + 0x304, val);
rc = gaudi_coresight_timeout(hdev, base_reg + 0x304, 6, false);
if (rc) {
dev_err(hdev->dev,
"Failed to %s ETF on timeout, error %d\n",
params->enable ? "enable" : "disable", rc);
return rc;
}
rc = gaudi_coresight_timeout(hdev, base_reg + 0xC, 2, true);
if (rc) {
dev_err(hdev->dev,
"Failed to %s ETF on timeout, error %d\n",
params->enable ? "enable" : "disable", rc);
return rc;
}
WREG32(base_reg + 0x20, 0);
if (params->enable) {
input = params->input;
if (!input)
return -EINVAL;
WREG32(base_reg + 0x34, 0x3FFC);
WREG32(base_reg + 0x28, input->sink_mode);
WREG32(base_reg + 0x304, 0x4001);
WREG32(base_reg + 0x308, 0xA);
WREG32(base_reg + 0x20, 1);
} else {
WREG32(base_reg + 0x34, 0);
WREG32(base_reg + 0x28, 0);
WREG32(base_reg + 0x304, 0);
}
return 0;
}
static bool gaudi_etr_validate_address(struct hl_device *hdev, u64 addr,
u64 size, bool *is_host)
{
struct asic_fixed_properties *prop = &hdev->asic_prop;
struct gaudi_device *gaudi = hdev->asic_specific;
/* maximum address length is 50 bits */
if (addr >> 50) {
dev_err(hdev->dev,
"ETR buffer address shouldn't exceed 50 bits\n");
return false;
Annotation
- Immediate include surface: `gaudiP.h`, `../include/gaudi/gaudi_coresight.h`, `../include/gaudi/asic_reg/gaudi_regs.h`, `../include/gaudi/gaudi_masks.h`, `../include/gaudi/gaudi_reg_map.h`, `uapi/drm/habanalabs_accel.h`.
- Detected declarations: `function gaudi_coresight_timeout`, `function gaudi_config_stm`, `function gaudi_config_etf`, `function gaudi_etr_validate_address`, `function hl_mem_area_inside_range`, `function gaudi_config_etr`, `function gaudi_config_funnel`, `function gaudi_config_bmon`, `function gaudi_config_spmu`, `function gaudi_debug_coresight`.
- Atlas domain: Driver Families / drivers/accel.
- Implementation status: source implementation candidate.
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.