Bug 228480 - [amdtemp] Add device id for Ryzen 2
Summary: [amdtemp] Add device id for Ryzen 2
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: CURRENT
Hardware: amd64 Any
: --- Affects Some People
Assignee: Conrad Meyer
URL:
Keywords: patch
Depends on:
Blocks: 233215
  Show dependency treegraph
 
Reported: 2018-05-25 09:11 UTC by Johannes Lundberg
Modified: 2019-01-22 21:33 UTC (History)
1 user (show)

See Also:
koobs: mfc-stable12+


Attachments
Patch for amdtemp.c and amdsmn.c (2.70 KB, patch)
2018-05-25 09:11 UTC, Johannes Lundberg
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Johannes Lundberg 2018-05-25 09:11:07 UTC
Created attachment 193681 [details]
Patch for amdtemp.c and amdsmn.c

I added a device id 0x15d0 to amdtemp and amdsmn and fixed up amdsmn a bit wrt pciids struct to match amdtemp and with proper macros.


# sysctl
dev.amdtemp.3.core0.sensor0: 60.2C
dev.amdtemp.3.sensor_offset: 0
dev.amdtemp.3.%parent: hostb0
dev.amdtemp.3.%pnpinfo: 
dev.amdtemp.3.%location: 
dev.amdtemp.3.%driver: amdtemp
dev.amdtemp.3.%desc: AMD CPU On-Die Thermal Sensors
dev.amdtemp.%parent: 

It seem to show the correct temperature but only for one core. If I attached the device to Data Fabric Function 3 pci id 0x15eb, which is suggested to be the correct way described here: 
https://patchwork.kernel.org/patch/10381565/ 
I get 4 temperatures in dev.cpu, however they're all 0.

The out then is:
# sysctl
dev.amdtemp.0.core0.sensor0: -0.0C
dev.amdtemp.0.sensor_offset: 0
dev.amdtemp.0.%parent: hostb6
dev.amdtemp.0.%pnpinfo: 
dev.amdtemp.0.%location: 
dev.amdtemp.0.%driver: amdtemp
dev.amdtemp.0.%desc: AMD CPU On-Die Thermal Sensors
dev.amdtemp.%parent: 
dev.cpu.3.temperature: -0.0C
dev.cpu.2.temperature: -0.0C
dev.cpu.1.temperature: -0.0C
dev.cpu.0.temperature: -0.0C

Maybe some offset that is not correct. 

I will continue to tinker with this but I'll post this for now. 

The motherboard is ASRock A320M-HDV.

# dmesg
CPU: AMD Ryzen 3 2200G with Radeon Vega Graphics     (3493.51-MHz K8-class CPU)
  Origin="AuthenticAMD"  Id=0x810f10  Family=0x17  Model=0x11  Stepping=0
  Features=0x178bfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CLFLUSH,MMX,FXSR,SSE,SSE2,HTT>
  Features2=0x7ed8320b<SSE3,PCLMULQDQ,MON,SSSE3,FMA,CX16,SSE4.1,SSE4.2,MOVBE,POPCNT,AESNI,XSAVE,OSXSAVE,AVX,F16C,RDRAND>
  AMD Features=0x2e500800<SYSCALL,NX,MMX+,FFXSR,Page1GB,RDTSCP,LM>
  AMD Features2=0x35c233ff<LAHF,CMP,SVM,ExtAPIC,CR8,ABM,SSE4A,MAS,Prefetch,OSVW,SKINIT,WDT,TCE,Topology,PCXC,PNXC,DBE,PL2I,MWAITX>
  Structured Extended Features=0x209c01a9<FSGSBASE,BMI1,AVX2,SMEP,BMI2,RDSEED,ADX,SMAP,CLFLUSHOPT,SHA>
  XSAVE Features=0xf<XSAVEOPT,XSAVEC,XINUSE,XSAVES>
  AMD Extended Feature Extensions ID EBX=0x1007<CLZERO,IRPerf,XSaveErPtr>
  SVM: (disabled in BIOS) NP,NRIP,VClean,AFlush,DAssist,NAsids=32768
  TSC: P-state invariant, performance statistics


