From 70a6b47a1e2a6af9cf8f7efdf90c1da364f4d68a Mon Sep 17 00:00:00 2001 From: Janne Grunau Date: Sat, 18 May 2024 00:08:17 +0200 Subject: [PATCH 1/2] dart: Fix parsing of variable lenght "vm-base" property Signed-off-by: Janne Grunau --- src/dart.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/dart.c b/src/dart.c index bdc804ed8..abb020110 100644 --- a/src/dart.c +++ b/src/dart.c @@ -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); + } + } + if (dart->locked) dart->vm_base &= (1LLU << 36) - 1; return dart; From 6c9d1c15c1353bd881ac32a0da1225988a461113 Mon Sep 17 00:00:00 2001 From: Janne Grunau Date: Sat, 18 May 2024 00:15:09 +0200 Subject: [PATCH 2/2] dcp: Fix firmware mapping check on t8103/t600x 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 --- src/dcp.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/dcp.c b/src/dcp.c index d7a74db89..fb7b6cc1f 100644 --- a/src/dcp.c +++ b/src/dcp.c @@ -116,6 +116,10 @@ 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; @@ -123,13 +127,14 @@ static int dcp_create_firmware_mappings(const display_config_t *cfg, dcp_dev_t * 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; }