From nobody Tue Oct 06 18:53:52 2026 X-Original-To: dev-commits-src-main@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 4hzllh29kjz6Z2yw for ; Tue, 06 Oct 2026 18:53:52 +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 4hzllh1L8xz4Hh4 for ; Tue, 06 Oct 2026 18:53:52 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1791312832; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=jENtJj4cK2nRjRLtALRFKHsSIY6zyS5zOqshs46iD2I=; b=osfsmeq+qJv+aprTp4qRsnNW9hKd+FLLCRb8GyK55QnRqlTQ+LN7K2T0lAXRG4vbkSrPwe Pj+r6Yq6CuaIq6LShOyMVI3pi2gJ0b8mDhAwrcnwdMBSRirinGzA6VU8a1rG3qXdHckhjt fegvECSFSrl6OH/fgmpMgahSjwfiJ8JcMmaKnIC4tt7dmUtPGUXa9k0epdlI2SL3sdEQBV ltlF42PHSMKHTjNWc0F4BOFq395G4T7xzYHqLcHgqkE/cFen+QZ5RomQbXGGhiEaorZwjV lwJD3BJVzxJqMH2DQVS2n+zYsIPAC0upWllCHKrTzUVacli7fVu8HGsM0Fp1gQ== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1791312832; b=UzUGgINud90RZIbUQGpLNko9nzZCmpyBNgUjm634qNxMpqrsEJRRIarPnuBSL/Sy3eMxlL tdkBNuKgwnWMchOCVgzrtCjq5PzLQ9kvVBrxDW3Px+H+Fo1/D15ByZK/p2dGEf7gSFepU/ og0rS0iFmhxUpyEOdajMRllLiO8J4DPPpA2iiCfCYicB3JZ/mbAKjsADoCCgnCKZ8xPjv/ LOXZLUsWaQBAcOXArWXnWL7Xs5haQCFhPV2Rlu72qG5WuT7WtLvulLiWe79uMr3N9K2Nfk AOKEGyUYkD2758k38kflHkV7ZKJ2LBwOGV/peym2Jo348tLMFcfK8B4mJqIRqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1791312832; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=jENtJj4cK2nRjRLtALRFKHsSIY6zyS5zOqshs46iD2I=; b=unQVCLTYlOabqXLS+CMiP7jFcDOp9WU5Sb3GuYBqk50U42bfJTAfQGv+0NqIXdSGZWHJKL 1mcnwgc6503tmEKLqqyHSZo77Vzsew0nx3qqg2wrX2ChS+NAzjKb/BuuyqhYoKvNpUutsH w1FbH0pKL/hER/7ARMgk/ifqRk9W4z+VNBmfJTftH2bRyEX+GNa+PigNcNXd/akbgK20WN B/e8EHoHKnSnqE4DiYE03P2uGkRjS4nYOjePCt9khdEahN0XCGYyLZmH6P9n1vrZ7G9xMe 7C6ifRiIURgXrnYgW/ygu4peQsPpx6KMP4Yo4m7+VXedFjqrx+tkbB1ywCwqqA== 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 4hzllh0Pc3zJHy for ; Tue, 06 Oct 2026 18:53:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 40061 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 06 Oct 2026 18:53:52 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Cc: Andre Silva From: Mitchell Horne Subject: git: 572cd669d699 - main - hwpmc: handle delayed IBS NMIs on Zen 6 List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 572cd669d6997b759084191007f3744a3610b529 Auto-Submitted: auto-generated Date: Tue, 06 Oct 2026 18:53:52 +0000 Message-Id: <6ac543c0.40061.62706664@gitrepo.freebsd.org> The branch main has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=572cd669d6997b759084191007f3744a3610b529 commit 572cd669d6997b759084191007f3744a3610b529 Author: Andre Silva AuthorDate: 2026-10-06 18:42:35 +0000 Commit: Mitchell Horne CommitDate: 2026-10-06 18:53:44 +0000 hwpmc: handle delayed IBS NMIs on Zen 6 On Zen 6, an extra IBS NMI can arrive after later samples. Keep the credit until the empty NMI arrives, and handle fetch and op samples when both are ready. Reviewed by: mhorne Fixes: 34b00ed041a4 ("hwpmc: fix IBS fetch and op NMI handling") Fixes: e51ef8ae490f ("hwpmc: Initial support for AMD IBS") Sponsored by: AMD Differential Revision: https://reviews.freebsd.org/D60367 --- sys/dev/hwpmc/hwpmc_ibs.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/sys/dev/hwpmc/hwpmc_ibs.c b/sys/dev/hwpmc/hwpmc_ibs.c index be981b0c7a07..60e7323dbcb8 100644 --- a/sys/dev/hwpmc/hwpmc_ibs.c +++ b/sys/dev/hwpmc/hwpmc_ibs.c @@ -48,6 +48,7 @@ #include #define IBS_STOP_ITER 50 /* Stopping iterations */ +#define IBS_NMI_CREDIT_MAX 2 /* Max owed IBS NMIs per CPU */ /* AMD IBS PMCs */ struct ibs_descr { @@ -97,7 +98,7 @@ SYSCTL_U64(_kern_hwpmc, OID_AUTO, ibs_op_ctl2_extra_mask, CTLFLAG_RDTUN, struct ibs_cpu { int pc_status; - int pc_nmi_credit; /* latched NMIs already serviced */ + int pc_nmi_credit; /* owed NMIs already serviced */ struct pmc_hw pc_ibspmcs[IBS_NPMCS]; }; static struct ibs_cpu **ibs_pcpu; @@ -725,13 +726,21 @@ pmc_ibs_intr(struct trapframe *tf) } /* - * When both units were serviced, the second unit's NMI may still be - * latched and will arrive with no valid bit set. Claim that one - * NMI so it is not reported as unknown. + * When both units were serviced, the second unit's NMI is still + * owed and will arrive with no valid bit set. It is not always + * the next NMI: on Zen 6 one or more NMIs carrying a single new + * sample can arrive first, and those may carry both samples again. + * Count the owed NMIs and let each NMI with no valid bit consume one, + * so they are not reported as unknown. Cap the count, since every + * leftover credit would hide a genuine unknown NMI later. */ - if (retval == 0 && pac->pc_nmi_credit != 0) + if (retval == 2) { + if (pac->pc_nmi_credit < IBS_NMI_CREDIT_MAX) + pac->pc_nmi_credit++; + } else if (retval == 0 && pac->pc_nmi_credit > 0) { + pac->pc_nmi_credit--; retval = 1; - pac->pc_nmi_credit = (retval == 2); + } if (retval > 1) retval = 1;