Skip to content

Commit 5c00540

Browse files
committed
[ot] hw/opentitan: ot_sram_ctrl: change the defaut pace delay for initialization.
Make it faster to avoid ROM initialization timeout. Also add a property for fine-grained control of the pace delay. Signed-off-by: Emmanuel Blot <eblot@rivosinc.com>
1 parent 18614aa commit 5c00540

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

hw/opentitan/ot_sram_ctrl.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ REG32(READBACK, 0x20u)
8888
#define REG_NAME(_reg_) \
8989
((((_reg_) < REGS_COUNT) && REG_NAMES[_reg_]) ? REG_NAMES[_reg_] : "?")
9090

91-
#define INIT_TIMER_CHUNK_NS 100000 /* 100 us */
91+
#define INIT_TIMER_CHUNK_US 10u /* us */
9292
#define INIT_TIMER_CHUNK_WORDS (4096u / sizeof(uint32_t)) /* 4 KB */
9393

9494
/* clang-format off */
@@ -140,6 +140,7 @@ struct OtSramCtrlState {
140140
OtVMapperState *vmapper; /* optional */
141141
uint32_t size; /* in bytes */
142142
uint32_t init_chunk_words; /* init chunk size in words */
143+
uint32_t init_pace_us; /* init delay pacing, in us */
143144
bool ifetch; /* only used when no otp_ctrl is defined */
144145
bool noinit; /* discard initialization emulation feature */
145146
bool noswitch; /* do not switch to performance/host RAM after init */
@@ -253,8 +254,9 @@ static bool ot_sram_ctrl_initialize(OtSramCtrlState *s, unsigned count,
253254
trace_ot_sram_ctrl_schedule_init(s->ot_id);
254255

255256
/* schedule a new initialization chunk */
256-
uint64_t now = qemu_clock_get_ns(OT_VIRTUAL_CLOCK);
257-
timer_mod(s->init_timer, (int64_t)(now + INIT_TIMER_CHUNK_NS));
257+
int64_t now = qemu_clock_get_ns(OT_VIRTUAL_CLOCK);
258+
timer_mod(s->init_timer,
259+
(int64_t)(now + ((int64_t)s->init_pace_us) * 1000u));
258260

259261
return false;
260262
}
@@ -677,6 +679,8 @@ static const Property ot_sram_ctrl_properties[] = {
677679
OtVMapperState *),
678680
DEFINE_PROP_UINT32("size", OtSramCtrlState, size, 0u),
679681
DEFINE_PROP_UINT32("wci_size", OtSramCtrlState, init_chunk_words, 0u),
682+
DEFINE_PROP_UINT32("init-pace-us", OtSramCtrlState, init_pace_us,
683+
INIT_TIMER_CHUNK_US),
680684
DEFINE_PROP_BOOL("ifetch", OtSramCtrlState, ifetch, false),
681685
DEFINE_PROP_BOOL("noinit", OtSramCtrlState, noinit, false),
682686
DEFINE_PROP_BOOL("noswitch", OtSramCtrlState, noswitch, false),

0 commit comments

Comments
 (0)