floe / smc_util

Apple System Management Control (SMC) utility
147 stars 26 forks source link

Will it work on post High Sierra macOS? #8

Open mwkchan opened 3 years ago

mwkchan commented 3 years ago

This work on my 2011 iMac 27" under Linux environment. I was wondering if I am able to install a post High Sierra macOS (using OpenCore Patcher) to my 2011 iMac, would this bring back the TDM functionality?

kgarrels commented 3 years ago

I did a little investigation: on the 2011 iMac, TDM does not go through the SMC, but is handled by Thunderbolt. So the method described here will not work.

Below show the console log when you enable/disable TDM.

Here is a link that describes Thunderbolt paths: https://developer.apple.com/library/archive/documentation/HardwareDrivers/Conceptual/ThunderboltDevGuide/Basics/Basics.html#//apple_ref/doc/uid/TP40011138-CH2-SW6

I guess you need some deep Thunderbolt know how to enable these video paths under linux.

Any suggestions?

standard    14:55:10.813548 +0200   kernel  Thunderbolt DP - activating Video path - SRC [0:0x0:0x2] DST [0:0x0:0xb] - Initial Credits [int=0 src=0 dst=0] NFC Credits [int=14 src=5 dst=14]
standard    14:55:10.814050 +0200   kernel  Thunderbolt DP - activating Aux Tx path (A) - SRC [0:0x0:0x2] DST [0:0x0:0x6] - Initial Credits [int=2 src=2 dst=1] NFC Credits [int=0 src=0 dst=0]
standard    14:55:10.814564 +0200   kernel  Thunderbolt DP - activating Aux Tx path (B) - SRC [0:0x0:0x6] DST [0:0x0:0xb] - Initial Credits [int=2 src=2 dst=1] NFC Credits [int=0 src=0 dst=0]
standard    14:55:10.815079 +0200   kernel  Thunderbolt DP - activating Aux Rx path (A) - SRC [0:0x0:0xb] DST [0:0x0:0x6] - Initial Credits [int=2 src=7 dst=1] NFC Credits [int=0 src=0 dst=0]
standard    14:55:10.815594 +0200   kernel  Thunderbolt DP - activating Aux Rx path (B) - SRC [0:0x0:0x6] DST [0:0x0:0x2] - Initial Credits [int=2 src=7 dst=1] NFC Credits [int=0 src=0 dst=0]
standard    14:55:11.986277 +0200   kernel  IOThunderboltSwitch<0x0>(0x0)::listenerCallback - Thunderbolt HPD packet for route = 0x0 port = 11 unplug = 0
standard    14:55:11.986318 +0200   kernel  IOThunderboltSwitch<0x0>(0x0)::listenerCallback - Thunderbolt HPD packet for route = 0x0 port = 11 unplug = 0
standard    14:59:35.347288 +0200   kernel  IOThunderboltSwitch<0x0>(0x0)::listenerCallback - Thunderbolt HPD packet for route = 0x0 port = 11 unplug = 1
standard    14:59:35.347668 +0200   kernel  Thunderbolt DP - destroying Video path - SRC [0:0x0:0x2] DST [0:0x0:0xb]
standard    14:59:35.368898 +0200   kernel  Thunderbolt DP - destroying Aux Rx path (A) - SRC [0:0x0:0xb] DST [0:0x0:0x6]
standard    14:59:35.390523 +0200   kernel  Thunderbolt DP - destroying Aux Rx path (B) - SRC [0:0x0:0x6] DST [0:0x0:0x2]
standard    14:59:35.413360 +0200   kernel  Thunderbolt DP - destroying Aux Tx path (A) - SRC [0:0x0:0x2] DST [0:0x0:0x6]
standard    14:59:35.435888 +0200   kernel  Thunderbolt DP - destroying Aux Tx path (B) - SRC [0:0x0:0x6] DST [0:0x0:0xb]
protocold commented 3 years ago

wait, I think @mwkchan said this work on his 2011 under linux tho so this method ought to have worked?!

Also, what he was asking is whether there is a way to retrofit all these into the iMac that run later version of MacOS (e.g. Mojave/Catalina/Big Sur etc) which apple removed the TDM feature?

@kgarrels when you did the investigation, did you run it under High Sierra or other Mac OS version?

Any thought?

kgarrels commented 3 years ago

good point - I assume the difference lies in "mid 2011" and "late 2011", you can see the difference in the video option: https://everymac.com/systems/apple/imac/imac-aluminum-faq/differences-between-imac-aluminum-mid-2011-late-2011-education-models.html

not sure though...

my tests were under High Sierra, mid 2011 27'' imac, the relevant SMC registers do not exist on it.

protocold commented 3 years ago

I have a mid-2010 27" here but I think it doesnt help on the thunderbolt situation that you encountered.

However, I am also trying to see if it is possible to retrofit this in later version of the macos...

From what I understand in the 2010 case, it seems like dpd (under mac os in High Sierra or older) and SmcDumpKey (under linux which Floe modified) are responsible for writing to the smc register and then it is the smc that do the actual switching... is that how you understand it?

I wonder if i can just replace/drop in the dpd and dpaudiothru (which dpd launches) from high sierra into the later version of Mac OS to make this works... all guessing at this point..

protocold commented 3 years ago

So I dug up this small util called smc that can do read/write to SMC which is part of smcFanControl : https://github.com/hholtmann/smcFanControl/releases/tag/2.6

Apple System Management Control (SMC) tool 0.01 Usage: ./smc [options] -f : fan info decoded -h : help -k : key to manipulate -l : list all keys and values -r : read the value of a key -w : write the specified value to a key -v : version

If i ran "smc -l" I could see a list of keys in the SMC which includes MVHR/MVMR.

Macs-iMac:Resources mac$ ./smc -k MVHR -r MVHR [flag] (bytes 01) Macs-iMac:Resources mac$ ./smc -k MVMR -r MVMR [ui8 ] 0 (bytes 00) Macs-iMac:Resources mac$ ./smc -k MVMR -w 2 Error: value is not valid Macs-iMac:Resources mac$ ./smc -k MVMR -w 02 Error: SMCWriteKey() = e00002c1

I tried to write the value 2 to it but it doesnt work. Any idea?

protocold commented 3 years ago

I ran the dtrace script but it didnt work:

mac$ sudo dtrace -qCs powermetrics.d -c 'powermetrics --sampler smc -n 1' Password: unable to get smc values Machine model: iMac11,3 SMC version: 1.59f2 EFI version: 99.0.0 OS version: 17G14042 Boot arguments: Boot time: Thu Oct 14 00:58:06 2021

Sampled system activity (Thu Oct 14 10:25:02 2021 +0800) (5000.94ms elapsed)

Did i launch the command correctly? Maybe it only works under Yosemite?

protocold commented 2 years ago

Ok. I re-run the smc util as root and this time it works!

On the 2010 under High Sierra:

To turn TDM on: sudo ./smc -k MVHR -w 01 (wait 1 second) sudo ./smc -k MVMR -w 02

To turn TDM off: sudo ./smc -k MVHR -w 00 (wait 1 second) sudo ./smc -k MVMR -w 02

protocold commented 2 years ago

I can confirm these commands also work under Big Sur on the 2010!!!

JaggerJo commented 2 years ago

@protocold Thx :)

mwkchan commented 2 years ago

I will need to install that to try. Sounds like a task for one of my coming weekends.

On Mon, 18 Oct 2021 at 15:39, protocold @.***> wrote:

@mwkchan https://github.com/mwkchan Do you have any newer macos on your machine that you can run some test?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/floe/smc_util/issues/8#issuecomment-945845620, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMG6EA6SWHL3NIG4S6OZD6LUHQWSLANCNFSM47DGTEXA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

mwkchan commented 2 years ago

How can I find the smc binary? Do I need to compile it from the source code?

On Wed, 13 Oct 2021 at 16:52, protocold @.***> wrote:

So I dug up this small util called smc that can do read/write to SMC which is part of smcFanControl : https://github.com/hholtmann/smcFanControl/releases/tag/2.6

If i ran "smc -l" I could see a list of keys in the SMC which includes MVMR.

Macs-iMac:Resources mac$ ./smc -k MVHR -r MVHR [flag] (bytes 01) Macs-iMac:Resources mac$ ./smc -k MVMR -r MVMR [ui8 ] 0 (bytes 00) Macs-iMac:Resources mac$ ./smc -k MVMR -w 2 Error: value is not valid Macs-iMac:Resources mac$ ./smc -k MVMR -w 02 Error: SMCWriteKey() = e00002c1

I tried to write the value 2 to it but it doesnt work. Any idea?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/floe/smc_util/issues/8#issuecomment-942443642, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMG6EA5NSFTBNEHKYFSSIW3UGWTNPANCNFSM47DGTEXA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

aruizcon commented 2 years ago

You can find smc binary in ./Resources/ folder from smcFanControl repository.

I have an iMac mid 2011 (Model iMac 12,2) with High Sierra. I've installed Gnu Linux distribution as a primary OS but I need TDM functionality too. In Mac OS High Sierra it is still working. But this method doesn't work because MVHR and MVMR registers doesn't exists in keys list from smc utility.

strick commented 2 years ago

Was anyone able to overcome the Thunderbolt issue regarding iMac mid 2011?

BeauSlim commented 2 years ago

Great stuff! This repo's Linux tool is working great under Ubuntu 22.02 and protocold's smc method works great under OCLP Monterey. iMac 11,3 (Mid 2010).
If anybody is having trouble installing smc, just "brew install smcfancontrol" and you will find it under /Applications/smcFanControl.app/Contents/Resources/