Skip to content

Commit 50c65a8

Browse files
johnstultz-workshuahkh
authored andcommitted
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]>
1 parent 64ba3d5 commit 50c65a8

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -130,16 +130,13 @@ static int dmabuf_heap_alloc(int fd, size_t len, unsigned int flags,
130130
dmabuf_fd);
131131
}
132132

133-
static void dmabuf_sync(int fd, int start_stop)
133+
static int dmabuf_sync(int fd, int start_stop)
134134
{
135135
struct dma_buf_sync sync = {
136136
.flags = start_stop | DMA_BUF_SYNC_RW,
137137
};
138-
int ret;
139138

140-
ret = ioctl(fd, DMA_BUF_IOCTL_SYNC, &sync);
141-
if (ret)
142-
printf("sync failed %d\n", errno);
139+
return ioctl(fd, DMA_BUF_IOCTL_SYNC, &sync);
143140
}
144141

145142
#define ONE_MEG (1024 * 1024)
@@ -197,9 +194,18 @@ static int test_alloc_and_import(char *heap_name)
197194
}
198195
printf("import passed\n");
199196

200-
dmabuf_sync(dmabuf_fd, DMA_BUF_SYNC_START);
197+
ret = dmabuf_sync(dmabuf_fd, DMA_BUF_SYNC_START);
198+
if (ret < 0) {
199+
printf("Sync start failed!\n");
200+
goto out;
201+
}
202+
201203
memset(p, 0xff, ONE_MEG);
202-
dmabuf_sync(dmabuf_fd, DMA_BUF_SYNC_END);
204+
ret = dmabuf_sync(dmabuf_fd, DMA_BUF_SYNC_END);
205+
if (ret < 0) {
206+
printf("Sync end failed!\n");
207+
goto out;
208+
}
203209
printf("syncs passed\n");
204210

205211
close_handle(importer_fd, handle);

0 commit comments

Comments
 (0)