OpenCorePkg icon indicating copy to clipboard operation
OpenCorePkg copied to clipboard

OcAfterBootCompatLib: Add `DisableExternalAppleGpu` quirk to disable external GPUs on real Macs

Open PMheart opened this issue 3 years ago • 5 comments

Help Wanted

This does not work as reported at https://github.com/acidanthera/bugtracker/issues/928#issuecomment-1105446248. At this stage debug printing won't work either, making it harder to trace the correct Status code. One possible strategy suggested by @vit9696 is to brute-force it by DirectResetCold (i.e. check if Status == something, then DirectResetCold). However, this takes time. If someone wants to help with this process, I'd really appreciate.

closes https://github.com/acidanthera/bugtracker/issues/928

TODO:

  • [ ] Rebuild pdf after merging

PMheart avatar Apr 20 '22 19:04 PMheart

MacBookPro8,2 Testing

Tested using a MacBookPro8,2 (2011 15") unit with commit 98c923c305fd4a5881bfdd47b3e0d9d9e997f580, OpenCore will stall out after executing if (BootCompat->Settings.DisableExternalAppleGpu) {} code block. This is seen after End RandomSeed.

Setting the block to only set the variable still stalls the system in the same way:

  if (BootCompat->Settings.DisableExternalAppleGpu) {
    DisabledGpu = 1U;
    Status = gRT->SetVariable (
      L"gpu-power-prefs",
      &gApplePersonalizationVariableGuid,
      EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
      sizeof (DisabledGpu),
      &DisabledGpu
      );
  }

Image reference for stall: Screen Shot 2022-04-09 at 3 27 10 PM

khronokernel avatar Apr 24 '22 17:04 khronokernel

@PMheart Can put exit status in another var, assuming it is even exiting? And can put something else in another var before setting, and something other else in that var if setting exits, to check that?

mikebeaton avatar May 03 '22 08:05 mikebeaton

@khronokernel - probably a stupid suggestion, but what happens if you remove the EFI_VARIABLE_BOOTSERVICE_ACCESS bit from the mask sent to SetVariable?

mikebeaton avatar May 03 '22 08:05 mikebeaton

This could be replaced by https://github.com/acidanthera/OpenCorePkg/pull/390 if testing works out.

EDIT: The approach was not without any merit - e.g. it allowed setting the variable - but testing did not work out, see discussion on closed PR.

mikebeaton avatar Oct 25 '22 06:10 mikebeaton

Having gone round the houses, I'm now back to thinking that this commit should have been the right way to do it all along, except that it doesn't work! I'll try to PM yourself, pmheart, and Vit to try to work out what the heck we could try next.

EDIT: Actually, I've thought of one more thing to try, based more on the approach of this commit, before I ping you... so I'll do that.

mikebeaton avatar Oct 29 '22 21:10 mikebeaton

@PMheart - Hi! Is it worth keeping this PR open, for now, given that there remains an open bugtracker issue on this, plus my own failed attempt to do something similar, throwing up further issues, it seems.

mikebeaton avatar Nov 20 '23 20:11 mikebeaton