aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Stultz <[email protected]>2021-01-29 03:05:11 +0000
committerShuah Khan <[email protected]>2021-02-08 16:25:25 -0700
commit50c65a8342941d30dd5874993052a91c9a52591b (patch)
tree28b3009daa47683977df2a6de25377a0a23811a6
parent64ba3d591c9d2be2a9c09e99b00732afe002ad0d (diff)
kselftests: dmabuf-heaps: Add clearer checks on DMABUF_BEGIN/END_SYNC
Add logic to check the dmabuf sync calls succeed. Cc: Shuah Khan <[email protected]> Cc: Brian Starkey <[email protected]> Cc: Sumit Semwal <[email protected]> Cc: Laura Abbott <[email protected]> Cc: Hridya Valsaraju <[email protected]> Cc: Suren Baghdasaryan <[email protected]> Cc: Sandeep Patil <[email protected]> Cc: Daniel Mentz <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Signed-off-by: John Stultz <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
-rw-r--r--tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c b/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c
index 909da9cdda97..46f6759a8acc 100644
--- a/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c
+++ b/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c
@@ -130,16 +130,13 @@ static int dmabuf_heap_alloc(int fd, size_t len, unsigned int flags,
dmabuf_fd);
}
-static void dmabuf_sync(int fd, int start_stop)
+static int dmabuf_sync(int fd, int start_stop)
{
struct dma_buf_sync sync = {
.flags = start_stop | DMA_BUF_SYNC_RW,
};
- int ret;
- ret = ioctl(fd, DMA_BUF_IOCTL_SYNC, &sync);
- if (ret)
- printf("sync failed %d\n", errno);
+ return ioctl(fd, DMA_BUF_IOCTL_SYNC, &sync);
}
#define ONE_MEG (1024 * 1024)
@@ -197,9 +194,18 @@ static int test_alloc_and_import(char *heap_name)
}
printf("import passed\n");
- dmabuf_sync(dmabuf_fd, DMA_BUF_SYNC_START);
+ ret = dmabuf_sync(dmabuf_fd, DMA_BUF_SYNC_START);
+ if (ret < 0) {
+ printf("Sync start failed!\n");
+ goto out;
+ }
+
memset(p, 0xff, ONE_MEG);
- dmabuf_sync(dmabuf_fd, DMA_BUF_SYNC_END);
+ ret = dmabuf_sync(dmabuf_fd, DMA_BUF_SYNC_END);
+ if (ret < 0) {
+ printf("Sync end failed!\n");
+ goto out;
+ }
printf("syncs passed\n");
close_handle(importer_fd, handle);