Skip to content

Commit e42acf1

Browse files
jejbjarkkojs
authored andcommitted
tpm_tis: Clean up locality release
The current release locality code seems to be based on the misunderstanding that the TPM interrupts when a locality is released: it doesn't, only when the locality is acquired. Furthermore, there seems to be no point in waiting for the locality to be released. All it does is penalize the last TPM user. However, if there's no next TPM user, this is a pointless wait and if there is a next TPM user, they'll pay the penalty waiting for the new locality (or possibly not if it's the same as the old locality). Fix the code by making release_locality as simple write to release with no waiting for completion. Cc: [email protected] Fixes: 33bafe9 ("tpm_tis: verify locality released before returning from release_locality") Signed-off-by: James Bottomley <[email protected]> Reviewed-by: Jerry Snitselaar <[email protected]> Reviewed-by: Jarkko Sakkinen <[email protected]> Signed-off-by: Jarkko Sakkinen <[email protected]>
1 parent 3d9ae54 commit e42acf1

File tree

1 file changed

+1
-46
lines changed

1 file changed

+1
-46
lines changed

drivers/char/tpm/tpm_tis_core.c

Lines changed: 1 addition & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -135,58 +135,13 @@ static bool check_locality(struct tpm_chip *chip, int l)
135135
return false;
136136
}
137137

138-
static bool locality_inactive(struct tpm_chip *chip, int l)
139-
{
140-
struct tpm_tis_data *priv = dev_get_drvdata(&chip->dev);
141-
int rc;
142-
u8 access;
143-
144-
rc = tpm_tis_read8(priv, TPM_ACCESS(l), &access);
145-
if (rc < 0)
146-
return false;
147-
148-
if ((access & (TPM_ACCESS_VALID | TPM_ACCESS_ACTIVE_LOCALITY))
149-
== TPM_ACCESS_VALID)
150-
return true;
151-
152-
return false;
153-
}
154-
155138
static int release_locality(struct tpm_chip *chip, int l)
156139
{
157140
struct tpm_tis_data *priv = dev_get_drvdata(&chip->dev);
158-
unsigned long stop, timeout;
159-
long rc;
160141

161142
tpm_tis_write8(priv, TPM_ACCESS(l), TPM_ACCESS_ACTIVE_LOCALITY);
162143

163-
stop = jiffies + chip->timeout_a;
164-
165-
if (chip->flags & TPM_CHIP_FLAG_IRQ) {
166-
again:
167-
timeout = stop - jiffies;
168-
if ((long)timeout <= 0)
169-
return -1;
170-
171-
rc = wait_event_interruptible_timeout(priv->int_queue,
172-
(locality_inactive(chip, l)),
173-
timeout);
174-
175-
if (rc > 0)
176-
return 0;
177-
178-
if (rc == -ERESTARTSYS && freezing(current)) {
179-
clear_thread_flag(TIF_SIGPENDING);
180-
goto again;
181-
}
182-
} else {
183-
do {
184-
if (locality_inactive(chip, l))
185-
return 0;
186-
tpm_msleep(TPM_TIMEOUT);
187-
} while (time_before(jiffies, stop));
188-
}
189-
return -1;
144+
return 0;
190145
}
191146

192147
static int request_locality(struct tpm_chip *chip, int l)

0 commit comments

Comments
 (0)