# pciconf -lv
hostb0@pci0:0:0:0:	class=0x060000 card=0x15d01849 chip=0x15d01022 rev=0x00 hdr=0x00
    vendor     = 'Advanced Micro Devices, Inc. [AMD]'
    class      = bridge
    subclass   = HOST-PCI
none0@pci0:0:0:2:	class=0x080600 card=0x15d11022 chip=0x15d11022 rev=0x00 hdr=0x00
    vendor     = 'Advanced Micro Devices, Inc. [AMD]'
    class      = base peripheral
    subclass   = IOMMU
hostb1@pci0:0:1:0:	class=0x060000 card=0x00000000 chip=0x14521022 rev=0x00 hdr=0x00
    vendor     = 'Advanced Micro Devices, Inc. [AMD]'
    device     = 'Family 17h (Models 00h-0fh) PCIe Dummy Host Bridge'
    class      = bridge
    subclass   = HOST-PCI
pcib1@pci0:0:1:2:	class=0x060400 card=0x14531022 chip=0x15d31022 rev=0x00 hdr=0x01
    vendor     = 'Advanced Micro Devices, Inc. [AMD]'
    class      = bridge
    subclass   = PCI-PCI
pcib6@pci0:0:1:6:	class=0x060400 card=0x14531022 chip=0x15d31022 rev=0x00 hdr=0x01
    vendor     = 'Advanced Micro Devices, Inc. [AMD]'
    class      = bridge
    subclass   = PCI-PCI
hostb2@pci0:0:8:0:	class=0x060000 card=0x00000000 chip=0x14521022 rev=0x00 hdr=0x00
    vendor     = 'Advanced Micro Devices, Inc. [AMD]'
    device     = 'Family 17h (Models 00h-0fh) PCIe Dummy Host Bridge'
    class      = bridge
    subclass   = HOST-PCI
pcib7@pci0:0:8:1:	class=0x060400 card=0x00001022 chip=0x15db1022 rev=0x00 hdr=0x01
    vendor     = 'Advanced Micro Devices, Inc. [AMD]'
    class      = bridge
    subclass   = PCI-PCI
pcib8@pci0:0:8:2:	class=0x060400 card=0x00001022 chip=0x15dc1022 rev=0x00 hdr=0x01
    vendor     = 'Advanced Micro Devices, Inc. [AMD]'
    class      = bridge
    subclass   = PCI-PCI
intsmb0@pci0:0:20:0:	class=0x0c0500 card=0xffff1849 chip=0x790b1022 rev=0x61 hdr=0x00
    vendor     = 'Advanced Micro Devices, Inc. [AMD]'
    device     = 'FCH SMBus Controller'
    class      = serial bus
    subclass   = SMBus
isab0@pci0:0:20:3:	class=0x060100 card=0xffff1849 chip=0x790e1022 rev=0x51 hdr=0x00
    vendor     = 'Advanced Micro Devices, Inc. [AMD]'
    device     = 'FCH LPC Bridge'
    class      = bridge
    subclass   = PCI-ISA
hostb3@pci0:0:24:0:	class=0x060000 card=0x00000000 chip=0x15e81022 rev=0x00 hdr=0x00
    vendor     = 'Advanced Micro Devices, Inc. [AMD]'
    class      = bridge
    subclass   = HOST-PCI
hostb4@pci0:0:24:1:	class=0x060000 card=0x00000000 chip=0x15e91022 rev=0x00 hdr=0x00
    vendor     = 'Advanced Micro Devices, Inc. [AMD]'
    class      = bridge
    subclass   = HOST-PCI
hostb5@pci0:0:24:2:	class=0x060000 card=0x00000000 chip=0x15ea1022 rev=0x00 hdr=0x00
    vendor     = 'Advanced Micro Devices, Inc. [AMD]'
    class      = bridge
    subclass   = HOST-PCI
hostb6@pci0:0:24:3:	class=0x060000 card=0x00000000 chip=0x15eb1022 rev=0x00 hdr=0x00
    vendor     = 'Advanced Micro Devices, Inc. [AMD]'
    class      = bridge
    subclass   = HOST-PCI
