From nobody Fri Nov 13 01:16:48 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 4jQfVS6Bpxz6y0KL for ; Fri, 13 Nov 2026 01:16:48 +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) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jQfVS5lyQz4mvS for ; Fri, 13 Nov 2026 01:16:48 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794532608; 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=8w065MxQV3OdULJnsF+BXENtPhCUpfLgRBlDLWgqq/U=; b=nn/Bwdr+1euVX7KdxZBxup4vu4dw+1ajf+qCKi/P6A03Bs1qcN8k76BVv6t9x2LwRc5N2r /yAt3NNYRtzZm/B6Ca5OGl0gm5Y5BRgV2y2adfxSNceZC9oVn9ThTVE28ys11vlcEdWBxm SJVmAlaeuz1vX02bqyZLPtXOezH/4ZpN1pNzpmrs5rWNpRVbtWLBsL8iRuvhWUjlHvUt8S +S8fK9wYEdc3KotHNbiHf7YpQ6c3AqS9Jhq9fM7hj8u+nrDamyUfGkGsBYprr0528rnTP2 WUZVu3bHD4iQRoKiq/PwCFOMqPWcMvR+TpOALKs6GiH+5a9i6ztB4WX8yH4vrw== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794532608; b=N5ImJf/dQmZD7HatfpKoMQ5i+20IaHPiCtQSnJkf2jDb2CyErx9mrUdG3z4fVF1//dX5Bs oV0tq6uo2c+mxVDvyMY4h3V5Gl6BSpZThmVpX9+f6+9hsGLpQ8vnPc/3TRetoxeIAeKLSo mTMxYqkI9c4oxbrPzWzv6PwlOZhkCCS77GkRBceF6ZDEaRufr7GwPNMgZwUvyiaVegJ1mr Yu2recyDlhF+zVRR+ZK1SF6wFLop+LZ9rTXAQR1blvt1KG6XvxceTI5DY5wgh6gqXEczMo v0kNWGhsOUkJXaoP46m2VFfikt2VH+kfWB4bUp2iIQAcMGrQ7KYoZOhoDZeHZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794532608; 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=8w065MxQV3OdULJnsF+BXENtPhCUpfLgRBlDLWgqq/U=; b=W5aW9uFQPuIG7KWWGIPwG/pbkLuEGXSoXGyDzaULajGbPH0zm+T79unrV9WfXTAr65Mqlv UC4EEAjnwNbrtqd6WwneFVEp7Qhbf06h/vRFc8vKi4e4q+C153rk9mjDAjuy3Dd5erRUTQ Ctmm4rAf/Q2fUy8gpQrcpGYOMHXT6ZSO91EvRhX0asueW9K6F5Sx+keQYE+F330JdIh/KG i1oBdpm94hvCK1Kg/h7SaJhZr0/mAVqEUWr0v8UgkG8RNeSNJVgIR9PLXe81gAt52Myyqd 5KfgWBWoIQWIUPEaVDAOY/vIfldw09R41AoMP0uq2szir/BovR3Vbor6zcD2Bg== 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 4jQfVS4syCz1Qsp for ; Fri, 13 Nov 2026 01:16:48 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 19230 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Fri, 13 Nov 2026 01:16:48 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kevin Bowling Subject: git: d6f6160b8ced - stable/15 - tpm: crb: Correct the Pluton mailbox handshake List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org List-Id: Commit messages for all branches of the src repository 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: kbowling X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: d6f6160b8ced163d024c4abeb78aaac11a0b1428 Auto-Submitted: auto-generated Date: Fri, 13 Nov 2026 01:16:48 +0000 Message-Id: <6af66500.19230.5a63e281@gitrepo.freebsd.org> The branch stable/15 has been updated by kbowling: URL: https://cgit.FreeBSD.org/src/commit/?id=d6f6160b8ced163d024c4abeb78aaac11a0b1428 commit d6f6160b8ced163d024c4abeb78aaac11a0b1428 Author: Kevin Bowling AuthorDate: 2026-11-04 19:43:28 +0000 Commit: Kevin Bowling CommitDate: 2026-11-13 01:16:39 +0000 tpm: crb: Correct the Pluton mailbox handshake Pluton's REPLY register indicates readiness for a new notification, not completion of the notification just sent. Wait for REPLY=1 before ringing the mailbox, then wait for START=0 when a synchronous state change needs acknowledgement. Use a separate command notification callback that waits for mailbox readiness but leaves command completion to the existing CRB_CTRL_START polling. Bound readiness waits by TPM_TIMEOUT_C, including asynchronous idle notifications, while retaining the command's execution timeout. This resolves reported command timeouts on a Framework AMD laptop. Tested by: olivier, tuexen Sponsored by: BBOX.io Differential Revision: https://reviews.freebsd.org/D61128 (cherry picked from commit 4995fd4bf2c61e30363e588c5b90d7fc9145bf5e) --- sys/dev/tpm/tpm_crb.c | 43 ++++++++++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/sys/dev/tpm/tpm_crb.c b/sys/dev/tpm/tpm_crb.c index ac472ce40eda..6e77655c3aab 100644 --- a/sys/dev/tpm/tpm_crb.c +++ b/sys/dev/tpm/tpm_crb.c @@ -81,7 +81,7 @@ struct tpmcrb_sc; /* Attach/detach callbacks */ typedef bool (sm_attach_t)(struct tpmcrb_sc *, void *, size_t); typedef void (sm_detach_t)(struct tpmcrb_sc *); -/* State change notification (timeout == 0 for 'no timeout') */ +/* State change notification (timeout == 0 for no completion wait). */ typedef bool (sm_statechange_t)(struct tpmcrb_sc *, int); struct tpmcrb_sm_cfg { @@ -94,6 +94,7 @@ struct tpmcrb_sm_cfg { static sm_attach_t pluton_attach; static sm_detach_t pluton_detach; static sm_statechange_t pluton_doorbell; +static sm_statechange_t pluton_cmdready; static const struct tpmcrb_sm_cfg_map { int acpi_sm; @@ -112,7 +113,7 @@ static const struct tpmcrb_sm_cfg_map { .sm_attach = &pluton_attach, .sm_detach = &pluton_detach, .sm_statechange = &pluton_doorbell, - .sm_cmdready = &pluton_doorbell, + .sm_cmdready = &pluton_cmdready, }, }, }; @@ -830,15 +831,15 @@ pluton_detach(struct tpmcrb_sc *crb_sc) } static bool -pluton_wait_reply(struct tpmcrb_sc *crb_sc, int32_t timeout) +pluton_wait_reg(struct tpmcrb_sc *crb_sc, bus_space_handle_t bsh, + uint32_t value, int32_t timeout) { for (;;) { /* * Always read at least once, and try one more time after we hit * the timeout. */ - if (bus_space_read_4(crb_sc->pluton.bst, - crb_sc->pluton.reply_bsh, 0) == 1) + if (bus_space_read_4(crb_sc->pluton.bst, bsh, 0) == value) return (true); else if (timeout <= 0) break; @@ -853,18 +854,38 @@ pluton_wait_reply(struct tpmcrb_sc *crb_sc, int32_t timeout) static bool pluton_doorbell(struct tpmcrb_sc *crb_sc, int timeout) { + + /* + * REPLY indicates readiness for a new notification, not its completion. + */ + if (!pluton_wait_reg(crb_sc, crb_sc->pluton.reply_bsh, 1, + TPM_TIMEOUT_C)) { + device_printf(crb_sc->base.dev, + "Pluton mailbox readiness timed out\n"); + return (false); + } + bus_space_write_4(crb_sc->pluton.bst, crb_sc->pluton.start_bsh, 0, 1); bus_space_barrier(crb_sc->pluton.bst, crb_sc->pluton.start_bsh, 0, sizeof(uint32_t), BUS_SPACE_BARRIER_WRITE); - /* - * We assume at timeout == 0 that they're not really interested in a - * reply immediately. Otherwise, we poll for a reply at least once, - * even with low timeouts. - */ + /* Wait for consumption of synchronous state-change notifications. */ if (timeout <= 0) return (true); - return (pluton_wait_reply(crb_sc, timeout)); + if (!pluton_wait_reg(crb_sc, crb_sc->pluton.start_bsh, 0, timeout)) { + device_printf(crb_sc->base.dev, + "Pluton mailbox acknowledgement timed out\n"); + return (false); + } + return (true); +} + +static bool +pluton_cmdready(struct tpmcrb_sc *crb_sc, int timeout __unused) +{ + + /* Command completion is polled separately through CRB_CTRL_START. */ + return (pluton_doorbell(crb_sc, 0)); } /* ACPI Driver */