This commit fixes the timing issue caused when `run_sync()`'s inference is finished too
early. This patch introduces an extra variable to check whether the callback is
called or not.
Signed-off-by: Dongju Chae <dongju.chae@samsung.com>
typedef struct {
npu_device *npu_dev;
output_buffer *user_output;
+ bool handled;
} sync_cb_data;
/**
if (err < 0) {
logerr (TAG, "Error setting output buffer, errno: %d\n", err);
}
+ cb_data->handled = true;
/** wake the sync process up, if any */
DEVICE_WAKEUP();
sync_cb_data cb_data = {
.npu_dev = dev,
.user_output = output,
+ .handled = false,
};
npu_dev = dev;
/** wait until the internal callback is finished */
DEVICE_LOCK();
- DEVICE_WAIT();
+ if (!cb_data.handled)
+ DEVICE_WAIT();
DEVICE_UNLOCK();
return 0;