From nobody Fri Sep 18 13:26:18 2026 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 4hmYL25s1qz6sSPG for ; Fri, 18 Sep 2026 13:26:18 +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 "YR2" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4hmYL24K1Hz4X2c for ; Fri, 18 Sep 2026 13:26:18 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1789737978; 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=d5ss1CHkkTcCqsWzY4g7v8fR9VwOGF/ne1BlbpWK/bY=; b=ItQ4NvuJ4tj9kLm3xkawg/yz4f5/bOGT0YEPPQuW9EWEnlG0O037GB8yTE08JXFVqnQ7lp 6fJ3pUO7g4vjjpEcM5YtkVtERkRCdYtwJDKL1V9LKMPI1nnJcCT7wP3vOeSeU0vai4gPLo 10WYsdjHiUav8bwWdP/dpXxwMIWuGNr8c2jGb3ujBE7ZWoWiEIwfrAn8RZ3Xrlk7kHT8IJ opijY1U0FxR+leNCERwti47IpEI2qZtuOgYcICQ8hHXXxn/wOT7eBT2GKqjyl0hSbdpSI3 GDKMslYxLX4TLlu9gGh7QaZs3W97motvekIcTu916V/JsWExOcmVSh2t++tg9g== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1789737978; b=copZOtLW4gXjlFA13lU4I26kcDQaOc3KJ7Tik6Xqr6yWT2Uw/oyz+gtWYBA1k35dl5yGmI sIYyKY41iO+rdc1zoCAOUV7iH2ZgLPFInLCSM4WRKQnoz/MEYCLTSGd/IhJ9CvG/oCnA3b Io33RT+l5WUOHmOeooud/lZdKxOFvKBSyETpCAA/l2RyvLqgza+lNOIbnVrU0XD4T9sNOo 07Ys3RKnydbyHL2V6J+e9DhleGtIL1ZMODeN23TCKH4NBd+iyFW96gzoAUicWfn5aqCC6k GP8Hn8vd0enfSofJ93yzdLdFgFtkkMe3ampvGVmt7PuoSBn01/PvVR4s82mozQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1789737978; 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=d5ss1CHkkTcCqsWzY4g7v8fR9VwOGF/ne1BlbpWK/bY=; b=Zo3AVgMK9UOpzioOrfhoVaRdcBRxEfrkJ6wAP5DI1deRYZZktP8nDEjVY6T5QMIt2ZXC9s lorK5A9wrqQa0yrTUQxrbKX74WbyZpX8aK4jm+jhtRjdGTwLw8ll3oGhGw07DgevK41o3O kdHQ1ZuZCVRq1uwIi7XI/CjBxTnhYYyAmMtUo6hcrAnNw+hbXoVCwOPdObeo9wx1Ks52nG 1Bz6pwTz+Tk2HKJmIT4HQ/+5PnWM3eK1R1rLvmDJntDGGRyLSxarukT7aNqK2Pq8YMw6V+ /MTqIDaI++COwLuByLH4D4wZiQmr4Mndw9EIpd0vwyteo/V6wCzfIroObzRUZQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4hmYL23M6dzKqW for ; Fri, 18 Sep 2026 13:26:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 3ed25 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Fri, 18 Sep 2026 13:26:18 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Olivier Certner Subject: git: 8aab12ca1898 - main - amdsmu: Fix CPU-model-specific matching 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: olce X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 8aab12ca1898e3fe62a85c39aa1921950d739284 Auto-Submitted: auto-generated Date: Fri, 18 Sep 2026 13:26:18 +0000 Message-Id: <6aad3bfa.3ed25.628adaf2@gitrepo.freebsd.org> The branch main has been updated by olce: URL: https://cgit.FreeBSD.org/src/commit/?id=8aab12ca1898e3fe62a85c39aa1921950d739284 commit 8aab12ca1898e3fe62a85c39aa1921950d739284 Author: Olivier Certner AuthorDate: 2026-09-17 13:38:57 +0000 Commit: Olivier Certner CommitDate: 2026-09-18 13:25:59 +0000 amdsmu: Fix CPU-model-specific matching For Krackan Point, CPU-model-specific matching would not work because amdsmu_match() browses amdsmu_products[] in order and returns the first match, and the Krackan Point's 'struct amdsmu_product' object variant with a 'model' field of 0, indicating that any model matches, is listed before the variant with model 0x70 in amdsmu_products[]. In practice, this means that reporting of IP blocks for Krackan Point model 0x70 only was broken. Specifically, not all the existing blocks were reported and most statistics were not attributed to the right blocks. Fix this by making amdsmu_match() parse amdsmu_products[] in reverse, so CPU-model-generic entries can continue to appear first and new specific ones can be added after them, which is the expected chronological order of additions. While here, since the CPU model is between 0 and 255, change the type used for CPU models to an 'int' and use the special value -1 to skip model match, as there exist CPUs reporting 0 as the model (even if, to our knowledge, only old CPUs seem to be doing that). While here, fix alignement and whitespace in amdsmu_products[]'s initializers. Reviewed by: obiwac Fixes: 9c77fb6aaa36 ("amdsmu: Add Krackan Point support") Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D59788 --- sys/dev/amdsmu/amdsmu.c | 20 ++++++++------------ sys/dev/amdsmu/amdsmu.h | 27 ++++++++++++++++----------- 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/sys/dev/amdsmu/amdsmu.c b/sys/dev/amdsmu/amdsmu.c index f7edc073efea..45e5cf7e944d 100644 --- a/sys/dev/amdsmu/amdsmu.c +++ b/sys/dev/amdsmu/amdsmu.c @@ -30,21 +30,17 @@ amdsmu_match(device_t dev, const struct amdsmu_product **product_out) const uint16_t vendorid = pci_get_vendor(dev); const uint16_t deviceid = pci_get_device(dev); - const uint32_t model = CPUID_TO_MODEL(cpu_id); + /* CPUID_TO_MODEL() returns a number between 0 and 255. */ + const int model = CPUID_TO_MODEL(cpu_id); - for (size_t i = 0; i < nitems(amdsmu_products); i++) { - const struct amdsmu_product *prod = &amdsmu_products[i]; + /* Reverse order to match specific models first. */ + for (size_t i = nitems(amdsmu_products); i != 0; i--) { + const struct amdsmu_product *prod = &amdsmu_products[i-1]; if (vendorid == prod->amdsmu_vendorid && - deviceid == prod->amdsmu_deviceid) { - - /* - * Some Krackan Point devices have different ip blocks - * based on CPU model. - */ - if (prod->model != 0x00 && model != prod->model) - continue; - + deviceid == prod->amdsmu_deviceid && + /* -1 indicates all models match. */ + (prod->model == -1 || model == prod->model)) { if (product_out != NULL) *product_out = prod; return (true); diff --git a/sys/dev/amdsmu/amdsmu.h b/sys/dev/amdsmu/amdsmu.h index ede275ac7168..2dc3890afb93 100644 --- a/sys/dev/amdsmu/amdsmu.h +++ b/sys/dev/amdsmu/amdsmu.h @@ -87,26 +87,31 @@ CTASSERT(nitems(amdsmu_ip_blocks_names_v2) <= IP_MAX_BLOCK_NAMES); static const struct amdsmu_product { uint16_t amdsmu_vendorid; uint16_t amdsmu_deviceid; - uint32_t model; + /* CPU model from CPUID_TO_MODEL() if specific to that model, or -1. */ + int model; int16_t idlemask_reg; size_t ip_block_count; const char **ip_blocks_names; uint32_t amdsmu_msg; } amdsmu_products[] = { - { CPU_VENDOR_AMD, PCI_DEVICEID_AMD_CEZANNE_ROOT, 0x00, - SMU_REG_IDLEMASK_CEZANNE, 12 , amdsmu_ip_blocks_names, + /* + * Lines with -1 as 'model' must come before ones having same vendor and + * device IDs but a real CPU model. + */ + { CPU_VENDOR_AMD, PCI_DEVICEID_AMD_CEZANNE_ROOT, -1, + SMU_REG_IDLEMASK_CEZANNE, 12, amdsmu_ip_blocks_names, SMU_REG_MSG_CEZANNE}, - { CPU_VENDOR_AMD, PCI_DEVICEID_AMD_REMBRANDT_ROOT, 0x00, - SMU_REG_IDLEMASK_PHOENIX, 12 , amdsmu_ip_blocks_names, + { CPU_VENDOR_AMD, PCI_DEVICEID_AMD_REMBRANDT_ROOT, -1, + SMU_REG_IDLEMASK_PHOENIX, 12, amdsmu_ip_blocks_names, SMU_REG_MSG_CEZANNE}, - { CPU_VENDOR_AMD, PCI_DEVICEID_AMD_PHOENIX_ROOT, 0x00, - SMU_REG_IDLEMASK_PHOENIX, 21 , amdsmu_ip_blocks_names, + { CPU_VENDOR_AMD, PCI_DEVICEID_AMD_PHOENIX_ROOT, -1, + SMU_REG_IDLEMASK_PHOENIX, 21, amdsmu_ip_blocks_names, SMU_REG_MSG_CEZANNE}, - { CPU_VENDOR_AMD, PCI_DEVICEID_AMD_KRACKAN_POINT_ROOT, 0x00, - SMU_REG_IDLEMASK_KRACKAN, 22, amdsmu_ip_blocks_names, + { CPU_VENDOR_AMD, PCI_DEVICEID_AMD_KRACKAN_POINT_ROOT, -1, + SMU_REG_IDLEMASK_KRACKAN, 22, amdsmu_ip_blocks_names, SMU_REG_MSG_KRACKAN }, - { CPU_VENDOR_AMD, PCI_DEVICEID_AMD_KRACKAN_POINT_ROOT, 0x70, - SMU_REG_IDLEMASK_KRACKAN, 25, amdsmu_ip_blocks_names_v2, + { CPU_VENDOR_AMD, PCI_DEVICEID_AMD_KRACKAN_POINT_ROOT, 0x70, + SMU_REG_IDLEMASK_KRACKAN, 25, amdsmu_ip_blocks_names_v2, SMU_REG_MSG_KRACKAN }, /* * XXX Strix Point (PCI_DEVICEID_AMD_STRIX_POINT_ROOT) doesn't support