From nobody Wed Nov 04 19:49:35 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 4jKbch4vyLz6yt9h for ; Wed, 04 Nov 2026 19:49:40 +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 4jKbch4G8yz4HTZ for ; Wed, 04 Nov 2026 19:49:40 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1793821780; 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=ddJWLC1pLt7GewADogVlcJfj3C1bFjQod8kRgEHEE74=; b=FbysnmF3VCeTJ2+i2h4RkRTTG+/7+9/SxSn4GYuKkAgUtus4kagEvYcanUZkyzoOWkCNq8 aLBXdXL3Qu4wYF68OHya+2Sq8DG8n40AzOtHlxCVXaoQaiRG67myXLVjCzX72V3i8vskSL Jg4JdDvWIEYBtbf9S7EFwqbfa6rz1fC2t/zRISeQrWxK61/T8qKc6KQhYQxsdX+H/A7c+c ZepE3wvUdytKQpHXDpXUIayFH3vi6f259OXbszFKf0aXOuFcir0CMk8G+M4hqYBjXi54lB le5SA6pNxkSy/SQAtgcCx9IhZil9HZv6eljk7YZh42Vi+wlsBsGL20dJ7cTSLA== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1793821780; b=ZRa3InwhZOwytWVKyVB89b9z54bBrQkuOstaKHTm3oEcIc2gsVuQzD0zQzdqwS/nn9+pSI ExvddKddDBECx69AI4lyY9NFlyKyq7WRGuFlmOJH1fxAdXpWksD4SA2sa0fDFaT/zaTvnS EwWPDGB/G1+5UjAFwLRlCCM7kSypgaI9ZiUEWCU5+O7r3is7wb3obUhX9/wjbRcD0zF4ow naSNlFXFyi+6kf8AfgnQ9/Pd4SpfRwumu0ft5nkefMcwYCANlH+ckrGoleRPtv6AoyAC1s BUxyaUyFIdT+B6d6+Xmlol/B4ZyghniTmKJUA9UMg+HvBVRF1inVogeF3vUrHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1793821780; 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=ddJWLC1pLt7GewADogVlcJfj3C1bFjQod8kRgEHEE74=; b=dRHYXsUtNMrT5z8iIPZOvOZpIt+M1taqFrBdIuwNLo1McBbH1TQOf0fdtQvUUgxPPsx37d Va5LL9gPqGlTawZoJbj9E817tJNCXJZUwkInGzFFvXH9dxyR1GQFsMX5jKWj1qH5UjpQGY i/bc1WGa8sW94euIIeYN0nMlCcoOpyjcqkoQovdbEyTuQW1OPvlqcNaL357kwCp47aTcu2 eTX7ncd6sIKFq3Nx6LZiEyWMBfiIMonl1rF/utCgSs8fysjtpNt3RIyzwUgzTT729A9JAP lzJ64gO/TNQKCx7ZauDly0uwAswF2PTNguuatHIJlnRm6uhxQRbvMotNcqs/Nw== 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 4jKbch3XK9zH8C for ; Wed, 04 Nov 2026 19:49:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 3cb2d by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Wed, 04 Nov 2026 19:49:35 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kevin Bowling Subject: git: 4995fd4bf2c6 - main - 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 Sender: owner-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/main X-Git-Reftype: branch X-Git-Commit: 4995fd4bf2c61e30363e588c5b90d7fc9145bf5e Auto-Submitted: auto-generated Date: Wed, 04 Nov 2026 19:49:35 +0000 Message-Id: <6aeb8c4f.3cb2d.6d3fb2e3@gitrepo.freebsd.org> The branch main has been updated by kbowling: URL: https://cgit.FreeBSD.org/src/commit/?id=4995fd4bf2c61e30363e588c5b90d7fc9145bf5e commit 4995fd4bf2c61e30363e588c5b90d7fc9145bf5e Author: Kevin Bowling AuthorDate: 2026-11-04 19:43:28 +0000 Commit: Kevin Bowling CommitDate: 2026-11-04 19:49:28 +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 MFC after: 2 weeks Sponsored by: BBOX.io Differential Revision: https://reviews.freebsd.org/D61128 --- 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 */