Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F109480297
D36412.id110041.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D36412.id110041.diff
View Options
Index: sys/dev/tpm/tpm20.h
===================================================================
--- sys/dev/tpm/tpm20.h
+++ sys/dev/tpm/tpm20.h
@@ -44,6 +44,7 @@
#include <sys/module.h>
#include <sys/rman.h>
#include <sys/sx.h>
+#include <sys/taskqueue.h>
#include <sys/uio.h>
#include <machine/bus.h>
@@ -125,8 +126,7 @@
struct callout discard_buffer_callout;
#ifdef TPM_HARVEST
- struct callout harvest_callout;
- int harvest_ticks;
+ struct timeout_task harvest_task;
#endif
int (*transmit)(struct tpm_sc *, size_t);
Index: sys/dev/tpm/tpm20.c
===================================================================
--- sys/dev/tpm/tpm20.c
+++ sys/dev/tpm/tpm20.c
@@ -39,13 +39,13 @@
* we don't want to execute this too often
* as the chip is likely to be used by others too.
*/
-#define TPM_HARVEST_INTERVAL 10000000
+#define TPM_HARVEST_INTERVAL 10
MALLOC_DEFINE(M_TPM20, "tpm_buffer", "buffer for tpm 2.0 driver");
static void tpm20_discard_buffer(void *arg);
#ifdef TPM_HARVEST
-static void tpm20_harvest(void *arg);
+static void tpm20_harvest(void *arg, int unused);
#endif
static int tpm20_save_state(device_t dev, bool suspend);
@@ -192,11 +192,6 @@
cv_init(&sc->buf_cv, "TPM buffer cv");
callout_init(&sc->discard_buffer_callout, 1);
-#ifdef TPM_HARVEST
- sc->harvest_ticks = TPM_HARVEST_INTERVAL / tick;
- callout_init(&sc->harvest_callout, 1);
- callout_reset(&sc->harvest_callout, 0, tpm20_harvest, sc);
-#endif
sc->pending_data_length = 0;
make_dev_args_init(&args);
@@ -209,6 +204,12 @@
if (result != 0)
tpm20_release(sc);
+#ifdef TPM_HARVEST
+ TIMEOUT_TASK_INIT(taskqueue_thread, &sc->harvest_task, 0,
+ tpm20_harvest, sc);
+ taskqueue_enqueue_timeout(taskqueue_thread, &sc->harvest_task, 0);
+#endif
+
return (result);
}
@@ -218,7 +219,8 @@
{
#ifdef TPM_HARVEST
- callout_drain(&sc->harvest_callout);
+ if (device_is_attached(sc->dev))
+ taskqueue_drain_timeout(taskqueue_thread, &sc->harvest_task);
#endif
if (sc->buf != NULL)
@@ -243,13 +245,12 @@
}
#ifdef TPM_HARVEST
-
/*
* Get TPM_HARVEST_SIZE random bytes and add them
* into system entropy pool.
*/
static void
-tpm20_harvest(void *arg)
+tpm20_harvest(void *arg, int unused)
{
struct tpm_sc *sc;
unsigned char entropy[TPM_HARVEST_SIZE];
@@ -290,7 +291,8 @@
if (entropy_size > 0)
random_harvest_queue(entropy, entropy_size, RANDOM_PURE_TPM);
- callout_reset(&sc->harvest_callout, sc->harvest_ticks, tpm20_harvest, sc);
+ taskqueue_enqueue_timeout(taskqueue_thread, &sc->harvest_task,
+ hz * TPM_HARVEST_INTERVAL);
}
#endif /* TPM_HARVEST */
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Feb 6, 3:37 PM (8 h, 14 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
16495453
Default Alt Text
D36412.id110041.diff (2 KB)
Attached To
Mode
D36412: tpm: Fix entropy harvesting logic
Attached
Detach File
Event Timeline
Log In to Comment