From nobody Tue Jan 30 14:31:13 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4TPSJx6nLyz58x00; Tue, 30 Jan 2024 14:31:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4TPSJx6JhNz4mKY; Tue, 30 Jan 2024 14:31:13 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1706625073; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=K33teYIhHghiqd9o1tq/DLILVO6jAXGEpQqi9btMGYA=; b=B0NmwXoK2j7h5A2hxIuJsLJsQSW0JQjVltWGlDGAgv2VGm/dNCg242qYv0SMzN0mNiUEdZ VLFAE10PorPb/lFsk7pFlqzW+BhRnhe+vtZ07MGjW4pbrWm5eKVP5KYFKoMjLt+H1l3ijg DB37SoGi2k2MW0COTVFI+dnM0m7pRwKWUKULrrzBatpVZ+BIX7L3RFqFZNFwZhmIKeQJGO jQbS5TEkqEXEcWHd8CEtCxUUt+Wkwt4Ddqyv8/Biqtg9nXPVoJvcHPEQh2qJdgIzpeuPTP TRYImp4TvUqtAPyNnTGYGqOVuH9DHWrVxbWLb/FI58lAInsY8OVtijGHMltmmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1706625073; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=K33teYIhHghiqd9o1tq/DLILVO6jAXGEpQqi9btMGYA=; b=IQ7na6x0tQxC7z5B+GDw7ljvNiWlhMAaqG+mzOeD+6qjx41BwWuqLs2VQceOzlLTVEfG43 +cm+DAEZ6zm16moa+vGE4yl3tk5ssWA0MOTDGS/I1f9UvM8iOQH+RJnxSxyDI/sKIWeVNA bqmI8uoBhgzghtHL2kTe7xIl/VT80e+KIZnbwUH/bfixGXVRicBeGofOlNTYdD2vAqLKsE f4ngfa6vndZQjGyUh7U29N87foObKNDR1CDkNcvLj1SgieCzTjRw3hZl28dKNlBtSyi2ti v5ez3jPOS0xCldZergoZkmW2YdWLmFEhvnig2iEHHJIzckLHZXBcOQbKDzLJnQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1706625073; a=rsa-sha256; cv=none; b=D84rfPoBdnbbmixGgLnaWjZ5ebS5Sl/elv/rziwZ6cisgZOBpxzp7UdLem/yoGdRO05Y/c EaGHg9jZEoUw6kRuaowHixwOd20M/1sseuFn2hjWZ+iqv+38hcuIGXYbqFc205aONDEFz7 r0cGG/v2PkPiCCOJxpyrHwuxGk6/FsNE07QanH3s1KEOLS43u1U7Km8FKGWEPdPEjkM1j8 DrlMciTbLRtaOLreqGkZDYFY3/AKSIv070ClxYZEsmN/btmrZeRTH5X+EgdmTNSxd8F0li Km2wn66+pMngmQ7K+B5++qJy8H1hGX3+n7TGWYkeCTykNFrI1rXZaLr15fTsTw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4TPSJx5FgXzftG; Tue, 30 Jan 2024 14:31:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 40UEVDS7024050; Tue, 30 Jan 2024 14:31:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 40UEVDEl024047; Tue, 30 Jan 2024 14:31:13 GMT (envelope-from git) Date: Tue, 30 Jan 2024 14:31:13 GMT Message-Id: <202401301431.40UEVDEl024047@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: f0122974fba0 - stable/13 - amdsmn(4), amdtemp(4): add support for Zen 4 List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: f0122974fba0cee78e8bd86351803d855ce85758 Auto-Submitted: auto-generated The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=f0122974fba0cee78e8bd86351803d855ce85758 commit f0122974fba0cee78e8bd86351803d855ce85758 Author: Akio Morita AuthorDate: 2023-08-01 20:32:12 +0000 Commit: Mark Johnston CommitDate: 2024-01-30 14:26:29 +0000 amdsmn(4), amdtemp(4): add support for Zen 4 Zen 4 support, tested on Ryzen 9 7900 Reviewed by: imp (previous version), mhorne Approved by: mhorne Obtained from: http://jyurai.ddo.jp/~amorita/diary/?date=20221102#p01 Differential Revision: https://reviews.freebsd.org/D41049 (cherry picked from commit 323a94afb6236bcec3a07721566aec6f2ea2b209) --- sys/dev/amdsmn/amdsmn.c | 7 +++++++ sys/dev/amdtemp/amdtemp.c | 17 +++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/sys/dev/amdsmn/amdsmn.c b/sys/dev/amdsmn/amdsmn.c index c38a549756c5..7737a3c3fa4c 100644 --- a/sys/dev/amdsmn/amdsmn.c +++ b/sys/dev/amdsmn/amdsmn.c @@ -59,6 +59,7 @@ #define PCI_DEVICE_ID_AMD_17H_M10H_ROOT 0x15d0 #define PCI_DEVICE_ID_AMD_17H_M30H_ROOT 0x1480 /* Also M70H, F19H M00H/M20H */ #define PCI_DEVICE_ID_AMD_17H_M60H_ROOT 0x1630 +#define PCI_DEVICE_ID_AMD_19H_M60H_ROOT 0x14d8 struct pciid; struct amdsmn_softc { @@ -102,6 +103,12 @@ static const struct pciid { .amdsmn_addr_reg = F17H_SMN_ADDR_REG, .amdsmn_data_reg = F17H_SMN_DATA_REG, }, + { + .amdsmn_vendorid = CPU_VENDOR_AMD, + .amdsmn_deviceid = PCI_DEVICE_ID_AMD_19H_M60H_ROOT, + .amdsmn_addr_reg = F17H_SMN_ADDR_REG, + .amdsmn_data_reg = F17H_SMN_DATA_REG, + }, }; /* diff --git a/sys/dev/amdtemp/amdtemp.c b/sys/dev/amdtemp/amdtemp.c index 2ead5ba96cf5..2fdecead6c0f 100644 --- a/sys/dev/amdtemp/amdtemp.c +++ b/sys/dev/amdtemp/amdtemp.c @@ -82,6 +82,7 @@ struct amdtemp_softc { #define AMDTEMP_FLAG_CT_10BIT 0x02 /* CurTmp is 10-bit wide. */ #define AMDTEMP_FLAG_ALT_OFFSET 0x04 /* CurTmp starts at -28C. */ int32_t sc_offset; + int32_t sc_temp_base; int32_t (*sc_gettemp)(device_t, amdsensor_t); struct sysctl_oid *sc_sysctl_cpu[MAXCPU]; struct intr_config_hook sc_ich; @@ -109,6 +110,7 @@ struct amdtemp_softc { #define DEVICEID_AMD_HOSTB17H_M10H_ROOT 0x15d0 #define DEVICEID_AMD_HOSTB17H_M30H_ROOT 0x1480 /* Also M70H, F19H M00H/M20H */ #define DEVICEID_AMD_HOSTB17H_M60H_ROOT 0x1630 +#define DEVICEID_AMD_HOSTB19H_M60H_ROOT 0x14d8 static const struct amdtemp_product { uint16_t amdtemp_vendorid; @@ -133,6 +135,7 @@ static const struct amdtemp_product { { VENDORID_AMD, DEVICEID_AMD_HOSTB17H_M10H_ROOT, false }, { VENDORID_AMD, DEVICEID_AMD_HOSTB17H_M30H_ROOT, false }, { VENDORID_AMD, DEVICEID_AMD_HOSTB17H_M60H_ROOT, false }, + { VENDORID_AMD, DEVICEID_AMD_HOSTB19H_M60H_ROOT, false }, }; /* @@ -178,6 +181,8 @@ static const struct amdtemp_product { #define AMDTEMP_17H_CCD_TMP_BASE 0x59954 #define AMDTEMP_17H_CCD_TMP_VALID (1u << 11) +#define AMDTEMP_ZEN4_CCD_TMP_BASE 0x59b08 + /* * AMD temperature range adjustment, in deciKelvins (i.e., 49.0 Celsius). */ @@ -519,6 +524,8 @@ amdtemp_attach(device_t dev) dev, CORE0_SENSOR0, amdtemp_sysctl, "IK", "Core 0 / Sensor 0 temperature"); + sc->sc_temp_base = AMDTEMP_17H_CCD_TMP_BASE; + if (family == 0x17) amdtemp_probe_ccd_sensors17h(dev, model); else if (family == 0x19) @@ -780,7 +787,7 @@ amdtemp_gettemp17h(device_t dev, amdsensor_t sensor) return (amdtemp_decode_fam17h_tctl(sc->sc_offset, val)); case CCD_BASE ... CCD_MAX: /* Tccd */ - error = amdsmn_read(sc->sc_smn, AMDTEMP_17H_CCD_TMP_BASE + + error = amdsmn_read(sc->sc_smn, sc->sc_temp_base + (((int)sensor - CCD_BASE) * sizeof(val)), &val); KASSERT(error == 0, ("amdsmn_read2")); KASSERT((val & AMDTEMP_17H_CCD_TMP_VALID) != 0, @@ -801,7 +808,7 @@ amdtemp_probe_ccd_sensors(device_t dev, uint32_t maxreg) sc = device_get_softc(dev); for (i = 0; i < maxreg; i++) { - error = amdsmn_read(sc->sc_smn, AMDTEMP_17H_CCD_TMP_BASE + + error = amdsmn_read(sc->sc_smn, sc->sc_temp_base + (i * sizeof(val)), &val); if (error != 0) continue; @@ -846,6 +853,7 @@ amdtemp_probe_ccd_sensors17h(device_t dev, uint32_t model) static void amdtemp_probe_ccd_sensors19h(device_t dev, uint32_t model) { + struct amdtemp_softc *sc = device_get_softc(dev); uint32_t maxreg; switch (model) { @@ -854,6 +862,11 @@ amdtemp_probe_ccd_sensors19h(device_t dev, uint32_t model) maxreg = 8; _Static_assert((int)NUM_CCDS >= 8, ""); break; + case 0x60 ... 0x6f: /* Zen4 Ryzen "Raphael" */ + sc->sc_temp_base = AMDTEMP_ZEN4_CCD_TMP_BASE; + maxreg = 8; + _Static_assert((int)NUM_CCDS >= 8, ""); + break; default: device_printf(dev, "Unrecognized Family 19h Model: %02xh\n", model);