Bug 239607

Summary: amdtemp: Does not recognize AMD Ryzen 5 3600
Product: Base System Reporter: drclaw <drclaw>
Component: kernAssignee: Conrad Meyer <cem>
Status: Closed FIXED    
Severity: Affects Some People CC: blackvenom, cem, fullermd, johalun, koobs, mav, vangyzen, wes
Priority: --- Keywords: feature
Version: 12.1-RELEASEFlags: koobs: mfc-stable12+
koobs: mfc-stable11+
Hardware: amd64   
OS: Any   
See Also: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=218264
Attachments:
Description Flags
devinfo none

Description drclaw 2019-08-03 05:24:21 UTC
Created attachment 206229 [details]
devinfo

System : FreeBSD 12.0-RELEASE-p8 r350525 GENERIC  amd64
CPU : Ryzen 5 3600
Motherboard : MSI B450 Mortar

After kldloading amdtemp, amdsmn, no temperatures appear under sysctl dev.cpu


dmidecode -t processor

# dmidecode 3.2
# SMBIOS entry point at 0xdce5e000
Found SMBIOS entry point in EFI, reading table from /dev/mem.
SMBIOS 2.8 present.

Handle 0x0015, DMI type 4, 48 bytes
Processor Information
        Socket Designation: AM4
        Type: Central Processor
        Family: Zen
        Manufacturer: Advanced Micro Devices, Inc.
        ID: 10 0F 87 00 FF FB 8B 17
        Signature: Family 23, Model 113, Stepping 0
        Flags:
                FPU (Floating-point unit on-chip)
                VME (Virtual mode extension)
                DE (Debugging extension)
                PSE (Page size extension)
                TSC (Time stamp counter)
                MSR (Model specific registers)
                PAE (Physical address extension)
                MCE (Machine check exception)
                CX8 (CMPXCHG8 instruction supported)
                APIC (On-chip APIC hardware supported)
                SEP (Fast system call)
                MTRR (Memory type range registers)
                PGE (Page global enable)
                MCA (Machine check architecture)
                CMOV (Conditional move instruction supported)
                PAT (Page attribute table)
                PSE-36 (36-bit page size extension)
                CLFSH (CLFLUSH instruction supported)
                MMX (MMX technology supported)
                FXSR (FXSAVE and FXSTOR instructions supported)
                SSE (Streaming SIMD extensions)
                SSE2 (Streaming SIMD extensions 2)
                HTT (Multi-threading)
        Version: AMD Ryzen 5 3600 6-Core Processor
        Voltage: 1.1 V
        External Clock: 100 MHz
        Max Speed: 4200 MHz
        Current Speed: 3600 MHz
        Status: Populated, Enabled
        Upgrade: Socket AM4
        L1 Cache Handle: 0x0012
        L2 Cache Handle: 0x0013
        L3 Cache Handle: 0x0014
        Serial Number: Unknown
        Asset Tag: Unknown
        Part Number: Unknown
        Core Count: 6
        Core Enabled: 6
        Thread Count: 12
        Characteristics:
                64-bit capable
                Multi-Core
                Hardware Thread
                Execute Protection
                Enhanced Virtualization
                Power/Performance Control

Attachments :

devinfo -v > output.txt
pciconf -lv >> output.txt

Let me know if you need any further details.
Comment 1 Conrad Meyer freebsd_committer freebsd_triage 2019-08-05 21:36:47 UTC
Please try the following patch.  I believe it is all that is needed to add support for Zen 2 family 17h devices (such as Ryzen 3):

https://people.freebsd.org/~cem/pr239607.amdtemp.zen2.0.patch
Comment 2 commit-hook freebsd_committer freebsd_triage 2019-08-06 03:54:37 UTC
A commit references this bug:

Author: cem
Date: Tue Aug  6 03:54:28 UTC 2019
New revision: 350624
URL: https://svnweb.freebsd.org/changeset/base/350624

Log:
  amdtemp(4), amdsmn(4): Attach to Ryzen 3 (Zen 2) hostbridges

  PR:	239607
  Reported by:	"drclaw" <drclaw AT gmail.com>

Changes:
  head/sys/dev/amdsmn/amdsmn.c
  head/sys/dev/amdtemp/amdtemp.c
Comment 3 Kubilay Kocak freebsd_committer freebsd_triage 2019-08-06 09:49:08 UTC
@Conrad Thanks for resolving this so quickly! Could/should this be merged to stable/12,11 or did amdtemp et al only make it to 12?

