Skip to content

Commit

Permalink
display: Avoid placing FBs at IOVA 0
Browse files Browse the repository at this point in the history
Also search harder for a matching dcp/disp iova, in case it matters.

Fixes: #391
Signed-off-by: Hector Martin <[email protected]>
  • Loading branch information
marcan committed May 17, 2024
1 parent 1841d88 commit dfffdf6
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/display.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ static uintptr_t display_map_fb(uintptr_t iova, u64 paddr, u64 size)
u64 iova_dcp = 0;

// start scanning for free iova space on vm-base
iova_dcp = dart_find_iova(dcp->dart_dcp, dart_vm_base(dcp->dart_dcp), size);
iova_dcp = dart_find_iova(dcp->dart_dcp, dart_vm_base(dcp->dart_dcp) + SZ_16K, size);
if (DART_IS_ERR(iova_dcp)) {
printf("display: failed to find IOVA for fb of %06zx bytes (dcp)\n", size);
return iova_dcp;
Expand All @@ -204,6 +204,15 @@ static uintptr_t display_map_fb(uintptr_t iova, u64 paddr, u64 size)
return iova_disp0;
}

// try to find the same IOVA on DCP again
if (iova_disp0 != iova_dcp) {
iova_dcp = dart_find_iova(dcp->dart_dcp, iova_disp0, size);
if (DART_IS_ERR(iova_dcp)) {
printf("display: failed to find IOVA for fb of %06zx bytes (dcp)\n", size);
return iova_dcp;
}
}

// assume this results in the same IOVA, not sure if this is required but matches what iboot
// does on other models.
if (iova_disp0 != iova_dcp) {
Expand Down Expand Up @@ -276,7 +285,7 @@ int display_start_dcp(void)
// Find the framebuffer DVA
fb_dva = dart_search(dcp->dart_disp, (void *)cur_boot_args.video.base);
// framebuffer is not mapped on the M1 Ultra Mac Studio
if (DART_IS_ERR(fb_dva))
if (DART_IS_ERR(fb_dva) || !fb_dva)
fb_dva = display_map_fb(0, pa, size);
if (DART_IS_ERR(fb_dva)) {
printf("display: failed to find display DVA\n");
Expand Down

0 comments on commit dfffdf6

Please sign in to comment.