hostb7@pci0:0:24:4:	class=0x060000 card=0x00000000 chip=0x15ec1022 rev=0x00 hdr=0x00
    vendor     = 'Advanced Micro Devices, Inc. [AMD]'
    class      = bridge
    subclass   = HOST-PCI
hostb8@pci0:0:24:5:	class=0x060000 card=0x00000000 chip=0x15ed1022 rev=0x00 hdr=0x00
    vendor     = 'Advanced Micro Devices, Inc. [AMD]'
    class      = bridge
    subclass   = HOST-PCI
hostb9@pci0:0:24:6:	class=0x060000 card=0x00000000 chip=0x15ee1022 rev=0x00 hdr=0x00
    vendor     = 'Advanced Micro Devices, Inc. [AMD]'
    class      = bridge
    subclass   = HOST-PCI
hostb10@pci0:0:24:7:	class=0x060000 card=0x00000000 chip=0x15ef1022 rev=0x00 hdr=0x00
    vendor     = 'Advanced Micro Devices, Inc. [AMD]'
    class      = bridge
    subclass   = HOST-PCI
xhci0@pci0:21:0:0:	class=0x0c0330 card=0x11421b21 chip=0x43bc1022 rev=0x02 hdr=0x00
    vendor     = 'Advanced Micro Devices, Inc. [AMD]'
    class      = serial bus
    subclass   = USB
ahci0@pci0:21:0:1:	class=0x010601 card=0x10621b21 chip=0x43b81022 rev=0x02 hdr=0x00
    vendor     = 'Advanced Micro Devices, Inc. [AMD]'
    class      = mass storage
    subclass   = SATA
pcib2@pci0:21:0:2:	class=0x060400 card=0x02011b21 chip=0x43b31022 rev=0x02 hdr=0x01
    vendor     = 'Advanced Micro Devices, Inc. [AMD]'
    class      = bridge
    subclass   = PCI-PCI
pcib3@pci0:29:4:0:	class=0x060400 card=0x33061b21 chip=0x43b41022 rev=0x02 hdr=0x01
    vendor     = 'Advanced Micro Devices, Inc. [AMD]'
    device     = '300 Series Chipset PCIe Port'
    class      = bridge
    subclass   = PCI-PCI
pcib4@pci0:29:6:0:	class=0x060400 card=0x33061b21 chip=0x43b41022 rev=0x02 hdr=0x01
    vendor     = 'Advanced Micro Devices, Inc. [AMD]'
    device     = '300 Series Chipset PCIe Port'
    class      = bridge
    subclass   = PCI-PCI
pcib5@pci0:29:7:0:	class=0x060400 card=0x33061b21 chip=0x43b41022 rev=0x02 hdr=0x01
    vendor     = 'Advanced Micro Devices, Inc. [AMD]'
    device     = '300 Series Chipset PCIe Port'
    class      = bridge
    subclass   = PCI-PCI
re0@pci0:37:0:0:	class=0x020000 card=0x81681849 chip=0x816810ec rev=0x11 hdr=0x00
    vendor     = 'Realtek Semiconductor Co., Ltd.'
    device     = 'RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller'
    class      = network
    subclass   = ethernet
vgapci0@pci0:56:0:0:	class=0x030000 card=0x15dd1002 chip=0x15dd1002 rev=0xc8 hdr=0x00
    vendor     = 'Advanced Micro Devices, Inc. [AMD/ATI]'
    device     = 'Radeon Vega 8 Mobile'
    class      = display
    subclass   = VGA
none1@pci0:56:0:1:	class=0x040300 card=0x15de1002 chip=0x15de1002 rev=0x00 hdr=0x00
    vendor     = 'Advanced Micro Devices, Inc. [AMD/ATI]'
    class      = multimedia
    subclass   = HDA
none2@pci0:56:0:2:	class=0x108000 card=0x15df1022 chip=0x15df1022 rev=0x00 hdr=0x00
    vendor     = 'Advanced Micro Devices, Inc. [AMD]'
    class      = encrypt/decrypt
xhci1@pci0:56:0:3:	class=0x0c0330 card=0xffff1849 chip=0x15e01022 rev=0x00 hdr=0x00
    vendor     = 'Advanced Micro Devices, Inc. [AMD]'
    class      = serial bus
    subclass   = USB
