Skip to content

Commit

Permalink
dcp: Fix firmware mapping check on t8103/t600x
Browse files Browse the repository at this point in the history
t8103 and t600x use "asc-dram-mask" in iop-dcp-nub to mask bits out of
DMA addresses. This needs to be used in the firmware mappings
check/remap since the segments have maskable bits sets.

Fixes: 8332e24 ("dcp: Undo carnage from bad stage1 DART code")
Signed-off-by: Janne Grunau <[email protected]>
  • Loading branch information
jannau authored and marcan committed May 18, 2024
1 parent 56feda2 commit 421dfa4
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/dcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,20 +116,25 @@ static int dcp_create_firmware_mappings(const display_config_t *cfg, dcp_dev_t *
return -1;
}

u64 asc_dram_mask;
if (ADT_GETPROP(adt, node, "asc-dram-mask", &asc_dram_mask) < 0)
asc_dram_mask = 0;

const struct adt_segment_ranges *seg;
u32 segments_len;

seg = adt_getprop(adt, node, "segment-ranges", &segments_len);
unsigned int count = segments_len / sizeof(*seg);

for (unsigned int i = 0; i < count; i++) {
if (dart_translate_silent(dcp->dart_dcp, seg[i].remap))
u64 iova = seg[i].remap & ~asc_dram_mask;
if (dart_translate_silent(dcp->dart_dcp, iova))
continue;

size_t len = ALIGN_UP(seg[i].size, SZ_16K);
u32 flags = i == 0 ? 0b0100 : 0; // TEXT gets this bit set?
printf("dcp: Mapping segment #0 %lx -> %lx [%lx]\n", seg[i].remap, seg[i].phys, len);
if (dart_map_flags(dcp->dart_dcp, seg[i].remap, (void *)seg[i].phys, len, flags)) {
printf("dcp: Mapping segment #%u %lx -> %lx [%lx]\n", i, iova, seg[i].phys, len);
if (dart_map_flags(dcp->dart_dcp, iova, (void *)seg[i].phys, len, flags)) {
printf("dcp: Failed to map segment\n");
return -1;
}
Expand Down

0 comments on commit 421dfa4

Please sign in to comment.