Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F177852023
D61128.1795432581.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None
D61128.1795432581.diff
View Options
diff --git a/sys/dev/tpm/tpm_crb.c b/sys/dev/tpm/tpm_crb.c
--- a/sys/dev/tpm/tpm_crb.c
+++ b/sys/dev/tpm/tpm_crb.c
@@ -81,7 +81,7 @@
/* 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 @@
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 @@
.sm_attach = &pluton_attach,
.sm_detach = &pluton_detach,
.sm_statechange = &pluton_doorbell,
- .sm_cmdready = &pluton_doorbell,
+ .sm_cmdready = &pluton_cmdready,
},
},
};
@@ -830,15 +831,15 @@
}
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 @@
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 */
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Nov 23, 11:16 AM (11 m, 49 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41475759
Default Alt Text
D61128.1795432581.diff (2 KB)
Attached To
Mode
D61128: tpm: crb: Log cmd failures, correct Pluton mailbox handshake
Attached
Detach File
Event Timeline