drivers/ras/amd/atl/map.c
Source file repositories/reference/linux-study-clean/drivers/ras/amd/atl/map.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/ras/amd/atl/map.c- Extension
.c- Size
- 19188 bytes
- Lines
- 780
- Domain
- Driver Families
- Bucket
- drivers/ras
- 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
internal.h
Detected Declarations
function Copyrightfunction df3_get_intlv_modefunction df3p5_get_intlv_modefunction df4_get_intlv_modefunction df4p5_get_intlv_modefunction get_intlv_modefunction get_hi_addr_offsetfunction get_dram_offsetfunction df3_6ch_get_dram_addr_mapfunction df2_get_dram_addr_mapfunction df3_get_dram_addr_mapfunction df4_get_dram_addr_mapfunction df4p5_get_dram_addr_mapfunction get_dram_addr_mapfunction get_coh_st_fabric_idfunction find_normalized_offsetfunction valid_mapfunction get_address_map_commonfunction get_num_intlv_chanfunction calculate_intlv_bitsfunction get_intlv_bit_posfunction get_num_intlv_diesfunction get_num_intlv_socketsfunction get_global_map_datafunction map_bits_validfunction validate_address_mapfunction dump_address_mapfunction get_address_map
Annotated Snippet
if (*norm_offset == 0) {
atl_debug(ctx, "Enabled map %u offset is 0", ctx->map.num);
return -EINVAL;
}
/* Offsets should always increase from one map to the next. */
if (*norm_offset <= last_offset) {
atl_debug(ctx, "Map %u offset (0x%016llx) <= previous (0x%016llx)",
ctx->map.num, *norm_offset, last_offset);
return -EINVAL;
}
/* Match if this map's offset is less than the current calculated address. */
if (ctx->ret_addr >= *norm_offset)
break;
last_offset = *norm_offset;
}
/*
* Finished search without finding a match.
* Reset to map 0 and no offset.
*/
if (ctx->map.num >= df_cfg.num_coh_st_maps) {
ctx->map.num = 0;
*norm_offset = 0;
}
return 0;
}
static bool valid_map(struct addr_ctx *ctx)
{
if (df_cfg.rev >= DF4)
return FIELD_GET(DF_ADDR_RANGE_VAL, ctx->map.ctl);
else
return FIELD_GET(DF_ADDR_RANGE_VAL, ctx->map.base);
}
static int get_address_map_common(struct addr_ctx *ctx)
{
u64 norm_offset = 0;
if (get_coh_st_fabric_id(ctx))
return -EINVAL;
if (find_normalized_offset(ctx, &norm_offset))
return -EINVAL;
if (get_dram_addr_map(ctx))
return -EINVAL;
if (!valid_map(ctx))
return -EINVAL;
ctx->ret_addr -= norm_offset;
return 0;
}
static u8 get_num_intlv_chan(struct addr_ctx *ctx)
{
switch (ctx->map.intlv_mode) {
case NONE:
return 1;
case NOHASH_2CHAN:
case DF2_2CHAN_HASH:
case DF3_COD4_2CHAN_HASH:
case DF4_NPS4_2CHAN_HASH:
case DF4p5_NPS4_2CHAN_1K_HASH:
case DF4p5_NPS4_2CHAN_2K_HASH:
return 2;
case DF4_NPS4_3CHAN_HASH:
case DF4p5_NPS4_3CHAN_1K_HASH:
case DF4p5_NPS4_3CHAN_2K_HASH:
return 3;
case NOHASH_4CHAN:
case DF3_COD2_4CHAN_HASH:
case DF4_NPS2_4CHAN_HASH:
case DF4p5_NPS2_4CHAN_1K_HASH:
case DF4p5_NPS2_4CHAN_2K_HASH:
return 4;
case DF4_NPS2_5CHAN_HASH:
case DF4p5_NPS2_5CHAN_1K_HASH:
case DF4p5_NPS2_5CHAN_2K_HASH:
return 5;
case DF3_6CHAN:
case DF4_NPS2_6CHAN_HASH:
case DF4p5_NPS2_6CHAN_1K_HASH:
case DF4p5_NPS2_6CHAN_2K_HASH:
Annotation
- Immediate include surface: `internal.h`.
- Detected declarations: `function Copyright`, `function df3_get_intlv_mode`, `function df3p5_get_intlv_mode`, `function df4_get_intlv_mode`, `function df4p5_get_intlv_mode`, `function get_intlv_mode`, `function get_hi_addr_offset`, `function get_dram_offset`, `function df3_6ch_get_dram_addr_map`, `function df2_get_dram_addr_map`.
- Atlas domain: Driver Families / drivers/ras.
- 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.