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

Enhanced maximum link rate fix, Fixed the page fault in the LSPCON driver, Submodules refactoring. #72

Merged
merged 115 commits into from
Oct 19, 2020

Conversation

0xFireWolf
Copy link
Contributor

This pull request contains 2 new features, 1 bug fix, and 5 code refactoring changes on submodules.

>> Enhanced Maximum Link Rate Fix

Abstract:

Users are no longer required to specify a maximum link rate for their builtin display via the dpcd-max-link-rate property. The "invalid" maximum link rate reported by the display panel has a special meaning in the eDP 1.4 standard. eDP 1.4 panels may support more link rates other than traditional ones such as RBR, HBR, HBR2 and HBR3. As such, a table of all supported rates can be found in another DPCD register. This update adds a new probe function to find and check the maximum link rate for eDP 1.4 panels, and hence eliminates the need of a manual value injection. The previous solution is used as a fallback mechanism, in case the probed value is not supported by the graphics driver. Additionally, this fix is extended to support Ice Lake platform.

Related Research Article:

Coffee Lake Intel UHD Graphics 630 on macOS Catalina: The ultimate solution to the kernel panic due to division by zero in the framebuffer driver

>> Fixed Page Fault in the LSPCON Driver

Abstract:

ReadAUX() is resolved for the maximum link rate fix but not for the LSPCON driver. As a result, if the maximum link rate fix is disabled, the function pointer is NULL and hence a page fault occurs. LSPCON driver needs ReadAUX() to wake up the DisplayPort AUX channel for the adapter. This issue is addressed by resolving the symbol for the LSPCON driver as well.

>> Submodules Refactoring

Abstract:

  • The maximum link rate fix, core display clock fix and HDMI dividers calculation fix are now implemented as patch submodules. A new file kern_igfx_clock.cpp is created to implement these clock-related fixes.
  • The I2C-over-AUX transaction APIs are separated from the LSPCON driver into a standalone submodule. Now one can enable verbose output in I2C transactions without enabling the LSPCON driver. It is also convenient to develop new patches that rely on I2C APIs.
  • The LSPCON driver has been relocated to a standalone source unit kern_igfx_lspcon.cpp/hpp.

In general, the size of IGFX is greatly reduced, and it is more clear to identify which functions are routed by a submodule.

0xFireWolf and others added 30 commits March 28, 2019 05:44
Conflicts:
	WhateverGreen/kern_igfx.cpp
	WhateverGreen/kern_igfx.hpp
…e from the adapter as some LSPCON adapters are automatically switched back to LS mode on power off (i.e. Cable removal, sleep/wake up cycle).
Copy link
Collaborator

@vit9696 vit9696 left a comment

Choose a reason for hiding this comment

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

Thanks for the patches, particularly the submodules. Makes it better as we go.

The changes look good. The refactored code was mostly there, so I did not review the it too precisely. Noted a few issues, mostly stylistic.

Also, could you do a history rebase next time, like git rebase origin/master? Would be easier to handle the changes with cleaner commit history.

WhateverGreen/kern_igfx.cpp Outdated Show resolved Hide resolved
WhateverGreen/kern_igfx.hpp Outdated Show resolved Hide resolved
WhateverGreen/kern_igfx.hpp Outdated Show resolved Hide resolved
WhateverGreen/kern_igfx.hpp Outdated Show resolved Hide resolved
WhateverGreen/kern_igfx_clock.cpp Outdated Show resolved Hide resolved
WhateverGreen/kern_igfx_clock.cpp Outdated Show resolved Hide resolved
WhateverGreen/kern_igfx_clock.cpp Outdated Show resolved Hide resolved
WhateverGreen/kern_igfx_i2c_aux.cpp Outdated Show resolved Hide resolved
@@ -503,7 +437,7 @@ bool IGFX::processKext(KernelPatcher &patcher, size_t index, mach_vm_address_t a
bool bklKabyFb = realFramebuffer == &kextIntelKBLFb && cflBacklightPatch == CoffeeBacklightPatch::On;
// Solve ReadRegister32 just once as it is shared
if (bklCoffeeFb || bklKabyFb ||
RPSControl.enabled || ForceWakeWorkaround.enabled || coreDisplayClockPatch) {
RPSControl.enabled || ForceWakeWorkaround.enabled || modCoreDisplayClockFix.enabled) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is a bit ugly. Probably we want a separate bool for submodules like requiresGenericRegisterIo. We can make a joint version of this bool in IGFX, assign it in processKernel as an OR of all the submodules values, and then use here.

For now since not all entries are submodules we can assign it some hardcoded entries too. But please add a FIXME.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Totally agreed. At this moment, backlight fix is the only one that injects code to readRegister32/writeRegister32, while others only need them as helper functions.

The worst case is that multiple fixes request to inject code to those functions, so we probably need something like GenericRegisterModifier to orchestrate injection requests. The same thing might happen in the AUX register case.

For the global controller access, we could apply the same concept as well. Apple has refactored a lot of code from AppleIntelFramebufferController to the new class AppleIntelPort, so a new fix might need the controller instance to fetch the framebuffer instance associated with a port via AppleIntelFramebufferController::getFBFromPort().

WhateverGreen/kern_igfx.hpp Show resolved Hide resolved
@0xFireWolf
Copy link
Contributor Author

@vit9696 I think that's all for this PR. I will do a history rebase next time, and I will take a look at the register refactoring (#72 (comment)) once I have time. The current RPS control fix and the force wake workaround are already nicely packed, so I think it would be easy to port them as a submodule.

Let me know if there any further changes I need to make before this PR is merged.

Thanks for your time.

@vit9696
Copy link
Collaborator

vit9696 commented Oct 18, 2020

routeMultiple and solveMultiple should not leave errors after them, so you do not need clearError. The rest looks good.

@0xFireWolf
Copy link
Contributor Author

routeMultiple and solveMultiple should not leave errors after them, so you do not need clearError. The rest looks good.

Done.

@vit9696 vit9696 merged commit 80f4727 into acidanthera:master Oct 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants