Skip to content
This repository has been archived by the owner on Jun 24, 2023. It is now read-only.

SMC Key for TGDD and TCGC - Stats temperature not showing #14

Closed
seven-of-eleven opened this issue Aug 22, 2022 · 10 comments
Closed

SMC Key for TGDD and TCGC - Stats temperature not showing #14

seven-of-eleven opened this issue Aug 22, 2022 · 10 comments

Comments

@seven-of-eleven
Copy link

Hi, first thanks for the kexts.

Using smcread -s I get the following:

  TG0D  [sp78]  3.437500 (bytes 37 00)
  TG0P  [sp78]  3.437500 (bytes 37 00)
  TG0d  [sp78]  3.437500 (bytes 37 00)
  TG0p  [sp78]  3.437500 (bytes 37 00)

So I know your kext is working. However I am using Stats and the iGPU and 6600XT temperatures don't show. I did some digging in the Stats code and noted that it is using:

  • TGDD for the Radeon temperature
  • TCGS for the iGPU temperature
    image

"Stats/Modules/GPU/reader.swift"

            } else if ioClass.contains("amd") { // amd
                predictModel = "AMD Graphics"
                type = .discrete
                
                if temperature == nil || temperature == 0 {
                    if let tmp = SMC.shared.getValue("TGDD"), tmp != 128 {
                        temperature = Int(tmp)
                    }
                }
            } else if ioClass.contains("intel") { // intel
                predictModel = "Intel Graphics"
                type = .integrated
                
                if temperature == nil || temperature == 0 {
                    if let tmp = SMC.shared.getValue("TCGC"), tmp != 128 {
                        temperature = Int(tmp)
                    }
                }

The keys from SMCRadeonGPU.kext are translated as follows in Stats:
"Stats/Modules/Sensors/values.swift"

    Sensor(key: "TCGC", name: "GPU Intel Graphics", group: .GPU, type: .temperature),
    Sensor(key: "TG0D", name: "GPU diode", group: .GPU, type: .temperature),
    Sensor(key: "TGDD", name: "GPU AMD Radeon", group: .GPU, type: .temperature),
    Sensor(key: "TG0H", name: "GPU heatsink", group: .GPU, type: .temperature),
    Sensor(key: "TG0P", name: "GPU proximity", group: .GPU, type: .temperature),

I also found this SMC key listing that shows the same:

	{Key: "TCGC", Desc: "GPU Intel Graphics"},
	{Key: "TG%D", Desc: "GPU Diode %"},
	{Key: "TGDD", Desc: "GPU AMD Radeon"},

I have managed to manually change the Stats code and compile the program by simply changing the SMC key names and it does work but would require a recompile for each update.

So my ask is, can the TGDD key be added to your SMCRadeonGPU.kext? I tried but adding the TGDD key but was unsuccessful (I have no experience with this, other than poking through some code 😀).

@aluveitie
Copy link
Owner

Thanks for your detailed investigation 👍

This was a very tricky topic to begin with since the set of smc keys is specific to the SMBIOS used.
The current list of published keys proved to be working across most commonly used SMBIOS/App combinations.

If you look into dumps from VirtualSMC you'll see that TGDD is only used in certain MacBookPro's.
I'll make a custom build of SMCRadeonGPU to test, if that works I'd be happy to add that.

@seven-of-eleven
Copy link
Author

That's great. Thanks so much for your help. Let me know if there's anything else I can do.
For reference, the two devices I use Stats on are SMBIOS MacPro7,1 and iMac20,1. Based on my understanding of the programming, I assume Stats is not adjusting their SMC keys based on SMBIOS.

Thanks again.

@aluveitie
Copy link
Owner

I made a custom build of the SMCRadeonGPU kext to publish TGDD for the first found GPU:
SMCRadeonGPU.kext.zip

@seven-of-eleven
Copy link
Author

Ok. I tried the custom build. I noted the following from running smcread -s

[D0GT] type [87ps] 38377073 len [ 2] attr [80] -> 3200
[P0GT] type [87ps] 38377073 len [ 2] attr [80] -> 3200
[d0GT] type [87ps] 38377073 len [ 2] attr [80] -> 3200
[p0GT] type [87ps] 38377073 len [ 2] attr [80] -> 3200
[DDGT] type [?] 00000000 len [ 0] attr [00] -> NOT READABLE, code 89

So it looks like all the SMC key values are inverted? I included the complete listing from the command in the attached file.
smclisting.txt

Thanks.

@aluveitie
Copy link
Owner

Right, they have to be added in a specific order, otherwise this happens...

SMCRadeonGPU.kext.zip

@seven-of-eleven
Copy link
Author

Seems the order has changed but the SMC key values are still reversed.
smcread -s

[D0GT] type [87ps] 38377073 len [ 2] attr [80] -> 3200
[DDGT] type [87ps] 38377073 len [ 2] attr [80] -> 3200
[P0GT] type [87ps] 38377073 len [ 2] attr [80] -> 3200
[d0GT] type [87ps] 38377073 len [ 2] attr [80] -> 3200
[p0GT] type [87ps] 38377073 len [ 2] attr [80] -> 3200

Thanks.

@nishyp
Copy link

nishyp commented Dec 19, 2022

I also use the Stats app and I noticed the GPU Temp shows up in the Sensors section under GPU Proximity as it uses the TG0P Key based on @seven-of-eleven findings through Stats source.

I wanted to know if there was any progress on this implementation with TGDD Key?

@aluveitie
Copy link
Owner

I retried it, but still can't figure out why the keys get inverted. I already ran into this once years ago but forgot why this exactly happens...

@aluveitie
Copy link
Owner

Finally got a build working:

[TG0D] type [sp78] 73703738 len [ 2] attr [80] -> 2500
[TG0P] type [sp78] 73703738 len [ 2] attr [80] -> 2500
[TG0d] type [sp78] 73703738 len [ 2] attr [80] -> 2500
[TG0p] type [sp78] 73703738 len [ 2] attr [80] -> 2500
[TGDD] type [sp78] 73703738 len [ 2] attr [80] -> 2500

You can try:
SMCRadeonGPU.kext.zip

@nishyp
Copy link

nishyp commented Feb 15, 2023

Sorry for the delayed response @aluveitie
I just wanted to confirm temperature is working!
Thank you for this! 🥳

Screen Shot 2023-02-15 at 5 50 03 PM

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants