Skip to content

Commit

Permalink
test: dma_perf: drain poll transfers before teardown
Browse files Browse the repository at this point in the history
Wait for transfers to complete in asynchronous poll mode before
tearing down the associated memory.

Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
Reviewed-by: Tuomas Taipale <tuomas.taipale@nokia.com>
  • Loading branch information
PavanNikhilesh authored and MatiasElo committed Aug 24, 2023
1 parent 9dd86d4 commit 2f7e755
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions test/performance/odp_dma_perf.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ typedef struct {
/* Wait and handle finished transfer. */
void (*wait_fn)(sd_t *sd, stats_t *stats);
/* Handle all unfinished transfers after main test has been stopped. */
void (*drain_fn)(void);
void (*drain_fn)(sd_t *sd);
/* Free any resources that might have been allocated during setup phase. */
void (*free_fn)(const sd_t *sd);
} test_api_t;
Expand Down Expand Up @@ -1111,7 +1111,7 @@ static void wait_compl_event(sd_t *sd, stats_t *stats)
}
}

static void drain_compl_events(void)
static void drain_compl_events(ODP_UNUSED sd_t *sd)
{
odp_event_t ev;

Expand All @@ -1123,6 +1123,25 @@ static void drain_compl_events(void)
}
}

static void drain_poll_transfers(sd_t *sd)
{
const uint32_t count = sd->dma.num_inflight;
trs_info_t *infos = sd->dma.infos, *info;
odp_dma_t handle = sd->dma.handle;
int rc;

for (uint32_t i = 0U; i < count; ++i) {
info = &infos[i];

if (info->is_running) {
do {
rc = odp_dma_transfer_done(handle, info->compl_param.transfer_id,
NULL);
} while (rc == 0);
}
}
}

static void setup_api(prog_config_t *config)
{
if (config->seg_type == PACKET) {
Expand All @@ -1147,7 +1166,7 @@ static void setup_api(prog_config_t *config)
config->api.bootstrap_fn = NULL;
config->api.wait_fn = config->num_workers == 1 || config->policy == MANY ?
poll_transfers_mt_unsafe : poll_transfers_mt_safe;
config->api.drain_fn = NULL;
config->api.drain_fn = drain_poll_transfers;
} else {
config->api.session_cfg_fn = configure_event_compl_session;
config->api.compl_fn = configure_event_compl;
Expand Down Expand Up @@ -1245,7 +1264,7 @@ static int transfer(void *args)
thr_config->stats.tot_tm = end_tm - start_tm;

if (api->drain_fn != NULL)
api->drain_fn();
api->drain_fn(sd);

out:
odp_barrier_wait(&prog_config->term_barrier);
Expand Down

0 comments on commit 2f7e755

Please sign in to comment.