Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dcp: Fix firmware mapping check on t8103/t600x #392

Merged
merged 2 commits into from
May 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions src/dart.c
Original file line number Diff line number Diff line change
Expand Up @@ -320,9 +320,22 @@ dart_dev_t *dart_init_adt(const char *path, int instance, int device, bool keep_
dart->l1[i]);
}
}
if (ADT_GETPROP(adt, node, "vm-base", &dart->vm_base) < 0)
dart->vm_base = 0;
else
u32 len;
const void *prop = adt_getprop(adt, node, "vm-base", &len);
if (prop) {
if (len == sizeof(u32)) {
u32 tmp;
memcpy(&tmp, prop, sizeof(tmp));
dart->vm_base = tmp;
} else if (len == sizeof(u64)) {
u64 tmp;
memcpy(&tmp, prop, sizeof(tmp));
dart->vm_base = tmp;
} else {
printf("dart: unexpected length of vm-base property: %u\n", len);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't dart->vm_base be set to 0 here, just in case™?

}
}
if (dart->locked)
dart->vm_base &= (1LLU << 36) - 1;

return dart;
Expand Down
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
Loading