xhci2@pci0:56:0:4:	class=0x0c0330 card=0xffff1849 chip=0x15e11022 rev=0x00 hdr=0x00
    vendor     = 'Advanced Micro Devices, Inc. [AMD]'
    class      = serial bus
    subclass   = USB
none3@pci0:56:0:6:	class=0x040300 card=0xd8871849 chip=0x15e31022 rev=0x00 hdr=0x00
    vendor     = 'Advanced Micro Devices, Inc. [AMD]'
    class      = multimedia
    subclass   = HDA
ahci1@pci0:57:0:0:	class=0x010601 card=0x79011022 chip=0x79011022 rev=0x61 hdr=0x00
    vendor     = 'Advanced Micro Devices, Inc. [AMD]'
    device     = 'FCH SATA Controller [AHCI mode]'
    class      = mass storage
    subclass   = SATA
Comment 1 Johannes Lundberg 2018-05-25 09:24:54 UTC
Differential here: https://reviews.freebsd.org/D15567
Comment 2 Conrad Meyer freebsd_committer freebsd_triage 2018-11-14 03:22:46 UTC
I will go ahead and just commit the minimal patch to get the single working sensor on Ryzen 2 for now.  We can follow up trying to get more sensors in a later revision, ok?
Comment 3 commit-hook freebsd_committer freebsd_triage 2018-11-14 03:42:45 UTC
A commit references this bug:

Author: cem
Date: Wed Nov 14 03:42:40 UTC 2018
New revision: 340425
URL: https://svnweb.freebsd.org/changeset/base/340425

Log:
  amdsmn(4)/amdtemp(4): Attach to Ryzen 2 hostbridges

  As reported, tested, and patch supplied by Johannes.

  There may be future work to do to support multiple sensors, but for now, any
  sensor at all is a strict improvement for Ryzen 2 systems.

  PR:		228480
  Submitted by:	Johannes Lundberg <johalun0 AT gmail.com> (earlier version)
  Reported by:	deischen@, Johannes, and numerous others
  MFC after:	3.72 days

Changes:
  head/sys/dev/amdsmn/amdsmn.c
  head/sys/dev/amdtemp/amdtemp.c
Comment 4 commit-hook freebsd_committer freebsd_triage 2018-11-14 21:32:02 UTC
A commit references this bug:

Author: vangyzen
Date: Wed Nov 14 21:31:27 UTC 2018
New revision: 340446
URL: https://svnweb.freebsd.org/changeset/base/340446

Log:
  MFC r340425 (by cem)

  amdsmn(4)/amdtemp(4): Attach to Ryzen 2 hostbridges

  As reported, tested, and patch supplied by Johannes.

  There may be future work to do to support multiple sensors, but for now, any
  sensor at all is a strict improvement for Ryzen 2 systems.

  PR:		228480
  Submitted by:	Johannes Lundberg <johalun0 AT gmail.com> (earlier version)
  Reported by:	deischen@, Johannes, and numerous others
  Early MFC approved by:  cem
  Approved by:    re (kib)
  Relnotes:       yes

Changes:
_U  stable/12/
  stable/12/sys/dev/amdsmn/amdsmn.c
  stable/12/sys/dev/amdtemp/amdtemp.c
Comment 5 commit-hook freebsd_committer freebsd_triage 2019-01-22 21:33:32 UTC
A commit references this bug:

Author: mav
Date: Tue Jan 22 21:33:14 UTC 2019
New revision: 343323
URL: https://svnweb.freebsd.org/changeset/base/343323

Log:
  MFC r340425 (by cem): amdsmn(4)/amdtemp(4): Attach to Ryzen 2 hostbridges

  As reported, tested, and patch supplied by Johannes.

  There may be future work to do to support multiple sensors, but for now, any
  sensor at all is a strict improvement for Ryzen 2 systems.

  PR:             228480
  Submitted by:   Johannes Lundberg <johalun0 AT gmail.com> (earlier version)
  Reported by:    deischen@, Johannes, and numerous others

Changes:
_U  stable/11/
  stable/11/sys/dev/amdsmn/amdsmn.c
  stable/11/sys/dev/amdtemp/amdtemp.c