Skip to content

Commit 978c293

Browse files
committed
[ot] hw/opentitan: ot_dma: add a property to define the DMA pace delay.
The smaller the delay, the faster the DMA transfer. Signed-off-by: Emmanuel Blot <[email protected]> (cherry picked from commit b2869e6)
1 parent 2cd6f00 commit 978c293

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

hw/opentitan/ot_dma.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ struct OtDMAState {
264264
char *ot_as_name; /* private AS unique name */
265265
char *ctn_as_name; /* externel port AS unique name */
266266
char *sys_as_name; /* external system AS unique name */
267+
uint32_t pace_delay; /* pace DMA scheduling (ns) */
267268
uint8_t block_size_lg2; /* log2 of DMA transfer block size */
268269
#ifdef OT_DMA_HAS_ROLE
269270
uint8_t role;
@@ -289,7 +290,7 @@ struct OtDMAState {
289290

290291
#define DMA_ERROR(_err_) (1u << (_err_))
291292

292-
/* the following values are arbitrary end may be changed if needed */
293+
/* default values, can be overridden with properties */
293294
#define DMA_PACE_NS 10000u /* 10us: slow down DMA, handle aborts */
294295
#define DMA_TRANSFER_BLOCK_LG2 12u /* log2(size) of a single DMA block */
295296

@@ -924,7 +925,7 @@ static bool ot_dma_go(OtDMAState *s)
924925

925926
timer_del(s->timer);
926927
uint64_t now = qemu_clock_get_ns(OT_VIRTUAL_CLOCK);
927-
timer_mod(s->timer, (int64_t)(now + DMA_PACE_NS));
928+
timer_mod_anticipate(s->timer, (int64_t)(now + s->pace_delay));
928929

929930
return true;
930931
}
@@ -943,7 +944,7 @@ static void ot_dma_abort(OtDMAState *s)
943944
/* simulate a delayed response */
944945
timer_del(s->timer);
945946
uint64_t now = qemu_clock_get_ns(OT_VIRTUAL_CLOCK);
946-
timer_mod(s->timer, (int64_t)(now + DMA_PACE_NS));
947+
timer_mod(s->timer, (int64_t)(now + s->pace_delay));
947948
}
948949

949950
static void ot_dma_complete(OtDMAState *s)
@@ -1064,7 +1065,7 @@ static void ot_dma_transfer(void *opaque)
10641065

10651066
/* schedule next block if any */
10661067
uint64_t now = qemu_clock_get_ns(OT_VIRTUAL_CLOCK);
1067-
timer_mod(s->timer, (int64_t)(now + DMA_PACE_NS));
1068+
timer_mod(s->timer, (int64_t)(now + s->pace_delay));
10681069
return;
10691070
}
10701071
}
@@ -1315,6 +1316,7 @@ static Property ot_dma_properties[] = {
13151316
DEFINE_PROP_STRING("ot_as_name", OtDMAState, ot_as_name),
13161317
DEFINE_PROP_STRING("ctn_as_name", OtDMAState, ctn_as_name),
13171318
DEFINE_PROP_STRING("sys_as_name", OtDMAState, sys_as_name),
1319+
DEFINE_PROP_UINT32("pace_delay", OtDMAState, pace_delay, DMA_PACE_NS),
13181320
DEFINE_PROP_UINT8("block_size_lg2", OtDMAState, block_size_lg2,
13191321
DMA_TRANSFER_BLOCK_LG2),
13201322
#ifdef OT_DMA_HAS_ROLE

0 commit comments

Comments
 (0)