Re-open for MFC (at least to 12)
Comment 4 Conrad Meyer freebsd_committer freebsd_triage 2019-08-06 15:49:26 UTC
(In reply to Kubilay Kocak from comment #3)
> @Conrad Thanks for resolving this so quickly! Could/should this be merged to
> stable/12,11 or did amdtemp et al only make it to 12?
> 
> Re-open for MFC (at least to 12)

They're both in 12 thanks to mav and vangyzen.  I don't do MFCs myself, but anyone else is welcome to.
Comment 5 drclaw 2019-08-08 23:04:25 UTC
Sorry for the delay.

Finally got around to installing kernel with the patches, looks good here. Thanks for fixing so quickly :)


% uname -a
FreeBSD dutch 12.0-STABLE FreeBSD 12.0-STABLE #2 r350624M: Wed Aug  7 08:43:02 AEST 2019     root@dutch:/usr/obj/usr/src/amd64.amd64/sys/GENERIC  amd64

% sysctl dev.cpu | grep -i temp
dev.cpu.11.temperature: 40.1C
dev.cpu.10.temperature: 40.1C
dev.cpu.9.temperature: 40.1C
dev.cpu.8.temperature: 40.1C
dev.cpu.7.temperature: 40.1C
dev.cpu.6.temperature: 40.1C
dev.cpu.5.temperature: 40.1C
dev.cpu.4.temperature: 40.1C
dev.cpu.3.temperature: 40.1C
dev.cpu.2.temperature: 40.1C
dev.cpu.1.temperature: 40.1C
dev.cpu.0.temperature: 40.1C
Comment 6 Conrad Meyer freebsd_committer freebsd_triage 2019-08-08 23:18:32 UTC
Cool, thanks for confirming the fix!
Comment 7 drclaw 2019-11-07 22:38:09 UTC
Still present in 12.1, updating to reflect.

Patch works fine. Just applied and rebuilt kernel and my temps are back again.
Comment 8 Kubilay Kocak freebsd_committer freebsd_triage 2019-11-15 01:58:49 UTC
Unless an EN or approval to merge support to releng/12.1 is possible, the feature/support will land in 12.2-RELEASE.

It is apparently presently supported in CURRENT 12-STABLE (stable/12), effectively 'resolving' this issue, minus a merge to stable/11.

Alexander/Eric: 

- Would you consider a merge to stable/11 ?
- I couldn't find the MFC commit to stable/12 for this issue (base r350624), can you mention which one it was in "base r<revision>" comment formatting
Comment 9 fullermd 2019-12-09 16:52:10 UTC
Still WBNI if it made it into stable/12.  The diff from r350624 applies cleanly and works:

% sysctl dev.cpu.0.temperature
dev.cpu.0.temperature: 34.2C
Comment 10 commit-hook freebsd_committer freebsd_triage 2019-12-09 17:13:42 UTC
A commit references this bug:

Author: mav
Date: Mon Dec  9 17:13:17 UTC 2019
New revision: 355561
URL: https://svnweb.freebsd.org/changeset/base/355561

Log:
  MFC r350624 (by cem):
  amdtemp(4), amdsmn(4): Attach to Ryzen 3 (Zen 2) hostbridges

  PR:	239607

Changes:
_U  stable/12/
  stable/12/sys/dev/amdsmn/amdsmn.c
  stable/12/sys/dev/amdtemp/amdtemp.c
Comment 11 commit-hook freebsd_committer freebsd_triage 2019-12-09 17:15:44 UTC
A commit references this bug:

Author: mav
Date: Mon Dec  9 17:14:44 UTC 2019
New revision: 355562
URL: https://svnweb.freebsd.org/changeset/base/355562

Log:
  MFC r350624 (by cem):
  amdtemp(4), amdsmn(4): Attach to Ryzen 3 (Zen 2) hostbridges

  PR:	239607

Changes:
_U  stable/11/
  stable/11/sys/dev/amdsmn/amdsmn.c
  stable/11/sys/dev/amdtemp/amdtemp.c
Comment 12 Kubilay Kocak freebsd_committer freebsd_triage 2019-12-10 01:24:57 UTC
^Triage: Assign to committer that resolved. Thank you mav@ for the merges to stable/*
Comment 13 Conrad Meyer freebsd_committer freebsd_triage 2020-01-17 17:03:07 UTC
*** Bug 243406 has been marked as a duplicate of this bug. ***