Skip to content

Commit b16de8b

Browse files
jgunthorperleon
authored andcommitted
RDMA: Handle the return code from dma_resv_wait_timeout() properly
ib_umem_dmabuf_map_pages() returns 0 on success and -ERRNO on failure. dma_resv_wait_timeout() uses a different scheme: * Returns -ERESTARTSYS if interrupted, 0 if the wait timed out, or * greater than zero on success. This results in ib_umem_dmabuf_map_pages() being non-functional as a positive return will be understood to be an error by drivers. Fixes: f30bcea ("RDMA: use dma_resv_wait() instead of extracting the fence") Cc: [email protected] Link: https://lore.kernel.org/r/[email protected] Tested-by: Maor Gottlieb <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]> Signed-off-by: Leon Romanovsky <[email protected]>
1 parent 6cd8351 commit b16de8b

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

drivers/infiniband/core/umem_dmabuf.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ int ib_umem_dmabuf_map_pages(struct ib_umem_dmabuf *umem_dmabuf)
1818
struct scatterlist *sg;
1919
unsigned long start, end, cur = 0;
2020
unsigned int nmap = 0;
21+
long ret;
2122
int i;
2223

2324
dma_resv_assert_held(umem_dmabuf->attach->dmabuf->resv);
@@ -67,9 +68,14 @@ int ib_umem_dmabuf_map_pages(struct ib_umem_dmabuf *umem_dmabuf)
6768
* may be not up-to-date. Wait for the exporter to finish
6869
* the migration.
6970
*/
70-
return dma_resv_wait_timeout(umem_dmabuf->attach->dmabuf->resv,
71+
ret = dma_resv_wait_timeout(umem_dmabuf->attach->dmabuf->resv,
7172
DMA_RESV_USAGE_KERNEL,
7273
false, MAX_SCHEDULE_TIMEOUT);
74+
if (ret < 0)
75+
return ret;
76+
if (ret == 0)
77+
return -ETIMEDOUT;
78+
return 0;
7379
}
7480
EXPORT_SYMBOL(ib_umem_dmabuf_map_pages);
7581

0 commit comments

Comments
 (0)