From 3df3e11504d552c9560be5c87bb4e3963b2c522f Mon Sep 17 00:00:00 2001 From: lvs1974 Date: Fri, 19 Nov 2021 13:27:38 +0100 Subject: [PATCH] Do not override CPU proximity SMC key in SMCDellSensors, clear activity counter in timer --- Changelog.md | 3 +++ Sensors/SMCDellSensors/KeyImplementations.cpp | 6 ------ Sensors/SMCDellSensors/SMCDellSensors.cpp | 3 +-- Sensors/SMCDellSensors/SMCDellSensors.hpp | 1 - Sensors/SMCDellSensors/kern_hooks.cpp | 3 ++- 5 files changed, 6 insertions(+), 10 deletions(-) diff --git a/Changelog.md b/Changelog.md index 2481b08b..a691f386 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,8 @@ VirtualSMC Changelog ==================== +#### v1.2.8 +- Do not override CPU proximity SMC key in SMCDellSensors + minor fixes in logic + #### v1.2.7 - Fixed build settings for 32-bit - Improved EC fan monitoring instructions, thx all the contributors diff --git a/Sensors/SMCDellSensors/KeyImplementations.cpp b/Sensors/SMCDellSensors/KeyImplementations.cpp index 67ae23cf..094a3fb0 100644 --- a/Sensors/SMCDellSensors/KeyImplementations.cpp +++ b/Sensors/SMCDellSensors/KeyImplementations.cpp @@ -76,12 +76,6 @@ SMC_RESULT FS__::update(const SMC_DATA *src) { return SmcSuccess; } -SMC_RESULT TC0P::readAccess() { - auto val = SMIMonitor::getShared()->state.tempInfo[index].temp; - *reinterpret_cast(data) = VirtualSMCAPI::encodeIntSp(SmcKeyTypeSp78, val); - return SmcSuccess; -} - SMC_RESULT TG0P::readAccess() { auto val = SMIMonitor::getShared()->state.tempInfo[index].temp; *reinterpret_cast(data) = VirtualSMCAPI::encodeIntSp(SmcKeyTypeSp78, val); diff --git a/Sensors/SMCDellSensors/SMCDellSensors.cpp b/Sensors/SMCDellSensors/SMCDellSensors.cpp index 44a829e1..8814eaf6 100644 --- a/Sensors/SMCDellSensors/SMCDellSensors.cpp +++ b/Sensors/SMCDellSensors/SMCDellSensors.cpp @@ -95,8 +95,7 @@ IOService *SMCDellSensors::probe(IOService *provider, SInt32 *score) { switch (type) { case TempInfo::CPU: - VirtualSMCAPI::addKey(KeyTC0P(0), vsmcPlugin.data, VirtualSMCAPI::valueWithSp(0, SmcKeyTypeSp78, new TC0P(i), - SMC_KEY_ATTRIBUTE_WRITE|SMC_KEY_ATTRIBUTE_READ)); + DBGLOG("sdell", "CPU Proximity sensor is handled by SMCProcessor plugin"); break; case TempInfo::GPU: VirtualSMCAPI::addKey(KeyTG0P(0), vsmcPlugin.data, VirtualSMCAPI::valueWithSp(0, SmcKeyTypeSp78, new TG0P(i), diff --git a/Sensors/SMCDellSensors/SMCDellSensors.hpp b/Sensors/SMCDellSensors/SMCDellSensors.hpp index 722b38bf..a219d71e 100644 --- a/Sensors/SMCDellSensors/SMCDellSensors.hpp +++ b/Sensors/SMCDellSensors/SMCDellSensors.hpp @@ -45,7 +45,6 @@ class EXPORT SMCDellSensors : public IOService { // the following constant defines smc key 'FS! ' static constexpr SMC_KEY KeyFS__ = SMC_MAKE_IDENTIFIER('F','S','!',' '); - static constexpr SMC_KEY KeyTC0P(size_t i) { return SMC_MAKE_IDENTIFIER('T','C',KeyIndexes[i],'P'); } static constexpr SMC_KEY KeyTG0P(size_t i) { return SMC_MAKE_IDENTIFIER('T','G',KeyIndexes[i],'P'); } static constexpr SMC_KEY KeyTm0P(size_t i) { return SMC_MAKE_IDENTIFIER('T','m',KeyIndexes[i],'P'); } static constexpr SMC_KEY KeyTN0P(size_t i) { return SMC_MAKE_IDENTIFIER('T','N',KeyIndexes[i],'P'); } diff --git a/Sensors/SMCDellSensors/kern_hooks.cpp b/Sensors/SMCDellSensors/kern_hooks.cpp index eb9f1522..203e7130 100644 --- a/Sensors/SMCDellSensors/kern_hooks.cpp +++ b/Sensors/SMCDellSensors/kern_hooks.cpp @@ -47,6 +47,7 @@ void KERNELHOOKS::deinit() void KERNELHOOKS::activateTimer(UInt32 delay) { + callbackKERNELHOOKS->eventTimer->cancelTimeout(); callbackKERNELHOOKS->eventTimer->setTimeoutMS(delay); } @@ -184,7 +185,7 @@ void KERNELHOOKS::processKext(KernelPatcher &patcher, size_t index, mach_vm_addr if (workLoop) { eventTimer = IOTimerEventSource::timerEventSource(workLoop, [](OSObject *owner, IOTimerEventSource *) { - if (atomic_load_explicit(&KERNELHOOKS::active_output, memory_order_acquire)) + while (atomic_load_explicit(&KERNELHOOKS::active_output, memory_order_acquire)) atomic_fetch_sub_explicit(&active_output, 1, memory_order_release); });